iwlwifi: get rid of fw/nvm.c
authorShaul Triebitz <shaul.triebitz@intel.com>
Wed, 24 Jan 2018 14:12:49 +0000 (16:12 +0200)
committerLuca Coelho <luciano.coelho@intel.com>
Fri, 20 Apr 2018 07:57:16 +0000 (10:57 +0300)
There's already an opmode common file for nvm iwl-nvm-parse.c
Move the content of fw/nvm.c to iwl-nvm-parse.c and delete fw/nvm.c.

Signed-off-by: Shaul Triebitz <shaul.triebitz@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/Makefile
drivers/net/wireless/intel/iwlwifi/fw/nvm.c [deleted file]
drivers/net/wireless/intel/iwlwifi/fw/runtime.h
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h
drivers/net/wireless/intel/iwlwifi/mvm/fw.c

index e6205ea..4d08d78 100644 (file)
@@ -13,7 +13,7 @@ iwlwifi-$(CONFIG_IWLMVM) += cfg/7000.o cfg/8000.o cfg/9000.o cfg/22000.o
 iwlwifi-objs           += iwl-trans.o
 iwlwifi-objs           += fw/notif-wait.o
 iwlwifi-$(CONFIG_IWLMVM) += fw/paging.o fw/smem.o fw/init.o fw/dbg.o
-iwlwifi-$(CONFIG_IWLMVM) += fw/common_rx.o fw/nvm.o
+iwlwifi-$(CONFIG_IWLMVM) += fw/common_rx.o
 iwlwifi-$(CONFIG_ACPI) += fw/acpi.o
 iwlwifi-$(CONFIG_IWLWIFI_DEBUGFS) += fw/debugfs.o
 
diff --git a/drivers/net/wireless/intel/iwlwifi/fw/nvm.c b/drivers/net/wireless/intel/iwlwifi/fw/nvm.c
deleted file mode 100644 (file)
index b8d88df..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/******************************************************************************
- *
- * This file is provided under a dual BSD/GPLv2 license.  When using or
- * redistributing this file, you may do so under either license.
- *
- * GPL LICENSE SUMMARY
- *
- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
- * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
- * USA
- *
- * The full GNU General Public License is included in this distribution
- * in the file called COPYING.
- *
- * Contact Information:
- *  Intel Linux Wireless <linuxwifi@intel.com>
- * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
- *
- * BSD LICENSE
- *
- * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
- * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
- * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- *  * Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in
- *    the documentation and/or other materials provided with the
- *    distribution.
- *  * Neither the name Intel Corporation nor the names of its
- *    contributors may be used to endorse or promote products derived
- *    from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *****************************************************************************/
-#include "iwl-drv.h"
-#include "runtime.h"
-#include "fw/api/nvm-reg.h"
-#include "fw/api/commands.h"
-#include "iwl-nvm-parse.h"
-
-struct iwl_nvm_data *iwl_fw_get_nvm(struct iwl_fw_runtime *fwrt)
-{
-       struct iwl_nvm_get_info cmd = {};
-       struct iwl_nvm_get_info_rsp *rsp;
-       struct iwl_trans *trans = fwrt->trans;
-       struct iwl_nvm_data *nvm;
-       struct iwl_host_cmd hcmd = {
-               .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
-               .data = { &cmd, },
-               .len = { sizeof(cmd) },
-               .id = WIDE_ID(REGULATORY_AND_NVM_GROUP, NVM_GET_INFO)
-       };
-       int  ret;
-       bool lar_fw_supported = !iwlwifi_mod_params.lar_disable &&
-                               fw_has_capa(&fwrt->fw->ucode_capa,
-                                           IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
-       u32 mac_flags;
-       u32 sbands_flags = 0;
-
-       ret = iwl_trans_send_cmd(trans, &hcmd);
-       if (ret)
-               return ERR_PTR(ret);
-
-       if (WARN(iwl_rx_packet_payload_len(hcmd.resp_pkt) != sizeof(*rsp),
-                "Invalid payload len in NVM response from FW %d",
-                iwl_rx_packet_payload_len(hcmd.resp_pkt))) {
-               ret = -EINVAL;
-               goto out;
-       }
-
-       rsp = (void *)hcmd.resp_pkt->data;
-       if (le32_to_cpu(rsp->general.flags) & NVM_GENERAL_FLAGS_EMPTY_OTP)
-               IWL_INFO(fwrt, "OTP is empty\n");
-
-       nvm = kzalloc(sizeof(*nvm) +
-                     sizeof(struct ieee80211_channel) * IWL_NUM_CHANNELS,
-                     GFP_KERNEL);
-       if (!nvm) {
-               ret = -ENOMEM;
-               goto out;
-       }
-
-       iwl_set_hw_address_from_csr(trans, nvm);
-       /* TODO: if platform NVM has MAC address - override it here */
-
-       if (!is_valid_ether_addr(nvm->hw_addr)) {
-               IWL_ERR(fwrt, "no valid mac address was found\n");
-               ret = -EINVAL;
-               goto err_free;
-       }
-
-       IWL_INFO(trans, "base HW address: %pM\n", nvm->hw_addr);
-
-       /* Initialize general data */
-       nvm->nvm_version = le16_to_cpu(rsp->general.nvm_version);
-
-       /* Initialize MAC sku data */
-       mac_flags = le32_to_cpu(rsp->mac_sku.mac_sku_flags);
-       nvm->sku_cap_11ac_enable =
-               !!(mac_flags & NVM_MAC_SKU_FLAGS_802_11AC_ENABLED);
-       nvm->sku_cap_11n_enable =
-               !!(mac_flags & NVM_MAC_SKU_FLAGS_802_11N_ENABLED);
-       nvm->sku_cap_11ax_enable =
-               !!(mac_flags & NVM_MAC_SKU_FLAGS_802_11AX_ENABLED);
-       nvm->sku_cap_band_24ghz_enable =
-               !!(mac_flags & NVM_MAC_SKU_FLAGS_BAND_2_4_ENABLED);
-       nvm->sku_cap_band_52ghz_enable =
-               !!(mac_flags & NVM_MAC_SKU_FLAGS_BAND_5_2_ENABLED);
-       nvm->sku_cap_mimo_disabled =
-               !!(mac_flags & NVM_MAC_SKU_FLAGS_MIMO_DISABLED);
-
-       /* Initialize PHY sku data */
-       nvm->valid_tx_ant = (u8)le32_to_cpu(rsp->phy_sku.tx_chains);
-       nvm->valid_rx_ant = (u8)le32_to_cpu(rsp->phy_sku.rx_chains);
-
-       if (le32_to_cpu(rsp->regulatory.lar_enabled) && lar_fw_supported) {
-               nvm->lar_enabled = true;
-               sbands_flags |= IWL_NVM_SBANDS_FLAGS_LAR;
-       }
-
-       iwl_init_sbands(trans->dev, trans->cfg, nvm,
-                       rsp->regulatory.channel_profile,
-                       nvm->valid_tx_ant & fwrt->fw->valid_tx_ant,
-                       nvm->valid_rx_ant & fwrt->fw->valid_rx_ant,
-                       sbands_flags);
-
-       iwl_free_resp(&hcmd);
-       return nvm;
-
-err_free:
-       kfree(nvm);
-out:
-       iwl_free_resp(&hcmd);
-       return ERR_PTR(ret);
-}
-IWL_EXPORT_SYMBOL(iwl_fw_get_nvm);
index 3fb940e..d8db1dd 100644 (file)
@@ -170,6 +170,5 @@ void iwl_get_shared_mem_conf(struct iwl_fw_runtime *fwrt);
 
 void iwl_fwrt_handle_notification(struct iwl_fw_runtime *fwrt,
                                  struct iwl_rx_cmd_buffer *rxb);
-struct iwl_nvm_data *iwl_fw_get_nvm(struct iwl_fw_runtime *fwrt);
 
 #endif /* __iwl_fw_runtime_h__ */
index a6246dc..6d33c14 100644 (file)
@@ -80,6 +80,9 @@
 #include "iwl-csr.h"
 #include "fw/acpi.h"
 #include "fw/api/nvm-reg.h"
+#include "fw/api/commands.h"
+#include "fw/api/cmdhdr.h"
+#include "fw/img.h"
 
 /* NVM offsets (in words) definitions */
 enum nvm_offsets {
@@ -460,9 +463,10 @@ static void iwl_init_vht_hw_capab(const struct iwl_cfg *cfg,
        vht_cap->vht_mcs.tx_mcs_map = vht_cap->vht_mcs.rx_mcs_map;
 }
 
-void iwl_init_sbands(struct device *dev, const struct iwl_cfg *cfg,
-                    struct iwl_nvm_data *data, const __le16 *nvm_ch_flags,
-                    u8 tx_chains, u8 rx_chains, u32 sbands_flags)
+static void iwl_init_sbands(struct device *dev, const struct iwl_cfg *cfg,
+                           struct iwl_nvm_data *data,
+                           const __le16 *nvm_ch_flags, u8 tx_chains,
+                           u8 rx_chains, u32 sbands_flags)
 {
        int n_channels;
        int n_used = 0;
@@ -495,7 +499,6 @@ void iwl_init_sbands(struct device *dev, const struct iwl_cfg *cfg,
                IWL_ERR_DEV(dev, "NVM: used only %d of %d channels\n",
                            n_used, n_channels);
 }
-IWL_EXPORT_SYMBOL(iwl_init_sbands);
 
 static int iwl_get_sku(const struct iwl_cfg *cfg, const __le16 *nvm_sw,
                       const __le16 *phy_sku)
@@ -573,8 +576,8 @@ static void iwl_flip_hw_address(__le32 mac_addr0, __le32 mac_addr1, u8 *dest)
        dest[5] = hw_addr[0];
 }
 
-void iwl_set_hw_address_from_csr(struct iwl_trans *trans,
-                                struct iwl_nvm_data *data)
+static void iwl_set_hw_address_from_csr(struct iwl_trans *trans,
+                                       struct iwl_nvm_data *data)
 {
        __le32 mac_addr0 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR0_STRAP));
        __le32 mac_addr1 = cpu_to_le32(iwl_read32(trans, CSR_MAC_ADDR1_STRAP));
@@ -592,7 +595,6 @@ void iwl_set_hw_address_from_csr(struct iwl_trans *trans,
 
        iwl_flip_hw_address(mac_addr0, mac_addr1, data->hw_addr);
 }
-IWL_EXPORT_SYMBOL(iwl_set_hw_address_from_csr);
 
 static void iwl_set_hw_address_family_8000(struct iwl_trans *trans,
                                           const struct iwl_cfg *cfg,
@@ -1145,3 +1147,98 @@ out:
        return ret;
 }
 IWL_EXPORT_SYMBOL(iwl_read_external_nvm);
+
+struct iwl_nvm_data *iwl_get_nvm(struct iwl_trans *trans,
+                                const struct iwl_fw *fw)
+{
+       struct iwl_nvm_get_info cmd = {};
+       struct iwl_nvm_get_info_rsp *rsp;
+       struct iwl_nvm_data *nvm;
+       struct iwl_host_cmd hcmd = {
+               .flags = CMD_WANT_SKB | CMD_SEND_IN_RFKILL,
+               .data = { &cmd, },
+               .len = { sizeof(cmd) },
+               .id = WIDE_ID(REGULATORY_AND_NVM_GROUP, NVM_GET_INFO)
+       };
+       int  ret;
+       bool lar_fw_supported = !iwlwifi_mod_params.lar_disable &&
+                               fw_has_capa(&fw->ucode_capa,
+                                           IWL_UCODE_TLV_CAPA_LAR_SUPPORT);
+       u32 mac_flags;
+       u32 sbands_flags = 0;
+
+       ret = iwl_trans_send_cmd(trans, &hcmd);
+       if (ret)
+               return ERR_PTR(ret);
+
+       if (WARN(iwl_rx_packet_payload_len(hcmd.resp_pkt) != sizeof(*rsp),
+                "Invalid payload len in NVM response from FW %d",
+                iwl_rx_packet_payload_len(hcmd.resp_pkt))) {
+               ret = -EINVAL;
+               goto out;
+       }
+
+       rsp = (void *)hcmd.resp_pkt->data;
+       if (le32_to_cpu(rsp->general.flags) & NVM_GENERAL_FLAGS_EMPTY_OTP)
+               IWL_INFO(trans, "OTP is empty\n");
+
+       nvm = kzalloc(sizeof(*nvm) +
+                     sizeof(struct ieee80211_channel) * IWL_NUM_CHANNELS,
+                     GFP_KERNEL);
+       if (!nvm) {
+               ret = -ENOMEM;
+               goto out;
+       }
+
+       iwl_set_hw_address_from_csr(trans, nvm);
+       /* TODO: if platform NVM has MAC address - override it here */
+
+       if (!is_valid_ether_addr(nvm->hw_addr)) {
+               IWL_ERR(trans, "no valid mac address was found\n");
+               ret = -EINVAL;
+               goto err_free;
+       }
+
+       IWL_INFO(trans, "base HW address: %pM\n", nvm->hw_addr);
+
+       /* Initialize general data */
+       nvm->nvm_version = le16_to_cpu(rsp->general.nvm_version);
+
+       /* Initialize MAC sku data */
+       mac_flags = le32_to_cpu(rsp->mac_sku.mac_sku_flags);
+       nvm->sku_cap_11ac_enable =
+               !!(mac_flags & NVM_MAC_SKU_FLAGS_802_11AC_ENABLED);
+       nvm->sku_cap_11n_enable =
+               !!(mac_flags & NVM_MAC_SKU_FLAGS_802_11N_ENABLED);
+       nvm->sku_cap_band_24ghz_enable =
+               !!(mac_flags & NVM_MAC_SKU_FLAGS_BAND_2_4_ENABLED);
+       nvm->sku_cap_band_52ghz_enable =
+               !!(mac_flags & NVM_MAC_SKU_FLAGS_BAND_5_2_ENABLED);
+       nvm->sku_cap_mimo_disabled =
+               !!(mac_flags & NVM_MAC_SKU_FLAGS_MIMO_DISABLED);
+
+       /* Initialize PHY sku data */
+       nvm->valid_tx_ant = (u8)le32_to_cpu(rsp->phy_sku.tx_chains);
+       nvm->valid_rx_ant = (u8)le32_to_cpu(rsp->phy_sku.rx_chains);
+
+       if (le32_to_cpu(rsp->regulatory.lar_enabled) && lar_fw_supported) {
+               nvm->lar_enabled = true;
+               sbands_flags |= IWL_NVM_SBANDS_FLAGS_LAR;
+       }
+
+       iwl_init_sbands(trans->dev, trans->cfg, nvm,
+                       rsp->regulatory.channel_profile,
+                       nvm->valid_tx_ant & fw->valid_tx_ant,
+                       nvm->valid_rx_ant & fw->valid_rx_ant,
+                       sbands_flags);
+
+       iwl_free_resp(&hcmd);
+       return nvm;
+
+err_free:
+       kfree(nvm);
+out:
+       iwl_free_resp(&hcmd);
+       return ERR_PTR(ret);
+}
+IWL_EXPORT_SYMBOL(iwl_get_nvm);
index 868baa5..60c7586 100644 (file)
@@ -96,19 +96,6 @@ iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg,
                   u8 tx_chains, u8 rx_chains, bool lar_fw_supported);
 
 /**
- * iwl_set_hw_address_from_csr - sets HW address for 9000 devices and on
- */
-void iwl_set_hw_address_from_csr(struct iwl_trans *trans,
-                                struct iwl_nvm_data *data);
-
-/**
- * iwl_init_sbands - parse and set all channel profiles
- */
-void iwl_init_sbands(struct device *dev, const struct iwl_cfg *cfg,
-                    struct iwl_nvm_data *data, const __le16 *nvm_ch_flags,
-                    u8 tx_chains, u8 rx_chains, u32 sbands_flags);
-
-/**
  * iwl_parse_mcc_info - parse MCC (mobile country code) info coming from FW
  *
  * This function parses the regulatory channel data received as a
@@ -142,4 +129,12 @@ int iwl_read_external_nvm(struct iwl_trans *trans,
 void iwl_nvm_fixups(u32 hw_id, unsigned int section, u8 *data,
                    unsigned int len);
 
+/**
+ * iwl_get_nvm - retrieve NVM data from firmware
+ *
+ * Allocates a new iwl_nvm_data structure, fills it with
+ * NVM data, and returns it to caller.
+ */
+struct iwl_nvm_data *iwl_get_nvm(struct iwl_trans *trans,
+                                const struct iwl_fw *fw);
 #endif /* __iwl_nvm_parse_h__ */
index d5a612a..866c91c 100644 (file)
@@ -415,7 +415,7 @@ static int iwl_run_unified_mvm_ucode(struct iwl_mvm *mvm, bool read_nvm)
 
        /* Read the NVM only at driver load time, no need to do this twice */
        if (!IWL_MVM_PARSE_NVM && read_nvm) {
-               mvm->nvm_data = iwl_fw_get_nvm(&mvm->fwrt);
+               mvm->nvm_data = iwl_get_nvm(mvm->trans, mvm->fw);
                if (IS_ERR(mvm->nvm_data)) {
                        ret = PTR_ERR(mvm->nvm_data);
                        mvm->nvm_data = NULL;