15449c685a4b39534f18869a93896370224463715Forest Bond/* 25449c685a4b39534f18869a93896370224463715Forest Bond * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. 35449c685a4b39534f18869a93896370224463715Forest Bond * All rights reserved. 45449c685a4b39534f18869a93896370224463715Forest Bond * 55449c685a4b39534f18869a93896370224463715Forest Bond * This program is free software; you can redistribute it and/or modify 65449c685a4b39534f18869a93896370224463715Forest Bond * it under the terms of the GNU General Public License as published by 75449c685a4b39534f18869a93896370224463715Forest Bond * the Free Software Foundation; either version 2 of the License, or 85449c685a4b39534f18869a93896370224463715Forest Bond * (at your option) any later version. 95449c685a4b39534f18869a93896370224463715Forest Bond * 105449c685a4b39534f18869a93896370224463715Forest Bond * This program is distributed in the hope that it will be useful, 115449c685a4b39534f18869a93896370224463715Forest Bond * but WITHOUT ANY WARRANTY; without even the implied warranty of 125449c685a4b39534f18869a93896370224463715Forest Bond * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 135449c685a4b39534f18869a93896370224463715Forest Bond * GNU General Public License for more details. 145449c685a4b39534f18869a93896370224463715Forest Bond * 155449c685a4b39534f18869a93896370224463715Forest Bond * You should have received a copy of the GNU General Public License along 165449c685a4b39534f18869a93896370224463715Forest Bond * with this program; if not, write to the Free Software Foundation, Inc., 175449c685a4b39534f18869a93896370224463715Forest Bond * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 185449c685a4b39534f18869a93896370224463715Forest Bond * 195449c685a4b39534f18869a93896370224463715Forest Bond * 205449c685a4b39534f18869a93896370224463715Forest Bond * File: srom.h 215449c685a4b39534f18869a93896370224463715Forest Bond * 225449c685a4b39534f18869a93896370224463715Forest Bond * Purpose: Implement functions to access eeprom 235449c685a4b39534f18869a93896370224463715Forest Bond * 245449c685a4b39534f18869a93896370224463715Forest Bond * Author: Jerry Chen 255449c685a4b39534f18869a93896370224463715Forest Bond * 265449c685a4b39534f18869a93896370224463715Forest Bond * Date: Jan 29, 2003 275449c685a4b39534f18869a93896370224463715Forest Bond * 285449c685a4b39534f18869a93896370224463715Forest Bond */ 295449c685a4b39534f18869a93896370224463715Forest Bond 305449c685a4b39534f18869a93896370224463715Forest Bond#ifndef __SROM_H__ 315449c685a4b39534f18869a93896370224463715Forest Bond#define __SROM_H__ 325449c685a4b39534f18869a93896370224463715Forest Bond 335449c685a4b39534f18869a93896370224463715Forest Bond#include "ttype.h" 345449c685a4b39534f18869a93896370224463715Forest Bond 35612822f5dd1638de442cf50eb9da54632fba0e66Jim Lieb/*--------------------- Export Definitions -------------------------*/ 36612822f5dd1638de442cf50eb9da54632fba0e66Jim Lieb 375449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_MAX_CONTEXT_SIZE 256 385449c685a4b39534f18869a93896370224463715Forest Bond 395449c685a4b39534f18869a93896370224463715Forest Bond#define CB_EEPROM_READBYTE_WAIT 900 //us 405449c685a4b39534f18869a93896370224463715Forest Bond 415449c685a4b39534f18869a93896370224463715Forest Bond#define W_MAX_I2CRETRY 0x0fff 425449c685a4b39534f18869a93896370224463715Forest Bond 435449c685a4b39534f18869a93896370224463715Forest Bond// 445449c685a4b39534f18869a93896370224463715Forest Bond// Contents in the EEPROM 455449c685a4b39534f18869a93896370224463715Forest Bond// 465449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_PAR 0x00 // physical address 475449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_ANTENNA 0x16 485449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_RADIOCTL 0x17 495449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_RFTYPE 0x1B // for select RF 505449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_MINCHANNEL 0x1C // Min Channel # 515449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_MAXCHANNEL 0x1D // Max Channel # 525449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_SIGNATURE 0x1E // 535449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_ZONETYPE 0x1F // 545449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_RFTABLE 0x20 // RF POWER TABLE 555449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_PWR_CCK 0x20 565449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_SETPT_CCK 0x21 575449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_PWR_OFDMG 0x23 585449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_SETPT_OFDMG 0x24 595449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_PWR_FORMULA_OST 0x26 // 605449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_MAJOR_VER 0x2E 615449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_MINOR_VER 0x2F 625449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_CCK_PWR_TBL 0x30 635449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_CCK_PWR_dBm 0x3F 645449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_OFDM_PWR_TBL 0x40 655449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_OFDM_PWR_dBm 0x4F 665449c685a4b39534f18869a93896370224463715Forest Bond//{{ RobertYu: 20041124 675449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_SETPT_OFDMA 0x4E 685449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_OFDMA_PWR_TBL 0x50 695449c685a4b39534f18869a93896370224463715Forest Bond//}} 705449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_OFDMA_PWR_dBm 0xD2 715449c685a4b39534f18869a93896370224463715Forest Bond 725449c685a4b39534f18869a93896370224463715Forest Bond//----------need to remove -------------------- 735449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_BBTAB_LEN 0x70 // BB Table Length 745449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_BBTAB_ADR 0x71 // BB Table Offset 755449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_OFS_CHECKSUM 0xFF // reserved area for baseband 28h ~ 78h 765449c685a4b39534f18869a93896370224463715Forest Bond 775449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_I2C_DEV_ID 0x50 // EEPROM device address on the I2C bus 785449c685a4b39534f18869a93896370224463715Forest Bond 795449c685a4b39534f18869a93896370224463715Forest Bond// 805449c685a4b39534f18869a93896370224463715Forest Bond// Bits in EEP_OFS_ANTENNA 815449c685a4b39534f18869a93896370224463715Forest Bond// 825449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_ANTENNA_MAIN 0x01 835449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_ANTENNA_AUX 0x02 845449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_ANTINV 0x04 855449c685a4b39534f18869a93896370224463715Forest Bond 865449c685a4b39534f18869a93896370224463715Forest Bond// 875449c685a4b39534f18869a93896370224463715Forest Bond// Bits in EEP_OFS_RADIOCTL 885449c685a4b39534f18869a93896370224463715Forest Bond// 895449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_RADIOCTL_ENABLE 0x80 905449c685a4b39534f18869a93896370224463715Forest Bond#define EEP_RADIOCTL_INV 0x01 915449c685a4b39534f18869a93896370224463715Forest Bond 925449c685a4b39534f18869a93896370224463715Forest Bond/*--------------------- Export Types ------------------------------*/ 935449c685a4b39534f18869a93896370224463715Forest Bond 945449c685a4b39534f18869a93896370224463715Forest Bond// AT24C02 eeprom contents 955449c685a4b39534f18869a93896370224463715Forest Bond// 2048 bits = 256 bytes = 128 words 965449c685a4b39534f18869a93896370224463715Forest Bond// 975449c685a4b39534f18869a93896370224463715Forest Bondtypedef struct tagSSromReg { 980c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char abyPAR[6]; // 0x00 (unsigned short) 990c979148d2967848713117961a87bfa4b24e8b08Joe Perches 1000c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned short wSUB_VID; // 0x03 (unsigned short) 1010c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned short wSUB_SID; 1020c979148d2967848713117961a87bfa4b24e8b08Joe Perches 1030c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byBCFG0; // 0x05 (unsigned short) 1040c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byBCFG1; 1050c979148d2967848713117961a87bfa4b24e8b08Joe Perches 1060c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byFCR0; // 0x06 (unsigned short) 1070c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byFCR1; 1080c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byPMC0; // 0x07 (unsigned short) 1090c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byPMC1; 1100c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byMAXLAT; // 0x08 (unsigned short) 1110c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byMINGNT; 1120c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byCFG0; // 0x09 (unsigned short) 1130c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byCFG1; 1140c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned short wCISPTR; // 0x0A (unsigned short) 1150c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned short wRsv0; // 0x0B (unsigned short) 1160c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned short wRsv1; // 0x0C (unsigned short) 1170c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byBBPAIR; // 0x0D (unsigned short) 1180c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byRFTYPE; 1190c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byMinChannel; // 0x0E (unsigned short) 1200c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byMaxChannel; 1210c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char bySignature; // 0x0F (unsigned short) 1220c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char byCheckSum; 1230c979148d2967848713117961a87bfa4b24e8b08Joe Perches 1240c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char abyReserved0[96]; // 0x10 (unsigned short) 1250c979148d2967848713117961a87bfa4b24e8b08Joe Perches unsigned char abyCIS[128]; // 0x80 (unsigned short) 126a884847a1a30be9a55d975f1e3fe8cf5f922bb79Jim Lieb} SSromReg, *PSSromReg; 1275449c685a4b39534f18869a93896370224463715Forest Bond 1285449c685a4b39534f18869a93896370224463715Forest Bond/*--------------------- Export Macros ------------------------------*/ 1295449c685a4b39534f18869a93896370224463715Forest Bond 1305449c685a4b39534f18869a93896370224463715Forest Bond/*--------------------- Export Classes ----------------------------*/ 1315449c685a4b39534f18869a93896370224463715Forest Bond 1325449c685a4b39534f18869a93896370224463715Forest Bond/*--------------------- Export Variables --------------------------*/ 1335449c685a4b39534f18869a93896370224463715Forest Bond 1345449c685a4b39534f18869a93896370224463715Forest Bond/*--------------------- Export Functions --------------------------*/ 1355449c685a4b39534f18869a93896370224463715Forest Bond 1361683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementunsigned char SROMbyReadEmbedded(void __iomem *dwIoBase, unsigned char byContntOffset); 1371683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementbool SROMbWriteEmbedded(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byData); 1385449c685a4b39534f18869a93896370224463715Forest Bond 1391683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementvoid SROMvRegBitsOn(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byBits); 1401683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementvoid SROMvRegBitsOff(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byBits); 1415449c685a4b39534f18869a93896370224463715Forest Bond 1421683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementbool SROMbIsRegBitsOn(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byTestBits); 1431683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementbool SROMbIsRegBitsOff(void __iomem *dwIoBase, unsigned char byContntOffset, unsigned char byTestBits); 1445449c685a4b39534f18869a93896370224463715Forest Bond 1451683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementvoid SROMvReadAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs); 1461683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementvoid SROMvWriteAllContents(void __iomem *dwIoBase, unsigned char *pbyEepromRegs); 1475449c685a4b39534f18869a93896370224463715Forest Bond 1481683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementvoid SROMvReadEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddress); 1491683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementvoid SROMvWriteEtherAddress(void __iomem *dwIoBase, unsigned char *pbyEtherAddress); 1505449c685a4b39534f18869a93896370224463715Forest Bond 1511683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementvoid SROMvReadSubSysVenId(void __iomem *dwIoBase, unsigned long *pdwSubSysVenId); 1525449c685a4b39534f18869a93896370224463715Forest Bond 1531683440595ea33cc019fb8524b04319cf82bc6acGuillaume Clementbool SROMbAutoLoad(void __iomem *dwIoBase); 1545449c685a4b39534f18869a93896370224463715Forest Bond 1555449c685a4b39534f18869a93896370224463715Forest Bond#endif // __EEPROM_H__ 156