blob: e2f42a13395249d96a8406a6599ff5921804cf74 [file] [log] [blame]
Kalle Valobdcd8172011-07-18 00:22:30 +03001/*
2 * Copyright (c) 2004-2011 Atheros Communications Inc.
Vasanthakumar Thiagarajan1b2df402012-02-06 20:15:53 +05303 * Copyright (c) 2011-2012 Qualcomm Atheros, Inc.
Kalle Valobdcd8172011-07-18 00:22:30 +03004 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
Paul Gortmaker9d9779e2011-07-03 15:21:01 -040018#include <linux/module.h>
Kalle Valobdcd8172011-07-18 00:22:30 +030019#include <linux/mmc/card.h>
20#include <linux/mmc/mmc.h>
21#include <linux/mmc/host.h>
22#include <linux/mmc/sdio_func.h>
23#include <linux/mmc/sdio_ids.h>
24#include <linux/mmc/sdio.h>
25#include <linux/mmc/sd.h>
Kalle Valo2e1cb232011-10-05 12:23:49 +030026#include "hif.h"
Kalle Valobdcd8172011-07-18 00:22:30 +030027#include "hif-ops.h"
28#include "target.h"
29#include "debug.h"
Vivek Natarajan9df337a2011-09-15 20:30:43 +053030#include "cfg80211.h"
Kalle Valobdcd8172011-07-18 00:22:30 +030031
32struct ath6kl_sdio {
33 struct sdio_func *func;
34
35 spinlock_t lock;
36
37 /* free list */
38 struct list_head bus_req_freeq;
39
40 /* available bus requests */
41 struct bus_request bus_req[BUS_REQUEST_MAX_NUM];
42
43 struct ath6kl *ar;
Raja Manifdb28582011-11-21 12:26:51 +053044
Kalle Valobdcd8172011-07-18 00:22:30 +030045 u8 *dma_buffer;
46
Raja Manifdb28582011-11-21 12:26:51 +053047 /* protects access to dma_buffer */
48 struct mutex dma_buffer_mutex;
49
Kalle Valobdcd8172011-07-18 00:22:30 +030050 /* scatter request list head */
51 struct list_head scat_req;
52
Raja Manid1f41592012-02-09 12:57:12 +053053 atomic_t irq_handling;
54 wait_queue_head_t irq_wq;
Vasanthakumar Thiagarajan9d826822012-01-04 15:57:19 +053055
Kalle Valobdcd8172011-07-18 00:22:30 +030056 spinlock_t scat_lock;
Kalle Valo32a07e42011-10-30 21:15:57 +020057 bool scatter_enabled;
58
Kalle Valobdcd8172011-07-18 00:22:30 +030059 bool is_disabled;
Kalle Valobdcd8172011-07-18 00:22:30 +030060 const struct sdio_device_id *id;
61 struct work_struct wr_async_work;
62 struct list_head wr_asyncq;
63 spinlock_t wr_async_lock;
64};
65
66#define CMD53_ARG_READ 0
67#define CMD53_ARG_WRITE 1
68#define CMD53_ARG_BLOCK_BASIS 1
69#define CMD53_ARG_FIXED_ADDRESS 0
70#define CMD53_ARG_INCR_ADDRESS 1
71
72static inline struct ath6kl_sdio *ath6kl_sdio_priv(struct ath6kl *ar)
73{
74 return ar->hif_priv;
75}
76
77/*
78 * Macro to check if DMA buffer is WORD-aligned and DMA-able.
79 * Most host controllers assume the buffer is DMA'able and will
80 * bug-check otherwise (i.e. buffers on the stack). virt_addr_valid
81 * check fails on stack memory.
82 */
83static inline bool buf_needs_bounce(u8 *buf)
84{
85 return ((unsigned long) buf & 0x3) || !virt_addr_valid(buf);
86}
87
88static void ath6kl_sdio_set_mbox_info(struct ath6kl *ar)
89{
90 struct ath6kl_mbox_info *mbox_info = &ar->mbox_info;
91
92 /* EP1 has an extended range */
93 mbox_info->htc_addr = HIF_MBOX_BASE_ADDR;
94 mbox_info->htc_ext_addr = HIF_MBOX0_EXT_BASE_ADDR;
95 mbox_info->htc_ext_sz = HIF_MBOX0_EXT_WIDTH;
96 mbox_info->block_size = HIF_MBOX_BLOCK_SIZE;
97 mbox_info->gmbox_addr = HIF_GMBOX_BASE_ADDR;
98 mbox_info->gmbox_sz = HIF_GMBOX_WIDTH;
99}
100
101static inline void ath6kl_sdio_set_cmd53_arg(u32 *arg, u8 rw, u8 func,
102 u8 mode, u8 opcode, u32 addr,
103 u16 blksz)
104{
105 *arg = (((rw & 1) << 31) |
106 ((func & 0x7) << 28) |
107 ((mode & 1) << 27) |
108 ((opcode & 1) << 26) |
109 ((addr & 0x1FFFF) << 9) |
110 (blksz & 0x1FF));
111}
112
113static inline void ath6kl_sdio_set_cmd52_arg(u32 *arg, u8 write, u8 raw,
114 unsigned int address,
115 unsigned char val)
116{
117 const u8 func = 0;
118
119 *arg = ((write & 1) << 31) |
120 ((func & 0x7) << 28) |
121 ((raw & 1) << 27) |
122 (1 << 26) |
123 ((address & 0x1FFFF) << 9) |
124 (1 << 8) |
125 (val & 0xFF);
126}
127
128static int ath6kl_sdio_func0_cmd52_wr_byte(struct mmc_card *card,
129 unsigned int address,
130 unsigned char byte)
131{
132 struct mmc_command io_cmd;
133
134 memset(&io_cmd, 0, sizeof(io_cmd));
135 ath6kl_sdio_set_cmd52_arg(&io_cmd.arg, 1, 0, address, byte);
136 io_cmd.opcode = SD_IO_RW_DIRECT;
137 io_cmd.flags = MMC_RSP_R5 | MMC_CMD_AC;
138
139 return mmc_wait_for_cmd(card->host, &io_cmd, 0);
140}
141
Vasanthakumar Thiagarajanda220692011-07-16 20:29:16 +0530142static int ath6kl_sdio_io(struct sdio_func *func, u32 request, u32 addr,
143 u8 *buf, u32 len)
144{
145 int ret = 0;
146
Vasanthakumar Thiagarajan861dd052011-09-30 21:46:59 +0530147 sdio_claim_host(func);
148
Vasanthakumar Thiagarajanda220692011-07-16 20:29:16 +0530149 if (request & HIF_WRITE) {
Kalle Valof7325b82011-09-27 14:30:58 +0300150 /* FIXME: looks like ugly workaround for something */
Vasanthakumar Thiagarajanda220692011-07-16 20:29:16 +0530151 if (addr >= HIF_MBOX_BASE_ADDR &&
152 addr <= HIF_MBOX_END_ADDR)
153 addr += (HIF_MBOX_WIDTH - len);
154
Kalle Valof7325b82011-09-27 14:30:58 +0300155 /* FIXME: this also looks like ugly workaround */
Vasanthakumar Thiagarajanda220692011-07-16 20:29:16 +0530156 if (addr == HIF_MBOX0_EXT_BASE_ADDR)
157 addr += HIF_MBOX0_EXT_WIDTH - len;
158
159 if (request & HIF_FIXED_ADDRESS)
160 ret = sdio_writesb(func, addr, buf, len);
161 else
162 ret = sdio_memcpy_toio(func, addr, buf, len);
163 } else {
164 if (request & HIF_FIXED_ADDRESS)
165 ret = sdio_readsb(func, buf, addr, len);
166 else
167 ret = sdio_memcpy_fromio(func, buf, addr, len);
168 }
169
Vasanthakumar Thiagarajan861dd052011-09-30 21:46:59 +0530170 sdio_release_host(func);
171
Kalle Valof7325b82011-09-27 14:30:58 +0300172 ath6kl_dbg(ATH6KL_DBG_SDIO, "%s addr 0x%x%s buf 0x%p len %d\n",
173 request & HIF_WRITE ? "wr" : "rd", addr,
174 request & HIF_FIXED_ADDRESS ? " (fixed)" : "", buf, len);
175 ath6kl_dbg_dump(ATH6KL_DBG_SDIO_DUMP, NULL, "sdio ", buf, len);
176
Vasanthakumar Thiagarajanda220692011-07-16 20:29:16 +0530177 return ret;
178}
179
Kalle Valobdcd8172011-07-18 00:22:30 +0300180static struct bus_request *ath6kl_sdio_alloc_busreq(struct ath6kl_sdio *ar_sdio)
181{
182 struct bus_request *bus_req;
Kalle Valobdcd8172011-07-18 00:22:30 +0300183
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530184 spin_lock_bh(&ar_sdio->lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300185
186 if (list_empty(&ar_sdio->bus_req_freeq)) {
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530187 spin_unlock_bh(&ar_sdio->lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300188 return NULL;
189 }
190
191 bus_req = list_first_entry(&ar_sdio->bus_req_freeq,
192 struct bus_request, list);
193 list_del(&bus_req->list);
194
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530195 spin_unlock_bh(&ar_sdio->lock);
Kalle Valof7325b82011-09-27 14:30:58 +0300196 ath6kl_dbg(ATH6KL_DBG_SCATTER, "%s: bus request 0x%p\n",
197 __func__, bus_req);
Kalle Valobdcd8172011-07-18 00:22:30 +0300198
199 return bus_req;
200}
201
202static void ath6kl_sdio_free_bus_req(struct ath6kl_sdio *ar_sdio,
203 struct bus_request *bus_req)
204{
Kalle Valof7325b82011-09-27 14:30:58 +0300205 ath6kl_dbg(ATH6KL_DBG_SCATTER, "%s: bus request 0x%p\n",
206 __func__, bus_req);
Kalle Valobdcd8172011-07-18 00:22:30 +0300207
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530208 spin_lock_bh(&ar_sdio->lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300209 list_add_tail(&bus_req->list, &ar_sdio->bus_req_freeq);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530210 spin_unlock_bh(&ar_sdio->lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300211}
212
213static void ath6kl_sdio_setup_scat_data(struct hif_scatter_req *scat_req,
Kalle Valobdcd8172011-07-18 00:22:30 +0300214 struct mmc_data *data)
215{
216 struct scatterlist *sg;
217 int i;
218
219 data->blksz = HIF_MBOX_BLOCK_SIZE;
220 data->blocks = scat_req->len / HIF_MBOX_BLOCK_SIZE;
221
222 ath6kl_dbg(ATH6KL_DBG_SCATTER,
223 "hif-scatter: (%s) addr: 0x%X, (block len: %d, block count: %d) , (tot:%d,sg:%d)\n",
224 (scat_req->req & HIF_WRITE) ? "WR" : "RD", scat_req->addr,
225 data->blksz, data->blocks, scat_req->len,
226 scat_req->scat_entries);
227
228 data->flags = (scat_req->req & HIF_WRITE) ? MMC_DATA_WRITE :
229 MMC_DATA_READ;
230
231 /* fill SG entries */
Vasanthakumar Thiagarajand4df7892011-07-16 20:29:07 +0530232 sg = scat_req->sgentries;
Kalle Valobdcd8172011-07-18 00:22:30 +0300233 sg_init_table(sg, scat_req->scat_entries);
234
235 /* assemble SG list */
236 for (i = 0; i < scat_req->scat_entries; i++, sg++) {
Kalle Valobdcd8172011-07-18 00:22:30 +0300237 ath6kl_dbg(ATH6KL_DBG_SCATTER, "%d: addr:0x%p, len:%d\n",
238 i, scat_req->scat_list[i].buf,
239 scat_req->scat_list[i].len);
240
241 sg_set_buf(sg, scat_req->scat_list[i].buf,
242 scat_req->scat_list[i].len);
243 }
244
245 /* set scatter-gather table for request */
Vasanthakumar Thiagarajand4df7892011-07-16 20:29:07 +0530246 data->sg = scat_req->sgentries;
Kalle Valobdcd8172011-07-18 00:22:30 +0300247 data->sg_len = scat_req->scat_entries;
248}
249
250static int ath6kl_sdio_scat_rw(struct ath6kl_sdio *ar_sdio,
251 struct bus_request *req)
252{
253 struct mmc_request mmc_req;
254 struct mmc_command cmd;
255 struct mmc_data data;
256 struct hif_scatter_req *scat_req;
257 u8 opcode, rw;
Vasanthakumar Thiagarajan348a8fb2011-07-16 20:29:17 +0530258 int status, len;
Kalle Valobdcd8172011-07-18 00:22:30 +0300259
260 scat_req = req->scat_req;
261
Vasanthakumar Thiagarajan348a8fb2011-07-16 20:29:17 +0530262 if (scat_req->virt_scat) {
263 len = scat_req->len;
264 if (scat_req->req & HIF_BLOCK_BASIS)
265 len = round_down(len, HIF_MBOX_BLOCK_SIZE);
266
267 status = ath6kl_sdio_io(ar_sdio->func, scat_req->req,
268 scat_req->addr, scat_req->virt_dma_buf,
269 len);
270 goto scat_complete;
271 }
272
Kalle Valobdcd8172011-07-18 00:22:30 +0300273 memset(&mmc_req, 0, sizeof(struct mmc_request));
274 memset(&cmd, 0, sizeof(struct mmc_command));
275 memset(&data, 0, sizeof(struct mmc_data));
276
Vasanthakumar Thiagarajand4df7892011-07-16 20:29:07 +0530277 ath6kl_sdio_setup_scat_data(scat_req, &data);
Kalle Valobdcd8172011-07-18 00:22:30 +0300278
279 opcode = (scat_req->req & HIF_FIXED_ADDRESS) ?
280 CMD53_ARG_FIXED_ADDRESS : CMD53_ARG_INCR_ADDRESS;
281
282 rw = (scat_req->req & HIF_WRITE) ? CMD53_ARG_WRITE : CMD53_ARG_READ;
283
284 /* Fixup the address so that the last byte will fall on MBOX EOM */
285 if (scat_req->req & HIF_WRITE) {
286 if (scat_req->addr == HIF_MBOX_BASE_ADDR)
287 scat_req->addr += HIF_MBOX_WIDTH - scat_req->len;
288 else
289 /* Uses extended address range */
290 scat_req->addr += HIF_MBOX0_EXT_WIDTH - scat_req->len;
291 }
292
293 /* set command argument */
294 ath6kl_sdio_set_cmd53_arg(&cmd.arg, rw, ar_sdio->func->num,
295 CMD53_ARG_BLOCK_BASIS, opcode, scat_req->addr,
296 data.blocks);
297
298 cmd.opcode = SD_IO_RW_EXTENDED;
299 cmd.flags = MMC_RSP_SPI_R5 | MMC_RSP_R5 | MMC_CMD_ADTC;
300
301 mmc_req.cmd = &cmd;
302 mmc_req.data = &data;
303
Vasanthakumar Thiagarajan861dd052011-09-30 21:46:59 +0530304 sdio_claim_host(ar_sdio->func);
305
Kalle Valobdcd8172011-07-18 00:22:30 +0300306 mmc_set_data_timeout(&data, ar_sdio->func->card);
307 /* synchronous call to process request */
308 mmc_wait_for_req(ar_sdio->func->card->host, &mmc_req);
309
Vasanthakumar Thiagarajan861dd052011-09-30 21:46:59 +0530310 sdio_release_host(ar_sdio->func);
311
Kalle Valobdcd8172011-07-18 00:22:30 +0300312 status = cmd.error ? cmd.error : data.error;
Vasanthakumar Thiagarajan348a8fb2011-07-16 20:29:17 +0530313
314scat_complete:
Kalle Valobdcd8172011-07-18 00:22:30 +0300315 scat_req->status = status;
316
317 if (scat_req->status)
318 ath6kl_err("Scatter write request failed:%d\n",
319 scat_req->status);
320
321 if (scat_req->req & HIF_ASYNCHRONOUS)
Vasanthakumar Thiagarajane041c7f2011-07-16 20:29:09 +0530322 scat_req->complete(ar_sdio->ar->htc_target, scat_req);
Kalle Valobdcd8172011-07-18 00:22:30 +0300323
324 return status;
325}
326
Vasanthakumar Thiagarajan3df505a2011-07-16 20:29:10 +0530327static int ath6kl_sdio_alloc_prep_scat_req(struct ath6kl_sdio *ar_sdio,
328 int n_scat_entry, int n_scat_req,
329 bool virt_scat)
330{
331 struct hif_scatter_req *s_req;
332 struct bus_request *bus_req;
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530333 int i, scat_req_sz, scat_list_sz, sg_sz, buf_sz;
334 u8 *virt_buf;
Vasanthakumar Thiagarajan3df505a2011-07-16 20:29:10 +0530335
336 scat_list_sz = (n_scat_entry - 1) * sizeof(struct hif_scatter_item);
337 scat_req_sz = sizeof(*s_req) + scat_list_sz;
338
339 if (!virt_scat)
340 sg_sz = sizeof(struct scatterlist) * n_scat_entry;
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530341 else
342 buf_sz = 2 * L1_CACHE_BYTES +
343 ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER;
Vasanthakumar Thiagarajan3df505a2011-07-16 20:29:10 +0530344
345 for (i = 0; i < n_scat_req; i++) {
346 /* allocate the scatter request */
347 s_req = kzalloc(scat_req_sz, GFP_KERNEL);
348 if (!s_req)
349 return -ENOMEM;
350
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530351 if (virt_scat) {
352 virt_buf = kzalloc(buf_sz, GFP_KERNEL);
353 if (!virt_buf) {
354 kfree(s_req);
355 return -ENOMEM;
356 }
357
358 s_req->virt_dma_buf =
359 (u8 *)L1_CACHE_ALIGN((unsigned long)virt_buf);
360 } else {
Vasanthakumar Thiagarajan3df505a2011-07-16 20:29:10 +0530361 /* allocate sglist */
362 s_req->sgentries = kzalloc(sg_sz, GFP_KERNEL);
363
364 if (!s_req->sgentries) {
365 kfree(s_req);
366 return -ENOMEM;
367 }
368 }
369
370 /* allocate a bus request for this scatter request */
371 bus_req = ath6kl_sdio_alloc_busreq(ar_sdio);
372 if (!bus_req) {
373 kfree(s_req->sgentries);
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530374 kfree(s_req->virt_dma_buf);
Vasanthakumar Thiagarajan3df505a2011-07-16 20:29:10 +0530375 kfree(s_req);
376 return -ENOMEM;
377 }
378
379 /* assign the scatter request to this bus request */
380 bus_req->scat_req = s_req;
381 s_req->busrequest = bus_req;
382
Vasanthakumar Thiagarajan4a005c32011-07-16 20:29:15 +0530383 s_req->virt_scat = virt_scat;
384
Vasanthakumar Thiagarajan3df505a2011-07-16 20:29:10 +0530385 /* add it to the scatter pool */
386 hif_scatter_req_add(ar_sdio->ar, s_req);
387 }
388
389 return 0;
390}
391
Kalle Valobdcd8172011-07-18 00:22:30 +0300392static int ath6kl_sdio_read_write_sync(struct ath6kl *ar, u32 addr, u8 *buf,
393 u32 len, u32 request)
394{
395 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
396 u8 *tbuf = NULL;
397 int ret;
398 bool bounced = false;
399
400 if (request & HIF_BLOCK_BASIS)
401 len = round_down(len, HIF_MBOX_BLOCK_SIZE);
402
403 if (buf_needs_bounce(buf)) {
404 if (!ar_sdio->dma_buffer)
405 return -ENOMEM;
Raja Manifdb28582011-11-21 12:26:51 +0530406 mutex_lock(&ar_sdio->dma_buffer_mutex);
Kalle Valobdcd8172011-07-18 00:22:30 +0300407 tbuf = ar_sdio->dma_buffer;
Raja Manidaa16bc2012-03-02 18:02:08 +0530408
409 if (request & HIF_WRITE)
410 memcpy(tbuf, buf, len);
411
Kalle Valobdcd8172011-07-18 00:22:30 +0300412 bounced = true;
413 } else
414 tbuf = buf;
415
Vasanthakumar Thiagarajanda220692011-07-16 20:29:16 +0530416 ret = ath6kl_sdio_io(ar_sdio->func, request, addr, tbuf, len);
417 if ((request & HIF_READ) && bounced)
418 memcpy(buf, tbuf, len);
Kalle Valobdcd8172011-07-18 00:22:30 +0300419
Raja Manifdb28582011-11-21 12:26:51 +0530420 if (bounced)
421 mutex_unlock(&ar_sdio->dma_buffer_mutex);
422
Kalle Valobdcd8172011-07-18 00:22:30 +0300423 return ret;
424}
425
426static void __ath6kl_sdio_write_async(struct ath6kl_sdio *ar_sdio,
427 struct bus_request *req)
428{
429 if (req->scat_req)
430 ath6kl_sdio_scat_rw(ar_sdio, req);
431 else {
432 void *context;
433 int status;
434
435 status = ath6kl_sdio_read_write_sync(ar_sdio->ar, req->address,
436 req->buffer, req->length,
437 req->request);
438 context = req->packet;
439 ath6kl_sdio_free_bus_req(ar_sdio, req);
Kalle Valo8e8ddb22011-10-05 12:23:33 +0300440 ath6kl_hif_rw_comp_handler(context, status);
Kalle Valobdcd8172011-07-18 00:22:30 +0300441 }
442}
443
444static void ath6kl_sdio_write_async_work(struct work_struct *work)
445{
446 struct ath6kl_sdio *ar_sdio;
Kalle Valobdcd8172011-07-18 00:22:30 +0300447 struct bus_request *req, *tmp_req;
448
449 ar_sdio = container_of(work, struct ath6kl_sdio, wr_async_work);
Kalle Valobdcd8172011-07-18 00:22:30 +0300450
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530451 spin_lock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300452 list_for_each_entry_safe(req, tmp_req, &ar_sdio->wr_asyncq, list) {
453 list_del(&req->list);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530454 spin_unlock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300455 __ath6kl_sdio_write_async(ar_sdio, req);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530456 spin_lock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300457 }
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530458 spin_unlock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300459}
460
461static void ath6kl_sdio_irq_handler(struct sdio_func *func)
462{
463 int status;
464 struct ath6kl_sdio *ar_sdio;
465
Kalle Valof7325b82011-09-27 14:30:58 +0300466 ath6kl_dbg(ATH6KL_DBG_SDIO, "irq\n");
467
Kalle Valobdcd8172011-07-18 00:22:30 +0300468 ar_sdio = sdio_get_drvdata(func);
Raja Manid1f41592012-02-09 12:57:12 +0530469 atomic_set(&ar_sdio->irq_handling, 1);
Kalle Valobdcd8172011-07-18 00:22:30 +0300470 /*
471 * Release the host during interrups so we can pick it back up when
472 * we process commands.
473 */
474 sdio_release_host(ar_sdio->func);
475
Kalle Valo8e8ddb22011-10-05 12:23:33 +0300476 status = ath6kl_hif_intr_bh_handler(ar_sdio->ar);
Kalle Valobdcd8172011-07-18 00:22:30 +0300477 sdio_claim_host(ar_sdio->func);
Raja Manid1f41592012-02-09 12:57:12 +0530478
479 atomic_set(&ar_sdio->irq_handling, 0);
480 wake_up(&ar_sdio->irq_wq);
481
Kalle Valobdcd8172011-07-18 00:22:30 +0300482 WARN_ON(status && status != -ECANCELED);
483}
484
Kalle Valob2e75692011-10-27 18:48:14 +0300485static int ath6kl_sdio_power_on(struct ath6kl *ar)
Kalle Valobdcd8172011-07-18 00:22:30 +0300486{
Kalle Valob2e75692011-10-27 18:48:14 +0300487 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
Kalle Valobdcd8172011-07-18 00:22:30 +0300488 struct sdio_func *func = ar_sdio->func;
489 int ret = 0;
490
491 if (!ar_sdio->is_disabled)
492 return 0;
493
Kalle Valo3ef987b2011-10-24 12:18:07 +0300494 ath6kl_dbg(ATH6KL_DBG_BOOT, "sdio power on\n");
495
Kalle Valobdcd8172011-07-18 00:22:30 +0300496 sdio_claim_host(func);
497
498 ret = sdio_enable_func(func);
499 if (ret) {
500 ath6kl_err("Unable to enable sdio func: %d)\n", ret);
501 sdio_release_host(func);
502 return ret;
503 }
504
505 sdio_release_host(func);
506
507 /*
508 * Wait for hardware to initialise. It should take a lot less than
509 * 10 ms but let's be conservative here.
510 */
511 msleep(10);
512
513 ar_sdio->is_disabled = false;
514
515 return ret;
516}
517
Kalle Valob2e75692011-10-27 18:48:14 +0300518static int ath6kl_sdio_power_off(struct ath6kl *ar)
Kalle Valobdcd8172011-07-18 00:22:30 +0300519{
Kalle Valob2e75692011-10-27 18:48:14 +0300520 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
Kalle Valobdcd8172011-07-18 00:22:30 +0300521 int ret;
522
523 if (ar_sdio->is_disabled)
524 return 0;
525
Kalle Valo3ef987b2011-10-24 12:18:07 +0300526 ath6kl_dbg(ATH6KL_DBG_BOOT, "sdio power off\n");
527
Kalle Valobdcd8172011-07-18 00:22:30 +0300528 /* Disable the card */
529 sdio_claim_host(ar_sdio->func);
530 ret = sdio_disable_func(ar_sdio->func);
531 sdio_release_host(ar_sdio->func);
532
533 if (ret)
534 return ret;
535
536 ar_sdio->is_disabled = true;
537
538 return ret;
539}
540
541static int ath6kl_sdio_write_async(struct ath6kl *ar, u32 address, u8 *buffer,
542 u32 length, u32 request,
543 struct htc_packet *packet)
544{
545 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
546 struct bus_request *bus_req;
Kalle Valobdcd8172011-07-18 00:22:30 +0300547
548 bus_req = ath6kl_sdio_alloc_busreq(ar_sdio);
549
550 if (!bus_req)
551 return -ENOMEM;
552
553 bus_req->address = address;
554 bus_req->buffer = buffer;
555 bus_req->length = length;
556 bus_req->request = request;
557 bus_req->packet = packet;
558
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530559 spin_lock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300560 list_add_tail(&bus_req->list, &ar_sdio->wr_asyncq);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530561 spin_unlock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300562 queue_work(ar->ath6kl_wq, &ar_sdio->wr_async_work);
563
564 return 0;
565}
566
567static void ath6kl_sdio_irq_enable(struct ath6kl *ar)
568{
569 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
570 int ret;
571
572 sdio_claim_host(ar_sdio->func);
573
574 /* Register the isr */
575 ret = sdio_claim_irq(ar_sdio->func, ath6kl_sdio_irq_handler);
576 if (ret)
577 ath6kl_err("Failed to claim sdio irq: %d\n", ret);
578
579 sdio_release_host(ar_sdio->func);
580}
581
Raja Manid1f41592012-02-09 12:57:12 +0530582static bool ath6kl_sdio_is_on_irq(struct ath6kl *ar)
583{
584 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
585
586 return !atomic_read(&ar_sdio->irq_handling);
587}
588
Kalle Valobdcd8172011-07-18 00:22:30 +0300589static void ath6kl_sdio_irq_disable(struct ath6kl *ar)
590{
591 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
592 int ret;
593
594 sdio_claim_host(ar_sdio->func);
595
Raja Manid1f41592012-02-09 12:57:12 +0530596 if (atomic_read(&ar_sdio->irq_handling)) {
597 sdio_release_host(ar_sdio->func);
598
599 ret = wait_event_interruptible(ar_sdio->irq_wq,
600 ath6kl_sdio_is_on_irq(ar));
601 if (ret)
602 return;
603
604 sdio_claim_host(ar_sdio->func);
605 }
Kalle Valobdcd8172011-07-18 00:22:30 +0300606
607 ret = sdio_release_irq(ar_sdio->func);
608 if (ret)
609 ath6kl_err("Failed to release sdio irq: %d\n", ret);
610
611 sdio_release_host(ar_sdio->func);
612}
613
614static struct hif_scatter_req *ath6kl_sdio_scatter_req_get(struct ath6kl *ar)
615{
616 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
617 struct hif_scatter_req *node = NULL;
Kalle Valobdcd8172011-07-18 00:22:30 +0300618
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530619 spin_lock_bh(&ar_sdio->scat_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300620
621 if (!list_empty(&ar_sdio->scat_req)) {
622 node = list_first_entry(&ar_sdio->scat_req,
623 struct hif_scatter_req, list);
624 list_del(&node->list);
Chilam Ngb29072c2012-02-07 01:33:00 -0800625
626 node->scat_q_depth = get_queue_depth(&ar_sdio->scat_req);
Kalle Valobdcd8172011-07-18 00:22:30 +0300627 }
628
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530629 spin_unlock_bh(&ar_sdio->scat_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300630
631 return node;
632}
633
634static void ath6kl_sdio_scatter_req_add(struct ath6kl *ar,
635 struct hif_scatter_req *s_req)
636{
637 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
Kalle Valobdcd8172011-07-18 00:22:30 +0300638
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530639 spin_lock_bh(&ar_sdio->scat_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300640
641 list_add_tail(&s_req->list, &ar_sdio->scat_req);
642
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530643 spin_unlock_bh(&ar_sdio->scat_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300644
645}
646
Vasanthakumar Thiagarajanc630d182011-07-16 20:29:06 +0530647/* scatter gather read write request */
648static int ath6kl_sdio_async_rw_scatter(struct ath6kl *ar,
649 struct hif_scatter_req *scat_req)
650{
651 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
Vasanthakumar Thiagarajanc630d182011-07-16 20:29:06 +0530652 u32 request = scat_req->req;
653 int status = 0;
Vasanthakumar Thiagarajanc630d182011-07-16 20:29:06 +0530654
655 if (!scat_req->len)
656 return -EINVAL;
657
658 ath6kl_dbg(ATH6KL_DBG_SCATTER,
659 "hif-scatter: total len: %d scatter entries: %d\n",
660 scat_req->len, scat_req->scat_entries);
661
Vasanthakumar Thiagarajan861dd052011-09-30 21:46:59 +0530662 if (request & HIF_SYNCHRONOUS)
Vasanthakumar Thiagarajand4df7892011-07-16 20:29:07 +0530663 status = ath6kl_sdio_scat_rw(ar_sdio, scat_req->busrequest);
Vasanthakumar Thiagarajan861dd052011-09-30 21:46:59 +0530664 else {
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530665 spin_lock_bh(&ar_sdio->wr_async_lock);
Vasanthakumar Thiagarajand4df7892011-07-16 20:29:07 +0530666 list_add_tail(&scat_req->busrequest->list, &ar_sdio->wr_asyncq);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530667 spin_unlock_bh(&ar_sdio->wr_async_lock);
Vasanthakumar Thiagarajanc630d182011-07-16 20:29:06 +0530668 queue_work(ar->ath6kl_wq, &ar_sdio->wr_async_work);
669 }
670
671 return status;
672}
673
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530674/* clean up scatter support */
675static void ath6kl_sdio_cleanup_scatter(struct ath6kl *ar)
676{
677 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
678 struct hif_scatter_req *s_req, *tmp_req;
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530679
680 /* empty the free list */
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530681 spin_lock_bh(&ar_sdio->scat_lock);
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530682 list_for_each_entry_safe(s_req, tmp_req, &ar_sdio->scat_req, list) {
683 list_del(&s_req->list);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530684 spin_unlock_bh(&ar_sdio->scat_lock);
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530685
Kalle Valo32a07e42011-10-30 21:15:57 +0200686 /*
687 * FIXME: should we also call completion handler with
688 * ath6kl_hif_rw_comp_handler() with status -ECANCELED so
689 * that the packet is properly freed?
690 */
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530691 if (s_req->busrequest)
692 ath6kl_sdio_free_bus_req(ar_sdio, s_req->busrequest);
693 kfree(s_req->virt_dma_buf);
694 kfree(s_req->sgentries);
695 kfree(s_req);
696
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530697 spin_lock_bh(&ar_sdio->scat_lock);
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530698 }
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530699 spin_unlock_bh(&ar_sdio->scat_lock);
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530700}
701
702/* setup of HIF scatter resources */
Vasanthakumar Thiagarajan50745af2011-07-18 14:23:29 +0530703static int ath6kl_sdio_enable_scatter(struct ath6kl *ar)
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530704{
705 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
Vasanthakumar Thiagarajan50745af2011-07-18 14:23:29 +0530706 struct htc_target *target = ar->htc_target;
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530707 int ret;
708 bool virt_scat = false;
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530709
Kalle Valo32a07e42011-10-30 21:15:57 +0200710 if (ar_sdio->scatter_enabled)
711 return 0;
712
713 ar_sdio->scatter_enabled = true;
714
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530715 /* check if host supports scatter and it meets our requirements */
716 if (ar_sdio->func->card->host->max_segs < MAX_SCATTER_ENTRIES_PER_REQ) {
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530717 ath6kl_err("host only supports scatter of :%d entries, need: %d\n",
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530718 ar_sdio->func->card->host->max_segs,
719 MAX_SCATTER_ENTRIES_PER_REQ);
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530720 virt_scat = true;
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530721 }
722
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530723 if (!virt_scat) {
724 ret = ath6kl_sdio_alloc_prep_scat_req(ar_sdio,
725 MAX_SCATTER_ENTRIES_PER_REQ,
726 MAX_SCATTER_REQUESTS, virt_scat);
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530727
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530728 if (!ret) {
Kalle Valo3ef987b2011-10-24 12:18:07 +0300729 ath6kl_dbg(ATH6KL_DBG_BOOT,
730 "hif-scatter enabled requests %d entries %d\n",
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530731 MAX_SCATTER_REQUESTS,
732 MAX_SCATTER_ENTRIES_PER_REQ);
733
Vasanthakumar Thiagarajan50745af2011-07-18 14:23:29 +0530734 target->max_scat_entries = MAX_SCATTER_ENTRIES_PER_REQ;
735 target->max_xfer_szper_scatreq =
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530736 MAX_SCATTER_REQ_TRANSFER_SIZE;
737 } else {
738 ath6kl_sdio_cleanup_scatter(ar);
739 ath6kl_warn("hif scatter resource setup failed, trying virtual scatter method\n");
740 }
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530741 }
742
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530743 if (virt_scat || ret) {
744 ret = ath6kl_sdio_alloc_prep_scat_req(ar_sdio,
745 ATH6KL_SCATTER_ENTRIES_PER_REQ,
746 ATH6KL_SCATTER_REQS, virt_scat);
747
748 if (ret) {
749 ath6kl_err("failed to alloc virtual scatter resources !\n");
750 ath6kl_sdio_cleanup_scatter(ar);
751 return ret;
752 }
753
Kalle Valo3ef987b2011-10-24 12:18:07 +0300754 ath6kl_dbg(ATH6KL_DBG_BOOT,
755 "virtual scatter enabled requests %d entries %d\n",
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530756 ATH6KL_SCATTER_REQS, ATH6KL_SCATTER_ENTRIES_PER_REQ);
757
Vasanthakumar Thiagarajan50745af2011-07-18 14:23:29 +0530758 target->max_scat_entries = ATH6KL_SCATTER_ENTRIES_PER_REQ;
759 target->max_xfer_szper_scatreq =
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530760 ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER;
761 }
762
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530763 return 0;
764}
765
Kalle Valoe28e8102011-11-01 08:44:36 +0200766static int ath6kl_sdio_config(struct ath6kl *ar)
767{
768 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
769 struct sdio_func *func = ar_sdio->func;
770 int ret;
771
772 sdio_claim_host(func);
773
774 if ((ar_sdio->id->device & MANUFACTURER_ID_ATH6KL_BASE_MASK) >=
775 MANUFACTURER_ID_AR6003_BASE) {
776 /* enable 4-bit ASYNC interrupt on AR6003 or later */
777 ret = ath6kl_sdio_func0_cmd52_wr_byte(func->card,
778 CCCR_SDIO_IRQ_MODE_REG,
779 SDIO_IRQ_MODE_ASYNC_4BIT_IRQ);
780 if (ret) {
781 ath6kl_err("Failed to enable 4-bit async irq mode %d\n",
782 ret);
783 goto out;
784 }
785
786 ath6kl_dbg(ATH6KL_DBG_BOOT, "4-bit async irq mode enabled\n");
787 }
788
789 /* give us some time to enable, in ms */
790 func->enable_timeout = 100;
791
792 ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE);
793 if (ret) {
794 ath6kl_err("Set sdio block size %d failed: %d)\n",
795 HIF_MBOX_BLOCK_SIZE, ret);
Kalle Valoe28e8102011-11-01 08:44:36 +0200796 goto out;
797 }
798
799out:
800 sdio_release_host(func);
801
802 return ret;
803}
804
Raja Manie390af72012-01-30 17:13:09 +0530805static int ath6kl_set_sdio_pm_caps(struct ath6kl *ar)
Kalle Valoabcb3442011-07-22 08:26:20 +0300806{
807 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
808 struct sdio_func *func = ar_sdio->func;
809 mmc_pm_flag_t flags;
810 int ret;
811
812 flags = sdio_get_host_pm_caps(func);
813
Kalle Valob4b2a0b2011-11-01 08:44:44 +0200814 ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio suspend pm_caps 0x%x\n", flags);
815
Raja Manie390af72012-01-30 17:13:09 +0530816 if (!(flags & MMC_PM_WAKE_SDIO_IRQ) ||
817 !(flags & MMC_PM_KEEP_POWER))
818 return -EINVAL;
Kalle Valoabcb3442011-07-22 08:26:20 +0300819
820 ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
821 if (ret) {
Raja Manie390af72012-01-30 17:13:09 +0530822 ath6kl_err("set sdio keep pwr flag failed: %d\n", ret);
Kalle Valoabcb3442011-07-22 08:26:20 +0300823 return ret;
824 }
825
Kalle Valo10509f92011-12-13 14:52:07 +0200826 /* sdio irq wakes up host */
Raja Manie390af72012-01-30 17:13:09 +0530827 ret = sdio_set_host_pm_flags(func, MMC_PM_WAKE_SDIO_IRQ);
828 if (ret)
829 ath6kl_err("set sdio wake irq flag failed: %d\n", ret);
830
831 return ret;
832}
833
834static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow)
835{
836 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
837 struct sdio_func *func = ar_sdio->func;
838 mmc_pm_flag_t flags;
839 int ret;
Kalle Valo10509f92011-12-13 14:52:07 +0200840
841 if (ar->state == ATH6KL_STATE_SCHED_SCAN) {
Raja Manie390af72012-01-30 17:13:09 +0530842 ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sched scan is in progress\n");
843
844 ret = ath6kl_set_sdio_pm_caps(ar);
845 if (ret)
846 goto cut_pwr;
847
Kalle Valo10509f92011-12-13 14:52:07 +0200848 ret = ath6kl_cfg80211_suspend(ar,
849 ATH6KL_CFG_SUSPEND_SCHED_SCAN,
850 NULL);
Kalle Valo10509f92011-12-13 14:52:07 +0200851 if (ret)
Raja Manie390af72012-01-30 17:13:09 +0530852 goto cut_pwr;
Kalle Valo10509f92011-12-13 14:52:07 +0200853
Raja Manie390af72012-01-30 17:13:09 +0530854 return 0;
Kalle Valo10509f92011-12-13 14:52:07 +0200855 }
856
Raja Manie390af72012-01-30 17:13:09 +0530857 if (ar->suspend_mode == WLAN_POWER_STATE_WOW ||
858 (!ar->suspend_mode && wow)) {
859
860 ret = ath6kl_set_sdio_pm_caps(ar);
861 if (ret)
862 goto cut_pwr;
863
Raja Manid7c44e02011-11-07 22:52:46 +0200864 ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_WOW, wow);
865 if (ret)
Raja Manie390af72012-01-30 17:13:09 +0530866 goto cut_pwr;
Raja Manid7c44e02011-11-07 22:52:46 +0200867
Raja Manie390af72012-01-30 17:13:09 +0530868 return 0;
Raja Manid7c44e02011-11-07 22:52:46 +0200869 }
870
Raja Manie390af72012-01-30 17:13:09 +0530871 if (ar->suspend_mode == WLAN_POWER_STATE_DEEP_SLEEP ||
872 !ar->suspend_mode) {
873
874 flags = sdio_get_host_pm_caps(func);
875 if (!(flags & MMC_PM_KEEP_POWER))
876 goto cut_pwr;
877
878 ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
879 if (ret)
880 goto cut_pwr;
881
Santosh Sajjancca4d5a2012-01-30 22:02:26 +0200882 /*
883 * Workaround to support Deep Sleep with MSM, set the host pm
884 * flag as MMC_PM_WAKE_SDIO_IRQ to allow SDCC deiver to disable
885 * the sdc2_clock and internally allows MSM to enter
886 * TCXO shutdown properly.
887 */
888 if ((flags & MMC_PM_WAKE_SDIO_IRQ)) {
889 ret = sdio_set_host_pm_flags(func,
890 MMC_PM_WAKE_SDIO_IRQ);
891 if (ret)
892 goto cut_pwr;
893 }
894
Raja Manie390af72012-01-30 17:13:09 +0530895 ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP,
896 NULL);
897 if (ret)
898 goto cut_pwr;
899
900 return 0;
901 }
902
903cut_pwr:
904 return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_CUTPOWER, NULL);
Kalle Valoabcb3442011-07-22 08:26:20 +0300905}
906
Chilam Ngaa6cffc2011-10-05 10:12:52 +0300907static int ath6kl_sdio_resume(struct ath6kl *ar)
908{
Kalle Valob4b2a0b2011-11-01 08:44:44 +0200909 switch (ar->state) {
910 case ATH6KL_STATE_OFF:
911 case ATH6KL_STATE_CUTPOWER:
912 ath6kl_dbg(ATH6KL_DBG_SUSPEND,
913 "sdio resume configuring sdio\n");
914
915 /* need to set sdio settings after power is cut from sdio */
916 ath6kl_sdio_config(ar);
917 break;
918
919 case ATH6KL_STATE_ON:
Kalle Valob4b2a0b2011-11-01 08:44:44 +0200920 break;
921
922 case ATH6KL_STATE_DEEPSLEEP:
923 break;
Raja Manid7c44e02011-11-07 22:52:46 +0200924
925 case ATH6KL_STATE_WOW:
926 break;
Kalle Valo10509f92011-12-13 14:52:07 +0200927 case ATH6KL_STATE_SCHED_SCAN:
928 break;
Kalle Valob4b2a0b2011-11-01 08:44:44 +0200929 }
930
Kalle Valo52d81a62011-11-01 08:44:21 +0200931 ath6kl_cfg80211_resume(ar);
Chilam Ngaa6cffc2011-10-05 10:12:52 +0300932
933 return 0;
934}
935
Kalle Valoc7111492011-11-11 12:17:51 +0200936/* set the window address register (using 4-byte register access ). */
937static int ath6kl_set_addrwin_reg(struct ath6kl *ar, u32 reg_addr, u32 addr)
938{
939 int status;
940 u8 addr_val[4];
941 s32 i;
942
943 /*
944 * Write bytes 1,2,3 of the register to set the upper address bytes,
945 * the LSB is written last to initiate the access cycle
946 */
947
948 for (i = 1; i <= 3; i++) {
949 /*
950 * Fill the buffer with the address byte value we want to
951 * hit 4 times.
952 */
953 memset(addr_val, ((u8 *)&addr)[i], 4);
954
955 /*
956 * Hit each byte of the register address with a 4-byte
957 * write operation to the same address, this is a harmless
958 * operation.
959 */
960 status = ath6kl_sdio_read_write_sync(ar, reg_addr + i, addr_val,
961 4, HIF_WR_SYNC_BYTE_FIX);
962 if (status)
963 break;
964 }
965
966 if (status) {
967 ath6kl_err("%s: failed to write initial bytes of 0x%x "
968 "to window reg: 0x%X\n", __func__,
969 addr, reg_addr);
970 return status;
971 }
972
973 /*
974 * Write the address register again, this time write the whole
975 * 4-byte value. The effect here is that the LSB write causes the
976 * cycle to start, the extra 3 byte write to bytes 1,2,3 has no
977 * effect since we are writing the same values again
978 */
979 status = ath6kl_sdio_read_write_sync(ar, reg_addr, (u8 *)(&addr),
980 4, HIF_WR_SYNC_BYTE_INC);
981
982 if (status) {
983 ath6kl_err("%s: failed to write 0x%x to window reg: 0x%X\n",
984 __func__, addr, reg_addr);
985 return status;
986 }
987
988 return 0;
989}
990
991static int ath6kl_sdio_diag_read32(struct ath6kl *ar, u32 address, u32 *data)
992{
993 int status;
994
995 /* set window register to start read cycle */
996 status = ath6kl_set_addrwin_reg(ar, WINDOW_READ_ADDR_ADDRESS,
997 address);
998
999 if (status)
1000 return status;
1001
1002 /* read the data */
1003 status = ath6kl_sdio_read_write_sync(ar, WINDOW_DATA_ADDRESS,
1004 (u8 *)data, sizeof(u32), HIF_RD_SYNC_BYTE_INC);
1005 if (status) {
1006 ath6kl_err("%s: failed to read from window data addr\n",
1007 __func__);
1008 return status;
1009 }
1010
1011 return status;
1012}
1013
1014static int ath6kl_sdio_diag_write32(struct ath6kl *ar, u32 address,
1015 __le32 data)
1016{
1017 int status;
1018 u32 val = (__force u32) data;
1019
1020 /* set write data */
1021 status = ath6kl_sdio_read_write_sync(ar, WINDOW_DATA_ADDRESS,
1022 (u8 *) &val, sizeof(u32), HIF_WR_SYNC_BYTE_INC);
1023 if (status) {
1024 ath6kl_err("%s: failed to write 0x%x to window data addr\n",
1025 __func__, data);
1026 return status;
1027 }
1028
1029 /* set window register, which starts the write cycle */
1030 return ath6kl_set_addrwin_reg(ar, WINDOW_WRITE_ADDR_ADDRESS,
1031 address);
1032}
1033
Kalle Valo66b693c2011-11-11 12:17:33 +02001034static int ath6kl_sdio_bmi_credits(struct ath6kl *ar)
1035{
1036 u32 addr;
1037 unsigned long timeout;
1038 int ret;
1039
1040 ar->bmi.cmd_credits = 0;
1041
1042 /* Read the counter register to get the command credits */
1043 addr = COUNT_DEC_ADDRESS + (HTC_MAILBOX_NUM_MAX + ENDPOINT1) * 4;
1044
1045 timeout = jiffies + msecs_to_jiffies(BMI_COMMUNICATION_TIMEOUT);
1046 while (time_before(jiffies, timeout) && !ar->bmi.cmd_credits) {
1047
1048 /*
1049 * Hit the credit counter with a 4-byte access, the first byte
1050 * read will hit the counter and cause a decrement, while the
1051 * remaining 3 bytes has no effect. The rationale behind this
1052 * is to make all HIF accesses 4-byte aligned.
1053 */
1054 ret = ath6kl_sdio_read_write_sync(ar, addr,
1055 (u8 *)&ar->bmi.cmd_credits, 4,
1056 HIF_RD_SYNC_BYTE_INC);
1057 if (ret) {
1058 ath6kl_err("Unable to decrement the command credit "
1059 "count register: %d\n", ret);
1060 return ret;
1061 }
1062
1063 /* The counter is only 8 bits.
1064 * Ignore anything in the upper 3 bytes
1065 */
1066 ar->bmi.cmd_credits &= 0xFF;
1067 }
1068
1069 if (!ar->bmi.cmd_credits) {
1070 ath6kl_err("bmi communication timeout\n");
1071 return -ETIMEDOUT;
1072 }
1073
1074 return 0;
1075}
1076
1077static int ath6kl_bmi_get_rx_lkahd(struct ath6kl *ar)
1078{
1079 unsigned long timeout;
1080 u32 rx_word = 0;
1081 int ret = 0;
1082
1083 timeout = jiffies + msecs_to_jiffies(BMI_COMMUNICATION_TIMEOUT);
1084 while ((time_before(jiffies, timeout)) && !rx_word) {
1085 ret = ath6kl_sdio_read_write_sync(ar,
1086 RX_LOOKAHEAD_VALID_ADDRESS,
1087 (u8 *)&rx_word, sizeof(rx_word),
1088 HIF_RD_SYNC_BYTE_INC);
1089 if (ret) {
1090 ath6kl_err("unable to read RX_LOOKAHEAD_VALID\n");
1091 return ret;
1092 }
1093
1094 /* all we really want is one bit */
1095 rx_word &= (1 << ENDPOINT1);
1096 }
1097
1098 if (!rx_word) {
1099 ath6kl_err("bmi_recv_buf FIFO empty\n");
1100 return -EINVAL;
1101 }
1102
1103 return ret;
1104}
1105
1106static int ath6kl_sdio_bmi_write(struct ath6kl *ar, u8 *buf, u32 len)
1107{
1108 int ret;
1109 u32 addr;
1110
1111 ret = ath6kl_sdio_bmi_credits(ar);
1112 if (ret)
1113 return ret;
1114
1115 addr = ar->mbox_info.htc_addr;
1116
1117 ret = ath6kl_sdio_read_write_sync(ar, addr, buf, len,
1118 HIF_WR_SYNC_BYTE_INC);
1119 if (ret)
1120 ath6kl_err("unable to send the bmi data to the device\n");
1121
1122 return ret;
1123}
1124
1125static int ath6kl_sdio_bmi_read(struct ath6kl *ar, u8 *buf, u32 len)
1126{
1127 int ret;
1128 u32 addr;
1129
1130 /*
1131 * During normal bootup, small reads may be required.
1132 * Rather than issue an HIF Read and then wait as the Target
1133 * adds successive bytes to the FIFO, we wait here until
1134 * we know that response data is available.
1135 *
1136 * This allows us to cleanly timeout on an unexpected
1137 * Target failure rather than risk problems at the HIF level.
1138 * In particular, this avoids SDIO timeouts and possibly garbage
1139 * data on some host controllers. And on an interconnect
1140 * such as Compact Flash (as well as some SDIO masters) which
1141 * does not provide any indication on data timeout, it avoids
1142 * a potential hang or garbage response.
1143 *
1144 * Synchronization is more difficult for reads larger than the
1145 * size of the MBOX FIFO (128B), because the Target is unable
1146 * to push the 129th byte of data until AFTER the Host posts an
1147 * HIF Read and removes some FIFO data. So for large reads the
1148 * Host proceeds to post an HIF Read BEFORE all the data is
1149 * actually available to read. Fortunately, large BMI reads do
1150 * not occur in practice -- they're supported for debug/development.
1151 *
1152 * So Host/Target BMI synchronization is divided into these cases:
1153 * CASE 1: length < 4
1154 * Should not happen
1155 *
1156 * CASE 2: 4 <= length <= 128
1157 * Wait for first 4 bytes to be in FIFO
1158 * If CONSERVATIVE_BMI_READ is enabled, also wait for
1159 * a BMI command credit, which indicates that the ENTIRE
1160 * response is available in the the FIFO
1161 *
1162 * CASE 3: length > 128
1163 * Wait for the first 4 bytes to be in FIFO
1164 *
1165 * For most uses, a small timeout should be sufficient and we will
1166 * usually see a response quickly; but there may be some unusual
1167 * (debug) cases of BMI_EXECUTE where we want an larger timeout.
1168 * For now, we use an unbounded busy loop while waiting for
1169 * BMI_EXECUTE.
1170 *
1171 * If BMI_EXECUTE ever needs to support longer-latency execution,
1172 * especially in production, this code needs to be enhanced to sleep
1173 * and yield. Also note that BMI_COMMUNICATION_TIMEOUT is currently
1174 * a function of Host processor speed.
1175 */
1176 if (len >= 4) { /* NB: Currently, always true */
1177 ret = ath6kl_bmi_get_rx_lkahd(ar);
1178 if (ret)
1179 return ret;
1180 }
1181
1182 addr = ar->mbox_info.htc_addr;
1183 ret = ath6kl_sdio_read_write_sync(ar, addr, buf, len,
1184 HIF_RD_SYNC_BYTE_INC);
1185 if (ret) {
1186 ath6kl_err("Unable to read the bmi data from the device: %d\n",
1187 ret);
1188 return ret;
1189 }
1190
1191 return 0;
1192}
1193
Kalle Valo32a07e42011-10-30 21:15:57 +02001194static void ath6kl_sdio_stop(struct ath6kl *ar)
1195{
1196 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
1197 struct bus_request *req, *tmp_req;
1198 void *context;
1199
1200 /* FIXME: make sure that wq is not queued again */
1201
1202 cancel_work_sync(&ar_sdio->wr_async_work);
1203
1204 spin_lock_bh(&ar_sdio->wr_async_lock);
1205
1206 list_for_each_entry_safe(req, tmp_req, &ar_sdio->wr_asyncq, list) {
1207 list_del(&req->list);
1208
1209 if (req->scat_req) {
1210 /* this is a scatter gather request */
1211 req->scat_req->status = -ECANCELED;
1212 req->scat_req->complete(ar_sdio->ar->htc_target,
1213 req->scat_req);
1214 } else {
1215 context = req->packet;
1216 ath6kl_sdio_free_bus_req(ar_sdio, req);
1217 ath6kl_hif_rw_comp_handler(context, -ECANCELED);
1218 }
1219 }
1220
1221 spin_unlock_bh(&ar_sdio->wr_async_lock);
1222
1223 WARN_ON(get_queue_depth(&ar_sdio->scat_req) != 4);
1224}
1225
Kalle Valobdcd8172011-07-18 00:22:30 +03001226static const struct ath6kl_hif_ops ath6kl_sdio_ops = {
1227 .read_write_sync = ath6kl_sdio_read_write_sync,
1228 .write_async = ath6kl_sdio_write_async,
1229 .irq_enable = ath6kl_sdio_irq_enable,
1230 .irq_disable = ath6kl_sdio_irq_disable,
1231 .scatter_req_get = ath6kl_sdio_scatter_req_get,
1232 .scatter_req_add = ath6kl_sdio_scatter_req_add,
1233 .enable_scatter = ath6kl_sdio_enable_scatter,
Vasanthakumar Thiagarajanf74a7362011-07-16 20:29:05 +05301234 .scat_req_rw = ath6kl_sdio_async_rw_scatter,
Kalle Valobdcd8172011-07-18 00:22:30 +03001235 .cleanup_scatter = ath6kl_sdio_cleanup_scatter,
Kalle Valoabcb3442011-07-22 08:26:20 +03001236 .suspend = ath6kl_sdio_suspend,
Chilam Ngaa6cffc2011-10-05 10:12:52 +03001237 .resume = ath6kl_sdio_resume,
Kalle Valoc7111492011-11-11 12:17:51 +02001238 .diag_read32 = ath6kl_sdio_diag_read32,
1239 .diag_write32 = ath6kl_sdio_diag_write32,
Kalle Valo66b693c2011-11-11 12:17:33 +02001240 .bmi_read = ath6kl_sdio_bmi_read,
1241 .bmi_write = ath6kl_sdio_bmi_write,
Kalle Valob2e75692011-10-27 18:48:14 +03001242 .power_on = ath6kl_sdio_power_on,
1243 .power_off = ath6kl_sdio_power_off,
Kalle Valo32a07e42011-10-30 21:15:57 +02001244 .stop = ath6kl_sdio_stop,
Kalle Valobdcd8172011-07-18 00:22:30 +03001245};
1246
Kalle Valob4b2a0b2011-11-01 08:44:44 +02001247#ifdef CONFIG_PM_SLEEP
1248
1249/*
1250 * Empty handlers so that mmc subsystem doesn't remove us entirely during
1251 * suspend. We instead follow cfg80211 suspend/resume handlers.
1252 */
1253static int ath6kl_sdio_pm_suspend(struct device *device)
1254{
1255 ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio pm suspend\n");
1256
1257 return 0;
1258}
1259
1260static int ath6kl_sdio_pm_resume(struct device *device)
1261{
1262 ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio pm resume\n");
1263
1264 return 0;
1265}
1266
1267static SIMPLE_DEV_PM_OPS(ath6kl_sdio_pm_ops, ath6kl_sdio_pm_suspend,
1268 ath6kl_sdio_pm_resume);
1269
1270#define ATH6KL_SDIO_PM_OPS (&ath6kl_sdio_pm_ops)
1271
1272#else
1273
1274#define ATH6KL_SDIO_PM_OPS NULL
1275
1276#endif /* CONFIG_PM_SLEEP */
1277
Kalle Valobdcd8172011-07-18 00:22:30 +03001278static int ath6kl_sdio_probe(struct sdio_func *func,
1279 const struct sdio_device_id *id)
1280{
1281 int ret;
1282 struct ath6kl_sdio *ar_sdio;
1283 struct ath6kl *ar;
1284 int count;
1285
Kalle Valo3ef987b2011-10-24 12:18:07 +03001286 ath6kl_dbg(ATH6KL_DBG_BOOT,
1287 "sdio new func %d vendor 0x%x device 0x%x block 0x%x/0x%x\n",
Kalle Valof7325b82011-09-27 14:30:58 +03001288 func->num, func->vendor, func->device,
1289 func->max_blksize, func->cur_blksize);
Kalle Valobdcd8172011-07-18 00:22:30 +03001290
1291 ar_sdio = kzalloc(sizeof(struct ath6kl_sdio), GFP_KERNEL);
1292 if (!ar_sdio)
1293 return -ENOMEM;
1294
1295 ar_sdio->dma_buffer = kzalloc(HIF_DMA_BUFFER_SIZE, GFP_KERNEL);
1296 if (!ar_sdio->dma_buffer) {
1297 ret = -ENOMEM;
1298 goto err_hif;
1299 }
1300
1301 ar_sdio->func = func;
1302 sdio_set_drvdata(func, ar_sdio);
1303
1304 ar_sdio->id = id;
1305 ar_sdio->is_disabled = true;
1306
1307 spin_lock_init(&ar_sdio->lock);
1308 spin_lock_init(&ar_sdio->scat_lock);
1309 spin_lock_init(&ar_sdio->wr_async_lock);
Raja Manifdb28582011-11-21 12:26:51 +05301310 mutex_init(&ar_sdio->dma_buffer_mutex);
Kalle Valobdcd8172011-07-18 00:22:30 +03001311
1312 INIT_LIST_HEAD(&ar_sdio->scat_req);
1313 INIT_LIST_HEAD(&ar_sdio->bus_req_freeq);
1314 INIT_LIST_HEAD(&ar_sdio->wr_asyncq);
1315
1316 INIT_WORK(&ar_sdio->wr_async_work, ath6kl_sdio_write_async_work);
1317
Raja Manid1f41592012-02-09 12:57:12 +05301318 init_waitqueue_head(&ar_sdio->irq_wq);
1319
Kalle Valobdcd8172011-07-18 00:22:30 +03001320 for (count = 0; count < BUS_REQUEST_MAX_NUM; count++)
1321 ath6kl_sdio_free_bus_req(ar_sdio, &ar_sdio->bus_req[count]);
1322
Kalle Valo45eaa782012-01-17 20:09:05 +02001323 ar = ath6kl_core_create(&ar_sdio->func->dev);
Kalle Valobdcd8172011-07-18 00:22:30 +03001324 if (!ar) {
1325 ath6kl_err("Failed to alloc ath6kl core\n");
1326 ret = -ENOMEM;
1327 goto err_dma;
1328 }
1329
1330 ar_sdio->ar = ar;
Kalle Valo77eab1e2011-11-11 12:18:22 +02001331 ar->hif_type = ATH6KL_HIF_TYPE_SDIO;
Kalle Valobdcd8172011-07-18 00:22:30 +03001332 ar->hif_priv = ar_sdio;
1333 ar->hif_ops = &ath6kl_sdio_ops;
Kalle Valo1f4c8942011-11-11 12:17:42 +02001334 ar->bmi.max_data_size = 256;
Kalle Valobdcd8172011-07-18 00:22:30 +03001335
1336 ath6kl_sdio_set_mbox_info(ar);
1337
Kalle Valoe28e8102011-11-01 08:44:36 +02001338 ret = ath6kl_sdio_config(ar);
Kalle Valobdcd8172011-07-18 00:22:30 +03001339 if (ret) {
Kalle Valoe28e8102011-11-01 08:44:36 +02001340 ath6kl_err("Failed to config sdio: %d\n", ret);
1341 goto err_core_alloc;
Kalle Valobdcd8172011-07-18 00:22:30 +03001342 }
1343
Kalle Valobdcd8172011-07-18 00:22:30 +03001344 ret = ath6kl_core_init(ar);
1345 if (ret) {
1346 ath6kl_err("Failed to init ath6kl core\n");
Kalle Valoe28e8102011-11-01 08:44:36 +02001347 goto err_core_alloc;
Kalle Valobdcd8172011-07-18 00:22:30 +03001348 }
1349
1350 return ret;
1351
Vasanthakumar Thiagarajan8dafb702011-10-25 19:33:58 +05301352err_core_alloc:
Kalle Valo45eaa782012-01-17 20:09:05 +02001353 ath6kl_core_destroy(ar_sdio->ar);
Kalle Valobdcd8172011-07-18 00:22:30 +03001354err_dma:
1355 kfree(ar_sdio->dma_buffer);
1356err_hif:
1357 kfree(ar_sdio);
1358
1359 return ret;
1360}
1361
1362static void ath6kl_sdio_remove(struct sdio_func *func)
1363{
1364 struct ath6kl_sdio *ar_sdio;
1365
Kalle Valo3ef987b2011-10-24 12:18:07 +03001366 ath6kl_dbg(ATH6KL_DBG_BOOT,
1367 "sdio removed func %d vendor 0x%x device 0x%x\n",
Kalle Valof7325b82011-09-27 14:30:58 +03001368 func->num, func->vendor, func->device);
1369
Kalle Valobdcd8172011-07-18 00:22:30 +03001370 ar_sdio = sdio_get_drvdata(func);
1371
1372 ath6kl_stop_txrx(ar_sdio->ar);
1373 cancel_work_sync(&ar_sdio->wr_async_work);
1374
Vasanthakumar Thiagarajan6db8fa52011-10-25 19:34:16 +05301375 ath6kl_core_cleanup(ar_sdio->ar);
Vasanthakumar Thiagarajan0e7de662012-01-21 15:22:49 +05301376 ath6kl_core_destroy(ar_sdio->ar);
Kalle Valobdcd8172011-07-18 00:22:30 +03001377
Kalle Valobdcd8172011-07-18 00:22:30 +03001378 kfree(ar_sdio->dma_buffer);
1379 kfree(ar_sdio);
1380}
1381
1382static const struct sdio_device_id ath6kl_sdio_devices[] = {
1383 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x0))},
1384 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x1))},
Naveen Gangadharand93e2c22011-11-11 12:18:14 +02001385 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x0))},
1386 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x1))},
Kalle Valobdcd8172011-07-18 00:22:30 +03001387 {},
1388};
1389
1390MODULE_DEVICE_TABLE(sdio, ath6kl_sdio_devices);
1391
1392static struct sdio_driver ath6kl_sdio_driver = {
Kalle Valo241b1282012-01-17 20:09:45 +02001393 .name = "ath6kl_sdio",
Kalle Valobdcd8172011-07-18 00:22:30 +03001394 .id_table = ath6kl_sdio_devices,
1395 .probe = ath6kl_sdio_probe,
1396 .remove = ath6kl_sdio_remove,
Kalle Valob4b2a0b2011-11-01 08:44:44 +02001397 .drv.pm = ATH6KL_SDIO_PM_OPS,
Kalle Valobdcd8172011-07-18 00:22:30 +03001398};
1399
1400static int __init ath6kl_sdio_init(void)
1401{
1402 int ret;
1403
1404 ret = sdio_register_driver(&ath6kl_sdio_driver);
1405 if (ret)
1406 ath6kl_err("sdio driver registration failed: %d\n", ret);
1407
1408 return ret;
1409}
1410
1411static void __exit ath6kl_sdio_exit(void)
1412{
1413 sdio_unregister_driver(&ath6kl_sdio_driver);
1414}
1415
1416module_init(ath6kl_sdio_init);
1417module_exit(ath6kl_sdio_exit);
1418
1419MODULE_AUTHOR("Atheros Communications, Inc.");
1420MODULE_DESCRIPTION("Driver support for Atheros AR600x SDIO devices");
1421MODULE_LICENSE("Dual BSD/GPL");
1422
Kalle Valoc0038972011-12-16 20:53:31 +02001423MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_OTP_FILE);
1424MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_FIRMWARE_FILE);
1425MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_PATCH_FILE);
Kalle Valo0d0192b2011-11-14 19:31:07 +02001426MODULE_FIRMWARE(AR6003_HW_2_0_BOARD_DATA_FILE);
1427MODULE_FIRMWARE(AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE);
Kalle Valoc0038972011-12-16 20:53:31 +02001428MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_OTP_FILE);
1429MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_FIRMWARE_FILE);
1430MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_PATCH_FILE);
Kalle Valo0d0192b2011-11-14 19:31:07 +02001431MODULE_FIRMWARE(AR6003_HW_2_1_1_BOARD_DATA_FILE);
1432MODULE_FIRMWARE(AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE);
Kalle Valoc0038972011-12-16 20:53:31 +02001433MODULE_FIRMWARE(AR6004_HW_1_0_FW_DIR "/" AR6004_HW_1_0_FIRMWARE_FILE);
Kalle Valof0ea5d52011-11-14 19:31:15 +02001434MODULE_FIRMWARE(AR6004_HW_1_0_BOARD_DATA_FILE);
1435MODULE_FIRMWARE(AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE);
Kalle Valoc0038972011-12-16 20:53:31 +02001436MODULE_FIRMWARE(AR6004_HW_1_1_FW_DIR "/" AR6004_HW_1_1_FIRMWARE_FILE);
Kalle Valof0ea5d52011-11-14 19:31:15 +02001437MODULE_FIRMWARE(AR6004_HW_1_1_BOARD_DATA_FILE);
1438MODULE_FIRMWARE(AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE);