2 * Toshiba Bluetooth Enable Driver
4 * Copyright (C) 2009 Jes Sorensen <Jes.Sorensen@gmail.com>
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 #include <linux/kernel.h>
21 #include <linux/module.h>
22 #include <linux/init.h>
23 #include <linux/types.h>
24 #include <acpi/acpi_bus.h>
25 #include <acpi/acpi_drivers.h>
27 MODULE_AUTHOR("Jes Sorensen <Jes.Sorensen@gmail.com>");
28 MODULE_DESCRIPTION("Toshiba Laptop ACPI Bluetooth Enable Driver");
29 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
, int type
);
34 static void toshiba_bt_rfkill_notify(struct acpi_device
*device
, u32 event
);
35 static int toshiba_bt_resume(struct acpi_device
*device
);
37 static const struct acpi_device_id bt_device_ids
[] = {
41 MODULE_DEVICE_TABLE(acpi
, bt_device_ids
);
43 static struct acpi_driver toshiba_bt_rfkill_driver
= {
48 .add
= toshiba_bt_rfkill_add
,
49 .remove
= toshiba_bt_rfkill_remove
,
50 .notify
= toshiba_bt_rfkill_notify
,
51 .resume
= toshiba_bt_resume
,
57 static int toshiba_bluetooth_enable(acpi_handle handle
)
59 acpi_status res1
, res2
;
63 * Query ACPI to verify RFKill switch is set to 'on'.
64 * If not, we return silently, no need to report it as
67 res1
= acpi_evaluate_integer(handle
, "BTST", NULL
, &result
);
68 if (ACPI_FAILURE(res1
))
73 printk(KERN_INFO
"toshiba_bluetooth: Re-enabling Toshiba Bluetooth\n");
74 res1
= acpi_evaluate_object(handle
, "AUSB", NULL
, NULL
);
75 res2
= acpi_evaluate_object(handle
, "BTPO", NULL
, NULL
);
76 if (!ACPI_FAILURE(res1
) || !ACPI_FAILURE(res2
))
79 printk(KERN_WARNING
"toshiba_bluetooth: Failed to re-enable "
80 "Toshiba Bluetooth\n");
85 static void toshiba_bt_rfkill_notify(struct acpi_device
*device
, u32 event
)
87 toshiba_bluetooth_enable(device
->handle
);
90 static int toshiba_bt_resume(struct acpi_device
*device
)
92 return toshiba_bluetooth_enable(device
->handle
);
95 static int toshiba_bt_rfkill_add(struct acpi_device
*device
)
102 * Some Toshiba laptops may have a fake TOS6205 device in
103 * their ACPI BIOS, so query the _STA method to see if there
104 * is really anything there, before trying to enable it.
106 status
= acpi_evaluate_integer(device
->handle
, "_STA", NULL
,
109 if (!ACPI_FAILURE(status
) && bt_present
) {
110 printk(KERN_INFO
"Detected Toshiba ACPI Bluetooth device - "
111 "installing RFKill handler\n");
112 result
= toshiba_bluetooth_enable(device
->handle
);
118 static int __init
toshiba_bt_rfkill_init(void)
122 result
= acpi_bus_register_driver(&toshiba_bt_rfkill_driver
);
124 ACPI_DEBUG_PRINT((ACPI_DB_ERROR
,
125 "Error registering driver\n"));
132 static int toshiba_bt_rfkill_remove(struct acpi_device
*device
, int type
)
138 static void __exit
toshiba_bt_rfkill_exit(void)
140 acpi_bus_unregister_driver(&toshiba_bt_rfkill_driver
);
143 module_init(toshiba_bt_rfkill_init
);
144 module_exit(toshiba_bt_rfkill_exit
);