Bluetooth: btintel: Add support for enabling tracing functionality
[firefly-linux-kernel-4.4.55.git] / drivers / bluetooth / hci_intel.c
index 215e8e9dd65f664174e728bef4a91c46a826f1a4..c5e69e08788a40c73641df8b4e92d8976a6d7ddb 100644 (file)
@@ -190,7 +190,8 @@ static int intel_lpm_suspend(struct hci_uart *hu)
 
        set_bit(STATE_LPM_TRANSACTION, &intel->flags);
 
-       skb_queue_tail(&intel->txq, skb);
+       /* LPM flow is a priority, enqueue packet at list head */
+       skb_queue_head(&intel->txq, skb);
        hci_uart_tx_wakeup(hu);
 
        intel_wait_lpm_transaction(hu);
@@ -233,7 +234,8 @@ static int intel_lpm_resume(struct hci_uart *hu)
 
        set_bit(STATE_LPM_TRANSACTION, &intel->flags);
 
-       skb_queue_tail(&intel->txq, skb);
+       /* LPM flow is a priority, enqueue packet at list head */
+       skb_queue_head(&intel->txq, skb);
        hci_uart_tx_wakeup(hu);
 
        intel_wait_lpm_transaction(hu);
@@ -272,7 +274,8 @@ static int intel_lpm_host_wake(struct hci_uart *hu)
               sizeof(lpm_resume_ack));
        bt_cb(skb)->pkt_type = HCI_LPM_PKT;
 
-       skb_queue_tail(&intel->txq, skb);
+       /* LPM flow is a priority, enqueue packet at list head */
+       skb_queue_head(&intel->txq, skb);
        hci_uart_tx_wakeup(hu);
 
        bt_dev_dbg(hu->hdev, "Resumed by controller");
@@ -554,6 +557,7 @@ static int intel_setup(struct hci_uart *hu)
 
        bt_dev_dbg(hdev, "start intel_setup");
 
+       hu->hdev->set_diag = btintel_set_diag;
        hu->hdev->set_bdaddr = btintel_set_bdaddr;
 
        calltime = ktime_get();
@@ -737,6 +741,10 @@ static int intel_setup(struct hci_uart *hu)
 
        bt_dev_info(hdev, "Found device firmware: %s", fwname);
 
+       /* Save the DDC file name for later */
+       snprintf(fwname, sizeof(fwname), "intel/ibt-11-%u.ddc",
+                le16_to_cpu(params->dev_revid));
+
        kfree_skb(skb);
 
        if (fw->size < 644) {
@@ -929,6 +937,9 @@ done:
        set_bit(STATE_LPM_ENABLED, &intel->flags);
 
 no_lpm:
+       /* Ignore errors, device can work without DDC parameters */
+       btintel_load_ddc_config(hdev, fwname);
+
        skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_CMD_TIMEOUT);
        if (IS_ERR(skb))
                return PTR_ERR(skb);
@@ -1155,31 +1166,13 @@ static const struct acpi_device_id intel_acpi_match[] = {
        { },
 };
 MODULE_DEVICE_TABLE(acpi, intel_acpi_match);
-
-static int intel_acpi_probe(struct intel_device *idev)
-{
-       const struct acpi_device_id *id;
-
-       id = acpi_match_device(intel_acpi_match, &idev->pdev->dev);
-       if (!id)
-               return -ENODEV;
-
-       return 0;
-}
-#else
-static int intel_acpi_probe(struct intel_device *idev)
-{
-       return -ENODEV;
-}
 #endif
 
 #ifdef CONFIG_PM
-static int intel_suspend(struct device *dev)
+static int intel_suspend_device(struct device *dev)
 {
        struct intel_device *idev = dev_get_drvdata(dev);
 
-       dev_dbg(dev, "intel_suspend");
-
        mutex_lock(&idev->hu_lock);
        if (idev->hu)
                intel_lpm_suspend(idev->hu);
@@ -1188,12 +1181,10 @@ static int intel_suspend(struct device *dev)
        return 0;
 }
 
-static int intel_resume(struct device *dev)
+static int intel_resume_device(struct device *dev)
 {
        struct intel_device *idev = dev_get_drvdata(dev);
 
-       dev_dbg(dev, "intel_resume");
-
        mutex_lock(&idev->hu_lock);
        if (idev->hu)
                intel_lpm_resume(idev->hu);
@@ -1203,9 +1194,31 @@ static int intel_resume(struct device *dev)
 }
 #endif
 
+#ifdef CONFIG_PM_SLEEP
+static int intel_suspend(struct device *dev)
+{
+       struct intel_device *idev = dev_get_drvdata(dev);
+
+       if (device_may_wakeup(dev))
+               enable_irq_wake(idev->irq);
+
+       return intel_suspend_device(dev);
+}
+
+static int intel_resume(struct device *dev)
+{
+       struct intel_device *idev = dev_get_drvdata(dev);
+
+       if (device_may_wakeup(dev))
+               disable_irq_wake(idev->irq);
+
+       return intel_resume_device(dev);
+}
+#endif
+
 static const struct dev_pm_ops intel_pm_ops = {
        SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)
-       SET_RUNTIME_PM_OPS(intel_suspend, intel_resume, NULL)
+       SET_RUNTIME_PM_OPS(intel_suspend_device, intel_resume_device, NULL)
 };
 
 static int intel_probe(struct platform_device *pdev)
@@ -1220,14 +1233,6 @@ static int intel_probe(struct platform_device *pdev)
 
        idev->pdev = pdev;
 
-       if (ACPI_HANDLE(&pdev->dev)) {
-               int err = intel_acpi_probe(idev);
-               if (err)
-                       return err;
-       } else {
-               return -ENODEV;
-       }
-
        idev->reset = devm_gpiod_get_optional(&pdev->dev, "reset",
                                              GPIOD_OUT_LOW);
        if (IS_ERR(idev->reset)) {