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 | |
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>
-rw-r--r-- | drivers/net/wireless/wl12xx/Makefile | 2 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_acx.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_boot.c | 2 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_cmd.c | 10 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_event.c | 4 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_io.c | 86 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_io.h | 54 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_main.c | 3 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_ops.c | 6 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_ps.c | 3 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_rx.c | 7 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_spi.c | 81 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_spi.h | 30 | ||||
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1251_tx.c | 61 |
14 files changed, 192 insertions, 159 deletions
diff --git a/drivers/net/wireless/wl12xx/Makefile b/drivers/net/wireless/wl12xx/Makefile index ecb883333656..a1a15cef7351 100644 --- a/drivers/net/wireless/wl12xx/Makefile +++ b/drivers/net/wireless/wl12xx/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | wl1251-objs = wl1251_main.o wl1251_spi.o wl1251_event.o \ | 1 | wl1251-objs = wl1251_main.o wl1251_spi.o wl1251_event.o \ |
2 | wl1251_tx.o wl1251_rx.o wl1251_ps.o wl1251_cmd.o \ | 2 | wl1251_tx.o wl1251_rx.o wl1251_ps.o wl1251_cmd.o \ |
3 | wl1251_acx.o wl1251_boot.o wl1251_init.o \ | 3 | wl1251_acx.o wl1251_boot.o wl1251_init.o \ |
4 | wl1251_ops.o wl1251_debugfs.o | 4 | wl1251_ops.o wl1251_debugfs.o wl1251_io.o |
5 | obj-$(CONFIG_WL1251) += wl1251.o | 5 | obj-$(CONFIG_WL1251) += wl1251.o |
6 | 6 | ||
7 | wl1271-objs = wl1271_main.o wl1271_spi.o wl1271_cmd.o \ | 7 | wl1271-objs = wl1271_main.o wl1271_spi.o wl1271_cmd.o \ |
diff --git a/drivers/net/wireless/wl12xx/wl1251_acx.c b/drivers/net/wireless/wl12xx/wl1251_acx.c index a46c92a29526..2e3171a61b77 100644 --- a/drivers/net/wireless/wl12xx/wl1251_acx.c +++ b/drivers/net/wireless/wl12xx/wl1251_acx.c | |||
@@ -6,7 +6,7 @@ | |||
6 | 6 | ||
7 | #include "wl1251.h" | 7 | #include "wl1251.h" |
8 | #include "reg.h" | 8 | #include "reg.h" |
9 | #include "wl1251_spi.h" | 9 | #include "wl1251_cmd.h" |
10 | #include "wl1251_ps.h" | 10 | #include "wl1251_ps.h" |
11 | 11 | ||
12 | int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod, | 12 | int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod, |
diff --git a/drivers/net/wireless/wl12xx/wl1251_boot.c b/drivers/net/wireless/wl12xx/wl1251_boot.c index d8a155dc2fa1..5702398de16a 100644 --- a/drivers/net/wireless/wl12xx/wl1251_boot.c +++ b/drivers/net/wireless/wl12xx/wl1251_boot.c | |||
@@ -25,7 +25,7 @@ | |||
25 | 25 | ||
26 | #include "reg.h" | 26 | #include "reg.h" |
27 | #include "wl1251_boot.h" | 27 | #include "wl1251_boot.h" |
28 | #include "wl1251_spi.h" | 28 | #include "wl1251_io.h" |
29 | #include "wl1251_event.h" | 29 | #include "wl1251_event.h" |
30 | 30 | ||
31 | static void wl1251_boot_enable_interrupts(struct wl1251 *wl) | 31 | static void wl1251_boot_enable_interrupts(struct wl1251 *wl) |
diff --git a/drivers/net/wireless/wl12xx/wl1251_cmd.c b/drivers/net/wireless/wl12xx/wl1251_cmd.c index dc04d1fc2ee4..2c30c705908e 100644 --- a/drivers/net/wireless/wl12xx/wl1251_cmd.c +++ b/drivers/net/wireless/wl12xx/wl1251_cmd.c | |||
@@ -6,7 +6,7 @@ | |||
6 | 6 | ||
7 | #include "wl1251.h" | 7 | #include "wl1251.h" |
8 | #include "reg.h" | 8 | #include "reg.h" |
9 | #include "wl1251_spi.h" | 9 | #include "wl1251_io.h" |
10 | #include "wl1251_ps.h" | 10 | #include "wl1251_ps.h" |
11 | #include "wl1251_acx.h" | 11 | #include "wl1251_acx.h" |
12 | 12 | ||
@@ -31,7 +31,7 @@ int wl1251_cmd_send(struct wl1251 *wl, u16 id, void *buf, size_t len) | |||
31 | 31 | ||
32 | WARN_ON(len % 4 != 0); | 32 | WARN_ON(len % 4 != 0); |
33 | 33 | ||
34 | wl1251_spi_mem_write(wl, wl->cmd_box_addr, buf, len); | 34 | wl1251_mem_write(wl, wl->cmd_box_addr, buf, len); |
35 | 35 | ||
36 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD); | 36 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD); |
37 | 37 | ||
@@ -86,7 +86,7 @@ int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer) | |||
86 | * The answer would be a wl1251_command, where the | 86 | * The answer would be a wl1251_command, where the |
87 | * parameter array contains the actual answer. | 87 | * parameter array contains the actual answer. |
88 | */ | 88 | */ |
89 | wl1251_spi_mem_read(wl, wl->cmd_box_addr, buf, buf_len); | 89 | wl1251_mem_read(wl, wl->cmd_box_addr, buf, buf_len); |
90 | 90 | ||
91 | cmd_answer = buf; | 91 | cmd_answer = buf; |
92 | 92 | ||
@@ -125,7 +125,7 @@ int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len) | |||
125 | } | 125 | } |
126 | 126 | ||
127 | /* the interrogate command got in, we can read the answer */ | 127 | /* the interrogate command got in, we can read the answer */ |
128 | wl1251_spi_mem_read(wl, wl->cmd_box_addr, buf, len); | 128 | wl1251_mem_read(wl, wl->cmd_box_addr, buf, len); |
129 | 129 | ||
130 | acx = buf; | 130 | acx = buf; |
131 | if (acx->cmd.status != CMD_STATUS_SUCCESS) | 131 | if (acx->cmd.status != CMD_STATUS_SUCCESS) |
@@ -379,7 +379,7 @@ int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer, | |||
379 | } | 379 | } |
380 | 380 | ||
381 | /* the read command got in, we can now read the answer */ | 381 | /* the read command got in, we can now read the answer */ |
382 | wl1251_spi_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd)); | 382 | wl1251_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd)); |
383 | 383 | ||
384 | if (cmd->header.status != CMD_STATUS_SUCCESS) | 384 | if (cmd->header.status != CMD_STATUS_SUCCESS) |
385 | wl1251_error("error in read command result: %d", | 385 | wl1251_error("error in read command result: %d", |
diff --git a/drivers/net/wireless/wl12xx/wl1251_event.c b/drivers/net/wireless/wl12xx/wl1251_event.c index 1a0a0bc1a31f..1b4f8d2850c5 100644 --- a/drivers/net/wireless/wl12xx/wl1251_event.c +++ b/drivers/net/wireless/wl12xx/wl1251_event.c | |||
@@ -24,7 +24,7 @@ | |||
24 | 24 | ||
25 | #include "wl1251.h" | 25 | #include "wl1251.h" |
26 | #include "reg.h" | 26 | #include "reg.h" |
27 | #include "wl1251_spi.h" | 27 | #include "wl1251_io.h" |
28 | #include "wl1251_event.h" | 28 | #include "wl1251_event.h" |
29 | #include "wl1251_ps.h" | 29 | #include "wl1251_ps.h" |
30 | 30 | ||
@@ -112,7 +112,7 @@ int wl1251_event_handle(struct wl1251 *wl, u8 mbox_num) | |||
112 | return -EINVAL; | 112 | return -EINVAL; |
113 | 113 | ||
114 | /* first we read the mbox descriptor */ | 114 | /* first we read the mbox descriptor */ |
115 | wl1251_spi_mem_read(wl, wl->mbox_ptr[mbox_num], &mbox, | 115 | wl1251_mem_read(wl, wl->mbox_ptr[mbox_num], &mbox, |
116 | sizeof(struct event_mailbox)); | 116 | sizeof(struct event_mailbox)); |
117 | 117 | ||
118 | /* process the descriptor */ | 118 | /* process the descriptor */ |
diff --git a/drivers/net/wireless/wl12xx/wl1251_io.c b/drivers/net/wireless/wl12xx/wl1251_io.c new file mode 100644 index 000000000000..1fa26749af32 --- /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 | } | ||
diff --git a/drivers/net/wireless/wl12xx/wl1251_io.h b/drivers/net/wireless/wl12xx/wl1251_io.h new file mode 100644 index 000000000000..e2bb9546fa68 --- /dev/null +++ b/drivers/net/wireless/wl12xx/wl1251_io.h | |||
@@ -0,0 +1,54 @@ | |||
1 | /* | ||
2 | * This file is part of wl12xx | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or | ||
7 | * modify it under the terms of the GNU General Public License | ||
8 | * version 2 as published by the Free Software Foundation. | ||
9 | * | ||
10 | * This program is distributed in the hope that it will be useful, but | ||
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | * General Public License for more details. | ||
14 | * | ||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program; if not, write to the Free Software | ||
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
18 | * 02110-1301 USA | ||
19 | * | ||
20 | */ | ||
21 | #ifndef __WL1251_IO_H__ | ||
22 | #define __WL1251_IO_H__ | ||
23 | |||
24 | #include "wl1251.h" | ||
25 | #include "wl1251_spi.h" | ||
26 | |||
27 | /* Raw target IO, address is not translated */ | ||
28 | void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
29 | void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
30 | |||
31 | static inline u32 wl1251_read32(struct wl1251 *wl, int addr) | ||
32 | { | ||
33 | u32 response; | ||
34 | |||
35 | wl1251_spi_read(wl, addr, &response, sizeof(u32)); | ||
36 | |||
37 | return response; | ||
38 | } | ||
39 | |||
40 | static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val) | ||
41 | { | ||
42 | wl1251_spi_write(wl, addr, &val, sizeof(u32)); | ||
43 | } | ||
44 | |||
45 | /* Memory target IO, address is translated to partition 0 */ | ||
46 | void wl1251_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
47 | void wl1251_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
48 | u32 wl1251_mem_read32(struct wl1251 *wl, int addr); | ||
49 | void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val); | ||
50 | /* Registers IO */ | ||
51 | u32 wl1251_reg_read32(struct wl1251 *wl, int addr); | ||
52 | void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val); | ||
53 | |||
54 | #endif | ||
diff --git a/drivers/net/wireless/wl12xx/wl1251_main.c b/drivers/net/wireless/wl12xx/wl1251_main.c index da4c688c46af..a858e4dc20eb 100644 --- a/drivers/net/wireless/wl12xx/wl1251_main.c +++ b/drivers/net/wireless/wl12xx/wl1251_main.c | |||
@@ -35,6 +35,7 @@ | |||
35 | #include "wl12xx_80211.h" | 35 | #include "wl12xx_80211.h" |
36 | #include "reg.h" | 36 | #include "reg.h" |
37 | #include "wl1251_ops.h" | 37 | #include "wl1251_ops.h" |
38 | #include "wl1251_io.h" | ||
38 | #include "wl1251_spi.h" | 39 | #include "wl1251_spi.h" |
39 | #include "wl1251_event.h" | 40 | #include "wl1251_event.h" |
40 | #include "wl1251_tx.h" | 41 | #include "wl1251_tx.h" |
@@ -877,7 +878,7 @@ static int wl1251_hw_scan(struct wl1251 *wl, u8 *ssid, size_t len, | |||
877 | if (ret < 0) | 878 | if (ret < 0) |
878 | wl1251_error("SCAN failed"); | 879 | wl1251_error("SCAN failed"); |
879 | 880 | ||
880 | wl1251_spi_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params)); | 881 | wl1251_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params)); |
881 | 882 | ||
882 | if (params->header.status != CMD_STATUS_SUCCESS) { | 883 | if (params->header.status != CMD_STATUS_SUCCESS) { |
883 | wl1251_error("TEST command answer error: %d", | 884 | wl1251_error("TEST command answer error: %d", |
diff --git a/drivers/net/wireless/wl12xx/wl1251_ops.c b/drivers/net/wireless/wl12xx/wl1251_ops.c index e7b9aab3682f..506123f1c8f5 100644 --- a/drivers/net/wireless/wl12xx/wl1251_ops.c +++ b/drivers/net/wireless/wl12xx/wl1251_ops.c | |||
@@ -26,7 +26,7 @@ | |||
26 | 26 | ||
27 | #include "wl1251_ops.h" | 27 | #include "wl1251_ops.h" |
28 | #include "reg.h" | 28 | #include "reg.h" |
29 | #include "wl1251_spi.h" | 29 | #include "wl1251_io.h" |
30 | #include "wl1251_boot.h" | 30 | #include "wl1251_boot.h" |
31 | #include "wl1251_event.h" | 31 | #include "wl1251_event.h" |
32 | #include "wl1251_acx.h" | 32 | #include "wl1251_acx.h" |
@@ -130,7 +130,7 @@ static int wl1251_upload_firmware(struct wl1251 *wl) | |||
130 | p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; | 130 | p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; |
131 | wl1251_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x", | 131 | wl1251_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x", |
132 | p, addr); | 132 | p, addr); |
133 | wl1251_spi_mem_write(wl, addr, p, CHUNK_SIZE); | 133 | wl1251_mem_write(wl, addr, p, CHUNK_SIZE); |
134 | 134 | ||
135 | chunk_num++; | 135 | chunk_num++; |
136 | } | 136 | } |
@@ -140,7 +140,7 @@ static int wl1251_upload_firmware(struct wl1251 *wl) | |||
140 | p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; | 140 | p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; |
141 | wl1251_debug(DEBUG_BOOT, "uploading fw last chunk (%zu B) 0x%p to 0x%x", | 141 | wl1251_debug(DEBUG_BOOT, "uploading fw last chunk (%zu B) 0x%p to 0x%x", |
142 | fw_data_len % CHUNK_SIZE, p, addr); | 142 | fw_data_len % CHUNK_SIZE, p, addr); |
143 | wl1251_spi_mem_write(wl, addr, p, fw_data_len % CHUNK_SIZE); | 143 | wl1251_mem_write(wl, addr, p, fw_data_len % CHUNK_SIZE); |
144 | 144 | ||
145 | return 0; | 145 | return 0; |
146 | } | 146 | } |
diff --git a/drivers/net/wireless/wl12xx/wl1251_ps.c b/drivers/net/wireless/wl12xx/wl1251_ps.c index 68ff7f1900ed..05816778f3db 100644 --- a/drivers/net/wireless/wl12xx/wl1251_ps.c +++ b/drivers/net/wireless/wl12xx/wl1251_ps.c | |||
@@ -23,7 +23,8 @@ | |||
23 | 23 | ||
24 | #include "reg.h" | 24 | #include "reg.h" |
25 | #include "wl1251_ps.h" | 25 | #include "wl1251_ps.h" |
26 | #include "wl1251_spi.h" | 26 | #include "wl1251_cmd.h" |
27 | #include "wl1251_io.h" | ||
27 | 28 | ||
28 | #define WL1251_WAKEUP_TIMEOUT 2000 | 29 | #define WL1251_WAKEUP_TIMEOUT 2000 |
29 | 30 | ||
diff --git a/drivers/net/wireless/wl12xx/wl1251_rx.c b/drivers/net/wireless/wl12xx/wl1251_rx.c index 0dbb483a0973..af8187909c94 100644 --- a/drivers/net/wireless/wl12xx/wl1251_rx.c +++ b/drivers/net/wireless/wl12xx/wl1251_rx.c | |||
@@ -27,8 +27,9 @@ | |||
27 | 27 | ||
28 | #include "wl1251.h" | 28 | #include "wl1251.h" |
29 | #include "reg.h" | 29 | #include "reg.h" |
30 | #include "wl1251_spi.h" | 30 | #include "wl1251_io.h" |
31 | #include "wl1251_rx.h" | 31 | #include "wl1251_rx.h" |
32 | #include "wl1251_cmd.h" | ||
32 | #include "wl1251_acx.h" | 33 | #include "wl1251_acx.h" |
33 | 34 | ||
34 | static void wl1251_rx_header(struct wl1251 *wl, | 35 | static void wl1251_rx_header(struct wl1251 *wl, |
@@ -40,7 +41,7 @@ static void wl1251_rx_header(struct wl1251 *wl, | |||
40 | if (wl->rx_current_buffer) | 41 | if (wl->rx_current_buffer) |
41 | rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; | 42 | rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; |
42 | 43 | ||
43 | wl1251_spi_mem_read(wl, rx_packet_ring_addr, desc, sizeof(*desc)); | 44 | wl1251_mem_read(wl, rx_packet_ring_addr, desc, sizeof(*desc)); |
44 | } | 45 | } |
45 | 46 | ||
46 | static void wl1251_rx_status(struct wl1251 *wl, | 47 | static void wl1251_rx_status(struct wl1251 *wl, |
@@ -136,7 +137,7 @@ static void wl1251_rx_body(struct wl1251 *wl, | |||
136 | } | 137 | } |
137 | 138 | ||
138 | rx_buffer = skb_put(skb, length); | 139 | rx_buffer = skb_put(skb, length); |
139 | wl1251_spi_mem_read(wl, rx_packet_ring_addr, rx_buffer, length); | 140 | wl1251_mem_read(wl, rx_packet_ring_addr, rx_buffer, length); |
140 | 141 | ||
141 | /* The actual lenght doesn't include the target's alignment */ | 142 | /* The actual lenght doesn't include the target's alignment */ |
142 | skb->len = desc->length - PLCP_HEADER_LENGTH; | 143 | skb->len = desc->length - PLCP_HEADER_LENGTH; |
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 | ||
32 | static 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 | |||
49 | static 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 | |||
55 | void wl1251_spi_reset(struct wl1251 *wl) | 32 | void 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 | |||
327 | void 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 | |||
337 | void 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 | |||
347 | void 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 | |||
356 | void 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 | |||
365 | u32 wl1251_mem_read32(struct wl1251 *wl, int addr) | ||
366 | { | ||
367 | return wl1251_read32(wl, wl1251_translate_mem_addr(wl, addr)); | ||
368 | } | ||
369 | |||
370 | void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val) | ||
371 | { | ||
372 | wl1251_write32(wl, wl1251_translate_mem_addr(wl, addr), val); | ||
373 | } | ||
374 | |||
375 | u32 wl1251_reg_read32(struct wl1251 *wl, int addr) | ||
376 | { | ||
377 | return wl1251_read32(wl, wl1251_translate_reg_addr(wl, addr)); | ||
378 | } | ||
379 | |||
380 | void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val) | ||
381 | { | ||
382 | wl1251_write32(wl, wl1251_translate_reg_addr(wl, addr), val); | ||
383 | } | ||
diff --git a/drivers/net/wireless/wl12xx/wl1251_spi.h b/drivers/net/wireless/wl12xx/wl1251_spi.h index 70763528db27..ca9a85118ec5 100644 --- a/drivers/net/wireless/wl12xx/wl1251_spi.h +++ b/drivers/net/wireless/wl12xx/wl1251_spi.h | |||
@@ -69,23 +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 | |||
73 | /* Raw target IO, address is not translated */ | ||
74 | void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
75 | void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
76 | |||
77 | /* Memory target IO, address is tranlated to partition 0 */ | ||
78 | void wl1251_spi_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
79 | void wl1251_spi_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
80 | u32 wl1251_mem_read32(struct wl1251 *wl, int addr); | ||
81 | void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val); | ||
82 | |||
83 | /* Registers IO */ | ||
84 | void wl1251_spi_reg_read(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
85 | void wl1251_spi_reg_write(struct wl1251 *wl, int addr, void *buf, size_t len); | ||
86 | u32 wl1251_reg_read32(struct wl1251 *wl, int addr); | ||
87 | void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val); | ||
88 | |||
89 | /* INIT and RESET words */ | 72 | /* INIT and RESET words */ |
90 | void wl1251_spi_reset(struct wl1251 *wl); | 73 | void wl1251_spi_reset(struct wl1251 *wl); |
91 | void wl1251_spi_init(struct wl1251 *wl); | 74 | void wl1251_spi_init(struct wl1251 *wl); |
@@ -93,17 +76,4 @@ int wl1251_set_partition(struct wl1251 *wl, | |||
93 | u32 part_start, u32 part_size, | 76 | u32 part_start, u32 part_size, |
94 | u32 reg_start, u32 reg_size); | 77 | u32 reg_start, u32 reg_size); |
95 | 78 | ||
96 | static inline u32 wl1251_read32(struct wl1251 *wl, int addr) | ||
97 | { | ||
98 | wl1251_spi_read(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32)); | ||
99 | |||
100 | return wl->buffer_32; | ||
101 | } | ||
102 | |||
103 | static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val) | ||
104 | { | ||
105 | wl->buffer_32 = val; | ||
106 | wl1251_spi_write(wl, addr, &wl->buffer_32, sizeof(wl->buffer_32)); | ||
107 | } | ||
108 | |||
109 | #endif /* __WL1251_SPI_H__ */ | 79 | #endif /* __WL1251_SPI_H__ */ |
diff --git a/drivers/net/wireless/wl12xx/wl1251_tx.c b/drivers/net/wireless/wl12xx/wl1251_tx.c index 2652a222383a..7ddc9a346304 100644 --- a/drivers/net/wireless/wl12xx/wl1251_tx.c +++ b/drivers/net/wireless/wl12xx/wl1251_tx.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "wl1251_spi.h" | 30 | #include "wl1251_spi.h" |
31 | #include "wl1251_tx.h" | 31 | #include "wl1251_tx.h" |
32 | #include "wl1251_ps.h" | 32 | #include "wl1251_ps.h" |
33 | #include "wl1251_io.h" | ||
33 | 34 | ||
34 | static bool wl1251_tx_double_buffer_busy(struct wl1251 *wl, u32 data_out_count) | 35 | static bool wl1251_tx_double_buffer_busy(struct wl1251 *wl, u32 data_out_count) |
35 | { | 36 | { |
@@ -235,7 +236,7 @@ static int wl1251_tx_send_packet(struct wl1251 *wl, struct sk_buff *skb, | |||
235 | else | 236 | else |
236 | addr = wl->data_path->tx_packet_ring_addr; | 237 | addr = wl->data_path->tx_packet_ring_addr; |
237 | 238 | ||
238 | wl1251_spi_mem_write(wl, addr, skb->data, len); | 239 | wl1251_mem_write(wl, addr, skb->data, len); |
239 | 240 | ||
240 | wl1251_debug(DEBUG_TX, "tx id %u skb 0x%p payload %u rate 0x%x", | 241 | wl1251_debug(DEBUG_TX, "tx id %u skb 0x%p payload %u rate 0x%x", |
241 | tx_hdr->id, skb, tx_hdr->length, tx_hdr->rate); | 242 | tx_hdr->id, skb, tx_hdr->length, tx_hdr->rate); |
@@ -451,7 +452,7 @@ void wl1251_tx_complete(struct wl1251 *wl) | |||
451 | return; | 452 | return; |
452 | 453 | ||
453 | /* First we read the result */ | 454 | /* First we read the result */ |
454 | wl1251_spi_mem_read(wl, wl->data_path->tx_complete_addr, | 455 | wl1251_mem_read(wl, wl->data_path->tx_complete_addr, |
455 | result, sizeof(result)); | 456 | result, sizeof(result)); |
456 | 457 | ||
457 | result_index = wl->next_tx_complete; | 458 | result_index = wl->next_tx_complete; |
@@ -482,41 +483,41 @@ void wl1251_tx_complete(struct wl1251 *wl) | |||
482 | */ | 483 | */ |
483 | if (result_index > wl->next_tx_complete) { | 484 | if (result_index > wl->next_tx_complete) { |
484 | /* Only 1 write is needed */ | 485 | /* Only 1 write is needed */ |
485 | wl1251_spi_mem_write(wl, | 486 | wl1251_mem_write(wl, |
486 | wl->data_path->tx_complete_addr + | 487 | wl->data_path->tx_complete_addr + |
487 | (wl->next_tx_complete * | 488 | (wl->next_tx_complete * |
488 | sizeof(struct tx_result)), | 489 | sizeof(struct tx_result)), |
489 | &result[wl->next_tx_complete], | 490 | &result[wl->next_tx_complete], |
490 | num_complete * | 491 | num_complete * |
491 | sizeof(struct tx_result)); | 492 | sizeof(struct tx_result)); |
492 | 493 | ||
493 | 494 | ||
494 | } else if (result_index < wl->next_tx_complete) { | 495 | } else if (result_index < wl->next_tx_complete) { |
495 | /* 2 writes are needed */ | 496 | /* 2 writes are needed */ |
496 | wl1251_spi_mem_write(wl, | 497 | wl1251_mem_write(wl, |
497 | wl->data_path->tx_complete_addr + | 498 | wl->data_path->tx_complete_addr + |
498 | (wl->next_tx_complete * | 499 | (wl->next_tx_complete * |
499 | sizeof(struct tx_result)), | 500 | sizeof(struct tx_result)), |
500 | &result[wl->next_tx_complete], | 501 | &result[wl->next_tx_complete], |
501 | (FW_TX_CMPLT_BLOCK_SIZE - | 502 | (FW_TX_CMPLT_BLOCK_SIZE - |
502 | wl->next_tx_complete) * | 503 | wl->next_tx_complete) * |
503 | sizeof(struct tx_result)); | 504 | sizeof(struct tx_result)); |
504 | 505 | ||
505 | wl1251_spi_mem_write(wl, | 506 | wl1251_mem_write(wl, |
506 | wl->data_path->tx_complete_addr, | 507 | wl->data_path->tx_complete_addr, |
507 | result, | 508 | result, |
508 | (num_complete - | 509 | (num_complete - |
509 | FW_TX_CMPLT_BLOCK_SIZE + | 510 | FW_TX_CMPLT_BLOCK_SIZE + |
510 | wl->next_tx_complete) * | 511 | wl->next_tx_complete) * |
511 | sizeof(struct tx_result)); | 512 | sizeof(struct tx_result)); |
512 | 513 | ||
513 | } else { | 514 | } else { |
514 | /* We have to write the whole array */ | 515 | /* We have to write the whole array */ |
515 | wl1251_spi_mem_write(wl, | 516 | wl1251_mem_write(wl, |
516 | wl->data_path->tx_complete_addr, | 517 | wl->data_path->tx_complete_addr, |
517 | result, | 518 | result, |
518 | FW_TX_CMPLT_BLOCK_SIZE * | 519 | FW_TX_CMPLT_BLOCK_SIZE * |
519 | sizeof(struct tx_result)); | 520 | sizeof(struct tx_result)); |
520 | } | 521 | } |
521 | 522 | ||
522 | } | 523 | } |