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);
66 static int toshiba_bluetooth_present(acpi_handle handle) in toshiba_bluetooth_present() argument
72 * Some Toshiba laptops may have a fake TOS6205 device in in toshiba_bluetooth_present()
76 result = acpi_evaluate_integer(handle, "_STA", NULL, &bt_present); in toshiba_bluetooth_present()
79 return -ENXIO; in toshiba_bluetooth_present()
83 pr_info("Bluetooth device not present\n"); in toshiba_bluetooth_present()
84 return -ENODEV; in toshiba_bluetooth_present()
90 static int toshiba_bluetooth_status(acpi_handle handle) in toshiba_bluetooth_status() argument
95 result = acpi_evaluate_integer(handle, "BTST", NULL, &status); in toshiba_bluetooth_status()
97 pr_err("Could not get Bluetooth device status\n"); in toshiba_bluetooth_status()
98 return -ENXIO; in toshiba_bluetooth_status()
104 static int toshiba_bluetooth_enable(acpi_handle handle) in toshiba_bluetooth_enable() argument
108 result = acpi_evaluate_object(handle, "AUSB", NULL, NULL); in toshiba_bluetooth_enable()
110 pr_err("Could not attach USB Bluetooth device\n"); in toshiba_bluetooth_enable()
111 return -ENXIO; in toshiba_bluetooth_enable()
114 result = acpi_evaluate_object(handle, "BTPO", NULL, NULL); in toshiba_bluetooth_enable()
116 pr_err("Could not power ON Bluetooth device\n"); in toshiba_bluetooth_enable()
117 return -ENXIO; in toshiba_bluetooth_enable()
123 static int toshiba_bluetooth_disable(acpi_handle handle) in toshiba_bluetooth_disable() argument
127 result = acpi_evaluate_object(handle, "BTPF", NULL, NULL); in toshiba_bluetooth_disable()
129 pr_err("Could not power OFF Bluetooth device\n"); in toshiba_bluetooth_disable()
130 return -ENXIO; in toshiba_bluetooth_disable()
133 result = acpi_evaluate_object(handle, "DUSB", NULL, NULL); in toshiba_bluetooth_disable()
135 pr_err("Could not detach USB Bluetooth device\n"); in toshiba_bluetooth_disable()
136 return -ENXIO; in toshiba_bluetooth_disable()
147 status = toshiba_bluetooth_status(bt_dev->acpi_dev->handle); in toshiba_bluetooth_sync_status()
149 pr_err("Could not sync bluetooth device status\n"); in toshiba_bluetooth_sync_status()
153 bt_dev->killswitch = (status & BT_KILLSWITCH_MASK) ? true : false; in toshiba_bluetooth_sync_status()
154 bt_dev->plugged = (status & BT_PLUGGED_MASK) ? true : false; in toshiba_bluetooth_sync_status()
155 bt_dev->powered = (status & BT_POWER_MASK) ? true : false; in toshiba_bluetooth_sync_status()
158 status, bt_dev->killswitch, bt_dev->plugged, bt_dev->powered); in toshiba_bluetooth_sync_status()
173 if (!bt_dev->killswitch) in bt_rfkill_set_block()
177 ret = toshiba_bluetooth_disable(bt_dev->acpi_dev->handle); in bt_rfkill_set_block()
179 ret = toshiba_bluetooth_enable(bt_dev->acpi_dev->handle); in bt_rfkill_set_block()
194 * the 'on' position. When flipping it to 'off', the USB device is in bt_rfkill_poll()
198 rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch); in bt_rfkill_poll()
207 static void toshiba_bt_rfkill_notify(struct acpi_device *device, u32 event) in toshiba_bt_rfkill_notify() argument
209 struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device); in toshiba_bt_rfkill_notify()
214 rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch); in toshiba_bt_rfkill_notify()
218 static int toshiba_bt_resume(struct device *dev) in toshiba_bt_resume()
229 rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch); in toshiba_bt_resume()
235 static int toshiba_bt_rfkill_add(struct acpi_device *device) in toshiba_bt_rfkill_add() argument
240 result = toshiba_bluetooth_present(device->handle); in toshiba_bt_rfkill_add()
244 pr_info("Toshiba ACPI Bluetooth device driver\n"); in toshiba_bt_rfkill_add()
248 return -ENOMEM; in toshiba_bt_rfkill_add()
249 bt_dev->acpi_dev = device; in toshiba_bt_rfkill_add()
250 device->driver_data = bt_dev; in toshiba_bt_rfkill_add()
251 dev_set_drvdata(&device->dev, bt_dev); in toshiba_bt_rfkill_add()
259 bt_dev->rfk = rfkill_alloc("Toshiba Bluetooth", in toshiba_bt_rfkill_add()
260 &device->dev, in toshiba_bt_rfkill_add()
264 if (!bt_dev->rfk) { in toshiba_bt_rfkill_add()
265 pr_err("Unable to allocate rfkill device\n"); in toshiba_bt_rfkill_add()
267 return -ENOMEM; in toshiba_bt_rfkill_add()
270 rfkill_set_hw_state(bt_dev->rfk, !bt_dev->killswitch); in toshiba_bt_rfkill_add()
272 result = rfkill_register(bt_dev->rfk); in toshiba_bt_rfkill_add()
274 pr_err("Unable to register rfkill device\n"); in toshiba_bt_rfkill_add()
275 rfkill_destroy(bt_dev->rfk); in toshiba_bt_rfkill_add()
282 static void toshiba_bt_rfkill_remove(struct acpi_device *device) in toshiba_bt_rfkill_remove() argument
284 struct toshiba_bluetooth_dev *bt_dev = acpi_driver_data(device); in toshiba_bt_rfkill_remove()
287 if (bt_dev->rfk) { in toshiba_bt_rfkill_remove()
288 rfkill_unregister(bt_dev->rfk); in toshiba_bt_rfkill_remove()
289 rfkill_destroy(bt_dev->rfk); in toshiba_bt_rfkill_remove()
294 toshiba_bluetooth_disable(device->handle); in toshiba_bt_rfkill_remove()