rt2x00: Add dynamic detection of eFuse EEPROM in rt2800pci.
authorGertjan van Wingerde <gwingerde@gmail.com>
Sun, 8 Nov 2009 11:30:35 +0000 (12:30 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 11 Nov 2009 22:09:11 +0000 (17:09 -0500)
Instead of assuming that all rt3090 devices will have an eFuse EEPROM,
do as the legacy Ralink driver, and detect at run-time whether an
eFuse EEPROM is present.

Signed-off-by: Gertjan van Wingerde <gwingerde@gmail.com>
Acked-by: Ivo van Doorn <IvDoorn@gmail.com>
Acked-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/rt2x00/rt2800pci.c
drivers/net/wireless/rt2x00/rt2800pci.h

index bff870799f64c14638ccfb14343be9a169d197c2..2f284a6f384ec46497b4962d89a64713a52954a2 100644 (file)
@@ -145,6 +145,15 @@ static void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
                               EEPROM_SIZE / sizeof(u16));
 }
 
+static int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
+{
+       u32 reg;
+
+       rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
+
+       return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+}
+
 static void rt2800pci_efuse_read(struct rt2x00_dev *rt2x00dev,
                                 unsigned int i)
 {
@@ -182,6 +191,11 @@ static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
 {
 }
 
+static inline int rt2800pci_efuse_detect(struct rt2x00_dev *rt2x00dev)
+{
+       return 0;
+}
+
 static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
 }
@@ -1091,11 +1105,11 @@ static int rt2800pci_validate_eeprom(struct rt2x00_dev *rt2x00dev)
        case RT3052:
                rt2800pci_read_eeprom_soc(rt2x00dev);
                break;
-       case RT3090:
-               rt2800pci_read_eeprom_efuse(rt2x00dev);
-               break;
        default:
-               rt2800pci_read_eeprom_pci(rt2x00dev);
+               if (rt2800pci_efuse_detect(rt2x00dev))
+                       rt2800pci_read_eeprom_efuse(rt2x00dev);
+               else
+                       rt2800pci_read_eeprom_pci(rt2x00dev);
                break;
        }
 
index 1dbf13270cda9a5bf991067575e6940431d1b984..8f944ee8a9708ae7a684d945308732b57791e2ae 100644 (file)
@@ -62,6 +62,7 @@
 #define EFUSE_CTRL_ADDRESS_IN          FIELD32(0x03fe0000)
 #define EFUSE_CTRL_MODE                        FIELD32(0x000000c0)
 #define EFUSE_CTRL_KICK                        FIELD32(0x40000000)
+#define EFUSE_CTRL_PRESENT             FIELD32(0x80000000)
 
 /*
  * EFUSE_DATA0