Lines Matching +full:powered +full:- +full:remotely

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>
120 /* Misc NVRAM-related */
138 TP_ACPI_WGSV_PWR_ON_ON_RESUME = 0x02, /* Resume WWAN powered on */
139 TP_ACPI_WGSV_PWR_OFF_ON_RESUME = 0x03, /* Resume WWAN powered off */
159 /* Hotkey-related */
178 /* Auto-sleep after eject request */
195 /* User-interface events */
207 /* Key-related user-interface events */
225 /* AC-related events */
228 /* Further user-interface events */
243 #define TPACPI_URL "http://ibm-acpi.sf.net/"
244 #define TPACPI_MAIL "ibm-acpi-devel@lists.sourceforge.net"
271 * Driver-wide structs and misc. variables
368 char *ec_version_str; /* Something like 1ZHT51WW-1.04a */
376 char *nummodel_str; /* 9384A9C for a 9384-A9C model */
457 * two or three characters from the set [0-9A-Z], i.e. base 36.
509 * tpacpi_check_quirks() - search BIOS/EC version on a list
526 if ((qlist->vendor == thinkpad_id.vendor || in tpacpi_check_quirks()
527 qlist->vendor == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
528 (qlist->bios == thinkpad_id.bios_model || in tpacpi_check_quirks()
529 qlist->bios == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
530 (qlist->ec == thinkpad_id.ec_model || in tpacpi_check_quirks()
531 qlist->ec == TPACPI_MATCH_ANY)) in tpacpi_check_quirks()
532 return qlist->quirks; in tpacpi_check_quirks()
534 qlist_size--; in tpacpi_check_quirks()
576 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
702 return -ENXIO; in issue_thinkpad_cmos_command()
705 return -EIO; in issue_thinkpad_cmos_command()
794 if (!ibm || !ibm->acpi || !ibm->acpi->notify) in dispatch_acpi_notify()
797 ibm->acpi->notify(ibm, event); in dispatch_acpi_notify()
804 BUG_ON(!ibm->acpi); in setup_acpi_notify()
806 if (!*ibm->acpi->handle) in setup_acpi_notify()
810 "setting up ACPI notify for %s\n", ibm->name); in setup_acpi_notify()
812 ibm->acpi->device = acpi_fetch_acpi_dev(*ibm->acpi->handle); in setup_acpi_notify()
813 if (!ibm->acpi->device) { in setup_acpi_notify()
814 pr_err("acpi_fetch_acpi_dev(%s) failed\n", ibm->name); in setup_acpi_notify()
815 return -ENODEV; in setup_acpi_notify()
818 ibm->acpi->device->driver_data = ibm; in setup_acpi_notify()
819 sprintf(acpi_device_class(ibm->acpi->device), "%s/%s", in setup_acpi_notify()
821 ibm->name); in setup_acpi_notify()
823 status = acpi_install_notify_handler(*ibm->acpi->handle, in setup_acpi_notify()
824 ibm->acpi->type, dispatch_acpi_notify, ibm); in setup_acpi_notify()
828 ibm->name); in setup_acpi_notify()
831 ibm->name, acpi_format_exception(status)); in setup_acpi_notify()
833 return -ENODEV; in setup_acpi_notify()
835 ibm->flags.acpi_notify_installed = 1; in setup_acpi_notify()
849 "registering %s as an ACPI driver\n", ibm->name); in register_tpacpi_subdriver()
851 BUG_ON(!ibm->acpi); in register_tpacpi_subdriver()
853 ibm->acpi->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL); in register_tpacpi_subdriver()
854 if (!ibm->acpi->driver) { in register_tpacpi_subdriver()
855 pr_err("failed to allocate memory for ibm->acpi->driver\n"); in register_tpacpi_subdriver()
856 return -ENOMEM; in register_tpacpi_subdriver()
859 sprintf(ibm->acpi->driver->name, "%s_%s", TPACPI_NAME, ibm->name); in register_tpacpi_subdriver()
860 ibm->acpi->driver->ids = ibm->acpi->hid; in register_tpacpi_subdriver()
862 ibm->acpi->driver->ops.add = &tpacpi_device_add; in register_tpacpi_subdriver()
864 rc = acpi_bus_register_driver(ibm->acpi->driver); in register_tpacpi_subdriver()
867 ibm->name, rc); in register_tpacpi_subdriver()
868 kfree(ibm->acpi->driver); in register_tpacpi_subdriver()
869 ibm->acpi->driver = NULL; in register_tpacpi_subdriver()
871 ibm->flags.acpi_driver_registered = 1; in register_tpacpi_subdriver()
887 struct ibm_struct *ibm = m->private; in dispatch_proc_show()
889 if (!ibm || !ibm->read) in dispatch_proc_show()
890 return -EINVAL; in dispatch_proc_show()
891 return ibm->read(m); in dispatch_proc_show()
907 if (!ibm || !ibm->write) in dispatch_proc_write()
908 return -EINVAL; in dispatch_proc_write()
909 if (count > PAGE_SIZE - 1) in dispatch_proc_write()
910 return -EINVAL; in dispatch_proc_write()
915 ret = ibm->write(kernbuf); in dispatch_proc_write()
955 if (ibm->suspend) in tpacpi_suspend_handler()
956 (ibm->suspend)(); in tpacpi_suspend_handler()
969 if (ibm->resume) in tpacpi_resume_handler()
970 (ibm->resume)(); in tpacpi_resume_handler()
987 if (ibm->shutdown) in tpacpi_shutdown_handler()
988 (ibm->shutdown)(); in tpacpi_shutdown_handler()
1004 return -EINVAL; in parse_strtoul()
1028 * ThinkPad-ACPI firmware handling model:
1030 * WLSW (master wireless switch) is event-driven, and is common to all
1031 * firmware-controlled radios. It cannot be controlled, just monitored,
1034 * The kernel, a masked-off hotkey, and WLSW can change the radio state
1038 * masked-off hotkeys are used.
1067 /* ThinkPad-ACPI rfkill subdriver */
1088 return -ENODEV; in tpacpi_rfk_update_swstate()
1090 status = (tp_rfk->ops->get_status)(); in tpacpi_rfk_update_swstate()
1094 rfkill_set_sw_state(tp_rfk->rfkill, in tpacpi_rfk_update_swstate()
1101 * Sync the HW-blocking state of all rfkill switches,
1112 if (rfkill_set_hw_state(tp_rfk->rfkill, in tpacpi_rfk_update_hwblock_state()
1114 /* ignore -- we track sw block */ in tpacpi_rfk_update_hwblock_state()
1149 res = (tp_rfk->ops->set_status)(blocked ? in tpacpi_rfk_hook_set_block()
1178 atp_rfk->rfkill = rfkill_alloc(name, in tpacpi_new_rfkill()
1179 &tpacpi_pdev->dev, in tpacpi_new_rfkill()
1183 if (!atp_rfk || !atp_rfk->rfkill) { in tpacpi_new_rfkill()
1186 return -ENOMEM; in tpacpi_new_rfkill()
1189 atp_rfk->id = id; in tpacpi_new_rfkill()
1190 atp_rfk->ops = tp_rfkops; in tpacpi_new_rfkill()
1192 sw_status = (tp_rfkops->get_status)(); in tpacpi_new_rfkill()
1201 rfkill_init_sw_state(atp_rfk->rfkill, sw_state); in tpacpi_new_rfkill()
1205 rfkill_set_hw_state(atp_rfk->rfkill, hw_state); in tpacpi_new_rfkill()
1207 res = rfkill_register(atp_rfk->rfkill); in tpacpi_new_rfkill()
1210 rfkill_destroy(atp_rfk->rfkill); in tpacpi_new_rfkill()
1230 rfkill_unregister(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1231 rfkill_destroy(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1243 /* sysfs <radio> enable ------------------------------------------------ */
1250 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_show()
1272 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_store()
1275 return -EINVAL; in tpacpi_rfk_sysfs_enable_store()
1277 tpacpi_disclose_usertask(attr->attr.name, "set to %ld\n", t); in tpacpi_rfk_sysfs_enable_store()
1281 return -EPERM; in tpacpi_rfk_sysfs_enable_store()
1283 res = tpacpi_rfkill_switches[id]->ops->set_status((!!t) ? in tpacpi_rfk_sysfs_enable_store()
1290 /* procfs -------------------------------------------------------------- */
1318 int status = -1; in tpacpi_rfk_procfs_write()
1322 return -ENODEV; in tpacpi_rfk_procfs_write()
1330 return -EINVAL; in tpacpi_rfk_procfs_write()
1333 if (status != -1) { in tpacpi_rfk_procfs_write()
1337 res = (tpacpi_rfkill_switches[id]->ops->set_status)(status); in tpacpi_rfk_procfs_write()
1345 * thinkpad-acpi driver attributes
1348 /* interface_version --------------------------------------------------- */
1355 /* debug_level --------------------------------------------------------- */
1367 return -EINVAL; in debug_level_store()
1375 /* version ------------------------------------------------------------- */
1383 /* --------------------------------------------------------------------- */
1387 /* wlsw_emulstate ------------------------------------------------------ */
1399 return -EINVAL; in wlsw_emulstate_store()
1410 /* bluetooth_emulstate ------------------------------------------------- */
1422 return -EINVAL; in bluetooth_emulstate_store()
1430 /* wwan_emulstate ------------------------------------------------- */
1442 return -EINVAL; in wwan_emulstate_store()
1450 /* uwb_emulstate ------------------------------------------------- */
1462 return -EINVAL; in uwb_emulstate_store()
1548 /* Numeric models ------------------ */
1560 /* A-series ------------------------- */
1574 /* G-series ------------------------- */
1579 /* R-series, T-series --------------- */
1609 /* X-series ------------------------- */
1622 /* (0) - older versions lack DMI EC fw string and functionality */
1623 /* (1) - older versions known to lack functionality */
1679 * thinkpad-acpi metadata subdriver
1714 * Unlike other classes, hotkey-class events have mask/unmask control on
1715 * non-ancient firmware. However, how it behaves changes a lot with the
1939 return -ENODEV; in hotkey_get_wlsw()
1948 return -EIO; in hotkey_get_wlsw()
2042 return -EIO; in hotkey_get_tablet_mode()
2048 return -EIO; in hotkey_get_tablet_mode()
2073 return -EIO; in hotkey_mask_get()
2081 /* sync userspace-visible mask */ in hotkey_mask_get()
2119 rc = -EIO; in hotkey_mask_set()
2160 …pr_notice("please consider using the driver defaults, and refer to up-to-date thinkpad-acpi docume… in hotkey_user_mask_set()
2209 return -EIO; in hotkey_status_get()
2217 return -EIO; in hotkey_status_set()
2281 n->thinkpad_toggle = !!(d & TP_NVRAM_MASK_HKT_THINKPAD); in hotkey_read_nvram()
2282 n->zoom_toggle = !!(d & TP_NVRAM_MASK_HKT_ZOOM); in hotkey_read_nvram()
2283 n->display_toggle = !!(d & TP_NVRAM_MASK_HKT_DISPLAY); in hotkey_read_nvram()
2284 n->hibernate_toggle = !!(d & TP_NVRAM_MASK_HKT_HIBERNATE); in hotkey_read_nvram()
2288 n->thinklight_toggle = !!(d & TP_NVRAM_MASK_THINKLIGHT); in hotkey_read_nvram()
2292 n->displayexp_toggle = in hotkey_read_nvram()
2297 n->brightness_level = (d & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) in hotkey_read_nvram()
2299 n->brightness_toggle = in hotkey_read_nvram()
2304 n->volume_level = (d & TP_NVRAM_MASK_LEVEL_VOLUME) in hotkey_read_nvram()
2306 n->mute = !!(d & TP_NVRAM_MASK_MUTE); in hotkey_read_nvram()
2307 n->volume_toggle = !!(d & TP_NVRAM_MASK_HKT_VOLUME); in hotkey_read_nvram()
2314 oldn->__member != newn->__member) \
2332 i--; in issue_volchange()
2348 i--; in issue_brightnesschange()
2374 * - Pressing MUTE issues mute hotkey message, even when already mute in hotkey_compare_and_issue_event()
2375 * - Pressing Volume up/down issues volume up/down hotkey messages, in hotkey_compare_and_issue_event()
2377 * - The act of unmuting issues volume up/down notification, in hotkey_compare_and_issue_event()
2387 if (newn->mute) { in hotkey_compare_and_issue_event()
2389 if (!oldn->mute || in hotkey_compare_and_issue_event()
2390 oldn->volume_toggle != newn->volume_toggle || in hotkey_compare_and_issue_event()
2391 oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2394 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2400 if (oldn->mute) { in hotkey_compare_and_issue_event()
2404 if (oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2405 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2407 } else if (oldn->volume_toggle != newn->volume_toggle) { in hotkey_compare_and_issue_event()
2409 if (newn->volume_level == 0) in hotkey_compare_and_issue_event()
2411 else if (newn->volume_level >= TP_NVRAM_LEVEL_VOLUME_MAX) in hotkey_compare_and_issue_event()
2417 if (oldn->brightness_level != newn->brightness_level) { in hotkey_compare_and_issue_event()
2418 issue_brightnesschange(oldn->brightness_level, in hotkey_compare_and_issue_event()
2419 newn->brightness_level, event_mask); in hotkey_compare_and_issue_event()
2420 } else if (oldn->brightness_toggle != newn->brightness_toggle) { in hotkey_compare_and_issue_event()
2422 if (newn->brightness_level == 0) in hotkey_compare_and_issue_event()
2424 else if (newn->brightness_level >= bright_maxlvl in hotkey_compare_and_issue_event()
2437 * most of them are edge-based. We only issue those requested by
2531 (poll_user_mask && tpacpi_inputdev->users > 0))) { in hotkey_poll_setup()
2587 return -EBUSY; in hotkey_inputdev_open()
2592 return -EBUSY; in hotkey_inputdev_open()
2603 /* sysfs hotkey enable ------------------------------------------------- */
2630 return -EINVAL; in hotkey_enable_store()
2633 return -EPERM; in hotkey_enable_store()
2640 /* sysfs hotkey mask --------------------------------------------------- */
2656 return -EINVAL; in hotkey_mask_store()
2659 return -ERESTARTSYS; in hotkey_mask_store()
2676 /* sysfs hotkey bios_enabled ------------------------------------------- */
2686 /* sysfs hotkey bios_mask ---------------------------------------------- */
2698 /* sysfs hotkey all_mask ----------------------------------------------- */
2709 /* sysfs hotkey all_mask ----------------------------------------------- */
2720 /* sysfs hotkey recommended_mask --------------------------------------- */
2734 /* sysfs hotkey hotkey_source_mask ------------------------------------- */
2752 return -EINVAL; in hotkey_source_mask_store()
2755 return -ERESTARTSYS; in hotkey_source_mask_store()
2785 /* sysfs hotkey hotkey_poll_freq --------------------------------------- */
2800 return -EINVAL; in hotkey_poll_freq_store()
2803 return -ERESTARTSYS; in hotkey_poll_freq_store()
2819 /* sysfs hotkey radio_sw (pollable) ------------------------------------ */
2841 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_radio_sw_notify_change()
2845 /* sysfs hotkey tablet mode (pollable) --------------------------------- */
2863 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_tablet_mode_notify_change()
2867 /* sysfs wakeup reason (pollable) -------------------------------------- */
2879 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_reason_notify_change()
2883 /* sysfs wakeup hotunplug_complete (pollable) -------------------------- */
2896 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_hotunplug_complete_notify_change()
2900 /* sysfs adaptive kbd mode --------------------------------------------- */
2934 return -EINVAL; in adaptive_kbd_mode_store()
2950 return tp_features.has_adaptive_kbd ? attr->mode : 0; in hadaptive_kbd_attr_is_visible()
2958 /* --------------------------------------------------------------------- */
2990 return attr->mode; in hotkey_attr_is_visible()
3018 /* Sync hw blocking state first if it is hw-blocked */ in tpacpi_send_radiosw_update()
3022 /* Sync hw blocking state last if it is hw-unblocked */ in tpacpi_send_radiosw_update()
3066 tpacpi_inputdev->keybit); in hotkey_unmap()
3150 * firmware at driver load time, which means the firm- in hotkey_init()
3154 * 2. You must be subscribed to the linux-thinkpad and in hotkey_init()
3155 * ibm-acpi-devel mailing lists, and you should read the in hotkey_init()
3158 * know the past history of problems with the thinkpad- in hotkey_init()
3162 * 3. Do not send thinkpad-acpi specific patches directly to in hotkey_init()
3163 * for merging, *ever*. Send them to the linux-acpi in hotkey_init()
3165 * through acpi-test and the ACPI maintainer. in hotkey_init()
3168 * Ask the thinkpad-acpi maintainer to do it, instead. in hotkey_init()
3200 * the built-in *extra* mixer. Never map it to control in hotkey_init()
3241 /* These should be enabled --only-- when ACPI video in hotkey_init()
3253 * react to it and reprograms the built-in *extra* mixer. in hotkey_init()
3257 * these over the regular keyboard, so these are no-ops, in hotkey_init()
3372 BUG_ON(tpacpi_inputdev->open != NULL || in hotkey_init()
3373 tpacpi_inputdev->close != NULL); in hotkey_init()
3390 return -ENODEV; in hotkey_init()
3398 A30, R30, R31, T20-22, X20-21, X22-24. Detected by checking in hotkey_init()
3417 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3434 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3514 return -ENOMEM; in hotkey_init()
3518 tpacpi_inputdev->keycodesize = TPACPI_HOTKEY_MAP_TYPESIZE; in hotkey_init()
3519 tpacpi_inputdev->keycodemax = TPACPI_HOTKEY_MAP_LEN; in hotkey_init()
3520 tpacpi_inputdev->keycode = hotkey_keycode_map; in hotkey_init()
3547 pr_notice("Disabling thinkpad-acpi brightness events by default...\n"); in hotkey_init()
3551 * for userspace to do something even remotely sane */ in hotkey_init()
3581 if (res < 0 && res != -ENXIO) { in hotkey_init()
3591 tpacpi_inputdev->open = &hotkey_inputdev_open; in hotkey_init()
3592 tpacpi_inputdev->close = &hotkey_inputdev_close; in hotkey_init()
3600 * mode, Web conference mode, Function mode and Lay-flat mode.
3629 return -EIO; in adaptive_keyboard_get_mode()
3639 return -EINVAL; in adaptive_keyboard_set_mode()
3643 return -EIO; in adaptive_keyboard_set_mode()
3652 size_t max_mode = ARRAY_SIZE(adaptive_keyboard_modes) - 1; in adaptive_keyboard_get_next_mode()
3706 TP_ACPI_HOTKEYSCAN_EXTENDED_START - in adaptive_keyboard_hotkey_notify_hotkey()
3712 keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY + in adaptive_keyboard_hotkey_notify_hotkey()
3744 scancode = (hkey & 0xfff) - (0x300 - TP_ACPI_HOTKEYSCAN_EXTENDED_START); in hotkey_notify_extended_hotkey()
3758 /* 0x1000-0x1FFF: key presses */ in hotkey_notify_hotkey()
3773 scancode--; in hotkey_notify_hotkey()
3798 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify_wakeup()
3818 /* how to auto-heal: */ in hotkey_notify_wakeup()
3828 pr_info("woke up due to a hot-unplug request...\n"); in hotkey_notify_wakeup()
3838 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify_dockevent()
3859 * duplicates from intel-vbtn, which already emits SW_TABLET_MODE events in hotkey_notify_dockevent()
3866 * https://lore.kernel.org/platform-driver-x86/38cb8265-1e30-d547-9e12-b4ae290be737@a-kobel.de/ in hotkey_notify_dockevent()
3883 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify_usrevent()
3892 case TP_HKEY_EV_TABLET_TABLET: /* X41t-X61t: tablet mode */ in hotkey_notify_usrevent()
3893 case TP_HKEY_EV_TABLET_NOTEBOOK: /* X41t-X61t: normal mode */ in hotkey_notify_usrevent()
3918 /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */ in hotkey_notify_6xxx()
3930 /* Thermal event - pass on to event handler */ in hotkey_notify_6xxx()
3989 /* palm detected - pass on to event handler */ in hotkey_notify_6xxx()
4013 ibm->acpi->device->pnp.device_class, in hotkey_notify()
4014 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4035 /* 0x1000-0x1FFF: key presses */ in hotkey_notify()
4040 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify()
4045 /* 0x3000-0x3FFF: bay-related wakeups */ in hotkey_notify()
4062 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify()
4067 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify()
4072 /* 0x6000-0x6FFF: thermal alarms/notices and in hotkey_notify()
4078 /* 0x7000-0x7FFF: misc */ in hotkey_notify()
4099 ibm->acpi->device->pnp.device_class, in hotkey_notify()
4100 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4147 /* procfs -------------------------------------------------------------- */
4158 return -ERESTARTSYS; in hotkey_read()
4193 return -ENODEV; in hotkey_write()
4196 return -ERESTARTSYS; in hotkey_write()
4206 res = -EPERM; in hotkey_write()
4215 res = -EINVAL; in hotkey_write()
4270 TP_ACPI_BLTH_GET_PWR_ON_RESUME = 0x01, /* Get power-on-resume state */
4271 TP_ACPI_BLTH_PWR_ON_ON_RESUME = 0x02, /* Resume powered on */
4272 TP_ACPI_BLTH_PWR_OFF_ON_RESUME = 0x03, /* Resume powered off */
4289 return -EIO; in bluetooth_get_status()
4316 return -EIO; in bluetooth_set_status()
4321 /* sysfs bluetooth enable ---------------------------------------------- */
4340 /* --------------------------------------------------------------------- */
4350 return tp_features.bluetooth ? attr->mode : 0; in bluetooth_attr_is_visible()
4398 .ident = "ThinkPad A285 - 20MW",
4406 .ident = "ThinkPad A285 - 20MX",
4414 .ident = "ThinkPad A485 - 20MU",
4422 .ident = "ThinkPad A485 - 20MV",
4446 if (tp_features.quirks && tp_features.quirks->btusb_bug && in have_bt_fwbug()
4466 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ in bluetooth_init()
4490 return -ENODEV; in bluetooth_init()
4500 /* procfs -------------------------------------------------------------- */
4544 return -EIO; in wan_get_status()
4571 return -EIO; in wan_set_status()
4576 /* sysfs wan enable ---------------------------------------------------- */
4596 /* --------------------------------------------------------------------- */
4606 return tp_features.wan ? attr->mode : 0; in wan_attr_is_visible()
4669 return -ENODEV; in wan_init()
4679 /* procfs -------------------------------------------------------------- */
4721 return -EIO; in uwb_get_status()
4747 return -EIO; in uwb_set_status()
4752 /* --------------------------------------------------------------------- */
4797 return -ENODEV; in uwb_init()
4890 return (video_supported != TPACPI_VIDEO_NONE) ? 0 : -ENODEV; in video_init()
4910 return -EIO; in video_outputsw_get()
4915 return -EIO; in video_outputsw_get()
4919 return -EIO; in video_outputsw_get()
4926 return -EIO; in video_outputsw_get()
4932 return -EIO; in video_outputsw_get()
4936 return -EIO; in video_outputsw_get()
4941 return -ENOSYS; in video_outputsw_get()
4970 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_set()
4971 return -EIO; in video_outputsw_set()
4979 return -ENOSYS; in video_outputsw_set()
4982 return (res) ? 0 : -EIO; in video_outputsw_set()
4992 return -EIO; in video_autosw_get()
4997 return -EIO; in video_autosw_get()
5000 return -ENOSYS; in video_autosw_get()
5009 return -EIO; in video_autosw_set()
5036 return -ENOSYS; in video_outputsw_cycle()
5039 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_cycle()
5040 return -EIO; in video_outputsw_cycle()
5043 return (res) ? 0 : -EIO; in video_outputsw_cycle()
5051 0 : -EIO; in video_expand_toggle()
5054 0 : -EIO; in video_expand_toggle()
5057 0 : -EIO; in video_expand_toggle()
5059 return -ENOSYS; in video_expand_toggle()
5075 return -EPERM; in video_read()
5108 return -ENODEV; in video_write()
5112 return -EPERM; in video_write()
5149 return -EINVAL; in video_write()
5185 return -ENXIO; in kbdlight_set_level()
5190 ret = -EIO; in kbdlight_set_level()
5204 return -ENXIO; in kbdlight_get_level()
5207 return -EIO; in kbdlight_get_level()
5242 * b010100000010000000XX - ThinkPad X1 Carbon 3rd in kbdlight_is_supported()
5243 * b110100010010000000XX - ThinkPad x230 in kbdlight_is_supported()
5244 * b010100000010000000XX - ThinkPad x240 in kbdlight_is_supported()
5245 * b010100000010000000XX - ThinkPad W541 in kbdlight_is_supported()
5249 * b10100001000000000000 - ThinkPad x230 in kbdlight_is_supported()
5250 * b10110001000000000000 - ThinkPad E430 in kbdlight_is_supported()
5251 * b00000000000000000000 - ThinkPad E450 in kbdlight_is_supported()
5298 return -ENODEV; in kbdlight_init()
5304 rc = led_classdev_register(&tpacpi_pdev->dev, in kbdlight_init()
5329 if (ret == 0 && !(led_cdev->flags & LED_SUSPENDED)) in kbdlight_set_level_and_update()
5330 led_cdev->brightness = level; in kbdlight_set_level_and_update()
5356 int res, level = -EINVAL; in kbdlight_write()
5359 return -ENODEV; in kbdlight_write()
5368 return -EINVAL; in kbdlight_write()
5406 TPACPI_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
5415 return -EIO; in light_get_status()
5419 return -ENXIO; in light_get_status()
5436 return (rc) ? 0 : -EIO; in light_set_status()
5439 return -ENXIO; in light_set_status()
5489 return -ENODEV; in light_init()
5491 rc = led_classdev_register(&tpacpi_pdev->dev, in light_init()
5535 return -ENODEV; in light_write()
5543 return -EINVAL; in light_write()
5560 /* sysfs cmos_command -------------------------------------------------- */
5569 return -EINVAL; in cmos_command_store()
5585 return cmos_handle ? attr->mode : 0; in cmos_attr_is_visible()
5593 /* --------------------------------------------------------------------- */
5605 return cmos_handle ? 0 : -ENODEV; in cmos_init()
5611 R30, R31, T20-22, X20-21 */ in cmos_read()
5616 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n"); in cmos_read()
5632 return -EINVAL; in cmos_write()
5655 TPACPI_LED_OLD, /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
5708 return -EIO; in led_get_status()
5717 return -ENXIO; in led_get_status()
5736 return -EINVAL; in led_set_status()
5738 return -EPERM; in led_set_status()
5741 return -EIO; in led_set_status()
5744 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */ in led_set_status()
5746 return -EINVAL; in led_set_status()
5748 return -EPERM; in led_set_status()
5760 return -EINVAL; in led_set_status()
5762 return -EPERM; in led_set_status()
5765 return -EIO; in led_set_status()
5768 return -ENXIO; in led_set_status()
5786 else if (tpacpi_led_state_cache[data->led] != TPACPI_LED_BLINK) in led_sysfs_set()
5791 return led_set_status(data->led, new_state); in led_sysfs_set()
5806 return -EINVAL; in led_sysfs_blink_set()
5808 return led_set_status(data->led, TPACPI_LED_BLINK); in led_sysfs_blink_set()
5818 rc = led_get_status(data->led); in led_sysfs_get()
5853 return led_classdev_register(&tpacpi_pdev->dev, &tpacpi_leds[led].led_classdev); in tpacpi_init_led()
5881 /* (1) - may have excess leds enabled on MSB */
5911 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ in led_init_detect_mode()
5951 return -ENODEV; in led_init()
5957 return -ENOMEM; in led_init()
5961 tpacpi_leds[i].led = -1; in led_init()
5994 return -EIO; in led_read()
5999 seq_printf(m, "commands:\t<led> on, <led> off, <led> blink (<led> is 0-15)\n"); in led_read()
6011 return -ENODEV; in led_write()
6015 return -EINVAL; in led_write()
6017 if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1)) in led_write()
6018 return -ENODEV; in led_write()
6021 return -ENODEV; in led_write()
6030 return -EINVAL; in led_write()
6058 TPACPI_Q_IBM('I', 'U', TPACPI_BEEP_Q1), /* 570E - unverified */
6077 return (beep_handle) ? 0 : -ENODEV; in beep_init()
6086 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n"); in beep_read()
6098 return -ENODEV; in beep_write()
6105 return -EINVAL; in beep_write()
6109 return -EIO; in beep_write()
6113 return -EIO; in beep_write()
6132 TPACPI_THERMAL_ACPI_TMP07, /* Use ACPI TMP0-7 */
6133 TPACPI_THERMAL_ACPI_UPDT, /* Use ACPI TMP0-7 with UPDT */
6142 TP_EC_THERMAL_TMP_NA = -128, /* ACPI EC sensor not available */
6144 TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */
6156 /* idx is zero-based */
6170 idx -= 8; in thermal_get_sensor()
6177 return -EIO; in thermal_get_sensor()
6187 return -EIO; in thermal_get_sensor()
6189 return -EIO; in thermal_get_sensor()
6190 *value = (t - 2732) * 100; in thermal_get_sensor()
6199 return -EIO; in thermal_get_sensor()
6200 if (t > 127 || t < -127) in thermal_get_sensor()
6209 return -ENOSYS; in thermal_get_sensor()
6212 return -EINVAL; in thermal_get_sensor()
6224 return -EINVAL; in thermal_get_sensors()
6230 res = thermal_get_sensor(i, &s->temp[i]); in thermal_get_sensors()
6259 /* sysfs temp##_input -------------------------------------------------- */
6267 int idx = sensor_attr->index; in thermal_temp_input_show()
6275 return -ENXIO; in thermal_temp_input_show()
6340 return attr->mode; in thermal_attr_is_visible()
6372 return thermal_use_labels ? attr->mode : 0; in temp_label_attr_is_visible()
6380 /* --------------------------------------------------------------------- */
6395 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for in thermal_init()
6396 * non-implemented, thermal sensors return 0x80 when in thermal_init()
6401 * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7 in thermal_init()
6461 return thermal_read_mode != TPACPI_THERMAL_NONE ? 0 : -ENODEV; in thermal_init()
6476 for (i = 0; i < (n - 1); i++) in thermal_read()
6498 * CMOS NVRAM byte 0x5E, bits 0-3.
6505 * Bit 3-0: backlight brightness level
6526 TPACPI_BRGHT_MODE_UCMS_STEP, /* UCMS step-based control */
6607 return -EIO; in tpacpi_brightness_get_raw()
6611 return -ENXIO; in tpacpi_brightness_get_raw()
6623 return -EIO; in tpacpi_brightness_set_ec()
6628 return -EIO; in tpacpi_brightness_set_ec()
6648 inc = (value > current_value) ? 1 : -1; in tpacpi_brightness_set_ucmsstep()
6652 return -EIO; in tpacpi_brightness_set_ucmsstep()
6663 return -EINVAL; in brightness_set()
6681 res = -ENXIO; in brightness_set()
6688 /* sysfs backlight class ----------------------------------------------- */
6732 /* --------------------------------------------------------------------- */
6741 status = acpi_evaluate_object(adev->handle, "_BCL", NULL, &buffer); in tpacpi_evaluate_bcl()
6746 if (!obj || obj->type != ACPI_TYPE_PACKAGE) { in tpacpi_evaluate_bcl()
6747 acpi_handle_info(adev->handle, in tpacpi_evaluate_bcl()
6752 rc = obj->package.count; in tpacpi_evaluate_bcl()
6790 return (bcl_levels > 2) ? (bcl_levels - 2) : 0; in tpacpi_check_std_acpi_brightness_support()
6807 TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), /* R50,51 T40-42 */
6853 bright_maxlvl = b - 1; in tpacpi_detect_brightness_capabilities()
6875 return -ENODEV; in brightness_init()
6880 return -ENODEV; in brightness_init()
6886 return -ENODEV; in brightness_init()
6889 return -ENODEV; in brightness_init()
6893 return -ENODEV; in brightness_init()
6904 return -EINVAL; in brightness_init()
6915 "driver auto-selected brightness_mode=%d\n", in brightness_init()
6923 return -EINVAL; in brightness_init()
6926 return -ENODEV; in brightness_init()
6997 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in brightness_read()
7020 level--; in brightness_write()
7025 return -EINVAL; in brightness_write()
7039 return (rc == -EINTR) ? -ERESTARTSYS : rc; in brightness_write()
7064 * Bit 3-0: Volume
7068 * bits 3-0 (volume). Other bits in NVRAM may have other functions,
7080 * To avoid confusing userspace, we simply disable all EC-based mute
7091 #define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1)
7093 #define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1)
7124 TPACPI_VOL_MODE_UCMS_STEP, /* UCMS step-based control: N/A */
7154 * TP_NVRAM_ADDR_MIXER, as we need to do read-modify-write
7210 return -EIO; in volume_get_status_ec()
7227 return -EIO; in volume_set_status_ec()
7252 return -EINTR; in __volume_set_mute_ec()
7297 return -EINVAL; in __volume_set_volume_ec()
7300 return -EINTR; in __volume_set_volume_ec()
7324 return -ENODEV; in volume_set_software_mute()
7329 return -EIO; in volume_set_software_mute()
7338 return -EIO; in volume_set_software_mute()
7347 * startup. Just on case there are SAUM-capable ThinkPads in volume_set_software_mute()
7381 if (alsa_card && alsa_card->private_data) { in volume_alsa_notify_change()
7382 d = alsa_card->private_data; in volume_alsa_notify_change()
7383 if (d->ctl_mute_id) in volume_alsa_notify_change()
7386 d->ctl_mute_id); in volume_alsa_notify_change()
7387 if (d->ctl_vol_id) in volume_alsa_notify_change()
7390 d->ctl_vol_id); in volume_alsa_notify_change()
7397 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in volume_alsa_vol_info()
7398 uinfo->count = 1; in volume_alsa_vol_info()
7399 uinfo->value.integer.min = 0; in volume_alsa_vol_info()
7400 uinfo->value.integer.max = TP_EC_VOLUME_MAX; in volume_alsa_vol_info()
7414 ucontrol->value.integer.value[0] = s & TP_EC_AUDIO_LVL_MSK; in volume_alsa_vol_get()
7422 ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7423 return volume_alsa_set_volume(ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7438 ucontrol->value.integer.value[0] = in volume_alsa_mute_get()
7447 ucontrol->value.integer.value[0] ? in volume_alsa_mute_put()
7449 return volume_alsa_set_mute(!ucontrol->value.integer.value[0]); in volume_alsa_mute_put()
7511 rc = snd_card_new(&tpacpi_pdev->dev, in volume_create_alsa_mixer()
7516 return -ENODEV; in volume_create_alsa_mixer()
7519 BUG_ON(!card->private_data); in volume_create_alsa_mixer()
7520 data = card->private_data; in volume_create_alsa_mixer()
7521 data->card = card; in volume_create_alsa_mixer()
7523 strscpy(card->driver, TPACPI_ALSA_DRVNAME, in volume_create_alsa_mixer()
7524 sizeof(card->driver)); in volume_create_alsa_mixer()
7525 strscpy(card->shortname, TPACPI_ALSA_SHRTNAME, in volume_create_alsa_mixer()
7526 sizeof(card->shortname)); in volume_create_alsa_mixer()
7527 snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s", in volume_create_alsa_mixer()
7530 snprintf(card->longname, sizeof(card->longname), in volume_create_alsa_mixer()
7531 "%s at EC reg 0x%02x, fw %s", card->shortname, TP_EC_AUDIO, in volume_create_alsa_mixer()
7553 data->ctl_vol_id = &ctl_vol->id; in volume_create_alsa_mixer()
7562 data->ctl_mute_id = &ctl_mute->id; in volume_create_alsa_mixer()
7575 return -ENODEV; in volume_create_alsa_mixer()
7578 #define TPACPI_VOL_Q_MUTEONLY 0x0001 /* Mute-only control available */
7597 /* Whitelist mute-only on all Lenovo by default */
7619 return -EINVAL; in volume_init()
7624 return -ENODEV; in volume_init()
7628 return -EINVAL; in volume_init()
7637 return -ENODEV; in volume_init()
7650 return -ENODEV; /* no mixer */ in volume_init()
7659 return -ENODEV; in volume_init()
7664 "using user-supplied volume_capabilities=%d\n", in volume_init()
7672 "driver auto-selected volume_mode=%d\n", in volume_init()
7676 "using user-supplied volume_mode=%d\n", in volume_init()
7728 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in volume_read()
7755 return -EPERM; in volume_write()
7777 new_level--; in volume_write()
7790 return -EINVAL; in volume_write()
7805 return (rc == -EINTR) ? -ERESTARTSYS : rc; in volume_write()
7830 return -ENODEV; in volume_init()
7878 * Speeds up fan to 100% duty-cycle, which is far above
7881 * 5-3 unused in some models. Extra bits for fan level
7884 * 2-0 fan level (0..7 usually)
7897 * ----
7902 * This register is present on all ThinkPads with a new-style EC, and
7908 * Unfortunately a lot of ThinkPads with new-style ECs but whose firmware
7922 * ----
7934 * So far, only the firmware for the X60/X61 non-tablet versions
7935 * seem to support this (firmware TP-7M).
7960 * that are using non-standard EC locations for reporting fan speeds.
7965 #define FAN_RPM_CAL_CONST 491520 /* FAN RPM calculation offset for some non-standard ECFW */
7978 fan_status_offset_ns = 0x93, /* Special status/control offset for non-standard EC Fan1 */
7979 fan2_status_offset_ns = 0x96, /* Special status/control offset for non-standard EC Fan2 */
7980 fan_rpm_status_ns = 0x95, /* Special offset for Fan1 RPM status for non-standard EC */
7981 fan2_rpm_status_ns = 0x98, /* Special offset for Fan2 RPM status for non-standard EC */
7986 TPACPI_FAN_LAST_LEVEL = 0x100, /* Use cached last-seen fan level */
7992 TPACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */
7993 TPACPI_FAN_RD_TPEC_NS, /* Use non-standard ACPI EC regs (eg: L13 Yoga gen2 etc.) */
8035 "JFNS", /* 770x-JL */
8050 * Enable for TP-1Y (T43), TP-78 (R51e), TP-76 (R52),
8051 * TP-70 (T43, R52), which are known to be buggy.
8136 return -EIO; in fan_get_status()
8146 return -EIO; in fan_get_status()
8157 return -EIO; in fan_get_status()
8165 return -ENXIO; in fan_get_status()
8177 return -ERESTARTSYS; in fan_get_status_safe()
8200 return -EIO; in fan_get_speed()
8203 return -EIO; in fan_get_speed()
8213 return -EIO; in fan_get_speed()
8220 return -ENXIO; in fan_get_speed()
8235 return -EIO; in fan2_get_speed()
8240 return -EIO; in fan2_get_speed()
8252 return -EIO; in fan2_get_speed()
8255 return -EIO; in fan2_get_speed()
8259 return -EIO; in fan2_get_speed()
8265 return -ENXIO; in fan2_get_speed()
8274 return -EPERM; in fan_set_level()
8279 return -EINVAL; in fan_set_level()
8290 return -EIO; in fan_set_level()
8298 return -EINVAL; in fan_set_level()
8317 return -EIO; in fan_set_level()
8323 return -ENXIO; in fan_set_level()
8336 return -EPERM; in fan_set_level_safe()
8339 return -ERESTARTSYS; in fan_set_level_safe()
8358 return -EPERM; in fan_set_enable()
8361 return -ERESTARTSYS; in fan_set_enable()
8377 rc = -EIO; in fan_set_enable()
8395 rc = -EIO; in fan_set_enable()
8401 rc = -ENXIO; in fan_set_enable()
8418 return -EPERM; in fan_set_disable()
8421 return -ERESTARTSYS; in fan_set_disable()
8428 rc = -EIO; in fan_set_disable()
8437 rc = -EIO; in fan_set_disable()
8443 rc = -ENXIO; in fan_set_disable()
8459 return -EPERM; in fan_set_speed()
8462 return -ERESTARTSYS; in fan_set_speed()
8470 rc = -EIO; in fan_set_speed()
8472 rc = -EINVAL; in fan_set_speed()
8476 rc = -ENXIO; in fan_set_speed()
8534 /* sysfs fan pwm1_enable ----------------------------------------------- */
8564 return -EINVAL; in fan_pwm1_enable_store()
8580 /* reserved for software-controlled auto mode */ in fan_pwm1_enable_store()
8581 return -ENOSYS; in fan_pwm1_enable_store()
8583 return -EINVAL; in fan_pwm1_enable_store()
8587 if (res == -ENXIO) in fan_pwm1_enable_store()
8588 return -EINVAL; in fan_pwm1_enable_store()
8600 /* sysfs fan pwm1 ------------------------------------------------------ */
8631 return -EINVAL; in fan_pwm1_store()
8636 /* scale down from 0-255 to 0-7 */ in fan_pwm1_store()
8640 return -ERESTARTSYS; in fan_pwm1_store()
8646 if (rc == -ENXIO) in fan_pwm1_store()
8647 rc = -EINVAL; in fan_pwm1_store()
8660 /* sysfs fan fan1_input ------------------------------------------------ */
8681 /* sysfs fan fan2_input ------------------------------------------------ */
8702 /* sysfs fan fan_watchdog (hwmon driver) ------------------------------- */
8714 return -EINVAL; in fan_watchdog_store()
8717 return -EPERM; in fan_watchdog_store()
8728 /* --------------------------------------------------------------------- */
8750 return attr->mode; in fan_attr_is_visible()
8772 #define TPACPI_FAN_NS 0x0010 /* For EC with non-Standard register addresses */
8828 return -ENODEV; in fan_init()
8832 pr_info("ECFW with non-standard fan reg control found\n"); in fan_init()
8849 /* all other ThinkPads: note that even old-style in fan_init()
8867 /* It responded - so let's assume it's there */ in fan_init()
8873 /* Fan not auto-detected */ in fan_init()
8887 return -ENODEV; in fan_init()
8892 /* 570, 770x-JL */ in fan_init()
8938 return -ENODEV; in fan_init()
9092 seq_printf(m, " (<level> is 0-7)\n"); in fan_read()
9096 seq_printf(m, " (<level> is 0-7, auto, disengaged, full-speed)\n"); in fan_read()
9103 "commands:\twatchdog <timeout> (<timeout> is 0 (off), 1-120 (seconds))\n"); in fan_read()
9106 seq_printf(m, "commands:\tspeed <speed> (<speed> is 0-65535)\n"); in fan_read()
9117 else if (strstarts(cmd, "level disengaged") || strstarts(cmd, "level full-speed")) in fan_write_cmd_level()
9123 if (*rc == -ENXIO) in fan_write_cmd_level()
9139 if (*rc == -ENXIO) in fan_write_cmd_enable()
9154 if (*rc == -ENXIO) in fan_write_cmd_disable()
9174 if (*rc == -ENXIO) in fan_write_cmd_speed()
9192 *rc = -EINVAL; in fan_write_cmd_watchdog()
9218 rc = -EINVAL; in fan_write()
9266 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_on_off()
9267 pr_warn("Thinkpad ACPI has no %s interface.\n", t->name); in mute_led_on_off()
9268 return -EIO; in mute_led_on_off()
9271 if (!acpi_evalf(hkey_handle, &output, t->name, "dd", in mute_led_on_off()
9272 state ? t->on_value : t->off_value)) in mute_led_on_off()
9273 return -EIO; in mute_led_on_off()
9275 t->state = state; in mute_led_on_off()
9284 if (t->state < 0 || t->state == on) in tpacpi_led_set()
9285 return t->state; in tpacpi_led_set()
9306 .default_trigger = "audio-mute",
9312 .default_trigger = "audio-micmute",
9323 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_init()
9324 t->state = -ENODEV; in mute_led_init()
9329 err = led_classdev_register(&tpacpi_pdev->dev, &mute_led_cdev[i]); in mute_led_init()
9331 while (i--) in mute_led_init()
9355 if (t->state >= 0) in mute_led_resume()
9356 mute_led_on_off(t, t->state); in mute_led_resume()
9445 return -ENODEV; in tpacpi_battery_get()
9452 return -ENODEV; in tpacpi_battery_get()
9466 return -ENODEV; in tpacpi_battery_get()
9472 return -ENODEV; in tpacpi_battery_get()
9478 return -EINVAL; in tpacpi_battery_get()
9487 /* The battery ID is in bits 8-9, 2 bits */ in tpacpi_battery_set()
9495 return -ENODEV; in tpacpi_battery_set()
9501 return -ENODEV; in tpacpi_battery_set()
9507 * battery ID is in bits 8-9, 2 bits. in tpacpi_battery_set()
9511 return -ENODEV; in tpacpi_battery_set()
9518 * The battery ID is in bits 4-5, 2 bits, in tpacpi_battery_set()
9519 * the effective time is in bits 8-23, 2 bytes. in tpacpi_battery_set()
9527 return -ENODEV; in tpacpi_battery_set()
9532 return -EINVAL; in tpacpi_battery_set()
9560 return -EIO; in tpacpi_battery_set_validate()
9583 return -ENODEV; in tpacpi_battery_probe()
9592 return -ENODEV; in tpacpi_battery_probe()
9596 return -ENODEV; in tpacpi_battery_probe()
9602 return -ENODEV; in tpacpi_battery_probe()
9608 return -ENODEV; in tpacpi_battery_probe()
9612 return -ENODEV; in tpacpi_battery_probe()
9618 return -ENODEV; in tpacpi_battery_probe()
9628 return -ENODEV; in tpacpi_battery_probe()
9689 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_store()
9700 return -ENODEV; in tpacpi_battery_store()
9703 return -EINVAL; in tpacpi_battery_store()
9705 return -EINVAL; in tpacpi_battery_store()
9707 return -ENODEV; in tpacpi_battery_store()
9713 return -ENODEV; in tpacpi_battery_store()
9716 return -EINVAL; in tpacpi_battery_store()
9718 return -EINVAL; in tpacpi_battery_store()
9728 return -EINVAL; in tpacpi_battery_store()
9732 return -EINVAL; in tpacpi_battery_store()
9756 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_show()
9760 return -ENODEV; in tpacpi_battery_show()
9787 battery = tpacpi_battery_get_id(supply->desc->name); in charge_behaviour_show()
9792 return -ENODEV; in charge_behaviour_show()
9801 return -ENODEV; in charge_behaviour_show()
9834 battery = tpacpi_battery_get_id(supply->desc->name); in charge_behaviour_store()
9866 return -EINVAL; in charge_behaviour_store()
9903 int batteryid = tpacpi_battery_get_id(battery->desc->name); in tpacpi_battery_add()
9906 return -ENODEV; in tpacpi_battery_add()
9907 if (device_add_groups(&battery->dev, tpacpi_battery_groups)) in tpacpi_battery_add()
9908 return -ENODEV; in tpacpi_battery_add()
9914 device_remove_groups(&battery->dev, tpacpi_battery_groups); in tpacpi_battery_remove()
9976 if (WARN_ON(!mutex_is_locked(&priv->lock))) in lcdshadow_set_sw_state()
9977 return -EIO; in lcdshadow_set_sw_state()
9980 return -EIO; in lcdshadow_set_sw_state()
9982 priv->hw_state = priv->sw_state = state; in lcdshadow_set_sw_state()
9993 priv->hw_state = priv->sw_state = output & 0x1; in lcdshadow_get_hw_state()
10012 return -EIO; in tpacpi_lcdshadow_init()
10017 lcdshadow_dev = drm_privacy_screen_register(&tpacpi_pdev->dev, in tpacpi_lcdshadow_init()
10035 mutex_lock(&lcdshadow_dev->lock); in lcdshadow_resume()
10036 lcdshadow_set_sw_state(lcdshadow_dev, lcdshadow_dev->sw_state); in lcdshadow_resume()
10037 mutex_unlock(&lcdshadow_dev->lock); in lcdshadow_resume()
10045 seq_printf(m, "status:\t\t%d\n", lcdshadow_dev->hw_state); in lcdshadow_read()
10055 int res, state = -EINVAL; in lcdshadow_write()
10058 return -ENODEV; in lcdshadow_write()
10067 return -EINVAL; in lcdshadow_write()
10069 mutex_lock(&lcdshadow_dev->lock); in lcdshadow_write()
10071 mutex_unlock(&lcdshadow_dev->lock); in lcdshadow_write()
10090 #define DYTC_CMD_QUERY 0 /* To get DYTC status - enable/revision */
10091 #define DYTC_QUERY_ENABLE_BIT 8 /* Bit 8 - 0 = disabled, 1 = enabled */
10092 #define DYTC_QUERY_SUBREV_BIT 16 /* Bits 16 - 27 - sub revision */
10093 #define DYTC_QUERY_REV_BIT 28 /* Bits 28 - 31 - revision */
10113 return -ENODEV; in dytc_command()
10116 return -EIO; in dytc_command()
10141 return -ENODEV; in palmsensor_get()
10143 return -EIO; in palmsensor_get()
10161 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "dytc_lapmode"); in lapsensor_refresh()
10177 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "palmsensor"); in palmsensor_refresh()
10223 return attr->mode; in proxsensor_attr_is_visible()
10237 /* If support isn't available for both devices return -ENODEV */ in tpacpi_proxsensor_init()
10238 if ((palm_err == -ENODEV) && (lap_err == -ENODEV)) in tpacpi_proxsensor_init()
10239 return -ENODEV; in tpacpi_proxsensor_init()
10241 if (palm_err && (palm_err != -ENODEV)) in tpacpi_proxsensor_init()
10243 if (lap_err && (lap_err != -ENODEV)) in tpacpi_proxsensor_init()
10250 .name = "proximity-sensor",
10266 #define DYTC_GET_FUNCTION_BIT 8 /* Bits 8-11 - function setting */
10267 #define DYTC_GET_MODE_BIT 12 /* Bits 12-15 - mode setting */
10269 #define DYTC_SET_FUNCTION_BIT 12 /* Bits 12-15 - function setting */
10270 #define DYTC_SET_MODE_BIT 16 /* Bits 16-19 - mode setting */
10271 #define DYTC_SET_VALID_BIT 20 /* Bit 20 - 1 = on, 0 = off */
10295 #define DYTC_ERR_MASK 0xF /* Bits 0-3 in cmd result are the error result */
10336 return -EINVAL; in convert_dytc_to_profile()
10347 return -EINVAL; in convert_dytc_to_profile()
10357 return -EOPNOTSUPP; in convert_dytc_to_profile()
10384 return -EOPNOTSUPP; in convert_profile_to_dytc()
10408 return -ENODEV; in dytc_control_amt()
10425 * Helper function - check if we are in CQL mode and if we are
10426 * - disable CQL,
10427 * - run the command
10428 * - enable CQL
10487 * Note we still need to disable CQL mode before hand and re-enable in dytc_profile_set()
10510 /* Success - update current profile */ in dytc_profile_set()
10535 err = -ENODEV; in dytc_profile_refresh()
10573 return -ENODEV; in tpacpi_dytc_profile_init()
10583 case -1: in tpacpi_dytc_profile_init()
10616 return -ENODEV; in tpacpi_dytc_profile_init()
10629 return -ENODEV; in tpacpi_dytc_profile_init()
10647 .name = "dytc-profile",
10669 {"fr-ch", 0x100c},
10689 return -ENODEV; in set_keyboard_lang_command()
10693 return -EIO; in set_keyboard_lang_command()
10705 return -ENODEV; in get_keyboard_lang()
10709 return -EIO; in get_keyboard_lang()
10713 * '(' and ')') keys which use layout dependent key-press emulation. in get_keyboard_lang()
10716 return -ENODEV; in get_keyboard_lang()
10773 dev_err(&tpacpi_pdev->dev, "Unknown Keyboard language. Ignoring\n"); in keyboard_lang_store()
10774 return -EINVAL; in keyboard_lang_store()
10777 tpacpi_disclose_usertask(attr->attr.name, in keyboard_lang_store()
10780 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang"); in keyboard_lang_store()
10794 return tp_features.kbd_lang ? attr->mode : 0; in kbdlang_attr_is_visible()
10831 return -ENODEV; in dprc_command()
10835 return -EIO; in dprc_command()
10843 return -ENODEV; in dprc_command()
10862 return -ENODEV; in get_wwan_antenna()
10878 return -ENODATA; in wwan_antenna_type_show()
10891 return has_antennatype ? attr->mode : 0; in dprc_attr_is_visible()
10915 /* --------------------------------------------------------------------- */
10948 return attr->mode; in tpacpi_attr_is_visible()
11064 if (!atomic_add_unless(&dytc_ignore_event, -1, 0)) in tpacpi_driver_event()
11072 mutex_lock(&lcdshadow_dev->lock); in tpacpi_driver_event()
11073 old_hw_state = lcdshadow_dev->hw_state; in tpacpi_driver_event()
11075 changed = lcdshadow_dev->hw_state != old_hw_state; in tpacpi_driver_event()
11076 mutex_unlock(&lcdshadow_dev->lock); in tpacpi_driver_event()
11097 /* --------------------------------------------------------------------- */
11119 dbg_printk(TPACPI_DBG_EXIT, "removing %s\n", ibm->name); in ibm_exit()
11121 list_del_init(&ibm->all_drivers); in ibm_exit()
11123 if (ibm->flags.acpi_notify_installed) { in ibm_exit()
11125 "%s: acpi_remove_notify_handler\n", ibm->name); in ibm_exit()
11126 BUG_ON(!ibm->acpi); in ibm_exit()
11127 acpi_remove_notify_handler(*ibm->acpi->handle, in ibm_exit()
11128 ibm->acpi->type, in ibm_exit()
11130 ibm->flags.acpi_notify_installed = 0; in ibm_exit()
11133 if (ibm->flags.proc_created) { in ibm_exit()
11135 "%s: remove_proc_entry\n", ibm->name); in ibm_exit()
11136 remove_proc_entry(ibm->name, proc_dir); in ibm_exit()
11137 ibm->flags.proc_created = 0; in ibm_exit()
11140 if (ibm->flags.acpi_driver_registered) { in ibm_exit()
11142 "%s: acpi_bus_unregister_driver\n", ibm->name); in ibm_exit()
11143 BUG_ON(!ibm->acpi); in ibm_exit()
11144 acpi_bus_unregister_driver(ibm->acpi->driver); in ibm_exit()
11145 kfree(ibm->acpi->driver); in ibm_exit()
11146 ibm->acpi->driver = NULL; in ibm_exit()
11147 ibm->flags.acpi_driver_registered = 0; in ibm_exit()
11150 if (ibm->flags.init_called && ibm->exit) { in ibm_exit()
11151 ibm->exit(); in ibm_exit()
11152 ibm->flags.init_called = 0; in ibm_exit()
11155 dbg_printk(TPACPI_DBG_INIT, "finished removing %s\n", ibm->name); in ibm_exit()
11161 struct ibm_struct *ibm = iibm->data; in ibm_init()
11166 INIT_LIST_HEAD(&ibm->all_drivers); in ibm_init()
11168 if (ibm->flags.experimental && !experimental) in ibm_init()
11172 "probing for %s\n", ibm->name); in ibm_init()
11174 if (iibm->init) { in ibm_init()
11175 ret = iibm->init(iibm); in ibm_init()
11176 if (ret > 0 || ret == -ENODEV) in ibm_init()
11181 ibm->flags.init_called = 1; in ibm_init()
11184 if (ibm->acpi) { in ibm_init()
11185 if (ibm->acpi->hid) { in ibm_init()
11191 if (ibm->acpi->notify) { in ibm_init()
11193 if (ret == -ENODEV) { in ibm_init()
11195 ibm->name); in ibm_init()
11205 "%s installed\n", ibm->name); in ibm_init()
11207 if (ibm->read) { in ibm_init()
11208 umode_t mode = iibm->base_procfs_mode; in ibm_init()
11212 if (ibm->write) in ibm_init()
11214 entry = proc_create_data(ibm->name, mode, proc_dir, in ibm_init()
11217 pr_err("unable to create proc entry %s\n", ibm->name); in ibm_init()
11218 ret = -ENODEV; in ibm_init()
11221 ibm->flags.proc_created = 1; in ibm_init()
11224 list_add_tail(&ibm->all_drivers, &tpacpi_all_drivers); in ibm_init()
11231 ibm->name, ret); in ibm_init()
11254 * Ancient 570/600 and -SL lacks (#.##c) in tpacpi_parse_fw_id()
11280 * ---------------------------------------------------- in find_new_ec_fwstr()
11293 if (dm->type != 140 || dm->length < 0x0F || in find_new_ec_fwstr()
11303 /* returns 0 - probe ok, or < 0 - probe error.
11305 * On error, kfree() cleanup on tp->* is not performed, caller must do it */
11315 return -EINVAL; in get_thinkpad_model_data()
11320 tp->vendor = PCI_VENDOR_ID_IBM; in get_thinkpad_model_data()
11322 tp->vendor = PCI_VENDOR_ID_LENOVO; in get_thinkpad_model_data()
11324 tp->vendor = PCI_VENDOR_ID_LENOVO; in get_thinkpad_model_data()
11329 tp->bios_version_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11330 if (s && !tp->bios_version_str) in get_thinkpad_model_data()
11331 return -ENOMEM; in get_thinkpad_model_data()
11334 t = tpacpi_parse_fw_id(tp->bios_version_str, in get_thinkpad_model_data()
11335 &tp->bios_model, &tp->bios_release); in get_thinkpad_model_data()
11342 * up-to-date BIOS or they will not be detected. in get_thinkpad_model_data()
11347 if (sscanf(dev->name, in get_thinkpad_model_data()
11348 "IBM ThinkPad Embedded Controller -[%17c", in get_thinkpad_model_data()
11350 ec_fw_string[sizeof(ec_fw_string) - 1] = 0; in get_thinkpad_model_data()
11361 tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL); in get_thinkpad_model_data()
11362 if (!tp->ec_version_str) in get_thinkpad_model_data()
11363 return -ENOMEM; in get_thinkpad_model_data()
11366 &tp->ec_model, &tp->ec_release); in get_thinkpad_model_data()
11376 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11377 if (!tp->model_str) in get_thinkpad_model_data()
11378 return -ENOMEM; in get_thinkpad_model_data()
11382 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11383 if (!tp->model_str) in get_thinkpad_model_data()
11384 return -ENOMEM; in get_thinkpad_model_data()
11389 tp->nummodel_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11390 if (s && !tp->nummodel_str) in get_thinkpad_model_data()
11391 return -ENOMEM; in get_thinkpad_model_data()
11401 return -ENODEV; in probe_for_thinkpad()
11405 return -ENODEV; in probe_for_thinkpad()
11408 * Non-ancient models have better DMI tagging, but very old models in probe_for_thinkpad()
11420 return -ENODEV; in probe_for_thinkpad()
11424 return -ENODEV; in probe_for_thinkpad()
11553 if (!kp || !kp->name || !val) in set_ibm_param()
11554 return -EINVAL; in set_ibm_param()
11558 if (!ibm || !ibm->name) in set_ibm_param()
11561 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { in set_ibm_param()
11562 if (strlen(val) > sizeof(ibms_init[i].param) - 1) in set_ibm_param()
11563 return -ENOSPC; in set_ibm_param()
11569 return -EINVAL; in set_ibm_param()
11574 "Enables experimental features when non-zero");
11577 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
11581 "Attempts to load the driver even on a mis-identified ThinkPad when true");
11624 …MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command at module load, see documentatio…
11664 MODULE_PARM_DESC(profile_force, "Force profile mode. -1=off, 1=MMC, 2=PSC");
11719 /* Driver-level probe */ in thinkpad_acpi_module_init()
11759 return -ENOMEM; in thinkpad_acpi_module_init()
11766 return -ENODEV; in thinkpad_acpi_module_init()
11771 tp_features.quirks = dmi_id->driver_data; in thinkpad_acpi_module_init()
11798 return -ENOMEM; in thinkpad_acpi_module_init()
11801 tpacpi_inputdev->name = "ThinkPad Extra Buttons"; in thinkpad_acpi_module_init()
11802 tpacpi_inputdev->phys = TPACPI_DRVR_NAME "/input0"; in thinkpad_acpi_module_init()
11803 tpacpi_inputdev->id.bustype = BUS_HOST; in thinkpad_acpi_module_init()
11804 tpacpi_inputdev->id.vendor = thinkpad_id.vendor; in thinkpad_acpi_module_init()
11805 tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT; in thinkpad_acpi_module_init()
11806 tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION; in thinkpad_acpi_module_init()
11807 tpacpi_inputdev->dev.parent = &tpacpi_pdev->dev; in thinkpad_acpi_module_init()
11817 ret = ibms_init[i].data->write(ibms_init[i].param); in thinkpad_acpi_module_init()
11843 &tpacpi_sensors_pdev->dev, TPACPI_NAME, NULL, tpacpi_hwmon_groups); in thinkpad_acpi_module_init()