1 /******************************************************************************
5 * Copyright(c) 2008 - 2012 Intel Corporation. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
21 * The full GNU General Public License is included in this distribution
22 * in the file called LICENSE.GPL.
24 * Contact Information:
25 * Intel Linux Wireless <ilw@linux.intel.com>
26 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
28 *****************************************************************************/
30 #include <linux/kernel.h>
31 #include <linux/module.h>
32 #include <linux/init.h>
33 #include <linux/sched.h>
34 #include <linux/dma-mapping.h>
40 #include "iwl-agn-hw.h"
42 #include "iwl-agn-calib.h"
43 #include "iwl-trans.h"
46 static struct iwl_wimax_coex_event_entry cu_priorities
[COEX_NUM_OF_EVENTS
] = {
47 {COEX_CU_UNASSOC_IDLE_RP
, COEX_CU_UNASSOC_IDLE_WP
,
48 0, COEX_UNASSOC_IDLE_FLAGS
},
49 {COEX_CU_UNASSOC_MANUAL_SCAN_RP
, COEX_CU_UNASSOC_MANUAL_SCAN_WP
,
50 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS
},
51 {COEX_CU_UNASSOC_AUTO_SCAN_RP
, COEX_CU_UNASSOC_AUTO_SCAN_WP
,
52 0, COEX_UNASSOC_AUTO_SCAN_FLAGS
},
53 {COEX_CU_CALIBRATION_RP
, COEX_CU_CALIBRATION_WP
,
54 0, COEX_CALIBRATION_FLAGS
},
55 {COEX_CU_PERIODIC_CALIBRATION_RP
, COEX_CU_PERIODIC_CALIBRATION_WP
,
56 0, COEX_PERIODIC_CALIBRATION_FLAGS
},
57 {COEX_CU_CONNECTION_ESTAB_RP
, COEX_CU_CONNECTION_ESTAB_WP
,
58 0, COEX_CONNECTION_ESTAB_FLAGS
},
59 {COEX_CU_ASSOCIATED_IDLE_RP
, COEX_CU_ASSOCIATED_IDLE_WP
,
60 0, COEX_ASSOCIATED_IDLE_FLAGS
},
61 {COEX_CU_ASSOC_MANUAL_SCAN_RP
, COEX_CU_ASSOC_MANUAL_SCAN_WP
,
62 0, COEX_ASSOC_MANUAL_SCAN_FLAGS
},
63 {COEX_CU_ASSOC_AUTO_SCAN_RP
, COEX_CU_ASSOC_AUTO_SCAN_WP
,
64 0, COEX_ASSOC_AUTO_SCAN_FLAGS
},
65 {COEX_CU_ASSOC_ACTIVE_LEVEL_RP
, COEX_CU_ASSOC_ACTIVE_LEVEL_WP
,
66 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS
},
67 {COEX_CU_RF_ON_RP
, COEX_CU_RF_ON_WP
, 0, COEX_CU_RF_ON_FLAGS
},
68 {COEX_CU_RF_OFF_RP
, COEX_CU_RF_OFF_WP
, 0, COEX_RF_OFF_FLAGS
},
69 {COEX_CU_STAND_ALONE_DEBUG_RP
, COEX_CU_STAND_ALONE_DEBUG_WP
,
70 0, COEX_STAND_ALONE_DEBUG_FLAGS
},
71 {COEX_CU_IPAN_ASSOC_LEVEL_RP
, COEX_CU_IPAN_ASSOC_LEVEL_WP
,
72 0, COEX_IPAN_ASSOC_LEVEL_FLAGS
},
73 {COEX_CU_RSRVD1_RP
, COEX_CU_RSRVD1_WP
, 0, COEX_RSRVD1_FLAGS
},
74 {COEX_CU_RSRVD2_RP
, COEX_CU_RSRVD2_WP
, 0, COEX_RSRVD2_FLAGS
}
77 /******************************************************************************
79 * uCode download functions
81 ******************************************************************************/
83 static void iwl_free_fw_desc(struct iwl_trans
*trans
, struct fw_desc
*desc
)
86 dma_free_coherent(trans
->dev
, desc
->len
,
87 desc
->v_addr
, desc
->p_addr
);
92 static void iwl_free_fw_img(struct iwl_trans
*trans
, struct fw_img
*img
)
94 iwl_free_fw_desc(trans
, &img
->code
);
95 iwl_free_fw_desc(trans
, &img
->data
);
98 void iwl_dealloc_ucode(struct iwl_trans
*trans
)
100 iwl_free_fw_img(trans
, &trans
->ucode_rt
);
101 iwl_free_fw_img(trans
, &trans
->ucode_init
);
102 iwl_free_fw_img(trans
, &trans
->ucode_wowlan
);
105 int iwl_alloc_fw_desc(struct iwl_trans
*trans
, struct fw_desc
*desc
,
106 const void *data
, size_t len
)
113 desc
->v_addr
= dma_alloc_coherent(trans
->dev
, len
,
114 &desc
->p_addr
, GFP_KERNEL
);
119 memcpy(desc
->v_addr
, data
, len
);
123 static inline struct fw_img
*iwl_get_ucode_image(struct iwl_trans
*trans
,
124 enum iwl_ucode_type ucode_type
)
126 switch (ucode_type
) {
128 return &trans
->ucode_init
;
129 case IWL_UCODE_WOWLAN
:
130 return &trans
->ucode_wowlan
;
131 case IWL_UCODE_REGULAR
:
132 return &trans
->ucode_rt
;
142 static int iwl_set_Xtal_calib(struct iwl_trans
*trans
)
144 struct iwl_calib_xtal_freq_cmd cmd
;
146 (__le16
*)iwl_eeprom_query_addr(trans
->shrd
, EEPROM_XTAL
);
148 iwl_set_calib_hdr(&cmd
.hdr
, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD
);
149 cmd
.cap_pin1
= le16_to_cpu(xtal_calib
[0]);
150 cmd
.cap_pin2
= le16_to_cpu(xtal_calib
[1]);
151 return iwl_calib_set(trans
, (void *)&cmd
, sizeof(cmd
));
154 static int iwl_set_temperature_offset_calib(struct iwl_trans
*trans
)
156 struct iwl_calib_temperature_offset_cmd cmd
;
157 __le16
*offset_calib
=
158 (__le16
*)iwl_eeprom_query_addr(trans
->shrd
,
159 EEPROM_RAW_TEMPERATURE
);
161 memset(&cmd
, 0, sizeof(cmd
));
162 iwl_set_calib_hdr(&cmd
.hdr
, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD
);
163 memcpy(&cmd
.radio_sensor_offset
, offset_calib
, sizeof(*offset_calib
));
164 if (!(cmd
.radio_sensor_offset
))
165 cmd
.radio_sensor_offset
= DEFAULT_RADIO_SENSOR_OFFSET
;
167 IWL_DEBUG_CALIB(trans
, "Radio sensor offset: %d\n",
168 le16_to_cpu(cmd
.radio_sensor_offset
));
169 return iwl_calib_set(trans
, (void *)&cmd
, sizeof(cmd
));
172 static int iwl_set_temperature_offset_calib_v2(struct iwl_trans
*trans
)
174 struct iwl_calib_temperature_offset_v2_cmd cmd
;
175 __le16
*offset_calib_high
= (__le16
*)iwl_eeprom_query_addr(trans
->shrd
,
176 EEPROM_KELVIN_TEMPERATURE
);
177 __le16
*offset_calib_low
=
178 (__le16
*)iwl_eeprom_query_addr(trans
->shrd
,
179 EEPROM_RAW_TEMPERATURE
);
180 struct iwl_eeprom_calib_hdr
*hdr
;
182 memset(&cmd
, 0, sizeof(cmd
));
183 iwl_set_calib_hdr(&cmd
.hdr
, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD
);
184 hdr
= (struct iwl_eeprom_calib_hdr
*)iwl_eeprom_query_addr(trans
->shrd
,
186 memcpy(&cmd
.radio_sensor_offset_high
, offset_calib_high
,
187 sizeof(*offset_calib_high
));
188 memcpy(&cmd
.radio_sensor_offset_low
, offset_calib_low
,
189 sizeof(*offset_calib_low
));
190 if (!(cmd
.radio_sensor_offset_low
)) {
191 IWL_DEBUG_CALIB(trans
, "no info in EEPROM, use default\n");
192 cmd
.radio_sensor_offset_low
= DEFAULT_RADIO_SENSOR_OFFSET
;
193 cmd
.radio_sensor_offset_high
= DEFAULT_RADIO_SENSOR_OFFSET
;
195 memcpy(&cmd
.burntVoltageRef
, &hdr
->voltage
,
196 sizeof(hdr
->voltage
));
198 IWL_DEBUG_CALIB(trans
, "Radio sensor offset high: %d\n",
199 le16_to_cpu(cmd
.radio_sensor_offset_high
));
200 IWL_DEBUG_CALIB(trans
, "Radio sensor offset low: %d\n",
201 le16_to_cpu(cmd
.radio_sensor_offset_low
));
202 IWL_DEBUG_CALIB(trans
, "Voltage Ref: %d\n",
203 le16_to_cpu(cmd
.burntVoltageRef
));
205 return iwl_calib_set(trans
, (void *)&cmd
, sizeof(cmd
));
208 static int iwl_send_calib_cfg(struct iwl_trans
*trans
)
210 struct iwl_calib_cfg_cmd calib_cfg_cmd
;
211 struct iwl_host_cmd cmd
= {
212 .id
= CALIBRATION_CFG_CMD
,
213 .len
= { sizeof(struct iwl_calib_cfg_cmd
), },
214 .data
= { &calib_cfg_cmd
, },
217 memset(&calib_cfg_cmd
, 0, sizeof(calib_cfg_cmd
));
218 calib_cfg_cmd
.ucd_calib_cfg
.once
.is_enable
= IWL_CALIB_INIT_CFG_ALL
;
219 calib_cfg_cmd
.ucd_calib_cfg
.once
.start
= IWL_CALIB_INIT_CFG_ALL
;
220 calib_cfg_cmd
.ucd_calib_cfg
.once
.send_res
= IWL_CALIB_INIT_CFG_ALL
;
221 calib_cfg_cmd
.ucd_calib_cfg
.flags
=
222 IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK
;
224 return iwl_trans_send_cmd(trans
, &cmd
);
227 int iwlagn_rx_calib_result(struct iwl_priv
*priv
,
228 struct iwl_rx_mem_buffer
*rxb
,
229 struct iwl_device_cmd
*cmd
)
231 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
232 struct iwl_calib_hdr
*hdr
= (struct iwl_calib_hdr
*)pkt
->u
.raw
;
233 int len
= le32_to_cpu(pkt
->len_n_flags
) & FH_RSCSR_FRAME_SIZE_MSK
;
235 /* reduce the size of the length field itself */
238 if (iwl_calib_set(trans(priv
), hdr
, len
))
239 IWL_ERR(priv
, "Failed to record calibration data %d\n",
245 int iwl_init_alive_start(struct iwl_trans
*trans
)
249 if (cfg(trans
)->bt_params
&&
250 cfg(trans
)->bt_params
->advanced_bt_coexist
) {
252 * Tell uCode we are ready to perform calibration
253 * need to perform this before any calibration
254 * no need to close the envlope since we are going
255 * to load the runtime uCode later.
257 ret
= iwl_send_bt_env(trans
, IWL_BT_COEX_ENV_OPEN
,
258 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2
);
264 ret
= iwl_send_calib_cfg(trans
);
269 * temperature offset calibration is only needed for runtime ucode,
270 * so prepare the value now.
272 if (cfg(trans
)->need_temp_offset_calib
) {
273 if (cfg(trans
)->temp_offset_v2
)
274 return iwl_set_temperature_offset_calib_v2(trans
);
276 return iwl_set_temperature_offset_calib(trans
);
282 static int iwl_send_wimax_coex(struct iwl_trans
*trans
)
284 struct iwl_wimax_coex_cmd coex_cmd
;
286 if (cfg(trans
)->base_params
->support_wimax_coexist
) {
287 /* UnMask wake up src at associated sleep */
288 coex_cmd
.flags
= COEX_FLAGS_ASSOC_WA_UNMASK_MSK
;
290 /* UnMask wake up src at unassociated sleep */
291 coex_cmd
.flags
|= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK
;
292 memcpy(coex_cmd
.sta_prio
, cu_priorities
,
293 sizeof(struct iwl_wimax_coex_event_entry
) *
296 /* enabling the coexistence feature */
297 coex_cmd
.flags
|= COEX_FLAGS_COEX_ENABLE_MSK
;
299 /* enabling the priorities tables */
300 coex_cmd
.flags
|= COEX_FLAGS_STA_TABLE_VALID_MSK
;
302 /* coexistence is disabled */
303 memset(&coex_cmd
, 0, sizeof(coex_cmd
));
305 return iwl_trans_send_cmd_pdu(trans
,
306 COEX_PRIORITY_TABLE_CMD
, CMD_SYNC
,
307 sizeof(coex_cmd
), &coex_cmd
);
310 static const u8 iwl_bt_prio_tbl
[BT_COEX_PRIO_TBL_EVT_MAX
] = {
311 ((BT_COEX_PRIO_TBL_PRIO_BYPASS
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
312 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
313 ((BT_COEX_PRIO_TBL_PRIO_BYPASS
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
314 (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
315 ((BT_COEX_PRIO_TBL_PRIO_LOW
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
316 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
317 ((BT_COEX_PRIO_TBL_PRIO_LOW
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
318 (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
319 ((BT_COEX_PRIO_TBL_PRIO_HIGH
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
320 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
321 ((BT_COEX_PRIO_TBL_PRIO_HIGH
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
322 (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
323 ((BT_COEX_PRIO_TBL_PRIO_BYPASS
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
324 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
325 ((BT_COEX_PRIO_TBL_PRIO_COEX_OFF
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
326 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
327 ((BT_COEX_PRIO_TBL_PRIO_COEX_ON
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
328 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
332 void iwl_send_prio_tbl(struct iwl_trans
*trans
)
334 struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd
;
336 memcpy(prio_tbl_cmd
.prio_tbl
, iwl_bt_prio_tbl
,
337 sizeof(iwl_bt_prio_tbl
));
338 if (iwl_trans_send_cmd_pdu(trans
,
339 REPLY_BT_COEX_PRIO_TABLE
, CMD_SYNC
,
340 sizeof(prio_tbl_cmd
), &prio_tbl_cmd
))
341 IWL_ERR(trans
, "failed to send BT prio tbl command\n");
344 int iwl_send_bt_env(struct iwl_trans
*trans
, u8 action
, u8 type
)
346 struct iwl_bt_coex_prot_env_cmd env_cmd
;
349 env_cmd
.action
= action
;
351 ret
= iwl_trans_send_cmd_pdu(trans
,
352 REPLY_BT_COEX_PROT_ENV
, CMD_SYNC
,
353 sizeof(env_cmd
), &env_cmd
);
355 IWL_ERR(trans
, "failed to send BT env command\n");
360 static int iwl_alive_notify(struct iwl_trans
*trans
)
362 struct iwl_priv
*priv
= priv(trans
);
363 struct iwl_rxon_context
*ctx
;
366 if (!priv
->tx_cmd_pool
)
368 kmem_cache_create("iwl_dev_cmd",
369 sizeof(struct iwl_device_cmd
),
370 sizeof(void *), 0, NULL
);
372 if (!priv
->tx_cmd_pool
)
375 iwl_trans_fw_alive(trans
);
376 for_each_context(priv
, ctx
)
377 ctx
->last_tx_rejected
= false;
379 ret
= iwl_send_wimax_coex(trans
);
383 if (!cfg(priv
)->no_xtal_calib
) {
384 ret
= iwl_set_Xtal_calib(trans
);
389 return iwl_send_calib_results(trans
);
394 * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host,
395 * using sample data 100 bytes apart. If these sample points are good,
396 * it's a pretty good bet that everything between them is good, too.
398 static int iwl_verify_inst_sparse(struct iwl_trans
*trans
,
399 struct fw_desc
*fw_desc
)
401 __le32
*image
= (__le32
*)fw_desc
->v_addr
;
402 u32 len
= fw_desc
->len
;
406 IWL_DEBUG_FW(trans
, "ucode inst image size is %u\n", len
);
408 for (i
= 0; i
< len
; i
+= 100, image
+= 100/sizeof(u32
)) {
409 /* read data comes through single port, auto-incr addr */
410 /* NOTE: Use the debugless read so we don't flood kernel log
411 * if IWL_DL_IO is set */
412 iwl_write_direct32(trans
, HBUS_TARG_MEM_RADDR
,
413 i
+ IWLAGN_RTC_INST_LOWER_BOUND
);
414 val
= iwl_read32(trans
, HBUS_TARG_MEM_RDAT
);
415 if (val
!= le32_to_cpu(*image
))
422 static void iwl_print_mismatch_inst(struct iwl_trans
*trans
,
423 struct fw_desc
*fw_desc
)
425 __le32
*image
= (__le32
*)fw_desc
->v_addr
;
426 u32 len
= fw_desc
->len
;
431 IWL_DEBUG_FW(trans
, "ucode inst image size is %u\n", len
);
433 iwl_write_direct32(trans
, HBUS_TARG_MEM_RADDR
,
434 IWLAGN_RTC_INST_LOWER_BOUND
);
437 offs
< len
&& errors
< 20;
438 offs
+= sizeof(u32
), image
++) {
439 /* read data comes through single port, auto-incr addr */
440 val
= iwl_read32(trans
, HBUS_TARG_MEM_RDAT
);
441 if (val
!= le32_to_cpu(*image
)) {
442 IWL_ERR(trans
, "uCode INST section at "
443 "offset 0x%x, is 0x%x, s/b 0x%x\n",
444 offs
, val
, le32_to_cpu(*image
));
451 * iwl_verify_ucode - determine which instruction image is in SRAM,
452 * and verify its contents
454 static int iwl_verify_ucode(struct iwl_trans
*trans
,
455 enum iwl_ucode_type ucode_type
)
457 struct fw_img
*img
= iwl_get_ucode_image(trans
, ucode_type
);
460 IWL_ERR(trans
, "Invalid ucode requested (%d)\n", ucode_type
);
464 if (!iwl_verify_inst_sparse(trans
, &img
->code
)) {
465 IWL_DEBUG_FW(trans
, "uCode is good in inst SRAM\n");
469 IWL_ERR(trans
, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n");
471 iwl_print_mismatch_inst(trans
, &img
->code
);
475 struct iwl_alive_data
{
480 static void iwl_alive_fn(struct iwl_trans
*trans
,
481 struct iwl_rx_packet
*pkt
,
484 struct iwl_alive_data
*alive_data
= data
;
485 struct iwl_alive_resp
*palive
;
487 palive
= &pkt
->u
.alive_frame
;
489 IWL_DEBUG_FW(trans
, "Alive ucode status 0x%08X revision "
491 palive
->is_valid
, palive
->ver_type
,
492 palive
->ver_subtype
);
494 trans
->shrd
->device_pointers
.error_event_table
=
495 le32_to_cpu(palive
->error_event_table_ptr
);
496 trans
->shrd
->device_pointers
.log_event_table
=
497 le32_to_cpu(palive
->log_event_table_ptr
);
499 alive_data
->subtype
= palive
->ver_subtype
;
500 alive_data
->valid
= palive
->is_valid
== UCODE_VALID_OK
;
503 /* notification wait support */
504 void iwl_init_notification_wait(struct iwl_shared
*shrd
,
505 struct iwl_notification_wait
*wait_entry
,
507 void (*fn
)(struct iwl_trans
*trans
,
508 struct iwl_rx_packet
*pkt
,
513 wait_entry
->fn_data
= fn_data
;
514 wait_entry
->cmd
= cmd
;
515 wait_entry
->triggered
= false;
516 wait_entry
->aborted
= false;
518 spin_lock_bh(&shrd
->notif_wait_lock
);
519 list_add(&wait_entry
->list
, &shrd
->notif_waits
);
520 spin_unlock_bh(&shrd
->notif_wait_lock
);
523 int iwl_wait_notification(struct iwl_shared
*shrd
,
524 struct iwl_notification_wait
*wait_entry
,
525 unsigned long timeout
)
529 ret
= wait_event_timeout(shrd
->notif_waitq
,
530 wait_entry
->triggered
|| wait_entry
->aborted
,
533 spin_lock_bh(&shrd
->notif_wait_lock
);
534 list_del(&wait_entry
->list
);
535 spin_unlock_bh(&shrd
->notif_wait_lock
);
537 if (wait_entry
->aborted
)
540 /* return value is always >= 0 */
546 void iwl_remove_notification(struct iwl_shared
*shrd
,
547 struct iwl_notification_wait
*wait_entry
)
549 spin_lock_bh(&shrd
->notif_wait_lock
);
550 list_del(&wait_entry
->list
);
551 spin_unlock_bh(&shrd
->notif_wait_lock
);
554 void iwl_abort_notification_waits(struct iwl_shared
*shrd
)
557 struct iwl_notification_wait
*wait_entry
;
559 spin_lock_irqsave(&shrd
->notif_wait_lock
, flags
);
560 list_for_each_entry(wait_entry
, &shrd
->notif_waits
, list
)
561 wait_entry
->aborted
= true;
562 spin_unlock_irqrestore(&shrd
->notif_wait_lock
, flags
);
564 wake_up_all(&shrd
->notif_waitq
);
567 #define UCODE_ALIVE_TIMEOUT HZ
568 #define UCODE_CALIB_TIMEOUT (2*HZ)
570 int iwl_load_ucode_wait_alive(struct iwl_trans
*trans
,
571 enum iwl_ucode_type ucode_type
)
573 struct iwl_notification_wait alive_wait
;
574 struct iwl_alive_data alive_data
;
577 enum iwl_ucode_type old_type
;
579 iwl_init_notification_wait(trans
->shrd
, &alive_wait
, REPLY_ALIVE
,
580 iwl_alive_fn
, &alive_data
);
582 old_type
= trans
->shrd
->ucode_type
;
583 trans
->shrd
->ucode_type
= ucode_type
;
584 fw
= iwl_get_ucode_image(trans
, ucode_type
);
589 ret
= iwl_trans_start_fw(trans
, fw
);
591 trans
->shrd
->ucode_type
= old_type
;
592 iwl_remove_notification(trans
->shrd
, &alive_wait
);
597 * Some things may run in the background now, but we
598 * just wait for the ALIVE notification here.
600 ret
= iwl_wait_notification(trans
->shrd
, &alive_wait
,
601 UCODE_ALIVE_TIMEOUT
);
603 trans
->shrd
->ucode_type
= old_type
;
607 if (!alive_data
.valid
) {
608 IWL_ERR(trans
, "Loaded ucode is not valid!\n");
609 trans
->shrd
->ucode_type
= old_type
;
614 * This step takes a long time (60-80ms!!) and
615 * WoWLAN image should be loaded quickly, so
616 * skip it for WoWLAN.
618 if (ucode_type
!= IWL_UCODE_WOWLAN
) {
619 ret
= iwl_verify_ucode(trans
, ucode_type
);
621 trans
->shrd
->ucode_type
= old_type
;
625 /* delay a bit to give rfkill time to run */
629 ret
= iwl_alive_notify(trans
);
632 "Could not complete ALIVE transition: %d\n", ret
);
633 trans
->shrd
->ucode_type
= old_type
;
640 int iwl_run_init_ucode(struct iwl_trans
*trans
)
642 struct iwl_notification_wait calib_wait
;
645 lockdep_assert_held(&trans
->shrd
->mutex
);
647 /* No init ucode required? Curious, but maybe ok */
648 if (!trans
->ucode_init
.code
.len
)
651 if (trans
->shrd
->ucode_type
!= IWL_UCODE_NONE
)
654 iwl_init_notification_wait(trans
->shrd
, &calib_wait
,
655 CALIBRATION_COMPLETE_NOTIFICATION
,
658 /* Will also start the device */
659 ret
= iwl_load_ucode_wait_alive(trans
, IWL_UCODE_INIT
);
663 ret
= iwl_init_alive_start(trans
);
668 * Some things may run in the background now, but we
669 * just wait for the calibration complete notification.
671 ret
= iwl_wait_notification(trans
->shrd
, &calib_wait
,
672 UCODE_CALIB_TIMEOUT
);
677 iwl_remove_notification(trans
->shrd
, &calib_wait
);
679 /* Whatever happened, stop the device */
680 iwl_trans_stop_device(trans
);