diff options
author | Gertjan van Wingerde <gwingerde@gmail.com> | 2010-06-03 04:52:04 -0400 |
---|---|---|
committer | Ivo van Doorn <IvDoorn@gmail.com> | 2010-06-03 04:52:04 -0400 |
commit | e3a896b9924d6dcd88ad16186d7ec77f32d12ef8 (patch) | |
tree | c1b629c50a81f005e6af11b8e32d85f632becb39 | |
parent | 8440c292798a6a7dc70356df80de84e0082bd99d (diff) |
rt2x00: Move PCI/USB specific register initializations to rt2800{pci,usb}.
This prevents us having common code depend on PCI or USB specific code.
Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Signed-off-by: Ivo van Doorn <IvDoorn@gmail.com>
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.c | 61 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800lib.h | 9 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800pci.c | 34 | ||||
-rw-r--r-- | drivers/net/wireless/rt2x00/rt2800usb.c | 40 |
4 files changed, 87 insertions, 57 deletions
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c index cf2e3b9f77f8..9aa480117172 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.c +++ b/drivers/net/wireless/rt2x00/rt2800lib.c | |||
@@ -38,12 +38,8 @@ | |||
38 | #include <linux/slab.h> | 38 | #include <linux/slab.h> |
39 | 39 | ||
40 | #include "rt2x00.h" | 40 | #include "rt2x00.h" |
41 | #if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE) | ||
42 | #include "rt2x00usb.h" | ||
43 | #endif | ||
44 | #include "rt2800lib.h" | 41 | #include "rt2800lib.h" |
45 | #include "rt2800.h" | 42 | #include "rt2800.h" |
46 | #include "rt2800usb.h" | ||
47 | 43 | ||
48 | MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); | 44 | MODULE_AUTHOR("Bartlomiej Zolnierkiewicz"); |
49 | MODULE_DESCRIPTION("rt2800 library"); | 45 | MODULE_DESCRIPTION("rt2800 library"); |
@@ -1272,6 +1268,7 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
1272 | u32 reg; | 1268 | u32 reg; |
1273 | u16 eeprom; | 1269 | u16 eeprom; |
1274 | unsigned int i; | 1270 | unsigned int i; |
1271 | int ret; | ||
1275 | 1272 | ||
1276 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); | 1273 | rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, ®); |
1277 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0); | 1274 | rt2x00_set_field32(®, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0); |
@@ -1281,59 +1278,9 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev) | |||
1281 | rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1); | 1278 | rt2x00_set_field32(®, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1); |
1282 | rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); | 1279 | rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg); |
1283 | 1280 | ||
1284 | if (rt2x00_is_usb(rt2x00dev)) { | 1281 | ret = rt2800_drv_init_registers(rt2x00dev); |
1285 | /* | 1282 | if (ret) |
1286 | * Wait until BBP and RF are ready. | 1283 | return ret; |
1287 | */ | ||
1288 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | ||
1289 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); | ||
1290 | if (reg && reg != ~0) | ||
1291 | break; | ||
1292 | msleep(1); | ||
1293 | } | ||
1294 | |||
1295 | if (i == REGISTER_BUSY_COUNT) { | ||
1296 | ERROR(rt2x00dev, "Unstable hardware.\n"); | ||
1297 | return -EBUSY; | ||
1298 | } | ||
1299 | |||
1300 | rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, ®); | ||
1301 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, | ||
1302 | reg & ~0x00002000); | ||
1303 | } else if (rt2x00_is_pci(rt2x00dev) || rt2x00_is_soc(rt2x00dev)) { | ||
1304 | /* | ||
1305 | * Reset DMA indexes | ||
1306 | */ | ||
1307 | rt2800_register_read(rt2x00dev, WPDMA_RST_IDX, ®); | ||
1308 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX0, 1); | ||
1309 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX1, 1); | ||
1310 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX2, 1); | ||
1311 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX3, 1); | ||
1312 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX4, 1); | ||
1313 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX5, 1); | ||
1314 | rt2x00_set_field32(®, WPDMA_RST_IDX_DRX_IDX0, 1); | ||
1315 | rt2800_register_write(rt2x00dev, WPDMA_RST_IDX, reg); | ||
1316 | |||
1317 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e1f); | ||
1318 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e00); | ||
1319 | |||
1320 | rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); | ||
1321 | } | ||
1322 | |||
1323 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); | ||
1324 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); | ||
1325 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); | ||
1326 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); | ||
1327 | |||
1328 | if (rt2x00_is_usb(rt2x00dev)) { | ||
1329 | rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000); | ||
1330 | #if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE) | ||
1331 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0, | ||
1332 | USB_MODE_RESET, REGISTER_TIMEOUT); | ||
1333 | #endif | ||
1334 | } | ||
1335 | |||
1336 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000); | ||
1337 | 1284 | ||
1338 | rt2800_register_read(rt2x00dev, BCN_OFFSET0, ®); | 1285 | rt2800_register_read(rt2x00dev, BCN_OFFSET0, ®); |
1339 | rt2x00_set_field32(®, BCN_OFFSET0_BCN0, 0xe0); /* 0x3800 */ | 1286 | rt2x00_set_field32(®, BCN_OFFSET0_BCN0, 0xe0); /* 0x3800 */ |
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.h b/drivers/net/wireless/rt2x00/rt2800lib.h index b16fd6d2d22c..8313dbf441a5 100644 --- a/drivers/net/wireless/rt2x00/rt2800lib.h +++ b/drivers/net/wireless/rt2x00/rt2800lib.h | |||
@@ -40,6 +40,8 @@ struct rt2800_ops { | |||
40 | int (*regbusy_read)(struct rt2x00_dev *rt2x00dev, | 40 | int (*regbusy_read)(struct rt2x00_dev *rt2x00dev, |
41 | const unsigned int offset, | 41 | const unsigned int offset, |
42 | const struct rt2x00_field32 field, u32 *reg); | 42 | const struct rt2x00_field32 field, u32 *reg); |
43 | |||
44 | int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev); | ||
43 | }; | 45 | }; |
44 | 46 | ||
45 | static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev, | 47 | static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev, |
@@ -107,6 +109,13 @@ static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev, | |||
107 | return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg); | 109 | return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg); |
108 | } | 110 | } |
109 | 111 | ||
112 | static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev) | ||
113 | { | ||
114 | const struct rt2800_ops *rt2800ops = rt2x00dev->priv; | ||
115 | |||
116 | return rt2800ops->drv_init_registers(rt2x00dev); | ||
117 | } | ||
118 | |||
110 | void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev, | 119 | void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev, |
111 | const u8 command, const u8 token, | 120 | const u8 command, const u8 token, |
112 | const u8 arg0, const u8 arg1); | 121 | const u8 arg0, const u8 arg1); |
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c index f2718367d1a0..846600f81657 100644 --- a/drivers/net/wireless/rt2x00/rt2800pci.c +++ b/drivers/net/wireless/rt2x00/rt2800pci.c | |||
@@ -446,6 +446,38 @@ static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev, | |||
446 | rt2800_register_write(rt2x00dev, INT_MASK_CSR, reg); | 446 | rt2800_register_write(rt2x00dev, INT_MASK_CSR, reg); |
447 | } | 447 | } |
448 | 448 | ||
449 | static int rt2800pci_init_registers(struct rt2x00_dev *rt2x00dev) | ||
450 | { | ||
451 | u32 reg; | ||
452 | |||
453 | /* | ||
454 | * Reset DMA indexes | ||
455 | */ | ||
456 | rt2800_register_read(rt2x00dev, WPDMA_RST_IDX, ®); | ||
457 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX0, 1); | ||
458 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX1, 1); | ||
459 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX2, 1); | ||
460 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX3, 1); | ||
461 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX4, 1); | ||
462 | rt2x00_set_field32(®, WPDMA_RST_IDX_DTX_IDX5, 1); | ||
463 | rt2x00_set_field32(®, WPDMA_RST_IDX_DRX_IDX0, 1); | ||
464 | rt2800_register_write(rt2x00dev, WPDMA_RST_IDX, reg); | ||
465 | |||
466 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e1f); | ||
467 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e00); | ||
468 | |||
469 | rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003); | ||
470 | |||
471 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); | ||
472 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); | ||
473 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); | ||
474 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); | ||
475 | |||
476 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000); | ||
477 | |||
478 | return 0; | ||
479 | } | ||
480 | |||
449 | static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev) | 481 | static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev) |
450 | { | 482 | { |
451 | u32 reg; | 483 | u32 reg; |
@@ -944,6 +976,8 @@ static const struct rt2800_ops rt2800pci_rt2800_ops = { | |||
944 | .register_multiwrite = rt2x00pci_register_multiwrite, | 976 | .register_multiwrite = rt2x00pci_register_multiwrite, |
945 | 977 | ||
946 | .regbusy_read = rt2x00pci_regbusy_read, | 978 | .regbusy_read = rt2x00pci_regbusy_read, |
979 | |||
980 | .drv_init_registers = rt2800pci_init_registers, | ||
947 | }; | 981 | }; |
948 | 982 | ||
949 | static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev) | 983 | static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev) |
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 2e584b5c8d36..3487d300e597 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -243,6 +243,44 @@ static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev, | |||
243 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); | 243 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); |
244 | } | 244 | } |
245 | 245 | ||
246 | static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev) | ||
247 | { | ||
248 | u32 reg; | ||
249 | int i; | ||
250 | |||
251 | /* | ||
252 | * Wait until BBP and RF are ready. | ||
253 | */ | ||
254 | for (i = 0; i < REGISTER_BUSY_COUNT; i++) { | ||
255 | rt2800_register_read(rt2x00dev, MAC_CSR0, ®); | ||
256 | if (reg && reg != ~0) | ||
257 | break; | ||
258 | msleep(1); | ||
259 | } | ||
260 | |||
261 | if (i == REGISTER_BUSY_COUNT) { | ||
262 | ERROR(rt2x00dev, "Unstable hardware.\n"); | ||
263 | return -EBUSY; | ||
264 | } | ||
265 | |||
266 | rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, ®); | ||
267 | rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000); | ||
268 | |||
269 | rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, ®); | ||
270 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_CSR, 1); | ||
271 | rt2x00_set_field32(®, MAC_SYS_CTRL_RESET_BBP, 1); | ||
272 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg); | ||
273 | |||
274 | rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000); | ||
275 | |||
276 | rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0, | ||
277 | USB_MODE_RESET, REGISTER_TIMEOUT); | ||
278 | |||
279 | rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000); | ||
280 | |||
281 | return 0; | ||
282 | } | ||
283 | |||
246 | static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) | 284 | static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev) |
247 | { | 285 | { |
248 | u32 reg; | 286 | u32 reg; |
@@ -549,6 +587,8 @@ static const struct rt2800_ops rt2800usb_rt2800_ops = { | |||
549 | .register_multiwrite = rt2x00usb_register_multiwrite, | 587 | .register_multiwrite = rt2x00usb_register_multiwrite, |
550 | 588 | ||
551 | .regbusy_read = rt2x00usb_regbusy_read, | 589 | .regbusy_read = rt2x00usb_regbusy_read, |
590 | |||
591 | .drv_init_registers = rt2800usb_init_registers, | ||
552 | }; | 592 | }; |
553 | 593 | ||
554 | static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) | 594 | static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev) |