Path: blob/main/sys/contrib/dev/ath/ath_hal/ar9300/ar9300eep.h
48526 views
/*1* Copyright (c) 2013 Qualcomm Atheros, Inc.2*3* Permission to use, copy, modify, and/or distribute this software for any4* purpose with or without fee is hereby granted, provided that the above5* copyright notice and this permission notice appear in all copies.6*7* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH8* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY9* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,10* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM11* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR12* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR13* PERFORMANCE OF THIS SOFTWARE.14*/1516#ifndef _ATH_AR9300_EEP_H_17#define _ATH_AR9300_EEP_H_1819#include "opt_ah.h"20#include "ah.h"2122#if defined(WIN32) || defined(WIN64)23#pragma pack (push, ar9300, 1)24#endif2526/* Ensure that AH_BYTE_ORDER is defined */27#ifndef AH_BYTE_ORDER28#error AH_BYTE_ORDER needs to be defined!29#endif3031/* FreeBSD extras - should be in ah_eeprom.h ? */32#define AR_EEPROM_EEPCAP_COMPRESS_DIS 0x000133#define AR_EEPROM_EEPCAP_AES_DIS 0x000234#define AR_EEPROM_EEPCAP_FASTFRAME_DIS 0x000435#define AR_EEPROM_EEPCAP_BURST_DIS 0x000836#define AR_EEPROM_EEPCAP_MAXQCU 0x01F037#define AR_EEPROM_EEPCAP_MAXQCU_S 438#define AR_EEPROM_EEPCAP_HEAVY_CLIP_EN 0x020039#define AR_EEPROM_EEPCAP_KC_ENTRIES 0xF00040#define AR_EEPROM_EEPCAP_KC_ENTRIES_S 12414243#define MSTATE 10044#define MOUTPUT 204845#define MDEFAULT 1546#define MVALUE 1004748enum CompressAlgorithm49{50_compress_none = 0,51_compress_lzma,52_compress_pairs,53_compress_block,54_compress4,55_compress5,56_compress6,57_compress7,58};596061enum62{63calibration_data_none = 0,64calibration_data_dram,65calibration_data_flash,66calibration_data_eeprom,67calibration_data_otp,68#ifdef ATH_CAL_NAND_FLASH69calibration_data_nand,70#endif71CalibrationDataDontLoad,72};73#define HOST_CALDATA_SIZE (16*1024)7475//76// DO NOT CHANGE THE DEFINTIONS OF THESE SYMBOLS.77// Add additional definitions to the end.78// Yes, the first one is 2. Do not use 0 or 1.79//80enum Ar9300EepromTemplate81{82ar9300_eeprom_template_generic = 2,83ar9300_eeprom_template_hb112 = 3,84ar9300_eeprom_template_hb116 = 4,85ar9300_eeprom_template_xb112 = 5,86ar9300_eeprom_template_xb113 = 6,87ar9300_eeprom_template_xb114 = 7,88ar9300_eeprom_template_tb417 = 8,89ar9300_eeprom_template_ap111 = 9,90ar9300_eeprom_template_ap121 = 10,91ar9300_eeprom_template_hornet_generic = 11,92ar9300_eeprom_template_wasp_2 = 12,93ar9300_eeprom_template_wasp_k31 = 13,94ar9300_eeprom_template_osprey_k31 = 14,95ar9300_eeprom_template_aphrodite = 1596};9798#define ar9300_eeprom_template_default ar9300_eeprom_template_generic99#define Ar9300EepromFormatDefault 2100101#define reference_current 0102#define compression_header_length 4103#define compression_checksum_length 2104105#define OSPREY_EEP_VER 0xD000106#define OSPREY_EEP_VER_MINOR_MASK 0xFFF107#define OSPREY_EEP_MINOR_VER_1 0x1108#define OSPREY_EEP_MINOR_VER OSPREY_EEP_MINOR_VER_1109110// 16-bit offset location start of calibration struct111#define OSPREY_EEP_START_LOC 256112#define OSPREY_NUM_5G_CAL_PIERS 8113#define OSPREY_NUM_2G_CAL_PIERS 3114#define OSPREY_NUM_5G_20_TARGET_POWERS 8115#define OSPREY_NUM_5G_40_TARGET_POWERS 8116#define OSPREY_NUM_2G_CCK_TARGET_POWERS 2117#define OSPREY_NUM_2G_20_TARGET_POWERS 3118#define OSPREY_NUM_2G_40_TARGET_POWERS 3119//#define OSPREY_NUM_CTLS 21120#define OSPREY_NUM_CTLS_5G 9121#define OSPREY_NUM_CTLS_2G 12122#define OSPREY_CTL_MODE_M 0xF123#define OSPREY_NUM_BAND_EDGES_5G 8124#define OSPREY_NUM_BAND_EDGES_2G 4125#define OSPREY_NUM_PD_GAINS 4126#define OSPREY_PD_GAINS_IN_MASK 4127#define OSPREY_PD_GAIN_ICEPTS 5128#define OSPREY_EEPROM_MODAL_SPURS 5129#define OSPREY_MAX_RATE_POWER 63130#define OSPREY_NUM_PDADC_VALUES 128131#define OSPREY_NUM_RATES 16132#define OSPREY_BCHAN_UNUSED 0xFF133#define OSPREY_MAX_PWR_RANGE_IN_HALF_DB 64134#define OSPREY_OPFLAGS_11A 0x01135#define OSPREY_OPFLAGS_11G 0x02136#define OSPREY_OPFLAGS_5G_HT40 0x04137#define OSPREY_OPFLAGS_2G_HT40 0x08138#define OSPREY_OPFLAGS_5G_HT20 0x10139#define OSPREY_OPFLAGS_2G_HT20 0x20140#define OSPREY_EEPMISC_BIG_ENDIAN 0x01141#define OSPREY_EEPMISC_WOW 0x02142#define OSPREY_CUSTOMER_DATA_SIZE 20143144#define FREQ2FBIN(freq,is_2ghz) \145(u_int8_t)((is_2ghz) ? ((freq) - 2300) : (((freq) - 4800) / 5))146#define FBIN2FREQ(freq,is_2ghz) \147((is_2ghz) ? (2300 + freq) : (4800 + 5 * freq))148#define OSPREY_MAX_CHAINS 3149#define OSPREY_ANT_16S 25150#define OSPREY_FUTURE_MODAL_SZ 6151152#define OSPREY_NUM_ANT_CHAIN_FIELDS 7153#define OSPREY_NUM_ANT_COMMON_FIELDS 4154#define OSPREY_SIZE_ANT_CHAIN_FIELD 3155#define OSPREY_SIZE_ANT_COMMON_FIELD 4156#define OSPREY_ANT_CHAIN_MASK 0x7157#define OSPREY_ANT_COMMON_MASK 0xf158#define OSPREY_CHAIN_0_IDX 0159#define OSPREY_CHAIN_1_IDX 1160#define OSPREY_CHAIN_2_IDX 2161#define OSPREY_1_CHAINMASK 1162#define OSPREY_2LOHI_CHAINMASK 5163#define OSPREY_2LOMID_CHAINMASK 3164#define OSPREY_3_CHAINMASK 7165166#define AR928X_NUM_ANT_CHAIN_FIELDS 6167#define AR928X_SIZE_ANT_CHAIN_FIELD 2168#define AR928X_ANT_CHAIN_MASK 0x3169170/* Delta from which to start power to pdadc table */171/* This offset is used in both open loop and closed loop power control172* schemes. In open loop power control, it is not really needed, but for173* the "sake of consistency" it was kept.174* For certain AP designs, this value is overwritten by the value in the flag175* "pwrTableOffset" just before writing the pdadc vs pwr into the chip registers.176*/177#define OSPREY_PWR_TABLE_OFFSET 0178179//enable flags for voltage and temp compensation180#define ENABLE_TEMP_COMPENSATION 0x01181#define ENABLE_VOLT_COMPENSATION 0x02182183#define FLASH_BASE_CALDATA_OFFSET 0x1000184#define AR9300_EEPROM_SIZE 16*1024 // byte addressable185#define FIXED_CCA_THRESHOLD 15186187typedef struct eepFlags {188u_int8_t op_flags;189u_int8_t eepMisc;190} __packed EEP_FLAGS;191192typedef enum targetPowerHTRates {193HT_TARGET_RATE_0_8_16,194HT_TARGET_RATE_1_3_9_11_17_19,195HT_TARGET_RATE_4,196HT_TARGET_RATE_5,197HT_TARGET_RATE_6,198HT_TARGET_RATE_7,199HT_TARGET_RATE_12,200HT_TARGET_RATE_13,201HT_TARGET_RATE_14,202HT_TARGET_RATE_15,203HT_TARGET_RATE_20,204HT_TARGET_RATE_21,205HT_TARGET_RATE_22,206HT_TARGET_RATE_23207}TARGET_POWER_HT_RATES;208209const static int mapRate2Index[24]=210{2110,1,1,1,2,2123,4,5,0,1,2131,1,6,7,8,2149,0,1,1,1,21510,11,12,13216};217218typedef enum targetPowerLegacyRates {219LEGACY_TARGET_RATE_6_24,220LEGACY_TARGET_RATE_36,221LEGACY_TARGET_RATE_48,222LEGACY_TARGET_RATE_54223}TARGET_POWER_LEGACY_RATES;224225typedef enum targetPowerCckRates {226LEGACY_TARGET_RATE_1L_5L,227LEGACY_TARGET_RATE_5S,228LEGACY_TARGET_RATE_11L,229LEGACY_TARGET_RATE_11S230}TARGET_POWER_CCK_RATES;231232#define MAX_MODAL_RESERVED 11233#define MAX_MODAL_FUTURE 5234#define MAX_BASE_EXTENSION_FUTURE 2235#define MAX_TEMP_SLOPE 8236#define OSPREY_CHECKSUM_LOCATION (OSPREY_EEP_START_LOC + 1)237238typedef struct osprey_BaseEepHeader {239u_int16_t reg_dmn[2]; //Does this need to be outside of this structure, if it gets written after calibration240u_int8_t txrx_mask; //4 bits tx and 4 bits rx241EEP_FLAGS op_cap_flags;242u_int8_t rf_silent;243u_int8_t blue_tooth_options;244u_int8_t device_cap;245u_int8_t device_type; // takes lower byte in eeprom location246int8_t pwrTableOffset; // offset in dB to be added to beginning of pdadc table in calibration247u_int8_t params_for_tuning_caps[2]; //placeholder, get more details from Don248u_int8_t feature_enable; //bit0 - enable tx temp comp249//bit1 - enable tx volt comp250//bit2 - enable fastClock - default to 1251//bit3 - enable doubling - default to 1252//bit4 - enable internal regulator - default to 1253//bit5 - enable paprd - default to 0254//bit6 - enable TuningCaps - default to 0255//bit7 - enable tx_frame_to_xpa_on - default to 0256u_int8_t misc_configuration; //misc flags: bit0 - turn down drivestrength257// bit 1:2 - 0=don't force, 1=force to thermometer 0, 2=force to thermometer 1, 3=force to thermometer 2258// bit 3 - reduce chain mask from 0x7 to 0x3 on 2 stream rates259// bit 4 - enable quick drop260// bit 5 - enable 8 temp slop261// bit 6; enable xLNA_bias_strength262// bit 7; enable rf_gain_cap263u_int8_t eeprom_write_enable_gpio;264u_int8_t wlan_disable_gpio;265u_int8_t wlan_led_gpio;266u_int8_t rx_band_select_gpio;267u_int8_t txrxgain;268u_int32_t swreg; // SW controlled internal regulator fields269} __packed OSPREY_BASE_EEP_HEADER;270271typedef struct osprey_BaseExtension_1 {272u_int8_t ant_div_control;273u_int8_t future[MAX_BASE_EXTENSION_FUTURE];274u_int8_t misc_enable;275int8_t tempslopextension[MAX_TEMP_SLOPE];276int8_t quick_drop_low;277int8_t quick_drop_high;278} __packed OSPREY_BASE_EXTENSION_1;279280typedef struct osprey_BaseExtension_2 {281int8_t temp_slope_low;282int8_t temp_slope_high;283u_int8_t xatten1_db_low[OSPREY_MAX_CHAINS]; // 3 //xatten1_db for merlin (0xa20c/b20c 5:0)284u_int8_t xatten1_margin_low[OSPREY_MAX_CHAINS]; // 3 //xatten1_margin for merlin (0xa20c/b20c 16:12285u_int8_t xatten1_db_high[OSPREY_MAX_CHAINS]; // 3 //xatten1_db for merlin (0xa20c/b20c 5:0)286u_int8_t xatten1_margin_high[OSPREY_MAX_CHAINS]; // 3 //xatten1_margin for merlin (0xa20c/b20c 16:12287} __packed OSPREY_BASE_EXTENSION_2;288289typedef struct spurChanStruct {290u_int16_t spur_chan;291u_int8_t spurRangeLow;292u_int8_t spurRangeHigh;293} __packed SPUR_CHAN;294295//Note the order of the fields in this structure has been optimized to put all fields likely to change together296typedef struct ospreyModalEepHeader {297u_int32_t ant_ctrl_common; // 4 idle, t1, t2, b (4 bits per setting)298u_int32_t ant_ctrl_common2; // 4 ra1l1, ra2l1, ra1l2, ra2l2, ra12299u_int16_t ant_ctrl_chain[OSPREY_MAX_CHAINS]; // 6 idle, t, r, rx1, rx12, b (2 bits each)300u_int8_t xatten1_db[OSPREY_MAX_CHAINS]; // 3 //xatten1_db for merlin (0xa20c/b20c 5:0)301u_int8_t xatten1_margin[OSPREY_MAX_CHAINS]; // 3 //xatten1_margin for merlin (0xa20c/b20c 16:12302int8_t temp_slope;303int8_t voltSlope;304u_int8_t spur_chans[OSPREY_EEPROM_MODAL_SPURS]; // spur channels in usual fbin coding format305int8_t noise_floor_thresh_ch[OSPREY_MAX_CHAINS];// 3 //Check if the register is per chain306u_int8_t reserved[MAX_MODAL_RESERVED];307int8_t quick_drop;308u_int8_t xpa_bias_lvl; // 1309u_int8_t tx_frame_to_data_start; // 1310u_int8_t tx_frame_to_pa_on; // 1311u_int8_t txClip; // 4 bits tx_clip, 4 bits dac_scale_cck312int8_t antenna_gain; // 1313u_int8_t switchSettling; // 1314int8_t adcDesiredSize; // 1315u_int8_t tx_end_to_xpa_off; // 1316u_int8_t txEndToRxOn; // 1317u_int8_t tx_frame_to_xpa_on; // 1318u_int8_t thresh62; // 1319u_int32_t paprd_rate_mask_ht20;320u_int32_t paprd_rate_mask_ht40;321u_int16_t switchcomspdt;322u_int8_t xLNA_bias_strength; // bit: 0,1:chain0, 2,3:chain1, 4,5:chain2323u_int8_t rf_gain_cap;324u_int8_t tx_gain_cap; // bit0:4 txgain cap, txgain index for max_txgain + 20 (10dBm higher than max txgain)325u_int8_t futureModal[MAX_MODAL_FUTURE];326// last 12 bytes stolen and moved to newly created base extension structure327} __packed OSPREY_MODAL_EEP_HEADER; // == 100 B328329typedef struct ospCalDataPerFreqOpLoop {330int8_t ref_power; /* */331u_int8_t volt_meas; /* pdadc voltage at power measurement */332u_int8_t temp_meas; /* pcdac used for power measurement */333int8_t rx_noisefloor_cal; /*range is -60 to -127 create a mapping equation 1db resolution */334int8_t rx_noisefloor_power; /*range is same as noisefloor */335u_int8_t rxTempMeas; /*temp measured when noisefloor cal was performed */336} __packed OSP_CAL_DATA_PER_FREQ_OP_LOOP;337338typedef struct CalTargetPowerLegacy {339u_int8_t t_pow2x[4];340} __packed CAL_TARGET_POWER_LEG;341342typedef struct ospCalTargetPowerHt {343u_int8_t t_pow2x[14];344} __packed OSP_CAL_TARGET_POWER_HT;345346#if AH_BYTE_ORDER == AH_BIG_ENDIAN347typedef struct CalCtlEdgePwr {348u_int8_t flag :2,349t_power :6;350} __packed CAL_CTL_EDGE_PWR;351#elif AH_BYTE_ORDER == AH_LITTLE_ENDIAN352typedef struct CalCtlEdgePwr {353u_int8_t t_power :6,354flag :2;355} __packed CAL_CTL_EDGE_PWR;356#else357#error AH_BYTE_ORDER undefined!358#endif359360typedef struct ospCalCtlData_5G {361CAL_CTL_EDGE_PWR ctl_edges[OSPREY_NUM_BAND_EDGES_5G];362} __packed OSP_CAL_CTL_DATA_5G;363364typedef struct ospCalCtlData_2G {365CAL_CTL_EDGE_PWR ctl_edges[OSPREY_NUM_BAND_EDGES_2G];366} __packed OSP_CAL_CTL_DATA_2G;367368typedef struct ospreyEeprom {369u_int8_t eeprom_version;370u_int8_t template_version;371u_int8_t mac_addr[6];372u_int8_t custData[OSPREY_CUSTOMER_DATA_SIZE];373374OSPREY_BASE_EEP_HEADER base_eep_header;375376OSPREY_MODAL_EEP_HEADER modal_header_2g;377OSPREY_BASE_EXTENSION_1 base_ext1;378u_int8_t cal_freq_pier_2g[OSPREY_NUM_2G_CAL_PIERS];379OSP_CAL_DATA_PER_FREQ_OP_LOOP cal_pier_data_2g[OSPREY_MAX_CHAINS][OSPREY_NUM_2G_CAL_PIERS];380u_int8_t cal_target_freqbin_cck[OSPREY_NUM_2G_CCK_TARGET_POWERS];381u_int8_t cal_target_freqbin_2g[OSPREY_NUM_2G_20_TARGET_POWERS];382u_int8_t cal_target_freqbin_2g_ht20[OSPREY_NUM_2G_20_TARGET_POWERS];383u_int8_t cal_target_freqbin_2g_ht40[OSPREY_NUM_2G_40_TARGET_POWERS];384CAL_TARGET_POWER_LEG cal_target_power_cck[OSPREY_NUM_2G_CCK_TARGET_POWERS];385CAL_TARGET_POWER_LEG cal_target_power_2g[OSPREY_NUM_2G_20_TARGET_POWERS];386OSP_CAL_TARGET_POWER_HT cal_target_power_2g_ht20[OSPREY_NUM_2G_20_TARGET_POWERS];387OSP_CAL_TARGET_POWER_HT cal_target_power_2g_ht40[OSPREY_NUM_2G_40_TARGET_POWERS];388u_int8_t ctl_index_2g[OSPREY_NUM_CTLS_2G];389u_int8_t ctl_freqbin_2G[OSPREY_NUM_CTLS_2G][OSPREY_NUM_BAND_EDGES_2G];390OSP_CAL_CTL_DATA_2G ctl_power_data_2g[OSPREY_NUM_CTLS_2G];391392OSPREY_MODAL_EEP_HEADER modal_header_5g;393OSPREY_BASE_EXTENSION_2 base_ext2;394u_int8_t cal_freq_pier_5g[OSPREY_NUM_5G_CAL_PIERS];395OSP_CAL_DATA_PER_FREQ_OP_LOOP cal_pier_data_5g[OSPREY_MAX_CHAINS][OSPREY_NUM_5G_CAL_PIERS];396u_int8_t cal_target_freqbin_5g[OSPREY_NUM_5G_20_TARGET_POWERS];397u_int8_t cal_target_freqbin_5g_ht20[OSPREY_NUM_5G_20_TARGET_POWERS];398u_int8_t cal_target_freqbin_5g_ht40[OSPREY_NUM_5G_40_TARGET_POWERS];399CAL_TARGET_POWER_LEG cal_target_power_5g[OSPREY_NUM_5G_20_TARGET_POWERS];400OSP_CAL_TARGET_POWER_HT cal_target_power_5g_ht20[OSPREY_NUM_5G_20_TARGET_POWERS];401OSP_CAL_TARGET_POWER_HT cal_target_power_5g_ht40[OSPREY_NUM_5G_40_TARGET_POWERS];402u_int8_t ctl_index_5g[OSPREY_NUM_CTLS_5G];403u_int8_t ctl_freqbin_5G[OSPREY_NUM_CTLS_5G][OSPREY_NUM_BAND_EDGES_5G];404OSP_CAL_CTL_DATA_5G ctl_power_data_5g[OSPREY_NUM_CTLS_5G];405} __packed ar9300_eeprom_t;406407408/*409** SWAP Functions410** used to read EEPROM data, which is apparently stored in little411** endian form. We have included both forms of the swap functions,412** one for big endian and one for little endian. The indices of the413** array elements are the differences414*/415#if AH_BYTE_ORDER == AH_BIG_ENDIAN416417#define AR9300_EEPROM_MAGIC 0x5aa5418#define SWAP16(_x) ( (u_int16_t)( (((const u_int8_t *)(&_x))[0] ) |\419( ( (const u_int8_t *)( &_x ) )[1]<< 8) ) )420421#define SWAP32(_x) ((u_int32_t)( \422(((const u_int8_t *)(&_x))[0]) | \423(((const u_int8_t *)(&_x))[1]<< 8) | \424(((const u_int8_t *)(&_x))[2]<<16) | \425(((const u_int8_t *)(&_x))[3]<<24)))426427#else // AH_BYTE_ORDER428429#define AR9300_EEPROM_MAGIC 0xa55a430#define SWAP16(_x) ( (u_int16_t)( (((const u_int8_t *)(&_x))[1] ) |\431( ( (const u_int8_t *)( &_x ) )[0]<< 8) ) )432433#define SWAP32(_x) ((u_int32_t)( \434(((const u_int8_t *)(&_x))[3]) | \435(((const u_int8_t *)(&_x))[2]<< 8) | \436(((const u_int8_t *)(&_x))[1]<<16) | \437(((const u_int8_t *)(&_x))[0]<<24)))438439#endif // AH_BYTE_ORDER440441// OTP registers for OSPREY442443#define AR_GPIO_IN_OUT 0x4048 // GPIO input / output register444#define OTP_MEM_START_ADDRESS 0x14000445#define OTP_STATUS0_OTP_SM_BUSY 0x00015f18446#define OTP_STATUS1_EFUSE_READ_DATA 0x00015f1c447448#define OTP_LDO_CONTROL_ENABLE 0x00015f24449#define OTP_LDO_STATUS_POWER_ON 0x00015f2c450#define OTP_INTF0_EFUSE_WR_ENABLE_REG_V 0x00015f00451// OTP register for Jupiter452#define GLB_OTP_LDO_CONTROL_ENABLE 0x00020020453#define GLB_OTP_LDO_STATUS_POWER_ON 0x00020028454#define OTP_PGENB_SETUP_HOLD_TIME_DELAY 0x15f34455456// OTP register for Jupiter BT457#define BTOTP_MEM_START_ADDRESS 0x64000458#define BTOTP_STATUS0_OTP_SM_BUSY 0x00065f18459#define BTOTP_STATUS1_EFUSE_READ_DATA 0x00065f1c460#define BTOTP_INTF0_EFUSE_WR_ENABLE_REG_V 0x00065f00461#define BTOTP_INTF2 0x00065f08462#define BTOTP_PGENB_SETUP_HOLD_TIME_DELAY 0x65f34463#define BT_RESET_CTL 0x44000464#define BT_CLOCK_CONTROL 0x44028465466467// OTP register for WASP468#define OTP_MEM_START_ADDRESS_WASP 0x00030000469#define OTP_STATUS0_OTP_SM_BUSY_WASP (OTP_MEM_START_ADDRESS_WASP + 0x1018)470#define OTP_STATUS1_EFUSE_READ_DATA_WASP (OTP_MEM_START_ADDRESS_WASP + 0x101C)471#define OTP_LDO_CONTROL_ENABLE_WASP (OTP_MEM_START_ADDRESS_WASP + 0x1024)472#define OTP_LDO_STATUS_POWER_ON_WASP (OTP_MEM_START_ADDRESS_WASP + 0x102C)473#define OTP_INTF0_EFUSE_WR_ENABLE_REG_V_WASP (OTP_MEM_START_ADDRESS_WASP + 0x1000)474// Below control the access timing of OTP read/write475#define OTP_PG_STROBE_PW_REG_V_WASP (OTP_MEM_START_ADDRESS_WASP + 0x1008)476#define OTP_RD_STROBE_PW_REG_V_WASP (OTP_MEM_START_ADDRESS_WASP + 0x100C)477#define OTP_VDDQ_HOLD_TIME_DELAY_WASP (OTP_MEM_START_ADDRESS_WASP + 0x1030)478#define OTP_PGENB_SETUP_HOLD_TIME_DELAY_WASP (OTP_MEM_START_ADDRESS_WASP + 0x1034)479#define OTP_STROBE_PULSE_INTERVAL_DELAY_WASP (OTP_MEM_START_ADDRESS_WASP + 0x1038)480#define OTP_CSB_ADDR_LOAD_SETUP_HOLD_DELAY_WASP (OTP_MEM_START_ADDRESS_WASP + 0x103C)481482#define AR9300_EEPROM_MAGIC_OFFSET 0x0483/* reg_off = 4 * (eep_off) */484#define AR9300_EEPROM_S 2485#define AR9300_EEPROM_OFFSET 0x2000486#ifdef AR9100487#define AR9300_EEPROM_START_ADDR 0x1fff1000488#else489#define AR9300_EEPROM_START_ADDR 0x503f1200490#endif491#define AR9300_FLASH_CAL_START_OFFSET 0x1000492#define AR9300_EEPROM_MAX 0xae0493#define IS_EEP_MINOR_V3(_ahp) (ar9300_eeprom_get((_ahp), EEP_MINOR_REV) >= AR9300_EEP_MINOR_VER_3)494495#define ar9300_get_ntxchains(_txchainmask) \496(((_txchainmask >> 2) & 1) + ((_txchainmask >> 1) & 1) + (_txchainmask & 1))497498/* RF silent fields in \ */499#define EEP_RFSILENT_ENABLED 0x0001 /* bit 0: enabled/disabled */500#define EEP_RFSILENT_ENABLED_S 0 /* bit 0: enabled/disabled */501#define EEP_RFSILENT_POLARITY 0x0002 /* bit 1: polarity */502#define EEP_RFSILENT_POLARITY_S 1 /* bit 1: polarity */503#define EEP_RFSILENT_GPIO_SEL 0x00fc /* bits 2..7: gpio PIN */504#define EEP_RFSILENT_GPIO_SEL_S 2 /* bits 2..7: gpio PIN */505#define AR9300_EEP_VER 0xE506#define AR9300_BCHAN_UNUSED 0xFF507#define AR9300_MAX_RATE_POWER 63508509typedef enum {510CALDATA_AUTO=0,511CALDATA_EEPROM,512CALDATA_FLASH,513CALDATA_OTP514} CALDATA_TYPE;515516typedef enum {517EEP_NFTHRESH_5,518EEP_NFTHRESH_2,519EEP_MAC_MSW,520EEP_MAC_MID,521EEP_MAC_LSW,522EEP_REG_0,523EEP_REG_1,524EEP_OP_CAP,525EEP_OP_MODE,526EEP_RF_SILENT,527EEP_OB_5,528EEP_DB_5,529EEP_OB_2,530EEP_DB_2,531EEP_MINOR_REV,532EEP_TX_MASK,533EEP_RX_MASK,534EEP_FSTCLK_5G,535EEP_RXGAIN_TYPE,536EEP_OL_PWRCTRL,537EEP_TXGAIN_TYPE,538EEP_RC_CHAIN_MASK,539EEP_DAC_HPWR_5G,540EEP_FRAC_N_5G,541EEP_DEV_TYPE,542EEP_TEMPSENSE_SLOPE,543EEP_TEMPSENSE_SLOPE_PAL_ON,544EEP_PWR_TABLE_OFFSET,545EEP_DRIVE_STRENGTH,546EEP_INTERNAL_REGULATOR,547EEP_SWREG,548EEP_PAPRD_ENABLED,549EEP_ANTDIV_control,550EEP_CHAIN_MASK_REDUCE,551} EEPROM_PARAM;552553#define AR9300_RATES_OFDM_OFFSET 0554#define AR9300_RATES_CCK_OFFSET 4555#define AR9300_RATES_HT20_OFFSET 8556#define AR9300_RATES_HT40_OFFSET 22557typedef enum ar9300_Rates {558ALL_TARGET_LEGACY_6_24,559ALL_TARGET_LEGACY_36,560ALL_TARGET_LEGACY_48,561ALL_TARGET_LEGACY_54,562ALL_TARGET_LEGACY_1L_5L,563ALL_TARGET_LEGACY_5S,564ALL_TARGET_LEGACY_11L,565ALL_TARGET_LEGACY_11S,566ALL_TARGET_HT20_0_8_16,567ALL_TARGET_HT20_1_3_9_11_17_19,568ALL_TARGET_HT20_4,569ALL_TARGET_HT20_5,570ALL_TARGET_HT20_6,571ALL_TARGET_HT20_7,572ALL_TARGET_HT20_12,573ALL_TARGET_HT20_13,574ALL_TARGET_HT20_14,575ALL_TARGET_HT20_15,576ALL_TARGET_HT20_20,577ALL_TARGET_HT20_21,578ALL_TARGET_HT20_22,579ALL_TARGET_HT20_23,580ALL_TARGET_HT40_0_8_16,581ALL_TARGET_HT40_1_3_9_11_17_19,582ALL_TARGET_HT40_4,583ALL_TARGET_HT40_5,584ALL_TARGET_HT40_6,585ALL_TARGET_HT40_7,586ALL_TARGET_HT40_12,587ALL_TARGET_HT40_13,588ALL_TARGET_HT40_14,589ALL_TARGET_HT40_15,590ALL_TARGET_HT40_20,591ALL_TARGET_HT40_21,592ALL_TARGET_HT40_22,593ALL_TARGET_HT40_23,594ar9300_rate_size595} AR9300_RATES;596597598/**************************************************************************599* fbin2freq600*601* Get channel value from binary representation held in eeprom602* RETURNS: the frequency in MHz603*/604static inline u_int16_t605fbin2freq(u_int8_t fbin, HAL_BOOL is_2ghz)606{607/*608* Reserved value 0xFF provides an empty definition both as609* an fbin and as a frequency - do not convert610*/611if (fbin == AR9300_BCHAN_UNUSED)612{613return fbin;614}615616return (u_int16_t)((is_2ghz) ? (2300 + fbin) : (4800 + 5 * fbin));617}618619extern int CompressionHeaderUnpack(u_int8_t *best, int *code, int *reference, int *length, int *major, int *minor);620extern void Ar9300EepromFormatConvert(ar9300_eeprom_t *mptr);621extern HAL_BOOL ar9300_eeprom_restore(struct ath_hal *ah);622extern int ar9300_eeprom_restore_internal(struct ath_hal *ah, ar9300_eeprom_t *mptr, int /*msize*/);623extern int ar9300_eeprom_base_address(struct ath_hal *ah);624extern int ar9300_eeprom_volatile(struct ath_hal *ah);625extern int ar9300_eeprom_low_limit(struct ath_hal *ah);626extern u_int16_t ar9300_compression_checksum(u_int8_t *data, int dsize);627extern int ar9300_compression_header_unpack(u_int8_t *best, int *code, int *reference, int *length, int *major, int *minor);628629extern u_int16_t ar9300_eeprom_struct_size(void);630extern ar9300_eeprom_t *ar9300EepromStructInit(int default_index);631extern ar9300_eeprom_t *ar9300EepromStructGet(void);632extern ar9300_eeprom_t *ar9300_eeprom_struct_default(int default_index);633extern ar9300_eeprom_t *ar9300_eeprom_struct_default_find_by_id(int ver);634extern int ar9300_eeprom_struct_default_many(void);635extern int ar9300EepromUpdateCalPier(int pierIdx, int freq, int chain,636int pwrCorrection, int volt_meas, int temp_meas);637extern int ar9300_power_control_override(struct ath_hal *ah, int frequency, int *correction, int *voltage, int *temperature);638639extern void ar9300EepromDisplayCalData(int for2GHz);640extern void ar9300EepromDisplayAll(void);641extern void ar9300_set_target_power_from_eeprom(struct ath_hal *ah, u_int16_t freq,642u_int8_t *target_power_val_t2);643extern HAL_BOOL ar9300_eeprom_set_power_per_rate_table(struct ath_hal *ah,644ar9300_eeprom_t *p_eep_data,645const struct ieee80211_channel *chan,646u_int8_t *p_pwr_array,647u_int16_t cfg_ctl,648u_int16_t antenna_reduction,649u_int16_t twice_max_regulatory_power,650u_int16_t power_limit,651u_int8_t chainmask);652extern int ar9300_transmit_power_reg_write(struct ath_hal *ah, u_int8_t *p_pwr_array);653654extern u_int8_t ar9300_eeprom_get_legacy_trgt_pwr(struct ath_hal *ah, u_int16_t rate_index, u_int16_t freq, HAL_BOOL is_2ghz);655extern u_int8_t ar9300_eeprom_get_ht20_trgt_pwr(struct ath_hal *ah, u_int16_t rate_index, u_int16_t freq, HAL_BOOL is_2ghz);656extern u_int8_t ar9300_eeprom_get_ht40_trgt_pwr(struct ath_hal *ah, u_int16_t rate_index, u_int16_t freq, HAL_BOOL is_2ghz);657extern u_int8_t ar9300_eeprom_get_cck_trgt_pwr(struct ath_hal *ah, u_int16_t rate_index, u_int16_t freq);658extern HAL_BOOL ar9300_internal_regulator_apply(struct ath_hal *ah);659extern HAL_BOOL ar9300_drive_strength_apply(struct ath_hal *ah);660extern HAL_BOOL ar9300_attenuation_apply(struct ath_hal *ah, u_int16_t channel);661extern int32_t ar9300_thermometer_get(struct ath_hal *ah);662extern HAL_BOOL ar9300_thermometer_apply(struct ath_hal *ah);663extern HAL_BOOL ar9300_xpa_timing_control_apply(struct ath_hal *ah, HAL_BOOL is_2ghz);664extern HAL_BOOL ar9300_x_lNA_bias_strength_apply(struct ath_hal *ah, HAL_BOOL is_2ghz);665666extern int32_t ar9300MacAdressGet(u_int8_t *mac);667extern int32_t ar9300CustomerDataGet(u_int8_t *data, int32_t len);668extern int32_t ar9300ReconfigDriveStrengthGet(void);669extern int32_t ar9300EnableTempCompensationGet(void);670extern int32_t ar9300EnableVoltCompensationGet(void);671extern int32_t ar9300FastClockEnableGet(void);672extern int32_t ar9300EnableDoublingGet(void);673674extern u_int16_t *ar9300_regulatory_domain_get(struct ath_hal *ah);675extern int32_t ar9300_eeprom_write_enable_gpio_get(struct ath_hal *ah);676extern int32_t ar9300_wlan_led_gpio_get(struct ath_hal *ah);677extern int32_t ar9300_wlan_disable_gpio_get(struct ath_hal *ah);678extern int32_t ar9300_rx_band_select_gpio_get(struct ath_hal *ah);679extern int32_t ar9300_rx_gain_index_get(struct ath_hal *ah);680extern int32_t ar9300_tx_gain_index_get(struct ath_hal *ah);681extern int32_t ar9300_xpa_bias_level_get(struct ath_hal *ah, HAL_BOOL is_2ghz);682extern HAL_BOOL ar9300_xpa_bias_level_apply(struct ath_hal *ah, HAL_BOOL is_2ghz);683extern u_int32_t ar9300_ant_ctrl_common_get(struct ath_hal *ah, HAL_BOOL is_2ghz);684extern u_int32_t ar9300_ant_ctrl_common2_get(struct ath_hal *ah, HAL_BOOL is_2ghz);685extern u_int16_t ar9300_ant_ctrl_chain_get(struct ath_hal *ah, int chain, HAL_BOOL is_2ghz);686extern HAL_BOOL ar9300_ant_ctrl_apply(struct ath_hal *ah, HAL_BOOL is_2ghz);687/* since valid noise floor values are negative, returns 1 on error */688extern int32_t ar9300_noise_floor_cal_or_power_get(689struct ath_hal *ah, int32_t frequency, int32_t ichain, HAL_BOOL use_cal);690#define ar9300NoiseFloorGet(ah, frequency, ichain) \691ar9300_noise_floor_cal_or_power_get(ah, frequency, ichain, 1/*use_cal*/)692#define ar9300NoiseFloorPowerGet(ah, frequency, ichain) \693ar9300_noise_floor_cal_or_power_get(ah, frequency, ichain, 0/*use_cal*/)694extern void ar9300_eeprom_template_preference(int32_t value);695extern int32_t ar9300_eeprom_template_install(struct ath_hal *ah, int32_t value);696extern void ar9300_calibration_data_set(struct ath_hal *ah, int32_t source);697extern int32_t ar9300_calibration_data_get(struct ath_hal *ah);698extern int32_t ar9300_calibration_data_address_get(struct ath_hal *ah);699extern void ar9300_calibration_data_address_set(struct ath_hal *ah, int32_t source);700extern HAL_BOOL ar9300_calibration_data_read_flash(struct ath_hal *ah, long address, u_int8_t *buffer, int many);701extern HAL_BOOL ar9300_calibration_data_read_eeprom(struct ath_hal *ah, long address, u_int8_t *buffer, int many);702extern HAL_BOOL ar9300_calibration_data_read_otp(struct ath_hal *ah, long address, u_int8_t *buffer, int many, HAL_BOOL is_wifi);703extern HAL_BOOL ar9300_calibration_data_read(struct ath_hal *ah, long address, u_int8_t *buffer, int many);704extern int32_t ar9300_eeprom_size(struct ath_hal *ah);705extern int32_t ar9300_otp_size(struct ath_hal *ah);706extern HAL_BOOL ar9300_calibration_data_read_array(struct ath_hal *ah, int address, u_int8_t *buffer, int many);707708709710#if defined(WIN32) || defined(WIN64)711#pragma pack (pop, ar9300)712#endif713714#endif /* _ATH_AR9300_EEP_H_ */715716717