Lines Matching +full:pico +full:- +full:seconds
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
44 #include <linux/hwmon-sysfs.h>
47 #include <linux/input/sparse-keymap.h>
121 /* Misc NVRAM-related */
180 * hkey -> scancode translation for
182 * directly in the sparse-keymap.
198 /* Auto-sleep after eject request */
215 /* User-interface events */
227 /* Key-related user-interface events */
245 /* AC-related events */
248 /* Further user-interface events */
266 #define TPACPI_URL "http://ibm-acpi.sf.net/"
267 #define TPACPI_MAIL "ibm-acpi-devel@lists.sourceforge.net"
294 * 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 scnprintf(acpi_device_class(ibm->acpi->device), in setup_acpi_notify()
842 sizeof(acpi_device_class(ibm->acpi->device)), in setup_acpi_notify()
843 "%s/%s", TPACPI_ACPI_EVENT_PREFIX, 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()
978 if (ibm->suspend) in tpacpi_suspend_handler()
979 (ibm->suspend)(); in tpacpi_suspend_handler()
992 if (ibm->resume) in tpacpi_resume_handler()
993 (ibm->resume)(); in tpacpi_resume_handler()
1010 if (ibm->shutdown) in tpacpi_shutdown_handler()
1011 (ibm->shutdown)(); in tpacpi_shutdown_handler()
1027 return -EINVAL; in parse_strtoul()
1051 * ThinkPad-ACPI firmware handling model:
1053 * WLSW (master wireless switch) is event-driven, and is common to all
1054 * firmware-controlled radios. It cannot be controlled, just monitored,
1057 * The kernel, a masked-off hotkey, and WLSW can change the radio state
1061 * masked-off hotkeys are used.
1090 /* ThinkPad-ACPI rfkill subdriver */
1111 return -ENODEV; in tpacpi_rfk_update_swstate()
1113 status = (tp_rfk->ops->get_status)(); in tpacpi_rfk_update_swstate()
1117 rfkill_set_sw_state(tp_rfk->rfkill, in tpacpi_rfk_update_swstate()
1124 * Sync the HW-blocking state of all rfkill switches,
1135 if (rfkill_set_hw_state(tp_rfk->rfkill, in tpacpi_rfk_update_hwblock_state()
1137 /* ignore -- we track sw block */ in tpacpi_rfk_update_hwblock_state()
1172 res = (tp_rfk->ops->set_status)(blocked ? in tpacpi_rfk_hook_set_block()
1201 atp_rfk->rfkill = rfkill_alloc(name, in tpacpi_new_rfkill()
1202 &tpacpi_pdev->dev, in tpacpi_new_rfkill()
1206 if (!atp_rfk || !atp_rfk->rfkill) { in tpacpi_new_rfkill()
1209 return -ENOMEM; in tpacpi_new_rfkill()
1212 atp_rfk->id = id; in tpacpi_new_rfkill()
1213 atp_rfk->ops = tp_rfkops; in tpacpi_new_rfkill()
1215 sw_status = (tp_rfkops->get_status)(); in tpacpi_new_rfkill()
1224 rfkill_init_sw_state(atp_rfk->rfkill, sw_state); in tpacpi_new_rfkill()
1228 rfkill_set_hw_state(atp_rfk->rfkill, hw_state); in tpacpi_new_rfkill()
1230 res = rfkill_register(atp_rfk->rfkill); in tpacpi_new_rfkill()
1233 rfkill_destroy(atp_rfk->rfkill); in tpacpi_new_rfkill()
1253 rfkill_unregister(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1254 rfkill_destroy(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1266 /* sysfs <radio> enable ------------------------------------------------ */
1273 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_show()
1295 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_store()
1298 return -EINVAL; in tpacpi_rfk_sysfs_enable_store()
1300 tpacpi_disclose_usertask(attr->attr.name, "set to %ld\n", t); in tpacpi_rfk_sysfs_enable_store()
1304 return -EPERM; in tpacpi_rfk_sysfs_enable_store()
1306 res = tpacpi_rfkill_switches[id]->ops->set_status((!!t) ? in tpacpi_rfk_sysfs_enable_store()
1313 /* procfs -------------------------------------------------------------- */
1341 int status = -1; in tpacpi_rfk_procfs_write()
1345 return -ENODEV; in tpacpi_rfk_procfs_write()
1353 return -EINVAL; in tpacpi_rfk_procfs_write()
1356 if (status != -1) { in tpacpi_rfk_procfs_write()
1360 res = (tpacpi_rfkill_switches[id]->ops->set_status)(status); in tpacpi_rfk_procfs_write()
1368 * thinkpad-acpi driver attributes
1371 /* interface_version --------------------------------------------------- */
1378 /* debug_level --------------------------------------------------------- */
1390 return -EINVAL; in debug_level_store()
1398 /* version ------------------------------------------------------------- */
1406 /* --------------------------------------------------------------------- */
1410 /* wlsw_emulstate ------------------------------------------------------ */
1422 return -EINVAL; in wlsw_emulstate_store()
1433 /* bluetooth_emulstate ------------------------------------------------- */
1445 return -EINVAL; in bluetooth_emulstate_store()
1453 /* wwan_emulstate ------------------------------------------------- */
1465 return -EINVAL; in wwan_emulstate_store()
1473 /* uwb_emulstate ------------------------------------------------- */
1485 return -EINVAL; in uwb_emulstate_store()
1571 /* Numeric models ------------------ */
1583 /* A-series ------------------------- */
1597 /* G-series ------------------------- */
1602 /* R-series, T-series --------------- */
1632 /* X-series ------------------------- */
1645 /* (0) - older versions lack DMI EC fw string and functionality */
1646 /* (1) - older versions known to lack functionality */
1702 * thinkpad-acpi metadata subdriver
1737 * Unlike other classes, hotkey-class events have mask/unmask control on
1738 * non-ancient firmware. However, how it behaves changes a lot with the
1956 return -ENODEV; in hotkey_get_wlsw()
1965 return -EIO; in hotkey_get_wlsw()
2059 return -EIO; in hotkey_get_tablet_mode()
2065 return -EIO; in hotkey_get_tablet_mode()
2090 return -EIO; in hotkey_mask_get()
2098 /* sync userspace-visible mask */ in hotkey_mask_get()
2136 rc = -EIO; in hotkey_mask_set()
2177 …pr_notice("please consider using the driver defaults, and refer to up-to-date thinkpad-acpi docume… in hotkey_user_mask_set()
2226 return -EIO; in hotkey_status_get()
2234 return -EIO; in hotkey_status_set()
2263 return -ENODEV; in get_camera_shutter()
2266 return -EIO; in get_camera_shutter()
2269 return -ENODEV; in get_camera_shutter()
2283 * Before the conversion to using the sparse-keymap helpers the driver used to in tpacpi_input_send_key()
2284 * map the hkey event codes to 0x00 - 0x4d scancodes so that a straight scancode in tpacpi_input_send_key()
2287 * 0x1001 - 0x1020 -> 0x00 - 0x1f (Original ThinkPad events) in tpacpi_input_send_key()
2288 * 0x1103 - 0x1116 -> 0x20 - 0x33 (Adaptive keyboard, 2014 X1 Carbon) in tpacpi_input_send_key()
2289 * 0x1300 - 0x1319 -> 0x34 - 0x4d (Additional keys send in 2017+ models) in tpacpi_input_send_key()
2291 * The sparse-keymap tables still use these scancodes for these ranges to in tpacpi_input_send_key()
2296 scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; in tpacpi_input_send_key()
2301 scancode = hkey - TP_HKEY_EV_ADAPTIVE_KEY_START + in tpacpi_input_send_key()
2305 scancode = hkey - TP_HKEY_EV_EXTENDED_KEY_START + in tpacpi_input_send_key()
2341 n->thinkpad_toggle = !!(d & TP_NVRAM_MASK_HKT_THINKPAD); in hotkey_read_nvram()
2342 n->zoom_toggle = !!(d & TP_NVRAM_MASK_HKT_ZOOM); in hotkey_read_nvram()
2343 n->display_toggle = !!(d & TP_NVRAM_MASK_HKT_DISPLAY); in hotkey_read_nvram()
2344 n->hibernate_toggle = !!(d & TP_NVRAM_MASK_HKT_HIBERNATE); in hotkey_read_nvram()
2348 n->thinklight_toggle = !!(d & TP_NVRAM_MASK_THINKLIGHT); in hotkey_read_nvram()
2352 n->displayexp_toggle = in hotkey_read_nvram()
2357 n->brightness_level = (d & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) in hotkey_read_nvram()
2359 n->brightness_toggle = in hotkey_read_nvram()
2364 n->volume_level = (d & TP_NVRAM_MASK_LEVEL_VOLUME) in hotkey_read_nvram()
2366 n->mute = !!(d & TP_NVRAM_MASK_MUTE); in hotkey_read_nvram()
2367 n->volume_toggle = !!(d & TP_NVRAM_MASK_HKT_VOLUME); in hotkey_read_nvram()
2374 oldn->__member != newn->__member) \
2392 i--; in issue_volchange()
2408 i--; in issue_brightnesschange()
2434 * - Pressing MUTE issues mute hotkey message, even when already mute in hotkey_compare_and_issue_event()
2435 * - Pressing Volume up/down issues volume up/down hotkey messages, in hotkey_compare_and_issue_event()
2437 * - The act of unmuting issues volume up/down notification, in hotkey_compare_and_issue_event()
2447 if (newn->mute) { in hotkey_compare_and_issue_event()
2449 if (!oldn->mute || in hotkey_compare_and_issue_event()
2450 oldn->volume_toggle != newn->volume_toggle || in hotkey_compare_and_issue_event()
2451 oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2454 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2460 if (oldn->mute) { in hotkey_compare_and_issue_event()
2464 if (oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2465 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2467 } else if (oldn->volume_toggle != newn->volume_toggle) { in hotkey_compare_and_issue_event()
2469 if (newn->volume_level == 0) in hotkey_compare_and_issue_event()
2471 else if (newn->volume_level >= TP_NVRAM_LEVEL_VOLUME_MAX) in hotkey_compare_and_issue_event()
2477 if (oldn->brightness_level != newn->brightness_level) { in hotkey_compare_and_issue_event()
2478 issue_brightnesschange(oldn->brightness_level, in hotkey_compare_and_issue_event()
2479 newn->brightness_level, event_mask); in hotkey_compare_and_issue_event()
2480 } else if (oldn->brightness_toggle != newn->brightness_toggle) { in hotkey_compare_and_issue_event()
2482 if (newn->brightness_level == 0) in hotkey_compare_and_issue_event()
2484 else if (newn->brightness_level >= bright_maxlvl in hotkey_compare_and_issue_event()
2497 * most of them are edge-based. We only issue those requested by
2591 (poll_user_mask && tpacpi_inputdev->users > 0))) { in hotkey_poll_setup()
2650 return -EBUSY; in hotkey_inputdev_open()
2655 return -EBUSY; in hotkey_inputdev_open()
2666 /* sysfs hotkey enable ------------------------------------------------- */
2693 return -EINVAL; in hotkey_enable_store()
2696 return -EPERM; in hotkey_enable_store()
2703 /* sysfs hotkey mask --------------------------------------------------- */
2719 return -EINVAL; in hotkey_mask_store()
2722 return -ERESTARTSYS; in hotkey_mask_store()
2739 /* sysfs hotkey bios_enabled ------------------------------------------- */
2749 /* sysfs hotkey bios_mask ---------------------------------------------- */
2761 /* sysfs hotkey all_mask ----------------------------------------------- */
2772 /* sysfs hotkey all_mask ----------------------------------------------- */
2783 /* sysfs hotkey recommended_mask --------------------------------------- */
2797 /* sysfs hotkey hotkey_source_mask ------------------------------------- */
2815 return -EINVAL; in hotkey_source_mask_store()
2818 return -ERESTARTSYS; in hotkey_source_mask_store()
2848 /* sysfs hotkey hotkey_poll_freq --------------------------------------- */
2863 return -EINVAL; in hotkey_poll_freq_store()
2866 return -ERESTARTSYS; in hotkey_poll_freq_store()
2882 /* sysfs hotkey radio_sw (pollable) ------------------------------------ */
2904 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_radio_sw_notify_change()
2908 /* sysfs hotkey tablet mode (pollable) --------------------------------- */
2926 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_tablet_mode_notify_change()
2930 /* sysfs wakeup reason (pollable) -------------------------------------- */
2942 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_reason_notify_change()
2946 /* sysfs wakeup hotunplug_complete (pollable) -------------------------- */
2959 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_hotunplug_complete_notify_change()
2963 /* sysfs adaptive kbd mode --------------------------------------------- */
2997 return -EINVAL; in adaptive_kbd_mode_store()
3013 return tp_features.has_adaptive_kbd ? attr->mode : 0; in hadaptive_kbd_attr_is_visible()
3021 /* --------------------------------------------------------------------- */
3053 return attr->mode; in hotkey_attr_is_visible()
3081 /* Sync hw blocking state first if it is hw-blocked */ in tpacpi_send_radiosw_update()
3085 /* Sync hw blocking state last if it is hw-unblocked */ in tpacpi_send_radiosw_update()
3189 /* Original hotkey mappings translated scancodes 0x00 - 0x1f */
3209 * Volume: firmware always reacts and reprograms the built-in *extra* mixer.
3220 /* Original hotkey mappings translated scancodes 0x00 - 0x1f */
3234 * These should be enabled --only-- when ACPI video is disabled and
3244 * reprograms the built-in *extra* mixer.
3259 /* Adaptive keyboard mappings for Carbon X1 2014 translated scancodes 0x20 - 0x33 */
3280 /* Extended hotkeys mappings translated scancodes 0x34 - 0x4d */
3333 BUG_ON(tpacpi_inputdev->open != NULL || in hotkey_init()
3334 tpacpi_inputdev->close != NULL); in hotkey_init()
3351 return -ENODEV; in hotkey_init()
3359 A30, R30, R31, T20-22, X20-21, X22-24. Detected by checking in hotkey_init()
3378 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3395 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3513 pr_notice("Disabling thinkpad-acpi brightness events by default...\n"); in hotkey_init()
3544 if (res < 0 && res != -ENXIO) { in hotkey_init()
3554 tpacpi_inputdev->open = &hotkey_inputdev_open; in hotkey_init()
3555 tpacpi_inputdev->close = &hotkey_inputdev_close; in hotkey_init()
3566 * mode, Web conference mode, Function mode and Lay-flat mode.
3591 return -EIO; in adaptive_keyboard_get_mode()
3601 return -EINVAL; in adaptive_keyboard_set_mode()
3605 return -EIO; in adaptive_keyboard_set_mode()
3614 size_t max_mode = ARRAY_SIZE(adaptive_keyboard_modes) - 1; in adaptive_keyboard_get_next_mode()
3660 /* 0x1000-0x1FFF: key presses */
3663 /* Never send ACPI netlink events for original hotkeys (hkey: 0x1001 - 0x1020) */ in hotkey_notify_hotkey()
3668 unsigned int scancode = hkey - TP_HKEY_EV_ORIG_KEY_START; in hotkey_notify_hotkey()
3676 /* 0x2000-0x2FFF: Wakeup reason */
3695 /* how to auto-heal: */ in hotkey_notify_wakeup()
3705 pr_info("woke up due to a hot-unplug request...\n"); in hotkey_notify_wakeup()
3711 /* 0x4000-0x4FFF: dock-related events */
3731 * duplicates from intel-vbtn, which already emits SW_TABLET_MODE events in hotkey_notify_dockevent()
3737 * the Pico cartridge dock module: in hotkey_notify_dockevent()
3738 * https://lore.kernel.org/platform-driver-x86/38cb8265-1e30-d547-9e12-b4ae290be737@a-kobel.de/ in hotkey_notify_dockevent()
3750 /* 0x5000-0x5FFF: human interface helpers */
3758 case TP_HKEY_EV_TABLET_TABLET: /* X41t-X61t: tablet mode */ in hotkey_notify_usrevent()
3759 case TP_HKEY_EV_TABLET_NOTEBOOK: /* X41t-X61t: normal mode */ in hotkey_notify_usrevent()
3780 /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */
3791 /* Thermal event - pass on to event handler */ in hotkey_notify_6xxx()
3848 /* palm detected - pass on to event handler */ in hotkey_notify_6xxx()
3884 ibm->acpi->device->pnp.device_class, in hotkey_notify()
3885 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
3906 /* 0x1000-0x1FFF: key presses */ in hotkey_notify()
3910 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify()
3914 /* 0x3000-0x3FFF: bay-related wakeups */ in hotkey_notify()
3929 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify()
3933 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify()
3937 /* 0x6000-0x6FFF: thermal alarms/notices and in hotkey_notify()
3942 /* 0x7000-0x7FFF: misc */ in hotkey_notify()
3951 /* 0x8000-0x8FFF: misc2 */ in hotkey_notify()
3964 ibm->acpi->device->pnp.device_class, in hotkey_notify()
3965 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4012 /* procfs -------------------------------------------------------------- */
4023 return -ERESTARTSYS; in hotkey_read()
4058 return -ENODEV; in hotkey_write()
4061 return -ERESTARTSYS; in hotkey_write()
4071 res = -EPERM; in hotkey_write()
4080 res = -EINVAL; in hotkey_write()
4135 TP_ACPI_BLTH_GET_PWR_ON_RESUME = 0x01, /* Get power-on-resume state */
4154 return -EIO; in bluetooth_get_status()
4181 return -EIO; in bluetooth_set_status()
4186 /* sysfs bluetooth enable ---------------------------------------------- */
4205 /* --------------------------------------------------------------------- */
4215 return tp_features.bluetooth ? attr->mode : 0; in bluetooth_attr_is_visible()
4263 .ident = "ThinkPad A285 - 20MW",
4271 .ident = "ThinkPad A285 - 20MX",
4279 .ident = "ThinkPad A485 - 20MU",
4287 .ident = "ThinkPad A485 - 20MV",
4311 if (tp_features.quirks && tp_features.quirks->btusb_bug && in have_bt_fwbug()
4331 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ in bluetooth_init()
4355 return -ENODEV; in bluetooth_init()
4365 /* procfs -------------------------------------------------------------- */
4409 return -EIO; in wan_get_status()
4436 return -EIO; in wan_set_status()
4441 /* sysfs wan enable ---------------------------------------------------- */
4461 /* --------------------------------------------------------------------- */
4471 return tp_features.wan ? attr->mode : 0; in wan_attr_is_visible()
4534 return -ENODEV; in wan_init()
4544 /* procfs -------------------------------------------------------------- */
4586 return -EIO; in uwb_get_status()
4612 return -EIO; in uwb_set_status()
4617 /* --------------------------------------------------------------------- */
4662 return -ENODEV; in uwb_init()
4755 return (video_supported != TPACPI_VIDEO_NONE) ? 0 : -ENODEV; in video_init()
4775 return -EIO; in video_outputsw_get()
4780 return -EIO; in video_outputsw_get()
4784 return -EIO; in video_outputsw_get()
4791 return -EIO; in video_outputsw_get()
4797 return -EIO; in video_outputsw_get()
4801 return -EIO; in video_outputsw_get()
4806 return -ENOSYS; in video_outputsw_get()
4835 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_set()
4836 return -EIO; in video_outputsw_set()
4844 return -ENOSYS; in video_outputsw_set()
4847 return (res) ? 0 : -EIO; in video_outputsw_set()
4857 return -EIO; in video_autosw_get()
4862 return -EIO; in video_autosw_get()
4865 return -ENOSYS; in video_autosw_get()
4874 return -EIO; in video_autosw_set()
4901 return -ENOSYS; in video_outputsw_cycle()
4904 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_cycle()
4905 return -EIO; in video_outputsw_cycle()
4908 return (res) ? 0 : -EIO; in video_outputsw_cycle()
4916 0 : -EIO; in video_expand_toggle()
4919 0 : -EIO; in video_expand_toggle()
4922 0 : -EIO; in video_expand_toggle()
4924 return -ENOSYS; in video_expand_toggle()
4940 return -EPERM; in video_read()
4973 return -ENODEV; in video_write()
4977 return -EPERM; in video_write()
5014 return -EINVAL; in video_write()
5050 return -ENXIO; in kbdlight_set_level()
5055 ret = -EIO; in kbdlight_set_level()
5069 return -ENXIO; in kbdlight_get_level()
5072 return -EIO; in kbdlight_get_level()
5107 * b010100000010000000XX - ThinkPad X1 Carbon 3rd in kbdlight_is_supported()
5108 * b110100010010000000XX - ThinkPad x230 in kbdlight_is_supported()
5109 * b010100000010000000XX - ThinkPad x240 in kbdlight_is_supported()
5110 * b010100000010000000XX - ThinkPad W541 in kbdlight_is_supported()
5114 * b10100001000000000000 - ThinkPad x230 in kbdlight_is_supported()
5115 * b10110001000000000000 - ThinkPad E430 in kbdlight_is_supported()
5116 * b00000000000000000000 - ThinkPad E450 in kbdlight_is_supported()
5163 return -ENODEV; in kbdlight_init()
5169 rc = led_classdev_register(&tpacpi_pdev->dev, in kbdlight_init()
5194 if (ret == 0 && !(led_cdev->flags & LED_SUSPENDED)) in kbdlight_set_level_and_update()
5195 led_cdev->brightness = level; in kbdlight_set_level_and_update()
5221 int res, level = -EINVAL; in kbdlight_write()
5224 return -ENODEV; in kbdlight_write()
5233 return -EINVAL; in kbdlight_write()
5271 TPACPI_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
5280 return -EIO; in light_get_status()
5284 return -ENXIO; in light_get_status()
5301 return (rc) ? 0 : -EIO; in light_set_status()
5304 return -ENXIO; in light_set_status()
5354 return -ENODEV; in light_init()
5356 rc = led_classdev_register(&tpacpi_pdev->dev, in light_init()
5400 return -ENODEV; in light_write()
5408 return -EINVAL; in light_write()
5425 /* sysfs cmos_command -------------------------------------------------- */
5434 return -EINVAL; in cmos_command_store()
5450 return cmos_handle ? attr->mode : 0; in cmos_attr_is_visible()
5458 /* --------------------------------------------------------------------- */
5470 return cmos_handle ? 0 : -ENODEV; in cmos_init()
5476 R30, R31, T20-22, X20-21 */ in cmos_read()
5481 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n"); in cmos_read()
5497 return -EINVAL; in cmos_write()
5520 TPACPI_LED_OLD, /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
5573 return -EIO; in led_get_status()
5582 return -ENXIO; in led_get_status()
5601 return -EINVAL; in led_set_status()
5603 return -EPERM; in led_set_status()
5606 return -EIO; in led_set_status()
5609 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */ in led_set_status()
5611 return -EINVAL; in led_set_status()
5613 return -EPERM; in led_set_status()
5625 return -EINVAL; in led_set_status()
5627 return -EPERM; in led_set_status()
5630 return -EIO; in led_set_status()
5633 return -ENXIO; in led_set_status()
5651 else if (tpacpi_led_state_cache[data->led] != TPACPI_LED_BLINK) in led_sysfs_set()
5656 return led_set_status(data->led, new_state); in led_sysfs_set()
5671 return -EINVAL; in led_sysfs_blink_set()
5673 return led_set_status(data->led, TPACPI_LED_BLINK); in led_sysfs_blink_set()
5683 rc = led_get_status(data->led); in led_sysfs_get()
5718 return led_classdev_register(&tpacpi_pdev->dev, &tpacpi_leds[led].led_classdev); in tpacpi_init_led()
5746 /* (1) - may have excess leds enabled on MSB */
5776 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ in led_init_detect_mode()
5816 return -ENODEV; in led_init()
5822 return -ENOMEM; in led_init()
5826 tpacpi_leds[i].led = -1; in led_init()
5859 return -EIO; in led_read()
5864 seq_printf(m, "commands:\t<led> on, <led> off, <led> blink (<led> is 0-15)\n"); in led_read()
5876 return -ENODEV; in led_write()
5880 return -EINVAL; in led_write()
5882 if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1)) in led_write()
5883 return -ENODEV; in led_write()
5886 return -ENODEV; in led_write()
5895 return -EINVAL; in led_write()
5923 TPACPI_Q_IBM('I', 'U', TPACPI_BEEP_Q1), /* 570E - unverified */
5942 return (beep_handle) ? 0 : -ENODEV; in beep_init()
5951 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n"); in beep_read()
5963 return -ENODEV; in beep_write()
5970 return -EINVAL; in beep_write()
5974 return -EIO; in beep_write()
5978 return -EIO; in beep_write()
5997 TPACPI_THERMAL_ACPI_TMP07, /* Use ACPI TMP0-7 */
5998 TPACPI_THERMAL_ACPI_UPDT, /* Use ACPI TMP0-7 with UPDT */
6007 TP_EC_THERMAL_TMP0_NS = 0xA8, /* ACPI EC Non-Standard regs TMP 0..7 */
6008 TP_EC_THERMAL_TMP8_NS = 0xB8, /* ACPI EC Non-standard regs TMP 8..11 */
6010 TP_EC_THERMAL_TMP_NA = -128, /* ACPI EC sensor not available */
6012 TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */
6022 /* Non-standard address for thermal registers on some ThinkPads */
6030 TPACPI_Q_LNV3('R', '1', 'D', true), /* 11e Gen5 GL-R*/
6031 TPACPI_Q_LNV3('R', '0', 'V', true), /* 11e Gen5 KL-Y*/
6036 static bool thermal_with_ns_address; /* Non-standard thermal reg address */
6049 * Direct EC access mode: sensors at registers 0x78-0x7F, in thermal_read_mode_check()
6050 * 0xC0-0xC7. Registers return 0x00 for non-implemented, in thermal_read_mode_check()
6055 * determines EC version. 0xC0-0xC7 are not thermal registers in thermal_read_mode_check()
6061 /* Quirks to check non-standard EC */ in thermal_read_mode_check()
6065 /* Support for Thinkpads with non-standard address */ in thermal_read_mode_check()
6067 pr_info("ECFW with non-standard thermal registers found\n"); in thermal_read_mode_check()
6120 /* idx is zero-based */
6134 idx -= 8; in thermal_get_sensor()
6141 return -EIO; in thermal_get_sensor()
6147 /* The Non-standard EC uses 12 Thermal areas */ in thermal_get_sensor()
6150 return -EINVAL; in thermal_get_sensor()
6153 TP_EC_THERMAL_TMP8_NS + (idx - 8); in thermal_get_sensor()
6156 return -EIO; in thermal_get_sensor()
6165 return -EIO; in thermal_get_sensor()
6167 return -EIO; in thermal_get_sensor()
6168 *value = (t - 2732) * 100; in thermal_get_sensor()
6177 return -EIO; in thermal_get_sensor()
6178 if (t > 127 || t < -127) in thermal_get_sensor()
6187 return -ENOSYS; in thermal_get_sensor()
6190 return -EINVAL; in thermal_get_sensor()
6198 return -EINVAL; in thermal_get_sensors()
6208 res = thermal_get_sensor(i, &s->temp[i]); in thermal_get_sensors()
6237 /* sysfs temp##_input -------------------------------------------------- */
6245 int idx = sensor_attr->index; in thermal_temp_input_show()
6253 return -ENXIO; in thermal_temp_input_show()
6313 int idx = sensor_attr->index; in thermal_attr_is_visible()
6336 return attr->mode; in thermal_attr_is_visible()
6368 return thermal_use_labels ? attr->mode : 0; in temp_label_attr_is_visible()
6376 /* --------------------------------------------------------------------- */
6388 return thermal_read_mode != TPACPI_THERMAL_NONE ? 0 : -ENODEV; in thermal_init()
6403 for (i = 0; i < (n - 1); i++) in thermal_read()
6425 * CMOS NVRAM byte 0x5E, bits 0-3.
6432 * Bit 3-0: backlight brightness level
6453 TPACPI_BRGHT_MODE_UCMS_STEP, /* UCMS step-based control */
6534 return -EIO; in tpacpi_brightness_get_raw()
6538 return -ENXIO; in tpacpi_brightness_get_raw()
6550 return -EIO; in tpacpi_brightness_set_ec()
6555 return -EIO; in tpacpi_brightness_set_ec()
6575 inc = (value > current_value) ? 1 : -1; in tpacpi_brightness_set_ucmsstep()
6579 return -EIO; in tpacpi_brightness_set_ucmsstep()
6590 return -EINVAL; in brightness_set()
6608 res = -ENXIO; in brightness_set()
6615 /* sysfs backlight class ----------------------------------------------- */
6659 /* --------------------------------------------------------------------- */
6668 status = acpi_evaluate_object(adev->handle, "_BCL", NULL, &buffer); in tpacpi_evaluate_bcl()
6673 if (!obj || obj->type != ACPI_TYPE_PACKAGE) { in tpacpi_evaluate_bcl()
6674 acpi_handle_info(adev->handle, in tpacpi_evaluate_bcl()
6679 rc = obj->package.count; in tpacpi_evaluate_bcl()
6717 return (bcl_levels > 2) ? (bcl_levels - 2) : 0; in tpacpi_check_std_acpi_brightness_support()
6734 TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), /* R50,51 T40-42 */
6780 bright_maxlvl = b - 1; in tpacpi_detect_brightness_capabilities()
6802 return -ENODEV; in brightness_init()
6807 return -ENODEV; in brightness_init()
6813 return -ENODEV; in brightness_init()
6816 return -ENODEV; in brightness_init()
6820 return -ENODEV; in brightness_init()
6831 return -EINVAL; in brightness_init()
6842 "driver auto-selected brightness_mode=%d\n", in brightness_init()
6850 return -EINVAL; in brightness_init()
6853 return -ENODEV; in brightness_init()
6924 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in brightness_read()
6947 level--; in brightness_write()
6952 return -EINVAL; in brightness_write()
6966 return (rc == -EINTR) ? -ERESTARTSYS : rc; in brightness_write()
6991 * Bit 3-0: Volume
6995 * bits 3-0 (volume). Other bits in NVRAM may have other functions,
7007 * To avoid confusing userspace, we simply disable all EC-based mute
7018 #define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1)
7020 #define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1)
7051 TPACPI_VOL_MODE_UCMS_STEP, /* UCMS step-based control: N/A */
7081 * TP_NVRAM_ADDR_MIXER, as we need to do read-modify-write
7137 return -EIO; in volume_get_status_ec()
7154 return -EIO; in volume_set_status_ec()
7179 return -EINTR; in __volume_set_mute_ec()
7224 return -EINVAL; in __volume_set_volume_ec()
7227 return -EINTR; in __volume_set_volume_ec()
7251 return -ENODEV; in volume_set_software_mute()
7256 return -EIO; in volume_set_software_mute()
7265 return -EIO; in volume_set_software_mute()
7274 * startup. Just on case there are SAUM-capable ThinkPads in volume_set_software_mute()
7308 if (alsa_card && alsa_card->private_data) { in volume_alsa_notify_change()
7309 d = alsa_card->private_data; in volume_alsa_notify_change()
7310 if (d->ctl_mute_id) in volume_alsa_notify_change()
7313 d->ctl_mute_id); in volume_alsa_notify_change()
7314 if (d->ctl_vol_id) in volume_alsa_notify_change()
7317 d->ctl_vol_id); in volume_alsa_notify_change()
7324 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in volume_alsa_vol_info()
7325 uinfo->count = 1; in volume_alsa_vol_info()
7326 uinfo->value.integer.min = 0; in volume_alsa_vol_info()
7327 uinfo->value.integer.max = TP_EC_VOLUME_MAX; in volume_alsa_vol_info()
7341 ucontrol->value.integer.value[0] = s & TP_EC_AUDIO_LVL_MSK; in volume_alsa_vol_get()
7349 ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7350 return volume_alsa_set_volume(ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7365 ucontrol->value.integer.value[0] = in volume_alsa_mute_get()
7374 ucontrol->value.integer.value[0] ? in volume_alsa_mute_put()
7376 return volume_alsa_set_mute(!ucontrol->value.integer.value[0]); in volume_alsa_mute_put()
7438 rc = snd_card_new(&tpacpi_pdev->dev, in volume_create_alsa_mixer()
7443 return -ENODEV; in volume_create_alsa_mixer()
7446 BUG_ON(!card->private_data); in volume_create_alsa_mixer()
7447 data = card->private_data; in volume_create_alsa_mixer()
7448 data->card = card; in volume_create_alsa_mixer()
7450 strscpy(card->driver, TPACPI_ALSA_DRVNAME); in volume_create_alsa_mixer()
7451 strscpy(card->shortname, TPACPI_ALSA_SHRTNAME); in volume_create_alsa_mixer()
7452 snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s", in volume_create_alsa_mixer()
7455 snprintf(card->longname, sizeof(card->longname), in volume_create_alsa_mixer()
7456 "%s at EC reg 0x%02x, fw %s", card->shortname, TP_EC_AUDIO, in volume_create_alsa_mixer()
7478 data->ctl_vol_id = &ctl_vol->id; in volume_create_alsa_mixer()
7487 data->ctl_mute_id = &ctl_mute->id; in volume_create_alsa_mixer()
7500 return -ENODEV; in volume_create_alsa_mixer()
7503 #define TPACPI_VOL_Q_MUTEONLY 0x0001 /* Mute-only control available */
7522 /* Whitelist mute-only on all Lenovo by default */
7544 return -EINVAL; in volume_init()
7549 return -ENODEV; in volume_init()
7553 return -EINVAL; in volume_init()
7562 return -ENODEV; in volume_init()
7575 return -ENODEV; /* no mixer */ in volume_init()
7584 return -ENODEV; in volume_init()
7589 "using user-supplied volume_capabilities=%d\n", in volume_init()
7597 "driver auto-selected volume_mode=%d\n", in volume_init()
7601 "using user-supplied volume_mode=%d\n", in volume_init()
7653 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in volume_read()
7680 return -EPERM; in volume_write()
7702 new_level--; in volume_write()
7715 return -EINVAL; in volume_write()
7730 return (rc == -EINTR) ? -ERESTARTSYS : rc; in volume_write()
7755 return -ENODEV; in volume_init()
7792 * Contains the current fan speed from 0-100%
7825 * Speeds up fan to 100% duty-cycle, which is far above
7828 * 5-3 unused in some models. Extra bits for fan level
7831 * 2-0 fan level (0..7 usually)
7844 * ----
7849 * This register is present on all ThinkPads with a new-style EC, and
7855 * Unfortunately a lot of ThinkPads with new-style ECs but whose firmware
7869 * ----
7881 * So far, only the firmware for the X60/X61 non-tablet versions
7882 * seem to support this (firmware TP-7M).
7907 * that are using non-standard EC locations for reporting fan speeds.
7912 #define FAN_RPM_CAL_CONST 491520 /* FAN RPM calculation offset for some non-standard ECFW */
7925 fan_status_offset_ns = 0x93, /* Special status/control offset for non-standard EC Fan1 */
7926 fan2_status_offset_ns = 0x96, /* Special status/control offset for non-standard EC Fan2 */
7927 fan_rpm_status_ns = 0x95, /* Special offset for Fan1 RPM status for non-standard EC */
7928 fan2_rpm_status_ns = 0x98, /* Special offset for Fan2 RPM status for non-standard EC */
7933 TPACPI_FAN_LAST_LEVEL = 0x100, /* Use cached last-seen fan level */
7940 TPACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */
7941 TPACPI_FAN_RD_TPEC_NS, /* Use non-standard ACPI EC regs (eg: L13 Yoga gen2 etc.) */
7986 "JFNS", /* 770x-JL */
8003 * Enable for TP-1Y (T43), TP-78 (R51e), TP-76 (R52),
8004 * TP-70 (T43, R52), which are known to be buggy.
8089 return -EIO; in fan_get_status()
8101 return -EIO; in fan_get_status()
8103 return -EIO; in fan_get_status()
8116 return -EIO; in fan_get_status()
8127 return -EIO; in fan_get_status()
8135 return -ENXIO; in fan_get_status()
8147 return -ERESTARTSYS; in fan_get_status_safe()
8170 return -EIO; in fan_get_speed()
8173 return -EIO; in fan_get_speed()
8183 return -EIO; in fan_get_speed()
8190 return -ENXIO; in fan_get_speed()
8205 return -EIO; in fan2_get_speed()
8210 return -EIO; in fan2_get_speed()
8222 return -EIO; in fan2_get_speed()
8225 return -EIO; in fan2_get_speed()
8229 return -EIO; in fan2_get_speed()
8238 return -EIO; in fan2_get_speed()
8246 return -ENXIO; in fan2_get_speed()
8255 return -EPERM; in fan_set_level()
8260 return -EINVAL; in fan_set_level()
8271 return -EIO; in fan_set_level()
8279 return -EINVAL; in fan_set_level()
8298 return -EIO; in fan_set_level()
8305 return -EINVAL; in fan_set_level()
8307 return -EINVAL; in fan_set_level()
8311 return -EIO; in fan_set_level()
8314 return -EIO; in fan_set_level()
8318 return -EIO; in fan_set_level()
8321 return -EIO; in fan_set_level()
8324 return -EIO; in fan_set_level()
8330 return -ENXIO; in fan_set_level()
8343 return -EPERM; in fan_set_level_safe()
8346 return -ERESTARTSYS; in fan_set_level_safe()
8365 return -EPERM; in fan_set_enable()
8368 return -ERESTARTSYS; in fan_set_enable()
8384 rc = -EIO; in fan_set_enable()
8402 rc = -EIO; in fan_set_enable()
8409 rc = -EIO; in fan_set_enable()
8413 rc = -EIO; in fan_set_enable()
8421 rc = -ENXIO; in fan_set_enable()
8438 return -EPERM; in fan_set_disable()
8441 return -ERESTARTSYS; in fan_set_disable()
8448 rc = -EIO; in fan_set_disable()
8457 rc = -EIO; in fan_set_disable()
8464 rc = -EIO; in fan_set_disable()
8468 rc = -EIO; in fan_set_disable()
8472 rc = -EIO; in fan_set_disable()
8479 rc = -ENXIO; in fan_set_disable()
8495 return -EPERM; in fan_set_speed()
8498 return -ERESTARTSYS; in fan_set_speed()
8506 rc = -EIO; in fan_set_speed()
8508 rc = -EINVAL; in fan_set_speed()
8514 rc = -EIO; in fan_set_speed()
8518 rc = -EIO; in fan_set_speed()
8523 rc = -EIO; in fan_set_speed()
8525 rc = -EINVAL; in fan_set_speed()
8529 rc = -ENXIO; in fan_set_speed()
8584 * fan watchdog interval in seconds, 0 disables (default), max 120
8587 /* sysfs fan pwm1_enable ----------------------------------------------- */
8617 return -EINVAL; in fan_pwm1_enable_store()
8633 /* reserved for software-controlled auto mode */ in fan_pwm1_enable_store()
8634 return -ENOSYS; in fan_pwm1_enable_store()
8636 return -EINVAL; in fan_pwm1_enable_store()
8640 if (res == -ENXIO) in fan_pwm1_enable_store()
8641 return -EINVAL; in fan_pwm1_enable_store()
8653 /* sysfs fan pwm1 ------------------------------------------------------ */
8684 return -EINVAL; in fan_pwm1_store()
8689 /* scale down from 0-255 to 0-7 */ in fan_pwm1_store()
8693 return -ERESTARTSYS; in fan_pwm1_store()
8699 if (rc == -ENXIO) in fan_pwm1_store()
8700 rc = -EINVAL; in fan_pwm1_store()
8713 /* sysfs fan fan1_input ------------------------------------------------ */
8734 /* sysfs fan fan2_input ------------------------------------------------ */
8755 /* sysfs fan fan_watchdog (hwmon driver) ------------------------------- */
8767 return -EINVAL; in fan_watchdog_store()
8770 return -EPERM; in fan_watchdog_store()
8781 /* --------------------------------------------------------------------- */
8803 return attr->mode; in fan_attr_is_visible()
8825 #define TPACPI_FAN_NS 0x0010 /* For EC with non-Standard register addresses */
8854 TPACPI_Q_LNV3('R', '1', 'D', TPACPI_FAN_NS), /* 11e Gen5 GL-R */
8855 TPACPI_Q_LNV3('R', '0', 'V', TPACPI_FAN_NS), /* 11e Gen5 KL-Y */
8896 return -ENODEV; in fan_init()
8900 pr_info("ECFW with non-standard fan reg control found\n"); in fan_init()
8927 /* all other ThinkPads: note that even old-style in fan_init()
8945 /* It responded - so let's assume it's there */ in fan_init()
8951 /* Fan not auto-detected */ in fan_init()
8965 return -ENODEV; in fan_init()
8970 /* 570, 770x-JL */ in fan_init()
9021 return -ENODEV; in fan_init()
9176 seq_printf(m, " (<level> is 0-7)\n"); in fan_read()
9180 seq_printf(m, " (<level> is 0-7, auto, disengaged, full-speed)\n"); in fan_read()
9187 "commands:\twatchdog <timeout> (<timeout> is 0 (off), 1-120 (seconds))\n"); in fan_read()
9190 seq_printf(m, "commands:\tspeed <speed> (<speed> is 0-65535)\n"); in fan_read()
9201 else if (strstarts(cmd, "level disengaged") || strstarts(cmd, "level full-speed")) in fan_write_cmd_level()
9207 if (*rc == -ENXIO) in fan_write_cmd_level()
9223 if (*rc == -ENXIO) in fan_write_cmd_enable()
9238 if (*rc == -ENXIO) in fan_write_cmd_disable()
9258 if (*rc == -ENXIO) in fan_write_cmd_speed()
9276 *rc = -EINVAL; in fan_write_cmd_watchdog()
9302 rc = -EINVAL; in fan_write()
9350 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_on_off()
9351 pr_warn("Thinkpad ACPI has no %s interface.\n", t->name); in mute_led_on_off()
9352 return -EIO; in mute_led_on_off()
9355 if (!acpi_evalf(hkey_handle, &output, t->name, "dd", in mute_led_on_off()
9356 state ? t->on_value : t->off_value)) in mute_led_on_off()
9357 return -EIO; in mute_led_on_off()
9359 t->state = state; in mute_led_on_off()
9368 if (t->state < 0 || t->state == on) in tpacpi_led_set()
9369 return t->state; in tpacpi_led_set()
9390 .default_trigger = "audio-mute",
9396 .default_trigger = "audio-micmute",
9407 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_init()
9408 t->state = -ENODEV; in mute_led_init()
9412 err = led_classdev_register(&tpacpi_pdev->dev, &mute_led_cdev[i]); in mute_led_init()
9414 while (i--) in mute_led_init()
9438 if (t->state >= 0) in mute_led_resume()
9439 mute_led_on_off(t, t->state); in mute_led_resume()
9528 return -ENODEV; in tpacpi_battery_get()
9535 return -ENODEV; in tpacpi_battery_get()
9549 return -ENODEV; in tpacpi_battery_get()
9555 return -ENODEV; in tpacpi_battery_get()
9561 return -EINVAL; in tpacpi_battery_get()
9570 /* The battery ID is in bits 8-9, 2 bits */ in tpacpi_battery_set()
9578 return -ENODEV; in tpacpi_battery_set()
9584 return -ENODEV; in tpacpi_battery_set()
9590 * battery ID is in bits 8-9, 2 bits. in tpacpi_battery_set()
9594 return -ENODEV; in tpacpi_battery_set()
9601 * The battery ID is in bits 4-5, 2 bits, in tpacpi_battery_set()
9602 * the effective time is in bits 8-23, 2 bytes. in tpacpi_battery_set()
9610 return -ENODEV; in tpacpi_battery_set()
9615 return -EINVAL; in tpacpi_battery_set()
9643 return -EIO; in tpacpi_battery_set_validate()
9666 return -ENODEV; in tpacpi_battery_probe()
9675 return -ENODEV; in tpacpi_battery_probe()
9679 return -ENODEV; in tpacpi_battery_probe()
9685 return -ENODEV; in tpacpi_battery_probe()
9691 return -ENODEV; in tpacpi_battery_probe()
9695 return -ENODEV; in tpacpi_battery_probe()
9701 return -ENODEV; in tpacpi_battery_probe()
9711 return -ENODEV; in tpacpi_battery_probe()
9772 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_store()
9783 return -ENODEV; in tpacpi_battery_store()
9786 return -EINVAL; in tpacpi_battery_store()
9788 return -EINVAL; in tpacpi_battery_store()
9790 return -ENODEV; in tpacpi_battery_store()
9796 return -ENODEV; in tpacpi_battery_store()
9799 return -EINVAL; in tpacpi_battery_store()
9801 return -EINVAL; in tpacpi_battery_store()
9811 return -EINVAL; in tpacpi_battery_store()
9815 return -EINVAL; in tpacpi_battery_store()
9839 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_show()
9843 return -ENODEV; in tpacpi_battery_show()
9870 battery = tpacpi_battery_get_id(supply->desc->name); in charge_behaviour_show()
9875 return -ENODEV; in charge_behaviour_show()
9884 return -ENODEV; in charge_behaviour_show()
9917 battery = tpacpi_battery_get_id(supply->desc->name); in charge_behaviour_store()
9949 return -EINVAL; in charge_behaviour_store()
9986 int batteryid = tpacpi_battery_get_id(battery->desc->name); in tpacpi_battery_add()
9989 return -ENODEV; in tpacpi_battery_add()
9990 if (device_add_groups(&battery->dev, tpacpi_battery_groups)) in tpacpi_battery_add()
9991 return -ENODEV; in tpacpi_battery_add()
9997 device_remove_groups(&battery->dev, tpacpi_battery_groups); in tpacpi_battery_remove()
10059 if (WARN_ON(!mutex_is_locked(&priv->lock))) in lcdshadow_set_sw_state()
10060 return -EIO; in lcdshadow_set_sw_state()
10063 return -EIO; in lcdshadow_set_sw_state()
10065 priv->hw_state = priv->sw_state = state; in lcdshadow_set_sw_state()
10076 priv->hw_state = priv->sw_state = output & 0x1; in lcdshadow_get_hw_state()
10095 return -EIO; in tpacpi_lcdshadow_init()
10100 lcdshadow_dev = drm_privacy_screen_register(&tpacpi_pdev->dev, in tpacpi_lcdshadow_init()
10118 mutex_lock(&lcdshadow_dev->lock); in lcdshadow_resume()
10119 lcdshadow_set_sw_state(lcdshadow_dev, lcdshadow_dev->sw_state); in lcdshadow_resume()
10120 mutex_unlock(&lcdshadow_dev->lock); in lcdshadow_resume()
10128 seq_printf(m, "status:\t\t%d\n", lcdshadow_dev->hw_state); in lcdshadow_read()
10138 int res, state = -EINVAL; in lcdshadow_write()
10141 return -ENODEV; in lcdshadow_write()
10150 return -EINVAL; in lcdshadow_write()
10152 mutex_lock(&lcdshadow_dev->lock); in lcdshadow_write()
10154 mutex_unlock(&lcdshadow_dev->lock); in lcdshadow_write()
10173 #define DYTC_CMD_QUERY 0 /* To get DYTC status - enable/revision */
10174 #define DYTC_QUERY_ENABLE_BIT 8 /* Bit 8 - 0 = disabled, 1 = enabled */
10175 #define DYTC_QUERY_SUBREV_BIT 16 /* Bits 16 - 27 - sub revision */
10176 #define DYTC_QUERY_REV_BIT 28 /* Bits 28 - 31 - revision */
10196 return -ENODEV; in dytc_command()
10199 return -EIO; in dytc_command()
10224 return -ENODEV; in palmsensor_get()
10226 return -EIO; in palmsensor_get()
10244 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "dytc_lapmode"); in lapsensor_refresh()
10260 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "palmsensor"); in palmsensor_refresh()
10306 return attr->mode; in proxsensor_attr_is_visible()
10320 /* If support isn't available for both devices return -ENODEV */ in tpacpi_proxsensor_init()
10321 if ((palm_err == -ENODEV) && (lap_err == -ENODEV)) in tpacpi_proxsensor_init()
10322 return -ENODEV; in tpacpi_proxsensor_init()
10324 if (palm_err && (palm_err != -ENODEV)) in tpacpi_proxsensor_init()
10326 if (lap_err && (lap_err != -ENODEV)) in tpacpi_proxsensor_init()
10333 .name = "proximity-sensor",
10349 #define DYTC_GET_FUNCTION_BIT 8 /* Bits 8-11 - function setting */
10350 #define DYTC_GET_MODE_BIT 12 /* Bits 12-15 - mode setting */
10352 #define DYTC_SET_FUNCTION_BIT 12 /* Bits 12-15 - function setting */
10353 #define DYTC_SET_MODE_BIT 16 /* Bits 16-19 - mode setting */
10354 #define DYTC_SET_VALID_BIT 20 /* Bit 20 - 1 = on, 0 = off */
10378 #define DYTC_ERR_MASK 0xF /* Bits 0-3 in cmd result are the error result */
10419 return -EINVAL; in convert_dytc_to_profile()
10430 return -EINVAL; in convert_dytc_to_profile()
10440 return -EOPNOTSUPP; in convert_dytc_to_profile()
10467 return -EOPNOTSUPP; in convert_profile_to_dytc()
10491 return -ENODEV; in dytc_control_amt()
10508 * Helper function - check if we are in CQL mode and if we are
10509 * - disable CQL,
10510 * - run the command
10511 * - enable CQL
10570 * Note we still need to disable CQL mode before hand and re-enable in dytc_profile_set()
10593 /* Success - update current profile */ in dytc_profile_set()
10633 err = -ENODEV; in dytc_profile_refresh()
10661 return -ENODEV; in tpacpi_dytc_profile_init()
10671 case -1: in tpacpi_dytc_profile_init()
10704 return -ENODEV; in tpacpi_dytc_profile_init()
10711 tpacpi_pprof = platform_profile_register(&tpacpi_pdev->dev, "thinkpad-acpi-profile", in tpacpi_dytc_profile_init()
10718 return -ENODEV; in tpacpi_dytc_profile_init()
10737 .name = "dytc-profile",
10759 {"fr-ch", 0x100c},
10779 return -ENODEV; in set_keyboard_lang_command()
10783 return -EIO; in set_keyboard_lang_command()
10795 return -ENODEV; in get_keyboard_lang()
10799 return -EIO; in get_keyboard_lang()
10803 * '(' and ')') keys which use layout dependent key-press emulation. in get_keyboard_lang()
10806 return -ENODEV; in get_keyboard_lang()
10863 dev_err(&tpacpi_pdev->dev, "Unknown Keyboard language. Ignoring\n"); in keyboard_lang_store()
10864 return -EINVAL; in keyboard_lang_store()
10867 tpacpi_disclose_usertask(attr->attr.name, in keyboard_lang_store()
10870 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang"); in keyboard_lang_store()
10884 return tp_features.kbd_lang ? attr->mode : 0; in kbdlang_attr_is_visible()
10921 return -ENODEV; in dprc_command()
10925 return -EIO; in dprc_command()
10933 return -ENODEV; in dprc_command()
10952 return -ENODEV; in get_wwan_antenna()
10968 return -ENODATA; in wwan_antenna_type_show()
10981 return has_antennatype ? attr->mode : 0; in dprc_attr_is_visible()
11009 * MAC Address Pass-through feature. In most cases, there are three
11031 return -ENODEV; in auxmac_init()
11035 if (obj->type != ACPI_TYPE_STRING || obj->string.length != AUXMAC_STRLEN) { in auxmac_init()
11036 pr_info("Invalid buffer for MAC address pass-through.\n"); in auxmac_init()
11040 if (obj->string.pointer[AUXMAC_BEGIN_MARKER] != '#' || in auxmac_init()
11041 obj->string.pointer[AUXMAC_END_MARKER] != '#') { in auxmac_init()
11042 pr_info("Invalid header for MAC address pass-through.\n"); in auxmac_init()
11046 if (strncmp(obj->string.pointer + AUXMAC_START, "XXXXXXXXXXXX", AUXMAC_LEN) != 0) in auxmac_init()
11047 strscpy(auxmac, obj->string.pointer + AUXMAC_START, sizeof(auxmac)); in auxmac_init()
11069 return auxmac[0] == 0 ? 0 : attr->mode; in auxmac_attr_is_visible()
11082 /* --------------------------------------------------------------------- */
11115 return attr->mode; in tpacpi_attr_is_visible()
11245 if (!atomic_add_unless(&dytc_ignore_event, -1, 0)) in tpacpi_driver_event()
11254 mutex_lock(&lcdshadow_dev->lock); in tpacpi_driver_event()
11255 old_hw_state = lcdshadow_dev->hw_state; in tpacpi_driver_event()
11257 changed = lcdshadow_dev->hw_state != old_hw_state; in tpacpi_driver_event()
11258 mutex_unlock(&lcdshadow_dev->lock); in tpacpi_driver_event()
11298 /* --------------------------------------------------------------------- */
11320 dbg_printk(TPACPI_DBG_EXIT, "removing %s\n", ibm->name); in ibm_exit()
11322 list_del_init(&ibm->all_drivers); in ibm_exit()
11324 if (ibm->flags.acpi_notify_installed) { in ibm_exit()
11326 "%s: acpi_remove_notify_handler\n", ibm->name); in ibm_exit()
11327 BUG_ON(!ibm->acpi); in ibm_exit()
11328 acpi_remove_notify_handler(*ibm->acpi->handle, in ibm_exit()
11329 ibm->acpi->type, in ibm_exit()
11331 ibm->flags.acpi_notify_installed = 0; in ibm_exit()
11334 if (ibm->flags.proc_created) { in ibm_exit()
11336 "%s: remove_proc_entry\n", ibm->name); in ibm_exit()
11337 remove_proc_entry(ibm->name, proc_dir); in ibm_exit()
11338 ibm->flags.proc_created = 0; in ibm_exit()
11341 if (ibm->flags.acpi_driver_registered) { in ibm_exit()
11343 "%s: acpi_bus_unregister_driver\n", ibm->name); in ibm_exit()
11344 BUG_ON(!ibm->acpi); in ibm_exit()
11345 acpi_bus_unregister_driver(ibm->acpi->driver); in ibm_exit()
11346 kfree(ibm->acpi->driver); in ibm_exit()
11347 ibm->acpi->driver = NULL; in ibm_exit()
11348 ibm->flags.acpi_driver_registered = 0; in ibm_exit()
11351 if (ibm->flags.init_called && ibm->exit) { in ibm_exit()
11352 ibm->exit(); in ibm_exit()
11353 ibm->flags.init_called = 0; in ibm_exit()
11356 dbg_printk(TPACPI_DBG_INIT, "finished removing %s\n", ibm->name); in ibm_exit()
11362 struct ibm_struct *ibm = iibm->data; in ibm_init()
11367 INIT_LIST_HEAD(&ibm->all_drivers); in ibm_init()
11369 if (ibm->flags.experimental && !experimental) in ibm_init()
11373 "probing for %s\n", ibm->name); in ibm_init()
11375 if (iibm->init) { in ibm_init()
11376 ret = iibm->init(iibm); in ibm_init()
11377 if (ret > 0 || ret == -ENODEV) in ibm_init()
11382 ibm->flags.init_called = 1; in ibm_init()
11385 if (ibm->acpi) { in ibm_init()
11386 if (ibm->acpi->hid) { in ibm_init()
11392 if (ibm->acpi->notify) { in ibm_init()
11394 if (ret == -ENODEV) { in ibm_init()
11396 ibm->name); in ibm_init()
11406 "%s installed\n", ibm->name); in ibm_init()
11408 if (ibm->read) { in ibm_init()
11409 umode_t mode = iibm->base_procfs_mode; in ibm_init()
11413 if (ibm->write) in ibm_init()
11415 entry = proc_create_data(ibm->name, mode, proc_dir, in ibm_init()
11418 pr_err("unable to create proc entry %s\n", ibm->name); in ibm_init()
11419 ret = -ENODEV; in ibm_init()
11422 ibm->flags.proc_created = 1; in ibm_init()
11425 list_add_tail(&ibm->all_drivers, &tpacpi_all_drivers); in ibm_init()
11432 ibm->name, ret); in ibm_init()
11455 * Ancient 570/600 and -SL lacks (#.##c) in tpacpi_parse_fw_id()
11483 * ---------------------------------------------------- in find_new_ec_fwstr()
11496 if (dm->type != 140 || dm->length < 0x0F || in find_new_ec_fwstr()
11507 /* returns 0 - probe ok, or < 0 - probe error.
11509 * On error, kfree() cleanup on tp->* is not performed, caller must do it */
11519 return -EINVAL; in get_thinkpad_model_data()
11524 tp->vendor = PCI_VENDOR_ID_IBM; in get_thinkpad_model_data()
11526 tp->vendor = PCI_VENDOR_ID_LENOVO; in get_thinkpad_model_data()
11528 tp->vendor = PCI_VENDOR_ID_LENOVO; in get_thinkpad_model_data()
11533 tp->bios_version_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11534 if (s && !tp->bios_version_str) in get_thinkpad_model_data()
11535 return -ENOMEM; in get_thinkpad_model_data()
11538 t = tpacpi_parse_fw_id(tp->bios_version_str, in get_thinkpad_model_data()
11539 &tp->bios_model, &tp->bios_release); in get_thinkpad_model_data()
11546 * up-to-date BIOS or they will not be detected. in get_thinkpad_model_data()
11551 if (sscanf(dev->name, in get_thinkpad_model_data()
11552 "IBM ThinkPad Embedded Controller -[%17c", in get_thinkpad_model_data()
11554 ec_fw_string[sizeof(ec_fw_string) - 1] = 0; in get_thinkpad_model_data()
11565 tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL); in get_thinkpad_model_data()
11566 if (!tp->ec_version_str) in get_thinkpad_model_data()
11567 return -ENOMEM; in get_thinkpad_model_data()
11570 &tp->ec_model, &tp->ec_release); in get_thinkpad_model_data()
11580 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11581 if (!tp->model_str) in get_thinkpad_model_data()
11582 return -ENOMEM; in get_thinkpad_model_data()
11586 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11587 if (!tp->model_str) in get_thinkpad_model_data()
11588 return -ENOMEM; in get_thinkpad_model_data()
11593 tp->nummodel_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11594 if (s && !tp->nummodel_str) in get_thinkpad_model_data()
11595 return -ENOMEM; in get_thinkpad_model_data()
11605 return -ENODEV; in probe_for_thinkpad()
11609 return -ENODEV; in probe_for_thinkpad()
11612 * Non-ancient models have better DMI tagging, but very old models in probe_for_thinkpad()
11624 return -ENODEV; in probe_for_thinkpad()
11628 return -ENODEV; in probe_for_thinkpad()
11761 if (!kp || !kp->name || !val) in set_ibm_param()
11762 return -EINVAL; in set_ibm_param()
11766 if (!ibm || !ibm->name) in set_ibm_param()
11769 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { in set_ibm_param()
11770 if (strlen(val) > sizeof(ibms_init[i].param) - 1) in set_ibm_param()
11771 return -ENOSPC; in set_ibm_param()
11777 return -EINVAL; in set_ibm_param()
11782 "Enables experimental features when non-zero");
11785 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
11789 "Attempts to load the driver even on a mis-identified ThinkPad when true");
11832 …MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command at module load, see documentatio…
11872 MODULE_PARM_DESC(profile_force, "Force profile mode. -1=off, 1=MMC, 2=PSC");
11913 ret = devm_mutex_init(&pdev->dev, &tpacpi_inputdev_send_mutex); in tpacpi_pdriver_probe()
11917 tpacpi_inputdev = devm_input_allocate_device(&pdev->dev); in tpacpi_pdriver_probe()
11919 return -ENOMEM; in tpacpi_pdriver_probe()
11921 tpacpi_inputdev->name = "ThinkPad Extra Buttons"; in tpacpi_pdriver_probe()
11922 tpacpi_inputdev->phys = TPACPI_DRVR_NAME "/input0"; in tpacpi_pdriver_probe()
11923 tpacpi_inputdev->id.bustype = BUS_HOST; in tpacpi_pdriver_probe()
11924 tpacpi_inputdev->id.vendor = thinkpad_id.vendor; in tpacpi_pdriver_probe()
11925 tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT; in tpacpi_pdriver_probe()
11926 tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION; in tpacpi_pdriver_probe()
11927 tpacpi_inputdev->dev.parent = &tpacpi_pdev->dev; in tpacpi_pdriver_probe()
11936 ret = ibms_init[i].data->write(ibms_init[i].param); in tpacpi_pdriver_probe()
11943 ret = devm_add_action_or_reset(&pdev->dev, tpacpi_subdrivers_release, NULL); in tpacpi_pdriver_probe()
11956 tpacpi_hwmon = devm_hwmon_device_register_with_groups(&pdev->dev, TPACPI_NAME, in tpacpi_hwmon_pdriver_probe()
11972 /* Driver-level probe */ in thinkpad_acpi_module_init()
12012 return -ENOMEM; in thinkpad_acpi_module_init()
12019 return -ENODEV; in thinkpad_acpi_module_init()
12024 tp_features.quirks = dmi_id->driver_data; in thinkpad_acpi_module_init()