2 * Marvell BT-over-SDIO driver: SDIO interface related functions.
4 * Copyright (C) 2009, Marvell International Ltd.
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.
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.
21 #include <linux/firmware.h>
22 #include <linux/slab.h>
24 #include <linux/mmc/sdio_ids.h>
25 #include <linux/mmc/sdio_func.h>
27 #include <net/bluetooth/bluetooth.h>
28 #include <net/bluetooth/hci_core.h>
30 #include "btmrvl_drv.h"
31 #include "btmrvl_sdio.h"
35 /* The btmrvl_sdio_remove() callback function is called
36 * when user removes this module from kernel space or ejects
37 * the card from the slot. The driver handles these 2 cases
39 * If the user is removing the module, a MODULE_SHUTDOWN_REQ
40 * command is sent to firmware and interrupt will be disabled.
41 * If the card is removed, there is no need to send command
42 * or disable interrupt.
44 * The variable 'user_rmmod' is used to distinguish these two
45 * scenarios. This flag is initialized as FALSE in case the card
46 * is removed, and will be set to TRUE for module removal when
47 * module_exit function is called.
52 static const struct btmrvl_sdio_card_reg btmrvl_reg_8688
= {
54 .host_int_mask
= 0x04,
55 .host_intstatus
= 0x05,
57 .sq_read_base_addr_a0
= 0x10,
58 .sq_read_base_addr_a1
= 0x11,
59 .card_fw_status0
= 0x40,
60 .card_fw_status1
= 0x41,
67 static const struct btmrvl_sdio_card_reg btmrvl_reg_8787
= {
69 .host_int_mask
= 0x02,
70 .host_intstatus
= 0x03,
72 .sq_read_base_addr_a0
= 0x40,
73 .sq_read_base_addr_a1
= 0x41,
74 .card_revision
= 0x5c,
75 .card_fw_status0
= 0x60,
76 .card_fw_status1
= 0x61,
84 static const struct btmrvl_sdio_device btmrvl_sdio_sd8688
= {
85 .helper
= "sd8688_helper.bin",
86 .firmware
= "sd8688.bin",
87 .reg
= &btmrvl_reg_8688
,
91 static const struct btmrvl_sdio_device btmrvl_sdio_sd8787
= {
93 .firmware
= "mrvl/sd8787_uapsta.bin",
94 .reg
= &btmrvl_reg_8787
,
95 .sd_blksz_fw_dl
= 256,
98 static const struct sdio_device_id btmrvl_sdio_ids
[] = {
99 /* Marvell SD8688 Bluetooth device */
100 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, 0x9105),
101 .driver_data
= (unsigned long) &btmrvl_sdio_sd8688
},
102 /* Marvell SD8787 Bluetooth device */
103 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, 0x911A),
104 .driver_data
= (unsigned long) &btmrvl_sdio_sd8787
},
106 { } /* Terminating entry */
109 MODULE_DEVICE_TABLE(sdio
, btmrvl_sdio_ids
);
111 static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_card
*card
)
116 reg
= sdio_readb(card
->func
, card
->reg
->card_rx_unit
, &ret
);
123 static int btmrvl_sdio_read_fw_status(struct btmrvl_sdio_card
*card
, u16
*dat
)
130 fws0
= sdio_readb(card
->func
, card
->reg
->card_fw_status0
, &ret
);
134 fws1
= sdio_readb(card
->func
, card
->reg
->card_fw_status1
, &ret
);
138 *dat
= (((u16
) fws1
) << 8) | fws0
;
143 static int btmrvl_sdio_read_rx_len(struct btmrvl_sdio_card
*card
, u16
*dat
)
148 reg
= sdio_readb(card
->func
, card
->reg
->card_rx_len
, &ret
);
150 *dat
= (u16
) reg
<< card
->rx_unit
;
155 static int btmrvl_sdio_enable_host_int_mask(struct btmrvl_sdio_card
*card
,
160 sdio_writeb(card
->func
, mask
, card
->reg
->host_int_mask
, &ret
);
162 BT_ERR("Unable to enable the host interrupt!");
169 static int btmrvl_sdio_disable_host_int_mask(struct btmrvl_sdio_card
*card
,
175 host_int_mask
= sdio_readb(card
->func
, card
->reg
->host_int_mask
, &ret
);
179 host_int_mask
&= ~mask
;
181 sdio_writeb(card
->func
, host_int_mask
, card
->reg
->host_int_mask
, &ret
);
183 BT_ERR("Unable to disable the host interrupt!");
190 static int btmrvl_sdio_poll_card_status(struct btmrvl_sdio_card
*card
, u8 bits
)
196 for (tries
= 0; tries
< MAX_POLL_TRIES
* 1000; tries
++) {
197 status
= sdio_readb(card
->func
, card
->reg
->card_status
, &ret
);
200 if ((status
& bits
) == bits
)
209 BT_ERR("FAILED! ret=%d", ret
);
214 static int btmrvl_sdio_verify_fw_download(struct btmrvl_sdio_card
*card
,
217 int ret
= -ETIMEDOUT
;
221 /* Wait for firmware to become ready */
222 for (tries
= 0; tries
< pollnum
; tries
++) {
223 if (btmrvl_sdio_read_fw_status(card
, &firmwarestat
) < 0)
226 if (firmwarestat
== FIRMWARE_READY
) {
237 static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card
*card
)
239 const struct firmware
*fw_helper
= NULL
;
240 const u8
*helper
= NULL
;
242 void *tmphlprbuf
= NULL
;
243 int tmphlprbufsz
, hlprblknow
, helperlen
;
247 ret
= request_firmware(&fw_helper
, card
->helper
,
249 if ((ret
< 0) || !fw_helper
) {
250 BT_ERR("request_firmware(helper) failed, error code = %d",
256 helper
= fw_helper
->data
;
257 helperlen
= fw_helper
->size
;
259 BT_DBG("Downloading helper image (%d bytes), block size %d bytes",
260 helperlen
, SDIO_BLOCK_SIZE
);
262 tmphlprbufsz
= ALIGN_SZ(BTM_UPLD_SIZE
, BTSDIO_DMA_ALIGN
);
264 tmphlprbuf
= kzalloc(tmphlprbufsz
, GFP_KERNEL
);
266 BT_ERR("Unable to allocate buffer for helper."
267 " Terminating download");
272 helperbuf
= (u8
*) ALIGN_ADDR(tmphlprbuf
, BTSDIO_DMA_ALIGN
);
274 /* Perform helper data transfer */
275 tx_len
= (FIRMWARE_TRANSFER_NBLOCK
* SDIO_BLOCK_SIZE
)
280 ret
= btmrvl_sdio_poll_card_status(card
,
281 CARD_IO_READY
| DN_LD_CARD_RDY
);
283 BT_ERR("Helper download poll status timeout @ %d",
288 /* Check if there is more data? */
289 if (hlprblknow
>= helperlen
)
292 if (helperlen
- hlprblknow
< tx_len
)
293 tx_len
= helperlen
- hlprblknow
;
296 helperbuf
[0] = ((tx_len
& 0x000000ff) >> 0);
297 helperbuf
[1] = ((tx_len
& 0x0000ff00) >> 8);
298 helperbuf
[2] = ((tx_len
& 0x00ff0000) >> 16);
299 helperbuf
[3] = ((tx_len
& 0xff000000) >> 24);
301 memcpy(&helperbuf
[SDIO_HEADER_LEN
], &helper
[hlprblknow
],
304 /* Now send the data */
305 ret
= sdio_writesb(card
->func
, card
->ioport
, helperbuf
,
306 FIRMWARE_TRANSFER_NBLOCK
* SDIO_BLOCK_SIZE
);
308 BT_ERR("IO error during helper download @ %d",
313 hlprblknow
+= tx_len
;
316 BT_DBG("Transferring helper image EOF block");
318 memset(helperbuf
, 0x0, SDIO_BLOCK_SIZE
);
320 ret
= sdio_writesb(card
->func
, card
->ioport
, helperbuf
,
323 BT_ERR("IO error in writing helper image EOF block");
332 release_firmware(fw_helper
);
337 static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card
*card
)
339 const struct firmware
*fw_firmware
= NULL
;
340 const u8
*firmware
= NULL
;
341 int firmwarelen
, tmpfwbufsz
, ret
;
342 unsigned int tries
, offset
;
344 void *tmpfwbuf
= NULL
;
346 u16 len
, blksz_dl
= card
->sd_blksz_fw_dl
;
347 int txlen
= 0, tx_blocks
= 0, count
= 0;
349 ret
= request_firmware(&fw_firmware
, card
->firmware
,
351 if ((ret
< 0) || !fw_firmware
) {
352 BT_ERR("request_firmware(firmware) failed, error code = %d",
358 firmware
= fw_firmware
->data
;
359 firmwarelen
= fw_firmware
->size
;
361 BT_DBG("Downloading FW image (%d bytes)", firmwarelen
);
363 tmpfwbufsz
= ALIGN_SZ(BTM_UPLD_SIZE
, BTSDIO_DMA_ALIGN
);
364 tmpfwbuf
= kzalloc(tmpfwbufsz
, GFP_KERNEL
);
366 BT_ERR("Unable to allocate buffer for firmware."
367 " Terminating download");
372 /* Ensure aligned firmware buffer */
373 fwbuf
= (u8
*) ALIGN_ADDR(tmpfwbuf
, BTSDIO_DMA_ALIGN
);
375 /* Perform firmware data transfer */
378 ret
= btmrvl_sdio_poll_card_status(card
,
379 CARD_IO_READY
| DN_LD_CARD_RDY
);
381 BT_ERR("FW download with helper poll status"
382 " timeout @ %d", offset
);
386 /* Check if there is more data ? */
387 if (offset
>= firmwarelen
)
390 for (tries
= 0; tries
< MAX_POLL_TRIES
; tries
++) {
391 base0
= sdio_readb(card
->func
,
392 card
->reg
->sq_read_base_addr_a0
, &ret
);
394 BT_ERR("BASE0 register read failed:"
395 " base0 = 0x%04X(%d)."
396 " Terminating download",
401 base1
= sdio_readb(card
->func
,
402 card
->reg
->sq_read_base_addr_a1
, &ret
);
404 BT_ERR("BASE1 register read failed:"
405 " base1 = 0x%04X(%d)."
406 " Terminating download",
412 len
= (((u16
) base1
) << 8) | base0
;
421 else if (len
> BTM_UPLD_SIZE
) {
422 BT_ERR("FW download failure @%d, invalid length %d",
432 if (count
> MAX_WRITE_IOMEM_RETRY
) {
433 BT_ERR("FW download failure @%d, "
434 "over max retry count", offset
);
438 BT_ERR("FW CRC error indicated by the helper: "
439 "len = 0x%04X, txlen = %d", len
, txlen
);
441 /* Set txlen to 0 so as to resend from same offset */
447 if (firmwarelen
- offset
< txlen
)
448 txlen
= firmwarelen
- offset
;
450 tx_blocks
= (txlen
+ blksz_dl
- 1) / blksz_dl
;
452 memcpy(fwbuf
, &firmware
[offset
], txlen
);
455 ret
= sdio_writesb(card
->func
, card
->ioport
, fwbuf
,
456 tx_blocks
* blksz_dl
);
459 BT_ERR("FW download, writesb(%d) failed @%d",
461 sdio_writeb(card
->func
, HOST_CMD53_FIN
,
462 card
->reg
->cfg
, &ret
);
464 BT_ERR("writeb failed (CFG)");
470 BT_DBG("FW download over, size %d bytes", offset
);
478 release_firmware(fw_firmware
);
483 static int btmrvl_sdio_card_to_host(struct btmrvl_private
*priv
)
486 int ret
, buf_block_len
, blksz
;
487 struct sk_buff
*skb
= NULL
;
490 struct hci_dev
*hdev
= priv
->btmrvl_dev
.hcidev
;
491 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
493 if (!card
|| !card
->func
) {
494 BT_ERR("card or function is NULL!");
499 /* Read the length of data to be transferred */
500 ret
= btmrvl_sdio_read_rx_len(card
, &buf_len
);
502 BT_ERR("read rx_len failed");
507 blksz
= SDIO_BLOCK_SIZE
;
508 buf_block_len
= (buf_len
+ blksz
- 1) / blksz
;
510 if (buf_len
<= SDIO_HEADER_LEN
511 || (buf_block_len
* blksz
) > ALLOC_BUF_SIZE
) {
512 BT_ERR("invalid packet length: %d", buf_len
);
517 /* Allocate buffer */
518 skb
= bt_skb_alloc(buf_block_len
* blksz
+ BTSDIO_DMA_ALIGN
,
521 BT_ERR("No free skb");
525 if ((unsigned long) skb
->data
& (BTSDIO_DMA_ALIGN
- 1)) {
526 skb_put(skb
, (unsigned long) skb
->data
&
527 (BTSDIO_DMA_ALIGN
- 1));
528 skb_pull(skb
, (unsigned long) skb
->data
&
529 (BTSDIO_DMA_ALIGN
- 1));
534 ret
= sdio_readsb(card
->func
, payload
, card
->ioport
,
535 buf_block_len
* blksz
);
537 BT_ERR("readsb failed: %d", ret
);
542 /* This is SDIO specific header length: byte[2][1][0], type: byte[3]
543 * (HCI_COMMAND = 1, ACL_DATA = 2, SCO_DATA = 3, 0xFE = Vendor)
546 buf_len
= payload
[0];
547 buf_len
|= (u16
) payload
[1] << 8;
551 case HCI_ACLDATA_PKT
:
552 case HCI_SCODATA_PKT
:
554 bt_cb(skb
)->pkt_type
= type
;
555 skb
->dev
= (void *)hdev
;
556 skb_put(skb
, buf_len
);
557 skb_pull(skb
, SDIO_HEADER_LEN
);
559 if (type
== HCI_EVENT_PKT
)
560 btmrvl_check_evtpkt(priv
, skb
);
563 hdev
->stat
.byte_rx
+= buf_len
;
566 case MRVL_VENDOR_PKT
:
567 bt_cb(skb
)->pkt_type
= HCI_VENDOR_PKT
;
568 skb
->dev
= (void *)hdev
;
569 skb_put(skb
, buf_len
);
570 skb_pull(skb
, SDIO_HEADER_LEN
);
572 if (btmrvl_process_event(priv
, skb
))
575 hdev
->stat
.byte_rx
+= buf_len
;
579 BT_ERR("Unknown packet type:%d", type
);
580 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET
, payload
,
581 blksz
* buf_block_len
);
598 static int btmrvl_sdio_process_int_status(struct btmrvl_private
*priv
)
602 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
604 spin_lock_irqsave(&priv
->driver_lock
, flags
);
607 spin_unlock_irqrestore(&priv
->driver_lock
, flags
);
609 sdio_claim_host(card
->func
);
610 if (ireg
& DN_LD_HOST_INT_STATUS
) {
611 if (priv
->btmrvl_dev
.tx_dnld_rdy
)
612 BT_DBG("tx_done already received: "
613 " int_status=0x%x", ireg
);
615 priv
->btmrvl_dev
.tx_dnld_rdy
= true;
618 if (ireg
& UP_LD_HOST_INT_STATUS
)
619 btmrvl_sdio_card_to_host(priv
);
621 sdio_release_host(card
->func
);
626 static void btmrvl_sdio_interrupt(struct sdio_func
*func
)
628 struct btmrvl_private
*priv
;
629 struct btmrvl_sdio_card
*card
;
634 card
= sdio_get_drvdata(func
);
635 if (!card
|| !card
->priv
) {
636 BT_ERR("sbi_interrupt(%p) card or priv is "
637 "NULL, card=%p\n", func
, card
);
643 ireg
= sdio_readb(card
->func
, card
->reg
->host_intstatus
, &ret
);
645 BT_ERR("sdio_readb: read int status register failed");
651 * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS
652 * Clear the interrupt status register and re-enable the
655 BT_DBG("ireg = 0x%x", ireg
);
657 sdio_writeb(card
->func
, ~(ireg
) & (DN_LD_HOST_INT_STATUS
|
658 UP_LD_HOST_INT_STATUS
),
659 card
->reg
->host_intstatus
, &ret
);
661 BT_ERR("sdio_writeb: clear int status register failed");
666 spin_lock_irqsave(&priv
->driver_lock
, flags
);
668 spin_unlock_irqrestore(&priv
->driver_lock
, flags
);
670 btmrvl_interrupt(priv
);
673 static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card
*card
)
675 struct sdio_func
*func
;
679 if (!card
|| !card
->func
) {
680 BT_ERR("Error: card or function is NULL!");
687 sdio_claim_host(func
);
689 ret
= sdio_enable_func(func
);
691 BT_ERR("sdio_enable_func() failed: ret=%d", ret
);
696 ret
= sdio_claim_irq(func
, btmrvl_sdio_interrupt
);
698 BT_ERR("sdio_claim_irq failed: ret=%d", ret
);
703 ret
= sdio_set_block_size(card
->func
, SDIO_BLOCK_SIZE
);
705 BT_ERR("cannot set SDIO block size");
710 reg
= sdio_readb(func
, card
->reg
->io_port_0
, &ret
);
718 reg
= sdio_readb(func
, card
->reg
->io_port_1
, &ret
);
724 card
->ioport
|= (reg
<< 8);
726 reg
= sdio_readb(func
, card
->reg
->io_port_2
, &ret
);
732 card
->ioport
|= (reg
<< 16);
734 BT_DBG("SDIO FUNC%d IO port: 0x%x", func
->num
, card
->ioport
);
736 sdio_set_drvdata(func
, card
);
738 sdio_release_host(func
);
743 sdio_release_irq(func
);
746 sdio_disable_func(func
);
749 sdio_release_host(func
);
755 static int btmrvl_sdio_unregister_dev(struct btmrvl_sdio_card
*card
)
757 if (card
&& card
->func
) {
758 sdio_claim_host(card
->func
);
759 sdio_release_irq(card
->func
);
760 sdio_disable_func(card
->func
);
761 sdio_release_host(card
->func
);
762 sdio_set_drvdata(card
->func
, NULL
);
768 static int btmrvl_sdio_enable_host_int(struct btmrvl_sdio_card
*card
)
772 if (!card
|| !card
->func
)
775 sdio_claim_host(card
->func
);
777 ret
= btmrvl_sdio_enable_host_int_mask(card
, HIM_ENABLE
);
779 btmrvl_sdio_get_rx_unit(card
);
781 sdio_release_host(card
->func
);
786 static int btmrvl_sdio_disable_host_int(struct btmrvl_sdio_card
*card
)
790 if (!card
|| !card
->func
)
793 sdio_claim_host(card
->func
);
795 ret
= btmrvl_sdio_disable_host_int_mask(card
, HIM_DISABLE
);
797 sdio_release_host(card
->func
);
802 static int btmrvl_sdio_host_to_card(struct btmrvl_private
*priv
,
805 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
814 if (!card
|| !card
->func
) {
815 BT_ERR("card or function is NULL!");
820 if ((unsigned long) payload
& (BTSDIO_DMA_ALIGN
- 1)) {
821 tmpbufsz
= ALIGN_SZ(nb
, BTSDIO_DMA_ALIGN
);
822 tmpbuf
= kzalloc(tmpbufsz
, GFP_KERNEL
);
825 buf
= (u8
*) ALIGN_ADDR(tmpbuf
, BTSDIO_DMA_ALIGN
);
826 memcpy(buf
, payload
, nb
);
829 blksz
= SDIO_BLOCK_SIZE
;
830 buf_block_len
= (nb
+ blksz
- 1) / blksz
;
832 sdio_claim_host(card
->func
);
835 /* Transfer data to card */
836 ret
= sdio_writesb(card
->func
, card
->ioport
, buf
,
837 buf_block_len
* blksz
);
840 BT_ERR("i=%d writesb failed: %d", i
, ret
);
841 print_hex_dump_bytes("", DUMP_PREFIX_OFFSET
,
844 if (i
> MAX_WRITE_IOMEM_RETRY
)
849 priv
->btmrvl_dev
.tx_dnld_rdy
= false;
852 sdio_release_host(card
->func
);
858 static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card
*card
)
862 int pollnum
= MAX_POLL_TRIES
;
864 if (!card
|| !card
->func
) {
865 BT_ERR("card or function is NULL!");
868 sdio_claim_host(card
->func
);
870 if (!btmrvl_sdio_verify_fw_download(card
, 1)) {
871 BT_DBG("Firmware already downloaded!");
875 /* Check if other function driver is downloading the firmware */
876 fws0
= sdio_readb(card
->func
, card
->reg
->card_fw_status0
, &ret
);
878 BT_ERR("Failed to read FW downloading status!");
883 BT_DBG("BT not the winner (%#x). Skip FW downloading", fws0
);
885 /* Give other function more time to download the firmware */
889 ret
= btmrvl_sdio_download_helper(card
);
891 BT_ERR("Failed to download helper!");
897 if (btmrvl_sdio_download_fw_w_helper(card
)) {
898 BT_ERR("Failed to download firmware!");
904 if (btmrvl_sdio_verify_fw_download(card
, pollnum
)) {
905 BT_ERR("FW failed to be active in time!");
911 sdio_release_host(card
->func
);
916 static int btmrvl_sdio_wakeup_fw(struct btmrvl_private
*priv
)
918 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
921 if (!card
|| !card
->func
) {
922 BT_ERR("card or function is NULL!");
926 sdio_claim_host(card
->func
);
928 sdio_writeb(card
->func
, HOST_POWER_UP
, card
->reg
->cfg
, &ret
);
930 sdio_release_host(card
->func
);
932 BT_DBG("wake up firmware");
937 static int btmrvl_sdio_probe(struct sdio_func
*func
,
938 const struct sdio_device_id
*id
)
941 struct btmrvl_private
*priv
= NULL
;
942 struct btmrvl_sdio_card
*card
= NULL
;
944 BT_INFO("vendor=0x%x, device=0x%x, class=%d, fn=%d",
945 id
->vendor
, id
->device
, id
->class, func
->num
);
947 card
= kzalloc(sizeof(*card
), GFP_KERNEL
);
955 if (id
->driver_data
) {
956 struct btmrvl_sdio_device
*data
= (void *) id
->driver_data
;
957 card
->helper
= data
->helper
;
958 card
->firmware
= data
->firmware
;
959 card
->reg
= data
->reg
;
960 card
->sd_blksz_fw_dl
= data
->sd_blksz_fw_dl
;
963 if (btmrvl_sdio_register_dev(card
) < 0) {
964 BT_ERR("Failed to register BT device!");
969 /* Disable the interrupts on the card */
970 btmrvl_sdio_disable_host_int(card
);
972 if (btmrvl_sdio_download_fw(card
)) {
973 BT_ERR("Downloading firmware failed!");
980 btmrvl_sdio_enable_host_int(card
);
982 priv
= btmrvl_add_card(card
);
984 BT_ERR("Initializing card failed!");
986 goto disable_host_int
;
991 /* Initialize the interface specific function pointers */
992 priv
->hw_host_to_card
= btmrvl_sdio_host_to_card
;
993 priv
->hw_wakeup_firmware
= btmrvl_sdio_wakeup_fw
;
994 priv
->hw_process_int_status
= btmrvl_sdio_process_int_status
;
996 if (btmrvl_register_hdev(priv
)) {
997 BT_ERR("Register hdev failed!");
999 goto disable_host_int
;
1002 priv
->btmrvl_dev
.psmode
= 1;
1003 btmrvl_enable_ps(priv
);
1008 btmrvl_sdio_disable_host_int(card
);
1010 btmrvl_sdio_unregister_dev(card
);
1017 static void btmrvl_sdio_remove(struct sdio_func
*func
)
1019 struct btmrvl_sdio_card
*card
;
1022 card
= sdio_get_drvdata(func
);
1024 /* Send SHUTDOWN command & disable interrupt
1025 * if user removes the module.
1028 btmrvl_send_module_cfg_cmd(card
->priv
,
1029 MODULE_SHUTDOWN_REQ
);
1030 btmrvl_sdio_disable_host_int(card
);
1032 BT_DBG("unregester dev");
1033 btmrvl_sdio_unregister_dev(card
);
1034 btmrvl_remove_card(card
->priv
);
1040 static struct sdio_driver bt_mrvl_sdio
= {
1041 .name
= "btmrvl_sdio",
1042 .id_table
= btmrvl_sdio_ids
,
1043 .probe
= btmrvl_sdio_probe
,
1044 .remove
= btmrvl_sdio_remove
,
1047 static int __init
btmrvl_sdio_init_module(void)
1049 if (sdio_register_driver(&bt_mrvl_sdio
) != 0) {
1050 BT_ERR("SDIO Driver Registration Failed");
1054 /* Clear the flag in case user removes the card. */
1060 static void __exit
btmrvl_sdio_exit_module(void)
1062 /* Set the flag as user is removing this module. */
1065 sdio_unregister_driver(&bt_mrvl_sdio
);
1068 module_init(btmrvl_sdio_init_module
);
1069 module_exit(btmrvl_sdio_exit_module
);
1071 MODULE_AUTHOR("Marvell International Ltd.");
1072 MODULE_DESCRIPTION("Marvell BT-over-SDIO driver ver " VERSION
);
1073 MODULE_VERSION(VERSION
);
1074 MODULE_LICENSE("GPL v2");
1075 MODULE_FIRMWARE("sd8688_helper.bin");
1076 MODULE_FIRMWARE("sd8688.bin");
1077 MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin");