Lines Matching +full:kbd +full:- +full:led +full:- +full:backlight
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * toshiba_acpi.c - Toshiba Laptop ACPI Extras
5 * Copyright (C) 2002-2004 John Belmonte
8 * Copyright (C) 2014-2016 Azael Avalos
14 * Jonathan A. Buzzard - Toshiba HCI info, and critical tips on reverse
16 * Yasushi Nagato - changes for linux kernel 2.4 -> 2.5
17 * Rob Miller - TV out and hotkeys help
34 #include <linux/backlight.h>
36 #include <linux/input/sparse-keymap.h>
55 static int turn_on_panel_on_resume = -1;
58 "Call HCI_PANEL_POWER_ON on resume (-1 = auto, 0 = no, 1 = yes");
60 static int hci_hotkey_quickstart = -1;
63 … "Call HCI_HOTKEY_EVENT with value 0x5 for quickstart button support (-1 = auto, 0 = no, 1 = yes");
65 #define TOSHIBA_WMI_EVENT_GUID "59142400-C6A3-40FA-BADB-8A2652834100"
148 #define HCI_LCD_BRIGHTNESS_SHIFT (16-HCI_LCD_BRIGHTNESS_BITS)
314 return (status == AE_OK) ? 0 : -EIO; in write_acpi_int()
340 status = acpi_evaluate_object(dev->acpi_dev->handle, in tci_raw()
341 (char *)dev->method_hci, ¶ms, in tci_raw()
343 if ((status == AE_OK) && (out_objs->package.count <= TCI_WORDS)) { in tci_raw()
344 for (i = 0; i < out_objs->package.count; ++i) in tci_raw()
345 out[i] = out_objs->package.elements[i].integer.value; in tci_raw()
471 dev->illumination_supported = 0; in toshiba_illumination_available()
486 dev->illumination_supported = 1; in toshiba_illumination_available()
533 /* KBD Illumination */
540 dev->kbd_illum_supported = 0; in toshiba_kbd_illum_available()
541 dev->kbd_event_generated = false; in toshiba_kbd_illum_available()
549 pr_err("ACPI call to query kbd illumination support failed\n"); in toshiba_kbd_illum_available()
557 * Check for keyboard backlight timeout max value, in toshiba_kbd_illum_available()
558 * previous kbd backlight implementation set this to in toshiba_kbd_illum_available()
563 dev->kbd_type = 2; in toshiba_kbd_illum_available()
565 dev->kbd_type = 1; in toshiba_kbd_illum_available()
566 /* Get the current keyboard backlight mode */ in toshiba_kbd_illum_available()
567 dev->kbd_mode = out[2] & SCI_KBD_MODE_MASK; in toshiba_kbd_illum_available()
568 /* Get the current time (1-60 seconds) */ in toshiba_kbd_illum_available()
569 dev->kbd_time = out[2] >> HCI_MISC_SHIFT; in toshiba_kbd_illum_available()
571 dev->kbd_illum_supported = 1; in toshiba_kbd_illum_available()
579 return -EIO; in toshiba_kbd_illum_status_set()
584 pr_err("ACPI call to set KBD backlight status failed\n"); in toshiba_kbd_illum_status_set()
586 return -ENODEV; in toshiba_kbd_illum_status_set()
588 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_kbd_illum_status_set()
596 return -EIO; in toshiba_kbd_illum_status_get()
601 pr_err("ACPI call to get KBD backlight status failed\n"); in toshiba_kbd_illum_status_get()
603 return -ENODEV; in toshiba_kbd_illum_status_get()
605 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_kbd_illum_status_get()
615 /* Check the keyboard backlight state */ in toshiba_kbd_backlight_get()
618 pr_err("ACPI call to get the keyboard backlight failed\n"); in toshiba_kbd_backlight_get()
635 /* Set the keyboard backlight state */ in toshiba_kbd_backlight_set()
639 pr_err("ACPI call to set KBD Illumination mode failed\n"); in toshiba_kbd_backlight_set()
648 return -EIO; in toshiba_touchpad_set()
655 return -ENODEV; in toshiba_touchpad_set()
657 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_touchpad_set()
665 return -EIO; in toshiba_touchpad_get()
672 return -ENODEV; in toshiba_touchpad_get()
674 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_touchpad_get()
684 dev->eco_supported = 0; in toshiba_eco_mode_available()
688 pr_err("ACPI call to get ECO led failed\n"); in toshiba_eco_mode_available()
695 * LED device is present, but that we just screwed the input in toshiba_eco_mode_available()
701 * Let's query the status of the LED to see if we really have a in toshiba_eco_mode_available()
702 * success response, indicating the actual presense of the LED, in toshiba_eco_mode_available()
708 pr_err("ACPI call to get ECO led failed\n"); in toshiba_eco_mode_available()
715 dev->eco_supported = 1; in toshiba_eco_mode_available()
730 pr_err("ACPI call to get ECO led failed\n"); in toshiba_eco_mode_get_status()
749 /* Switch the Eco Mode led on/off */ in toshiba_eco_mode_set_status()
753 pr_err("ACPI call to set ECO led failed\n"); in toshiba_eco_mode_set_status()
763 dev->accelerometer_supported = 0; in toshiba_accelerometer_available()
778 dev->accelerometer_supported = 1; in toshiba_accelerometer_available()
792 return -EIO; in toshiba_accelerometer_get()
796 return -ENODEV; in toshiba_accelerometer_get()
799 return -EIO; in toshiba_accelerometer_get()
814 dev->usb_sleep_charge_supported = 0; in toshiba_usb_sleep_charge_available()
831 dev->usbsc_mode_base = out[4]; in toshiba_usb_sleep_charge_available()
844 dev->usbsc_bat_level = out[2]; in toshiba_usb_sleep_charge_available()
846 dev->usb_sleep_charge_supported = 1; in toshiba_usb_sleep_charge_available()
855 return -EIO; in toshiba_usb_sleep_charge_get()
862 return -ENODEV; in toshiba_usb_sleep_charge_get()
864 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_charge_get()
873 return -EIO; in toshiba_usb_sleep_charge_set()
880 return -ENODEV; in toshiba_usb_sleep_charge_set()
882 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_charge_set()
893 return -EIO; in toshiba_sleep_functions_status_get()
900 return -EIO; in toshiba_sleep_functions_status_get()
904 return -ENODEV; in toshiba_sleep_functions_status_get()
907 return -EIO; in toshiba_sleep_functions_status_get()
923 return -EIO; in toshiba_sleep_functions_status_set()
931 return -EIO; in toshiba_sleep_functions_status_set()
935 return -ENODEV; in toshiba_sleep_functions_status_set()
937 return out[0] == TOS_SUCCESS ? 0 : -EIO; in toshiba_sleep_functions_status_set()
948 return -EIO; in toshiba_usb_rapid_charge_get()
955 return -EIO; in toshiba_usb_rapid_charge_get()
959 return -ENODEV; in toshiba_usb_rapid_charge_get()
962 return -EIO; in toshiba_usb_rapid_charge_get()
977 return -EIO; in toshiba_usb_rapid_charge_set()
985 return -EIO; in toshiba_usb_rapid_charge_set()
989 return -ENODEV; in toshiba_usb_rapid_charge_set()
991 return (out[0] == TOS_SUCCESS || out[0] == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_usb_rapid_charge_set()
999 return -EIO; in toshiba_usb_sleep_music_get()
1006 return -ENODEV; in toshiba_usb_sleep_music_get()
1008 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_music_get()
1016 return -EIO; in toshiba_usb_sleep_music_set()
1023 return -ENODEV; in toshiba_usb_sleep_music_set()
1025 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_usb_sleep_music_set()
1034 return -EIO; in toshiba_function_keys_get()
1039 pr_err("ACPI call to get KBD function keys failed\n"); in toshiba_function_keys_get()
1041 return -ENODEV; in toshiba_function_keys_get()
1043 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_function_keys_get()
1051 return -EIO; in toshiba_function_keys_set()
1056 pr_err("ACPI call to set KBD function keys failed\n"); in toshiba_function_keys_set()
1058 return -ENODEV; in toshiba_function_keys_set()
1060 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_function_keys_set()
1069 return -EIO; in toshiba_panel_power_on_get()
1076 return -ENODEV; in toshiba_panel_power_on_get()
1078 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_panel_power_on_get()
1086 return -EIO; in toshiba_panel_power_on_set()
1093 return -ENODEV; in toshiba_panel_power_on_set()
1095 return result == TOS_SUCCESS ? 0 : -EIO; in toshiba_panel_power_on_set()
1104 return -EIO; in toshiba_usb_three_get()
1111 return -ENODEV; in toshiba_usb_three_get()
1113 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_usb_three_get()
1121 return -EIO; in toshiba_usb_three_set()
1128 return -ENODEV; in toshiba_usb_three_set()
1130 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_usb_three_set()
1144 return -EIO; in toshiba_hotkey_event_type_get()
1148 return -ENODEV; in toshiba_hotkey_event_type_get()
1151 return -EIO; in toshiba_hotkey_event_type_get()
1170 return -EIO; in toshiba_wireless_status()
1174 return -ENODEV; in toshiba_wireless_status()
1177 return -EIO; in toshiba_wireless_status()
1179 dev->killswitch = !!(out[2] & HCI_WIRELESS_STATUS); in toshiba_wireless_status()
1191 dev->wwan_supported = 0; in toshiba_wwan_available()
1213 dev->wwan_supported = (out[2] == HCI_WIRELESS_WWAN_STATUS); in toshiba_wwan_available()
1226 return -EIO; in toshiba_wwan_set()
1230 return -ENODEV; in toshiba_wwan_set()
1233 return -EIO; in toshiba_wwan_set()
1244 return -EIO; in toshiba_wwan_set()
1248 return -ENODEV; in toshiba_wwan_set()
1250 return out[0] == TOS_SUCCESS ? 0 : -EIO; in toshiba_wwan_set()
1260 dev->cooling_method_supported = 0; in toshiba_cooling_method_available()
1261 dev->max_cooling_method = 0; in toshiba_cooling_method_available()
1272 dev->cooling_method_supported = 1; in toshiba_cooling_method_available()
1273 dev->max_cooling_method = out[3]; in toshiba_cooling_method_available()
1284 return -ENODEV; in toshiba_cooling_method_get()
1286 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_cooling_method_get()
1297 return -ENODEV; in toshiba_cooling_method_set()
1299 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_cooling_method_set()
1309 dev->battery_charge_mode_supported = 0; in toshiba_battery_charge_mode_available()
1320 dev->battery_charge_mode_supported = 1; in toshiba_battery_charge_mode_available()
1340 return -ENODEV; in toshiba_battery_charge_mode_get()
1342 retries--; in toshiba_battery_charge_mode_get()
1345 return -EIO; in toshiba_battery_charge_mode_get()
1349 return -EIO; in toshiba_battery_charge_mode_get()
1360 return -ENODEV; in toshiba_battery_charge_mode_set()
1362 return (result == TOS_SUCCESS || result == TOS_SUCCESS2) ? 0 : -EIO; in toshiba_battery_charge_mode_set()
1365 /* Transflective Backlight */
1371 pr_err("ACPI call to get Transflective Backlight failed\n"); in get_tr_backlight_status()
1373 return -ENODEV; in get_tr_backlight_status()
1375 return result == TOS_SUCCESS ? 0 : -EIO; in get_tr_backlight_status()
1383 pr_err("ACPI call to set Transflective Backlight failed\n"); in set_tr_backlight_status()
1385 return -ENODEV; in set_tr_backlight_status()
1387 return result == TOS_SUCCESS ? 0 : -EIO; in set_tr_backlight_status()
1399 if (dev->tr_backlight_supported) { in __get_lcd_brightness()
1413 return -ENODEV; in __get_lcd_brightness()
1417 -EIO; in __get_lcd_brightness()
1429 struct toshiba_acpi_dev *dev = m->private; in lcd_proc_show()
1433 if (!dev->backlight_dev) in lcd_proc_show()
1434 return -ENODEV; in lcd_proc_show()
1436 levels = dev->backlight_dev->props.max_brightness + 1; in lcd_proc_show()
1437 value = get_lcd_brightness(dev->backlight_dev); in lcd_proc_show()
1458 if (dev->tr_backlight_supported) { in set_lcd_brightness()
1464 value--; in set_lcd_brightness()
1472 return -ENODEV; in set_lcd_brightness()
1474 return result == TOS_SUCCESS ? 0 : -EIO; in set_lcd_brightness()
1481 return set_lcd_brightness(dev, bd->props.brightness); in set_lcd_status()
1493 len = min(count, sizeof(cmd) - 1); in lcd_proc_write()
1495 return -EFAULT; in lcd_proc_write()
1498 levels = dev->backlight_dev->props.max_brightness + 1; in lcd_proc_write()
1501 return -EINVAL; in lcd_proc_write()
1504 return -EIO; in lcd_proc_write()
1517 /* Video-Out */
1523 pr_err("ACPI call to get Video-Out failed\n"); in get_video_status()
1525 return -ENODEV; in get_video_status()
1527 return result == TOS_SUCCESS ? 0 : -EIO; in get_video_status()
1532 struct toshiba_acpi_dev *dev = m->private; in video_proc_show()
1537 return -EIO; in video_proc_show()
1561 int lcd_out = -1, crt_out = -1, tv_out = -1; in video_proc_write()
1587 --remain; in video_proc_write()
1588 } while (remain && *(buffer - 1) != ';'); in video_proc_write()
1597 if (lcd_out != -1) in video_proc_write()
1599 if (crt_out != -1) in video_proc_write()
1601 if (tv_out != -1) in video_proc_write()
1611 return ret ? -EIO : count; in video_proc_write()
1630 return -ENODEV; in get_fan_status()
1632 return result == TOS_SUCCESS ? 0 : -EIO; in get_fan_status()
1642 return -ENODEV; in set_fan_status()
1644 return result == TOS_SUCCESS ? 0 : -EIO; in set_fan_status()
1649 struct toshiba_acpi_dev *dev = m->private; in fan_proc_show()
1653 return -EIO; in fan_proc_show()
1656 seq_printf(m, "force_on: %d\n", dev->force_fan); in fan_proc_show()
1674 len = min(count, sizeof(cmd) - 1); in fan_proc_write()
1676 return -EFAULT; in fan_proc_write()
1681 return -EINVAL; in fan_proc_write()
1684 return -EIO; in fan_proc_write()
1686 dev->force_fan = value; in fan_proc_write()
1708 return -EIO; in get_fan_rpm()
1712 return -ENODEV; in get_fan_rpm()
1719 return -EIO; in get_fan_rpm()
1724 struct toshiba_acpi_dev *dev = m->private; in keys_proc_show()
1726 seq_printf(m, "hotkey_ready: %d\n", dev->key_event_valid); in keys_proc_show()
1727 seq_printf(m, "hotkey: 0x%04x\n", dev->last_key_event); in keys_proc_show()
1745 len = min(count, sizeof(cmd) - 1); in keys_proc_write()
1747 return -EFAULT; in keys_proc_write()
1751 dev->key_event_valid = 0; in keys_proc_write()
1753 return -EINVAL; in keys_proc_write()
1781 if (dev->backlight_dev) in create_toshiba_proc_entries()
1784 if (dev->video_supported) in create_toshiba_proc_entries()
1787 if (dev->fan_supported) in create_toshiba_proc_entries()
1790 if (dev->hotkey_dev) in create_toshiba_proc_entries()
1799 if (dev->backlight_dev) in remove_toshiba_proc_entries()
1801 if (dev->video_supported) in remove_toshiba_proc_entries()
1803 if (dev->fan_supported) in remove_toshiba_proc_entries()
1805 if (dev->hotkey_dev) in remove_toshiba_proc_entries()
1816 /* Keyboard backlight work */
1839 return -EINVAL; in fan_store()
1876 /* Check for supported modes depending on keyboard backlight type */ in kbd_backlight_mode_store()
1877 if (toshiba->kbd_type == 1) { in kbd_backlight_mode_store()
1880 return -EINVAL; in kbd_backlight_mode_store()
1881 } else if (toshiba->kbd_type == 2) { in kbd_backlight_mode_store()
1885 return -EINVAL; in kbd_backlight_mode_store()
1889 * Set the Keyboard Backlight Mode where: in kbd_backlight_mode_store()
1890 * Auto - KBD backlight turns off automatically in given time in kbd_backlight_mode_store()
1891 * FN-Z - KBD backlight "toggles" when hotkey pressed in kbd_backlight_mode_store()
1892 * ON - KBD backlight is always on in kbd_backlight_mode_store()
1893 * OFF - KBD backlight is always off in kbd_backlight_mode_store()
1897 if (toshiba->kbd_mode != mode) { in kbd_backlight_mode_store()
1899 int time = toshiba->kbd_time << HCI_MISC_SHIFT; in kbd_backlight_mode_store()
1902 if (toshiba->kbd_type == 1) { in kbd_backlight_mode_store()
1904 time |= toshiba->kbd_mode; in kbd_backlight_mode_store()
1905 } else if (toshiba->kbd_type == 2) { in kbd_backlight_mode_store()
1914 toshiba->kbd_mode = mode; in kbd_backlight_mode_store()
1915 toshiba_acpi->kbd_mode = mode; in kbd_backlight_mode_store()
1919 * keyboard (type 2) do not generate the keyboard backlight in kbd_backlight_mode_store()
1924 * backlight mode and the *notify function will set the in kbd_backlight_mode_store()
1928 * backlight work to update the sysfs entries and emulate the in kbd_backlight_mode_store()
1931 if (toshiba->kbd_type == 2 && in kbd_backlight_mode_store()
1932 !toshiba->kbd_event_generated) in kbd_backlight_mode_store()
1947 return -EIO; in kbd_backlight_mode_show()
1958 return sprintf(buf, "%d\n", toshiba->kbd_type); in kbd_type_show()
1968 if (toshiba->kbd_type == 1) in available_kbd_modes_show()
1990 if (toshiba->kbd_type == 1) { in kbd_backlight_timeout_store()
1992 return -EINVAL; in kbd_backlight_timeout_store()
1993 } else if (toshiba->kbd_type == 2) { in kbd_backlight_timeout_store()
1995 return -EINVAL; in kbd_backlight_timeout_store()
1998 /* Set the Keyboard Backlight Timeout */ in kbd_backlight_timeout_store()
2001 if (toshiba->kbd_time != time) { in kbd_backlight_timeout_store()
2005 if (toshiba->kbd_type == 1) in kbd_backlight_timeout_store()
2007 else if (toshiba->kbd_type == 2) in kbd_backlight_timeout_store()
2014 toshiba->kbd_time = time >> HCI_MISC_SHIFT; in kbd_backlight_timeout_store()
2028 return -EIO; in kbd_backlight_timeout_show()
2042 /* Set the TouchPad on/off, 0 - Disable | 1 - Enable */ in touchpad_store()
2047 return -EINVAL; in touchpad_store()
2099 * 0 - Disabled in usb_sleep_charge_store()
2100 * 1 - Alternate (Non USB conformant devices that require more power) in usb_sleep_charge_store()
2101 * 2 - Auto (USB conformant devices) in usb_sleep_charge_store()
2102 * 3 - Typical in usb_sleep_charge_store()
2105 return -EINVAL; in usb_sleep_charge_store()
2108 mode = toshiba->usbsc_mode_base; in usb_sleep_charge_store()
2140 /* Determine the status: 0x4 - Enabled | 0x1 - Disabled */ in sleep_functions_on_battery_show()
2165 * 0 - Disabled in sleep_functions_on_battery_store()
2166 * 1-100 - Enabled in sleep_functions_on_battery_store()
2169 return -EINVAL; in sleep_functions_on_battery_store()
2172 tmp = toshiba->usbsc_bat_level << HCI_MISC_SHIFT; in sleep_functions_on_battery_store()
2182 toshiba->usbsc_bat_level = status >> HCI_MISC_SHIFT; in sleep_functions_on_battery_store()
2214 return -EINVAL; in usb_rapid_charge_store()
2250 return -EINVAL; in usb_sleep_music_store()
2287 * 0 - Normal operation (F{1-12} as usual and hotkeys via FN-F{1-12}) in kbd_function_keys_store()
2288 * 1 - Special functions (Opposite of the above setting) in kbd_function_keys_store()
2291 return -EINVAL; in kbd_function_keys_store()
2297 pr_info("Reboot for changes to KBD Function Keys to take effect"); in kbd_function_keys_store()
2329 return -EINVAL; in panel_power_on_store()
2368 * 0 - Disabled (Acts like a USB 2 port, saving power) in usb_three_store()
2369 * 1 - Enabled in usb_three_store()
2372 return -EINVAL; in usb_three_store()
2395 return sprintf(buf, "%d %d\n", state, toshiba->max_cooling_method); in cooling_method_show()
2413 * 0 - Maximum Performance in cooling_method_store()
2414 * 1 - Battery Optimized in cooling_method_store()
2417 * 0 - Maximum Performance in cooling_method_store()
2418 * 1 - Performance in cooling_method_store()
2419 * 2 - Battery Optimized in cooling_method_store()
2421 if (state < 0 || state > toshiba->max_cooling_method) in cooling_method_store()
2422 return -EINVAL; in cooling_method_store()
2459 exists = (drv->fan_supported) ? true : false; in toshiba_sysfs_is_visible()
2461 exists = (drv->kbd_illum_supported) ? true : false; in toshiba_sysfs_is_visible()
2463 exists = (drv->kbd_mode == SCI_KBD_MODE_AUTO) ? true : false; in toshiba_sysfs_is_visible()
2465 exists = (drv->touchpad_supported) ? true : false; in toshiba_sysfs_is_visible()
2467 exists = (drv->usb_sleep_charge_supported) ? true : false; in toshiba_sysfs_is_visible()
2469 exists = (drv->usb_sleep_charge_supported) ? true : false; in toshiba_sysfs_is_visible()
2471 exists = (drv->usb_rapid_charge_supported) ? true : false; in toshiba_sysfs_is_visible()
2473 exists = (drv->usb_sleep_music_supported) ? true : false; in toshiba_sysfs_is_visible()
2475 exists = (drv->kbd_function_keys_supported) ? true : false; in toshiba_sysfs_is_visible()
2477 exists = (drv->panel_power_on_supported) ? true : false; in toshiba_sysfs_is_visible()
2479 exists = (drv->usb_three_supported) ? true : false; in toshiba_sysfs_is_visible()
2481 exists = (drv->cooling_method_supported) ? true : false; in toshiba_sysfs_is_visible()
2483 return exists ? attr->mode : 0; in toshiba_sysfs_is_visible()
2494 if (sysfs_update_group(&toshiba_acpi->acpi_dev->dev.kobj, in toshiba_acpi_kbd_bl_work()
2498 /* Notify LED subsystem about keyboard backlight change */ in toshiba_acpi_kbd_bl_work()
2499 if (toshiba_acpi->kbd_type == 2 && in toshiba_acpi_kbd_bl_work()
2500 toshiba_acpi->kbd_mode != SCI_KBD_MODE_AUTO) in toshiba_acpi_kbd_bl_work()
2501 led_classdev_notify_brightness_hw_changed(&toshiba_acpi->kbd_led, in toshiba_acpi_kbd_bl_work()
2502 (toshiba_acpi->kbd_mode == SCI_KBD_MODE_ON) ? in toshiba_acpi_kbd_bl_work()
2505 /* Emulate the keyboard backlight event */ in toshiba_acpi_kbd_bl_work()
2506 acpi_bus_generate_netlink_event(toshiba_acpi->acpi_dev->pnp.device_class, in toshiba_acpi_kbd_bl_work()
2507 dev_name(&toshiba_acpi->acpi_dev->dev), in toshiba_acpi_kbd_bl_work()
2533 -(xyval & HCI_ACCEL_MASK) : xyval & HCI_ACCEL_MASK; in toshiba_iio_accel_get_axis()
2536 -((xyval >> HCI_MISC_SHIFT) & HCI_ACCEL_MASK) : in toshiba_iio_accel_get_axis()
2540 -(zval & HCI_ACCEL_MASK) : zval & HCI_ACCEL_MASK; in toshiba_iio_accel_get_axis()
2554 ret = toshiba_iio_accel_get_axis(chan->channel); in toshiba_iio_accel_read_raw()
2555 if (ret == -EIO || ret == -ENODEV) in toshiba_iio_accel_read_raw()
2563 return -EINVAL; in toshiba_iio_accel_read_raw()
2590 u32 in[TCI_WORDS] = { regs->eax, regs->ebx, regs->ecx, in toshiba_acpi_smm_bridge()
2591 regs->edx, regs->esi, regs->edi }; in toshiba_acpi_smm_bridge()
2598 return -EIO; in toshiba_acpi_smm_bridge()
2602 regs->eax = out[0]; in toshiba_acpi_smm_bridge()
2603 regs->ebx = out[1]; in toshiba_acpi_smm_bridge()
2604 regs->ecx = out[2]; in toshiba_acpi_smm_bridge()
2605 regs->edx = out[3]; in toshiba_acpi_smm_bridge()
2606 regs->esi = out[4]; in toshiba_acpi_smm_bridge()
2607 regs->edi = out[5]; in toshiba_acpi_smm_bridge()
2620 return -EINVAL; in toshiba_acpi_ioctl()
2625 return -EFAULT; in toshiba_acpi_ioctl()
2630 return -EFAULT; in toshiba_acpi_ioctl()
2634 return -EFAULT; in toshiba_acpi_ioctl()
2637 return -EINVAL; in toshiba_acpi_ioctl()
2639 return -EIO; in toshiba_acpi_ioctl()
2645 return -EFAULT; in toshiba_acpi_ioctl()
2648 return -EINVAL; in toshiba_acpi_ioctl()
2672 if (!dev->killswitch) in toshiba_acpi_wwan_set_block()
2685 rfkill_set_hw_state(dev->wwan_rfk, !dev->killswitch); in toshiba_acpi_wwan_poll()
2700 dev->wwan_rfk = rfkill_alloc("Toshiba WWAN", in toshiba_acpi_setup_wwan_rfkill()
2701 &dev->acpi_dev->dev, in toshiba_acpi_setup_wwan_rfkill()
2705 if (!dev->wwan_rfk) { in toshiba_acpi_setup_wwan_rfkill()
2707 return -ENOMEM; in toshiba_acpi_setup_wwan_rfkill()
2710 rfkill_set_hw_state(dev->wwan_rfk, !dev->killswitch); in toshiba_acpi_setup_wwan_rfkill()
2712 ret = rfkill_register(dev->wwan_rfk); in toshiba_acpi_setup_wwan_rfkill()
2715 rfkill_destroy(dev->wwan_rfk); in toshiba_acpi_setup_wwan_rfkill()
2729 status = acpi_evaluate_object(dev->acpi_dev->handle, in toshiba_acpi_enable_hotkeys()
2732 return -ENODEV; in toshiba_acpi_enable_hotkeys()
2743 else if (dev->kbd_function_keys_supported && dev->special_functions) in toshiba_acpi_enable_hotkeys()
2750 return -EIO; in toshiba_acpi_enable_hotkeys()
2752 return -ENODEV; in toshiba_acpi_enable_hotkeys()
2767 schedule_work(&toshiba_acpi->hotkey_work); in toshiba_acpi_i8042_filter()
2795 status = acpi_evaluate_integer(dev->acpi_dev->handle, "INFO", in toshiba_acpi_query_hotkey()
2799 return -EIO; in toshiba_acpi_query_hotkey()
2815 if (!sparse_keymap_report_event(dev->hotkey_dev, scancode, 1, true)) in toshiba_acpi_report_hotkey()
2821 if (dev->info_supported) { in toshiba_acpi_process_hotkeys()
2828 dev->key_event_valid = 1; in toshiba_acpi_process_hotkeys()
2829 dev->last_key_event = scancode; in toshiba_acpi_process_hotkeys()
2831 } else if (dev->system_event_supported) { in toshiba_acpi_process_hotkeys()
2841 dev->key_event_valid = 1; in toshiba_acpi_process_hotkeys()
2842 dev->last_key_event = value; in toshiba_acpi_process_hotkeys()
2852 pr_notice("Re-enabled hotkeys\n"); in toshiba_acpi_process_hotkeys()
2855 retries--; in toshiba_acpi_process_hotkeys()
2882 if (toshiba_hotkey_event_type_get(dev, &dev->hotkey_event_type)) in toshiba_acpi_setup_keyboard()
2885 dev->hotkey_dev = input_allocate_device(); in toshiba_acpi_setup_keyboard()
2886 if (!dev->hotkey_dev) in toshiba_acpi_setup_keyboard()
2887 return -ENOMEM; in toshiba_acpi_setup_keyboard()
2889 dev->hotkey_dev->name = "Toshiba input device"; in toshiba_acpi_setup_keyboard()
2890 dev->hotkey_dev->phys = "toshiba_acpi/input0"; in toshiba_acpi_setup_keyboard()
2891 dev->hotkey_dev->id.bustype = BUS_HOST; in toshiba_acpi_setup_keyboard()
2892 dev->hotkey_dev->dev.parent = &dev->acpi_dev->dev; in toshiba_acpi_setup_keyboard()
2894 if (dev->hotkey_event_type == HCI_SYSTEM_TYPE1 || in toshiba_acpi_setup_keyboard()
2895 !dev->kbd_function_keys_supported) in toshiba_acpi_setup_keyboard()
2897 else if (dev->hotkey_event_type == HCI_SYSTEM_TYPE2 || in toshiba_acpi_setup_keyboard()
2898 dev->kbd_function_keys_supported) in toshiba_acpi_setup_keyboard()
2902 dev->hotkey_event_type); in toshiba_acpi_setup_keyboard()
2903 error = sparse_keymap_setup(dev->hotkey_dev, keymap, NULL); in toshiba_acpi_setup_keyboard()
2916 INIT_WORK(&dev->hotkey_work, toshiba_acpi_hotkey_work); in toshiba_acpi_setup_keyboard()
2924 dev->ntfy_supported = 1; in toshiba_acpi_setup_keyboard()
2931 if (acpi_has_method(dev->acpi_dev->handle, "INFO")) in toshiba_acpi_setup_keyboard()
2932 dev->info_supported = 1; in toshiba_acpi_setup_keyboard()
2934 dev->system_event_supported = 1; in toshiba_acpi_setup_keyboard()
2936 if (!dev->info_supported && !dev->system_event_supported) { in toshiba_acpi_setup_keyboard()
2938 error = -EINVAL; in toshiba_acpi_setup_keyboard()
2942 error = input_register_device(dev->hotkey_dev); in toshiba_acpi_setup_keyboard()
2951 if (dev->ntfy_supported) in toshiba_acpi_setup_keyboard()
2954 input_free_device(dev->hotkey_dev); in toshiba_acpi_setup_keyboard()
2955 dev->hotkey_dev = NULL; in toshiba_acpi_setup_keyboard()
2966 * Some machines don't support the backlight methods at all, and in toshiba_acpi_setup_backlight()
2967 * others support it read-only. Either of these is pretty useless, in toshiba_acpi_setup_backlight()
2968 * so only register the backlight device if the backlight method in toshiba_acpi_setup_backlight()
2975 * If transflective backlight is supported and the brightness is zero in toshiba_acpi_setup_backlight()
2977 * activate the transflective backlight, making the LCD appear to be in toshiba_acpi_setup_backlight()
2980 if (dev->tr_backlight_supported && brightness == 0) in toshiba_acpi_setup_backlight()
2984 pr_debug("Backlight method is read-only, disabling backlight support\n"); in toshiba_acpi_setup_backlight()
2993 props.max_brightness = HCI_LCD_BRIGHTNESS_LEVELS - 1; in toshiba_acpi_setup_backlight()
2996 if (dev->tr_backlight_supported) in toshiba_acpi_setup_backlight()
2999 dev->backlight_dev = backlight_device_register("toshiba", in toshiba_acpi_setup_backlight()
3000 &dev->acpi_dev->dev, in toshiba_acpi_setup_backlight()
3004 if (IS_ERR(dev->backlight_dev)) { in toshiba_acpi_setup_backlight()
3005 ret = PTR_ERR(dev->backlight_dev); in toshiba_acpi_setup_backlight()
3006 pr_err("Could not register toshiba backlight device\n"); in toshiba_acpi_setup_backlight()
3007 dev->backlight_dev = NULL; in toshiba_acpi_setup_backlight()
3011 dev->backlight_dev->props.brightness = brightness; in toshiba_acpi_setup_backlight()
3044 return -EOPNOTSUPP; in toshiba_acpi_hwmon_read()
3073 return -ENODEV; in charge_control_end_threshold_show()
3097 return -ENODEV; in charge_control_end_threshold_store()
3105 return -EINVAL; in charge_control_end_threshold_store()
3127 return -ENODEV; in toshiba_acpi_battery_add()
3129 if (!toshiba_acpi->battery_charge_mode_supported) in toshiba_acpi_battery_add()
3130 return -ENODEV; in toshiba_acpi_battery_add()
3131 if (device_add_groups(&battery->dev, toshiba_acpi_battery_groups)) in toshiba_acpi_battery_add()
3132 return -ENODEV; in toshiba_acpi_battery_add()
3138 device_remove_groups(&battery->dev, toshiba_acpi_battery_groups); in toshiba_acpi_battery_remove()
3152 if (dev->hotkey_dev) in print_supported_features()
3154 if (dev->backlight_dev) in print_supported_features()
3155 pr_cont(" backlight"); in print_supported_features()
3156 if (dev->video_supported) in print_supported_features()
3157 pr_cont(" video-out"); in print_supported_features()
3158 if (dev->fan_supported) in print_supported_features()
3160 if (dev->fan_rpm_supported) in print_supported_features()
3161 pr_cont(" fan-rpm"); in print_supported_features()
3162 if (dev->tr_backlight_supported) in print_supported_features()
3163 pr_cont(" transflective-backlight"); in print_supported_features()
3164 if (dev->illumination_supported) in print_supported_features()
3166 if (dev->kbd_illum_supported) in print_supported_features()
3167 pr_cont(" keyboard-backlight"); in print_supported_features()
3168 if (dev->touchpad_supported) in print_supported_features()
3170 if (dev->eco_supported) in print_supported_features()
3171 pr_cont(" eco-led"); in print_supported_features()
3172 if (dev->accelerometer_supported) in print_supported_features()
3173 pr_cont(" accelerometer-axes"); in print_supported_features()
3174 if (dev->usb_sleep_charge_supported) in print_supported_features()
3175 pr_cont(" usb-sleep-charge"); in print_supported_features()
3176 if (dev->usb_rapid_charge_supported) in print_supported_features()
3177 pr_cont(" usb-rapid-charge"); in print_supported_features()
3178 if (dev->usb_sleep_music_supported) in print_supported_features()
3179 pr_cont(" usb-sleep-music"); in print_supported_features()
3180 if (dev->kbd_function_keys_supported) in print_supported_features()
3181 pr_cont(" special-function-keys"); in print_supported_features()
3182 if (dev->panel_power_on_supported) in print_supported_features()
3183 pr_cont(" panel-power-on"); in print_supported_features()
3184 if (dev->usb_three_supported) in print_supported_features()
3186 if (dev->wwan_supported) in print_supported_features()
3188 if (dev->cooling_method_supported) in print_supported_features()
3189 pr_cont(" cooling-method"); in print_supported_features()
3190 if (dev->battery_charge_mode_supported) in print_supported_features()
3191 pr_cont(" battery-charge-mode"); in print_supported_features()
3200 misc_deregister(&dev->miscdev); in toshiba_acpi_remove()
3205 if (dev->hwmon_device) in toshiba_acpi_remove()
3206 hwmon_device_unregister(dev->hwmon_device); in toshiba_acpi_remove()
3209 if (dev->accelerometer_supported && dev->indio_dev) { in toshiba_acpi_remove()
3210 iio_device_unregister(dev->indio_dev); in toshiba_acpi_remove()
3211 iio_device_free(dev->indio_dev); in toshiba_acpi_remove()
3214 if (dev->sysfs_created) in toshiba_acpi_remove()
3215 sysfs_remove_group(&dev->acpi_dev->dev.kobj, in toshiba_acpi_remove()
3218 if (dev->ntfy_supported) { in toshiba_acpi_remove()
3220 cancel_work_sync(&dev->hotkey_work); in toshiba_acpi_remove()
3223 if (dev->hotkey_dev) in toshiba_acpi_remove()
3224 input_unregister_device(dev->hotkey_dev); in toshiba_acpi_remove()
3226 backlight_device_unregister(dev->backlight_dev); in toshiba_acpi_remove()
3228 led_classdev_unregister(&dev->led_dev); in toshiba_acpi_remove()
3229 led_classdev_unregister(&dev->kbd_led); in toshiba_acpi_remove()
3230 led_classdev_unregister(&dev->eco_led); in toshiba_acpi_remove()
3232 if (dev->wwan_rfk) { in toshiba_acpi_remove()
3233 rfkill_unregister(dev->wwan_rfk); in toshiba_acpi_remove()
3234 rfkill_destroy(dev->wwan_rfk); in toshiba_acpi_remove()
3237 if (dev->battery_charge_mode_supported) in toshiba_acpi_remove()
3258 * Some Toshibas have a broken acpi-video interface for brightness control,
3260 * (/sys/class/backlight/intel_backlight) instead.
3313 return -EBUSY; in toshiba_acpi_add()
3318 hci_method = find_hci_method(acpi_dev->handle); in toshiba_acpi_add()
3321 return -ENODEV; in toshiba_acpi_add()
3326 return -ENOMEM; in toshiba_acpi_add()
3327 dev->acpi_dev = acpi_dev; in toshiba_acpi_add()
3328 dev->method_hci = hci_method; in toshiba_acpi_add()
3329 dev->miscdev.minor = MISC_DYNAMIC_MINOR; in toshiba_acpi_add()
3330 dev->miscdev.name = "toshiba_acpi"; in toshiba_acpi_add()
3331 dev->miscdev.fops = &toshiba_acpi_fops; in toshiba_acpi_add()
3333 ret = misc_register(&dev->miscdev); in toshiba_acpi_add()
3340 acpi_dev->driver_data = dev; in toshiba_acpi_add()
3341 dev_set_drvdata(&acpi_dev->dev, dev); in toshiba_acpi_add()
3350 ret = toshiba_function_keys_get(dev, &dev->special_functions); in toshiba_acpi_add()
3351 dev->kbd_function_keys_supported = !ret; in toshiba_acpi_add()
3353 dev->hotkey_event_type = 0; in toshiba_acpi_add()
3357 /* Determine whether or not BIOS supports transflective backlight */ in toshiba_acpi_add()
3359 dev->tr_backlight_supported = !ret; in toshiba_acpi_add()
3366 if (dev->illumination_supported) { in toshiba_acpi_add()
3367 dev->led_dev.name = "toshiba::illumination"; in toshiba_acpi_add()
3368 dev->led_dev.max_brightness = 1; in toshiba_acpi_add()
3369 dev->led_dev.brightness_set = toshiba_illumination_set; in toshiba_acpi_add()
3370 dev->led_dev.brightness_get = toshiba_illumination_get; in toshiba_acpi_add()
3371 led_classdev_register(&acpi_dev->dev, &dev->led_dev); in toshiba_acpi_add()
3375 if (dev->eco_supported) { in toshiba_acpi_add()
3376 dev->eco_led.name = "toshiba::eco_mode"; in toshiba_acpi_add()
3377 dev->eco_led.max_brightness = 1; in toshiba_acpi_add()
3378 dev->eco_led.brightness_set = toshiba_eco_mode_set_status; in toshiba_acpi_add()
3379 dev->eco_led.brightness_get = toshiba_eco_mode_get_status; in toshiba_acpi_add()
3380 led_classdev_register(&dev->acpi_dev->dev, &dev->eco_led); in toshiba_acpi_add()
3385 * Only register the LED if KBD illumination is supported in toshiba_acpi_add()
3386 * and the keyboard backlight operation mode is set to FN-Z in toshiba_acpi_add()
3387 * or we detect a second gen keyboard backlight in toshiba_acpi_add()
3389 if (dev->kbd_illum_supported && in toshiba_acpi_add()
3390 (dev->kbd_mode == SCI_KBD_MODE_FNZ || dev->kbd_type == 2)) { in toshiba_acpi_add()
3391 dev->kbd_led.name = "toshiba::kbd_backlight"; in toshiba_acpi_add()
3392 dev->kbd_led.flags = LED_BRIGHT_HW_CHANGED; in toshiba_acpi_add()
3393 dev->kbd_led.max_brightness = 1; in toshiba_acpi_add()
3394 dev->kbd_led.brightness_set = toshiba_kbd_backlight_set; in toshiba_acpi_add()
3395 dev->kbd_led.brightness_get = toshiba_kbd_backlight_get; in toshiba_acpi_add()
3396 led_classdev_register(&dev->acpi_dev->dev, &dev->kbd_led); in toshiba_acpi_add()
3400 dev->touchpad_supported = !ret; in toshiba_acpi_add()
3403 if (dev->accelerometer_supported) { in toshiba_acpi_add()
3404 dev->indio_dev = iio_device_alloc(&acpi_dev->dev, sizeof(*dev)); in toshiba_acpi_add()
3405 if (!dev->indio_dev) { in toshiba_acpi_add()
3412 dev->indio_dev->info = &toshiba_iio_accel_info; in toshiba_acpi_add()
3413 dev->indio_dev->name = "Toshiba accelerometer"; in toshiba_acpi_add()
3414 dev->indio_dev->modes = INDIO_DIRECT_MODE; in toshiba_acpi_add()
3415 dev->indio_dev->channels = toshiba_iio_accel_channels; in toshiba_acpi_add()
3416 dev->indio_dev->num_channels = in toshiba_acpi_add()
3419 ret = iio_device_register(dev->indio_dev); in toshiba_acpi_add()
3422 iio_device_free(dev->indio_dev); in toshiba_acpi_add()
3430 dev->usb_rapid_charge_supported = !ret; in toshiba_acpi_add()
3433 dev->usb_sleep_music_supported = !ret; in toshiba_acpi_add()
3436 dev->panel_power_on_supported = !ret; in toshiba_acpi_add()
3439 dev->usb_three_supported = !ret; in toshiba_acpi_add()
3442 dev->video_supported = !ret; in toshiba_acpi_add()
3445 dev->fan_supported = !ret; in toshiba_acpi_add()
3448 dev->fan_rpm_supported = !ret; in toshiba_acpi_add()
3451 if (dev->fan_rpm_supported) { in toshiba_acpi_add()
3452 dev->hwmon_device = hwmon_device_register_with_info( in toshiba_acpi_add()
3453 &dev->acpi_dev->dev, "toshiba_acpi_sensors", NULL, in toshiba_acpi_add()
3455 if (IS_ERR(dev->hwmon_device)) { in toshiba_acpi_add()
3456 dev->hwmon_device = NULL; in toshiba_acpi_add()
3463 if (dev->wwan_supported) in toshiba_acpi_add()
3472 ret = sysfs_create_group(&dev->acpi_dev->dev.kobj, in toshiba_acpi_add()
3475 dev->sysfs_created = 0; in toshiba_acpi_add()
3478 dev->sysfs_created = !ret; in toshiba_acpi_add()
3488 if (dev->battery_charge_mode_supported) in toshiba_acpi_add()
3529 case 0x92: /* Keyboard backlight mode changed */ in toshiba_acpi_notify()
3530 dev->kbd_event_generated = true; in toshiba_acpi_notify()
3532 if (sysfs_update_group(&acpi_dev->dev.kobj, in toshiba_acpi_notify()
3535 /* Notify LED subsystem about keyboard backlight change */ in toshiba_acpi_notify()
3536 if (dev->kbd_type == 2 && dev->kbd_mode != SCI_KBD_MODE_AUTO) in toshiba_acpi_notify()
3537 led_classdev_notify_brightness_hw_changed(&dev->kbd_led, in toshiba_acpi_notify()
3538 (dev->kbd_mode == SCI_KBD_MODE_ON) ? in toshiba_acpi_notify()
3552 acpi_bus_generate_netlink_event(acpi_dev->pnp.device_class, in toshiba_acpi_notify()
3553 dev_name(&acpi_dev->dev), in toshiba_acpi_notify()
3555 dev->last_key_event : 0); in toshiba_acpi_notify()
3563 if (dev->hotkey_dev) { in toshiba_acpi_suspend()
3578 if (dev->hotkey_dev) { in toshiba_acpi_resume()
3580 pr_info("Unable to re-enable hotkeys\n"); in toshiba_acpi_resume()
3583 if (dev->wwan_rfk) { in toshiba_acpi_resume()
3585 rfkill_set_hw_state(dev->wwan_rfk, !dev->killswitch); in toshiba_acpi_resume()
3617 quirks = (long)dmi_id->driver_data; in toshiba_dmi_init()
3619 if (turn_on_panel_on_resume == -1) in toshiba_dmi_init()
3622 if (hci_hotkey_quickstart == -1) in toshiba_dmi_init()
3634 return -ENODEV; in toshiba_acpi_init()