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