blob: 9ef48167e2cf8ba64c790d4846a2d297e84c6fd0 [file] [log] [blame]
Bing Zhao789221e2009-06-02 14:29:36 -07001/**
2 * Marvell BT-over-SDIO driver: SDIO interface related functions.
3 *
4 * Copyright (C) 2009, Marvell International Ltd.
5 *
6 * This software file (the "File") is distributed by Marvell International
7 * Ltd. under the terms of the GNU General Public License Version 2, June 1991
8 * (the "License"). You may use, redistribute and/or modify this File in
9 * accordance with the terms and conditions of the License, a copy of which
10 * is available by writing to the Free Software Foundation, Inc.,
11 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the
12 * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt.
13 *
14 *
15 * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE
17 * ARE EXPRESSLY DISCLAIMED. The License provides additional details about
18 * this warranty disclaimer.
19 **/
20
21#include <linux/firmware.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090022#include <linux/slab.h>
Bing Zhao789221e2009-06-02 14:29:36 -070023
24#include <linux/mmc/sdio_ids.h>
25#include <linux/mmc/sdio_func.h>
Paul Gortmakera59b9682011-08-29 16:44:23 -040026#include <linux/module.h>
Bing Zhao789221e2009-06-02 14:29:36 -070027
28#include <net/bluetooth/bluetooth.h>
29#include <net/bluetooth/hci_core.h>
30
31#include "btmrvl_drv.h"
32#include "btmrvl_sdio.h"
33
34#define VERSION "1.0"
35
Bing Zhao789221e2009-06-02 14:29:36 -070036/* The btmrvl_sdio_remove() callback function is called
37 * when user removes this module from kernel space or ejects
38 * the card from the slot. The driver handles these 2 cases
39 * differently.
40 * If the user is removing the module, a MODULE_SHUTDOWN_REQ
41 * command is sent to firmware and interrupt will be disabled.
42 * If the card is removed, there is no need to send command
43 * or disable interrupt.
44 *
45 * The variable 'user_rmmod' is used to distinguish these two
46 * scenarios. This flag is initialized as FALSE in case the card
47 * is removed, and will be set to TRUE for module removal when
48 * module_exit function is called.
49 */
50static u8 user_rmmod;
Amitkumar Karward1d10d72010-05-27 16:38:37 -070051static u8 sdio_ireg;
Bing Zhao789221e2009-06-02 14:29:36 -070052
Kevin Gan9f72c1d2011-04-08 18:19:33 -070053static const struct btmrvl_sdio_card_reg btmrvl_reg_8688 = {
54 .cfg = 0x03,
55 .host_int_mask = 0x04,
56 .host_intstatus = 0x05,
57 .card_status = 0x20,
58 .sq_read_base_addr_a0 = 0x10,
59 .sq_read_base_addr_a1 = 0x11,
60 .card_fw_status0 = 0x40,
61 .card_fw_status1 = 0x41,
62 .card_rx_len = 0x42,
63 .card_rx_unit = 0x43,
64 .io_port_0 = 0x00,
65 .io_port_1 = 0x01,
66 .io_port_2 = 0x02,
67};
68static const struct btmrvl_sdio_card_reg btmrvl_reg_8787 = {
69 .cfg = 0x00,
70 .host_int_mask = 0x02,
71 .host_intstatus = 0x03,
72 .card_status = 0x30,
73 .sq_read_base_addr_a0 = 0x40,
74 .sq_read_base_addr_a1 = 0x41,
75 .card_revision = 0x5c,
76 .card_fw_status0 = 0x60,
77 .card_fw_status1 = 0x61,
78 .card_rx_len = 0x62,
79 .card_rx_unit = 0x63,
80 .io_port_0 = 0x78,
81 .io_port_1 = 0x79,
82 .io_port_2 = 0x7a,
83};
84
Paul Bollec6757862011-10-05 14:56:46 +020085static const struct btmrvl_sdio_device btmrvl_sdio_sd8688 = {
Marcel Holtmanndcf47f32009-06-09 16:21:58 +020086 .helper = "sd8688_helper.bin",
87 .firmware = "sd8688.bin",
Kevin Gan9f72c1d2011-04-08 18:19:33 -070088 .reg = &btmrvl_reg_8688,
89 .sd_blksz_fw_dl = 64,
90};
91
92static const struct btmrvl_sdio_device btmrvl_sdio_sd8787 = {
93 .helper = NULL,
94 .firmware = "mrvl/sd8787_uapsta.bin",
95 .reg = &btmrvl_reg_8787,
96 .sd_blksz_fw_dl = 256,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +020097};
98
Bing Zhao789221e2009-06-02 14:29:36 -070099static const struct sdio_device_id btmrvl_sdio_ids[] = {
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200100 /* Marvell SD8688 Bluetooth device */
101 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9105),
Paul Bollec6757862011-10-05 14:56:46 +0200102 .driver_data = (unsigned long) &btmrvl_sdio_sd8688 },
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700103 /* Marvell SD8787 Bluetooth device */
104 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x911A),
105 .driver_data = (unsigned long) &btmrvl_sdio_sd8787 },
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200106
107 { } /* Terminating entry */
Bing Zhao789221e2009-06-02 14:29:36 -0700108};
109
110MODULE_DEVICE_TABLE(sdio, btmrvl_sdio_ids);
111
Bing Zhao789221e2009-06-02 14:29:36 -0700112static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_card *card)
113{
114 u8 reg;
115 int ret;
116
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700117 reg = sdio_readb(card->func, card->reg->card_rx_unit, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700118 if (!ret)
119 card->rx_unit = reg;
120
Bing Zhao789221e2009-06-02 14:29:36 -0700121 return ret;
122}
123
124static int btmrvl_sdio_read_fw_status(struct btmrvl_sdio_card *card, u16 *dat)
125{
Bing Zhao789221e2009-06-02 14:29:36 -0700126 u8 fws0, fws1;
Marcel Holtmann93742532009-06-13 07:40:18 +0200127 int ret;
Bing Zhao789221e2009-06-02 14:29:36 -0700128
129 *dat = 0;
130
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700131 fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret);
Kulikov Vasiliy278be272010-07-05 12:01:22 +0400132 if (ret)
133 return -EIO;
Bing Zhao789221e2009-06-02 14:29:36 -0700134
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700135 fws1 = sdio_readb(card->func, card->reg->card_fw_status1, &ret);
Marcel Holtmann93742532009-06-13 07:40:18 +0200136 if (ret)
Bing Zhao789221e2009-06-02 14:29:36 -0700137 return -EIO;
Bing Zhao789221e2009-06-02 14:29:36 -0700138
139 *dat = (((u16) fws1) << 8) | fws0;
140
Bing Zhao789221e2009-06-02 14:29:36 -0700141 return 0;
142}
143
144static int btmrvl_sdio_read_rx_len(struct btmrvl_sdio_card *card, u16 *dat)
145{
Bing Zhao789221e2009-06-02 14:29:36 -0700146 u8 reg;
Marcel Holtmann93742532009-06-13 07:40:18 +0200147 int ret;
Bing Zhao789221e2009-06-02 14:29:36 -0700148
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700149 reg = sdio_readb(card->func, card->reg->card_rx_len, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700150 if (!ret)
151 *dat = (u16) reg << card->rx_unit;
152
Bing Zhao789221e2009-06-02 14:29:36 -0700153 return ret;
154}
155
156static int btmrvl_sdio_enable_host_int_mask(struct btmrvl_sdio_card *card,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200157 u8 mask)
Bing Zhao789221e2009-06-02 14:29:36 -0700158{
159 int ret;
160
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700161 sdio_writeb(card->func, mask, card->reg->host_int_mask, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700162 if (ret) {
163 BT_ERR("Unable to enable the host interrupt!");
164 ret = -EIO;
165 }
166
Bing Zhao789221e2009-06-02 14:29:36 -0700167 return ret;
168}
169
170static int btmrvl_sdio_disable_host_int_mask(struct btmrvl_sdio_card *card,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200171 u8 mask)
Bing Zhao789221e2009-06-02 14:29:36 -0700172{
Bing Zhao789221e2009-06-02 14:29:36 -0700173 u8 host_int_mask;
Marcel Holtmann93742532009-06-13 07:40:18 +0200174 int ret;
Bing Zhao789221e2009-06-02 14:29:36 -0700175
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700176 host_int_mask = sdio_readb(card->func, card->reg->host_int_mask, &ret);
Marcel Holtmann93742532009-06-13 07:40:18 +0200177 if (ret)
178 return -EIO;
Bing Zhao789221e2009-06-02 14:29:36 -0700179
180 host_int_mask &= ~mask;
181
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700182 sdio_writeb(card->func, host_int_mask, card->reg->host_int_mask, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700183 if (ret < 0) {
184 BT_ERR("Unable to disable the host interrupt!");
Marcel Holtmann93742532009-06-13 07:40:18 +0200185 return -EIO;
Bing Zhao789221e2009-06-02 14:29:36 -0700186 }
187
Marcel Holtmann93742532009-06-13 07:40:18 +0200188 return 0;
Bing Zhao789221e2009-06-02 14:29:36 -0700189}
190
191static int btmrvl_sdio_poll_card_status(struct btmrvl_sdio_card *card, u8 bits)
192{
193 unsigned int tries;
Bing Zhao789221e2009-06-02 14:29:36 -0700194 u8 status;
Marcel Holtmann93742532009-06-13 07:40:18 +0200195 int ret;
Bing Zhao789221e2009-06-02 14:29:36 -0700196
197 for (tries = 0; tries < MAX_POLL_TRIES * 1000; tries++) {
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700198 status = sdio_readb(card->func, card->reg->card_status, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700199 if (ret)
200 goto failed;
201 if ((status & bits) == bits)
Marcel Holtmann93742532009-06-13 07:40:18 +0200202 return ret;
Bing Zhao789221e2009-06-02 14:29:36 -0700203
204 udelay(1);
205 }
206
207 ret = -ETIMEDOUT;
208
209failed:
210 BT_ERR("FAILED! ret=%d", ret);
211
Bing Zhao789221e2009-06-02 14:29:36 -0700212 return ret;
213}
214
215static int btmrvl_sdio_verify_fw_download(struct btmrvl_sdio_card *card,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200216 int pollnum)
Bing Zhao789221e2009-06-02 14:29:36 -0700217{
218 int ret = -ETIMEDOUT;
219 u16 firmwarestat;
220 unsigned int tries;
221
Bing Zhao789221e2009-06-02 14:29:36 -0700222 /* Wait for firmware to become ready */
223 for (tries = 0; tries < pollnum; tries++) {
224 if (btmrvl_sdio_read_fw_status(card, &firmwarestat) < 0)
225 continue;
226
227 if (firmwarestat == FIRMWARE_READY) {
228 ret = 0;
229 break;
230 } else {
231 msleep(10);
232 }
233 }
234
Bing Zhao789221e2009-06-02 14:29:36 -0700235 return ret;
236}
237
238static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card)
239{
240 const struct firmware *fw_helper = NULL;
241 const u8 *helper = NULL;
242 int ret;
243 void *tmphlprbuf = NULL;
244 int tmphlprbufsz, hlprblknow, helperlen;
245 u8 *helperbuf;
246 u32 tx_len;
247
Bing Zhao789221e2009-06-02 14:29:36 -0700248 ret = request_firmware(&fw_helper, card->helper,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200249 &card->func->dev);
Bing Zhao789221e2009-06-02 14:29:36 -0700250 if ((ret < 0) || !fw_helper) {
251 BT_ERR("request_firmware(helper) failed, error code = %d",
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200252 ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700253 ret = -ENOENT;
254 goto done;
255 }
256
257 helper = fw_helper->data;
258 helperlen = fw_helper->size;
259
260 BT_DBG("Downloading helper image (%d bytes), block size %d bytes",
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200261 helperlen, SDIO_BLOCK_SIZE);
Bing Zhao789221e2009-06-02 14:29:36 -0700262
263 tmphlprbufsz = ALIGN_SZ(BTM_UPLD_SIZE, BTSDIO_DMA_ALIGN);
264
Julia Lawallf8df39f2010-05-13 22:02:03 +0200265 tmphlprbuf = kzalloc(tmphlprbufsz, GFP_KERNEL);
Bing Zhao789221e2009-06-02 14:29:36 -0700266 if (!tmphlprbuf) {
267 BT_ERR("Unable to allocate buffer for helper."
268 " Terminating download");
269 ret = -ENOMEM;
270 goto done;
271 }
272
Bing Zhao789221e2009-06-02 14:29:36 -0700273 helperbuf = (u8 *) ALIGN_ADDR(tmphlprbuf, BTSDIO_DMA_ALIGN);
274
275 /* Perform helper data transfer */
276 tx_len = (FIRMWARE_TRANSFER_NBLOCK * SDIO_BLOCK_SIZE)
277 - SDIO_HEADER_LEN;
278 hlprblknow = 0;
279
280 do {
281 ret = btmrvl_sdio_poll_card_status(card,
282 CARD_IO_READY | DN_LD_CARD_RDY);
283 if (ret < 0) {
284 BT_ERR("Helper download poll status timeout @ %d",
285 hlprblknow);
286 goto done;
287 }
288
289 /* Check if there is more data? */
290 if (hlprblknow >= helperlen)
291 break;
292
293 if (helperlen - hlprblknow < tx_len)
294 tx_len = helperlen - hlprblknow;
295
296 /* Little-endian */
297 helperbuf[0] = ((tx_len & 0x000000ff) >> 0);
298 helperbuf[1] = ((tx_len & 0x0000ff00) >> 8);
299 helperbuf[2] = ((tx_len & 0x00ff0000) >> 16);
300 helperbuf[3] = ((tx_len & 0xff000000) >> 24);
301
302 memcpy(&helperbuf[SDIO_HEADER_LEN], &helper[hlprblknow],
303 tx_len);
304
305 /* Now send the data */
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200306 ret = sdio_writesb(card->func, card->ioport, helperbuf,
307 FIRMWARE_TRANSFER_NBLOCK * SDIO_BLOCK_SIZE);
Bing Zhao789221e2009-06-02 14:29:36 -0700308 if (ret < 0) {
309 BT_ERR("IO error during helper download @ %d",
310 hlprblknow);
311 goto done;
312 }
313
314 hlprblknow += tx_len;
315 } while (true);
316
317 BT_DBG("Transferring helper image EOF block");
318
319 memset(helperbuf, 0x0, SDIO_BLOCK_SIZE);
320
321 ret = sdio_writesb(card->func, card->ioport, helperbuf,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200322 SDIO_BLOCK_SIZE);
Bing Zhao789221e2009-06-02 14:29:36 -0700323 if (ret < 0) {
324 BT_ERR("IO error in writing helper image EOF block");
325 goto done;
326 }
327
328 ret = 0;
329
330done:
331 kfree(tmphlprbuf);
332 if (fw_helper)
333 release_firmware(fw_helper);
334
Bing Zhao789221e2009-06-02 14:29:36 -0700335 return ret;
336}
337
338static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card)
339{
340 const struct firmware *fw_firmware = NULL;
341 const u8 *firmware = NULL;
342 int firmwarelen, tmpfwbufsz, ret;
343 unsigned int tries, offset;
344 u8 base0, base1;
345 void *tmpfwbuf = NULL;
346 u8 *fwbuf;
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700347 u16 len, blksz_dl = card->sd_blksz_fw_dl;
Bing Zhao789221e2009-06-02 14:29:36 -0700348 int txlen = 0, tx_blocks = 0, count = 0;
349
Bing Zhao789221e2009-06-02 14:29:36 -0700350 ret = request_firmware(&fw_firmware, card->firmware,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200351 &card->func->dev);
Bing Zhao789221e2009-06-02 14:29:36 -0700352 if ((ret < 0) || !fw_firmware) {
353 BT_ERR("request_firmware(firmware) failed, error code = %d",
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200354 ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700355 ret = -ENOENT;
356 goto done;
357 }
358
359 firmware = fw_firmware->data;
360 firmwarelen = fw_firmware->size;
361
362 BT_DBG("Downloading FW image (%d bytes)", firmwarelen);
363
364 tmpfwbufsz = ALIGN_SZ(BTM_UPLD_SIZE, BTSDIO_DMA_ALIGN);
Julia Lawallf8df39f2010-05-13 22:02:03 +0200365 tmpfwbuf = kzalloc(tmpfwbufsz, GFP_KERNEL);
Bing Zhao789221e2009-06-02 14:29:36 -0700366 if (!tmpfwbuf) {
367 BT_ERR("Unable to allocate buffer for firmware."
368 " Terminating download");
369 ret = -ENOMEM;
370 goto done;
371 }
372
Bing Zhao789221e2009-06-02 14:29:36 -0700373 /* Ensure aligned firmware buffer */
374 fwbuf = (u8 *) ALIGN_ADDR(tmpfwbuf, BTSDIO_DMA_ALIGN);
375
376 /* Perform firmware data transfer */
377 offset = 0;
378 do {
379 ret = btmrvl_sdio_poll_card_status(card,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200380 CARD_IO_READY | DN_LD_CARD_RDY);
Bing Zhao789221e2009-06-02 14:29:36 -0700381 if (ret < 0) {
382 BT_ERR("FW download with helper poll status"
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200383 " timeout @ %d", offset);
Bing Zhao789221e2009-06-02 14:29:36 -0700384 goto done;
385 }
386
387 /* Check if there is more data ? */
388 if (offset >= firmwarelen)
389 break;
390
391 for (tries = 0; tries < MAX_POLL_TRIES; tries++) {
392 base0 = sdio_readb(card->func,
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700393 card->reg->sq_read_base_addr_a0, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700394 if (ret) {
395 BT_ERR("BASE0 register read failed:"
396 " base0 = 0x%04X(%d)."
397 " Terminating download",
398 base0, base0);
399 ret = -EIO;
400 goto done;
401 }
402 base1 = sdio_readb(card->func,
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700403 card->reg->sq_read_base_addr_a1, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700404 if (ret) {
405 BT_ERR("BASE1 register read failed:"
406 " base1 = 0x%04X(%d)."
407 " Terminating download",
408 base1, base1);
409 ret = -EIO;
410 goto done;
411 }
412
413 len = (((u16) base1) << 8) | base0;
414 if (len)
415 break;
416
417 udelay(10);
418 }
419
420 if (!len)
421 break;
422 else if (len > BTM_UPLD_SIZE) {
423 BT_ERR("FW download failure @%d, invalid length %d",
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200424 offset, len);
Bing Zhao789221e2009-06-02 14:29:36 -0700425 ret = -EINVAL;
426 goto done;
427 }
428
429 txlen = len;
430
431 if (len & BIT(0)) {
432 count++;
433 if (count > MAX_WRITE_IOMEM_RETRY) {
434 BT_ERR("FW download failure @%d, "
435 "over max retry count", offset);
436 ret = -EIO;
437 goto done;
438 }
439 BT_ERR("FW CRC error indicated by the helper: "
440 "len = 0x%04X, txlen = %d", len, txlen);
441 len &= ~BIT(0);
442 /* Set txlen to 0 so as to resend from same offset */
443 txlen = 0;
444 } else {
445 count = 0;
446
447 /* Last block ? */
448 if (firmwarelen - offset < txlen)
449 txlen = firmwarelen - offset;
450
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700451 tx_blocks = (txlen + blksz_dl - 1) / blksz_dl;
Bing Zhao789221e2009-06-02 14:29:36 -0700452
453 memcpy(fwbuf, &firmware[offset], txlen);
454 }
455
456 ret = sdio_writesb(card->func, card->ioport, fwbuf,
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700457 tx_blocks * blksz_dl);
Bing Zhao789221e2009-06-02 14:29:36 -0700458
459 if (ret < 0) {
460 BT_ERR("FW download, writesb(%d) failed @%d",
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200461 count, offset);
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700462 sdio_writeb(card->func, HOST_CMD53_FIN,
463 card->reg->cfg, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700464 if (ret)
465 BT_ERR("writeb failed (CFG)");
466 }
467
468 offset += txlen;
469 } while (true);
470
471 BT_DBG("FW download over, size %d bytes", offset);
472
473 ret = 0;
474
475done:
476 kfree(tmpfwbuf);
477
478 if (fw_firmware)
479 release_firmware(fw_firmware);
480
Bing Zhao789221e2009-06-02 14:29:36 -0700481 return ret;
482}
483
484static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv)
485{
486 u16 buf_len = 0;
487 int ret, buf_block_len, blksz;
488 struct sk_buff *skb = NULL;
489 u32 type;
490 u8 *payload = NULL;
491 struct hci_dev *hdev = priv->btmrvl_dev.hcidev;
492 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
493
Bing Zhao789221e2009-06-02 14:29:36 -0700494 if (!card || !card->func) {
495 BT_ERR("card or function is NULL!");
496 ret = -EINVAL;
497 goto exit;
498 }
499
500 /* Read the length of data to be transferred */
501 ret = btmrvl_sdio_read_rx_len(card, &buf_len);
502 if (ret < 0) {
503 BT_ERR("read rx_len failed");
504 ret = -EIO;
505 goto exit;
506 }
507
508 blksz = SDIO_BLOCK_SIZE;
509 buf_block_len = (buf_len + blksz - 1) / blksz;
510
511 if (buf_len <= SDIO_HEADER_LEN
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200512 || (buf_block_len * blksz) > ALLOC_BUF_SIZE) {
Bing Zhao789221e2009-06-02 14:29:36 -0700513 BT_ERR("invalid packet length: %d", buf_len);
514 ret = -EINVAL;
515 goto exit;
516 }
517
518 /* Allocate buffer */
519 skb = bt_skb_alloc(buf_block_len * blksz + BTSDIO_DMA_ALIGN,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200520 GFP_ATOMIC);
Bing Zhao789221e2009-06-02 14:29:36 -0700521 if (skb == NULL) {
522 BT_ERR("No free skb");
523 goto exit;
524 }
525
Bing Zhao3318b232009-07-08 11:44:14 -0700526 if ((unsigned long) skb->data & (BTSDIO_DMA_ALIGN - 1)) {
527 skb_put(skb, (unsigned long) skb->data &
528 (BTSDIO_DMA_ALIGN - 1));
529 skb_pull(skb, (unsigned long) skb->data &
530 (BTSDIO_DMA_ALIGN - 1));
Bing Zhao789221e2009-06-02 14:29:36 -0700531 }
532
Bing Zhao3318b232009-07-08 11:44:14 -0700533 payload = skb->data;
Bing Zhao789221e2009-06-02 14:29:36 -0700534
535 ret = sdio_readsb(card->func, payload, card->ioport,
536 buf_block_len * blksz);
537 if (ret < 0) {
538 BT_ERR("readsb failed: %d", ret);
539 ret = -EIO;
540 goto exit;
541 }
542
543 /* This is SDIO specific header length: byte[2][1][0], type: byte[3]
544 * (HCI_COMMAND = 1, ACL_DATA = 2, SCO_DATA = 3, 0xFE = Vendor)
545 */
546
547 buf_len = payload[0];
548 buf_len |= (u16) payload[1] << 8;
549 type = payload[3];
550
551 switch (type) {
552 case HCI_ACLDATA_PKT:
553 case HCI_SCODATA_PKT:
554 case HCI_EVENT_PKT:
555 bt_cb(skb)->pkt_type = type;
556 skb->dev = (void *)hdev;
557 skb_put(skb, buf_len);
558 skb_pull(skb, SDIO_HEADER_LEN);
559
560 if (type == HCI_EVENT_PKT)
561 btmrvl_check_evtpkt(priv, skb);
562
563 hci_recv_frame(skb);
564 hdev->stat.byte_rx += buf_len;
565 break;
566
567 case MRVL_VENDOR_PKT:
568 bt_cb(skb)->pkt_type = HCI_VENDOR_PKT;
569 skb->dev = (void *)hdev;
570 skb_put(skb, buf_len);
571 skb_pull(skb, SDIO_HEADER_LEN);
572
573 if (btmrvl_process_event(priv, skb))
574 hci_recv_frame(skb);
575
576 hdev->stat.byte_rx += buf_len;
577 break;
578
579 default:
André Goddard Rosaaf901ca2009-11-14 13:09:05 -0200580 BT_ERR("Unknown packet type:%d", type);
Bing Zhao789221e2009-06-02 14:29:36 -0700581 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, payload,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200582 blksz * buf_block_len);
Bing Zhao789221e2009-06-02 14:29:36 -0700583
584 kfree_skb(skb);
585 skb = NULL;
586 break;
587 }
588
589exit:
590 if (ret) {
591 hdev->stat.err_rx++;
592 if (skb)
593 kfree_skb(skb);
594 }
595
Bing Zhao789221e2009-06-02 14:29:36 -0700596 return ret;
597}
598
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700599static int btmrvl_sdio_process_int_status(struct btmrvl_private *priv)
Bing Zhao789221e2009-06-02 14:29:36 -0700600{
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700601 ulong flags;
602 u8 ireg;
Bing Zhao789221e2009-06-02 14:29:36 -0700603 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
604
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700605 spin_lock_irqsave(&priv->driver_lock, flags);
606 ireg = sdio_ireg;
607 sdio_ireg = 0;
608 spin_unlock_irqrestore(&priv->driver_lock, flags);
Bing Zhao789221e2009-06-02 14:29:36 -0700609
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700610 sdio_claim_host(card->func);
611 if (ireg & DN_LD_HOST_INT_STATUS) {
Bing Zhao789221e2009-06-02 14:29:36 -0700612 if (priv->btmrvl_dev.tx_dnld_rdy)
613 BT_DBG("tx_done already received: "
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700614 " int_status=0x%x", ireg);
Bing Zhao789221e2009-06-02 14:29:36 -0700615 else
616 priv->btmrvl_dev.tx_dnld_rdy = true;
617 }
618
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700619 if (ireg & UP_LD_HOST_INT_STATUS)
Bing Zhao789221e2009-06-02 14:29:36 -0700620 btmrvl_sdio_card_to_host(priv);
621
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700622 sdio_release_host(card->func);
Bing Zhao789221e2009-06-02 14:29:36 -0700623
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700624 return 0;
Bing Zhao789221e2009-06-02 14:29:36 -0700625}
626
627static void btmrvl_sdio_interrupt(struct sdio_func *func)
628{
629 struct btmrvl_private *priv;
Bing Zhao789221e2009-06-02 14:29:36 -0700630 struct btmrvl_sdio_card *card;
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700631 ulong flags;
Bing Zhao789221e2009-06-02 14:29:36 -0700632 u8 ireg = 0;
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700633 int ret;
Bing Zhao789221e2009-06-02 14:29:36 -0700634
Bing Zhao789221e2009-06-02 14:29:36 -0700635 card = sdio_get_drvdata(func);
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700636 if (!card || !card->priv) {
637 BT_ERR("sbi_interrupt(%p) card or priv is "
638 "NULL, card=%p\n", func, card);
639 return;
Bing Zhao789221e2009-06-02 14:29:36 -0700640 }
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700641
642 priv = card->priv;
643
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700644 ireg = sdio_readb(card->func, card->reg->host_intstatus, &ret);
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700645 if (ret) {
646 BT_ERR("sdio_readb: read int status register failed");
647 return;
648 }
649
650 if (ireg != 0) {
651 /*
652 * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS
653 * Clear the interrupt status register and re-enable the
654 * interrupt.
655 */
656 BT_DBG("ireg = 0x%x", ireg);
657
658 sdio_writeb(card->func, ~(ireg) & (DN_LD_HOST_INT_STATUS |
659 UP_LD_HOST_INT_STATUS),
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700660 card->reg->host_intstatus, &ret);
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700661 if (ret) {
662 BT_ERR("sdio_writeb: clear int status register failed");
663 return;
664 }
665 }
666
667 spin_lock_irqsave(&priv->driver_lock, flags);
668 sdio_ireg |= ireg;
669 spin_unlock_irqrestore(&priv->driver_lock, flags);
670
671 btmrvl_interrupt(priv);
Bing Zhao789221e2009-06-02 14:29:36 -0700672}
673
674static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card)
675{
Bing Zhao789221e2009-06-02 14:29:36 -0700676 struct sdio_func *func;
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200677 u8 reg;
678 int ret = 0;
Bing Zhao789221e2009-06-02 14:29:36 -0700679
Bing Zhao789221e2009-06-02 14:29:36 -0700680 if (!card || !card->func) {
681 BT_ERR("Error: card or function is NULL!");
682 ret = -EINVAL;
683 goto failed;
684 }
685
686 func = card->func;
687
Bing Zhao789221e2009-06-02 14:29:36 -0700688 sdio_claim_host(func);
689
690 ret = sdio_enable_func(func);
691 if (ret) {
692 BT_ERR("sdio_enable_func() failed: ret=%d", ret);
693 ret = -EIO;
694 goto release_host;
695 }
696
697 ret = sdio_claim_irq(func, btmrvl_sdio_interrupt);
698 if (ret) {
699 BT_ERR("sdio_claim_irq failed: ret=%d", ret);
700 ret = -EIO;
701 goto disable_func;
702 }
703
704 ret = sdio_set_block_size(card->func, SDIO_BLOCK_SIZE);
705 if (ret) {
706 BT_ERR("cannot set SDIO block size");
707 ret = -EIO;
708 goto release_irq;
709 }
710
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700711 reg = sdio_readb(func, card->reg->io_port_0, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700712 if (ret < 0) {
713 ret = -EIO;
714 goto release_irq;
715 }
716
717 card->ioport = reg;
718
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700719 reg = sdio_readb(func, card->reg->io_port_1, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700720 if (ret < 0) {
721 ret = -EIO;
722 goto release_irq;
723 }
724
725 card->ioport |= (reg << 8);
726
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700727 reg = sdio_readb(func, card->reg->io_port_2, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700728 if (ret < 0) {
729 ret = -EIO;
730 goto release_irq;
731 }
732
733 card->ioport |= (reg << 16);
734
735 BT_DBG("SDIO FUNC%d IO port: 0x%x", func->num, card->ioport);
736
737 sdio_set_drvdata(func, card);
738
739 sdio_release_host(func);
740
Bing Zhao789221e2009-06-02 14:29:36 -0700741 return 0;
742
743release_irq:
744 sdio_release_irq(func);
745
746disable_func:
747 sdio_disable_func(func);
748
749release_host:
750 sdio_release_host(func);
751
752failed:
Bing Zhao789221e2009-06-02 14:29:36 -0700753 return ret;
754}
755
756static int btmrvl_sdio_unregister_dev(struct btmrvl_sdio_card *card)
757{
Bing Zhao789221e2009-06-02 14:29:36 -0700758 if (card && card->func) {
759 sdio_claim_host(card->func);
760 sdio_release_irq(card->func);
761 sdio_disable_func(card->func);
762 sdio_release_host(card->func);
763 sdio_set_drvdata(card->func, NULL);
764 }
765
Bing Zhao789221e2009-06-02 14:29:36 -0700766 return 0;
767}
768
769static int btmrvl_sdio_enable_host_int(struct btmrvl_sdio_card *card)
770{
771 int ret;
772
Marcel Holtmann93742532009-06-13 07:40:18 +0200773 if (!card || !card->func)
Bing Zhao789221e2009-06-02 14:29:36 -0700774 return -EINVAL;
Bing Zhao789221e2009-06-02 14:29:36 -0700775
776 sdio_claim_host(card->func);
777
778 ret = btmrvl_sdio_enable_host_int_mask(card, HIM_ENABLE);
779
780 btmrvl_sdio_get_rx_unit(card);
781
782 sdio_release_host(card->func);
783
Bing Zhao789221e2009-06-02 14:29:36 -0700784 return ret;
785}
786
787static int btmrvl_sdio_disable_host_int(struct btmrvl_sdio_card *card)
788{
789 int ret;
790
Marcel Holtmann93742532009-06-13 07:40:18 +0200791 if (!card || !card->func)
Bing Zhao789221e2009-06-02 14:29:36 -0700792 return -EINVAL;
Bing Zhao789221e2009-06-02 14:29:36 -0700793
794 sdio_claim_host(card->func);
795
796 ret = btmrvl_sdio_disable_host_int_mask(card, HIM_DISABLE);
797
798 sdio_release_host(card->func);
799
Bing Zhao789221e2009-06-02 14:29:36 -0700800 return ret;
801}
802
803static int btmrvl_sdio_host_to_card(struct btmrvl_private *priv,
804 u8 *payload, u16 nb)
805{
806 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
807 int ret = 0;
808 int buf_block_len;
809 int blksz;
810 int i = 0;
811 u8 *buf = NULL;
812 void *tmpbuf = NULL;
813 int tmpbufsz;
814
Bing Zhao789221e2009-06-02 14:29:36 -0700815 if (!card || !card->func) {
816 BT_ERR("card or function is NULL!");
Bing Zhao789221e2009-06-02 14:29:36 -0700817 return -EINVAL;
818 }
819
820 buf = payload;
Bing Zhao3318b232009-07-08 11:44:14 -0700821 if ((unsigned long) payload & (BTSDIO_DMA_ALIGN - 1)) {
Bing Zhao789221e2009-06-02 14:29:36 -0700822 tmpbufsz = ALIGN_SZ(nb, BTSDIO_DMA_ALIGN);
Julia Lawall59598092009-08-06 22:05:18 +0200823 tmpbuf = kzalloc(tmpbufsz, GFP_KERNEL);
824 if (!tmpbuf)
825 return -ENOMEM;
Bing Zhao789221e2009-06-02 14:29:36 -0700826 buf = (u8 *) ALIGN_ADDR(tmpbuf, BTSDIO_DMA_ALIGN);
827 memcpy(buf, payload, nb);
828 }
829
830 blksz = SDIO_BLOCK_SIZE;
831 buf_block_len = (nb + blksz - 1) / blksz;
832
833 sdio_claim_host(card->func);
834
835 do {
836 /* Transfer data to card */
837 ret = sdio_writesb(card->func, card->ioport, buf,
838 buf_block_len * blksz);
839 if (ret < 0) {
840 i++;
841 BT_ERR("i=%d writesb failed: %d", i, ret);
842 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
843 payload, nb);
844 ret = -EIO;
845 if (i > MAX_WRITE_IOMEM_RETRY)
846 goto exit;
847 }
848 } while (ret);
849
850 priv->btmrvl_dev.tx_dnld_rdy = false;
851
852exit:
853 sdio_release_host(card->func);
Yoichi Yuasa88d1a0c2010-02-04 09:55:51 +0900854 kfree(tmpbuf);
Bing Zhao789221e2009-06-02 14:29:36 -0700855
Bing Zhao789221e2009-06-02 14:29:36 -0700856 return ret;
857}
858
859static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card)
860{
861 int ret = 0;
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700862 u8 fws0;
863 int pollnum = MAX_POLL_TRIES;
Bing Zhao789221e2009-06-02 14:29:36 -0700864
Bing Zhao789221e2009-06-02 14:29:36 -0700865 if (!card || !card->func) {
866 BT_ERR("card or function is NULL!");
Bing Zhao789221e2009-06-02 14:29:36 -0700867 return -EINVAL;
868 }
869 sdio_claim_host(card->func);
870
871 if (!btmrvl_sdio_verify_fw_download(card, 1)) {
872 BT_DBG("Firmware already downloaded!");
873 goto done;
874 }
875
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700876 /* Check if other function driver is downloading the firmware */
877 fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700878 if (ret) {
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700879 BT_ERR("Failed to read FW downloading status!");
Bing Zhao789221e2009-06-02 14:29:36 -0700880 ret = -EIO;
881 goto done;
882 }
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700883 if (fws0) {
884 BT_DBG("BT not the winner (%#x). Skip FW downloading", fws0);
Bing Zhao789221e2009-06-02 14:29:36 -0700885
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700886 /* Give other function more time to download the firmware */
887 pollnum *= 10;
888 } else {
889 if (card->helper) {
890 ret = btmrvl_sdio_download_helper(card);
891 if (ret) {
892 BT_ERR("Failed to download helper!");
893 ret = -EIO;
894 goto done;
895 }
896 }
897
898 if (btmrvl_sdio_download_fw_w_helper(card)) {
899 BT_ERR("Failed to download firmware!");
900 ret = -EIO;
901 goto done;
902 }
Bing Zhao789221e2009-06-02 14:29:36 -0700903 }
904
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700905 if (btmrvl_sdio_verify_fw_download(card, pollnum)) {
Bing Zhao789221e2009-06-02 14:29:36 -0700906 BT_ERR("FW failed to be active in time!");
907 ret = -ETIMEDOUT;
908 goto done;
909 }
910
911done:
912 sdio_release_host(card->func);
913
Bing Zhao789221e2009-06-02 14:29:36 -0700914 return ret;
915}
916
917static int btmrvl_sdio_wakeup_fw(struct btmrvl_private *priv)
918{
919 struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
920 int ret = 0;
921
Bing Zhao789221e2009-06-02 14:29:36 -0700922 if (!card || !card->func) {
923 BT_ERR("card or function is NULL!");
Bing Zhao789221e2009-06-02 14:29:36 -0700924 return -EINVAL;
925 }
926
927 sdio_claim_host(card->func);
928
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700929 sdio_writeb(card->func, HOST_POWER_UP, card->reg->cfg, &ret);
Bing Zhao789221e2009-06-02 14:29:36 -0700930
931 sdio_release_host(card->func);
932
933 BT_DBG("wake up firmware");
934
Bing Zhao789221e2009-06-02 14:29:36 -0700935 return ret;
936}
937
938static int btmrvl_sdio_probe(struct sdio_func *func,
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200939 const struct sdio_device_id *id)
Bing Zhao789221e2009-06-02 14:29:36 -0700940{
941 int ret = 0;
942 struct btmrvl_private *priv = NULL;
943 struct btmrvl_sdio_card *card = NULL;
944
Bing Zhao789221e2009-06-02 14:29:36 -0700945 BT_INFO("vendor=0x%x, device=0x%x, class=%d, fn=%d",
946 id->vendor, id->device, id->class, func->num);
947
948 card = kzalloc(sizeof(*card), GFP_KERNEL);
949 if (!card) {
950 ret = -ENOMEM;
951 goto done;
952 }
953
954 card->func = func;
955
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200956 if (id->driver_data) {
957 struct btmrvl_sdio_device *data = (void *) id->driver_data;
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700958 card->helper = data->helper;
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200959 card->firmware = data->firmware;
Kevin Gan9f72c1d2011-04-08 18:19:33 -0700960 card->reg = data->reg;
961 card->sd_blksz_fw_dl = data->sd_blksz_fw_dl;
Marcel Holtmanndcf47f32009-06-09 16:21:58 +0200962 }
963
Bing Zhao789221e2009-06-02 14:29:36 -0700964 if (btmrvl_sdio_register_dev(card) < 0) {
965 BT_ERR("Failed to register BT device!");
966 ret = -ENODEV;
967 goto free_card;
968 }
969
970 /* Disable the interrupts on the card */
971 btmrvl_sdio_disable_host_int(card);
972
973 if (btmrvl_sdio_download_fw(card)) {
974 BT_ERR("Downloading firmware failed!");
975 ret = -ENODEV;
976 goto unreg_dev;
977 }
978
979 msleep(100);
980
981 btmrvl_sdio_enable_host_int(card);
982
983 priv = btmrvl_add_card(card);
984 if (!priv) {
985 BT_ERR("Initializing card failed!");
986 ret = -ENODEV;
987 goto disable_host_int;
988 }
989
990 card->priv = priv;
991
992 /* Initialize the interface specific function pointers */
993 priv->hw_host_to_card = btmrvl_sdio_host_to_card;
994 priv->hw_wakeup_firmware = btmrvl_sdio_wakeup_fw;
Amitkumar Karward1d10d72010-05-27 16:38:37 -0700995 priv->hw_process_int_status = btmrvl_sdio_process_int_status;
Bing Zhao789221e2009-06-02 14:29:36 -0700996
Bing Zhao64061602010-03-03 14:37:36 -0800997 if (btmrvl_register_hdev(priv)) {
998 BT_ERR("Register hdev failed!");
999 ret = -ENODEV;
1000 goto disable_host_int;
1001 }
1002
Amitkumar Karwar32fd6392009-09-30 11:18:30 -07001003 priv->btmrvl_dev.psmode = 1;
1004 btmrvl_enable_ps(priv);
Bing Zhao789221e2009-06-02 14:29:36 -07001005
Bing Zhao789221e2009-06-02 14:29:36 -07001006 return 0;
1007
1008disable_host_int:
1009 btmrvl_sdio_disable_host_int(card);
1010unreg_dev:
1011 btmrvl_sdio_unregister_dev(card);
1012free_card:
1013 kfree(card);
1014done:
Bing Zhao789221e2009-06-02 14:29:36 -07001015 return ret;
1016}
1017
1018static void btmrvl_sdio_remove(struct sdio_func *func)
1019{
1020 struct btmrvl_sdio_card *card;
1021
Bing Zhao789221e2009-06-02 14:29:36 -07001022 if (func) {
1023 card = sdio_get_drvdata(func);
1024 if (card) {
1025 /* Send SHUTDOWN command & disable interrupt
1026 * if user removes the module.
1027 */
1028 if (user_rmmod) {
1029 btmrvl_send_module_cfg_cmd(card->priv,
1030 MODULE_SHUTDOWN_REQ);
1031 btmrvl_sdio_disable_host_int(card);
1032 }
1033 BT_DBG("unregester dev");
1034 btmrvl_sdio_unregister_dev(card);
1035 btmrvl_remove_card(card->priv);
1036 kfree(card);
1037 }
1038 }
Bing Zhao789221e2009-06-02 14:29:36 -07001039}
1040
1041static struct sdio_driver bt_mrvl_sdio = {
1042 .name = "btmrvl_sdio",
1043 .id_table = btmrvl_sdio_ids,
1044 .probe = btmrvl_sdio_probe,
1045 .remove = btmrvl_sdio_remove,
1046};
1047
Peter Huewe8e5b2302009-12-22 09:34:20 +01001048static int __init btmrvl_sdio_init_module(void)
Bing Zhao789221e2009-06-02 14:29:36 -07001049{
Bing Zhao789221e2009-06-02 14:29:36 -07001050 if (sdio_register_driver(&bt_mrvl_sdio) != 0) {
1051 BT_ERR("SDIO Driver Registration Failed");
Bing Zhao789221e2009-06-02 14:29:36 -07001052 return -ENODEV;
1053 }
1054
1055 /* Clear the flag in case user removes the card. */
1056 user_rmmod = 0;
1057
Bing Zhao789221e2009-06-02 14:29:36 -07001058 return 0;
1059}
1060
Peter Huewe8e5b2302009-12-22 09:34:20 +01001061static void __exit btmrvl_sdio_exit_module(void)
Bing Zhao789221e2009-06-02 14:29:36 -07001062{
Bing Zhao789221e2009-06-02 14:29:36 -07001063 /* Set the flag as user is removing this module. */
1064 user_rmmod = 1;
1065
1066 sdio_unregister_driver(&bt_mrvl_sdio);
Bing Zhao789221e2009-06-02 14:29:36 -07001067}
1068
1069module_init(btmrvl_sdio_init_module);
1070module_exit(btmrvl_sdio_exit_module);
1071
1072MODULE_AUTHOR("Marvell International Ltd.");
Marcel Holtmann9666fb32009-06-09 21:45:04 +02001073MODULE_DESCRIPTION("Marvell BT-over-SDIO driver ver " VERSION);
Bing Zhao789221e2009-06-02 14:29:36 -07001074MODULE_VERSION(VERSION);
1075MODULE_LICENSE("GPL v2");
Ben Hutchings28614532009-11-07 21:41:18 +00001076MODULE_FIRMWARE("sd8688_helper.bin");
1077MODULE_FIRMWARE("sd8688.bin");
Kevin Gan9f72c1d2011-04-08 18:19:33 -07001078MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin");