aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
diff options
context:
space:
mode:
authorEmmanuel Grumbach <emmanuel.grumbach@intel.com>2012-01-08 09:33:58 -0500
committerWey-Yi Guy <wey-yi.w.guy@intel.com>2012-02-02 17:36:58 -0500
commitcf6142975bcbb731bc131ee9d2a68b7561076545 (patch)
tree7cec34553e1d121f0ae601cc603e33007ccd8269 /drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
parentd48e2074e240192e8a0396e1ae0082dd0e78aa8e (diff)
iwlwifi: consolidate the start_device flow
Now there is only one transport function that launch a specific fw: trans_ops->start_fw. This one replaces trans_ops->start_device and trans_ops->kick_nic. The code that actually loads the fw to the device has been moved to the transport specific code. Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-trans-pcie.c')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-trans-pcie.c88
1 files changed, 78 insertions, 10 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
index 362444a7ed57..1030a2524059 100644
--- a/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
+++ b/drivers/net/wireless/iwlwifi/iwl-trans-pcie.c
@@ -64,6 +64,7 @@
64#include <linux/pci-aspm.h> 64#include <linux/pci-aspm.h>
65#include <linux/interrupt.h> 65#include <linux/interrupt.h>
66#include <linux/debugfs.h> 66#include <linux/debugfs.h>
67#include <linux/sched.h>
67#include <linux/bitops.h> 68#include <linux/bitops.h>
68#include <linux/gfp.h> 69#include <linux/gfp.h>
69 70
@@ -895,7 +896,79 @@ static const u8 iwlagn_pan_ac_to_queue[] = {
895 7, 6, 5, 4, 896 7, 6, 5, 4,
896}; 897};
897 898
898static int iwl_trans_pcie_start_device(struct iwl_trans *trans) 899/*
900 * ucode
901 */
902static int iwl_load_section(struct iwl_trans *trans, const char *name,
903 struct fw_desc *image, u32 dst_addr)
904{
905 dma_addr_t phy_addr = image->p_addr;
906 u32 byte_cnt = image->len;
907 int ret;
908
909 trans->ucode_write_complete = 0;
910
911 iwl_write_direct32(trans,
912 FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
913 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE);
914
915 iwl_write_direct32(trans,
916 FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr);
917
918 iwl_write_direct32(trans,
919 FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL),
920 phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK);
921
922 iwl_write_direct32(trans,
923 FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL),
924 (iwl_get_dma_hi_addr(phy_addr)
925 << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt);
926
927 iwl_write_direct32(trans,
928 FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL),
929 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM |
930 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX |
931 FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID);
932
933 iwl_write_direct32(trans,
934 FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
935 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
936 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE |
937 FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
938
939 IWL_DEBUG_FW(trans, "%s uCode section being loaded...\n", name);
940 ret = wait_event_timeout(trans->shrd->wait_command_queue,
941 trans->ucode_write_complete, 5 * HZ);
942 if (!ret) {
943 IWL_ERR(trans, "Could not load the %s uCode section\n",
944 name);
945 return -ETIMEDOUT;
946 }
947
948 return 0;
949}
950
951static int iwl_load_given_ucode(struct iwl_trans *trans, struct fw_img *image)
952{
953 int ret = 0;
954
955 ret = iwl_load_section(trans, "INST", &image->code,
956 IWLAGN_RTC_INST_LOWER_BOUND);
957 if (ret)
958 return ret;
959
960 ret = iwl_load_section(trans, "DATA", &image->data,
961 IWLAGN_RTC_DATA_LOWER_BOUND);
962 if (ret)
963 return ret;
964
965 /* Remove all resets to allow NIC to operate */
966 iwl_write32(trans, CSR_RESET, 0);
967
968 return 0;
969}
970
971static int iwl_trans_pcie_start_fw(struct iwl_trans *trans, struct fw_img *fw)
899{ 972{
900 int ret; 973 int ret;
901 struct iwl_trans_pcie *trans_pcie = 974 struct iwl_trans_pcie *trans_pcie =
@@ -951,6 +1024,9 @@ static int iwl_trans_pcie_start_device(struct iwl_trans *trans)
951 iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); 1024 iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
952 iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); 1025 iwl_write32(trans, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL);
953 1026
1027 /* Load the given image to the HW */
1028 iwl_load_given_ucode(trans, fw);
1029
954 return 0; 1030 return 0;
955} 1031}
956 1032
@@ -1353,12 +1429,6 @@ static int iwl_trans_pcie_tx(struct iwl_trans *trans, struct sk_buff *skb,
1353 return 0; 1429 return 0;
1354} 1430}
1355 1431
1356static void iwl_trans_pcie_kick_nic(struct iwl_trans *trans)
1357{
1358 /* Remove all resets to allow NIC to operate */
1359 iwl_write32(trans, CSR_RESET, 0);
1360}
1361
1362static int iwl_trans_pcie_start_hw(struct iwl_trans *trans) 1432static int iwl_trans_pcie_start_hw(struct iwl_trans *trans)
1363{ 1433{
1364 struct iwl_trans_pcie *trans_pcie = 1434 struct iwl_trans_pcie *trans_pcie =
@@ -2086,7 +2156,7 @@ const struct iwl_trans_ops trans_ops_pcie = {
2086 .start_hw = iwl_trans_pcie_start_hw, 2156 .start_hw = iwl_trans_pcie_start_hw,
2087 .stop_hw = iwl_trans_pcie_stop_hw, 2157 .stop_hw = iwl_trans_pcie_stop_hw,
2088 .fw_alive = iwl_trans_pcie_fw_alive, 2158 .fw_alive = iwl_trans_pcie_fw_alive,
2089 .start_device = iwl_trans_pcie_start_device, 2159 .start_fw = iwl_trans_pcie_start_fw,
2090 .stop_device = iwl_trans_pcie_stop_device, 2160 .stop_device = iwl_trans_pcie_stop_device,
2091 2161
2092 .wake_any_queue = iwl_trans_pcie_wake_any_queue, 2162 .wake_any_queue = iwl_trans_pcie_wake_any_queue,
@@ -2100,8 +2170,6 @@ const struct iwl_trans_ops trans_ops_pcie = {
2100 .tx_agg_alloc = iwl_trans_pcie_tx_agg_alloc, 2170 .tx_agg_alloc = iwl_trans_pcie_tx_agg_alloc,
2101 .tx_agg_setup = iwl_trans_pcie_tx_agg_setup, 2171 .tx_agg_setup = iwl_trans_pcie_tx_agg_setup,
2102 2172
2103 .kick_nic = iwl_trans_pcie_kick_nic,
2104
2105 .free = iwl_trans_pcie_free, 2173 .free = iwl_trans_pcie_free,
2106 .stop_queue = iwl_trans_pcie_stop_queue, 2174 .stop_queue = iwl_trans_pcie_stop_queue,
2107 2175