diff options
author | Bob Copeland <me@bobcopeland.com> | 2009-08-07 06:32:56 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-08-14 09:13:36 -0400 |
commit | 0764de64c8628f653c7e8493017d6bd8d43f4e3b (patch) | |
tree | 31a9f7ed97caf521e37166c79d3a39fbad920941 /drivers/net/wireless/wl12xx/wl1251_io.c | |
parent | b8010790c480f495520fd458197f86d758f0c83a (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_io.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_io.c | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1251_io.c b/drivers/net/wireless/wl12xx/wl1251_io.c new file mode 100644 index 00000000000..1fa26749af3 --- /dev/null +++ b/drivers/net/wireless/wl12xx/wl1251_io.c | |||
@@ -0,0 +1,86 @@ | |||
1 | /* | ||
2 | * This file is part of wl12xx | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * | ||
6 | * Contact: Kalle Valo <kalle.valo@nokia.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * version 2 as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
20 | * 02110-1301 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #include "wl1251.h" | ||
25 | #include "reg.h" | ||
26 | #include "wl1251_io.h" | ||
27 | |||
28 | static int wl1251_translate_reg_addr(struct wl1251 *wl, int addr) | ||
29 | { | ||
30 | /* If the address is lower than REGISTERS_BASE, it means that this is | ||
31 | * a chip-specific register address, so look it up in the registers | ||
32 | * table */ | ||
33 | if (addr < REGISTERS_BASE) { | ||
34 | /* Make sure we don't go over the table */ | ||
35 | if (addr >= ACX_REG_TABLE_LEN) { | ||
36 | wl1251_error("address out of range (%d)", addr); | ||
37 | return -EINVAL; | ||
38 | } | ||
39 | addr = wl->chip.acx_reg_table[addr]; | ||
40 | } | ||
41 | |||
42 | return addr - wl->physical_reg_addr + wl->virtual_reg_addr; | ||
43 | } | ||
44 | |||
45 | static int wl1251_translate_mem_addr(struct wl1251 *wl, int addr) | ||
46 | { | ||
47 | return addr - wl->physical_mem_addr + wl->virtual_mem_addr; | ||
48 | } | ||
49 | |||
50 | void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len) | ||
51 | { | ||
52 | int physical; | ||
53 | |||
54 | physical = wl1251_translate_mem_addr(wl, addr); | ||
55 | |||
56 | wl1251_spi_read(wl, physical, buf, len); | ||
57 | } | ||
58 | |||
59 | void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len) | ||
60 | { | ||
61 | int physical; | ||
62 | |||
63 | physical = wl1251_translate_mem_addr(wl, addr); | ||
64 | |||
65 | wl1251_spi_write(wl, physical, buf, len); | ||
66 | } | ||
67 | |||
68 | u32 wl1251_mem_read32(struct wl1251 *wl, int addr) | ||
69 | { | ||
70 | return wl1251_read32(wl, wl1251_translate_mem_addr(wl, addr)); | ||
71 | } | ||
72 | |||
73 | void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val) | ||
74 | { | ||
75 | wl1251_write32(wl, wl1251_translate_mem_addr(wl, addr), val); | ||
76 | } | ||
77 | |||
78 | u32 wl1251_reg_read32(struct wl1251 *wl, int addr) | ||
79 | { | ||
80 | return wl1251_read32(wl, wl1251_translate_reg_addr(wl, addr)); | ||
81 | } | ||
82 | |||
83 | void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val) | ||
84 | { | ||
85 | wl1251_write32(wl, wl1251_translate_reg_addr(wl, addr), val); | ||
86 | } | ||