2 *************************************************************************
4 * 5F., No.36, Taiyuan St., Jhubei City,
8 * (c) Copyright 2002-2007, Ralink Technology, Inc.
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
15 * This program is distributed in the hope that it will be useful, *
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
18 * GNU General Public License for more details. *
20 * You should have received a copy of the GNU General Public License *
21 * along with this program; if not, write to the *
22 * Free Software Foundation, Inc., *
23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
25 *************************************************************************
34 -------- ---------- ----------------------------------------------
35 Name Date Modification logs
37 #include "../rt_config.h"
40 #define EEPROM_SIZE 0x200
41 #define NVRAM_OFFSET 0x30000
42 #define RF_OFFSET 0x40000
44 static UCHAR init_flag
= 0;
45 static PUCHAR nv_ee_start
= 0;
47 static UCHAR EeBuffer
[EEPROM_SIZE
];
49 // IRQL = PASSIVE_LEVEL
55 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, *x
);
56 RTMPusecDelay(1); // Max frequency = 1MHz in Spec. definition
59 // IRQL = PASSIVE_LEVEL
65 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, *x
);
69 // IRQL = PASSIVE_LEVEL
76 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
85 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
97 // IRQL = PASSIVE_LEVEL
105 mask
= 0x01 << (count
- 1);
106 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
113 if(data
& mask
) x
|= EEDI
;
115 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
124 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
127 // IRQL = PASSIVE_LEVEL
129 IN PRTMP_ADAPTER pAd
)
133 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
136 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
143 IN PRTMP_ADAPTER pAd
)
147 // reset bits and set EECS
148 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
149 x
&= ~(EEDI
| EEDO
| EESK
);
151 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
157 // output the read_opcode and six pulse in that order
158 ShiftOutBits(pAd
, EEPROM_EWEN_OPCODE
, 5);
159 ShiftOutBits(pAd
, 0, 6);
165 IN PRTMP_ADAPTER pAd
)
169 // reset bits and set EECS
170 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
171 x
&= ~(EEDI
| EEDO
| EESK
);
173 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
179 // output the read_opcode and six pulse in that order
180 ShiftOutBits(pAd
, EEPROM_EWDS_OPCODE
, 5);
181 ShiftOutBits(pAd
, 0, 6);
186 // IRQL = PASSIVE_LEVEL
187 USHORT
RTMP_EEPROM_READ16(
188 IN PRTMP_ADAPTER pAd
,
195 // reset bits and set EECS
196 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
197 x
&= ~(EEDI
| EEDO
| EESK
);
199 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
205 // output the read_opcode and register number in that order
206 ShiftOutBits(pAd
, EEPROM_READ_OPCODE
, 3);
207 ShiftOutBits(pAd
, Offset
, pAd
->EEPROMAddressNum
);
209 // Now read the data (16 bits) in from the selected EEPROM word
210 data
= ShiftInBits(pAd
);
217 VOID
RTMP_EEPROM_WRITE16(
218 IN PRTMP_ADAPTER pAd
,
228 // reset bits and set EECS
229 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
230 x
&= ~(EEDI
| EEDO
| EESK
);
232 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
238 // output the read_opcode ,register number and data in that order
239 ShiftOutBits(pAd
, EEPROM_WRITE_OPCODE
, 3);
240 ShiftOutBits(pAd
, Offset
, pAd
->EEPROMAddressNum
);
241 ShiftOutBits(pAd
, Data
, 16); // 16-bit access
244 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
248 RTMPusecDelay(10000); //delay for twp(MAX)=10ms