⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ar5416_eeprom.c

📁 Atheros wifi driver source code
💻 C
📖 第 1 页 / 共 5 页
字号:
/* * Copyright (c) 2002-2005 Atheros Communications, Inc. * All rights reserved. * * $Id: ar5416_eeprom.c,v 1.1.1.1 2006/09/12 03:45:25 steven Exp $ */#include "opt_ah.h"#ifdef AH_SUPPORT_AR5416#include "ah.h"#include "ah_internal.h"#include "ah_devid.h"#include "ar5212/ar5416phy.h"#include "ar5212/ar5416reg.h"#include "ar5212/ar5416.h"/* * Temporary cap on maximum power used in rate => power table * as workaround for board issues. */#define TEMP_POWER_CAP      1#define IS_5416_EMU_EEP(_ah)  ((AH_PRIVATE(_ah)->ah_devid == AR5416_DEVID_EMU_PCI) ||  (AH_PRIVATE(_ah)->ah_devid == AR5416_DEVID_EMU_PCIE))/* reg_off = 4 * (eep_off) */#define AR5416_EEPROM_S			2#define AR5416_EEPROM_OFFSET		0x2000#define AR5416_EEPROM_START_ADDR	0x503f1200#define AR5416_EEPROM_MAX		0xae0 /* Ignore for the moment used only on the flash implementations */#define owl_get_eep_ver(_ahp)   \    (((_ahp)->baseEepHeader.version >> 12) & 0xF)#define owl_get_eep_rev(_eep)   \    (((_eep)->baseEepHeader.version) & 0xFFF)#define owl_get_ntxchains(_txchainmask) \    (((_txchainmask >> 2) & 1) + ((_txchainmask >> 1) & 1) + (_txchainmask & 1))#define ah_5416eeprom			ah_eeprom.ee_u.eepromData5416#ifdef __LINUX_ARM_ARCH__ /* AP71 */#define owl_eep_start_loc		0#define owl_eeprom_map(_ah)		ar5416FlashMap(_ah)#define owl_eeprom_read			ar5416FlashRead#define owl_eeprom_write		ar5416FlashWrite#else#define owl_eep_start_loc		256#define owl_eeprom_map(_ah)#define owl_eeprom_read			ar5416EepromRead#define owl_eeprom_write		ar5416EepromWrite#endif//#define EEPROM_DUMP/* End temp defines */#define AR5416_OPFLAGS_11A           	1#define AR5416_OPFLAGS_11G           	2/* RF silent fields in EEPROM */#define EEP_RFSILENT_ENABLED        	1#define EEP_RFSILENT_POLARITY       	0x0002#define EEP_RFSILENT_POLARITY_S     	1#define EEP_RFSILENT_GPIO_SEL       	0x001c#define EEP_RFSILENT_GPIO_SEL_S     	2#define AR5416_EEP_NO_BACK_VER       	0x1#define AR5416_EEP_VER               	0xE// 16-bit offset location start of calibration struct#define AR5416_EEP_START_LOC         	256#define AR5416_NUM_5G_CAL_PIERS      	8#define AR5416_NUM_2G_CAL_PIERS      	4#define AR5416_NUM_5G_20_TARGET_POWERS  4#define AR5416_NUM_5G_40_TARGET_POWERS  4#define AR5416_NUM_2G_CCK_TARGET_POWERS 3#define AR5416_NUM_2G_20_TARGET_POWERS  4#define AR5416_NUM_2G_40_TARGET_POWERS  4#define AR5416_NUM_CTLS              	16#define AR5416_NUM_BAND_EDGES        	8#define AR5416_NUM_PD_GAINS          	3#define AR5416_PD_GAINS_IN_MASK      	4#define AR5416_PD_GAIN_ICEPTS        	5#define AR5416_EEPROM_MODAL_SPURS    	5#define AR5416_MAX_RATE_POWER        	63#define AR5416_NUM_PDADC_VALUES      	128#define AR5416_NUM_RATES             	16#define AR5416_BCHAN_UNUSED          	0xFF#define AR5416_MAX_PWR_RANGE_IN_HALF_DB 64#define AR5416_EEPMISC_BIG_ENDIAN    	0x01#define FREQ2FBIN(x,y) 			((y) ? ((x) - 2300) : (((x) - 4800) / 5))#define AR5416_MAX_CHAINS            	3#define AR5416_ANT_16S               	25#define AR5416_NUM_ANT_CHAIN_FIELDS     7#define AR5416_NUM_ANT_COMMON_FIELDS    4#define AR5416_SIZE_ANT_CHAIN_FIELD     3#define AR5416_SIZE_ANT_COMMON_FIELD    4#define AR5416_ANT_CHAIN_MASK           0x7#define AR5416_ANT_COMMON_MASK          0xf#define AR5416_CHAIN_0_IDX              0#define AR5416_CHAIN_1_IDX              1#define AR5416_CHAIN_2_IDX              2typedef enum {    EEP_NFTHRESH_5,    EEP_NFTHRESH_2,    EEP_MAC_MSW,    EEP_MAC_MID,    EEP_MAC_LSW,    EEP_REG_0,    EEP_REG_1,    EEP_OP_CAP,    EEP_OP_MODE,    EEP_RF_SILENT,} EEPROM_PARAM;typedef enum Ar5416_Rates {    rate6mb,  rate9mb,  rate12mb, rate18mb,    rate24mb, rate36mb, rate48mb, rate54mb,    rate1l,   rate2l,   rate2s,   rate5_5l,    rate5_5s, rate11l,  rate11s,  rateXr,    rateHt20_0, rateHt20_1, rateHt20_2, rateHt20_3,    rateHt20_4, rateHt20_5, rateHt20_6, rateHt20_7,    rateHt40_0, rateHt40_1, rateHt40_2, rateHt40_3,    rateHt40_4, rateHt40_5, rateHt40_6, rateHt40_7,    rateDupCck, rateDupOfdm, rateExtCck, rateExtOfdm,    Ar5416RateSize} AR5416_RATES;typedef struct BaseEepHeader {    u_int16_t  length;    u_int16_t  checksum;    u_int16_t  version;    u_int8_t   opCapFlags;    u_int8_t   eepMisc;    u_int16_t  regDmn[2];    u_int8_t   macAddr[6];    u_int8_t   rxMask;    u_int8_t   txMask;    u_int16_t  rfSilent;    u_int16_t  blueToothOptions;    u_int16_t  deviceCap;    u_int8_t   futureBase[38];} __packed BASE_EEP_HEADER; // 64 Btypedef struct spurChanStruct {    u_int16_t spurChan;    u_int8_t  spurRangeLow;    u_int8_t  spurRangeHigh;} __packed SPUR_CHAN;typedef struct ModalEepHeader {    u_int32_t  antCtrlChain[AR5416_MAX_CHAINS];       // 12    u_int32_t  antCtrlCommon;                         // 4    u_int8_t   antennaGainCh[AR5416_MAX_CHAINS];      // 3    u_int8_t   switchSettling;                        // 1    u_int8_t   txRxAttenCh[AR5416_MAX_CHAINS];        // 3    u_int8_t   rxTxMarginCh[AR5416_MAX_CHAINS];       // 3    u_int8_t   adcDesiredSize;                        // 1    u_int8_t   pgaDesiredSize;                        // 1    u_int8_t   xlnaGainCh[AR5416_MAX_CHAINS];         // 3    u_int8_t   txEndToXpaOff;                         // 1    u_int8_t   txEndToRxOn;                           // 1    u_int8_t   txFrameToXpaOn;                        // 1    u_int8_t   thresh62;                              // 1    u_int8_t   noiseFloorThreshCh[AR5416_MAX_CHAINS]; // 3    u_int8_t   xpdGain;                               // 1    u_int8_t   xpd;                                   // 1    u_int8_t   iqCalICh[AR5416_MAX_CHAINS];           // 1    u_int8_t   iqCalQCh[AR5416_MAX_CHAINS];           // 1    u_int8_t   pdGainOverlap;                         // 1    u_int8_t   ob;                                    // 1    u_int8_t   db;                                    // 1    u_int8_t   xpaBiasLvl;                            // 1    u_int8_t   pwrDecreaseFor2Chain;                  // 1    u_int8_t   pwrDecreaseFor3Chain;                  // 1 -> 48 B    u_int8_t   futureModal[32];                       // 32 B    SPUR_CHAN spurChans[AR5416_EEPROM_MODAL_SPURS];  // 20 B} __packed MODAL_EEP_HEADER;                    // == 100 Btypedef struct calDataPerFreq {    u_int8_t pwrPdg[AR5416_NUM_PD_GAINS+1][AR5416_PD_GAIN_ICEPTS];    u_int8_t vpdPdg[AR5416_NUM_PD_GAINS+1][AR5416_PD_GAIN_ICEPTS];} __packed CAL_DATA_PER_FREQ;typedef struct CalTargetPowerLegacy {    u_int8_t  bChannel;    u_int8_t  tPow2x[4];} __packed CAL_TARGET_POWER_LEG;typedef struct CalTargetPowerHt {    u_int8_t  bChannel;    u_int8_t  tPow2x[8];} __packed CAL_TARGET_POWER_HT;#ifdef BIG_ENDIANtypedef struct CalCtlEdges {    u_int8_t  bChannel;    u_int8_t  flag   :2,             tPower :6;} __packed CAL_CTL_EDGES;#elsetypedef struct CalCtlEdges {    u_int8_t  bChannel;    u_int8_t  tPower :6,             flag   :2;} __packed CAL_CTL_EDGES;#endiftypedef struct CalCtlData {    CAL_CTL_EDGES  ctlEdges[AR5416_MAX_CHAINS][AR5416_NUM_BAND_EDGES];} __packed CAL_CTL_DATA;typedef struct eepMap {    BASE_EEP_HEADER      baseEepHeader;         // 64 B    u_int8_t             custData[64];          // 64 B    MODAL_EEP_HEADER     modalHeader[2];        // 200 B    u_int8_t             calFreqPier5G[AR5416_NUM_5G_CAL_PIERS];    u_int8_t             calFreqPier2G[AR5416_NUM_2G_CAL_PIERS];    CAL_DATA_PER_FREQ    calPierData5G[AR5416_MAX_CHAINS][AR5416_NUM_5G_CAL_PIERS];    CAL_DATA_PER_FREQ    calPierData2G[AR5416_MAX_CHAINS][AR5416_NUM_2G_CAL_PIERS];    CAL_TARGET_POWER_LEG calTargetPower5G[AR5416_NUM_5G_20_TARGET_POWERS];    CAL_TARGET_POWER_HT  calTargetPower5GHT20[AR5416_NUM_5G_20_TARGET_POWERS];    CAL_TARGET_POWER_HT  calTargetPower5GHT40[AR5416_NUM_5G_40_TARGET_POWERS];    CAL_TARGET_POWER_LEG calTargetPowerCck[AR5416_NUM_2G_CCK_TARGET_POWERS];    CAL_TARGET_POWER_LEG calTargetPower2G[AR5416_NUM_2G_20_TARGET_POWERS];    CAL_TARGET_POWER_HT  calTargetPower2GHT20[AR5416_NUM_2G_20_TARGET_POWERS];    CAL_TARGET_POWER_HT  calTargetPower2GHT40[AR5416_NUM_2G_40_TARGET_POWERS];    u_int8_t             ctlIndex[AR5416_NUM_CTLS];    CAL_CTL_DATA         ctlData[AR5416_NUM_CTLS];} __packed ar5416_eeprom_t;/* Fake Owl Eeprom Yeech...*/#define OWLEMU_EEPROM_SZ        1024static u_int16_t owlemu_eeprom[OWLEMU_EEPROM_SZ] = {0x0013, 0x168c, 0x0200, 0x0001, 0x0000, 0x5001, 0x0000, 0x1042,0x168c, 0x1c0a, 0x0100, 0x0000, 0x01c2, 0x0002, 0xc606, 0x0001,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x43b5, 0x7f03, 0x0003,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5aa5, 0x0000, 0x0000,0x0313, 0x4943, 0x2053, 0x7104, 0x1202, 0x0400, 0x0306, 0x0001,0x0000, 0x0500, 0x410e, 0x39b1, 0x1eb5, 0x4e2d, 0x3056, 0xffff,0xe902, 0x0700, 0x0106, 0x0000, 0x0100, 0x1500, 0x0752, 0x4101,0x6874, 0x7265, 0x736f, 0x4320, 0x6d6f, 0x756d, 0x696e, 0x6163,0x6974, 0x6e6f, 0x2c73, 0x4920, 0x636e, 0x002e, 0x5241, 0x3035,0x3130, 0x302d, 0x3030, 0x2d30, 0x3030, 0x3030, 0x5700, 0x7269,0x6c65, 0x7365, 0x2073, 0x414c, 0x204e, 0x6552, 0x6566, 0x6572,0x636e, 0x2065, 0x6143, 0x6472, 0x3000, 0x0030, 0x00ff, 0x2100,0x0602, 0x2201, 0x0205, 0x8d80, 0x005b, 0x0522, 0x4002, 0x8954,0x2200, 0x0205, 0x1b00, 0x00b7, 0x0522, 0x8002, 0x12a8, 0x2201,0x0205, 0x3600, 0x016e, 0x0522, 0x0002, 0x2551, 0x2202, 0x0205,0x6c00, 0x02dc, 0x0522, 0x8002, 0x37f9, 0x2203, 0x0205, 0xa200,0x044a, 0x0222, 0x0803, 0x0822, 0x0604, 0x0300, 0x037f, 0xb543,0x0222, 0x0105, 0x00ff, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x4243, 0x3234, 0x3035, 0x5f4c, 0x3930, 0x3934, 0x3061, 0xffff,0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xf000, 0x2094, 0x0000,0xe839, 0x4008, 0x0a07, 0x0000, 0x420a, 0x41a0, 0x0101, 0x3002,0x0003, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x2d3c, 0x0081, 0x0000, 0x0108,0x0000, 0xe049, 0x2492, 0x020f, 0x000e, 0xb0ca, 0x21a3, 0x4024,0x08f9, 0x000b, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x2398, 0x0091, 0x0410, 0x4148, 0x2082, 0xda22,0x021c, 0x0007, 0xb0ff, 0x01a3, 0x4012, 0x0001, 0xa270, 0x17b8,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3198, 0x0091, 0x0410,0x4148, 0x2082, 0xe022, 0x021c, 0x000e, 0xb0ff, 0x21a3, 0x4012,0x7851, 0xa270, 0x1320, 0x17b8, 0x0080, 0x0003, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x1013, 0x1112, 0x1440, 0x3031, 0x3234, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x3214, 0x5c4a, 0x7868, 0xb9a0, 0x00cd, 0x3619, 0x5543, 0x1d55,0x0000, 0x1900, 0x381e, 0x5346, 0x1534, 0x0000, 0x1900, 0x3e1f,0x5252, 0x0935, 0x0000, 0x1900, 0x3e23, 0x5252, 0x0534, 0x0000,0x1900, 0x3e25, 0x5252, 0x0533, 0x0000, 0x1900, 0x3e25, 0x5252,0x0532, 0x0000, 0x1900, 0x412b, 0x5353, 0x0510, 0x0000, 0x1900,0x4430, 0x5750, 0x08ef, 0x0000, 0x1900, 0x4334, 0x574b, 0x10cc,0x0000, 0x1900, 0x4a2f, 0x5858, 0x00f4, 0x0000, 0x1900, 0x4c30,0x5858, 0x00f4, 0x0000, 0x1900, 0x4429, 0x5854, 0x0933, 0x0000,0x1900, 0x4a2d, 0x5c56, 0x0534, 0x0000, 0x1900, 0x482d, 0x5c57,0x0534, 0x0000, 0x1900, 0x4a2d, 0x5c58, 0x0535, 0x0000, 0x1900,0x4c91, 0xe71a, 0x5089, 0xe71a, 0x6889, 0xe71a, 0x8c89, 0xe71a,0xb489, 0xe71a, 0xbd89, 0xe71a, 0xcd89, 0xe71a, 0xd289, 0xe71a,0x70a2, 0x8a28, 0xb8a2, 0x8a28, 0x709a, 0x481e, 0x939a, 0x481e,0xac9a, 0x481e, 0x4c58, 0x5c68, 0xbdc1, 0xcd00, 0x2222, 0x2423,0x2464, 0x2400, 0x5052, 0x5a60, 0x62c0, 0xc1c9, 0x2262, 0x2224,0x2423, 0x6323, 0x7075, 0xa200, 0x0000, 0x0000, 0x2868, 0x2800,0x0000, 0x0000, 0x7075, 0x9da2, 0x0000, 0x0000, 0x2166, 0x6621,0x0000, 0x0000, 0x8989, 0x0000, 0x0000, 0x0000, 0x2626, 0x0000,0x0000, 0x0000, 0x4a56, 0x0000, 0x0000, 0x0000, 0x3c3c, 0x0000,0x0000, 0x0000, 0x4c68, 0x8cb4, 0xbdc1, 0xcd00, 0x2424, 0x2424,0x3c7c, 0x3c00, 0x7075, 0xac00, 0x0000, 0x0000, 0x2464, 0x2300,0x0000, 0x0000, 0x7075, 0xac00, 0x0000, 0x0000, 0x2262, 0x2100,0x0000, 0x0000, 0x8989, 0x0000, 0x0000, 0x0000, 0x2222, 0x0000,0x0000, 0x0000, 0xea0e, 0xc000, 0x0e07, 0x8042, 0xa204, 0x0002,0x0e03, 0x8186, 0x9858, 0x0000, 0x0e01, 0x800c, 0x9824, 0x0707,0x0e02, 0x8063, 0x9860, 0x0003, 0x03ff, 0xa210, 0x0080, 0x6333,0x03ff, 0xa214, 0x0010, 0x6c10, 0x03ff, 0xa21c, 0x1883, 0x800a,0x03ff, 0xa220, 0x0188, 0x30c6, 0x05ff, 0xc0fd, 0x1001, 0xc8f5,0x707f, 0xc8fc, 0x1000, 0xc85a, 0x2001, 0xc85c, 0x2002, 0xc85e,0x2001, 0xc8fe, 0x1001, 0xc519, 0x1001, 0xcc01, 0x2001, 0xcc03,0x2001, 0xcc8b, 0x1001, 0xcc8c, 0x1001, 0xdc92, 0x1001, 0x0fff,0x8081, 0x1230, 0x0001, 0x0fff, 0x8010, 0x982c, 0xa002, 0x09ff,0x8063, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -