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>
23 #include <linux/suspend.h>
25 #include <linux/mmc/sdio_ids.h>
26 #include <linux/mmc/sdio_func.h>
27 #include <linux/module.h>
28 #include <linux/devcoredump.h>
30 #include <net/bluetooth/bluetooth.h>
31 #include <net/bluetooth/hci_core.h>
33 #include "btmrvl_drv.h"
34 #include "btmrvl_sdio.h"
38 static struct memory_type_mapping mem_type_mapping_tbl
[] = {
39 {"ITCM", NULL
, 0, 0xF0},
40 {"DTCM", NULL
, 0, 0xF1},
41 {"SQRAM", NULL
, 0, 0xF2},
42 {"APU", NULL
, 0, 0xF3},
43 {"CIU", NULL
, 0, 0xF4},
44 {"ICU", NULL
, 0, 0xF5},
45 {"MAC", NULL
, 0, 0xF6},
46 {"EXT7", NULL
, 0, 0xF7},
47 {"EXT8", NULL
, 0, 0xF8},
48 {"EXT9", NULL
, 0, 0xF9},
49 {"EXT10", NULL
, 0, 0xFA},
50 {"EXT11", NULL
, 0, 0xFB},
51 {"EXT12", NULL
, 0, 0xFC},
52 {"EXT13", NULL
, 0, 0xFD},
53 {"EXTLAST", NULL
, 0, 0xFE},
56 static const struct of_device_id btmrvl_sdio_of_match_table
[] = {
57 { .compatible
= "marvell,sd8897-bt" },
58 { .compatible
= "marvell,sd8997-bt" },
62 static irqreturn_t
btmrvl_wake_irq_bt(int irq
, void *priv
)
64 struct btmrvl_sdio_card
*card
= priv
;
65 struct btmrvl_plt_wake_cfg
*cfg
= card
->plt_wake_cfg
;
67 pr_info("%s: wake by bt\n", __func__
);
68 cfg
->wake_by_bt
= true;
69 disable_irq_nosync(irq
);
71 pm_wakeup_event(&card
->func
->dev
, 0);
77 /* This function parses device tree node using mmc subnode devicetree API.
78 * The device node is saved in card->plt_of_node.
79 * If the device tree node exists and includes interrupts attributes, this
80 * function will request platform specific wakeup interrupt.
82 static int btmrvl_sdio_probe_of(struct device
*dev
,
83 struct btmrvl_sdio_card
*card
)
85 struct btmrvl_plt_wake_cfg
*cfg
;
89 !of_match_node(btmrvl_sdio_of_match_table
, dev
->of_node
)) {
90 pr_err("sdio platform data not available\n");
94 card
->plt_of_node
= dev
->of_node
;
96 card
->plt_wake_cfg
= devm_kzalloc(dev
, sizeof(*card
->plt_wake_cfg
),
98 cfg
= card
->plt_wake_cfg
;
99 if (cfg
&& card
->plt_of_node
) {
100 cfg
->irq_bt
= irq_of_parse_and_map(card
->plt_of_node
, 0);
102 dev_err(dev
, "fail to parse irq_bt from device tree\n");
105 ret
= devm_request_irq(dev
, cfg
->irq_bt
,
110 "Failed to request irq_bt %d (%d)\n",
113 disable_irq(cfg
->irq_bt
);
120 /* The btmrvl_sdio_remove() callback function is called
121 * when user removes this module from kernel space or ejects
122 * the card from the slot. The driver handles these 2 cases
124 * If the user is removing the module, a MODULE_SHUTDOWN_REQ
125 * command is sent to firmware and interrupt will be disabled.
126 * If the card is removed, there is no need to send command
127 * or disable interrupt.
129 * The variable 'user_rmmod' is used to distinguish these two
130 * scenarios. This flag is initialized as FALSE in case the card
131 * is removed, and will be set to TRUE for module removal when
132 * module_exit function is called.
134 static u8 user_rmmod
;
137 static const struct btmrvl_sdio_card_reg btmrvl_reg_8688
= {
139 .host_int_mask
= 0x04,
140 .host_intstatus
= 0x05,
142 .sq_read_base_addr_a0
= 0x10,
143 .sq_read_base_addr_a1
= 0x11,
144 .card_fw_status0
= 0x40,
145 .card_fw_status1
= 0x41,
147 .card_rx_unit
= 0x43,
151 .int_read_to_clear
= false,
153 static const struct btmrvl_sdio_card_reg btmrvl_reg_87xx
= {
155 .host_int_mask
= 0x02,
156 .host_intstatus
= 0x03,
158 .sq_read_base_addr_a0
= 0x40,
159 .sq_read_base_addr_a1
= 0x41,
160 .card_revision
= 0x5c,
161 .card_fw_status0
= 0x60,
162 .card_fw_status1
= 0x61,
164 .card_rx_unit
= 0x63,
168 .int_read_to_clear
= false,
171 static const struct btmrvl_sdio_card_reg btmrvl_reg_8887
= {
173 .host_int_mask
= 0x08,
174 .host_intstatus
= 0x0C,
176 .sq_read_base_addr_a0
= 0x6C,
177 .sq_read_base_addr_a1
= 0x6D,
178 .card_revision
= 0xC8,
179 .card_fw_status0
= 0x88,
180 .card_fw_status1
= 0x89,
182 .card_rx_unit
= 0x8B,
186 .int_read_to_clear
= true,
187 .host_int_rsr
= 0x04,
188 .card_misc_cfg
= 0xD8,
191 static const struct btmrvl_sdio_card_reg btmrvl_reg_8897
= {
193 .host_int_mask
= 0x02,
194 .host_intstatus
= 0x03,
196 .sq_read_base_addr_a0
= 0x60,
197 .sq_read_base_addr_a1
= 0x61,
198 .card_revision
= 0xbc,
199 .card_fw_status0
= 0xc0,
200 .card_fw_status1
= 0xc1,
202 .card_rx_unit
= 0xc3,
206 .int_read_to_clear
= true,
207 .host_int_rsr
= 0x01,
208 .card_misc_cfg
= 0xcc,
209 .fw_dump_ctrl
= 0xe2,
210 .fw_dump_start
= 0xe3,
214 static const struct btmrvl_sdio_card_reg btmrvl_reg_8997
= {
216 .host_int_mask
= 0x08,
217 .host_intstatus
= 0x0c,
219 .sq_read_base_addr_a0
= 0xf8,
220 .sq_read_base_addr_a1
= 0xf9,
221 .card_revision
= 0xc8,
222 .card_fw_status0
= 0xe8,
223 .card_fw_status1
= 0xe9,
225 .card_rx_unit
= 0xeb,
229 .int_read_to_clear
= true,
230 .host_int_rsr
= 0x04,
231 .card_misc_cfg
= 0xD8,
232 .fw_dump_ctrl
= 0xf0,
233 .fw_dump_start
= 0xf1,
237 static const struct btmrvl_sdio_device btmrvl_sdio_sd8688
= {
238 .helper
= "mrvl/sd8688_helper.bin",
239 .firmware
= "mrvl/sd8688.bin",
240 .reg
= &btmrvl_reg_8688
,
241 .support_pscan_win_report
= false,
242 .sd_blksz_fw_dl
= 64,
243 .supports_fw_dump
= false,
246 static const struct btmrvl_sdio_device btmrvl_sdio_sd8787
= {
248 .firmware
= "mrvl/sd8787_uapsta.bin",
249 .reg
= &btmrvl_reg_87xx
,
250 .support_pscan_win_report
= false,
251 .sd_blksz_fw_dl
= 256,
252 .supports_fw_dump
= false,
255 static const struct btmrvl_sdio_device btmrvl_sdio_sd8797
= {
257 .firmware
= "mrvl/sd8797_uapsta.bin",
258 .reg
= &btmrvl_reg_87xx
,
259 .support_pscan_win_report
= false,
260 .sd_blksz_fw_dl
= 256,
261 .supports_fw_dump
= false,
264 static const struct btmrvl_sdio_device btmrvl_sdio_sd8887
= {
266 .firmware
= "mrvl/sd8887_uapsta.bin",
267 .reg
= &btmrvl_reg_8887
,
268 .support_pscan_win_report
= true,
269 .sd_blksz_fw_dl
= 256,
270 .supports_fw_dump
= false,
273 static const struct btmrvl_sdio_device btmrvl_sdio_sd8897
= {
275 .firmware
= "mrvl/sd8897_uapsta.bin",
276 .reg
= &btmrvl_reg_8897
,
277 .support_pscan_win_report
= true,
278 .sd_blksz_fw_dl
= 256,
279 .supports_fw_dump
= true,
282 static const struct btmrvl_sdio_device btmrvl_sdio_sd8997
= {
284 .firmware
= "mrvl/sd8997_uapsta.bin",
285 .reg
= &btmrvl_reg_8997
,
286 .support_pscan_win_report
= true,
287 .sd_blksz_fw_dl
= 256,
288 .supports_fw_dump
= true,
291 static const struct sdio_device_id btmrvl_sdio_ids
[] = {
292 /* Marvell SD8688 Bluetooth device */
293 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, 0x9105),
294 .driver_data
= (unsigned long)&btmrvl_sdio_sd8688
},
295 /* Marvell SD8787 Bluetooth device */
296 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, 0x911A),
297 .driver_data
= (unsigned long)&btmrvl_sdio_sd8787
},
298 /* Marvell SD8787 Bluetooth AMP device */
299 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, 0x911B),
300 .driver_data
= (unsigned long)&btmrvl_sdio_sd8787
},
301 /* Marvell SD8797 Bluetooth device */
302 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, 0x912A),
303 .driver_data
= (unsigned long)&btmrvl_sdio_sd8797
},
304 /* Marvell SD8887 Bluetooth device */
305 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, 0x9136),
306 .driver_data
= (unsigned long)&btmrvl_sdio_sd8887
},
307 /* Marvell SD8897 Bluetooth device */
308 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, 0x912E),
309 .driver_data
= (unsigned long)&btmrvl_sdio_sd8897
},
310 /* Marvell SD8997 Bluetooth device */
311 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, 0x9142),
312 .driver_data
= (unsigned long)&btmrvl_sdio_sd8997
},
314 { } /* Terminating entry */
317 MODULE_DEVICE_TABLE(sdio
, btmrvl_sdio_ids
);
319 static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_card
*card
)
324 reg
= sdio_readb(card
->func
, card
->reg
->card_rx_unit
, &ret
);
331 static int btmrvl_sdio_read_fw_status(struct btmrvl_sdio_card
*card
, u16
*dat
)
338 fws0
= sdio_readb(card
->func
, card
->reg
->card_fw_status0
, &ret
);
342 fws1
= sdio_readb(card
->func
, card
->reg
->card_fw_status1
, &ret
);
346 *dat
= (((u16
) fws1
) << 8) | fws0
;
351 static int btmrvl_sdio_read_rx_len(struct btmrvl_sdio_card
*card
, u16
*dat
)
356 reg
= sdio_readb(card
->func
, card
->reg
->card_rx_len
, &ret
);
358 *dat
= (u16
) reg
<< card
->rx_unit
;
363 static int btmrvl_sdio_enable_host_int_mask(struct btmrvl_sdio_card
*card
,
368 sdio_writeb(card
->func
, mask
, card
->reg
->host_int_mask
, &ret
);
370 BT_ERR("Unable to enable the host interrupt!");
377 static int btmrvl_sdio_disable_host_int_mask(struct btmrvl_sdio_card
*card
,
383 host_int_mask
= sdio_readb(card
->func
, card
->reg
->host_int_mask
, &ret
);
387 host_int_mask
&= ~mask
;
389 sdio_writeb(card
->func
, host_int_mask
, card
->reg
->host_int_mask
, &ret
);
391 BT_ERR("Unable to disable the host interrupt!");
398 static int btmrvl_sdio_poll_card_status(struct btmrvl_sdio_card
*card
, u8 bits
)
404 for (tries
= 0; tries
< MAX_POLL_TRIES
* 1000; tries
++) {
405 status
= sdio_readb(card
->func
, card
->reg
->card_status
, &ret
);
408 if ((status
& bits
) == bits
)
417 BT_ERR("FAILED! ret=%d", ret
);
422 static int btmrvl_sdio_verify_fw_download(struct btmrvl_sdio_card
*card
,
428 /* Wait for firmware to become ready */
429 for (tries
= 0; tries
< pollnum
; tries
++) {
430 sdio_claim_host(card
->func
);
431 ret
= btmrvl_sdio_read_fw_status(card
, &firmwarestat
);
432 sdio_release_host(card
->func
);
436 if (firmwarestat
== FIRMWARE_READY
)
445 static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card
*card
)
447 const struct firmware
*fw_helper
= NULL
;
448 const u8
*helper
= NULL
;
450 void *tmphlprbuf
= NULL
;
451 int tmphlprbufsz
, hlprblknow
, helperlen
;
455 ret
= request_firmware(&fw_helper
, card
->helper
,
457 if ((ret
< 0) || !fw_helper
) {
458 BT_ERR("request_firmware(helper) failed, error code = %d",
464 helper
= fw_helper
->data
;
465 helperlen
= fw_helper
->size
;
467 BT_DBG("Downloading helper image (%d bytes), block size %d bytes",
468 helperlen
, SDIO_BLOCK_SIZE
);
470 tmphlprbufsz
= ALIGN_SZ(BTM_UPLD_SIZE
, BTSDIO_DMA_ALIGN
);
472 tmphlprbuf
= kzalloc(tmphlprbufsz
, GFP_KERNEL
);
474 BT_ERR("Unable to allocate buffer for helper."
475 " Terminating download");
480 helperbuf
= (u8
*) ALIGN_ADDR(tmphlprbuf
, BTSDIO_DMA_ALIGN
);
482 /* Perform helper data transfer */
483 tx_len
= (FIRMWARE_TRANSFER_NBLOCK
* SDIO_BLOCK_SIZE
)
488 ret
= btmrvl_sdio_poll_card_status(card
,
489 CARD_IO_READY
| DN_LD_CARD_RDY
);
491 BT_ERR("Helper download poll status timeout @ %d",
496 /* Check if there is more data? */
497 if (hlprblknow
>= helperlen
)
500 if (helperlen
- hlprblknow
< tx_len
)
501 tx_len
= helperlen
- hlprblknow
;
504 helperbuf
[0] = ((tx_len
& 0x000000ff) >> 0);
505 helperbuf
[1] = ((tx_len
& 0x0000ff00) >> 8);
506 helperbuf
[2] = ((tx_len
& 0x00ff0000) >> 16);
507 helperbuf
[3] = ((tx_len
& 0xff000000) >> 24);
509 memcpy(&helperbuf
[SDIO_HEADER_LEN
], &helper
[hlprblknow
],
512 /* Now send the data */
513 ret
= sdio_writesb(card
->func
, card
->ioport
, helperbuf
,
514 FIRMWARE_TRANSFER_NBLOCK
* SDIO_BLOCK_SIZE
);
516 BT_ERR("IO error during helper download @ %d",
521 hlprblknow
+= tx_len
;
524 BT_DBG("Transferring helper image EOF block");
526 memset(helperbuf
, 0x0, SDIO_BLOCK_SIZE
);
528 ret
= sdio_writesb(card
->func
, card
->ioport
, helperbuf
,
531 BT_ERR("IO error in writing helper image EOF block");
539 release_firmware(fw_helper
);
543 static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card
*card
)
545 const struct firmware
*fw_firmware
= NULL
;
546 const u8
*firmware
= NULL
;
547 int firmwarelen
, tmpfwbufsz
, ret
;
548 unsigned int tries
, offset
;
550 void *tmpfwbuf
= NULL
;
552 u16 len
, blksz_dl
= card
->sd_blksz_fw_dl
;
553 int txlen
= 0, tx_blocks
= 0, count
= 0;
555 ret
= request_firmware(&fw_firmware
, card
->firmware
,
557 if ((ret
< 0) || !fw_firmware
) {
558 BT_ERR("request_firmware(firmware) failed, error code = %d",
564 firmware
= fw_firmware
->data
;
565 firmwarelen
= fw_firmware
->size
;
567 BT_DBG("Downloading FW image (%d bytes)", firmwarelen
);
569 tmpfwbufsz
= ALIGN_SZ(BTM_UPLD_SIZE
, BTSDIO_DMA_ALIGN
);
570 tmpfwbuf
= kzalloc(tmpfwbufsz
, GFP_KERNEL
);
572 BT_ERR("Unable to allocate buffer for firmware."
573 " Terminating download");
578 /* Ensure aligned firmware buffer */
579 fwbuf
= (u8
*) ALIGN_ADDR(tmpfwbuf
, BTSDIO_DMA_ALIGN
);
581 /* Perform firmware data transfer */
584 ret
= btmrvl_sdio_poll_card_status(card
,
585 CARD_IO_READY
| DN_LD_CARD_RDY
);
587 BT_ERR("FW download with helper poll status"
588 " timeout @ %d", offset
);
592 /* Check if there is more data ? */
593 if (offset
>= firmwarelen
)
596 for (tries
= 0; tries
< MAX_POLL_TRIES
; tries
++) {
597 base0
= sdio_readb(card
->func
,
598 card
->reg
->sq_read_base_addr_a0
, &ret
);
600 BT_ERR("BASE0 register read failed:"
601 " base0 = 0x%04X(%d)."
602 " Terminating download",
607 base1
= sdio_readb(card
->func
,
608 card
->reg
->sq_read_base_addr_a1
, &ret
);
610 BT_ERR("BASE1 register read failed:"
611 " base1 = 0x%04X(%d)."
612 " Terminating download",
618 len
= (((u16
) base1
) << 8) | base0
;
627 else if (len
> BTM_UPLD_SIZE
) {
628 BT_ERR("FW download failure @%d, invalid length %d",
638 if (count
> MAX_WRITE_IOMEM_RETRY
) {
639 BT_ERR("FW download failure @%d, "
640 "over max retry count", offset
);
644 BT_ERR("FW CRC error indicated by the helper: "
645 "len = 0x%04X, txlen = %d", len
, txlen
);
647 /* Set txlen to 0 so as to resend from same offset */
653 if (firmwarelen
- offset
< txlen
)
654 txlen
= firmwarelen
- offset
;
656 tx_blocks
= DIV_ROUND_UP(txlen
, blksz_dl
);
658 memcpy(fwbuf
, &firmware
[offset
], txlen
);
661 ret
= sdio_writesb(card
->func
, card
->ioport
, fwbuf
,
662 tx_blocks
* blksz_dl
);
665 BT_ERR("FW download, writesb(%d) failed @%d",
667 sdio_writeb(card
->func
, HOST_CMD53_FIN
,
668 card
->reg
->cfg
, &ret
);
670 BT_ERR("writeb failed (CFG)");
676 BT_INFO("FW download over, size %d bytes", offset
);
682 release_firmware(fw_firmware
);
686 static int btmrvl_sdio_card_to_host(struct btmrvl_private
*priv
)
689 int ret
, num_blocks
, blksz
;
690 struct sk_buff
*skb
= NULL
;
693 struct hci_dev
*hdev
= priv
->btmrvl_dev
.hcidev
;
694 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
696 if (!card
|| !card
->func
) {
697 BT_ERR("card or function is NULL!");
702 /* Read the length of data to be transferred */
703 ret
= btmrvl_sdio_read_rx_len(card
, &buf_len
);
705 BT_ERR("read rx_len failed");
710 blksz
= SDIO_BLOCK_SIZE
;
711 num_blocks
= DIV_ROUND_UP(buf_len
, blksz
);
713 if (buf_len
<= SDIO_HEADER_LEN
714 || (num_blocks
* blksz
) > ALLOC_BUF_SIZE
) {
715 BT_ERR("invalid packet length: %d", buf_len
);
720 /* Allocate buffer */
721 skb
= bt_skb_alloc(num_blocks
* blksz
+ BTSDIO_DMA_ALIGN
, GFP_ATOMIC
);
723 BT_ERR("No free skb");
728 if ((unsigned long) skb
->data
& (BTSDIO_DMA_ALIGN
- 1)) {
729 skb_put(skb
, (unsigned long) skb
->data
&
730 (BTSDIO_DMA_ALIGN
- 1));
731 skb_pull(skb
, (unsigned long) skb
->data
&
732 (BTSDIO_DMA_ALIGN
- 1));
737 ret
= sdio_readsb(card
->func
, payload
, card
->ioport
,
740 BT_ERR("readsb failed: %d", ret
);
745 /* This is SDIO specific header length: byte[2][1][0], type: byte[3]
746 * (HCI_COMMAND = 1, ACL_DATA = 2, SCO_DATA = 3, 0xFE = Vendor)
749 buf_len
= payload
[0];
750 buf_len
|= payload
[1] << 8;
751 buf_len
|= payload
[2] << 16;
753 if (buf_len
> blksz
* num_blocks
) {
754 BT_ERR("Skip incorrect packet: hdrlen %d buffer %d",
755 buf_len
, blksz
* num_blocks
);
763 case HCI_ACLDATA_PKT
:
764 case HCI_SCODATA_PKT
:
766 hci_skb_pkt_type(skb
) = type
;
767 skb_put(skb
, buf_len
);
768 skb_pull(skb
, SDIO_HEADER_LEN
);
770 if (type
== HCI_EVENT_PKT
) {
771 if (btmrvl_check_evtpkt(priv
, skb
))
772 hci_recv_frame(hdev
, skb
);
774 hci_recv_frame(hdev
, skb
);
777 hdev
->stat
.byte_rx
+= buf_len
;
780 case MRVL_VENDOR_PKT
:
781 hci_skb_pkt_type(skb
) = HCI_VENDOR_PKT
;
782 skb_put(skb
, buf_len
);
783 skb_pull(skb
, SDIO_HEADER_LEN
);
785 if (btmrvl_process_event(priv
, skb
))
786 hci_recv_frame(hdev
, skb
);
788 hdev
->stat
.byte_rx
+= buf_len
;
792 BT_ERR("Unknown packet type:%d", type
);
793 BT_ERR("hex: %*ph", blksz
* num_blocks
, payload
);
809 static int btmrvl_sdio_process_int_status(struct btmrvl_private
*priv
)
813 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
815 spin_lock_irqsave(&priv
->driver_lock
, flags
);
818 spin_unlock_irqrestore(&priv
->driver_lock
, flags
);
820 sdio_claim_host(card
->func
);
821 if (ireg
& DN_LD_HOST_INT_STATUS
) {
822 if (priv
->btmrvl_dev
.tx_dnld_rdy
)
823 BT_DBG("tx_done already received: "
824 " int_status=0x%x", ireg
);
826 priv
->btmrvl_dev
.tx_dnld_rdy
= true;
829 if (ireg
& UP_LD_HOST_INT_STATUS
)
830 btmrvl_sdio_card_to_host(priv
);
832 sdio_release_host(card
->func
);
837 static int btmrvl_sdio_read_to_clear(struct btmrvl_sdio_card
*card
, u8
*ireg
)
839 struct btmrvl_adapter
*adapter
= card
->priv
->adapter
;
842 ret
= sdio_readsb(card
->func
, adapter
->hw_regs
, 0, SDIO_BLOCK_SIZE
);
844 BT_ERR("sdio_readsb: read int hw_regs failed: %d", ret
);
848 *ireg
= adapter
->hw_regs
[card
->reg
->host_intstatus
];
849 BT_DBG("hw_regs[%#x]=%#x", card
->reg
->host_intstatus
, *ireg
);
854 static int btmrvl_sdio_write_to_clear(struct btmrvl_sdio_card
*card
, u8
*ireg
)
858 *ireg
= sdio_readb(card
->func
, card
->reg
->host_intstatus
, &ret
);
860 BT_ERR("sdio_readb: read int status failed: %d", ret
);
866 * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS
867 * Clear the interrupt status register and re-enable the
870 BT_DBG("int_status = 0x%x", *ireg
);
872 sdio_writeb(card
->func
, ~(*ireg
) & (DN_LD_HOST_INT_STATUS
|
873 UP_LD_HOST_INT_STATUS
),
874 card
->reg
->host_intstatus
, &ret
);
876 BT_ERR("sdio_writeb: clear int status failed: %d", ret
);
884 static void btmrvl_sdio_interrupt(struct sdio_func
*func
)
886 struct btmrvl_private
*priv
;
887 struct btmrvl_sdio_card
*card
;
892 card
= sdio_get_drvdata(func
);
893 if (!card
|| !card
->priv
) {
894 BT_ERR("sbi_interrupt(%p) card or priv is NULL, card=%p",
901 if (priv
->surprise_removed
)
904 if (card
->reg
->int_read_to_clear
)
905 ret
= btmrvl_sdio_read_to_clear(card
, &ireg
);
907 ret
= btmrvl_sdio_write_to_clear(card
, &ireg
);
912 spin_lock_irqsave(&priv
->driver_lock
, flags
);
914 spin_unlock_irqrestore(&priv
->driver_lock
, flags
);
916 btmrvl_interrupt(priv
);
919 static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card
*card
)
921 struct sdio_func
*func
;
925 if (!card
|| !card
->func
) {
926 BT_ERR("Error: card or function is NULL!");
933 sdio_claim_host(func
);
935 ret
= sdio_enable_func(func
);
937 BT_ERR("sdio_enable_func() failed: ret=%d", ret
);
942 ret
= sdio_claim_irq(func
, btmrvl_sdio_interrupt
);
944 BT_ERR("sdio_claim_irq failed: ret=%d", ret
);
949 ret
= sdio_set_block_size(card
->func
, SDIO_BLOCK_SIZE
);
951 BT_ERR("cannot set SDIO block size");
956 reg
= sdio_readb(func
, card
->reg
->io_port_0
, &ret
);
964 reg
= sdio_readb(func
, card
->reg
->io_port_1
, &ret
);
970 card
->ioport
|= (reg
<< 8);
972 reg
= sdio_readb(func
, card
->reg
->io_port_2
, &ret
);
978 card
->ioport
|= (reg
<< 16);
980 BT_DBG("SDIO FUNC%d IO port: 0x%x", func
->num
, card
->ioport
);
982 if (card
->reg
->int_read_to_clear
) {
983 reg
= sdio_readb(func
, card
->reg
->host_int_rsr
, &ret
);
988 sdio_writeb(func
, reg
| 0x3f, card
->reg
->host_int_rsr
, &ret
);
994 reg
= sdio_readb(func
, card
->reg
->card_misc_cfg
, &ret
);
999 sdio_writeb(func
, reg
| 0x10, card
->reg
->card_misc_cfg
, &ret
);
1006 sdio_set_drvdata(func
, card
);
1008 sdio_release_host(func
);
1013 sdio_release_irq(func
);
1016 sdio_disable_func(func
);
1019 sdio_release_host(func
);
1025 static int btmrvl_sdio_unregister_dev(struct btmrvl_sdio_card
*card
)
1027 if (card
&& card
->func
) {
1028 sdio_claim_host(card
->func
);
1029 sdio_release_irq(card
->func
);
1030 sdio_disable_func(card
->func
);
1031 sdio_release_host(card
->func
);
1032 sdio_set_drvdata(card
->func
, NULL
);
1038 static int btmrvl_sdio_enable_host_int(struct btmrvl_sdio_card
*card
)
1042 if (!card
|| !card
->func
)
1045 sdio_claim_host(card
->func
);
1047 ret
= btmrvl_sdio_enable_host_int_mask(card
, HIM_ENABLE
);
1049 btmrvl_sdio_get_rx_unit(card
);
1051 sdio_release_host(card
->func
);
1056 static int btmrvl_sdio_disable_host_int(struct btmrvl_sdio_card
*card
)
1060 if (!card
|| !card
->func
)
1063 sdio_claim_host(card
->func
);
1065 ret
= btmrvl_sdio_disable_host_int_mask(card
, HIM_DISABLE
);
1067 sdio_release_host(card
->func
);
1072 static int btmrvl_sdio_host_to_card(struct btmrvl_private
*priv
,
1073 u8
*payload
, u16 nb
)
1075 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
1080 void *tmpbuf
= NULL
;
1083 if (!card
|| !card
->func
) {
1084 BT_ERR("card or function is NULL!");
1088 blksz
= DIV_ROUND_UP(nb
, SDIO_BLOCK_SIZE
) * SDIO_BLOCK_SIZE
;
1091 if ((unsigned long) payload
& (BTSDIO_DMA_ALIGN
- 1) ||
1093 tmpbufsz
= ALIGN_SZ(blksz
, BTSDIO_DMA_ALIGN
) +
1095 tmpbuf
= kzalloc(tmpbufsz
, GFP_KERNEL
);
1098 buf
= (u8
*) ALIGN_ADDR(tmpbuf
, BTSDIO_DMA_ALIGN
);
1099 memcpy(buf
, payload
, nb
);
1102 sdio_claim_host(card
->func
);
1105 /* Transfer data to card */
1106 ret
= sdio_writesb(card
->func
, card
->ioport
, buf
,
1110 BT_ERR("i=%d writesb failed: %d", i
, ret
);
1111 BT_ERR("hex: %*ph", nb
, payload
);
1113 if (i
> MAX_WRITE_IOMEM_RETRY
)
1118 priv
->btmrvl_dev
.tx_dnld_rdy
= false;
1121 sdio_release_host(card
->func
);
1127 static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card
*card
)
1131 int pollnum
= MAX_POLL_TRIES
;
1133 if (!card
|| !card
->func
) {
1134 BT_ERR("card or function is NULL!");
1138 if (!btmrvl_sdio_verify_fw_download(card
, 1)) {
1139 BT_DBG("Firmware already downloaded!");
1143 sdio_claim_host(card
->func
);
1145 /* Check if other function driver is downloading the firmware */
1146 fws0
= sdio_readb(card
->func
, card
->reg
->card_fw_status0
, &ret
);
1148 BT_ERR("Failed to read FW downloading status!");
1153 BT_DBG("BT not the winner (%#x). Skip FW downloading", fws0
);
1155 /* Give other function more time to download the firmware */
1159 ret
= btmrvl_sdio_download_helper(card
);
1161 BT_ERR("Failed to download helper!");
1167 if (btmrvl_sdio_download_fw_w_helper(card
)) {
1168 BT_ERR("Failed to download firmware!");
1175 * winner or not, with this test the FW synchronizes when the
1176 * module can continue its initialization
1178 if (btmrvl_sdio_verify_fw_download(card
, pollnum
)) {
1179 BT_ERR("FW failed to be active in time!");
1184 sdio_release_host(card
->func
);
1189 sdio_release_host(card
->func
);
1193 static int btmrvl_sdio_wakeup_fw(struct btmrvl_private
*priv
)
1195 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
1198 if (!card
|| !card
->func
) {
1199 BT_ERR("card or function is NULL!");
1203 sdio_claim_host(card
->func
);
1205 sdio_writeb(card
->func
, HOST_POWER_UP
, card
->reg
->cfg
, &ret
);
1207 sdio_release_host(card
->func
);
1209 BT_DBG("wake up firmware");
1214 static void btmrvl_sdio_dump_regs(struct btmrvl_private
*priv
)
1216 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
1218 unsigned int reg
, reg_start
, reg_end
;
1219 char buf
[256], *ptr
;
1220 u8 loop
, func
, data
;
1223 btmrvl_sdio_wakeup_fw(priv
);
1224 sdio_claim_host(card
->func
);
1226 for (loop
= 0; loop
< MAX_LOOP
; loop
++) {
1227 memset(buf
, 0, sizeof(buf
));
1231 /* Read the registers of SDIO function0 */
1241 ptr
+= sprintf(ptr
, "SDIO Func%d (%#x-%#x): ",
1242 func
, reg_start
, reg_end
);
1243 for (reg
= reg_start
; reg
<= reg_end
; reg
++) {
1245 data
= sdio_f0_readb(card
->func
, reg
, &ret
);
1247 data
= sdio_readb(card
->func
, reg
, &ret
);
1250 ptr
+= sprintf(ptr
, "%02x ", data
);
1252 ptr
+= sprintf(ptr
, "ERR");
1260 sdio_release_host(card
->func
);
1263 /* This function read/write firmware */
1265 rdwr_status
btmrvl_sdio_rdwr_firmware(struct btmrvl_private
*priv
,
1268 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
1272 sdio_writeb(card
->func
, FW_DUMP_HOST_READY
, card
->reg
->fw_dump_ctrl
,
1276 BT_ERR("SDIO write err");
1277 return RDWR_STATUS_FAILURE
;
1280 for (tries
= 0; tries
< MAX_POLL_TRIES
; tries
++) {
1281 ctrl_data
= sdio_readb(card
->func
, card
->reg
->fw_dump_ctrl
,
1285 BT_ERR("SDIO read err");
1286 return RDWR_STATUS_FAILURE
;
1289 if (ctrl_data
== FW_DUMP_DONE
)
1291 if (doneflag
&& ctrl_data
== doneflag
)
1292 return RDWR_STATUS_DONE
;
1293 if (ctrl_data
!= FW_DUMP_HOST_READY
) {
1294 BT_INFO("The ctrl reg was changed, re-try again!");
1295 sdio_writeb(card
->func
, FW_DUMP_HOST_READY
,
1296 card
->reg
->fw_dump_ctrl
, &ret
);
1298 BT_ERR("SDIO write err");
1299 return RDWR_STATUS_FAILURE
;
1302 usleep_range(100, 200);
1305 if (ctrl_data
== FW_DUMP_HOST_READY
) {
1306 BT_ERR("Fail to pull ctrl_data");
1307 return RDWR_STATUS_FAILURE
;
1310 return RDWR_STATUS_SUCCESS
;
1313 /* This function dump sdio register and memory data */
1314 static void btmrvl_sdio_dump_firmware(struct btmrvl_private
*priv
)
1316 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
1318 unsigned int reg
, reg_start
, reg_end
;
1319 enum rdwr_status stat
;
1320 u8
*dbg_ptr
, *end_ptr
, *fw_dump_data
, *fw_dump_ptr
;
1321 u8 dump_num
= 0, idx
, i
, read_reg
, doneflag
= 0;
1322 u32 memory_size
, fw_dump_len
= 0;
1324 /* dump sdio register first */
1325 btmrvl_sdio_dump_regs(priv
);
1327 if (!card
->supports_fw_dump
) {
1328 BT_ERR("Firmware dump not supported for this card!");
1332 for (idx
= 0; idx
< ARRAY_SIZE(mem_type_mapping_tbl
); idx
++) {
1333 struct memory_type_mapping
*entry
= &mem_type_mapping_tbl
[idx
];
1335 if (entry
->mem_ptr
) {
1336 vfree(entry
->mem_ptr
);
1337 entry
->mem_ptr
= NULL
;
1339 entry
->mem_size
= 0;
1342 btmrvl_sdio_wakeup_fw(priv
);
1343 sdio_claim_host(card
->func
);
1345 BT_INFO("== btmrvl firmware dump start ==");
1347 stat
= btmrvl_sdio_rdwr_firmware(priv
, doneflag
);
1348 if (stat
== RDWR_STATUS_FAILURE
)
1351 reg
= card
->reg
->fw_dump_start
;
1352 /* Read the number of the memories which will dump */
1353 dump_num
= sdio_readb(card
->func
, reg
, &ret
);
1356 BT_ERR("SDIO read memory length err");
1360 /* Read the length of every memory which will dump */
1361 for (idx
= 0; idx
< dump_num
; idx
++) {
1362 struct memory_type_mapping
*entry
= &mem_type_mapping_tbl
[idx
];
1364 stat
= btmrvl_sdio_rdwr_firmware(priv
, doneflag
);
1365 if (stat
== RDWR_STATUS_FAILURE
)
1369 reg
= card
->reg
->fw_dump_start
;
1370 for (i
= 0; i
< 4; i
++) {
1371 read_reg
= sdio_readb(card
->func
, reg
, &ret
);
1373 BT_ERR("SDIO read err");
1376 memory_size
|= (read_reg
<< i
*8);
1380 if (memory_size
== 0) {
1381 BT_INFO("Firmware dump finished!");
1382 sdio_writeb(card
->func
, FW_DUMP_READ_DONE
,
1383 card
->reg
->fw_dump_ctrl
, &ret
);
1385 BT_ERR("SDIO Write MEMDUMP_FINISH ERR");
1391 BT_INFO("%s_SIZE=0x%x", entry
->mem_name
, memory_size
);
1392 entry
->mem_ptr
= vzalloc(memory_size
+ 1);
1393 entry
->mem_size
= memory_size
;
1394 if (!entry
->mem_ptr
) {
1395 BT_ERR("Vzalloc %s failed", entry
->mem_name
);
1399 fw_dump_len
+= (strlen("========Start dump ") +
1400 strlen(entry
->mem_name
) +
1401 strlen("========\n") +
1403 strlen("\n========End dump========\n"));
1405 dbg_ptr
= entry
->mem_ptr
;
1406 end_ptr
= dbg_ptr
+ memory_size
;
1408 doneflag
= entry
->done_flag
;
1409 BT_INFO("Start %s output, please wait...",
1413 stat
= btmrvl_sdio_rdwr_firmware(priv
, doneflag
);
1414 if (stat
== RDWR_STATUS_FAILURE
)
1417 reg_start
= card
->reg
->fw_dump_start
;
1418 reg_end
= card
->reg
->fw_dump_end
;
1419 for (reg
= reg_start
; reg
<= reg_end
; reg
++) {
1420 *dbg_ptr
= sdio_readb(card
->func
, reg
, &ret
);
1422 BT_ERR("SDIO read err");
1425 if (dbg_ptr
< end_ptr
)
1428 BT_ERR("Allocated buffer not enough");
1431 if (stat
!= RDWR_STATUS_DONE
) {
1434 BT_INFO("%s done: size=0x%tx",
1436 dbg_ptr
- entry
->mem_ptr
);
1442 BT_INFO("== btmrvl firmware dump end ==");
1445 sdio_release_host(card
->func
);
1447 if (fw_dump_len
== 0)
1450 fw_dump_data
= vzalloc(fw_dump_len
+1);
1451 if (!fw_dump_data
) {
1452 BT_ERR("Vzalloc fw_dump_data fail!");
1455 fw_dump_ptr
= fw_dump_data
;
1457 /* Dump all the memory data into single file, a userspace script will
1458 * be used to split all the memory data to multiple files
1460 BT_INFO("== btmrvl firmware dump to /sys/class/devcoredump start");
1461 for (idx
= 0; idx
< dump_num
; idx
++) {
1462 struct memory_type_mapping
*entry
= &mem_type_mapping_tbl
[idx
];
1464 if (entry
->mem_ptr
) {
1465 strcpy(fw_dump_ptr
, "========Start dump ");
1466 fw_dump_ptr
+= strlen("========Start dump ");
1468 strcpy(fw_dump_ptr
, entry
->mem_name
);
1469 fw_dump_ptr
+= strlen(entry
->mem_name
);
1471 strcpy(fw_dump_ptr
, "========\n");
1472 fw_dump_ptr
+= strlen("========\n");
1474 memcpy(fw_dump_ptr
, entry
->mem_ptr
, entry
->mem_size
);
1475 fw_dump_ptr
+= entry
->mem_size
;
1477 strcpy(fw_dump_ptr
, "\n========End dump========\n");
1478 fw_dump_ptr
+= strlen("\n========End dump========\n");
1480 vfree(mem_type_mapping_tbl
[idx
].mem_ptr
);
1481 mem_type_mapping_tbl
[idx
].mem_ptr
= NULL
;
1485 /* fw_dump_data will be free in device coredump release function
1488 dev_coredumpv(&card
->func
->dev
, fw_dump_data
, fw_dump_len
, GFP_KERNEL
);
1489 BT_INFO("== btmrvl firmware dump to /sys/class/devcoredump end");
1492 static int btmrvl_sdio_probe(struct sdio_func
*func
,
1493 const struct sdio_device_id
*id
)
1496 struct btmrvl_private
*priv
= NULL
;
1497 struct btmrvl_sdio_card
*card
= NULL
;
1499 BT_INFO("vendor=0x%x, device=0x%x, class=%d, fn=%d",
1500 id
->vendor
, id
->device
, id
->class, func
->num
);
1502 card
= devm_kzalloc(&func
->dev
, sizeof(*card
), GFP_KERNEL
);
1508 if (id
->driver_data
) {
1509 struct btmrvl_sdio_device
*data
= (void *) id
->driver_data
;
1510 card
->helper
= data
->helper
;
1511 card
->firmware
= data
->firmware
;
1512 card
->reg
= data
->reg
;
1513 card
->sd_blksz_fw_dl
= data
->sd_blksz_fw_dl
;
1514 card
->support_pscan_win_report
= data
->support_pscan_win_report
;
1515 card
->supports_fw_dump
= data
->supports_fw_dump
;
1518 if (btmrvl_sdio_register_dev(card
) < 0) {
1519 BT_ERR("Failed to register BT device!");
1523 /* Disable the interrupts on the card */
1524 btmrvl_sdio_disable_host_int(card
);
1526 if (btmrvl_sdio_download_fw(card
)) {
1527 BT_ERR("Downloading firmware failed!");
1532 btmrvl_sdio_enable_host_int(card
);
1534 /* Device tree node parsing and platform specific configuration*/
1535 btmrvl_sdio_probe_of(&func
->dev
, card
);
1537 priv
= btmrvl_add_card(card
);
1539 BT_ERR("Initializing card failed!");
1541 goto disable_host_int
;
1546 /* Initialize the interface specific function pointers */
1547 priv
->hw_host_to_card
= btmrvl_sdio_host_to_card
;
1548 priv
->hw_wakeup_firmware
= btmrvl_sdio_wakeup_fw
;
1549 priv
->hw_process_int_status
= btmrvl_sdio_process_int_status
;
1550 priv
->firmware_dump
= btmrvl_sdio_dump_firmware
;
1552 if (btmrvl_register_hdev(priv
)) {
1553 BT_ERR("Register hdev failed!");
1555 goto disable_host_int
;
1561 btmrvl_sdio_disable_host_int(card
);
1563 btmrvl_sdio_unregister_dev(card
);
1567 static void btmrvl_sdio_remove(struct sdio_func
*func
)
1569 struct btmrvl_sdio_card
*card
;
1572 card
= sdio_get_drvdata(func
);
1574 /* Send SHUTDOWN command & disable interrupt
1575 * if user removes the module.
1578 btmrvl_send_module_cfg_cmd(card
->priv
,
1579 MODULE_SHUTDOWN_REQ
);
1580 btmrvl_sdio_disable_host_int(card
);
1582 BT_DBG("unregister dev");
1583 card
->priv
->surprise_removed
= true;
1584 btmrvl_sdio_unregister_dev(card
);
1585 btmrvl_remove_card(card
->priv
);
1590 static int btmrvl_sdio_suspend(struct device
*dev
)
1592 struct sdio_func
*func
= dev_to_sdio_func(dev
);
1593 struct btmrvl_sdio_card
*card
;
1594 struct btmrvl_private
*priv
;
1595 mmc_pm_flag_t pm_flags
;
1596 struct hci_dev
*hcidev
;
1599 pm_flags
= sdio_get_host_pm_caps(func
);
1600 BT_DBG("%s: suspend: PM flags = 0x%x", sdio_func_id(func
),
1602 if (!(pm_flags
& MMC_PM_KEEP_POWER
)) {
1603 BT_ERR("%s: cannot remain alive while suspended",
1604 sdio_func_id(func
));
1607 card
= sdio_get_drvdata(func
);
1608 if (!card
|| !card
->priv
) {
1609 BT_ERR("card or priv structure is not valid");
1613 BT_ERR("sdio_func is not specified");
1617 /* Enable platform specific wakeup interrupt */
1618 if (card
->plt_wake_cfg
&& card
->plt_wake_cfg
->irq_bt
>= 0) {
1619 card
->plt_wake_cfg
->wake_by_bt
= false;
1620 enable_irq(card
->plt_wake_cfg
->irq_bt
);
1621 enable_irq_wake(card
->plt_wake_cfg
->irq_bt
);
1625 priv
->adapter
->is_suspending
= true;
1626 hcidev
= priv
->btmrvl_dev
.hcidev
;
1627 BT_DBG("%s: SDIO suspend", hcidev
->name
);
1628 hci_suspend_dev(hcidev
);
1630 if (priv
->adapter
->hs_state
!= HS_ACTIVATED
) {
1631 if (btmrvl_enable_hs(priv
)) {
1632 BT_ERR("HS not activated, suspend failed!");
1633 /* Disable platform specific wakeup interrupt */
1634 if (card
->plt_wake_cfg
&&
1635 card
->plt_wake_cfg
->irq_bt
>= 0) {
1636 disable_irq_wake(card
->plt_wake_cfg
->irq_bt
);
1637 disable_irq(card
->plt_wake_cfg
->irq_bt
);
1640 priv
->adapter
->is_suspending
= false;
1645 priv
->adapter
->is_suspending
= false;
1646 priv
->adapter
->is_suspended
= true;
1648 /* We will keep the power when hs enabled successfully */
1649 if (priv
->adapter
->hs_state
== HS_ACTIVATED
) {
1650 BT_DBG("suspend with MMC_PM_KEEP_POWER");
1651 return sdio_set_host_pm_flags(func
, MMC_PM_KEEP_POWER
);
1654 BT_DBG("suspend without MMC_PM_KEEP_POWER");
1658 static int btmrvl_sdio_resume(struct device
*dev
)
1660 struct sdio_func
*func
= dev_to_sdio_func(dev
);
1661 struct btmrvl_sdio_card
*card
;
1662 struct btmrvl_private
*priv
;
1663 mmc_pm_flag_t pm_flags
;
1664 struct hci_dev
*hcidev
;
1667 pm_flags
= sdio_get_host_pm_caps(func
);
1668 BT_DBG("%s: resume: PM flags = 0x%x", sdio_func_id(func
),
1670 card
= sdio_get_drvdata(func
);
1671 if (!card
|| !card
->priv
) {
1672 BT_ERR("card or priv structure is not valid");
1676 BT_ERR("sdio_func is not specified");
1681 if (!priv
->adapter
->is_suspended
) {
1682 BT_DBG("device already resumed");
1686 priv
->hw_wakeup_firmware(priv
);
1687 priv
->adapter
->hs_state
= HS_DEACTIVATED
;
1688 hcidev
= priv
->btmrvl_dev
.hcidev
;
1689 BT_DBG("%s: HS DEACTIVATED in resume!", hcidev
->name
);
1690 priv
->adapter
->is_suspended
= false;
1691 BT_DBG("%s: SDIO resume", hcidev
->name
);
1692 hci_resume_dev(hcidev
);
1694 /* Disable platform specific wakeup interrupt */
1695 if (card
->plt_wake_cfg
&& card
->plt_wake_cfg
->irq_bt
>= 0) {
1696 disable_irq_wake(card
->plt_wake_cfg
->irq_bt
);
1697 disable_irq(card
->plt_wake_cfg
->irq_bt
);
1698 if (card
->plt_wake_cfg
->wake_by_bt
)
1699 /* Undo our disable, since interrupt handler already
1702 enable_irq(card
->plt_wake_cfg
->irq_bt
);
1708 static const struct dev_pm_ops btmrvl_sdio_pm_ops
= {
1709 .suspend
= btmrvl_sdio_suspend
,
1710 .resume
= btmrvl_sdio_resume
,
1713 static struct sdio_driver bt_mrvl_sdio
= {
1714 .name
= "btmrvl_sdio",
1715 .id_table
= btmrvl_sdio_ids
,
1716 .probe
= btmrvl_sdio_probe
,
1717 .remove
= btmrvl_sdio_remove
,
1719 .owner
= THIS_MODULE
,
1720 .pm
= &btmrvl_sdio_pm_ops
,
1724 static int __init
btmrvl_sdio_init_module(void)
1726 if (sdio_register_driver(&bt_mrvl_sdio
) != 0) {
1727 BT_ERR("SDIO Driver Registration Failed");
1731 /* Clear the flag in case user removes the card. */
1737 static void __exit
btmrvl_sdio_exit_module(void)
1739 /* Set the flag as user is removing this module. */
1742 sdio_unregister_driver(&bt_mrvl_sdio
);
1745 module_init(btmrvl_sdio_init_module
);
1746 module_exit(btmrvl_sdio_exit_module
);
1748 MODULE_AUTHOR("Marvell International Ltd.");
1749 MODULE_DESCRIPTION("Marvell BT-over-SDIO driver ver " VERSION
);
1750 MODULE_VERSION(VERSION
);
1751 MODULE_LICENSE("GPL v2");
1752 MODULE_FIRMWARE("mrvl/sd8688_helper.bin");
1753 MODULE_FIRMWARE("mrvl/sd8688.bin");
1754 MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin");
1755 MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin");
1756 MODULE_FIRMWARE("mrvl/sd8887_uapsta.bin");
1757 MODULE_FIRMWARE("mrvl/sd8897_uapsta.bin");
1758 MODULE_FIRMWARE("mrvl/sd8997_uapsta.bin");