2 * Toshiba Bluetooth Enable Driver
6 * Thanks to Matthew Garrett for background info on ACPI innards which
7 * normal people aren't meant to understand :-)
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 * Note the Toshiba Bluetooth RFKill switch seems to be a strange
14 * fish. It only provides a BT event when the switch is flipped to
15 * the 'on' position. When flipping it to 'off', the USB device is
16 * simply pulled away underneath us, without any BT event being
20 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
22 #include <linux/kernel.h>
23 #include <linux/module.h>
24 #include <linux/init.h>
25 #include <linux/types.h>
26 #include <linux/acpi.h>
29 MODULE_DESCRIPTION("Toshiba Laptop ACPI Bluetooth Enable Driver");
30 MODULE_LICENSE("GPL");
32 static int toshiba_bt_rfkill_add(struct acpi_device *device);
33 static int toshiba_bt_rfkill_remove(struct acpi_device *device);
34 static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event);
36 static const struct acpi_device_id bt_device_ids[] = {
40 MODULE_DEVICE_TABLE(acpi, bt_device_ids);
42 #ifdef CONFIG_PM_SLEEP
43 static int toshiba_bt_resume(struct device *dev);
45 static SIMPLE_DEV_PM_OPS(toshiba_bt_pm, NULL, toshiba_bt_resume);
47 static struct acpi_driver toshiba_bt_rfkill_driver = {
52 .add = toshiba_bt_rfkill_add,
53 .remove = toshiba_bt_rfkill_remove,
54 .notify = toshiba_bt_rfkill_notify,
57 .drv.pm = &toshiba_bt_pm,
61 static int toshiba_bluetooth_enable(acpi_handle handle)
63 acpi_status res1, res2;
67 * Query ACPI to verify RFKill switch is set to 'on'.
68 * If not, we return silently, no need to report it as
71 res1 = acpi_evaluate_integer(handle, "BTST", NULL, &result);
72 if (ACPI_FAILURE(res1))
77 pr_info("Re-enabling Toshiba Bluetooth\n");
78 res1 = acpi_evaluate_object(handle, "AUSB", NULL, NULL);
79 res2 = acpi_evaluate_object(handle, "BTPO", NULL, NULL);
80 if (!ACPI_FAILURE(res1) || !ACPI_FAILURE(res2))
83 pr_warn("Failed to re-enable Toshiba Bluetooth\n");
88 static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event)
90 toshiba_bluetooth_enable(device->handle);
93 #ifdef CONFIG_PM_SLEEP
94 static int toshiba_bt_resume(struct device *dev)
96 return toshiba_bluetooth_enable(to_acpi_device(dev)->handle);
100 static int toshiba_bt_rfkill_add(struct acpi_device *device)
104 int result = -ENODEV;
107 * Some Toshiba laptops may have a fake TOS6205 device in
108 * their ACPI BIOS, so query the _STA method to see if there
109 * is really anything there, before trying to enable it.
111 status = acpi_evaluate_integer(device->handle, "_STA", NULL,
114 if (!ACPI_FAILURE(status) && bt_present) {
115 pr_info("Detected Toshiba ACPI Bluetooth device - "
116 "installing RFKill handler\n");
117 result = toshiba_bluetooth_enable(device->handle);
123 static int toshiba_bt_rfkill_remove(struct acpi_device *device)
129 module_acpi_driver(toshiba_bt_rfkill_driver);