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 -------- ---------- ----------------------------------------------
38 #include "../rt_config.h"
40 /* IRQL = PASSIVE_LEVEL */
41 static inline void RaiseClock(struct rt_rtmp_adapter
*pAd
, u32
* x
)
44 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, *x
);
45 RTMPusecDelay(1); /* Max frequency = 1MHz in Spec. definition */
48 /* IRQL = PASSIVE_LEVEL */
49 static inline void LowerClock(struct rt_rtmp_adapter
*pAd
, u32
* x
)
52 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, *x
);
56 /* IRQL = PASSIVE_LEVEL */
57 static inline u16
ShiftInBits(struct rt_rtmp_adapter
*pAd
)
62 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
66 for (i
= 0; i
< 16; i
++) {
70 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
71 LowerClock(pAd
, &x
); /*prevent read failed */
81 /* IRQL = PASSIVE_LEVEL */
82 static inline void ShiftOutBits(struct rt_rtmp_adapter
*pAd
,
87 mask
= 0x01 << (count
- 1);
88 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
97 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
106 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
109 /* IRQL = PASSIVE_LEVEL */
110 static inline void EEpromCleanup(struct rt_rtmp_adapter
*pAd
)
114 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
117 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
123 static inline void EWEN(struct rt_rtmp_adapter
*pAd
)
127 /* reset bits and set EECS */
128 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
129 x
&= ~(EEDI
| EEDO
| EESK
);
131 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
137 /* output the read_opcode and six pulse in that order */
138 ShiftOutBits(pAd
, EEPROM_EWEN_OPCODE
, 5);
139 ShiftOutBits(pAd
, 0, 6);
144 static inline void EWDS(struct rt_rtmp_adapter
*pAd
)
148 /* reset bits and set EECS */
149 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
150 x
&= ~(EEDI
| EEDO
| EESK
);
152 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
158 /* output the read_opcode and six pulse in that order */
159 ShiftOutBits(pAd
, EEPROM_EWDS_OPCODE
, 5);
160 ShiftOutBits(pAd
, 0, 6);
165 /* IRQL = PASSIVE_LEVEL */
166 int rtmp_ee_prom_read16(struct rt_rtmp_adapter
*pAd
,
167 u16 Offset
, u16
* pValue
)
173 /* reset bits and set EECS */
174 RTMP_IO_READ32(pAd
, E2PROM_CSR
, &x
);
175 x
&= ~(EEDI
| EEDO
| EESK
);
177 RTMP_IO_WRITE32(pAd
, E2PROM_CSR
, x
);
179 /* patch can not access e-Fuse issue */
180 if (!(IS_RT3090(pAd
) || IS_RT3572(pAd
) || IS_RT3390(pAd
))) {
185 /* output the read_opcode and register number in that order */
186 ShiftOutBits(pAd
, EEPROM_READ_OPCODE
, 3);
187 ShiftOutBits(pAd
, Offset
, pAd
->EEPROMAddressNum
);
189 /* Now read the data (16 bits) in from the selected EEPROM word */
190 data
= ShiftInBits(pAd
);
196 return NDIS_STATUS_SUCCESS
;