Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License along |
| 16 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * |
| 20 | * File: srom.h |
| 21 | * |
| 22 | * Purpose: Implement functions to access eeprom |
| 23 | * |
| 24 | * Author: Jerry Chen |
| 25 | * |
| 26 | * Date: Jan 29, 2003 |
| 27 | * |
| 28 | */ |
| 29 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 30 | #ifndef __SROM_H__ |
| 31 | #define __SROM_H__ |
| 32 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 33 | #include "ttype.h" |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 34 | |
Jim Lieb | 612822f | 2009-08-12 14:54:03 -0700 | [diff] [blame] | 35 | /*--------------------- Export Definitions -------------------------*/ |
| 36 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 37 | #define EEP_MAX_CONTEXT_SIZE 256 |
| 38 | |
| 39 | #define CB_EEPROM_READBYTE_WAIT 900 //us |
| 40 | |
| 41 | #define W_MAX_I2CRETRY 0x0fff |
| 42 | |
| 43 | // |
| 44 | // Contents in the EEPROM |
| 45 | // |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 46 | #define EEP_OFS_PAR 0x00 // physical address |
| 47 | #define EEP_OFS_ANTENNA 0x16 |
| 48 | #define EEP_OFS_RADIOCTL 0x17 |
| 49 | #define EEP_OFS_RFTYPE 0x1B // for select RF |
| 50 | #define EEP_OFS_MINCHANNEL 0x1C // Min Channel # |
| 51 | #define EEP_OFS_MAXCHANNEL 0x1D // Max Channel # |
| 52 | #define EEP_OFS_SIGNATURE 0x1E // |
| 53 | #define EEP_OFS_ZONETYPE 0x1F // |
| 54 | #define EEP_OFS_RFTABLE 0x20 // RF POWER TABLE |
| 55 | #define EEP_OFS_PWR_CCK 0x20 |
| 56 | #define EEP_OFS_SETPT_CCK 0x21 |
| 57 | #define EEP_OFS_PWR_OFDMG 0x23 |
| 58 | #define EEP_OFS_SETPT_OFDMG 0x24 |
| 59 | #define EEP_OFS_PWR_FORMULA_OST 0x26 // |
| 60 | #define EEP_OFS_MAJOR_VER 0x2E |
| 61 | #define EEP_OFS_MINOR_VER 0x2F |
| 62 | #define EEP_OFS_CCK_PWR_TBL 0x30 |
| 63 | #define EEP_OFS_CCK_PWR_dBm 0x3F |
| 64 | #define EEP_OFS_OFDM_PWR_TBL 0x40 |
| 65 | #define EEP_OFS_OFDM_PWR_dBm 0x4F |
| 66 | //{{ RobertYu: 20041124 |
| 67 | #define EEP_OFS_SETPT_OFDMA 0x4E |
| 68 | #define EEP_OFS_OFDMA_PWR_TBL 0x50 |
| 69 | //}} |
| 70 | #define EEP_OFS_OFDMA_PWR_dBm 0xD2 |
| 71 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 72 | //----------need to remove -------------------- |
| 73 | #define EEP_OFS_BBTAB_LEN 0x70 // BB Table Length |
| 74 | #define EEP_OFS_BBTAB_ADR 0x71 // BB Table Offset |
| 75 | #define EEP_OFS_CHECKSUM 0xFF // reserved area for baseband 28h ~ 78h |
| 76 | |
| 77 | #define EEP_I2C_DEV_ID 0x50 // EEPROM device address on the I2C bus |
| 78 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 79 | // |
| 80 | // Bits in EEP_OFS_ANTENNA |
| 81 | // |
| 82 | #define EEP_ANTENNA_MAIN 0x01 |
| 83 | #define EEP_ANTENNA_AUX 0x02 |
| 84 | #define EEP_ANTINV 0x04 |
| 85 | |
| 86 | // |
| 87 | // Bits in EEP_OFS_RADIOCTL |
| 88 | // |
| 89 | #define EEP_RADIOCTL_ENABLE 0x80 |
| 90 | #define EEP_RADIOCTL_INV 0x01 |
| 91 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 92 | /*--------------------- Export Types ------------------------------*/ |
| 93 | |
| 94 | // AT24C02 eeprom contents |
| 95 | // 2048 bits = 256 bytes = 128 words |
| 96 | // |
| 97 | typedef struct tagSSromReg { |
Joe Perches | 0c97914 | 2013-03-18 10:45:02 -0700 | [diff] [blame] | 98 | unsigned char abyPAR[6]; // 0x00 (unsigned short) |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 99 | |
Joe Perches | 0c97914 | 2013-03-18 10:45:02 -0700 | [diff] [blame] | 100 | unsigned short wSUB_VID; // 0x03 (unsigned short) |
| 101 | unsigned short wSUB_SID; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 102 | |
Joe Perches | 0c97914 | 2013-03-18 10:45:02 -0700 | [diff] [blame] | 103 | unsigned char byBCFG0; // 0x05 (unsigned short) |
| 104 | unsigned char byBCFG1; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 105 | |
Joe Perches | 0c97914 | 2013-03-18 10:45:02 -0700 | [diff] [blame] | 106 | unsigned char byFCR0; // 0x06 (unsigned short) |
| 107 | unsigned char byFCR1; |
| 108 | unsigned char byPMC0; // 0x07 (unsigned short) |
| 109 | unsigned char byPMC1; |
| 110 | unsigned char byMAXLAT; // 0x08 (unsigned short) |
| 111 | unsigned char byMINGNT; |
| 112 | unsigned char byCFG0; // 0x09 (unsigned short) |
| 113 | unsigned char byCFG1; |
| 114 | unsigned short wCISPTR; // 0x0A (unsigned short) |
| 115 | unsigned short wRsv0; // 0x0B (unsigned short) |
| 116 | unsigned short wRsv1; // 0x0C (unsigned short) |
| 117 | unsigned char byBBPAIR; // 0x0D (unsigned short) |
| 118 | unsigned char byRFTYPE; |
| 119 | unsigned char byMinChannel; // 0x0E (unsigned short) |
| 120 | unsigned char byMaxChannel; |
| 121 | unsigned char bySignature; // 0x0F (unsigned short) |
| 122 | unsigned char byCheckSum; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 123 | |
Joe Perches | 0c97914 | 2013-03-18 10:45:02 -0700 | [diff] [blame] | 124 | unsigned char abyReserved0[96]; // 0x10 (unsigned short) |
| 125 | unsigned char abyCIS[128]; // 0x80 (unsigned short) |
Jim Lieb | a884847 | 2009-08-12 14:54:07 -0700 | [diff] [blame] | 126 | } SSromReg, *PSSromReg; |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 127 | |
| 128 | /*--------------------- Export Macros ------------------------------*/ |
| 129 | |
| 130 | /*--------------------- Export Classes ----------------------------*/ |
| 131 | |
| 132 | /*--------------------- Export Variables --------------------------*/ |
| 133 | |
| 134 | /*--------------------- Export Functions --------------------------*/ |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 135 | |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 136 | unsigned char SROMbyReadEmbedded(unsigned long dwIoBase, unsigned char byContntOffset); |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 137 | bool SROMbWriteEmbedded(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byData); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 138 | |
Charles Clément | 3fc9b58 | 2010-06-24 11:02:27 -0700 | [diff] [blame] | 139 | void SROMvRegBitsOn(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byBits); |
| 140 | void SROMvRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byBits); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 141 | |
Charles Clément | 7b6a001 | 2010-08-01 17:15:50 +0200 | [diff] [blame] | 142 | bool SROMbIsRegBitsOn(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byTestBits); |
| 143 | bool SROMbIsRegBitsOff(unsigned long dwIoBase, unsigned char byContntOffset, unsigned char byTestBits); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 144 | |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 145 | void SROMvReadAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs); |
| 146 | void SROMvWriteAllContents(unsigned long dwIoBase, unsigned char *pbyEepromRegs); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 147 | |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 148 | void SROMvReadEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddress); |
| 149 | void SROMvWriteEtherAddress(unsigned long dwIoBase, unsigned char *pbyEtherAddress); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 150 | |
Charles Clément | 412b2d0 | 2010-06-22 08:54:42 -0700 | [diff] [blame] | 151 | void SROMvReadSubSysVenId(unsigned long dwIoBase, unsigned long *pdwSubSysVenId); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 152 | |
Joe Perches | 0c97914 | 2013-03-18 10:45:02 -0700 | [diff] [blame] | 153 | bool SROMbAutoLoad(unsigned long dwIoBase); |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 154 | |
Forest Bond | 5449c68 | 2009-04-25 10:30:44 -0400 | [diff] [blame] | 155 | #endif // __EEPROM_H__ |