Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2004-2011 Atheros Communications Inc. |
Vasanthakumar Thiagarajan | 1b2df40 | 2012-02-06 20:15:53 +0530 | [diff] [blame] | 3 | * Copyright (c) 2011-2012 Qualcomm Atheros, Inc. |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 4 | * |
| 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 Gortmaker | 9d9779e | 2011-07-03 15:21:01 -0400 | [diff] [blame] | 18 | #include <linux/module.h> |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 19 | #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 Valo | 2e1cb23 | 2011-10-05 12:23:49 +0300 | [diff] [blame] | 26 | #include "hif.h" |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 27 | #include "hif-ops.h" |
| 28 | #include "target.h" |
| 29 | #include "debug.h" |
Vivek Natarajan | 9df337a | 2011-09-15 20:30:43 +0530 | [diff] [blame] | 30 | #include "cfg80211.h" |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 31 | |
| 32 | struct 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 Mani | fdb2858 | 2011-11-21 12:26:51 +0530 | [diff] [blame] | 44 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 45 | u8 *dma_buffer; |
| 46 | |
Raja Mani | fdb2858 | 2011-11-21 12:26:51 +0530 | [diff] [blame] | 47 | /* protects access to dma_buffer */ |
| 48 | struct mutex dma_buffer_mutex; |
| 49 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 50 | /* scatter request list head */ |
| 51 | struct list_head scat_req; |
| 52 | |
Raja Mani | d1f4159 | 2012-02-09 12:57:12 +0530 | [diff] [blame^] | 53 | atomic_t irq_handling; |
| 54 | wait_queue_head_t irq_wq; |
Vasanthakumar Thiagarajan | 9d82682 | 2012-01-04 15:57:19 +0530 | [diff] [blame] | 55 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 56 | spinlock_t scat_lock; |
Kalle Valo | 32a07e4 | 2011-10-30 21:15:57 +0200 | [diff] [blame] | 57 | bool scatter_enabled; |
| 58 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 59 | bool is_disabled; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 60 | 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 | |
| 72 | static 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 | */ |
| 83 | static inline bool buf_needs_bounce(u8 *buf) |
| 84 | { |
| 85 | return ((unsigned long) buf & 0x3) || !virt_addr_valid(buf); |
| 86 | } |
| 87 | |
| 88 | static 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 | |
| 101 | static 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 | |
| 113 | static 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 | |
| 128 | static 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 Thiagarajan | da22069 | 2011-07-16 20:29:16 +0530 | [diff] [blame] | 142 | static int ath6kl_sdio_io(struct sdio_func *func, u32 request, u32 addr, |
| 143 | u8 *buf, u32 len) |
| 144 | { |
| 145 | int ret = 0; |
| 146 | |
Vasanthakumar Thiagarajan | 861dd05 | 2011-09-30 21:46:59 +0530 | [diff] [blame] | 147 | sdio_claim_host(func); |
| 148 | |
Vasanthakumar Thiagarajan | da22069 | 2011-07-16 20:29:16 +0530 | [diff] [blame] | 149 | if (request & HIF_WRITE) { |
Kalle Valo | f7325b8 | 2011-09-27 14:30:58 +0300 | [diff] [blame] | 150 | /* FIXME: looks like ugly workaround for something */ |
Vasanthakumar Thiagarajan | da22069 | 2011-07-16 20:29:16 +0530 | [diff] [blame] | 151 | if (addr >= HIF_MBOX_BASE_ADDR && |
| 152 | addr <= HIF_MBOX_END_ADDR) |
| 153 | addr += (HIF_MBOX_WIDTH - len); |
| 154 | |
Kalle Valo | f7325b8 | 2011-09-27 14:30:58 +0300 | [diff] [blame] | 155 | /* FIXME: this also looks like ugly workaround */ |
Vasanthakumar Thiagarajan | da22069 | 2011-07-16 20:29:16 +0530 | [diff] [blame] | 156 | 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 Thiagarajan | 861dd05 | 2011-09-30 21:46:59 +0530 | [diff] [blame] | 170 | sdio_release_host(func); |
| 171 | |
Kalle Valo | f7325b8 | 2011-09-27 14:30:58 +0300 | [diff] [blame] | 172 | 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 Thiagarajan | da22069 | 2011-07-16 20:29:16 +0530 | [diff] [blame] | 177 | return ret; |
| 178 | } |
| 179 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 180 | static struct bus_request *ath6kl_sdio_alloc_busreq(struct ath6kl_sdio *ar_sdio) |
| 181 | { |
| 182 | struct bus_request *bus_req; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 183 | |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 184 | spin_lock_bh(&ar_sdio->lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 185 | |
| 186 | if (list_empty(&ar_sdio->bus_req_freeq)) { |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 187 | spin_unlock_bh(&ar_sdio->lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 188 | 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 Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 195 | spin_unlock_bh(&ar_sdio->lock); |
Kalle Valo | f7325b8 | 2011-09-27 14:30:58 +0300 | [diff] [blame] | 196 | ath6kl_dbg(ATH6KL_DBG_SCATTER, "%s: bus request 0x%p\n", |
| 197 | __func__, bus_req); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 198 | |
| 199 | return bus_req; |
| 200 | } |
| 201 | |
| 202 | static void ath6kl_sdio_free_bus_req(struct ath6kl_sdio *ar_sdio, |
| 203 | struct bus_request *bus_req) |
| 204 | { |
Kalle Valo | f7325b8 | 2011-09-27 14:30:58 +0300 | [diff] [blame] | 205 | ath6kl_dbg(ATH6KL_DBG_SCATTER, "%s: bus request 0x%p\n", |
| 206 | __func__, bus_req); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 207 | |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 208 | spin_lock_bh(&ar_sdio->lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 209 | list_add_tail(&bus_req->list, &ar_sdio->bus_req_freeq); |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 210 | spin_unlock_bh(&ar_sdio->lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | static void ath6kl_sdio_setup_scat_data(struct hif_scatter_req *scat_req, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 214 | 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 Thiagarajan | d4df789 | 2011-07-16 20:29:07 +0530 | [diff] [blame] | 232 | sg = scat_req->sgentries; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 233 | 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 Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 237 | 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 Thiagarajan | d4df789 | 2011-07-16 20:29:07 +0530 | [diff] [blame] | 246 | data->sg = scat_req->sgentries; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 247 | data->sg_len = scat_req->scat_entries; |
| 248 | } |
| 249 | |
| 250 | static 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 Thiagarajan | 348a8fb | 2011-07-16 20:29:17 +0530 | [diff] [blame] | 258 | int status, len; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 259 | |
| 260 | scat_req = req->scat_req; |
| 261 | |
Vasanthakumar Thiagarajan | 348a8fb | 2011-07-16 20:29:17 +0530 | [diff] [blame] | 262 | 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 Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 273 | 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 Thiagarajan | d4df789 | 2011-07-16 20:29:07 +0530 | [diff] [blame] | 277 | ath6kl_sdio_setup_scat_data(scat_req, &data); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 278 | |
| 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 Thiagarajan | 861dd05 | 2011-09-30 21:46:59 +0530 | [diff] [blame] | 304 | sdio_claim_host(ar_sdio->func); |
| 305 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 306 | 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 Thiagarajan | 861dd05 | 2011-09-30 21:46:59 +0530 | [diff] [blame] | 310 | sdio_release_host(ar_sdio->func); |
| 311 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 312 | status = cmd.error ? cmd.error : data.error; |
Vasanthakumar Thiagarajan | 348a8fb | 2011-07-16 20:29:17 +0530 | [diff] [blame] | 313 | |
| 314 | scat_complete: |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 315 | 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 Thiagarajan | e041c7f | 2011-07-16 20:29:09 +0530 | [diff] [blame] | 322 | scat_req->complete(ar_sdio->ar->htc_target, scat_req); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 323 | |
| 324 | return status; |
| 325 | } |
| 326 | |
Vasanthakumar Thiagarajan | 3df505a | 2011-07-16 20:29:10 +0530 | [diff] [blame] | 327 | static 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 Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 333 | int i, scat_req_sz, scat_list_sz, sg_sz, buf_sz; |
| 334 | u8 *virt_buf; |
Vasanthakumar Thiagarajan | 3df505a | 2011-07-16 20:29:10 +0530 | [diff] [blame] | 335 | |
| 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 Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 341 | else |
| 342 | buf_sz = 2 * L1_CACHE_BYTES + |
| 343 | ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER; |
Vasanthakumar Thiagarajan | 3df505a | 2011-07-16 20:29:10 +0530 | [diff] [blame] | 344 | |
| 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 Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 351 | 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 Thiagarajan | 3df505a | 2011-07-16 20:29:10 +0530 | [diff] [blame] | 361 | /* 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 Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 374 | kfree(s_req->virt_dma_buf); |
Vasanthakumar Thiagarajan | 3df505a | 2011-07-16 20:29:10 +0530 | [diff] [blame] | 375 | 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 Thiagarajan | 4a005c3 | 2011-07-16 20:29:15 +0530 | [diff] [blame] | 383 | s_req->virt_scat = virt_scat; |
| 384 | |
Vasanthakumar Thiagarajan | 3df505a | 2011-07-16 20:29:10 +0530 | [diff] [blame] | 385 | /* add it to the scatter pool */ |
| 386 | hif_scatter_req_add(ar_sdio->ar, s_req); |
| 387 | } |
| 388 | |
| 389 | return 0; |
| 390 | } |
| 391 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 392 | static 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 Mani | fdb2858 | 2011-11-21 12:26:51 +0530 | [diff] [blame] | 406 | mutex_lock(&ar_sdio->dma_buffer_mutex); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 407 | tbuf = ar_sdio->dma_buffer; |
| 408 | memcpy(tbuf, buf, len); |
| 409 | bounced = true; |
| 410 | } else |
| 411 | tbuf = buf; |
| 412 | |
Vasanthakumar Thiagarajan | da22069 | 2011-07-16 20:29:16 +0530 | [diff] [blame] | 413 | ret = ath6kl_sdio_io(ar_sdio->func, request, addr, tbuf, len); |
| 414 | if ((request & HIF_READ) && bounced) |
| 415 | memcpy(buf, tbuf, len); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 416 | |
Raja Mani | fdb2858 | 2011-11-21 12:26:51 +0530 | [diff] [blame] | 417 | if (bounced) |
| 418 | mutex_unlock(&ar_sdio->dma_buffer_mutex); |
| 419 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 420 | return ret; |
| 421 | } |
| 422 | |
| 423 | static 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 Valo | 8e8ddb2 | 2011-10-05 12:23:33 +0300 | [diff] [blame] | 437 | ath6kl_hif_rw_comp_handler(context, status); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 438 | } |
| 439 | } |
| 440 | |
| 441 | static void ath6kl_sdio_write_async_work(struct work_struct *work) |
| 442 | { |
| 443 | struct ath6kl_sdio *ar_sdio; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 444 | struct bus_request *req, *tmp_req; |
| 445 | |
| 446 | ar_sdio = container_of(work, struct ath6kl_sdio, wr_async_work); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 447 | |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 448 | spin_lock_bh(&ar_sdio->wr_async_lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 449 | list_for_each_entry_safe(req, tmp_req, &ar_sdio->wr_asyncq, list) { |
| 450 | list_del(&req->list); |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 451 | spin_unlock_bh(&ar_sdio->wr_async_lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 452 | __ath6kl_sdio_write_async(ar_sdio, req); |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 453 | spin_lock_bh(&ar_sdio->wr_async_lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 454 | } |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 455 | spin_unlock_bh(&ar_sdio->wr_async_lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 456 | } |
| 457 | |
| 458 | static void ath6kl_sdio_irq_handler(struct sdio_func *func) |
| 459 | { |
| 460 | int status; |
| 461 | struct ath6kl_sdio *ar_sdio; |
| 462 | |
Kalle Valo | f7325b8 | 2011-09-27 14:30:58 +0300 | [diff] [blame] | 463 | ath6kl_dbg(ATH6KL_DBG_SDIO, "irq\n"); |
| 464 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 465 | ar_sdio = sdio_get_drvdata(func); |
Raja Mani | d1f4159 | 2012-02-09 12:57:12 +0530 | [diff] [blame^] | 466 | atomic_set(&ar_sdio->irq_handling, 1); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 467 | /* |
| 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 Valo | 8e8ddb2 | 2011-10-05 12:23:33 +0300 | [diff] [blame] | 473 | status = ath6kl_hif_intr_bh_handler(ar_sdio->ar); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 474 | sdio_claim_host(ar_sdio->func); |
Raja Mani | d1f4159 | 2012-02-09 12:57:12 +0530 | [diff] [blame^] | 475 | |
| 476 | atomic_set(&ar_sdio->irq_handling, 0); |
| 477 | wake_up(&ar_sdio->irq_wq); |
| 478 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 479 | WARN_ON(status && status != -ECANCELED); |
| 480 | } |
| 481 | |
Kalle Valo | b2e7569 | 2011-10-27 18:48:14 +0300 | [diff] [blame] | 482 | static int ath6kl_sdio_power_on(struct ath6kl *ar) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 483 | { |
Kalle Valo | b2e7569 | 2011-10-27 18:48:14 +0300 | [diff] [blame] | 484 | struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 485 | struct sdio_func *func = ar_sdio->func; |
| 486 | int ret = 0; |
| 487 | |
| 488 | if (!ar_sdio->is_disabled) |
| 489 | return 0; |
| 490 | |
Kalle Valo | 3ef987b | 2011-10-24 12:18:07 +0300 | [diff] [blame] | 491 | ath6kl_dbg(ATH6KL_DBG_BOOT, "sdio power on\n"); |
| 492 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 493 | 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 Valo | b2e7569 | 2011-10-27 18:48:14 +0300 | [diff] [blame] | 515 | static int ath6kl_sdio_power_off(struct ath6kl *ar) |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 516 | { |
Kalle Valo | b2e7569 | 2011-10-27 18:48:14 +0300 | [diff] [blame] | 517 | struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 518 | int ret; |
| 519 | |
| 520 | if (ar_sdio->is_disabled) |
| 521 | return 0; |
| 522 | |
Kalle Valo | 3ef987b | 2011-10-24 12:18:07 +0300 | [diff] [blame] | 523 | ath6kl_dbg(ATH6KL_DBG_BOOT, "sdio power off\n"); |
| 524 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 525 | /* 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 | |
| 538 | static 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 Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 544 | |
| 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 Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 556 | spin_lock_bh(&ar_sdio->wr_async_lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 557 | list_add_tail(&bus_req->list, &ar_sdio->wr_asyncq); |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 558 | spin_unlock_bh(&ar_sdio->wr_async_lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 559 | queue_work(ar->ath6kl_wq, &ar_sdio->wr_async_work); |
| 560 | |
| 561 | return 0; |
| 562 | } |
| 563 | |
| 564 | static 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 Mani | d1f4159 | 2012-02-09 12:57:12 +0530 | [diff] [blame^] | 579 | static 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 Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 586 | static 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 Mani | d1f4159 | 2012-02-09 12:57:12 +0530 | [diff] [blame^] | 593 | 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 Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 603 | |
| 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 | |
| 611 | static 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 Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 615 | |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 616 | spin_lock_bh(&ar_sdio->scat_lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 617 | |
| 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 Ng | b29072c | 2012-02-07 01:33:00 -0800 | [diff] [blame] | 622 | |
| 623 | node->scat_q_depth = get_queue_depth(&ar_sdio->scat_req); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 624 | } |
| 625 | |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 626 | spin_unlock_bh(&ar_sdio->scat_lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 627 | |
| 628 | return node; |
| 629 | } |
| 630 | |
| 631 | static 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 Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 635 | |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 636 | spin_lock_bh(&ar_sdio->scat_lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 637 | |
| 638 | list_add_tail(&s_req->list, &ar_sdio->scat_req); |
| 639 | |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 640 | spin_unlock_bh(&ar_sdio->scat_lock); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 641 | |
| 642 | } |
| 643 | |
Vasanthakumar Thiagarajan | c630d18 | 2011-07-16 20:29:06 +0530 | [diff] [blame] | 644 | /* scatter gather read write request */ |
| 645 | static 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 Thiagarajan | c630d18 | 2011-07-16 20:29:06 +0530 | [diff] [blame] | 649 | u32 request = scat_req->req; |
| 650 | int status = 0; |
Vasanthakumar Thiagarajan | c630d18 | 2011-07-16 20:29:06 +0530 | [diff] [blame] | 651 | |
| 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 Thiagarajan | 861dd05 | 2011-09-30 21:46:59 +0530 | [diff] [blame] | 659 | if (request & HIF_SYNCHRONOUS) |
Vasanthakumar Thiagarajan | d4df789 | 2011-07-16 20:29:07 +0530 | [diff] [blame] | 660 | status = ath6kl_sdio_scat_rw(ar_sdio, scat_req->busrequest); |
Vasanthakumar Thiagarajan | 861dd05 | 2011-09-30 21:46:59 +0530 | [diff] [blame] | 661 | else { |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 662 | spin_lock_bh(&ar_sdio->wr_async_lock); |
Vasanthakumar Thiagarajan | d4df789 | 2011-07-16 20:29:07 +0530 | [diff] [blame] | 663 | list_add_tail(&scat_req->busrequest->list, &ar_sdio->wr_asyncq); |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 664 | spin_unlock_bh(&ar_sdio->wr_async_lock); |
Vasanthakumar Thiagarajan | c630d18 | 2011-07-16 20:29:06 +0530 | [diff] [blame] | 665 | queue_work(ar->ath6kl_wq, &ar_sdio->wr_async_work); |
| 666 | } |
| 667 | |
| 668 | return status; |
| 669 | } |
| 670 | |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 671 | /* clean up scatter support */ |
| 672 | static 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 Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 676 | |
| 677 | /* empty the free list */ |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 678 | spin_lock_bh(&ar_sdio->scat_lock); |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 679 | list_for_each_entry_safe(s_req, tmp_req, &ar_sdio->scat_req, list) { |
| 680 | list_del(&s_req->list); |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 681 | spin_unlock_bh(&ar_sdio->scat_lock); |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 682 | |
Kalle Valo | 32a07e4 | 2011-10-30 21:15:57 +0200 | [diff] [blame] | 683 | /* |
| 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 Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 688 | 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 Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 694 | spin_lock_bh(&ar_sdio->scat_lock); |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 695 | } |
Vasanthakumar Thiagarajan | 151bd30 | 2011-09-30 19:18:43 +0530 | [diff] [blame] | 696 | spin_unlock_bh(&ar_sdio->scat_lock); |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 697 | } |
| 698 | |
| 699 | /* setup of HIF scatter resources */ |
Vasanthakumar Thiagarajan | 50745af | 2011-07-18 14:23:29 +0530 | [diff] [blame] | 700 | static int ath6kl_sdio_enable_scatter(struct ath6kl *ar) |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 701 | { |
| 702 | struct ath6kl_sdio *ar_sdio = ath6kl_sdio_priv(ar); |
Vasanthakumar Thiagarajan | 50745af | 2011-07-18 14:23:29 +0530 | [diff] [blame] | 703 | struct htc_target *target = ar->htc_target; |
Vasanthakumar Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 704 | int ret; |
| 705 | bool virt_scat = false; |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 706 | |
Kalle Valo | 32a07e4 | 2011-10-30 21:15:57 +0200 | [diff] [blame] | 707 | if (ar_sdio->scatter_enabled) |
| 708 | return 0; |
| 709 | |
| 710 | ar_sdio->scatter_enabled = true; |
| 711 | |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 712 | /* 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 Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 714 | ath6kl_err("host only supports scatter of :%d entries, need: %d\n", |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 715 | ar_sdio->func->card->host->max_segs, |
| 716 | MAX_SCATTER_ENTRIES_PER_REQ); |
Vasanthakumar Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 717 | virt_scat = true; |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 718 | } |
| 719 | |
Vasanthakumar Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 720 | 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 Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 724 | |
Vasanthakumar Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 725 | if (!ret) { |
Kalle Valo | 3ef987b | 2011-10-24 12:18:07 +0300 | [diff] [blame] | 726 | ath6kl_dbg(ATH6KL_DBG_BOOT, |
| 727 | "hif-scatter enabled requests %d entries %d\n", |
Vasanthakumar Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 728 | MAX_SCATTER_REQUESTS, |
| 729 | MAX_SCATTER_ENTRIES_PER_REQ); |
| 730 | |
Vasanthakumar Thiagarajan | 50745af | 2011-07-18 14:23:29 +0530 | [diff] [blame] | 731 | target->max_scat_entries = MAX_SCATTER_ENTRIES_PER_REQ; |
| 732 | target->max_xfer_szper_scatreq = |
Vasanthakumar Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 733 | 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 Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 738 | } |
| 739 | |
Vasanthakumar Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 740 | 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 Valo | 3ef987b | 2011-10-24 12:18:07 +0300 | [diff] [blame] | 751 | ath6kl_dbg(ATH6KL_DBG_BOOT, |
| 752 | "virtual scatter enabled requests %d entries %d\n", |
Vasanthakumar Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 753 | ATH6KL_SCATTER_REQS, ATH6KL_SCATTER_ENTRIES_PER_REQ); |
| 754 | |
Vasanthakumar Thiagarajan | 50745af | 2011-07-18 14:23:29 +0530 | [diff] [blame] | 755 | target->max_scat_entries = ATH6KL_SCATTER_ENTRIES_PER_REQ; |
| 756 | target->max_xfer_szper_scatreq = |
Vasanthakumar Thiagarajan | cfeab10 | 2011-07-16 20:29:14 +0530 | [diff] [blame] | 757 | ATH6KL_MAX_TRANSFER_SIZE_PER_SCATTER; |
| 758 | } |
| 759 | |
Vasanthakumar Thiagarajan | 18a0f93 | 2011-07-16 20:29:13 +0530 | [diff] [blame] | 760 | return 0; |
| 761 | } |
| 762 | |
Kalle Valo | e28e810 | 2011-11-01 08:44:36 +0200 | [diff] [blame] | 763 | static 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 Valo | e28e810 | 2011-11-01 08:44:36 +0200 | [diff] [blame] | 793 | goto out; |
| 794 | } |
| 795 | |
| 796 | out: |
| 797 | sdio_release_host(func); |
| 798 | |
| 799 | return ret; |
| 800 | } |
| 801 | |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 802 | static int ath6kl_set_sdio_pm_caps(struct ath6kl *ar) |
Kalle Valo | abcb344 | 2011-07-22 08:26:20 +0300 | [diff] [blame] | 803 | { |
| 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 Valo | b4b2a0b | 2011-11-01 08:44:44 +0200 | [diff] [blame] | 811 | ath6kl_dbg(ATH6KL_DBG_SUSPEND, "sdio suspend pm_caps 0x%x\n", flags); |
| 812 | |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 813 | if (!(flags & MMC_PM_WAKE_SDIO_IRQ) || |
| 814 | !(flags & MMC_PM_KEEP_POWER)) |
| 815 | return -EINVAL; |
Kalle Valo | abcb344 | 2011-07-22 08:26:20 +0300 | [diff] [blame] | 816 | |
| 817 | ret = sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); |
| 818 | if (ret) { |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 819 | ath6kl_err("set sdio keep pwr flag failed: %d\n", ret); |
Kalle Valo | abcb344 | 2011-07-22 08:26:20 +0300 | [diff] [blame] | 820 | return ret; |
| 821 | } |
| 822 | |
Kalle Valo | 10509f9 | 2011-12-13 14:52:07 +0200 | [diff] [blame] | 823 | /* sdio irq wakes up host */ |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 824 | 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 | |
| 831 | static 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 Valo | 10509f9 | 2011-12-13 14:52:07 +0200 | [diff] [blame] | 837 | |
| 838 | if (ar->state == ATH6KL_STATE_SCHED_SCAN) { |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 839 | 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 Valo | 10509f9 | 2011-12-13 14:52:07 +0200 | [diff] [blame] | 845 | ret = ath6kl_cfg80211_suspend(ar, |
| 846 | ATH6KL_CFG_SUSPEND_SCHED_SCAN, |
| 847 | NULL); |
Kalle Valo | 10509f9 | 2011-12-13 14:52:07 +0200 | [diff] [blame] | 848 | if (ret) |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 849 | goto cut_pwr; |
Kalle Valo | 10509f9 | 2011-12-13 14:52:07 +0200 | [diff] [blame] | 850 | |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 851 | return 0; |
Kalle Valo | 10509f9 | 2011-12-13 14:52:07 +0200 | [diff] [blame] | 852 | } |
| 853 | |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 854 | 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 Mani | d7c44e0 | 2011-11-07 22:52:46 +0200 | [diff] [blame] | 861 | ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_WOW, wow); |
| 862 | if (ret) |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 863 | goto cut_pwr; |
Raja Mani | d7c44e0 | 2011-11-07 22:52:46 +0200 | [diff] [blame] | 864 | |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 865 | return 0; |
Raja Mani | d7c44e0 | 2011-11-07 22:52:46 +0200 | [diff] [blame] | 866 | } |
| 867 | |
Raja Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 868 | 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 Sajjan | cca4d5a | 2012-01-30 22:02:26 +0200 | [diff] [blame] | 879 | /* |
| 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 Mani | e390af7 | 2012-01-30 17:13:09 +0530 | [diff] [blame] | 892 | ret = ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_DEEPSLEEP, |
| 893 | NULL); |
| 894 | if (ret) |
| 895 | goto cut_pwr; |
| 896 | |
| 897 | return 0; |
| 898 | } |
| 899 | |
| 900 | cut_pwr: |
| 901 | return ath6kl_cfg80211_suspend(ar, ATH6KL_CFG_SUSPEND_CUTPOWER, NULL); |
Kalle Valo | abcb344 | 2011-07-22 08:26:20 +0300 | [diff] [blame] | 902 | } |
| 903 | |
Chilam Ng | aa6cffc | 2011-10-05 10:12:52 +0300 | [diff] [blame] | 904 | static int ath6kl_sdio_resume(struct ath6kl *ar) |
| 905 | { |
Kalle Valo | b4b2a0b | 2011-11-01 08:44:44 +0200 | [diff] [blame] | 906 | 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 Valo | b4b2a0b | 2011-11-01 08:44:44 +0200 | [diff] [blame] | 917 | break; |
| 918 | |
| 919 | case ATH6KL_STATE_DEEPSLEEP: |
| 920 | break; |
Raja Mani | d7c44e0 | 2011-11-07 22:52:46 +0200 | [diff] [blame] | 921 | |
| 922 | case ATH6KL_STATE_WOW: |
| 923 | break; |
Kalle Valo | 10509f9 | 2011-12-13 14:52:07 +0200 | [diff] [blame] | 924 | case ATH6KL_STATE_SCHED_SCAN: |
| 925 | break; |
Kalle Valo | b4b2a0b | 2011-11-01 08:44:44 +0200 | [diff] [blame] | 926 | } |
| 927 | |
Kalle Valo | 52d81a6 | 2011-11-01 08:44:21 +0200 | [diff] [blame] | 928 | ath6kl_cfg80211_resume(ar); |
Chilam Ng | aa6cffc | 2011-10-05 10:12:52 +0300 | [diff] [blame] | 929 | |
| 930 | return 0; |
| 931 | } |
| 932 | |
Kalle Valo | c711149 | 2011-11-11 12:17:51 +0200 | [diff] [blame] | 933 | /* set the window address register (using 4-byte register access ). */ |
| 934 | static 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 | |
| 988 | static 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 | |
| 1011 | static 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 Valo | 66b693c | 2011-11-11 12:17:33 +0200 | [diff] [blame] | 1031 | static 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 | |
| 1074 | static 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 | |
| 1103 | static 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 | |
| 1122 | static 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 Valo | 32a07e4 | 2011-10-30 21:15:57 +0200 | [diff] [blame] | 1191 | static 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 Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1223 | static 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 Thiagarajan | f74a736 | 2011-07-16 20:29:05 +0530 | [diff] [blame] | 1231 | .scat_req_rw = ath6kl_sdio_async_rw_scatter, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1232 | .cleanup_scatter = ath6kl_sdio_cleanup_scatter, |
Kalle Valo | abcb344 | 2011-07-22 08:26:20 +0300 | [diff] [blame] | 1233 | .suspend = ath6kl_sdio_suspend, |
Chilam Ng | aa6cffc | 2011-10-05 10:12:52 +0300 | [diff] [blame] | 1234 | .resume = ath6kl_sdio_resume, |
Kalle Valo | c711149 | 2011-11-11 12:17:51 +0200 | [diff] [blame] | 1235 | .diag_read32 = ath6kl_sdio_diag_read32, |
| 1236 | .diag_write32 = ath6kl_sdio_diag_write32, |
Kalle Valo | 66b693c | 2011-11-11 12:17:33 +0200 | [diff] [blame] | 1237 | .bmi_read = ath6kl_sdio_bmi_read, |
| 1238 | .bmi_write = ath6kl_sdio_bmi_write, |
Kalle Valo | b2e7569 | 2011-10-27 18:48:14 +0300 | [diff] [blame] | 1239 | .power_on = ath6kl_sdio_power_on, |
| 1240 | .power_off = ath6kl_sdio_power_off, |
Kalle Valo | 32a07e4 | 2011-10-30 21:15:57 +0200 | [diff] [blame] | 1241 | .stop = ath6kl_sdio_stop, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1242 | }; |
| 1243 | |
Kalle Valo | b4b2a0b | 2011-11-01 08:44:44 +0200 | [diff] [blame] | 1244 | #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 | */ |
| 1250 | static 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 | |
| 1257 | static 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 | |
| 1264 | static 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 Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1275 | static 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 Valo | 3ef987b | 2011-10-24 12:18:07 +0300 | [diff] [blame] | 1283 | ath6kl_dbg(ATH6KL_DBG_BOOT, |
| 1284 | "sdio new func %d vendor 0x%x device 0x%x block 0x%x/0x%x\n", |
Kalle Valo | f7325b8 | 2011-09-27 14:30:58 +0300 | [diff] [blame] | 1285 | func->num, func->vendor, func->device, |
| 1286 | func->max_blksize, func->cur_blksize); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1287 | |
| 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 Mani | fdb2858 | 2011-11-21 12:26:51 +0530 | [diff] [blame] | 1307 | mutex_init(&ar_sdio->dma_buffer_mutex); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1308 | |
| 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 Mani | d1f4159 | 2012-02-09 12:57:12 +0530 | [diff] [blame^] | 1315 | init_waitqueue_head(&ar_sdio->irq_wq); |
| 1316 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1317 | for (count = 0; count < BUS_REQUEST_MAX_NUM; count++) |
| 1318 | ath6kl_sdio_free_bus_req(ar_sdio, &ar_sdio->bus_req[count]); |
| 1319 | |
Kalle Valo | 45eaa78 | 2012-01-17 20:09:05 +0200 | [diff] [blame] | 1320 | ar = ath6kl_core_create(&ar_sdio->func->dev); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1321 | 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 Valo | 77eab1e | 2011-11-11 12:18:22 +0200 | [diff] [blame] | 1328 | ar->hif_type = ATH6KL_HIF_TYPE_SDIO; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1329 | ar->hif_priv = ar_sdio; |
| 1330 | ar->hif_ops = &ath6kl_sdio_ops; |
Kalle Valo | 1f4c894 | 2011-11-11 12:17:42 +0200 | [diff] [blame] | 1331 | ar->bmi.max_data_size = 256; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1332 | |
| 1333 | ath6kl_sdio_set_mbox_info(ar); |
| 1334 | |
Kalle Valo | e28e810 | 2011-11-01 08:44:36 +0200 | [diff] [blame] | 1335 | ret = ath6kl_sdio_config(ar); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1336 | if (ret) { |
Kalle Valo | e28e810 | 2011-11-01 08:44:36 +0200 | [diff] [blame] | 1337 | ath6kl_err("Failed to config sdio: %d\n", ret); |
| 1338 | goto err_core_alloc; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1339 | } |
| 1340 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1341 | ret = ath6kl_core_init(ar); |
| 1342 | if (ret) { |
| 1343 | ath6kl_err("Failed to init ath6kl core\n"); |
Kalle Valo | e28e810 | 2011-11-01 08:44:36 +0200 | [diff] [blame] | 1344 | goto err_core_alloc; |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1345 | } |
| 1346 | |
| 1347 | return ret; |
| 1348 | |
Vasanthakumar Thiagarajan | 8dafb70 | 2011-10-25 19:33:58 +0530 | [diff] [blame] | 1349 | err_core_alloc: |
Kalle Valo | 45eaa78 | 2012-01-17 20:09:05 +0200 | [diff] [blame] | 1350 | ath6kl_core_destroy(ar_sdio->ar); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1351 | err_dma: |
| 1352 | kfree(ar_sdio->dma_buffer); |
| 1353 | err_hif: |
| 1354 | kfree(ar_sdio); |
| 1355 | |
| 1356 | return ret; |
| 1357 | } |
| 1358 | |
| 1359 | static void ath6kl_sdio_remove(struct sdio_func *func) |
| 1360 | { |
| 1361 | struct ath6kl_sdio *ar_sdio; |
| 1362 | |
Kalle Valo | 3ef987b | 2011-10-24 12:18:07 +0300 | [diff] [blame] | 1363 | ath6kl_dbg(ATH6KL_DBG_BOOT, |
| 1364 | "sdio removed func %d vendor 0x%x device 0x%x\n", |
Kalle Valo | f7325b8 | 2011-09-27 14:30:58 +0300 | [diff] [blame] | 1365 | func->num, func->vendor, func->device); |
| 1366 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1367 | 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 Thiagarajan | 6db8fa5 | 2011-10-25 19:34:16 +0530 | [diff] [blame] | 1372 | ath6kl_core_cleanup(ar_sdio->ar); |
Vasanthakumar Thiagarajan | 0e7de66 | 2012-01-21 15:22:49 +0530 | [diff] [blame] | 1373 | ath6kl_core_destroy(ar_sdio->ar); |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1374 | |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1375 | kfree(ar_sdio->dma_buffer); |
| 1376 | kfree(ar_sdio); |
| 1377 | } |
| 1378 | |
| 1379 | static 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 Gangadharan | d93e2c2 | 2011-11-11 12:18:14 +0200 | [diff] [blame] | 1382 | {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x0))}, |
| 1383 | {SDIO_DEVICE(MANUFACTURER_CODE, (MANUFACTURER_ID_AR6004_BASE | 0x1))}, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1384 | {}, |
| 1385 | }; |
| 1386 | |
| 1387 | MODULE_DEVICE_TABLE(sdio, ath6kl_sdio_devices); |
| 1388 | |
| 1389 | static struct sdio_driver ath6kl_sdio_driver = { |
Kalle Valo | 241b128 | 2012-01-17 20:09:45 +0200 | [diff] [blame] | 1390 | .name = "ath6kl_sdio", |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1391 | .id_table = ath6kl_sdio_devices, |
| 1392 | .probe = ath6kl_sdio_probe, |
| 1393 | .remove = ath6kl_sdio_remove, |
Kalle Valo | b4b2a0b | 2011-11-01 08:44:44 +0200 | [diff] [blame] | 1394 | .drv.pm = ATH6KL_SDIO_PM_OPS, |
Kalle Valo | bdcd817 | 2011-07-18 00:22:30 +0300 | [diff] [blame] | 1395 | }; |
| 1396 | |
| 1397 | static 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 | |
| 1408 | static void __exit ath6kl_sdio_exit(void) |
| 1409 | { |
| 1410 | sdio_unregister_driver(&ath6kl_sdio_driver); |
| 1411 | } |
| 1412 | |
| 1413 | module_init(ath6kl_sdio_init); |
| 1414 | module_exit(ath6kl_sdio_exit); |
| 1415 | |
| 1416 | MODULE_AUTHOR("Atheros Communications, Inc."); |
| 1417 | MODULE_DESCRIPTION("Driver support for Atheros AR600x SDIO devices"); |
| 1418 | MODULE_LICENSE("Dual BSD/GPL"); |
| 1419 | |
Kalle Valo | c003897 | 2011-12-16 20:53:31 +0200 | [diff] [blame] | 1420 | MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_OTP_FILE); |
| 1421 | MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_FIRMWARE_FILE); |
| 1422 | MODULE_FIRMWARE(AR6003_HW_2_0_FW_DIR "/" AR6003_HW_2_0_PATCH_FILE); |
Kalle Valo | 0d0192ba | 2011-11-14 19:31:07 +0200 | [diff] [blame] | 1423 | MODULE_FIRMWARE(AR6003_HW_2_0_BOARD_DATA_FILE); |
| 1424 | MODULE_FIRMWARE(AR6003_HW_2_0_DEFAULT_BOARD_DATA_FILE); |
Kalle Valo | c003897 | 2011-12-16 20:53:31 +0200 | [diff] [blame] | 1425 | MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_OTP_FILE); |
| 1426 | MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_FIRMWARE_FILE); |
| 1427 | MODULE_FIRMWARE(AR6003_HW_2_1_1_FW_DIR "/" AR6003_HW_2_1_1_PATCH_FILE); |
Kalle Valo | 0d0192ba | 2011-11-14 19:31:07 +0200 | [diff] [blame] | 1428 | MODULE_FIRMWARE(AR6003_HW_2_1_1_BOARD_DATA_FILE); |
| 1429 | MODULE_FIRMWARE(AR6003_HW_2_1_1_DEFAULT_BOARD_DATA_FILE); |
Kalle Valo | c003897 | 2011-12-16 20:53:31 +0200 | [diff] [blame] | 1430 | MODULE_FIRMWARE(AR6004_HW_1_0_FW_DIR "/" AR6004_HW_1_0_FIRMWARE_FILE); |
Kalle Valo | f0ea5d5 | 2011-11-14 19:31:15 +0200 | [diff] [blame] | 1431 | MODULE_FIRMWARE(AR6004_HW_1_0_BOARD_DATA_FILE); |
| 1432 | MODULE_FIRMWARE(AR6004_HW_1_0_DEFAULT_BOARD_DATA_FILE); |
Kalle Valo | c003897 | 2011-12-16 20:53:31 +0200 | [diff] [blame] | 1433 | MODULE_FIRMWARE(AR6004_HW_1_1_FW_DIR "/" AR6004_HW_1_1_FIRMWARE_FILE); |
Kalle Valo | f0ea5d5 | 2011-11-14 19:31:15 +0200 | [diff] [blame] | 1434 | MODULE_FIRMWARE(AR6004_HW_1_1_BOARD_DATA_FILE); |
| 1435 | MODULE_FIRMWARE(AR6004_HW_1_1_DEFAULT_BOARD_DATA_FILE); |