Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1 | /** |
| 2 | * Marvell BT-over-SDIO driver: SDIO interface related functions. |
| 3 | * |
| 4 | * Copyright (C) 2009, Marvell International Ltd. |
| 5 | * |
| 6 | * This software file (the "File") is distributed by Marvell International |
| 7 | * Ltd. under the terms of the GNU General Public License Version 2, June 1991 |
| 8 | * (the "License"). You may use, redistribute and/or modify this File in |
| 9 | * accordance with the terms and conditions of the License, a copy of which |
| 10 | * is available by writing to the Free Software Foundation, Inc., |
| 11 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA or on the |
| 12 | * worldwide web at http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. |
| 13 | * |
| 14 | * |
| 15 | * THE FILE IS DISTRIBUTED AS-IS, WITHOUT WARRANTY OF ANY KIND, AND THE |
| 16 | * IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE |
| 17 | * ARE EXPRESSLY DISCLAIMED. The License provides additional details about |
| 18 | * this warranty disclaimer. |
| 19 | **/ |
| 20 | |
Bing Zhao | 433a938 | 2013-11-01 15:28:24 -0700 | [diff] [blame] | 21 | #include <linux/firmware.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 22 | #include <linux/slab.h> |
Jeffy Chen | 17e41ea | 2017-02-24 14:24:30 +0800 | [diff] [blame] | 23 | #include <linux/suspend.h> |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 24 | |
| 25 | #include <linux/mmc/sdio_ids.h> |
| 26 | #include <linux/mmc/sdio_func.h> |
Paul Gortmaker | a59b968 | 2011-08-29 16:44:23 -0400 | [diff] [blame] | 27 | #include <linux/module.h> |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 28 | #include <linux/devcoredump.h> |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 29 | |
| 30 | #include <net/bluetooth/bluetooth.h> |
| 31 | #include <net/bluetooth/hci_core.h> |
| 32 | |
| 33 | #include "btmrvl_drv.h" |
| 34 | #include "btmrvl_sdio.h" |
| 35 | |
| 36 | #define VERSION "1.0" |
| 37 | |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 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}, |
| 54 | }; |
| 55 | |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 56 | static const struct of_device_id btmrvl_sdio_of_match_table[] = { |
| 57 | { .compatible = "marvell,sd8897-bt" }, |
| 58 | { .compatible = "marvell,sd8997-bt" }, |
| 59 | { } |
| 60 | }; |
| 61 | |
| 62 | static irqreturn_t btmrvl_wake_irq_bt(int irq, void *priv) |
| 63 | { |
Jeffy Chen | 17e41ea | 2017-02-24 14:24:30 +0800 | [diff] [blame] | 64 | struct btmrvl_sdio_card *card = priv; |
| 65 | struct btmrvl_plt_wake_cfg *cfg = card->plt_wake_cfg; |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 66 | |
Arvind Yadav | 24a3a32 | 2017-09-25 13:07:39 +0530 | [diff] [blame] | 67 | pr_info("%s: wake by bt\n", __func__); |
Xinming Hu | c8ba804 | 2017-03-31 14:32:32 +0800 | [diff] [blame] | 68 | cfg->wake_by_bt = true; |
| 69 | disable_irq_nosync(irq); |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 70 | |
Jeffy Chen | 17e41ea | 2017-02-24 14:24:30 +0800 | [diff] [blame] | 71 | pm_wakeup_event(&card->func->dev, 0); |
| 72 | pm_system_wakeup(); |
| 73 | |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 74 | return IRQ_HANDLED; |
| 75 | } |
| 76 | |
| 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. |
| 81 | */ |
| 82 | static int btmrvl_sdio_probe_of(struct device *dev, |
| 83 | struct btmrvl_sdio_card *card) |
| 84 | { |
| 85 | struct btmrvl_plt_wake_cfg *cfg; |
| 86 | int ret; |
| 87 | |
| 88 | if (!dev->of_node || |
| 89 | !of_match_node(btmrvl_sdio_of_match_table, dev->of_node)) { |
Arvind Yadav | 24a3a32 | 2017-09-25 13:07:39 +0530 | [diff] [blame] | 90 | pr_err("sdio platform data not available\n"); |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 91 | return -1; |
| 92 | } |
| 93 | |
| 94 | card->plt_of_node = dev->of_node; |
| 95 | |
| 96 | card->plt_wake_cfg = devm_kzalloc(dev, sizeof(*card->plt_wake_cfg), |
| 97 | GFP_KERNEL); |
| 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); |
| 101 | if (!cfg->irq_bt) { |
Arvind Yadav | 24a3a32 | 2017-09-25 13:07:39 +0530 | [diff] [blame] | 102 | dev_err(dev, "fail to parse irq_bt from device tree\n"); |
Jeffy Chen | fd1a88d | 2017-01-23 12:18:52 +0800 | [diff] [blame] | 103 | cfg->irq_bt = -1; |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 104 | } else { |
| 105 | ret = devm_request_irq(dev, cfg->irq_bt, |
| 106 | btmrvl_wake_irq_bt, |
Jeffy Chen | 17e41ea | 2017-02-24 14:24:30 +0800 | [diff] [blame] | 107 | 0, "bt_wake", card); |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 108 | if (ret) { |
| 109 | dev_err(dev, |
| 110 | "Failed to request irq_bt %d (%d)\n", |
| 111 | cfg->irq_bt, ret); |
| 112 | } |
| 113 | disable_irq(cfg->irq_bt); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | return 0; |
| 118 | } |
| 119 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 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 |
| 123 | * differently. |
| 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. |
| 128 | * |
| 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. |
| 133 | */ |
| 134 | static u8 user_rmmod; |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 135 | static u8 sdio_ireg; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 136 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 137 | static const struct btmrvl_sdio_card_reg btmrvl_reg_8688 = { |
| 138 | .cfg = 0x03, |
| 139 | .host_int_mask = 0x04, |
| 140 | .host_intstatus = 0x05, |
| 141 | .card_status = 0x20, |
| 142 | .sq_read_base_addr_a0 = 0x10, |
| 143 | .sq_read_base_addr_a1 = 0x11, |
| 144 | .card_fw_status0 = 0x40, |
| 145 | .card_fw_status1 = 0x41, |
| 146 | .card_rx_len = 0x42, |
| 147 | .card_rx_unit = 0x43, |
| 148 | .io_port_0 = 0x00, |
| 149 | .io_port_1 = 0x01, |
| 150 | .io_port_2 = 0x02, |
Bing Zhao | 0d36740 | 2014-03-28 14:54:39 -0700 | [diff] [blame] | 151 | .int_read_to_clear = false, |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 152 | }; |
Bing Zhao | 2ac654f | 2011-11-16 20:40:42 -0800 | [diff] [blame] | 153 | static const struct btmrvl_sdio_card_reg btmrvl_reg_87xx = { |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 154 | .cfg = 0x00, |
| 155 | .host_int_mask = 0x02, |
| 156 | .host_intstatus = 0x03, |
| 157 | .card_status = 0x30, |
| 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, |
| 163 | .card_rx_len = 0x62, |
| 164 | .card_rx_unit = 0x63, |
| 165 | .io_port_0 = 0x78, |
| 166 | .io_port_1 = 0x79, |
| 167 | .io_port_2 = 0x7a, |
Bing Zhao | 0d36740 | 2014-03-28 14:54:39 -0700 | [diff] [blame] | 168 | .int_read_to_clear = false, |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 169 | }; |
| 170 | |
Xinming Hu | 3907d55 | 2014-09-30 06:45:33 -0400 | [diff] [blame] | 171 | static const struct btmrvl_sdio_card_reg btmrvl_reg_8887 = { |
| 172 | .cfg = 0x00, |
| 173 | .host_int_mask = 0x08, |
| 174 | .host_intstatus = 0x0C, |
| 175 | .card_status = 0x5C, |
| 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, |
| 181 | .card_rx_len = 0x8A, |
| 182 | .card_rx_unit = 0x8B, |
| 183 | .io_port_0 = 0xE4, |
| 184 | .io_port_1 = 0xE5, |
| 185 | .io_port_2 = 0xE6, |
| 186 | .int_read_to_clear = true, |
| 187 | .host_int_rsr = 0x04, |
| 188 | .card_misc_cfg = 0xD8, |
| 189 | }; |
| 190 | |
Amitkumar Karwar | 1e3e492 | 2014-09-30 06:45:32 -0400 | [diff] [blame] | 191 | static const struct btmrvl_sdio_card_reg btmrvl_reg_8897 = { |
Bing Zhao | 22f2efe | 2013-05-13 18:15:32 -0700 | [diff] [blame] | 192 | .cfg = 0x00, |
| 193 | .host_int_mask = 0x02, |
| 194 | .host_intstatus = 0x03, |
| 195 | .card_status = 0x50, |
| 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, |
| 201 | .card_rx_len = 0xc2, |
| 202 | .card_rx_unit = 0xc3, |
| 203 | .io_port_0 = 0xd8, |
| 204 | .io_port_1 = 0xd9, |
| 205 | .io_port_2 = 0xda, |
Bing Zhao | 0d36740 | 2014-03-28 14:54:39 -0700 | [diff] [blame] | 206 | .int_read_to_clear = true, |
| 207 | .host_int_rsr = 0x01, |
| 208 | .card_misc_cfg = 0xcc, |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 209 | .fw_dump_ctrl = 0xe2, |
| 210 | .fw_dump_start = 0xe3, |
| 211 | .fw_dump_end = 0xea, |
Bing Zhao | 22f2efe | 2013-05-13 18:15:32 -0700 | [diff] [blame] | 212 | }; |
| 213 | |
Amitkumar Karwar | f0ef674 | 2015-09-21 03:06:42 -0700 | [diff] [blame] | 214 | static const struct btmrvl_sdio_card_reg btmrvl_reg_8997 = { |
| 215 | .cfg = 0x00, |
| 216 | .host_int_mask = 0x08, |
| 217 | .host_intstatus = 0x0c, |
| 218 | .card_status = 0x5c, |
| 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, |
| 224 | .card_rx_len = 0xea, |
| 225 | .card_rx_unit = 0xeb, |
| 226 | .io_port_0 = 0xe4, |
| 227 | .io_port_1 = 0xe5, |
| 228 | .io_port_2 = 0xe6, |
| 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, |
| 234 | .fw_dump_end = 0xf8, |
| 235 | }; |
| 236 | |
Paul Bolle | c675786 | 2011-10-05 14:56:46 +0200 | [diff] [blame] | 237 | static const struct btmrvl_sdio_device btmrvl_sdio_sd8688 = { |
Lubomir Rintel | 77189df | 2013-03-13 12:04:30 +0100 | [diff] [blame] | 238 | .helper = "mrvl/sd8688_helper.bin", |
| 239 | .firmware = "mrvl/sd8688.bin", |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 240 | .reg = &btmrvl_reg_8688, |
Bing Zhao | 4df82b5 | 2014-03-31 14:41:44 -0700 | [diff] [blame] | 241 | .support_pscan_win_report = false, |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 242 | .sd_blksz_fw_dl = 64, |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 243 | .supports_fw_dump = false, |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 244 | }; |
| 245 | |
| 246 | static const struct btmrvl_sdio_device btmrvl_sdio_sd8787 = { |
| 247 | .helper = NULL, |
| 248 | .firmware = "mrvl/sd8787_uapsta.bin", |
Bing Zhao | 2ac654f | 2011-11-16 20:40:42 -0800 | [diff] [blame] | 249 | .reg = &btmrvl_reg_87xx, |
Bing Zhao | 4df82b5 | 2014-03-31 14:41:44 -0700 | [diff] [blame] | 250 | .support_pscan_win_report = false, |
Bing Zhao | 2ac654f | 2011-11-16 20:40:42 -0800 | [diff] [blame] | 251 | .sd_blksz_fw_dl = 256, |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 252 | .supports_fw_dump = false, |
Bing Zhao | 2ac654f | 2011-11-16 20:40:42 -0800 | [diff] [blame] | 253 | }; |
| 254 | |
| 255 | static const struct btmrvl_sdio_device btmrvl_sdio_sd8797 = { |
| 256 | .helper = NULL, |
| 257 | .firmware = "mrvl/sd8797_uapsta.bin", |
| 258 | .reg = &btmrvl_reg_87xx, |
Bing Zhao | 4df82b5 | 2014-03-31 14:41:44 -0700 | [diff] [blame] | 259 | .support_pscan_win_report = false, |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 260 | .sd_blksz_fw_dl = 256, |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 261 | .supports_fw_dump = false, |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 262 | }; |
| 263 | |
Xinming Hu | 3907d55 | 2014-09-30 06:45:33 -0400 | [diff] [blame] | 264 | static const struct btmrvl_sdio_device btmrvl_sdio_sd8887 = { |
| 265 | .helper = NULL, |
| 266 | .firmware = "mrvl/sd8887_uapsta.bin", |
| 267 | .reg = &btmrvl_reg_8887, |
| 268 | .support_pscan_win_report = true, |
| 269 | .sd_blksz_fw_dl = 256, |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 270 | .supports_fw_dump = false, |
Xinming Hu | 3907d55 | 2014-09-30 06:45:33 -0400 | [diff] [blame] | 271 | }; |
| 272 | |
Bing Zhao | 22f2efe | 2013-05-13 18:15:32 -0700 | [diff] [blame] | 273 | static const struct btmrvl_sdio_device btmrvl_sdio_sd8897 = { |
| 274 | .helper = NULL, |
| 275 | .firmware = "mrvl/sd8897_uapsta.bin", |
Amitkumar Karwar | 1e3e492 | 2014-09-30 06:45:32 -0400 | [diff] [blame] | 276 | .reg = &btmrvl_reg_8897, |
Bing Zhao | 4df82b5 | 2014-03-31 14:41:44 -0700 | [diff] [blame] | 277 | .support_pscan_win_report = true, |
Bing Zhao | 22f2efe | 2013-05-13 18:15:32 -0700 | [diff] [blame] | 278 | .sd_blksz_fw_dl = 256, |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 279 | .supports_fw_dump = true, |
Bing Zhao | 22f2efe | 2013-05-13 18:15:32 -0700 | [diff] [blame] | 280 | }; |
| 281 | |
Amitkumar Karwar | f0ef674 | 2015-09-21 03:06:42 -0700 | [diff] [blame] | 282 | static const struct btmrvl_sdio_device btmrvl_sdio_sd8997 = { |
| 283 | .helper = NULL, |
| 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, |
| 289 | }; |
| 290 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 291 | static const struct sdio_device_id btmrvl_sdio_ids[] = { |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 292 | /* Marvell SD8688 Bluetooth device */ |
| 293 | { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9105), |
Amitkumar Karwar | 53d6cfa | 2015-09-21 03:06:41 -0700 | [diff] [blame] | 294 | .driver_data = (unsigned long)&btmrvl_sdio_sd8688 }, |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 295 | /* Marvell SD8787 Bluetooth device */ |
| 296 | { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x911A), |
Amitkumar Karwar | 53d6cfa | 2015-09-21 03:06:41 -0700 | [diff] [blame] | 297 | .driver_data = (unsigned long)&btmrvl_sdio_sd8787 }, |
Bing Zhao | 37ed561 | 2012-05-23 18:50:04 -0700 | [diff] [blame] | 298 | /* Marvell SD8787 Bluetooth AMP device */ |
| 299 | { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x911B), |
Amitkumar Karwar | 53d6cfa | 2015-09-21 03:06:41 -0700 | [diff] [blame] | 300 | .driver_data = (unsigned long)&btmrvl_sdio_sd8787 }, |
Bing Zhao | 2ac654f | 2011-11-16 20:40:42 -0800 | [diff] [blame] | 301 | /* Marvell SD8797 Bluetooth device */ |
| 302 | { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x912A), |
Amitkumar Karwar | 53d6cfa | 2015-09-21 03:06:41 -0700 | [diff] [blame] | 303 | .driver_data = (unsigned long)&btmrvl_sdio_sd8797 }, |
Xinming Hu | 3907d55 | 2014-09-30 06:45:33 -0400 | [diff] [blame] | 304 | /* Marvell SD8887 Bluetooth device */ |
| 305 | { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9136), |
| 306 | .driver_data = (unsigned long)&btmrvl_sdio_sd8887 }, |
Bing Zhao | 22f2efe | 2013-05-13 18:15:32 -0700 | [diff] [blame] | 307 | /* Marvell SD8897 Bluetooth device */ |
| 308 | { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x912E), |
Amitkumar Karwar | 53d6cfa | 2015-09-21 03:06:41 -0700 | [diff] [blame] | 309 | .driver_data = (unsigned long)&btmrvl_sdio_sd8897 }, |
Amitkumar Karwar | f0ef674 | 2015-09-21 03:06:42 -0700 | [diff] [blame] | 310 | /* Marvell SD8997 Bluetooth device */ |
| 311 | { SDIO_DEVICE(SDIO_VENDOR_ID_MARVELL, 0x9142), |
| 312 | .driver_data = (unsigned long)&btmrvl_sdio_sd8997 }, |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 313 | |
| 314 | { } /* Terminating entry */ |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 315 | }; |
| 316 | |
| 317 | MODULE_DEVICE_TABLE(sdio, btmrvl_sdio_ids); |
| 318 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 319 | static int btmrvl_sdio_get_rx_unit(struct btmrvl_sdio_card *card) |
| 320 | { |
| 321 | u8 reg; |
| 322 | int ret; |
| 323 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 324 | reg = sdio_readb(card->func, card->reg->card_rx_unit, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 325 | if (!ret) |
| 326 | card->rx_unit = reg; |
| 327 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 328 | return ret; |
| 329 | } |
| 330 | |
| 331 | static int btmrvl_sdio_read_fw_status(struct btmrvl_sdio_card *card, u16 *dat) |
| 332 | { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 333 | u8 fws0, fws1; |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 334 | int ret; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 335 | |
| 336 | *dat = 0; |
| 337 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 338 | fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret); |
Kulikov Vasiliy | 278be27 | 2010-07-05 12:01:22 +0400 | [diff] [blame] | 339 | if (ret) |
| 340 | return -EIO; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 341 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 342 | fws1 = sdio_readb(card->func, card->reg->card_fw_status1, &ret); |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 343 | if (ret) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 344 | return -EIO; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 345 | |
| 346 | *dat = (((u16) fws1) << 8) | fws0; |
| 347 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 348 | return 0; |
| 349 | } |
| 350 | |
| 351 | static int btmrvl_sdio_read_rx_len(struct btmrvl_sdio_card *card, u16 *dat) |
| 352 | { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 353 | u8 reg; |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 354 | int ret; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 355 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 356 | reg = sdio_readb(card->func, card->reg->card_rx_len, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 357 | if (!ret) |
| 358 | *dat = (u16) reg << card->rx_unit; |
| 359 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 360 | return ret; |
| 361 | } |
| 362 | |
| 363 | static int btmrvl_sdio_enable_host_int_mask(struct btmrvl_sdio_card *card, |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 364 | u8 mask) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 365 | { |
| 366 | int ret; |
| 367 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 368 | sdio_writeb(card->func, mask, card->reg->host_int_mask, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 369 | if (ret) { |
| 370 | BT_ERR("Unable to enable the host interrupt!"); |
| 371 | ret = -EIO; |
| 372 | } |
| 373 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 374 | return ret; |
| 375 | } |
| 376 | |
| 377 | static int btmrvl_sdio_disable_host_int_mask(struct btmrvl_sdio_card *card, |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 378 | u8 mask) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 379 | { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 380 | u8 host_int_mask; |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 381 | int ret; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 382 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 383 | host_int_mask = sdio_readb(card->func, card->reg->host_int_mask, &ret); |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 384 | if (ret) |
| 385 | return -EIO; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 386 | |
| 387 | host_int_mask &= ~mask; |
| 388 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 389 | sdio_writeb(card->func, host_int_mask, card->reg->host_int_mask, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 390 | if (ret < 0) { |
| 391 | BT_ERR("Unable to disable the host interrupt!"); |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 392 | return -EIO; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 393 | } |
| 394 | |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 395 | return 0; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 396 | } |
| 397 | |
| 398 | static int btmrvl_sdio_poll_card_status(struct btmrvl_sdio_card *card, u8 bits) |
| 399 | { |
| 400 | unsigned int tries; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 401 | u8 status; |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 402 | int ret; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 403 | |
| 404 | for (tries = 0; tries < MAX_POLL_TRIES * 1000; tries++) { |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 405 | status = sdio_readb(card->func, card->reg->card_status, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 406 | if (ret) |
| 407 | goto failed; |
| 408 | if ((status & bits) == bits) |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 409 | return ret; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 410 | |
| 411 | udelay(1); |
| 412 | } |
| 413 | |
| 414 | ret = -ETIMEDOUT; |
| 415 | |
| 416 | failed: |
| 417 | BT_ERR("FAILED! ret=%d", ret); |
| 418 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 419 | return ret; |
| 420 | } |
| 421 | |
| 422 | static int btmrvl_sdio_verify_fw_download(struct btmrvl_sdio_card *card, |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 423 | int pollnum) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 424 | { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 425 | u16 firmwarestat; |
Andreas Fenkart | 69676b1 | 2013-04-22 11:10:23 +0200 | [diff] [blame] | 426 | int tries, ret; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 427 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 428 | /* Wait for firmware to become ready */ |
| 429 | for (tries = 0; tries < pollnum; tries++) { |
Andreas Fenkart | c1c999e | 2013-04-22 11:10:22 +0200 | [diff] [blame] | 430 | sdio_claim_host(card->func); |
| 431 | ret = btmrvl_sdio_read_fw_status(card, &firmwarestat); |
| 432 | sdio_release_host(card->func); |
| 433 | if (ret < 0) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 434 | continue; |
| 435 | |
Andreas Fenkart | 69676b1 | 2013-04-22 11:10:23 +0200 | [diff] [blame] | 436 | if (firmwarestat == FIRMWARE_READY) |
| 437 | return 0; |
| 438 | |
Wei-Ning Huang | 9a01242 | 2016-03-08 11:40:06 +0800 | [diff] [blame] | 439 | msleep(100); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 440 | } |
| 441 | |
Andreas Fenkart | 69676b1 | 2013-04-22 11:10:23 +0200 | [diff] [blame] | 442 | return -ETIMEDOUT; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | static int btmrvl_sdio_download_helper(struct btmrvl_sdio_card *card) |
| 446 | { |
| 447 | const struct firmware *fw_helper = NULL; |
| 448 | const u8 *helper = NULL; |
| 449 | int ret; |
| 450 | void *tmphlprbuf = NULL; |
| 451 | int tmphlprbufsz, hlprblknow, helperlen; |
| 452 | u8 *helperbuf; |
| 453 | u32 tx_len; |
| 454 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 455 | ret = request_firmware(&fw_helper, card->helper, |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 456 | &card->func->dev); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 457 | if ((ret < 0) || !fw_helper) { |
| 458 | BT_ERR("request_firmware(helper) failed, error code = %d", |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 459 | ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 460 | ret = -ENOENT; |
| 461 | goto done; |
| 462 | } |
| 463 | |
| 464 | helper = fw_helper->data; |
| 465 | helperlen = fw_helper->size; |
| 466 | |
| 467 | BT_DBG("Downloading helper image (%d bytes), block size %d bytes", |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 468 | helperlen, SDIO_BLOCK_SIZE); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 469 | |
| 470 | tmphlprbufsz = ALIGN_SZ(BTM_UPLD_SIZE, BTSDIO_DMA_ALIGN); |
| 471 | |
Julia Lawall | f8df39f | 2010-05-13 22:02:03 +0200 | [diff] [blame] | 472 | tmphlprbuf = kzalloc(tmphlprbufsz, GFP_KERNEL); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 473 | if (!tmphlprbuf) { |
| 474 | BT_ERR("Unable to allocate buffer for helper." |
| 475 | " Terminating download"); |
| 476 | ret = -ENOMEM; |
| 477 | goto done; |
| 478 | } |
| 479 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 480 | helperbuf = (u8 *) ALIGN_ADDR(tmphlprbuf, BTSDIO_DMA_ALIGN); |
| 481 | |
| 482 | /* Perform helper data transfer */ |
| 483 | tx_len = (FIRMWARE_TRANSFER_NBLOCK * SDIO_BLOCK_SIZE) |
| 484 | - SDIO_HEADER_LEN; |
| 485 | hlprblknow = 0; |
| 486 | |
| 487 | do { |
| 488 | ret = btmrvl_sdio_poll_card_status(card, |
| 489 | CARD_IO_READY | DN_LD_CARD_RDY); |
| 490 | if (ret < 0) { |
| 491 | BT_ERR("Helper download poll status timeout @ %d", |
| 492 | hlprblknow); |
| 493 | goto done; |
| 494 | } |
| 495 | |
| 496 | /* Check if there is more data? */ |
| 497 | if (hlprblknow >= helperlen) |
| 498 | break; |
| 499 | |
| 500 | if (helperlen - hlprblknow < tx_len) |
| 501 | tx_len = helperlen - hlprblknow; |
| 502 | |
| 503 | /* Little-endian */ |
| 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); |
| 508 | |
| 509 | memcpy(&helperbuf[SDIO_HEADER_LEN], &helper[hlprblknow], |
| 510 | tx_len); |
| 511 | |
| 512 | /* Now send the data */ |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 513 | ret = sdio_writesb(card->func, card->ioport, helperbuf, |
| 514 | FIRMWARE_TRANSFER_NBLOCK * SDIO_BLOCK_SIZE); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 515 | if (ret < 0) { |
| 516 | BT_ERR("IO error during helper download @ %d", |
| 517 | hlprblknow); |
| 518 | goto done; |
| 519 | } |
| 520 | |
| 521 | hlprblknow += tx_len; |
| 522 | } while (true); |
| 523 | |
| 524 | BT_DBG("Transferring helper image EOF block"); |
| 525 | |
| 526 | memset(helperbuf, 0x0, SDIO_BLOCK_SIZE); |
| 527 | |
| 528 | ret = sdio_writesb(card->func, card->ioport, helperbuf, |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 529 | SDIO_BLOCK_SIZE); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 530 | if (ret < 0) { |
| 531 | BT_ERR("IO error in writing helper image EOF block"); |
| 532 | goto done; |
| 533 | } |
| 534 | |
| 535 | ret = 0; |
| 536 | |
| 537 | done: |
| 538 | kfree(tmphlprbuf); |
Jesper Juhl | 59f34fb | 2012-04-09 22:49:49 +0200 | [diff] [blame] | 539 | release_firmware(fw_helper); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 540 | return ret; |
| 541 | } |
| 542 | |
| 543 | static int btmrvl_sdio_download_fw_w_helper(struct btmrvl_sdio_card *card) |
| 544 | { |
| 545 | const struct firmware *fw_firmware = NULL; |
| 546 | const u8 *firmware = NULL; |
| 547 | int firmwarelen, tmpfwbufsz, ret; |
| 548 | unsigned int tries, offset; |
| 549 | u8 base0, base1; |
| 550 | void *tmpfwbuf = NULL; |
| 551 | u8 *fwbuf; |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 552 | u16 len, blksz_dl = card->sd_blksz_fw_dl; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 553 | int txlen = 0, tx_blocks = 0, count = 0; |
| 554 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 555 | ret = request_firmware(&fw_firmware, card->firmware, |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 556 | &card->func->dev); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 557 | if ((ret < 0) || !fw_firmware) { |
| 558 | BT_ERR("request_firmware(firmware) failed, error code = %d", |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 559 | ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 560 | ret = -ENOENT; |
| 561 | goto done; |
| 562 | } |
| 563 | |
| 564 | firmware = fw_firmware->data; |
| 565 | firmwarelen = fw_firmware->size; |
| 566 | |
| 567 | BT_DBG("Downloading FW image (%d bytes)", firmwarelen); |
| 568 | |
| 569 | tmpfwbufsz = ALIGN_SZ(BTM_UPLD_SIZE, BTSDIO_DMA_ALIGN); |
Julia Lawall | f8df39f | 2010-05-13 22:02:03 +0200 | [diff] [blame] | 570 | tmpfwbuf = kzalloc(tmpfwbufsz, GFP_KERNEL); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 571 | if (!tmpfwbuf) { |
| 572 | BT_ERR("Unable to allocate buffer for firmware." |
| 573 | " Terminating download"); |
| 574 | ret = -ENOMEM; |
| 575 | goto done; |
| 576 | } |
| 577 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 578 | /* Ensure aligned firmware buffer */ |
| 579 | fwbuf = (u8 *) ALIGN_ADDR(tmpfwbuf, BTSDIO_DMA_ALIGN); |
| 580 | |
| 581 | /* Perform firmware data transfer */ |
| 582 | offset = 0; |
| 583 | do { |
| 584 | ret = btmrvl_sdio_poll_card_status(card, |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 585 | CARD_IO_READY | DN_LD_CARD_RDY); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 586 | if (ret < 0) { |
| 587 | BT_ERR("FW download with helper poll status" |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 588 | " timeout @ %d", offset); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 589 | goto done; |
| 590 | } |
| 591 | |
| 592 | /* Check if there is more data ? */ |
| 593 | if (offset >= firmwarelen) |
| 594 | break; |
| 595 | |
| 596 | for (tries = 0; tries < MAX_POLL_TRIES; tries++) { |
| 597 | base0 = sdio_readb(card->func, |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 598 | card->reg->sq_read_base_addr_a0, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 599 | if (ret) { |
| 600 | BT_ERR("BASE0 register read failed:" |
| 601 | " base0 = 0x%04X(%d)." |
| 602 | " Terminating download", |
| 603 | base0, base0); |
| 604 | ret = -EIO; |
| 605 | goto done; |
| 606 | } |
| 607 | base1 = sdio_readb(card->func, |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 608 | card->reg->sq_read_base_addr_a1, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 609 | if (ret) { |
| 610 | BT_ERR("BASE1 register read failed:" |
| 611 | " base1 = 0x%04X(%d)." |
| 612 | " Terminating download", |
| 613 | base1, base1); |
| 614 | ret = -EIO; |
| 615 | goto done; |
| 616 | } |
| 617 | |
| 618 | len = (((u16) base1) << 8) | base0; |
| 619 | if (len) |
| 620 | break; |
| 621 | |
| 622 | udelay(10); |
| 623 | } |
| 624 | |
| 625 | if (!len) |
| 626 | break; |
| 627 | else if (len > BTM_UPLD_SIZE) { |
| 628 | BT_ERR("FW download failure @%d, invalid length %d", |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 629 | offset, len); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 630 | ret = -EINVAL; |
| 631 | goto done; |
| 632 | } |
| 633 | |
| 634 | txlen = len; |
| 635 | |
| 636 | if (len & BIT(0)) { |
| 637 | count++; |
| 638 | if (count > MAX_WRITE_IOMEM_RETRY) { |
| 639 | BT_ERR("FW download failure @%d, " |
| 640 | "over max retry count", offset); |
| 641 | ret = -EIO; |
| 642 | goto done; |
| 643 | } |
| 644 | BT_ERR("FW CRC error indicated by the helper: " |
| 645 | "len = 0x%04X, txlen = %d", len, txlen); |
| 646 | len &= ~BIT(0); |
| 647 | /* Set txlen to 0 so as to resend from same offset */ |
| 648 | txlen = 0; |
| 649 | } else { |
| 650 | count = 0; |
| 651 | |
| 652 | /* Last block ? */ |
| 653 | if (firmwarelen - offset < txlen) |
| 654 | txlen = firmwarelen - offset; |
| 655 | |
Andy Shevchenko | ba34dd3 | 2013-08-02 14:10:12 +0300 | [diff] [blame] | 656 | tx_blocks = DIV_ROUND_UP(txlen, blksz_dl); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 657 | |
| 658 | memcpy(fwbuf, &firmware[offset], txlen); |
| 659 | } |
| 660 | |
| 661 | ret = sdio_writesb(card->func, card->ioport, fwbuf, |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 662 | tx_blocks * blksz_dl); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 663 | |
| 664 | if (ret < 0) { |
| 665 | BT_ERR("FW download, writesb(%d) failed @%d", |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 666 | count, offset); |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 667 | sdio_writeb(card->func, HOST_CMD53_FIN, |
| 668 | card->reg->cfg, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 669 | if (ret) |
| 670 | BT_ERR("writeb failed (CFG)"); |
| 671 | } |
| 672 | |
| 673 | offset += txlen; |
| 674 | } while (true); |
| 675 | |
Amitkumar Karwar | 1c6098e | 2015-01-01 00:13:42 -0800 | [diff] [blame] | 676 | BT_INFO("FW download over, size %d bytes", offset); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 677 | |
| 678 | ret = 0; |
| 679 | |
| 680 | done: |
| 681 | kfree(tmpfwbuf); |
Jesper Juhl | 59f34fb | 2012-04-09 22:49:49 +0200 | [diff] [blame] | 682 | release_firmware(fw_firmware); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 683 | return ret; |
| 684 | } |
| 685 | |
| 686 | static int btmrvl_sdio_card_to_host(struct btmrvl_private *priv) |
| 687 | { |
| 688 | u16 buf_len = 0; |
Andrei Emeltchenko | 4263280 | 2012-09-28 14:36:08 +0300 | [diff] [blame] | 689 | int ret, num_blocks, blksz; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 690 | struct sk_buff *skb = NULL; |
| 691 | u32 type; |
Markus Elfring | 9376e4a | 2018-03-12 11:15:59 +0100 | [diff] [blame] | 692 | u8 *payload; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 693 | struct hci_dev *hdev = priv->btmrvl_dev.hcidev; |
| 694 | struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; |
| 695 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 696 | if (!card || !card->func) { |
| 697 | BT_ERR("card or function is NULL!"); |
| 698 | ret = -EINVAL; |
| 699 | goto exit; |
| 700 | } |
| 701 | |
| 702 | /* Read the length of data to be transferred */ |
| 703 | ret = btmrvl_sdio_read_rx_len(card, &buf_len); |
| 704 | if (ret < 0) { |
| 705 | BT_ERR("read rx_len failed"); |
| 706 | ret = -EIO; |
| 707 | goto exit; |
| 708 | } |
| 709 | |
| 710 | blksz = SDIO_BLOCK_SIZE; |
Andrei Emeltchenko | e678bad | 2012-09-28 14:36:09 +0300 | [diff] [blame] | 711 | num_blocks = DIV_ROUND_UP(buf_len, blksz); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 712 | |
| 713 | if (buf_len <= SDIO_HEADER_LEN |
Andrei Emeltchenko | 4263280 | 2012-09-28 14:36:08 +0300 | [diff] [blame] | 714 | || (num_blocks * blksz) > ALLOC_BUF_SIZE) { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 715 | BT_ERR("invalid packet length: %d", buf_len); |
| 716 | ret = -EINVAL; |
| 717 | goto exit; |
| 718 | } |
| 719 | |
| 720 | /* Allocate buffer */ |
Andrei Emeltchenko | 4263280 | 2012-09-28 14:36:08 +0300 | [diff] [blame] | 721 | skb = bt_skb_alloc(num_blocks * blksz + BTSDIO_DMA_ALIGN, GFP_ATOMIC); |
Prasanna Karthik | 1f438c6 | 2015-09-25 09:03:14 +0000 | [diff] [blame] | 722 | if (!skb) { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 723 | BT_ERR("No free skb"); |
Wei Yongjun | 6ea81c4 | 2013-06-05 10:16:55 +0800 | [diff] [blame] | 724 | ret = -ENOMEM; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 725 | goto exit; |
| 726 | } |
| 727 | |
Bing Zhao | 3318b23 | 2009-07-08 11:44:14 -0700 | [diff] [blame] | 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)); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 733 | } |
| 734 | |
Bing Zhao | 3318b23 | 2009-07-08 11:44:14 -0700 | [diff] [blame] | 735 | payload = skb->data; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 736 | |
| 737 | ret = sdio_readsb(card->func, payload, card->ioport, |
Andrei Emeltchenko | 4263280 | 2012-09-28 14:36:08 +0300 | [diff] [blame] | 738 | num_blocks * blksz); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 739 | if (ret < 0) { |
| 740 | BT_ERR("readsb failed: %d", ret); |
| 741 | ret = -EIO; |
| 742 | goto exit; |
| 743 | } |
| 744 | |
| 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) |
| 747 | */ |
| 748 | |
| 749 | buf_len = payload[0]; |
Andrei Emeltchenko | 9cb23dd | 2012-09-28 14:36:10 +0300 | [diff] [blame] | 750 | buf_len |= payload[1] << 8; |
| 751 | buf_len |= payload[2] << 16; |
| 752 | |
| 753 | if (buf_len > blksz * num_blocks) { |
| 754 | BT_ERR("Skip incorrect packet: hdrlen %d buffer %d", |
| 755 | buf_len, blksz * num_blocks); |
| 756 | ret = -EIO; |
| 757 | goto exit; |
| 758 | } |
| 759 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 760 | type = payload[3]; |
| 761 | |
| 762 | switch (type) { |
| 763 | case HCI_ACLDATA_PKT: |
| 764 | case HCI_SCODATA_PKT: |
| 765 | case HCI_EVENT_PKT: |
Marcel Holtmann | 618e8bc | 2015-11-05 07:33:56 +0100 | [diff] [blame] | 766 | hci_skb_pkt_type(skb) = type; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 767 | skb_put(skb, buf_len); |
| 768 | skb_pull(skb, SDIO_HEADER_LEN); |
| 769 | |
Andrei Emeltchenko | ea1e76a | 2012-06-13 13:35:44 +0300 | [diff] [blame] | 770 | if (type == HCI_EVENT_PKT) { |
| 771 | if (btmrvl_check_evtpkt(priv, skb)) |
Marcel Holtmann | e1a2617 | 2013-10-10 16:52:43 -0700 | [diff] [blame] | 772 | hci_recv_frame(hdev, skb); |
Andrei Emeltchenko | 2c2453f | 2012-07-09 13:57:18 +0300 | [diff] [blame] | 773 | } else { |
Marcel Holtmann | e1a2617 | 2013-10-10 16:52:43 -0700 | [diff] [blame] | 774 | hci_recv_frame(hdev, skb); |
Andrei Emeltchenko | 2c2453f | 2012-07-09 13:57:18 +0300 | [diff] [blame] | 775 | } |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 776 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 777 | hdev->stat.byte_rx += buf_len; |
| 778 | break; |
| 779 | |
| 780 | case MRVL_VENDOR_PKT: |
Marcel Holtmann | 618e8bc | 2015-11-05 07:33:56 +0100 | [diff] [blame] | 781 | hci_skb_pkt_type(skb) = HCI_VENDOR_PKT; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 782 | skb_put(skb, buf_len); |
| 783 | skb_pull(skb, SDIO_HEADER_LEN); |
| 784 | |
| 785 | if (btmrvl_process_event(priv, skb)) |
Marcel Holtmann | e1a2617 | 2013-10-10 16:52:43 -0700 | [diff] [blame] | 786 | hci_recv_frame(hdev, skb); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 787 | |
| 788 | hdev->stat.byte_rx += buf_len; |
| 789 | break; |
| 790 | |
| 791 | default: |
André Goddard Rosa | af901ca | 2009-11-14 13:09:05 -0200 | [diff] [blame] | 792 | BT_ERR("Unknown packet type:%d", type); |
Andrei Emeltchenko | 78c1b8e | 2012-10-10 17:41:33 +0300 | [diff] [blame] | 793 | BT_ERR("hex: %*ph", blksz * num_blocks, payload); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 794 | |
| 795 | kfree_skb(skb); |
| 796 | skb = NULL; |
| 797 | break; |
| 798 | } |
| 799 | |
| 800 | exit: |
| 801 | if (ret) { |
| 802 | hdev->stat.err_rx++; |
Wei Yongjun | 7923296 | 2012-08-28 21:12:48 +0800 | [diff] [blame] | 803 | kfree_skb(skb); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 804 | } |
| 805 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 806 | return ret; |
| 807 | } |
| 808 | |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 809 | static int btmrvl_sdio_process_int_status(struct btmrvl_private *priv) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 810 | { |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 811 | ulong flags; |
| 812 | u8 ireg; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 813 | struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; |
| 814 | |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 815 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 816 | ireg = sdio_ireg; |
| 817 | sdio_ireg = 0; |
| 818 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 819 | |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 820 | sdio_claim_host(card->func); |
| 821 | if (ireg & DN_LD_HOST_INT_STATUS) { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 822 | if (priv->btmrvl_dev.tx_dnld_rdy) |
| 823 | BT_DBG("tx_done already received: " |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 824 | " int_status=0x%x", ireg); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 825 | else |
| 826 | priv->btmrvl_dev.tx_dnld_rdy = true; |
| 827 | } |
| 828 | |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 829 | if (ireg & UP_LD_HOST_INT_STATUS) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 830 | btmrvl_sdio_card_to_host(priv); |
| 831 | |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 832 | sdio_release_host(card->func); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 833 | |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 834 | return 0; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 835 | } |
| 836 | |
Bing Zhao | 0d36740 | 2014-03-28 14:54:39 -0700 | [diff] [blame] | 837 | static int btmrvl_sdio_read_to_clear(struct btmrvl_sdio_card *card, u8 *ireg) |
| 838 | { |
| 839 | struct btmrvl_adapter *adapter = card->priv->adapter; |
| 840 | int ret; |
| 841 | |
| 842 | ret = sdio_readsb(card->func, adapter->hw_regs, 0, SDIO_BLOCK_SIZE); |
| 843 | if (ret) { |
| 844 | BT_ERR("sdio_readsb: read int hw_regs failed: %d", ret); |
| 845 | return ret; |
| 846 | } |
| 847 | |
| 848 | *ireg = adapter->hw_regs[card->reg->host_intstatus]; |
| 849 | BT_DBG("hw_regs[%#x]=%#x", card->reg->host_intstatus, *ireg); |
| 850 | |
| 851 | return 0; |
| 852 | } |
| 853 | |
Bing Zhao | 8af4840 | 2014-03-27 21:30:42 -0700 | [diff] [blame] | 854 | static int btmrvl_sdio_write_to_clear(struct btmrvl_sdio_card *card, u8 *ireg) |
| 855 | { |
| 856 | int ret; |
| 857 | |
| 858 | *ireg = sdio_readb(card->func, card->reg->host_intstatus, &ret); |
| 859 | if (ret) { |
| 860 | BT_ERR("sdio_readb: read int status failed: %d", ret); |
| 861 | return ret; |
| 862 | } |
| 863 | |
| 864 | if (*ireg) { |
| 865 | /* |
| 866 | * DN_LD_HOST_INT_STATUS and/or UP_LD_HOST_INT_STATUS |
| 867 | * Clear the interrupt status register and re-enable the |
| 868 | * interrupt. |
| 869 | */ |
| 870 | BT_DBG("int_status = 0x%x", *ireg); |
| 871 | |
| 872 | sdio_writeb(card->func, ~(*ireg) & (DN_LD_HOST_INT_STATUS | |
| 873 | UP_LD_HOST_INT_STATUS), |
| 874 | card->reg->host_intstatus, &ret); |
| 875 | if (ret) { |
| 876 | BT_ERR("sdio_writeb: clear int status failed: %d", ret); |
| 877 | return ret; |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | return 0; |
| 882 | } |
| 883 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 884 | static void btmrvl_sdio_interrupt(struct sdio_func *func) |
| 885 | { |
| 886 | struct btmrvl_private *priv; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 887 | struct btmrvl_sdio_card *card; |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 888 | ulong flags; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 889 | u8 ireg = 0; |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 890 | int ret; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 891 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 892 | card = sdio_get_drvdata(func); |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 893 | if (!card || !card->priv) { |
Amitkumar Karwar | 7365d47 | 2014-11-24 02:40:52 -0800 | [diff] [blame] | 894 | BT_ERR("sbi_interrupt(%p) card or priv is NULL, card=%p", |
| 895 | func, card); |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 896 | return; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 897 | } |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 898 | |
| 899 | priv = card->priv; |
| 900 | |
Amitkumar Karwar | 7b4b874 | 2015-01-01 00:13:41 -0800 | [diff] [blame] | 901 | if (priv->surprise_removed) |
| 902 | return; |
| 903 | |
Bing Zhao | 0d36740 | 2014-03-28 14:54:39 -0700 | [diff] [blame] | 904 | if (card->reg->int_read_to_clear) |
| 905 | ret = btmrvl_sdio_read_to_clear(card, &ireg); |
| 906 | else |
| 907 | ret = btmrvl_sdio_write_to_clear(card, &ireg); |
| 908 | |
Bing Zhao | 8af4840 | 2014-03-27 21:30:42 -0700 | [diff] [blame] | 909 | if (ret) |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 910 | return; |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 911 | |
| 912 | spin_lock_irqsave(&priv->driver_lock, flags); |
| 913 | sdio_ireg |= ireg; |
| 914 | spin_unlock_irqrestore(&priv->driver_lock, flags); |
| 915 | |
| 916 | btmrvl_interrupt(priv); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 917 | } |
| 918 | |
| 919 | static int btmrvl_sdio_register_dev(struct btmrvl_sdio_card *card) |
| 920 | { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 921 | struct sdio_func *func; |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 922 | u8 reg; |
Markus Elfring | a5c2f4c | 2018-03-12 10:20:04 +0100 | [diff] [blame] | 923 | int ret; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 924 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 925 | if (!card || !card->func) { |
| 926 | BT_ERR("Error: card or function is NULL!"); |
| 927 | ret = -EINVAL; |
| 928 | goto failed; |
| 929 | } |
| 930 | |
| 931 | func = card->func; |
| 932 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 933 | sdio_claim_host(func); |
| 934 | |
| 935 | ret = sdio_enable_func(func); |
| 936 | if (ret) { |
| 937 | BT_ERR("sdio_enable_func() failed: ret=%d", ret); |
| 938 | ret = -EIO; |
| 939 | goto release_host; |
| 940 | } |
| 941 | |
| 942 | ret = sdio_claim_irq(func, btmrvl_sdio_interrupt); |
| 943 | if (ret) { |
| 944 | BT_ERR("sdio_claim_irq failed: ret=%d", ret); |
| 945 | ret = -EIO; |
| 946 | goto disable_func; |
| 947 | } |
| 948 | |
| 949 | ret = sdio_set_block_size(card->func, SDIO_BLOCK_SIZE); |
| 950 | if (ret) { |
| 951 | BT_ERR("cannot set SDIO block size"); |
| 952 | ret = -EIO; |
| 953 | goto release_irq; |
| 954 | } |
| 955 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 956 | reg = sdio_readb(func, card->reg->io_port_0, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 957 | if (ret < 0) { |
| 958 | ret = -EIO; |
| 959 | goto release_irq; |
| 960 | } |
| 961 | |
| 962 | card->ioport = reg; |
| 963 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 964 | reg = sdio_readb(func, card->reg->io_port_1, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 965 | if (ret < 0) { |
| 966 | ret = -EIO; |
| 967 | goto release_irq; |
| 968 | } |
| 969 | |
| 970 | card->ioport |= (reg << 8); |
| 971 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 972 | reg = sdio_readb(func, card->reg->io_port_2, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 973 | if (ret < 0) { |
| 974 | ret = -EIO; |
| 975 | goto release_irq; |
| 976 | } |
| 977 | |
| 978 | card->ioport |= (reg << 16); |
| 979 | |
| 980 | BT_DBG("SDIO FUNC%d IO port: 0x%x", func->num, card->ioport); |
| 981 | |
Bing Zhao | 0d36740 | 2014-03-28 14:54:39 -0700 | [diff] [blame] | 982 | if (card->reg->int_read_to_clear) { |
| 983 | reg = sdio_readb(func, card->reg->host_int_rsr, &ret); |
| 984 | if (ret < 0) { |
| 985 | ret = -EIO; |
| 986 | goto release_irq; |
| 987 | } |
| 988 | sdio_writeb(func, reg | 0x3f, card->reg->host_int_rsr, &ret); |
| 989 | if (ret < 0) { |
| 990 | ret = -EIO; |
| 991 | goto release_irq; |
| 992 | } |
| 993 | |
| 994 | reg = sdio_readb(func, card->reg->card_misc_cfg, &ret); |
| 995 | if (ret < 0) { |
| 996 | ret = -EIO; |
| 997 | goto release_irq; |
| 998 | } |
| 999 | sdio_writeb(func, reg | 0x10, card->reg->card_misc_cfg, &ret); |
| 1000 | if (ret < 0) { |
| 1001 | ret = -EIO; |
| 1002 | goto release_irq; |
| 1003 | } |
| 1004 | } |
| 1005 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1006 | sdio_set_drvdata(func, card); |
| 1007 | |
| 1008 | sdio_release_host(func); |
| 1009 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1010 | return 0; |
| 1011 | |
| 1012 | release_irq: |
| 1013 | sdio_release_irq(func); |
| 1014 | |
| 1015 | disable_func: |
| 1016 | sdio_disable_func(func); |
| 1017 | |
| 1018 | release_host: |
| 1019 | sdio_release_host(func); |
| 1020 | |
| 1021 | failed: |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1022 | return ret; |
| 1023 | } |
| 1024 | |
| 1025 | static int btmrvl_sdio_unregister_dev(struct btmrvl_sdio_card *card) |
| 1026 | { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 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); |
| 1033 | } |
| 1034 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1035 | return 0; |
| 1036 | } |
| 1037 | |
| 1038 | static int btmrvl_sdio_enable_host_int(struct btmrvl_sdio_card *card) |
| 1039 | { |
| 1040 | int ret; |
| 1041 | |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 1042 | if (!card || !card->func) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1043 | return -EINVAL; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1044 | |
| 1045 | sdio_claim_host(card->func); |
| 1046 | |
| 1047 | ret = btmrvl_sdio_enable_host_int_mask(card, HIM_ENABLE); |
| 1048 | |
| 1049 | btmrvl_sdio_get_rx_unit(card); |
| 1050 | |
| 1051 | sdio_release_host(card->func); |
| 1052 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1053 | return ret; |
| 1054 | } |
| 1055 | |
| 1056 | static int btmrvl_sdio_disable_host_int(struct btmrvl_sdio_card *card) |
| 1057 | { |
| 1058 | int ret; |
| 1059 | |
Marcel Holtmann | 9374253 | 2009-06-13 07:40:18 +0200 | [diff] [blame] | 1060 | if (!card || !card->func) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1061 | return -EINVAL; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1062 | |
| 1063 | sdio_claim_host(card->func); |
| 1064 | |
| 1065 | ret = btmrvl_sdio_disable_host_int_mask(card, HIM_DISABLE); |
| 1066 | |
| 1067 | sdio_release_host(card->func); |
| 1068 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1069 | return ret; |
| 1070 | } |
| 1071 | |
| 1072 | static int btmrvl_sdio_host_to_card(struct btmrvl_private *priv, |
| 1073 | u8 *payload, u16 nb) |
| 1074 | { |
| 1075 | struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; |
| 1076 | int ret = 0; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1077 | int blksz; |
| 1078 | int i = 0; |
| 1079 | u8 *buf = NULL; |
| 1080 | void *tmpbuf = NULL; |
| 1081 | int tmpbufsz; |
| 1082 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1083 | if (!card || !card->func) { |
| 1084 | BT_ERR("card or function is NULL!"); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1085 | return -EINVAL; |
| 1086 | } |
| 1087 | |
Ricky Liang | d2f3024 | 2016-06-28 15:06:57 +0800 | [diff] [blame] | 1088 | blksz = DIV_ROUND_UP(nb, SDIO_BLOCK_SIZE) * SDIO_BLOCK_SIZE; |
| 1089 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1090 | buf = payload; |
Ricky Liang | d2f3024 | 2016-06-28 15:06:57 +0800 | [diff] [blame] | 1091 | if ((unsigned long) payload & (BTSDIO_DMA_ALIGN - 1) || |
| 1092 | nb < blksz) { |
| 1093 | tmpbufsz = ALIGN_SZ(blksz, BTSDIO_DMA_ALIGN) + |
| 1094 | BTSDIO_DMA_ALIGN; |
Julia Lawall | 5959809 | 2009-08-06 22:05:18 +0200 | [diff] [blame] | 1095 | tmpbuf = kzalloc(tmpbufsz, GFP_KERNEL); |
| 1096 | if (!tmpbuf) |
| 1097 | return -ENOMEM; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1098 | buf = (u8 *) ALIGN_ADDR(tmpbuf, BTSDIO_DMA_ALIGN); |
| 1099 | memcpy(buf, payload, nb); |
| 1100 | } |
| 1101 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1102 | sdio_claim_host(card->func); |
| 1103 | |
| 1104 | do { |
| 1105 | /* Transfer data to card */ |
| 1106 | ret = sdio_writesb(card->func, card->ioport, buf, |
Ricky Liang | d2f3024 | 2016-06-28 15:06:57 +0800 | [diff] [blame] | 1107 | blksz); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1108 | if (ret < 0) { |
| 1109 | i++; |
| 1110 | BT_ERR("i=%d writesb failed: %d", i, ret); |
Andrei Emeltchenko | 78c1b8e | 2012-10-10 17:41:33 +0300 | [diff] [blame] | 1111 | BT_ERR("hex: %*ph", nb, payload); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1112 | ret = -EIO; |
| 1113 | if (i > MAX_WRITE_IOMEM_RETRY) |
| 1114 | goto exit; |
| 1115 | } |
| 1116 | } while (ret); |
| 1117 | |
| 1118 | priv->btmrvl_dev.tx_dnld_rdy = false; |
| 1119 | |
| 1120 | exit: |
| 1121 | sdio_release_host(card->func); |
Yoichi Yuasa | 88d1a0c | 2010-02-04 09:55:51 +0900 | [diff] [blame] | 1122 | kfree(tmpbuf); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1123 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1124 | return ret; |
| 1125 | } |
| 1126 | |
| 1127 | static int btmrvl_sdio_download_fw(struct btmrvl_sdio_card *card) |
| 1128 | { |
Gustavo Padovan | faff7f7 | 2013-04-18 19:35:33 -0300 | [diff] [blame] | 1129 | int ret; |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 1130 | u8 fws0; |
| 1131 | int pollnum = MAX_POLL_TRIES; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1132 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1133 | if (!card || !card->func) { |
| 1134 | BT_ERR("card or function is NULL!"); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1135 | return -EINVAL; |
| 1136 | } |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1137 | |
| 1138 | if (!btmrvl_sdio_verify_fw_download(card, 1)) { |
| 1139 | BT_DBG("Firmware already downloaded!"); |
Andreas Fenkart | c1c999e | 2013-04-22 11:10:22 +0200 | [diff] [blame] | 1140 | return 0; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1141 | } |
| 1142 | |
Andreas Fenkart | c1c999e | 2013-04-22 11:10:22 +0200 | [diff] [blame] | 1143 | sdio_claim_host(card->func); |
| 1144 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 1145 | /* Check if other function driver is downloading the firmware */ |
| 1146 | fws0 = sdio_readb(card->func, card->reg->card_fw_status0, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1147 | if (ret) { |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 1148 | BT_ERR("Failed to read FW downloading status!"); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1149 | ret = -EIO; |
| 1150 | goto done; |
| 1151 | } |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 1152 | if (fws0) { |
| 1153 | BT_DBG("BT not the winner (%#x). Skip FW downloading", fws0); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1154 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 1155 | /* Give other function more time to download the firmware */ |
| 1156 | pollnum *= 10; |
| 1157 | } else { |
| 1158 | if (card->helper) { |
| 1159 | ret = btmrvl_sdio_download_helper(card); |
| 1160 | if (ret) { |
| 1161 | BT_ERR("Failed to download helper!"); |
| 1162 | ret = -EIO; |
| 1163 | goto done; |
| 1164 | } |
| 1165 | } |
| 1166 | |
| 1167 | if (btmrvl_sdio_download_fw_w_helper(card)) { |
| 1168 | BT_ERR("Failed to download firmware!"); |
| 1169 | ret = -EIO; |
| 1170 | goto done; |
| 1171 | } |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1172 | } |
| 1173 | |
Andreas Fenkart | 69676b1 | 2013-04-22 11:10:23 +0200 | [diff] [blame] | 1174 | /* |
| 1175 | * winner or not, with this test the FW synchronizes when the |
| 1176 | * module can continue its initialization |
| 1177 | */ |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 1178 | if (btmrvl_sdio_verify_fw_download(card, pollnum)) { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1179 | BT_ERR("FW failed to be active in time!"); |
Chin-Ran Lo | 86f7ac7 | 2015-12-29 04:26:33 -0800 | [diff] [blame] | 1180 | ret = -ETIMEDOUT; |
| 1181 | goto done; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1182 | } |
| 1183 | |
Aniket Nagarnaik | 4863e4c | 2015-08-06 03:43:09 -0700 | [diff] [blame] | 1184 | sdio_release_host(card->func); |
| 1185 | |
Andreas Fenkart | c1c999e | 2013-04-22 11:10:22 +0200 | [diff] [blame] | 1186 | return 0; |
| 1187 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1188 | done: |
| 1189 | sdio_release_host(card->func); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1190 | return ret; |
| 1191 | } |
| 1192 | |
| 1193 | static int btmrvl_sdio_wakeup_fw(struct btmrvl_private *priv) |
| 1194 | { |
| 1195 | struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; |
| 1196 | int ret = 0; |
| 1197 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1198 | if (!card || !card->func) { |
| 1199 | BT_ERR("card or function is NULL!"); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1200 | return -EINVAL; |
| 1201 | } |
| 1202 | |
| 1203 | sdio_claim_host(card->func); |
| 1204 | |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 1205 | sdio_writeb(card->func, HOST_POWER_UP, card->reg->cfg, &ret); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1206 | |
| 1207 | sdio_release_host(card->func); |
| 1208 | |
| 1209 | BT_DBG("wake up firmware"); |
| 1210 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1211 | return ret; |
| 1212 | } |
| 1213 | |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 1214 | static void btmrvl_sdio_dump_regs(struct btmrvl_private *priv) |
| 1215 | { |
| 1216 | struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; |
| 1217 | int ret = 0; |
| 1218 | unsigned int reg, reg_start, reg_end; |
| 1219 | char buf[256], *ptr; |
| 1220 | u8 loop, func, data; |
| 1221 | int MAX_LOOP = 2; |
| 1222 | |
| 1223 | btmrvl_sdio_wakeup_fw(priv); |
| 1224 | sdio_claim_host(card->func); |
| 1225 | |
| 1226 | for (loop = 0; loop < MAX_LOOP; loop++) { |
| 1227 | memset(buf, 0, sizeof(buf)); |
| 1228 | ptr = buf; |
| 1229 | |
| 1230 | if (loop == 0) { |
| 1231 | /* Read the registers of SDIO function0 */ |
| 1232 | func = loop; |
| 1233 | reg_start = 0; |
| 1234 | reg_end = 9; |
| 1235 | } else { |
| 1236 | func = 2; |
| 1237 | reg_start = 0; |
| 1238 | reg_end = 0x09; |
| 1239 | } |
| 1240 | |
| 1241 | ptr += sprintf(ptr, "SDIO Func%d (%#x-%#x): ", |
| 1242 | func, reg_start, reg_end); |
| 1243 | for (reg = reg_start; reg <= reg_end; reg++) { |
| 1244 | if (func == 0) |
| 1245 | data = sdio_f0_readb(card->func, reg, &ret); |
| 1246 | else |
| 1247 | data = sdio_readb(card->func, reg, &ret); |
| 1248 | |
| 1249 | if (!ret) { |
| 1250 | ptr += sprintf(ptr, "%02x ", data); |
| 1251 | } else { |
| 1252 | ptr += sprintf(ptr, "ERR"); |
| 1253 | break; |
| 1254 | } |
| 1255 | } |
| 1256 | |
| 1257 | BT_INFO("%s", buf); |
| 1258 | } |
| 1259 | |
| 1260 | sdio_release_host(card->func); |
| 1261 | } |
| 1262 | |
| 1263 | /* This function read/write firmware */ |
| 1264 | static enum |
| 1265 | rdwr_status btmrvl_sdio_rdwr_firmware(struct btmrvl_private *priv, |
| 1266 | u8 doneflag) |
| 1267 | { |
| 1268 | struct btmrvl_sdio_card *card = priv->btmrvl_dev.card; |
| 1269 | int ret, tries; |
| 1270 | u8 ctrl_data = 0; |
| 1271 | |
| 1272 | sdio_writeb(card->func, FW_DUMP_HOST_READY, card->reg->fw_dump_ctrl, |
| 1273 | &ret); |
| 1274 | |
| 1275 | if (ret) { |
| 1276 | BT_ERR("SDIO write err"); |
| 1277 | return RDWR_STATUS_FAILURE; |
| 1278 | } |
| 1279 | |
| 1280 | for (tries = 0; tries < MAX_POLL_TRIES; tries++) { |
| 1281 | ctrl_data = sdio_readb(card->func, card->reg->fw_dump_ctrl, |
| 1282 | &ret); |
| 1283 | |
| 1284 | if (ret) { |
| 1285 | BT_ERR("SDIO read err"); |
| 1286 | return RDWR_STATUS_FAILURE; |
| 1287 | } |
| 1288 | |
| 1289 | if (ctrl_data == FW_DUMP_DONE) |
| 1290 | break; |
| 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); |
| 1297 | if (ret) { |
| 1298 | BT_ERR("SDIO write err"); |
| 1299 | return RDWR_STATUS_FAILURE; |
| 1300 | } |
| 1301 | } |
| 1302 | usleep_range(100, 200); |
| 1303 | } |
| 1304 | |
| 1305 | if (ctrl_data == FW_DUMP_HOST_READY) { |
| 1306 | BT_ERR("Fail to pull ctrl_data"); |
| 1307 | return RDWR_STATUS_FAILURE; |
| 1308 | } |
| 1309 | |
| 1310 | return RDWR_STATUS_SUCCESS; |
| 1311 | } |
| 1312 | |
| 1313 | /* This function dump sdio register and memory data */ |
Arend van Spriel | 4565049 | 2018-05-18 00:15:12 +0200 | [diff] [blame^] | 1314 | static void btmrvl_sdio_coredump(struct device *dev) |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 1315 | { |
Arend van Spriel | 4565049 | 2018-05-18 00:15:12 +0200 | [diff] [blame^] | 1316 | struct sdio_func *func = dev_to_sdio_func(dev); |
| 1317 | struct btmrvl_sdio_card *card; |
| 1318 | struct btmrvl_private *priv; |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 1319 | int ret = 0; |
| 1320 | unsigned int reg, reg_start, reg_end; |
| 1321 | enum rdwr_status stat; |
| 1322 | u8 *dbg_ptr, *end_ptr, *fw_dump_data, *fw_dump_ptr; |
Xinming Hu | a1e85f04 | 2015-04-21 06:59:56 -0700 | [diff] [blame] | 1323 | u8 dump_num = 0, idx, i, read_reg, doneflag = 0; |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 1324 | u32 memory_size, fw_dump_len = 0; |
| 1325 | |
Arend van Spriel | 4565049 | 2018-05-18 00:15:12 +0200 | [diff] [blame^] | 1326 | card = sdio_get_drvdata(func); |
| 1327 | priv = card->priv; |
| 1328 | |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 1329 | /* dump sdio register first */ |
| 1330 | btmrvl_sdio_dump_regs(priv); |
| 1331 | |
| 1332 | if (!card->supports_fw_dump) { |
| 1333 | BT_ERR("Firmware dump not supported for this card!"); |
| 1334 | return; |
| 1335 | } |
| 1336 | |
| 1337 | for (idx = 0; idx < ARRAY_SIZE(mem_type_mapping_tbl); idx++) { |
| 1338 | struct memory_type_mapping *entry = &mem_type_mapping_tbl[idx]; |
| 1339 | |
| 1340 | if (entry->mem_ptr) { |
| 1341 | vfree(entry->mem_ptr); |
| 1342 | entry->mem_ptr = NULL; |
| 1343 | } |
| 1344 | entry->mem_size = 0; |
| 1345 | } |
| 1346 | |
| 1347 | btmrvl_sdio_wakeup_fw(priv); |
| 1348 | sdio_claim_host(card->func); |
| 1349 | |
| 1350 | BT_INFO("== btmrvl firmware dump start =="); |
| 1351 | |
| 1352 | stat = btmrvl_sdio_rdwr_firmware(priv, doneflag); |
| 1353 | if (stat == RDWR_STATUS_FAILURE) |
| 1354 | goto done; |
| 1355 | |
| 1356 | reg = card->reg->fw_dump_start; |
| 1357 | /* Read the number of the memories which will dump */ |
| 1358 | dump_num = sdio_readb(card->func, reg, &ret); |
| 1359 | |
| 1360 | if (ret) { |
| 1361 | BT_ERR("SDIO read memory length err"); |
| 1362 | goto done; |
| 1363 | } |
| 1364 | |
| 1365 | /* Read the length of every memory which will dump */ |
| 1366 | for (idx = 0; idx < dump_num; idx++) { |
| 1367 | struct memory_type_mapping *entry = &mem_type_mapping_tbl[idx]; |
| 1368 | |
| 1369 | stat = btmrvl_sdio_rdwr_firmware(priv, doneflag); |
| 1370 | if (stat == RDWR_STATUS_FAILURE) |
| 1371 | goto done; |
| 1372 | |
| 1373 | memory_size = 0; |
| 1374 | reg = card->reg->fw_dump_start; |
| 1375 | for (i = 0; i < 4; i++) { |
| 1376 | read_reg = sdio_readb(card->func, reg, &ret); |
| 1377 | if (ret) { |
| 1378 | BT_ERR("SDIO read err"); |
| 1379 | goto done; |
| 1380 | } |
| 1381 | memory_size |= (read_reg << i*8); |
| 1382 | reg++; |
| 1383 | } |
| 1384 | |
| 1385 | if (memory_size == 0) { |
| 1386 | BT_INFO("Firmware dump finished!"); |
Nachiket Kukade | 475b9ea | 2015-09-18 06:40:40 -0700 | [diff] [blame] | 1387 | sdio_writeb(card->func, FW_DUMP_READ_DONE, |
| 1388 | card->reg->fw_dump_ctrl, &ret); |
| 1389 | if (ret) { |
| 1390 | BT_ERR("SDIO Write MEMDUMP_FINISH ERR"); |
| 1391 | goto done; |
| 1392 | } |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 1393 | break; |
| 1394 | } |
| 1395 | |
| 1396 | BT_INFO("%s_SIZE=0x%x", entry->mem_name, memory_size); |
| 1397 | entry->mem_ptr = vzalloc(memory_size + 1); |
| 1398 | entry->mem_size = memory_size; |
| 1399 | if (!entry->mem_ptr) { |
| 1400 | BT_ERR("Vzalloc %s failed", entry->mem_name); |
| 1401 | goto done; |
| 1402 | } |
| 1403 | |
| 1404 | fw_dump_len += (strlen("========Start dump ") + |
| 1405 | strlen(entry->mem_name) + |
| 1406 | strlen("========\n") + |
| 1407 | (memory_size + 1) + |
| 1408 | strlen("\n========End dump========\n")); |
| 1409 | |
| 1410 | dbg_ptr = entry->mem_ptr; |
| 1411 | end_ptr = dbg_ptr + memory_size; |
| 1412 | |
| 1413 | doneflag = entry->done_flag; |
| 1414 | BT_INFO("Start %s output, please wait...", |
| 1415 | entry->mem_name); |
| 1416 | |
| 1417 | do { |
| 1418 | stat = btmrvl_sdio_rdwr_firmware(priv, doneflag); |
| 1419 | if (stat == RDWR_STATUS_FAILURE) |
| 1420 | goto done; |
| 1421 | |
| 1422 | reg_start = card->reg->fw_dump_start; |
| 1423 | reg_end = card->reg->fw_dump_end; |
| 1424 | for (reg = reg_start; reg <= reg_end; reg++) { |
| 1425 | *dbg_ptr = sdio_readb(card->func, reg, &ret); |
| 1426 | if (ret) { |
| 1427 | BT_ERR("SDIO read err"); |
| 1428 | goto done; |
| 1429 | } |
| 1430 | if (dbg_ptr < end_ptr) |
| 1431 | dbg_ptr++; |
| 1432 | else |
| 1433 | BT_ERR("Allocated buffer not enough"); |
| 1434 | } |
| 1435 | |
| 1436 | if (stat != RDWR_STATUS_DONE) { |
| 1437 | continue; |
| 1438 | } else { |
| 1439 | BT_INFO("%s done: size=0x%tx", |
| 1440 | entry->mem_name, |
| 1441 | dbg_ptr - entry->mem_ptr); |
| 1442 | break; |
| 1443 | } |
| 1444 | } while (1); |
| 1445 | } |
| 1446 | |
| 1447 | BT_INFO("== btmrvl firmware dump end =="); |
| 1448 | |
| 1449 | done: |
| 1450 | sdio_release_host(card->func); |
| 1451 | |
| 1452 | if (fw_dump_len == 0) |
| 1453 | return; |
| 1454 | |
| 1455 | fw_dump_data = vzalloc(fw_dump_len+1); |
| 1456 | if (!fw_dump_data) { |
| 1457 | BT_ERR("Vzalloc fw_dump_data fail!"); |
| 1458 | return; |
| 1459 | } |
| 1460 | fw_dump_ptr = fw_dump_data; |
| 1461 | |
| 1462 | /* Dump all the memory data into single file, a userspace script will |
Derek Robson | d98422c | 2017-07-22 13:47:07 +1200 | [diff] [blame] | 1463 | * be used to split all the memory data to multiple files |
| 1464 | */ |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 1465 | BT_INFO("== btmrvl firmware dump to /sys/class/devcoredump start"); |
| 1466 | for (idx = 0; idx < dump_num; idx++) { |
| 1467 | struct memory_type_mapping *entry = &mem_type_mapping_tbl[idx]; |
| 1468 | |
| 1469 | if (entry->mem_ptr) { |
| 1470 | strcpy(fw_dump_ptr, "========Start dump "); |
| 1471 | fw_dump_ptr += strlen("========Start dump "); |
| 1472 | |
| 1473 | strcpy(fw_dump_ptr, entry->mem_name); |
| 1474 | fw_dump_ptr += strlen(entry->mem_name); |
| 1475 | |
| 1476 | strcpy(fw_dump_ptr, "========\n"); |
| 1477 | fw_dump_ptr += strlen("========\n"); |
| 1478 | |
| 1479 | memcpy(fw_dump_ptr, entry->mem_ptr, entry->mem_size); |
| 1480 | fw_dump_ptr += entry->mem_size; |
| 1481 | |
| 1482 | strcpy(fw_dump_ptr, "\n========End dump========\n"); |
| 1483 | fw_dump_ptr += strlen("\n========End dump========\n"); |
| 1484 | |
| 1485 | vfree(mem_type_mapping_tbl[idx].mem_ptr); |
| 1486 | mem_type_mapping_tbl[idx].mem_ptr = NULL; |
| 1487 | } |
| 1488 | } |
| 1489 | |
| 1490 | /* fw_dump_data will be free in device coredump release function |
Derek Robson | d98422c | 2017-07-22 13:47:07 +1200 | [diff] [blame] | 1491 | * after 5 min |
| 1492 | */ |
Shengzhen Li | d490263 | 2015-08-19 03:12:19 -0700 | [diff] [blame] | 1493 | dev_coredumpv(&card->func->dev, fw_dump_data, fw_dump_len, GFP_KERNEL); |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 1494 | BT_INFO("== btmrvl firmware dump to /sys/class/devcoredump end"); |
| 1495 | } |
| 1496 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1497 | static int btmrvl_sdio_probe(struct sdio_func *func, |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 1498 | const struct sdio_device_id *id) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1499 | { |
| 1500 | int ret = 0; |
| 1501 | struct btmrvl_private *priv = NULL; |
| 1502 | struct btmrvl_sdio_card *card = NULL; |
| 1503 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1504 | BT_INFO("vendor=0x%x, device=0x%x, class=%d, fn=%d", |
| 1505 | id->vendor, id->device, id->class, func->num); |
| 1506 | |
Sachin Kamat | eb17ea3 | 2012-07-27 12:38:36 +0530 | [diff] [blame] | 1507 | card = devm_kzalloc(&func->dev, sizeof(*card), GFP_KERNEL); |
| 1508 | if (!card) |
| 1509 | return -ENOMEM; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1510 | |
| 1511 | card->func = func; |
| 1512 | |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 1513 | if (id->driver_data) { |
| 1514 | struct btmrvl_sdio_device *data = (void *) id->driver_data; |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 1515 | card->helper = data->helper; |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 1516 | card->firmware = data->firmware; |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 1517 | card->reg = data->reg; |
| 1518 | card->sd_blksz_fw_dl = data->sd_blksz_fw_dl; |
Bing Zhao | 4df82b5 | 2014-03-31 14:41:44 -0700 | [diff] [blame] | 1519 | card->support_pscan_win_report = data->support_pscan_win_report; |
Xinming Hu | dc75961 | 2014-11-24 02:40:53 -0800 | [diff] [blame] | 1520 | card->supports_fw_dump = data->supports_fw_dump; |
Marcel Holtmann | dcf47f3 | 2009-06-09 16:21:58 +0200 | [diff] [blame] | 1521 | } |
| 1522 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1523 | if (btmrvl_sdio_register_dev(card) < 0) { |
| 1524 | BT_ERR("Failed to register BT device!"); |
Sachin Kamat | eb17ea3 | 2012-07-27 12:38:36 +0530 | [diff] [blame] | 1525 | return -ENODEV; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1526 | } |
| 1527 | |
| 1528 | /* Disable the interrupts on the card */ |
| 1529 | btmrvl_sdio_disable_host_int(card); |
| 1530 | |
| 1531 | if (btmrvl_sdio_download_fw(card)) { |
| 1532 | BT_ERR("Downloading firmware failed!"); |
| 1533 | ret = -ENODEV; |
| 1534 | goto unreg_dev; |
| 1535 | } |
| 1536 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1537 | btmrvl_sdio_enable_host_int(card); |
| 1538 | |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 1539 | /* Device tree node parsing and platform specific configuration*/ |
| 1540 | btmrvl_sdio_probe_of(&func->dev, card); |
| 1541 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1542 | priv = btmrvl_add_card(card); |
| 1543 | if (!priv) { |
| 1544 | BT_ERR("Initializing card failed!"); |
| 1545 | ret = -ENODEV; |
| 1546 | goto disable_host_int; |
| 1547 | } |
| 1548 | |
| 1549 | card->priv = priv; |
| 1550 | |
| 1551 | /* Initialize the interface specific function pointers */ |
| 1552 | priv->hw_host_to_card = btmrvl_sdio_host_to_card; |
| 1553 | priv->hw_wakeup_firmware = btmrvl_sdio_wakeup_fw; |
Amitkumar Karwar | d1d10d7 | 2010-05-27 16:38:37 -0700 | [diff] [blame] | 1554 | priv->hw_process_int_status = btmrvl_sdio_process_int_status; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1555 | |
Bing Zhao | 6406160 | 2010-03-03 14:37:36 -0800 | [diff] [blame] | 1556 | if (btmrvl_register_hdev(priv)) { |
| 1557 | BT_ERR("Register hdev failed!"); |
| 1558 | ret = -ENODEV; |
| 1559 | goto disable_host_int; |
| 1560 | } |
| 1561 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1562 | return 0; |
| 1563 | |
| 1564 | disable_host_int: |
| 1565 | btmrvl_sdio_disable_host_int(card); |
| 1566 | unreg_dev: |
| 1567 | btmrvl_sdio_unregister_dev(card); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1568 | return ret; |
| 1569 | } |
| 1570 | |
| 1571 | static void btmrvl_sdio_remove(struct sdio_func *func) |
| 1572 | { |
| 1573 | struct btmrvl_sdio_card *card; |
| 1574 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1575 | if (func) { |
| 1576 | card = sdio_get_drvdata(func); |
| 1577 | if (card) { |
| 1578 | /* Send SHUTDOWN command & disable interrupt |
| 1579 | * if user removes the module. |
| 1580 | */ |
| 1581 | if (user_rmmod) { |
| 1582 | btmrvl_send_module_cfg_cmd(card->priv, |
| 1583 | MODULE_SHUTDOWN_REQ); |
| 1584 | btmrvl_sdio_disable_host_int(card); |
| 1585 | } |
Colin Ian King | 9232259 | 2017-03-21 12:20:28 +0000 | [diff] [blame] | 1586 | BT_DBG("unregister dev"); |
Amitkumar Karwar | 7b4b874 | 2015-01-01 00:13:41 -0800 | [diff] [blame] | 1587 | card->priv->surprise_removed = true; |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1588 | btmrvl_sdio_unregister_dev(card); |
| 1589 | btmrvl_remove_card(card->priv); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1590 | } |
| 1591 | } |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1592 | } |
| 1593 | |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1594 | static int btmrvl_sdio_suspend(struct device *dev) |
| 1595 | { |
| 1596 | struct sdio_func *func = dev_to_sdio_func(dev); |
| 1597 | struct btmrvl_sdio_card *card; |
| 1598 | struct btmrvl_private *priv; |
| 1599 | mmc_pm_flag_t pm_flags; |
| 1600 | struct hci_dev *hcidev; |
| 1601 | |
| 1602 | if (func) { |
| 1603 | pm_flags = sdio_get_host_pm_caps(func); |
| 1604 | BT_DBG("%s: suspend: PM flags = 0x%x", sdio_func_id(func), |
| 1605 | pm_flags); |
| 1606 | if (!(pm_flags & MMC_PM_KEEP_POWER)) { |
| 1607 | BT_ERR("%s: cannot remain alive while suspended", |
| 1608 | sdio_func_id(func)); |
| 1609 | return -ENOSYS; |
| 1610 | } |
| 1611 | card = sdio_get_drvdata(func); |
| 1612 | if (!card || !card->priv) { |
| 1613 | BT_ERR("card or priv structure is not valid"); |
| 1614 | return 0; |
| 1615 | } |
| 1616 | } else { |
| 1617 | BT_ERR("sdio_func is not specified"); |
| 1618 | return 0; |
| 1619 | } |
| 1620 | |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 1621 | /* Enable platform specific wakeup interrupt */ |
| 1622 | if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0) { |
| 1623 | card->plt_wake_cfg->wake_by_bt = false; |
| 1624 | enable_irq(card->plt_wake_cfg->irq_bt); |
| 1625 | enable_irq_wake(card->plt_wake_cfg->irq_bt); |
| 1626 | } |
| 1627 | |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1628 | priv = card->priv; |
Chin-Ran Lo | 8cf60cf | 2016-01-06 06:34:38 -0800 | [diff] [blame] | 1629 | priv->adapter->is_suspending = true; |
Chin-Ran Lo | 5bf8a74 | 2014-07-14 21:05:37 -0700 | [diff] [blame] | 1630 | hcidev = priv->btmrvl_dev.hcidev; |
| 1631 | BT_DBG("%s: SDIO suspend", hcidev->name); |
| 1632 | hci_suspend_dev(hcidev); |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1633 | |
| 1634 | if (priv->adapter->hs_state != HS_ACTIVATED) { |
| 1635 | if (btmrvl_enable_hs(priv)) { |
Colin Ian King | 8f91566 | 2017-02-18 22:52:55 +0000 | [diff] [blame] | 1636 | BT_ERR("HS not activated, suspend failed!"); |
Xinming Hu | 6eb7bd6 | 2017-03-31 14:32:31 +0800 | [diff] [blame] | 1637 | /* Disable platform specific wakeup interrupt */ |
| 1638 | if (card->plt_wake_cfg && |
| 1639 | card->plt_wake_cfg->irq_bt >= 0) { |
| 1640 | disable_irq_wake(card->plt_wake_cfg->irq_bt); |
| 1641 | disable_irq(card->plt_wake_cfg->irq_bt); |
| 1642 | } |
| 1643 | |
Amitkumar Karwar | e7acf43 | 2016-07-15 16:20:52 +0530 | [diff] [blame] | 1644 | priv->adapter->is_suspending = false; |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1645 | return -EBUSY; |
| 1646 | } |
| 1647 | } |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1648 | |
Chin-Ran Lo | 8cf60cf | 2016-01-06 06:34:38 -0800 | [diff] [blame] | 1649 | priv->adapter->is_suspending = false; |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1650 | priv->adapter->is_suspended = true; |
| 1651 | |
| 1652 | /* We will keep the power when hs enabled successfully */ |
| 1653 | if (priv->adapter->hs_state == HS_ACTIVATED) { |
| 1654 | BT_DBG("suspend with MMC_PM_KEEP_POWER"); |
| 1655 | return sdio_set_host_pm_flags(func, MMC_PM_KEEP_POWER); |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1656 | } |
prasanna karthik | f1554b7 | 2017-03-28 19:44:00 +0000 | [diff] [blame] | 1657 | |
| 1658 | BT_DBG("suspend without MMC_PM_KEEP_POWER"); |
| 1659 | return 0; |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1660 | } |
| 1661 | |
| 1662 | static int btmrvl_sdio_resume(struct device *dev) |
| 1663 | { |
| 1664 | struct sdio_func *func = dev_to_sdio_func(dev); |
| 1665 | struct btmrvl_sdio_card *card; |
| 1666 | struct btmrvl_private *priv; |
| 1667 | mmc_pm_flag_t pm_flags; |
| 1668 | struct hci_dev *hcidev; |
| 1669 | |
| 1670 | if (func) { |
| 1671 | pm_flags = sdio_get_host_pm_caps(func); |
| 1672 | BT_DBG("%s: resume: PM flags = 0x%x", sdio_func_id(func), |
| 1673 | pm_flags); |
| 1674 | card = sdio_get_drvdata(func); |
| 1675 | if (!card || !card->priv) { |
| 1676 | BT_ERR("card or priv structure is not valid"); |
| 1677 | return 0; |
| 1678 | } |
| 1679 | } else { |
| 1680 | BT_ERR("sdio_func is not specified"); |
| 1681 | return 0; |
| 1682 | } |
| 1683 | priv = card->priv; |
| 1684 | |
| 1685 | if (!priv->adapter->is_suspended) { |
| 1686 | BT_DBG("device already resumed"); |
| 1687 | return 0; |
| 1688 | } |
| 1689 | |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1690 | priv->hw_wakeup_firmware(priv); |
| 1691 | priv->adapter->hs_state = HS_DEACTIVATED; |
Chin-Ran Lo | 5bf8a74 | 2014-07-14 21:05:37 -0700 | [diff] [blame] | 1692 | hcidev = priv->btmrvl_dev.hcidev; |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1693 | BT_DBG("%s: HS DEACTIVATED in resume!", hcidev->name); |
Chin-Ran Lo | 5bf8a74 | 2014-07-14 21:05:37 -0700 | [diff] [blame] | 1694 | priv->adapter->is_suspended = false; |
| 1695 | BT_DBG("%s: SDIO resume", hcidev->name); |
| 1696 | hci_resume_dev(hcidev); |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1697 | |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 1698 | /* Disable platform specific wakeup interrupt */ |
| 1699 | if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0) { |
| 1700 | disable_irq_wake(card->plt_wake_cfg->irq_bt); |
Jeffy Chen | 9af02d8 | 2017-01-23 12:18:51 +0800 | [diff] [blame] | 1701 | disable_irq(card->plt_wake_cfg->irq_bt); |
| 1702 | if (card->plt_wake_cfg->wake_by_bt) |
| 1703 | /* Undo our disable, since interrupt handler already |
| 1704 | * did this. |
| 1705 | */ |
| 1706 | enable_irq(card->plt_wake_cfg->irq_bt); |
Xinming Hu | bb7f4f0 | 2016-04-26 06:57:27 -0700 | [diff] [blame] | 1707 | } |
| 1708 | |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1709 | return 0; |
| 1710 | } |
| 1711 | |
| 1712 | static const struct dev_pm_ops btmrvl_sdio_pm_ops = { |
| 1713 | .suspend = btmrvl_sdio_suspend, |
| 1714 | .resume = btmrvl_sdio_resume, |
| 1715 | }; |
| 1716 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1717 | static struct sdio_driver bt_mrvl_sdio = { |
| 1718 | .name = "btmrvl_sdio", |
| 1719 | .id_table = btmrvl_sdio_ids, |
| 1720 | .probe = btmrvl_sdio_probe, |
| 1721 | .remove = btmrvl_sdio_remove, |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1722 | .drv = { |
| 1723 | .owner = THIS_MODULE, |
Arend van Spriel | 4565049 | 2018-05-18 00:15:12 +0200 | [diff] [blame^] | 1724 | .coredump = btmrvl_sdio_coredump, |
Amitkumar Karwar | ba54a16 | 2012-04-25 11:43:54 -0700 | [diff] [blame] | 1725 | .pm = &btmrvl_sdio_pm_ops, |
| 1726 | } |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1727 | }; |
| 1728 | |
Peter Huewe | 8e5b230 | 2009-12-22 09:34:20 +0100 | [diff] [blame] | 1729 | static int __init btmrvl_sdio_init_module(void) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1730 | { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1731 | if (sdio_register_driver(&bt_mrvl_sdio) != 0) { |
| 1732 | BT_ERR("SDIO Driver Registration Failed"); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1733 | return -ENODEV; |
| 1734 | } |
| 1735 | |
| 1736 | /* Clear the flag in case user removes the card. */ |
| 1737 | user_rmmod = 0; |
| 1738 | |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1739 | return 0; |
| 1740 | } |
| 1741 | |
Peter Huewe | 8e5b230 | 2009-12-22 09:34:20 +0100 | [diff] [blame] | 1742 | static void __exit btmrvl_sdio_exit_module(void) |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1743 | { |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1744 | /* Set the flag as user is removing this module. */ |
| 1745 | user_rmmod = 1; |
| 1746 | |
| 1747 | sdio_unregister_driver(&bt_mrvl_sdio); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1748 | } |
| 1749 | |
| 1750 | module_init(btmrvl_sdio_init_module); |
| 1751 | module_exit(btmrvl_sdio_exit_module); |
| 1752 | |
| 1753 | MODULE_AUTHOR("Marvell International Ltd."); |
Marcel Holtmann | 9666fb3 | 2009-06-09 21:45:04 +0200 | [diff] [blame] | 1754 | MODULE_DESCRIPTION("Marvell BT-over-SDIO driver ver " VERSION); |
Bing Zhao | 789221e | 2009-06-02 14:29:36 -0700 | [diff] [blame] | 1755 | MODULE_VERSION(VERSION); |
| 1756 | MODULE_LICENSE("GPL v2"); |
Lubomir Rintel | 77189df | 2013-03-13 12:04:30 +0100 | [diff] [blame] | 1757 | MODULE_FIRMWARE("mrvl/sd8688_helper.bin"); |
| 1758 | MODULE_FIRMWARE("mrvl/sd8688.bin"); |
Kevin Gan | 9f72c1d | 2011-04-08 18:19:33 -0700 | [diff] [blame] | 1759 | MODULE_FIRMWARE("mrvl/sd8787_uapsta.bin"); |
Bing Zhao | 2ac654f | 2011-11-16 20:40:42 -0800 | [diff] [blame] | 1760 | MODULE_FIRMWARE("mrvl/sd8797_uapsta.bin"); |
Xinming Hu | 3907d55 | 2014-09-30 06:45:33 -0400 | [diff] [blame] | 1761 | MODULE_FIRMWARE("mrvl/sd8887_uapsta.bin"); |
Bing Zhao | 22f2efe | 2013-05-13 18:15:32 -0700 | [diff] [blame] | 1762 | MODULE_FIRMWARE("mrvl/sd8897_uapsta.bin"); |
Amitkumar Karwar | f0ef674 | 2015-09-21 03:06:42 -0700 | [diff] [blame] | 1763 | MODULE_FIRMWARE("mrvl/sd8997_uapsta.bin"); |