xref: /onnv-gate/usr/src/uts/common/io/iwk/iwk_eeprom.h (revision 7569:272eac3cbcd4)
16169Shx147065 /*
26169Shx147065  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
36169Shx147065  * Use is subject to license terms.
46169Shx147065  */
56169Shx147065 
66169Shx147065 /*
76169Shx147065  * Copyright (c) 2007, Intel Corporation
86169Shx147065  * All rights reserved.
96169Shx147065  */
106169Shx147065 
116169Shx147065 /*
126169Shx147065  * Sun elects to use this software under the BSD license.
136169Shx147065  */
146169Shx147065 
156169Shx147065 /*
166169Shx147065  * This file is provided under a dual BSD/GPLv2 license.  When using or
176169Shx147065  * redistributing this file, you may do so under either license.
186169Shx147065  *
196169Shx147065  * GPL LICENSE SUMMARY
206169Shx147065  *
216169Shx147065  * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
226169Shx147065  *
236169Shx147065  * This program is free software; you can redistribute it and/or modify
246169Shx147065  * it under the terms of version 2 of the GNU Geeral Public License as
256169Shx147065  * published by the Free Software Foundation.
266169Shx147065  *
276169Shx147065  * This program is distributed in the hope that it will be useful, but
286169Shx147065  * WITHOUT ANY WARRANTY; without even the implied warranty of
296169Shx147065  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
306169Shx147065  * General Public License for more details.
316169Shx147065  *
326169Shx147065  * You should have received a copy of the GNU General Public License
336169Shx147065  * along with this program; if not, write to the Free Software
346169Shx147065  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110,
356169Shx147065  * USA
366169Shx147065  *
376169Shx147065  * The full GNU General Public License is included in this distribution
386169Shx147065  * in the file called LICENSE.GPL.
396169Shx147065  *
406169Shx147065  * Contact Information:
416169Shx147065  * James P. Ketrenos <ipw2100-admin@linux.intel.com>
426169Shx147065  * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
436169Shx147065  *
446169Shx147065  * BSD LICENSE
456169Shx147065  *
466169Shx147065  * Copyright(c) 2005 - 2007 Intel Corporation. All rights reserved.
476169Shx147065  * All rights reserved.
486169Shx147065  *
496169Shx147065  * Redistribution and use in source and binary forms, with or without
506169Shx147065  * modification, are permitted provided that the following conditions
516169Shx147065  * are met:
526169Shx147065  *
536169Shx147065  *  * Redistributions of source code must retain the above copyright
546169Shx147065  *    notice, this list of conditions and the following disclaimer.
556169Shx147065  *  * Redistributions in binary form must reproduce the above copyright
566169Shx147065  *    notice, this list of conditions and the following disclaimer in
576169Shx147065  *    the documentation and/or other materials provided with the
586169Shx147065  *    distribution.
596169Shx147065  *  * Neither the name Intel Corporation nor the names of its
606169Shx147065  *    contributors may be used to endorse or promote products derived
616169Shx147065  *    from this software without specific prior written permission.
626169Shx147065  *
636169Shx147065  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
646169Shx147065  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
656169Shx147065  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
666169Shx147065  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
676169Shx147065  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
686169Shx147065  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
696169Shx147065  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
706169Shx147065  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
716169Shx147065  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
726169Shx147065  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
736169Shx147065  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
746169Shx147065  */
756169Shx147065 
766169Shx147065 #ifndef _IWK_EEPROM_H_
776169Shx147065 #define	_IWK_EEPROM_H_
786169Shx147065 
796169Shx147065 /*
806169Shx147065  * This file defines EEPROM related constants, enums, and inline functions.
816169Shx147065  */
826169Shx147065 
836169Shx147065 /*
846169Shx147065  * EEPROM field values
856169Shx147065  */
866169Shx147065 #define	ANTENNA_SWITCH_NORMAL		0
876169Shx147065 #define	ANTENNA_SWITCH_INVERSE		1
886169Shx147065 
896169Shx147065 enum {
906169Shx147065 	EEPROM_CHANNEL_VALID = (1 << 0),	/* usable for this SKU/geo */
916169Shx147065 	EEPROM_CHANNEL_IBSS = (1 << 1),	/* usable as an IBSS channel */
926169Shx147065 	/* Bit 2 Reserved */
936169Shx147065 	EEPROM_CHANNEL_ACTIVE = (1 << 3),	/* active scanning allowed */
946169Shx147065 	EEPROM_CHANNEL_RADAR = (1 << 4),	/* radar detection required */
956169Shx147065 	EEPROM_CHANNEL_WIDE = (1 << 5),
966169Shx147065 	EEPROM_CHANNEL_NARROW = (1 << 6),
976169Shx147065 	EEPROM_CHANNEL_DFS = (1 << 7),	/* dynamic freq selection candidate */
986169Shx147065 };
996169Shx147065 
1006169Shx147065 /*
1016169Shx147065  * EEPROM field lengths
1026169Shx147065  */
1036169Shx147065 #define	EEPROM_BOARD_PBA_NUMBER_LENGTH		11
1046169Shx147065 
1056169Shx147065 /*
1066169Shx147065  * EEPROM field lengths
1076169Shx147065  */
1086169Shx147065 #define	EEPROM_BOARD_PBA_NUMBER_LENGTH		11
1096169Shx147065 #define	EEPROM_REGULATORY_SKU_ID_LENGTH		4
1106169Shx147065 #define	EEPROM_REGULATORY_BAND1_CHANNELS_LENGTH	14
1116169Shx147065 #define	EEPROM_REGULATORY_BAND2_CHANNELS_LENGTH	13
1126169Shx147065 #define	EEPROM_REGULATORY_BAND3_CHANNELS_LENGTH	12
1136169Shx147065 #define	EEPROM_REGULATORY_BAND4_CHANNELS_LENGTH	11
1146169Shx147065 #define	EEPROM_REGULATORY_BAND5_CHANNELS_LENGTH	6
1156169Shx147065 
1166169Shx147065 
1176169Shx147065 #define	EEPROM_REGULATORY_NUMBER_OF_BANDS	5
1186169Shx147065 
1196169Shx147065 /*
1206169Shx147065  * SKU Capabilities
1216169Shx147065  */
1226169Shx147065 #define	EEPROM_SKU_CAP_SW_RF_KILL_ENABLE	(1 << 0)
1236169Shx147065 #define	EEPROM_SKU_CAP_HW_RF_KILL_ENABLE	(1 << 1)
1246169Shx147065 #define	EEPROM_SKU_CAP_OP_MODE_MRC		(1 << 7)
1256169Shx147065 
1266169Shx147065 /*
1276169Shx147065  * *regulatory* channel data from eeprom, one for each channel
1286169Shx147065  */
1296169Shx147065 struct iwl_eeprom_channel {
1306169Shx147065 	uint8_t flags;		/* flags copied from EEPROM */
1316169Shx147065 	int8_t max_power_avg;	/* max power (dBm) on this chnl, limit 31 */
1326169Shx147065 };
1336169Shx147065 
1346169Shx147065 /*
1356169Shx147065  * Mapping of a Tx power level, at factory calibration temperature,
1366169Shx147065  *   to a radio/DSP gain table index.
1376169Shx147065  * One for each of 5 "sample" power levels in each band.
1386169Shx147065  * v_det is measured at the factory, using the 3945's built-in power amplifier
1396169Shx147065  *   (PA) output voltage detector.  This same detector is used during Tx of
1406169Shx147065  *   long packets in normal operation to provide feedback as to proper output
1416169Shx147065  *   level.
1426169Shx147065  * Data copied from EEPROM.
1436169Shx147065  */
1446169Shx147065 struct iwl_eeprom_txpower_sample {
1456169Shx147065 	uint8_t gain_index;	/* index into power (gain) setup table ... */
1466169Shx147065 	int8_t power;		/* ... for this pwr level for this chnl group */
1476169Shx147065 	uint16_t v_det;		/* PA output voltage */
1486169Shx147065 };
1496169Shx147065 
1506169Shx147065 /*
1516169Shx147065  * Mappings of Tx power levels -> nominal radio/DSP gain table indexes.
1526169Shx147065  * One for each channel group (a.k.a. "band") (1 for BG, 4 for A).
1536169Shx147065  * Tx power setup code interpolates between the 5 "sample" power levels
1546169Shx147065  *    to determine the nominal setup for a requested power level.
1556169Shx147065  * Data copied from EEPROM.
1566169Shx147065  * DO NOT ALTER THIS STRUCTURE!!!
1576169Shx147065  */
1586169Shx147065 struct iwl_eeprom_txpower_group {
1596169Shx147065 	/* 5 power levels */
1606169Shx147065 	struct iwl_eeprom_txpower_sample samples[5];
1616169Shx147065 	/* coefficients for voltage->power formula (signed) */
1626169Shx147065 	uint32_t a, b, c, d, e;
1636169Shx147065 	/* these modify coeffs based on frequency (signed) */
1646169Shx147065 	uint32_t Fa, Fb, Fc, Fd, Fe;
1656169Shx147065 	/* highest power possible by h/w in this * band */
1666169Shx147065 	int8_t saturation_power;
1676169Shx147065 	/* "representative" channel # in this band */
1686169Shx147065 	uint8_t group_channel;
1696169Shx147065 	/* h/w temperature at factory calib this band (signed) */
1706169Shx147065 	uint16_t temperature;
1716169Shx147065 };
1726169Shx147065 
1736169Shx147065 /*
1746169Shx147065  * Temperature-based Tx-power compensation data, not band-specific.
1756169Shx147065  * These coefficients are use to modify a/b/c/d/e coeffs based on
1766169Shx147065  *   difference between current temperature and factory calib temperature.
1776169Shx147065  * Data copied from EEPROM.
1786169Shx147065  */
1796169Shx147065 struct iwl_eeprom_temperature_corr {
1806169Shx147065 	uint32_t Ta;
1816169Shx147065 	uint32_t Tb;
1826169Shx147065 	uint32_t Tc;
1836169Shx147065 	uint32_t Td;
1846169Shx147065 	uint32_t Te;
1856169Shx147065 };
1866169Shx147065 
1876169Shx147065 #define	EEP_TX_POWER_TX_CHAINS		(2)
188*7569SXinghua.Wen@Sun.COM #define	EEP_TX_POWER_BANDS		(8)
189*7569SXinghua.Wen@Sun.COM #define	EEP_TX_POWER_MEASUREMENTS	(3)
190*7569SXinghua.Wen@Sun.COM #define	EEP_TX_POWER_VERSION		(2)
1916169Shx147065 #define	EEP_TX_POWER_VERSION_NEW	(5)
1926169Shx147065 
1936169Shx147065 struct iwk_eep_calib_measure {
1946169Shx147065 	uint8_t temperature;
1956169Shx147065 	uint8_t gain_idx;
1966169Shx147065 	uint8_t actual_pow;
1976169Shx147065 	int8_t pa_det;
1986169Shx147065 };
1996169Shx147065 
2006169Shx147065 struct iwk_eep_calib_channel_info {
2016169Shx147065 	uint8_t ch_num;
2026169Shx147065 	struct iwk_eep_calib_measure
203*7569SXinghua.Wen@Sun.COM 	    measure[EEP_TX_POWER_TX_CHAINS][EEP_TX_POWER_MEASUREMENTS];
2046169Shx147065 };
2056169Shx147065 
2066169Shx147065 struct iwk_eep_calib_subband_info {
2076169Shx147065 	uint8_t ch_from;
2086169Shx147065 	uint8_t ch_to;
2096169Shx147065 	struct iwk_eep_calib_channel_info ch1;
2106169Shx147065 	struct iwk_eep_calib_channel_info ch2;
2116169Shx147065 };
2126169Shx147065 
2136169Shx147065 struct iwk_eep_calib_info {
2146169Shx147065 	uint8_t saturation_power24;
2156169Shx147065 	uint8_t saturation_power52;
2166169Shx147065 	uint16_t voltage;
2176169Shx147065 	struct iwk_eep_calib_subband_info band_info_tbl[EEP_TX_POWER_BANDS];
2186169Shx147065 };
2196169Shx147065 
2206169Shx147065 struct iwk_eep_channel {
2216169Shx147065 	uint8_t flags;
2226169Shx147065 	int8_t max_power_avg; /* each channel's maximum power, 31 as limit */
2236169Shx147065 };
2246169Shx147065 
2256169Shx147065 /*
2266169Shx147065  * eeprom map
2276169Shx147065  */
2286169Shx147065 struct iwk_eep {
2296169Shx147065 	uint8_t reser0[16];
2306169Shx147065 	uint16_t device_id;
2316169Shx147065 	uint8_t reser1[2];
2326169Shx147065 	uint16_t pmc;
2336169Shx147065 	uint8_t reser2[20];
2346169Shx147065 	uint8_t mac_address[6];
2356169Shx147065 	uint8_t reser3[58];
2366169Shx147065 	uint16_t board_revision;
2376169Shx147065 	uint8_t reser4[11];
2386169Shx147065 	uint8_t board_pba_number[9];
2396169Shx147065 	uint8_t reser5[8];
2406169Shx147065 	uint16_t version;
2416169Shx147065 	uint8_t sku_cap;
2426169Shx147065 	uint8_t leds_mode;
2436169Shx147065 	uint16_t oem_mode;
2446169Shx147065 	uint16_t wowlan_mode;
2456169Shx147065 	uint16_t leds_times_interval;
2466169Shx147065 	uint8_t leds_off_time;
2476169Shx147065 	uint8_t leds_on_time;
2486169Shx147065 	uint8_t almgor_m_version;
2496169Shx147065 	uint8_t antenna_switch_type;
2506169Shx147065 	uint8_t reser6[8];
2516169Shx147065 	uint16_t board_revision_4965;
2526169Shx147065 	uint8_t reser7[13];
2536169Shx147065 	uint8_t board_pba_number_4965[9];
2546169Shx147065 	uint8_t reser8[10];
2556169Shx147065 	uint8_t sku_id[4];
2566169Shx147065 	uint16_t band_1_count;
2576169Shx147065 	struct iwk_eep_channel  band_1_channels[14];
2586169Shx147065 	uint16_t band_2_count;
2596169Shx147065 	struct iwk_eep_channel  band_2_channels[13];
2606169Shx147065 	uint16_t band_3_count;
2616169Shx147065 	struct iwk_eep_channel  band_3_channels[12];
2626169Shx147065 	uint16_t band_4_count;
2636169Shx147065 	struct iwk_eep_channel  band_4_channels[11];
2646169Shx147065 	uint16_t band_5_count;
2656169Shx147065 	struct iwk_eep_channel  band_5_channels[6];
2666169Shx147065 	uint8_t reser10[2];
2676169Shx147065 	struct iwk_eep_channel  band_24_channels[7];
2686169Shx147065 	uint8_t reser11[2];
2696169Shx147065 	struct iwk_eep_channel  band_52_channels[11];
2706169Shx147065 	uint8_t reser12[6];
2716169Shx147065 	uint16_t calib_version;
2726169Shx147065 	uint8_t reser13[2];
2736169Shx147065 	uint16_t satruation_power;
2746169Shx147065 	uint8_t reser14[94];
2756169Shx147065 	struct iwk_eep_calib_info calib_info;
2766169Shx147065 	uint8_t reser15[140];
2776169Shx147065 };
2786169Shx147065 
2796169Shx147065 #define	CSR_EEPROM_REG			(CSR_BASE+0x02c)
2806169Shx147065 #define	CSR_EEPROM_GP			(CSR_BASE+0x030)
2816169Shx147065 #define	CSR_EEPROM_GP_VALID_MSK		0x00000007
2826169Shx147065 #define	CSR_EEPROM_GP_BAD_SIGNATURE	0x00000000
2836169Shx147065 
2846169Shx147065 
2856169Shx147065 
2866169Shx147065 #endif /* _IWK_EEPROM_H_ */
287