wl1251: add NVS in EEPROM support
authorDavid-John Willis <John.Willis@Distant-earth.com>
Tue, 17 Nov 2009 16:50:09 +0000 (18:50 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Wed, 18 Nov 2009 22:09:24 +0000 (17:09 -0500)
wl1251 supports also that NVS is stored in a separate EEPROM, add support
for that.

kvalo: use platform data instead Kconfig and use kernel style

Signed-off-by: David-John Willis <John.Willis@Distant-earth.com>
Signed-off-by: Kalle Valo <kalle.valo@nokia.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/wl12xx/wl1251.h
drivers/net/wireless/wl12xx/wl1251_boot.c
drivers/net/wireless/wl12xx/wl1251_reg.h
drivers/net/wireless/wl12xx/wl1251_spi.c
include/linux/spi/wl12xx.h

index a839466664f0884deecd122703b9c624e0eff530..054533f7a12432554b424156ad4d2a436badca1f 100644 (file)
@@ -269,6 +269,7 @@ struct wl1251 {
 
        void (*set_power)(bool enable);
        int irq;
+       bool use_eeprom;
 
        enum wl1251_state state;
        struct mutex mutex;
index 5094f24ad034a16532868ed0aa70d3bf09c70f24..2e733e7bdfd41453f77f3a607e0e7cc2da3bee4c 100644 (file)
@@ -494,13 +494,19 @@ int wl1251_boot(struct wl1251 *wl)
                goto out;
 
        /* 2. start processing NVS file */
-       ret = wl1251_boot_upload_nvs(wl);
-       if (ret < 0)
-               goto out;
-
-       /* write firmware's last address (ie. it's length) to
-        * ACX_EEPROMLESS_IND_REG */
-       wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, wl->fw_len);
+       if (wl->use_eeprom) {
+               wl1251_reg_write32(wl, ACX_REG_EE_START, START_EEPROM_MGR);
+               msleep(4000);
+               wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, USE_EEPROM);
+       } else {
+               ret = wl1251_boot_upload_nvs(wl);
+               if (ret < 0)
+                       goto out;
+
+               /* write firmware's last address (ie. it's length) to
+                * ACX_EEPROMLESS_IND_REG */
+               wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, wl->fw_len);
+       }
 
        /* 6. read the EEPROM parameters */
        tmp = wl1251_reg_read32(wl, SCR_PAD2);
index 06e1bd94a7393a430028c8afb2b7f5387db2652a..0ca3b4326056896f5c3e970df26afb44a4ffe58e 100644 (file)
@@ -370,6 +370,7 @@ enum wl12xx_acx_int_reg {
  EEPROM location specified in the EE_ADDR register.
  The Wlan hardware hardware clears this bit automatically.
 *===============================================*/
+#define EE_CTL                              (REGISTERS_BASE + 0x2000)
 #define ACX_EE_CTL_REG                      EE_CTL
 #define EE_WRITE                            0x00000001ul
 #define EE_READ                             0x00000002ul
@@ -380,6 +381,7 @@ enum wl12xx_acx_int_reg {
   This register specifies the address
   within the EEPROM from/to which to read/write data.
   ===============================================*/
+#define EE_ADDR                             (REGISTERS_BASE + 0x2008)
 #define ACX_EE_ADDR_REG                     EE_ADDR
 
 /*===============================================
@@ -389,8 +391,12 @@ enum wl12xx_acx_int_reg {
   data from the EEPROM or the write data
   to be written to the EEPROM.
   ===============================================*/
+#define EE_DATA                             (REGISTERS_BASE + 0x2004)
 #define ACX_EE_DATA_REG                     EE_DATA
 
+#define EEPROM_ACCESS_TO                    10000   /* timeout counter */
+#define START_EEPROM_MGR                    0x00000001
+
 /*===============================================
   EEPROM Base Address  - 32bit RW
   ------------------------------------------
index 2cf8a2169d4321781539e9a337eb82fb22885388..9cc8c323830fdf8a34f5bf49cd7c43206fd523ea 100644 (file)
@@ -270,6 +270,8 @@ static int __devinit wl1251_spi_probe(struct spi_device *spi)
                return -ENODEV;
        }
 
+       wl->use_eeprom = pdata->use_eeprom;
+
        ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl);
        if (ret < 0) {
                wl1251_error("request_irq() failed: %d", ret);
index 11430cab2aad71242946ebfc7c0ce778d8bf26a1..aed64ed3dc8a4f2d32839c34a442217dea4bc81b 100644 (file)
@@ -26,6 +26,7 @@
 
 struct wl12xx_platform_data {
        void (*set_power)(bool enable);
+       bool use_eeprom;
 };
 
 #endif