diff options
author | Tomas Winkler <tomas.winkler@intel.com> | 2008-04-15 00:16:03 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2008-04-16 15:59:57 -0400 |
commit | 57aab75a39089744aba4bd126df2de526481b128 (patch) | |
tree | 34c7a4a3a29aea852e7886e68fc8778390f809e7 /drivers/net/wireless/iwlwifi/iwl-4965.c | |
parent | b454048cb933eb69dd9d46c16bf01e9df997fa3d (diff) |
iwlwifi: generalize iwlwifi init flow
This patch creates handlers to support
iwlwifi init flow for multiple HWs
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
Signed-off-by: Ron Rindjunsky <ron.rindjunsky@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/iwlwifi/iwl-4965.c')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-4965.c | 149 |
1 files changed, 149 insertions, 0 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index 472ca3d7e034..822169e61e9b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -114,6 +114,151 @@ static const u16 default_tid_to_tx_fifo[] = { | |||
114 | 114 | ||
115 | #endif /*CONFIG_IWL4965_HT */ | 115 | #endif /*CONFIG_IWL4965_HT */ |
116 | 116 | ||
117 | /* check contents of special bootstrap uCode SRAM */ | ||
118 | static int iwl4965_verify_bsm(struct iwl_priv *priv) | ||
119 | { | ||
120 | __le32 *image = priv->ucode_boot.v_addr; | ||
121 | u32 len = priv->ucode_boot.len; | ||
122 | u32 reg; | ||
123 | u32 val; | ||
124 | |||
125 | IWL_DEBUG_INFO("Begin verify bsm\n"); | ||
126 | |||
127 | /* verify BSM SRAM contents */ | ||
128 | val = iwl_read_prph(priv, BSM_WR_DWCOUNT_REG); | ||
129 | for (reg = BSM_SRAM_LOWER_BOUND; | ||
130 | reg < BSM_SRAM_LOWER_BOUND + len; | ||
131 | reg += sizeof(u32), image++) { | ||
132 | val = iwl_read_prph(priv, reg); | ||
133 | if (val != le32_to_cpu(*image)) { | ||
134 | IWL_ERROR("BSM uCode verification failed at " | ||
135 | "addr 0x%08X+%u (of %u), is 0x%x, s/b 0x%x\n", | ||
136 | BSM_SRAM_LOWER_BOUND, | ||
137 | reg - BSM_SRAM_LOWER_BOUND, len, | ||
138 | val, le32_to_cpu(*image)); | ||
139 | return -EIO; | ||
140 | } | ||
141 | } | ||
142 | |||
143 | IWL_DEBUG_INFO("BSM bootstrap uCode image OK\n"); | ||
144 | |||
145 | return 0; | ||
146 | } | ||
147 | |||
148 | /** | ||
149 | * iwl4965_load_bsm - Load bootstrap instructions | ||
150 | * | ||
151 | * BSM operation: | ||
152 | * | ||
153 | * The Bootstrap State Machine (BSM) stores a short bootstrap uCode program | ||
154 | * in special SRAM that does not power down during RFKILL. When powering back | ||
155 | * up after power-saving sleeps (or during initial uCode load), the BSM loads | ||
156 | * the bootstrap program into the on-board processor, and starts it. | ||
157 | * | ||
158 | * The bootstrap program loads (via DMA) instructions and data for a new | ||
159 | * program from host DRAM locations indicated by the host driver in the | ||
160 | * BSM_DRAM_* registers. Once the new program is loaded, it starts | ||
161 | * automatically. | ||
162 | * | ||
163 | * When initializing the NIC, the host driver points the BSM to the | ||
164 | * "initialize" uCode image. This uCode sets up some internal data, then | ||
165 | * notifies host via "initialize alive" that it is complete. | ||
166 | * | ||
167 | * The host then replaces the BSM_DRAM_* pointer values to point to the | ||
168 | * normal runtime uCode instructions and a backup uCode data cache buffer | ||
169 | * (filled initially with starting data values for the on-board processor), | ||
170 | * then triggers the "initialize" uCode to load and launch the runtime uCode, | ||
171 | * which begins normal operation. | ||
172 | * | ||
173 | * When doing a power-save shutdown, runtime uCode saves data SRAM into | ||
174 | * the backup data cache in DRAM before SRAM is powered down. | ||
175 | * | ||
176 | * When powering back up, the BSM loads the bootstrap program. This reloads | ||
177 | * the runtime uCode instructions and the backup data cache into SRAM, | ||
178 | * and re-launches the runtime uCode from where it left off. | ||
179 | */ | ||
180 | static int iwl4965_load_bsm(struct iwl_priv *priv) | ||
181 | { | ||
182 | __le32 *image = priv->ucode_boot.v_addr; | ||
183 | u32 len = priv->ucode_boot.len; | ||
184 | dma_addr_t pinst; | ||
185 | dma_addr_t pdata; | ||
186 | u32 inst_len; | ||
187 | u32 data_len; | ||
188 | int i; | ||
189 | u32 done; | ||
190 | u32 reg_offset; | ||
191 | int ret; | ||
192 | |||
193 | IWL_DEBUG_INFO("Begin load bsm\n"); | ||
194 | |||
195 | /* make sure bootstrap program is no larger than BSM's SRAM size */ | ||
196 | if (len > IWL_MAX_BSM_SIZE) | ||
197 | return -EINVAL; | ||
198 | |||
199 | /* Tell bootstrap uCode where to find the "Initialize" uCode | ||
200 | * in host DRAM ... host DRAM physical address bits 35:4 for 4965. | ||
201 | * NOTE: iwl4965_initialize_alive_start() will replace these values, | ||
202 | * after the "initialize" uCode has run, to point to | ||
203 | * runtime/protocol instructions and backup data cache. */ | ||
204 | pinst = priv->ucode_init.p_addr >> 4; | ||
205 | pdata = priv->ucode_init_data.p_addr >> 4; | ||
206 | inst_len = priv->ucode_init.len; | ||
207 | data_len = priv->ucode_init_data.len; | ||
208 | |||
209 | ret = iwl_grab_nic_access(priv); | ||
210 | if (ret) | ||
211 | return ret; | ||
212 | |||
213 | iwl_write_prph(priv, BSM_DRAM_INST_PTR_REG, pinst); | ||
214 | iwl_write_prph(priv, BSM_DRAM_DATA_PTR_REG, pdata); | ||
215 | iwl_write_prph(priv, BSM_DRAM_INST_BYTECOUNT_REG, inst_len); | ||
216 | iwl_write_prph(priv, BSM_DRAM_DATA_BYTECOUNT_REG, data_len); | ||
217 | |||
218 | /* Fill BSM memory with bootstrap instructions */ | ||
219 | for (reg_offset = BSM_SRAM_LOWER_BOUND; | ||
220 | reg_offset < BSM_SRAM_LOWER_BOUND + len; | ||
221 | reg_offset += sizeof(u32), image++) | ||
222 | _iwl_write_prph(priv, reg_offset, le32_to_cpu(*image)); | ||
223 | |||
224 | ret = iwl4965_verify_bsm(priv); | ||
225 | if (ret) { | ||
226 | iwl_release_nic_access(priv); | ||
227 | return ret; | ||
228 | } | ||
229 | |||
230 | /* Tell BSM to copy from BSM SRAM into instruction SRAM, when asked */ | ||
231 | iwl_write_prph(priv, BSM_WR_MEM_SRC_REG, 0x0); | ||
232 | iwl_write_prph(priv, BSM_WR_MEM_DST_REG, RTC_INST_LOWER_BOUND); | ||
233 | iwl_write_prph(priv, BSM_WR_DWCOUNT_REG, len / sizeof(u32)); | ||
234 | |||
235 | /* Load bootstrap code into instruction SRAM now, | ||
236 | * to prepare to load "initialize" uCode */ | ||
237 | iwl_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START); | ||
238 | |||
239 | /* Wait for load of bootstrap uCode to finish */ | ||
240 | for (i = 0; i < 100; i++) { | ||
241 | done = iwl_read_prph(priv, BSM_WR_CTRL_REG); | ||
242 | if (!(done & BSM_WR_CTRL_REG_BIT_START)) | ||
243 | break; | ||
244 | udelay(10); | ||
245 | } | ||
246 | if (i < 100) | ||
247 | IWL_DEBUG_INFO("BSM write complete, poll %d iterations\n", i); | ||
248 | else { | ||
249 | IWL_ERROR("BSM write did not complete!\n"); | ||
250 | return -EIO; | ||
251 | } | ||
252 | |||
253 | /* Enable future boot loads whenever power management unit triggers it | ||
254 | * (e.g. when powering back up after power-save shutdown) */ | ||
255 | iwl_write_prph(priv, BSM_WR_CTRL_REG, BSM_WR_CTRL_REG_BIT_START_EN); | ||
256 | |||
257 | iwl_release_nic_access(priv); | ||
258 | |||
259 | return 0; | ||
260 | } | ||
261 | |||
117 | static int iwl4965_init_drv(struct iwl_priv *priv) | 262 | static int iwl4965_init_drv(struct iwl_priv *priv) |
118 | { | 263 | { |
119 | int ret; | 264 | int ret; |
@@ -4789,6 +4934,10 @@ static struct iwl_hcmd_utils_ops iwl4965_hcmd_utils = { | |||
4789 | 4934 | ||
4790 | static struct iwl_lib_ops iwl4965_lib = { | 4935 | static struct iwl_lib_ops iwl4965_lib = { |
4791 | .init_drv = iwl4965_init_drv, | 4936 | .init_drv = iwl4965_init_drv, |
4937 | .hw_nic_init = iwl4965_hw_nic_init, | ||
4938 | .is_valid_rtc_data_addr = iwl4965_hw_valid_rtc_data_addr, | ||
4939 | .alive_notify = iwl4965_alive_notify, | ||
4940 | .load_ucode = iwl4965_load_bsm, | ||
4792 | .eeprom_ops = { | 4941 | .eeprom_ops = { |
4793 | .verify_signature = iwlcore_eeprom_verify_signature, | 4942 | .verify_signature = iwlcore_eeprom_verify_signature, |
4794 | .acquire_semaphore = iwlcore_eeprom_acquire_semaphore, | 4943 | .acquire_semaphore = iwlcore_eeprom_acquire_semaphore, |