Marcel Holtmann | e9a2dd2 | 2015-04-04 16:13:03 -0700 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Bluetooth HCI UART driver for Broadcom devices |
| 4 | * |
| 5 | * Copyright (C) 2015 Intel Corporation |
| 6 | * |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/errno.h> |
| 26 | #include <linux/skbuff.h> |
Frederic Danis | 18aeb44 | 2015-05-28 11:25:01 +0200 | [diff] [blame] | 27 | #include <linux/firmware.h> |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 28 | #include <linux/module.h> |
| 29 | #include <linux/acpi.h> |
| 30 | #include <linux/platform_device.h> |
| 31 | #include <linux/clk.h> |
| 32 | #include <linux/gpio/consumer.h> |
| 33 | #include <linux/tty.h> |
Marcel Holtmann | e9a2dd2 | 2015-04-04 16:13:03 -0700 | [diff] [blame] | 34 | |
| 35 | #include <net/bluetooth/bluetooth.h> |
| 36 | #include <net/bluetooth/hci_core.h> |
| 37 | |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 38 | #include "btbcm.h" |
Marcel Holtmann | e9a2dd2 | 2015-04-04 16:13:03 -0700 | [diff] [blame] | 39 | #include "hci_uart.h" |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 40 | |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 41 | struct bcm_device { |
| 42 | struct list_head list; |
| 43 | |
| 44 | struct platform_device *pdev; |
| 45 | |
| 46 | const char *name; |
| 47 | struct gpio_desc *device_wakeup; |
| 48 | struct gpio_desc *shutdown; |
| 49 | |
| 50 | struct clk *clk; |
| 51 | bool clk_enabled; |
Frederic Danis | ae05690 | 2015-08-11 16:35:37 +0200 | [diff] [blame^] | 52 | |
| 53 | u32 init_speed; |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 56 | struct bcm_data { |
| 57 | struct sk_buff *rx_skb; |
| 58 | struct sk_buff_head txq; |
| 59 | |
| 60 | struct bcm_device *dev; |
| 61 | }; |
| 62 | |
| 63 | /* List of BCM BT UART devices */ |
| 64 | static DEFINE_SPINLOCK(bcm_device_list_lock); |
| 65 | static LIST_HEAD(bcm_device_list); |
| 66 | |
Frederic Danis | 61b2fc2 | 2015-06-09 16:15:37 +0200 | [diff] [blame] | 67 | static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed) |
| 68 | { |
| 69 | struct hci_dev *hdev = hu->hdev; |
| 70 | struct sk_buff *skb; |
| 71 | struct bcm_update_uart_baud_rate param; |
| 72 | |
| 73 | if (speed > 3000000) { |
| 74 | struct bcm_write_uart_clock_setting clock; |
| 75 | |
| 76 | clock.type = BCM_UART_CLOCK_48MHZ; |
| 77 | |
| 78 | BT_DBG("%s: Set Controller clock (%d)", hdev->name, clock.type); |
| 79 | |
| 80 | /* This Broadcom specific command changes the UART's controller |
| 81 | * clock for baud rate > 3000000. |
| 82 | */ |
| 83 | skb = __hci_cmd_sync(hdev, 0xfc45, 1, &clock, HCI_INIT_TIMEOUT); |
| 84 | if (IS_ERR(skb)) { |
| 85 | int err = PTR_ERR(skb); |
| 86 | BT_ERR("%s: BCM: failed to write clock command (%d)", |
| 87 | hdev->name, err); |
| 88 | return err; |
| 89 | } |
| 90 | |
| 91 | kfree_skb(skb); |
| 92 | } |
| 93 | |
| 94 | BT_DBG("%s: Set Controller UART speed to %d bit/s", hdev->name, speed); |
| 95 | |
| 96 | param.zero = cpu_to_le16(0); |
| 97 | param.baud_rate = cpu_to_le32(speed); |
| 98 | |
| 99 | /* This Broadcom specific command changes the UART's controller baud |
| 100 | * rate. |
| 101 | */ |
| 102 | skb = __hci_cmd_sync(hdev, 0xfc18, sizeof(param), ¶m, |
| 103 | HCI_INIT_TIMEOUT); |
| 104 | if (IS_ERR(skb)) { |
| 105 | int err = PTR_ERR(skb); |
| 106 | BT_ERR("%s: BCM: failed to write update baudrate command (%d)", |
| 107 | hdev->name, err); |
| 108 | return err; |
| 109 | } |
| 110 | |
| 111 | kfree_skb(skb); |
| 112 | |
| 113 | return 0; |
| 114 | } |
| 115 | |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 116 | /* bcm_device_exists should be protected by bcm_device_list_lock */ |
| 117 | static bool bcm_device_exists(struct bcm_device *device) |
| 118 | { |
| 119 | struct list_head *p; |
| 120 | |
| 121 | list_for_each(p, &bcm_device_list) { |
| 122 | struct bcm_device *dev = list_entry(p, struct bcm_device, list); |
| 123 | |
| 124 | if (device == dev) |
| 125 | return true; |
| 126 | } |
| 127 | |
| 128 | return false; |
| 129 | } |
| 130 | |
| 131 | static int bcm_gpio_set_power(struct bcm_device *dev, bool powered) |
| 132 | { |
| 133 | if (powered && !IS_ERR(dev->clk) && !dev->clk_enabled) |
| 134 | clk_enable(dev->clk); |
| 135 | |
| 136 | gpiod_set_value_cansleep(dev->shutdown, powered); |
| 137 | gpiod_set_value_cansleep(dev->device_wakeup, powered); |
| 138 | |
| 139 | if (!powered && !IS_ERR(dev->clk) && dev->clk_enabled) |
| 140 | clk_disable(dev->clk); |
| 141 | |
| 142 | dev->clk_enabled = powered; |
| 143 | |
| 144 | return 0; |
| 145 | } |
| 146 | |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 147 | static int bcm_open(struct hci_uart *hu) |
| 148 | { |
| 149 | struct bcm_data *bcm; |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 150 | struct list_head *p; |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 151 | |
| 152 | BT_DBG("hu %p", hu); |
| 153 | |
| 154 | bcm = kzalloc(sizeof(*bcm), GFP_KERNEL); |
| 155 | if (!bcm) |
| 156 | return -ENOMEM; |
| 157 | |
| 158 | skb_queue_head_init(&bcm->txq); |
| 159 | |
| 160 | hu->priv = bcm; |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 161 | |
| 162 | spin_lock(&bcm_device_list_lock); |
| 163 | list_for_each(p, &bcm_device_list) { |
| 164 | struct bcm_device *dev = list_entry(p, struct bcm_device, list); |
| 165 | |
| 166 | /* Retrieve saved bcm_device based on parent of the |
| 167 | * platform device (saved during device probe) and |
| 168 | * parent of tty device used by hci_uart |
| 169 | */ |
| 170 | if (hu->tty->dev->parent == dev->pdev->dev.parent) { |
| 171 | bcm->dev = dev; |
Frederic Danis | ae05690 | 2015-08-11 16:35:37 +0200 | [diff] [blame^] | 172 | hu->init_speed = dev->init_speed; |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 173 | break; |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | if (bcm->dev) |
| 178 | bcm_gpio_set_power(bcm->dev, true); |
| 179 | |
| 180 | spin_unlock(&bcm_device_list_lock); |
| 181 | |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 182 | return 0; |
| 183 | } |
| 184 | |
| 185 | static int bcm_close(struct hci_uart *hu) |
| 186 | { |
| 187 | struct bcm_data *bcm = hu->priv; |
| 188 | |
| 189 | BT_DBG("hu %p", hu); |
| 190 | |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 191 | /* Protect bcm->dev against removal of the device or driver */ |
| 192 | spin_lock(&bcm_device_list_lock); |
| 193 | if (bcm_device_exists(bcm->dev)) |
| 194 | bcm_gpio_set_power(bcm->dev, false); |
| 195 | spin_unlock(&bcm_device_list_lock); |
| 196 | |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 197 | skb_queue_purge(&bcm->txq); |
| 198 | kfree_skb(bcm->rx_skb); |
| 199 | kfree(bcm); |
| 200 | |
| 201 | hu->priv = NULL; |
| 202 | return 0; |
| 203 | } |
| 204 | |
| 205 | static int bcm_flush(struct hci_uart *hu) |
| 206 | { |
| 207 | struct bcm_data *bcm = hu->priv; |
| 208 | |
| 209 | BT_DBG("hu %p", hu); |
| 210 | |
| 211 | skb_queue_purge(&bcm->txq); |
| 212 | |
| 213 | return 0; |
| 214 | } |
| 215 | |
| 216 | static int bcm_setup(struct hci_uart *hu) |
| 217 | { |
Frederic Danis | 6be09b4 | 2015-05-28 11:25:05 +0200 | [diff] [blame] | 218 | char fw_name[64]; |
| 219 | const struct firmware *fw; |
Frederic Danis | 960ef1d | 2015-06-18 12:43:27 +0200 | [diff] [blame] | 220 | unsigned int speed; |
Frederic Danis | 6be09b4 | 2015-05-28 11:25:05 +0200 | [diff] [blame] | 221 | int err; |
| 222 | |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 223 | BT_DBG("hu %p", hu); |
| 224 | |
| 225 | hu->hdev->set_bdaddr = btbcm_set_bdaddr; |
| 226 | |
Frederic Danis | 6be09b4 | 2015-05-28 11:25:05 +0200 | [diff] [blame] | 227 | err = btbcm_initialize(hu->hdev, fw_name, sizeof(fw_name)); |
| 228 | if (err) |
| 229 | return err; |
| 230 | |
| 231 | err = request_firmware(&fw, fw_name, &hu->hdev->dev); |
| 232 | if (err < 0) { |
| 233 | BT_INFO("%s: BCM: Patch %s not found", hu->hdev->name, fw_name); |
| 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | err = btbcm_patchram(hu->hdev, fw); |
| 238 | if (err) { |
| 239 | BT_INFO("%s: BCM: Patch failed (%d)", hu->hdev->name, err); |
| 240 | goto finalize; |
| 241 | } |
| 242 | |
Frederic Danis | 960ef1d | 2015-06-18 12:43:27 +0200 | [diff] [blame] | 243 | /* Init speed if any */ |
| 244 | if (hu->init_speed) |
| 245 | speed = hu->init_speed; |
| 246 | else if (hu->proto->init_speed) |
| 247 | speed = hu->proto->init_speed; |
| 248 | else |
| 249 | speed = 0; |
Frederic Danis | 6be09b4 | 2015-05-28 11:25:05 +0200 | [diff] [blame] | 250 | |
Frederic Danis | 960ef1d | 2015-06-18 12:43:27 +0200 | [diff] [blame] | 251 | if (speed) |
| 252 | hci_uart_set_baudrate(hu, speed); |
| 253 | |
| 254 | /* Operational speed if any */ |
| 255 | if (hu->oper_speed) |
| 256 | speed = hu->oper_speed; |
| 257 | else if (hu->proto->oper_speed) |
| 258 | speed = hu->proto->oper_speed; |
| 259 | else |
| 260 | speed = 0; |
| 261 | |
| 262 | if (speed) { |
| 263 | err = bcm_set_baudrate(hu, speed); |
Frederic Danis | 61b2fc2 | 2015-06-09 16:15:37 +0200 | [diff] [blame] | 264 | if (!err) |
Frederic Danis | 960ef1d | 2015-06-18 12:43:27 +0200 | [diff] [blame] | 265 | hci_uart_set_baudrate(hu, speed); |
Frederic Danis | 61b2fc2 | 2015-06-09 16:15:37 +0200 | [diff] [blame] | 266 | } |
| 267 | |
Frederic Danis | 6be09b4 | 2015-05-28 11:25:05 +0200 | [diff] [blame] | 268 | finalize: |
| 269 | release_firmware(fw); |
| 270 | |
| 271 | err = btbcm_finalize(hu->hdev); |
| 272 | |
| 273 | return err; |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 274 | } |
| 275 | |
Marcel Holtmann | 79b8df9 | 2015-04-05 23:44:59 -0700 | [diff] [blame] | 276 | static const struct h4_recv_pkt bcm_recv_pkts[] = { |
| 277 | { H4_RECV_ACL, .recv = hci_recv_frame }, |
| 278 | { H4_RECV_SCO, .recv = hci_recv_frame }, |
| 279 | { H4_RECV_EVENT, .recv = hci_recv_frame }, |
| 280 | }; |
| 281 | |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 282 | static int bcm_recv(struct hci_uart *hu, const void *data, int count) |
| 283 | { |
| 284 | struct bcm_data *bcm = hu->priv; |
| 285 | |
| 286 | if (!test_bit(HCI_UART_REGISTERED, &hu->flags)) |
| 287 | return -EUNATCH; |
| 288 | |
Marcel Holtmann | 79b8df9 | 2015-04-05 23:44:59 -0700 | [diff] [blame] | 289 | bcm->rx_skb = h4_recv_buf(hu->hdev, bcm->rx_skb, data, count, |
| 290 | bcm_recv_pkts, ARRAY_SIZE(bcm_recv_pkts)); |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 291 | if (IS_ERR(bcm->rx_skb)) { |
| 292 | int err = PTR_ERR(bcm->rx_skb); |
| 293 | BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err); |
Chan-yeol Park | 3713416 | 2015-06-17 21:10:39 +0900 | [diff] [blame] | 294 | bcm->rx_skb = NULL; |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 295 | return err; |
| 296 | } |
| 297 | |
| 298 | return count; |
| 299 | } |
| 300 | |
| 301 | static int bcm_enqueue(struct hci_uart *hu, struct sk_buff *skb) |
| 302 | { |
| 303 | struct bcm_data *bcm = hu->priv; |
| 304 | |
| 305 | BT_DBG("hu %p skb %p", hu, skb); |
| 306 | |
| 307 | /* Prepend skb with frame type */ |
| 308 | memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1); |
| 309 | skb_queue_tail(&bcm->txq, skb); |
| 310 | |
| 311 | return 0; |
| 312 | } |
| 313 | |
| 314 | static struct sk_buff *bcm_dequeue(struct hci_uart *hu) |
| 315 | { |
| 316 | struct bcm_data *bcm = hu->priv; |
| 317 | |
| 318 | return skb_dequeue(&bcm->txq); |
| 319 | } |
| 320 | |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 321 | static const struct acpi_gpio_params device_wakeup_gpios = { 0, 0, false }; |
| 322 | static const struct acpi_gpio_params shutdown_gpios = { 1, 0, false }; |
| 323 | |
| 324 | static const struct acpi_gpio_mapping acpi_bcm_default_gpios[] = { |
| 325 | { "device-wakeup-gpios", &device_wakeup_gpios, 1 }, |
| 326 | { "shutdown-gpios", &shutdown_gpios, 1 }, |
| 327 | { }, |
| 328 | }; |
| 329 | |
Frederic Danis | ae05690 | 2015-08-11 16:35:37 +0200 | [diff] [blame^] | 330 | static int bcm_resource(struct acpi_resource *ares, void *data) |
| 331 | { |
| 332 | struct bcm_device *dev = data; |
| 333 | |
| 334 | if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) { |
| 335 | struct acpi_resource_uart_serialbus *sb; |
| 336 | |
| 337 | sb = &ares->data.uart_serial_bus; |
| 338 | if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_UART) |
| 339 | dev->init_speed = sb->default_baud_rate; |
| 340 | } |
| 341 | |
| 342 | /* Always tell the ACPI core to skip this resource */ |
| 343 | return 1; |
| 344 | } |
| 345 | |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 346 | static int bcm_acpi_probe(struct bcm_device *dev) |
| 347 | { |
| 348 | struct platform_device *pdev = dev->pdev; |
| 349 | const struct acpi_device_id *id; |
| 350 | struct gpio_desc *gpio; |
Frederic Danis | ae05690 | 2015-08-11 16:35:37 +0200 | [diff] [blame^] | 351 | struct acpi_device *adev; |
| 352 | LIST_HEAD(resources); |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 353 | int ret; |
| 354 | |
| 355 | id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev); |
| 356 | if (!id) |
| 357 | return -ENODEV; |
| 358 | |
| 359 | /* Retrieve GPIO data */ |
| 360 | dev->name = dev_name(&pdev->dev); |
| 361 | ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev), |
| 362 | acpi_bcm_default_gpios); |
| 363 | if (ret) |
| 364 | return ret; |
| 365 | |
| 366 | dev->clk = devm_clk_get(&pdev->dev, NULL); |
| 367 | |
| 368 | gpio = devm_gpiod_get(&pdev->dev, "device-wakeup"); |
| 369 | if (!IS_ERR(gpio)) { |
| 370 | ret = gpiod_direction_output(gpio, 0); |
| 371 | if (ret) |
| 372 | return ret; |
| 373 | dev->device_wakeup = gpio; |
| 374 | } |
| 375 | |
| 376 | gpio = devm_gpiod_get(&pdev->dev, "shutdown"); |
| 377 | if (!IS_ERR(gpio)) { |
| 378 | ret = gpiod_direction_output(gpio, 0); |
| 379 | if (ret) |
| 380 | return ret; |
| 381 | dev->shutdown = gpio; |
| 382 | } |
| 383 | |
| 384 | /* Make sure at-least one of the GPIO is defined and that |
| 385 | * a name is specified for this instance |
| 386 | */ |
| 387 | if ((!dev->device_wakeup && !dev->shutdown) || !dev->name) { |
| 388 | dev_err(&pdev->dev, "invalid platform data\n"); |
| 389 | return -EINVAL; |
| 390 | } |
| 391 | |
Frederic Danis | ae05690 | 2015-08-11 16:35:37 +0200 | [diff] [blame^] | 392 | /* Retrieve UART ACPI info */ |
| 393 | adev = ACPI_COMPANION(&dev->pdev->dev); |
| 394 | if (!adev) |
| 395 | return 0; |
| 396 | |
| 397 | acpi_dev_get_resources(adev, &resources, bcm_resource, dev); |
| 398 | |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 399 | return 0; |
| 400 | } |
| 401 | |
| 402 | static int bcm_probe(struct platform_device *pdev) |
| 403 | { |
| 404 | struct bcm_device *dev; |
| 405 | struct acpi_device_id *pdata = pdev->dev.platform_data; |
| 406 | int ret; |
| 407 | |
| 408 | dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); |
| 409 | if (!dev) |
| 410 | return -ENOMEM; |
| 411 | |
| 412 | dev->pdev = pdev; |
| 413 | |
| 414 | if (ACPI_HANDLE(&pdev->dev)) { |
| 415 | ret = bcm_acpi_probe(dev); |
| 416 | if (ret) |
| 417 | return ret; |
| 418 | } else if (pdata) { |
| 419 | dev->name = pdata->id; |
| 420 | } else { |
| 421 | return -ENODEV; |
| 422 | } |
| 423 | |
| 424 | platform_set_drvdata(pdev, dev); |
| 425 | |
| 426 | dev_info(&pdev->dev, "%s device registered.\n", dev->name); |
| 427 | |
| 428 | /* Place this instance on the device list */ |
| 429 | spin_lock(&bcm_device_list_lock); |
| 430 | list_add_tail(&dev->list, &bcm_device_list); |
| 431 | spin_unlock(&bcm_device_list_lock); |
| 432 | |
| 433 | bcm_gpio_set_power(dev, false); |
| 434 | |
| 435 | return 0; |
| 436 | } |
| 437 | |
| 438 | static int bcm_remove(struct platform_device *pdev) |
| 439 | { |
| 440 | struct bcm_device *dev = platform_get_drvdata(pdev); |
| 441 | |
| 442 | spin_lock(&bcm_device_list_lock); |
| 443 | list_del(&dev->list); |
| 444 | spin_unlock(&bcm_device_list_lock); |
| 445 | |
| 446 | acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev)); |
| 447 | |
| 448 | dev_info(&pdev->dev, "%s device unregistered.\n", dev->name); |
| 449 | |
| 450 | return 0; |
| 451 | } |
| 452 | |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 453 | static const struct hci_uart_proto bcm_proto = { |
| 454 | .id = HCI_UART_BCM, |
| 455 | .name = "BCM", |
Frederic Danis | 61b2fc2 | 2015-06-09 16:15:37 +0200 | [diff] [blame] | 456 | .init_speed = 115200, |
| 457 | .oper_speed = 4000000, |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 458 | .open = bcm_open, |
| 459 | .close = bcm_close, |
| 460 | .flush = bcm_flush, |
| 461 | .setup = bcm_setup, |
Frederic Danis | 61b2fc2 | 2015-06-09 16:15:37 +0200 | [diff] [blame] | 462 | .set_baudrate = bcm_set_baudrate, |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 463 | .recv = bcm_recv, |
| 464 | .enqueue = bcm_enqueue, |
| 465 | .dequeue = bcm_dequeue, |
| 466 | }; |
| 467 | |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 468 | #ifdef CONFIG_ACPI |
| 469 | static const struct acpi_device_id bcm_acpi_match[] = { |
| 470 | { "BCM2E39", 0 }, |
| 471 | { "BCM2E67", 0 }, |
| 472 | { }, |
| 473 | }; |
| 474 | MODULE_DEVICE_TABLE(acpi, bcm_acpi_match); |
| 475 | #endif |
| 476 | |
| 477 | static struct platform_driver bcm_driver = { |
| 478 | .probe = bcm_probe, |
| 479 | .remove = bcm_remove, |
| 480 | .driver = { |
| 481 | .name = "hci_bcm", |
| 482 | .acpi_match_table = ACPI_PTR(bcm_acpi_match), |
| 483 | }, |
| 484 | }; |
| 485 | |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 486 | int __init bcm_init(void) |
| 487 | { |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 488 | platform_driver_register(&bcm_driver); |
| 489 | |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 490 | return hci_uart_register_proto(&bcm_proto); |
| 491 | } |
| 492 | |
| 493 | int __exit bcm_deinit(void) |
| 494 | { |
Frederic Danis | 0395ffc | 2015-08-11 16:35:35 +0200 | [diff] [blame] | 495 | platform_driver_unregister(&bcm_driver); |
| 496 | |
Marcel Holtmann | bdd8818 | 2015-04-05 22:52:18 -0700 | [diff] [blame] | 497 | return hci_uart_unregister_proto(&bcm_proto); |
| 498 | } |