Lines Matching +full:device +full:- +full:handle
1 // SPDX-License-Identifier: GPL-2.0-only
9 * normal people aren't meant to understand :-)
38 static int toshiba_bt_rfkill_add(struct acpi_device *device);
39 static void toshiba_bt_rfkill_remove(struct acpi_device *device);
40 static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event);
49 static int toshiba_bt_resume(struct device *dev);
65 static int toshiba_bluetooth_present(acpi_handle handle) in toshiba_bluetooth_present() argument
71 * Some Toshiba laptops may have a fake TOS6205 device in in toshiba_bluetooth_present()
75 result = acpi_evaluate_integer(handle, "_STA", NULL, &bt_present); in toshiba_bluetooth_present()
78 return -ENXIO; in toshiba_bluetooth_present()
82 pr_info("Bluetooth device not present\n"); in toshiba_bluetooth_present()
83 return -ENODEV; in toshiba_bluetooth_present()
89 static int toshiba_bluetooth_status(acpi_handle handle) in toshiba_bluetooth_status() argument
94 result = acpi_evaluate_integer(handle, "BTST", NULL, &status); in toshiba_bluetooth_status()
96 pr_err("Could not get Bluetooth device status\n"); in toshiba_bluetooth_status()
97 return -ENXIO; in toshiba_bluetooth_status()
103 static int toshiba_bluetooth_enable(acpi_handle handle) in toshiba_bluetooth_enable() argument
107 result = acpi_evaluate_object(handle, "AUSB", NULL, NULL); in toshiba_bluetooth_enable()
109 pr_err("Could not attach USB Bluetooth device\n"); in toshiba_bluetooth_enable()
110 return -ENXIO; in toshiba_bluetooth_enable()
113 result = acpi_evaluate_object(handle, "BTPO", NULL, NULL); in toshiba_bluetooth_enable()
115 pr_err("Could not power ON Bluetooth device\n"); in toshiba_bluetooth_enable()
116 return -ENXIO; in toshiba_bluetooth_enable()
122 static int toshiba_bluetooth_disable(acpi_handle handle) in toshiba_bluetooth_disable() argument
126 result = acpi_evaluate_object(handle, "BTPF", NULL, NULL); in toshiba_bluetooth_disable()
128 pr_err("Could not power OFF Bluetooth device\n"); in toshiba_bluetooth_disable()
129 return -ENXIO; in toshiba_bluetooth_disable()
132 result = acpi_evaluate_object(handle, "DUSB", NULL, NULL); in toshiba_bluetooth_disable()
134 pr_err("Could not detach USB Bluetooth device\n"); in toshiba_bluetooth_disable()
135 return -ENXIO; in toshiba_bluetooth_disable()
146 status = toshiba_bluetooth_status(bt_dev->acpi_dev->handle); in toshiba_bluetooth_sync_status()
148 pr_err("Could not sync bluetooth device status\n"); in toshiba_bluetooth_sync_status()
152 bt_dev->killswitch = (status & BT_KILLSWITCH_MASK) ? true : false; in toshiba_bluetooth_sync_status()
153 bt_dev->plugged = (status & BT_PLUGGED_MASK) ? true : false; in toshiba_bluetooth_sync_status()
154 bt_dev->powered = (status & BT_POWER_MASK) ? true : false; in toshiba_bluetooth_sync_status()
157 status, bt_dev->killswitch, bt_dev->plugged, bt_dev->powered); in toshiba_bluetooth_sync_status()
172 if (!bt_dev->killswitch) in bt_rfkill_set_block()
176 ret = toshiba_bluetooth_disable(bt_dev->acpi_dev->handle); in bt_rfkill_set_block()
178 ret = toshiba_bluetooth_enable(bt_dev->acpi_dev->handle); in bt_rfkill_set_block()
193 * the 'on' position. When flipping it to 'off', the USB device is in bt_rfkill_poll()
197 rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch); in bt_rfkill_poll()
206 static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event) in toshiba_bt_rfkill_notify() argument
208 struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device); in toshiba_bt_rfkill_notify()
213 rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch); in toshiba_bt_rfkill_notify()
217 static int toshiba_bt_resume(struct device *dev) in toshiba_bt_resume()
228 rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch); in toshiba_bt_resume()
234 static int toshiba_bt_rfkill_add(struct acpi_device *device) in toshiba_bt_rfkill_add() argument
239 result = toshiba_bluetooth_present(device->handle); in toshiba_bt_rfkill_add()
243 pr_info("Toshiba ACPI Bluetooth device driver\n"); in toshiba_bt_rfkill_add()
247 return -ENOMEM; in toshiba_bt_rfkill_add()
248 bt_dev->acpi_dev = device; in toshiba_bt_rfkill_add()
249 device->driver_data = bt_dev; in toshiba_bt_rfkill_add()
250 dev_set_drvdata(&device->dev, bt_dev); in toshiba_bt_rfkill_add()
258 bt_dev->rfk = rfkill_alloc("Toshiba Bluetooth", in toshiba_bt_rfkill_add()
259 &device->dev, in toshiba_bt_rfkill_add()
263 if (!bt_dev->rfk) { in toshiba_bt_rfkill_add()
264 pr_err("Unable to allocate rfkill device\n"); in toshiba_bt_rfkill_add()
266 return -ENOMEM; in toshiba_bt_rfkill_add()
269 rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch); in toshiba_bt_rfkill_add()
271 result = rfkill_register(bt_dev->rfk); in toshiba_bt_rfkill_add()
273 pr_err("Unable to register rfkill device\n"); in toshiba_bt_rfkill_add()
274 rfkill_destroy(bt_dev->rfk); in toshiba_bt_rfkill_add()
281 static void toshiba_bt_rfkill_remove(struct acpi_device *device) in toshiba_bt_rfkill_remove() argument
283 struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device); in toshiba_bt_rfkill_remove()
286 if (bt_dev->rfk) { in toshiba_bt_rfkill_remove()
287 rfkill_unregister(bt_dev->rfk); in toshiba_bt_rfkill_remove()
288 rfkill_destroy(bt_dev->rfk); in toshiba_bt_rfkill_remove()
293 toshiba_bluetooth_disable(device->handle); in toshiba_bt_rfkill_remove()