]> git.kernelconcepts.de Git - karo-tx-linux.git/blobdiff - drivers/bluetooth/hci_bcm.c
Merge remote-tracking branch 'omap/for-next'
[karo-tx-linux.git] / drivers / bluetooth / hci_bcm.c
index 835bfab88ef56acecbf9887d2e13ea912af750cf..cb852cc750b78256cd05fb62eda18dfb28c246aa 100644 (file)
@@ -31,6 +31,9 @@
 #include <linux/clk.h>
 #include <linux/gpio/consumer.h>
 #include <linux/tty.h>
+#include <linux/interrupt.h>
+#include <linux/dmi.h>
+#include <linux/pm_runtime.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
 #include "btbcm.h"
 #include "hci_uart.h"
 
+#define BCM_LM_DIAG_PKT 0x07
+#define BCM_LM_DIAG_SIZE 63
+
+#define BCM_AUTOSUSPEND_DELAY  5000 /* default autosleep delay */
+
 struct bcm_device {
        struct list_head        list;
 
@@ -51,8 +59,10 @@ struct bcm_device {
        bool                    clk_enabled;
 
        u32                     init_speed;
+       int                     irq;
+       u8                      irq_polarity;
 
-#ifdef CONFIG_PM_SLEEP
+#ifdef CONFIG_PM
        struct hci_uart         *hu;
        bool                    is_suspended; /* suspend/resume flag */
 #endif
@@ -66,7 +76,7 @@ struct bcm_data {
 };
 
 /* List of BCM BT UART devices */
-static DEFINE_SPINLOCK(bcm_device_lock);
+static DEFINE_MUTEX(bcm_device_lock);
 static LIST_HEAD(bcm_device_list);
 
 static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed)
@@ -80,7 +90,7 @@ static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed)
 
                clock.type = BCM_UART_CLOCK_48MHZ;
 
-               BT_DBG("%s: Set Controller clock (%d)", hdev->name, clock.type);
+               bt_dev_dbg(hdev, "Set Controller clock (%d)", clock.type);
 
                /* This Broadcom specific command changes the UART's controller
                 * clock for baud rate > 3000000.
@@ -88,15 +98,15 @@ static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed)
                skb = __hci_cmd_sync(hdev, 0xfc45, 1, &clock, HCI_INIT_TIMEOUT);
                if (IS_ERR(skb)) {
                        int err = PTR_ERR(skb);
-                       BT_ERR("%s: BCM: failed to write clock command (%d)",
-                              hdev->name, err);
+                       bt_dev_err(hdev, "BCM: failed to write clock (%d)",
+                                  err);
                        return err;
                }
 
                kfree_skb(skb);
        }
 
-       BT_DBG("%s: Set Controller UART speed to %d bit/s", hdev->name, speed);
+       bt_dev_dbg(hdev, "Set Controller UART speed to %d bit/s", speed);
 
        param.zero = cpu_to_le16(0);
        param.baud_rate = cpu_to_le32(speed);
@@ -108,8 +118,8 @@ static int bcm_set_baudrate(struct hci_uart *hu, unsigned int speed)
                             HCI_INIT_TIMEOUT);
        if (IS_ERR(skb)) {
                int err = PTR_ERR(skb);
-               BT_ERR("%s: BCM: failed to write update baudrate command (%d)",
-                      hdev->name, err);
+               bt_dev_err(hdev, "BCM: failed to write update baudrate (%d)",
+                          err);
                return err;
        }
 
@@ -149,12 +159,125 @@ static int bcm_gpio_set_power(struct bcm_device *dev, bool powered)
        return 0;
 }
 
+#ifdef CONFIG_PM
+static irqreturn_t bcm_host_wake(int irq, void *data)
+{
+       struct bcm_device *bdev = data;
+
+       bt_dev_dbg(bdev, "Host wake IRQ");
+
+       pm_runtime_get(&bdev->pdev->dev);
+       pm_runtime_mark_last_busy(&bdev->pdev->dev);
+       pm_runtime_put_autosuspend(&bdev->pdev->dev);
+
+       return IRQ_HANDLED;
+}
+
+static int bcm_request_irq(struct bcm_data *bcm)
+{
+       struct bcm_device *bdev = bcm->dev;
+       int err = 0;
+
+       /* If this is not a platform device, do not enable PM functionalities */
+       mutex_lock(&bcm_device_lock);
+       if (!bcm_device_exists(bdev)) {
+               err = -ENODEV;
+               goto unlock;
+       }
+
+       if (bdev->irq > 0) {
+               err = devm_request_irq(&bdev->pdev->dev, bdev->irq,
+                                      bcm_host_wake, IRQF_TRIGGER_RISING,
+                                      "host_wake", bdev);
+               if (err)
+                       goto unlock;
+
+               device_init_wakeup(&bdev->pdev->dev, true);
+
+               pm_runtime_set_autosuspend_delay(&bdev->pdev->dev,
+                                                BCM_AUTOSUSPEND_DELAY);
+               pm_runtime_use_autosuspend(&bdev->pdev->dev);
+               pm_runtime_set_active(&bdev->pdev->dev);
+               pm_runtime_enable(&bdev->pdev->dev);
+       }
+
+unlock:
+       mutex_unlock(&bcm_device_lock);
+
+       return err;
+}
+
+static const struct bcm_set_sleep_mode default_sleep_params = {
+       .sleep_mode = 1,        /* 0=Disabled, 1=UART, 2=Reserved, 3=USB */
+       .idle_host = 2,         /* idle threshold HOST, in 300ms */
+       .idle_dev = 2,          /* idle threshold device, in 300ms */
+       .bt_wake_active = 1,    /* BT_WAKE active mode: 1 = high, 0 = low */
+       .host_wake_active = 0,  /* HOST_WAKE active mode: 1 = high, 0 = low */
+       .allow_host_sleep = 1,  /* Allow host sleep in SCO flag */
+       .combine_modes = 1,     /* Combine sleep and LPM flag */
+       .tristate_control = 0,  /* Allow tri-state control of UART tx flag */
+       /* Irrelevant USB flags */
+       .usb_auto_sleep = 0,
+       .usb_resume_timeout = 0,
+       .pulsed_host_wake = 0,
+       .break_to_host = 0
+};
+
+static int bcm_setup_sleep(struct hci_uart *hu)
+{
+       struct bcm_data *bcm = hu->priv;
+       struct sk_buff *skb;
+       struct bcm_set_sleep_mode sleep_params = default_sleep_params;
+
+       sleep_params.host_wake_active = !bcm->dev->irq_polarity;
+
+       skb = __hci_cmd_sync(hu->hdev, 0xfc27, sizeof(sleep_params),
+                            &sleep_params, HCI_INIT_TIMEOUT);
+       if (IS_ERR(skb)) {
+               int err = PTR_ERR(skb);
+               bt_dev_err(hu->hdev, "Sleep VSC failed (%d)", err);
+               return err;
+       }
+       kfree_skb(skb);
+
+       bt_dev_dbg(hu->hdev, "Set Sleep Parameters VSC succeeded");
+
+       return 0;
+}
+#else
+static inline int bcm_request_irq(struct bcm_data *bcm) { return 0; }
+static inline int bcm_setup_sleep(struct hci_uart *hu) { return 0; }
+#endif
+
+static int bcm_set_diag(struct hci_dev *hdev, bool enable)
+{
+       struct hci_uart *hu = hci_get_drvdata(hdev);
+       struct bcm_data *bcm = hu->priv;
+       struct sk_buff *skb;
+
+       if (!test_bit(HCI_RUNNING, &hdev->flags))
+               return -ENETDOWN;
+
+       skb = bt_skb_alloc(3, GFP_KERNEL);
+       if (!skb)
+               return -ENOMEM;
+
+       *skb_put(skb, 1) = BCM_LM_DIAG_PKT;
+       *skb_put(skb, 1) = 0xf0;
+       *skb_put(skb, 1) = enable;
+
+       skb_queue_tail(&bcm->txq, skb);
+       hci_uart_tx_wakeup(hu);
+
+       return 0;
+}
+
 static int bcm_open(struct hci_uart *hu)
 {
        struct bcm_data *bcm;
        struct list_head *p;
 
-       BT_DBG("hu %p", hu);
+       bt_dev_dbg(hu->hdev, "hu %p", hu);
 
        bcm = kzalloc(sizeof(*bcm), GFP_KERNEL);
        if (!bcm)
@@ -164,7 +287,7 @@ static int bcm_open(struct hci_uart *hu)
 
        hu->priv = bcm;
 
-       spin_lock(&bcm_device_lock);
+       mutex_lock(&bcm_device_lock);
        list_for_each(p, &bcm_device_list) {
                struct bcm_device *dev = list_entry(p, struct bcm_device, list);
 
@@ -175,17 +298,15 @@ static int bcm_open(struct hci_uart *hu)
                if (hu->tty->dev->parent == dev->pdev->dev.parent) {
                        bcm->dev = dev;
                        hu->init_speed = dev->init_speed;
-#ifdef CONFIG_PM_SLEEP
+#ifdef CONFIG_PM
                        dev->hu = hu;
 #endif
+                       bcm_gpio_set_power(bcm->dev, true);
                        break;
                }
        }
 
-       if (bcm->dev)
-               bcm_gpio_set_power(bcm->dev, true);
-
-       spin_unlock(&bcm_device_lock);
+       mutex_unlock(&bcm_device_lock);
 
        return 0;
 }
@@ -193,18 +314,27 @@ static int bcm_open(struct hci_uart *hu)
 static int bcm_close(struct hci_uart *hu)
 {
        struct bcm_data *bcm = hu->priv;
+       struct bcm_device *bdev = bcm->dev;
 
-       BT_DBG("hu %p", hu);
+       bt_dev_dbg(hu->hdev, "hu %p", hu);
 
        /* Protect bcm->dev against removal of the device or driver */
-       spin_lock(&bcm_device_lock);
-       if (bcm_device_exists(bcm->dev)) {
-               bcm_gpio_set_power(bcm->dev, false);
-#ifdef CONFIG_PM_SLEEP
-               bcm->dev->hu = NULL;
+       mutex_lock(&bcm_device_lock);
+       if (bcm_device_exists(bdev)) {
+               bcm_gpio_set_power(bdev, false);
+#ifdef CONFIG_PM
+               pm_runtime_disable(&bdev->pdev->dev);
+               pm_runtime_set_suspended(&bdev->pdev->dev);
+
+               if (device_can_wakeup(&bdev->pdev->dev)) {
+                       devm_free_irq(&bdev->pdev->dev, bdev->irq, bdev);
+                       device_init_wakeup(&bdev->pdev->dev, false);
+               }
+
+               bdev->hu = NULL;
 #endif
        }
-       spin_unlock(&bcm_device_lock);
+       mutex_unlock(&bcm_device_lock);
 
        skb_queue_purge(&bcm->txq);
        kfree_skb(bcm->rx_skb);
@@ -218,7 +348,7 @@ static int bcm_flush(struct hci_uart *hu)
 {
        struct bcm_data *bcm = hu->priv;
 
-       BT_DBG("hu %p", hu);
+       bt_dev_dbg(hu->hdev, "hu %p", hu);
 
        skb_queue_purge(&bcm->txq);
 
@@ -227,13 +357,15 @@ static int bcm_flush(struct hci_uart *hu)
 
 static int bcm_setup(struct hci_uart *hu)
 {
+       struct bcm_data *bcm = hu->priv;
        char fw_name[64];
        const struct firmware *fw;
        unsigned int speed;
        int err;
 
-       BT_DBG("hu %p", hu);
+       bt_dev_dbg(hu->hdev, "hu %p", hu);
 
+       hu->hdev->set_diag = bcm_set_diag;
        hu->hdev->set_bdaddr = btbcm_set_bdaddr;
 
        err = btbcm_initialize(hu->hdev, fw_name, sizeof(fw_name));
@@ -242,13 +374,13 @@ static int bcm_setup(struct hci_uart *hu)
 
        err = request_firmware(&fw, fw_name, &hu->hdev->dev);
        if (err < 0) {
-               BT_INFO("%s: BCM: Patch %s not found", hu->hdev->name, fw_name);
+               bt_dev_info(hu->hdev, "BCM: Patch %s not found", fw_name);
                return 0;
        }
 
        err = btbcm_patchram(hu->hdev, fw);
        if (err) {
-               BT_INFO("%s: BCM: Patch failed (%d)", hu->hdev->name, err);
+               bt_dev_info(hu->hdev, "BCM: Patch failed (%d)", err);
                goto finalize;
        }
 
@@ -281,14 +413,28 @@ finalize:
        release_firmware(fw);
 
        err = btbcm_finalize(hu->hdev);
+       if (err)
+               return err;
+
+       err = bcm_request_irq(bcm);
+       if (!err)
+               err = bcm_setup_sleep(hu);
 
        return err;
 }
 
+#define BCM_RECV_LM_DIAG \
+       .type = BCM_LM_DIAG_PKT, \
+       .hlen = BCM_LM_DIAG_SIZE, \
+       .loff = 0, \
+       .lsize = 0, \
+       .maxlen = BCM_LM_DIAG_SIZE
+
 static const struct h4_recv_pkt bcm_recv_pkts[] = {
-       { H4_RECV_ACL,   .recv = hci_recv_frame },
-       { H4_RECV_SCO,   .recv = hci_recv_frame },
-       { H4_RECV_EVENT, .recv = hci_recv_frame },
+       { H4_RECV_ACL,      .recv = hci_recv_frame },
+       { H4_RECV_SCO,      .recv = hci_recv_frame },
+       { H4_RECV_EVENT,    .recv = hci_recv_frame },
+       { BCM_RECV_LM_DIAG, .recv = hci_recv_diag  },
 };
 
 static int bcm_recv(struct hci_uart *hu, const void *data, int count)
@@ -302,9 +448,18 @@ static int bcm_recv(struct hci_uart *hu, const void *data, int count)
                                  bcm_recv_pkts, ARRAY_SIZE(bcm_recv_pkts));
        if (IS_ERR(bcm->rx_skb)) {
                int err = PTR_ERR(bcm->rx_skb);
-               BT_ERR("%s: Frame reassembly failed (%d)", hu->hdev->name, err);
+               bt_dev_err(hu->hdev, "Frame reassembly failed (%d)", err);
                bcm->rx_skb = NULL;
                return err;
+       } else if (!bcm->rx_skb) {
+               /* Delay auto-suspend when receiving completed packet */
+               mutex_lock(&bcm_device_lock);
+               if (bcm->dev && bcm_device_exists(bcm->dev)) {
+                       pm_runtime_get(&bcm->dev->pdev->dev);
+                       pm_runtime_mark_last_busy(&bcm->dev->pdev->dev);
+                       pm_runtime_put_autosuspend(&bcm->dev->pdev->dev);
+               }
+               mutex_unlock(&bcm_device_lock);
        }
 
        return count;
@@ -314,7 +469,7 @@ static int bcm_enqueue(struct hci_uart *hu, struct sk_buff *skb)
 {
        struct bcm_data *bcm = hu->priv;
 
-       BT_DBG("hu %p skb %p", hu, skb);
+       bt_dev_dbg(hu->hdev, "hu %p skb %p", hu, skb);
 
        /* Prepend skb with frame type */
        memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
@@ -326,39 +481,105 @@ static int bcm_enqueue(struct hci_uart *hu, struct sk_buff *skb)
 static struct sk_buff *bcm_dequeue(struct hci_uart *hu)
 {
        struct bcm_data *bcm = hu->priv;
+       struct sk_buff *skb = NULL;
+       struct bcm_device *bdev = NULL;
+
+       mutex_lock(&bcm_device_lock);
+
+       if (bcm_device_exists(bcm->dev)) {
+               bdev = bcm->dev;
+               pm_runtime_get_sync(&bdev->pdev->dev);
+               /* Shall be resumed here */
+       }
+
+       skb = skb_dequeue(&bcm->txq);
+
+       if (bdev) {
+               pm_runtime_mark_last_busy(&bdev->pdev->dev);
+               pm_runtime_put_autosuspend(&bdev->pdev->dev);
+       }
+
+       mutex_unlock(&bcm_device_lock);
 
-       return skb_dequeue(&bcm->txq);
+       return skb;
 }
 
-#ifdef CONFIG_PM_SLEEP
-/* Platform suspend callback */
-static int bcm_suspend(struct device *dev)
+#ifdef CONFIG_PM
+static int bcm_suspend_device(struct device *dev)
 {
        struct bcm_device *bdev = platform_get_drvdata(to_platform_device(dev));
 
-       BT_DBG("suspend (%p): is_suspended %d", bdev, bdev->is_suspended);
+       bt_dev_dbg(bdev, "");
 
-       spin_lock(&bcm_device_lock);
-
-       if (!bdev->hu)
-               goto unlock;
-
-       if (!bdev->is_suspended) {
+       if (!bdev->is_suspended && bdev->hu) {
                hci_uart_set_flow_control(bdev->hu, true);
 
-               /* Once this callback returns, driver suspends BT via GPIO */
+               /* Once this returns, driver suspends BT via GPIO */
                bdev->is_suspended = true;
        }
 
        /* Suspend the device */
        if (bdev->device_wakeup) {
                gpiod_set_value(bdev->device_wakeup, false);
-               BT_DBG("suspend, delaying 15 ms");
+               bt_dev_dbg(bdev, "suspend, delaying 15 ms");
                mdelay(15);
        }
 
+       return 0;
+}
+
+static int bcm_resume_device(struct device *dev)
+{
+       struct bcm_device *bdev = platform_get_drvdata(to_platform_device(dev));
+
+       bt_dev_dbg(bdev, "");
+
+       if (bdev->device_wakeup) {
+               gpiod_set_value(bdev->device_wakeup, true);
+               bt_dev_dbg(bdev, "resume, delaying 15 ms");
+               mdelay(15);
+       }
+
+       /* When this executes, the device has woken up already */
+       if (bdev->is_suspended && bdev->hu) {
+               bdev->is_suspended = false;
+
+               hci_uart_set_flow_control(bdev->hu, false);
+       }
+
+       return 0;
+}
+#endif
+
+#ifdef CONFIG_PM_SLEEP
+/* Platform suspend callback */
+static int bcm_suspend(struct device *dev)
+{
+       struct bcm_device *bdev = platform_get_drvdata(to_platform_device(dev));
+       int error;
+
+       bt_dev_dbg(bdev, "suspend: is_suspended %d", bdev->is_suspended);
+
+       /* bcm_suspend can be called at any time as long as platform device is
+        * bound, so it should use bcm_device_lock to protect access to hci_uart
+        * and device_wake-up GPIO.
+        */
+       mutex_lock(&bcm_device_lock);
+
+       if (!bdev->hu)
+               goto unlock;
+
+       if (pm_runtime_active(dev))
+               bcm_suspend_device(dev);
+
+       if (device_may_wakeup(&bdev->pdev->dev)) {
+               error = enable_irq_wake(bdev->irq);
+               if (!error)
+                       bt_dev_dbg(bdev, "BCM irq: enabled");
+       }
+
 unlock:
-       spin_unlock(&bcm_device_lock);
+       mutex_unlock(&bcm_device_lock);
 
        return 0;
 }
@@ -368,28 +589,30 @@ static int bcm_resume(struct device *dev)
 {
        struct bcm_device *bdev = platform_get_drvdata(to_platform_device(dev));
 
-       BT_DBG("resume (%p): is_suspended %d", bdev, bdev->is_suspended);
+       bt_dev_dbg(bdev, "resume: is_suspended %d", bdev->is_suspended);
 
-       spin_lock(&bcm_device_lock);
+       /* bcm_resume can be called at any time as long as platform device is
+        * bound, so it should use bcm_device_lock to protect access to hci_uart
+        * and device_wake-up GPIO.
+        */
+       mutex_lock(&bcm_device_lock);
 
        if (!bdev->hu)
                goto unlock;
 
-       if (bdev->device_wakeup) {
-               gpiod_set_value(bdev->device_wakeup, true);
-               BT_DBG("resume, delaying 15 ms");
-               mdelay(15);
+       if (device_may_wakeup(&bdev->pdev->dev)) {
+               disable_irq_wake(bdev->irq);
+               bt_dev_dbg(bdev, "BCM irq: disabled");
        }
 
-       /* When this callback executes, the device has woken up already */
-       if (bdev->is_suspended) {
-               bdev->is_suspended = false;
-
-               hci_uart_set_flow_control(bdev->hu, false);
-       }
+       bcm_resume_device(dev);
 
 unlock:
-       spin_unlock(&bcm_device_lock);
+       mutex_unlock(&bcm_device_lock);
+
+       pm_runtime_disable(dev);
+       pm_runtime_set_active(dev);
+       pm_runtime_enable(dev);
 
        return 0;
 }
@@ -397,24 +620,59 @@ unlock:
 
 static const struct acpi_gpio_params device_wakeup_gpios = { 0, 0, false };
 static const struct acpi_gpio_params shutdown_gpios = { 1, 0, false };
+static const struct acpi_gpio_params host_wakeup_gpios = { 2, 0, false };
 
 static const struct acpi_gpio_mapping acpi_bcm_default_gpios[] = {
        { "device-wakeup-gpios", &device_wakeup_gpios, 1 },
        { "shutdown-gpios", &shutdown_gpios, 1 },
+       { "host-wakeup-gpios", &host_wakeup_gpios, 1 },
        { },
 };
 
 #ifdef CONFIG_ACPI
+static u8 acpi_active_low = ACPI_ACTIVE_LOW;
+
+/* IRQ polarity of some chipsets are not defined correctly in ACPI table. */
+static const struct dmi_system_id bcm_wrong_irq_dmi_table[] = {
+       {
+               .ident = "Asus T100TA",
+               .matches = {
+                       DMI_EXACT_MATCH(DMI_SYS_VENDOR,
+                                       "ASUSTeK COMPUTER INC."),
+                       DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "T100TA"),
+               },
+               .driver_data = &acpi_active_low,
+       },
+       { }
+};
+
 static int bcm_resource(struct acpi_resource *ares, void *data)
 {
        struct bcm_device *dev = data;
-
-       if (ares->type == ACPI_RESOURCE_TYPE_SERIAL_BUS) {
-               struct acpi_resource_uart_serialbus *sb;
-
+       struct acpi_resource_extended_irq *irq;
+       struct acpi_resource_gpio *gpio;
+       struct acpi_resource_uart_serialbus *sb;
+
+       switch (ares->type) {
+       case ACPI_RESOURCE_TYPE_EXTENDED_IRQ:
+               irq = &ares->data.extended_irq;
+               dev->irq_polarity = irq->polarity;
+               break;
+
+       case ACPI_RESOURCE_TYPE_GPIO:
+               gpio = &ares->data.gpio;
+               if (gpio->connection_type == ACPI_RESOURCE_GPIO_TYPE_INT)
+                       dev->irq_polarity = gpio->polarity;
+               break;
+
+       case ACPI_RESOURCE_TYPE_SERIAL_BUS:
                sb = &ares->data.uart_serial_bus;
                if (sb->type == ACPI_RESOURCE_SERIAL_TYPE_UART)
                        dev->init_speed = sb->default_baud_rate;
+               break;
+
+       default:
+               break;
        }
 
        /* Always tell the ACPI core to skip this resource */
@@ -424,15 +682,10 @@ static int bcm_resource(struct acpi_resource *ares, void *data)
 static int bcm_acpi_probe(struct bcm_device *dev)
 {
        struct platform_device *pdev = dev->pdev;
-       const struct acpi_device_id *id;
-       struct acpi_device *adev;
        LIST_HEAD(resources);
+       const struct dmi_system_id *dmi_id;
        int ret;
 
-       id = acpi_match_device(pdev->dev.driver->acpi_match_table, &pdev->dev);
-       if (!id)
-               return -ENODEV;
-
        /* Retrieve GPIO data */
        dev->name = dev_name(&pdev->dev);
        ret = acpi_dev_add_driver_gpios(ACPI_COMPANION(&pdev->dev),
@@ -453,6 +706,21 @@ static int bcm_acpi_probe(struct bcm_device *dev)
        if (IS_ERR(dev->shutdown))
                return PTR_ERR(dev->shutdown);
 
+       /* IRQ can be declared in ACPI table as Interrupt or GpioInt */
+       dev->irq = platform_get_irq(pdev, 0);
+       if (dev->irq <= 0) {
+               struct gpio_desc *gpio;
+
+               gpio = devm_gpiod_get_optional(&pdev->dev, "host-wakeup",
+                                              GPIOD_IN);
+               if (IS_ERR(gpio))
+                       return PTR_ERR(gpio);
+
+               dev->irq = gpiod_to_irq(gpio);
+       }
+
+       dev_info(&pdev->dev, "BCM irq: %d\n", dev->irq);
+
        /* Make sure at-least one of the GPIO is defined and that
         * a name is specified for this instance
         */
@@ -462,11 +730,18 @@ static int bcm_acpi_probe(struct bcm_device *dev)
        }
 
        /* Retrieve UART ACPI info */
-       adev = ACPI_COMPANION(&dev->pdev->dev);
-       if (!adev)
-               return 0;
+       ret = acpi_dev_get_resources(ACPI_COMPANION(&dev->pdev->dev),
+                                    &resources, bcm_resource, dev);
+       if (ret < 0)
+               return ret;
+       acpi_dev_free_resource_list(&resources);
 
-       acpi_dev_get_resources(adev, &resources, bcm_resource, dev);
+       dmi_id = dmi_first_match(bcm_wrong_irq_dmi_table);
+       if (dmi_id) {
+               bt_dev_warn(dev, "%s: Overwriting IRQ polarity to active low",
+                           dmi_id->ident);
+               dev->irq_polarity = *(u8 *)dmi_id->driver_data;
+       }
 
        return 0;
 }
@@ -480,7 +755,6 @@ static int bcm_acpi_probe(struct bcm_device *dev)
 static int bcm_probe(struct platform_device *pdev)
 {
        struct bcm_device *dev;
-       struct acpi_device_id *pdata = pdev->dev.platform_data;
        int ret;
 
        dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
@@ -489,24 +763,18 @@ static int bcm_probe(struct platform_device *pdev)
 
        dev->pdev = pdev;
 
-       if (ACPI_HANDLE(&pdev->dev)) {
-               ret = bcm_acpi_probe(dev);
-               if (ret)
-                       return ret;
-       } else if (pdata) {
-               dev->name = pdata->id;
-       } else {
-               return -ENODEV;
-       }
+       ret = bcm_acpi_probe(dev);
+       if (ret)
+               return ret;
 
        platform_set_drvdata(pdev, dev);
 
        dev_info(&pdev->dev, "%s device registered.\n", dev->name);
 
        /* Place this instance on the device list */
-       spin_lock(&bcm_device_lock);
+       mutex_lock(&bcm_device_lock);
        list_add_tail(&dev->list, &bcm_device_list);
-       spin_unlock(&bcm_device_lock);
+       mutex_unlock(&bcm_device_lock);
 
        bcm_gpio_set_power(dev, false);
 
@@ -517,9 +785,9 @@ static int bcm_remove(struct platform_device *pdev)
 {
        struct bcm_device *dev = platform_get_drvdata(pdev);
 
-       spin_lock(&bcm_device_lock);
+       mutex_lock(&bcm_device_lock);
        list_del(&dev->list);
-       spin_unlock(&bcm_device_lock);
+       mutex_unlock(&bcm_device_lock);
 
        acpi_dev_remove_driver_gpios(ACPI_COMPANION(&pdev->dev));
 
@@ -531,6 +799,7 @@ static int bcm_remove(struct platform_device *pdev)
 static const struct hci_uart_proto bcm_proto = {
        .id             = HCI_UART_BCM,
        .name           = "BCM",
+       .manufacturer   = 15,
        .init_speed     = 115200,
        .oper_speed     = 4000000,
        .open           = bcm_open,
@@ -553,7 +822,10 @@ MODULE_DEVICE_TABLE(acpi, bcm_acpi_match);
 #endif
 
 /* Platform suspend and resume callbacks */
-static SIMPLE_DEV_PM_OPS(bcm_pm_ops, bcm_suspend, bcm_resume);
+static const struct dev_pm_ops bcm_pm_ops = {
+       SET_SYSTEM_SLEEP_PM_OPS(bcm_suspend, bcm_resume)
+       SET_RUNTIME_PM_OPS(bcm_suspend_device, bcm_resume_device, NULL)
+};
 
 static struct platform_driver bcm_driver = {
        .probe = bcm_probe,