1 // SPDX-License-Identifier: GPL-2.0-only
3 * Marvell BT-over-SDIO driver: SDIO interface related functions.
5 * Copyright (C) 2009, Marvell International Ltd.
8 #include <linux/firmware.h>
9 #include <linux/slab.h>
10 #include <linux/suspend.h>
12 #include <linux/mmc/sdio_ids.h>
13 #include <linux/mmc/sdio_func.h>
14 #include <linux/module.h>
15 #include <linux/devcoredump.h>
17 #include <net/bluetooth/bluetooth.h>
18 #include <net/bluetooth/hci_core.h>
20 #include "btmrvl_drv.h"
21 #include "btmrvl_sdio.h"
25 static struct memory_type_mapping mem_type_mapping_tbl
[] = {
26 {"ITCM", NULL
, 0, 0xF0},
27 {"DTCM", NULL
, 0, 0xF1},
28 {"SQRAM", NULL
, 0, 0xF2},
29 {"APU", NULL
, 0, 0xF3},
30 {"CIU", NULL
, 0, 0xF4},
31 {"ICU", NULL
, 0, 0xF5},
32 {"MAC", NULL
, 0, 0xF6},
33 {"EXT7", NULL
, 0, 0xF7},
34 {"EXT8", NULL
, 0, 0xF8},
35 {"EXT9", NULL
, 0, 0xF9},
36 {"EXT10", NULL
, 0, 0xFA},
37 {"EXT11", NULL
, 0, 0xFB},
38 {"EXT12", NULL
, 0, 0xFC},
39 {"EXT13", NULL
, 0, 0xFD},
40 {"EXTLAST", NULL
, 0, 0xFE},
43 static const struct of_device_id btmrvl_sdio_of_match_table
[] __maybe_unused
= {
44 { .compatible
= "marvell,sd8897-bt" },
45 { .compatible
= "marvell,sd8997-bt" },
49 static irqreturn_t
btmrvl_wake_irq_bt(int irq
, void *priv
)
51 struct btmrvl_sdio_card
*card
= priv
;
52 struct device
*dev
= &card
->func
->dev
;
53 struct btmrvl_plt_wake_cfg
*cfg
= card
->plt_wake_cfg
;
55 dev_info(dev
, "wake by bt\n");
56 cfg
->wake_by_bt
= true;
57 disable_irq_nosync(irq
);
59 pm_wakeup_event(dev
, 0);
65 /* This function parses device tree node using mmc subnode devicetree API.
66 * The device node is saved in card->plt_of_node.
67 * If the device tree node exists and includes interrupts attributes, this
68 * function will request platform specific wakeup interrupt.
70 static int btmrvl_sdio_probe_of(struct device
*dev
,
71 struct btmrvl_sdio_card
*card
)
73 struct btmrvl_plt_wake_cfg
*cfg
;
77 !of_match_node(btmrvl_sdio_of_match_table
, dev
->of_node
)) {
78 dev_info(dev
, "sdio device tree data not available\n");
82 card
->plt_of_node
= dev
->of_node
;
84 card
->plt_wake_cfg
= devm_kzalloc(dev
, sizeof(*card
->plt_wake_cfg
),
86 cfg
= card
->plt_wake_cfg
;
87 if (cfg
&& card
->plt_of_node
) {
88 cfg
->irq_bt
= irq_of_parse_and_map(card
->plt_of_node
, 0);
90 dev_err(dev
, "fail to parse irq_bt from device tree\n");
93 ret
= devm_request_irq(dev
, cfg
->irq_bt
,
95 IRQF_NO_AUTOEN
, "bt_wake", card
);
98 "Failed to request irq_bt %d (%d)\n",
102 /* Configure wakeup (enabled by default) */
103 device_init_wakeup(dev
, true);
110 /* The btmrvl_sdio_remove() callback function is called
111 * when user removes this module from kernel space or ejects
112 * the card from the slot. The driver handles these 2 cases
114 * If the user is removing the module, a MODULE_SHUTDOWN_REQ
115 * command is sent to firmware and interrupt will be disabled.
116 * If the card is removed, there is no need to send command
117 * or disable interrupt.
119 * The variable 'user_rmmod' is used to distinguish these two
120 * scenarios. This flag is initialized as FALSE in case the card
121 * is removed, and will be set to TRUE for module removal when
122 * module_exit function is called.
124 static u8 user_rmmod
;
127 static const struct btmrvl_sdio_card_reg btmrvl_reg_8688
= {
129 .host_int_mask
= 0x04,
130 .host_intstatus
= 0x05,
132 .sq_read_base_addr_a0
= 0x10,
133 .sq_read_base_addr_a1
= 0x11,
134 .card_fw_status0
= 0x40,
135 .card_fw_status1
= 0x41,
137 .card_rx_unit
= 0x43,
141 .int_read_to_clear
= false,
143 static const struct btmrvl_sdio_card_reg btmrvl_reg_87xx
= {
145 .host_int_mask
= 0x02,
146 .host_intstatus
= 0x03,
148 .sq_read_base_addr_a0
= 0x40,
149 .sq_read_base_addr_a1
= 0x41,
150 .card_revision
= 0x5c,
151 .card_fw_status0
= 0x60,
152 .card_fw_status1
= 0x61,
154 .card_rx_unit
= 0x63,
158 .int_read_to_clear
= false,
161 static const struct btmrvl_sdio_card_reg btmrvl_reg_8887
= {
163 .host_int_mask
= 0x08,
164 .host_intstatus
= 0x0C,
166 .sq_read_base_addr_a0
= 0x6C,
167 .sq_read_base_addr_a1
= 0x6D,
168 .card_revision
= 0xC8,
169 .card_fw_status0
= 0x88,
170 .card_fw_status1
= 0x89,
172 .card_rx_unit
= 0x8B,
176 .int_read_to_clear
= true,
177 .host_int_rsr
= 0x04,
178 .card_misc_cfg
= 0xD8,
181 static const struct btmrvl_sdio_card_reg btmrvl_reg_8897
= {
183 .host_int_mask
= 0x02,
184 .host_intstatus
= 0x03,
186 .sq_read_base_addr_a0
= 0x60,
187 .sq_read_base_addr_a1
= 0x61,
188 .card_revision
= 0xbc,
189 .card_fw_status0
= 0xc0,
190 .card_fw_status1
= 0xc1,
192 .card_rx_unit
= 0xc3,
196 .int_read_to_clear
= true,
197 .host_int_rsr
= 0x01,
198 .card_misc_cfg
= 0xcc,
199 .fw_dump_ctrl
= 0xe2,
200 .fw_dump_start
= 0xe3,
204 static const struct btmrvl_sdio_card_reg btmrvl_reg_89xx
= {
206 .host_int_mask
= 0x08,
207 .host_intstatus
= 0x0c,
209 .sq_read_base_addr_a0
= 0xf8,
210 .sq_read_base_addr_a1
= 0xf9,
211 .card_revision
= 0xc8,
212 .card_fw_status0
= 0xe8,
213 .card_fw_status1
= 0xe9,
215 .card_rx_unit
= 0xeb,
219 .int_read_to_clear
= true,
220 .host_int_rsr
= 0x04,
221 .card_misc_cfg
= 0xd8,
222 .fw_dump_ctrl
= 0xf0,
223 .fw_dump_start
= 0xf1,
227 static const struct btmrvl_sdio_device btmrvl_sdio_sd8688
= {
228 .helper
= "mrvl/sd8688_helper.bin",
229 .firmware
= "mrvl/sd8688.bin",
230 .reg
= &btmrvl_reg_8688
,
231 .support_pscan_win_report
= false,
232 .sd_blksz_fw_dl
= 64,
233 .supports_fw_dump
= false,
236 static const struct btmrvl_sdio_device btmrvl_sdio_sd8787
= {
238 .firmware
= "mrvl/sd8787_uapsta.bin",
239 .reg
= &btmrvl_reg_87xx
,
240 .support_pscan_win_report
= false,
241 .sd_blksz_fw_dl
= 256,
242 .supports_fw_dump
= false,
245 static const struct btmrvl_sdio_device btmrvl_sdio_sd8797
= {
247 .firmware
= "mrvl/sd8797_uapsta.bin",
248 .reg
= &btmrvl_reg_87xx
,
249 .support_pscan_win_report
= false,
250 .sd_blksz_fw_dl
= 256,
251 .supports_fw_dump
= false,
254 static const struct btmrvl_sdio_device btmrvl_sdio_sd8887
= {
256 .firmware
= "mrvl/sd8887_uapsta.bin",
257 .reg
= &btmrvl_reg_8887
,
258 .support_pscan_win_report
= true,
259 .sd_blksz_fw_dl
= 256,
260 .supports_fw_dump
= false,
263 static const struct btmrvl_sdio_device btmrvl_sdio_sd8897
= {
265 .firmware
= "mrvl/sd8897_uapsta.bin",
266 .reg
= &btmrvl_reg_8897
,
267 .support_pscan_win_report
= true,
268 .sd_blksz_fw_dl
= 256,
269 .supports_fw_dump
= true,
272 static const struct btmrvl_sdio_device btmrvl_sdio_sd8977
= {
274 .firmware
= "mrvl/sdsd8977_combo_v2.bin",
275 .reg
= &btmrvl_reg_89xx
,
276 .support_pscan_win_report
= true,
277 .sd_blksz_fw_dl
= 256,
278 .supports_fw_dump
= true,
281 static const struct btmrvl_sdio_device btmrvl_sdio_sd8987
= {
283 .firmware
= "mrvl/sd8987_uapsta.bin",
284 .reg
= &btmrvl_reg_89xx
,
285 .support_pscan_win_report
= true,
286 .sd_blksz_fw_dl
= 256,
287 .supports_fw_dump
= true,
290 static const struct btmrvl_sdio_device btmrvl_sdio_sd8997
= {
292 .firmware
= "mrvl/sdsd8997_combo_v4.bin",
293 .reg
= &btmrvl_reg_89xx
,
294 .support_pscan_win_report
= true,
295 .sd_blksz_fw_dl
= 256,
296 .supports_fw_dump
= true,
299 static const struct sdio_device_id btmrvl_sdio_ids
[] = {
300 /* Marvell SD8688 Bluetooth device */
301 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, SDIO_DEVICE_ID_MARVELL_8688_BT
),
302 .driver_data
= (unsigned long)&btmrvl_sdio_sd8688
},
303 /* Marvell SD8787 Bluetooth device */
304 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, SDIO_DEVICE_ID_MARVELL_8787_BT
),
305 .driver_data
= (unsigned long)&btmrvl_sdio_sd8787
},
306 /* Marvell SD8787 Bluetooth AMP device */
307 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, SDIO_DEVICE_ID_MARVELL_8787_BT_AMP
),
308 .driver_data
= (unsigned long)&btmrvl_sdio_sd8787
},
309 /* Marvell SD8797 Bluetooth device */
310 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, SDIO_DEVICE_ID_MARVELL_8797_BT
),
311 .driver_data
= (unsigned long)&btmrvl_sdio_sd8797
},
312 /* Marvell SD8887 Bluetooth device */
313 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, SDIO_DEVICE_ID_MARVELL_8887_BT
),
314 .driver_data
= (unsigned long)&btmrvl_sdio_sd8887
},
315 /* Marvell SD8897 Bluetooth device */
316 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, SDIO_DEVICE_ID_MARVELL_8897_BT
),
317 .driver_data
= (unsigned long)&btmrvl_sdio_sd8897
},
318 /* Marvell SD8977 Bluetooth device */
319 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, SDIO_DEVICE_ID_MARVELL_8977_BT
),
320 .driver_data
= (unsigned long)&btmrvl_sdio_sd8977
},
321 /* Marvell SD8987 Bluetooth device */
322 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, SDIO_DEVICE_ID_MARVELL_8987_BT
),
323 .driver_data
= (unsigned long)&btmrvl_sdio_sd8987
},
324 /* Marvell SD8997 Bluetooth device */
325 { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL
, SDIO_DEVICE_ID_MARVELL_8997_BT
),
326 .driver_data
= (unsigned long)&btmrvl_sdio_sd8997
},
328 { } /* Terminating entry */
331 MODULE_DEVICE_TABLE(sdio
, btmrvl_sdio_ids
);
333 static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_card
*card
)
338 reg
= sdio_readb(card
->func
, card
->reg
->card_rx_unit
, &ret
);
345 static int btmrvl_sdio_read_fw_status(struct btmrvl_sdio_card
*card
, u16
*dat
)
352 fws0
= sdio_readb(card
->func
, card
->reg
->card_fw_status0
, &ret
);
356 fws1
= sdio_readb(card
->func
, card
->reg
->card_fw_status1
, &ret
);
360 *dat
= (((u16
) fws1
) << 8) | fws0
;
365 static int btmrvl_sdio_read_rx_len(struct btmrvl_sdio_card
*card
, u16
*dat
)
370 reg
= sdio_readb(card
->func
, card
->reg
->card_rx_len
, &ret
);
372 *dat
= (u16
) reg
<< card
->rx_unit
;
377 static int btmrvl_sdio_enable_host_int_mask(struct btmrvl_sdio_card
*card
,
382 sdio_writeb(card
->func
, mask
, card
->reg
->host_int_mask
, &ret
);
384 BT_ERR("Unable to enable the host interrupt!");
391 static int btmrvl_sdio_disable_host_int_mask(struct btmrvl_sdio_card
*card
,
397 host_int_mask
= sdio_readb(card
->func
, card
->reg
->host_int_mask
, &ret
);
401 host_int_mask
&= ~mask
;
403 sdio_writeb(card
->func
, host_int_mask
, card
->reg
->host_int_mask
, &ret
);
405 BT_ERR("Unable to disable the host interrupt!");
412 static int btmrvl_sdio_poll_card_status(struct btmrvl_sdio_card
*card
, u8 bits
)
418 for (tries
= 0; tries
< MAX_POLL_TRIES
* 1000; tries
++) {
419 status
= sdio_readb(card
->func
, card
->reg
->card_status
, &ret
);
422 if ((status
& bits
) == bits
)
431 BT_ERR("FAILED! ret=%d", ret
);
436 static int btmrvl_sdio_verify_fw_download(struct btmrvl_sdio_card
*card
,
442 /* Wait for firmware to become ready */
443 for (tries
= 0; tries
< pollnum
; tries
++) {
444 sdio_claim_host(card
->func
);
445 ret
= btmrvl_sdio_read_fw_status(card
, &firmwarestat
);
446 sdio_release_host(card
->func
);
450 if (firmwarestat
== FIRMWARE_READY
)
459 static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card
*card
)
461 const struct firmware
*fw_helper
= NULL
;
462 const u8
*helper
= NULL
;
464 void *tmphlprbuf
= NULL
;
465 int tmphlprbufsz
, hlprblknow
, helperlen
;
469 ret
= request_firmware(&fw_helper
, card
->helper
,
471 if ((ret
< 0) || !fw_helper
) {
472 BT_ERR("request_firmware(helper) failed, error code = %d",
478 helper
= fw_helper
->data
;
479 helperlen
= fw_helper
->size
;
481 BT_DBG("Downloading helper image (%d bytes), block size %d bytes",
482 helperlen
, SDIO_BLOCK_SIZE
);
484 tmphlprbufsz
= ALIGN_SZ(BTM_UPLD_SIZE
, BTSDIO_DMA_ALIGN
);
486 tmphlprbuf
= kzalloc(tmphlprbufsz
, GFP_KERNEL
);
488 BT_ERR("Unable to allocate buffer for helper."
489 " Terminating download");
494 helperbuf
= (u8
*) ALIGN_ADDR(tmphlprbuf
, BTSDIO_DMA_ALIGN
);
496 /* Perform helper data transfer */
497 tx_len
= (FIRMWARE_TRANSFER_NBLOCK
* SDIO_BLOCK_SIZE
)
502 ret
= btmrvl_sdio_poll_card_status(card
,
503 CARD_IO_READY
| DN_LD_CARD_RDY
);
505 BT_ERR("Helper download poll status timeout @ %d",
510 /* Check if there is more data? */
511 if (hlprblknow
>= helperlen
)
514 if (helperlen
- hlprblknow
< tx_len
)
515 tx_len
= helperlen
- hlprblknow
;
518 helperbuf
[0] = ((tx_len
& 0x000000ff) >> 0);
519 helperbuf
[1] = ((tx_len
& 0x0000ff00) >> 8);
520 helperbuf
[2] = ((tx_len
& 0x00ff0000) >> 16);
521 helperbuf
[3] = ((tx_len
& 0xff000000) >> 24);
523 memcpy(&helperbuf
[SDIO_HEADER_LEN
], &helper
[hlprblknow
],
526 /* Now send the data */
527 ret
= sdio_writesb(card
->func
, card
->ioport
, helperbuf
,
528 FIRMWARE_TRANSFER_NBLOCK
* SDIO_BLOCK_SIZE
);
530 BT_ERR("IO error during helper download @ %d",
535 hlprblknow
+= tx_len
;
538 BT_DBG("Transferring helper image EOF block");
540 memset(helperbuf
, 0x0, SDIO_BLOCK_SIZE
);
542 ret
= sdio_writesb(card
->func
, card
->ioport
, helperbuf
,
545 BT_ERR("IO error in writing helper image EOF block");
553 release_firmware(fw_helper
);
557 static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card
*card
)
559 const struct firmware
*fw_firmware
= NULL
;
560 const u8
*firmware
= NULL
;
561 int firmwarelen
, tmpfwbufsz
, ret
;
562 unsigned int tries
, offset
;
564 void *tmpfwbuf
= NULL
;
566 u16 len
, blksz_dl
= card
->sd_blksz_fw_dl
;
567 int txlen
= 0, tx_blocks
= 0, count
= 0;
569 ret
= request_firmware(&fw_firmware
, card
->firmware
,
571 if ((ret
< 0) || !fw_firmware
) {
572 BT_ERR("request_firmware(firmware) failed, error code = %d",
578 firmware
= fw_firmware
->data
;
579 firmwarelen
= fw_firmware
->size
;
581 BT_DBG("Downloading FW image (%d bytes)", firmwarelen
);
583 tmpfwbufsz
= ALIGN_SZ(BTM_UPLD_SIZE
, BTSDIO_DMA_ALIGN
);
584 tmpfwbuf
= kzalloc(tmpfwbufsz
, GFP_KERNEL
);
586 BT_ERR("Unable to allocate buffer for firmware."
587 " Terminating download");
592 /* Ensure aligned firmware buffer */
593 fwbuf
= (u8
*) ALIGN_ADDR(tmpfwbuf
, BTSDIO_DMA_ALIGN
);
595 /* Perform firmware data transfer */
598 ret
= btmrvl_sdio_poll_card_status(card
,
599 CARD_IO_READY
| DN_LD_CARD_RDY
);
601 BT_ERR("FW download with helper poll status"
602 " timeout @ %d", offset
);
606 /* Check if there is more data ? */
607 if (offset
>= firmwarelen
)
610 for (tries
= 0; tries
< MAX_POLL_TRIES
; tries
++) {
611 base0
= sdio_readb(card
->func
,
612 card
->reg
->sq_read_base_addr_a0
, &ret
);
614 BT_ERR("BASE0 register read failed:"
615 " base0 = 0x%04X(%d)."
616 " Terminating download",
621 base1
= sdio_readb(card
->func
,
622 card
->reg
->sq_read_base_addr_a1
, &ret
);
624 BT_ERR("BASE1 register read failed:"
625 " base1 = 0x%04X(%d)."
626 " Terminating download",
632 len
= (((u16
) base1
) << 8) | base0
;
641 else if (len
> BTM_UPLD_SIZE
) {
642 BT_ERR("FW download failure @%d, invalid length %d",
652 if (count
> MAX_WRITE_IOMEM_RETRY
) {
653 BT_ERR("FW download failure @%d, "
654 "over max retry count", offset
);
658 BT_ERR("FW CRC error indicated by the helper: "
659 "len = 0x%04X, txlen = %d", len
, txlen
);
661 /* Set txlen to 0 so as to resend from same offset */
667 if (firmwarelen
- offset
< txlen
)
668 txlen
= firmwarelen
- offset
;
670 tx_blocks
= DIV_ROUND_UP(txlen
, blksz_dl
);
672 memcpy(fwbuf
, &firmware
[offset
], txlen
);
675 ret
= sdio_writesb(card
->func
, card
->ioport
, fwbuf
,
676 tx_blocks
* blksz_dl
);
679 BT_ERR("FW download, writesb(%d) failed @%d",
681 sdio_writeb(card
->func
, HOST_CMD53_FIN
,
682 card
->reg
->cfg
, &ret
);
684 BT_ERR("writeb failed (CFG)");
690 BT_INFO("FW download over, size %d bytes", offset
);
696 release_firmware(fw_firmware
);
700 static int btmrvl_sdio_card_to_host(struct btmrvl_private
*priv
)
703 int ret
, num_blocks
, blksz
;
704 struct sk_buff
*skb
= NULL
;
707 struct hci_dev
*hdev
= priv
->btmrvl_dev
.hcidev
;
708 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
710 if (!card
|| !card
->func
) {
711 BT_ERR("card or function is NULL!");
716 /* Read the length of data to be transferred */
717 ret
= btmrvl_sdio_read_rx_len(card
, &buf_len
);
719 BT_ERR("read rx_len failed");
724 blksz
= SDIO_BLOCK_SIZE
;
725 num_blocks
= DIV_ROUND_UP(buf_len
, blksz
);
727 if (buf_len
<= SDIO_HEADER_LEN
728 || (num_blocks
* blksz
) > ALLOC_BUF_SIZE
) {
729 BT_ERR("invalid packet length: %d", buf_len
);
734 /* Allocate buffer */
735 skb
= bt_skb_alloc(num_blocks
* blksz
+ BTSDIO_DMA_ALIGN
, GFP_KERNEL
);
737 BT_ERR("No free skb");
742 if ((unsigned long) skb
->data
& (BTSDIO_DMA_ALIGN
- 1)) {
743 skb_put(skb
, (unsigned long) skb
->data
&
744 (BTSDIO_DMA_ALIGN
- 1));
745 skb_pull(skb
, (unsigned long) skb
->data
&
746 (BTSDIO_DMA_ALIGN
- 1));
751 ret
= sdio_readsb(card
->func
, payload
, card
->ioport
,
754 BT_ERR("readsb failed: %d", ret
);
759 /* This is SDIO specific header length: byte[2][1][0], type: byte[3]
760 * (HCI_COMMAND = 1, ACL_DATA = 2, SCO_DATA = 3, 0xFE = Vendor)
763 buf_len
= payload
[0];
764 buf_len
|= payload
[1] << 8;
765 buf_len
|= payload
[2] << 16;
767 if (buf_len
> blksz
* num_blocks
) {
768 BT_ERR("Skip incorrect packet: hdrlen %d buffer %d",
769 buf_len
, blksz
* num_blocks
);
777 case HCI_ACLDATA_PKT
:
778 case HCI_SCODATA_PKT
:
780 hci_skb_pkt_type(skb
) = type
;
781 skb_put(skb
, buf_len
);
782 skb_pull(skb
, SDIO_HEADER_LEN
);
784 if (type
== HCI_EVENT_PKT
) {
785 if (btmrvl_check_evtpkt(priv
, skb
))
786 hci_recv_frame(hdev
, skb
);
788 hci_recv_frame(hdev
, skb
);
791 hdev
->stat
.byte_rx
+= buf_len
;
794 case MRVL_VENDOR_PKT
:
795 hci_skb_pkt_type(skb
) = HCI_VENDOR_PKT
;
796 skb_put(skb
, buf_len
);
797 skb_pull(skb
, SDIO_HEADER_LEN
);
799 if (btmrvl_process_event(priv
, skb
))
800 hci_recv_frame(hdev
, skb
);
802 hdev
->stat
.byte_rx
+= buf_len
;
806 BT_ERR("Unknown packet type:%d", type
);
807 BT_ERR("hex: %*ph", blksz
* num_blocks
, payload
);
823 static int btmrvl_sdio_process_int_status(struct btmrvl_private
*priv
)
827 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
829 spin_lock_irqsave(&priv
->driver_lock
, flags
);
832 spin_unlock_irqrestore(&priv
->driver_lock
, flags
);
834 sdio_claim_host(card
->func
);
835 if (ireg
& DN_LD_HOST_INT_STATUS
) {
836 if (priv
->btmrvl_dev
.tx_dnld_rdy
)
837 BT_DBG("tx_done already received: "
838 " int_status=0x%x", ireg
);
840 priv
->btmrvl_dev
.tx_dnld_rdy
= true;
843 if (ireg
& UP_LD_HOST_INT_STATUS
)
844 btmrvl_sdio_card_to_host(priv
);
846 sdio_release_host(card
->func
);
851 static int btmrvl_sdio_read_to_clear(struct btmrvl_sdio_card
*card
, u8
*ireg
)
853 struct btmrvl_adapter
*adapter
= card
->priv
->adapter
;
856 ret
= sdio_readsb(card
->func
, adapter
->hw_regs
, 0, SDIO_BLOCK_SIZE
);
858 BT_ERR("sdio_readsb: read int hw_regs failed: %d", ret
);
862 *ireg
= adapter
->hw_regs
[card
->reg
->host_intstatus
];
863 BT_DBG("hw_regs[%#x]=%#x", card
->reg
->host_intstatus
, *ireg
);
868 static int btmrvl_sdio_write_to_clear(struct btmrvl_sdio_card
*card
, u8
*ireg
)
872 *ireg
= sdio_readb(card
->func
, card
->reg
->host_intstatus
, &ret
);
874 BT_ERR("sdio_readb: read int status failed: %d", ret
);
880 * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS
881 * Clear the interrupt status register and re-enable the
884 BT_DBG("int_status = 0x%x", *ireg
);
886 sdio_writeb(card
->func
, ~(*ireg
) & (DN_LD_HOST_INT_STATUS
|
887 UP_LD_HOST_INT_STATUS
),
888 card
->reg
->host_intstatus
, &ret
);
890 BT_ERR("sdio_writeb: clear int status failed: %d", ret
);
898 static void btmrvl_sdio_interrupt(struct sdio_func
*func
)
900 struct btmrvl_private
*priv
;
901 struct btmrvl_sdio_card
*card
;
906 card
= sdio_get_drvdata(func
);
907 if (!card
|| !card
->priv
) {
908 BT_ERR("sbi_interrupt(%p) card or priv is NULL, card=%p",
915 if (priv
->surprise_removed
)
918 if (card
->reg
->int_read_to_clear
)
919 ret
= btmrvl_sdio_read_to_clear(card
, &ireg
);
921 ret
= btmrvl_sdio_write_to_clear(card
, &ireg
);
926 spin_lock_irqsave(&priv
->driver_lock
, flags
);
928 spin_unlock_irqrestore(&priv
->driver_lock
, flags
);
930 btmrvl_interrupt(priv
);
933 static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card
*card
)
935 struct sdio_func
*func
;
939 if (!card
|| !card
->func
) {
940 BT_ERR("Error: card or function is NULL!");
947 sdio_claim_host(func
);
949 ret
= sdio_enable_func(func
);
951 BT_ERR("sdio_enable_func() failed: ret=%d", ret
);
956 ret
= sdio_claim_irq(func
, btmrvl_sdio_interrupt
);
958 BT_ERR("sdio_claim_irq failed: ret=%d", ret
);
963 ret
= sdio_set_block_size(card
->func
, SDIO_BLOCK_SIZE
);
965 BT_ERR("cannot set SDIO block size");
970 reg
= sdio_readb(func
, card
->reg
->io_port_0
, &ret
);
978 reg
= sdio_readb(func
, card
->reg
->io_port_1
, &ret
);
984 card
->ioport
|= (reg
<< 8);
986 reg
= sdio_readb(func
, card
->reg
->io_port_2
, &ret
);
992 card
->ioport
|= (reg
<< 16);
994 BT_DBG("SDIO FUNC%d IO port: 0x%x", func
->num
, card
->ioport
);
996 if (card
->reg
->int_read_to_clear
) {
997 reg
= sdio_readb(func
, card
->reg
->host_int_rsr
, &ret
);
1002 sdio_writeb(func
, reg
| 0x3f, card
->reg
->host_int_rsr
, &ret
);
1008 reg
= sdio_readb(func
, card
->reg
->card_misc_cfg
, &ret
);
1013 sdio_writeb(func
, reg
| 0x10, card
->reg
->card_misc_cfg
, &ret
);
1020 sdio_set_drvdata(func
, card
);
1022 sdio_release_host(func
);
1027 sdio_release_irq(func
);
1030 sdio_disable_func(func
);
1033 sdio_release_host(func
);
1039 static int btmrvl_sdio_unregister_dev(struct btmrvl_sdio_card
*card
)
1041 if (card
&& card
->func
) {
1042 sdio_claim_host(card
->func
);
1043 sdio_release_irq(card
->func
);
1044 sdio_disable_func(card
->func
);
1045 sdio_release_host(card
->func
);
1046 sdio_set_drvdata(card
->func
, NULL
);
1052 static int btmrvl_sdio_enable_host_int(struct btmrvl_sdio_card
*card
)
1056 if (!card
|| !card
->func
)
1059 sdio_claim_host(card
->func
);
1061 ret
= btmrvl_sdio_enable_host_int_mask(card
, HIM_ENABLE
);
1063 btmrvl_sdio_get_rx_unit(card
);
1065 sdio_release_host(card
->func
);
1070 static int btmrvl_sdio_disable_host_int(struct btmrvl_sdio_card
*card
)
1074 if (!card
|| !card
->func
)
1077 sdio_claim_host(card
->func
);
1079 ret
= btmrvl_sdio_disable_host_int_mask(card
, HIM_DISABLE
);
1081 sdio_release_host(card
->func
);
1086 static int btmrvl_sdio_host_to_card(struct btmrvl_private
*priv
,
1087 u8
*payload
, u16 nb
)
1089 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
1094 void *tmpbuf
= NULL
;
1097 if (!card
|| !card
->func
) {
1098 BT_ERR("card or function is NULL!");
1102 blksz
= DIV_ROUND_UP(nb
, SDIO_BLOCK_SIZE
) * SDIO_BLOCK_SIZE
;
1105 if ((unsigned long) payload
& (BTSDIO_DMA_ALIGN
- 1) ||
1107 tmpbufsz
= ALIGN_SZ(blksz
, BTSDIO_DMA_ALIGN
) +
1109 tmpbuf
= kzalloc(tmpbufsz
, GFP_KERNEL
);
1112 buf
= (u8
*) ALIGN_ADDR(tmpbuf
, BTSDIO_DMA_ALIGN
);
1113 memcpy(buf
, payload
, nb
);
1116 sdio_claim_host(card
->func
);
1119 /* Transfer data to card */
1120 ret
= sdio_writesb(card
->func
, card
->ioport
, buf
,
1124 BT_ERR("i=%d writesb failed: %d", i
, ret
);
1125 BT_ERR("hex: %*ph", nb
, payload
);
1127 if (i
> MAX_WRITE_IOMEM_RETRY
)
1132 priv
->btmrvl_dev
.tx_dnld_rdy
= false;
1135 sdio_release_host(card
->func
);
1141 static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card
*card
)
1145 int pollnum
= MAX_POLL_TRIES
;
1147 if (!card
|| !card
->func
) {
1148 BT_ERR("card or function is NULL!");
1152 if (!btmrvl_sdio_verify_fw_download(card
, 1)) {
1153 BT_DBG("Firmware already downloaded!");
1157 sdio_claim_host(card
->func
);
1159 /* Check if other function driver is downloading the firmware */
1160 fws0
= sdio_readb(card
->func
, card
->reg
->card_fw_status0
, &ret
);
1162 BT_ERR("Failed to read FW downloading status!");
1167 BT_DBG("BT not the winner (%#x). Skip FW downloading", fws0
);
1169 /* Give other function more time to download the firmware */
1173 ret
= btmrvl_sdio_download_helper(card
);
1175 BT_ERR("Failed to download helper!");
1181 if (btmrvl_sdio_download_fw_w_helper(card
)) {
1182 BT_ERR("Failed to download firmware!");
1189 * winner or not, with this test the FW synchronizes when the
1190 * module can continue its initialization
1192 if (btmrvl_sdio_verify_fw_download(card
, pollnum
)) {
1193 BT_ERR("FW failed to be active in time!");
1198 sdio_release_host(card
->func
);
1203 sdio_release_host(card
->func
);
1207 static int btmrvl_sdio_wakeup_fw(struct btmrvl_private
*priv
)
1209 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
1212 if (!card
|| !card
->func
) {
1213 BT_ERR("card or function is NULL!");
1217 sdio_claim_host(card
->func
);
1219 sdio_writeb(card
->func
, HOST_POWER_UP
, card
->reg
->cfg
, &ret
);
1221 sdio_release_host(card
->func
);
1223 BT_DBG("wake up firmware");
1228 static void btmrvl_sdio_dump_regs(struct btmrvl_private
*priv
)
1230 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
1232 unsigned int reg
, reg_start
, reg_end
;
1233 char buf
[256], *ptr
;
1234 u8 loop
, func
, data
;
1237 btmrvl_sdio_wakeup_fw(priv
);
1238 sdio_claim_host(card
->func
);
1240 for (loop
= 0; loop
< MAX_LOOP
; loop
++) {
1241 memset(buf
, 0, sizeof(buf
));
1245 /* Read the registers of SDIO function0 */
1255 ptr
+= sprintf(ptr
, "SDIO Func%d (%#x-%#x): ",
1256 func
, reg_start
, reg_end
);
1257 for (reg
= reg_start
; reg
<= reg_end
; reg
++) {
1259 data
= sdio_f0_readb(card
->func
, reg
, &ret
);
1261 data
= sdio_readb(card
->func
, reg
, &ret
);
1264 ptr
+= sprintf(ptr
, "%02x ", data
);
1266 ptr
+= sprintf(ptr
, "ERR");
1274 sdio_release_host(card
->func
);
1277 /* This function read/write firmware */
1279 rdwr_status
btmrvl_sdio_rdwr_firmware(struct btmrvl_private
*priv
,
1282 struct btmrvl_sdio_card
*card
= priv
->btmrvl_dev
.card
;
1286 sdio_writeb(card
->func
, FW_DUMP_HOST_READY
, card
->reg
->fw_dump_ctrl
,
1290 BT_ERR("SDIO write err");
1291 return RDWR_STATUS_FAILURE
;
1294 for (tries
= 0; tries
< MAX_POLL_TRIES
; tries
++) {
1295 ctrl_data
= sdio_readb(card
->func
, card
->reg
->fw_dump_ctrl
,
1299 BT_ERR("SDIO read err");
1300 return RDWR_STATUS_FAILURE
;
1303 if (ctrl_data
== FW_DUMP_DONE
)
1305 if (doneflag
&& ctrl_data
== doneflag
)
1306 return RDWR_STATUS_DONE
;
1307 if (ctrl_data
!= FW_DUMP_HOST_READY
) {
1308 BT_INFO("The ctrl reg was changed, re-try again!");
1309 sdio_writeb(card
->func
, FW_DUMP_HOST_READY
,
1310 card
->reg
->fw_dump_ctrl
, &ret
);
1312 BT_ERR("SDIO write err");
1313 return RDWR_STATUS_FAILURE
;
1316 usleep_range(100, 200);
1319 if (ctrl_data
== FW_DUMP_HOST_READY
) {
1320 BT_ERR("Fail to pull ctrl_data");
1321 return RDWR_STATUS_FAILURE
;
1324 return RDWR_STATUS_SUCCESS
;
1327 /* This function dump sdio register and memory data */
1328 static void btmrvl_sdio_coredump(struct device
*dev
)
1330 struct sdio_func
*func
= dev_to_sdio_func(dev
);
1331 struct btmrvl_sdio_card
*card
;
1332 struct btmrvl_private
*priv
;
1334 unsigned int reg
, reg_start
, reg_end
;
1335 enum rdwr_status stat
;
1336 u8
*dbg_ptr
, *end_ptr
, *fw_dump_data
, *fw_dump_ptr
;
1337 u8 dump_num
= 0, idx
, i
, read_reg
, doneflag
= 0;
1338 u32 memory_size
, fw_dump_len
= 0;
1341 card
= sdio_get_drvdata(func
);
1344 /* dump sdio register first */
1345 btmrvl_sdio_dump_regs(priv
);
1347 if (!card
->supports_fw_dump
) {
1348 BT_ERR("Firmware dump not supported for this card!");
1352 for (idx
= 0; idx
< ARRAY_SIZE(mem_type_mapping_tbl
); idx
++) {
1353 struct memory_type_mapping
*entry
= &mem_type_mapping_tbl
[idx
];
1355 if (entry
->mem_ptr
) {
1356 vfree(entry
->mem_ptr
);
1357 entry
->mem_ptr
= NULL
;
1359 entry
->mem_size
= 0;
1362 btmrvl_sdio_wakeup_fw(priv
);
1363 sdio_claim_host(card
->func
);
1365 BT_INFO("== btmrvl firmware dump start ==");
1367 stat
= btmrvl_sdio_rdwr_firmware(priv
, doneflag
);
1368 if (stat
== RDWR_STATUS_FAILURE
)
1371 reg
= card
->reg
->fw_dump_start
;
1372 /* Read the number of the memories which will dump */
1373 dump_num
= sdio_readb(card
->func
, reg
, &ret
);
1376 BT_ERR("SDIO read memory length err");
1380 /* Read the length of every memory which will dump */
1381 for (idx
= 0; idx
< dump_num
; idx
++) {
1382 struct memory_type_mapping
*entry
= &mem_type_mapping_tbl
[idx
];
1384 stat
= btmrvl_sdio_rdwr_firmware(priv
, doneflag
);
1385 if (stat
== RDWR_STATUS_FAILURE
)
1389 reg
= card
->reg
->fw_dump_start
;
1390 for (i
= 0; i
< 4; i
++) {
1391 read_reg
= sdio_readb(card
->func
, reg
, &ret
);
1393 BT_ERR("SDIO read err");
1396 memory_size
|= (read_reg
<< i
*8);
1400 if (memory_size
== 0) {
1401 BT_INFO("Firmware dump finished!");
1402 sdio_writeb(card
->func
, FW_DUMP_READ_DONE
,
1403 card
->reg
->fw_dump_ctrl
, &ret
);
1405 BT_ERR("SDIO Write MEMDUMP_FINISH ERR");
1411 BT_INFO("%s_SIZE=0x%x", entry
->mem_name
, memory_size
);
1412 entry
->mem_ptr
= vzalloc(memory_size
+ 1);
1413 entry
->mem_size
= memory_size
;
1414 if (!entry
->mem_ptr
) {
1415 BT_ERR("Vzalloc %s failed", entry
->mem_name
);
1419 fw_dump_len
+= (strlen("========Start dump ") +
1420 strlen(entry
->mem_name
) +
1421 strlen("========\n") +
1423 strlen("\n========End dump========\n"));
1425 dbg_ptr
= entry
->mem_ptr
;
1426 end_ptr
= dbg_ptr
+ memory_size
;
1428 doneflag
= entry
->done_flag
;
1429 BT_INFO("Start %s output, please wait...",
1433 stat
= btmrvl_sdio_rdwr_firmware(priv
, doneflag
);
1434 if (stat
== RDWR_STATUS_FAILURE
)
1437 reg_start
= card
->reg
->fw_dump_start
;
1438 reg_end
= card
->reg
->fw_dump_end
;
1439 for (reg
= reg_start
; reg
<= reg_end
; reg
++) {
1440 *dbg_ptr
= sdio_readb(card
->func
, reg
, &ret
);
1442 BT_ERR("SDIO read err");
1445 if (dbg_ptr
< end_ptr
)
1448 BT_ERR("Allocated buffer not enough");
1451 if (stat
== RDWR_STATUS_DONE
) {
1452 BT_INFO("%s done: size=0x%tx",
1454 dbg_ptr
- entry
->mem_ptr
);
1460 BT_INFO("== btmrvl firmware dump end ==");
1463 sdio_release_host(card
->func
);
1465 if (fw_dump_len
== 0)
1468 fw_dump_data
= vzalloc(fw_dump_len
+ 1);
1469 if (!fw_dump_data
) {
1470 BT_ERR("Vzalloc fw_dump_data fail!");
1473 fw_dump_ptr
= fw_dump_data
;
1475 /* Dump all the memory data into single file, a userspace script will
1476 * be used to split all the memory data to multiple files
1478 BT_INFO("== btmrvl firmware dump to /sys/class/devcoredump start");
1479 for (idx
= 0; idx
< dump_num
; idx
++) {
1480 struct memory_type_mapping
*entry
= &mem_type_mapping_tbl
[idx
];
1482 if (entry
->mem_ptr
) {
1483 size
+= scnprintf(fw_dump_ptr
+ size
,
1484 fw_dump_len
+ 1 - size
,
1485 "========Start dump %s========\n",
1488 memcpy(fw_dump_ptr
+ size
, entry
->mem_ptr
,
1490 size
+= entry
->mem_size
;
1492 size
+= scnprintf(fw_dump_ptr
+ size
,
1493 fw_dump_len
+ 1 - size
,
1494 "\n========End dump========\n");
1496 vfree(mem_type_mapping_tbl
[idx
].mem_ptr
);
1497 mem_type_mapping_tbl
[idx
].mem_ptr
= NULL
;
1501 /* fw_dump_data will be free in device coredump release function
1504 dev_coredumpv(&card
->func
->dev
, fw_dump_data
, fw_dump_len
, GFP_KERNEL
);
1505 BT_INFO("== btmrvl firmware dump to /sys/class/devcoredump end");
1508 static int btmrvl_sdio_probe(struct sdio_func
*func
,
1509 const struct sdio_device_id
*id
)
1512 struct btmrvl_private
*priv
= NULL
;
1513 struct btmrvl_sdio_card
*card
= NULL
;
1515 BT_INFO("vendor=0x%x, device=0x%x, class=%d, fn=%d",
1516 id
->vendor
, id
->device
, id
->class, func
->num
);
1518 card
= devm_kzalloc(&func
->dev
, sizeof(*card
), GFP_KERNEL
);
1524 if (id
->driver_data
) {
1525 struct btmrvl_sdio_device
*data
= (void *) id
->driver_data
;
1526 card
->helper
= data
->helper
;
1527 card
->firmware
= data
->firmware
;
1528 card
->reg
= data
->reg
;
1529 card
->sd_blksz_fw_dl
= data
->sd_blksz_fw_dl
;
1530 card
->support_pscan_win_report
= data
->support_pscan_win_report
;
1531 card
->supports_fw_dump
= data
->supports_fw_dump
;
1534 if (btmrvl_sdio_register_dev(card
) < 0) {
1535 BT_ERR("Failed to register BT device!");
1539 /* Disable the interrupts on the card */
1540 btmrvl_sdio_disable_host_int(card
);
1542 if (btmrvl_sdio_download_fw(card
)) {
1543 BT_ERR("Downloading firmware failed!");
1548 btmrvl_sdio_enable_host_int(card
);
1550 /* Device tree node parsing and platform specific configuration*/
1551 btmrvl_sdio_probe_of(&func
->dev
, card
);
1553 priv
= btmrvl_add_card(card
);
1555 BT_ERR("Initializing card failed!");
1557 goto disable_host_int
;
1562 /* Initialize the interface specific function pointers */
1563 priv
->hw_host_to_card
= btmrvl_sdio_host_to_card
;
1564 priv
->hw_wakeup_firmware
= btmrvl_sdio_wakeup_fw
;
1565 priv
->hw_process_int_status
= btmrvl_sdio_process_int_status
;
1567 if (btmrvl_register_hdev(priv
)) {
1568 BT_ERR("Register hdev failed!");
1570 goto disable_host_int
;
1576 btmrvl_sdio_disable_host_int(card
);
1578 btmrvl_sdio_unregister_dev(card
);
1582 static void btmrvl_sdio_remove(struct sdio_func
*func
)
1584 struct btmrvl_sdio_card
*card
;
1587 card
= sdio_get_drvdata(func
);
1589 /* Send SHUTDOWN command & disable interrupt
1590 * if user removes the module.
1593 btmrvl_send_module_cfg_cmd(card
->priv
,
1594 MODULE_SHUTDOWN_REQ
);
1595 btmrvl_sdio_disable_host_int(card
);
1598 BT_DBG("unregister dev");
1599 card
->priv
->surprise_removed
= true;
1600 btmrvl_sdio_unregister_dev(card
);
1601 btmrvl_remove_card(card
->priv
);
1606 static int btmrvl_sdio_suspend(struct device
*dev
)
1608 struct sdio_func
*func
= dev_to_sdio_func(dev
);
1609 struct btmrvl_sdio_card
*card
;
1610 struct btmrvl_private
*priv
;
1611 mmc_pm_flag_t pm_flags
;
1612 struct hci_dev
*hcidev
;
1615 pm_flags
= sdio_get_host_pm_caps(func
);
1616 BT_DBG("%s: suspend: PM flags = 0x%x", sdio_func_id(func
),
1618 if (!(pm_flags
& MMC_PM_KEEP_POWER
)) {
1619 BT_ERR("%s: cannot remain alive while suspended",
1620 sdio_func_id(func
));
1623 card
= sdio_get_drvdata(func
);
1624 if (!card
|| !card
->priv
) {
1625 BT_ERR("card or priv structure is not valid");
1629 BT_ERR("sdio_func is not specified");
1633 /* Enable platform specific wakeup interrupt */
1634 if (card
->plt_wake_cfg
&& card
->plt_wake_cfg
->irq_bt
>= 0 &&
1635 device_may_wakeup(dev
)) {
1636 card
->plt_wake_cfg
->wake_by_bt
= false;
1637 enable_irq(card
->plt_wake_cfg
->irq_bt
);
1638 enable_irq_wake(card
->plt_wake_cfg
->irq_bt
);
1642 priv
->adapter
->is_suspending
= true;
1643 hcidev
= priv
->btmrvl_dev
.hcidev
;
1644 BT_DBG("%s: SDIO suspend", hcidev
->name
);
1645 hci_suspend_dev(hcidev
);
1647 if (priv
->adapter
->hs_state
!= HS_ACTIVATED
) {
1648 if (btmrvl_enable_hs(priv
)) {
1649 BT_ERR("HS not activated, suspend failed!");
1650 /* Disable platform specific wakeup interrupt */
1651 if (card
->plt_wake_cfg
&&
1652 card
->plt_wake_cfg
->irq_bt
>= 0 &&
1653 device_may_wakeup(dev
)) {
1654 disable_irq_wake(card
->plt_wake_cfg
->irq_bt
);
1655 disable_irq(card
->plt_wake_cfg
->irq_bt
);
1658 priv
->adapter
->is_suspending
= false;
1663 priv
->adapter
->is_suspending
= false;
1664 priv
->adapter
->is_suspended
= true;
1666 /* We will keep the power when hs enabled successfully */
1667 if (priv
->adapter
->hs_state
== HS_ACTIVATED
) {
1668 BT_DBG("suspend with MMC_PM_KEEP_POWER");
1669 return sdio_set_host_pm_flags(func
, MMC_PM_KEEP_POWER
);
1672 BT_DBG("suspend without MMC_PM_KEEP_POWER");
1676 static int btmrvl_sdio_resume(struct device
*dev
)
1678 struct sdio_func
*func
= dev_to_sdio_func(dev
);
1679 struct btmrvl_sdio_card
*card
;
1680 struct btmrvl_private
*priv
;
1681 mmc_pm_flag_t pm_flags
;
1682 struct hci_dev
*hcidev
;
1685 pm_flags
= sdio_get_host_pm_caps(func
);
1686 BT_DBG("%s: resume: PM flags = 0x%x", sdio_func_id(func
),
1688 card
= sdio_get_drvdata(func
);
1689 if (!card
|| !card
->priv
) {
1690 BT_ERR("card or priv structure is not valid");
1694 BT_ERR("sdio_func is not specified");
1699 if (!priv
->adapter
->is_suspended
) {
1700 BT_DBG("device already resumed");
1704 priv
->hw_wakeup_firmware(priv
);
1705 priv
->adapter
->hs_state
= HS_DEACTIVATED
;
1706 hcidev
= priv
->btmrvl_dev
.hcidev
;
1707 BT_DBG("%s: HS DEACTIVATED in resume!", hcidev
->name
);
1708 priv
->adapter
->is_suspended
= false;
1709 BT_DBG("%s: SDIO resume", hcidev
->name
);
1710 hci_resume_dev(hcidev
);
1712 /* Disable platform specific wakeup interrupt */
1713 if (card
->plt_wake_cfg
&& card
->plt_wake_cfg
->irq_bt
>= 0 &&
1714 device_may_wakeup(dev
)) {
1715 disable_irq_wake(card
->plt_wake_cfg
->irq_bt
);
1716 disable_irq(card
->plt_wake_cfg
->irq_bt
);
1717 if (card
->plt_wake_cfg
->wake_by_bt
)
1718 /* Undo our disable, since interrupt handler already
1721 enable_irq(card
->plt_wake_cfg
->irq_bt
);
1727 static const struct dev_pm_ops btmrvl_sdio_pm_ops
= {
1728 .suspend
= btmrvl_sdio_suspend
,
1729 .resume
= btmrvl_sdio_resume
,
1732 static struct sdio_driver bt_mrvl_sdio
= {
1733 .name
= "btmrvl_sdio",
1734 .id_table
= btmrvl_sdio_ids
,
1735 .probe
= btmrvl_sdio_probe
,
1736 .remove
= btmrvl_sdio_remove
,
1738 .coredump
= btmrvl_sdio_coredump
,
1739 .pm
= &btmrvl_sdio_pm_ops
,
1743 static int __init
btmrvl_sdio_init_module(void)
1745 if (sdio_register_driver(&bt_mrvl_sdio
) != 0) {
1746 BT_ERR("SDIO Driver Registration Failed");
1750 /* Clear the flag in case user removes the card. */
1756 static void __exit
btmrvl_sdio_exit_module(void)
1758 /* Set the flag as user is removing this module. */
1761 sdio_unregister_driver(&bt_mrvl_sdio
);
1764 module_init(btmrvl_sdio_init_module
);
1765 module_exit(btmrvl_sdio_exit_module
);
1767 MODULE_AUTHOR("Marvell International Ltd.");
1768 MODULE_DESCRIPTION("Marvell BT-over-SDIO driver ver " VERSION
);
1769 MODULE_VERSION(VERSION
);
1770 MODULE_LICENSE("GPL v2");
1771 MODULE_FIRMWARE("mrvl/sd8688_helper.bin");
1772 MODULE_FIRMWARE("mrvl/sd8688.bin");
1773 MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin");
1774 MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin");
1775 MODULE_FIRMWARE("mrvl/sd8887_uapsta.bin");
1776 MODULE_FIRMWARE("mrvl/sd8897_uapsta.bin");
1777 MODULE_FIRMWARE("mrvl/sdsd8977_combo_v2.bin");
1778 MODULE_FIRMWARE("mrvl/sd8987_uapsta.bin");
1779 MODULE_FIRMWARE("mrvl/sdsd8997_combo_v4.bin");