]> git.karo-electronics.de Git - linux-beck.git/commitdiff
wl1251: introduce wl1251_if_operations struct
authorBob Copeland <me@bobcopeland.com>
Fri, 7 Aug 2009 10:33:11 +0000 (13:33 +0300)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 14 Aug 2009 13:13:37 +0000 (09:13 -0400)
Introduce an ops struct with read, write, and reset functions to
abstract away the details of the wl1251 bus interface.  Doing this
will allow SDIO to coexist with SPI by supplying its own I/O
routines.

Signed-off-by: Bob Copeland <me@bobcopeland.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_io.c
drivers/net/wireless/wl12xx/wl1251_io.h
drivers/net/wireless/wl12xx/wl1251_main.c
drivers/net/wireless/wl12xx/wl1251_ops.c
drivers/net/wireless/wl12xx/wl1251_spi.c
drivers/net/wireless/wl12xx/wl1251_spi.h

index 665aca02bea9e376c05a839bdd8a07eec5d20d08..284bb508c87b3cf6b404fcebc03c7eb601b42088 100644 (file)
@@ -281,11 +281,18 @@ struct wl1251_debugfs {
        struct dentry *excessive_retries;
 };
 
+struct wl1251_if_operations {
+       void (*read)(struct wl1251 *wl, int addr, void *buf, size_t len);
+       void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len);
+       void (*reset)(struct wl1251 *wl);
+};
+
 struct wl1251 {
        struct ieee80211_hw *hw;
        bool mac80211_registered;
 
        struct spi_device *spi;
+       struct wl1251_if_operations *if_ops;
 
        void (*set_power)(bool enable);
        int irq;
index 5702398de16af65a0f4f8308c49395dd0ae6ce1e..5c6f32757ac421d67baef21f342440d9dcecf582 100644 (file)
@@ -26,6 +26,7 @@
 #include "reg.h"
 #include "wl1251_boot.h"
 #include "wl1251_io.h"
+#include "wl1251_spi.h"
 #include "wl1251_event.h"
 
 static void wl1251_boot_enable_interrupts(struct wl1251 *wl)
index 1fa26749af3286f81875b55cb58c3fbba2e8e3a6..bc957858b9f6d22269ce74684fe596d31aa3dc32 100644 (file)
@@ -53,7 +53,7 @@ void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len)
 
        physical = wl1251_translate_mem_addr(wl, addr);
 
-       wl1251_spi_read(wl, physical, buf, len);
+       wl->if_ops->read(wl, physical, buf, len);
 }
 
 void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len)
@@ -62,7 +62,7 @@ void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len)
 
        physical = wl1251_translate_mem_addr(wl, addr);
 
-       wl1251_spi_write(wl, physical, buf, len);
+       wl->if_ops->write(wl, physical, buf, len);
 }
 
 u32 wl1251_mem_read32(struct wl1251 *wl, int addr)
index e2bb9546fa68cda39799e7bed59fa90034a630a9..1fa2ab18a9e180c0d80fb3cdf4ba0cb9a7218ff5 100644 (file)
 #define __WL1251_IO_H__
 
 #include "wl1251.h"
-#include "wl1251_spi.h"
-
-/* Raw target IO, address is not translated */
-void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, size_t len);
-void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len);
 
 static inline u32 wl1251_read32(struct wl1251 *wl, int addr)
 {
        u32 response;
 
-       wl1251_spi_read(wl, addr, &response, sizeof(u32));
+       wl->if_ops->read(wl, addr, &response, sizeof(u32));
 
        return response;
 }
 
 static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val)
 {
-       wl1251_spi_write(wl, addr, &val, sizeof(u32));
+       wl->if_ops->write(wl, addr, &val, sizeof(u32));
 }
 
 /* Memory target IO, address is translated to partition 0 */
index 953cdb4fd38f6b264894e9ec0bc64ccf95f0c2bd..0f30d0a62aa9acc3d87dde6da49f337259fe1ad2 100644 (file)
@@ -168,8 +168,7 @@ static int wl1251_chip_wakeup(struct wl1251 *wl)
 
        wl1251_power_on(wl);
        msleep(wl->chip.power_on_sleep);
-       wl1251_spi_reset(wl);
-       wl1251_spi_init(wl);
+       wl->if_ops->reset(wl);
 
        /* We don't need a real memory partition here, because we only want
         * to use the registers at this point. */
@@ -1192,6 +1191,8 @@ static int wl1251_init_ieee80211(struct wl1251 *wl)
        return 0;
 }
 
+extern struct wl1251_if_operations wl1251_spi_ops;
+
 #define WL1251_DEFAULT_CHANNEL 1
 static int __devinit wl1251_probe(struct spi_device *spi)
 {
@@ -1219,6 +1220,7 @@ static int __devinit wl1251_probe(struct spi_device *spi)
        wl->hw = hw;
        dev_set_drvdata(&spi->dev, wl);
        wl->spi = spi;
+       wl->if_ops = &wl1251_spi_ops;
 
        wl->data_in_count = 0;
 
index 506123f1c8f5b68693b29fa148e43e0eb818a559..758280af10d43632b7d399474e0c03e08f43cbf2 100644 (file)
@@ -27,6 +27,7 @@
 #include "wl1251_ops.h"
 #include "reg.h"
 #include "wl1251_io.h"
+#include "wl1251_spi.h"
 #include "wl1251_boot.h"
 #include "wl1251_event.h"
 #include "wl1251_acx.h"
index 031a3bac95e561eb44d3b6c2429b86b9d0940c72..61a0852b4ee7b08719a46b7b6c030b7e8d60d4b7 100644 (file)
@@ -29,7 +29,7 @@
 #include "reg.h"
 #include "wl1251_spi.h"
 
-void wl1251_spi_reset(struct wl1251 *wl)
+static void wl1251_spi_reset(struct wl1251 *wl)
 {
        u8 *cmd;
        struct spi_transfer t;
@@ -55,7 +55,7 @@ void wl1251_spi_reset(struct wl1251 *wl)
        wl1251_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN);
 }
 
-void wl1251_spi_init(struct wl1251 *wl)
+static void wl1251_spi_init(struct wl1251 *wl)
 {
        u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd;
        struct spi_transfer t;
@@ -109,6 +109,13 @@ void wl1251_spi_init(struct wl1251 *wl)
        wl1251_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN);
 }
 
+static void wl1251_spi_reset_wake(struct wl1251 *wl)
+{
+       wl1251_spi_reset(wl);
+       wl1251_spi_init(wl);
+}
+
+
 /* Set the SPI partitions to access the chip addresses
  *
  * There are two VIRTUAL (SPI) partitions (the memory partition and the
@@ -232,7 +239,8 @@ int wl1251_set_partition(struct wl1251 *wl,
        return 0;
 }
 
-void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, size_t len)
+static void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf,
+                           size_t len)
 {
        struct spi_transfer t[3];
        struct spi_message m;
@@ -271,7 +279,8 @@ void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, size_t len)
        wl1251_dump(DEBUG_SPI, "spi_read buf <- ", buf, len);
 }
 
-void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len)
+static void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf,
+                            size_t len)
 {
        struct spi_transfer t[2];
        struct spi_message m;
@@ -300,3 +309,9 @@ void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len)
        wl1251_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd));
        wl1251_dump(DEBUG_SPI, "spi_write buf -> ", buf, len);
 }
+
+const struct wl1251_if_operations wl1251_spi_ops = {
+       .read = wl1251_spi_read,
+       .write = wl1251_spi_write,
+       .reset = wl1251_spi_reset_wake,
+};
index ca9a85118ec5cb016bbc395ec1f48ee80d6201ea..7c6da21cb00bc2a93f35eb874f333e0c9ade7a00 100644 (file)
@@ -69,9 +69,6 @@
                ((WL1251_BUSY_WORD_LEN - 4) / sizeof(u32))
 #define HW_ACCESS_WSPI_INIT_CMD_MASK  0
 
-/* INIT and RESET words */
-void wl1251_spi_reset(struct wl1251 *wl);
-void wl1251_spi_init(struct wl1251 *wl);
 int wl1251_set_partition(struct wl1251 *wl,
                         u32 part_start, u32 part_size,
                         u32 reg_start,  u32 reg_size);