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" |
Emmanuel Grumbach | c15797e | 2012-04-19 10:29:58 +0300 | [diff] [blame] | 69 | #include "iwl-debug.h" |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 70 | #include "iwl-trans.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" |
Johannes Berg | 6238b00 | 2012-04-02 15:04:33 +0200 | [diff] [blame] | 73 | #include "iwl-fw.h" |
| 74 | #include "iwl-config.h" |
Johannes Berg | 65de7e8 | 2012-04-17 07:36:30 -0700 | [diff] [blame] | 75 | #include "iwl-modparams.h" |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 76 | |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 77 | /* private includes */ |
Johannes Berg | 3995dea | 2012-03-06 13:30:44 -0800 | [diff] [blame] | 78 | #include "iwl-fw-file.h" |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 79 | |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 80 | /****************************************************************************** |
| 81 | * |
| 82 | * module boiler plate |
| 83 | * |
| 84 | ******************************************************************************/ |
| 85 | |
| 86 | /* |
| 87 | * module name, copyright, version, etc. |
| 88 | */ |
| 89 | #define DRV_DESCRIPTION "Intel(R) Wireless WiFi driver for Linux" |
| 90 | |
| 91 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 92 | #define VD "d" |
| 93 | #else |
| 94 | #define VD |
| 95 | #endif |
| 96 | |
| 97 | #define DRV_VERSION IWLWIFI_VERSION VD |
| 98 | |
| 99 | MODULE_DESCRIPTION(DRV_DESCRIPTION); |
| 100 | MODULE_VERSION(DRV_VERSION); |
| 101 | MODULE_AUTHOR(DRV_COPYRIGHT " " DRV_AUTHOR); |
| 102 | MODULE_LICENSE("GPL"); |
| 103 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 104 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 105 | static struct dentry *iwl_dbgfs_root; |
| 106 | #endif |
| 107 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 108 | /** |
| 109 | * struct iwl_drv - drv common data |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 110 | * @list: list of drv structures using this opmode |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 111 | * @fw: the iwl_fw structure |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 112 | * @op_mode: the running op_mode |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 113 | * @trans: transport layer |
Emmanuel Grumbach | 4b9844f | 2012-03-22 23:59:52 +0200 | [diff] [blame] | 114 | * @dev: for debug prints only |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 115 | * @cfg: configuration struct |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 116 | * @fw_index: firmware revision to try loading |
| 117 | * @firmware_name: composite filename of ucode file to load |
| 118 | * @request_firmware_complete: the firmware has been obtained from user space |
| 119 | */ |
| 120 | struct iwl_drv { |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 121 | struct list_head list; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 122 | struct iwl_fw fw; |
| 123 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 124 | struct iwl_op_mode *op_mode; |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 125 | struct iwl_trans *trans; |
Emmanuel Grumbach | 4b9844f | 2012-03-22 23:59:52 +0200 | [diff] [blame] | 126 | struct device *dev; |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 127 | const struct iwl_cfg *cfg; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 128 | |
| 129 | int fw_index; /* firmware we're trying to load */ |
| 130 | char firmware_name[25]; /* name of firmware file to load */ |
| 131 | |
| 132 | struct completion request_firmware_complete; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 133 | |
| 134 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 135 | struct dentry *dbgfs_drv; |
| 136 | struct dentry *dbgfs_trans; |
| 137 | struct dentry *dbgfs_op_mode; |
| 138 | #endif |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 139 | }; |
| 140 | |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 141 | #define DVM_OP_MODE 0 |
| 142 | #define MVM_OP_MODE 1 |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 143 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 144 | /* Protects the table contents, i.e. the ops pointer & drv list */ |
| 145 | static struct mutex iwlwifi_opmode_table_mtx; |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 146 | static struct iwlwifi_opmode_table { |
| 147 | const char *name; /* name: iwldvm, iwlmvm, etc */ |
| 148 | const struct iwl_op_mode_ops *ops; /* pointer to op_mode ops */ |
| 149 | struct list_head drv; /* list of devices using this op_mode */ |
| 150 | } iwlwifi_opmode_table[] = { /* ops set when driver is initialized */ |
| 151 | { .name = "iwldvm", .ops = NULL }, |
| 152 | { .name = "iwlmvm", .ops = NULL }, |
| 153 | }; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 154 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 155 | /* |
| 156 | * struct fw_sec: Just for the image parsing proccess. |
| 157 | * For the fw storage we are using struct fw_desc. |
| 158 | */ |
| 159 | struct fw_sec { |
| 160 | const void *data; /* the sec data */ |
| 161 | size_t size; /* section size */ |
| 162 | u32 offset; /* offset of writing in the device */ |
| 163 | }; |
| 164 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 165 | 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] | 166 | { |
| 167 | if (desc->v_addr) |
Emmanuel Grumbach | 93faaee | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 168 | dma_free_coherent(drv->trans->dev, desc->len, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 169 | desc->v_addr, desc->p_addr); |
| 170 | desc->v_addr = NULL; |
| 171 | desc->len = 0; |
| 172 | } |
| 173 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 174 | 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] | 175 | { |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 176 | int i; |
| 177 | for (i = 0; i < IWL_UCODE_SECTION_MAX; i++) |
| 178 | iwl_free_fw_desc(drv, &img->sec[i]); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 179 | } |
| 180 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 181 | static void iwl_dealloc_ucode(struct iwl_drv *drv) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 182 | { |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 183 | int i; |
| 184 | for (i = 0; i < IWL_UCODE_TYPE_MAX; i++) |
| 185 | iwl_free_fw_img(drv, drv->fw.img + i); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 186 | } |
| 187 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 188 | 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] | 189 | struct fw_sec *sec) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 190 | { |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 191 | if (!sec || !sec->size) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 192 | desc->v_addr = NULL; |
| 193 | return -EINVAL; |
| 194 | } |
| 195 | |
Emmanuel Grumbach | 93faaee | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 196 | desc->v_addr = dma_alloc_coherent(drv->trans->dev, sec->size, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 197 | &desc->p_addr, GFP_KERNEL); |
| 198 | if (!desc->v_addr) |
| 199 | return -ENOMEM; |
| 200 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 201 | desc->len = sec->size; |
| 202 | desc->offset = sec->offset; |
| 203 | memcpy(desc->v_addr, sec->data, sec->size); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 204 | return 0; |
| 205 | } |
| 206 | |
Emmanuel Grumbach | 1c8e11e | 2012-07-16 12:31:28 +0300 | [diff] [blame] | 207 | static void iwl_req_fw_callback(const struct firmware *ucode_raw, |
| 208 | void *context); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 209 | |
| 210 | #define UCODE_EXPERIMENTAL_INDEX 100 |
| 211 | #define UCODE_EXPERIMENTAL_TAG "exp" |
| 212 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 213 | static int iwl_request_firmware(struct iwl_drv *drv, bool first) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 214 | { |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 215 | const char *name_pre = drv->cfg->fw_name_pre; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 216 | char tag[8]; |
| 217 | |
| 218 | if (first) { |
| 219 | #ifdef CONFIG_IWLWIFI_DEBUG_EXPERIMENTAL_UCODE |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 220 | drv->fw_index = UCODE_EXPERIMENTAL_INDEX; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 221 | strcpy(tag, UCODE_EXPERIMENTAL_TAG); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 222 | } else if (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 223 | #endif |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 224 | drv->fw_index = drv->cfg->ucode_api_max; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 225 | sprintf(tag, "%d", drv->fw_index); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 226 | } else { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 227 | drv->fw_index--; |
| 228 | sprintf(tag, "%d", drv->fw_index); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 229 | } |
| 230 | |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 231 | if (drv->fw_index < drv->cfg->ucode_api_min) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 232 | IWL_ERR(drv, "no suitable firmware found!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 233 | return -ENOENT; |
| 234 | } |
| 235 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 236 | sprintf(drv->firmware_name, "%s%s%s", name_pre, tag, ".ucode"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 237 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 238 | IWL_DEBUG_INFO(drv, "attempting to load firmware %s'%s'\n", |
| 239 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 240 | ? "EXPERIMENTAL " : "", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 241 | drv->firmware_name); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 242 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 243 | return request_firmware_nowait(THIS_MODULE, 1, drv->firmware_name, |
Emmanuel Grumbach | 93faaee | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 244 | drv->trans->dev, |
Emmanuel Grumbach | 1c8e11e | 2012-07-16 12:31:28 +0300 | [diff] [blame] | 245 | GFP_KERNEL, drv, iwl_req_fw_callback); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 246 | } |
| 247 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 248 | struct fw_img_parsing { |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 249 | struct fw_sec sec[IWL_UCODE_SECTION_MAX]; |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 250 | int sec_counter; |
| 251 | }; |
| 252 | |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 253 | /* |
| 254 | * struct fw_sec_parsing: to extract fw section and it's offset from tlv |
| 255 | */ |
| 256 | struct fw_sec_parsing { |
| 257 | __le32 offset; |
| 258 | const u8 data[]; |
| 259 | } __packed; |
| 260 | |
| 261 | /** |
| 262 | * struct iwl_tlv_calib_data - parse the default calib data from TLV |
| 263 | * |
| 264 | * @ucode_type: the uCode to which the following default calib relates. |
| 265 | * @calib: default calibrations. |
| 266 | */ |
| 267 | struct iwl_tlv_calib_data { |
| 268 | __le32 ucode_type; |
| 269 | __le64 calib; |
| 270 | } __packed; |
| 271 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 272 | struct iwl_firmware_pieces { |
| 273 | struct fw_img_parsing img[IWL_UCODE_TYPE_MAX]; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 274 | |
| 275 | u32 init_evtlog_ptr, init_evtlog_size, init_errlog_ptr; |
| 276 | u32 inst_evtlog_ptr, inst_evtlog_size, inst_errlog_ptr; |
| 277 | }; |
| 278 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 279 | /* |
| 280 | * These functions are just to extract uCode section data from the pieces |
| 281 | * structure. |
| 282 | */ |
| 283 | static struct fw_sec *get_sec(struct iwl_firmware_pieces *pieces, |
| 284 | enum iwl_ucode_type type, |
| 285 | int sec) |
| 286 | { |
| 287 | return &pieces->img[type].sec[sec]; |
| 288 | } |
| 289 | |
| 290 | static void set_sec_data(struct iwl_firmware_pieces *pieces, |
| 291 | enum iwl_ucode_type type, |
| 292 | int sec, |
| 293 | const void *data) |
| 294 | { |
| 295 | pieces->img[type].sec[sec].data = data; |
| 296 | } |
| 297 | |
| 298 | static void set_sec_size(struct iwl_firmware_pieces *pieces, |
| 299 | enum iwl_ucode_type type, |
| 300 | int sec, |
| 301 | size_t size) |
| 302 | { |
| 303 | pieces->img[type].sec[sec].size = size; |
| 304 | } |
| 305 | |
| 306 | static size_t get_sec_size(struct iwl_firmware_pieces *pieces, |
| 307 | enum iwl_ucode_type type, |
| 308 | int sec) |
| 309 | { |
| 310 | return pieces->img[type].sec[sec].size; |
| 311 | } |
| 312 | |
| 313 | static void set_sec_offset(struct iwl_firmware_pieces *pieces, |
| 314 | enum iwl_ucode_type type, |
| 315 | int sec, |
| 316 | u32 offset) |
| 317 | { |
| 318 | pieces->img[type].sec[sec].offset = offset; |
| 319 | } |
| 320 | |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 321 | /* |
| 322 | * Gets uCode section from tlv. |
| 323 | */ |
| 324 | static int iwl_store_ucode_sec(struct iwl_firmware_pieces *pieces, |
| 325 | const void *data, enum iwl_ucode_type type, |
| 326 | int size) |
| 327 | { |
| 328 | struct fw_img_parsing *img; |
| 329 | struct fw_sec *sec; |
| 330 | struct fw_sec_parsing *sec_parse; |
| 331 | |
| 332 | if (WARN_ON(!pieces || !data || type >= IWL_UCODE_TYPE_MAX)) |
| 333 | return -1; |
| 334 | |
| 335 | sec_parse = (struct fw_sec_parsing *)data; |
| 336 | |
| 337 | img = &pieces->img[type]; |
| 338 | sec = &img->sec[img->sec_counter]; |
| 339 | |
| 340 | sec->offset = le32_to_cpu(sec_parse->offset); |
| 341 | sec->data = sec_parse->data; |
David Spinadel | 1176f43 | 2012-03-13 14:32:48 +0200 | [diff] [blame] | 342 | sec->size = size - sizeof(sec_parse->offset); |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 343 | |
| 344 | ++img->sec_counter; |
| 345 | |
| 346 | return 0; |
| 347 | } |
| 348 | |
| 349 | static int iwl_set_default_calib(struct iwl_drv *drv, const u8 *data) |
| 350 | { |
| 351 | struct iwl_tlv_calib_data *def_calib = |
| 352 | (struct iwl_tlv_calib_data *)data; |
| 353 | u32 ucode_type = le32_to_cpu(def_calib->ucode_type); |
| 354 | if (ucode_type >= IWL_UCODE_TYPE_MAX) { |
| 355 | IWL_ERR(drv, "Wrong ucode_type %u for default calibration.\n", |
| 356 | ucode_type); |
| 357 | return -EINVAL; |
| 358 | } |
| 359 | drv->fw.default_calib[ucode_type] = le64_to_cpu(def_calib->calib); |
| 360 | return 0; |
| 361 | } |
| 362 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 363 | static int iwl_parse_v1_v2_firmware(struct iwl_drv *drv, |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 364 | const struct firmware *ucode_raw, |
| 365 | struct iwl_firmware_pieces *pieces) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 366 | { |
| 367 | struct iwl_ucode_header *ucode = (void *)ucode_raw->data; |
| 368 | u32 api_ver, hdr_size, build; |
| 369 | char buildstr[25]; |
| 370 | const u8 *src; |
| 371 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 372 | drv->fw.ucode_ver = le32_to_cpu(ucode->ver); |
| 373 | api_ver = IWL_UCODE_API(drv->fw.ucode_ver); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 374 | |
| 375 | switch (api_ver) { |
| 376 | default: |
| 377 | hdr_size = 28; |
| 378 | if (ucode_raw->size < hdr_size) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 379 | IWL_ERR(drv, "File size too small!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 380 | return -EINVAL; |
| 381 | } |
| 382 | build = le32_to_cpu(ucode->u.v2.build); |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 383 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
| 384 | le32_to_cpu(ucode->u.v2.inst_size)); |
| 385 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, |
| 386 | le32_to_cpu(ucode->u.v2.data_size)); |
| 387 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, |
| 388 | le32_to_cpu(ucode->u.v2.init_size)); |
| 389 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, |
| 390 | le32_to_cpu(ucode->u.v2.init_data_size)); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 391 | src = ucode->u.v2.data; |
| 392 | break; |
| 393 | case 0: |
| 394 | case 1: |
| 395 | case 2: |
| 396 | hdr_size = 24; |
| 397 | if (ucode_raw->size < hdr_size) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 398 | IWL_ERR(drv, "File size too small!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 399 | return -EINVAL; |
| 400 | } |
| 401 | build = 0; |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 402 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
| 403 | le32_to_cpu(ucode->u.v1.inst_size)); |
| 404 | set_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, |
| 405 | le32_to_cpu(ucode->u.v1.data_size)); |
| 406 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, |
| 407 | le32_to_cpu(ucode->u.v1.init_size)); |
| 408 | set_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, |
| 409 | le32_to_cpu(ucode->u.v1.init_data_size)); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 410 | src = ucode->u.v1.data; |
| 411 | break; |
| 412 | } |
| 413 | |
| 414 | if (build) |
| 415 | sprintf(buildstr, " build %u%s", build, |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 416 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 417 | ? " (EXP)" : ""); |
| 418 | else |
| 419 | buildstr[0] = '\0'; |
| 420 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 421 | snprintf(drv->fw.fw_version, |
| 422 | sizeof(drv->fw.fw_version), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 423 | "%u.%u.%u.%u%s", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 424 | IWL_UCODE_MAJOR(drv->fw.ucode_ver), |
| 425 | IWL_UCODE_MINOR(drv->fw.ucode_ver), |
| 426 | IWL_UCODE_API(drv->fw.ucode_ver), |
| 427 | IWL_UCODE_SERIAL(drv->fw.ucode_ver), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 428 | buildstr); |
| 429 | |
| 430 | /* Verify size of file vs. image size info in file's header */ |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 431 | |
| 432 | if (ucode_raw->size != hdr_size + |
| 433 | get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) + |
| 434 | get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) + |
| 435 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) + |
| 436 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 437 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 438 | IWL_ERR(drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 439 | "uCode file size %d does not match expected size\n", |
| 440 | (int)ucode_raw->size); |
| 441 | return -EINVAL; |
| 442 | } |
| 443 | |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 444 | |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 445 | set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, src); |
| 446 | src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST); |
| 447 | set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST, |
| 448 | IWLAGN_RTC_INST_LOWER_BOUND); |
| 449 | set_sec_data(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, src); |
| 450 | src += get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA); |
| 451 | set_sec_offset(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA, |
| 452 | IWLAGN_RTC_DATA_LOWER_BOUND); |
| 453 | set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, src); |
| 454 | src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST); |
| 455 | set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST, |
| 456 | IWLAGN_RTC_INST_LOWER_BOUND); |
| 457 | set_sec_data(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, src); |
| 458 | src += get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA); |
| 459 | set_sec_offset(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA, |
| 460 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 461 | return 0; |
| 462 | } |
| 463 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 464 | static int iwl_parse_tlv_firmware(struct iwl_drv *drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 465 | const struct firmware *ucode_raw, |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 466 | struct iwl_firmware_pieces *pieces, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 467 | struct iwl_ucode_capabilities *capa) |
| 468 | { |
| 469 | struct iwl_tlv_ucode_header *ucode = (void *)ucode_raw->data; |
| 470 | struct iwl_ucode_tlv *tlv; |
| 471 | size_t len = ucode_raw->size; |
| 472 | const u8 *data; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 473 | u32 tlv_len; |
| 474 | enum iwl_ucode_tlv_type tlv_type; |
| 475 | const u8 *tlv_data; |
| 476 | char buildstr[25]; |
| 477 | u32 build; |
| 478 | |
| 479 | if (len < sizeof(*ucode)) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 480 | IWL_ERR(drv, "uCode has invalid length: %zd\n", len); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 481 | return -EINVAL; |
| 482 | } |
| 483 | |
| 484 | if (ucode->magic != cpu_to_le32(IWL_TLV_UCODE_MAGIC)) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 485 | IWL_ERR(drv, "invalid uCode magic: 0X%x\n", |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 486 | le32_to_cpu(ucode->magic)); |
| 487 | return -EINVAL; |
| 488 | } |
| 489 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 490 | drv->fw.ucode_ver = le32_to_cpu(ucode->ver); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 491 | build = le32_to_cpu(ucode->build); |
| 492 | |
| 493 | if (build) |
| 494 | sprintf(buildstr, " build %u%s", build, |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 495 | (drv->fw_index == UCODE_EXPERIMENTAL_INDEX) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 496 | ? " (EXP)" : ""); |
| 497 | else |
| 498 | buildstr[0] = '\0'; |
| 499 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 500 | snprintf(drv->fw.fw_version, |
| 501 | sizeof(drv->fw.fw_version), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 502 | "%u.%u.%u.%u%s", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 503 | IWL_UCODE_MAJOR(drv->fw.ucode_ver), |
| 504 | IWL_UCODE_MINOR(drv->fw.ucode_ver), |
| 505 | IWL_UCODE_API(drv->fw.ucode_ver), |
| 506 | IWL_UCODE_SERIAL(drv->fw.ucode_ver), |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 507 | buildstr); |
| 508 | |
| 509 | data = ucode->data; |
| 510 | |
| 511 | len -= sizeof(*ucode); |
| 512 | |
| 513 | while (len >= sizeof(*tlv)) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 514 | len -= sizeof(*tlv); |
| 515 | tlv = (void *)data; |
| 516 | |
| 517 | tlv_len = le32_to_cpu(tlv->length); |
Johannes Berg | 0479c19 | 2012-03-09 09:16:35 +0100 | [diff] [blame] | 518 | tlv_type = le32_to_cpu(tlv->type); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 519 | tlv_data = tlv->data; |
| 520 | |
| 521 | if (len < tlv_len) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 522 | IWL_ERR(drv, "invalid TLV len: %zd/%u\n", |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 523 | len, tlv_len); |
| 524 | return -EINVAL; |
| 525 | } |
| 526 | len -= ALIGN(tlv_len, 4); |
| 527 | data += sizeof(*tlv) + ALIGN(tlv_len, 4); |
| 528 | |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 529 | switch (tlv_type) { |
| 530 | case IWL_UCODE_TLV_INST: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 531 | set_sec_data(pieces, IWL_UCODE_REGULAR, |
| 532 | IWL_UCODE_SECTION_INST, tlv_data); |
| 533 | set_sec_size(pieces, IWL_UCODE_REGULAR, |
| 534 | IWL_UCODE_SECTION_INST, tlv_len); |
| 535 | set_sec_offset(pieces, IWL_UCODE_REGULAR, |
| 536 | IWL_UCODE_SECTION_INST, |
| 537 | IWLAGN_RTC_INST_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 538 | break; |
| 539 | case IWL_UCODE_TLV_DATA: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 540 | set_sec_data(pieces, IWL_UCODE_REGULAR, |
| 541 | IWL_UCODE_SECTION_DATA, tlv_data); |
| 542 | set_sec_size(pieces, IWL_UCODE_REGULAR, |
| 543 | IWL_UCODE_SECTION_DATA, tlv_len); |
| 544 | set_sec_offset(pieces, IWL_UCODE_REGULAR, |
| 545 | IWL_UCODE_SECTION_DATA, |
| 546 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 547 | break; |
| 548 | case IWL_UCODE_TLV_INIT: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 549 | set_sec_data(pieces, IWL_UCODE_INIT, |
| 550 | IWL_UCODE_SECTION_INST, tlv_data); |
| 551 | set_sec_size(pieces, IWL_UCODE_INIT, |
| 552 | IWL_UCODE_SECTION_INST, tlv_len); |
| 553 | set_sec_offset(pieces, IWL_UCODE_INIT, |
| 554 | IWL_UCODE_SECTION_INST, |
| 555 | IWLAGN_RTC_INST_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 556 | break; |
| 557 | case IWL_UCODE_TLV_INIT_DATA: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 558 | set_sec_data(pieces, IWL_UCODE_INIT, |
| 559 | IWL_UCODE_SECTION_DATA, tlv_data); |
| 560 | set_sec_size(pieces, IWL_UCODE_INIT, |
| 561 | IWL_UCODE_SECTION_DATA, tlv_len); |
| 562 | set_sec_offset(pieces, IWL_UCODE_INIT, |
| 563 | IWL_UCODE_SECTION_DATA, |
| 564 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 565 | break; |
| 566 | case IWL_UCODE_TLV_BOOT: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 567 | IWL_ERR(drv, "Found unexpected BOOT ucode\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 568 | break; |
| 569 | case IWL_UCODE_TLV_PROBE_MAX_LEN: |
| 570 | if (tlv_len != sizeof(u32)) |
| 571 | goto invalid_tlv_len; |
| 572 | capa->max_probe_length = |
| 573 | le32_to_cpup((__le32 *)tlv_data); |
| 574 | break; |
| 575 | case IWL_UCODE_TLV_PAN: |
| 576 | if (tlv_len) |
| 577 | goto invalid_tlv_len; |
| 578 | capa->flags |= IWL_UCODE_TLV_FLAGS_PAN; |
| 579 | break; |
| 580 | case IWL_UCODE_TLV_FLAGS: |
| 581 | /* must be at least one u32 */ |
| 582 | if (tlv_len < sizeof(u32)) |
| 583 | goto invalid_tlv_len; |
| 584 | /* and a proper number of u32s */ |
| 585 | if (tlv_len % sizeof(u32)) |
| 586 | goto invalid_tlv_len; |
| 587 | /* |
| 588 | * This driver only reads the first u32 as |
| 589 | * right now no more features are defined, |
| 590 | * if that changes then either the driver |
| 591 | * will not work with the new firmware, or |
| 592 | * it'll not take advantage of new features. |
| 593 | */ |
| 594 | capa->flags = le32_to_cpup((__le32 *)tlv_data); |
| 595 | break; |
| 596 | case IWL_UCODE_TLV_INIT_EVTLOG_PTR: |
| 597 | if (tlv_len != sizeof(u32)) |
| 598 | goto invalid_tlv_len; |
| 599 | pieces->init_evtlog_ptr = |
| 600 | le32_to_cpup((__le32 *)tlv_data); |
| 601 | break; |
| 602 | case IWL_UCODE_TLV_INIT_EVTLOG_SIZE: |
| 603 | if (tlv_len != sizeof(u32)) |
| 604 | goto invalid_tlv_len; |
| 605 | pieces->init_evtlog_size = |
| 606 | le32_to_cpup((__le32 *)tlv_data); |
| 607 | break; |
| 608 | case IWL_UCODE_TLV_INIT_ERRLOG_PTR: |
| 609 | if (tlv_len != sizeof(u32)) |
| 610 | goto invalid_tlv_len; |
| 611 | pieces->init_errlog_ptr = |
| 612 | le32_to_cpup((__le32 *)tlv_data); |
| 613 | break; |
| 614 | case IWL_UCODE_TLV_RUNT_EVTLOG_PTR: |
| 615 | if (tlv_len != sizeof(u32)) |
| 616 | goto invalid_tlv_len; |
| 617 | pieces->inst_evtlog_ptr = |
| 618 | le32_to_cpup((__le32 *)tlv_data); |
| 619 | break; |
| 620 | case IWL_UCODE_TLV_RUNT_EVTLOG_SIZE: |
| 621 | if (tlv_len != sizeof(u32)) |
| 622 | goto invalid_tlv_len; |
| 623 | pieces->inst_evtlog_size = |
| 624 | le32_to_cpup((__le32 *)tlv_data); |
| 625 | break; |
| 626 | case IWL_UCODE_TLV_RUNT_ERRLOG_PTR: |
| 627 | if (tlv_len != sizeof(u32)) |
| 628 | goto invalid_tlv_len; |
| 629 | pieces->inst_errlog_ptr = |
| 630 | le32_to_cpup((__le32 *)tlv_data); |
| 631 | break; |
| 632 | case IWL_UCODE_TLV_ENHANCE_SENS_TBL: |
| 633 | if (tlv_len) |
| 634 | goto invalid_tlv_len; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 635 | drv->fw.enhance_sensitivity_table = true; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 636 | break; |
| 637 | case IWL_UCODE_TLV_WOWLAN_INST: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 638 | set_sec_data(pieces, IWL_UCODE_WOWLAN, |
| 639 | IWL_UCODE_SECTION_INST, tlv_data); |
| 640 | set_sec_size(pieces, IWL_UCODE_WOWLAN, |
| 641 | IWL_UCODE_SECTION_INST, tlv_len); |
| 642 | set_sec_offset(pieces, IWL_UCODE_WOWLAN, |
| 643 | IWL_UCODE_SECTION_INST, |
| 644 | IWLAGN_RTC_INST_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 645 | break; |
| 646 | case IWL_UCODE_TLV_WOWLAN_DATA: |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 647 | set_sec_data(pieces, IWL_UCODE_WOWLAN, |
| 648 | IWL_UCODE_SECTION_DATA, tlv_data); |
| 649 | set_sec_size(pieces, IWL_UCODE_WOWLAN, |
| 650 | IWL_UCODE_SECTION_DATA, tlv_len); |
| 651 | set_sec_offset(pieces, IWL_UCODE_WOWLAN, |
| 652 | IWL_UCODE_SECTION_DATA, |
| 653 | IWLAGN_RTC_DATA_LOWER_BOUND); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 654 | break; |
| 655 | case IWL_UCODE_TLV_PHY_CALIBRATION_SIZE: |
| 656 | if (tlv_len != sizeof(u32)) |
| 657 | goto invalid_tlv_len; |
| 658 | capa->standard_phy_calibration_size = |
| 659 | le32_to_cpup((__le32 *)tlv_data); |
| 660 | break; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 661 | case IWL_UCODE_TLV_SEC_RT: |
| 662 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_REGULAR, |
| 663 | tlv_len); |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 664 | drv->fw.mvm_fw = true; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 665 | break; |
| 666 | case IWL_UCODE_TLV_SEC_INIT: |
| 667 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_INIT, |
| 668 | tlv_len); |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 669 | drv->fw.mvm_fw = true; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 670 | break; |
| 671 | case IWL_UCODE_TLV_SEC_WOWLAN: |
| 672 | iwl_store_ucode_sec(pieces, tlv_data, IWL_UCODE_WOWLAN, |
| 673 | tlv_len); |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 674 | drv->fw.mvm_fw = true; |
David Spinadel | ed8c836 | 2012-03-10 13:00:13 -0800 | [diff] [blame] | 675 | break; |
| 676 | case IWL_UCODE_TLV_DEF_CALIB: |
| 677 | if (tlv_len != sizeof(struct iwl_tlv_calib_data)) |
| 678 | goto invalid_tlv_len; |
| 679 | if (iwl_set_default_calib(drv, tlv_data)) |
| 680 | goto tlv_error; |
| 681 | break; |
| 682 | case IWL_UCODE_TLV_PHY_SKU: |
| 683 | if (tlv_len != sizeof(u32)) |
| 684 | goto invalid_tlv_len; |
| 685 | drv->fw.phy_config = le32_to_cpup((__le32 *)tlv_data); |
| 686 | break; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 687 | default: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 688 | IWL_DEBUG_INFO(drv, "unknown TLV: %d\n", tlv_type); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 689 | break; |
| 690 | } |
| 691 | } |
| 692 | |
| 693 | if (len) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 694 | IWL_ERR(drv, "invalid TLV after parsing: %zd\n", len); |
| 695 | iwl_print_hex_dump(drv, IWL_DL_FW, (u8 *)data, len); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 696 | return -EINVAL; |
| 697 | } |
| 698 | |
| 699 | return 0; |
| 700 | |
| 701 | invalid_tlv_len: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 702 | 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] | 703 | tlv_error: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 704 | iwl_print_hex_dump(drv, IWL_DL_FW, tlv_data, tlv_len); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 705 | |
| 706 | return -EINVAL; |
| 707 | } |
| 708 | |
Johannes Berg | 75813bd | 2012-05-16 22:49:49 +0200 | [diff] [blame] | 709 | static int iwl_alloc_ucode(struct iwl_drv *drv, |
| 710 | struct iwl_firmware_pieces *pieces, |
| 711 | enum iwl_ucode_type type) |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 712 | { |
| 713 | int i; |
| 714 | for (i = 0; |
| 715 | i < IWL_UCODE_SECTION_MAX && get_sec_size(pieces, type, i); |
| 716 | i++) |
| 717 | if (iwl_alloc_fw_desc(drv, &(drv->fw.img[type].sec[i]), |
Johannes Berg | 75813bd | 2012-05-16 22:49:49 +0200 | [diff] [blame] | 718 | get_sec(pieces, type, i))) |
| 719 | return -ENOMEM; |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 720 | return 0; |
| 721 | } |
| 722 | |
| 723 | static int validate_sec_sizes(struct iwl_drv *drv, |
| 724 | struct iwl_firmware_pieces *pieces, |
| 725 | const struct iwl_cfg *cfg) |
| 726 | { |
| 727 | IWL_DEBUG_INFO(drv, "f/w package hdr runtime inst size = %Zd\n", |
| 728 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 729 | IWL_UCODE_SECTION_INST)); |
| 730 | IWL_DEBUG_INFO(drv, "f/w package hdr runtime data size = %Zd\n", |
| 731 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 732 | IWL_UCODE_SECTION_DATA)); |
| 733 | IWL_DEBUG_INFO(drv, "f/w package hdr init inst size = %Zd\n", |
| 734 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST)); |
| 735 | IWL_DEBUG_INFO(drv, "f/w package hdr init data size = %Zd\n", |
| 736 | get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA)); |
| 737 | |
| 738 | /* Verify that uCode images will fit in card's SRAM. */ |
| 739 | if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_INST) > |
| 740 | cfg->max_inst_size) { |
| 741 | IWL_ERR(drv, "uCode instr len %Zd too large to fit in\n", |
| 742 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 743 | IWL_UCODE_SECTION_INST)); |
| 744 | return -1; |
| 745 | } |
| 746 | |
| 747 | if (get_sec_size(pieces, IWL_UCODE_REGULAR, IWL_UCODE_SECTION_DATA) > |
| 748 | cfg->max_data_size) { |
| 749 | IWL_ERR(drv, "uCode data len %Zd too large to fit in\n", |
| 750 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 751 | IWL_UCODE_SECTION_DATA)); |
| 752 | return -1; |
| 753 | } |
| 754 | |
| 755 | if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_INST) > |
| 756 | cfg->max_inst_size) { |
| 757 | IWL_ERR(drv, "uCode init instr len %Zd too large to fit in\n", |
| 758 | get_sec_size(pieces, IWL_UCODE_INIT, |
| 759 | IWL_UCODE_SECTION_INST)); |
| 760 | return -1; |
| 761 | } |
| 762 | |
| 763 | if (get_sec_size(pieces, IWL_UCODE_INIT, IWL_UCODE_SECTION_DATA) > |
| 764 | cfg->max_data_size) { |
| 765 | IWL_ERR(drv, "uCode init data len %Zd too large to fit in\n", |
| 766 | get_sec_size(pieces, IWL_UCODE_REGULAR, |
| 767 | IWL_UCODE_SECTION_DATA)); |
| 768 | return -1; |
| 769 | } |
| 770 | return 0; |
| 771 | } |
| 772 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 773 | static struct iwl_op_mode * |
| 774 | _iwl_op_mode_start(struct iwl_drv *drv, struct iwlwifi_opmode_table *op) |
| 775 | { |
| 776 | const struct iwl_op_mode_ops *ops = op->ops; |
| 777 | struct dentry *dbgfs_dir = NULL; |
| 778 | struct iwl_op_mode *op_mode = NULL; |
| 779 | |
| 780 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 781 | drv->dbgfs_op_mode = debugfs_create_dir(op->name, |
| 782 | drv->dbgfs_drv); |
| 783 | if (!drv->dbgfs_op_mode) { |
| 784 | IWL_ERR(drv, |
| 785 | "failed to create opmode debugfs directory\n"); |
| 786 | return op_mode; |
| 787 | } |
| 788 | dbgfs_dir = drv->dbgfs_op_mode; |
| 789 | #endif |
| 790 | |
| 791 | op_mode = ops->start(drv->trans, drv->cfg, &drv->fw, dbgfs_dir); |
| 792 | |
| 793 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 794 | if (!op_mode) { |
| 795 | debugfs_remove_recursive(drv->dbgfs_op_mode); |
| 796 | drv->dbgfs_op_mode = NULL; |
| 797 | } |
| 798 | #endif |
| 799 | |
| 800 | return op_mode; |
| 801 | } |
| 802 | |
| 803 | static void _iwl_op_mode_stop(struct iwl_drv *drv) |
| 804 | { |
| 805 | /* op_mode can be NULL if its start failed */ |
| 806 | if (drv->op_mode) { |
| 807 | iwl_op_mode_stop(drv->op_mode); |
| 808 | drv->op_mode = NULL; |
| 809 | |
| 810 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 811 | debugfs_remove_recursive(drv->dbgfs_op_mode); |
| 812 | drv->dbgfs_op_mode = NULL; |
| 813 | #endif |
| 814 | } |
| 815 | } |
| 816 | |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 817 | /** |
Emmanuel Grumbach | 1c8e11e | 2012-07-16 12:31:28 +0300 | [diff] [blame] | 818 | * iwl_req_fw_callback - callback when firmware was loaded |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 819 | * |
| 820 | * If loaded successfully, copies the firmware into buffers |
| 821 | * for the card to fetch (via DMA). |
| 822 | */ |
Emmanuel Grumbach | 1c8e11e | 2012-07-16 12:31:28 +0300 | [diff] [blame] | 823 | static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 824 | { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 825 | struct iwl_drv *drv = context; |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 826 | struct iwl_fw *fw = &drv->fw; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 827 | struct iwl_ucode_header *ucode; |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 828 | struct iwlwifi_opmode_table *op; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 829 | int err; |
David Spinadel | 0cedacc | 2012-03-10 13:00:12 -0800 | [diff] [blame] | 830 | struct iwl_firmware_pieces pieces; |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 831 | const unsigned int api_max = drv->cfg->ucode_api_max; |
| 832 | unsigned int api_ok = drv->cfg->ucode_api_ok; |
| 833 | const unsigned int api_min = drv->cfg->ucode_api_min; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 834 | u32 api_ver; |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 835 | int i; |
Johannes Berg | d4b1048 | 2012-06-12 19:50:43 +0200 | [diff] [blame] | 836 | bool load_module = false; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 837 | |
| 838 | fw->ucode_capa.max_probe_length = 200; |
| 839 | fw->ucode_capa.standard_phy_calibration_size = |
| 840 | IWL_DEFAULT_STANDARD_PHY_CALIBRATE_TBL_SIZE; |
| 841 | |
| 842 | if (!api_ok) |
| 843 | api_ok = api_max; |
| 844 | |
| 845 | memset(&pieces, 0, sizeof(pieces)); |
| 846 | |
| 847 | if (!ucode_raw) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 848 | if (drv->fw_index <= api_ok) |
| 849 | IWL_ERR(drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 850 | "request for firmware file '%s' failed.\n", |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 851 | drv->firmware_name); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 852 | goto try_again; |
| 853 | } |
| 854 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 855 | IWL_DEBUG_INFO(drv, "Loaded firmware file '%s' (%zd bytes).\n", |
| 856 | drv->firmware_name, ucode_raw->size); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 857 | |
| 858 | /* Make sure that we got at least the API version number */ |
| 859 | if (ucode_raw->size < 4) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 860 | IWL_ERR(drv, "File size way too small!\n"); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 861 | goto try_again; |
| 862 | } |
| 863 | |
| 864 | /* Data from ucode file: header followed by uCode images */ |
| 865 | ucode = (struct iwl_ucode_header *)ucode_raw->data; |
| 866 | |
| 867 | if (ucode->ver) |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 868 | err = iwl_parse_v1_v2_firmware(drv, ucode_raw, &pieces); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 869 | else |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 870 | err = iwl_parse_tlv_firmware(drv, ucode_raw, &pieces, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 871 | &fw->ucode_capa); |
| 872 | |
| 873 | if (err) |
| 874 | goto try_again; |
| 875 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 876 | api_ver = IWL_UCODE_API(drv->fw.ucode_ver); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 877 | |
| 878 | /* |
| 879 | * api_ver should match the api version forming part of the |
| 880 | * firmware filename ... but we don't check for that and only rely |
| 881 | * on the API version read from firmware header from here on forward |
| 882 | */ |
| 883 | /* no api version check required for experimental uCode */ |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 884 | if (drv->fw_index != UCODE_EXPERIMENTAL_INDEX) { |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 885 | if (api_ver < api_min || api_ver > api_max) { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 886 | IWL_ERR(drv, |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 887 | "Driver unable to support your firmware API. " |
| 888 | "Driver supports v%u, firmware is v%u.\n", |
| 889 | api_max, api_ver); |
| 890 | goto try_again; |
| 891 | } |
| 892 | |
| 893 | if (api_ver < api_ok) { |
| 894 | if (api_ok != api_max) |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 895 | IWL_ERR(drv, "Firmware has old API version, " |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 896 | "expected v%u through v%u, got v%u.\n", |
| 897 | api_ok, api_max, api_ver); |
| 898 | else |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 899 | IWL_ERR(drv, "Firmware has old API version, " |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 900 | "expected v%u, got v%u.\n", |
| 901 | api_max, api_ver); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 902 | IWL_ERR(drv, "New firmware can be obtained from " |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 903 | "http://www.intellinuxwireless.org/.\n"); |
| 904 | } |
| 905 | } |
| 906 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 907 | IWL_INFO(drv, "loaded firmware version %s", drv->fw.fw_version); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 908 | |
| 909 | /* |
David Spinadel | 4db2c9a | 2012-03-10 13:00:15 -0800 | [diff] [blame] | 910 | * In mvm uCode there is no difference between data and instructions |
| 911 | * sections. |
| 912 | */ |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 913 | if (!fw->mvm_fw && validate_sec_sizes(drv, &pieces, drv->cfg)) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 914 | goto try_again; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 915 | |
| 916 | /* Allocate ucode buffers for card's bus-master loading ... */ |
| 917 | |
| 918 | /* Runtime instructions and 2 copies of data: |
| 919 | * 1) unmodified from disk |
| 920 | * 2) backup cache for save/restore during power-downs */ |
David Spinadel | 6dfa8d0 | 2012-03-10 13:00:14 -0800 | [diff] [blame] | 921 | for (i = 0; i < IWL_UCODE_TYPE_MAX; i++) |
Johannes Berg | 75813bd | 2012-05-16 22:49:49 +0200 | [diff] [blame] | 922 | if (iwl_alloc_ucode(drv, &pieces, i)) |
| 923 | goto out_free_fw; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 924 | |
| 925 | /* Now that we can no longer fail, copy information */ |
| 926 | |
| 927 | /* |
| 928 | * The (size - 16) / 12 formula is based on the information recorded |
| 929 | * for each event, which is of mode 1 (including timestamp) for all |
| 930 | * new microcodes that include this information. |
| 931 | */ |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 932 | fw->init_evtlog_ptr = pieces.init_evtlog_ptr; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 933 | if (pieces.init_evtlog_size) |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 934 | fw->init_evtlog_size = (pieces.init_evtlog_size - 16)/12; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 935 | else |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 936 | fw->init_evtlog_size = |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 937 | drv->cfg->base_params->max_event_log_size; |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 938 | fw->init_errlog_ptr = pieces.init_errlog_ptr; |
| 939 | fw->inst_evtlog_ptr = pieces.inst_evtlog_ptr; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 940 | if (pieces.inst_evtlog_size) |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 941 | fw->inst_evtlog_size = (pieces.inst_evtlog_size - 16)/12; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 942 | else |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 943 | fw->inst_evtlog_size = |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 944 | drv->cfg->base_params->max_event_log_size; |
Johannes Berg | 0692fe4 | 2012-03-06 13:30:37 -0800 | [diff] [blame] | 945 | fw->inst_errlog_ptr = pieces.inst_errlog_ptr; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 946 | |
| 947 | /* |
| 948 | * figure out the offset of chain noise reset and gain commands |
| 949 | * base on the size of standard phy calibration commands table size |
| 950 | */ |
| 951 | if (fw->ucode_capa.standard_phy_calibration_size > |
| 952 | IWL_MAX_PHY_CALIBRATE_TBL_SIZE) |
| 953 | fw->ucode_capa.standard_phy_calibration_size = |
| 954 | IWL_MAX_STANDARD_PHY_CALIBRATE_TBL_SIZE; |
| 955 | |
| 956 | /* We have our copies now, allow OS release its copies */ |
| 957 | release_firmware(ucode_raw); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 958 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 959 | mutex_lock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 960 | op = &iwlwifi_opmode_table[DVM_OP_MODE]; |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 961 | |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 962 | /* add this device to the list of devices using this op_mode */ |
| 963 | list_add_tail(&drv->list, &op->drv); |
| 964 | |
| 965 | if (op->ops) { |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 966 | drv->op_mode = _iwl_op_mode_start(drv, op); |
John W. Linville | 7c9c46c | 2012-06-06 14:40:06 -0400 | [diff] [blame] | 967 | |
Dan Carpenter | daf67ce | 2012-06-14 21:35:26 +0300 | [diff] [blame] | 968 | if (!drv->op_mode) { |
| 969 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
John W. Linville | 7c9c46c | 2012-06-06 14:40:06 -0400 | [diff] [blame] | 970 | goto out_unbind; |
Dan Carpenter | daf67ce | 2012-06-14 21:35:26 +0300 | [diff] [blame] | 971 | } |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 972 | } else { |
Johannes Berg | d4b1048 | 2012-06-12 19:50:43 +0200 | [diff] [blame] | 973 | load_module = true; |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 974 | } |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 975 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 976 | |
Johannes Berg | f69a23b | 2012-06-05 19:56:06 +0200 | [diff] [blame] | 977 | /* |
| 978 | * Complete the firmware request last so that |
| 979 | * a driver unbind (stop) doesn't run while we |
| 980 | * are doing the start() above. |
| 981 | */ |
| 982 | complete(&drv->request_firmware_complete); |
Johannes Berg | d4b1048 | 2012-06-12 19:50:43 +0200 | [diff] [blame] | 983 | |
| 984 | /* |
| 985 | * Load the module last so we don't block anything |
| 986 | * else from proceeding if the module fails to load |
| 987 | * or hangs loading. |
| 988 | */ |
| 989 | if (load_module) |
| 990 | request_module("%s", op->name); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 991 | return; |
| 992 | |
| 993 | try_again: |
| 994 | /* try next, if any */ |
| 995 | release_firmware(ucode_raw); |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 996 | if (iwl_request_firmware(drv, false)) |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 997 | goto out_unbind; |
| 998 | return; |
| 999 | |
Johannes Berg | 75813bd | 2012-05-16 22:49:49 +0200 | [diff] [blame] | 1000 | out_free_fw: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1001 | IWL_ERR(drv, "failed to allocate pci memory\n"); |
| 1002 | iwl_dealloc_ucode(drv); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 1003 | release_firmware(ucode_raw); |
| 1004 | out_unbind: |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1005 | complete(&drv->request_firmware_complete); |
Emmanuel Grumbach | 93faaee | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 1006 | device_release_driver(drv->trans->dev); |
Johannes Berg | 15854ef9 | 2012-03-05 11:24:50 -0800 | [diff] [blame] | 1007 | } |
| 1008 | |
Emmanuel Grumbach | 87ce05a | 2012-03-26 09:03:18 -0700 | [diff] [blame] | 1009 | struct iwl_drv *iwl_drv_start(struct iwl_trans *trans, |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 1010 | const struct iwl_cfg *cfg) |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1011 | { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1012 | struct iwl_drv *drv; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1013 | int ret; |
| 1014 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1015 | drv = kzalloc(sizeof(*drv), GFP_KERNEL); |
Emmanuel Grumbach | c15797e | 2012-04-19 10:29:58 +0300 | [diff] [blame] | 1016 | if (!drv) |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 1017 | return NULL; |
Emmanuel Grumbach | c15797e | 2012-04-19 10:29:58 +0300 | [diff] [blame] | 1018 | |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 1019 | drv->trans = trans; |
Emmanuel Grumbach | 4b9844f | 2012-03-22 23:59:52 +0200 | [diff] [blame] | 1020 | drv->dev = trans->dev; |
Emmanuel Grumbach | 68f360d | 2012-03-22 17:51:44 +0200 | [diff] [blame] | 1021 | drv->cfg = cfg; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1022 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1023 | init_completion(&drv->request_firmware_complete); |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1024 | INIT_LIST_HEAD(&drv->list); |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1025 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1026 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1027 | /* Create the device debugfs entries. */ |
| 1028 | drv->dbgfs_drv = debugfs_create_dir(dev_name(trans->dev), |
| 1029 | iwl_dbgfs_root); |
| 1030 | |
| 1031 | if (!drv->dbgfs_drv) { |
| 1032 | IWL_ERR(drv, "failed to create debugfs directory\n"); |
| 1033 | goto err_free_drv; |
| 1034 | } |
| 1035 | |
| 1036 | /* Create transport layer debugfs dir */ |
| 1037 | drv->trans->dbgfs_dir = debugfs_create_dir("trans", drv->dbgfs_drv); |
| 1038 | |
| 1039 | if (!drv->trans->dbgfs_dir) { |
| 1040 | IWL_ERR(drv, "failed to create transport debugfs directory\n"); |
| 1041 | goto err_free_dbgfs; |
| 1042 | } |
| 1043 | #endif |
| 1044 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1045 | ret = iwl_request_firmware(drv, true); |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1046 | |
| 1047 | if (ret) { |
Emmanuel Grumbach | c15797e | 2012-04-19 10:29:58 +0300 | [diff] [blame] | 1048 | IWL_ERR(trans, "Couldn't request the fw\n"); |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1049 | goto err_fw; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1050 | } |
| 1051 | |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 1052 | return drv; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1053 | |
| 1054 | err_fw: |
| 1055 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1056 | err_free_dbgfs: |
| 1057 | debugfs_remove_recursive(drv->dbgfs_drv); |
| 1058 | err_free_drv: |
| 1059 | #endif |
| 1060 | kfree(drv); |
| 1061 | drv = NULL; |
| 1062 | |
| 1063 | return drv; |
Emmanuel Grumbach | 5c58edc | 2012-02-07 14:18:40 +0200 | [diff] [blame] | 1064 | } |
| 1065 | |
Emmanuel Grumbach | 9130bab | 2012-03-26 08:51:09 -0700 | [diff] [blame] | 1066 | void iwl_drv_stop(struct iwl_drv *drv) |
Emmanuel Grumbach | 07590f0 | 2012-02-07 14:27:31 +0200 | [diff] [blame] | 1067 | { |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1068 | wait_for_completion(&drv->request_firmware_complete); |
Johannes Berg | 2e7eb11 | 2012-03-05 11:24:51 -0800 | [diff] [blame] | 1069 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1070 | _iwl_op_mode_stop(drv); |
Emmanuel Grumbach | 07590f0 | 2012-02-07 14:27:31 +0200 | [diff] [blame] | 1071 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1072 | iwl_dealloc_ucode(drv); |
Johannes Berg | 7db5b98 | 2012-03-05 11:24:48 -0800 | [diff] [blame] | 1073 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1074 | mutex_lock(&iwlwifi_opmode_table_mtx); |
| 1075 | /* |
| 1076 | * List is empty (this item wasn't added) |
| 1077 | * when firmware loading failed -- in that |
| 1078 | * case we can't remove it from any list. |
| 1079 | */ |
| 1080 | if (!list_empty(&drv->list)) |
| 1081 | list_del(&drv->list); |
| 1082 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
| 1083 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1084 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1085 | debugfs_remove_recursive(drv->dbgfs_drv); |
| 1086 | #endif |
| 1087 | |
Johannes Berg | 965974a6 | 2012-03-06 13:30:38 -0800 | [diff] [blame] | 1088 | kfree(drv); |
Emmanuel Grumbach | 07590f0 | 2012-02-07 14:27:31 +0200 | [diff] [blame] | 1089 | } |
Johannes Berg | 65de7e8 | 2012-04-17 07:36:30 -0700 | [diff] [blame] | 1090 | |
| 1091 | |
| 1092 | /* shared module parameters */ |
| 1093 | struct iwl_mod_params iwlwifi_mod_params = { |
| 1094 | .amsdu_size_8K = 1, |
| 1095 | .restart_fw = 1, |
| 1096 | .plcp_check = true, |
| 1097 | .bt_coex_active = true, |
| 1098 | .power_level = IWL_POWER_INDEX_1, |
| 1099 | .bt_ch_announce = true, |
| 1100 | .auto_agg = true, |
Emmanuel Grumbach | 020c876 | 2012-06-24 15:51:59 +0300 | [diff] [blame] | 1101 | .wd_disable = true, |
Johannes Berg | 65de7e8 | 2012-04-17 07:36:30 -0700 | [diff] [blame] | 1102 | /* the rest are 0 by default */ |
| 1103 | }; |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1104 | EXPORT_SYMBOL_GPL(iwlwifi_mod_params); |
| 1105 | |
| 1106 | int iwl_opmode_register(const char *name, const struct iwl_op_mode_ops *ops) |
| 1107 | { |
| 1108 | int i; |
| 1109 | struct iwl_drv *drv; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1110 | struct iwlwifi_opmode_table *op; |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1111 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1112 | mutex_lock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1113 | for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) { |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1114 | op = &iwlwifi_opmode_table[i]; |
| 1115 | if (strcmp(op->name, name)) |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1116 | continue; |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1117 | op->ops = ops; |
| 1118 | /* TODO: need to handle exceptional case */ |
| 1119 | list_for_each_entry(drv, &op->drv, list) |
| 1120 | drv->op_mode = _iwl_op_mode_start(drv, op); |
| 1121 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1122 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1123 | return 0; |
| 1124 | } |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1125 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1126 | return -EIO; |
| 1127 | } |
| 1128 | EXPORT_SYMBOL_GPL(iwl_opmode_register); |
| 1129 | |
| 1130 | void iwl_opmode_deregister(const char *name) |
| 1131 | { |
| 1132 | int i; |
| 1133 | struct iwl_drv *drv; |
| 1134 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1135 | mutex_lock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1136 | for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) { |
| 1137 | if (strcmp(iwlwifi_opmode_table[i].name, name)) |
| 1138 | continue; |
| 1139 | iwlwifi_opmode_table[i].ops = NULL; |
| 1140 | |
| 1141 | /* call the stop routine for all devices */ |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1142 | list_for_each_entry(drv, &iwlwifi_opmode_table[i].drv, list) |
| 1143 | _iwl_op_mode_stop(drv); |
| 1144 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1145 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1146 | return; |
| 1147 | } |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1148 | mutex_unlock(&iwlwifi_opmode_table_mtx); |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1149 | } |
| 1150 | EXPORT_SYMBOL_GPL(iwl_opmode_deregister); |
| 1151 | |
| 1152 | static int __init iwl_drv_init(void) |
| 1153 | { |
| 1154 | int i; |
| 1155 | |
Johannes Berg | ff1ffb8 | 2012-06-06 09:42:57 +0200 | [diff] [blame] | 1156 | mutex_init(&iwlwifi_opmode_table_mtx); |
| 1157 | |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1158 | for (i = 0; i < ARRAY_SIZE(iwlwifi_opmode_table); i++) |
| 1159 | INIT_LIST_HEAD(&iwlwifi_opmode_table[i].drv); |
| 1160 | |
| 1161 | pr_info(DRV_DESCRIPTION ", " DRV_VERSION "\n"); |
| 1162 | pr_info(DRV_COPYRIGHT "\n"); |
| 1163 | |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1164 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1165 | /* Create the root of iwlwifi debugfs subsystem. */ |
| 1166 | iwl_dbgfs_root = debugfs_create_dir(DRV_NAME, NULL); |
| 1167 | |
| 1168 | if (!iwl_dbgfs_root) |
| 1169 | return -EFAULT; |
| 1170 | #endif |
| 1171 | |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1172 | return iwl_pci_register_driver(); |
| 1173 | } |
| 1174 | module_init(iwl_drv_init); |
| 1175 | |
| 1176 | static void __exit iwl_drv_exit(void) |
| 1177 | { |
| 1178 | iwl_pci_unregister_driver(); |
Meenakshi Venkataraman | 9da987a | 2012-07-16 18:43:56 -0700 | [diff] [blame^] | 1179 | |
| 1180 | #ifdef CONFIG_IWLWIFI_DEBUGFS |
| 1181 | debugfs_remove_recursive(iwl_dbgfs_root); |
| 1182 | #endif |
Don Fry | cc5f7e3 | 2012-05-16 22:54:27 +0200 | [diff] [blame] | 1183 | } |
| 1184 | module_exit(iwl_drv_exit); |
Johannes Berg | 65de7e8 | 2012-04-17 07:36:30 -0700 | [diff] [blame] | 1185 | |
| 1186 | #ifdef CONFIG_IWLWIFI_DEBUG |
| 1187 | module_param_named(debug, iwlwifi_mod_params.debug_level, uint, |
| 1188 | S_IRUGO | S_IWUSR); |
| 1189 | MODULE_PARM_DESC(debug, "debug output mask"); |
| 1190 | #endif |
| 1191 | |
| 1192 | module_param_named(swcrypto, iwlwifi_mod_params.sw_crypto, int, S_IRUGO); |
| 1193 | MODULE_PARM_DESC(swcrypto, "using crypto in software (default 0 [hardware])"); |
| 1194 | module_param_named(11n_disable, iwlwifi_mod_params.disable_11n, uint, S_IRUGO); |
| 1195 | MODULE_PARM_DESC(11n_disable, |
| 1196 | "disable 11n functionality, bitmap: 1: full, 2: agg TX, 4: agg RX"); |
| 1197 | module_param_named(amsdu_size_8K, iwlwifi_mod_params.amsdu_size_8K, |
| 1198 | int, S_IRUGO); |
| 1199 | MODULE_PARM_DESC(amsdu_size_8K, "enable 8K amsdu size"); |
| 1200 | module_param_named(fw_restart, iwlwifi_mod_params.restart_fw, int, S_IRUGO); |
| 1201 | MODULE_PARM_DESC(fw_restart, "restart firmware in case of error"); |
| 1202 | |
| 1203 | module_param_named(antenna_coupling, iwlwifi_mod_params.ant_coupling, |
| 1204 | int, S_IRUGO); |
| 1205 | MODULE_PARM_DESC(antenna_coupling, |
| 1206 | "specify antenna coupling in dB (defualt: 0 dB)"); |
| 1207 | |
| 1208 | module_param_named(bt_ch_inhibition, iwlwifi_mod_params.bt_ch_announce, |
| 1209 | bool, S_IRUGO); |
| 1210 | MODULE_PARM_DESC(bt_ch_inhibition, |
| 1211 | "Enable BT channel inhibition (default: enable)"); |
| 1212 | |
| 1213 | module_param_named(plcp_check, iwlwifi_mod_params.plcp_check, bool, S_IRUGO); |
| 1214 | MODULE_PARM_DESC(plcp_check, "Check plcp health (default: 1 [enabled])"); |
| 1215 | |
| 1216 | module_param_named(wd_disable, iwlwifi_mod_params.wd_disable, int, S_IRUGO); |
| 1217 | MODULE_PARM_DESC(wd_disable, |
| 1218 | "Disable stuck queue watchdog timer 0=system default, " |
| 1219 | "1=disable, 2=enable (default: 0)"); |
| 1220 | |
| 1221 | /* |
| 1222 | * set bt_coex_active to true, uCode will do kill/defer |
| 1223 | * every time the priority line is asserted (BT is sending signals on the |
| 1224 | * priority line in the PCIx). |
| 1225 | * set bt_coex_active to false, uCode will ignore the BT activity and |
| 1226 | * perform the normal operation |
| 1227 | * |
| 1228 | * User might experience transmit issue on some platform due to WiFi/BT |
| 1229 | * co-exist problem. The possible behaviors are: |
| 1230 | * Able to scan and finding all the available AP |
| 1231 | * Not able to associate with any AP |
| 1232 | * On those platforms, WiFi communication can be restored by set |
| 1233 | * "bt_coex_active" module parameter to "false" |
| 1234 | * |
| 1235 | * default: bt_coex_active = true (BT_COEX_ENABLE) |
| 1236 | */ |
| 1237 | module_param_named(bt_coex_active, iwlwifi_mod_params.bt_coex_active, |
| 1238 | bool, S_IRUGO); |
| 1239 | MODULE_PARM_DESC(bt_coex_active, "enable wifi/bt co-exist (default: enable)"); |
| 1240 | |
| 1241 | module_param_named(led_mode, iwlwifi_mod_params.led_mode, int, S_IRUGO); |
| 1242 | MODULE_PARM_DESC(led_mode, "0=system default, " |
| 1243 | "1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)"); |
| 1244 | |
| 1245 | module_param_named(power_save, iwlwifi_mod_params.power_save, |
| 1246 | bool, S_IRUGO); |
| 1247 | MODULE_PARM_DESC(power_save, |
| 1248 | "enable WiFi power management (default: disable)"); |
| 1249 | |
| 1250 | module_param_named(power_level, iwlwifi_mod_params.power_level, |
| 1251 | int, S_IRUGO); |
| 1252 | MODULE_PARM_DESC(power_level, |
| 1253 | "default power save level (range from 1 - 5, default: 1)"); |
| 1254 | |
| 1255 | module_param_named(auto_agg, iwlwifi_mod_params.auto_agg, |
| 1256 | bool, S_IRUGO); |
| 1257 | MODULE_PARM_DESC(auto_agg, |
| 1258 | "enable agg w/o check traffic load (default: enable)"); |
Stanislaw Gruszka | f6b1154 | 2012-04-19 09:51:24 -0700 | [diff] [blame] | 1259 | |
| 1260 | module_param_named(5ghz_disable, iwlwifi_mod_params.disable_5ghz, |
| 1261 | bool, S_IRUGO); |
| 1262 | MODULE_PARM_DESC(5ghz_disable, "disable 5GHz band (default: 0 [enabled])"); |