aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1271_spi.c
diff options
context:
space:
mode:
authorTeemu Paasikivi <ext-teemu.3.paasikivi@nokia.com>2010-02-22 01:38:23 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-03-09 15:02:57 -0500
commit8197b7118add28f9aaa99c1fb73c0e201c8cde52 (patch)
treece6c7c4cb5cdb8113b19d17b98d04929eef5030e /drivers/net/wireless/wl12xx/wl1271_spi.c
parent54f7e5037c95f2beff0252bfcf288f711c185799 (diff)
wl1271: Implemented abstraction of IO functions.
Changed the driver to use if_ops structure to abstract access to the IO layer (SPI or SDIO). Signed-off-by: Teemu Paasikivi <ext-teemu.3.paasikivi@nokia.com> Reviewed-by: Juuso Oikarinen <juuso.oikarinen@nokia.com> Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_spi.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_spi.c37
1 files changed, 29 insertions, 8 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_spi.c b/drivers/net/wireless/wl12xx/wl1271_spi.c
index b422c9fdcd22..a0f416972be2 100644
--- a/drivers/net/wireless/wl12xx/wl1271_spi.c
+++ b/drivers/net/wireless/wl12xx/wl1271_spi.c
@@ -33,6 +33,15 @@
33#include "wl1271_spi.h" 33#include "wl1271_spi.h"
34#include "wl1271_io.h" 34#include "wl1271_io.h"
35 35
36static struct spi_device *wl_to_spi(struct wl1271 *wl)
37{
38 return wl->if_priv;
39}
40
41static struct device *wl1271_spi_wl_to_dev(struct wl1271 *wl)
42{
43 return &(wl_to_spi(wl)->dev);
44}
36 45
37void wl1271_spi_disable_interrupts(struct wl1271 *wl) 46void wl1271_spi_disable_interrupts(struct wl1271 *wl)
38{ 47{
@@ -65,7 +74,7 @@ void wl1271_spi_reset(struct wl1271 *wl)
65 t.len = WSPI_INIT_CMD_LEN; 74 t.len = WSPI_INIT_CMD_LEN;
66 spi_message_add_tail(&t, &m); 75 spi_message_add_tail(&t, &m);
67 76
68 spi_sync(wl->spi, &m); 77 spi_sync(wl_to_spi(wl), &m);
69 78
70 wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); 79 wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN);
71} 80}
@@ -119,7 +128,7 @@ void wl1271_spi_init(struct wl1271 *wl)
119 t.len = WSPI_INIT_CMD_LEN; 128 t.len = WSPI_INIT_CMD_LEN;
120 spi_message_add_tail(&t, &m); 129 spi_message_add_tail(&t, &m);
121 130
122 spi_sync(wl->spi, &m); 131 spi_sync(wl_to_spi(wl), &m);
123 132
124 wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); 133 wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN);
125} 134}
@@ -151,7 +160,7 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len)
151 t[0].rx_buf = buf + (len - num_busy_bytes); 160 t[0].rx_buf = buf + (len - num_busy_bytes);
152 t[0].len = num_busy_bytes; 161 t[0].len = num_busy_bytes;
153 spi_message_add_tail(&t[0], &m); 162 spi_message_add_tail(&t[0], &m);
154 spi_sync(wl->spi, &m); 163 spi_sync(wl_to_spi(wl), &m);
155 return; 164 return;
156 } 165 }
157 } 166 }
@@ -171,7 +180,7 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len)
171 t[0].rx_buf = busy_buf; 180 t[0].rx_buf = busy_buf;
172 t[0].len = sizeof(u32); 181 t[0].len = sizeof(u32);
173 spi_message_add_tail(&t[0], &m); 182 spi_message_add_tail(&t[0], &m);
174 spi_sync(wl->spi, &m); 183 spi_sync(wl_to_spi(wl), &m);
175 184
176 if (*busy_buf & 0x1) { 185 if (*busy_buf & 0x1) {
177 spi_message_init(&m); 186 spi_message_init(&m);
@@ -179,7 +188,7 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len)
179 t[0].rx_buf = buf; 188 t[0].rx_buf = buf;
180 t[0].len = len; 189 t[0].len = len;
181 spi_message_add_tail(&t[0], &m); 190 spi_message_add_tail(&t[0], &m);
182 spi_sync(wl->spi, &m); 191 spi_sync(wl_to_spi(wl), &m);
183 return; 192 return;
184 } 193 }
185 } 194 }
@@ -225,7 +234,7 @@ void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf,
225 t[2].len = len; 234 t[2].len = len;
226 spi_message_add_tail(&t[2], &m); 235 spi_message_add_tail(&t[2], &m);
227 236
228 spi_sync(wl->spi, &m); 237 spi_sync(wl_to_spi(wl), &m);
229 238
230 /* FIXME: Check busy words, removed due to SPI bug */ 239 /* FIXME: Check busy words, removed due to SPI bug */
231 /* if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1)) 240 /* if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1))
@@ -263,7 +272,7 @@ void wl1271_spi_raw_write(struct wl1271 *wl, int addr, void *buf,
263 t[1].len = len; 272 t[1].len = len;
264 spi_message_add_tail(&t[1], &m); 273 spi_message_add_tail(&t[1], &m);
265 274
266 spi_sync(wl->spi, &m); 275 spi_sync(wl_to_spi(wl), &m);
267 276
268 wl1271_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); 277 wl1271_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd));
269 wl1271_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); 278 wl1271_dump(DEBUG_SPI, "spi_write buf -> ", buf, len);
@@ -306,6 +315,16 @@ static struct platform_device wl1271_device = {
306 }, 315 },
307}; 316};
308 317
318static struct wl1271_if_operations spi_ops = {
319 .read = wl1271_spi_raw_read,
320 .write = wl1271_spi_raw_write,
321 .reset = wl1271_spi_reset,
322 .init = wl1271_spi_init,
323 .dev = wl1271_spi_wl_to_dev,
324 .enable_irq = wl1271_spi_enable_interrupts,
325 .disable_irq = wl1271_spi_disable_interrupts
326};
327
309static int __devinit wl1271_probe(struct spi_device *spi) 328static int __devinit wl1271_probe(struct spi_device *spi)
310{ 329{
311 struct wl12xx_platform_data *pdata; 330 struct wl12xx_platform_data *pdata;
@@ -326,7 +345,9 @@ static int __devinit wl1271_probe(struct spi_device *spi)
326 wl = hw->priv; 345 wl = hw->priv;
327 346
328 dev_set_drvdata(&spi->dev, wl); 347 dev_set_drvdata(&spi->dev, wl);
329 wl->spi = spi; 348 wl->if_priv = spi;
349
350 wl->if_ops = &spi_ops;
330 351
331 /* This is the only SPI value that we need to set here, the rest 352 /* This is the only SPI value that we need to set here, the rest
332 * comes from the board-peripherals file */ 353 * comes from the board-peripherals file */