aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1251_spi.c
diff options
context:
space:
mode:
authorBob Copeland <me@bobcopeland.com>2009-08-07 06:32:56 -0400
committerJohn W. Linville <linville@tuxdriver.com>2009-08-14 09:13:36 -0400
commit0764de64c8628f653c7e8493017d6bd8d43f4e3b (patch)
tree31a9f7ed97caf521e37166c79d3a39fbad920941 /drivers/net/wireless/wl12xx/wl1251_spi.c
parentb8010790c480f495520fd458197f86d758f0c83a (diff)
wl1251: separate bus i/o code into io.c
In order to eventually support wl1251 spi and sdio interfaces, move the register and memory transfer functions to a common file. Also rename wl1251_spi_mem_{read,write} to indicate its common usage. We still use spi_read internally until SDIO interface is introduced so nothing functional should change here. 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/wireless/wl12xx/wl1251_spi.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_spi.c81
1 files changed, 0 insertions, 81 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1251_spi.c b/drivers/net/wireless/wl12xx/wl1251_spi.c
index c2b813f51846..031a3bac95e5 100644
--- a/drivers/net/wireless/wl12xx/wl1251_spi.c
+++ b/drivers/net/wireless/wl12xx/wl1251_spi.c
@@ -29,29 +29,6 @@
29#include "reg.h" 29#include "reg.h"
30#include "wl1251_spi.h" 30#include "wl1251_spi.h"
31 31
32static int wl1251_translate_reg_addr(struct wl1251 *wl, int addr)
33{
34 /* If the address is lower than REGISTERS_BASE, it means that this is
35 * a chip-specific register address, so look it up in the registers
36 * table */
37 if (addr < REGISTERS_BASE) {
38 /* Make sure we don't go over the table */
39 if (addr >= ACX_REG_TABLE_LEN) {
40 wl1251_error("address out of range (%d)", addr);
41 return -EINVAL;
42 }
43 addr = wl->chip.acx_reg_table[addr];
44 }
45
46 return addr - wl->physical_reg_addr + wl->virtual_reg_addr;
47}
48
49static int wl1251_translate_mem_addr(struct wl1251 *wl, int addr)
50{
51 return addr - wl->physical_mem_addr + wl->virtual_mem_addr;
52}
53
54
55void wl1251_spi_reset(struct wl1251 *wl) 32void wl1251_spi_reset(struct wl1251 *wl)
56{ 33{
57 u8 *cmd; 34 u8 *cmd;
@@ -323,61 +300,3 @@ void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len)
323 wl1251_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); 300 wl1251_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd));
324 wl1251_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); 301 wl1251_dump(DEBUG_SPI, "spi_write buf -> ", buf, len);
325} 302}
326
327void wl1251_spi_mem_read(struct wl1251 *wl, int addr, void *buf,
328 size_t len)
329{
330 int physical;
331
332 physical = wl1251_translate_mem_addr(wl, addr);
333
334 wl1251_spi_read(wl, physical, buf, len);
335}
336
337void wl1251_spi_mem_write(struct wl1251 *wl, int addr, void *buf,
338 size_t len)
339{
340 int physical;
341
342 physical = wl1251_translate_mem_addr(wl, addr);
343
344 wl1251_spi_write(wl, physical, buf, len);
345}
346
347void wl1251_spi_reg_read(struct wl1251 *wl, int addr, void *buf, size_t len)
348{
349 int physical;
350
351 physical = wl1251_translate_reg_addr(wl, addr);
352
353 wl1251_spi_read(wl, physical, buf, len);
354}
355
356void wl1251_spi_reg_write(struct wl1251 *wl, int addr, void *buf, size_t len)
357{
358 int physical;
359
360 physical = wl1251_translate_reg_addr(wl, addr);
361
362 wl1251_spi_write(wl, physical, buf, len);
363}
364
365u32 wl1251_mem_read32(struct wl1251 *wl, int addr)
366{
367 return wl1251_read32(wl, wl1251_translate_mem_addr(wl, addr));
368}
369
370void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val)
371{
372 wl1251_write32(wl, wl1251_translate_mem_addr(wl, addr), val);
373}
374
375u32 wl1251_reg_read32(struct wl1251 *wl, int addr)
376{
377 return wl1251_read32(wl, wl1251_translate_reg_addr(wl, addr));
378}
379
380void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val)
381{
382 wl1251_write32(wl, wl1251_translate_reg_addr(wl, addr), val);
383}