[PATCH v2 05/10] Bluetooth: hci_bcm: Add helper to toggle device wake GPIO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is already a bcm_gpio_set_power() helper to toggle the power
enable pin.  Add a corresponding helper to toggle the device wake pin.
This will allow us to more easily integrate support for MacBooks which
use custom ACPI methods to access both pins.

The only functional change here is an additional 15 ms delay when
toggling the device wake pin in bcm_gpio_set_power().  It is unclear why
this delay is observed in bcm_suspend_device() and bcm_resume_device(),
but not in bcm_gpio_set_power() so far.

Signed-off-by: Lukas Wunner <lukas@xxxxxxxxx>
---
Changes since v1:
  I had previously forgotten to toggle the device wake
  GPIO in bcm_gpio_set_power() on Macs, this is now fixed.

 drivers/bluetooth/hci_bcm.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index dbba08fd05a3..01d0943b7bbb 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -168,13 +168,25 @@ static bool bcm_device_exists(struct bcm_device *device)
 	return false;
 }
 
+static int bcm_gpio_set_device_wakeup(struct bcm_device *dev, bool awake)
+{
+	int err = 0;
+
+	gpiod_set_value(dev->device_wakeup, awake);
+	bt_dev_dbg(dev, "%s, delaying 15 ms", awake ? "resume" : "suspend");
+	mdelay(15);
+
+	return err;
+}
+
 static int bcm_gpio_set_power(struct bcm_device *dev, bool powered)
 {
 	if (powered && !IS_ERR(dev->clk) && !dev->clk_enabled)
 		clk_prepare_enable(dev->clk);
 
 	gpiod_set_value(dev->shutdown, powered);
-	gpiod_set_value(dev->device_wakeup, powered);
+
+	bcm_gpio_set_device_wakeup(dev, powered);
 
 	if (!powered && !IS_ERR(dev->clk) && dev->clk_enabled)
 		clk_disable_unprepare(dev->clk);
@@ -571,9 +583,7 @@ static int bcm_suspend_device(struct device *dev)
 	}
 
 	/* Suspend the device */
-	gpiod_set_value(bdev->device_wakeup, false);
-	bt_dev_dbg(bdev, "suspend, delaying 15 ms");
-	mdelay(15);
+	bcm_gpio_set_device_wakeup(bdev, false);
 
 	return 0;
 }
@@ -584,9 +594,7 @@ static int bcm_resume_device(struct device *dev)
 
 	bt_dev_dbg(bdev, "");
 
-	gpiod_set_value(bdev->device_wakeup, true);
-	bt_dev_dbg(bdev, "resume, delaying 15 ms");
-	mdelay(15);
+	bcm_gpio_set_device_wakeup(bdev, true);
 
 	/* When this executes, the device has woken up already */
 	if (bdev->is_suspended && bdev->hu) {
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux