rt2800: add eFuse EEPROM support code to rt2800lib
authorBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Sun, 8 Nov 2009 13:39:48 +0000 (14:39 +0100)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 11 Nov 2009 22:09:16 +0000 (17:09 -0500)
eFuse EEPROM is used also by USB chips (i.e. RT3070)
so move the needed code from rt2800pci to rt2800lib.

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

index d9b6a72e6d27d1edcb46aa6f1346b5590b4e4dd2..74fb5253ee23f8426debe750f03e3f0921d5dcef 100644 (file)
 #define RF_CSR_CFG_WRITE               FIELD32(0x00010000)
 #define RF_CSR_CFG_BUSY                        FIELD32(0x00020000)
 
+/*
+ * EFUSE_CSR: RT30x0 EEPROM
+ */
+#define EFUSE_CTRL                     0x0580
+#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
+ */
+#define EFUSE_DATA0                    0x0590
+
+/*
+ * EFUSE_DATA1
+ */
+#define EFUSE_DATA1                    0x0594
+
+/*
+ * EFUSE_DATA2
+ */
+#define EFUSE_DATA2                    0x0598
+
+/*
+ * EFUSE_DATA3
+ */
+#define EFUSE_DATA3                    0x059c
+
 /*
  * MAC Control/Status Registers(CSR).
  * Some values are set in TU, whereas 1 TU == 1024 us.
index d7771eaee04960fcf8bb5c8ebd98b27aaa710a47..f207e9fa5b9849fe5766549335dd257f5bdc0f48 100644 (file)
@@ -1659,6 +1659,49 @@ int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev)
 }
 EXPORT_SYMBOL_GPL(rt2800_init_rfcsr);
 
+int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev)
+{
+       u32 reg;
+
+       rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
+
+       return rt2x00_get_field32(reg, EFUSE_CTRL_PRESENT);
+}
+EXPORT_SYMBOL_GPL(rt2800_efuse_detect);
+
+static void rt2800_efuse_read(struct rt2x00_dev *rt2x00dev, unsigned int i)
+{
+       u32 reg;
+
+       rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
+       rt2x00_set_field32(&reg, EFUSE_CTRL_ADDRESS_IN, i);
+       rt2x00_set_field32(&reg, EFUSE_CTRL_MODE, 0);
+       rt2x00_set_field32(&reg, EFUSE_CTRL_KICK, 1);
+       rt2800_register_write(rt2x00dev, EFUSE_CTRL, reg);
+
+       /* Wait until the EEPROM has been loaded */
+       rt2800_regbusy_read(rt2x00dev, EFUSE_CTRL, EFUSE_CTRL_KICK, &reg);
+
+       /* Apparently the data is read from end to start */
+       rt2800_register_read(rt2x00dev, EFUSE_DATA3,
+                               (u32 *)&rt2x00dev->eeprom[i]);
+       rt2800_register_read(rt2x00dev, EFUSE_DATA2,
+                               (u32 *)&rt2x00dev->eeprom[i + 2]);
+       rt2800_register_read(rt2x00dev, EFUSE_DATA1,
+                               (u32 *)&rt2x00dev->eeprom[i + 4]);
+       rt2800_register_read(rt2x00dev, EFUSE_DATA0,
+                               (u32 *)&rt2x00dev->eeprom[i + 6]);
+}
+
+void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+{
+       unsigned int i;
+
+       for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
+               rt2800_efuse_read(rt2x00dev, i);
+}
+EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse);
+
 int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev)
 {
        u16 word;
index 2aa15f2b2c5d461482c57dbb59962caa5b118a83..7c790118999bf632eefa44946c45c7e4d79aee7b 100644 (file)
@@ -129,6 +129,8 @@ int rt2800_init_registers(struct rt2x00_dev *rt2x00dev);
 int rt2800_init_bbp(struct rt2x00_dev *rt2x00dev);
 int rt2800_init_rfcsr(struct rt2x00_dev *rt2x00dev);
 
+int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
+void rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
 int rt2800_validate_eeprom(struct rt2x00_dev *rt2x00dev);
 int rt2800_init_eeprom(struct rt2x00_dev *rt2x00dev);
 int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev);
index e8fe2eabebbdce42d2d7c9f4f9fe5e94b8297969..6f151d0c6b026907c0791de0e9efb8e1edf66886 100644 (file)
@@ -147,44 +147,12 @@ static void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
 
 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);
+       return rt2800_efuse_detect(rt2x00dev);
 }
 
-static void rt2800pci_efuse_read(struct rt2x00_dev *rt2x00dev,
-                                unsigned int i)
-{
-       u32 reg;
-
-       rt2800_register_read(rt2x00dev, EFUSE_CTRL, &reg);
-       rt2x00_set_field32(&reg, EFUSE_CTRL_ADDRESS_IN, i);
-       rt2x00_set_field32(&reg, EFUSE_CTRL_MODE, 0);
-       rt2x00_set_field32(&reg, EFUSE_CTRL_KICK, 1);
-       rt2800_register_write(rt2x00dev, EFUSE_CTRL, reg);
-
-       /* Wait until the EEPROM has been loaded */
-       rt2800_regbusy_read(rt2x00dev, EFUSE_CTRL, EFUSE_CTRL_KICK, &reg);
-
-       /* Apparently the data is read from end to start */
-       rt2800_register_read(rt2x00dev, EFUSE_DATA3,
-                               (u32 *)&rt2x00dev->eeprom[i]);
-       rt2800_register_read(rt2x00dev, EFUSE_DATA2,
-                               (u32 *)&rt2x00dev->eeprom[i + 2]);
-       rt2800_register_read(rt2x00dev, EFUSE_DATA1,
-                               (u32 *)&rt2x00dev->eeprom[i + 4]);
-       rt2800_register_read(rt2x00dev, EFUSE_DATA0,
-                               (u32 *)&rt2x00dev->eeprom[i + 6]);
-}
-
-static void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
+static inline void rt2800pci_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
 {
-       unsigned int i;
-
-       for (i = 0; i < EEPROM_SIZE / sizeof(u16); i += 8)
-               rt2800pci_efuse_read(rt2x00dev, i);
+       rt2800_read_eeprom_efuse(rt2x00dev);
 }
 #else
 static inline void rt2800pci_read_eeprom_pci(struct rt2x00_dev *rt2x00dev)
index 8f944ee8a9708ae7a684d945308732b57791e2ae..b866dd01f2865a84076796b327199b4351eea261 100644 (file)
 #define TX_CTX_IDX(__x)                        TX_CTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET)
 #define TX_DTX_IDX(__x)                        TX_DTX_IDX0 + ((__x) * TX_QUEUE_REG_OFFSET)
 
-/*
- * EFUSE_CSR: RT3090 EEPROM
- */
-#define EFUSE_CTRL                     0x0580
-#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
- */
-#define EFUSE_DATA0                    0x0590
-
-/*
- * EFUSE_DATA1
- */
-#define EFUSE_DATA1                    0x0594
-
-/*
- * EFUSE_DATA2
- */
-#define EFUSE_DATA2                    0x0598
-
-/*
- * EFUSE_DATA3
- */
-#define EFUSE_DATA3                    0x059c
-
 /*
  * 8051 firmware image.
  */