]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
rt2x00: Move PCI/USB specific register initializations to rt2800{pci,usb}.
authorGertjan van Wingerde <gwingerde@gmail.com>
Thu, 3 Jun 2010 08:52:04 +0000 (10:52 +0200)
committerIvo van Doorn <IvDoorn@gmail.com>
Thu, 3 Jun 2010 08:52:04 +0000 (10:52 +0200)
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>
drivers/net/wireless/rt2x00/rt2800lib.c
drivers/net/wireless/rt2x00/rt2800lib.h
drivers/net/wireless/rt2x00/rt2800pci.c
drivers/net/wireless/rt2x00/rt2800usb.c

index cf2e3b9f77f88b2c622b4547db2373282b688e62..9aa480117172c3e2ea0dc73b82880fdc93f5659e 100644 (file)
 #include <linux/slab.h>
 
 #include "rt2x00.h"
 #include <linux/slab.h>
 
 #include "rt2x00.h"
-#if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE)
-#include "rt2x00usb.h"
-#endif
 #include "rt2800lib.h"
 #include "rt2800.h"
 #include "rt2800lib.h"
 #include "rt2800.h"
-#include "rt2800usb.h"
 
 MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
 MODULE_DESCRIPTION("rt2800 library");
 
 MODULE_AUTHOR("Bartlomiej Zolnierkiewicz");
 MODULE_DESCRIPTION("rt2800 library");
@@ -1272,6 +1268,7 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
        u32 reg;
        u16 eeprom;
        unsigned int i;
        u32 reg;
        u16 eeprom;
        unsigned int i;
+       int ret;
 
        rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
        rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
 
        rt2800_register_read(rt2x00dev, WPDMA_GLO_CFG, &reg);
        rt2x00_set_field32(&reg, WPDMA_GLO_CFG_ENABLE_TX_DMA, 0);
@@ -1281,59 +1278,9 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev)
        rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1);
        rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
 
        rt2x00_set_field32(&reg, WPDMA_GLO_CFG_TX_WRITEBACK_DONE, 1);
        rt2800_register_write(rt2x00dev, WPDMA_GLO_CFG, reg);
 
-       if (rt2x00_is_usb(rt2x00dev)) {
-               /*
-                * Wait until BBP and RF are ready.
-                */
-               for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
-                       rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
-                       if (reg && reg != ~0)
-                               break;
-                       msleep(1);
-               }
-
-               if (i == REGISTER_BUSY_COUNT) {
-                       ERROR(rt2x00dev, "Unstable hardware.\n");
-                       return -EBUSY;
-               }
-
-               rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, &reg);
-               rt2800_register_write(rt2x00dev, PBF_SYS_CTRL,
-                                     reg & ~0x00002000);
-       } else if (rt2x00_is_pci(rt2x00dev) || rt2x00_is_soc(rt2x00dev)) {
-               /*
-                * Reset DMA indexes
-                */
-               rt2800_register_read(rt2x00dev, WPDMA_RST_IDX, &reg);
-               rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX0, 1);
-               rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX1, 1);
-               rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX2, 1);
-               rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX3, 1);
-               rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX4, 1);
-               rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX5, 1);
-               rt2x00_set_field32(&reg, WPDMA_RST_IDX_DRX_IDX0, 1);
-               rt2800_register_write(rt2x00dev, WPDMA_RST_IDX, reg);
-
-               rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e1f);
-               rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e00);
-
-               rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003);
-       }
-
-       rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
-       rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_CSR, 1);
-       rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_BBP, 1);
-       rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
-
-       if (rt2x00_is_usb(rt2x00dev)) {
-               rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000);
-#if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE)
-               rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
-                                           USB_MODE_RESET, REGISTER_TIMEOUT);
-#endif
-       }
-
-       rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
+       ret = rt2800_drv_init_registers(rt2x00dev);
+       if (ret)
+               return ret;
 
        rt2800_register_read(rt2x00dev, BCN_OFFSET0, &reg);
        rt2x00_set_field32(&reg, BCN_OFFSET0_BCN0, 0xe0); /* 0x3800 */
 
        rt2800_register_read(rt2x00dev, BCN_OFFSET0, &reg);
        rt2x00_set_field32(&reg, BCN_OFFSET0_BCN0, 0xe0); /* 0x3800 */
index b16fd6d2d22c748b84f8a157e230fa8dbf0f0cde..8313dbf441a5be7aac2a59fa1ce089e90d7181e4 100644 (file)
@@ -40,6 +40,8 @@ struct rt2800_ops {
        int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,
                            const unsigned int offset,
                            const struct rt2x00_field32 field, u32 *reg);
        int (*regbusy_read)(struct rt2x00_dev *rt2x00dev,
                            const unsigned int offset,
                            const struct rt2x00_field32 field, u32 *reg);
+
+       int (*drv_init_registers)(struct rt2x00_dev *rt2x00dev);
 };
 
 static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
 };
 
 static inline void rt2800_register_read(struct rt2x00_dev *rt2x00dev,
@@ -107,6 +109,13 @@ static inline int rt2800_regbusy_read(struct rt2x00_dev *rt2x00dev,
        return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
 }
 
        return rt2800ops->regbusy_read(rt2x00dev, offset, field, reg);
 }
 
+static inline int rt2800_drv_init_registers(struct rt2x00_dev *rt2x00dev)
+{
+       const struct rt2800_ops *rt2800ops = rt2x00dev->priv;
+
+       return rt2800ops->drv_init_registers(rt2x00dev);
+}
+
 void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
                        const u8 command, const u8 token,
                        const u8 arg0, const u8 arg1);
 void rt2800_mcu_request(struct rt2x00_dev *rt2x00dev,
                        const u8 command, const u8 token,
                        const u8 arg0, const u8 arg1);
index f2718367d1a06017c5b7a866756aa930382ad22c..846600f81657763d883d004b56dbb99aa0a78ff5 100644 (file)
@@ -446,6 +446,38 @@ static void rt2800pci_toggle_irq(struct rt2x00_dev *rt2x00dev,
        rt2800_register_write(rt2x00dev, INT_MASK_CSR, reg);
 }
 
        rt2800_register_write(rt2x00dev, INT_MASK_CSR, reg);
 }
 
+static int rt2800pci_init_registers(struct rt2x00_dev *rt2x00dev)
+{
+       u32 reg;
+
+       /*
+        * Reset DMA indexes
+        */
+       rt2800_register_read(rt2x00dev, WPDMA_RST_IDX, &reg);
+       rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX0, 1);
+       rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX1, 1);
+       rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX2, 1);
+       rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX3, 1);
+       rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX4, 1);
+       rt2x00_set_field32(&reg, WPDMA_RST_IDX_DTX_IDX5, 1);
+       rt2x00_set_field32(&reg, WPDMA_RST_IDX_DRX_IDX0, 1);
+       rt2800_register_write(rt2x00dev, WPDMA_RST_IDX, reg);
+
+       rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e1f);
+       rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, 0x00000e00);
+
+       rt2800_register_write(rt2x00dev, PWR_PIN_CFG, 0x00000003);
+
+       rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
+       rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_CSR, 1);
+       rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_BBP, 1);
+       rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
+
+       rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
+
+       return 0;
+}
+
 static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
 static int rt2800pci_enable_radio(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
@@ -944,6 +976,8 @@ static const struct rt2800_ops rt2800pci_rt2800_ops = {
        .register_multiwrite    = rt2x00pci_register_multiwrite,
 
        .regbusy_read           = rt2x00pci_regbusy_read,
        .register_multiwrite    = rt2x00pci_register_multiwrite,
 
        .regbusy_read           = rt2x00pci_regbusy_read,
+
+       .drv_init_registers     = rt2800pci_init_registers,
 };
 
 static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)
 };
 
 static int rt2800pci_probe_hw(struct rt2x00_dev *rt2x00dev)
index 2e584b5c8d36a5cf4f762d7e833526c0100cd2ce..3487d300e59769e6871b928bfa1172b4c73d9e18 100644 (file)
@@ -243,6 +243,44 @@ static void rt2800usb_toggle_rx(struct rt2x00_dev *rt2x00dev,
        rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
 }
 
        rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
 }
 
+static int rt2800usb_init_registers(struct rt2x00_dev *rt2x00dev)
+{
+       u32 reg;
+       int i;
+
+       /*
+        * Wait until BBP and RF are ready.
+        */
+       for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
+               rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
+               if (reg && reg != ~0)
+                       break;
+               msleep(1);
+       }
+
+       if (i == REGISTER_BUSY_COUNT) {
+               ERROR(rt2x00dev, "Unstable hardware.\n");
+               return -EBUSY;
+       }
+
+       rt2800_register_read(rt2x00dev, PBF_SYS_CTRL, &reg);
+       rt2800_register_write(rt2x00dev, PBF_SYS_CTRL, reg & ~0x00002000);
+
+       rt2800_register_read(rt2x00dev, MAC_SYS_CTRL, &reg);
+       rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_CSR, 1);
+       rt2x00_set_field32(&reg, MAC_SYS_CTRL_RESET_BBP, 1);
+       rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, reg);
+
+       rt2800_register_write(rt2x00dev, USB_DMA_CFG, 0x00000000);
+
+       rt2x00usb_vendor_request_sw(rt2x00dev, USB_DEVICE_MODE, 0,
+                                   USB_MODE_RESET, REGISTER_TIMEOUT);
+
+       rt2800_register_write(rt2x00dev, MAC_SYS_CTRL, 0x00000000);
+
+       return 0;
+}
+
 static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
 static int rt2800usb_enable_radio(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
@@ -549,6 +587,8 @@ static const struct rt2800_ops rt2800usb_rt2800_ops = {
        .register_multiwrite    = rt2x00usb_register_multiwrite,
 
        .regbusy_read           = rt2x00usb_regbusy_read,
        .register_multiwrite    = rt2x00usb_register_multiwrite,
 
        .regbusy_read           = rt2x00usb_regbusy_read,
+
+       .drv_init_registers     = rt2800usb_init_registers,
 };
 
 static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)
 };
 
 static int rt2800usb_probe_hw(struct rt2x00_dev *rt2x00dev)