Linux Audio

Check our new training course

Loading...
Note: File does not exist in v5.4.
  1/******************************************************************************
  2 *
  3 * Copyright(c) 2008 - 2011 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/delay.h>
 31#include <linux/skbuff.h>
 32#include <linux/netdevice.h>
 33#include <linux/wireless.h>
 34#include <net/mac80211.h>
 35#include <linux/etherdevice.h>
 36#include <asm/unaligned.h>
 37#include <linux/stringify.h>
 38
 39#include "iwl-eeprom.h"
 40#include "iwl-dev.h"
 41#include "iwl-core.h"
 42#include "iwl-io.h"
 43#include "iwl-sta.h"
 44#include "iwl-agn.h"
 45#include "iwl-helpers.h"
 46#include "iwl-agn-hw.h"
 47#include "iwl-6000-hw.h"
 48
 49/* Highest firmware API version supported */
 50#define IWL2030_UCODE_API_MAX 5
 51#define IWL2000_UCODE_API_MAX 5
 52#define IWL105_UCODE_API_MAX 5
 53#define IWL135_UCODE_API_MAX 5
 54
 55/* Lowest firmware API version supported */
 56#define IWL2030_UCODE_API_MIN 5
 57#define IWL2000_UCODE_API_MIN 5
 58#define IWL105_UCODE_API_MIN 5
 59#define IWL135_UCODE_API_MIN 5
 60
 61#define IWL2030_FW_PRE "iwlwifi-2030-"
 62#define IWL2030_MODULE_FIRMWARE(api) IWL2030_FW_PRE __stringify(api) ".ucode"
 63
 64#define IWL2000_FW_PRE "iwlwifi-2000-"
 65#define IWL2000_MODULE_FIRMWARE(api) IWL2000_FW_PRE __stringify(api) ".ucode"
 66
 67#define IWL105_FW_PRE "iwlwifi-105-"
 68#define IWL105_MODULE_FIRMWARE(api) IWL105_FW_PRE __stringify(api) ".ucode"
 69
 70#define IWL135_FW_PRE "iwlwifi-135-"
 71#define IWL135_MODULE_FIRMWARE(api) IWL135_FW_PRE #api ".ucode"
 72
 73static void iwl2000_set_ct_threshold(struct iwl_priv *priv)
 74{
 75	/* want Celsius */
 76	priv->hw_params.ct_kill_threshold = CT_KILL_THRESHOLD;
 77	priv->hw_params.ct_kill_exit_threshold = CT_KILL_EXIT_THRESHOLD;
 78}
 79
 80/* NIC configuration for 2000 series */
 81static void iwl2000_nic_config(struct iwl_priv *priv)
 82{
 83	iwl_rf_config(priv);
 84
 85	if (priv->cfg->iq_invert)
 86		iwl_set_bit(priv, CSR_GP_DRIVER_REG,
 87			    CSR_GP_DRIVER_REG_BIT_RADIO_IQ_INVER);
 88}
 89
 90static struct iwl_sensitivity_ranges iwl2000_sensitivity = {
 91	.min_nrg_cck = 97,
 92	.max_nrg_cck = 0, /* not used, set to 0 */
 93	.auto_corr_min_ofdm = 80,
 94	.auto_corr_min_ofdm_mrc = 128,
 95	.auto_corr_min_ofdm_x1 = 105,
 96	.auto_corr_min_ofdm_mrc_x1 = 192,
 97
 98	.auto_corr_max_ofdm = 145,
 99	.auto_corr_max_ofdm_mrc = 232,
100	.auto_corr_max_ofdm_x1 = 110,
101	.auto_corr_max_ofdm_mrc_x1 = 232,
102
103	.auto_corr_min_cck = 125,
104	.auto_corr_max_cck = 175,
105	.auto_corr_min_cck_mrc = 160,
106	.auto_corr_max_cck_mrc = 310,
107	.nrg_th_cck = 97,
108	.nrg_th_ofdm = 100,
109
110	.barker_corr_th_min = 190,
111	.barker_corr_th_min_mrc = 390,
112	.nrg_th_cca = 62,
113};
114
115static int iwl2000_hw_set_hw_params(struct iwl_priv *priv)
116{
117	if (iwlagn_mod_params.num_of_queues >= IWL_MIN_NUM_QUEUES &&
118	    iwlagn_mod_params.num_of_queues <= IWLAGN_NUM_QUEUES)
119		priv->cfg->base_params->num_of_queues =
120			iwlagn_mod_params.num_of_queues;
121
122	priv->hw_params.max_txq_num = priv->cfg->base_params->num_of_queues;
123	priv->hw_params.scd_bc_tbls_size =
124		priv->cfg->base_params->num_of_queues *
125		sizeof(struct iwlagn_scd_bc_tbl);
126	priv->hw_params.tfd_size = sizeof(struct iwl_tfd);
127	priv->hw_params.max_stations = IWLAGN_STATION_COUNT;
128	priv->contexts[IWL_RXON_CTX_BSS].bcast_sta_id = IWLAGN_BROADCAST_ID;
129
130	priv->hw_params.max_data_size = IWL60_RTC_DATA_SIZE;
131	priv->hw_params.max_inst_size = IWL60_RTC_INST_SIZE;
132
133	priv->hw_params.ht40_channel =  BIT(IEEE80211_BAND_2GHZ) |
134					BIT(IEEE80211_BAND_5GHZ);
135
136	priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant);
137	if (priv->cfg->rx_with_siso_diversity)
138		priv->hw_params.rx_chains_num = 1;
139	else
140		priv->hw_params.rx_chains_num =
141			num_of_ant(priv->cfg->valid_rx_ant);
142	priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant;
143	priv->hw_params.valid_rx_ant = priv->cfg->valid_rx_ant;
144
145	iwl2000_set_ct_threshold(priv);
146
147	/* Set initial sensitivity parameters */
148	/* Set initial calibration set */
149	priv->hw_params.sens = &iwl2000_sensitivity;
150	priv->hw_params.calib_init_cfg =
151		BIT(IWL_CALIB_XTAL)             |
152		BIT(IWL_CALIB_LO)               |
153		BIT(IWL_CALIB_TX_IQ)            |
154		BIT(IWL_CALIB_BASE_BAND);
155	if (priv->cfg->need_dc_calib)
156		priv->hw_params.calib_rt_cfg |= IWL_CALIB_CFG_DC_IDX;
157	if (priv->cfg->need_temp_offset_calib)
158		priv->hw_params.calib_init_cfg |= BIT(IWL_CALIB_TEMP_OFFSET);
159
160	priv->hw_params.beacon_time_tsf_bits = IWLAGN_EXT_BEACON_TIME_POS;
161
162	return 0;
163}
164
165static struct iwl_lib_ops iwl2000_lib = {
166	.set_hw_params = iwl2000_hw_set_hw_params,
167	.nic_config = iwl2000_nic_config,
168	.eeprom_ops = {
169		.regulatory_bands = {
170			EEPROM_REG_BAND_1_CHANNELS,
171			EEPROM_REG_BAND_2_CHANNELS,
172			EEPROM_REG_BAND_3_CHANNELS,
173			EEPROM_REG_BAND_4_CHANNELS,
174			EEPROM_REG_BAND_5_CHANNELS,
175			EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
176			EEPROM_REGULATORY_BAND_NO_HT40,
177		},
178		.update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
179	},
180	.temperature = iwlagn_temperature,
181};
182
183static struct iwl_lib_ops iwl2030_lib = {
184	.set_hw_params = iwl2000_hw_set_hw_params,
185	.bt_rx_handler_setup = iwlagn_bt_rx_handler_setup,
186	.bt_setup_deferred_work = iwlagn_bt_setup_deferred_work,
187	.cancel_deferred_work = iwlagn_bt_cancel_deferred_work,
188	.nic_config = iwl2000_nic_config,
189	.eeprom_ops = {
190		.regulatory_bands = {
191			EEPROM_REG_BAND_1_CHANNELS,
192			EEPROM_REG_BAND_2_CHANNELS,
193			EEPROM_REG_BAND_3_CHANNELS,
194			EEPROM_REG_BAND_4_CHANNELS,
195			EEPROM_REG_BAND_5_CHANNELS,
196			EEPROM_6000_REG_BAND_24_HT40_CHANNELS,
197			EEPROM_REGULATORY_BAND_NO_HT40,
198		},
199		.update_enhanced_txpower = iwlcore_eeprom_enhanced_txpower,
200	},
201	.temperature = iwlagn_temperature,
202};
203
204static struct iwl_base_params iwl2000_base_params = {
205	.eeprom_size = OTP_LOW_IMAGE_SIZE,
206	.num_of_queues = IWLAGN_NUM_QUEUES,
207	.num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
208	.pll_cfg_val = 0,
209	.max_ll_items = OTP_MAX_LL_ITEMS_2x00,
210	.shadow_ram_support = true,
211	.led_compensation = 51,
212	.chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
213	.adv_thermal_throttle = true,
214	.support_ct_kill_exit = true,
215	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
216	.chain_noise_scale = 1000,
217	.wd_timeout = IWL_DEF_WD_TIMEOUT,
218	.max_event_log_size = 512,
219	.shadow_reg_enable = true,
220};
221
222
223static struct iwl_base_params iwl2030_base_params = {
224	.eeprom_size = OTP_LOW_IMAGE_SIZE,
225	.num_of_queues = IWLAGN_NUM_QUEUES,
226	.num_of_ampdu_queues = IWLAGN_NUM_AMPDU_QUEUES,
227	.pll_cfg_val = 0,
228	.max_ll_items = OTP_MAX_LL_ITEMS_2x00,
229	.shadow_ram_support = true,
230	.led_compensation = 57,
231	.chain_noise_num_beacons = IWL_CAL_NUM_BEACONS,
232	.adv_thermal_throttle = true,
233	.support_ct_kill_exit = true,
234	.plcp_delta_threshold = IWL_MAX_PLCP_ERR_THRESHOLD_DEF,
235	.chain_noise_scale = 1000,
236	.wd_timeout = IWL_LONG_WD_TIMEOUT,
237	.max_event_log_size = 512,
238	.shadow_reg_enable = true,
239};
240
241static struct iwl_ht_params iwl2000_ht_params = {
242	.ht_greenfield_support = true,
243	.use_rts_for_aggregation = true, /* use rts/cts protection */
244};
245
246static struct iwl_bt_params iwl2030_bt_params = {
247	/* Due to bluetooth, we transmit 2.4 GHz probes only on antenna A */
248	.advanced_bt_coexist = true,
249	.agg_time_limit = BT_AGG_THRESHOLD_DEF,
250	.bt_init_traffic_load = IWL_BT_COEX_TRAFFIC_LOAD_NONE,
251	.bt_prio_boost = IWLAGN_BT_PRIO_BOOST_DEFAULT,
252	.bt_sco_disable = true,
253	.bt_session_2 = true,
254};
255
256#define IWL_DEVICE_2000						\
257	.fw_name_pre = IWL2000_FW_PRE,				\
258	.ucode_api_max = IWL2000_UCODE_API_MAX,			\
259	.ucode_api_min = IWL2000_UCODE_API_MIN,			\
260	.eeprom_ver = EEPROM_2000_EEPROM_VERSION,		\
261	.eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION,	\
262	.lib = &iwl2000_lib,					\
263	.base_params = &iwl2000_base_params,			\
264	.need_dc_calib = true,					\
265	.need_temp_offset_calib = true,				\
266	.led_mode = IWL_LED_RF_STATE,				\
267	.iq_invert = true					\
268
269struct iwl_cfg iwl2000_2bgn_cfg = {
270	.name = "2000 Series 2x2 BGN",
271	IWL_DEVICE_2000,
272	.ht_params = &iwl2000_ht_params,
273};
274
275struct iwl_cfg iwl2000_2bg_cfg = {
276	.name = "2000 Series 2x2 BG",
277	IWL_DEVICE_2000,
278};
279
280#define IWL_DEVICE_2030						\
281	.fw_name_pre = IWL2030_FW_PRE,				\
282	.ucode_api_max = IWL2030_UCODE_API_MAX,			\
283	.ucode_api_min = IWL2030_UCODE_API_MIN,			\
284	.eeprom_ver = EEPROM_2000_EEPROM_VERSION,		\
285	.eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION,	\
286	.lib = &iwl2030_lib,					\
287	.base_params = &iwl2030_base_params,			\
288	.bt_params = &iwl2030_bt_params,			\
289	.need_dc_calib = true,					\
290	.need_temp_offset_calib = true,				\
291	.led_mode = IWL_LED_RF_STATE,				\
292	.adv_pm = true,						\
293	.iq_invert = true					\
294
295struct iwl_cfg iwl2030_2bgn_cfg = {
296	.name = "2000 Series 2x2 BGN/BT",
297	IWL_DEVICE_2030,
298	.ht_params = &iwl2000_ht_params,
299};
300
301struct iwl_cfg iwl2030_2bg_cfg = {
302	.name = "2000 Series 2x2 BG/BT",
303	IWL_DEVICE_2030,
304};
305
306#define IWL_DEVICE_105						\
307	.fw_name_pre = IWL105_FW_PRE,				\
308	.ucode_api_max = IWL105_UCODE_API_MAX,			\
309	.ucode_api_min = IWL105_UCODE_API_MIN,			\
310	.eeprom_ver = EEPROM_2000_EEPROM_VERSION,		\
311	.eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION,	\
312	.lib = &iwl2000_lib,					\
313	.base_params = &iwl2000_base_params,			\
314	.need_dc_calib = true,					\
315	.need_temp_offset_calib = true,				\
316	.led_mode = IWL_LED_RF_STATE,				\
317	.adv_pm = true,						\
318	.rx_with_siso_diversity = true,				\
319	.iq_invert = true					\
320
321struct iwl_cfg iwl105_bg_cfg = {
322	.name = "105 Series 1x1 BG",
323	IWL_DEVICE_105,
324};
325
326struct iwl_cfg iwl105_bgn_cfg = {
327	.name = "105 Series 1x1 BGN",
328	IWL_DEVICE_105,
329	.ht_params = &iwl2000_ht_params,
330};
331
332#define IWL_DEVICE_135						\
333	.fw_name_pre = IWL135_FW_PRE,				\
334	.ucode_api_max = IWL135_UCODE_API_MAX,			\
335	.ucode_api_min = IWL135_UCODE_API_MIN,			\
336	.eeprom_ver = EEPROM_2000_EEPROM_VERSION,		\
337	.eeprom_calib_ver = EEPROM_2000_TX_POWER_VERSION,	\
338	.lib = &iwl2030_lib,					\
339	.base_params = &iwl2030_base_params,			\
340	.bt_params = &iwl2030_bt_params,			\
341	.need_dc_calib = true,					\
342	.need_temp_offset_calib = true,				\
343	.led_mode = IWL_LED_RF_STATE,				\
344	.adv_pm = true,						\
345	.rx_with_siso_diversity = true,				\
346	.iq_invert = true					\
347
348struct iwl_cfg iwl135_bg_cfg = {
349	.name = "135 Series 1x1 BG/BT",
350	IWL_DEVICE_135,
351};
352
353struct iwl_cfg iwl135_bgn_cfg = {
354	.name = "135 Series 1x1 BGN/BT",
355	IWL_DEVICE_135,
356	.ht_params = &iwl2000_ht_params,
357};
358
359MODULE_FIRMWARE(IWL2000_MODULE_FIRMWARE(IWL2000_UCODE_API_MAX));
360MODULE_FIRMWARE(IWL2030_MODULE_FIRMWARE(IWL2030_UCODE_API_MAX));
361MODULE_FIRMWARE(IWL105_MODULE_FIRMWARE(IWL105_UCODE_API_MAX));
362MODULE_FIRMWARE(IWL135_MODULE_FIRMWARE(IWL135_UCODE_API_MAX));