xref: /illumos-gate/usr/src/uts/common/io/iwk/iwk_eeprom.h (revision cdc64593)
1c533a883Shx /*
2c533a883Shx  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
3c533a883Shx  * Use is subject to license terms.
4c533a883Shx  */
5c533a883Shx 
6c533a883Shx /*
7c533a883Shx  * Copyright (c) 2007, Intel Corporation
8c533a883Shx  * All rights reserved.
9c533a883Shx  */
10c533a883Shx 
11c533a883Shx /*
12c533a883Shx  * Sun elects to use this software under the BSD license.
13c533a883Shx  */
14c533a883Shx 
15c533a883Shx /*
16c533a883Shx  * This file is provided under a dual BSD/GPLv2 license.  When using or
17c533a883Shx  * redistributing this file, you may do so under either license.
18c533a883Shx  *
19c533a883Shx  * GPL LICENSE SUMMARY
20c533a883Shx  *
21c533a883Shx  * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
22c533a883Shx  *
23c533a883Shx  * This program is free software; you can redistribute it and/or modify
24c533a883Shx  * it under the terms of version 2 of the GNU Geeral Public License as
25c533a883Shx  * published by the Free Software Foundation.
26c533a883Shx  *
27c533a883Shx  * This program is distributed in the hope that it will be useful, but
28c533a883Shx  * WITHOUT ANY WARRANTY; without even the implied warranty of
29c533a883Shx  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
30c533a883Shx  * General Public License for more details.
31c533a883Shx  *
32c533a883Shx  * You should have received a copy of the GNU General Public License
33c533a883Shx  * along with this program; if not, write to the Free Software
34c533a883Shx  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
35c533a883Shx  * USA
36c533a883Shx  *
37c533a883Shx  * The full GNU General Public License is included in this distribution
38c533a883Shx  * in the file called LICENSE.GPL.
39c533a883Shx  *
40c533a883Shx  * Contact Information:
41c533a883Shx  * James P. Ketrenos <ipw2100-admin@linux.intel.com>
42c533a883Shx  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
43c533a883Shx  *
44c533a883Shx  * BSD LICENSE
45c533a883Shx  *
46c533a883Shx  * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
47c533a883Shx  * All rights reserved.
48c533a883Shx  *
49c533a883Shx  * Redistribution and use in source and binary forms, with or without
50c533a883Shx  * modification, are permitted provided that the following conditions
51c533a883Shx  * are met:
52c533a883Shx  *
53c533a883Shx  *  * Redistributions of source code must retain the above copyright
54c533a883Shx  *    notice, this list of conditions and the following disclaimer.
55c533a883Shx  *  * Redistributions in binary form must reproduce the above copyright
56c533a883Shx  *    notice, this list of conditions and the following disclaimer in
57c533a883Shx  *    the documentation and/or other materials provided with the
58c533a883Shx  *    distribution.
59c533a883Shx  *  * Neither the name Intel Corporation nor the names of its
60c533a883Shx  *    contributors may be used to endorse or promote products derived
61c533a883Shx  *    from this software without specific prior written permission.
62c533a883Shx  *
63c533a883Shx  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
64c533a883Shx  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
65c533a883Shx  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
66c533a883Shx  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
67c533a883Shx  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
68c533a883Shx  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
69c533a883Shx  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
70c533a883Shx  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
71c533a883Shx  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
72c533a883Shx  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
73c533a883Shx  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
74c533a883Shx  */
75c533a883Shx 
76c533a883Shx #ifndef _IWK_EEPROM_H_
77c533a883Shx #define	_IWK_EEPROM_H_
78c533a883Shx 
79c533a883Shx /*
80c533a883Shx  * This file defines EEPROM related constants, enums, and inline functions.
81c533a883Shx  */
82c533a883Shx 
83c533a883Shx /*
84c533a883Shx  * EEPROM field values
85c533a883Shx  */
86c533a883Shx #define	ANTENNA_SWITCH_NORMAL		0
87c533a883Shx #define	ANTENNA_SWITCH_INVERSE		1
88c533a883Shx 
89c533a883Shx enum {
90c533a883Shx 	EEPROM_CHANNEL_VALID = (1 << 0),	/* usable for this SKU/geo */
91c533a883Shx 	EEPROM_CHANNEL_IBSS = (1 << 1),	/* usable as an IBSS channel */
92c533a883Shx 	/* Bit 2 Reserved */
93c533a883Shx 	EEPROM_CHANNEL_ACTIVE = (1 << 3),	/* active scanning allowed */
94c533a883Shx 	EEPROM_CHANNEL_RADAR = (1 << 4),	/* radar detection required */
95c533a883Shx 	EEPROM_CHANNEL_WIDE = (1 << 5),
96c533a883Shx 	EEPROM_CHANNEL_NARROW = (1 << 6),
97c533a883Shx 	EEPROM_CHANNEL_DFS = (1 << 7),	/* dynamic freq selection candidate */
98c533a883Shx };
99c533a883Shx 
100c533a883Shx /*
101c533a883Shx  * EEPROM field lengths
102c533a883Shx  */
103c533a883Shx #define	EEPROM_BOARD_PBA_NUMBER_LENGTH		11
104c533a883Shx 
105c533a883Shx /*
106c533a883Shx  * EEPROM field lengths
107c533a883Shx  */
108c533a883Shx #define	EEPROM_BOARD_PBA_NUMBER_LENGTH		11
109c533a883Shx #define	EEPROM_REGULATORY_SKU_ID_LENGTH		4
110c533a883Shx #define	EEPROM_REGULATORY_BAND1_CHANNELS_LENGTH	14
111c533a883Shx #define	EEPROM_REGULATORY_BAND2_CHANNELS_LENGTH	13
112c533a883Shx #define	EEPROM_REGULATORY_BAND3_CHANNELS_LENGTH	12
113c533a883Shx #define	EEPROM_REGULATORY_BAND4_CHANNELS_LENGTH	11
114c533a883Shx #define	EEPROM_REGULATORY_BAND5_CHANNELS_LENGTH	6
115c533a883Shx 
116c533a883Shx 
117c533a883Shx #define	EEPROM_REGULATORY_NUMBER_OF_BANDS	5
118c533a883Shx 
119c533a883Shx /*
120c533a883Shx  * SKU Capabilities
121c533a883Shx  */
122c533a883Shx #define	EEPROM_SKU_CAP_SW_RF_KILL_ENABLE	(1 << 0)
123c533a883Shx #define	EEPROM_SKU_CAP_HW_RF_KILL_ENABLE	(1 << 1)
124c533a883Shx #define	EEPROM_SKU_CAP_OP_MODE_MRC		(1 << 7)
125c533a883Shx 
126c533a883Shx /*
127c533a883Shx  * *regulatory* channel data from eeprom, one for each channel
128c533a883Shx  */
129c533a883Shx struct iwl_eeprom_channel {
130c533a883Shx 	uint8_t flags;		/* flags copied from EEPROM */
131c533a883Shx 	int8_t max_power_avg;	/* max power (dBm) on this chnl, limit 31 */
132c533a883Shx };
133c533a883Shx 
134c533a883Shx /*
135c533a883Shx  * Mapping of a Tx power level, at factory calibration temperature,
136c533a883Shx  *   to a radio/DSP gain table index.
137c533a883Shx  * One for each of 5 "sample" power levels in each band.
138c533a883Shx  * v_det is measured at the factory, using the 3945's built-in power amplifier
139c533a883Shx  *   (PA) output voltage detector.  This same detector is used during Tx of
140c533a883Shx  *   long packets in normal operation to provide feedback as to proper output
141c533a883Shx  *   level.
142c533a883Shx  * Data copied from EEPROM.
143c533a883Shx  */
144c533a883Shx struct iwl_eeprom_txpower_sample {
145c533a883Shx 	uint8_t gain_index;	/* index into power (gain) setup table ... */
146c533a883Shx 	int8_t power;		/* ... for this pwr level for this chnl group */
147c533a883Shx 	uint16_t v_det;		/* PA output voltage */
148c533a883Shx };
149c533a883Shx 
150c533a883Shx /*
151c533a883Shx  * Mappings of Tx power levels -> nominal radio/DSP gain table indexes.
152c533a883Shx  * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
153c533a883Shx  * Tx power setup code interpolates between the 5 "sample" power levels
154c533a883Shx  *    to determine the nominal setup for a requested power level.
155c533a883Shx  * Data copied from EEPROM.
156c533a883Shx  * DO NOT ALTER THIS STRUCTURE!!!
157c533a883Shx  */
158c533a883Shx struct iwl_eeprom_txpower_group {
159c533a883Shx 	/* 5 power levels */
160c533a883Shx 	struct iwl_eeprom_txpower_sample samples[5];
161c533a883Shx 	/* coefficients for voltage->power formula (signed) */
162c533a883Shx 	uint32_t a, b, c, d, e;
163c533a883Shx 	/* these modify coeffs based on frequency (signed) */
164c533a883Shx 	uint32_t Fa, Fb, Fc, Fd, Fe;
165c533a883Shx 	/* highest power possible by h/w in this * band */
166c533a883Shx 	int8_t saturation_power;
167c533a883Shx 	/* "representative" channel # in this band */
168c533a883Shx 	uint8_t group_channel;
169c533a883Shx 	/* h/w temperature at factory calib this band (signed) */
170c533a883Shx 	uint16_t temperature;
171c533a883Shx };
172c533a883Shx 
173c533a883Shx /*
174c533a883Shx  * Temperature-based Tx-power compensation data, not band-specific.
175c533a883Shx  * These coefficients are use to modify a/b/c/d/e coeffs based on
176c533a883Shx  *   difference between current temperature and factory calib temperature.
177c533a883Shx  * Data copied from EEPROM.
178c533a883Shx  */
179c533a883Shx struct iwl_eeprom_temperature_corr {
180c533a883Shx 	uint32_t Ta;
181c533a883Shx 	uint32_t Tb;
182c533a883Shx 	uint32_t Tc;
183c533a883Shx 	uint32_t Td;
184c533a883Shx 	uint32_t Te;
185c533a883Shx };
186c533a883Shx 
187c533a883Shx #define	EEP_TX_POWER_TX_CHAINS		(2)
188*cdc64593Sxinghua wen - Sun Microsystems - Beijing China #define	EEP_TX_POWER_BANDS		(8)
189*cdc64593Sxinghua wen - Sun Microsystems - Beijing China #define	EEP_TX_POWER_MEASUREMENTS	(3)
190*cdc64593Sxinghua wen - Sun Microsystems - Beijing China #define	EEP_TX_POWER_VERSION		(2)
191c533a883Shx #define	EEP_TX_POWER_VERSION_NEW	(5)
192c533a883Shx 
193c533a883Shx struct iwk_eep_calib_measure {
194c533a883Shx 	uint8_t temperature;
195c533a883Shx 	uint8_t gain_idx;
196c533a883Shx 	uint8_t actual_pow;
197c533a883Shx 	int8_t pa_det;
198c533a883Shx };
199c533a883Shx 
200c533a883Shx struct iwk_eep_calib_channel_info {
201c533a883Shx 	uint8_t ch_num;
202c533a883Shx 	struct iwk_eep_calib_measure
203*cdc64593Sxinghua wen - Sun Microsystems - Beijing China 	    measure[EEP_TX_POWER_TX_CHAINS][EEP_TX_POWER_MEASUREMENTS];
204c533a883Shx };
205c533a883Shx 
206c533a883Shx struct iwk_eep_calib_subband_info {
207c533a883Shx 	uint8_t ch_from;
208c533a883Shx 	uint8_t ch_to;
209c533a883Shx 	struct iwk_eep_calib_channel_info ch1;
210c533a883Shx 	struct iwk_eep_calib_channel_info ch2;
211c533a883Shx };
212c533a883Shx 
213c533a883Shx struct iwk_eep_calib_info {
214c533a883Shx 	uint8_t saturation_power24;
215c533a883Shx 	uint8_t saturation_power52;
216c533a883Shx 	uint16_t voltage;
217c533a883Shx 	struct iwk_eep_calib_subband_info band_info_tbl[EEP_TX_POWER_BANDS];
218c533a883Shx };
219c533a883Shx 
220c533a883Shx struct iwk_eep_channel {
221c533a883Shx 	uint8_t flags;
222c533a883Shx 	int8_t max_power_avg; /* each channel's maximum power, 31 as limit */
223c533a883Shx };
224c533a883Shx 
225c533a883Shx /*
226c533a883Shx  * eeprom map
227c533a883Shx  */
228c533a883Shx struct iwk_eep {
229c533a883Shx 	uint8_t reser0[16];
230c533a883Shx 	uint16_t device_id;
231c533a883Shx 	uint8_t reser1[2];
232c533a883Shx 	uint16_t pmc;
233c533a883Shx 	uint8_t reser2[20];
234c533a883Shx 	uint8_t mac_address[6];
235c533a883Shx 	uint8_t reser3[58];
236c533a883Shx 	uint16_t board_revision;
237c533a883Shx 	uint8_t reser4[11];
238c533a883Shx 	uint8_t board_pba_number[9];
239c533a883Shx 	uint8_t reser5[8];
240c533a883Shx 	uint16_t version;
241c533a883Shx 	uint8_t sku_cap;
242c533a883Shx 	uint8_t leds_mode;
243c533a883Shx 	uint16_t oem_mode;
244c533a883Shx 	uint16_t wowlan_mode;
245c533a883Shx 	uint16_t leds_times_interval;
246c533a883Shx 	uint8_t leds_off_time;
247c533a883Shx 	uint8_t leds_on_time;
248c533a883Shx 	uint8_t almgor_m_version;
249c533a883Shx 	uint8_t antenna_switch_type;
250c533a883Shx 	uint8_t reser6[8];
251c533a883Shx 	uint16_t board_revision_4965;
252c533a883Shx 	uint8_t reser7[13];
253c533a883Shx 	uint8_t board_pba_number_4965[9];
254c533a883Shx 	uint8_t reser8[10];
255c533a883Shx 	uint8_t sku_id[4];
256c533a883Shx 	uint16_t band_1_count;
257c533a883Shx 	struct iwk_eep_channel  band_1_channels[14];
258c533a883Shx 	uint16_t band_2_count;
259c533a883Shx 	struct iwk_eep_channel  band_2_channels[13];
260c533a883Shx 	uint16_t band_3_count;
261c533a883Shx 	struct iwk_eep_channel  band_3_channels[12];
262c533a883Shx 	uint16_t band_4_count;
263c533a883Shx 	struct iwk_eep_channel  band_4_channels[11];
264c533a883Shx 	uint16_t band_5_count;
265c533a883Shx 	struct iwk_eep_channel  band_5_channels[6];
266c533a883Shx 	uint8_t reser10[2];
267c533a883Shx 	struct iwk_eep_channel  band_24_channels[7];
268c533a883Shx 	uint8_t reser11[2];
269c533a883Shx 	struct iwk_eep_channel  band_52_channels[11];
270c533a883Shx 	uint8_t reser12[6];
271c533a883Shx 	uint16_t calib_version;
272c533a883Shx 	uint8_t reser13[2];
273c533a883Shx 	uint16_t satruation_power;
274c533a883Shx 	uint8_t reser14[94];
275c533a883Shx 	struct iwk_eep_calib_info calib_info;
276c533a883Shx 	uint8_t reser15[140];
277c533a883Shx };
278c533a883Shx 
279c533a883Shx #define	CSR_EEPROM_REG			(CSR_BASE+0x02c)
280c533a883Shx #define	CSR_EEPROM_GP			(CSR_BASE+0x030)
281c533a883Shx #define	CSR_EEPROM_GP_VALID_MSK		0x00000007
282c533a883Shx #define	CSR_EEPROM_GP_BAD_SIGNATURE	0x00000000
283c533a883Shx 
284c533a883Shx 
285c533a883Shx 
286c533a883Shx #endif /* _IWK_EEPROM_H_ */
287