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 | |
| 81 | #define AR9300_BASE_ADDR 0x3ff |
| 82 | |
| 83 | enum targetPowerHTRates { |
| 84 | HT_TARGET_RATE_0_8_16, |
| 85 | HT_TARGET_RATE_1_3_9_11_17_19, |
| 86 | HT_TARGET_RATE_4, |
| 87 | HT_TARGET_RATE_5, |
| 88 | HT_TARGET_RATE_6, |
| 89 | HT_TARGET_RATE_7, |
| 90 | HT_TARGET_RATE_12, |
| 91 | HT_TARGET_RATE_13, |
| 92 | HT_TARGET_RATE_14, |
| 93 | HT_TARGET_RATE_15, |
| 94 | HT_TARGET_RATE_20, |
| 95 | HT_TARGET_RATE_21, |
| 96 | HT_TARGET_RATE_22, |
| 97 | HT_TARGET_RATE_23 |
| 98 | }; |
| 99 | |
| 100 | enum targetPowerLegacyRates { |
| 101 | LEGACY_TARGET_RATE_6_24, |
| 102 | LEGACY_TARGET_RATE_36, |
| 103 | LEGACY_TARGET_RATE_48, |
| 104 | LEGACY_TARGET_RATE_54 |
| 105 | }; |
| 106 | |
| 107 | enum targetPowerCckRates { |
| 108 | LEGACY_TARGET_RATE_1L_5L, |
| 109 | LEGACY_TARGET_RATE_5S, |
| 110 | LEGACY_TARGET_RATE_11L, |
| 111 | LEGACY_TARGET_RATE_11S |
| 112 | }; |
| 113 | |
| 114 | enum ar9300_Rates { |
| 115 | ALL_TARGET_LEGACY_6_24, |
| 116 | ALL_TARGET_LEGACY_36, |
| 117 | ALL_TARGET_LEGACY_48, |
| 118 | ALL_TARGET_LEGACY_54, |
| 119 | ALL_TARGET_LEGACY_1L_5L, |
| 120 | ALL_TARGET_LEGACY_5S, |
| 121 | ALL_TARGET_LEGACY_11L, |
| 122 | ALL_TARGET_LEGACY_11S, |
| 123 | ALL_TARGET_HT20_0_8_16, |
| 124 | ALL_TARGET_HT20_1_3_9_11_17_19, |
| 125 | ALL_TARGET_HT20_4, |
| 126 | ALL_TARGET_HT20_5, |
| 127 | ALL_TARGET_HT20_6, |
| 128 | ALL_TARGET_HT20_7, |
| 129 | ALL_TARGET_HT20_12, |
| 130 | ALL_TARGET_HT20_13, |
| 131 | ALL_TARGET_HT20_14, |
| 132 | ALL_TARGET_HT20_15, |
| 133 | ALL_TARGET_HT20_20, |
| 134 | ALL_TARGET_HT20_21, |
| 135 | ALL_TARGET_HT20_22, |
| 136 | ALL_TARGET_HT20_23, |
| 137 | ALL_TARGET_HT40_0_8_16, |
| 138 | ALL_TARGET_HT40_1_3_9_11_17_19, |
| 139 | ALL_TARGET_HT40_4, |
| 140 | ALL_TARGET_HT40_5, |
| 141 | ALL_TARGET_HT40_6, |
| 142 | ALL_TARGET_HT40_7, |
| 143 | ALL_TARGET_HT40_12, |
| 144 | ALL_TARGET_HT40_13, |
| 145 | ALL_TARGET_HT40_14, |
| 146 | ALL_TARGET_HT40_15, |
| 147 | ALL_TARGET_HT40_20, |
| 148 | ALL_TARGET_HT40_21, |
| 149 | ALL_TARGET_HT40_22, |
| 150 | ALL_TARGET_HT40_23, |
| 151 | ar9300RateSize, |
| 152 | }; |
| 153 | |
| 154 | |
| 155 | struct eepFlags { |
| 156 | u8 opFlags; |
| 157 | u8 eepMisc; |
| 158 | } __packed; |
| 159 | |
| 160 | enum CompressAlgorithm { |
| 161 | _CompressNone = 0, |
| 162 | _CompressLzma, |
| 163 | _CompressPairs, |
| 164 | _CompressBlock, |
| 165 | _Compress4, |
| 166 | _Compress5, |
| 167 | _Compress6, |
| 168 | _Compress7, |
| 169 | }; |
| 170 | |
| 171 | struct ar9300_base_eep_hdr { |
Felix Fietkau | ffdc4cb | 2010-05-11 17:23:03 +0200 | [diff] [blame] | 172 | __le16 regDmn[2]; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 173 | /* 4 bits tx and 4 bits rx */ |
| 174 | u8 txrxMask; |
| 175 | struct eepFlags opCapFlags; |
| 176 | u8 rfSilent; |
| 177 | u8 blueToothOptions; |
| 178 | u8 deviceCap; |
| 179 | /* takes lower byte in eeprom location */ |
| 180 | u8 deviceType; |
| 181 | /* offset in dB to be added to beginning |
| 182 | * of pdadc table in calibration |
| 183 | */ |
| 184 | int8_t pwrTableOffset; |
| 185 | u8 params_for_tuning_caps[2]; |
| 186 | /* |
| 187 | * bit0 - enable tx temp comp |
| 188 | * bit1 - enable tx volt comp |
| 189 | * bit2 - enable fastClock - default to 1 |
| 190 | * bit3 - enable doubling - default to 1 |
| 191 | * bit4 - enable internal regulator - default to 1 |
| 192 | */ |
| 193 | u8 featureEnable; |
| 194 | /* misc flags: bit0 - turn down drivestrength */ |
| 195 | u8 miscConfiguration; |
| 196 | u8 eepromWriteEnableGpio; |
| 197 | u8 wlanDisableGpio; |
| 198 | u8 wlanLedGpio; |
| 199 | u8 rxBandSelectGpio; |
| 200 | u8 txrxgain; |
| 201 | /* SW controlled internal regulator fields */ |
Felix Fietkau | ffdc4cb | 2010-05-11 17:23:03 +0200 | [diff] [blame] | 202 | __le32 swreg; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 203 | } __packed; |
| 204 | |
| 205 | struct ar9300_modal_eep_header { |
| 206 | /* 4 idle, t1, t2, b (4 bits per setting) */ |
Felix Fietkau | ffdc4cb | 2010-05-11 17:23:03 +0200 | [diff] [blame] | 207 | __le32 antCtrlCommon; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 208 | /* 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12 */ |
Felix Fietkau | ffdc4cb | 2010-05-11 17:23:03 +0200 | [diff] [blame] | 209 | __le32 antCtrlCommon2; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 210 | /* 6 idle, t, r, rx1, rx12, b (2 bits each) */ |
Felix Fietkau | ffdc4cb | 2010-05-11 17:23:03 +0200 | [diff] [blame] | 211 | __le16 antCtrlChain[AR9300_MAX_CHAINS]; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 212 | /* 3 xatten1_db for AR9280 (0xa20c/b20c 5:0) */ |
| 213 | u8 xatten1DB[AR9300_MAX_CHAINS]; |
| 214 | /* 3 xatten1_margin for merlin (0xa20c/b20c 16:12 */ |
| 215 | u8 xatten1Margin[AR9300_MAX_CHAINS]; |
| 216 | int8_t tempSlope; |
| 217 | int8_t voltSlope; |
| 218 | /* spur channels in usual fbin coding format */ |
| 219 | u8 spurChans[AR9300_EEPROM_MODAL_SPURS]; |
| 220 | /* 3 Check if the register is per chain */ |
| 221 | int8_t noiseFloorThreshCh[AR9300_MAX_CHAINS]; |
| 222 | u8 ob[AR9300_MAX_CHAINS]; |
| 223 | u8 db_stage2[AR9300_MAX_CHAINS]; |
| 224 | u8 db_stage3[AR9300_MAX_CHAINS]; |
| 225 | u8 db_stage4[AR9300_MAX_CHAINS]; |
| 226 | u8 xpaBiasLvl; |
| 227 | u8 txFrameToDataStart; |
| 228 | u8 txFrameToPaOn; |
| 229 | u8 txClip; |
| 230 | int8_t antennaGain; |
| 231 | u8 switchSettling; |
| 232 | int8_t adcDesiredSize; |
| 233 | u8 txEndToXpaOff; |
| 234 | u8 txEndToRxOn; |
| 235 | u8 txFrameToXpaOn; |
| 236 | u8 thresh62; |
Felix Fietkau | 4935250 | 2010-06-12 00:33:59 -0400 | [diff] [blame] | 237 | __le32 papdRateMaskHt20; |
| 238 | __le32 papdRateMaskHt40; |
| 239 | u8 futureModal[24]; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 240 | } __packed; |
| 241 | |
| 242 | struct ar9300_cal_data_per_freq_op_loop { |
| 243 | int8_t refPower; |
| 244 | /* pdadc voltage at power measurement */ |
| 245 | u8 voltMeas; |
| 246 | /* pcdac used for power measurement */ |
| 247 | u8 tempMeas; |
| 248 | /* range is -60 to -127 create a mapping equation 1db resolution */ |
| 249 | int8_t rxNoisefloorCal; |
| 250 | /*range is same as noisefloor */ |
| 251 | int8_t rxNoisefloorPower; |
| 252 | /* temp measured when noisefloor cal was performed */ |
| 253 | u8 rxTempMeas; |
| 254 | } __packed; |
| 255 | |
| 256 | struct cal_tgt_pow_legacy { |
| 257 | u8 tPow2x[4]; |
| 258 | } __packed; |
| 259 | |
| 260 | struct cal_tgt_pow_ht { |
| 261 | u8 tPow2x[14]; |
| 262 | } __packed; |
| 263 | |
| 264 | struct cal_ctl_edge_pwr { |
| 265 | u8 tPower:6, |
| 266 | flag:2; |
| 267 | } __packed; |
| 268 | |
| 269 | struct cal_ctl_data_2g { |
Felix Fietkau | 8393722 | 2010-04-26 15:04:31 -0400 | [diff] [blame] | 270 | struct cal_ctl_edge_pwr ctlEdges[AR9300_NUM_BAND_EDGES_2G]; |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 271 | } __packed; |
| 272 | |
| 273 | struct cal_ctl_data_5g { |
| 274 | struct cal_ctl_edge_pwr ctlEdges[AR9300_NUM_BAND_EDGES_5G]; |
| 275 | } __packed; |
| 276 | |
| 277 | struct ar9300_eeprom { |
| 278 | u8 eepromVersion; |
| 279 | u8 templateVersion; |
| 280 | u8 macAddr[6]; |
| 281 | u8 custData[AR9300_CUSTOMER_DATA_SIZE]; |
| 282 | |
| 283 | struct ar9300_base_eep_hdr baseEepHeader; |
| 284 | |
| 285 | struct ar9300_modal_eep_header modalHeader2G; |
| 286 | u8 calFreqPier2G[AR9300_NUM_2G_CAL_PIERS]; |
| 287 | struct ar9300_cal_data_per_freq_op_loop |
| 288 | calPierData2G[AR9300_MAX_CHAINS][AR9300_NUM_2G_CAL_PIERS]; |
| 289 | u8 calTarget_freqbin_Cck[AR9300_NUM_2G_CCK_TARGET_POWERS]; |
| 290 | u8 calTarget_freqbin_2G[AR9300_NUM_2G_20_TARGET_POWERS]; |
| 291 | u8 calTarget_freqbin_2GHT20[AR9300_NUM_2G_20_TARGET_POWERS]; |
| 292 | u8 calTarget_freqbin_2GHT40[AR9300_NUM_2G_40_TARGET_POWERS]; |
| 293 | struct cal_tgt_pow_legacy |
| 294 | calTargetPowerCck[AR9300_NUM_2G_CCK_TARGET_POWERS]; |
| 295 | struct cal_tgt_pow_legacy |
| 296 | calTargetPower2G[AR9300_NUM_2G_20_TARGET_POWERS]; |
| 297 | struct cal_tgt_pow_ht |
| 298 | calTargetPower2GHT20[AR9300_NUM_2G_20_TARGET_POWERS]; |
| 299 | struct cal_tgt_pow_ht |
| 300 | calTargetPower2GHT40[AR9300_NUM_2G_40_TARGET_POWERS]; |
| 301 | u8 ctlIndex_2G[AR9300_NUM_CTLS_2G]; |
| 302 | u8 ctl_freqbin_2G[AR9300_NUM_CTLS_2G][AR9300_NUM_BAND_EDGES_2G]; |
| 303 | struct cal_ctl_data_2g ctlPowerData_2G[AR9300_NUM_CTLS_2G]; |
| 304 | struct ar9300_modal_eep_header modalHeader5G; |
| 305 | u8 calFreqPier5G[AR9300_NUM_5G_CAL_PIERS]; |
| 306 | struct ar9300_cal_data_per_freq_op_loop |
| 307 | calPierData5G[AR9300_MAX_CHAINS][AR9300_NUM_5G_CAL_PIERS]; |
| 308 | u8 calTarget_freqbin_5G[AR9300_NUM_5G_20_TARGET_POWERS]; |
| 309 | u8 calTarget_freqbin_5GHT20[AR9300_NUM_5G_20_TARGET_POWERS]; |
| 310 | u8 calTarget_freqbin_5GHT40[AR9300_NUM_5G_40_TARGET_POWERS]; |
| 311 | struct cal_tgt_pow_legacy |
| 312 | calTargetPower5G[AR9300_NUM_5G_20_TARGET_POWERS]; |
| 313 | struct cal_tgt_pow_ht |
| 314 | calTargetPower5GHT20[AR9300_NUM_5G_20_TARGET_POWERS]; |
| 315 | struct cal_tgt_pow_ht |
| 316 | calTargetPower5GHT40[AR9300_NUM_5G_40_TARGET_POWERS]; |
| 317 | u8 ctlIndex_5G[AR9300_NUM_CTLS_5G]; |
| 318 | u8 ctl_freqbin_5G[AR9300_NUM_CTLS_5G][AR9300_NUM_BAND_EDGES_5G]; |
| 319 | struct cal_ctl_data_5g ctlPowerData_5G[AR9300_NUM_CTLS_5G]; |
| 320 | } __packed; |
Luis R. Rodriguez | c14a85d | 2010-04-15 17:39:21 -0400 | [diff] [blame] | 321 | |
| 322 | s32 ar9003_hw_get_tx_gain_idx(struct ath_hw *ah); |
| 323 | s32 ar9003_hw_get_rx_gain_idx(struct ath_hw *ah); |
| 324 | |
Senthil Balasubramanian | 15c9ee7 | 2010-04-15 17:39:14 -0400 | [diff] [blame] | 325 | #endif |