xref: /freebsd/sys/dev/ath/ath_hal/ah_eeprom_9287.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
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 
19 #ifndef	__AH_EEPROM_9287_H__
20 #define	__AH_EEPROM_9287_H__
21 
22 #define OLC_FOR_AR9287_10_LATER (AR_SREV_9287_11_OR_LATER(ah) && \
23 				 ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL))
24 
25 #define AR9287_EEP_VER               0xE
26 #define AR9287_EEP_VER_MINOR_MASK    0xFFF
27 #define AR9287_EEP_MINOR_VER_1       0x1
28 #define AR9287_EEP_MINOR_VER_2       0x2
29 #define AR9287_EEP_MINOR_VER_3       0x3
30 #define AR9287_EEP_MINOR_VER         AR9287_EEP_MINOR_VER_3
31 #define AR9287_EEP_MINOR_VER_b       AR9287_EEP_MINOR_VER
32 #define AR9287_EEP_NO_BACK_VER       AR9287_EEP_MINOR_VER_1
33 
34 #define	AR9287_RDEXT_DEFAULT		0x1F
35 
36 #define AR9287_EEP_START_LOC            128
37 #define AR9287_HTC_EEP_START_LOC        256
38 #define AR9287_NUM_2G_CAL_PIERS         3
39 #define AR9287_NUM_2G_CCK_TARGET_POWERS 3
40 #define AR9287_NUM_2G_20_TARGET_POWERS  3
41 #define AR9287_NUM_2G_40_TARGET_POWERS  3
42 #define AR9287_NUM_CTLS              	12
43 #define AR9287_NUM_BAND_EDGES        	4
44 #define AR9287_PD_GAIN_ICEPTS           1
45 #define AR9287_EEPMISC_BIG_ENDIAN       0x01
46 #define AR9287_EEPMISC_WOW              0x02
47 #define AR9287_MAX_CHAINS               2
48 #define AR9287_ANT_16S                  32
49 
50 #define AR9287_DATA_SZ                  32
51 
52 #define AR9287_PWR_TABLE_OFFSET_DB  -5
53 
54 #define AR9287_CHECKSUM_LOCATION (AR9287_EEP_START_LOC + 1)
55 
56 struct base_eep_ar9287_header {
57 	uint16_t version;		/* Swapped w/ length; check ah_eeprom_v14.h */
58 	uint16_t checksum;
59 	uint16_t length;
60 	uint8_t opCapFlags;
61 	uint8_t eepMisc;
62 	uint16_t regDmn[2];
63 	uint8_t macAddr[6];
64 	uint8_t rxMask;
65 	uint8_t txMask;
66 	uint16_t rfSilent;
67 	uint16_t blueToothOptions;
68 	uint16_t deviceCap;
69 	uint32_t binBuildNumber;
70 	uint8_t deviceType;
71 	uint8_t openLoopPwrCntl;
72 	int8_t pwrTableOffset;
73 	int8_t tempSensSlope;
74 	int8_t tempSensSlopePalOn;
75 	uint8_t futureBase[29];
76 } __packed;
77 
78 struct modal_eep_ar9287_header {
79 	uint32_t antCtrlChain[AR9287_MAX_CHAINS];
80 	uint32_t antCtrlCommon;
81 	int8_t antennaGainCh[AR9287_MAX_CHAINS];
82 	uint8_t switchSettling;
83 	uint8_t txRxAttenCh[AR9287_MAX_CHAINS];
84 	uint8_t rxTxMarginCh[AR9287_MAX_CHAINS];
85 	int8_t adcDesiredSize;
86 	uint8_t txEndToXpaOff;
87 	uint8_t txEndToRxOn;
88 	uint8_t txFrameToXpaOn;
89 	uint8_t thresh62;
90 	int8_t noiseFloorThreshCh[AR9287_MAX_CHAINS];
91 	uint8_t xpdGain;
92 	uint8_t xpd;
93 	int8_t iqCalICh[AR9287_MAX_CHAINS];
94 	int8_t iqCalQCh[AR9287_MAX_CHAINS];
95 	uint8_t pdGainOverlap;
96 	uint8_t xpaBiasLvl;
97 	uint8_t txFrameToDataStart;
98 	uint8_t txFrameToPaOn;
99 	uint8_t ht40PowerIncForPdadc;
100 	uint8_t bswAtten[AR9287_MAX_CHAINS];
101 	uint8_t bswMargin[AR9287_MAX_CHAINS];
102 	uint8_t swSettleHt40;
103 	uint8_t version;
104 	uint8_t db1;
105 	uint8_t db2;
106 	uint8_t ob_cck;
107 	uint8_t ob_psk;
108 	uint8_t ob_qam;
109 	uint8_t ob_pal_off;
110 	uint8_t futureModal[30];
111 	SPUR_CHAN spurChans[AR5416_EEPROM_MODAL_SPURS];
112 } __packed;
113 
114 struct cal_data_op_loop_ar9287 {
115 	uint8_t pwrPdg[2][5];
116 	uint8_t vpdPdg[2][5];
117 	uint8_t pcdac[2][5];
118 	uint8_t empty[2][5];
119 } __packed;
120 
121 struct cal_data_per_freq_ar9287 {
122 	uint8_t pwrPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
123 	uint8_t vpdPdg[AR5416_NUM_PD_GAINS][AR9287_PD_GAIN_ICEPTS];
124 } __packed;
125 
126 union cal_data_per_freq_ar9287_u {
127 	struct cal_data_op_loop_ar9287 calDataOpen;
128 	struct cal_data_per_freq_ar9287 calDataClose;
129 } __packed;
130 
131 struct cal_ctl_data_ar9287 {
132 	CAL_CTL_EDGES ctlEdges[AR9287_MAX_CHAINS][AR9287_NUM_BAND_EDGES];
133 } __packed;
134 
135 struct ar9287_eeprom {
136 	struct base_eep_ar9287_header baseEepHeader;
137 	uint8_t custData[AR9287_DATA_SZ];
138 	struct modal_eep_ar9287_header modalHeader;
139 	uint8_t calFreqPier2G[AR9287_NUM_2G_CAL_PIERS];
140 	union cal_data_per_freq_ar9287_u
141 	    calPierData2G[AR9287_MAX_CHAINS][AR9287_NUM_2G_CAL_PIERS];
142 	CAL_TARGET_POWER_LEG
143 	    calTargetPowerCck[AR9287_NUM_2G_CCK_TARGET_POWERS];
144 	CAL_TARGET_POWER_LEG
145 	    calTargetPower2G[AR9287_NUM_2G_20_TARGET_POWERS];
146 	CAL_TARGET_POWER_HT
147 	    calTargetPower2GHT20[AR9287_NUM_2G_20_TARGET_POWERS];
148 	CAL_TARGET_POWER_HT
149 	    calTargetPower2GHT40[AR9287_NUM_2G_40_TARGET_POWERS];
150 	uint8_t ctlIndex[AR9287_NUM_CTLS];
151 	struct cal_ctl_data_ar9287 ctlData[AR9287_NUM_CTLS];
152 	uint8_t padding;
153 } __packed;
154 
155 typedef struct {
156         struct ar9287_eeprom ee_base;
157 #define NUM_EDGES        8
158         uint16_t        ee_numCtls;
159         RD_EDGES_POWER  ee_rdEdgesPower[NUM_EDGES*AR9287_NUM_CTLS];
160         /* XXX these are dynamically calculated for use by shared code */
161         int8_t          ee_antennaGainMax[2];
162 } HAL_EEPROM_9287;
163 
164 typedef struct modal_eep_ar9287_header MODAL_EEP_9287_HEADER;
165 typedef struct base_eep_ar9287_header BASE_EEP_9287_HEADER;
166 
167 #endif /* __AH_EEPROM_9287_H__ */
168