Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * This file is provided under a dual BSD/GPLv2 license. When using or |
| 4 | * redistributing this file, you may do so under either license. |
| 5 | * |
| 6 | * GPL LICENSE SUMMARY |
| 7 | * |
| 8 | * Copyright(c) 2007 - 2012 Intel Corporation. All rights reserved. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of version 2 of the GNU General Public License as |
| 12 | * published by the Free Software Foundation. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, but |
| 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, |
| 22 | * USA |
| 23 | * |
| 24 | * The full GNU General Public License is included in this distribution |
| 25 | * in the file called LICENSE.GPL. |
| 26 | * |
| 27 | * Contact Information: |
| 28 | * Intel Linux Wireless <ilw@linux.intel.com> |
| 29 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 |
| 30 | * |
| 31 | * BSD LICENSE |
| 32 | * |
| 33 | * Copyright(c) 2005 - 2012 Intel Corporation. All rights reserved. |
| 34 | * All rights reserved. |
| 35 | * |
| 36 | * Redistribution and use in source and binary forms, with or without |
| 37 | * modification, are permitted provided that the following conditions |
| 38 | * are met: |
| 39 | * |
| 40 | * * Redistributions of source code must retain the above copyright |
| 41 | * notice, this list of conditions and the following disclaimer. |
| 42 | * * Redistributions in binary form must reproduce the above copyright |
| 43 | * notice, this list of conditions and the following disclaimer in |
| 44 | * the documentation and/or other materials provided with the |
| 45 | * distribution. |
| 46 | * * Neither the name Intel Corporation nor the names of its |
| 47 | * contributors may be used to endorse or promote products derived |
| 48 | * from this software without specific prior written permission. |
| 49 | * |
| 50 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 51 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 52 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 53 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 54 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 55 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 56 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 57 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 58 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 59 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 60 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 61 | * |
| 62 | *****************************************************************************/ |
| 63 | #include <linux/completion.h> |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 64 | #include <linux/dma-mapping.h> |
| 65 | #include <linux/firmware.h> |
| 66 | #include <linux/module.h> |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 67 | |
| 68 | #include "iwl-drv.h" |
| 69 | #include "iwl-trans.h" |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 70 | #include "iwl-shared.h" |
Emmanuel Grumbach | d0f76d6 | 2012-02-09 16:08:15 +0200 | [diff] [blame] | 71 | #include "iwl-op-mode.h" |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 72 | #include "iwl-agn-hw.h" |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 73 | |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 74 | /* private includes */ |
Johannes Berg | 3995dea | 2012-03-06 13:30:44 -0800 | [diff] [blame] | 75 | #include "iwl-fw-file.h" |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 76 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 77 | /** |
| 78 | * struct iwl_drv - drv common data |
| 79 | * @fw: the iwl_fw structure |
| 80 | * @shrd: pointer to common shared structure |
| 81 | * @op_mode: the running op_mode |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 82 | * @trans: transport layer |
| 83 | * @cfg: configuration struct |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 84 | * @fw_index: firmware revision to try loading |
| 85 | * @firmware_name: composite filename of ucode file to load |
| 86 | * @request_firmware_complete: the firmware has been obtained from user space |
| 87 | */ |
| 88 | struct iwl_drv { |
| 89 | struct iwl_fw fw; |
| 90 | |
| 91 | struct iwl_shared *shrd; |
| 92 | struct iwl_op_mode *op_mode; |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 93 | struct iwl_trans *trans; |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 94 | const struct iwl_cfg *cfg; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 95 | |
| 96 | int fw_index; /* firmware we're trying to load */ |
| 97 | char firmware_name[25]; /* name of firmware file to load */ |
| 98 | |
| 99 | struct completion request_firmware_complete; |
| 100 | }; |
| 101 | |
| 102 | |
| 103 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 104 | /* |
| 105 | * struct fw_sec: Just for the image parsing proccess. |
| 106 | * For the fw storage we are using struct fw_desc. |
| 107 | */ |
| 108 | struct fw_sec { |
| 109 | const void *data; /* the sec data */ |
| 110 | size_t size; /* section size */ |
| 111 | u32 offset; /* offset of writing in the device */ |
| 112 | }; |
| 113 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 114 | static void iwl_free_fw_desc(struct iwl_drv *drv, struct fw_desc *desc) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 115 | { |
| 116 | if (desc->v_addr) |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 117 | dma_free_coherent(trans(drv)->dev, desc->len, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 118 | desc->v_addr, desc->p_addr); |
| 119 | desc->v_addr = NULL; |
| 120 | desc->len = 0; |
| 121 | } |
| 122 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 123 | static void iwl_free_fw_img(struct iwl_drv *drv, struct fw_img *img) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 124 | { |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 125 | int i; |
| 126 | for (i = 0; i < IWL_UCODE_SECTION_MAX; i++) |
| 127 | iwl_free_fw_desc(drv, &img->sec[i]); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 128 | } |
| 129 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 130 | static void iwl_dealloc_ucode(struct iwl_drv *drv) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 131 | { |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 132 | int i; |
| 133 | for (i = 0; i < IWL_UCODE_TYPE_MAX; i++) |
| 134 | iwl_free_fw_img(drv, drv->fw.img + i); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 135 | } |
| 136 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 137 | static int iwl_alloc_fw_desc(struct iwl_drv *drv, struct fw_desc *desc, |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 138 | struct fw_sec *sec) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 139 | { |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 140 | if (!sec || !sec->size) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 141 | desc->v_addr = NULL; |
| 142 | return -EINVAL; |
| 143 | } |
| 144 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 145 | desc->v_addr = dma_alloc_coherent(trans(drv)->dev, sec->size, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 146 | &desc->p_addr, GFP_KERNEL); |
| 147 | if (!desc->v_addr) |
| 148 | return -ENOMEM; |
| 149 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 150 | desc->len = sec->size; |
| 151 | desc->offset = sec->offset; |
| 152 | memcpy(desc->v_addr, sec->data, sec->size); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 153 | return 0; |
| 154 | } |
| 155 | |
| 156 | static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context); |
| 157 | |
| 158 | #define UCODE_EXPERIMENTAL_INDEX 100 |
| 159 | #define UCODE_EXPERIMENTAL_TAG "exp" |
| 160 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 161 | static int iwl_request_firmware(struct iwl_drv *drv, bool first) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 162 | { |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 163 | const char *name_pre = drv->cfg->fw_name_pre; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 164 | char tag[8]; |
| 165 | |
| 166 | if (first) { |
| 167 | #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 168 | drv->fw_index = UCODE_EXPERIMENTAL_INDEX; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 169 | strcpy(tag, UCODE_EXPERIMENTAL_TAG); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 170 | } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 171 | #endif |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 172 | drv->fw_index = drv->cfg->ucode_api_max; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 173 | sprintf(tag, "%d", drv->fw_index); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 174 | } else { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 175 | drv->fw_index--; |
| 176 | sprintf(tag, "%d", drv->fw_index); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 177 | } |
| 178 | |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 179 | if (drv->fw_index < drv->cfg->ucode_api_min) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 180 | IWL_ERR(drv, "no suitable firmware found!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 181 | return -ENOENT; |
| 182 | } |
| 183 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 184 | sprintf(drv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 185 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 186 | IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n", |
| 187 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 188 | ? "EXPERIMENTAL " : "", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 189 | drv->firmware_name); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 190 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 191 | return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name, |
| 192 | trans(drv)->dev, |
| 193 | GFP_KERNEL, drv, iwl_ucode_callback); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 194 | } |
| 195 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 196 | struct fw_img_parsing { |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 197 | struct fw_sec sec[IWL_UCODE_SECTION_MAX]; |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 198 | int sec_counter; |
| 199 | }; |
| 200 | |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 201 | /* |
| 202 | * struct fw_sec_parsing: to extract fw section and it's offset from tlv |
| 203 | */ |
| 204 | struct fw_sec_parsing { |
| 205 | __le32 offset; |
| 206 | const u8 data[]; |
| 207 | } __packed; |
| 208 | |
| 209 | /** |
| 210 | * struct iwl_tlv_calib_data - parse the default calib data from TLV |
| 211 | * |
| 212 | * @ucode_type: the uCode to which the following default calib relates. |
| 213 | * @calib: default calibrations. |
| 214 | */ |
| 215 | struct iwl_tlv_calib_data { |
| 216 | __le32 ucode_type; |
| 217 | __le64 calib; |
| 218 | } __packed; |
| 219 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 220 | struct iwl_firmware_pieces { |
| 221 | struct fw_img_parsing img[IWL_UCODE_TYPE_MAX]; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 222 | |
| 223 | u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; |
| 224 | u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; |
| 225 | }; |
| 226 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 227 | /* |
| 228 | * These functions are just to extract uCode section data from the pieces |
| 229 | * structure. |
| 230 | */ |
| 231 | static struct fw_sec *get_sec(struct iwl_firmware_pieces *pieces, |
| 232 | enum iwl_ucode_type type, |
| 233 | int sec) |
| 234 | { |
| 235 | return &pieces->img[type].sec[sec]; |
| 236 | } |
| 237 | |
| 238 | static void set_sec_data(struct iwl_firmware_pieces *pieces, |
| 239 | enum iwl_ucode_type type, |
| 240 | int sec, |
| 241 | const void *data) |
| 242 | { |
| 243 | pieces->img[type].sec[sec].data = data; |
| 244 | } |
| 245 | |
| 246 | static void set_sec_size(struct iwl_firmware_pieces *pieces, |
| 247 | enum iwl_ucode_type type, |
| 248 | int sec, |
| 249 | size_t size) |
| 250 | { |
| 251 | pieces->img[type].sec[sec].size = size; |
| 252 | } |
| 253 | |
| 254 | static size_t get_sec_size(struct iwl_firmware_pieces *pieces, |
| 255 | enum iwl_ucode_type type, |
| 256 | int sec) |
| 257 | { |
| 258 | return pieces->img[type].sec[sec].size; |
| 259 | } |
| 260 | |
| 261 | static void set_sec_offset(struct iwl_firmware_pieces *pieces, |
| 262 | enum iwl_ucode_type type, |
| 263 | int sec, |
| 264 | u32 offset) |
| 265 | { |
| 266 | pieces->img[type].sec[sec].offset = offset; |
| 267 | } |
| 268 | |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 269 | /* |
| 270 | * Gets uCode section from tlv. |
| 271 | */ |
| 272 | static int iwl_store_ucode_sec(struct iwl_firmware_pieces *pieces, |
| 273 | const void *data, enum iwl_ucode_type type, |
| 274 | int size) |
| 275 | { |
| 276 | struct fw_img_parsing *img; |
| 277 | struct fw_sec *sec; |
| 278 | struct fw_sec_parsing *sec_parse; |
| 279 | |
| 280 | if (WARN_ON(!pieces || !data || type >= IWL_UCODE_TYPE_MAX)) |
| 281 | return -1; |
| 282 | |
| 283 | sec_parse = (struct fw_sec_parsing *)data; |
| 284 | |
| 285 | img = &pieces->img[type]; |
| 286 | sec = &img->sec[img->sec_counter]; |
| 287 | |
| 288 | sec->offset = le32_to_cpu(sec_parse->offset); |
| 289 | sec->data = sec_parse->data; |
David Spinadel | 1176f43 | 2012-03-13 14:32:48 +0200 | [diff] [blame] | 290 | sec->size = size - sizeof(sec_parse->offset); |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 291 | |
| 292 | ++img->sec_counter; |
| 293 | |
| 294 | return 0; |
| 295 | } |
| 296 | |
| 297 | static int iwl_set_default_calib(struct iwl_drv *drv, const u8 *data) |
| 298 | { |
| 299 | struct iwl_tlv_calib_data *def_calib = |
| 300 | (struct iwl_tlv_calib_data *)data; |
| 301 | u32 ucode_type = le32_to_cpu(def_calib->ucode_type); |
| 302 | if (ucode_type >= IWL_UCODE_TYPE_MAX) { |
| 303 | IWL_ERR(drv, "Wrong ucode_type %u for default calibration.\n", |
| 304 | ucode_type); |
| 305 | return -EINVAL; |
| 306 | } |
| 307 | drv->fw.default_calib[ucode_type] = le64_to_cpu(def_calib->calib); |
| 308 | return 0; |
| 309 | } |
| 310 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 311 | static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 312 | const struct firmware *ucode_raw, |
| 313 | struct iwl_firmware_pieces *pieces) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 314 | { |
| 315 | struct iwl_ucode_header *ucode = (void *)ucode_raw->data; |
| 316 | u32 api_ver, hdr_size, build; |
| 317 | char buildstr[25]; |
| 318 | const u8 *src; |
| 319 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 320 | drv->fw.ucode_ver = le32_to_cpu(ucode->ver); |
| 321 | api_ver = IWL_UCODE_API(drv->fw.ucode_ver); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 322 | |
| 323 | switch (api_ver) { |
| 324 | default: |
| 325 | hdr_size = 28; |
| 326 | if (ucode_raw->size < hdr_size) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 327 | IWL_ERR(drv, "File size too small!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 328 | return -EINVAL; |
| 329 | } |
| 330 | build = le32_to_cpu(ucode->u.v2.build); |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 331 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
| 332 | le32_to_cpu(ucode->u.v2.inst_size)); |
| 333 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, |
| 334 | le32_to_cpu(ucode->u.v2.data_size)); |
| 335 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, |
| 336 | le32_to_cpu(ucode->u.v2.init_size)); |
| 337 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, |
| 338 | le32_to_cpu(ucode->u.v2.init_data_size)); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 339 | src = ucode->u.v2.data; |
| 340 | break; |
| 341 | case 0: |
| 342 | case 1: |
| 343 | case 2: |
| 344 | hdr_size = 24; |
| 345 | if (ucode_raw->size < hdr_size) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 346 | IWL_ERR(drv, "File size too small!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 347 | return -EINVAL; |
| 348 | } |
| 349 | build = 0; |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 350 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
| 351 | le32_to_cpu(ucode->u.v1.inst_size)); |
| 352 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, |
| 353 | le32_to_cpu(ucode->u.v1.data_size)); |
| 354 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, |
| 355 | le32_to_cpu(ucode->u.v1.init_size)); |
| 356 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, |
| 357 | le32_to_cpu(ucode->u.v1.init_data_size)); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 358 | src = ucode->u.v1.data; |
| 359 | break; |
| 360 | } |
| 361 | |
| 362 | if (build) |
| 363 | sprintf(buildstr, " build %u%s", build, |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 364 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 365 | ? " (EXP)" : ""); |
| 366 | else |
| 367 | buildstr[0] = '\0'; |
| 368 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 369 | snprintf(drv->fw.fw_version, |
| 370 | sizeof(drv->fw.fw_version), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 371 | "%u.%u.%u.%u%s", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 372 | IWL_UCODE_MAJOR(drv->fw.ucode_ver), |
| 373 | IWL_UCODE_MINOR(drv->fw.ucode_ver), |
| 374 | IWL_UCODE_API(drv->fw.ucode_ver), |
| 375 | IWL_UCODE_SERIAL(drv->fw.ucode_ver), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 376 | buildstr); |
| 377 | |
| 378 | /* Verify size of file vs. image size info in file's header */ |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 379 | |
| 380 | if (ucode_raw->size != hdr_size + |
| 381 | get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) + |
| 382 | get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) + |
| 383 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) + |
| 384 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 385 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 386 | IWL_ERR(drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 387 | "uCode file size %d does not match expected size\n", |
| 388 | (int)ucode_raw->size); |
| 389 | return -EINVAL; |
| 390 | } |
| 391 | |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 392 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 393 | set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, src); |
| 394 | src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST); |
| 395 | set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
| 396 | IWLAGN_RTC_INST_LOWER_BOUND); |
| 397 | set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, src); |
| 398 | src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA); |
| 399 | set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, |
| 400 | IWLAGN_RTC_DATA_LOWER_BOUND); |
| 401 | set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, src); |
| 402 | src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST); |
| 403 | set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, |
| 404 | IWLAGN_RTC_INST_LOWER_BOUND); |
| 405 | set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, src); |
| 406 | src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA); |
| 407 | set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, |
| 408 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 409 | return 0; |
| 410 | } |
| 411 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 412 | static int iwl_parse_tlv_firmware(struct iwl_drv *drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 413 | const struct firmware *ucode_raw, |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 414 | struct iwl_firmware_pieces *pieces, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 415 | struct iwl_ucode_capabilities *capa) |
| 416 | { |
| 417 | struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; |
| 418 | struct iwl_ucode_tlv *tlv; |
| 419 | size_t len = ucode_raw->size; |
| 420 | const u8 *data; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 421 | u32 tlv_len; |
| 422 | enum iwl_ucode_tlv_type tlv_type; |
| 423 | const u8 *tlv_data; |
| 424 | char buildstr[25]; |
| 425 | u32 build; |
| 426 | |
| 427 | if (len < sizeof(*ucode)) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 428 | IWL_ERR(drv, "uCode has invalid length: %zd\n", len); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 429 | return -EINVAL; |
| 430 | } |
| 431 | |
| 432 | if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 433 | IWL_ERR(drv, "invalid uCode magic: 0X%x\n", |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 434 | le32_to_cpu(ucode->magic)); |
| 435 | return -EINVAL; |
| 436 | } |
| 437 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 438 | drv->fw.ucode_ver = le32_to_cpu(ucode->ver); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 439 | build = le32_to_cpu(ucode->build); |
| 440 | |
| 441 | if (build) |
| 442 | sprintf(buildstr, " build %u%s", build, |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 443 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 444 | ? " (EXP)" : ""); |
| 445 | else |
| 446 | buildstr[0] = '\0'; |
| 447 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 448 | snprintf(drv->fw.fw_version, |
| 449 | sizeof(drv->fw.fw_version), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 450 | "%u.%u.%u.%u%s", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 451 | IWL_UCODE_MAJOR(drv->fw.ucode_ver), |
| 452 | IWL_UCODE_MINOR(drv->fw.ucode_ver), |
| 453 | IWL_UCODE_API(drv->fw.ucode_ver), |
| 454 | IWL_UCODE_SERIAL(drv->fw.ucode_ver), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 455 | buildstr); |
| 456 | |
| 457 | data = ucode->data; |
| 458 | |
| 459 | len -= sizeof(*ucode); |
| 460 | |
| 461 | while (len >= sizeof(*tlv)) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 462 | len -= sizeof(*tlv); |
| 463 | tlv = (void *)data; |
| 464 | |
| 465 | tlv_len = le32_to_cpu(tlv->length); |
Johannes Berg | 0479c19 | 2012-03-09 09:16:35 +0100 | [diff] [blame] | 466 | tlv_type = le32_to_cpu(tlv->type); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 467 | tlv_data = tlv->data; |
| 468 | |
| 469 | if (len < tlv_len) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 470 | IWL_ERR(drv, "invalid TLV len: %zd/%u\n", |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 471 | len, tlv_len); |
| 472 | return -EINVAL; |
| 473 | } |
| 474 | len -= ALIGN(tlv_len, 4); |
| 475 | data += sizeof(*tlv) + ALIGN(tlv_len, 4); |
| 476 | |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 477 | switch (tlv_type) { |
| 478 | case IWL_UCODE_TLV_INST: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 479 | set_sec_data(pieces, IWL_UCODE_REGULAR, |
| 480 | IWL_UCODE_SECTION_INST, tlv_data); |
| 481 | set_sec_size(pieces, IWL_UCODE_REGULAR, |
| 482 | IWL_UCODE_SECTION_INST, tlv_len); |
| 483 | set_sec_offset(pieces, IWL_UCODE_REGULAR, |
| 484 | IWL_UCODE_SECTION_INST, |
| 485 | IWLAGN_RTC_INST_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 486 | break; |
| 487 | case IWL_UCODE_TLV_DATA: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 488 | set_sec_data(pieces, IWL_UCODE_REGULAR, |
| 489 | IWL_UCODE_SECTION_DATA, tlv_data); |
| 490 | set_sec_size(pieces, IWL_UCODE_REGULAR, |
| 491 | IWL_UCODE_SECTION_DATA, tlv_len); |
| 492 | set_sec_offset(pieces, IWL_UCODE_REGULAR, |
| 493 | IWL_UCODE_SECTION_DATA, |
| 494 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 495 | break; |
| 496 | case IWL_UCODE_TLV_INIT: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 497 | set_sec_data(pieces, IWL_UCODE_INIT, |
| 498 | IWL_UCODE_SECTION_INST, tlv_data); |
| 499 | set_sec_size(pieces, IWL_UCODE_INIT, |
| 500 | IWL_UCODE_SECTION_INST, tlv_len); |
| 501 | set_sec_offset(pieces, IWL_UCODE_INIT, |
| 502 | IWL_UCODE_SECTION_INST, |
| 503 | IWLAGN_RTC_INST_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 504 | break; |
| 505 | case IWL_UCODE_TLV_INIT_DATA: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 506 | set_sec_data(pieces, IWL_UCODE_INIT, |
| 507 | IWL_UCODE_SECTION_DATA, tlv_data); |
| 508 | set_sec_size(pieces, IWL_UCODE_INIT, |
| 509 | IWL_UCODE_SECTION_DATA, tlv_len); |
| 510 | set_sec_offset(pieces, IWL_UCODE_INIT, |
| 511 | IWL_UCODE_SECTION_DATA, |
| 512 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 513 | break; |
| 514 | case IWL_UCODE_TLV_BOOT: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 515 | IWL_ERR(drv, "Found unexpected BOOT ucode\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 516 | break; |
| 517 | case IWL_UCODE_TLV_PROBE_MAX_LEN: |
| 518 | if (tlv_len != sizeof(u32)) |
| 519 | goto invalid_tlv_len; |
| 520 | capa->max_probe_length = |
| 521 | le32_to_cpup((__le32 *)tlv_data); |
| 522 | break; |
| 523 | case IWL_UCODE_TLV_PAN: |
| 524 | if (tlv_len) |
| 525 | goto invalid_tlv_len; |
| 526 | capa->flags |= IWL_UCODE_TLV_FLAGS_PAN; |
| 527 | break; |
| 528 | case IWL_UCODE_TLV_FLAGS: |
| 529 | /* must be at least one u32 */ |
| 530 | if (tlv_len < sizeof(u32)) |
| 531 | goto invalid_tlv_len; |
| 532 | /* and a proper number of u32s */ |
| 533 | if (tlv_len % sizeof(u32)) |
| 534 | goto invalid_tlv_len; |
| 535 | /* |
| 536 | * This driver only reads the first u32 as |
| 537 | * right now no more features are defined, |
| 538 | * if that changes then either the driver |
| 539 | * will not work with the new firmware, or |
| 540 | * it'll not take advantage of new features. |
| 541 | */ |
| 542 | capa->flags = le32_to_cpup((__le32 *)tlv_data); |
| 543 | break; |
| 544 | case IWL_UCODE_TLV_INIT_EVTLOG_PTR: |
| 545 | if (tlv_len != sizeof(u32)) |
| 546 | goto invalid_tlv_len; |
| 547 | pieces->init_evtlog_ptr = |
| 548 | le32_to_cpup((__le32 *)tlv_data); |
| 549 | break; |
| 550 | case IWL_UCODE_TLV_INIT_EVTLOG_SIZE: |
| 551 | if (tlv_len != sizeof(u32)) |
| 552 | goto invalid_tlv_len; |
| 553 | pieces->init_evtlog_size = |
| 554 | le32_to_cpup((__le32 *)tlv_data); |
| 555 | break; |
| 556 | case IWL_UCODE_TLV_INIT_ERRLOG_PTR: |
| 557 | if (tlv_len != sizeof(u32)) |
| 558 | goto invalid_tlv_len; |
| 559 | pieces->init_errlog_ptr = |
| 560 | le32_to_cpup((__le32 *)tlv_data); |
| 561 | break; |
| 562 | case IWL_UCODE_TLV_RUNT_EVTLOG_PTR: |
| 563 | if (tlv_len != sizeof(u32)) |
| 564 | goto invalid_tlv_len; |
| 565 | pieces->inst_evtlog_ptr = |
| 566 | le32_to_cpup((__le32 *)tlv_data); |
| 567 | break; |
| 568 | case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE: |
| 569 | if (tlv_len != sizeof(u32)) |
| 570 | goto invalid_tlv_len; |
| 571 | pieces->inst_evtlog_size = |
| 572 | le32_to_cpup((__le32 *)tlv_data); |
| 573 | break; |
| 574 | case IWL_UCODE_TLV_RUNT_ERRLOG_PTR: |
| 575 | if (tlv_len != sizeof(u32)) |
| 576 | goto invalid_tlv_len; |
| 577 | pieces->inst_errlog_ptr = |
| 578 | le32_to_cpup((__le32 *)tlv_data); |
| 579 | break; |
| 580 | case IWL_UCODE_TLV_ENHANCE_SENS_TBL: |
| 581 | if (tlv_len) |
| 582 | goto invalid_tlv_len; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 583 | drv->fw.enhance_sensitivity_table = true; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 584 | break; |
| 585 | case IWL_UCODE_TLV_WOWLAN_INST: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 586 | set_sec_data(pieces, IWL_UCODE_WOWLAN, |
| 587 | IWL_UCODE_SECTION_INST, tlv_data); |
| 588 | set_sec_size(pieces, IWL_UCODE_WOWLAN, |
| 589 | IWL_UCODE_SECTION_INST, tlv_len); |
| 590 | set_sec_offset(pieces, IWL_UCODE_WOWLAN, |
| 591 | IWL_UCODE_SECTION_INST, |
| 592 | IWLAGN_RTC_INST_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 593 | break; |
| 594 | case IWL_UCODE_TLV_WOWLAN_DATA: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 595 | set_sec_data(pieces, IWL_UCODE_WOWLAN, |
| 596 | IWL_UCODE_SECTION_DATA, tlv_data); |
| 597 | set_sec_size(pieces, IWL_UCODE_WOWLAN, |
| 598 | IWL_UCODE_SECTION_DATA, tlv_len); |
| 599 | set_sec_offset(pieces, IWL_UCODE_WOWLAN, |
| 600 | IWL_UCODE_SECTION_DATA, |
| 601 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 602 | break; |
| 603 | case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: |
| 604 | if (tlv_len != sizeof(u32)) |
| 605 | goto invalid_tlv_len; |
| 606 | capa->standard_phy_calibration_size = |
| 607 | le32_to_cpup((__le32 *)tlv_data); |
| 608 | break; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 609 | case IWL_UCODE_TLV_SEC_RT: |
| 610 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR, |
| 611 | tlv_len); |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 612 | drv->fw.mvm_fw = true; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 613 | break; |
| 614 | case IWL_UCODE_TLV_SEC_INIT: |
| 615 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT, |
| 616 | tlv_len); |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 617 | drv->fw.mvm_fw = true; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 618 | break; |
| 619 | case IWL_UCODE_TLV_SEC_WOWLAN: |
| 620 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN, |
| 621 | tlv_len); |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 622 | drv->fw.mvm_fw = true; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 623 | break; |
| 624 | case IWL_UCODE_TLV_DEF_CALIB: |
| 625 | if (tlv_len != sizeof(struct iwl_tlv_calib_data)) |
| 626 | goto invalid_tlv_len; |
| 627 | if (iwl_set_default_calib(drv, tlv_data)) |
| 628 | goto tlv_error; |
| 629 | break; |
| 630 | case IWL_UCODE_TLV_PHY_SKU: |
| 631 | if (tlv_len != sizeof(u32)) |
| 632 | goto invalid_tlv_len; |
| 633 | drv->fw.phy_config = le32_to_cpup((__le32 *)tlv_data); |
| 634 | break; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 635 | default: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 636 | IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 637 | break; |
| 638 | } |
| 639 | } |
| 640 | |
| 641 | if (len) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 642 | IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len); |
| 643 | iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 644 | return -EINVAL; |
| 645 | } |
| 646 | |
| 647 | return 0; |
| 648 | |
| 649 | invalid_tlv_len: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 650 | IWL_ERR(drv, "TLV %d has invalid size: %u\n", tlv_type, tlv_len); |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 651 | tlv_error: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 652 | iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 653 | |
| 654 | return -EINVAL; |
| 655 | } |
| 656 | |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 657 | static int alloc_pci_desc(struct iwl_drv *drv, |
| 658 | struct iwl_firmware_pieces *pieces, |
| 659 | enum iwl_ucode_type type) |
| 660 | { |
| 661 | int i; |
| 662 | for (i = 0; |
| 663 | i < IWL_UCODE_SECTION_MAX && get_sec_size(pieces, type, i); |
| 664 | i++) |
| 665 | if (iwl_alloc_fw_desc(drv, &(drv->fw.img[type].sec[i]), |
| 666 | get_sec(pieces, type, i))) |
| 667 | return -1; |
| 668 | return 0; |
| 669 | } |
| 670 | |
| 671 | static int validate_sec_sizes(struct iwl_drv *drv, |
| 672 | struct iwl_firmware_pieces *pieces, |
| 673 | const struct iwl_cfg *cfg) |
| 674 | { |
| 675 | IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n", |
| 676 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 677 | IWL_UCODE_SECTION_INST)); |
| 678 | IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n", |
| 679 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 680 | IWL_UCODE_SECTION_DATA)); |
| 681 | IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n", |
| 682 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST)); |
| 683 | IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n", |
| 684 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)); |
| 685 | |
| 686 | /* Verify that uCode images will fit in card's SRAM. */ |
| 687 | if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) > |
| 688 | cfg->max_inst_size) { |
| 689 | IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n", |
| 690 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 691 | IWL_UCODE_SECTION_INST)); |
| 692 | return -1; |
| 693 | } |
| 694 | |
| 695 | if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) > |
| 696 | cfg->max_data_size) { |
| 697 | IWL_ERR(drv, "uCode data len %Zd too large to fit in\n", |
| 698 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 699 | IWL_UCODE_SECTION_DATA)); |
| 700 | return -1; |
| 701 | } |
| 702 | |
| 703 | if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) > |
| 704 | cfg->max_inst_size) { |
| 705 | IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n", |
| 706 | get_sec_size(pieces, IWL_UCODE_INIT, |
| 707 | IWL_UCODE_SECTION_INST)); |
| 708 | return -1; |
| 709 | } |
| 710 | |
| 711 | if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) > |
| 712 | cfg->max_data_size) { |
| 713 | IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n", |
| 714 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 715 | IWL_UCODE_SECTION_DATA)); |
| 716 | return -1; |
| 717 | } |
| 718 | return 0; |
| 719 | } |
| 720 | |
| 721 | |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 722 | /** |
| 723 | * iwl_ucode_callback - callback when firmware was loaded |
| 724 | * |
| 725 | * If loaded successfully, copies the firmware into buffers |
| 726 | * for the card to fetch (via DMA). |
| 727 | */ |
| 728 | static void iwl_ucode_callback(const struct firmware *ucode_raw, void *context) |
| 729 | { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 730 | struct iwl_drv *drv = context; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 731 | struct iwl_fw *fw = &drv->fw; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 732 | struct iwl_ucode_header *ucode; |
| 733 | int err; |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 734 | struct iwl_firmware_pieces pieces; |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 735 | const unsigned int api_max = drv->cfg->ucode_api_max; |
| 736 | unsigned int api_ok = drv->cfg->ucode_api_ok; |
| 737 | const unsigned int api_min = drv->cfg->ucode_api_min; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 738 | u32 api_ver; |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 739 | int i; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 740 | |
| 741 | fw->ucode_capa.max_probe_length = 200; |
| 742 | fw->ucode_capa.standard_phy_calibration_size = |
| 743 | IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; |
| 744 | |
| 745 | if (!api_ok) |
| 746 | api_ok = api_max; |
| 747 | |
| 748 | memset(&pieces, 0, sizeof(pieces)); |
| 749 | |
| 750 | if (!ucode_raw) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 751 | if (drv->fw_index <= api_ok) |
| 752 | IWL_ERR(drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 753 | "request for firmware file '%s' failed.\n", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 754 | drv->firmware_name); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 755 | goto try_again; |
| 756 | } |
| 757 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 758 | IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n", |
| 759 | drv->firmware_name, ucode_raw->size); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 760 | |
| 761 | /* Make sure that we got at least the API version number */ |
| 762 | if (ucode_raw->size < 4) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 763 | IWL_ERR(drv, "File size way too small!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 764 | goto try_again; |
| 765 | } |
| 766 | |
| 767 | /* Data from ucode file: header followed by uCode images */ |
| 768 | ucode = (struct iwl_ucode_header *)ucode_raw->data; |
| 769 | |
| 770 | if (ucode->ver) |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 771 | err = iwl_parse_v1_v2_firmware(drv, ucode_raw, &pieces); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 772 | else |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 773 | err = iwl_parse_tlv_firmware(drv, ucode_raw, &pieces, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 774 | &fw->ucode_capa); |
| 775 | |
| 776 | if (err) |
| 777 | goto try_again; |
| 778 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 779 | api_ver = IWL_UCODE_API(drv->fw.ucode_ver); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 780 | |
| 781 | /* |
| 782 | * api_ver should match the api version forming part of the |
| 783 | * firmware filename ... but we don't check for that and only rely |
| 784 | * on the API version read from firmware header from here on forward |
| 785 | */ |
| 786 | /* no api version check required for experimental uCode */ |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 787 | if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 788 | if (api_ver < api_min || api_ver > api_max) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 789 | IWL_ERR(drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 790 | "Driver unable to support your firmware API. " |
| 791 | "Driver supports v%u, firmware is v%u.\n", |
| 792 | api_max, api_ver); |
| 793 | goto try_again; |
| 794 | } |
| 795 | |
| 796 | if (api_ver < api_ok) { |
| 797 | if (api_ok != api_max) |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 798 | IWL_ERR(drv, "Firmware has old API version, " |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 799 | "expected v%u through v%u, got v%u.\n", |
| 800 | api_ok, api_max, api_ver); |
| 801 | else |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 802 | IWL_ERR(drv, "Firmware has old API version, " |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 803 | "expected v%u, got v%u.\n", |
| 804 | api_max, api_ver); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 805 | IWL_ERR(drv, "New firmware can be obtained from " |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 806 | "http://www.intellinuxwireless.org/.\n"); |
| 807 | } |
| 808 | } |
| 809 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 810 | IWL_INFO(drv, "loaded firmware version %s", drv->fw.fw_version); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 811 | |
| 812 | /* |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 813 | * In mvm uCode there is no difference between data and instructions |
| 814 | * sections. |
| 815 | */ |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 816 | if (!fw->mvm_fw && validate_sec_sizes(drv, &pieces, drv->cfg)) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 817 | goto try_again; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 818 | |
| 819 | /* Allocate ucode buffers for card's bus-master loading ... */ |
| 820 | |
| 821 | /* Runtime instructions and 2 copies of data: |
| 822 | * 1) unmodified from disk |
| 823 | * 2) backup cache for save/restore during power-downs */ |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 824 | for (i = 0; i < IWL_UCODE_TYPE_MAX; i++) |
| 825 | if (alloc_pci_desc(drv, &pieces, i)) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 826 | goto err_pci_alloc; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 827 | |
| 828 | /* Now that we can no longer fail, copy information */ |
| 829 | |
| 830 | /* |
| 831 | * The (size - 16) / 12 formula is based on the information recorded |
| 832 | * for each event, which is of mode 1 (including timestamp) for all |
| 833 | * new microcodes that include this information. |
| 834 | */ |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 835 | fw->init_evtlog_ptr = pieces.init_evtlog_ptr; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 836 | if (pieces.init_evtlog_size) |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 837 | fw->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 838 | else |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 839 | fw->init_evtlog_size = |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 840 | drv->cfg->base_params->max_event_log_size; |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 841 | fw->init_errlog_ptr = pieces.init_errlog_ptr; |
| 842 | fw->inst_evtlog_ptr = pieces.inst_evtlog_ptr; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 843 | if (pieces.inst_evtlog_size) |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 844 | fw->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 845 | else |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 846 | fw->inst_evtlog_size = |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 847 | drv->cfg->base_params->max_event_log_size; |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 848 | fw->inst_errlog_ptr = pieces.inst_errlog_ptr; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 849 | |
| 850 | /* |
| 851 | * figure out the offset of chain noise reset and gain commands |
| 852 | * base on the size of standard phy calibration commands table size |
| 853 | */ |
| 854 | if (fw->ucode_capa.standard_phy_calibration_size > |
| 855 | IWL_MAX_PHY_CALIBRATE_TBL_SIZE) |
| 856 | fw->ucode_capa.standard_phy_calibration_size = |
| 857 | IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; |
| 858 | |
| 859 | /* We have our copies now, allow OS release its copies */ |
| 860 | release_firmware(ucode_raw); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 861 | complete(&drv->request_firmware_complete); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 862 | |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 863 | drv->op_mode = iwl_dvm_ops.start(drv->trans, drv->cfg, &drv->fw); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 864 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 865 | if (!drv->op_mode) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 866 | goto out_unbind; |
| 867 | |
| 868 | return; |
| 869 | |
| 870 | try_again: |
| 871 | /* try next, if any */ |
| 872 | release_firmware(ucode_raw); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 873 | if (iwl_request_firmware(drv, false)) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 874 | goto out_unbind; |
| 875 | return; |
| 876 | |
| 877 | err_pci_alloc: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 878 | IWL_ERR(drv, "failed to allocate pci memory\n"); |
| 879 | iwl_dealloc_ucode(drv); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 880 | release_firmware(ucode_raw); |
| 881 | out_unbind: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 882 | complete(&drv->request_firmware_complete); |
| 883 | device_release_driver(trans(drv)->dev); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 884 | } |
| 885 | |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 886 | struct iwl_drv *iwl_drv_start(struct iwl_shared *shrd, |
| 887 | struct iwl_trans *trans, |
| 888 | const struct iwl_cfg *cfg) |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 889 | { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 890 | struct iwl_drv *drv; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 891 | int ret; |
| 892 | |
| 893 | shrd->cfg = cfg; |
| 894 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 895 | drv = kzalloc(sizeof(*drv), GFP_KERNEL); |
| 896 | if (!drv) { |
| 897 | dev_printk(KERN_ERR, trans->dev, "Couldn't allocate iwl_drv"); |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 898 | return NULL; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 899 | } |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 900 | /* For printing only - temporary until we change the logger */ |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 901 | drv->shrd = shrd; |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 902 | drv->trans = trans; |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame^] | 903 | drv->cfg = cfg; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 904 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 905 | init_completion(&drv->request_firmware_complete); |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 906 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 907 | ret = iwl_request_firmware(drv, true); |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 908 | |
| 909 | if (ret) { |
| 910 | dev_printk(KERN_ERR, trans->dev, "Couldn't request the fw"); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 911 | kfree(drv); |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 912 | drv = NULL; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 913 | } |
| 914 | |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 915 | return drv; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 916 | } |
| 917 | |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 918 | void iwl_drv_stop(struct iwl_drv *drv) |
Emmanuel Grumbach | 07590f0 | 2012-02-07 14:27:31 +0200 | [diff] [blame] | 919 | { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 920 | wait_for_completion(&drv->request_firmware_complete); |
Johannes Berg | 2e7eb11 | 2012-03-05 11:24:51 -0800 | [diff] [blame] | 921 | |
Emmanuel Grumbach | d0f76d6 | 2012-02-09 16:08:15 +0200 | [diff] [blame] | 922 | /* op_mode can be NULL if its start failed */ |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 923 | if (drv->op_mode) |
| 924 | iwl_op_mode_stop(drv->op_mode); |
Emmanuel Grumbach | 07590f0 | 2012-02-07 14:27:31 +0200 | [diff] [blame] | 925 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 926 | iwl_dealloc_ucode(drv); |
Johannes Berg | 7db5b98 | 2012-03-05 11:24:48 -0800 | [diff] [blame] | 927 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 928 | kfree(drv); |
Emmanuel Grumbach | 07590f0 | 2012-02-07 14:27:31 +0200 | [diff] [blame] | 929 | } |