aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorBob Copeland <me@bobcopeland.com>2009-08-07 06:33:11 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-08-14 09:13:37 -0400
commit08d9f57251841e4870cfd286e867ffcbef81d9a4 (patch)
tree98cff0725677bd4126b9e4fb0a095fe1be83741e /drivers/net
parent6c766f413c81d5a11588552934fa093eab6ae06e (diff)
wl1251: introduce wl1251_if_operations struct
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>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/wl12xx/wl1251.h7
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_boot.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_io.c4
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_io.h9
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_main.c6
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_ops.c1
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_spi.c23
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_spi.h3
8 files changed, 36 insertions, 18 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1251.h b/drivers/net/wireless/wl12xx/wl1251.h
index 665aca02bea9..284bb508c87b 100644
--- a/drivers/net/wireless/wl12xx/wl1251.h
+++ b/drivers/net/wireless/wl12xx/wl1251.h
@@ -281,11 +281,18 @@ struct wl1251_debugfs {
281 struct dentry *excessive_retries; 281 struct dentry *excessive_retries;
282}; 282};
283 283
284struct wl1251_if_operations {
285 void (*read)(struct wl1251 *wl, int addr, void *buf, size_t len);
286 void (*write)(struct wl1251 *wl, int addr, void *buf, size_t len);
287 void (*reset)(struct wl1251 *wl);
288};
289
284struct wl1251 { 290struct wl1251 {
285 struct ieee80211_hw *hw; 291 struct ieee80211_hw *hw;
286 bool mac80211_registered; 292 bool mac80211_registered;
287 293
288 struct spi_device *spi; 294 struct spi_device *spi;
295 struct wl1251_if_operations *if_ops;
289 296
290 void (*set_power)(bool enable); 297 void (*set_power)(bool enable);
291 int irq; 298 int irq;
diff --git a/drivers/net/wireless/wl12xx/wl1251_boot.c b/drivers/net/wireless/wl12xx/wl1251_boot.c
index 5702398de16a..5c6f32757ac4 100644
--- a/drivers/net/wireless/wl12xx/wl1251_boot.c
+++ b/drivers/net/wireless/wl12xx/wl1251_boot.c
@@ -26,6 +26,7 @@
26#include "reg.h" 26#include "reg.h"
27#include "wl1251_boot.h" 27#include "wl1251_boot.h"
28#include "wl1251_io.h" 28#include "wl1251_io.h"
29#include "wl1251_spi.h"
29#include "wl1251_event.h" 30#include "wl1251_event.h"
30 31
31static void wl1251_boot_enable_interrupts(struct wl1251 *wl) 32static void wl1251_boot_enable_interrupts(struct wl1251 *wl)
diff --git a/drivers/net/wireless/wl12xx/wl1251_io.c b/drivers/net/wireless/wl12xx/wl1251_io.c
index 1fa26749af32..bc957858b9f6 100644
--- a/drivers/net/wireless/wl12xx/wl1251_io.c
+++ b/drivers/net/wireless/wl12xx/wl1251_io.c
@@ -53,7 +53,7 @@ void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len)
53 53
54 physical = wl1251_translate_mem_addr(wl, addr); 54 physical = wl1251_translate_mem_addr(wl, addr);
55 55
56 wl1251_spi_read(wl, physical, buf, len); 56 wl->if_ops->read(wl, physical, buf, len);
57} 57}
58 58
59void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len) 59void 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)
62 62
63 physical = wl1251_translate_mem_addr(wl, addr); 63 physical = wl1251_translate_mem_addr(wl, addr);
64 64
65 wl1251_spi_write(wl, physical, buf, len); 65 wl->if_ops->write(wl, physical, buf, len);
66} 66}
67 67
68u32 wl1251_mem_read32(struct wl1251 *wl, int addr) 68u32 wl1251_mem_read32(struct wl1251 *wl, int addr)
diff --git a/drivers/net/wireless/wl12xx/wl1251_io.h b/drivers/net/wireless/wl12xx/wl1251_io.h
index e2bb9546fa68..1fa2ab18a9e1 100644
--- a/drivers/net/wireless/wl12xx/wl1251_io.h
+++ b/drivers/net/wireless/wl12xx/wl1251_io.h
@@ -22,24 +22,19 @@
22#define __WL1251_IO_H__ 22#define __WL1251_IO_H__
23 23
24#include "wl1251.h" 24#include "wl1251.h"
25#include "wl1251_spi.h"
26
27/* Raw target IO, address is not translated */
28void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, size_t len);
29void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len);
30 25
31static inline u32 wl1251_read32(struct wl1251 *wl, int addr) 26static inline u32 wl1251_read32(struct wl1251 *wl, int addr)
32{ 27{
33 u32 response; 28 u32 response;
34 29
35 wl1251_spi_read(wl, addr, &response, sizeof(u32)); 30 wl->if_ops->read(wl, addr, &response, sizeof(u32));
36 31
37 return response; 32 return response;
38} 33}
39 34
40static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val) 35static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val)
41{ 36{
42 wl1251_spi_write(wl, addr, &val, sizeof(u32)); 37 wl->if_ops->write(wl, addr, &val, sizeof(u32));
43} 38}
44 39
45/* Memory target IO, address is translated to partition 0 */ 40/* Memory target IO, address is translated to partition 0 */
diff --git a/drivers/net/wireless/wl12xx/wl1251_main.c b/drivers/net/wireless/wl12xx/wl1251_main.c
index 953cdb4fd38f..0f30d0a62aa9 100644
--- a/drivers/net/wireless/wl12xx/wl1251_main.c
+++ b/drivers/net/wireless/wl12xx/wl1251_main.c
@@ -168,8 +168,7 @@ static int wl1251_chip_wakeup(struct wl1251 *wl)
168 168
169 wl1251_power_on(wl); 169 wl1251_power_on(wl);
170 msleep(wl->chip.power_on_sleep); 170 msleep(wl->chip.power_on_sleep);
171 wl1251_spi_reset(wl); 171 wl->if_ops->reset(wl);
172 wl1251_spi_init(wl);
173 172
174 /* We don't need a real memory partition here, because we only want 173 /* We don't need a real memory partition here, because we only want
175 * to use the registers at this point. */ 174 * to use the registers at this point. */
@@ -1192,6 +1191,8 @@ static int wl1251_init_ieee80211(struct wl1251 *wl)
1192 return 0; 1191 return 0;
1193} 1192}
1194 1193
1194extern struct wl1251_if_operations wl1251_spi_ops;
1195
1195#define WL1251_DEFAULT_CHANNEL 1 1196#define WL1251_DEFAULT_CHANNEL 1
1196static int __devinit wl1251_probe(struct spi_device *spi) 1197static int __devinit wl1251_probe(struct spi_device *spi)
1197{ 1198{
@@ -1219,6 +1220,7 @@ static int __devinit wl1251_probe(struct spi_device *spi)
1219 wl->hw = hw; 1220 wl->hw = hw;
1220 dev_set_drvdata(&spi->dev, wl); 1221 dev_set_drvdata(&spi->dev, wl);
1221 wl->spi = spi; 1222 wl->spi = spi;
1223 wl->if_ops = &wl1251_spi_ops;
1222 1224
1223 wl->data_in_count = 0; 1225 wl->data_in_count = 0;
1224 1226
diff --git a/drivers/net/wireless/wl12xx/wl1251_ops.c b/drivers/net/wireless/wl12xx/wl1251_ops.c
index 506123f1c8f5..758280af10d4 100644
--- a/drivers/net/wireless/wl12xx/wl1251_ops.c
+++ b/drivers/net/wireless/wl12xx/wl1251_ops.c
@@ -27,6 +27,7 @@
27#include "wl1251_ops.h" 27#include "wl1251_ops.h"
28#include "reg.h" 28#include "reg.h"
29#include "wl1251_io.h" 29#include "wl1251_io.h"
30#include "wl1251_spi.h"
30#include "wl1251_boot.h" 31#include "wl1251_boot.h"
31#include "wl1251_event.h" 32#include "wl1251_event.h"
32#include "wl1251_acx.h" 33#include "wl1251_acx.h"
diff --git a/drivers/net/wireless/wl12xx/wl1251_spi.c b/drivers/net/wireless/wl12xx/wl1251_spi.c
index 031a3bac95e5..61a0852b4ee7 100644
--- a/drivers/net/wireless/wl12xx/wl1251_spi.c
+++ b/drivers/net/wireless/wl12xx/wl1251_spi.c
@@ -29,7 +29,7 @@
29#include "reg.h" 29#include "reg.h"
30#include "wl1251_spi.h" 30#include "wl1251_spi.h"
31 31
32void wl1251_spi_reset(struct wl1251 *wl) 32static void wl1251_spi_reset(struct wl1251 *wl)
33{ 33{
34 u8 *cmd; 34 u8 *cmd;
35 struct spi_transfer t; 35 struct spi_transfer t;
@@ -55,7 +55,7 @@ void wl1251_spi_reset(struct wl1251 *wl)
55 wl1251_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); 55 wl1251_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN);
56} 56}
57 57
58void wl1251_spi_init(struct wl1251 *wl) 58static void wl1251_spi_init(struct wl1251 *wl)
59{ 59{
60 u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; 60 u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd;
61 struct spi_transfer t; 61 struct spi_transfer t;
@@ -109,6 +109,13 @@ void wl1251_spi_init(struct wl1251 *wl)
109 wl1251_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); 109 wl1251_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN);
110} 110}
111 111
112static void wl1251_spi_reset_wake(struct wl1251 *wl)
113{
114 wl1251_spi_reset(wl);
115 wl1251_spi_init(wl);
116}
117
118
112/* Set the SPI partitions to access the chip addresses 119/* Set the SPI partitions to access the chip addresses
113 * 120 *
114 * There are two VIRTUAL (SPI) partitions (the memory partition and the 121 * There are two VIRTUAL (SPI) partitions (the memory partition and the
@@ -232,7 +239,8 @@ int wl1251_set_partition(struct wl1251 *wl,
232 return 0; 239 return 0;
233} 240}
234 241
235void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, size_t len) 242static void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf,
243 size_t len)
236{ 244{
237 struct spi_transfer t[3]; 245 struct spi_transfer t[3];
238 struct spi_message m; 246 struct spi_message m;
@@ -271,7 +279,8 @@ void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, size_t len)
271 wl1251_dump(DEBUG_SPI, "spi_read buf <- ", buf, len); 279 wl1251_dump(DEBUG_SPI, "spi_read buf <- ", buf, len);
272} 280}
273 281
274void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len) 282static void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf,
283 size_t len)
275{ 284{
276 struct spi_transfer t[2]; 285 struct spi_transfer t[2];
277 struct spi_message m; 286 struct spi_message m;
@@ -300,3 +309,9 @@ void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len)
300 wl1251_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); 309 wl1251_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd));
301 wl1251_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); 310 wl1251_dump(DEBUG_SPI, "spi_write buf -> ", buf, len);
302} 311}
312
313const struct wl1251_if_operations wl1251_spi_ops = {
314 .read = wl1251_spi_read,
315 .write = wl1251_spi_write,
316 .reset = wl1251_spi_reset_wake,
317};
diff --git a/drivers/net/wireless/wl12xx/wl1251_spi.h b/drivers/net/wireless/wl12xx/wl1251_spi.h
index ca9a85118ec5..7c6da21cb00b 100644
--- a/drivers/net/wireless/wl12xx/wl1251_spi.h
+++ b/drivers/net/wireless/wl12xx/wl1251_spi.h
@@ -69,9 +69,6 @@
69 ((WL1251_BUSY_WORD_LEN - 4) / sizeof(u32)) 69 ((WL1251_BUSY_WORD_LEN - 4) / sizeof(u32))
70#define HW_ACCESS_WSPI_INIT_CMD_MASK 0 70#define HW_ACCESS_WSPI_INIT_CMD_MASK 0
71 71
72/* INIT and RESET words */
73void wl1251_spi_reset(struct wl1251 *wl);
74void wl1251_spi_init(struct wl1251 *wl);
75int wl1251_set_partition(struct wl1251 *wl, 72int wl1251_set_partition(struct wl1251 *wl,
76 u32 part_start, u32 part_size, 73 u32 part_start, u32 part_size,
77 u32 reg_start, u32 reg_size); 74 u32 reg_start, u32 reg_size);