From: Loic Poulain <loic.poulain@intel.com>
To: marcel@holtmann.org
Cc: linux-bluetooth@vger.kernel.org, Loic Poulain <loic.poulain@intel.com>
Subject: [PATCH 2/3] Bluetooth: hci_intel: Add PM support
Date: Tue, 1 Sep 2015 16:42:09 +0200 [thread overview]
Message-ID: <1441118530-18154-2-git-send-email-loic.poulain@intel.com> (raw)
In-Reply-To: <1441118530-18154-1-git-send-email-loic.poulain@intel.com>
Add PM suspend/resume callbacks which call lpm_suspend/resume.
Add LPM ack in threaded IRQ handler to notify the controller that
resume is complete.
Protect hci_uart against concurrent removing during suspend/resume.
Signed-off-by: Loic Poulain <loic.poulain@intel.com>
---
drivers/bluetooth/hci_intel.c | 66 +++++++++++++++++++++++++++++++++++++------
1 file changed, 58 insertions(+), 8 deletions(-)
diff --git a/drivers/bluetooth/hci_intel.c b/drivers/bluetooth/hci_intel.c
index 387961a..8651803 100644
--- a/drivers/bluetooth/hci_intel.c
+++ b/drivers/bluetooth/hci_intel.c
@@ -68,6 +68,8 @@ struct intel_device {
struct list_head list;
struct platform_device *pdev;
struct gpio_desc *reset;
+ struct hci_uart *hu;
+ struct mutex hu_lock;
int irq;
};
@@ -156,14 +158,7 @@ static int intel_wait_lpm_transaction(struct hci_uart *hu)
return err;
}
-static irqreturn_t intel_irq(int irq, void *dev_id)
-{
- struct intel_device *idev = dev_id;
-
- dev_info(&idev->pdev->dev, "hci_intel irq\n");
-
- return IRQ_HANDLED;
-}
+static irqreturn_t intel_irq(int irq, void *dev_id);
static int intel_set_power(struct hci_uart *hu, bool powered)
{
@@ -192,6 +187,10 @@ static int intel_set_power(struct hci_uart *hu, bool powered)
gpiod_set_value(idev->reset, powered);
+ mutex_lock(&idev->hu_lock);
+ idev->hu = powered ? hu : NULL;
+ mutex_unlock(&idev->hu_lock);
+
if (idev->irq < 0)
break;
@@ -1061,6 +1060,20 @@ static const struct hci_uart_proto intel_proto = {
.dequeue = intel_dequeue,
};
+static irqreturn_t intel_irq(int irq, void *dev_id)
+{
+ struct intel_device *idev = dev_id;
+
+ dev_info(&idev->pdev->dev, "hci_intel irq\n");
+
+ mutex_lock(&idev->hu_lock);
+ if (idev->hu)
+ intel_lpm_host_wake(idev->hu);
+ mutex_unlock(&idev->hu_lock);
+
+ return IRQ_HANDLED;
+}
+
#ifdef CONFIG_ACPI
static const struct acpi_device_id intel_acpi_match[] = {
{ "INT33E1", 0 },
@@ -1085,6 +1098,40 @@ static int intel_acpi_probe(struct intel_device *idev)
}
#endif
+#ifdef CONFIG_PM_SLEEP
+static int intel_suspend(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);
+ mutex_unlock(&idev->hu_lock);
+
+ return 0;
+}
+
+static int intel_resume(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);
+ mutex_unlock(&idev->hu_lock);
+
+ return 0;
+}
+#endif
+
+static const struct dev_pm_ops intel_pm_ops = {
+ SET_SYSTEM_SLEEP_PM_OPS(intel_suspend, intel_resume)
+};
+
static int intel_probe(struct platform_device *pdev)
{
struct intel_device *idev;
@@ -1093,6 +1140,8 @@ static int intel_probe(struct platform_device *pdev)
if (!idev)
return -ENOMEM;
+ mutex_init(&idev->hu_lock);
+
idev->pdev = pdev;
if (ACPI_HANDLE(&pdev->dev)) {
@@ -1169,6 +1218,7 @@ static struct platform_driver intel_driver = {
.driver = {
.name = "hci_intel",
.acpi_match_table = ACPI_PTR(intel_acpi_match),
+ .pm = &intel_pm_ops,
},
};
--
1.9.1
next prev parent reply other threads:[~2015-09-01 14:42 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-01 14:42 [PATCH 1/3] Bluetooth: hci_intel: Implement LPM suspend/resume Loic Poulain
2015-09-01 14:42 ` Loic Poulain [this message]
2015-09-01 15:05 ` [PATCH 2/3] Bluetooth: hci_intel: Add PM support Marcel Holtmann
2015-09-01 14:42 ` [PATCH 3/3] Bluetooth: hci_intel: Add runtime " Loic Poulain
2015-09-01 15:09 ` Marcel Holtmann
2015-09-01 15:32 ` Loic Poulain
2015-09-01 15:37 ` Marcel Holtmann
2015-09-01 15:00 ` [PATCH 1/3] Bluetooth: hci_intel: Implement LPM suspend/resume Marcel Holtmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1441118530-18154-2-git-send-email-loic.poulain@intel.com \
--to=loic.poulain@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=marcel@holtmann.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox