blob: 346f5dd3a9541b33124fe04ccd695ca852b7dcb3 [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;
408 memcpy(tbuf, buf, len);
409 bounced = true;
410 } else
411 tbuf = buf;
412
Vasanthakumar Thiagarajanda220692011-07-16 20:29:16 +0530413 ret = ath6kl_sdio_io(ar_sdio->func, request, addr, tbuf, len);
414 if ((request & HIF_READ) && bounced)
415 memcpy(buf, tbuf, len);
Kalle Valobdcd8172011-07-18 00:22:30 +0300416
Raja Manifdb28582011-11-21 12:26:51 +0530417 if (bounced)
418 mutex_unlock(&ar_sdio->dma_buffer_mutex);
419
Kalle Valobdcd8172011-07-18 00:22:30 +0300420 return ret;
421}
422
423static void __ath6kl_sdio_write_async(struct ath6kl_sdio *ar_sdio,
424 struct bus_request *req)
425{
426 if (req->scat_req)
427 ath6kl_sdio_scat_rw(ar_sdio, req);
428 else {
429 void *context;
430 int status;
431
432 status = ath6kl_sdio_read_write_sync(ar_sdio->ar, req->address,
433 req->buffer, req->length,
434 req->request);
435 context = req->packet;
436 ath6kl_sdio_free_bus_req(ar_sdio, req);
Kalle Valo8e8ddb22011-10-05 12:23:33 +0300437 ath6kl_hif_rw_comp_handler(context, status);
Kalle Valobdcd8172011-07-18 00:22:30 +0300438 }
439}
440
441static void ath6kl_sdio_write_async_work(struct work_struct *work)
442{
443 struct ath6kl_sdio *ar_sdio;
Kalle Valobdcd8172011-07-18 00:22:30 +0300444 struct bus_request *req, *tmp_req;
445
446 ar_sdio = container_of(work, struct ath6kl_sdio, wr_async_work);
Kalle Valobdcd8172011-07-18 00:22:30 +0300447
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530448 spin_lock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300449 list_for_each_entry_safe(req, tmp_req, &ar_sdio->wr_asyncq, list) {
450 list_del(&req->list);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530451 spin_unlock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300452 __ath6kl_sdio_write_async(ar_sdio, req);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530453 spin_lock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300454 }
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530455 spin_unlock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300456}
457
458static void ath6kl_sdio_irq_handler(struct sdio_func *func)
459{
460 int status;
461 struct ath6kl_sdio *ar_sdio;
462
Kalle Valof7325b82011-09-27 14:30:58 +0300463 ath6kl_dbg(ATH6KL_DBG_SDIO, "irq\n");
464
Kalle Valobdcd8172011-07-18 00:22:30 +0300465 ar_sdio = sdio_get_drvdata(func);
Raja Manid1f41592012-02-09 12:57:12 +0530466 atomic_set(&ar_sdio->irq_handling, 1);
Kalle Valobdcd8172011-07-18 00:22:30 +0300467 /*
468 * Release the host during interrups so we can pick it back up when
469 * we process commands.
470 */
471 sdio_release_host(ar_sdio->func);
472
Kalle Valo8e8ddb22011-10-05 12:23:33 +0300473 status = ath6kl_hif_intr_bh_handler(ar_sdio->ar);
Kalle Valobdcd8172011-07-18 00:22:30 +0300474 sdio_claim_host(ar_sdio->func);
Raja Manid1f41592012-02-09 12:57:12 +0530475
476 atomic_set(&ar_sdio->irq_handling, 0);
477 wake_up(&ar_sdio->irq_wq);
478
Kalle Valobdcd8172011-07-18 00:22:30 +0300479 WARN_ON(status && status != -ECANCELED);
480}
481
Kalle Valob2e75692011-10-27 18:48:14 +0300482static int ath6kl_sdio_power_on(struct ath6kl *ar)
Kalle Valobdcd8172011-07-18 00:22:30 +0300483{
Kalle Valob2e75692011-10-27 18:48:14 +0300484 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
Kalle Valobdcd8172011-07-18 00:22:30 +0300485 struct sdio_func *func = ar_sdio->func;
486 int ret = 0;
487
488 if (!ar_sdio->is_disabled)
489 return 0;
490
Kalle Valo3ef987b2011-10-24 12:18:07 +0300491 ath6kl_dbg(ATH6KL_DBG_BOOT, "sdio power on\n");
492
Kalle Valobdcd8172011-07-18 00:22:30 +0300493 sdio_claim_host(func);
494
495 ret = sdio_enable_func(func);
496 if (ret) {
497 ath6kl_err("Unable to enable sdio func: %d)\n", ret);
498 sdio_release_host(func);
499 return ret;
500 }
501
502 sdio_release_host(func);
503
504 /*
505 * Wait for hardware to initialise. It should take a lot less than
506 * 10 ms but let's be conservative here.
507 */
508 msleep(10);
509
510 ar_sdio->is_disabled = false;
511
512 return ret;
513}
514
Kalle Valob2e75692011-10-27 18:48:14 +0300515static int ath6kl_sdio_power_off(struct ath6kl *ar)
Kalle Valobdcd8172011-07-18 00:22:30 +0300516{
Kalle Valob2e75692011-10-27 18:48:14 +0300517 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
Kalle Valobdcd8172011-07-18 00:22:30 +0300518 int ret;
519
520 if (ar_sdio->is_disabled)
521 return 0;
522
Kalle Valo3ef987b2011-10-24 12:18:07 +0300523 ath6kl_dbg(ATH6KL_DBG_BOOT, "sdio power off\n");
524
Kalle Valobdcd8172011-07-18 00:22:30 +0300525 /* Disable the card */
526 sdio_claim_host(ar_sdio->func);
527 ret = sdio_disable_func(ar_sdio->func);
528 sdio_release_host(ar_sdio->func);
529
530 if (ret)
531 return ret;
532
533 ar_sdio->is_disabled = true;
534
535 return ret;
536}
537
538static int ath6kl_sdio_write_async(struct ath6kl *ar, u32 address, u8 *buffer,
539 u32 length, u32 request,
540 struct htc_packet *packet)
541{
542 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
543 struct bus_request *bus_req;
Kalle Valobdcd8172011-07-18 00:22:30 +0300544
545 bus_req = ath6kl_sdio_alloc_busreq(ar_sdio);
546
547 if (!bus_req)
548 return -ENOMEM;
549
550 bus_req->address = address;
551 bus_req->buffer = buffer;
552 bus_req->length = length;
553 bus_req->request = request;
554 bus_req->packet = packet;
555
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530556 spin_lock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300557 list_add_tail(&bus_req->list, &ar_sdio->wr_asyncq);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530558 spin_unlock_bh(&ar_sdio->wr_async_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300559 queue_work(ar->ath6kl_wq, &ar_sdio->wr_async_work);
560
561 return 0;
562}
563
564static void ath6kl_sdio_irq_enable(struct ath6kl *ar)
565{
566 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
567 int ret;
568
569 sdio_claim_host(ar_sdio->func);
570
571 /* Register the isr */
572 ret = sdio_claim_irq(ar_sdio->func, ath6kl_sdio_irq_handler);
573 if (ret)
574 ath6kl_err("Failed to claim sdio irq: %d\n", ret);
575
576 sdio_release_host(ar_sdio->func);
577}
578
Raja Manid1f41592012-02-09 12:57:12 +0530579static bool ath6kl_sdio_is_on_irq(struct ath6kl *ar)
580{
581 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
582
583 return !atomic_read(&ar_sdio->irq_handling);
584}
585
Kalle Valobdcd8172011-07-18 00:22:30 +0300586static void ath6kl_sdio_irq_disable(struct ath6kl *ar)
587{
588 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
589 int ret;
590
591 sdio_claim_host(ar_sdio->func);
592
Raja Manid1f41592012-02-09 12:57:12 +0530593 if (atomic_read(&ar_sdio->irq_handling)) {
594 sdio_release_host(ar_sdio->func);
595
596 ret = wait_event_interruptible(ar_sdio->irq_wq,
597 ath6kl_sdio_is_on_irq(ar));
598 if (ret)
599 return;
600
601 sdio_claim_host(ar_sdio->func);
602 }
Kalle Valobdcd8172011-07-18 00:22:30 +0300603
604 ret = sdio_release_irq(ar_sdio->func);
605 if (ret)
606 ath6kl_err("Failed to release sdio irq: %d\n", ret);
607
608 sdio_release_host(ar_sdio->func);
609}
610
611static struct hif_scatter_req *ath6kl_sdio_scatter_req_get(struct ath6kl *ar)
612{
613 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
614 struct hif_scatter_req *node = NULL;
Kalle Valobdcd8172011-07-18 00:22:30 +0300615
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530616 spin_lock_bh(&ar_sdio->scat_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300617
618 if (!list_empty(&ar_sdio->scat_req)) {
619 node = list_first_entry(&ar_sdio->scat_req,
620 struct hif_scatter_req, list);
621 list_del(&node->list);
Chilam Ngb29072c2012-02-07 01:33:00 -0800622
623 node->scat_q_depth = get_queue_depth(&ar_sdio->scat_req);
Kalle Valobdcd8172011-07-18 00:22:30 +0300624 }
625
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530626 spin_unlock_bh(&ar_sdio->scat_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300627
628 return node;
629}
630
631static void ath6kl_sdio_scatter_req_add(struct ath6kl *ar,
632 struct hif_scatter_req *s_req)
633{
634 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
Kalle Valobdcd8172011-07-18 00:22:30 +0300635
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530636 spin_lock_bh(&ar_sdio->scat_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300637
638 list_add_tail(&s_req->list, &ar_sdio->scat_req);
639
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530640 spin_unlock_bh(&ar_sdio->scat_lock);
Kalle Valobdcd8172011-07-18 00:22:30 +0300641
642}
643
Vasanthakumar Thiagarajanc630d182011-07-16 20:29:06 +0530644/* scatter gather read write request */
645static int ath6kl_sdio_async_rw_scatter(struct ath6kl *ar,
646 struct hif_scatter_req *scat_req)
647{
648 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
Vasanthakumar Thiagarajanc630d182011-07-16 20:29:06 +0530649 u32 request = scat_req->req;
650 int status = 0;
Vasanthakumar Thiagarajanc630d182011-07-16 20:29:06 +0530651
652 if (!scat_req->len)
653 return -EINVAL;
654
655 ath6kl_dbg(ATH6KL_DBG_SCATTER,
656 "hif-scatter: total len: %d scatter entries: %d\n",
657 scat_req->len, scat_req->scat_entries);
658
Vasanthakumar Thiagarajan861dd052011-09-30 21:46:59 +0530659 if (request & HIF_SYNCHRONOUS)
Vasanthakumar Thiagarajand4df7892011-07-16 20:29:07 +0530660 status = ath6kl_sdio_scat_rw(ar_sdio, scat_req->busrequest);
Vasanthakumar Thiagarajan861dd052011-09-30 21:46:59 +0530661 else {
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530662 spin_lock_bh(&ar_sdio->wr_async_lock);
Vasanthakumar Thiagarajand4df7892011-07-16 20:29:07 +0530663 list_add_tail(&scat_req->busrequest->list, &ar_sdio->wr_asyncq);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530664 spin_unlock_bh(&ar_sdio->wr_async_lock);
Vasanthakumar Thiagarajanc630d182011-07-16 20:29:06 +0530665 queue_work(ar->ath6kl_wq, &ar_sdio->wr_async_work);
666 }
667
668 return status;
669}
670
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530671/* clean up scatter support */
672static void ath6kl_sdio_cleanup_scatter(struct ath6kl *ar)
673{
674 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
675 struct hif_scatter_req *s_req, *tmp_req;
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530676
677 /* empty the free list */
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530678 spin_lock_bh(&ar_sdio->scat_lock);
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530679 list_for_each_entry_safe(s_req, tmp_req, &ar_sdio->scat_req, list) {
680 list_del(&s_req->list);
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530681 spin_unlock_bh(&ar_sdio->scat_lock);
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530682
Kalle Valo32a07e42011-10-30 21:15:57 +0200683 /*
684 * FIXME: should we also call completion handler with
685 * ath6kl_hif_rw_comp_handler() with status -ECANCELED so
686 * that the packet is properly freed?
687 */
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530688 if (s_req->busrequest)
689 ath6kl_sdio_free_bus_req(ar_sdio, s_req->busrequest);
690 kfree(s_req->virt_dma_buf);
691 kfree(s_req->sgentries);
692 kfree(s_req);
693
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530694 spin_lock_bh(&ar_sdio->scat_lock);
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530695 }
Vasanthakumar Thiagarajan151bd302011-09-30 19:18:43 +0530696 spin_unlock_bh(&ar_sdio->scat_lock);
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530697}
698
699/* setup of HIF scatter resources */
Vasanthakumar Thiagarajan50745af2011-07-18 14:23:29 +0530700static int ath6kl_sdio_enable_scatter(struct ath6kl *ar)
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530701{
702 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
Vasanthakumar Thiagarajan50745af2011-07-18 14:23:29 +0530703 struct htc_target *target = ar->htc_target;
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530704 int ret;
705 bool virt_scat = false;
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530706
Kalle Valo32a07e42011-10-30 21:15:57 +0200707 if (ar_sdio->scatter_enabled)
708 return 0;
709
710 ar_sdio->scatter_enabled = true;
711
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530712 /* check if host supports scatter and it meets our requirements */
713 if (ar_sdio->func->card->host->max_segs < MAX_SCATTER_ENTRIES_PER_REQ) {
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530714 ath6kl_err("host only supports scatter of :%d entries, need: %d\n",
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530715 ar_sdio->func->card->host->max_segs,
716 MAX_SCATTER_ENTRIES_PER_REQ);
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530717 virt_scat = true;
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530718 }
719
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530720 if (!virt_scat) {
721 ret = ath6kl_sdio_alloc_prep_scat_req(ar_sdio,
722 MAX_SCATTER_ENTRIES_PER_REQ,
723 MAX_SCATTER_REQUESTS, virt_scat);
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530724
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530725 if (!ret) {
Kalle Valo3ef987b2011-10-24 12:18:07 +0300726 ath6kl_dbg(ATH6KL_DBG_BOOT,
727 "hif-scatter enabled requests %d entries %d\n",
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530728 MAX_SCATTER_REQUESTS,
729 MAX_SCATTER_ENTRIES_PER_REQ);
730
Vasanthakumar Thiagarajan50745af2011-07-18 14:23:29 +0530731 target->max_scat_entries = MAX_SCATTER_ENTRIES_PER_REQ;
732 target->max_xfer_szper_scatreq =
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530733 MAX_SCATTER_REQ_TRANSFER_SIZE;
734 } else {
735 ath6kl_sdio_cleanup_scatter(ar);
736 ath6kl_warn("hif scatter resource setup failed, trying virtual scatter method\n");
737 }
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530738 }
739
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530740 if (virt_scat || ret) {
741 ret = ath6kl_sdio_alloc_prep_scat_req(ar_sdio,
742 ATH6KL_SCATTER_ENTRIES_PER_REQ,
743 ATH6KL_SCATTER_REQS, virt_scat);
744
745 if (ret) {
746 ath6kl_err("failed to alloc virtual scatter resources !\n");
747 ath6kl_sdio_cleanup_scatter(ar);
748 return ret;
749 }
750
Kalle Valo3ef987b2011-10-24 12:18:07 +0300751 ath6kl_dbg(ATH6KL_DBG_BOOT,
752 "virtual scatter enabled requests %d entries %d\n",
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530753 ATH6KL_SCATTER_REQS, ATH6KL_SCATTER_ENTRIES_PER_REQ);
754
Vasanthakumar Thiagarajan50745af2011-07-18 14:23:29 +0530755 target->max_scat_entries = ATH6KL_SCATTER_ENTRIES_PER_REQ;
756 target->max_xfer_szper_scatreq =
Vasanthakumar Thiagarajancfeab102011-07-16 20:29:14 +0530757 ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER;
758 }
759
Vasanthakumar Thiagarajan18a0f932011-07-16 20:29:13 +0530760 return 0;
761}
762
Kalle Valoe28e8102011-11-01 08:44:36 +0200763static int ath6kl_sdio_config(struct ath6kl *ar)
764{
765 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
766 struct sdio_func *func = ar_sdio->func;
767 int ret;
768
769 sdio_claim_host(func);
770
771 if ((ar_sdio->id->device & MANUFACTURER_ID_ATH6KL_BASE_MASK) >=
772 MANUFACTURER_ID_AR6003_BASE) {
773 /* enable 4-bit ASYNC interrupt on AR6003 or later */
774 ret = ath6kl_sdio_func0_cmd52_wr_byte(func->card,
775 CCCR_SDIO_IRQ_MODE_REG,
776 SDIO_IRQ_MODE_ASYNC_4BIT_IRQ);
777 if (ret) {
778 ath6kl_err("Failed to enable 4-bit async irq mode %d\n",
779 ret);
780 goto out;
781 }
782
783 ath6kl_dbg(ATH6KL_DBG_BOOT, "4-bit async irq mode enabled\n");
784 }
785
786 /* give us some time to enable, in ms */
787 func->enable_timeout = 100;
788
789 ret = sdio_set_block_size(func, HIF_MBOX_BLOCK_SIZE);
790 if (ret) {
791 ath6kl_err("Set sdio block size %d failed: %d)\n",
792 HIF_MBOX_BLOCK_SIZE, ret);
Kalle Valoe28e8102011-11-01 08:44:36 +0200793 goto out;
794 }
795
796out:
797 sdio_release_host(func);
798
799 return ret;
800}
801
Raja Manie390af72012-01-30 17:13:09 +0530802static int ath6kl_set_sdio_pm_caps(struct ath6kl *ar)
Kalle Valoabcb3442011-07-22 08:26:20 +0300803{
804 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
805 struct sdio_func *func = ar_sdio->func;
806 mmc_pm_flag_t flags;
807 int ret;
808
809 flags = sdio_get_host_pm_caps(func);
810
Kalle Valob4b2a0b2011-11-01 08:44:44 +0200811 ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio suspend pm_caps 0x%x\n", flags);
812
Raja Manie390af72012-01-30 17:13:09 +0530813 if (!(flags & MMC_PM_WAKE_SDIO_IRQ) ||
814 !(flags & MMC_PM_KEEP_POWER))
815 return -EINVAL;
Kalle Valoabcb3442011-07-22 08:26:20 +0300816
817 ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
818 if (ret) {
Raja Manie390af72012-01-30 17:13:09 +0530819 ath6kl_err("set sdio keep pwr flag failed: %d\n", ret);
Kalle Valoabcb3442011-07-22 08:26:20 +0300820 return ret;
821 }
822
Kalle Valo10509f92011-12-13 14:52:07 +0200823 /* sdio irq wakes up host */
Raja Manie390af72012-01-30 17:13:09 +0530824 ret = sdio_set_host_pm_flags(func, MMC_PM_WAKE_SDIO_IRQ);
825 if (ret)
826 ath6kl_err("set sdio wake irq flag failed: %d\n", ret);
827
828 return ret;
829}
830
831static int ath6kl_sdio_suspend(struct ath6kl *ar, struct cfg80211_wowlan *wow)
832{
833 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
834 struct sdio_func *func = ar_sdio->func;
835 mmc_pm_flag_t flags;
836 int ret;
Kalle Valo10509f92011-12-13 14:52:07 +0200837
838 if (ar->state == ATH6KL_STATE_SCHED_SCAN) {
Raja Manie390af72012-01-30 17:13:09 +0530839 ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sched scan is in progress\n");
840
841 ret = ath6kl_set_sdio_pm_caps(ar);
842 if (ret)
843 goto cut_pwr;
844
Kalle Valo10509f92011-12-13 14:52:07 +0200845 ret = ath6kl_cfg80211_suspend(ar,
846 ATH6KL_CFG_SUSPEND_SCHED_SCAN,
847 NULL);
Kalle Valo10509f92011-12-13 14:52:07 +0200848 if (ret)
Raja Manie390af72012-01-30 17:13:09 +0530849 goto cut_pwr;
Kalle Valo10509f92011-12-13 14:52:07 +0200850
Raja Manie390af72012-01-30 17:13:09 +0530851 return 0;
Kalle Valo10509f92011-12-13 14:52:07 +0200852 }
853
Raja Manie390af72012-01-30 17:13:09 +0530854 if (ar->suspend_mode == WLAN_POWER_STATE_WOW ||
855 (!ar->suspend_mode && wow)) {
856
857 ret = ath6kl_set_sdio_pm_caps(ar);
858 if (ret)
859 goto cut_pwr;
860
Raja Manid7c44e02011-11-07 22:52:46 +0200861 ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_WOW, wow);
862 if (ret)
Raja Manie390af72012-01-30 17:13:09 +0530863 goto cut_pwr;
Raja Manid7c44e02011-11-07 22:52:46 +0200864
Raja Manie390af72012-01-30 17:13:09 +0530865 return 0;
Raja Manid7c44e02011-11-07 22:52:46 +0200866 }
867
Raja Manie390af72012-01-30 17:13:09 +0530868 if (ar->suspend_mode == WLAN_POWER_STATE_DEEP_SLEEP ||
869 !ar->suspend_mode) {
870
871 flags = sdio_get_host_pm_caps(func);
872 if (!(flags & MMC_PM_KEEP_POWER))
873 goto cut_pwr;
874
875 ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER);
876 if (ret)
877 goto cut_pwr;
878
Santosh Sajjancca4d5a2012-01-30 22:02:26 +0200879 /*
880 * Workaround to support Deep Sleep with MSM, set the host pm
881 * flag as MMC_PM_WAKE_SDIO_IRQ to allow SDCC deiver to disable
882 * the sdc2_clock and internally allows MSM to enter
883 * TCXO shutdown properly.
884 */
885 if ((flags & MMC_PM_WAKE_SDIO_IRQ)) {
886 ret = sdio_set_host_pm_flags(func,
887 MMC_PM_WAKE_SDIO_IRQ);
888 if (ret)
889 goto cut_pwr;
890 }
891
Raja Manie390af72012-01-30 17:13:09 +0530892 ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP,
893 NULL);
894 if (ret)
895 goto cut_pwr;
896
897 return 0;
898 }
899
900cut_pwr:
901 return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_CUTPOWER, NULL);
Kalle Valoabcb3442011-07-22 08:26:20 +0300902}
903
Chilam Ngaa6cffc2011-10-05 10:12:52 +0300904static int ath6kl_sdio_resume(struct ath6kl *ar)
905{
Kalle Valob4b2a0b2011-11-01 08:44:44 +0200906 switch (ar->state) {
907 case ATH6KL_STATE_OFF:
908 case ATH6KL_STATE_CUTPOWER:
909 ath6kl_dbg(ATH6KL_DBG_SUSPEND,
910 "sdio resume configuring sdio\n");
911
912 /* need to set sdio settings after power is cut from sdio */
913 ath6kl_sdio_config(ar);
914 break;
915
916 case ATH6KL_STATE_ON:
Kalle Valob4b2a0b2011-11-01 08:44:44 +0200917 break;
918
919 case ATH6KL_STATE_DEEPSLEEP:
920 break;
Raja Manid7c44e02011-11-07 22:52:46 +0200921
922 case ATH6KL_STATE_WOW:
923 break;
Kalle Valo10509f92011-12-13 14:52:07 +0200924 case ATH6KL_STATE_SCHED_SCAN:
925 break;
Kalle Valob4b2a0b2011-11-01 08:44:44 +0200926 }
927
Kalle Valo52d81a62011-11-01 08:44:21 +0200928 ath6kl_cfg80211_resume(ar);
Chilam Ngaa6cffc2011-10-05 10:12:52 +0300929
930 return 0;
931}
932
Kalle Valoc7111492011-11-11 12:17:51 +0200933/* set the window address register (using 4-byte register access ). */
934static int ath6kl_set_addrwin_reg(struct ath6kl *ar, u32 reg_addr, u32 addr)
935{
936 int status;
937 u8 addr_val[4];
938 s32 i;
939
940 /*
941 * Write bytes 1,2,3 of the register to set the upper address bytes,
942 * the LSB is written last to initiate the access cycle
943 */
944
945 for (i = 1; i <= 3; i++) {
946 /*
947 * Fill the buffer with the address byte value we want to
948 * hit 4 times.
949 */
950 memset(addr_val, ((u8 *)&addr)[i], 4);
951
952 /*
953 * Hit each byte of the register address with a 4-byte
954 * write operation to the same address, this is a harmless
955 * operation.
956 */
957 status = ath6kl_sdio_read_write_sync(ar, reg_addr + i, addr_val,
958 4, HIF_WR_SYNC_BYTE_FIX);
959 if (status)
960 break;
961 }
962
963 if (status) {
964 ath6kl_err("%s: failed to write initial bytes of 0x%x "
965 "to window reg: 0x%X\n", __func__,
966 addr, reg_addr);
967 return status;
968 }
969
970 /*
971 * Write the address register again, this time write the whole
972 * 4-byte value. The effect here is that the LSB write causes the
973 * cycle to start, the extra 3 byte write to bytes 1,2,3 has no
974 * effect since we are writing the same values again
975 */
976 status = ath6kl_sdio_read_write_sync(ar, reg_addr, (u8 *)(&addr),
977 4, HIF_WR_SYNC_BYTE_INC);
978
979 if (status) {
980 ath6kl_err("%s: failed to write 0x%x to window reg: 0x%X\n",
981 __func__, addr, reg_addr);
982 return status;
983 }
984
985 return 0;
986}
987
988static int ath6kl_sdio_diag_read32(struct ath6kl *ar, u32 address, u32 *data)
989{
990 int status;
991
992 /* set window register to start read cycle */
993 status = ath6kl_set_addrwin_reg(ar, WINDOW_READ_ADDR_ADDRESS,
994 address);
995
996 if (status)
997 return status;
998
999 /* read the data */
1000 status = ath6kl_sdio_read_write_sync(ar, WINDOW_DATA_ADDRESS,
1001 (u8 *)data, sizeof(u32), HIF_RD_SYNC_BYTE_INC);
1002 if (status) {
1003 ath6kl_err("%s: failed to read from window data addr\n",
1004 __func__);
1005 return status;
1006 }
1007
1008 return status;
1009}
1010
1011static int ath6kl_sdio_diag_write32(struct ath6kl *ar, u32 address,
1012 __le32 data)
1013{
1014 int status;
1015 u32 val = (__force u32) data;
1016
1017 /* set write data */
1018 status = ath6kl_sdio_read_write_sync(ar, WINDOW_DATA_ADDRESS,
1019 (u8 *) &val, sizeof(u32), HIF_WR_SYNC_BYTE_INC);
1020 if (status) {
1021 ath6kl_err("%s: failed to write 0x%x to window data addr\n",
1022 __func__, data);
1023 return status;
1024 }
1025
1026 /* set window register, which starts the write cycle */
1027 return ath6kl_set_addrwin_reg(ar, WINDOW_WRITE_ADDR_ADDRESS,
1028 address);
1029}
1030
Kalle Valo66b693c2011-11-11 12:17:33 +02001031static int ath6kl_sdio_bmi_credits(struct ath6kl *ar)
1032{
1033 u32 addr;
1034 unsigned long timeout;
1035 int ret;
1036
1037 ar->bmi.cmd_credits = 0;
1038
1039 /* Read the counter register to get the command credits */
1040 addr = COUNT_DEC_ADDRESS + (HTC_MAILBOX_NUM_MAX + ENDPOINT1) * 4;
1041
1042 timeout = jiffies + msecs_to_jiffies(BMI_COMMUNICATION_TIMEOUT);
1043 while (time_before(jiffies, timeout) && !ar->bmi.cmd_credits) {
1044
1045 /*
1046 * Hit the credit counter with a 4-byte access, the first byte
1047 * read will hit the counter and cause a decrement, while the
1048 * remaining 3 bytes has no effect. The rationale behind this
1049 * is to make all HIF accesses 4-byte aligned.
1050 */
1051 ret = ath6kl_sdio_read_write_sync(ar, addr,
1052 (u8 *)&ar->bmi.cmd_credits, 4,
1053 HIF_RD_SYNC_BYTE_INC);
1054 if (ret) {
1055 ath6kl_err("Unable to decrement the command credit "
1056 "count register: %d\n", ret);
1057 return ret;
1058 }
1059
1060 /* The counter is only 8 bits.
1061 * Ignore anything in the upper 3 bytes
1062 */
1063 ar->bmi.cmd_credits &= 0xFF;
1064 }
1065
1066 if (!ar->bmi.cmd_credits) {
1067 ath6kl_err("bmi communication timeout\n");
1068 return -ETIMEDOUT;
1069 }
1070
1071 return 0;
1072}
1073
1074static int ath6kl_bmi_get_rx_lkahd(struct ath6kl *ar)
1075{
1076 unsigned long timeout;
1077 u32 rx_word = 0;
1078 int ret = 0;
1079
1080 timeout = jiffies + msecs_to_jiffies(BMI_COMMUNICATION_TIMEOUT);
1081 while ((time_before(jiffies, timeout)) && !rx_word) {
1082 ret = ath6kl_sdio_read_write_sync(ar,
1083 RX_LOOKAHEAD_VALID_ADDRESS,
1084 (u8 *)&rx_word, sizeof(rx_word),
1085 HIF_RD_SYNC_BYTE_INC);
1086 if (ret) {
1087 ath6kl_err("unable to read RX_LOOKAHEAD_VALID\n");
1088 return ret;
1089 }
1090
1091 /* all we really want is one bit */
1092 rx_word &= (1 << ENDPOINT1);
1093 }
1094
1095 if (!rx_word) {
1096 ath6kl_err("bmi_recv_buf FIFO empty\n");
1097 return -EINVAL;
1098 }
1099
1100 return ret;
1101}
1102
1103static int ath6kl_sdio_bmi_write(struct ath6kl *ar, u8 *buf, u32 len)
1104{
1105 int ret;
1106 u32 addr;
1107
1108 ret = ath6kl_sdio_bmi_credits(ar);
1109 if (ret)
1110 return ret;
1111
1112 addr = ar->mbox_info.htc_addr;
1113
1114 ret = ath6kl_sdio_read_write_sync(ar, addr, buf, len,
1115 HIF_WR_SYNC_BYTE_INC);
1116 if (ret)
1117 ath6kl_err("unable to send the bmi data to the device\n");
1118
1119 return ret;
1120}
1121
1122static int ath6kl_sdio_bmi_read(struct ath6kl *ar, u8 *buf, u32 len)
1123{
1124 int ret;
1125 u32 addr;
1126
1127 /*
1128 * During normal bootup, small reads may be required.
1129 * Rather than issue an HIF Read and then wait as the Target
1130 * adds successive bytes to the FIFO, we wait here until
1131 * we know that response data is available.
1132 *
1133 * This allows us to cleanly timeout on an unexpected
1134 * Target failure rather than risk problems at the HIF level.
1135 * In particular, this avoids SDIO timeouts and possibly garbage
1136 * data on some host controllers. And on an interconnect
1137 * such as Compact Flash (as well as some SDIO masters) which
1138 * does not provide any indication on data timeout, it avoids
1139 * a potential hang or garbage response.
1140 *
1141 * Synchronization is more difficult for reads larger than the
1142 * size of the MBOX FIFO (128B), because the Target is unable
1143 * to push the 129th byte of data until AFTER the Host posts an
1144 * HIF Read and removes some FIFO data. So for large reads the
1145 * Host proceeds to post an HIF Read BEFORE all the data is
1146 * actually available to read. Fortunately, large BMI reads do
1147 * not occur in practice -- they're supported for debug/development.
1148 *
1149 * So Host/Target BMI synchronization is divided into these cases:
1150 * CASE 1: length < 4
1151 * Should not happen
1152 *
1153 * CASE 2: 4 <= length <= 128
1154 * Wait for first 4 bytes to be in FIFO
1155 * If CONSERVATIVE_BMI_READ is enabled, also wait for
1156 * a BMI command credit, which indicates that the ENTIRE
1157 * response is available in the the FIFO
1158 *
1159 * CASE 3: length > 128
1160 * Wait for the first 4 bytes to be in FIFO
1161 *
1162 * For most uses, a small timeout should be sufficient and we will
1163 * usually see a response quickly; but there may be some unusual
1164 * (debug) cases of BMI_EXECUTE where we want an larger timeout.
1165 * For now, we use an unbounded busy loop while waiting for
1166 * BMI_EXECUTE.
1167 *
1168 * If BMI_EXECUTE ever needs to support longer-latency execution,
1169 * especially in production, this code needs to be enhanced to sleep
1170 * and yield. Also note that BMI_COMMUNICATION_TIMEOUT is currently
1171 * a function of Host processor speed.
1172 */
1173 if (len >= 4) { /* NB: Currently, always true */
1174 ret = ath6kl_bmi_get_rx_lkahd(ar);
1175 if (ret)
1176 return ret;
1177 }
1178
1179 addr = ar->mbox_info.htc_addr;
1180 ret = ath6kl_sdio_read_write_sync(ar, addr, buf, len,
1181 HIF_RD_SYNC_BYTE_INC);
1182 if (ret) {
1183 ath6kl_err("Unable to read the bmi data from the device: %d\n",
1184 ret);
1185 return ret;
1186 }
1187
1188 return 0;
1189}
1190
Kalle Valo32a07e42011-10-30 21:15:57 +02001191static void ath6kl_sdio_stop(struct ath6kl *ar)
1192{
1193 struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar);
1194 struct bus_request *req, *tmp_req;
1195 void *context;
1196
1197 /* FIXME: make sure that wq is not queued again */
1198
1199 cancel_work_sync(&ar_sdio->wr_async_work);
1200
1201 spin_lock_bh(&ar_sdio->wr_async_lock);
1202
1203 list_for_each_entry_safe(req, tmp_req, &ar_sdio->wr_asyncq, list) {
1204 list_del(&req->list);
1205
1206 if (req->scat_req) {
1207 /* this is a scatter gather request */
1208 req->scat_req->status = -ECANCELED;
1209 req->scat_req->complete(ar_sdio->ar->htc_target,
1210 req->scat_req);
1211 } else {
1212 context = req->packet;
1213 ath6kl_sdio_free_bus_req(ar_sdio, req);
1214 ath6kl_hif_rw_comp_handler(context, -ECANCELED);
1215 }
1216 }
1217
1218 spin_unlock_bh(&ar_sdio->wr_async_lock);
1219
1220 WARN_ON(get_queue_depth(&ar_sdio->scat_req) != 4);
1221}
1222
Kalle Valobdcd8172011-07-18 00:22:30 +03001223static const struct ath6kl_hif_ops ath6kl_sdio_ops = {
1224 .read_write_sync = ath6kl_sdio_read_write_sync,
1225 .write_async = ath6kl_sdio_write_async,
1226 .irq_enable = ath6kl_sdio_irq_enable,
1227 .irq_disable = ath6kl_sdio_irq_disable,
1228 .scatter_req_get = ath6kl_sdio_scatter_req_get,
1229 .scatter_req_add = ath6kl_sdio_scatter_req_add,
1230 .enable_scatter = ath6kl_sdio_enable_scatter,
Vasanthakumar Thiagarajanf74a7362011-07-16 20:29:05 +05301231 .scat_req_rw = ath6kl_sdio_async_rw_scatter,
Kalle Valobdcd8172011-07-18 00:22:30 +03001232 .cleanup_scatter = ath6kl_sdio_cleanup_scatter,
Kalle Valoabcb3442011-07-22 08:26:20 +03001233 .suspend = ath6kl_sdio_suspend,
Chilam Ngaa6cffc2011-10-05 10:12:52 +03001234 .resume = ath6kl_sdio_resume,
Kalle Valoc7111492011-11-11 12:17:51 +02001235 .diag_read32 = ath6kl_sdio_diag_read32,
1236 .diag_write32 = ath6kl_sdio_diag_write32,
Kalle Valo66b693c2011-11-11 12:17:33 +02001237 .bmi_read = ath6kl_sdio_bmi_read,
1238 .bmi_write = ath6kl_sdio_bmi_write,
Kalle Valob2e75692011-10-27 18:48:14 +03001239 .power_on = ath6kl_sdio_power_on,
1240 .power_off = ath6kl_sdio_power_off,
Kalle Valo32a07e42011-10-30 21:15:57 +02001241 .stop = ath6kl_sdio_stop,
Kalle Valobdcd8172011-07-18 00:22:30 +03001242};
1243
Kalle Valob4b2a0b2011-11-01 08:44:44 +02001244#ifdef CONFIG_PM_SLEEP
1245
1246/*
1247 * Empty handlers so that mmc subsystem doesn't remove us entirely during
1248 * suspend. We instead follow cfg80211 suspend/resume handlers.
1249 */
1250static int ath6kl_sdio_pm_suspend(struct device *device)
1251{
1252 ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio pm suspend\n");
1253
1254 return 0;
1255}
1256
1257static int ath6kl_sdio_pm_resume(struct device *device)
1258{
1259 ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio pm resume\n");
1260
1261 return 0;
1262}
1263
1264static SIMPLE_DEV_PM_OPS(ath6kl_sdio_pm_ops, ath6kl_sdio_pm_suspend,
1265 ath6kl_sdio_pm_resume);
1266
1267#define ATH6KL_SDIO_PM_OPS (&ath6kl_sdio_pm_ops)
1268
1269#else
1270
1271#define ATH6KL_SDIO_PM_OPS NULL
1272
1273#endif /* CONFIG_PM_SLEEP */
1274
Kalle Valobdcd8172011-07-18 00:22:30 +03001275static int ath6kl_sdio_probe(struct sdio_func *func,
1276 const struct sdio_device_id *id)
1277{
1278 int ret;
1279 struct ath6kl_sdio *ar_sdio;
1280 struct ath6kl *ar;
1281 int count;
1282
Kalle Valo3ef987b2011-10-24 12:18:07 +03001283 ath6kl_dbg(ATH6KL_DBG_BOOT,
1284 "sdio new func %d vendor 0x%x device 0x%x block 0x%x/0x%x\n",
Kalle Valof7325b82011-09-27 14:30:58 +03001285 func->num, func->vendor, func->device,
1286 func->max_blksize, func->cur_blksize);
Kalle Valobdcd8172011-07-18 00:22:30 +03001287
1288 ar_sdio = kzalloc(sizeof(struct ath6kl_sdio), GFP_KERNEL);
1289 if (!ar_sdio)
1290 return -ENOMEM;
1291
1292 ar_sdio->dma_buffer = kzalloc(HIF_DMA_BUFFER_SIZE, GFP_KERNEL);
1293 if (!ar_sdio->dma_buffer) {
1294 ret = -ENOMEM;
1295 goto err_hif;
1296 }
1297
1298 ar_sdio->func = func;
1299 sdio_set_drvdata(func, ar_sdio);
1300
1301 ar_sdio->id = id;
1302 ar_sdio->is_disabled = true;
1303
1304 spin_lock_init(&ar_sdio->lock);
1305 spin_lock_init(&ar_sdio->scat_lock);
1306 spin_lock_init(&ar_sdio->wr_async_lock);
Raja Manifdb28582011-11-21 12:26:51 +05301307 mutex_init(&ar_sdio->dma_buffer_mutex);
Kalle Valobdcd8172011-07-18 00:22:30 +03001308
1309 INIT_LIST_HEAD(&ar_sdio->scat_req);
1310 INIT_LIST_HEAD(&ar_sdio->bus_req_freeq);
1311 INIT_LIST_HEAD(&ar_sdio->wr_asyncq);
1312
1313 INIT_WORK(&ar_sdio->wr_async_work, ath6kl_sdio_write_async_work);
1314
Raja Manid1f41592012-02-09 12:57:12 +05301315 init_waitqueue_head(&ar_sdio->irq_wq);
1316
Kalle Valobdcd8172011-07-18 00:22:30 +03001317 for (count = 0; count < BUS_REQUEST_MAX_NUM; count++)
1318 ath6kl_sdio_free_bus_req(ar_sdio, &ar_sdio->bus_req[count]);
1319
Kalle Valo45eaa782012-01-17 20:09:05 +02001320 ar = ath6kl_core_create(&ar_sdio->func->dev);
Kalle Valobdcd8172011-07-18 00:22:30 +03001321 if (!ar) {
1322 ath6kl_err("Failed to alloc ath6kl core\n");
1323 ret = -ENOMEM;
1324 goto err_dma;
1325 }
1326
1327 ar_sdio->ar = ar;
Kalle Valo77eab1e2011-11-11 12:18:22 +02001328 ar->hif_type = ATH6KL_HIF_TYPE_SDIO;
Kalle Valobdcd8172011-07-18 00:22:30 +03001329 ar->hif_priv = ar_sdio;
1330 ar->hif_ops = &ath6kl_sdio_ops;
Kalle Valo1f4c8942011-11-11 12:17:42 +02001331 ar->bmi.max_data_size = 256;
Kalle Valobdcd8172011-07-18 00:22:30 +03001332
1333 ath6kl_sdio_set_mbox_info(ar);
1334
Kalle Valoe28e8102011-11-01 08:44:36 +02001335 ret = ath6kl_sdio_config(ar);
Kalle Valobdcd8172011-07-18 00:22:30 +03001336 if (ret) {
Kalle Valoe28e8102011-11-01 08:44:36 +02001337 ath6kl_err("Failed to config sdio: %d\n", ret);
1338 goto err_core_alloc;
Kalle Valobdcd8172011-07-18 00:22:30 +03001339 }
1340
Kalle Valobdcd8172011-07-18 00:22:30 +03001341 ret = ath6kl_core_init(ar);
1342 if (ret) {
1343 ath6kl_err("Failed to init ath6kl core\n");
Kalle Valoe28e8102011-11-01 08:44:36 +02001344 goto err_core_alloc;
Kalle Valobdcd8172011-07-18 00:22:30 +03001345 }
1346
1347 return ret;
1348
Vasanthakumar Thiagarajan8dafb702011-10-25 19:33:58 +05301349err_core_alloc:
Kalle Valo45eaa782012-01-17 20:09:05 +02001350 ath6kl_core_destroy(ar_sdio->ar);
Kalle Valobdcd8172011-07-18 00:22:30 +03001351err_dma:
1352 kfree(ar_sdio->dma_buffer);
1353err_hif:
1354 kfree(ar_sdio);
1355
1356 return ret;
1357}
1358
1359static void ath6kl_sdio_remove(struct sdio_func *func)
1360{
1361 struct ath6kl_sdio *ar_sdio;
1362
Kalle Valo3ef987b2011-10-24 12:18:07 +03001363 ath6kl_dbg(ATH6KL_DBG_BOOT,
1364 "sdio removed func %d vendor 0x%x device 0x%x\n",
Kalle Valof7325b82011-09-27 14:30:58 +03001365 func->num, func->vendor, func->device);
1366
Kalle Valobdcd8172011-07-18 00:22:30 +03001367 ar_sdio = sdio_get_drvdata(func);
1368
1369 ath6kl_stop_txrx(ar_sdio->ar);
1370 cancel_work_sync(&ar_sdio->wr_async_work);
1371
Vasanthakumar Thiagarajan6db8fa52011-10-25 19:34:16 +05301372 ath6kl_core_cleanup(ar_sdio->ar);
Vasanthakumar Thiagarajan0e7de662012-01-21 15:22:49 +05301373 ath6kl_core_destroy(ar_sdio->ar);
Kalle Valobdcd8172011-07-18 00:22:30 +03001374
Kalle Valobdcd8172011-07-18 00:22:30 +03001375 kfree(ar_sdio->dma_buffer);
1376 kfree(ar_sdio);
1377}
1378
1379static const struct sdio_device_id ath6kl_sdio_devices[] = {
1380 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x0))},
1381 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6003_BASE | 0x1))},
Naveen Gangadharand93e2c22011-11-11 12:18:14 +02001382 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x0))},
1383 {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x1))},
Kalle Valobdcd8172011-07-18 00:22:30 +03001384 {},
1385};
1386
1387MODULE_DEVICE_TABLE(sdio, ath6kl_sdio_devices);
1388
1389static struct sdio_driver ath6kl_sdio_driver = {
Kalle Valo241b1282012-01-17 20:09:45 +02001390 .name = "ath6kl_sdio",
Kalle Valobdcd8172011-07-18 00:22:30 +03001391 .id_table = ath6kl_sdio_devices,
1392 .probe = ath6kl_sdio_probe,
1393 .remove = ath6kl_sdio_remove,
Kalle Valob4b2a0b2011-11-01 08:44:44 +02001394 .drv.pm = ATH6KL_SDIO_PM_OPS,
Kalle Valobdcd8172011-07-18 00:22:30 +03001395};
1396
1397static int __init ath6kl_sdio_init(void)
1398{
1399 int ret;
1400
1401 ret = sdio_register_driver(&ath6kl_sdio_driver);
1402 if (ret)
1403 ath6kl_err("sdio driver registration failed: %d\n", ret);
1404
1405 return ret;
1406}
1407
1408static void __exit ath6kl_sdio_exit(void)
1409{
1410 sdio_unregister_driver(&ath6kl_sdio_driver);
1411}
1412
1413module_init(ath6kl_sdio_init);
1414module_exit(ath6kl_sdio_exit);
1415
1416MODULE_AUTHOR("Atheros Communications, Inc.");
1417MODULE_DESCRIPTION("Driver support for Atheros AR600x SDIO devices");
1418MODULE_LICENSE("Dual BSD/GPL");
1419
Kalle Valoc0038972011-12-16 20:53:31 +02001420MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_OTP_FILE);
1421MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_FIRMWARE_FILE);
1422MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_PATCH_FILE);
Kalle Valo0d0192ba2011-11-14 19:31:07 +02001423MODULE_FIRMWARE(AR6003_HW_2_0_BOARD_DATA_FILE);
1424MODULE_FIRMWARE(AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE);
Kalle Valoc0038972011-12-16 20:53:31 +02001425MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_OTP_FILE);
1426MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_FIRMWARE_FILE);
1427MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_PATCH_FILE);
Kalle Valo0d0192ba2011-11-14 19:31:07 +02001428MODULE_FIRMWARE(AR6003_HW_2_1_1_BOARD_DATA_FILE);
1429MODULE_FIRMWARE(AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE);
Kalle Valoc0038972011-12-16 20:53:31 +02001430MODULE_FIRMWARE(AR6004_HW_1_0_FW_DIR "/" AR6004_HW_1_0_FIRMWARE_FILE);
Kalle Valof0ea5d52011-11-14 19:31:15 +02001431MODULE_FIRMWARE(AR6004_HW_1_0_BOARD_DATA_FILE);
1432MODULE_FIRMWARE(AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE);
Kalle Valoc0038972011-12-16 20:53:31 +02001433MODULE_FIRMWARE(AR6004_HW_1_1_FW_DIR "/" AR6004_HW_1_1_FIRMWARE_FILE);
Kalle Valof0ea5d52011-11-14 19:31:15 +02001434MODULE_FIRMWARE(AR6004_HW_1_1_BOARD_DATA_FILE);
1435MODULE_FIRMWARE(AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE);