Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 1 | #ifndef AR9003_EEPROM_H |
| 2 | #define AR9003_EEPROM_H |
| 3 | |
| 4 | #include <linux/types.h> |
| 5 | |
| 6 | #define AR9300_EEP_VER 0xD000 |
| 7 | #define AR9300_EEP_VER_MINOR_MASK 0xFFF |
| 8 | #define AR9300_EEP_MINOR_VER_1 0x1 |
| 9 | #define AR9300_EEP_MINOR_VER AR9300_EEP_MINOR_VER_1 |
| 10 | |
| 11 | /* 16-bit offset location start of calibration struct */ |
| 12 | #define AR9300_EEP_START_LOC 256 |
| 13 | #define AR9300_NUM_5G_CAL_PIERS 8 |
| 14 | #define AR9300_NUM_2G_CAL_PIERS 3 |
| 15 | #define AR9300_NUM_5G_20_TARGET_POWERS 8 |
| 16 | #define AR9300_NUM_5G_40_TARGET_POWERS 8 |
| 17 | #define AR9300_NUM_2G_CCK_TARGET_POWERS 2 |
| 18 | #define AR9300_NUM_2G_20_TARGET_POWERS 3 |
| 19 | #define AR9300_NUM_2G_40_TARGET_POWERS 3 |
| 20 | /* #define AR9300_NUM_CTLS 21 */ |
| 21 | #define AR9300_NUM_CTLS_5G 9 |
| 22 | #define AR9300_NUM_CTLS_2G 12 |
| 23 | #define AR9300_CTL_MODE_M 0xF |
| 24 | #define AR9300_NUM_BAND_EDGES_5G 8 |
| 25 | #define AR9300_NUM_BAND_EDGES_2G 4 |
| 26 | #define AR9300_NUM_PD_GAINS 4 |
| 27 | #define AR9300_PD_GAINS_IN_MASK 4 |
| 28 | #define AR9300_PD_GAIN_ICEPTS 5 |
| 29 | #define AR9300_EEPROM_MODAL_SPURS 5 |
| 30 | #define AR9300_MAX_RATE_POWER 63 |
| 31 | #define AR9300_NUM_PDADC_VALUES 128 |
| 32 | #define AR9300_NUM_RATES 16 |
| 33 | #define AR9300_BCHAN_UNUSED 0xFF |
| 34 | #define AR9300_MAX_PWR_RANGE_IN_HALF_DB 64 |
| 35 | #define AR9300_OPFLAGS_11A 0x01 |
| 36 | #define AR9300_OPFLAGS_11G 0x02 |
| 37 | #define AR9300_OPFLAGS_5G_HT40 0x04 |
| 38 | #define AR9300_OPFLAGS_2G_HT40 0x08 |
| 39 | #define AR9300_OPFLAGS_5G_HT20 0x10 |
| 40 | #define AR9300_OPFLAGS_2G_HT20 0x20 |
| 41 | #define AR9300_EEPMISC_BIG_ENDIAN 0x01 |
| 42 | #define AR9300_EEPMISC_WOW 0x02 |
| 43 | #define AR9300_CUSTOMER_DATA_SIZE 20 |
| 44 | |
| 45 | #define FREQ2FBIN(x, y) ((y) ? ((x) - 2300) : (((x) - 4800) / 5)) |
| 46 | #define FBIN2FREQ(x, y) ((y) ? (2300 + x) : (4800 + 5 * x)) |
| 47 | #define AR9300_MAX_CHAINS 3 |
| 48 | #define AR9300_ANT_16S 25 |
| 49 | #define AR9300_FUTURE_MODAL_SZ 6 |
| 50 | |
| 51 | #define AR9300_NUM_ANT_CHAIN_FIELDS 7 |
| 52 | #define AR9300_NUM_ANT_COMMON_FIELDS 4 |
| 53 | #define AR9300_SIZE_ANT_CHAIN_FIELD 3 |
| 54 | #define AR9300_SIZE_ANT_COMMON_FIELD 4 |
| 55 | #define AR9300_ANT_CHAIN_MASK 0x7 |
| 56 | #define AR9300_ANT_COMMON_MASK 0xf |
| 57 | #define AR9300_CHAIN_0_IDX 0 |
| 58 | #define AR9300_CHAIN_1_IDX 1 |
| 59 | #define AR9300_CHAIN_2_IDX 2 |
| 60 | |
| 61 | #define AR928X_NUM_ANT_CHAIN_FIELDS 6 |
| 62 | #define AR928X_SIZE_ANT_CHAIN_FIELD 2 |
| 63 | #define AR928X_ANT_CHAIN_MASK 0x3 |
| 64 | |
| 65 | /* Delta from which to start power to pdadc table */ |
| 66 | /* This offset is used in both open loop and closed loop power control |
| 67 | * schemes. In open loop power control, it is not really needed, but for |
| 68 | * the "sake of consistency" it was kept. For certain AP designs, this |
| 69 | * value is overwritten by the value in the flag "pwrTableOffset" just |
| 70 | * before writing the pdadc vs pwr into the chip registers. |
| 71 | */ |
| 72 | #define AR9300_PWR_TABLE_OFFSET 0 |
| 73 | |
| 74 | /* enable flags for voltage and temp compensation */ |
| 75 | #define ENABLE_TEMP_COMPENSATION 0x01 |
| 76 | #define ENABLE_VOLT_COMPENSATION 0x02 |
| 77 | /* byte addressable */ |
| 78 | #define AR9300_EEPROM_SIZE (16*1024) |
| 79 | #define FIXED_CCA_THRESHOLD 15 |
| 80 | |
Vasanthakumar Thiagarajan | 60e0c3a | 2010-12-06 04:27:39 -0800 | [diff] [blame] | 81 | #define AR9300_BASE_ADDR_4K 0xfff |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 82 | #define AR9300_BASE_ADDR 0x3ff |
Felix Fietkau | 488f6ba | 2010-11-16 19:20:28 +0100 | [diff] [blame] | 83 | #define AR9300_BASE_ADDR_512 0x1ff |
| 84 | |
| 85 | #define AR9300_OTP_BASE 0x14000 |
| 86 | #define AR9300_OTP_STATUS 0x15f18 |
| 87 | #define AR9300_OTP_STATUS_TYPE 0x7 |
| 88 | #define AR9300_OTP_STATUS_VALID 0x4 |
| 89 | #define AR9300_OTP_STATUS_ACCESS_BUSY 0x2 |
| 90 | #define AR9300_OTP_STATUS_SM_BUSY 0x1 |
| 91 | #define AR9300_OTP_READ_DATA 0x15f1c |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 92 | |
| 93 | enum targetPowerHTRates { |
| 94 | HT_TARGET_RATE_0_8_16, |
| 95 | HT_TARGET_RATE_1_3_9_11_17_19, |
| 96 | HT_TARGET_RATE_4, |
| 97 | HT_TARGET_RATE_5, |
| 98 | HT_TARGET_RATE_6, |
| 99 | HT_TARGET_RATE_7, |
| 100 | HT_TARGET_RATE_12, |
| 101 | HT_TARGET_RATE_13, |
| 102 | HT_TARGET_RATE_14, |
| 103 | HT_TARGET_RATE_15, |
| 104 | HT_TARGET_RATE_20, |
| 105 | HT_TARGET_RATE_21, |
| 106 | HT_TARGET_RATE_22, |
| 107 | HT_TARGET_RATE_23 |
| 108 | }; |
| 109 | |
| 110 | enum targetPowerLegacyRates { |
| 111 | LEGACY_TARGET_RATE_6_24, |
| 112 | LEGACY_TARGET_RATE_36, |
| 113 | LEGACY_TARGET_RATE_48, |
| 114 | LEGACY_TARGET_RATE_54 |
| 115 | }; |
| 116 | |
| 117 | enum targetPowerCckRates { |
| 118 | LEGACY_TARGET_RATE_1L_5L, |
| 119 | LEGACY_TARGET_RATE_5S, |
| 120 | LEGACY_TARGET_RATE_11L, |
| 121 | LEGACY_TARGET_RATE_11S |
| 122 | }; |
| 123 | |
| 124 | enum ar9300_Rates { |
| 125 | ALL_TARGET_LEGACY_6_24, |
| 126 | ALL_TARGET_LEGACY_36, |
| 127 | ALL_TARGET_LEGACY_48, |
| 128 | ALL_TARGET_LEGACY_54, |
| 129 | ALL_TARGET_LEGACY_1L_5L, |
| 130 | ALL_TARGET_LEGACY_5S, |
| 131 | ALL_TARGET_LEGACY_11L, |
| 132 | ALL_TARGET_LEGACY_11S, |
| 133 | ALL_TARGET_HT20_0_8_16, |
| 134 | ALL_TARGET_HT20_1_3_9_11_17_19, |
| 135 | ALL_TARGET_HT20_4, |
| 136 | ALL_TARGET_HT20_5, |
| 137 | ALL_TARGET_HT20_6, |
| 138 | ALL_TARGET_HT20_7, |
| 139 | ALL_TARGET_HT20_12, |
| 140 | ALL_TARGET_HT20_13, |
| 141 | ALL_TARGET_HT20_14, |
| 142 | ALL_TARGET_HT20_15, |
| 143 | ALL_TARGET_HT20_20, |
| 144 | ALL_TARGET_HT20_21, |
| 145 | ALL_TARGET_HT20_22, |
| 146 | ALL_TARGET_HT20_23, |
| 147 | ALL_TARGET_HT40_0_8_16, |
| 148 | ALL_TARGET_HT40_1_3_9_11_17_19, |
| 149 | ALL_TARGET_HT40_4, |
| 150 | ALL_TARGET_HT40_5, |
| 151 | ALL_TARGET_HT40_6, |
| 152 | ALL_TARGET_HT40_7, |
| 153 | ALL_TARGET_HT40_12, |
| 154 | ALL_TARGET_HT40_13, |
| 155 | ALL_TARGET_HT40_14, |
| 156 | ALL_TARGET_HT40_15, |
| 157 | ALL_TARGET_HT40_20, |
| 158 | ALL_TARGET_HT40_21, |
| 159 | ALL_TARGET_HT40_22, |
| 160 | ALL_TARGET_HT40_23, |
| 161 | ar9300RateSize, |
| 162 | }; |
| 163 | |
| 164 | |
| 165 | struct eepFlags { |
| 166 | u8 opFlags; |
| 167 | u8 eepMisc; |
| 168 | } __packed; |
| 169 | |
| 170 | enum CompressAlgorithm { |
| 171 | _CompressNone = 0, |
| 172 | _CompressLzma, |
| 173 | _CompressPairs, |
| 174 | _CompressBlock, |
| 175 | _Compress4, |
| 176 | _Compress5, |
| 177 | _Compress6, |
| 178 | _Compress7, |
| 179 | }; |
| 180 | |
| 181 | struct ar9300_base_eep_hdr { |
Felix Fietkau | ffdc4cb | 2010-05-11 17:23:03 +0200 | [diff] [blame] | 182 | __le16 regDmn[2]; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 183 | /* 4 bits tx and 4 bits rx */ |
| 184 | u8 txrxMask; |
| 185 | struct eepFlags opCapFlags; |
| 186 | u8 rfSilent; |
| 187 | u8 blueToothOptions; |
| 188 | u8 deviceCap; |
| 189 | /* takes lower byte in eeprom location */ |
| 190 | u8 deviceType; |
| 191 | /* offset in dB to be added to beginning |
| 192 | * of pdadc table in calibration |
| 193 | */ |
| 194 | int8_t pwrTableOffset; |
| 195 | u8 params_for_tuning_caps[2]; |
| 196 | /* |
| 197 | * bit0 - enable tx temp comp |
| 198 | * bit1 - enable tx volt comp |
| 199 | * bit2 - enable fastClock - default to 1 |
| 200 | * bit3 - enable doubling - default to 1 |
| 201 | * bit4 - enable internal regulator - default to 1 |
| 202 | */ |
| 203 | u8 featureEnable; |
| 204 | /* misc flags: bit0 - turn down drivestrength */ |
| 205 | u8 miscConfiguration; |
| 206 | u8 eepromWriteEnableGpio; |
| 207 | u8 wlanDisableGpio; |
| 208 | u8 wlanLedGpio; |
| 209 | u8 rxBandSelectGpio; |
| 210 | u8 txrxgain; |
| 211 | /* SW controlled internal regulator fields */ |
Felix Fietkau | ffdc4cb | 2010-05-11 17:23:03 +0200 | [diff] [blame] | 212 | __le32 swreg; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 213 | } __packed; |
| 214 | |
| 215 | struct ar9300_modal_eep_header { |
| 216 | /* 4 idle, t1, t2, b (4 bits per setting) */ |
Felix Fietkau | ffdc4cb | 2010-05-11 17:23:03 +0200 | [diff] [blame] | 217 | __le32 antCtrlCommon; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 218 | /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ |
Felix Fietkau | ffdc4cb | 2010-05-11 17:23:03 +0200 | [diff] [blame] | 219 | __le32 antCtrlCommon2; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 220 | /* 6 idle, t, r, rx1, rx12, b (2 bits each) */ |
Felix Fietkau | ffdc4cb | 2010-05-11 17:23:03 +0200 | [diff] [blame] | 221 | __le16 antCtrlChain[AR9300_MAX_CHAINS]; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 222 | /* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */ |
| 223 | u8 xatten1DB[AR9300_MAX_CHAINS]; |
| 224 | /* 3 xatten1_margin for merlin (0xa20c/b20c 16:12 */ |
| 225 | u8 xatten1Margin[AR9300_MAX_CHAINS]; |
| 226 | int8_t tempSlope; |
| 227 | int8_t voltSlope; |
| 228 | /* spur channels in usual fbin coding format */ |
| 229 | u8 spurChans[AR9300_EEPROM_MODAL_SPURS]; |
| 230 | /* 3 Check if the register is per chain */ |
| 231 | int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS]; |
| 232 | u8 ob[AR9300_MAX_CHAINS]; |
| 233 | u8 db_stage2[AR9300_MAX_CHAINS]; |
| 234 | u8 db_stage3[AR9300_MAX_CHAINS]; |
| 235 | u8 db_stage4[AR9300_MAX_CHAINS]; |
| 236 | u8 xpaBiasLvl; |
| 237 | u8 txFrameToDataStart; |
| 238 | u8 txFrameToPaOn; |
| 239 | u8 txClip; |
| 240 | int8_t antennaGain; |
| 241 | u8 switchSettling; |
| 242 | int8_t adcDesiredSize; |
| 243 | u8 txEndToXpaOff; |
| 244 | u8 txEndToRxOn; |
| 245 | u8 txFrameToXpaOn; |
| 246 | u8 thresh62; |
Felix Fietkau | 4935250 | 2010-06-12 00:33:59 -0400 | [diff] [blame] | 247 | __le32 papdRateMaskHt20; |
| 248 | __le32 papdRateMaskHt40; |
Senthil Balasubramanian | b3dd6bc | 2010-11-10 05:03:07 -0800 | [diff] [blame] | 249 | u8 futureModal[10]; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 250 | } __packed; |
| 251 | |
| 252 | struct ar9300_cal_data_per_freq_op_loop { |
| 253 | int8_t refPower; |
| 254 | /* pdadc voltage at power measurement */ |
| 255 | u8 voltMeas; |
| 256 | /* pcdac used for power measurement */ |
| 257 | u8 tempMeas; |
| 258 | /* range is -60 to -127 create a mapping equation 1db resolution */ |
| 259 | int8_t rxNoisefloorCal; |
| 260 | /*range is same as noisefloor */ |
| 261 | int8_t rxNoisefloorPower; |
| 262 | /* temp measured when noisefloor cal was performed */ |
| 263 | u8 rxTempMeas; |
| 264 | } __packed; |
| 265 | |
| 266 | struct cal_tgt_pow_legacy { |
| 267 | u8 tPow2x[4]; |
| 268 | } __packed; |
| 269 | |
| 270 | struct cal_tgt_pow_ht { |
| 271 | u8 tPow2x[14]; |
| 272 | } __packed; |
| 273 | |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 274 | struct cal_ctl_data_2g { |
Felix Fietkau | e702ba1 | 2010-12-01 19:07:46 +0100 | [diff] [blame] | 275 | u8 ctlEdges[AR9300_NUM_BAND_EDGES_2G]; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 276 | } __packed; |
| 277 | |
| 278 | struct cal_ctl_data_5g { |
Felix Fietkau | e702ba1 | 2010-12-01 19:07:46 +0100 | [diff] [blame] | 279 | u8 ctlEdges[AR9300_NUM_BAND_EDGES_5G]; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 280 | } __packed; |
| 281 | |
Senthil Balasubramanian | b3dd6bc | 2010-11-10 05:03:07 -0800 | [diff] [blame] | 282 | struct ar9300_BaseExtension_1 { |
| 283 | u8 ant_div_control; |
| 284 | u8 future[13]; |
| 285 | } __packed; |
| 286 | |
| 287 | struct ar9300_BaseExtension_2 { |
| 288 | int8_t tempSlopeLow; |
| 289 | int8_t tempSlopeHigh; |
| 290 | u8 xatten1DBLow[AR9300_MAX_CHAINS]; |
| 291 | u8 xatten1MarginLow[AR9300_MAX_CHAINS]; |
| 292 | u8 xatten1DBHigh[AR9300_MAX_CHAINS]; |
| 293 | u8 xatten1MarginHigh[AR9300_MAX_CHAINS]; |
| 294 | } __packed; |
| 295 | |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 296 | struct ar9300_eeprom { |
| 297 | u8 eepromVersion; |
| 298 | u8 templateVersion; |
| 299 | u8 macAddr[6]; |
| 300 | u8 custData[AR9300_CUSTOMER_DATA_SIZE]; |
| 301 | |
| 302 | struct ar9300_base_eep_hdr baseEepHeader; |
| 303 | |
| 304 | struct ar9300_modal_eep_header modalHeader2G; |
Senthil Balasubramanian | b3dd6bc | 2010-11-10 05:03:07 -0800 | [diff] [blame] | 305 | struct ar9300_BaseExtension_1 base_ext1; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 306 | u8 calFreqPier2G[AR9300_NUM_2G_CAL_PIERS]; |
| 307 | struct ar9300_cal_data_per_freq_op_loop |
| 308 | calPierData2G[AR9300_MAX_CHAINS][AR9300_NUM_2G_CAL_PIERS]; |
| 309 | u8 calTarget_freqbin_Cck[AR9300_NUM_2G_CCK_TARGET_POWERS]; |
| 310 | u8 calTarget_freqbin_2G[AR9300_NUM_2G_20_TARGET_POWERS]; |
| 311 | u8 calTarget_freqbin_2GHT20[AR9300_NUM_2G_20_TARGET_POWERS]; |
| 312 | u8 calTarget_freqbin_2GHT40[AR9300_NUM_2G_40_TARGET_POWERS]; |
| 313 | struct cal_tgt_pow_legacy |
| 314 | calTargetPowerCck[AR9300_NUM_2G_CCK_TARGET_POWERS]; |
| 315 | struct cal_tgt_pow_legacy |
| 316 | calTargetPower2G[AR9300_NUM_2G_20_TARGET_POWERS]; |
| 317 | struct cal_tgt_pow_ht |
| 318 | calTargetPower2GHT20[AR9300_NUM_2G_20_TARGET_POWERS]; |
| 319 | struct cal_tgt_pow_ht |
| 320 | calTargetPower2GHT40[AR9300_NUM_2G_40_TARGET_POWERS]; |
| 321 | u8 ctlIndex_2G[AR9300_NUM_CTLS_2G]; |
| 322 | u8 ctl_freqbin_2G[AR9300_NUM_CTLS_2G][AR9300_NUM_BAND_EDGES_2G]; |
| 323 | struct cal_ctl_data_2g ctlPowerData_2G[AR9300_NUM_CTLS_2G]; |
| 324 | struct ar9300_modal_eep_header modalHeader5G; |
Senthil Balasubramanian | b3dd6bc | 2010-11-10 05:03:07 -0800 | [diff] [blame] | 325 | struct ar9300_BaseExtension_2 base_ext2; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 326 | u8 calFreqPier5G[AR9300_NUM_5G_CAL_PIERS]; |
| 327 | struct ar9300_cal_data_per_freq_op_loop |
| 328 | calPierData5G[AR9300_MAX_CHAINS][AR9300_NUM_5G_CAL_PIERS]; |
| 329 | u8 calTarget_freqbin_5G[AR9300_NUM_5G_20_TARGET_POWERS]; |
| 330 | u8 calTarget_freqbin_5GHT20[AR9300_NUM_5G_20_TARGET_POWERS]; |
| 331 | u8 calTarget_freqbin_5GHT40[AR9300_NUM_5G_40_TARGET_POWERS]; |
| 332 | struct cal_tgt_pow_legacy |
| 333 | calTargetPower5G[AR9300_NUM_5G_20_TARGET_POWERS]; |
| 334 | struct cal_tgt_pow_ht |
| 335 | calTargetPower5GHT20[AR9300_NUM_5G_20_TARGET_POWERS]; |
| 336 | struct cal_tgt_pow_ht |
| 337 | calTargetPower5GHT40[AR9300_NUM_5G_40_TARGET_POWERS]; |
| 338 | u8 ctlIndex_5G[AR9300_NUM_CTLS_5G]; |
| 339 | u8 ctl_freqbin_5G[AR9300_NUM_CTLS_5G][AR9300_NUM_BAND_EDGES_5G]; |
| 340 | struct cal_ctl_data_5g ctlPowerData_5G[AR9300_NUM_CTLS_5G]; |
| 341 | } __packed; |
Luis R. Rodriguez | c14a85d | 2010-04-15 17:39:21 -0400 | [diff] [blame] | 342 | |
| 343 | s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah); |
| 344 | s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah); |
| 345 | |
Vasanthakumar Thiagarajan | 272ceba | 2010-12-06 04:27:46 -0800 | [diff] [blame^] | 346 | u8 *ar9003_get_spur_chan_ptr(struct ath_hw *ah, bool is_2ghz); |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 347 | #endif |