1*572ff6f6SMatthew Dillon /* 2*572ff6f6SMatthew Dillon * Copyright (c) 2009 Rui Paulo <rpaulo@FreeBSD.org> 3*572ff6f6SMatthew Dillon * Copyright (c) 2008 Sam Leffler, Errno Consulting 4*572ff6f6SMatthew Dillon * Copyright (c) 2008 Atheros Communications, Inc. 5*572ff6f6SMatthew Dillon * 6*572ff6f6SMatthew Dillon * Permission to use, copy, modify, and/or distribute this software for any 7*572ff6f6SMatthew Dillon * purpose with or without fee is hereby granted, provided that the above 8*572ff6f6SMatthew Dillon * copyright notice and this permission notice appear in all copies. 9*572ff6f6SMatthew Dillon * 10*572ff6f6SMatthew Dillon * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11*572ff6f6SMatthew Dillon * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12*572ff6f6SMatthew Dillon * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13*572ff6f6SMatthew Dillon * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14*572ff6f6SMatthew Dillon * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15*572ff6f6SMatthew Dillon * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16*572ff6f6SMatthew Dillon * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17*572ff6f6SMatthew Dillon * 18*572ff6f6SMatthew Dillon * $FreeBSD$ 19*572ff6f6SMatthew Dillon */ 20*572ff6f6SMatthew Dillon #ifndef _AH_EEPROM_V4K_H_ 21*572ff6f6SMatthew Dillon #define _AH_EEPROM_V4K_H_ 22*572ff6f6SMatthew Dillon 23*572ff6f6SMatthew Dillon #include "ah_eeprom.h" 24*572ff6f6SMatthew Dillon #include "ah_eeprom_v14.h" 25*572ff6f6SMatthew Dillon 26*572ff6f6SMatthew Dillon #if _BYTE_ORDER == _BIG_ENDIAN 27*572ff6f6SMatthew Dillon #define __BIG_ENDIAN_BITFIELD 28*572ff6f6SMatthew Dillon #endif 29*572ff6f6SMatthew Dillon 30*572ff6f6SMatthew Dillon #define AR9285_RDEXT_DEFAULT 0x1F 31*572ff6f6SMatthew Dillon 32*572ff6f6SMatthew Dillon #define AR5416_4K_EEP_PD_GAIN_BOUNDARY_DEFAULT 58 33*572ff6f6SMatthew Dillon 34*572ff6f6SMatthew Dillon #undef owl_eep_start_loc 35*572ff6f6SMatthew Dillon #ifdef __LINUX_ARM_ARCH__ /* AP71 */ 36*572ff6f6SMatthew Dillon #define owl_eep_start_loc 0 37*572ff6f6SMatthew Dillon #else 38*572ff6f6SMatthew Dillon #define owl_eep_start_loc 64 39*572ff6f6SMatthew Dillon #endif 40*572ff6f6SMatthew Dillon 41*572ff6f6SMatthew Dillon // 16-bit offset location start of calibration struct 42*572ff6f6SMatthew Dillon #define AR5416_4K_EEP_START_LOC 64 43*572ff6f6SMatthew Dillon #define AR5416_4K_NUM_2G_CAL_PIERS 3 44*572ff6f6SMatthew Dillon #define AR5416_4K_NUM_2G_CCK_TARGET_POWERS 3 45*572ff6f6SMatthew Dillon #define AR5416_4K_NUM_2G_20_TARGET_POWERS 3 46*572ff6f6SMatthew Dillon #define AR5416_4K_NUM_2G_40_TARGET_POWERS 3 47*572ff6f6SMatthew Dillon #define AR5416_4K_NUM_CTLS 12 48*572ff6f6SMatthew Dillon #define AR5416_4K_NUM_BAND_EDGES 4 49*572ff6f6SMatthew Dillon #define AR5416_4K_NUM_PD_GAINS 2 50*572ff6f6SMatthew Dillon #define AR5416_4K_MAX_CHAINS 1 51*572ff6f6SMatthew Dillon 52*572ff6f6SMatthew Dillon /* 53*572ff6f6SMatthew Dillon * NB: The format in EEPROM has words 0 and 2 swapped (i.e. version 54*572ff6f6SMatthew Dillon * and length are swapped). We reverse their position after reading 55*572ff6f6SMatthew Dillon * the data into host memory so the version field is at the same 56*572ff6f6SMatthew Dillon * offset as in previous EEPROM layouts. This makes utilities that 57*572ff6f6SMatthew Dillon * inspect the EEPROM contents work without looking at the PCI device 58*572ff6f6SMatthew Dillon * id which may or may not be reliable. 59*572ff6f6SMatthew Dillon */ 60*572ff6f6SMatthew Dillon typedef struct BaseEepHeader4k { 61*572ff6f6SMatthew Dillon uint16_t version; /* NB: length in EEPROM */ 62*572ff6f6SMatthew Dillon uint16_t checksum; 63*572ff6f6SMatthew Dillon uint16_t length; /* NB: version in EEPROM */ 64*572ff6f6SMatthew Dillon uint8_t opCapFlags; 65*572ff6f6SMatthew Dillon uint8_t eepMisc; 66*572ff6f6SMatthew Dillon uint16_t regDmn[2]; 67*572ff6f6SMatthew Dillon uint8_t macAddr[6]; 68*572ff6f6SMatthew Dillon uint8_t rxMask; 69*572ff6f6SMatthew Dillon uint8_t txMask; 70*572ff6f6SMatthew Dillon uint16_t rfSilent; 71*572ff6f6SMatthew Dillon uint16_t blueToothOptions; 72*572ff6f6SMatthew Dillon uint16_t deviceCap; 73*572ff6f6SMatthew Dillon uint32_t binBuildNumber; 74*572ff6f6SMatthew Dillon uint8_t deviceType; 75*572ff6f6SMatthew Dillon uint8_t txGainType; /* high power tx gain table support */ 76*572ff6f6SMatthew Dillon } __packed BASE_EEP4K_HEADER; // 32 B 77*572ff6f6SMatthew Dillon 78*572ff6f6SMatthew Dillon typedef struct ModalEepHeader4k { 79*572ff6f6SMatthew Dillon uint32_t antCtrlChain[AR5416_4K_MAX_CHAINS]; // 4 80*572ff6f6SMatthew Dillon uint32_t antCtrlCommon; // 4 81*572ff6f6SMatthew Dillon int8_t antennaGainCh[AR5416_4K_MAX_CHAINS]; // 1 82*572ff6f6SMatthew Dillon uint8_t switchSettling; // 1 83*572ff6f6SMatthew Dillon uint8_t txRxAttenCh[AR5416_4K_MAX_CHAINS]; // 1 84*572ff6f6SMatthew Dillon uint8_t rxTxMarginCh[AR5416_4K_MAX_CHAINS]; // 1 85*572ff6f6SMatthew Dillon uint8_t adcDesiredSize; // 1 86*572ff6f6SMatthew Dillon int8_t pgaDesiredSize; // 1 87*572ff6f6SMatthew Dillon uint8_t xlnaGainCh[AR5416_4K_MAX_CHAINS]; // 1 88*572ff6f6SMatthew Dillon uint8_t txEndToXpaOff; // 1 89*572ff6f6SMatthew Dillon uint8_t txEndToRxOn; // 1 90*572ff6f6SMatthew Dillon uint8_t txFrameToXpaOn; // 1 91*572ff6f6SMatthew Dillon uint8_t thresh62; // 1 92*572ff6f6SMatthew Dillon uint8_t noiseFloorThreshCh[AR5416_4K_MAX_CHAINS]; // 1 93*572ff6f6SMatthew Dillon uint8_t xpdGain; // 1 94*572ff6f6SMatthew Dillon uint8_t xpd; // 1 95*572ff6f6SMatthew Dillon int8_t iqCalICh[AR5416_4K_MAX_CHAINS]; // 1 96*572ff6f6SMatthew Dillon int8_t iqCalQCh[AR5416_4K_MAX_CHAINS]; // 1 97*572ff6f6SMatthew Dillon 98*572ff6f6SMatthew Dillon uint8_t pdGainOverlap; // 1 99*572ff6f6SMatthew Dillon 100*572ff6f6SMatthew Dillon #ifdef __BIG_ENDIAN_BITFIELD 101*572ff6f6SMatthew Dillon uint8_t ob_1:4, ob_0:4; // 1 102*572ff6f6SMatthew Dillon uint8_t db1_1:4, db1_0:4; // 1 103*572ff6f6SMatthew Dillon #else 104*572ff6f6SMatthew Dillon uint8_t ob_0:4, ob_1:4; 105*572ff6f6SMatthew Dillon uint8_t db1_0:4, db1_1:4; 106*572ff6f6SMatthew Dillon #endif 107*572ff6f6SMatthew Dillon 108*572ff6f6SMatthew Dillon uint8_t xpaBiasLvl; // 1 109*572ff6f6SMatthew Dillon uint8_t txFrameToDataStart; // 1 110*572ff6f6SMatthew Dillon uint8_t txFrameToPaOn; // 1 111*572ff6f6SMatthew Dillon uint8_t ht40PowerIncForPdadc; // 1 112*572ff6f6SMatthew Dillon uint8_t bswAtten[AR5416_4K_MAX_CHAINS]; // 1 113*572ff6f6SMatthew Dillon uint8_t bswMargin[AR5416_4K_MAX_CHAINS]; // 1 114*572ff6f6SMatthew Dillon uint8_t swSettleHt40; // 1 115*572ff6f6SMatthew Dillon uint8_t xatten2Db[AR5416_4K_MAX_CHAINS]; // 1 116*572ff6f6SMatthew Dillon uint8_t xatten2Margin[AR5416_4K_MAX_CHAINS]; // 1 117*572ff6f6SMatthew Dillon 118*572ff6f6SMatthew Dillon #ifdef __BIG_ENDIAN_BITFIELD 119*572ff6f6SMatthew Dillon uint8_t db2_1:4, db2_0:4; // 1 120*572ff6f6SMatthew Dillon #else 121*572ff6f6SMatthew Dillon uint8_t db2_0:4, db2_1:4; // 1 122*572ff6f6SMatthew Dillon #endif 123*572ff6f6SMatthew Dillon 124*572ff6f6SMatthew Dillon uint8_t version; // 1 125*572ff6f6SMatthew Dillon 126*572ff6f6SMatthew Dillon #ifdef __BIG_ENDIAN_BITFIELD 127*572ff6f6SMatthew Dillon uint8_t ob_3:4, ob_2:4; // 1 128*572ff6f6SMatthew Dillon uint8_t antdiv_ctl1:4, ob_4:4; // 1 129*572ff6f6SMatthew Dillon uint8_t db1_3:4, db1_2:4; // 1 130*572ff6f6SMatthew Dillon uint8_t antdiv_ctl2:4, db1_4:4; // 1 131*572ff6f6SMatthew Dillon uint8_t db2_2:4, db2_3:4; // 1 132*572ff6f6SMatthew Dillon uint8_t reserved:4, db2_4:4; // 1 133*572ff6f6SMatthew Dillon #else 134*572ff6f6SMatthew Dillon uint8_t ob_2:4, ob_3:4; 135*572ff6f6SMatthew Dillon uint8_t ob_4:4, antdiv_ctl1:4; 136*572ff6f6SMatthew Dillon uint8_t db1_2:4, db1_3:4; 137*572ff6f6SMatthew Dillon uint8_t db1_4:4, antdiv_ctl2:4; 138*572ff6f6SMatthew Dillon uint8_t db2_2:4, db2_3:4; 139*572ff6f6SMatthew Dillon uint8_t db2_4:4, reserved:4; 140*572ff6f6SMatthew Dillon #endif 141*572ff6f6SMatthew Dillon uint8_t tx_diversity; 142*572ff6f6SMatthew Dillon uint8_t flc_pwr_thresh; 143*572ff6f6SMatthew Dillon uint8_t bb_scale_smrt_antenna; 144*572ff6f6SMatthew Dillon #define EEP_4K_BB_DESIRED_SCALE_MASK 0x1f 145*572ff6f6SMatthew Dillon uint8_t futureModal[1]; 146*572ff6f6SMatthew Dillon 147*572ff6f6SMatthew Dillon SPUR_CHAN spurChans[AR5416_EEPROM_MODAL_SPURS]; // 20 B 148*572ff6f6SMatthew Dillon } __packed MODAL_EEP4K_HEADER; // == 68 B 149*572ff6f6SMatthew Dillon 150*572ff6f6SMatthew Dillon typedef struct CalCtlData4k { 151*572ff6f6SMatthew Dillon CAL_CTL_EDGES ctlEdges[AR5416_4K_MAX_CHAINS][AR5416_4K_NUM_BAND_EDGES]; 152*572ff6f6SMatthew Dillon } __packed CAL_CTL_DATA_4K; 153*572ff6f6SMatthew Dillon 154*572ff6f6SMatthew Dillon typedef struct calDataPerFreq4k { 155*572ff6f6SMatthew Dillon uint8_t pwrPdg[AR5416_4K_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS]; 156*572ff6f6SMatthew Dillon uint8_t vpdPdg[AR5416_4K_NUM_PD_GAINS][AR5416_PD_GAIN_ICEPTS]; 157*572ff6f6SMatthew Dillon } __packed CAL_DATA_PER_FREQ_4K; 158*572ff6f6SMatthew Dillon 159*572ff6f6SMatthew Dillon struct ar5416eeprom_4k { 160*572ff6f6SMatthew Dillon BASE_EEP4K_HEADER baseEepHeader; // 32 B 161*572ff6f6SMatthew Dillon uint8_t custData[20]; // 20 B 162*572ff6f6SMatthew Dillon MODAL_EEP4K_HEADER modalHeader; // 68 B 163*572ff6f6SMatthew Dillon uint8_t calFreqPier2G[AR5416_4K_NUM_2G_CAL_PIERS]; 164*572ff6f6SMatthew Dillon CAL_DATA_PER_FREQ_4K calPierData2G[AR5416_4K_MAX_CHAINS][AR5416_4K_NUM_2G_CAL_PIERS]; 165*572ff6f6SMatthew Dillon CAL_TARGET_POWER_LEG calTargetPowerCck[AR5416_4K_NUM_2G_CCK_TARGET_POWERS]; 166*572ff6f6SMatthew Dillon CAL_TARGET_POWER_LEG calTargetPower2G[AR5416_4K_NUM_2G_20_TARGET_POWERS]; 167*572ff6f6SMatthew Dillon CAL_TARGET_POWER_HT calTargetPower2GHT20[AR5416_4K_NUM_2G_20_TARGET_POWERS]; 168*572ff6f6SMatthew Dillon CAL_TARGET_POWER_HT calTargetPower2GHT40[AR5416_4K_NUM_2G_40_TARGET_POWERS]; 169*572ff6f6SMatthew Dillon uint8_t ctlIndex[AR5416_4K_NUM_CTLS]; 170*572ff6f6SMatthew Dillon CAL_CTL_DATA_4K ctlData[AR5416_4K_NUM_CTLS]; 171*572ff6f6SMatthew Dillon uint8_t padding; 172*572ff6f6SMatthew Dillon } __packed; 173*572ff6f6SMatthew Dillon 174*572ff6f6SMatthew Dillon typedef struct { 175*572ff6f6SMatthew Dillon struct ar5416eeprom_4k ee_base; 176*572ff6f6SMatthew Dillon #define NUM_EDGES 8 177*572ff6f6SMatthew Dillon uint16_t ee_numCtls; 178*572ff6f6SMatthew Dillon RD_EDGES_POWER ee_rdEdgesPower[NUM_EDGES*AR5416_4K_NUM_CTLS]; 179*572ff6f6SMatthew Dillon /* XXX these are dynamically calculated for use by shared code */ 180*572ff6f6SMatthew Dillon int8_t ee_antennaGainMax; 181*572ff6f6SMatthew Dillon } HAL_EEPROM_v4k; 182*572ff6f6SMatthew Dillon #endif /* _AH_EEPROM_V4K_H_ */ 183