blob: 37b3e2086633d43e1d57c605386a2975740344ba [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{
Wey-Yi Guy9371d4e2009-09-11 10:38:10 -070074 u16 radio_cfg;
75
76 radio_cfg = iwl_eeprom_query16(priv, EEPROM_RADIO_CONFIG);
77
78 /* write radio config values to register */
79 if (EEPROM_RF_CFG_TYPE_MSK(radio_cfg) <= EEPROM_RF_CONFIG_TYPE_MAX)
80 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
81 EEPROM_RF_CFG_TYPE_MSK(radio_cfg) |
82 EEPROM_RF_CFG_STEP_MSK(radio_cfg) |
83 EEPROM_RF_CFG_DASH_MSK(radio_cfg));
84
85 /* set CSR_HW_CONFIG_REG for uCode use */
86 iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG,
87 CSR_HW_IF_CONFIG_REG_BIT_RADIO_SI |
88 CSR_HW_IF_CONFIG_REG_BIT_MAC_SI);
Wey-Yi Guy65b79982009-07-31 14:28:07 -070089
90 /* no locking required for register write */
91 if (priv->cfg->pa_type == IWL_PA_HYBRID) {
92 /* 2x2 hybrid phy type */
93 iwl_write32(priv, CSR_GP_DRIVER_REG,
94 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_HYB);
95 } else if (priv->cfg->pa_type == IWL_PA_INTERNAL) {
96 /* 2x2 IPA phy type */
97 iwl_write32(priv, CSR_GP_DRIVER_REG,
98 CSR_GP_DRIVER_REG_BIT_RADIO_SKU_2x2_IPA);
99 }
100 /* else do nothing, uCode configured */
101}
102
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700103static struct iwl_lib_ops iwl6000_lib = {
104 .set_hw_params = iwl5000_hw_set_hw_params,
105 .txq_update_byte_cnt_tbl = iwl5000_txq_update_byte_cnt_tbl,
106 .txq_inval_byte_cnt_tbl = iwl5000_txq_inval_byte_cnt_tbl,
107 .txq_set_sched = iwl5000_txq_set_sched,
108 .txq_agg_enable = iwl5000_txq_agg_enable,
109 .txq_agg_disable = iwl5000_txq_agg_disable,
110 .txq_attach_buf_to_tfd = iwl_hw_txq_attach_buf_to_tfd,
111 .txq_free_tfd = iwl_hw_txq_free_tfd,
112 .txq_init = iwl_hw_tx_queue_init,
113 .rx_handler_setup = iwl5000_rx_handler_setup,
114 .setup_deferred_work = iwl5000_setup_deferred_work,
115 .is_valid_rtc_data_addr = iwl5000_hw_valid_rtc_data_addr,
116 .load_ucode = iwl5000_load_ucode,
Reinette Chatreb7a79402009-09-25 14:24:23 -0700117 .dump_nic_event_log = iwl_dump_nic_event_log,
118 .dump_nic_error_log = iwl_dump_nic_error_log,
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700119 .init_alive_start = iwl5000_init_alive_start,
120 .alive_notify = iwl5000_alive_notify,
121 .send_tx_power = iwl5000_send_tx_power,
122 .update_chain_flags = iwl_update_chain_flags,
123 .apm_ops = {
124 .init = iwl5000_apm_init,
125 .reset = iwl5000_apm_reset,
126 .stop = iwl5000_apm_stop,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700127 .config = iwl6000_nic_config,
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700128 .set_pwr_src = iwl_set_pwr_src,
129 },
130 .eeprom_ops = {
131 .regulatory_bands = {
132 EEPROM_5000_REG_BAND_1_CHANNELS,
133 EEPROM_5000_REG_BAND_2_CHANNELS,
134 EEPROM_5000_REG_BAND_3_CHANNELS,
135 EEPROM_5000_REG_BAND_4_CHANNELS,
136 EEPROM_5000_REG_BAND_5_CHANNELS,
Wey-Yi Guy7aafef12009-08-07 15:41:38 -0700137 EEPROM_5000_REG_BAND_24_HT40_CHANNELS,
138 EEPROM_5000_REG_BAND_52_HT40_CHANNELS
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700139 },
140 .verify_signature = iwlcore_eeprom_verify_signature,
141 .acquire_semaphore = iwlcore_eeprom_acquire_semaphore,
142 .release_semaphore = iwlcore_eeprom_release_semaphore,
143 .calib_version = iwl5000_eeprom_calib_version,
144 .query_addr = iwl5000_eeprom_query_addr,
Wey-Yi Guyab9fd1b2009-08-21 13:34:23 -0700145 .update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700146 },
147 .post_associate = iwl_post_associate,
148 .isr = iwl_isr_ict,
149 .config_ap = iwl_config_ap,
150 .temp_ops = {
151 .temperature = iwl5000_temperature,
152 .set_ct_kill = iwl6000_set_ct_threshold,
153 },
154};
155
Jay Sternberg29f35c12009-01-29 11:09:16 -0800156static struct iwl_hcmd_utils_ops iwl6000_hcmd_utils = {
157 .get_hcmd_size = iwl5000_get_hcmd_size,
158 .build_addsta_hcmd = iwl5000_build_addsta_hcmd,
159 .rts_tx_cmd_flag = iwl5000_rts_tx_cmd_flag,
160 .calc_rssi = iwl5000_calc_rssi,
161};
162
163static struct iwl_ops iwl6000_ops = {
Jay Sternbergcc0f5552009-07-17 09:30:16 -0700164 .ucode = &iwl5000_ucode,
Wey-Yi Guy672639d2009-07-24 11:13:01 -0700165 .lib = &iwl6000_lib,
Jay Sternberg29f35c12009-01-29 11:09:16 -0800166 .hcmd = &iwl5000_hcmd,
167 .utils = &iwl6000_hcmd_utils,
168};
169
Jay Sternberge1228372009-01-19 15:30:34 -0800170
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700171/*
172 * "h": Hybrid configuration, use both internal and external Power Amplifier
173 */
174struct iwl_cfg iwl6000h_2agn_cfg = {
Jay Sternberge1228372009-01-19 15:30:34 -0800175 .name = "6000 Series 2x2 AGN",
176 .fw_name_pre = IWL6000_FW_PRE,
177 .ucode_api_max = IWL6000_UCODE_API_MAX,
178 .ucode_api_min = IWL6000_UCODE_API_MIN,
179 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Jay Sternberg29f35c12009-01-29 11:09:16 -0800180 .ops = &iwl6000_ops,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700181 .eeprom_size = OTP_LOW_IMAGE_SIZE,
Jay Sternberge1228372009-01-19 15:30:34 -0800182 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
183 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
184 .mod_params = &iwl50_mod_params,
Jay Sternberg542cc792009-05-08 13:44:46 -0700185 .valid_tx_ant = ANT_AB,
186 .valid_rx_ant = ANT_AB,
Jay Sternberg050681b2009-01-29 11:09:13 -0800187 .need_pll_cfg = false,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700188 .pa_type = IWL_PA_HYBRID,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700189 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
190 .shadow_ram_support = true,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700191 .ht_greenfield_support = true,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700192};
193
194/*
195 * "i": Internal configuration, use internal Power Amplifier
196 */
197struct iwl_cfg iwl6000i_2agn_cfg = {
198 .name = "6000 Series 2x2 AGN",
199 .fw_name_pre = IWL6000_FW_PRE,
200 .ucode_api_max = IWL6000_UCODE_API_MAX,
201 .ucode_api_min = IWL6000_UCODE_API_MIN,
202 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
203 .ops = &iwl6000_ops,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700204 .eeprom_size = OTP_LOW_IMAGE_SIZE,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700205 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
206 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
207 .mod_params = &iwl50_mod_params,
208 .valid_tx_ant = ANT_BC,
209 .valid_rx_ant = ANT_BC,
210 .need_pll_cfg = false,
211 .pa_type = IWL_PA_INTERNAL,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700212 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
213 .shadow_ram_support = true,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700214 .ht_greenfield_support = true,
Jay Sternberge1228372009-01-19 15:30:34 -0800215};
216
217struct iwl_cfg iwl6050_2agn_cfg = {
218 .name = "6050 Series 2x2 AGN",
219 .fw_name_pre = IWL6050_FW_PRE,
220 .ucode_api_max = IWL6050_UCODE_API_MAX,
221 .ucode_api_min = IWL6050_UCODE_API_MIN,
222 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Jay Sternberg29f35c12009-01-29 11:09:16 -0800223 .ops = &iwl6000_ops,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700224 .eeprom_size = OTP_LOW_IMAGE_SIZE,
Jay Sternberge1228372009-01-19 15:30:34 -0800225 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
226 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
227 .mod_params = &iwl50_mod_params,
Jay Sternberg542cc792009-05-08 13:44:46 -0700228 .valid_tx_ant = ANT_AB,
229 .valid_rx_ant = ANT_AB,
Jay Sternberg050681b2009-01-29 11:09:13 -0800230 .need_pll_cfg = false,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700231 .pa_type = IWL_PA_SYSTEM,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700232 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
233 .shadow_ram_support = true,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700234 .ht_greenfield_support = true,
Jay Sternberge1228372009-01-19 15:30:34 -0800235};
236
237struct iwl_cfg iwl6000_3agn_cfg = {
238 .name = "6000 Series 3x3 AGN",
239 .fw_name_pre = IWL6000_FW_PRE,
240 .ucode_api_max = IWL6000_UCODE_API_MAX,
241 .ucode_api_min = IWL6000_UCODE_API_MIN,
242 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Jay Sternberg29f35c12009-01-29 11:09:16 -0800243 .ops = &iwl6000_ops,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700244 .eeprom_size = OTP_LOW_IMAGE_SIZE,
Jay Sternberge1228372009-01-19 15:30:34 -0800245 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
246 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
247 .mod_params = &iwl50_mod_params,
Jay Sternbergc0bac762009-02-02 16:21:14 -0800248 .valid_tx_ant = ANT_ABC,
249 .valid_rx_ant = ANT_ABC,
Jay Sternberg050681b2009-01-29 11:09:13 -0800250 .need_pll_cfg = false,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700251 .pa_type = IWL_PA_SYSTEM,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700252 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
253 .shadow_ram_support = true,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700254 .ht_greenfield_support = true,
Jay Sternberge1228372009-01-19 15:30:34 -0800255};
256
257struct iwl_cfg iwl6050_3agn_cfg = {
258 .name = "6050 Series 3x3 AGN",
259 .fw_name_pre = IWL6050_FW_PRE,
260 .ucode_api_max = IWL6050_UCODE_API_MAX,
261 .ucode_api_min = IWL6050_UCODE_API_MIN,
262 .sku = IWL_SKU_A|IWL_SKU_G|IWL_SKU_N,
Jay Sternberg29f35c12009-01-29 11:09:16 -0800263 .ops = &iwl6000_ops,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700264 .eeprom_size = OTP_LOW_IMAGE_SIZE,
Jay Sternberge1228372009-01-19 15:30:34 -0800265 .eeprom_ver = EEPROM_5000_EEPROM_VERSION,
266 .eeprom_calib_ver = EEPROM_5000_TX_POWER_VERSION,
267 .mod_params = &iwl50_mod_params,
Jay Sternbergc0bac762009-02-02 16:21:14 -0800268 .valid_tx_ant = ANT_ABC,
269 .valid_rx_ant = ANT_ABC,
Jay Sternberg050681b2009-01-29 11:09:13 -0800270 .need_pll_cfg = false,
Wey-Yi Guy65b79982009-07-31 14:28:07 -0700271 .pa_type = IWL_PA_SYSTEM,
Wey-Yi Guy415e4992009-08-13 13:30:54 -0700272 .max_ll_items = OTP_MAX_LL_ITEMS_6x00,
273 .shadow_ram_support = true,
Daniel C Halperinb2617932009-08-13 13:30:59 -0700274 .ht_greenfield_support = true,
Jay Sternberge1228372009-01-19 15:30:34 -0800275};
276
277MODULE_FIRMWARE(IWL6000_MODULE_FIRMWARE(IWL6000_UCODE_API_MAX));
278MODULE_FIRMWARE(IWL6050_MODULE_FIRMWARE(IWL6050_UCODE_API_MAX));