blob: 33ef736a48578caacac0b0db4e83589e08b05f12 [file] [log] [blame]
Jay Sternberge1228372009-01-19 15:30:34 -08001/******************************************************************************
2 *
3 * Copyright(c) 2008-2009 Intel Corporation. All rights reserved.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along with
15 * this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
17 *
18 * The full GNU General Public License is included in this distribution in the
19 * file called LICENSE.
20 *
21 * Contact Information:
22 * Intel Linux Wireless <ilw@linux.intel.com>
23 * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
24 *
25 *****************************************************************************/
26
27#include <linux/kernel.h>
28#include <linux/module.h>
29#include <linux/init.h>
30#include <linux/pci.h>
31#include <linux/dma-mapping.h>
32#include <linux/delay.h>
33#include <linux/skbuff.h>
34#include <linux/netdevice.h>
35#include <linux/wireless.h>
36#include <net/mac80211.h>
37#include <linux/etherdevice.h>
38#include <asm/unaligned.h>
39
40#include "iwl-eeprom.h"
41#include "iwl-dev.h"
42#include "iwl-core.h"
43#include "iwl-io.h"
44#include "iwl-sta.h"
45#include "iwl-helpers.h"
46#include "iwl-5000-hw.h"
47
48/* Highest firmware API version supported */
Wey-Yi Guyfcbaf8b2009-08-21 13:34:18 -070049#define IWL6000_UCODE_API_MAX 4
50#define IWL6050_UCODE_API_MAX 4
Jay Sternberge1228372009-01-19 15:30:34 -080051
52/* Lowest firmware API version supported */
53#define IWL6000_UCODE_API_MIN 1
54#define IWL6050_UCODE_API_MIN 1
55
56#define IWL6000_FW_PRE "iwlwifi-6000-"
57#define _IWL6000_MODULE_FIRMWARE(api) IWL6000_FW_PRE #api ".ucode"
58#define IWL6000_MODULE_FIRMWARE(api) _IWL6000_MODULE_FIRMWARE(api)
59
60#define IWL6050_FW_PRE "iwlwifi-6050-"
61#define _IWL6050_MODULE_FIRMWARE(api) IWL6050_FW_PRE #api ".ucode"
62#define IWL6050_MODULE_FIRMWARE(api) _IWL6050_MODULE_FIRMWARE(api)
63
Wey-Yi Guy672639d2009-07-24 11:13:01 -070064static void iwl6000_set_ct_threshold(struct iwl_priv *priv)
65{
66 /* want Celsius */
67 priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
68 priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
69}
70
Wey-Yi Guy65b79982009-07-31 14:28:07 -070071/* NIC configuration for 6000 series */
72static void iwl6000_nic_config(struct iwl_priv *priv)
73{
74 iwl5000_nic_config(priv);
75
76 /* no locking required for register write */
77 if (priv->cfg->pa_type == IWL_PA_HYBRID) {
78 /* 2x2 hybrid phy type */
79 iwl_write32(priv, CSR_GP_DRIVER_REG,
80 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_HYB);
81 } else if (priv->cfg->pa_type == IWL_PA_INTERNAL) {
82 /* 2x2 IPA phy type */
83 iwl_write32(priv, CSR_GP_DRIVER_REG,
84 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
85 }
86 /* else do nothing, uCode configured */
87}
88
Wey-Yi Guy672639d2009-07-24 11:13:01 -070089static struct iwl_lib_ops iwl6000_lib = {
90 .set_hw_params = iwl5000_hw_set_hw_params,
91 .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
92 .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
93 .txq_set_sched = iwl5000_txq_set_sched,
94 .txq_agg_enable = iwl5000_txq_agg_enable,
95 .txq_agg_disable = iwl5000_txq_agg_disable,
96 .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
97 .txq_free_tfd = iwl_hw_txq_free_tfd,
98 .txq_init = iwl_hw_tx_queue_init,
99 .rx_handler_setup = iwl5000_rx_handler_setup,
100 .setup_deferred_work = iwl5000_setup_deferred_work,
101 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
102 .load_ucode = iwl5000_load_ucode,
103 .init_alive_start = iwl5000_init_alive_start,
104 .alive_notify = iwl5000_alive_notify,
105 .send_tx_power = iwl5000_send_tx_power,
106 .update_chain_flags = iwl_update_chain_flags,
107 .apm_ops = {
108 .init = iwl5000_apm_init,
109 .reset = iwl5000_apm_reset,
110 .stop = iwl5000_apm_stop,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700111 .config = iwl6000_nic_config,
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700112 .set_pwr_src = iwl_set_pwr_src,
113 },
114 .eeprom_ops = {
115 .regulatory_bands = {
116 EEPROM_5000_REG_BAND_1_CHANNELS,
117 EEPROM_5000_REG_BAND_2_CHANNELS,
118 EEPROM_5000_REG_BAND_3_CHANNELS,
119 EEPROM_5000_REG_BAND_4_CHANNELS,
120 EEPROM_5000_REG_BAND_5_CHANNELS,
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700121 EEPROM_5000_REG_BAND_24_HT40_CHANNELS,
122 EEPROM_5000_REG_BAND_52_HT40_CHANNELS
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700123 },
124 .verify_signature = iwlcore_eeprom_verify_signature,
125 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
126 .release_semaphore = iwlcore_eeprom_release_semaphore,
127 .calib_version = iwl5000_eeprom_calib_version,
128 .query_addr = iwl5000_eeprom_query_addr,
129 },
130 .post_associate = iwl_post_associate,
131 .isr = iwl_isr_ict,
132 .config_ap = iwl_config_ap,
133 .temp_ops = {
134 .temperature = iwl5000_temperature,
135 .set_ct_kill = iwl6000_set_ct_threshold,
136 },
137};
138
Jay Sternberg29f35c12009-01-29 11:09:16 -0800139static struct iwl_hcmd_utils_ops iwl6000_hcmd_utils = {
140 .get_hcmd_size = iwl5000_get_hcmd_size,
141 .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
142 .rts_tx_cmd_flag = iwl5000_rts_tx_cmd_flag,
143 .calc_rssi = iwl5000_calc_rssi,
144};
145
146static struct iwl_ops iwl6000_ops = {
Jay Sternbergcc0f5552009-07-17 09:30:16 -0700147 .ucode = &iwl5000_ucode,
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700148 .lib = &iwl6000_lib,
Jay Sternberg29f35c12009-01-29 11:09:16 -0800149 .hcmd = &iwl5000_hcmd,
150 .utils = &iwl6000_hcmd_utils,
151};
152
Jay Sternberge1228372009-01-19 15:30:34 -0800153
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700154/*
155 * "h": Hybrid configuration, use both internal and external Power Amplifier
156 */
157struct iwl_cfg iwl6000h_2agn_cfg = {
Jay Sternberge1228372009-01-19 15:30:34 -0800158 .name = "6000 Series 2x2 AGN",
159 .fw_name_pre = IWL6000_FW_PRE,
160 .ucode_api_max = IWL6000_UCODE_API_MAX,
161 .ucode_api_min = IWL6000_UCODE_API_MIN,
162 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Jay Sternberg29f35c12009-01-29 11:09:16 -0800163 .ops = &iwl6000_ops,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700164 .eeprom_size = OTP_LOW_IMAGE_SIZE,
Jay Sternberge1228372009-01-19 15:30:34 -0800165 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
166 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
167 .mod_params = &iwl50_mod_params,
Jay Sternberg542cc792009-05-08 13:44:46 -0700168 .valid_tx_ant = ANT_AB,
169 .valid_rx_ant = ANT_AB,
Jay Sternberg050681b2009-01-29 11:09:13 -0800170 .need_pll_cfg = false,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700171 .pa_type = IWL_PA_HYBRID,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700172 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
173 .shadow_ram_support = true,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700174 .ht_greenfield_support = true,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700175};
176
177/*
178 * "i": Internal configuration, use internal Power Amplifier
179 */
180struct iwl_cfg iwl6000i_2agn_cfg = {
181 .name = "6000 Series 2x2 AGN",
182 .fw_name_pre = IWL6000_FW_PRE,
183 .ucode_api_max = IWL6000_UCODE_API_MAX,
184 .ucode_api_min = IWL6000_UCODE_API_MIN,
185 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
186 .ops = &iwl6000_ops,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700187 .eeprom_size = OTP_LOW_IMAGE_SIZE,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700188 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
189 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
190 .mod_params = &iwl50_mod_params,
191 .valid_tx_ant = ANT_BC,
192 .valid_rx_ant = ANT_BC,
193 .need_pll_cfg = false,
194 .pa_type = IWL_PA_INTERNAL,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700195 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
196 .shadow_ram_support = true,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700197 .ht_greenfield_support = true,
Jay Sternberge1228372009-01-19 15:30:34 -0800198};
199
200struct iwl_cfg iwl6050_2agn_cfg = {
201 .name = "6050 Series 2x2 AGN",
202 .fw_name_pre = IWL6050_FW_PRE,
203 .ucode_api_max = IWL6050_UCODE_API_MAX,
204 .ucode_api_min = IWL6050_UCODE_API_MIN,
205 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Jay Sternberg29f35c12009-01-29 11:09:16 -0800206 .ops = &iwl6000_ops,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700207 .eeprom_size = OTP_LOW_IMAGE_SIZE,
Jay Sternberge1228372009-01-19 15:30:34 -0800208 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
209 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
210 .mod_params = &iwl50_mod_params,
Jay Sternberg542cc792009-05-08 13:44:46 -0700211 .valid_tx_ant = ANT_AB,
212 .valid_rx_ant = ANT_AB,
Jay Sternberg050681b2009-01-29 11:09:13 -0800213 .need_pll_cfg = false,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700214 .pa_type = IWL_PA_SYSTEM,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700215 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
216 .shadow_ram_support = true,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700217 .ht_greenfield_support = true,
Jay Sternberge1228372009-01-19 15:30:34 -0800218};
219
220struct iwl_cfg iwl6000_3agn_cfg = {
221 .name = "6000 Series 3x3 AGN",
222 .fw_name_pre = IWL6000_FW_PRE,
223 .ucode_api_max = IWL6000_UCODE_API_MAX,
224 .ucode_api_min = IWL6000_UCODE_API_MIN,
225 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Jay Sternberg29f35c12009-01-29 11:09:16 -0800226 .ops = &iwl6000_ops,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700227 .eeprom_size = OTP_LOW_IMAGE_SIZE,
Jay Sternberge1228372009-01-19 15:30:34 -0800228 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
229 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
230 .mod_params = &iwl50_mod_params,
Jay Sternbergc0bac762009-02-02 16:21:14 -0800231 .valid_tx_ant = ANT_ABC,
232 .valid_rx_ant = ANT_ABC,
Jay Sternberg050681b2009-01-29 11:09:13 -0800233 .need_pll_cfg = false,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700234 .pa_type = IWL_PA_SYSTEM,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700235 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
236 .shadow_ram_support = true,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700237 .ht_greenfield_support = true,
Jay Sternberge1228372009-01-19 15:30:34 -0800238};
239
240struct iwl_cfg iwl6050_3agn_cfg = {
241 .name = "6050 Series 3x3 AGN",
242 .fw_name_pre = IWL6050_FW_PRE,
243 .ucode_api_max = IWL6050_UCODE_API_MAX,
244 .ucode_api_min = IWL6050_UCODE_API_MIN,
245 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Jay Sternberg29f35c12009-01-29 11:09:16 -0800246 .ops = &iwl6000_ops,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700247 .eeprom_size = OTP_LOW_IMAGE_SIZE,
Jay Sternberge1228372009-01-19 15:30:34 -0800248 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
249 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
250 .mod_params = &iwl50_mod_params,
Jay Sternbergc0bac762009-02-02 16:21:14 -0800251 .valid_tx_ant = ANT_ABC,
252 .valid_rx_ant = ANT_ABC,
Jay Sternberg050681b2009-01-29 11:09:13 -0800253 .need_pll_cfg = false,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700254 .pa_type = IWL_PA_SYSTEM,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700255 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
256 .shadow_ram_support = true,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700257 .ht_greenfield_support = true,
Jay Sternberge1228372009-01-19 15:30:34 -0800258};
259
260MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
261MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX));