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 Specific funcitons and variables for RT3070
35 -------- ---------- ----------------------------------------------
40 #include "../rt_config.h"
42 #ifndef RTMP_RF_RW_SUPPORT
43 #error "You Should Enable compile flag RTMP_RF_RW_SUPPORT for this chip"
44 #endif /* RTMP_RF_RW_SUPPORT // */
46 void NICInitRT3070RFRegisters(struct rt_rtmp_adapter
*pAd
)
51 /* Driver must read EEPROM to get RfIcType before initial RF registers */
52 /* Initialize RF register to default value */
53 if (IS_RT3070(pAd
) || IS_RT3071(pAd
)) {
54 /* Init RF calibration */
55 /* Driver should toggle RF R30 bit7 before init RF registers */
59 RT30xxReadRFRegister(pAd
, RF_R30
, (u8
*)&RfReg
);
61 RT30xxWriteRFRegister(pAd
, RF_R30
, (u8
)RfReg
);
64 RT30xxWriteRFRegister(pAd
, RF_R30
, (u8
)RfReg
);
66 /* Initialize RF register to default value */
67 for (i
= 0; i
< NUM_RF_REG_PARMS
; i
++) {
68 RT30xxWriteRFRegister(pAd
,
69 RT30xx_RFRegTable
[i
].Register
,
70 RT30xx_RFRegTable
[i
].Value
);
76 /* The DAC issue(LDO_CFG0) has been fixed in RT3070(F). */
77 /* The voltage raising patch is no longer needed for RT3070(F) */
79 if ((pAd
->MACVersion
& 0xffff) < 0x0201) {
80 /* Update MAC 0x05D4 from 01xxxxxx to 0Dxxxxxx (voltage 1.2V to 1.35V) for RT3070 to improve yield rate */
81 RTUSBReadMACRegister(pAd
, LDO_CFG0
, &data
);
82 data
= ((data
& 0xF0FFFFFF) | 0x0D000000);
83 RTUSBWriteMACRegister(pAd
, LDO_CFG0
, data
);
85 } else if (IS_RT3071(pAd
)) {
86 /* Driver should set RF R6 bit6 on before init RF registers */
87 RT30xxReadRFRegister(pAd
, RF_R06
, (u8
*)&RfReg
);
89 RT30xxWriteRFRegister(pAd
, RF_R06
, (u8
)RfReg
);
92 RT30xxWriteRFRegister(pAd
, RF_R31
, 0x14);
94 /* RT3071 version E has fixed this issue */
95 if ((pAd
->NicConfig2
.field
.DACTestBit
== 1)
96 && ((pAd
->MACVersion
& 0xffff) < 0x0211)) {
97 /* patch tx EVM issue temporarily */
98 RTUSBReadMACRegister(pAd
, LDO_CFG0
, &data
);
99 data
= ((data
& 0xE0FFFFFF) | 0x0D000000);
100 RTUSBWriteMACRegister(pAd
, LDO_CFG0
, data
);
102 RTMP_IO_READ32(pAd
, LDO_CFG0
, &data
);
103 data
= ((data
& 0xE0FFFFFF) | 0x01000000);
104 RTMP_IO_WRITE32(pAd
, LDO_CFG0
, data
);
107 /* patch LNA_PE_G1 failed issue */
108 RTUSBReadMACRegister(pAd
, GPIO_SWITCH
, &data
);
110 RTUSBWriteMACRegister(pAd
, GPIO_SWITCH
, data
);
112 /*For RF filter Calibration */
113 RTMPFilterCalibration(pAd
);
115 /* Initialize RF R27 register, set RF R27 must be behind RTMPFilterCalibration() */
117 /* TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F). */
118 /* Raising RF voltage is no longer needed for RT3070(F) */
120 if ((IS_RT3070(pAd
)) && ((pAd
->MACVersion
& 0xffff) < 0x0201)) {
121 RT30xxWriteRFRegister(pAd
, RF_R27
, 0x3);
122 } else if ((IS_RT3071(pAd
))
123 && ((pAd
->MACVersion
& 0xffff) < 0x0211)) {
124 RT30xxWriteRFRegister(pAd
, RF_R27
, 0x3);
126 /* set led open drain enable */
127 RTUSBReadMACRegister(pAd
, OPT_14
, &data
);
129 RTUSBWriteMACRegister(pAd
, OPT_14
, data
);
131 /* move from RT30xxLoadRFNormalModeSetup because it's needed for both RT3070 and RT3071 */
132 /* TX_LO1_en, RF R17 register Bit 3 to 0 */
133 RT30xxReadRFRegister(pAd
, RF_R17
, &RFValue
);
135 /* to fix rx long range issue */
136 if (pAd
->NicConfig2
.field
.ExternalLNAForG
== 0) {
138 && ((pAd
->MACVersion
& 0xffff) >= 0x0211))
143 /* set RF_R17_bit[2:0] equal to EEPROM setting at 0x48h */
144 if (pAd
->TxMixerGain24G
>= 1) {
145 RFValue
&= (~0x7); /* clean bit [2:0] */
146 RFValue
|= pAd
->TxMixerGain24G
;
148 RT30xxWriteRFRegister(pAd
, RF_R17
, RFValue
);
150 if (IS_RT3071(pAd
)) {
151 /* add by johnli, RF power sequence setup, load RF normal operation-mode setup */
152 RT30xxLoadRFNormalModeSetup(pAd
);
153 } else if (IS_RT3070(pAd
)) {
154 /* add by johnli, reset RF_R27 when interface down & up to fix throughput problem */
155 /* LDORF_VC, RF R27 register Bit 2 to 0 */
156 RT30xxReadRFRegister(pAd
, RF_R27
, &RFValue
);
157 /* TX to RX IQ glitch(RF_R27) has been fixed in RT3070(F). */
158 /* Raising RF voltage is no longer needed for RT3070(F) */
159 if ((pAd
->MACVersion
& 0xffff) < 0x0201)
160 RFValue
= (RFValue
& (~0x77)) | 0x3;
162 RFValue
= (RFValue
& (~0x77));
163 RT30xxWriteRFRegister(pAd
, RF_R27
, RFValue
);
169 #endif /* RT3070 // */