diff options
author | Kolekar, Abhijeet <abhijeet.kolekar@intel.com> | 2008-12-18 21:37:37 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-29 15:59:19 -0500 |
commit | 0164b9b45dbee4a3c4c95f59f9dd538b1e9c2635 (patch) | |
tree | f7557888904652b8a54a85bbf626a285df9b2c88 /drivers/net/wireless/iwlwifi/iwl3945-base.c | |
parent | 775a6e27bfca9d19f3ea6006a7e60a4a54aaf69c (diff) |
iwl3945: add load ucode op
The patch adds 3945 iwl_lib_ops->load_ucode to the driver.
Signed-off-by: Abhijeet Kolekar <abhijeet.kolekar@intel.com>
Signed-off-by: Zhu Yi <yi.zhu@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl3945-base.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 152 |
1 files changed, 1 insertions, 151 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 52c03cf29089..6669ab0d3f52 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -4924,156 +4924,6 @@ static int iwl3945_verify_ucode(struct iwl_priv *priv) | |||
4924 | return rc; | 4924 | return rc; |
4925 | } | 4925 | } |
4926 | 4926 | ||
4927 | |||
4928 | /* check contents of special bootstrap uCode SRAM */ | ||
4929 | static int iwl3945_verify_bsm(struct iwl_priv *priv) | ||
4930 | { | ||
4931 | __le32 *image = priv->ucode_boot.v_addr; | ||
4932 | u32 len = priv->ucode_boot.len; | ||
4933 | u32 reg; | ||
4934 | u32 val; | ||
4935 | |||
4936 | IWL_DEBUG_INFO("Begin verify bsm\n"); | ||
4937 | |||
4938 | /* verify BSM SRAM contents */ | ||
4939 | val = iwl_read_prph(priv, BSM_WR_DWCOUNT_REG); | ||
4940 | for (reg = BSM_SRAM_LOWER_BOUND; | ||
4941 | reg < BSM_SRAM_LOWER_BOUND + len; | ||
4942 | reg += sizeof(u32), image++) { | ||
4943 | val = iwl_read_prph(priv, reg); | ||
4944 | if (val != le32_to_cpu(*image)) { | ||
4945 | IWL_ERR(priv, "BSM uCode verification failed at " | ||
4946 | "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", | ||
4947 | BSM_SRAM_LOWER_BOUND, | ||
4948 | reg - BSM_SRAM_LOWER_BOUND, len, | ||
4949 | val, le32_to_cpu(*image)); | ||
4950 | return -EIO; | ||
4951 | } | ||
4952 | } | ||
4953 | |||
4954 | IWL_DEBUG_INFO("BSM bootstrap uCode image OK\n"); | ||
4955 | |||
4956 | return 0; | ||
4957 | } | ||
4958 | |||
4959 | /** | ||
4960 | * iwl3945_load_bsm - Load bootstrap instructions | ||
4961 | * | ||
4962 | * BSM operation: | ||
4963 | * | ||
4964 | * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program | ||
4965 | * in special SRAM that does not power down during RFKILL. When powering back | ||
4966 | * up after power-saving sleeps (or during initial uCode load), the BSM loads | ||
4967 | * the bootstrap program into the on-board processor, and starts it. | ||
4968 | * | ||
4969 | * The bootstrap program loads (via DMA) instructions and data for a new | ||
4970 | * program from host DRAM locations indicated by the host driver in the | ||
4971 | * BSM_DRAM_* registers. Once the new program is loaded, it starts | ||
4972 | * automatically. | ||
4973 | * | ||
4974 | * When initializing the NIC, the host driver points the BSM to the | ||
4975 | * "initialize" uCode image. This uCode sets up some internal data, then | ||
4976 | * notifies host via "initialize alive" that it is complete. | ||
4977 | * | ||
4978 | * The host then replaces the BSM_DRAM_* pointer values to point to the | ||
4979 | * normal runtime uCode instructions and a backup uCode data cache buffer | ||
4980 | * (filled initially with starting data values for the on-board processor), | ||
4981 | * then triggers the "initialize" uCode to load and launch the runtime uCode, | ||
4982 | * which begins normal operation. | ||
4983 | * | ||
4984 | * When doing a power-save shutdown, runtime uCode saves data SRAM into | ||
4985 | * the backup data cache in DRAM before SRAM is powered down. | ||
4986 | * | ||
4987 | * When powering back up, the BSM loads the bootstrap program. This reloads | ||
4988 | * the runtime uCode instructions and the backup data cache into SRAM, | ||
4989 | * and re-launches the runtime uCode from where it left off. | ||
4990 | */ | ||
4991 | static int iwl3945_load_bsm(struct iwl_priv *priv) | ||
4992 | { | ||
4993 | __le32 *image = priv->ucode_boot.v_addr; | ||
4994 | u32 len = priv->ucode_boot.len; | ||
4995 | dma_addr_t pinst; | ||
4996 | dma_addr_t pdata; | ||
4997 | u32 inst_len; | ||
4998 | u32 data_len; | ||
4999 | int rc; | ||
5000 | int i; | ||
5001 | u32 done; | ||
5002 | u32 reg_offset; | ||
5003 | |||
5004 | IWL_DEBUG_INFO("Begin load bsm\n"); | ||
5005 | |||
5006 | /* make sure bootstrap program is no larger than BSM's SRAM size */ | ||
5007 | if (len > IWL39_MAX_BSM_SIZE) | ||
5008 | return -EINVAL; | ||
5009 | |||
5010 | /* Tell bootstrap uCode where to find the "Initialize" uCode | ||
5011 | * in host DRAM ... host DRAM physical address bits 31:0 for 3945. | ||
5012 | * NOTE: iwl3945_initialize_alive_start() will replace these values, | ||
5013 | * after the "initialize" uCode has run, to point to | ||
5014 | * runtime/protocol instructions and backup data cache. */ | ||
5015 | pinst = priv->ucode_init.p_addr; | ||
5016 | pdata = priv->ucode_init_data.p_addr; | ||
5017 | inst_len = priv->ucode_init.len; | ||
5018 | data_len = priv->ucode_init_data.len; | ||
5019 | |||
5020 | rc = iwl_grab_nic_access(priv); | ||
5021 | if (rc) | ||
5022 | return rc; | ||
5023 | |||
5024 | iwl_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); | ||
5025 | iwl_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); | ||
5026 | iwl_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); | ||
5027 | iwl_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); | ||
5028 | |||
5029 | /* Fill BSM memory with bootstrap instructions */ | ||
5030 | for (reg_offset = BSM_SRAM_LOWER_BOUND; | ||
5031 | reg_offset < BSM_SRAM_LOWER_BOUND + len; | ||
5032 | reg_offset += sizeof(u32), image++) | ||
5033 | _iwl_write_prph(priv, reg_offset, | ||
5034 | le32_to_cpu(*image)); | ||
5035 | |||
5036 | rc = iwl3945_verify_bsm(priv); | ||
5037 | if (rc) { | ||
5038 | iwl_release_nic_access(priv); | ||
5039 | return rc; | ||
5040 | } | ||
5041 | |||
5042 | /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ | ||
5043 | iwl_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); | ||
5044 | iwl_write_prph(priv, BSM_WR_MEM_DST_REG, | ||
5045 | IWL39_RTC_INST_LOWER_BOUND); | ||
5046 | iwl_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); | ||
5047 | |||
5048 | /* Load bootstrap code into instruction SRAM now, | ||
5049 | * to prepare to load "initialize" uCode */ | ||
5050 | iwl_write_prph(priv, BSM_WR_CTRL_REG, | ||
5051 | BSM_WR_CTRL_REG_BIT_START); | ||
5052 | |||
5053 | /* Wait for load of bootstrap uCode to finish */ | ||
5054 | for (i = 0; i < 100; i++) { | ||
5055 | done = iwl_read_prph(priv, BSM_WR_CTRL_REG); | ||
5056 | if (!(done & BSM_WR_CTRL_REG_BIT_START)) | ||
5057 | break; | ||
5058 | udelay(10); | ||
5059 | } | ||
5060 | if (i < 100) | ||
5061 | IWL_DEBUG_INFO("BSM write complete, poll %d iterations\n", i); | ||
5062 | else { | ||
5063 | IWL_ERR(priv, "BSM write did not complete!\n"); | ||
5064 | return -EIO; | ||
5065 | } | ||
5066 | |||
5067 | /* Enable future boot loads whenever power management unit triggers it | ||
5068 | * (e.g. when powering back up after power-save shutdown) */ | ||
5069 | iwl_write_prph(priv, BSM_WR_CTRL_REG, | ||
5070 | BSM_WR_CTRL_REG_BIT_START_EN); | ||
5071 | |||
5072 | iwl_release_nic_access(priv); | ||
5073 | |||
5074 | return 0; | ||
5075 | } | ||
5076 | |||
5077 | static void iwl3945_nic_start(struct iwl_priv *priv) | 4927 | static void iwl3945_nic_start(struct iwl_priv *priv) |
5078 | { | 4928 | { |
5079 | /* Remove all resets to allow NIC to operate */ | 4929 | /* Remove all resets to allow NIC to operate */ |
@@ -5714,7 +5564,7 @@ static int __iwl3945_up(struct iwl_priv *priv) | |||
5714 | /* load bootstrap state machine, | 5564 | /* load bootstrap state machine, |
5715 | * load bootstrap program into processor's memory, | 5565 | * load bootstrap program into processor's memory, |
5716 | * prepare to load the "initialize" uCode */ | 5566 | * prepare to load the "initialize" uCode */ |
5717 | rc = iwl3945_load_bsm(priv); | 5567 | priv->cfg->ops->lib->load_ucode(priv); |
5718 | 5568 | ||
5719 | if (rc) { | 5569 | if (rc) { |
5720 | IWL_ERR(priv, | 5570 | IWL_ERR(priv, |