summaryrefslogtreecommitdiffstats
path: root/drivers/bluetooth
diff options
context:
space:
mode:
authorLukas Wunner <lukas@wunner.de>2018-01-10 16:32:10 +0100
committerMarcel Holtmann <marcel@holtmann.org>2018-01-10 19:00:13 +0100
commit8353b4a636f2c83de748656acc6b6a8757d7a0ff (patch)
tree0b5e411f5939d65f8afc3b8adb0b271c2ec99fab /drivers/bluetooth
parentBluetooth: hci_bcm: Document struct bcm_device (diff)
downloadlinux-8353b4a636f2c83de748656acc6b6a8757d7a0ff.tar.xz
linux-8353b4a636f2c83de748656acc6b6a8757d7a0ff.zip
Bluetooth: hci_bcm: Add callbacks to toggle GPIOs
MacBooks provides custom ACPI methods to toggle the GPIOs for device wake and shutdown instead of accessing the pins directly. Prepare for their support by adding callbacks to toggle the GPIOs, which on non-Macs do nothing more but call gpiod_set_value(). No functional change intended. Suggested-and-reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Lukas Wunner <lukas@wunner.de> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'drivers/bluetooth')
-rw-r--r--drivers/bluetooth/hci_bcm.c27
1 files changed, 23 insertions, 4 deletions
diff --git a/drivers/bluetooth/hci_bcm.c b/drivers/bluetooth/hci_bcm.c
index 3c1282a9fcd4..8741e302e6fd 100644
--- a/drivers/bluetooth/hci_bcm.c
+++ b/drivers/bluetooth/hci_bcm.c
@@ -63,6 +63,8 @@
* deassert = Bluetooth device may sleep when sleep criteria are met
* @shutdown: BT_REG_ON pin,
* power up or power down Bluetooth device internal regulators
+ * @set_device_wakeup: callback to toggle BT_WAKE pin
+ * @set_shutdown: callback to toggle BT_REG_ON pin
* @clk: clock used by Bluetooth device
* @clk_enabled: whether @clk is prepared and enabled
* @init_speed: default baudrate of Bluetooth device;
@@ -86,6 +88,8 @@ struct bcm_device {
const char *name;
struct gpio_desc *device_wakeup;
struct gpio_desc *shutdown;
+ int (*set_device_wakeup)(struct bcm_device *, bool);
+ int (*set_shutdown)(struct bcm_device *, bool);
struct clk *clk;
bool clk_enabled;
@@ -196,8 +200,8 @@ 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);
+ dev->set_shutdown(dev, powered);
+ dev->set_device_wakeup(dev, powered);
if (!powered && !IS_ERR(dev->clk) && dev->clk_enabled)
clk_disable_unprepare(dev->clk);
@@ -595,7 +599,7 @@ static int bcm_suspend_device(struct device *dev)
}
/* Suspend the device */
- gpiod_set_value(bdev->device_wakeup, false);
+ bdev->set_device_wakeup(bdev, false);
bt_dev_dbg(bdev, "suspend, delaying 15 ms");
mdelay(15);
@@ -608,7 +612,7 @@ static int bcm_resume_device(struct device *dev)
bt_dev_dbg(bdev, "");
- gpiod_set_value(bdev->device_wakeup, true);
+ bdev->set_device_wakeup(bdev, true);
bt_dev_dbg(bdev, "resume, delaying 15 ms");
mdelay(15);
@@ -787,6 +791,18 @@ static int bcm_resource(struct acpi_resource *ares, void *data)
}
#endif /* CONFIG_ACPI */
+static int bcm_gpio_set_device_wakeup(struct bcm_device *dev, bool awake)
+{
+ gpiod_set_value(dev->device_wakeup, awake);
+ return 0;
+}
+
+static int bcm_gpio_set_shutdown(struct bcm_device *dev, bool powered)
+{
+ gpiod_set_value(dev->shutdown, powered);
+ return 0;
+}
+
static int bcm_get_resources(struct bcm_device *dev)
{
dev->name = dev_name(dev->dev);
@@ -802,6 +818,9 @@ static int bcm_get_resources(struct bcm_device *dev)
if (IS_ERR(dev->shutdown))
return PTR_ERR(dev->shutdown);
+ dev->set_device_wakeup = bcm_gpio_set_device_wakeup;
+ dev->set_shutdown = bcm_gpio_set_shutdown;
+
/* IRQ can be declared in ACPI table as Interrupt or GpioInt */
if (dev->irq <= 0) {
struct gpio_desc *gpio;