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>
35 #include <linux/firmware.h>
37 #include "iwl-ucode.h"
42 #include "iwl-agn-hw.h"
44 #include "iwl-agn-calib.h"
45 #include "iwl-trans.h"
48 static struct iwl_wimax_coex_event_entry cu_priorities
[COEX_NUM_OF_EVENTS
] = {
49 {COEX_CU_UNASSOC_IDLE_RP
, COEX_CU_UNASSOC_IDLE_WP
,
50 0, COEX_UNASSOC_IDLE_FLAGS
},
51 {COEX_CU_UNASSOC_MANUAL_SCAN_RP
, COEX_CU_UNASSOC_MANUAL_SCAN_WP
,
52 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS
},
53 {COEX_CU_UNASSOC_AUTO_SCAN_RP
, COEX_CU_UNASSOC_AUTO_SCAN_WP
,
54 0, COEX_UNASSOC_AUTO_SCAN_FLAGS
},
55 {COEX_CU_CALIBRATION_RP
, COEX_CU_CALIBRATION_WP
,
56 0, COEX_CALIBRATION_FLAGS
},
57 {COEX_CU_PERIODIC_CALIBRATION_RP
, COEX_CU_PERIODIC_CALIBRATION_WP
,
58 0, COEX_PERIODIC_CALIBRATION_FLAGS
},
59 {COEX_CU_CONNECTION_ESTAB_RP
, COEX_CU_CONNECTION_ESTAB_WP
,
60 0, COEX_CONNECTION_ESTAB_FLAGS
},
61 {COEX_CU_ASSOCIATED_IDLE_RP
, COEX_CU_ASSOCIATED_IDLE_WP
,
62 0, COEX_ASSOCIATED_IDLE_FLAGS
},
63 {COEX_CU_ASSOC_MANUAL_SCAN_RP
, COEX_CU_ASSOC_MANUAL_SCAN_WP
,
64 0, COEX_ASSOC_MANUAL_SCAN_FLAGS
},
65 {COEX_CU_ASSOC_AUTO_SCAN_RP
, COEX_CU_ASSOC_AUTO_SCAN_WP
,
66 0, COEX_ASSOC_AUTO_SCAN_FLAGS
},
67 {COEX_CU_ASSOC_ACTIVE_LEVEL_RP
, COEX_CU_ASSOC_ACTIVE_LEVEL_WP
,
68 0, COEX_ASSOC_ACTIVE_LEVEL_FLAGS
},
69 {COEX_CU_RF_ON_RP
, COEX_CU_RF_ON_WP
, 0, COEX_CU_RF_ON_FLAGS
},
70 {COEX_CU_RF_OFF_RP
, COEX_CU_RF_OFF_WP
, 0, COEX_RF_OFF_FLAGS
},
71 {COEX_CU_STAND_ALONE_DEBUG_RP
, COEX_CU_STAND_ALONE_DEBUG_WP
,
72 0, COEX_STAND_ALONE_DEBUG_FLAGS
},
73 {COEX_CU_IPAN_ASSOC_LEVEL_RP
, COEX_CU_IPAN_ASSOC_LEVEL_WP
,
74 0, COEX_IPAN_ASSOC_LEVEL_FLAGS
},
75 {COEX_CU_RSRVD1_RP
, COEX_CU_RSRVD1_WP
, 0, COEX_RSRVD1_FLAGS
},
76 {COEX_CU_RSRVD2_RP
, COEX_CU_RSRVD2_WP
, 0, COEX_RSRVD2_FLAGS
}
79 /******************************************************************************
81 * uCode download functions
83 ******************************************************************************/
85 static void iwl_free_fw_desc(struct iwl_nic
*nic
, struct fw_desc
*desc
)
88 dma_free_coherent(trans(nic
)->dev
, desc
->len
,
89 desc
->v_addr
, desc
->p_addr
);
94 static void iwl_free_fw_img(struct iwl_nic
*nic
, struct fw_img
*img
)
96 iwl_free_fw_desc(nic
, &img
->code
);
97 iwl_free_fw_desc(nic
, &img
->data
);
100 void iwl_dealloc_ucode(struct iwl_nic
*nic
)
102 iwl_free_fw_img(nic
, &nic
->fw
.ucode_rt
);
103 iwl_free_fw_img(nic
, &nic
->fw
.ucode_init
);
104 iwl_free_fw_img(nic
, &nic
->fw
.ucode_wowlan
);
107 static int iwl_alloc_fw_desc(struct iwl_nic
*nic
, struct fw_desc
*desc
,
108 const void *data
, size_t len
)
115 desc
->v_addr
= dma_alloc_coherent(trans(nic
)->dev
, len
,
116 &desc
->p_addr
, GFP_KERNEL
);
121 memcpy(desc
->v_addr
, data
, len
);
125 static inline struct fw_img
*iwl_get_ucode_image(struct iwl_nic
*nic
,
126 enum iwl_ucode_type ucode_type
)
128 switch (ucode_type
) {
130 return &nic
->fw
.ucode_init
;
131 case IWL_UCODE_WOWLAN
:
132 return &nic
->fw
.ucode_wowlan
;
133 case IWL_UCODE_REGULAR
:
134 return &nic
->fw
.ucode_rt
;
144 static int iwl_set_Xtal_calib(struct iwl_trans
*trans
)
146 struct iwl_calib_xtal_freq_cmd cmd
;
148 (__le16
*)iwl_eeprom_query_addr(trans
->shrd
, EEPROM_XTAL
);
150 iwl_set_calib_hdr(&cmd
.hdr
, IWL_PHY_CALIBRATE_CRYSTAL_FRQ_CMD
);
151 cmd
.cap_pin1
= le16_to_cpu(xtal_calib
[0]);
152 cmd
.cap_pin2
= le16_to_cpu(xtal_calib
[1]);
153 return iwl_calib_set(trans
, (void *)&cmd
, sizeof(cmd
));
156 static int iwl_set_temperature_offset_calib(struct iwl_trans
*trans
)
158 struct iwl_calib_temperature_offset_cmd cmd
;
159 __le16
*offset_calib
=
160 (__le16
*)iwl_eeprom_query_addr(trans
->shrd
,
161 EEPROM_RAW_TEMPERATURE
);
163 memset(&cmd
, 0, sizeof(cmd
));
164 iwl_set_calib_hdr(&cmd
.hdr
, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD
);
165 memcpy(&cmd
.radio_sensor_offset
, offset_calib
, sizeof(*offset_calib
));
166 if (!(cmd
.radio_sensor_offset
))
167 cmd
.radio_sensor_offset
= DEFAULT_RADIO_SENSOR_OFFSET
;
169 IWL_DEBUG_CALIB(trans
, "Radio sensor offset: %d\n",
170 le16_to_cpu(cmd
.radio_sensor_offset
));
171 return iwl_calib_set(trans
, (void *)&cmd
, sizeof(cmd
));
174 static int iwl_set_temperature_offset_calib_v2(struct iwl_trans
*trans
)
176 struct iwl_calib_temperature_offset_v2_cmd cmd
;
177 __le16
*offset_calib_high
= (__le16
*)iwl_eeprom_query_addr(trans
->shrd
,
178 EEPROM_KELVIN_TEMPERATURE
);
179 __le16
*offset_calib_low
=
180 (__le16
*)iwl_eeprom_query_addr(trans
->shrd
,
181 EEPROM_RAW_TEMPERATURE
);
182 struct iwl_eeprom_calib_hdr
*hdr
;
184 memset(&cmd
, 0, sizeof(cmd
));
185 iwl_set_calib_hdr(&cmd
.hdr
, IWL_PHY_CALIBRATE_TEMP_OFFSET_CMD
);
186 hdr
= (struct iwl_eeprom_calib_hdr
*)iwl_eeprom_query_addr(trans
->shrd
,
188 memcpy(&cmd
.radio_sensor_offset_high
, offset_calib_high
,
189 sizeof(*offset_calib_high
));
190 memcpy(&cmd
.radio_sensor_offset_low
, offset_calib_low
,
191 sizeof(*offset_calib_low
));
192 if (!(cmd
.radio_sensor_offset_low
)) {
193 IWL_DEBUG_CALIB(trans
, "no info in EEPROM, use default\n");
194 cmd
.radio_sensor_offset_low
= DEFAULT_RADIO_SENSOR_OFFSET
;
195 cmd
.radio_sensor_offset_high
= DEFAULT_RADIO_SENSOR_OFFSET
;
197 memcpy(&cmd
.burntVoltageRef
, &hdr
->voltage
,
198 sizeof(hdr
->voltage
));
200 IWL_DEBUG_CALIB(trans
, "Radio sensor offset high: %d\n",
201 le16_to_cpu(cmd
.radio_sensor_offset_high
));
202 IWL_DEBUG_CALIB(trans
, "Radio sensor offset low: %d\n",
203 le16_to_cpu(cmd
.radio_sensor_offset_low
));
204 IWL_DEBUG_CALIB(trans
, "Voltage Ref: %d\n",
205 le16_to_cpu(cmd
.burntVoltageRef
));
207 return iwl_calib_set(trans
, (void *)&cmd
, sizeof(cmd
));
210 static int iwl_send_calib_cfg(struct iwl_trans
*trans
)
212 struct iwl_calib_cfg_cmd calib_cfg_cmd
;
213 struct iwl_host_cmd cmd
= {
214 .id
= CALIBRATION_CFG_CMD
,
215 .len
= { sizeof(struct iwl_calib_cfg_cmd
), },
216 .data
= { &calib_cfg_cmd
, },
219 memset(&calib_cfg_cmd
, 0, sizeof(calib_cfg_cmd
));
220 calib_cfg_cmd
.ucd_calib_cfg
.once
.is_enable
= IWL_CALIB_INIT_CFG_ALL
;
221 calib_cfg_cmd
.ucd_calib_cfg
.once
.start
= IWL_CALIB_INIT_CFG_ALL
;
222 calib_cfg_cmd
.ucd_calib_cfg
.once
.send_res
= IWL_CALIB_INIT_CFG_ALL
;
223 calib_cfg_cmd
.ucd_calib_cfg
.flags
=
224 IWL_CALIB_CFG_FLAG_SEND_COMPLETE_NTFY_MSK
;
226 return iwl_trans_send_cmd(trans
, &cmd
);
229 int iwlagn_rx_calib_result(struct iwl_priv
*priv
,
230 struct iwl_rx_mem_buffer
*rxb
,
231 struct iwl_device_cmd
*cmd
)
233 struct iwl_rx_packet
*pkt
= rxb_addr(rxb
);
234 struct iwl_calib_hdr
*hdr
= (struct iwl_calib_hdr
*)pkt
->u
.raw
;
235 int len
= le32_to_cpu(pkt
->len_n_flags
) & FH_RSCSR_FRAME_SIZE_MSK
;
237 /* reduce the size of the length field itself */
240 if (iwl_calib_set(trans(priv
), hdr
, len
))
241 IWL_ERR(priv
, "Failed to record calibration data %d\n",
247 int iwl_init_alive_start(struct iwl_trans
*trans
)
251 if (cfg(trans
)->bt_params
&&
252 cfg(trans
)->bt_params
->advanced_bt_coexist
) {
254 * Tell uCode we are ready to perform calibration
255 * need to perform this before any calibration
256 * no need to close the envlope since we are going
257 * to load the runtime uCode later.
259 ret
= iwl_send_bt_env(trans
, IWL_BT_COEX_ENV_OPEN
,
260 BT_COEX_PRIO_TBL_EVT_INIT_CALIB2
);
266 ret
= iwl_send_calib_cfg(trans
);
271 * temperature offset calibration is only needed for runtime ucode,
272 * so prepare the value now.
274 if (cfg(trans
)->need_temp_offset_calib
) {
275 if (cfg(trans
)->temp_offset_v2
)
276 return iwl_set_temperature_offset_calib_v2(trans
);
278 return iwl_set_temperature_offset_calib(trans
);
284 static int iwl_send_wimax_coex(struct iwl_trans
*trans
)
286 struct iwl_wimax_coex_cmd coex_cmd
;
288 if (cfg(trans
)->base_params
->support_wimax_coexist
) {
289 /* UnMask wake up src at associated sleep */
290 coex_cmd
.flags
= COEX_FLAGS_ASSOC_WA_UNMASK_MSK
;
292 /* UnMask wake up src at unassociated sleep */
293 coex_cmd
.flags
|= COEX_FLAGS_UNASSOC_WA_UNMASK_MSK
;
294 memcpy(coex_cmd
.sta_prio
, cu_priorities
,
295 sizeof(struct iwl_wimax_coex_event_entry
) *
298 /* enabling the coexistence feature */
299 coex_cmd
.flags
|= COEX_FLAGS_COEX_ENABLE_MSK
;
301 /* enabling the priorities tables */
302 coex_cmd
.flags
|= COEX_FLAGS_STA_TABLE_VALID_MSK
;
304 /* coexistence is disabled */
305 memset(&coex_cmd
, 0, sizeof(coex_cmd
));
307 return iwl_trans_send_cmd_pdu(trans
,
308 COEX_PRIORITY_TABLE_CMD
, CMD_SYNC
,
309 sizeof(coex_cmd
), &coex_cmd
);
312 static const u8 iwl_bt_prio_tbl
[BT_COEX_PRIO_TBL_EVT_MAX
] = {
313 ((BT_COEX_PRIO_TBL_PRIO_BYPASS
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
314 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
315 ((BT_COEX_PRIO_TBL_PRIO_BYPASS
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
316 (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
317 ((BT_COEX_PRIO_TBL_PRIO_LOW
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
318 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
319 ((BT_COEX_PRIO_TBL_PRIO_LOW
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
320 (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
321 ((BT_COEX_PRIO_TBL_PRIO_HIGH
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
322 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
323 ((BT_COEX_PRIO_TBL_PRIO_HIGH
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
324 (1 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
325 ((BT_COEX_PRIO_TBL_PRIO_BYPASS
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
326 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
327 ((BT_COEX_PRIO_TBL_PRIO_COEX_OFF
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
328 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
329 ((BT_COEX_PRIO_TBL_PRIO_COEX_ON
<< IWL_BT_COEX_PRIO_TBL_PRIO_POS
) |
330 (0 << IWL_BT_COEX_PRIO_TBL_SHARED_ANTENNA_POS
)),
334 void iwl_send_prio_tbl(struct iwl_trans
*trans
)
336 struct iwl_bt_coex_prio_table_cmd prio_tbl_cmd
;
338 memcpy(prio_tbl_cmd
.prio_tbl
, iwl_bt_prio_tbl
,
339 sizeof(iwl_bt_prio_tbl
));
340 if (iwl_trans_send_cmd_pdu(trans
,
341 REPLY_BT_COEX_PRIO_TABLE
, CMD_SYNC
,
342 sizeof(prio_tbl_cmd
), &prio_tbl_cmd
))
343 IWL_ERR(trans
, "failed to send BT prio tbl command\n");
346 int iwl_send_bt_env(struct iwl_trans
*trans
, u8 action
, u8 type
)
348 struct iwl_bt_coex_prot_env_cmd env_cmd
;
351 env_cmd
.action
= action
;
353 ret
= iwl_trans_send_cmd_pdu(trans
,
354 REPLY_BT_COEX_PROT_ENV
, CMD_SYNC
,
355 sizeof(env_cmd
), &env_cmd
);
357 IWL_ERR(trans
, "failed to send BT env command\n");
362 static int iwl_alive_notify(struct iwl_trans
*trans
)
364 struct iwl_priv
*priv
= priv(trans
);
365 struct iwl_rxon_context
*ctx
;
368 if (!priv
->tx_cmd_pool
)
370 kmem_cache_create("iwl_dev_cmd",
371 sizeof(struct iwl_device_cmd
),
372 sizeof(void *), 0, NULL
);
374 if (!priv
->tx_cmd_pool
)
377 iwl_trans_fw_alive(trans
);
378 for_each_context(priv
, ctx
)
379 ctx
->last_tx_rejected
= false;
381 ret
= iwl_send_wimax_coex(trans
);
385 if (!cfg(priv
)->no_xtal_calib
) {
386 ret
= iwl_set_Xtal_calib(trans
);
391 return iwl_send_calib_results(trans
);
396 * iwl_verify_inst_sparse - verify runtime uCode image in card vs. host,
397 * using sample data 100 bytes apart. If these sample points are good,
398 * it's a pretty good bet that everything between them is good, too.
400 static int iwl_verify_inst_sparse(struct iwl_nic
*nic
,
401 struct fw_desc
*fw_desc
)
403 struct iwl_trans
*trans
= trans(nic
);
404 __le32
*image
= (__le32
*)fw_desc
->v_addr
;
405 u32 len
= fw_desc
->len
;
409 IWL_DEBUG_FW(nic
, "ucode inst image size is %u\n", len
);
411 for (i
= 0; i
< len
; i
+= 100, image
+= 100/sizeof(u32
)) {
412 /* read data comes through single port, auto-incr addr */
413 /* NOTE: Use the debugless read so we don't flood kernel log
414 * if IWL_DL_IO is set */
415 iwl_write_direct32(trans
, HBUS_TARG_MEM_RADDR
,
416 i
+ IWLAGN_RTC_INST_LOWER_BOUND
);
417 val
= iwl_read32(trans
, HBUS_TARG_MEM_RDAT
);
418 if (val
!= le32_to_cpu(*image
))
425 static void iwl_print_mismatch_inst(struct iwl_nic
*nic
,
426 struct fw_desc
*fw_desc
)
428 struct iwl_trans
*trans
= trans(nic
);
429 __le32
*image
= (__le32
*)fw_desc
->v_addr
;
430 u32 len
= fw_desc
->len
;
435 IWL_DEBUG_FW(nic
, "ucode inst image size is %u\n", len
);
437 iwl_write_direct32(trans
, HBUS_TARG_MEM_RADDR
,
438 IWLAGN_RTC_INST_LOWER_BOUND
);
441 offs
< len
&& errors
< 20;
442 offs
+= sizeof(u32
), image
++) {
443 /* read data comes through single port, auto-incr addr */
444 val
= iwl_read32(trans
, HBUS_TARG_MEM_RDAT
);
445 if (val
!= le32_to_cpu(*image
)) {
446 IWL_ERR(nic
, "uCode INST section at "
447 "offset 0x%x, is 0x%x, s/b 0x%x\n",
448 offs
, val
, le32_to_cpu(*image
));
455 * iwl_verify_ucode - determine which instruction image is in SRAM,
456 * and verify its contents
458 static int iwl_verify_ucode(struct iwl_nic
*nic
,
459 enum iwl_ucode_type ucode_type
)
461 struct fw_img
*img
= iwl_get_ucode_image(nic
, ucode_type
);
464 IWL_ERR(nic
, "Invalid ucode requested (%d)\n", ucode_type
);
468 if (!iwl_verify_inst_sparse(nic
, &img
->code
)) {
469 IWL_DEBUG_FW(nic
, "uCode is good in inst SRAM\n");
473 IWL_ERR(nic
, "UCODE IMAGE IN INSTRUCTION SRAM NOT VALID!!\n");
475 iwl_print_mismatch_inst(nic
, &img
->code
);
479 struct iwl_alive_data
{
484 static void iwl_alive_fn(struct iwl_trans
*trans
,
485 struct iwl_rx_packet
*pkt
,
488 struct iwl_alive_data
*alive_data
= data
;
489 struct iwl_alive_resp
*palive
;
491 palive
= &pkt
->u
.alive_frame
;
493 IWL_DEBUG_FW(trans
, "Alive ucode status 0x%08X revision "
495 palive
->is_valid
, palive
->ver_type
,
496 palive
->ver_subtype
);
498 trans
->shrd
->device_pointers
.error_event_table
=
499 le32_to_cpu(palive
->error_event_table_ptr
);
500 trans
->shrd
->device_pointers
.log_event_table
=
501 le32_to_cpu(palive
->log_event_table_ptr
);
503 alive_data
->subtype
= palive
->ver_subtype
;
504 alive_data
->valid
= palive
->is_valid
== UCODE_VALID_OK
;
507 /* notification wait support */
508 void iwl_init_notification_wait(struct iwl_shared
*shrd
,
509 struct iwl_notification_wait
*wait_entry
,
511 void (*fn
)(struct iwl_trans
*trans
,
512 struct iwl_rx_packet
*pkt
,
517 wait_entry
->fn_data
= fn_data
;
518 wait_entry
->cmd
= cmd
;
519 wait_entry
->triggered
= false;
520 wait_entry
->aborted
= false;
522 spin_lock_bh(&shrd
->notif_wait_lock
);
523 list_add(&wait_entry
->list
, &shrd
->notif_waits
);
524 spin_unlock_bh(&shrd
->notif_wait_lock
);
527 int iwl_wait_notification(struct iwl_shared
*shrd
,
528 struct iwl_notification_wait
*wait_entry
,
529 unsigned long timeout
)
533 ret
= wait_event_timeout(shrd
->notif_waitq
,
534 wait_entry
->triggered
|| wait_entry
->aborted
,
537 spin_lock_bh(&shrd
->notif_wait_lock
);
538 list_del(&wait_entry
->list
);
539 spin_unlock_bh(&shrd
->notif_wait_lock
);
541 if (wait_entry
->aborted
)
544 /* return value is always >= 0 */
550 void iwl_remove_notification(struct iwl_shared
*shrd
,
551 struct iwl_notification_wait
*wait_entry
)
553 spin_lock_bh(&shrd
->notif_wait_lock
);
554 list_del(&wait_entry
->list
);
555 spin_unlock_bh(&shrd
->notif_wait_lock
);
558 void iwl_abort_notification_waits(struct iwl_shared
*shrd
)
561 struct iwl_notification_wait
*wait_entry
;
563 spin_lock_irqsave(&shrd
->notif_wait_lock
, flags
);
564 list_for_each_entry(wait_entry
, &shrd
->notif_waits
, list
)
565 wait_entry
->aborted
= true;
566 spin_unlock_irqrestore(&shrd
->notif_wait_lock
, flags
);
568 wake_up_all(&shrd
->notif_waitq
);
571 #define UCODE_ALIVE_TIMEOUT HZ
572 #define UCODE_CALIB_TIMEOUT (2*HZ)
574 int iwl_load_ucode_wait_alive(struct iwl_trans
*trans
,
575 enum iwl_ucode_type ucode_type
)
577 struct iwl_notification_wait alive_wait
;
578 struct iwl_alive_data alive_data
;
581 enum iwl_ucode_type old_type
;
583 iwl_init_notification_wait(trans
->shrd
, &alive_wait
, REPLY_ALIVE
,
584 iwl_alive_fn
, &alive_data
);
586 old_type
= trans
->shrd
->ucode_type
;
587 trans
->shrd
->ucode_type
= ucode_type
;
588 fw
= iwl_get_ucode_image(nic(trans
), ucode_type
);
593 ret
= iwl_trans_start_fw(trans
, fw
);
595 trans
->shrd
->ucode_type
= old_type
;
596 iwl_remove_notification(trans
->shrd
, &alive_wait
);
601 * Some things may run in the background now, but we
602 * just wait for the ALIVE notification here.
604 ret
= iwl_wait_notification(trans
->shrd
, &alive_wait
,
605 UCODE_ALIVE_TIMEOUT
);
607 trans
->shrd
->ucode_type
= old_type
;
611 if (!alive_data
.valid
) {
612 IWL_ERR(trans
, "Loaded ucode is not valid!\n");
613 trans
->shrd
->ucode_type
= old_type
;
618 * This step takes a long time (60-80ms!!) and
619 * WoWLAN image should be loaded quickly, so
620 * skip it for WoWLAN.
622 if (ucode_type
!= IWL_UCODE_WOWLAN
) {
623 ret
= iwl_verify_ucode(nic(trans
), ucode_type
);
625 trans
->shrd
->ucode_type
= old_type
;
629 /* delay a bit to give rfkill time to run */
633 ret
= iwl_alive_notify(trans
);
636 "Could not complete ALIVE transition: %d\n", ret
);
637 trans
->shrd
->ucode_type
= old_type
;
644 int iwl_run_init_ucode(struct iwl_trans
*trans
)
646 struct iwl_notification_wait calib_wait
;
649 lockdep_assert_held(&trans
->shrd
->mutex
);
651 /* No init ucode required? Curious, but maybe ok */
652 if (!nic(trans
)->fw
.ucode_init
.code
.len
)
655 if (trans
->shrd
->ucode_type
!= IWL_UCODE_NONE
)
658 iwl_init_notification_wait(trans
->shrd
, &calib_wait
,
659 CALIBRATION_COMPLETE_NOTIFICATION
,
662 /* Will also start the device */
663 ret
= iwl_load_ucode_wait_alive(trans
, IWL_UCODE_INIT
);
667 ret
= iwl_init_alive_start(trans
);
672 * Some things may run in the background now, but we
673 * just wait for the calibration complete notification.
675 ret
= iwl_wait_notification(trans
->shrd
, &calib_wait
,
676 UCODE_CALIB_TIMEOUT
);
681 iwl_remove_notification(trans
->shrd
, &calib_wait
);
683 /* Whatever happened, stop the device */
684 iwl_trans_stop_device(trans
);
688 static void iwl_ucode_callback(const struct firmware
*ucode_raw
, void *context
);
690 #define UCODE_EXPERIMENTAL_INDEX 100
691 #define UCODE_EXPERIMENTAL_TAG "exp"
693 int __must_check
iwl_request_firmware(struct iwl_nic
*nic
, bool first
)
695 struct iwl_cfg
*cfg
= cfg(nic
);
696 const char *name_pre
= cfg
->fw_name_pre
;
700 #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE
701 nic
->fw_index
= UCODE_EXPERIMENTAL_INDEX
;
702 strcpy(tag
, UCODE_EXPERIMENTAL_TAG
);
703 } else if (nic
->fw_index
== UCODE_EXPERIMENTAL_INDEX
) {
705 nic
->fw_index
= cfg
->ucode_api_max
;
706 sprintf(tag
, "%d", nic
->fw_index
);
709 sprintf(tag
, "%d", nic
->fw_index
);
712 if (nic
->fw_index
< cfg
->ucode_api_min
) {
713 IWL_ERR(nic
, "no suitable firmware found!\n");
717 sprintf(nic
->firmware_name
, "%s%s%s", name_pre
, tag
, ".ucode");
719 IWL_DEBUG_INFO(nic
, "attempting to load firmware %s'%s'\n",
720 (nic
->fw_index
== UCODE_EXPERIMENTAL_INDEX
)
721 ? "EXPERIMENTAL " : "",
724 return request_firmware_nowait(THIS_MODULE
, 1, nic
->firmware_name
,
726 GFP_KERNEL
, nic
, iwl_ucode_callback
);
729 struct iwlagn_firmware_pieces
{
730 const void *inst
, *data
, *init
, *init_data
, *wowlan_inst
, *wowlan_data
;
731 size_t inst_size
, data_size
, init_size
, init_data_size
,
732 wowlan_inst_size
, wowlan_data_size
;
736 u32 init_evtlog_ptr
, init_evtlog_size
, init_errlog_ptr
;
737 u32 inst_evtlog_ptr
, inst_evtlog_size
, inst_errlog_ptr
;
740 static int iwl_parse_v1_v2_firmware(struct iwl_nic
*nic
,
741 const struct firmware
*ucode_raw
,
742 struct iwlagn_firmware_pieces
*pieces
)
744 struct iwl_ucode_header
*ucode
= (void *)ucode_raw
->data
;
745 u32 api_ver
, hdr_size
;
748 nic
->fw
.ucode_ver
= le32_to_cpu(ucode
->ver
);
749 api_ver
= IWL_UCODE_API(nic
->fw
.ucode_ver
);
754 if (ucode_raw
->size
< hdr_size
) {
755 IWL_ERR(nic
, "File size too small!\n");
758 pieces
->build
= le32_to_cpu(ucode
->u
.v2
.build
);
759 pieces
->inst_size
= le32_to_cpu(ucode
->u
.v2
.inst_size
);
760 pieces
->data_size
= le32_to_cpu(ucode
->u
.v2
.data_size
);
761 pieces
->init_size
= le32_to_cpu(ucode
->u
.v2
.init_size
);
762 pieces
->init_data_size
= le32_to_cpu(ucode
->u
.v2
.init_data_size
);
763 src
= ucode
->u
.v2
.data
;
769 if (ucode_raw
->size
< hdr_size
) {
770 IWL_ERR(nic
, "File size too small!\n");
774 pieces
->inst_size
= le32_to_cpu(ucode
->u
.v1
.inst_size
);
775 pieces
->data_size
= le32_to_cpu(ucode
->u
.v1
.data_size
);
776 pieces
->init_size
= le32_to_cpu(ucode
->u
.v1
.init_size
);
777 pieces
->init_data_size
= le32_to_cpu(ucode
->u
.v1
.init_data_size
);
778 src
= ucode
->u
.v1
.data
;
782 /* Verify size of file vs. image size info in file's header */
783 if (ucode_raw
->size
!= hdr_size
+ pieces
->inst_size
+
784 pieces
->data_size
+ pieces
->init_size
+
785 pieces
->init_data_size
) {
788 "uCode file size %d does not match expected size\n",
789 (int)ucode_raw
->size
);
794 src
+= pieces
->inst_size
;
796 src
+= pieces
->data_size
;
798 src
+= pieces
->init_size
;
799 pieces
->init_data
= src
;
800 src
+= pieces
->init_data_size
;
805 static int iwl_parse_tlv_firmware(struct iwl_nic
*nic
,
806 const struct firmware
*ucode_raw
,
807 struct iwlagn_firmware_pieces
*pieces
,
808 struct iwlagn_ucode_capabilities
*capa
)
810 struct iwl_tlv_ucode_header
*ucode
= (void *)ucode_raw
->data
;
811 struct iwl_ucode_tlv
*tlv
;
812 size_t len
= ucode_raw
->size
;
814 int wanted_alternative
= iwlagn_mod_params
.wanted_ucode_alternative
;
818 enum iwl_ucode_tlv_type tlv_type
;
821 if (len
< sizeof(*ucode
)) {
822 IWL_ERR(nic
, "uCode has invalid length: %zd\n", len
);
826 if (ucode
->magic
!= cpu_to_le32(IWL_TLV_UCODE_MAGIC
)) {
827 IWL_ERR(nic
, "invalid uCode magic: 0X%x\n",
828 le32_to_cpu(ucode
->magic
));
833 * Check which alternatives are present, and "downgrade"
834 * when the chosen alternative is not present, warning
835 * the user when that happens. Some files may not have
836 * any alternatives, so don't warn in that case.
838 alternatives
= le64_to_cpu(ucode
->alternatives
);
839 tmp
= wanted_alternative
;
840 if (wanted_alternative
> 63)
841 wanted_alternative
= 63;
842 while (wanted_alternative
&& !(alternatives
& BIT(wanted_alternative
)))
843 wanted_alternative
--;
844 if (wanted_alternative
&& wanted_alternative
!= tmp
)
846 "uCode alternative %d not available, choosing %d\n",
847 tmp
, wanted_alternative
);
849 nic
->fw
.ucode_ver
= le32_to_cpu(ucode
->ver
);
850 pieces
->build
= le32_to_cpu(ucode
->build
);
853 len
-= sizeof(*ucode
);
855 while (len
>= sizeof(*tlv
)) {
861 tlv_len
= le32_to_cpu(tlv
->length
);
862 tlv_type
= le16_to_cpu(tlv
->type
);
863 tlv_alt
= le16_to_cpu(tlv
->alternative
);
864 tlv_data
= tlv
->data
;
867 IWL_ERR(nic
, "invalid TLV len: %zd/%u\n",
871 len
-= ALIGN(tlv_len
, 4);
872 data
+= sizeof(*tlv
) + ALIGN(tlv_len
, 4);
875 * Alternative 0 is always valid.
877 * Skip alternative TLVs that are not selected.
879 if (tlv_alt
!= 0 && tlv_alt
!= wanted_alternative
)
883 case IWL_UCODE_TLV_INST
:
884 pieces
->inst
= tlv_data
;
885 pieces
->inst_size
= tlv_len
;
887 case IWL_UCODE_TLV_DATA
:
888 pieces
->data
= tlv_data
;
889 pieces
->data_size
= tlv_len
;
891 case IWL_UCODE_TLV_INIT
:
892 pieces
->init
= tlv_data
;
893 pieces
->init_size
= tlv_len
;
895 case IWL_UCODE_TLV_INIT_DATA
:
896 pieces
->init_data
= tlv_data
;
897 pieces
->init_data_size
= tlv_len
;
899 case IWL_UCODE_TLV_BOOT
:
900 IWL_ERR(nic
, "Found unexpected BOOT ucode\n");
902 case IWL_UCODE_TLV_PROBE_MAX_LEN
:
903 if (tlv_len
!= sizeof(u32
))
904 goto invalid_tlv_len
;
905 capa
->max_probe_length
=
906 le32_to_cpup((__le32
*)tlv_data
);
908 case IWL_UCODE_TLV_PAN
:
910 goto invalid_tlv_len
;
911 capa
->flags
|= IWL_UCODE_TLV_FLAGS_PAN
;
913 case IWL_UCODE_TLV_FLAGS
:
914 /* must be at least one u32 */
915 if (tlv_len
< sizeof(u32
))
916 goto invalid_tlv_len
;
917 /* and a proper number of u32s */
918 if (tlv_len
% sizeof(u32
))
919 goto invalid_tlv_len
;
921 * This driver only reads the first u32 as
922 * right now no more features are defined,
923 * if that changes then either the driver
924 * will not work with the new firmware, or
925 * it'll not take advantage of new features.
927 capa
->flags
= le32_to_cpup((__le32
*)tlv_data
);
929 case IWL_UCODE_TLV_INIT_EVTLOG_PTR
:
930 if (tlv_len
!= sizeof(u32
))
931 goto invalid_tlv_len
;
932 pieces
->init_evtlog_ptr
=
933 le32_to_cpup((__le32
*)tlv_data
);
935 case IWL_UCODE_TLV_INIT_EVTLOG_SIZE
:
936 if (tlv_len
!= sizeof(u32
))
937 goto invalid_tlv_len
;
938 pieces
->init_evtlog_size
=
939 le32_to_cpup((__le32
*)tlv_data
);
941 case IWL_UCODE_TLV_INIT_ERRLOG_PTR
:
942 if (tlv_len
!= sizeof(u32
))
943 goto invalid_tlv_len
;
944 pieces
->init_errlog_ptr
=
945 le32_to_cpup((__le32
*)tlv_data
);
947 case IWL_UCODE_TLV_RUNT_EVTLOG_PTR
:
948 if (tlv_len
!= sizeof(u32
))
949 goto invalid_tlv_len
;
950 pieces
->inst_evtlog_ptr
=
951 le32_to_cpup((__le32
*)tlv_data
);
953 case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE
:
954 if (tlv_len
!= sizeof(u32
))
955 goto invalid_tlv_len
;
956 pieces
->inst_evtlog_size
=
957 le32_to_cpup((__le32
*)tlv_data
);
959 case IWL_UCODE_TLV_RUNT_ERRLOG_PTR
:
960 if (tlv_len
!= sizeof(u32
))
961 goto invalid_tlv_len
;
962 pieces
->inst_errlog_ptr
=
963 le32_to_cpup((__le32
*)tlv_data
);
965 case IWL_UCODE_TLV_ENHANCE_SENS_TBL
:
967 goto invalid_tlv_len
;
968 nic
->fw
.enhance_sensitivity_table
= true;
970 case IWL_UCODE_TLV_WOWLAN_INST
:
971 pieces
->wowlan_inst
= tlv_data
;
972 pieces
->wowlan_inst_size
= tlv_len
;
974 case IWL_UCODE_TLV_WOWLAN_DATA
:
975 pieces
->wowlan_data
= tlv_data
;
976 pieces
->wowlan_data_size
= tlv_len
;
978 case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE
:
979 if (tlv_len
!= sizeof(u32
))
980 goto invalid_tlv_len
;
981 capa
->standard_phy_calibration_size
=
982 le32_to_cpup((__le32
*)tlv_data
);
985 IWL_DEBUG_INFO(nic
, "unknown TLV: %d\n", tlv_type
);
991 IWL_ERR(nic
, "invalid TLV after parsing: %zd\n", len
);
992 iwl_print_hex_dump(nic
, IWL_DL_FW
, (u8
*)data
, len
);
999 IWL_ERR(nic
, "TLV %d has invalid size: %u\n", tlv_type
, tlv_len
);
1000 iwl_print_hex_dump(nic
, IWL_DL_FW
, tlv_data
, tlv_len
);
1006 * iwl_ucode_callback - callback when firmware was loaded
1008 * If loaded successfully, copies the firmware into buffers
1009 * for the card to fetch (via DMA).
1011 static void iwl_ucode_callback(const struct firmware
*ucode_raw
, void *context
)
1013 struct iwl_nic
*nic
= context
;
1014 struct iwl_cfg
*cfg
= cfg(nic
);
1015 struct iwl_priv
*priv
= priv(nic
); /* temporary */
1016 struct iwl_ucode_header
*ucode
;
1018 struct iwlagn_firmware_pieces pieces
;
1019 const unsigned int api_max
= cfg
->ucode_api_max
;
1020 unsigned int api_ok
= cfg
->ucode_api_ok
;
1021 const unsigned int api_min
= cfg
->ucode_api_min
;
1025 struct iwlagn_ucode_capabilities ucode_capa
= {
1026 .max_probe_length
= 200,
1027 .standard_phy_calibration_size
=
1028 IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE
,
1034 memset(&pieces
, 0, sizeof(pieces
));
1037 if (nic
->fw_index
<= api_ok
)
1039 "request for firmware file '%s' failed.\n",
1040 nic
->firmware_name
);
1044 IWL_DEBUG_INFO(nic
, "Loaded firmware file '%s' (%zd bytes).\n",
1045 nic
->firmware_name
, ucode_raw
->size
);
1047 /* Make sure that we got at least the API version number */
1048 if (ucode_raw
->size
< 4) {
1049 IWL_ERR(nic
, "File size way too small!\n");
1053 /* Data from ucode file: header followed by uCode images */
1054 ucode
= (struct iwl_ucode_header
*)ucode_raw
->data
;
1057 err
= iwl_parse_v1_v2_firmware(nic
, ucode_raw
, &pieces
);
1059 err
= iwl_parse_tlv_firmware(nic
, ucode_raw
, &pieces
,
1065 api_ver
= IWL_UCODE_API(nic
->fw
.ucode_ver
);
1066 build
= pieces
.build
;
1069 * api_ver should match the api version forming part of the
1070 * firmware filename ... but we don't check for that and only rely
1071 * on the API version read from firmware header from here on forward
1073 /* no api version check required for experimental uCode */
1074 if (nic
->fw_index
!= UCODE_EXPERIMENTAL_INDEX
) {
1075 if (api_ver
< api_min
|| api_ver
> api_max
) {
1077 "Driver unable to support your firmware API. "
1078 "Driver supports v%u, firmware is v%u.\n",
1083 if (api_ver
< api_ok
) {
1084 if (api_ok
!= api_max
)
1085 IWL_ERR(nic
, "Firmware has old API version, "
1086 "expected v%u through v%u, got v%u.\n",
1087 api_ok
, api_max
, api_ver
);
1089 IWL_ERR(nic
, "Firmware has old API version, "
1090 "expected v%u, got v%u.\n",
1092 IWL_ERR(nic
, "New firmware can be obtained from "
1093 "http://www.intellinuxwireless.org/.\n");
1098 sprintf(buildstr
, " build %u%s", build
,
1099 (nic
->fw_index
== UCODE_EXPERIMENTAL_INDEX
)
1104 IWL_INFO(nic
, "loaded firmware version %u.%u.%u.%u%s\n",
1105 IWL_UCODE_MAJOR(nic
->fw
.ucode_ver
),
1106 IWL_UCODE_MINOR(nic
->fw
.ucode_ver
),
1107 IWL_UCODE_API(nic
->fw
.ucode_ver
),
1108 IWL_UCODE_SERIAL(nic
->fw
.ucode_ver
),
1111 snprintf(priv
->hw
->wiphy
->fw_version
,
1112 sizeof(priv
->hw
->wiphy
->fw_version
),
1114 IWL_UCODE_MAJOR(nic
->fw
.ucode_ver
),
1115 IWL_UCODE_MINOR(nic
->fw
.ucode_ver
),
1116 IWL_UCODE_API(nic
->fw
.ucode_ver
),
1117 IWL_UCODE_SERIAL(nic
->fw
.ucode_ver
),
1121 * For any of the failures below (before allocating pci memory)
1122 * we will try to load a version with a smaller API -- maybe the
1123 * user just got a corrupted version of the latest API.
1126 IWL_DEBUG_INFO(nic
, "f/w package hdr ucode version raw = 0x%x\n",
1128 IWL_DEBUG_INFO(nic
, "f/w package hdr runtime inst size = %Zd\n",
1130 IWL_DEBUG_INFO(nic
, "f/w package hdr runtime data size = %Zd\n",
1132 IWL_DEBUG_INFO(nic
, "f/w package hdr init inst size = %Zd\n",
1134 IWL_DEBUG_INFO(nic
, "f/w package hdr init data size = %Zd\n",
1135 pieces
.init_data_size
);
1137 /* Verify that uCode images will fit in card's SRAM */
1138 if (pieces
.inst_size
> hw_params(nic
).max_inst_size
) {
1139 IWL_ERR(nic
, "uCode instr len %Zd too large to fit in\n",
1144 if (pieces
.data_size
> hw_params(nic
).max_data_size
) {
1145 IWL_ERR(nic
, "uCode data len %Zd too large to fit in\n",
1150 if (pieces
.init_size
> hw_params(nic
).max_inst_size
) {
1151 IWL_ERR(nic
, "uCode init instr len %Zd too large to fit in\n",
1156 if (pieces
.init_data_size
> hw_params(nic
).max_data_size
) {
1157 IWL_ERR(nic
, "uCode init data len %Zd too large to fit in\n",
1158 pieces
.init_data_size
);
1162 /* Allocate ucode buffers for card's bus-master loading ... */
1164 /* Runtime instructions and 2 copies of data:
1165 * 1) unmodified from disk
1166 * 2) backup cache for save/restore during power-downs */
1167 if (iwl_alloc_fw_desc(nic
, &nic
->fw
.ucode_rt
.code
,
1168 pieces
.inst
, pieces
.inst_size
))
1170 if (iwl_alloc_fw_desc(nic
, &nic
->fw
.ucode_rt
.data
,
1171 pieces
.data
, pieces
.data_size
))
1174 /* Initialization instructions and data */
1175 if (pieces
.init_size
&& pieces
.init_data_size
) {
1176 if (iwl_alloc_fw_desc(nic
,
1177 &nic
->fw
.ucode_init
.code
,
1178 pieces
.init
, pieces
.init_size
))
1180 if (iwl_alloc_fw_desc(nic
,
1181 &nic
->fw
.ucode_init
.data
,
1182 pieces
.init_data
, pieces
.init_data_size
))
1186 /* WoWLAN instructions and data */
1187 if (pieces
.wowlan_inst_size
&& pieces
.wowlan_data_size
) {
1188 if (iwl_alloc_fw_desc(nic
,
1189 &nic
->fw
.ucode_wowlan
.code
,
1191 pieces
.wowlan_inst_size
))
1193 if (iwl_alloc_fw_desc(nic
,
1194 &nic
->fw
.ucode_wowlan
.data
,
1196 pieces
.wowlan_data_size
))
1200 /* Now that we can no longer fail, copy information */
1203 * The (size - 16) / 12 formula is based on the information recorded
1204 * for each event, which is of mode 1 (including timestamp) for all
1205 * new microcodes that include this information.
1207 nic
->init_evtlog_ptr
= pieces
.init_evtlog_ptr
;
1208 if (pieces
.init_evtlog_size
)
1209 nic
->init_evtlog_size
= (pieces
.init_evtlog_size
- 16)/12;
1211 nic
->init_evtlog_size
=
1212 cfg
->base_params
->max_event_log_size
;
1213 nic
->init_errlog_ptr
= pieces
.init_errlog_ptr
;
1214 nic
->inst_evtlog_ptr
= pieces
.inst_evtlog_ptr
;
1215 if (pieces
.inst_evtlog_size
)
1216 nic
->inst_evtlog_size
= (pieces
.inst_evtlog_size
- 16)/12;
1218 nic
->inst_evtlog_size
=
1219 cfg
->base_params
->max_event_log_size
;
1220 nic
->inst_errlog_ptr
= pieces
.inst_errlog_ptr
;
1221 #ifndef CONFIG_IWLWIFI_P2P
1222 ucode_capa
.flags
&= ~IWL_UCODE_TLV_FLAGS_PAN
;
1225 priv
->new_scan_threshold_behaviour
=
1226 !!(ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_NEWSCAN
);
1228 if (!(cfg
->sku
& EEPROM_SKU_CAP_IPAN_ENABLE
))
1229 ucode_capa
.flags
&= ~IWL_UCODE_TLV_FLAGS_PAN
;
1232 * if not PAN, then don't support P2P -- might be a uCode
1233 * packaging bug or due to the eeprom check above
1235 if (!(ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_PAN
))
1236 ucode_capa
.flags
&= ~IWL_UCODE_TLV_FLAGS_P2P
;
1238 if (ucode_capa
.flags
& IWL_UCODE_TLV_FLAGS_PAN
) {
1239 priv
->sta_key_max_num
= STA_KEY_MAX_NUM_PAN
;
1240 nic
->shrd
->cmd_queue
= IWL_IPAN_CMD_QUEUE_NUM
;
1242 priv
->sta_key_max_num
= STA_KEY_MAX_NUM
;
1243 nic
->shrd
->cmd_queue
= IWL_DEFAULT_CMD_QUEUE_NUM
;
1246 * figure out the offset of chain noise reset and gain commands
1247 * base on the size of standard phy calibration commands table size
1249 if (ucode_capa
.standard_phy_calibration_size
>
1250 IWL_MAX_PHY_CALIBRATE_TBL_SIZE
)
1251 ucode_capa
.standard_phy_calibration_size
=
1252 IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE
;
1254 priv
->phy_calib_chain_noise_reset_cmd
=
1255 ucode_capa
.standard_phy_calibration_size
;
1256 priv
->phy_calib_chain_noise_gain_cmd
=
1257 ucode_capa
.standard_phy_calibration_size
+ 1;
1259 /* initialize all valid contexts */
1260 iwl_init_context(priv
, ucode_capa
.flags
);
1262 /**************************************************
1263 * This is still part of probe() in a sense...
1265 * 9. Setup and register with mac80211 and debugfs
1266 **************************************************/
1267 err
= iwlagn_mac_setup_register(priv
, &ucode_capa
);
1271 err
= iwl_dbgfs_register(priv
, DRV_NAME
);
1274 "failed to create debugfs files. Ignoring error: %d\n",
1277 /* We have our copies now, allow OS release its copies */
1278 release_firmware(ucode_raw
);
1279 complete(&nic
->request_firmware_complete
);
1283 /* try next, if any */
1284 if (iwl_request_firmware(nic
, false))
1286 release_firmware(ucode_raw
);
1290 IWL_ERR(nic
, "failed to allocate pci memory\n");
1291 iwl_dealloc_ucode(nic
);
1293 complete(&nic
->request_firmware_complete
);
1294 device_release_driver(trans(nic
)->dev
);
1295 release_firmware(ucode_raw
);