xref: /freebsd/sys/dev/ath/ath_hal/ah_eeprom_9287.h (revision 19261079b74319502c6ffa1249920079f0f69a72)
1 /*-
2  * SPDX-License-Identifier: ISC
3  *
4  * Copyright (c) 2008-2009 Atheros Communications Inc.
5  *
6  * Permission to use, copy, modify, and/or distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  *
18  * $FreeBSD$
19  */
20 
21 #ifndef	__AH_EEPROM_9287_H__
22 #define	__AH_EEPROM_9287_H__
23 
24 #define OLC_FOR_AR9287_10_LATER (AR_SREV_9287_11_OR_LATER(ah) && \
25 				 ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
26 
27 #define AR9287_EEP_VER               0xE
28 #define AR9287_EEP_VER_MINOR_MASK    0xFFF
29 #define AR9287_EEP_MINOR_VER_1       0x1
30 #define AR9287_EEP_MINOR_VER_2       0x2
31 #define AR9287_EEP_MINOR_VER_3       0x3
32 #define AR9287_EEP_MINOR_VER         AR9287_EEP_MINOR_VER_3
33 #define AR9287_EEP_MINOR_VER_b       AR9287_EEP_MINOR_VER
34 #define AR9287_EEP_NO_BACK_VER       AR9287_EEP_MINOR_VER_1
35 
36 #define	AR9287_RDEXT_DEFAULT		0x1F
37 
38 #define AR9287_EEP_START_LOC            128
39 #define AR9287_HTC_EEP_START_LOC        256
40 #define AR9287_NUM_2G_CAL_PIERS         3
41 #define AR9287_NUM_2G_CCK_TARGET_POWERS 3
42 #define AR9287_NUM_2G_20_TARGET_POWERS  3
43 #define AR9287_NUM_2G_40_TARGET_POWERS  3
44 #define AR9287_NUM_CTLS              	12
45 #define AR9287_NUM_BAND_EDGES        	4
46 #define AR9287_PD_GAIN_ICEPTS           1
47 #define AR9287_EEPMISC_BIG_ENDIAN       0x01
48 #define AR9287_EEPMISC_WOW              0x02
49 #define AR9287_MAX_CHAINS               2
50 #define AR9287_ANT_16S                  32
51 
52 #define AR9287_DATA_SZ                  32
53 
54 #define AR9287_PWR_TABLE_OFFSET_DB  -5
55 
56 #define AR9287_CHECKSUM_LOCATION (AR9287_EEP_START_LOC + 1)
57 
58 struct base_eep_ar9287_header {
59 	uint16_t version;		/* Swapped w/ length; check ah_eeprom_v14.h */
60 	uint16_t checksum;
61 	uint16_t length;
62 	uint8_t opCapFlags;
63 	uint8_t eepMisc;
64 	uint16_t regDmn[2];
65 	uint8_t macAddr[6];
66 	uint8_t rxMask;
67 	uint8_t txMask;
68 	uint16_t rfSilent;
69 	uint16_t blueToothOptions;
70 	uint16_t deviceCap;
71 	uint32_t binBuildNumber;
72 	uint8_t deviceType;
73 	uint8_t openLoopPwrCntl;
74 	int8_t pwrTableOffset;
75 	int8_t tempSensSlope;
76 	int8_t tempSensSlopePalOn;
77 	uint8_t futureBase[29];
78 } __packed;
79 
80 struct modal_eep_ar9287_header {
81 	uint32_t antCtrlChain[AR9287_MAX_CHAINS];
82 	uint32_t antCtrlCommon;
83 	int8_t antennaGainCh[AR9287_MAX_CHAINS];
84 	uint8_t switchSettling;
85 	uint8_t txRxAttenCh[AR9287_MAX_CHAINS];
86 	uint8_t rxTxMarginCh[AR9287_MAX_CHAINS];
87 	int8_t adcDesiredSize;
88 	uint8_t txEndToXpaOff;
89 	uint8_t txEndToRxOn;
90 	uint8_t txFrameToXpaOn;
91 	uint8_t thresh62;
92 	int8_t noiseFloorThreshCh[AR9287_MAX_CHAINS];
93 	uint8_t xpdGain;
94 	uint8_t xpd;
95 	int8_t iqCalICh[AR9287_MAX_CHAINS];
96 	int8_t iqCalQCh[AR9287_MAX_CHAINS];
97 	uint8_t pdGainOverlap;
98 	uint8_t xpaBiasLvl;
99 	uint8_t txFrameToDataStart;
100 	uint8_t txFrameToPaOn;
101 	uint8_t ht40PowerIncForPdadc;
102 	uint8_t bswAtten[AR9287_MAX_CHAINS];
103 	uint8_t bswMargin[AR9287_MAX_CHAINS];
104 	uint8_t swSettleHt40;
105 	uint8_t version;
106 	uint8_t db1;
107 	uint8_t db2;
108 	uint8_t ob_cck;
109 	uint8_t ob_psk;
110 	uint8_t ob_qam;
111 	uint8_t ob_pal_off;
112 	uint8_t futureModal[30];
113 	SPUR_CHAN spurChans[AR5416_EEPROM_MODAL_SPURS];
114 } __packed;
115 
116 struct cal_data_op_loop_ar9287 {
117 	uint8_t pwrPdg[2][5];
118 	uint8_t vpdPdg[2][5];
119 	uint8_t pcdac[2][5];
120 	uint8_t empty[2][5];
121 } __packed;
122 
123 struct cal_data_per_freq_ar9287 {
124 	uint8_t pwrPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
125 	uint8_t vpdPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
126 } __packed;
127 
128 union cal_data_per_freq_ar9287_u {
129 	struct cal_data_op_loop_ar9287 calDataOpen;
130 	struct cal_data_per_freq_ar9287 calDataClose;
131 } __packed;
132 
133 struct cal_ctl_data_ar9287 {
134 	CAL_CTL_EDGES ctlEdges[AR9287_MAX_CHAINS][AR9287_NUM_BAND_EDGES];
135 } __packed;
136 
137 struct ar9287_eeprom {
138 	struct base_eep_ar9287_header baseEepHeader;
139 	uint8_t custData[AR9287_DATA_SZ];
140 	struct modal_eep_ar9287_header modalHeader;
141 	uint8_t calFreqPier2G[AR9287_NUM_2G_CAL_PIERS];
142 	union cal_data_per_freq_ar9287_u
143 	    calPierData2G[AR9287_MAX_CHAINS][AR9287_NUM_2G_CAL_PIERS];
144 	CAL_TARGET_POWER_LEG
145 	    calTargetPowerCck[AR9287_NUM_2G_CCK_TARGET_POWERS];
146 	CAL_TARGET_POWER_LEG
147 	    calTargetPower2G[AR9287_NUM_2G_20_TARGET_POWERS];
148 	CAL_TARGET_POWER_HT
149 	    calTargetPower2GHT20[AR9287_NUM_2G_20_TARGET_POWERS];
150 	CAL_TARGET_POWER_HT
151 	    calTargetPower2GHT40[AR9287_NUM_2G_40_TARGET_POWERS];
152 	uint8_t ctlIndex[AR9287_NUM_CTLS];
153 	struct cal_ctl_data_ar9287 ctlData[AR9287_NUM_CTLS];
154 	uint8_t padding;
155 } __packed;
156 
157 typedef struct {
158         struct ar9287_eeprom ee_base;
159 #define NUM_EDGES        8
160         uint16_t        ee_numCtls;
161         RD_EDGES_POWER  ee_rdEdgesPower[NUM_EDGES*AR9287_NUM_CTLS];
162         /* XXX these are dynamically calculated for use by shared code */
163         int8_t          ee_antennaGainMax[2];
164 } HAL_EEPROM_9287;
165 
166 typedef struct modal_eep_ar9287_header MODAL_EEP_9287_HEADER;
167 typedef struct base_eep_ar9287_header BASE_EEP_9287_HEADER;
168 
169 #endif /* __AH_EEPROM_9287_H__ */
170