diff options
author | Bartlomiej Zolnierkiewicz <bzolnier@gmail.com> | 2009-11-04 12:36:57 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-11-06 16:49:02 -0500 |
commit | fcf5154118849cca3cdf424e83f863225d8173e7 (patch) | |
tree | 93cd91c94c13ca099533582e676f4591445ba370 /drivers/net/wireless/rt2x00/rt2800lib.c | |
parent | 1f285f1423e456cfa14331987782edeca64d8e70 (diff) |
rt2800: add rt2800lib (part three)
Code unification.
Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/rt2x00/rt2800lib.c')
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 614 |
1 files changed, 599 insertions, 15 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index ba88d643edd3..ddd53c02be7a 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -31,8 +31,12 @@ | |||
31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
32 | 32 | ||
33 | #include "rt2x00.h" | 33 | #include "rt2x00.h" |
34 | #ifdef CONFIG_RT2800USB | ||
35 | #include "rt2x00usb.h" | ||
36 | #endif | ||
34 | #include "rt2800lib.h" | 37 | #include "rt2800lib.h" |
35 | #include "rt2800.h" | 38 | #include "rt2800.h" |
39 | #include "rt2800usb.h" | ||
36 | 40 | ||
37 | MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); | 41 | MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); |
38 | MODULE_DESCRIPTION("rt2800 library"); | 42 | MODULE_DESCRIPTION("rt2800 library"); |
@@ -62,8 +66,8 @@ MODULE_LICENSE("GPL"); | |||
62 | rt2800_regbusy_read((__dev), H2M_MAILBOX_CSR, \ | 66 | rt2800_regbusy_read((__dev), H2M_MAILBOX_CSR, \ |
63 | H2M_MAILBOX_CSR_OWNER, (__reg)) | 67 | H2M_MAILBOX_CSR_OWNER, (__reg)) |
64 | 68 | ||
65 | void rt2800_bbp_write(struct rt2x00_dev *rt2x00dev, | 69 | static void rt2800_bbp_write(struct rt2x00_dev *rt2x00dev, |
66 | const unsigned int word, const u8 value) | 70 | const unsigned int word, const u8 value) |
67 | { | 71 | { |
68 | u32 reg; | 72 | u32 reg; |
69 | 73 | ||
@@ -87,10 +91,9 @@ void rt2800_bbp_write(struct rt2x00_dev *rt2x00dev, | |||
87 | 91 | ||
88 | mutex_unlock(&rt2x00dev->csr_mutex); | 92 | mutex_unlock(&rt2x00dev->csr_mutex); |
89 | } | 93 | } |
90 | EXPORT_SYMBOL_GPL(rt2800_bbp_write); | ||
91 | 94 | ||
92 | void rt2800_bbp_read(struct rt2x00_dev *rt2x00dev, | 95 | static void rt2800_bbp_read(struct rt2x00_dev *rt2x00dev, |
93 | const unsigned int word, u8 *value) | 96 | const unsigned int word, u8 *value) |
94 | { | 97 | { |
95 | u32 reg; | 98 | u32 reg; |
96 | 99 | ||
@@ -121,10 +124,9 @@ void rt2800_bbp_read(struct rt2x00_dev *rt2x00dev, | |||
121 | 124 | ||
122 | mutex_unlock(&rt2x00dev->csr_mutex); | 125 | mutex_unlock(&rt2x00dev->csr_mutex); |
123 | } | 126 | } |
124 | EXPORT_SYMBOL_GPL(rt2800_bbp_read); | ||
125 | 127 | ||
126 | void rt2800_rfcsr_write(struct rt2x00_dev *rt2x00dev, | 128 | static void rt2800_rfcsr_write(struct rt2x00_dev *rt2x00dev, |
127 | const unsigned int word, const u8 value) | 129 | const unsigned int word, const u8 value) |
128 | { | 130 | { |
129 | u32 reg; | 131 | u32 reg; |
130 | 132 | ||
@@ -146,10 +148,9 @@ void rt2800_rfcsr_write(struct rt2x00_dev *rt2x00dev, | |||
146 | 148 | ||
147 | mutex_unlock(&rt2x00dev->csr_mutex); | 149 | mutex_unlock(&rt2x00dev->csr_mutex); |
148 | } | 150 | } |
149 | EXPORT_SYMBOL_GPL(rt2800_rfcsr_write); | ||
150 | 151 | ||
151 | void rt2800_rfcsr_read(struct rt2x00_dev *rt2x00dev, | 152 | static void rt2800_rfcsr_read(struct rt2x00_dev *rt2x00dev, |
152 | const unsigned int word, u8 *value) | 153 | const unsigned int word, u8 *value) |
153 | { | 154 | { |
154 | u32 reg; | 155 | u32 reg; |
155 | 156 | ||
@@ -178,10 +179,9 @@ void rt2800_rfcsr_read(struct rt2x00_dev *rt2x00dev, | |||
178 | 179 | ||
179 | mutex_unlock(&rt2x00dev->csr_mutex); | 180 | mutex_unlock(&rt2x00dev->csr_mutex); |
180 | } | 181 | } |
181 | EXPORT_SYMBOL_GPL(rt2800_rfcsr_read); | ||
182 | 182 | ||
183 | void rt2800_rf_write(struct rt2x00_dev *rt2x00dev, | 183 | static void rt2800_rf_write(struct rt2x00_dev *rt2x00dev, |
184 | const unsigned int word, const u32 value) | 184 | const unsigned int word, const u32 value) |
185 | { | 185 | { |
186 | u32 reg; | 186 | u32 reg; |
187 | 187 | ||
@@ -204,7 +204,6 @@ void rt2800_rf_write(struct rt2x00_dev *rt2x00dev, | |||
204 | 204 | ||
205 | mutex_unlock(&rt2x00dev->csr_mutex); | 205 | mutex_unlock(&rt2x00dev->csr_mutex); |
206 | } | 206 | } |
207 | EXPORT_SYMBOL_GPL(rt2800_rf_write); | ||
208 | 207 | ||
209 | void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev, | 208 | void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev, |
210 | const u8 command, const u8 token, | 209 | const u8 command, const u8 token, |
@@ -1074,3 +1073,588 @@ void rt2800_link_tuner(struct rt2x00_dev *rt2x00dev, struct link_qual *qual, | |||
1074 | ((qual->rssi > -80) * 0x10)); | 1073 | ((qual->rssi > -80) * 0x10)); |
1075 | } | 1074 | } |
1076 | EXPORT_SYMBOL_GPL(rt2800_link_tuner); | 1075 | EXPORT_SYMBOL_GPL(rt2800_link_tuner); |
1076 | |||
1077 | /* | ||
1078 | * Initialization functions. | ||
1079 | */ | ||
1080 | int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | ||
1081 | { | ||
1082 | u32 reg; | ||
1083 | unsigned int i; | ||
1084 | |||
1085 | if (rt2x00_intf_is_usb(rt2x00dev)) { | ||
1086 | /* | ||
1087 | * Wait untill BBP and RF are ready. | ||
1088 | */ | ||
1089 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | ||
1090 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); | ||
1091 | if (reg && reg != ~0) | ||
1092 | break; | ||
1093 | msleep(1); | ||
1094 | } | ||
1095 | |||
1096 | if (i == REGISTER_BUSY_COUNT) { | ||
1097 | ERROR(rt2x00dev, "Unstable hardware.\n"); | ||
1098 | return -EBUSY; | ||
1099 | } | ||
1100 | |||
1101 | rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, ®); | ||
1102 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, | ||
1103 | reg & ~0x00002000); | ||
1104 | } else if (rt2x00_intf_is_pci(rt2x00dev)) | ||
1105 | rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); | ||
1106 | |||
1107 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); | ||
1108 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); | ||
1109 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); | ||
1110 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); | ||
1111 | |||
1112 | if (rt2x00_intf_is_usb(rt2x00dev)) { | ||
1113 | rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000); | ||
1114 | #ifdef CONFIG_RT2800USB | ||
1115 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0, | ||
1116 | USB_MODE_RESET, REGISTER_TIMEOUT); | ||
1117 | #endif | ||
1118 | } | ||
1119 | |||
1120 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000); | ||
1121 | |||
1122 | rt2800_register_read(rt2x00dev, BCN_OFFSET0, ®); | ||
1123 | rt2x00_set_field32(®, BCN_OFFSET0_BCN0, 0xe0); /* 0x3800 */ | ||
1124 | rt2x00_set_field32(®, BCN_OFFSET0_BCN1, 0xe8); /* 0x3a00 */ | ||
1125 | rt2x00_set_field32(®, BCN_OFFSET0_BCN2, 0xf0); /* 0x3c00 */ | ||
1126 | rt2x00_set_field32(®, BCN_OFFSET0_BCN3, 0xf8); /* 0x3e00 */ | ||
1127 | rt2800_register_write(rt2x00dev, BCN_OFFSET0, reg); | ||
1128 | |||
1129 | rt2800_register_read(rt2x00dev, BCN_OFFSET1, ®); | ||
1130 | rt2x00_set_field32(®, BCN_OFFSET1_BCN4, 0xc8); /* 0x3200 */ | ||
1131 | rt2x00_set_field32(®, BCN_OFFSET1_BCN5, 0xd0); /* 0x3400 */ | ||
1132 | rt2x00_set_field32(®, BCN_OFFSET1_BCN6, 0x77); /* 0x1dc0 */ | ||
1133 | rt2x00_set_field32(®, BCN_OFFSET1_BCN7, 0x6f); /* 0x1bc0 */ | ||
1134 | rt2800_register_write(rt2x00dev, BCN_OFFSET1, reg); | ||
1135 | |||
1136 | rt2800_register_write(rt2x00dev, LEGACY_BASIC_RATE, 0x0000013f); | ||
1137 | rt2800_register_write(rt2x00dev, HT_BASIC_RATE, 0x00008003); | ||
1138 | |||
1139 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000); | ||
1140 | |||
1141 | rt2800_register_read(rt2x00dev, BCN_TIME_CFG, ®); | ||
1142 | rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_INTERVAL, 0); | ||
1143 | rt2x00_set_field32(®, BCN_TIME_CFG_TSF_TICKING, 0); | ||
1144 | rt2x00_set_field32(®, BCN_TIME_CFG_TSF_SYNC, 0); | ||
1145 | rt2x00_set_field32(®, BCN_TIME_CFG_TBTT_ENABLE, 0); | ||
1146 | rt2x00_set_field32(®, BCN_TIME_CFG_BEACON_GEN, 0); | ||
1147 | rt2x00_set_field32(®, BCN_TIME_CFG_TX_TIME_COMPENSATE, 0); | ||
1148 | rt2800_register_write(rt2x00dev, BCN_TIME_CFG, reg); | ||
1149 | |||
1150 | if (rt2x00_intf_is_usb(rt2x00dev) && | ||
1151 | rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION) { | ||
1152 | rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000400); | ||
1153 | rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00000000); | ||
1154 | rt2800_register_write(rt2x00dev, TX_SW_CFG2, 0x00000000); | ||
1155 | } else { | ||
1156 | rt2800_register_write(rt2x00dev, TX_SW_CFG0, 0x00000000); | ||
1157 | rt2800_register_write(rt2x00dev, TX_SW_CFG1, 0x00080606); | ||
1158 | } | ||
1159 | |||
1160 | rt2800_register_read(rt2x00dev, TX_LINK_CFG, ®); | ||
1161 | rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_MFB_LIFETIME, 32); | ||
1162 | rt2x00_set_field32(®, TX_LINK_CFG_MFB_ENABLE, 0); | ||
1163 | rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_UMFS_ENABLE, 0); | ||
1164 | rt2x00_set_field32(®, TX_LINK_CFG_TX_MRQ_EN, 0); | ||
1165 | rt2x00_set_field32(®, TX_LINK_CFG_TX_RDG_EN, 0); | ||
1166 | rt2x00_set_field32(®, TX_LINK_CFG_TX_CF_ACK_EN, 1); | ||
1167 | rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_MFB, 0); | ||
1168 | rt2x00_set_field32(®, TX_LINK_CFG_REMOTE_MFS, 0); | ||
1169 | rt2800_register_write(rt2x00dev, TX_LINK_CFG, reg); | ||
1170 | |||
1171 | rt2800_register_read(rt2x00dev, TX_TIMEOUT_CFG, ®); | ||
1172 | rt2x00_set_field32(®, TX_TIMEOUT_CFG_MPDU_LIFETIME, 9); | ||
1173 | rt2x00_set_field32(®, TX_TIMEOUT_CFG_TX_OP_TIMEOUT, 10); | ||
1174 | rt2800_register_write(rt2x00dev, TX_TIMEOUT_CFG, reg); | ||
1175 | |||
1176 | rt2800_register_read(rt2x00dev, MAX_LEN_CFG, ®); | ||
1177 | rt2x00_set_field32(®, MAX_LEN_CFG_MAX_MPDU, AGGREGATION_SIZE); | ||
1178 | if (rt2x00_rev(&rt2x00dev->chip) >= RT2880E_VERSION && | ||
1179 | rt2x00_rev(&rt2x00dev->chip) < RT3070_VERSION) | ||
1180 | rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, 2); | ||
1181 | else | ||
1182 | rt2x00_set_field32(®, MAX_LEN_CFG_MAX_PSDU, 1); | ||
1183 | rt2x00_set_field32(®, MAX_LEN_CFG_MIN_PSDU, 0); | ||
1184 | rt2x00_set_field32(®, MAX_LEN_CFG_MIN_MPDU, 0); | ||
1185 | rt2800_register_write(rt2x00dev, MAX_LEN_CFG, reg); | ||
1186 | |||
1187 | rt2800_register_write(rt2x00dev, PBF_MAX_PCNT, 0x1f3fbf9f); | ||
1188 | |||
1189 | rt2800_register_read(rt2x00dev, AUTO_RSP_CFG, ®); | ||
1190 | rt2x00_set_field32(®, AUTO_RSP_CFG_AUTORESPONDER, 1); | ||
1191 | rt2x00_set_field32(®, AUTO_RSP_CFG_CTS_40_MMODE, 0); | ||
1192 | rt2x00_set_field32(®, AUTO_RSP_CFG_CTS_40_MREF, 0); | ||
1193 | rt2x00_set_field32(®, AUTO_RSP_CFG_DUAL_CTS_EN, 0); | ||
1194 | rt2x00_set_field32(®, AUTO_RSP_CFG_ACK_CTS_PSM_BIT, 0); | ||
1195 | rt2800_register_write(rt2x00dev, AUTO_RSP_CFG, reg); | ||
1196 | |||
1197 | rt2800_register_read(rt2x00dev, CCK_PROT_CFG, ®); | ||
1198 | rt2x00_set_field32(®, CCK_PROT_CFG_PROTECT_RATE, 8); | ||
1199 | rt2x00_set_field32(®, CCK_PROT_CFG_PROTECT_CTRL, 0); | ||
1200 | rt2x00_set_field32(®, CCK_PROT_CFG_PROTECT_NAV, 1); | ||
1201 | rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_CCK, 1); | ||
1202 | rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_OFDM, 1); | ||
1203 | rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_MM20, 1); | ||
1204 | rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_MM40, 1); | ||
1205 | rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_GF20, 1); | ||
1206 | rt2x00_set_field32(®, CCK_PROT_CFG_TX_OP_ALLOW_GF40, 1); | ||
1207 | rt2800_register_write(rt2x00dev, CCK_PROT_CFG, reg); | ||
1208 | |||
1209 | rt2800_register_read(rt2x00dev, OFDM_PROT_CFG, ®); | ||
1210 | rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_RATE, 8); | ||
1211 | rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_CTRL, 0); | ||
1212 | rt2x00_set_field32(®, OFDM_PROT_CFG_PROTECT_NAV, 1); | ||
1213 | rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_CCK, 1); | ||
1214 | rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_OFDM, 1); | ||
1215 | rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_MM20, 1); | ||
1216 | rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_MM40, 1); | ||
1217 | rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_GF20, 1); | ||
1218 | rt2x00_set_field32(®, OFDM_PROT_CFG_TX_OP_ALLOW_GF40, 1); | ||
1219 | rt2800_register_write(rt2x00dev, OFDM_PROT_CFG, reg); | ||
1220 | |||
1221 | rt2800_register_read(rt2x00dev, MM20_PROT_CFG, ®); | ||
1222 | rt2x00_set_field32(®, MM20_PROT_CFG_PROTECT_RATE, 0x4004); | ||
1223 | rt2x00_set_field32(®, MM20_PROT_CFG_PROTECT_CTRL, 0); | ||
1224 | rt2x00_set_field32(®, MM20_PROT_CFG_PROTECT_NAV, 1); | ||
1225 | rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_CCK, 1); | ||
1226 | rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_OFDM, 1); | ||
1227 | rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_MM20, 1); | ||
1228 | rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_MM40, 0); | ||
1229 | rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_GF20, 1); | ||
1230 | rt2x00_set_field32(®, MM20_PROT_CFG_TX_OP_ALLOW_GF40, 0); | ||
1231 | rt2800_register_write(rt2x00dev, MM20_PROT_CFG, reg); | ||
1232 | |||
1233 | rt2800_register_read(rt2x00dev, MM40_PROT_CFG, ®); | ||
1234 | rt2x00_set_field32(®, MM40_PROT_CFG_PROTECT_RATE, 0x4084); | ||
1235 | rt2x00_set_field32(®, MM40_PROT_CFG_PROTECT_CTRL, 0); | ||
1236 | rt2x00_set_field32(®, MM40_PROT_CFG_PROTECT_NAV, 1); | ||
1237 | rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_CCK, 1); | ||
1238 | rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_OFDM, 1); | ||
1239 | rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_MM20, 1); | ||
1240 | rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_MM40, 1); | ||
1241 | rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_GF20, 1); | ||
1242 | rt2x00_set_field32(®, MM40_PROT_CFG_TX_OP_ALLOW_GF40, 1); | ||
1243 | rt2800_register_write(rt2x00dev, MM40_PROT_CFG, reg); | ||
1244 | |||
1245 | rt2800_register_read(rt2x00dev, GF20_PROT_CFG, ®); | ||
1246 | rt2x00_set_field32(®, GF20_PROT_CFG_PROTECT_RATE, 0x4004); | ||
1247 | rt2x00_set_field32(®, GF20_PROT_CFG_PROTECT_CTRL, 0); | ||
1248 | rt2x00_set_field32(®, GF20_PROT_CFG_PROTECT_NAV, 1); | ||
1249 | rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_CCK, 1); | ||
1250 | rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_OFDM, 1); | ||
1251 | rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_MM20, 1); | ||
1252 | rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_MM40, 0); | ||
1253 | rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_GF20, 1); | ||
1254 | rt2x00_set_field32(®, GF20_PROT_CFG_TX_OP_ALLOW_GF40, 0); | ||
1255 | rt2800_register_write(rt2x00dev, GF20_PROT_CFG, reg); | ||
1256 | |||
1257 | rt2800_register_read(rt2x00dev, GF40_PROT_CFG, ®); | ||
1258 | rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_RATE, 0x4084); | ||
1259 | rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_CTRL, 0); | ||
1260 | rt2x00_set_field32(®, GF40_PROT_CFG_PROTECT_NAV, 1); | ||
1261 | rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_CCK, 1); | ||
1262 | rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_OFDM, 1); | ||
1263 | rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_MM20, 1); | ||
1264 | rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_MM40, 1); | ||
1265 | rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_GF20, 1); | ||
1266 | rt2x00_set_field32(®, GF40_PROT_CFG_TX_OP_ALLOW_GF40, 1); | ||
1267 | rt2800_register_write(rt2x00dev, GF40_PROT_CFG, reg); | ||
1268 | |||
1269 | if (rt2x00_intf_is_usb(rt2x00dev)) { | ||
1270 | rt2800_register_write(rt2x00dev, PBF_CFG, 0xf40006); | ||
1271 | |||
1272 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); | ||
1273 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0); | ||
1274 | rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_DMA_BUSY, 0); | ||
1275 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_RX_DMA, 0); | ||
1276 | rt2x00_set_field32(®, WPDMA_GLO_CFG_RX_DMA_BUSY, 0); | ||
1277 | rt2x00_set_field32(®, WPDMA_GLO_CFG_WP_DMA_BURST_SIZE, 3); | ||
1278 | rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 0); | ||
1279 | rt2x00_set_field32(®, WPDMA_GLO_CFG_BIG_ENDIAN, 0); | ||
1280 | rt2x00_set_field32(®, WPDMA_GLO_CFG_RX_HDR_SCATTER, 0); | ||
1281 | rt2x00_set_field32(®, WPDMA_GLO_CFG_HDR_SEG_LEN, 0); | ||
1282 | rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); | ||
1283 | } | ||
1284 | |||
1285 | rt2800_register_write(rt2x00dev, TXOP_CTRL_CFG, 0x0000583f); | ||
1286 | rt2800_register_write(rt2x00dev, TXOP_HLDR_ET, 0x00000002); | ||
1287 | |||
1288 | rt2800_register_read(rt2x00dev, TX_RTS_CFG, ®); | ||
1289 | rt2x00_set_field32(®, TX_RTS_CFG_AUTO_RTS_RETRY_LIMIT, 32); | ||
1290 | rt2x00_set_field32(®, TX_RTS_CFG_RTS_THRES, | ||
1291 | IEEE80211_MAX_RTS_THRESHOLD); | ||
1292 | rt2x00_set_field32(®, TX_RTS_CFG_RTS_FBK_EN, 0); | ||
1293 | rt2800_register_write(rt2x00dev, TX_RTS_CFG, reg); | ||
1294 | |||
1295 | rt2800_register_write(rt2x00dev, EXP_ACK_TIME, 0x002400ca); | ||
1296 | rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); | ||
1297 | |||
1298 | /* | ||
1299 | * ASIC will keep garbage value after boot, clear encryption keys. | ||
1300 | */ | ||
1301 | for (i = 0; i < 4; i++) | ||
1302 | rt2800_register_write(rt2x00dev, | ||
1303 | SHARED_KEY_MODE_ENTRY(i), 0); | ||
1304 | |||
1305 | for (i = 0; i < 256; i++) { | ||
1306 | u32 wcid[2] = { 0xffffffff, 0x00ffffff }; | ||
1307 | rt2800_register_multiwrite(rt2x00dev, MAC_WCID_ENTRY(i), | ||
1308 | wcid, sizeof(wcid)); | ||
1309 | |||
1310 | rt2800_register_write(rt2x00dev, MAC_WCID_ATTR_ENTRY(i), 1); | ||
1311 | rt2800_register_write(rt2x00dev, MAC_IVEIV_ENTRY(i), 0); | ||
1312 | } | ||
1313 | |||
1314 | /* | ||
1315 | * Clear all beacons | ||
1316 | * For the Beacon base registers we only need to clear | ||
1317 | * the first byte since that byte contains the VALID and OWNER | ||
1318 | * bits which (when set to 0) will invalidate the entire beacon. | ||
1319 | */ | ||
1320 | rt2800_register_write(rt2x00dev, HW_BEACON_BASE0, 0); | ||
1321 | rt2800_register_write(rt2x00dev, HW_BEACON_BASE1, 0); | ||
1322 | rt2800_register_write(rt2x00dev, HW_BEACON_BASE2, 0); | ||
1323 | rt2800_register_write(rt2x00dev, HW_BEACON_BASE3, 0); | ||
1324 | rt2800_register_write(rt2x00dev, HW_BEACON_BASE4, 0); | ||
1325 | rt2800_register_write(rt2x00dev, HW_BEACON_BASE5, 0); | ||
1326 | rt2800_register_write(rt2x00dev, HW_BEACON_BASE6, 0); | ||
1327 | rt2800_register_write(rt2x00dev, HW_BEACON_BASE7, 0); | ||
1328 | |||
1329 | if (rt2x00_intf_is_usb(rt2x00dev)) { | ||
1330 | rt2800_register_read(rt2x00dev, USB_CYC_CFG, ®); | ||
1331 | rt2x00_set_field32(®, USB_CYC_CFG_CLOCK_CYCLE, 30); | ||
1332 | rt2800_register_write(rt2x00dev, USB_CYC_CFG, reg); | ||
1333 | } | ||
1334 | |||
1335 | rt2800_register_read(rt2x00dev, HT_FBK_CFG0, ®); | ||
1336 | rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS0FBK, 0); | ||
1337 | rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS1FBK, 0); | ||
1338 | rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS2FBK, 1); | ||
1339 | rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS3FBK, 2); | ||
1340 | rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS4FBK, 3); | ||
1341 | rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS5FBK, 4); | ||
1342 | rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS6FBK, 5); | ||
1343 | rt2x00_set_field32(®, HT_FBK_CFG0_HTMCS7FBK, 6); | ||
1344 | rt2800_register_write(rt2x00dev, HT_FBK_CFG0, reg); | ||
1345 | |||
1346 | rt2800_register_read(rt2x00dev, HT_FBK_CFG1, ®); | ||
1347 | rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS8FBK, 8); | ||
1348 | rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS9FBK, 8); | ||
1349 | rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS10FBK, 9); | ||
1350 | rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS11FBK, 10); | ||
1351 | rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS12FBK, 11); | ||
1352 | rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS13FBK, 12); | ||
1353 | rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS14FBK, 13); | ||
1354 | rt2x00_set_field32(®, HT_FBK_CFG1_HTMCS15FBK, 14); | ||
1355 | rt2800_register_write(rt2x00dev, HT_FBK_CFG1, reg); | ||
1356 | |||
1357 | rt2800_register_read(rt2x00dev, LG_FBK_CFG0, ®); | ||
1358 | rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS0FBK, 8); | ||
1359 | rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS1FBK, 8); | ||
1360 | rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS2FBK, 9); | ||
1361 | rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS3FBK, 10); | ||
1362 | rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS4FBK, 11); | ||
1363 | rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS5FBK, 12); | ||
1364 | rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS6FBK, 13); | ||
1365 | rt2x00_set_field32(®, LG_FBK_CFG0_OFDMMCS7FBK, 14); | ||
1366 | rt2800_register_write(rt2x00dev, LG_FBK_CFG0, reg); | ||
1367 | |||
1368 | rt2800_register_read(rt2x00dev, LG_FBK_CFG1, ®); | ||
1369 | rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS0FBK, 0); | ||
1370 | rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS1FBK, 0); | ||
1371 | rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS2FBK, 1); | ||
1372 | rt2x00_set_field32(®, LG_FBK_CFG0_CCKMCS3FBK, 2); | ||
1373 | rt2800_register_write(rt2x00dev, LG_FBK_CFG1, reg); | ||
1374 | |||
1375 | /* | ||
1376 | * We must clear the error counters. | ||
1377 | * These registers are cleared on read, | ||
1378 | * so we may pass a useless variable to store the value. | ||
1379 | */ | ||
1380 | rt2800_register_read(rt2x00dev, RX_STA_CNT0, ®); | ||
1381 | rt2800_register_read(rt2x00dev, RX_STA_CNT1, ®); | ||
1382 | rt2800_register_read(rt2x00dev, RX_STA_CNT2, ®); | ||
1383 | rt2800_register_read(rt2x00dev, TX_STA_CNT0, ®); | ||
1384 | rt2800_register_read(rt2x00dev, TX_STA_CNT1, ®); | ||
1385 | rt2800_register_read(rt2x00dev, TX_STA_CNT2, ®); | ||
1386 | |||
1387 | return 0; | ||
1388 | } | ||
1389 | EXPORT_SYMBOL_GPL(rt2800_init_registers); | ||
1390 | |||
1391 | static int rt2800_wait_bbp_rf_ready(struct rt2x00_dev *rt2x00dev) | ||
1392 | { | ||
1393 | unsigned int i; | ||
1394 | u32 reg; | ||
1395 | |||
1396 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | ||
1397 | rt2800_register_read(rt2x00dev, MAC_STATUS_CFG, ®); | ||
1398 | if (!rt2x00_get_field32(reg, MAC_STATUS_CFG_BBP_RF_BUSY)) | ||
1399 | return 0; | ||
1400 | |||
1401 | udelay(REGISTER_BUSY_DELAY); | ||
1402 | } | ||
1403 | |||
1404 | ERROR(rt2x00dev, "BBP/RF register access failed, aborting.\n"); | ||
1405 | return -EACCES; | ||
1406 | } | ||
1407 | |||
1408 | static int rt2800_wait_bbp_ready(struct rt2x00_dev *rt2x00dev) | ||
1409 | { | ||
1410 | unsigned int i; | ||
1411 | u8 value; | ||
1412 | |||
1413 | /* | ||
1414 | * BBP was enabled after firmware was loaded, | ||
1415 | * but we need to reactivate it now. | ||
1416 | */ | ||
1417 | rt2800_register_write(rt2x00dev, H2M_BBP_AGENT, 0); | ||
1418 | rt2800_register_write(rt2x00dev, H2M_MAILBOX_CSR, 0); | ||
1419 | msleep(1); | ||
1420 | |||
1421 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | ||
1422 | rt2800_bbp_read(rt2x00dev, 0, &value); | ||
1423 | if ((value != 0xff) && (value != 0x00)) | ||
1424 | return 0; | ||
1425 | udelay(REGISTER_BUSY_DELAY); | ||
1426 | } | ||
1427 | |||
1428 | ERROR(rt2x00dev, "BBP register access failed, aborting.\n"); | ||
1429 | return -EACCES; | ||
1430 | } | ||
1431 | |||
1432 | int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev) | ||
1433 | { | ||
1434 | unsigned int i; | ||
1435 | u16 eeprom; | ||
1436 | u8 reg_id; | ||
1437 | u8 value; | ||
1438 | |||
1439 | if (unlikely(rt2800_wait_bbp_rf_ready(rt2x00dev) || | ||
1440 | rt2800_wait_bbp_ready(rt2x00dev))) | ||
1441 | return -EACCES; | ||
1442 | |||
1443 | rt2800_bbp_write(rt2x00dev, 65, 0x2c); | ||
1444 | rt2800_bbp_write(rt2x00dev, 66, 0x38); | ||
1445 | rt2800_bbp_write(rt2x00dev, 69, 0x12); | ||
1446 | rt2800_bbp_write(rt2x00dev, 70, 0x0a); | ||
1447 | rt2800_bbp_write(rt2x00dev, 73, 0x10); | ||
1448 | rt2800_bbp_write(rt2x00dev, 81, 0x37); | ||
1449 | rt2800_bbp_write(rt2x00dev, 82, 0x62); | ||
1450 | rt2800_bbp_write(rt2x00dev, 83, 0x6a); | ||
1451 | rt2800_bbp_write(rt2x00dev, 84, 0x99); | ||
1452 | rt2800_bbp_write(rt2x00dev, 86, 0x00); | ||
1453 | rt2800_bbp_write(rt2x00dev, 91, 0x04); | ||
1454 | rt2800_bbp_write(rt2x00dev, 92, 0x00); | ||
1455 | rt2800_bbp_write(rt2x00dev, 103, 0x00); | ||
1456 | rt2800_bbp_write(rt2x00dev, 105, 0x05); | ||
1457 | |||
1458 | if (rt2x00_rev(&rt2x00dev->chip) == RT2860C_VERSION) { | ||
1459 | rt2800_bbp_write(rt2x00dev, 69, 0x16); | ||
1460 | rt2800_bbp_write(rt2x00dev, 73, 0x12); | ||
1461 | } | ||
1462 | |||
1463 | if (rt2x00_rev(&rt2x00dev->chip) > RT2860D_VERSION) | ||
1464 | rt2800_bbp_write(rt2x00dev, 84, 0x19); | ||
1465 | |||
1466 | if (rt2x00_intf_is_usb(rt2x00dev) && | ||
1467 | rt2x00_rev(&rt2x00dev->chip) == RT3070_VERSION) { | ||
1468 | rt2800_bbp_write(rt2x00dev, 70, 0x0a); | ||
1469 | rt2800_bbp_write(rt2x00dev, 84, 0x99); | ||
1470 | rt2800_bbp_write(rt2x00dev, 105, 0x05); | ||
1471 | } | ||
1472 | |||
1473 | if (rt2x00_intf_is_pci(rt2x00dev) && | ||
1474 | rt2x00_rt(&rt2x00dev->chip, RT3052)) { | ||
1475 | rt2800_bbp_write(rt2x00dev, 31, 0x08); | ||
1476 | rt2800_bbp_write(rt2x00dev, 78, 0x0e); | ||
1477 | rt2800_bbp_write(rt2x00dev, 80, 0x08); | ||
1478 | } | ||
1479 | |||
1480 | for (i = 0; i < EEPROM_BBP_SIZE; i++) { | ||
1481 | rt2x00_eeprom_read(rt2x00dev, EEPROM_BBP_START + i, &eeprom); | ||
1482 | |||
1483 | if (eeprom != 0xffff && eeprom != 0x0000) { | ||
1484 | reg_id = rt2x00_get_field16(eeprom, EEPROM_BBP_REG_ID); | ||
1485 | value = rt2x00_get_field16(eeprom, EEPROM_BBP_VALUE); | ||
1486 | rt2800_bbp_write(rt2x00dev, reg_id, value); | ||
1487 | } | ||
1488 | } | ||
1489 | |||
1490 | return 0; | ||
1491 | } | ||
1492 | EXPORT_SYMBOL_GPL(rt2800_init_bbp); | ||
1493 | |||
1494 | static u8 rt2800_init_rx_filter(struct rt2x00_dev *rt2x00dev, | ||
1495 | bool bw40, u8 rfcsr24, u8 filter_target) | ||
1496 | { | ||
1497 | unsigned int i; | ||
1498 | u8 bbp; | ||
1499 | u8 rfcsr; | ||
1500 | u8 passband; | ||
1501 | u8 stopband; | ||
1502 | u8 overtuned = 0; | ||
1503 | |||
1504 | rt2800_rfcsr_write(rt2x00dev, 24, rfcsr24); | ||
1505 | |||
1506 | rt2800_bbp_read(rt2x00dev, 4, &bbp); | ||
1507 | rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 2 * bw40); | ||
1508 | rt2800_bbp_write(rt2x00dev, 4, bbp); | ||
1509 | |||
1510 | rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr); | ||
1511 | rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 1); | ||
1512 | rt2800_rfcsr_write(rt2x00dev, 22, rfcsr); | ||
1513 | |||
1514 | /* | ||
1515 | * Set power & frequency of passband test tone | ||
1516 | */ | ||
1517 | rt2800_bbp_write(rt2x00dev, 24, 0); | ||
1518 | |||
1519 | for (i = 0; i < 100; i++) { | ||
1520 | rt2800_bbp_write(rt2x00dev, 25, 0x90); | ||
1521 | msleep(1); | ||
1522 | |||
1523 | rt2800_bbp_read(rt2x00dev, 55, &passband); | ||
1524 | if (passband) | ||
1525 | break; | ||
1526 | } | ||
1527 | |||
1528 | /* | ||
1529 | * Set power & frequency of stopband test tone | ||
1530 | */ | ||
1531 | rt2800_bbp_write(rt2x00dev, 24, 0x06); | ||
1532 | |||
1533 | for (i = 0; i < 100; i++) { | ||
1534 | rt2800_bbp_write(rt2x00dev, 25, 0x90); | ||
1535 | msleep(1); | ||
1536 | |||
1537 | rt2800_bbp_read(rt2x00dev, 55, &stopband); | ||
1538 | |||
1539 | if ((passband - stopband) <= filter_target) { | ||
1540 | rfcsr24++; | ||
1541 | overtuned += ((passband - stopband) == filter_target); | ||
1542 | } else | ||
1543 | break; | ||
1544 | |||
1545 | rt2800_rfcsr_write(rt2x00dev, 24, rfcsr24); | ||
1546 | } | ||
1547 | |||
1548 | rfcsr24 -= !!overtuned; | ||
1549 | |||
1550 | rt2800_rfcsr_write(rt2x00dev, 24, rfcsr24); | ||
1551 | return rfcsr24; | ||
1552 | } | ||
1553 | |||
1554 | int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev) | ||
1555 | { | ||
1556 | u8 rfcsr; | ||
1557 | u8 bbp; | ||
1558 | |||
1559 | if (rt2x00_intf_is_usb(rt2x00dev) && | ||
1560 | rt2x00_rev(&rt2x00dev->chip) != RT3070_VERSION) | ||
1561 | return 0; | ||
1562 | |||
1563 | if (rt2x00_intf_is_pci(rt2x00dev)) { | ||
1564 | if (!rt2x00_rf(&rt2x00dev->chip, RF3020) && | ||
1565 | !rt2x00_rf(&rt2x00dev->chip, RF3021) && | ||
1566 | !rt2x00_rf(&rt2x00dev->chip, RF3022)) | ||
1567 | return 0; | ||
1568 | } | ||
1569 | |||
1570 | /* | ||
1571 | * Init RF calibration. | ||
1572 | */ | ||
1573 | rt2800_rfcsr_read(rt2x00dev, 30, &rfcsr); | ||
1574 | rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 1); | ||
1575 | rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); | ||
1576 | msleep(1); | ||
1577 | rt2x00_set_field8(&rfcsr, RFCSR30_RF_CALIBRATION, 0); | ||
1578 | rt2800_rfcsr_write(rt2x00dev, 30, rfcsr); | ||
1579 | |||
1580 | if (rt2x00_intf_is_usb(rt2x00dev)) { | ||
1581 | rt2800_rfcsr_write(rt2x00dev, 4, 0x40); | ||
1582 | rt2800_rfcsr_write(rt2x00dev, 5, 0x03); | ||
1583 | rt2800_rfcsr_write(rt2x00dev, 6, 0x02); | ||
1584 | rt2800_rfcsr_write(rt2x00dev, 7, 0x70); | ||
1585 | rt2800_rfcsr_write(rt2x00dev, 9, 0x0f); | ||
1586 | rt2800_rfcsr_write(rt2x00dev, 10, 0x71); | ||
1587 | rt2800_rfcsr_write(rt2x00dev, 11, 0x21); | ||
1588 | rt2800_rfcsr_write(rt2x00dev, 12, 0x7b); | ||
1589 | rt2800_rfcsr_write(rt2x00dev, 14, 0x90); | ||
1590 | rt2800_rfcsr_write(rt2x00dev, 15, 0x58); | ||
1591 | rt2800_rfcsr_write(rt2x00dev, 16, 0xb3); | ||
1592 | rt2800_rfcsr_write(rt2x00dev, 17, 0x92); | ||
1593 | rt2800_rfcsr_write(rt2x00dev, 18, 0x2c); | ||
1594 | rt2800_rfcsr_write(rt2x00dev, 19, 0x02); | ||
1595 | rt2800_rfcsr_write(rt2x00dev, 20, 0xba); | ||
1596 | rt2800_rfcsr_write(rt2x00dev, 21, 0xdb); | ||
1597 | rt2800_rfcsr_write(rt2x00dev, 24, 0x16); | ||
1598 | rt2800_rfcsr_write(rt2x00dev, 25, 0x01); | ||
1599 | rt2800_rfcsr_write(rt2x00dev, 27, 0x03); | ||
1600 | rt2800_rfcsr_write(rt2x00dev, 29, 0x1f); | ||
1601 | } else if (rt2x00_intf_is_pci(rt2x00dev)) { | ||
1602 | rt2800_rfcsr_write(rt2x00dev, 0, 0x50); | ||
1603 | rt2800_rfcsr_write(rt2x00dev, 1, 0x01); | ||
1604 | rt2800_rfcsr_write(rt2x00dev, 2, 0xf7); | ||
1605 | rt2800_rfcsr_write(rt2x00dev, 3, 0x75); | ||
1606 | rt2800_rfcsr_write(rt2x00dev, 4, 0x40); | ||
1607 | rt2800_rfcsr_write(rt2x00dev, 5, 0x03); | ||
1608 | rt2800_rfcsr_write(rt2x00dev, 6, 0x02); | ||
1609 | rt2800_rfcsr_write(rt2x00dev, 7, 0x50); | ||
1610 | rt2800_rfcsr_write(rt2x00dev, 8, 0x39); | ||
1611 | rt2800_rfcsr_write(rt2x00dev, 9, 0x0f); | ||
1612 | rt2800_rfcsr_write(rt2x00dev, 10, 0x60); | ||
1613 | rt2800_rfcsr_write(rt2x00dev, 11, 0x21); | ||
1614 | rt2800_rfcsr_write(rt2x00dev, 12, 0x75); | ||
1615 | rt2800_rfcsr_write(rt2x00dev, 13, 0x75); | ||
1616 | rt2800_rfcsr_write(rt2x00dev, 14, 0x90); | ||
1617 | rt2800_rfcsr_write(rt2x00dev, 15, 0x58); | ||
1618 | rt2800_rfcsr_write(rt2x00dev, 16, 0xb3); | ||
1619 | rt2800_rfcsr_write(rt2x00dev, 17, 0x92); | ||
1620 | rt2800_rfcsr_write(rt2x00dev, 18, 0x2c); | ||
1621 | rt2800_rfcsr_write(rt2x00dev, 19, 0x02); | ||
1622 | rt2800_rfcsr_write(rt2x00dev, 20, 0xba); | ||
1623 | rt2800_rfcsr_write(rt2x00dev, 21, 0xdb); | ||
1624 | rt2800_rfcsr_write(rt2x00dev, 22, 0x00); | ||
1625 | rt2800_rfcsr_write(rt2x00dev, 23, 0x31); | ||
1626 | rt2800_rfcsr_write(rt2x00dev, 24, 0x08); | ||
1627 | rt2800_rfcsr_write(rt2x00dev, 25, 0x01); | ||
1628 | rt2800_rfcsr_write(rt2x00dev, 26, 0x25); | ||
1629 | rt2800_rfcsr_write(rt2x00dev, 27, 0x23); | ||
1630 | rt2800_rfcsr_write(rt2x00dev, 28, 0x13); | ||
1631 | rt2800_rfcsr_write(rt2x00dev, 29, 0x83); | ||
1632 | } | ||
1633 | |||
1634 | /* | ||
1635 | * Set RX Filter calibration for 20MHz and 40MHz | ||
1636 | */ | ||
1637 | rt2x00dev->calibration[0] = | ||
1638 | rt2800_init_rx_filter(rt2x00dev, false, 0x07, 0x16); | ||
1639 | rt2x00dev->calibration[1] = | ||
1640 | rt2800_init_rx_filter(rt2x00dev, true, 0x27, 0x19); | ||
1641 | |||
1642 | /* | ||
1643 | * Set back to initial state | ||
1644 | */ | ||
1645 | rt2800_bbp_write(rt2x00dev, 24, 0); | ||
1646 | |||
1647 | rt2800_rfcsr_read(rt2x00dev, 22, &rfcsr); | ||
1648 | rt2x00_set_field8(&rfcsr, RFCSR22_BASEBAND_LOOPBACK, 0); | ||
1649 | rt2800_rfcsr_write(rt2x00dev, 22, rfcsr); | ||
1650 | |||
1651 | /* | ||
1652 | * set BBP back to BW20 | ||
1653 | */ | ||
1654 | rt2800_bbp_read(rt2x00dev, 4, &bbp); | ||
1655 | rt2x00_set_field8(&bbp, BBP4_BANDWIDTH, 0); | ||
1656 | rt2800_bbp_write(rt2x00dev, 4, bbp); | ||
1657 | |||
1658 | return 0; | ||
1659 | } | ||
1660 | EXPORT_SYMBOL_GPL(rt2800_init_rfcsr); | ||