aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWey-Yi Guy <wey-yi.w.guy@intel.com>2010-03-16 13:23:30 -0400
committerReinette Chatre <reinette.chatre@intel.com>2010-03-25 14:17:20 -0400
commit81b8176eb8edac7d2135db2af03ab5fe0cb3b6f7 (patch)
tree21ffa7c8f03ad289288278091db32ba09c889dcc
parent792bc3cbe06cddabd865acc3122ee0415f854a11 (diff)
iwlwifi: code cleanup for "load ucode" function
Loading uCode functions are shared across multiple agn devices. Move those functions to iwl-agn-ucode.c file with other uCode related functions. Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com> Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-1000.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-5000.c103
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-6000.c4
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn-ucode.c102
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-agn.h3
5 files changed, 110 insertions, 104 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-1000.c b/drivers/net/wireless/iwlwifi/iwl-1000.c
index ad61464703cb..283c4ed11709 100644
--- a/drivers/net/wireless/iwlwifi/iwl-1000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-1000.c
@@ -173,7 +173,7 @@ static struct iwl_lib_ops iwl1000_lib = {
173 .rx_handler_setup = iwl5000_rx_handler_setup, 173 .rx_handler_setup = iwl5000_rx_handler_setup,
174 .setup_deferred_work = iwl5000_setup_deferred_work, 174 .setup_deferred_work = iwl5000_setup_deferred_work,
175 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr, 175 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
176 .load_ucode = iwl5000_load_ucode, 176 .load_ucode = iwlagn_load_ucode,
177 .dump_nic_event_log = iwl_dump_nic_event_log, 177 .dump_nic_event_log = iwl_dump_nic_event_log,
178 .dump_nic_error_log = iwl_dump_nic_error_log, 178 .dump_nic_error_log = iwl_dump_nic_error_log,
179 .dump_csr = iwl_dump_csr, 179 .dump_csr = iwl_dump_csr,
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c
index bbcb9c5dde6a..bea2f46ef26f 100644
--- a/drivers/net/wireless/iwlwifi/iwl-5000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-5000.c
@@ -423,105 +423,6 @@ static void iwl5000_rx_calib_complete(struct iwl_priv *priv,
423 queue_work(priv->workqueue, &priv->restart); 423 queue_work(priv->workqueue, &priv->restart);
424} 424}
425 425
426/*
427 * ucode
428 */
429static int iwl5000_load_section(struct iwl_priv *priv, const char *name,
430 struct fw_desc *image, u32 dst_addr)
431{
432 dma_addr_t phy_addr = image->p_addr;
433 u32 byte_cnt = image->len;
434 int ret;
435
436 priv->ucode_write_complete = 0;
437
438 iwl_write_direct32(priv,
439 FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
440 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE);
441
442 iwl_write_direct32(priv,
443 FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr);
444
445 iwl_write_direct32(priv,
446 FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL),
447 phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK);
448
449 iwl_write_direct32(priv,
450 FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL),
451 (iwl_get_dma_hi_addr(phy_addr)
452 << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt);
453
454 iwl_write_direct32(priv,
455 FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL),
456 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM |
457 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX |
458 FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID);
459
460 iwl_write_direct32(priv,
461 FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
462 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
463 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE |
464 FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
465
466 IWL_DEBUG_INFO(priv, "%s uCode section being loaded...\n", name);
467 ret = wait_event_interruptible_timeout(priv->wait_command_queue,
468 priv->ucode_write_complete, 5 * HZ);
469 if (ret == -ERESTARTSYS) {
470 IWL_ERR(priv, "Could not load the %s uCode section due "
471 "to interrupt\n", name);
472 return ret;
473 }
474 if (!ret) {
475 IWL_ERR(priv, "Could not load the %s uCode section\n",
476 name);
477 return -ETIMEDOUT;
478 }
479
480 return 0;
481}
482
483static int iwl5000_load_given_ucode(struct iwl_priv *priv,
484 struct fw_desc *inst_image,
485 struct fw_desc *data_image)
486{
487 int ret = 0;
488
489 ret = iwl5000_load_section(priv, "INST", inst_image,
490 IWL50_RTC_INST_LOWER_BOUND);
491 if (ret)
492 return ret;
493
494 return iwl5000_load_section(priv, "DATA", data_image,
495 IWL50_RTC_DATA_LOWER_BOUND);
496}
497
498int iwl5000_load_ucode(struct iwl_priv *priv)
499{
500 int ret = 0;
501
502 /* check whether init ucode should be loaded, or rather runtime ucode */
503 if (priv->ucode_init.len && (priv->ucode_type == UCODE_NONE)) {
504 IWL_DEBUG_INFO(priv, "Init ucode found. Loading init ucode...\n");
505 ret = iwl5000_load_given_ucode(priv,
506 &priv->ucode_init, &priv->ucode_init_data);
507 if (!ret) {
508 IWL_DEBUG_INFO(priv, "Init ucode load complete.\n");
509 priv->ucode_type = UCODE_INIT;
510 }
511 } else {
512 IWL_DEBUG_INFO(priv, "Init ucode not found, or already loaded. "
513 "Loading runtime ucode...\n");
514 ret = iwl5000_load_given_ucode(priv,
515 &priv->ucode_code, &priv->ucode_data);
516 if (!ret) {
517 IWL_DEBUG_INFO(priv, "Runtime ucode load complete.\n");
518 priv->ucode_type = UCODE_RT;
519 }
520 }
521
522 return ret;
523}
524
525void iwl5000_init_alive_start(struct iwl_priv *priv) 426void iwl5000_init_alive_start(struct iwl_priv *priv)
526{ 427{
527 int ret = 0; 428 int ret = 0;
@@ -1413,7 +1314,7 @@ struct iwl_lib_ops iwl5000_lib = {
1413 .dump_nic_error_log = iwl_dump_nic_error_log, 1314 .dump_nic_error_log = iwl_dump_nic_error_log,
1414 .dump_csr = iwl_dump_csr, 1315 .dump_csr = iwl_dump_csr,
1415 .dump_fh = iwl_dump_fh, 1316 .dump_fh = iwl_dump_fh,
1416 .load_ucode = iwl5000_load_ucode, 1317 .load_ucode = iwlagn_load_ucode,
1417 .init_alive_start = iwl5000_init_alive_start, 1318 .init_alive_start = iwl5000_init_alive_start,
1418 .alive_notify = iwl5000_alive_notify, 1319 .alive_notify = iwl5000_alive_notify,
1419 .send_tx_power = iwl5000_send_tx_power, 1320 .send_tx_power = iwl5000_send_tx_power,
@@ -1470,7 +1371,7 @@ static struct iwl_lib_ops iwl5150_lib = {
1470 .dump_nic_event_log = iwl_dump_nic_event_log, 1371 .dump_nic_event_log = iwl_dump_nic_event_log,
1471 .dump_nic_error_log = iwl_dump_nic_error_log, 1372 .dump_nic_error_log = iwl_dump_nic_error_log,
1472 .dump_csr = iwl_dump_csr, 1373 .dump_csr = iwl_dump_csr,
1473 .load_ucode = iwl5000_load_ucode, 1374 .load_ucode = iwlagn_load_ucode,
1474 .init_alive_start = iwl5000_init_alive_start, 1375 .init_alive_start = iwl5000_init_alive_start,
1475 .alive_notify = iwl5000_alive_notify, 1376 .alive_notify = iwl5000_alive_notify,
1476 .send_tx_power = iwl5000_send_tx_power, 1377 .send_tx_power = iwl5000_send_tx_power,
diff --git a/drivers/net/wireless/iwlwifi/iwl-6000.c b/drivers/net/wireless/iwlwifi/iwl-6000.c
index 4026eb4e7faa..b7297177c054 100644
--- a/drivers/net/wireless/iwlwifi/iwl-6000.c
+++ b/drivers/net/wireless/iwlwifi/iwl-6000.c
@@ -237,7 +237,7 @@ static struct iwl_lib_ops iwl6000_lib = {
237 .rx_handler_setup = iwl5000_rx_handler_setup, 237 .rx_handler_setup = iwl5000_rx_handler_setup,
238 .setup_deferred_work = iwl5000_setup_deferred_work, 238 .setup_deferred_work = iwl5000_setup_deferred_work,
239 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr, 239 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
240 .load_ucode = iwl5000_load_ucode, 240 .load_ucode = iwlagn_load_ucode,
241 .dump_nic_event_log = iwl_dump_nic_event_log, 241 .dump_nic_event_log = iwl_dump_nic_event_log,
242 .dump_nic_error_log = iwl_dump_nic_error_log, 242 .dump_nic_error_log = iwl_dump_nic_error_log,
243 .dump_csr = iwl_dump_csr, 243 .dump_csr = iwl_dump_csr,
@@ -304,7 +304,7 @@ static struct iwl_lib_ops iwl6050_lib = {
304 .rx_handler_setup = iwl5000_rx_handler_setup, 304 .rx_handler_setup = iwl5000_rx_handler_setup,
305 .setup_deferred_work = iwl5000_setup_deferred_work, 305 .setup_deferred_work = iwl5000_setup_deferred_work,
306 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr, 306 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
307 .load_ucode = iwl5000_load_ucode, 307 .load_ucode = iwlagn_load_ucode,
308 .dump_nic_event_log = iwl_dump_nic_event_log, 308 .dump_nic_event_log = iwl_dump_nic_event_log,
309 .dump_nic_error_log = iwl_dump_nic_error_log, 309 .dump_nic_error_log = iwl_dump_nic_error_log,
310 .dump_csr = iwl_dump_csr, 310 .dump_csr = iwl_dump_csr,
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
index 67f15c0d2a4a..f57a4f8033f7 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
+++ b/drivers/net/wireless/iwlwifi/iwl-agn-ucode.c
@@ -30,9 +30,111 @@
30#include <linux/kernel.h> 30#include <linux/kernel.h>
31#include <linux/module.h> 31#include <linux/module.h>
32#include <linux/init.h> 32#include <linux/init.h>
33#include <linux/sched.h>
33 34
34#include "iwl-dev.h" 35#include "iwl-dev.h"
35#include "iwl-core.h" 36#include "iwl-core.h"
37#include "iwl-io.h"
38#include "iwl-5000-hw.h"
39
40/*
41 * ucode
42 */
43static int iwlagn_load_section(struct iwl_priv *priv, const char *name,
44 struct fw_desc *image, u32 dst_addr)
45{
46 dma_addr_t phy_addr = image->p_addr;
47 u32 byte_cnt = image->len;
48 int ret;
49
50 priv->ucode_write_complete = 0;
51
52 iwl_write_direct32(priv,
53 FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
54 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_PAUSE);
55
56 iwl_write_direct32(priv,
57 FH_SRVC_CHNL_SRAM_ADDR_REG(FH_SRVC_CHNL), dst_addr);
58
59 iwl_write_direct32(priv,
60 FH_TFDIB_CTRL0_REG(FH_SRVC_CHNL),
61 phy_addr & FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK);
62
63 iwl_write_direct32(priv,
64 FH_TFDIB_CTRL1_REG(FH_SRVC_CHNL),
65 (iwl_get_dma_hi_addr(phy_addr)
66 << FH_MEM_TFDIB_REG1_ADDR_BITSHIFT) | byte_cnt);
67
68 iwl_write_direct32(priv,
69 FH_TCSR_CHNL_TX_BUF_STS_REG(FH_SRVC_CHNL),
70 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_NUM |
71 1 << FH_TCSR_CHNL_TX_BUF_STS_REG_POS_TB_IDX |
72 FH_TCSR_CHNL_TX_BUF_STS_REG_VAL_TFDB_VALID);
73
74 iwl_write_direct32(priv,
75 FH_TCSR_CHNL_TX_CONFIG_REG(FH_SRVC_CHNL),
76 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CHNL_ENABLE |
77 FH_TCSR_TX_CONFIG_REG_VAL_DMA_CREDIT_DISABLE |
78 FH_TCSR_TX_CONFIG_REG_VAL_CIRQ_HOST_ENDTFD);
79
80 IWL_DEBUG_INFO(priv, "%s uCode section being loaded...\n", name);
81 ret = wait_event_interruptible_timeout(priv->wait_command_queue,
82 priv->ucode_write_complete, 5 * HZ);
83 if (ret == -ERESTARTSYS) {
84 IWL_ERR(priv, "Could not load the %s uCode section due "
85 "to interrupt\n", name);
86 return ret;
87 }
88 if (!ret) {
89 IWL_ERR(priv, "Could not load the %s uCode section\n",
90 name);
91 return -ETIMEDOUT;
92 }
93
94 return 0;
95}
96
97static int iwlagn_load_given_ucode(struct iwl_priv *priv,
98 struct fw_desc *inst_image,
99 struct fw_desc *data_image)
100{
101 int ret = 0;
102
103 ret = iwlagn_load_section(priv, "INST", inst_image,
104 IWL50_RTC_INST_LOWER_BOUND);
105 if (ret)
106 return ret;
107
108 return iwlagn_load_section(priv, "DATA", data_image,
109 IWL50_RTC_DATA_LOWER_BOUND);
110}
111
112int iwlagn_load_ucode(struct iwl_priv *priv)
113{
114 int ret = 0;
115
116 /* check whether init ucode should be loaded, or rather runtime ucode */
117 if (priv->ucode_init.len && (priv->ucode_type == UCODE_NONE)) {
118 IWL_DEBUG_INFO(priv, "Init ucode found. Loading init ucode...\n");
119 ret = iwlagn_load_given_ucode(priv,
120 &priv->ucode_init, &priv->ucode_init_data);
121 if (!ret) {
122 IWL_DEBUG_INFO(priv, "Init ucode load complete.\n");
123 priv->ucode_type = UCODE_INIT;
124 }
125 } else {
126 IWL_DEBUG_INFO(priv, "Init ucode not found, or already loaded. "
127 "Loading runtime ucode...\n");
128 ret = iwlagn_load_given_ucode(priv,
129 &priv->ucode_code, &priv->ucode_data);
130 if (!ret) {
131 IWL_DEBUG_INFO(priv, "Runtime ucode load complete.\n");
132 priv->ucode_type = UCODE_RT;
133 }
134 }
135
136 return ret;
137}
36 138
37#define IWL_UCODE_GET(item) \ 139#define IWL_UCODE_GET(item) \
38static u32 iwlagn_ucode_get_##item(const struct iwl_ucode_header *ucode,\ 140static u32 iwlagn_ucode_get_##item(const struct iwl_ucode_header *ucode,\
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.h b/drivers/net/wireless/iwlwifi/iwl-agn.h
index a266649a8bf5..5af528dd3c63 100644
--- a/drivers/net/wireless/iwlwifi/iwl-agn.h
+++ b/drivers/net/wireless/iwlwifi/iwl-agn.h
@@ -75,4 +75,7 @@ irqreturn_t iwl_isr_ict(int irq, void *data);
75bool iwl_good_ack_health(struct iwl_priv *priv, 75bool iwl_good_ack_health(struct iwl_priv *priv,
76 struct iwl_rx_packet *pkt); 76 struct iwl_rx_packet *pkt);
77 77
78/* uCode */
79int iwlagn_load_ucode(struct iwl_priv *priv);
80
78#endif /* __iwl_agn_h__ */ 81#endif /* __iwl_agn_h__ */