Lines Matching +full:timeout +full:- +full:ati +full:- +full:ms

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * thinkpad_acpi.c - ThinkPad ACPI Extras
5 * Copyright (C) 2004-2005 Borislav Deianov <borislav@users.sf.net>
6 * Copyright (C) 2006-2009 Henrique de Moraes Holschuh <hmh@hmh.eng.br>
16 * 2007-10-20 changelog trimmed down
18 * 2007-03-27 0.14 renamed to thinkpad_acpi and moved to
21 * 2006-11-22 0.13 new maintainer
23 * not be updated further in-file.
25 * 2005-03-17 0.11 support for 600e, 770x
28 * 2005-01-16 0.9 use MODULE_VERSION
33 * 2004-11-08 0.8 fix init error case, don't return from a macro
45 #include <linux/hwmon-sysfs.h>
48 #include <linux/input/sparse-keymap.h>
122 /* Misc NVRAM-related */
181 * hkey -> scancode translation for
183 * directly in the sparse-keymap.
197 /* Auto-sleep after eject request */
214 /* User-interface events */
226 /* Key-related user-interface events */
243 /* AC-related events */
246 /* Further user-interface events */
264 #define TPACPI_URL "http://ibm-acpi.sf.net/"
265 #define TPACPI_MAIL "ibm-acpi-devel@lists.sourceforge.net"
292 * Driver-wide structs and misc. variables
390 char *ec_version_str; /* Something like 1ZHT51WW-1.04a */
398 char *nummodel_str; /* 9384A9C for a 9384-A9C model */
479 * two or three characters from the set [0-9A-Z], i.e. base 36.
531 * tpacpi_check_quirks() - search BIOS/EC version on a list
548 if ((qlist->vendor == thinkpad_id.vendor || in tpacpi_check_quirks()
549 qlist->vendor == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
550 (qlist->bios == thinkpad_id.bios_model || in tpacpi_check_quirks()
551 qlist->bios == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
552 (qlist->ec == thinkpad_id.ec_model || in tpacpi_check_quirks()
553 qlist->ec == TPACPI_MATCH_ANY)) in tpacpi_check_quirks()
554 return qlist->quirks; in tpacpi_check_quirks()
556 qlist_size--; in tpacpi_check_quirks()
598 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
724 return -ENXIO; in issue_thinkpad_cmos_command()
727 return -EIO; in issue_thinkpad_cmos_command()
816 if (!ibm || !ibm->acpi || !ibm->acpi->notify) in dispatch_acpi_notify()
819 ibm->acpi->notify(ibm, event); in dispatch_acpi_notify()
826 BUG_ON(!ibm->acpi); in setup_acpi_notify()
828 if (!*ibm->acpi->handle) in setup_acpi_notify()
832 "setting up ACPI notify for %s\n", ibm->name); in setup_acpi_notify()
834 ibm->acpi->device = acpi_fetch_acpi_dev(*ibm->acpi->handle); in setup_acpi_notify()
835 if (!ibm->acpi->device) { in setup_acpi_notify()
836 pr_err("acpi_fetch_acpi_dev(%s) failed\n", ibm->name); in setup_acpi_notify()
837 return -ENODEV; in setup_acpi_notify()
840 ibm->acpi->device->driver_data = ibm; in setup_acpi_notify()
841 sprintf(acpi_device_class(ibm->acpi->device), "%s/%s", in setup_acpi_notify()
843 ibm->name); in setup_acpi_notify()
845 status = acpi_install_notify_handler(*ibm->acpi->handle, in setup_acpi_notify()
846 ibm->acpi->type, dispatch_acpi_notify, ibm); in setup_acpi_notify()
850 ibm->name); in setup_acpi_notify()
853 ibm->name, acpi_format_exception(status)); in setup_acpi_notify()
855 return -ENODEV; in setup_acpi_notify()
857 ibm->flags.acpi_notify_installed = 1; in setup_acpi_notify()
871 "registering %s as an ACPI driver\n", ibm->name); in register_tpacpi_subdriver()
873 BUG_ON(!ibm->acpi); in register_tpacpi_subdriver()
875 ibm->acpi->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL); in register_tpacpi_subdriver()
876 if (!ibm->acpi->driver) { in register_tpacpi_subdriver()
877 pr_err("failed to allocate memory for ibm->acpi->driver\n"); in register_tpacpi_subdriver()
878 return -ENOMEM; in register_tpacpi_subdriver()
881 sprintf(ibm->acpi->driver->name, "%s_%s", TPACPI_NAME, ibm->name); in register_tpacpi_subdriver()
882 ibm->acpi->driver->ids = ibm->acpi->hid; in register_tpacpi_subdriver()
884 ibm->acpi->driver->ops.add = &tpacpi_device_add; in register_tpacpi_subdriver()
886 rc = acpi_bus_register_driver(ibm->acpi->driver); in register_tpacpi_subdriver()
889 ibm->name, rc); in register_tpacpi_subdriver()
890 kfree(ibm->acpi->driver); in register_tpacpi_subdriver()
891 ibm->acpi->driver = NULL; in register_tpacpi_subdriver()
893 ibm->flags.acpi_driver_registered = 1; in register_tpacpi_subdriver()
909 struct ibm_struct *ibm = m->private; in dispatch_proc_show()
911 if (!ibm || !ibm->read) in dispatch_proc_show()
912 return -EINVAL; in dispatch_proc_show()
913 return ibm->read(m); in dispatch_proc_show()
929 if (!ibm || !ibm->write) in dispatch_proc_write()
930 return -EINVAL; in dispatch_proc_write()
931 if (count > PAGE_SIZE - 1) in dispatch_proc_write()
932 return -EINVAL; in dispatch_proc_write()
937 ret = ibm->write(kernbuf); in dispatch_proc_write()
977 if (ibm->suspend) in tpacpi_suspend_handler()
978 (ibm->suspend)(); in tpacpi_suspend_handler()
991 if (ibm->resume) in tpacpi_resume_handler()
992 (ibm->resume)(); in tpacpi_resume_handler()
1009 if (ibm->shutdown) in tpacpi_shutdown_handler()
1010 (ibm->shutdown)(); in tpacpi_shutdown_handler()
1026 return -EINVAL; in parse_strtoul()
1050 * ThinkPad-ACPI firmware handling model:
1052 * WLSW (master wireless switch) is event-driven, and is common to all
1053 * firmware-controlled radios. It cannot be controlled, just monitored,
1056 * The kernel, a masked-off hotkey, and WLSW can change the radio state
1060 * masked-off hotkeys are used.
1089 /* ThinkPad-ACPI rfkill subdriver */
1110 return -ENODEV; in tpacpi_rfk_update_swstate()
1112 status = (tp_rfk->ops->get_status)(); in tpacpi_rfk_update_swstate()
1116 rfkill_set_sw_state(tp_rfk->rfkill, in tpacpi_rfk_update_swstate()
1123 * Sync the HW-blocking state of all rfkill switches,
1134 if (rfkill_set_hw_state(tp_rfk->rfkill, in tpacpi_rfk_update_hwblock_state()
1136 /* ignore -- we track sw block */ in tpacpi_rfk_update_hwblock_state()
1171 res = (tp_rfk->ops->set_status)(blocked ? in tpacpi_rfk_hook_set_block()
1200 atp_rfk->rfkill = rfkill_alloc(name, in tpacpi_new_rfkill()
1201 &tpacpi_pdev->dev, in tpacpi_new_rfkill()
1205 if (!atp_rfk || !atp_rfk->rfkill) { in tpacpi_new_rfkill()
1208 return -ENOMEM; in tpacpi_new_rfkill()
1211 atp_rfk->id = id; in tpacpi_new_rfkill()
1212 atp_rfk->ops = tp_rfkops; in tpacpi_new_rfkill()
1214 sw_status = (tp_rfkops->get_status)(); in tpacpi_new_rfkill()
1223 rfkill_init_sw_state(atp_rfk->rfkill, sw_state); in tpacpi_new_rfkill()
1227 rfkill_set_hw_state(atp_rfk->rfkill, hw_state); in tpacpi_new_rfkill()
1229 res = rfkill_register(atp_rfk->rfkill); in tpacpi_new_rfkill()
1232 rfkill_destroy(atp_rfk->rfkill); in tpacpi_new_rfkill()
1252 rfkill_unregister(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1253 rfkill_destroy(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1265 /* sysfs <radio> enable ------------------------------------------------ */
1272 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_show()
1294 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_store()
1297 return -EINVAL; in tpacpi_rfk_sysfs_enable_store()
1299 tpacpi_disclose_usertask(attr->attr.name, "set to %ld\n", t); in tpacpi_rfk_sysfs_enable_store()
1303 return -EPERM; in tpacpi_rfk_sysfs_enable_store()
1305 res = tpacpi_rfkill_switches[id]->ops->set_status((!!t) ? in tpacpi_rfk_sysfs_enable_store()
1312 /* procfs -------------------------------------------------------------- */
1340 int status = -1; in tpacpi_rfk_procfs_write()
1344 return -ENODEV; in tpacpi_rfk_procfs_write()
1352 return -EINVAL; in tpacpi_rfk_procfs_write()
1355 if (status != -1) { in tpacpi_rfk_procfs_write()
1359 res = (tpacpi_rfkill_switches[id]->ops->set_status)(status); in tpacpi_rfk_procfs_write()
1367 * thinkpad-acpi driver attributes
1370 /* interface_version --------------------------------------------------- */
1377 /* debug_level --------------------------------------------------------- */
1389 return -EINVAL; in debug_level_store()
1397 /* version ------------------------------------------------------------- */
1405 /* --------------------------------------------------------------------- */
1409 /* wlsw_emulstate ------------------------------------------------------ */
1421 return -EINVAL; in wlsw_emulstate_store()
1432 /* bluetooth_emulstate ------------------------------------------------- */
1444 return -EINVAL; in bluetooth_emulstate_store()
1452 /* wwan_emulstate ------------------------------------------------- */
1464 return -EINVAL; in wwan_emulstate_store()
1472 /* uwb_emulstate ------------------------------------------------- */
1484 return -EINVAL; in uwb_emulstate_store()
1570 /* Numeric models ------------------ */
1582 /* A-series ------------------------- */
1596 /* G-series ------------------------- */
1601 /* R-series, T-series --------------- */
1631 /* X-series ------------------------- */
1644 /* (0) - older versions lack DMI EC fw string and functionality */
1645 /* (1) - older versions known to lack functionality */
1701 * thinkpad-acpi metadata subdriver
1736 * Unlike other classes, hotkey-class events have mask/unmask control on
1737 * non-ancient firmware. However, how it behaves changes a lot with the
1955 return -ENODEV; in hotkey_get_wlsw()
1964 return -EIO; in hotkey_get_wlsw()
2058 return -EIO; in hotkey_get_tablet_mode()
2064 return -EIO; in hotkey_get_tablet_mode()
2089 return -EIO; in hotkey_mask_get()
2097 /* sync userspace-visible mask */ in hotkey_mask_get()
2135 rc = -EIO; in hotkey_mask_set()
2176 …pr_notice("please consider using the driver defaults, and refer to up-to-date thinkpad-acpi docume… in hotkey_user_mask_set()
2225 return -EIO; in hotkey_status_get()
2233 return -EIO; in hotkey_status_set()
2263 * Before the conversion to using the sparse-keymap helpers the driver used to in tpacpi_input_send_key()
2264 * map the hkey event codes to 0x00 - 0x4d scancodes so that a straight scancode in tpacpi_input_send_key()
2267 * 0x1001 - 0x1020 -> 0x00 - 0x1f (Original ThinkPad events) in tpacpi_input_send_key()
2268 * 0x1103 - 0x1116 -> 0x20 - 0x33 (Adaptive keyboard, 2014 X1 Carbon) in tpacpi_input_send_key()
2269 * 0x1300 - 0x1319 -> 0x34 - 0x4d (Additional keys send in 2017+ models) in tpacpi_input_send_key()
2271 * The sparse-keymap tables still use these scancodes for these ranges to in tpacpi_input_send_key()
2276 scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; in tpacpi_input_send_key()
2281 scancode = hkey - TP_HKEY_EV_ADAPTIVE_KEY_START + in tpacpi_input_send_key()
2285 scancode = hkey - TP_HKEY_EV_EXTENDED_KEY_START + in tpacpi_input_send_key()
2321 n->thinkpad_toggle = !!(d & TP_NVRAM_MASK_HKT_THINKPAD); in hotkey_read_nvram()
2322 n->zoom_toggle = !!(d & TP_NVRAM_MASK_HKT_ZOOM); in hotkey_read_nvram()
2323 n->display_toggle = !!(d & TP_NVRAM_MASK_HKT_DISPLAY); in hotkey_read_nvram()
2324 n->hibernate_toggle = !!(d & TP_NVRAM_MASK_HKT_HIBERNATE); in hotkey_read_nvram()
2328 n->thinklight_toggle = !!(d & TP_NVRAM_MASK_THINKLIGHT); in hotkey_read_nvram()
2332 n->displayexp_toggle = in hotkey_read_nvram()
2337 n->brightness_level = (d & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) in hotkey_read_nvram()
2339 n->brightness_toggle = in hotkey_read_nvram()
2344 n->volume_level = (d & TP_NVRAM_MASK_LEVEL_VOLUME) in hotkey_read_nvram()
2346 n->mute = !!(d & TP_NVRAM_MASK_MUTE); in hotkey_read_nvram()
2347 n->volume_toggle = !!(d & TP_NVRAM_MASK_HKT_VOLUME); in hotkey_read_nvram()
2354 oldn->__member != newn->__member) \
2372 i--; in issue_volchange()
2388 i--; in issue_brightnesschange()
2414 * - Pressing MUTE issues mute hotkey message, even when already mute in hotkey_compare_and_issue_event()
2415 * - Pressing Volume up/down issues volume up/down hotkey messages, in hotkey_compare_and_issue_event()
2417 * - The act of unmuting issues volume up/down notification, in hotkey_compare_and_issue_event()
2427 if (newn->mute) { in hotkey_compare_and_issue_event()
2429 if (!oldn->mute || in hotkey_compare_and_issue_event()
2430 oldn->volume_toggle != newn->volume_toggle || in hotkey_compare_and_issue_event()
2431 oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2434 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2440 if (oldn->mute) { in hotkey_compare_and_issue_event()
2444 if (oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2445 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2447 } else if (oldn->volume_toggle != newn->volume_toggle) { in hotkey_compare_and_issue_event()
2449 if (newn->volume_level == 0) in hotkey_compare_and_issue_event()
2451 else if (newn->volume_level >= TP_NVRAM_LEVEL_VOLUME_MAX) in hotkey_compare_and_issue_event()
2457 if (oldn->brightness_level != newn->brightness_level) { in hotkey_compare_and_issue_event()
2458 issue_brightnesschange(oldn->brightness_level, in hotkey_compare_and_issue_event()
2459 newn->brightness_level, event_mask); in hotkey_compare_and_issue_event()
2460 } else if (oldn->brightness_toggle != newn->brightness_toggle) { in hotkey_compare_and_issue_event()
2462 if (newn->brightness_level == 0) in hotkey_compare_and_issue_event()
2464 else if (newn->brightness_level >= bright_maxlvl in hotkey_compare_and_issue_event()
2477 * most of them are edge-based. We only issue those requested by
2571 (poll_user_mask && tpacpi_inputdev->users > 0))) { in hotkey_poll_setup()
2630 return -EBUSY; in hotkey_inputdev_open()
2635 return -EBUSY; in hotkey_inputdev_open()
2646 /* sysfs hotkey enable ------------------------------------------------- */
2673 return -EINVAL; in hotkey_enable_store()
2676 return -EPERM; in hotkey_enable_store()
2683 /* sysfs hotkey mask --------------------------------------------------- */
2699 return -EINVAL; in hotkey_mask_store()
2702 return -ERESTARTSYS; in hotkey_mask_store()
2719 /* sysfs hotkey bios_enabled ------------------------------------------- */
2729 /* sysfs hotkey bios_mask ---------------------------------------------- */
2741 /* sysfs hotkey all_mask ----------------------------------------------- */
2752 /* sysfs hotkey all_mask ----------------------------------------------- */
2763 /* sysfs hotkey recommended_mask --------------------------------------- */
2777 /* sysfs hotkey hotkey_source_mask ------------------------------------- */
2795 return -EINVAL; in hotkey_source_mask_store()
2798 return -ERESTARTSYS; in hotkey_source_mask_store()
2828 /* sysfs hotkey hotkey_poll_freq --------------------------------------- */
2843 return -EINVAL; in hotkey_poll_freq_store()
2846 return -ERESTARTSYS; in hotkey_poll_freq_store()
2862 /* sysfs hotkey radio_sw (pollable) ------------------------------------ */
2884 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_radio_sw_notify_change()
2888 /* sysfs hotkey tablet mode (pollable) --------------------------------- */
2906 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_tablet_mode_notify_change()
2910 /* sysfs wakeup reason (pollable) -------------------------------------- */
2922 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_reason_notify_change()
2926 /* sysfs wakeup hotunplug_complete (pollable) -------------------------- */
2939 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_hotunplug_complete_notify_change()
2943 /* sysfs adaptive kbd mode --------------------------------------------- */
2977 return -EINVAL; in adaptive_kbd_mode_store()
2993 return tp_features.has_adaptive_kbd ? attr->mode : 0; in hadaptive_kbd_attr_is_visible()
3001 /* --------------------------------------------------------------------- */
3033 return attr->mode; in hotkey_attr_is_visible()
3061 /* Sync hw blocking state first if it is hw-blocked */ in tpacpi_send_radiosw_update()
3065 /* Sync hw blocking state last if it is hw-unblocked */ in tpacpi_send_radiosw_update()
3169 /* Original hotkey mappings translated scancodes 0x00 - 0x1f */
3189 * Volume: firmware always reacts and reprograms the built-in *extra* mixer.
3200 /* Original hotkey mappings translated scancodes 0x00 - 0x1f */
3214 * These should be enabled --only-- when ACPI video is disabled and
3224 * reprograms the built-in *extra* mixer.
3239 /* Adaptive keyboard mappings for Carbon X1 2014 translated scancodes 0x20 - 0x33 */
3260 /* Extended hotkeys mappings translated scancodes 0x34 - 0x4d */
3312 BUG_ON(tpacpi_inputdev->open != NULL || in hotkey_init()
3313 tpacpi_inputdev->close != NULL); in hotkey_init()
3330 return -ENODEV; in hotkey_init()
3338 A30, R30, R31, T20-22, X20-21, X22-24. Detected by checking in hotkey_init()
3357 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3374 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3486 pr_notice("Disabling thinkpad-acpi brightness events by default...\n"); in hotkey_init()
3517 if (res < 0 && res != -ENXIO) { in hotkey_init()
3527 tpacpi_inputdev->open = &hotkey_inputdev_open; in hotkey_init()
3528 tpacpi_inputdev->close = &hotkey_inputdev_close; in hotkey_init()
3539 * mode, Web conference mode, Function mode and Lay-flat mode.
3564 return -EIO; in adaptive_keyboard_get_mode()
3574 return -EINVAL; in adaptive_keyboard_set_mode()
3578 return -EIO; in adaptive_keyboard_set_mode()
3587 size_t max_mode = ARRAY_SIZE(adaptive_keyboard_modes) - 1; in adaptive_keyboard_get_next_mode()
3633 /* 0x1000-0x1FFF: key presses */
3636 /* Never send ACPI netlink events for original hotkeys (hkey: 0x1001 - 0x1020) */ in hotkey_notify_hotkey()
3641 unsigned int scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; in hotkey_notify_hotkey()
3649 /* 0x2000-0x2FFF: Wakeup reason */
3668 /* how to auto-heal: */ in hotkey_notify_wakeup()
3678 pr_info("woke up due to a hot-unplug request...\n"); in hotkey_notify_wakeup()
3684 /* 0x4000-0x4FFF: dock-related events */
3704 * duplicates from intel-vbtn, which already emits SW_TABLET_MODE events in hotkey_notify_dockevent()
3711 * https://lore.kernel.org/platform-driver-x86/38cb8265-1e30-d547-9e12-b4ae290be737@a-kobel.de/ in hotkey_notify_dockevent()
3723 /* 0x5000-0x5FFF: human interface helpers */
3731 case TP_HKEY_EV_TABLET_TABLET: /* X41t-X61t: tablet mode */ in hotkey_notify_usrevent()
3732 case TP_HKEY_EV_TABLET_NOTEBOOK: /* X41t-X61t: normal mode */ in hotkey_notify_usrevent()
3753 /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */
3764 /* Thermal event - pass on to event handler */ in hotkey_notify_6xxx()
3817 /* palm detected - pass on to event handler */ in hotkey_notify_6xxx()
3853 ibm->acpi->device->pnp.device_class, in hotkey_notify()
3854 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
3875 /* 0x1000-0x1FFF: key presses */ in hotkey_notify()
3879 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify()
3883 /* 0x3000-0x3FFF: bay-related wakeups */ in hotkey_notify()
3898 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify()
3902 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify()
3906 /* 0x6000-0x6FFF: thermal alarms/notices and in hotkey_notify()
3911 /* 0x7000-0x7FFF: misc */ in hotkey_notify()
3920 /* 0x8000-0x8FFF: misc2 */ in hotkey_notify()
3933 ibm->acpi->device->pnp.device_class, in hotkey_notify()
3934 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
3981 /* procfs -------------------------------------------------------------- */
3992 return -ERESTARTSYS; in hotkey_read()
4027 return -ENODEV; in hotkey_write()
4030 return -ERESTARTSYS; in hotkey_write()
4040 res = -EPERM; in hotkey_write()
4049 res = -EINVAL; in hotkey_write()
4104 TP_ACPI_BLTH_GET_PWR_ON_RESUME = 0x01, /* Get power-on-resume state */
4123 return -EIO; in bluetooth_get_status()
4150 return -EIO; in bluetooth_set_status()
4155 /* sysfs bluetooth enable ---------------------------------------------- */
4174 /* --------------------------------------------------------------------- */
4184 return tp_features.bluetooth ? attr->mode : 0; in bluetooth_attr_is_visible()
4232 .ident = "ThinkPad A285 - 20MW",
4240 .ident = "ThinkPad A285 - 20MX",
4248 .ident = "ThinkPad A485 - 20MU",
4256 .ident = "ThinkPad A485 - 20MV",
4280 if (tp_features.quirks && tp_features.quirks->btusb_bug && in have_bt_fwbug()
4300 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ in bluetooth_init()
4324 return -ENODEV; in bluetooth_init()
4334 /* procfs -------------------------------------------------------------- */
4378 return -EIO; in wan_get_status()
4405 return -EIO; in wan_set_status()
4410 /* sysfs wan enable ---------------------------------------------------- */
4430 /* --------------------------------------------------------------------- */
4440 return tp_features.wan ? attr->mode : 0; in wan_attr_is_visible()
4503 return -ENODEV; in wan_init()
4513 /* procfs -------------------------------------------------------------- */
4555 return -EIO; in uwb_get_status()
4581 return -EIO; in uwb_set_status()
4586 /* --------------------------------------------------------------------- */
4631 return -ENODEV; in uwb_init()
4724 return (video_supported != TPACPI_VIDEO_NONE) ? 0 : -ENODEV; in video_init()
4744 return -EIO; in video_outputsw_get()
4749 return -EIO; in video_outputsw_get()
4753 return -EIO; in video_outputsw_get()
4760 return -EIO; in video_outputsw_get()
4766 return -EIO; in video_outputsw_get()
4770 return -EIO; in video_outputsw_get()
4775 return -ENOSYS; in video_outputsw_get()
4804 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_set()
4805 return -EIO; in video_outputsw_set()
4813 return -ENOSYS; in video_outputsw_set()
4816 return (res) ? 0 : -EIO; in video_outputsw_set()
4826 return -EIO; in video_autosw_get()
4831 return -EIO; in video_autosw_get()
4834 return -ENOSYS; in video_autosw_get()
4843 return -EIO; in video_autosw_set()
4870 return -ENOSYS; in video_outputsw_cycle()
4873 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_cycle()
4874 return -EIO; in video_outputsw_cycle()
4877 return (res) ? 0 : -EIO; in video_outputsw_cycle()
4885 0 : -EIO; in video_expand_toggle()
4888 0 : -EIO; in video_expand_toggle()
4891 0 : -EIO; in video_expand_toggle()
4893 return -ENOSYS; in video_expand_toggle()
4909 return -EPERM; in video_read()
4942 return -ENODEV; in video_write()
4946 return -EPERM; in video_write()
4983 return -EINVAL; in video_write()
5019 return -ENXIO; in kbdlight_set_level()
5024 ret = -EIO; in kbdlight_set_level()
5038 return -ENXIO; in kbdlight_get_level()
5041 return -EIO; in kbdlight_get_level()
5076 * b010100000010000000XX - ThinkPad X1 Carbon 3rd in kbdlight_is_supported()
5077 * b110100010010000000XX - ThinkPad x230 in kbdlight_is_supported()
5078 * b010100000010000000XX - ThinkPad x240 in kbdlight_is_supported()
5079 * b010100000010000000XX - ThinkPad W541 in kbdlight_is_supported()
5083 * b10100001000000000000 - ThinkPad x230 in kbdlight_is_supported()
5084 * b10110001000000000000 - ThinkPad E430 in kbdlight_is_supported()
5085 * b00000000000000000000 - ThinkPad E450 in kbdlight_is_supported()
5132 return -ENODEV; in kbdlight_init()
5138 rc = led_classdev_register(&tpacpi_pdev->dev, in kbdlight_init()
5163 if (ret == 0 && !(led_cdev->flags & LED_SUSPENDED)) in kbdlight_set_level_and_update()
5164 led_cdev->brightness = level; in kbdlight_set_level_and_update()
5190 int res, level = -EINVAL; in kbdlight_write()
5193 return -ENODEV; in kbdlight_write()
5202 return -EINVAL; in kbdlight_write()
5240 TPACPI_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
5249 return -EIO; in light_get_status()
5253 return -ENXIO; in light_get_status()
5270 return (rc) ? 0 : -EIO; in light_set_status()
5273 return -ENXIO; in light_set_status()
5323 return -ENODEV; in light_init()
5325 rc = led_classdev_register(&tpacpi_pdev->dev, in light_init()
5369 return -ENODEV; in light_write()
5377 return -EINVAL; in light_write()
5394 /* sysfs cmos_command -------------------------------------------------- */
5403 return -EINVAL; in cmos_command_store()
5419 return cmos_handle ? attr->mode : 0; in cmos_attr_is_visible()
5427 /* --------------------------------------------------------------------- */
5439 return cmos_handle ? 0 : -ENODEV; in cmos_init()
5445 R30, R31, T20-22, X20-21 */ in cmos_read()
5450 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n"); in cmos_read()
5466 return -EINVAL; in cmos_write()
5489 TPACPI_LED_OLD, /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
5542 return -EIO; in led_get_status()
5551 return -ENXIO; in led_get_status()
5570 return -EINVAL; in led_set_status()
5572 return -EPERM; in led_set_status()
5575 return -EIO; in led_set_status()
5578 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */ in led_set_status()
5580 return -EINVAL; in led_set_status()
5582 return -EPERM; in led_set_status()
5594 return -EINVAL; in led_set_status()
5596 return -EPERM; in led_set_status()
5599 return -EIO; in led_set_status()
5602 return -ENXIO; in led_set_status()
5620 else if (tpacpi_led_state_cache[data->led] != TPACPI_LED_BLINK) in led_sysfs_set()
5625 return led_set_status(data->led, new_state); in led_sysfs_set()
5637 *delay_on = 500; /* ms */ in led_sysfs_blink_set()
5638 *delay_off = 500; /* ms */ in led_sysfs_blink_set()
5640 return -EINVAL; in led_sysfs_blink_set()
5642 return led_set_status(data->led, TPACPI_LED_BLINK); in led_sysfs_blink_set()
5652 rc = led_get_status(data->led); in led_sysfs_get()
5687 return led_classdev_register(&tpacpi_pdev->dev, &tpacpi_leds[led].led_classdev); in tpacpi_init_led()
5715 /* (1) - may have excess leds enabled on MSB */
5745 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ in led_init_detect_mode()
5785 return -ENODEV; in led_init()
5791 return -ENOMEM; in led_init()
5795 tpacpi_leds[i].led = -1; in led_init()
5828 return -EIO; in led_read()
5833 seq_printf(m, "commands:\t<led> on, <led> off, <led> blink (<led> is 0-15)\n"); in led_read()
5845 return -ENODEV; in led_write()
5849 return -EINVAL; in led_write()
5851 if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1)) in led_write()
5852 return -ENODEV; in led_write()
5855 return -ENODEV; in led_write()
5864 return -EINVAL; in led_write()
5892 TPACPI_Q_IBM('I', 'U', TPACPI_BEEP_Q1), /* 570E - unverified */
5911 return (beep_handle) ? 0 : -ENODEV; in beep_init()
5920 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n"); in beep_read()
5932 return -ENODEV; in beep_write()
5939 return -EINVAL; in beep_write()
5943 return -EIO; in beep_write()
5947 return -EIO; in beep_write()
5966 TPACPI_THERMAL_ACPI_TMP07, /* Use ACPI TMP0-7 */
5967 TPACPI_THERMAL_ACPI_UPDT, /* Use ACPI TMP0-7 with UPDT */
5976 TP_EC_THERMAL_TMP0_NS = 0xA8, /* ACPI EC Non-Standard regs TMP 0..7 */
5977 TP_EC_THERMAL_TMP8_NS = 0xB8, /* ACPI EC Non-standard regs TMP 8..11 */
5979 TP_EC_THERMAL_TMP_NA = -128, /* ACPI EC sensor not available */
5981 TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */
5991 /* Non-standard address for thermal registers on some ThinkPads */
5999 TPACPI_Q_LNV3('R', '1', 'D', true), /* 11e Gen5 GL-R*/
6000 TPACPI_Q_LNV3('R', '0', 'V', true), /* 11e Gen5 KL-Y*/
6005 static bool thermal_with_ns_address; /* Non-standard thermal reg address */
6018 * Direct EC access mode: sensors at registers 0x78-0x7F, in thermal_read_mode_check()
6019 * 0xC0-0xC7. Registers return 0x00 for non-implemented, in thermal_read_mode_check()
6024 * determines EC version. 0xC0-0xC7 are not thermal registers in thermal_read_mode_check()
6030 /* Quirks to check non-standard EC */ in thermal_read_mode_check()
6034 /* Support for Thinkpads with non-standard address */ in thermal_read_mode_check()
6036 pr_info("ECFW with non-standard thermal registers found\n"); in thermal_read_mode_check()
6089 /* idx is zero-based */
6103 idx -= 8; in thermal_get_sensor()
6110 return -EIO; in thermal_get_sensor()
6116 /* The Non-standard EC uses 12 Thermal areas */ in thermal_get_sensor()
6119 return -EINVAL; in thermal_get_sensor()
6122 TP_EC_THERMAL_TMP8_NS + (idx - 8); in thermal_get_sensor()
6125 return -EIO; in thermal_get_sensor()
6134 return -EIO; in thermal_get_sensor()
6136 return -EIO; in thermal_get_sensor()
6137 *value = (t - 2732) * 100; in thermal_get_sensor()
6146 return -EIO; in thermal_get_sensor()
6147 if (t > 127 || t < -127) in thermal_get_sensor()
6156 return -ENOSYS; in thermal_get_sensor()
6159 return -EINVAL; in thermal_get_sensor()
6167 return -EINVAL; in thermal_get_sensors()
6177 res = thermal_get_sensor(i, &s->temp[i]); in thermal_get_sensors()
6206 /* sysfs temp##_input -------------------------------------------------- */
6214 int idx = sensor_attr->index; in thermal_temp_input_show()
6222 return -ENXIO; in thermal_temp_input_show()
6282 int idx = sensor_attr->index; in thermal_attr_is_visible()
6305 return attr->mode; in thermal_attr_is_visible()
6337 return thermal_use_labels ? attr->mode : 0; in temp_label_attr_is_visible()
6345 /* --------------------------------------------------------------------- */
6357 return thermal_read_mode != TPACPI_THERMAL_NONE ? 0 : -ENODEV; in thermal_init()
6372 for (i = 0; i < (n - 1); i++) in thermal_read()
6394 * CMOS NVRAM byte 0x5E, bits 0-3.
6401 * Bit 3-0: backlight brightness level
6422 TPACPI_BRGHT_MODE_UCMS_STEP, /* UCMS step-based control */
6503 return -EIO; in tpacpi_brightness_get_raw()
6507 return -ENXIO; in tpacpi_brightness_get_raw()
6519 return -EIO; in tpacpi_brightness_set_ec()
6524 return -EIO; in tpacpi_brightness_set_ec()
6544 inc = (value > current_value) ? 1 : -1; in tpacpi_brightness_set_ucmsstep()
6548 return -EIO; in tpacpi_brightness_set_ucmsstep()
6559 return -EINVAL; in brightness_set()
6577 res = -ENXIO; in brightness_set()
6584 /* sysfs backlight class ----------------------------------------------- */
6628 /* --------------------------------------------------------------------- */
6637 status = acpi_evaluate_object(adev->handle, "_BCL", NULL, &buffer); in tpacpi_evaluate_bcl()
6642 if (!obj || obj->type != ACPI_TYPE_PACKAGE) { in tpacpi_evaluate_bcl()
6643 acpi_handle_info(adev->handle, in tpacpi_evaluate_bcl()
6648 rc = obj->package.count; in tpacpi_evaluate_bcl()
6686 return (bcl_levels > 2) ? (bcl_levels - 2) : 0; in tpacpi_check_std_acpi_brightness_support()
6691 * of GPU. If the BIOS model handles both ATI and Intel, don't use
6699 /* Models with ATI GPUs known to require ECNVRAM mode */
6700 TPACPI_Q_IBM('1', 'Y', TPACPI_BRGHT_Q_EC), /* T43/p ATI */
6702 /* Models with ATI GPUs that can use ECNVRAM */
6703 TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), /* R50,51 T40-42 */
6749 bright_maxlvl = b - 1; in tpacpi_detect_brightness_capabilities()
6771 return -ENODEV; in brightness_init()
6776 return -ENODEV; in brightness_init()
6782 return -ENODEV; in brightness_init()
6785 return -ENODEV; in brightness_init()
6789 return -ENODEV; in brightness_init()
6800 return -EINVAL; in brightness_init()
6811 "driver auto-selected brightness_mode=%d\n", in brightness_init()
6819 return -EINVAL; in brightness_init()
6822 return -ENODEV; in brightness_init()
6893 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in brightness_read()
6916 level--; in brightness_write()
6921 return -EINVAL; in brightness_write()
6935 return (rc == -EINTR) ? -ERESTARTSYS : rc; in brightness_write()
6960 * Bit 3-0: Volume
6964 * bits 3-0 (volume). Other bits in NVRAM may have other functions,
6976 * To avoid confusing userspace, we simply disable all EC-based mute
6987 #define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1)
6989 #define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1)
7020 TPACPI_VOL_MODE_UCMS_STEP, /* UCMS step-based control: N/A */
7050 * TP_NVRAM_ADDR_MIXER, as we need to do read-modify-write
7106 return -EIO; in volume_get_status_ec()
7123 return -EIO; in volume_set_status_ec()
7148 return -EINTR; in __volume_set_mute_ec()
7193 return -EINVAL; in __volume_set_volume_ec()
7196 return -EINTR; in __volume_set_volume_ec()
7220 return -ENODEV; in volume_set_software_mute()
7225 return -EIO; in volume_set_software_mute()
7234 return -EIO; in volume_set_software_mute()
7243 * startup. Just on case there are SAUM-capable ThinkPads in volume_set_software_mute()
7277 if (alsa_card && alsa_card->private_data) { in volume_alsa_notify_change()
7278 d = alsa_card->private_data; in volume_alsa_notify_change()
7279 if (d->ctl_mute_id) in volume_alsa_notify_change()
7282 d->ctl_mute_id); in volume_alsa_notify_change()
7283 if (d->ctl_vol_id) in volume_alsa_notify_change()
7286 d->ctl_vol_id); in volume_alsa_notify_change()
7293 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in volume_alsa_vol_info()
7294 uinfo->count = 1; in volume_alsa_vol_info()
7295 uinfo->value.integer.min = 0; in volume_alsa_vol_info()
7296 uinfo->value.integer.max = TP_EC_VOLUME_MAX; in volume_alsa_vol_info()
7310 ucontrol->value.integer.value[0] = s & TP_EC_AUDIO_LVL_MSK; in volume_alsa_vol_get()
7318 ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7319 return volume_alsa_set_volume(ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7334 ucontrol->value.integer.value[0] = in volume_alsa_mute_get()
7343 ucontrol->value.integer.value[0] ? in volume_alsa_mute_put()
7345 return volume_alsa_set_mute(!ucontrol->value.integer.value[0]); in volume_alsa_mute_put()
7407 rc = snd_card_new(&tpacpi_pdev->dev, in volume_create_alsa_mixer()
7412 return -ENODEV; in volume_create_alsa_mixer()
7415 BUG_ON(!card->private_data); in volume_create_alsa_mixer()
7416 data = card->private_data; in volume_create_alsa_mixer()
7417 data->card = card; in volume_create_alsa_mixer()
7419 strscpy(card->driver, TPACPI_ALSA_DRVNAME); in volume_create_alsa_mixer()
7420 strscpy(card->shortname, TPACPI_ALSA_SHRTNAME); in volume_create_alsa_mixer()
7421 snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s", in volume_create_alsa_mixer()
7424 snprintf(card->longname, sizeof(card->longname), in volume_create_alsa_mixer()
7425 "%s at EC reg 0x%02x, fw %s", card->shortname, TP_EC_AUDIO, in volume_create_alsa_mixer()
7447 data->ctl_vol_id = &ctl_vol->id; in volume_create_alsa_mixer()
7456 data->ctl_mute_id = &ctl_mute->id; in volume_create_alsa_mixer()
7469 return -ENODEV; in volume_create_alsa_mixer()
7472 #define TPACPI_VOL_Q_MUTEONLY 0x0001 /* Mute-only control available */
7491 /* Whitelist mute-only on all Lenovo by default */
7513 return -EINVAL; in volume_init()
7518 return -ENODEV; in volume_init()
7522 return -EINVAL; in volume_init()
7531 return -ENODEV; in volume_init()
7544 return -ENODEV; /* no mixer */ in volume_init()
7553 return -ENODEV; in volume_init()
7558 "using user-supplied volume_capabilities=%d\n", in volume_init()
7566 "driver auto-selected volume_mode=%d\n", in volume_init()
7570 "using user-supplied volume_mode=%d\n", in volume_init()
7622 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in volume_read()
7649 return -EPERM; in volume_write()
7671 new_level--; in volume_write()
7684 return -EINVAL; in volume_write()
7699 return (rc == -EINTR) ? -ERESTARTSYS : rc; in volume_write()
7724 return -ENODEV; in volume_init()
7761 * Contains the current fan speed from 0-100%
7794 * Speeds up fan to 100% duty-cycle, which is far above
7797 * 5-3 unused in some models. Extra bits for fan level
7800 * 2-0 fan level (0..7 usually)
7813 * ----
7818 * This register is present on all ThinkPads with a new-style EC, and
7824 * Unfortunately a lot of ThinkPads with new-style ECs but whose firmware
7838 * ----
7850 * So far, only the firmware for the X60/X61 non-tablet versions
7851 * seem to support this (firmware TP-7M).
7876 * that are using non-standard EC locations for reporting fan speeds.
7881 #define FAN_RPM_CAL_CONST 491520 /* FAN RPM calculation offset for some non-standard ECFW */
7893 fan_status_offset_ns = 0x93, /* Special status/control offset for non-standard EC Fan1 */
7894 fan2_status_offset_ns = 0x96, /* Special status/control offset for non-standard EC Fan2 */
7895 fan_rpm_status_ns = 0x95, /* Special offset for Fan1 RPM status for non-standard EC */
7896 fan2_rpm_status_ns = 0x98, /* Special offset for Fan2 RPM status for non-standard EC */
7901 TPACPI_FAN_LAST_LEVEL = 0x100, /* Use cached last-seen fan level */
7908 TPACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */
7909 TPACPI_FAN_RD_TPEC_NS, /* Use non-standard ACPI EC regs (eg: L13 Yoga gen2 etc.) */
7953 "JFNS", /* 770x-JL */
7970 * Enable for TP-1Y (T43), TP-78 (R51e), TP-76 (R52),
7971 * TP-70 (T43, R52), which are known to be buggy.
8056 return -EIO; in fan_get_status()
8068 return -EIO; in fan_get_status()
8070 return -EIO; in fan_get_status()
8083 return -EIO; in fan_get_status()
8094 return -EIO; in fan_get_status()
8102 return -ENXIO; in fan_get_status()
8114 return -ERESTARTSYS; in fan_get_status_safe()
8137 return -EIO; in fan_get_speed()
8140 return -EIO; in fan_get_speed()
8147 return -EIO; in fan_get_speed()
8154 return -ENXIO; in fan_get_speed()
8169 return -EIO; in fan2_get_speed()
8174 return -EIO; in fan2_get_speed()
8183 return -EIO; in fan2_get_speed()
8186 return -EIO; in fan2_get_speed()
8190 return -EIO; in fan2_get_speed()
8199 return -EIO; in fan2_get_speed()
8207 return -ENXIO; in fan2_get_speed()
8216 return -EPERM; in fan_set_level()
8221 return -EINVAL; in fan_set_level()
8232 return -EIO; in fan_set_level()
8240 return -EINVAL; in fan_set_level()
8259 return -EIO; in fan_set_level()
8266 return -EINVAL; in fan_set_level()
8268 return -EINVAL; in fan_set_level()
8272 return -EIO; in fan_set_level()
8275 return -EIO; in fan_set_level()
8279 return -EIO; in fan_set_level()
8282 return -EIO; in fan_set_level()
8285 return -EIO; in fan_set_level()
8291 return -ENXIO; in fan_set_level()
8304 return -EPERM; in fan_set_level_safe()
8307 return -ERESTARTSYS; in fan_set_level_safe()
8326 return -EPERM; in fan_set_enable()
8329 return -ERESTARTSYS; in fan_set_enable()
8345 rc = -EIO; in fan_set_enable()
8363 rc = -EIO; in fan_set_enable()
8370 rc = -EIO; in fan_set_enable()
8374 rc = -EIO; in fan_set_enable()
8382 rc = -ENXIO; in fan_set_enable()
8399 return -EPERM; in fan_set_disable()
8402 return -ERESTARTSYS; in fan_set_disable()
8409 rc = -EIO; in fan_set_disable()
8418 rc = -EIO; in fan_set_disable()
8425 rc = -EIO; in fan_set_disable()
8429 rc = -EIO; in fan_set_disable()
8433 rc = -EIO; in fan_set_disable()
8440 rc = -ENXIO; in fan_set_disable()
8456 return -EPERM; in fan_set_speed()
8459 return -ERESTARTSYS; in fan_set_speed()
8467 rc = -EIO; in fan_set_speed()
8469 rc = -EINVAL; in fan_set_speed()
8475 rc = -EIO; in fan_set_speed()
8479 rc = -EIO; in fan_set_speed()
8484 rc = -EIO; in fan_set_speed()
8486 rc = -EINVAL; in fan_set_speed()
8490 rc = -ENXIO; in fan_set_speed()
8548 /* sysfs fan pwm1_enable ----------------------------------------------- */
8578 return -EINVAL; in fan_pwm1_enable_store()
8594 /* reserved for software-controlled auto mode */ in fan_pwm1_enable_store()
8595 return -ENOSYS; in fan_pwm1_enable_store()
8597 return -EINVAL; in fan_pwm1_enable_store()
8601 if (res == -ENXIO) in fan_pwm1_enable_store()
8602 return -EINVAL; in fan_pwm1_enable_store()
8614 /* sysfs fan pwm1 ------------------------------------------------------ */
8645 return -EINVAL; in fan_pwm1_store()
8650 /* scale down from 0-255 to 0-7 */ in fan_pwm1_store()
8654 return -ERESTARTSYS; in fan_pwm1_store()
8660 if (rc == -ENXIO) in fan_pwm1_store()
8661 rc = -EINVAL; in fan_pwm1_store()
8674 /* sysfs fan fan1_input ------------------------------------------------ */
8695 /* sysfs fan fan2_input ------------------------------------------------ */
8716 /* sysfs fan fan_watchdog (hwmon driver) ------------------------------- */
8728 return -EINVAL; in fan_watchdog_store()
8731 return -EPERM; in fan_watchdog_store()
8742 /* --------------------------------------------------------------------- */
8764 return attr->mode; in fan_attr_is_visible()
8786 #define TPACPI_FAN_NS 0x0010 /* For EC with non-Standard register addresses */
8813 TPACPI_Q_LNV3('R', '1', 'D', TPACPI_FAN_NS), /* 11e Gen5 GL-R */
8814 TPACPI_Q_LNV3('R', '0', 'V', TPACPI_FAN_NS), /* 11e Gen5 KL-Y */
8851 return -ENODEV; in fan_init()
8855 pr_info("ECFW with non-standard fan reg control found\n"); in fan_init()
8875 /* all other ThinkPads: note that even old-style in fan_init()
8891 /* It responded - so let's assume it's there */ in fan_init()
8897 /* Fan not auto-detected */ in fan_init()
8911 return -ENODEV; in fan_init()
8916 /* 570, 770x-JL */ in fan_init()
8967 return -ENODEV; in fan_init()
9122 seq_printf(m, " (<level> is 0-7)\n"); in fan_read()
9126 seq_printf(m, " (<level> is 0-7, auto, disengaged, full-speed)\n"); in fan_read()
9133 "commands:\twatchdog <timeout> (<timeout> is 0 (off), 1-120 (seconds))\n"); in fan_read()
9136 seq_printf(m, "commands:\tspeed <speed> (<speed> is 0-65535)\n"); in fan_read()
9147 else if (strstarts(cmd, "level disengaged") || strstarts(cmd, "level full-speed")) in fan_write_cmd_level()
9153 if (*rc == -ENXIO) in fan_write_cmd_level()
9169 if (*rc == -ENXIO) in fan_write_cmd_enable()
9184 if (*rc == -ENXIO) in fan_write_cmd_disable()
9204 if (*rc == -ENXIO) in fan_write_cmd_speed()
9222 *rc = -EINVAL; in fan_write_cmd_watchdog()
9248 rc = -EINVAL; in fan_write()
9296 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_on_off()
9297 pr_warn("Thinkpad ACPI has no %s interface.\n", t->name); in mute_led_on_off()
9298 return -EIO; in mute_led_on_off()
9301 if (!acpi_evalf(hkey_handle, &output, t->name, "dd", in mute_led_on_off()
9302 state ? t->on_value : t->off_value)) in mute_led_on_off()
9303 return -EIO; in mute_led_on_off()
9305 t->state = state; in mute_led_on_off()
9314 if (t->state < 0 || t->state == on) in tpacpi_led_set()
9315 return t->state; in tpacpi_led_set()
9336 .default_trigger = "audio-mute",
9342 .default_trigger = "audio-micmute",
9353 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_init()
9354 t->state = -ENODEV; in mute_led_init()
9358 err = led_classdev_register(&tpacpi_pdev->dev, &mute_led_cdev[i]); in mute_led_init()
9360 while (i--) in mute_led_init()
9384 if (t->state >= 0) in mute_led_resume()
9385 mute_led_on_off(t, t->state); in mute_led_resume()
9474 return -ENODEV; in tpacpi_battery_get()
9481 return -ENODEV; in tpacpi_battery_get()
9495 return -ENODEV; in tpacpi_battery_get()
9501 return -ENODEV; in tpacpi_battery_get()
9507 return -EINVAL; in tpacpi_battery_get()
9516 /* The battery ID is in bits 8-9, 2 bits */ in tpacpi_battery_set()
9524 return -ENODEV; in tpacpi_battery_set()
9530 return -ENODEV; in tpacpi_battery_set()
9536 * battery ID is in bits 8-9, 2 bits. in tpacpi_battery_set()
9540 return -ENODEV; in tpacpi_battery_set()
9547 * The battery ID is in bits 4-5, 2 bits, in tpacpi_battery_set()
9548 * the effective time is in bits 8-23, 2 bytes. in tpacpi_battery_set()
9556 return -ENODEV; in tpacpi_battery_set()
9561 return -EINVAL; in tpacpi_battery_set()
9589 return -EIO; in tpacpi_battery_set_validate()
9612 return -ENODEV; in tpacpi_battery_probe()
9621 return -ENODEV; in tpacpi_battery_probe()
9625 return -ENODEV; in tpacpi_battery_probe()
9631 return -ENODEV; in tpacpi_battery_probe()
9637 return -ENODEV; in tpacpi_battery_probe()
9641 return -ENODEV; in tpacpi_battery_probe()
9647 return -ENODEV; in tpacpi_battery_probe()
9657 return -ENODEV; in tpacpi_battery_probe()
9718 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_store()
9729 return -ENODEV; in tpacpi_battery_store()
9732 return -EINVAL; in tpacpi_battery_store()
9734 return -EINVAL; in tpacpi_battery_store()
9736 return -ENODEV; in tpacpi_battery_store()
9742 return -ENODEV; in tpacpi_battery_store()
9745 return -EINVAL; in tpacpi_battery_store()
9747 return -EINVAL; in tpacpi_battery_store()
9757 return -EINVAL; in tpacpi_battery_store()
9761 return -EINVAL; in tpacpi_battery_store()
9785 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_show()
9789 return -ENODEV; in tpacpi_battery_show()
9816 battery = tpacpi_battery_get_id(supply->desc->name); in charge_behaviour_show()
9821 return -ENODEV; in charge_behaviour_show()
9830 return -ENODEV; in charge_behaviour_show()
9863 battery = tpacpi_battery_get_id(supply->desc->name); in charge_behaviour_store()
9895 return -EINVAL; in charge_behaviour_store()
9932 int batteryid = tpacpi_battery_get_id(battery->desc->name); in tpacpi_battery_add()
9935 return -ENODEV; in tpacpi_battery_add()
9936 if (device_add_groups(&battery->dev, tpacpi_battery_groups)) in tpacpi_battery_add()
9937 return -ENODEV; in tpacpi_battery_add()
9943 device_remove_groups(&battery->dev, tpacpi_battery_groups); in tpacpi_battery_remove()
10004 if (WARN_ON(!mutex_is_locked(&priv->lock))) in lcdshadow_set_sw_state()
10005 return -EIO; in lcdshadow_set_sw_state()
10008 return -EIO; in lcdshadow_set_sw_state()
10010 priv->hw_state = priv->sw_state = state; in lcdshadow_set_sw_state()
10021 priv->hw_state = priv->sw_state = output & 0x1; in lcdshadow_get_hw_state()
10040 return -EIO; in tpacpi_lcdshadow_init()
10045 lcdshadow_dev = drm_privacy_screen_register(&tpacpi_pdev->dev, in tpacpi_lcdshadow_init()
10063 mutex_lock(&lcdshadow_dev->lock); in lcdshadow_resume()
10064 lcdshadow_set_sw_state(lcdshadow_dev, lcdshadow_dev->sw_state); in lcdshadow_resume()
10065 mutex_unlock(&lcdshadow_dev->lock); in lcdshadow_resume()
10073 seq_printf(m, "status:\t\t%d\n", lcdshadow_dev->hw_state); in lcdshadow_read()
10083 int res, state = -EINVAL; in lcdshadow_write()
10086 return -ENODEV; in lcdshadow_write()
10095 return -EINVAL; in lcdshadow_write()
10097 mutex_lock(&lcdshadow_dev->lock); in lcdshadow_write()
10099 mutex_unlock(&lcdshadow_dev->lock); in lcdshadow_write()
10118 #define DYTC_CMD_QUERY 0 /* To get DYTC status - enable/revision */
10119 #define DYTC_QUERY_ENABLE_BIT 8 /* Bit 8 - 0 = disabled, 1 = enabled */
10120 #define DYTC_QUERY_SUBREV_BIT 16 /* Bits 16 - 27 - sub revision */
10121 #define DYTC_QUERY_REV_BIT 28 /* Bits 28 - 31 - revision */
10141 return -ENODEV; in dytc_command()
10144 return -EIO; in dytc_command()
10169 return -ENODEV; in palmsensor_get()
10171 return -EIO; in palmsensor_get()
10189 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "dytc_lapmode"); in lapsensor_refresh()
10205 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "palmsensor"); in palmsensor_refresh()
10251 return attr->mode; in proxsensor_attr_is_visible()
10265 /* If support isn't available for both devices return -ENODEV */ in tpacpi_proxsensor_init()
10266 if ((palm_err == -ENODEV) && (lap_err == -ENODEV)) in tpacpi_proxsensor_init()
10267 return -ENODEV; in tpacpi_proxsensor_init()
10269 if (palm_err && (palm_err != -ENODEV)) in tpacpi_proxsensor_init()
10271 if (lap_err && (lap_err != -ENODEV)) in tpacpi_proxsensor_init()
10278 .name = "proximity-sensor",
10294 #define DYTC_GET_FUNCTION_BIT 8 /* Bits 8-11 - function setting */
10295 #define DYTC_GET_MODE_BIT 12 /* Bits 12-15 - mode setting */
10297 #define DYTC_SET_FUNCTION_BIT 12 /* Bits 12-15 - function setting */
10298 #define DYTC_SET_MODE_BIT 16 /* Bits 16-19 - mode setting */
10299 #define DYTC_SET_VALID_BIT 20 /* Bit 20 - 1 = on, 0 = off */
10319 #define DYTC_ERR_MASK 0xF /* Bits 0-3 in cmd result are the error result */
10356 return -EINVAL; in convert_dytc_to_profile()
10371 return -EINVAL; in convert_dytc_to_profile()
10381 return -EOPNOTSUPP; in convert_dytc_to_profile()
10408 return -EOPNOTSUPP; in convert_profile_to_dytc()
10432 return -ENODEV; in dytc_control_amt()
10449 * Helper function - check if we are in CQL mode and if we are
10450 * - disable CQL,
10451 * - run the command
10452 * - enable CQL
10511 * Note we still need to disable CQL mode before hand and re-enable in dytc_profile_set()
10534 /* Success - update current profile */ in dytc_profile_set()
10559 err = -ENODEV; in dytc_profile_refresh()
10596 return -ENODEV; in tpacpi_dytc_profile_init()
10606 case -1: in tpacpi_dytc_profile_init()
10634 return -ENODEV; in tpacpi_dytc_profile_init()
10647 return -ENODEV; in tpacpi_dytc_profile_init()
10665 .name = "dytc-profile",
10687 {"fr-ch", 0x100c},
10707 return -ENODEV; in set_keyboard_lang_command()
10711 return -EIO; in set_keyboard_lang_command()
10723 return -ENODEV; in get_keyboard_lang()
10727 return -EIO; in get_keyboard_lang()
10731 * '(' and ')') keys which use layout dependent key-press emulation. in get_keyboard_lang()
10734 return -ENODEV; in get_keyboard_lang()
10791 dev_err(&tpacpi_pdev->dev, "Unknown Keyboard language. Ignoring\n"); in keyboard_lang_store()
10792 return -EINVAL; in keyboard_lang_store()
10795 tpacpi_disclose_usertask(attr->attr.name, in keyboard_lang_store()
10798 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang"); in keyboard_lang_store()
10812 return tp_features.kbd_lang ? attr->mode : 0; in kbdlang_attr_is_visible()
10849 return -ENODEV; in dprc_command()
10853 return -EIO; in dprc_command()
10861 return -ENODEV; in dprc_command()
10880 return -ENODEV; in get_wwan_antenna()
10896 return -ENODATA; in wwan_antenna_type_show()
10909 return has_antennatype ? attr->mode : 0; in dprc_attr_is_visible()
10937 * MAC Address Pass-through feature. In most cases, there are three
10959 return -ENODEV; in auxmac_init()
10963 if (obj->type != ACPI_TYPE_STRING || obj->string.length != AUXMAC_STRLEN) { in auxmac_init()
10964 pr_info("Invalid buffer for MAC address pass-through.\n"); in auxmac_init()
10968 if (obj->string.pointer[AUXMAC_BEGIN_MARKER] != '#' || in auxmac_init()
10969 obj->string.pointer[AUXMAC_END_MARKER] != '#') { in auxmac_init()
10970 pr_info("Invalid header for MAC address pass-through.\n"); in auxmac_init()
10974 if (strncmp(obj->string.pointer + AUXMAC_START, "XXXXXXXXXXXX", AUXMAC_LEN) != 0) in auxmac_init()
10975 strscpy(auxmac, obj->string.pointer + AUXMAC_START, sizeof(auxmac)); in auxmac_init()
10997 return auxmac[0] == 0 ? 0 : attr->mode; in auxmac_attr_is_visible()
11010 /* --------------------------------------------------------------------- */
11043 return attr->mode; in tpacpi_attr_is_visible()
11171 if (!atomic_add_unless(&dytc_ignore_event, -1, 0)) in tpacpi_driver_event()
11180 mutex_lock(&lcdshadow_dev->lock); in tpacpi_driver_event()
11181 old_hw_state = lcdshadow_dev->hw_state; in tpacpi_driver_event()
11183 changed = lcdshadow_dev->hw_state != old_hw_state; in tpacpi_driver_event()
11184 mutex_unlock(&lcdshadow_dev->lock); in tpacpi_driver_event()
11210 /* --------------------------------------------------------------------- */
11232 dbg_printk(TPACPI_DBG_EXIT, "removing %s\n", ibm->name); in ibm_exit()
11234 list_del_init(&ibm->all_drivers); in ibm_exit()
11236 if (ibm->flags.acpi_notify_installed) { in ibm_exit()
11238 "%s: acpi_remove_notify_handler\n", ibm->name); in ibm_exit()
11239 BUG_ON(!ibm->acpi); in ibm_exit()
11240 acpi_remove_notify_handler(*ibm->acpi->handle, in ibm_exit()
11241 ibm->acpi->type, in ibm_exit()
11243 ibm->flags.acpi_notify_installed = 0; in ibm_exit()
11246 if (ibm->flags.proc_created) { in ibm_exit()
11248 "%s: remove_proc_entry\n", ibm->name); in ibm_exit()
11249 remove_proc_entry(ibm->name, proc_dir); in ibm_exit()
11250 ibm->flags.proc_created = 0; in ibm_exit()
11253 if (ibm->flags.acpi_driver_registered) { in ibm_exit()
11255 "%s: acpi_bus_unregister_driver\n", ibm->name); in ibm_exit()
11256 BUG_ON(!ibm->acpi); in ibm_exit()
11257 acpi_bus_unregister_driver(ibm->acpi->driver); in ibm_exit()
11258 kfree(ibm->acpi->driver); in ibm_exit()
11259 ibm->acpi->driver = NULL; in ibm_exit()
11260 ibm->flags.acpi_driver_registered = 0; in ibm_exit()
11263 if (ibm->flags.init_called && ibm->exit) { in ibm_exit()
11264 ibm->exit(); in ibm_exit()
11265 ibm->flags.init_called = 0; in ibm_exit()
11268 dbg_printk(TPACPI_DBG_INIT, "finished removing %s\n", ibm->name); in ibm_exit()
11274 struct ibm_struct *ibm = iibm->data; in ibm_init()
11279 INIT_LIST_HEAD(&ibm->all_drivers); in ibm_init()
11281 if (ibm->flags.experimental && !experimental) in ibm_init()
11285 "probing for %s\n", ibm->name); in ibm_init()
11287 if (iibm->init) { in ibm_init()
11288 ret = iibm->init(iibm); in ibm_init()
11289 if (ret > 0 || ret == -ENODEV) in ibm_init()
11294 ibm->flags.init_called = 1; in ibm_init()
11297 if (ibm->acpi) { in ibm_init()
11298 if (ibm->acpi->hid) { in ibm_init()
11304 if (ibm->acpi->notify) { in ibm_init()
11306 if (ret == -ENODEV) { in ibm_init()
11308 ibm->name); in ibm_init()
11318 "%s installed\n", ibm->name); in ibm_init()
11320 if (ibm->read) { in ibm_init()
11321 umode_t mode = iibm->base_procfs_mode; in ibm_init()
11325 if (ibm->write) in ibm_init()
11327 entry = proc_create_data(ibm->name, mode, proc_dir, in ibm_init()
11330 pr_err("unable to create proc entry %s\n", ibm->name); in ibm_init()
11331 ret = -ENODEV; in ibm_init()
11334 ibm->flags.proc_created = 1; in ibm_init()
11337 list_add_tail(&ibm->all_drivers, &tpacpi_all_drivers); in ibm_init()
11344 ibm->name, ret); in ibm_init()
11367 * Ancient 570/600 and -SL lacks (#.##c) in tpacpi_parse_fw_id()
11395 * ---------------------------------------------------- in find_new_ec_fwstr()
11408 if (dm->type != 140 || dm->length < 0x0F || in find_new_ec_fwstr()
11419 /* returns 0 - probe ok, or < 0 - probe error.
11421 * On error, kfree() cleanup on tp->* is not performed, caller must do it */
11431 return -EINVAL; in get_thinkpad_model_data()
11436 tp->vendor = PCI_VENDOR_ID_IBM; in get_thinkpad_model_data()
11438 tp->vendor = PCI_VENDOR_ID_LENOVO; in get_thinkpad_model_data()
11443 tp->bios_version_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11444 if (s && !tp->bios_version_str) in get_thinkpad_model_data()
11445 return -ENOMEM; in get_thinkpad_model_data()
11448 t = tpacpi_parse_fw_id(tp->bios_version_str, in get_thinkpad_model_data()
11449 &tp->bios_model, &tp->bios_release); in get_thinkpad_model_data()
11456 * up-to-date BIOS or they will not be detected. in get_thinkpad_model_data()
11461 if (sscanf(dev->name, in get_thinkpad_model_data()
11462 "IBM ThinkPad Embedded Controller -[%17c", in get_thinkpad_model_data()
11464 ec_fw_string[sizeof(ec_fw_string) - 1] = 0; in get_thinkpad_model_data()
11475 tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL); in get_thinkpad_model_data()
11476 if (!tp->ec_version_str) in get_thinkpad_model_data()
11477 return -ENOMEM; in get_thinkpad_model_data()
11480 &tp->ec_model, &tp->ec_release); in get_thinkpad_model_data()
11490 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11491 if (!tp->model_str) in get_thinkpad_model_data()
11492 return -ENOMEM; in get_thinkpad_model_data()
11496 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11497 if (!tp->model_str) in get_thinkpad_model_data()
11498 return -ENOMEM; in get_thinkpad_model_data()
11503 tp->nummodel_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11504 if (s && !tp->nummodel_str) in get_thinkpad_model_data()
11505 return -ENOMEM; in get_thinkpad_model_data()
11515 return -ENODEV; in probe_for_thinkpad()
11519 return -ENODEV; in probe_for_thinkpad()
11522 * Non-ancient models have better DMI tagging, but very old models in probe_for_thinkpad()
11534 return -ENODEV; in probe_for_thinkpad()
11538 return -ENODEV; in probe_for_thinkpad()
11671 if (!kp || !kp->name || !val) in set_ibm_param()
11672 return -EINVAL; in set_ibm_param()
11676 if (!ibm || !ibm->name) in set_ibm_param()
11679 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { in set_ibm_param()
11680 if (strlen(val) > sizeof(ibms_init[i].param) - 1) in set_ibm_param()
11681 return -ENOSPC; in set_ibm_param()
11687 return -EINVAL; in set_ibm_param()
11692 "Enables experimental features when non-zero");
11695 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
11699 "Attempts to load the driver even on a mis-identified ThinkPad when true");
11742 …MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command at module load, see documentatio…
11782 MODULE_PARM_DESC(profile_force, "Force profile mode. -1=off, 1=MMC, 2=PSC");
11836 /* Driver-level probe */ in thinkpad_acpi_module_init()
11876 return -ENOMEM; in thinkpad_acpi_module_init()
11883 return -ENODEV; in thinkpad_acpi_module_init()
11888 tp_features.quirks = dmi_id->driver_data; in thinkpad_acpi_module_init()
11915 return -ENOMEM; in thinkpad_acpi_module_init()
11918 tpacpi_inputdev->name = "ThinkPad Extra Buttons"; in thinkpad_acpi_module_init()
11919 tpacpi_inputdev->phys = TPACPI_DRVR_NAME "/input0"; in thinkpad_acpi_module_init()
11920 tpacpi_inputdev->id.bustype = BUS_HOST; in thinkpad_acpi_module_init()
11921 tpacpi_inputdev->id.vendor = thinkpad_id.vendor; in thinkpad_acpi_module_init()
11922 tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT; in thinkpad_acpi_module_init()
11923 tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION; in thinkpad_acpi_module_init()
11924 tpacpi_inputdev->dev.parent = &tpacpi_pdev->dev; in thinkpad_acpi_module_init()
11934 ret = ibms_init[i].data->write(ibms_init[i].param); in thinkpad_acpi_module_init()
11960 &tpacpi_sensors_pdev->dev, TPACPI_NAME, NULL, tpacpi_hwmon_groups); in thinkpad_acpi_module_init()