diff options
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_spi.c')
-rw-r--r-- | drivers/net/wireless/wl12xx/wl1271_spi.c | 71 |
1 files changed, 26 insertions, 45 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_spi.c b/drivers/net/wireless/wl12xx/wl1271_spi.c index 256e84ad0baf..5189b812f939 100644 --- a/drivers/net/wireless/wl12xx/wl1271_spi.c +++ b/drivers/net/wireless/wl12xx/wl1271_spi.c | |||
@@ -105,6 +105,7 @@ static void wl1271_spi_reset(struct wl1271 *wl) | |||
105 | spi_message_add_tail(&t, &m); | 105 | spi_message_add_tail(&t, &m); |
106 | 106 | ||
107 | spi_sync(wl_to_spi(wl), &m); | 107 | spi_sync(wl_to_spi(wl), &m); |
108 | kfree(cmd); | ||
108 | 109 | ||
109 | wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); | 110 | wl1271_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); |
110 | } | 111 | } |
@@ -159,47 +160,24 @@ static void wl1271_spi_init(struct wl1271 *wl) | |||
159 | spi_message_add_tail(&t, &m); | 160 | spi_message_add_tail(&t, &m); |
160 | 161 | ||
161 | spi_sync(wl_to_spi(wl), &m); | 162 | spi_sync(wl_to_spi(wl), &m); |
163 | kfree(cmd); | ||
162 | 164 | ||
163 | wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); | 165 | wl1271_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); |
164 | } | 166 | } |
165 | 167 | ||
166 | #define WL1271_BUSY_WORD_TIMEOUT 1000 | 168 | #define WL1271_BUSY_WORD_TIMEOUT 1000 |
167 | 169 | ||
168 | /* FIXME: Check busy words, removed due to SPI bug */ | 170 | static int wl1271_spi_read_busy(struct wl1271 *wl) |
169 | #if 0 | ||
170 | static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len) | ||
171 | { | 171 | { |
172 | struct spi_transfer t[1]; | 172 | struct spi_transfer t[1]; |
173 | struct spi_message m; | 173 | struct spi_message m; |
174 | u32 *busy_buf; | 174 | u32 *busy_buf; |
175 | int num_busy_bytes = 0; | 175 | int num_busy_bytes = 0; |
176 | 176 | ||
177 | wl1271_info("spi read BUSY!"); | ||
178 | |||
179 | /* | ||
180 | * Look for the non-busy word in the read buffer, and if found, | ||
181 | * read in the remaining data into the buffer. | ||
182 | */ | ||
183 | busy_buf = (u32 *)buf; | ||
184 | for (; (u32)busy_buf < (u32)buf + len; busy_buf++) { | ||
185 | num_busy_bytes += sizeof(u32); | ||
186 | if (*busy_buf & 0x1) { | ||
187 | spi_message_init(&m); | ||
188 | memset(t, 0, sizeof(t)); | ||
189 | memmove(buf, busy_buf, len - num_busy_bytes); | ||
190 | t[0].rx_buf = buf + (len - num_busy_bytes); | ||
191 | t[0].len = num_busy_bytes; | ||
192 | spi_message_add_tail(&t[0], &m); | ||
193 | spi_sync(wl_to_spi(wl), &m); | ||
194 | return; | ||
195 | } | ||
196 | } | ||
197 | |||
198 | /* | 177 | /* |
199 | * Read further busy words from SPI until a non-busy word is | 178 | * Read further busy words from SPI until a non-busy word is |
200 | * encountered, then read the data itself into the buffer. | 179 | * encountered, then read the data itself into the buffer. |
201 | */ | 180 | */ |
202 | wl1271_info("spi read BUSY-polling needed!"); | ||
203 | 181 | ||
204 | num_busy_bytes = WL1271_BUSY_WORD_TIMEOUT; | 182 | num_busy_bytes = WL1271_BUSY_WORD_TIMEOUT; |
205 | busy_buf = wl->buffer_busyword; | 183 | busy_buf = wl->buffer_busyword; |
@@ -209,28 +187,21 @@ static void wl1271_spi_read_busy(struct wl1271 *wl, void *buf, size_t len) | |||
209 | memset(t, 0, sizeof(t)); | 187 | memset(t, 0, sizeof(t)); |
210 | t[0].rx_buf = busy_buf; | 188 | t[0].rx_buf = busy_buf; |
211 | t[0].len = sizeof(u32); | 189 | t[0].len = sizeof(u32); |
190 | t[0].cs_change = true; | ||
212 | spi_message_add_tail(&t[0], &m); | 191 | spi_message_add_tail(&t[0], &m); |
213 | spi_sync(wl_to_spi(wl), &m); | 192 | spi_sync(wl_to_spi(wl), &m); |
214 | 193 | ||
215 | if (*busy_buf & 0x1) { | 194 | if (*busy_buf & 0x1) |
216 | spi_message_init(&m); | 195 | return 0; |
217 | memset(t, 0, sizeof(t)); | ||
218 | t[0].rx_buf = buf; | ||
219 | t[0].len = len; | ||
220 | spi_message_add_tail(&t[0], &m); | ||
221 | spi_sync(wl_to_spi(wl), &m); | ||
222 | return; | ||
223 | } | ||
224 | } | 196 | } |
225 | 197 | ||
226 | /* The SPI bus is unresponsive, the read failed. */ | 198 | /* The SPI bus is unresponsive, the read failed. */ |
227 | memset(buf, 0, len); | ||
228 | wl1271_error("SPI read busy-word timeout!\n"); | 199 | wl1271_error("SPI read busy-word timeout!\n"); |
200 | return -ETIMEDOUT; | ||
229 | } | 201 | } |
230 | #endif | ||
231 | 202 | ||
232 | static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, | 203 | static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, |
233 | size_t len, bool fixed) | 204 | size_t len, bool fixed) |
234 | { | 205 | { |
235 | struct spi_transfer t[3]; | 206 | struct spi_transfer t[3]; |
236 | struct spi_message m; | 207 | struct spi_message m; |
@@ -253,22 +224,32 @@ static void wl1271_spi_raw_read(struct wl1271 *wl, int addr, void *buf, | |||
253 | 224 | ||
254 | t[0].tx_buf = cmd; | 225 | t[0].tx_buf = cmd; |
255 | t[0].len = 4; | 226 | t[0].len = 4; |
227 | t[0].cs_change = true; | ||
256 | spi_message_add_tail(&t[0], &m); | 228 | spi_message_add_tail(&t[0], &m); |
257 | 229 | ||
258 | /* Busy and non busy words read */ | 230 | /* Busy and non busy words read */ |
259 | t[1].rx_buf = busy_buf; | 231 | t[1].rx_buf = busy_buf; |
260 | t[1].len = WL1271_BUSY_WORD_LEN; | 232 | t[1].len = WL1271_BUSY_WORD_LEN; |
233 | t[1].cs_change = true; | ||
261 | spi_message_add_tail(&t[1], &m); | 234 | spi_message_add_tail(&t[1], &m); |
262 | 235 | ||
263 | t[2].rx_buf = buf; | ||
264 | t[2].len = len; | ||
265 | spi_message_add_tail(&t[2], &m); | ||
266 | |||
267 | spi_sync(wl_to_spi(wl), &m); | 236 | spi_sync(wl_to_spi(wl), &m); |
268 | 237 | ||
269 | /* FIXME: Check busy words, removed due to SPI bug */ | 238 | if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1) && |
270 | /* if (!(busy_buf[WL1271_BUSY_WORD_CNT - 1] & 0x1)) | 239 | wl1271_spi_read_busy(wl)) { |
271 | wl1271_spi_read_busy(wl, buf, len); */ | 240 | memset(buf, 0, len); |
241 | return; | ||
242 | } | ||
243 | |||
244 | spi_message_init(&m); | ||
245 | memset(t, 0, sizeof(t)); | ||
246 | |||
247 | t[0].rx_buf = buf; | ||
248 | t[0].len = len; | ||
249 | t[0].cs_change = true; | ||
250 | spi_message_add_tail(&t[0], &m); | ||
251 | |||
252 | spi_sync(wl_to_spi(wl), &m); | ||
272 | 253 | ||
273 | wl1271_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd)); | 254 | wl1271_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd)); |
274 | wl1271_dump(DEBUG_SPI, "spi_read buf <- ", buf, len); | 255 | wl1271_dump(DEBUG_SPI, "spi_read buf <- ", buf, len); |
@@ -443,7 +424,7 @@ static int __devexit wl1271_remove(struct spi_device *spi) | |||
443 | 424 | ||
444 | static struct spi_driver wl1271_spi_driver = { | 425 | static struct spi_driver wl1271_spi_driver = { |
445 | .driver = { | 426 | .driver = { |
446 | .name = "wl1271", | 427 | .name = "wl1271_spi", |
447 | .bus = &spi_bus_type, | 428 | .bus = &spi_bus_type, |
448 | .owner = THIS_MODULE, | 429 | .owner = THIS_MODULE, |
449 | }, | 430 | }, |