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 *************************************************************************
31 Miniport generic portion header file
35 -------- ---------- ----------------------------------------------
39 #include "../rt_config.h"
43 // IRQL = PASSIVE_LEVEL
44 static inline VOID RaiseClock(
49 RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
50 RTMPusecDelay(1); // Max frequency = 1MHz in Spec. definition
53 // IRQL = PASSIVE_LEVEL
54 static inline VOID LowerClock(
59 RTMP_IO_WRITE32(pAd, E2PROM_CSR, *x);
63 // IRQL = PASSIVE_LEVEL
64 static inline USHORT ShiftInBits(
70 RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
79 RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
80 LowerClock(pAd, &x); //prevent read failed
91 // IRQL = PASSIVE_LEVEL
92 static inline VOID ShiftOutBits(
99 mask = 0x01 << (count - 1);
100 RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
107 if(data & mask) x |= EEDI;
109 RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
118 RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
122 // IRQL = PASSIVE_LEVEL
123 static inline VOID EEpromCleanup(
124 IN PRTMP_ADAPTER pAd)
128 RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
131 RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
138 static inline VOID EWEN(
139 IN PRTMP_ADAPTER pAd)
143 // reset bits and set EECS
144 RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
145 x &= ~(EEDI | EEDO | EESK);
147 RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
153 // output the read_opcode and six pulse in that order
154 ShiftOutBits(pAd, EEPROM_EWEN_OPCODE, 5);
155 ShiftOutBits(pAd, 0, 6);
161 static inline VOID EWDS(
162 IN PRTMP_ADAPTER pAd)
166 // reset bits and set EECS
167 RTMP_IO_READ32(pAd, E2PROM_CSR, &x);
168 x &= ~(EEDI | EEDO | EESK);
170 RTMP_IO_WRITE32(pAd, E2PROM_CSR, x);
176 // output the read_opcode and six pulse in that order
177 ShiftOutBits(pAd, EEPROM_EWDS_OPCODE, 5);
178 ShiftOutBits(pAd, 0, 6);
184 // IRQL = PASSIVE_LEVEL
185 int rtmp_ee_prom_read16(
186 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);
201 // patch can not access e-Fuse issue
202 if (!(IS_RT3090(pAd) || IS_RT3572(pAd) || IS_RT3390(pAd)))
209 // output the read_opcode and register number in that order
210 ShiftOutBits(pAd, EEPROM_READ_OPCODE, 3);
211 ShiftOutBits(pAd, Offset, pAd->EEPROMAddressNum);
213 // Now read the data (16 bits) in from the selected EEPROM word
214 data = ShiftInBits(pAd);
221 return NDIS_STATUS_SUCCESS;