rt2x00: Reorganize RT chipset setting for PCI/SOC devices.
authorGertjan van Wingerde <gwingerde@gmail.com>
Sat, 13 Feb 2010 19:55:48 +0000 (20:55 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 15 Feb 2010 21:14:10 +0000 (16:14 -0500)
Don't set the RT chipset for a device from within the generic PCI/SOC code,
but rather from the individual drivers, so that individual drivers have
more control over what RT chipset is set.
Preparation for chip handling updates for rt2800 devices.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
12 files changed:
drivers/net/wireless/rt2x00/rt2400pci.c
drivers/net/wireless/rt2x00/rt2500pci.c
drivers/net/wireless/rt2x00/rt2500usb.c
drivers/net/wireless/rt2x00/rt2800lib.c
drivers/net/wireless/rt2x00/rt2800pci.c
drivers/net/wireless/rt2x00/rt2x00.h
drivers/net/wireless/rt2x00/rt2x00pci.c
drivers/net/wireless/rt2x00/rt2x00pci.h
drivers/net/wireless/rt2x00/rt2x00soc.c
drivers/net/wireless/rt2x00/rt2x00soc.h
drivers/net/wireless/rt2x00/rt61pci.c
drivers/net/wireless/rt2x00/rt73usb.c

index 184335950825e6fade835b61f7248b7fbeeebcbd..9207b9b100b0c84848f9f340371dabe29870deba 100644 (file)
@@ -1327,6 +1327,7 @@ static int rt2400pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
+       u16 chip;
        u16 value;
        u16 eeprom;
 
@@ -1335,13 +1336,17 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
         */
        rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
 
+       /*
+        * Identify RT chipset.
+        */
+       pci_read_config_word(to_pci_dev(rt2x00dev->dev), PCI_DEVICE_ID, &chip);
+
        /*
         * Identify RF chipset.
         */
        value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
        rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
-       rt2x00_set_chip_rf(rt2x00dev, value, reg);
-       rt2x00_print_chip(rt2x00dev);
+       rt2x00_set_chip(rt2x00dev, chip, value, reg);
 
        if (!rt2x00_rf(rt2x00dev, RF2420) && !rt2x00_rf(rt2x00dev, RF2421)) {
                ERROR(rt2x00dev, "Invalid RF chipset detected.\n");
index 7dfcffadda2a7f4c49f5d6f5ccfa46b93240842d..0f6d001267ac2ba2b85fb026747f63699e3253ec 100644 (file)
@@ -1490,6 +1490,7 @@ static int rt2500pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
+       u16 chip;
        u16 value;
        u16 eeprom;
 
@@ -1498,13 +1499,17 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
         */
        rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
 
+       /*
+        * Identify RT chipset.
+        */
+       pci_read_config_word(to_pci_dev(rt2x00dev->dev), PCI_DEVICE_ID, &chip);
+
        /*
         * Identify RF chipset.
         */
        value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
        rt2x00pci_register_read(rt2x00dev, CSR0, &reg);
-       rt2x00_set_chip_rf(rt2x00dev, value, reg);
-       rt2x00_print_chip(rt2x00dev);
+       rt2x00_set_chip(rt2x00dev, chip, value, reg);
 
        if (!rt2x00_rf(rt2x00dev, RF2522) &&
            !rt2x00_rf(rt2x00dev, RF2523) &&
index 81ca4ec068dba462e3dd410f42d1791645cc04a2..99b7cb88a648dd161c9589340c4c85b6d12640d5 100644 (file)
@@ -1408,7 +1408,6 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
        value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
        rt2500usb_register_read(rt2x00dev, MAC_CSR0, &reg);
        rt2x00_set_chip(rt2x00dev, RT2570, value, reg);
-       rt2x00_print_chip(rt2x00dev);
 
        if (!rt2x00_check_rev(rt2x00dev, 0x000ffff0, 0) ||
            rt2x00_check_rev(rt2x00dev, 0x0000000f, 0)) {
index e78df53b95157aaa515b480469fb65fafe127b07..7340e487df6b1a50e58e238d1cac0ddaaab053e6 100644 (file)
@@ -40,6 +40,9 @@
 #if defined(CONFIG_RT2X00_LIB_USB) || defined(CONFIG_RT2X00_LIB_USB_MODULE)
 #include "rt2x00usb.h"
 #endif
+#if defined(CONFIG_RT2X00_LIB_PCI) || defined(CONFIG_RT2X00_LIB_PCI_MODULE)
+#include "rt2x00pci.h"
+#endif
 #include "rt2800lib.h"
 #include "rt2800.h"
 #include "rt2800usb.h"
@@ -1839,6 +1842,7 @@ EXPORT_SYMBOL_GPL(rt2800_validate_eeprom);
 int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
+       u16 chip;
        u16 value;
        u16 eeprom;
 
@@ -1853,25 +1857,40 @@ int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev)
        value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
        rt2800_register_read(rt2x00dev, MAC_CSR0, &reg);
 
-       rt2x00_set_chip_rf(rt2x00dev, value, reg);
-
-       if (rt2x00_is_usb(rt2x00dev)) {
+       if (rt2x00_is_pci(rt2x00dev)) {
+#if defined(CONFIG_RT2X00_LIB_PCI) || defined(CONFIG_RT2X00_LIB_PCI_MODULE)
+               pci_read_config_word(to_pci_dev(rt2x00dev->dev),
+                                    PCI_DEVICE_ID,
+                                    &chip);
+#else
+               BUG();
+#endif
+       } else if (rt2x00_is_usb(rt2x00dev)) {
                /*
                 * The check for rt2860 is not a typo, some rt2870 hardware
                 * identifies itself as rt2860 in the CSR register.
                 */
-               if (rt2x00_check_rev(rt2x00dev, 0xfff00000, 0x28600000) ||
-                   rt2x00_check_rev(rt2x00dev, 0xfff00000, 0x28700000) ||
-                   rt2x00_check_rev(rt2x00dev, 0xfff00000, 0x28800000)) {
-                       rt2x00_set_chip_rt(rt2x00dev, RT2870);
-               } else if (rt2x00_check_rev(rt2x00dev, 0xffff0000, 0x30700000)) {
-                       rt2x00_set_chip_rt(rt2x00dev, RT3070);
+               if (((reg & 0xfff00000) == 0x28600000) ||
+                   ((reg & 0xfff00000) == 0x28700000) ||
+                   ((reg & 0xfff00000) == 0x28800000)) {
+                       chip = RT2870;
+               } else if ((reg & 0xffff0000) == 0x30700000) {
+                       chip = RT3070;
                } else {
                        ERROR(rt2x00dev, "Invalid RT chipset detected.\n");
                        return -ENODEV;
                }
+       } else if (rt2x00_is_soc(rt2x00dev)) {
+#if defined(CONFIG_RALINK_RT288X)
+               chip = RT2880;
+#elif defined(CONFIG_RALINK_RT305X)
+               chip = RT3052;
+#else
+               BUG();
+#endif
        }
-       rt2x00_print_chip(rt2x00dev);
+
+       rt2x00_set_chip(rt2x00dev, chip, value, reg);
 
        if (!rt2x00_rf(rt2x00dev, RF2820) &&
            !rt2x00_rf(rt2x00dev, RF2850) &&
index d57531ce1f825bb4cdd0ca9ddc2214ef31cf0e47..fc351052229bea08b9d8a963c9dbb14da0abd674 100644 (file)
@@ -1219,11 +1219,10 @@ MODULE_DEVICE_TABLE(pci, rt2800pci_device_table);
 MODULE_LICENSE("GPL");
 
 #ifdef CONFIG_RT2800PCI_SOC
-#if defined(CONFIG_RALINK_RT288X)
-__rt2x00soc_probe(RT2880, &rt2800pci_ops);
-#elif defined(CONFIG_RALINK_RT305X)
-__rt2x00soc_probe(RT3052, &rt2800pci_ops);
-#endif
+static int rt2800soc_probe(struct platform_device *pdev)
+{
+       return rt2x00soc_probe(pdev, rt2800pci_ops);
+}
 
 static struct platform_driver rt2800soc_driver = {
        .driver         = {
@@ -1231,7 +1230,7 @@ static struct platform_driver rt2800soc_driver = {
                .owner          = THIS_MODULE,
                .mod_name       = KBUILD_MODNAME,
        },
-       .probe          = __rt2x00soc_probe,
+       .probe          = rt2800soc_probe,
        .remove         = __devexit_p(rt2x00soc_remove),
        .suspend        = rt2x00soc_suspend,
        .resume         = rt2x00soc_resume,
index d741367304bbc2c65742356139ed359ced3f609f..1fed90acd198e9bdc4103805459ce24cb980fc97 100644 (file)
@@ -923,22 +923,7 @@ static inline void rt2x00_set_chip(struct rt2x00_dev *rt2x00dev,
        rt2x00dev->chip.rt = rt;
        rt2x00dev->chip.rf = rf;
        rt2x00dev->chip.rev = rev;
-}
-
-static inline void rt2x00_set_chip_rt(struct rt2x00_dev *rt2x00dev,
-                                     const u16 rt)
-{
-       rt2x00dev->chip.rt = rt;
-}
 
-static inline void rt2x00_set_chip_rf(struct rt2x00_dev *rt2x00dev,
-                                     const u16 rf, const u32 rev)
-{
-       rt2x00_set_chip(rt2x00dev, rt2x00dev->chip.rt, rf, rev);
-}
-
-static inline void rt2x00_print_chip(struct rt2x00_dev *rt2x00dev)
-{
        INFO(rt2x00dev,
             "Chipset detected - rt: %04x, rf: %04x, rev: %08x.\n",
             rt2x00dev->chip.rt, rt2x00dev->chip.rf, rt2x00dev->chip.rev);
index 801be436cf1d1bf8f01f16bfd33c84a1ca72641e..047123b766fce5576bd6f1ff3d297ec87ef6767f 100644 (file)
@@ -272,7 +272,6 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
        struct ieee80211_hw *hw;
        struct rt2x00_dev *rt2x00dev;
        int retval;
-       u16 chip;
 
        retval = pci_request_regions(pci_dev, pci_name(pci_dev));
        if (retval) {
@@ -315,12 +314,6 @@ int rt2x00pci_probe(struct pci_dev *pci_dev, const struct pci_device_id *id)
 
        rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_PCI);
 
-       /*
-        * Determine RT chipset by reading PCI header.
-        */
-       pci_read_config_word(pci_dev, PCI_DEVICE_ID, &chip);
-       rt2x00_set_chip_rt(rt2x00dev, chip);
-
        retval = rt2x00pci_alloc_reg(rt2x00dev);
        if (retval)
                goto exit_free_device;
index d4f9449ab0a4e6dfabec8fd3ced904d1db98e61c..8149ff68410a5f3a7bed11c6bf72e7b201bfed48 100644 (file)
@@ -27,6 +27,7 @@
 #define RT2X00PCI_H
 
 #include <linux/io.h>
+#include <linux/pci.h>
 
 /*
  * This variable should be used with the
index 0d6b43afc4e80d81acdb46ade2ef9b69e5f18c70..4efdc96010f6f9010add0380d2eb50ddb604e7a0 100644 (file)
@@ -71,9 +71,7 @@ exit:
        return -ENOMEM;
 }
 
-int rt2x00soc_probe(struct platform_device *pdev,
-                   const unsigned short chipset,
-                   const struct rt2x00_ops *ops)
+int rt2x00soc_probe(struct platform_device *pdev, const struct rt2x00_ops *ops)
 {
        struct ieee80211_hw *hw;
        struct rt2x00_dev *rt2x00dev;
@@ -95,7 +93,6 @@ int rt2x00soc_probe(struct platform_device *pdev,
        rt2x00dev->name = pdev->dev.driver->name;
 
        rt2x00_set_chip_intf(rt2x00dev, RT2X00_CHIP_INTF_SOC);
-       rt2x00_set_chip_rt(rt2x00dev, chipset);
 
        retval = rt2x00soc_alloc_reg(rt2x00dev);
        if (retval)
index 8a3416624af597dcc3dd63dcf5a3f8e9d95ac177..4739edfe2f00e49ee9a6fe5f137ea6408fbf05f5 100644 (file)
 
 #define KSEG1ADDR(__ptr) __ptr
 
-#define __rt2x00soc_probe(__chipset, __ops) \
-static int __rt2x00soc_probe(struct platform_device *pdev) \
-{ \
-       return rt2x00soc_probe(pdev, (__chipset), (__ops)); \
-}
-
 /*
  * SoC driver handlers.
  */
-int rt2x00soc_probe(struct platform_device *pdev,
-                   const unsigned short chipset,
-                   const struct rt2x00_ops *ops);
+int rt2x00soc_probe(struct platform_device *pdev, const struct rt2x00_ops *ops);
 int rt2x00soc_remove(struct platform_device *pdev);
 #ifdef CONFIG_PM
 int rt2x00soc_suspend(struct platform_device *pdev, pm_message_t state);
index 881340026c2a5420b349d36369dbb53991bf5bd2..4ca1d48fb737336556783b8d9b2396e103e74349 100644 (file)
@@ -2282,6 +2282,7 @@ static int rt61pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
 {
        u32 reg;
+       u16 chip;
        u16 value;
        u16 eeprom;
 
@@ -2290,13 +2291,17 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev)
         */
        rt2x00_eeprom_read(rt2x00dev, EEPROM_ANTENNA, &eeprom);
 
+       /*
+        * Identify RT chipset.
+        */
+       pci_read_config_word(to_pci_dev(rt2x00dev->dev), PCI_DEVICE_ID, &chip);
+
        /*
         * Identify RF chipset.
         */
        value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
        rt2x00pci_register_read(rt2x00dev, MAC_CSR0, &reg);
-       rt2x00_set_chip_rf(rt2x00dev, value, reg);
-       rt2x00_print_chip(rt2x00dev);
+       rt2x00_set_chip(rt2x00dev, chip, value, reg);
 
        if (!rt2x00_rf(rt2x00dev, RF5225) &&
            !rt2x00_rf(rt2x00dev, RF5325) &&
index 3781eb7b4aa06ec990cdca2c8618b2f96028a584..2950ac754921056793fd4e882ab118f773cbfeb8 100644 (file)
@@ -1821,7 +1821,6 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev)
        value = rt2x00_get_field16(eeprom, EEPROM_ANTENNA_RF_TYPE);
        rt2x00usb_register_read(rt2x00dev, MAC_CSR0, &reg);
        rt2x00_set_chip(rt2x00dev, RT2571, value, reg);
-       rt2x00_print_chip(rt2x00dev);
 
        if (!rt2x00_check_rev(rt2x00dev, 0x000ffff0, 0x25730) ||
            rt2x00_check_rev(rt2x00dev, 0x0000000f, 0)) {