Skip to content

Commit

Permalink
iwlwifi: move PNVM implementation to common code
Browse files Browse the repository at this point in the history
The PNVM code is generic and can be used by other opmodes.  Move it to
a common file and include it in the relevant opmodes.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/iwlwifi.20201008181047.232aa310693b.I03a18ffa4162753af38e759d88e27509007c7bca@changeid
  • Loading branch information
Luca Coelho authored and Kalle Valo committed Oct 8, 2020
1 parent 0fafaa9 commit b3e4c0f
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 48 deletions.
2 changes: 1 addition & 1 deletion drivers/net/wireless/intel/iwlwifi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ iwlwifi-objs += iwl-trans.o
iwlwifi-objs += queue/tx.o

iwlwifi-objs += fw/img.o fw/notif-wait.o
iwlwifi-objs += fw/dbg.o
iwlwifi-objs += fw/dbg.o fw/pnvm.o
iwlwifi-$(CONFIG_IWLMVM) += fw/paging.o fw/smem.o fw/init.o
iwlwifi-$(CONFIG_ACPI) += fw/acpi.o
iwlwifi-$(CONFIG_IWLWIFI_DEBUGFS) += fw/debugfs.o
Expand Down
55 changes: 55 additions & 0 deletions drivers/net/wireless/intel/iwlwifi/fw/pnvm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/******************************************************************************
*
* Copyright(c) 2020 Intel Corporation
*
*****************************************************************************/

#include "iwl-drv.h"
#include "pnvm.h"
#include "iwl-prph.h"
#include "iwl-io.h"
#include "fw/api/commands.h"
#include "fw/api/nvm-reg.h"

static bool iwl_pnvm_complete_fn(struct iwl_notif_wait_data *notif_wait,
struct iwl_rx_packet *pkt, void *data)
{
struct iwl_trans *trans = (struct iwl_trans *)data;
struct iwl_pnvm_init_complete_ntfy *pnvm_ntf = (void *)pkt->data;

IWL_DEBUG_FW(trans,
"PNVM complete notification received with status %d\n",
le32_to_cpu(pnvm_ntf->status));

return true;
}

int iwl_pnvm_load(struct iwl_trans *trans,
struct iwl_notif_wait_data *notif_wait)
{
struct iwl_notification_wait pnvm_wait;
static const u16 ntf_cmds[] = { WIDE_ID(REGULATORY_AND_NVM_GROUP,
PNVM_INIT_COMPLETE_NTFY) };

/* if the SKU_ID is empty, there's nothing to do */
if (!trans->sku_id[0] && !trans->sku_id[1] && !trans->sku_id[2])
return 0;

/*
* TODO: phase 2: load the pnvm file, find the right section,
* load it and set the right DMA pointer.
*/

iwl_init_notification_wait(notif_wait, &pnvm_wait,
ntf_cmds, ARRAY_SIZE(ntf_cmds),
iwl_pnvm_complete_fn, trans);

/* kick the doorbell */
iwl_write_umac_prph(trans, UREG_DOORBELL_TO_ISR6,
UREG_DOORBELL_TO_ISR6_PNVM);

return iwl_wait_notification(notif_wait, &pnvm_wait,
MVM_UCODE_PNVM_TIMEOUT);
}
IWL_EXPORT_SYMBOL(iwl_pnvm_load);
18 changes: 18 additions & 0 deletions drivers/net/wireless/intel/iwlwifi/fw/pnvm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
/******************************************************************************
*
* Copyright(c) 2020 Intel Corporation
*
*****************************************************************************/

#ifndef __IWL_PNVM_H__
#define __IWL_PNVM_H__

#include "fw/notif-wait.h"

#define MVM_UCODE_PNVM_TIMEOUT (HZ / 10)

int iwl_pnvm_load(struct iwl_trans *trans,
struct iwl_notif_wait_data *notif_wait);

#endif /* __IWL_PNVM_H__ */
51 changes: 4 additions & 47 deletions drivers/net/wireless/intel/iwlwifi/mvm/fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@
#include "iwl-io.h" /* for iwl_mvm_rx_card_state_notif */
#include "iwl-prph.h"
#include "fw/acpi.h"
#include "fw/pnvm.h"

#include "mvm.h"
#include "fw/dbg.h"
#include "iwl-phy-db.h"
#include "iwl-modparams.h"
#include "iwl-nvm-parse.h"

#define MVM_UCODE_ALIVE_TIMEOUT HZ
#define MVM_UCODE_CALIB_TIMEOUT (2*HZ)
#define MVM_UCODE_PNVM_TIMEOUT (HZ / 10)
#define MVM_UCODE_ALIVE_TIMEOUT (HZ)
#define MVM_UCODE_CALIB_TIMEOUT (2 * HZ)

#define UCODE_VALID_OK cpu_to_le32(0x1)

Expand Down Expand Up @@ -313,20 +313,6 @@ static bool iwl_alive_fn(struct iwl_notif_wait_data *notif_wait,
return true;
}

static bool iwl_pnvm_complete_fn(struct iwl_notif_wait_data *notif_wait,
struct iwl_rx_packet *pkt, void *data)
{
struct iwl_mvm *mvm =
container_of(notif_wait, struct iwl_mvm, notif_wait);
struct iwl_pnvm_init_complete_ntfy *pnvm_ntf = (void *)pkt->data;

IWL_DEBUG_FW(mvm,
"PNVM complete notification received with status %d\n",
le32_to_cpu(pnvm_ntf->status));

return true;
}

static bool iwl_wait_init_complete(struct iwl_notif_wait_data *notif_wait,
struct iwl_rx_packet *pkt, void *data)
{
Expand All @@ -350,35 +336,6 @@ static bool iwl_wait_phy_db_entry(struct iwl_notif_wait_data *notif_wait,
return false;
}

static int iwl_mvm_load_pnvm(struct iwl_mvm *mvm)
{
struct iwl_notification_wait pnvm_wait;
static const u16 ntf_cmds[] = { WIDE_ID(REGULATORY_AND_NVM_GROUP,
PNVM_INIT_COMPLETE_NTFY) };

/* if the SKU_ID is empty, there's nothing to do */
if (!mvm->trans->sku_id[0] &&
!mvm->trans->sku_id[1] &&
!mvm->trans->sku_id[2])
return 0;

/*
* TODO: phase 2: load the pnvm file, find the right section,
* load it and set the right DMA pointer.
*/

iwl_init_notification_wait(&mvm->notif_wait, &pnvm_wait,
ntf_cmds, ARRAY_SIZE(ntf_cmds),
iwl_pnvm_complete_fn, NULL);

/* kick the doorbell */
iwl_write_umac_prph(mvm->trans, UREG_DOORBELL_TO_ISR6,
UREG_DOORBELL_TO_ISR6_PNVM);

return iwl_wait_notification(&mvm->notif_wait, &pnvm_wait,
MVM_UCODE_PNVM_TIMEOUT);
}

static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
enum iwl_ucode_type ucode_type)
{
Expand Down Expand Up @@ -467,7 +424,7 @@ static int iwl_mvm_load_ucode_wait_alive(struct iwl_mvm *mvm,
return -EIO;
}

ret = iwl_mvm_load_pnvm(mvm);
ret = iwl_pnvm_load(mvm->trans, &mvm->notif_wait);
if (ret) {
IWL_ERR(mvm, "Timeout waiting for PNVM load!\n");
iwl_fw_set_current_image(&mvm->fwrt, old_type);
Expand Down

0 comments on commit b3e4c0f

Please sign in to comment.