Lines Matching +full:vd +full:- +full:supply
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
59 #include <linux/hwmon-sysfs.h>
111 /* Misc NVRAM-related */
150 /* Hotkey-related */
167 /* Auto-sleep after eject request */
178 /* User-interface events */
190 /* Key-related user-interface events */
207 /* AC-related events */
210 /* Further user-interface events */
225 #define TPACPI_URL "http://ibm-acpi.sf.net/"
226 #define TPACPI_MAIL "ibm-acpi-devel@lists.sourceforge.net"
256 * Driver-wide structs and misc. variables
345 char *ec_version_str; /* Something like 1ZHT51WW-1.04a */
353 char *nummodel_str; /* 9384A9C for a 9384-A9C model */
434 * two or three characters from the set [0-9A-Z], i.e. base 36.
486 * tpacpi_check_quirks() - search BIOS/EC version on a list
503 if ((qlist->vendor == thinkpad_id.vendor || in tpacpi_check_quirks()
504 qlist->vendor == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
505 (qlist->bios == thinkpad_id.bios_model || in tpacpi_check_quirks()
506 qlist->bios == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
507 (qlist->ec == thinkpad_id.ec_model || in tpacpi_check_quirks()
508 qlist->ec == TPACPI_MATCH_ANY)) in tpacpi_check_quirks()
509 return qlist->quirks; in tpacpi_check_quirks()
511 qlist_size--; in tpacpi_check_quirks()
553 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
679 return -ENXIO; in issue_thinkpad_cmos_command()
681 if (!acpi_evalf(cmos_handle, NULL, NULL, "vd", cmos_cmd)) in issue_thinkpad_cmos_command()
682 return -EIO; in issue_thinkpad_cmos_command()
772 if (!ibm || !ibm->acpi || !ibm->acpi->notify) in dispatch_acpi_notify()
775 ibm->acpi->notify(ibm, event); in dispatch_acpi_notify()
783 BUG_ON(!ibm->acpi); in setup_acpi_notify()
785 if (!*ibm->acpi->handle) in setup_acpi_notify()
789 "setting up ACPI notify for %s\n", ibm->name); in setup_acpi_notify()
791 rc = acpi_bus_get_device(*ibm->acpi->handle, &ibm->acpi->device); in setup_acpi_notify()
793 pr_err("acpi_bus_get_device(%s) failed: %d\n", ibm->name, rc); in setup_acpi_notify()
794 return -ENODEV; in setup_acpi_notify()
797 ibm->acpi->device->driver_data = ibm; in setup_acpi_notify()
798 sprintf(acpi_device_class(ibm->acpi->device), "%s/%s", in setup_acpi_notify()
800 ibm->name); in setup_acpi_notify()
802 status = acpi_install_notify_handler(*ibm->acpi->handle, in setup_acpi_notify()
803 ibm->acpi->type, dispatch_acpi_notify, ibm); in setup_acpi_notify()
807 ibm->name); in setup_acpi_notify()
810 ibm->name, acpi_format_exception(status)); in setup_acpi_notify()
812 return -ENODEV; in setup_acpi_notify()
814 ibm->flags.acpi_notify_installed = 1; in setup_acpi_notify()
828 "registering %s as an ACPI driver\n", ibm->name); in register_tpacpi_subdriver()
830 BUG_ON(!ibm->acpi); in register_tpacpi_subdriver()
832 ibm->acpi->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL); in register_tpacpi_subdriver()
833 if (!ibm->acpi->driver) { in register_tpacpi_subdriver()
834 pr_err("failed to allocate memory for ibm->acpi->driver\n"); in register_tpacpi_subdriver()
835 return -ENOMEM; in register_tpacpi_subdriver()
838 sprintf(ibm->acpi->driver->name, "%s_%s", TPACPI_NAME, ibm->name); in register_tpacpi_subdriver()
839 ibm->acpi->driver->ids = ibm->acpi->hid; in register_tpacpi_subdriver()
841 ibm->acpi->driver->ops.add = &tpacpi_device_add; in register_tpacpi_subdriver()
843 rc = acpi_bus_register_driver(ibm->acpi->driver); in register_tpacpi_subdriver()
846 ibm->name, rc); in register_tpacpi_subdriver()
847 kfree(ibm->acpi->driver); in register_tpacpi_subdriver()
848 ibm->acpi->driver = NULL; in register_tpacpi_subdriver()
850 ibm->flags.acpi_driver_registered = 1; in register_tpacpi_subdriver()
866 struct ibm_struct *ibm = m->private; in dispatch_proc_show()
868 if (!ibm || !ibm->read) in dispatch_proc_show()
869 return -EINVAL; in dispatch_proc_show()
870 return ibm->read(m); in dispatch_proc_show()
886 if (!ibm || !ibm->write) in dispatch_proc_write()
887 return -EINVAL; in dispatch_proc_write()
888 if (count > PAGE_SIZE - 1) in dispatch_proc_write()
889 return -EINVAL; in dispatch_proc_write()
893 return -ENOMEM; in dispatch_proc_write()
897 return -EFAULT; in dispatch_proc_write()
901 ret = ibm->write(kernbuf); in dispatch_proc_write()
941 if (ibm->suspend) in tpacpi_suspend_handler()
942 (ibm->suspend)(); in tpacpi_suspend_handler()
955 if (ibm->resume) in tpacpi_resume_handler()
956 (ibm->resume)(); in tpacpi_resume_handler()
973 if (ibm->shutdown) in tpacpi_shutdown_handler()
974 (ibm->shutdown)(); in tpacpi_shutdown_handler()
1020 sobj->s.max_members = max_members; in create_attr_set()
1021 sobj->s.group.attrs = &sobj->a; in create_attr_set()
1022 sobj->s.group.name = name; in create_attr_set()
1024 return &sobj->s; in create_attr_set()
1030 /* not multi-threaded safe, use it in a single thread per set */
1034 return -EINVAL; in add_to_attr_set()
1036 if (s->members >= s->max_members) in add_to_attr_set()
1037 return -ENOMEM; in add_to_attr_set()
1039 s->group.attrs[s->members] = attr; in add_to_attr_set()
1040 s->members++; in add_to_attr_set()
1062 sysfs_remove_group(kobj, &s->group); in delete_attr_set()
1067 sysfs_create_group(_kobj, &_attr_set->group)
1077 return -EINVAL; in parse_strtoul()
1101 * ThinkPad-ACPI firmware handling model:
1103 * WLSW (master wireless switch) is event-driven, and is common to all
1104 * firmware-controlled radios. It cannot be controlled, just monitored,
1107 * The kernel, a masked-off hotkey, and WLSW can change the radio state
1111 * masked-off hotkeys are used.
1140 /* ThinkPad-ACPI rfkill subdriver */
1161 return -ENODEV; in tpacpi_rfk_update_swstate()
1163 status = (tp_rfk->ops->get_status)(); in tpacpi_rfk_update_swstate()
1167 rfkill_set_sw_state(tp_rfk->rfkill, in tpacpi_rfk_update_swstate()
1183 * Sync the HW-blocking state of all rfkill switches,
1194 if (rfkill_set_hw_state(tp_rfk->rfkill, in tpacpi_rfk_update_hwblock_state()
1196 /* ignore -- we track sw block */ in tpacpi_rfk_update_hwblock_state()
1231 res = (tp_rfk->ops->set_status)(blocked ? in tpacpi_rfk_hook_set_block()
1260 atp_rfk->rfkill = rfkill_alloc(name, in tpacpi_new_rfkill()
1261 &tpacpi_pdev->dev, in tpacpi_new_rfkill()
1265 if (!atp_rfk || !atp_rfk->rfkill) { in tpacpi_new_rfkill()
1268 return -ENOMEM; in tpacpi_new_rfkill()
1271 atp_rfk->id = id; in tpacpi_new_rfkill()
1272 atp_rfk->ops = tp_rfkops; in tpacpi_new_rfkill()
1274 sw_status = (tp_rfkops->get_status)(); in tpacpi_new_rfkill()
1283 rfkill_init_sw_state(atp_rfk->rfkill, sw_state); in tpacpi_new_rfkill()
1287 rfkill_set_hw_state(atp_rfk->rfkill, hw_state); in tpacpi_new_rfkill()
1289 res = rfkill_register(atp_rfk->rfkill); in tpacpi_new_rfkill()
1292 rfkill_destroy(atp_rfk->rfkill); in tpacpi_new_rfkill()
1312 rfkill_unregister(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1313 rfkill_destroy(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1325 /* sysfs <radio> enable ------------------------------------------------ */
1332 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_show()
1354 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_store()
1357 return -EINVAL; in tpacpi_rfk_sysfs_enable_store()
1359 tpacpi_disclose_usertask(attr->attr.name, "set to %ld\n", t); in tpacpi_rfk_sysfs_enable_store()
1363 return -EPERM; in tpacpi_rfk_sysfs_enable_store()
1365 res = tpacpi_rfkill_switches[id]->ops->set_status((!!t) ? in tpacpi_rfk_sysfs_enable_store()
1372 /* procfs -------------------------------------------------------------- */
1402 int status = -1; in tpacpi_rfk_procfs_write()
1406 return -ENODEV; in tpacpi_rfk_procfs_write()
1414 return -EINVAL; in tpacpi_rfk_procfs_write()
1417 if (status != -1) { in tpacpi_rfk_procfs_write()
1422 res = (tpacpi_rfkill_switches[id]->ops->set_status)(status); in tpacpi_rfk_procfs_write()
1430 * thinkpad-acpi driver attributes
1433 /* interface_version --------------------------------------------------- */
1440 /* debug_level --------------------------------------------------------- */
1452 return -EINVAL; in debug_level_store()
1460 /* version ------------------------------------------------------------- */
1468 /* --------------------------------------------------------------------- */
1472 /* wlsw_emulstate ------------------------------------------------------ */
1484 return -EINVAL; in wlsw_emulstate_store()
1495 /* bluetooth_emulstate ------------------------------------------------- */
1507 return -EINVAL; in bluetooth_emulstate_store()
1515 /* wwan_emulstate ------------------------------------------------- */
1527 return -EINVAL; in wwan_emulstate_store()
1535 /* uwb_emulstate ------------------------------------------------- */
1547 return -EINVAL; in uwb_emulstate_store()
1556 /* --------------------------------------------------------------------- */
1680 /* Numeric models ------------------ */
1692 /* A-series ------------------------- */
1706 /* G-series ------------------------- */
1711 /* R-series, T-series --------------- */
1741 /* X-series ------------------------- */
1754 /* (0) - older versions lack DMI EC fw string and functionality */
1755 /* (1) - older versions known to lack functionality */
1811 * thinkpad-acpi metadata subdriver
1846 * Unlike other classes, hotkey-class events have mask/unmask control on
1847 * non-ancient firmware. However, how it behaves changes a lot with the
2073 return -ENODEV; in hotkey_get_wlsw()
2082 return -EIO; in hotkey_get_wlsw()
2176 return -EIO; in hotkey_get_tablet_mode()
2182 return -EIO; in hotkey_get_tablet_mode()
2207 return -EIO; in hotkey_mask_get()
2215 /* sync userspace-visible mask */ in hotkey_mask_get()
2253 rc = -EIO; in hotkey_mask_set()
2294 …pr_notice("please consider using the driver defaults, and refer to up-to-date thinkpad-acpi docume… in hotkey_user_mask_set()
2343 return -EIO; in hotkey_status_get()
2350 if (!acpi_evalf(hkey_handle, NULL, "MHKC", "vd", enable ? 1 : 0)) in hotkey_status_set()
2351 return -EIO; in hotkey_status_set()
2415 n->thinkpad_toggle = !!(d & TP_NVRAM_MASK_HKT_THINKPAD); in hotkey_read_nvram()
2416 n->zoom_toggle = !!(d & TP_NVRAM_MASK_HKT_ZOOM); in hotkey_read_nvram()
2417 n->display_toggle = !!(d & TP_NVRAM_MASK_HKT_DISPLAY); in hotkey_read_nvram()
2418 n->hibernate_toggle = !!(d & TP_NVRAM_MASK_HKT_HIBERNATE); in hotkey_read_nvram()
2422 n->thinklight_toggle = !!(d & TP_NVRAM_MASK_THINKLIGHT); in hotkey_read_nvram()
2426 n->displayexp_toggle = in hotkey_read_nvram()
2431 n->brightness_level = (d & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) in hotkey_read_nvram()
2433 n->brightness_toggle = in hotkey_read_nvram()
2438 n->volume_level = (d & TP_NVRAM_MASK_LEVEL_VOLUME) in hotkey_read_nvram()
2440 n->mute = !!(d & TP_NVRAM_MASK_MUTE); in hotkey_read_nvram()
2441 n->volume_toggle = !!(d & TP_NVRAM_MASK_HKT_VOLUME); in hotkey_read_nvram()
2448 oldn->__member != newn->__member) \
2466 i--; in issue_volchange()
2482 i--; in issue_brightnesschange()
2508 * - Pressing MUTE issues mute hotkey message, even when already mute in hotkey_compare_and_issue_event()
2509 * - Pressing Volume up/down issues volume up/down hotkey messages, in hotkey_compare_and_issue_event()
2511 * - The act of unmuting issues volume up/down notification, in hotkey_compare_and_issue_event()
2521 if (newn->mute) { in hotkey_compare_and_issue_event()
2523 if (!oldn->mute || in hotkey_compare_and_issue_event()
2524 oldn->volume_toggle != newn->volume_toggle || in hotkey_compare_and_issue_event()
2525 oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2528 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2534 if (oldn->mute) { in hotkey_compare_and_issue_event()
2538 if (oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2539 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2541 } else if (oldn->volume_toggle != newn->volume_toggle) { in hotkey_compare_and_issue_event()
2543 if (newn->volume_level == 0) in hotkey_compare_and_issue_event()
2545 else if (newn->volume_level >= TP_NVRAM_LEVEL_VOLUME_MAX) in hotkey_compare_and_issue_event()
2551 if (oldn->brightness_level != newn->brightness_level) { in hotkey_compare_and_issue_event()
2552 issue_brightnesschange(oldn->brightness_level, in hotkey_compare_and_issue_event()
2553 newn->brightness_level, event_mask); in hotkey_compare_and_issue_event()
2554 } else if (oldn->brightness_toggle != newn->brightness_toggle) { in hotkey_compare_and_issue_event()
2556 if (newn->brightness_level == 0) in hotkey_compare_and_issue_event()
2558 else if (newn->brightness_level >= bright_maxlvl in hotkey_compare_and_issue_event()
2571 * most of them are edge-based. We only issue those requested by
2663 (poll_user_mask && tpacpi_inputdev->users > 0))) { in hotkey_poll_setup()
2718 return -EBUSY; in hotkey_inputdev_open()
2723 return -EBUSY; in hotkey_inputdev_open()
2734 /* sysfs hotkey enable ------------------------------------------------- */
2761 return -EINVAL; in hotkey_enable_store()
2764 return -EPERM; in hotkey_enable_store()
2771 /* sysfs hotkey mask --------------------------------------------------- */
2787 return -EINVAL; in hotkey_mask_store()
2790 return -ERESTARTSYS; in hotkey_mask_store()
2807 /* sysfs hotkey bios_enabled ------------------------------------------- */
2817 /* sysfs hotkey bios_mask ---------------------------------------------- */
2829 /* sysfs hotkey all_mask ----------------------------------------------- */
2840 /* sysfs hotkey all_mask ----------------------------------------------- */
2851 /* sysfs hotkey recommended_mask --------------------------------------- */
2865 /* sysfs hotkey hotkey_source_mask ------------------------------------- */
2883 return -EINVAL; in hotkey_source_mask_store()
2886 return -ERESTARTSYS; in hotkey_source_mask_store()
2916 /* sysfs hotkey hotkey_poll_freq --------------------------------------- */
2931 return -EINVAL; in hotkey_poll_freq_store()
2934 return -ERESTARTSYS; in hotkey_poll_freq_store()
2950 /* sysfs hotkey radio_sw (pollable) ------------------------------------ */
2972 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_radio_sw_notify_change()
2976 /* sysfs hotkey tablet mode (pollable) --------------------------------- */
2994 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_tablet_mode_notify_change()
2998 /* sysfs wakeup reason (pollable) -------------------------------------- */
3010 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_reason_notify_change()
3014 /* sysfs wakeup hotunplug_complete (pollable) -------------------------- */
3027 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_hotunplug_complete_notify_change()
3031 /* sysfs adaptive kbd mode --------------------------------------------- */
3065 return -EINVAL; in adaptive_kbd_mode_store()
3082 /* --------------------------------------------------------------------- */
3120 /* Sync hw blocking state first if it is hw-blocked */ in tpacpi_send_radiosw_update()
3127 /* Sync hw blocking state last if it is hw-unblocked */ in tpacpi_send_radiosw_update()
3158 delete_attr_set(hotkey_dev_attributes, &tpacpi_pdev->dev.kobj); in hotkey_exit()
3174 tpacpi_inputdev->keybit); in hotkey_unmap()
3228 if (has_tablet_mode && !acpi_dev_present("BOSC0200", "1", -1)) in hotkey_init_tablet_mode()
3247 return -1; in hotkey_init_tablet_mode()
3263 * firmware at driver load time, which means the firm- in hotkey_init()
3267 * 2. You must be subscribed to the linux-thinkpad and in hotkey_init()
3268 * ibm-acpi-devel mailing lists, and you should read the in hotkey_init()
3271 * know the past history of problems with the thinkpad- in hotkey_init()
3275 * 3. Do not send thinkpad-acpi specific patches directly to in hotkey_init()
3276 * for merging, *ever*. Send them to the linux-acpi in hotkey_init()
3278 * through acpi-test and the ACPI maintainer. in hotkey_init()
3281 * Ask the thinkpad-acpi maintainer to do it, instead. in hotkey_init()
3313 * the built-in *extra* mixer. Never map it to control in hotkey_init()
3354 /* These should be enabled --only-- when ACPI video in hotkey_init()
3366 * react to it and reprograms the built-in *extra* mixer. in hotkey_init()
3370 * these over the regular keyboard, so these are no-ops, in hotkey_init()
3485 BUG_ON(tpacpi_inputdev->open != NULL || in hotkey_init()
3486 tpacpi_inputdev->close != NULL); in hotkey_init()
3516 return -ENOMEM; in hotkey_init()
3524 A30, R30, R31, T20-22, X20-21, X22-24. Detected by checking in hotkey_init()
3543 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3560 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3575 &tpacpi_pdev->dev.kobj, in hotkey_init()
3642 &tpacpi_pdev->dev.kobj); in hotkey_init()
3657 res = -ENOMEM; in hotkey_init()
3662 tpacpi_inputdev->keycodesize = TPACPI_HOTKEY_MAP_TYPESIZE; in hotkey_init()
3663 tpacpi_inputdev->keycodemax = TPACPI_HOTKEY_MAP_LEN; in hotkey_init()
3664 tpacpi_inputdev->keycode = hotkey_keycode_map; in hotkey_init()
3691 pr_notice("Disabling thinkpad-acpi brightness events by default...\n"); in hotkey_init()
3723 if (res < 0 && res != -ENXIO) { in hotkey_init()
3733 tpacpi_inputdev->open = &hotkey_inputdev_open; in hotkey_init()
3734 tpacpi_inputdev->close = &hotkey_inputdev_close; in hotkey_init()
3741 delete_attr_set(hotkey_dev_attributes, &tpacpi_pdev->dev.kobj); in hotkey_init()
3742 sysfs_remove_group(&tpacpi_pdev->dev.kobj, in hotkey_init()
3751 * mode, Web conference mode, Function mode and Lay-flat mode.
3780 return -EIO; in adaptive_keyboard_get_mode()
3790 return -EINVAL; in adaptive_keyboard_set_mode()
3792 if (!acpi_evalf(hkey_handle, NULL, "STRW", "vd", new_mode)) { in adaptive_keyboard_set_mode()
3794 return -EIO; in adaptive_keyboard_set_mode()
3803 size_t max_mode = ARRAY_SIZE(adaptive_keyboard_modes) - 1; in adaptive_keyboard_get_next_mode()
3857 TP_ACPI_HOTKEYSCAN_EXTENDED_START - in adaptive_keyboard_hotkey_notify_hotkey()
3863 keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY + in adaptive_keyboard_hotkey_notify_hotkey()
3884 /* 0x1000-0x1FFF: key presses */ in hotkey_notify_hotkey()
3899 scancode--; in hotkey_notify_hotkey()
3918 scancode -= (0x300 - TP_ACPI_HOTKEYSCAN_EXTENDED_START); in hotkey_notify_hotkey()
3934 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify_wakeup()
3954 /* how to auto-heal: */ in hotkey_notify_wakeup()
3964 pr_info("woke up due to a hot-unplug request...\n"); in hotkey_notify_wakeup()
3974 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify_dockevent()
4002 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify_usrevent()
4011 case TP_HKEY_EV_TABLET_TABLET: /* X41t-X61t: tablet mode */ in hotkey_notify_usrevent()
4012 case TP_HKEY_EV_TABLET_NOTEBOOK: /* X41t-X61t: normal mode */ in hotkey_notify_usrevent()
4036 /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */ in hotkey_notify_6xxx()
4048 /* Thermal event - pass on to event handler */ in hotkey_notify_6xxx()
4097 /* palm detected hovering the keyboard, forward to user-space in hotkey_notify_6xxx()
4121 ibm->acpi->device->pnp.device_class, in hotkey_notify()
4122 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4143 /* 0x1000-0x1FFF: key presses */ in hotkey_notify()
4148 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify()
4153 /* 0x3000-0x3FFF: bay-related wakeups */ in hotkey_notify()
4170 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify()
4175 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify()
4180 /* 0x6000-0x6FFF: thermal alarms/notices and in hotkey_notify()
4186 /* 0x7000-0x7FFF: misc */ in hotkey_notify()
4207 ibm->acpi->device->pnp.device_class, in hotkey_notify()
4208 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4246 if (!acpi_evalf(hkey_handle, NULL, "STRW", "vd", in hotkey_resume()
4253 /* procfs -------------------------------------------------------------- */
4264 return -ERESTARTSYS; in hotkey_read()
4299 return -ENODEV; in hotkey_write()
4302 return -ERESTARTSYS; in hotkey_write()
4312 res = -EPERM; in hotkey_write()
4321 res = -EINVAL; in hotkey_write()
4376 TP_ACPI_BLTH_GET_PWR_ON_RESUME = 0x01, /* Get power-on-resume state */
4395 return -EIO; in bluetooth_get_status()
4422 if (!acpi_evalf(hkey_handle, NULL, "SBDC", "vd", status)) in bluetooth_set_status()
4423 return -EIO; in bluetooth_set_status()
4428 /* sysfs bluetooth enable ---------------------------------------------- */
4447 /* --------------------------------------------------------------------- */
4466 if (!acpi_evalf(NULL, NULL, "\\BLTH", "vd", in bluetooth_shutdown()
4476 sysfs_remove_group(&tpacpi_pdev->dev.kobj, in bluetooth_exit()
4500 .ident = "ThinkPad A285 - 20MW",
4507 .ident = "ThinkPad A285 - 20MX",
4514 .ident = "ThinkPad A485 - 20MU",
4521 .ident = "ThinkPad A485 - 20MV",
4563 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ in bluetooth_init()
4597 res = sysfs_create_group(&tpacpi_pdev->dev.kobj, in bluetooth_init()
4607 /* procfs -------------------------------------------------------------- */
4651 return -EIO; in wan_get_status()
4678 if (!acpi_evalf(hkey_handle, NULL, "SWAN", "vd", status)) in wan_set_status()
4679 return -EIO; in wan_set_status()
4684 /* sysfs wan enable ---------------------------------------------------- */
4704 /* --------------------------------------------------------------------- */
4723 if (!acpi_evalf(NULL, NULL, "\\WGSV", "vd", in wan_shutdown()
4733 sysfs_remove_group(&tpacpi_pdev->dev.kobj, in wan_exit()
4784 res = sysfs_create_group(&tpacpi_pdev->dev.kobj, in wan_init()
4795 /* procfs -------------------------------------------------------------- */
4837 return -EIO; in uwb_get_status()
4863 if (!acpi_evalf(hkey_handle, NULL, "SUWB", "vd", status)) in uwb_set_status()
4864 return -EIO; in uwb_set_status()
4869 /* --------------------------------------------------------------------- */
5027 return -EIO; in video_outputsw_get()
5032 return -EIO; in video_outputsw_get()
5036 return -EIO; in video_outputsw_get()
5041 if (!acpi_evalf(NULL, NULL, "\\VUPS", "vd", 1) || in video_outputsw_get()
5043 return -EIO; in video_outputsw_get()
5047 if (!acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0) || in video_outputsw_get()
5049 return -EIO; in video_outputsw_get()
5053 return -EIO; in video_outputsw_get()
5058 return -ENOSYS; in video_outputsw_get()
5087 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_set()
5088 return -EIO; in video_outputsw_set()
5092 res = acpi_evalf(NULL, NULL, "\\VUPS", "vd", 0x80) && in video_outputsw_set()
5096 return -ENOSYS; in video_outputsw_set()
5099 return (res) ? 0 : -EIO; in video_outputsw_set()
5109 return -EIO; in video_autosw_get()
5114 return -EIO; in video_autosw_get()
5117 return -ENOSYS; in video_autosw_get()
5125 if (!acpi_evalf(vid_handle, NULL, "_DOS", "vd", (enable) ? 1 : 0)) in video_autosw_set()
5126 return -EIO; in video_autosw_set()
5153 return -ENOSYS; in video_outputsw_cycle()
5156 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_cycle()
5157 return -EIO; in video_outputsw_cycle()
5160 return (res) ? 0 : -EIO; in video_outputsw_cycle()
5168 0 : -EIO; in video_expand_toggle()
5171 0 : -EIO; in video_expand_toggle()
5174 0 : -EIO; in video_expand_toggle()
5176 return -ENOSYS; in video_expand_toggle()
5192 return -EPERM; in video_read()
5225 return -ENODEV; in video_write()
5229 return -EPERM; in video_write()
5266 return -EINVAL; in video_write()
5302 return -ENXIO; in kbdlight_set_level()
5307 ret = -EIO; in kbdlight_set_level()
5321 return -ENXIO; in kbdlight_get_level()
5324 return -EIO; in kbdlight_get_level()
5359 * b010100000010000000XX - ThinkPad X1 Carbon 3rd in kbdlight_is_supported()
5360 * b110100010010000000XX - ThinkPad x230 in kbdlight_is_supported()
5361 * b010100000010000000XX - ThinkPad x240 in kbdlight_is_supported()
5362 * b010100000010000000XX - ThinkPad W541 in kbdlight_is_supported()
5366 * b10100001000000000000 - ThinkPad x230 in kbdlight_is_supported()
5367 * b10110001000000000000 - ThinkPad E430 in kbdlight_is_supported()
5368 * b00000000000000000000 - ThinkPad E450 in kbdlight_is_supported()
5421 rc = led_classdev_register(&tpacpi_pdev->dev, in kbdlight_init()
5446 if (ret == 0 && !(led_cdev->flags & LED_SUSPENDED)) in kbdlight_set_level_and_update()
5447 led_cdev->brightness = level; in kbdlight_set_level_and_update()
5473 int res, level = -EINVAL; in kbdlight_write()
5476 return -ENODEV; in kbdlight_write()
5485 return -EINVAL; in kbdlight_write()
5523 TPACPI_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
5532 return -EIO; in light_get_status()
5536 return -ENXIO; in light_get_status()
5545 rc = acpi_evalf(cmos_handle, NULL, NULL, "vd", in light_set_status()
5550 rc = acpi_evalf(lght_handle, NULL, NULL, "vd", in light_set_status()
5553 return (rc) ? 0 : -EIO; in light_set_status()
5556 return -ENXIO; in light_set_status()
5607 rc = led_classdev_register(&tpacpi_pdev->dev, in light_init()
5651 return -ENODEV; in light_write()
5659 return -EINVAL; in light_write()
5676 /* sysfs cmos_command -------------------------------------------------- */
5685 return -EINVAL; in cmos_command_store()
5693 /* --------------------------------------------------------------------- */
5707 res = device_create_file(&tpacpi_pdev->dev, &dev_attr_cmos_command); in cmos_init()
5716 device_remove_file(&tpacpi_pdev->dev, &dev_attr_cmos_command); in cmos_exit()
5722 R30, R31, T20-22, X20-21 */ in cmos_read()
5727 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n"); in cmos_read()
5743 return -EINVAL; in cmos_write()
5767 TPACPI_LED_OLD, /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
5820 return -EIO; in led_get_status()
5829 return -ENXIO; in led_get_status()
5848 return -EINVAL; in led_set_status()
5850 return -EPERM; in led_set_status()
5853 return -EIO; in led_set_status()
5856 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */ in led_set_status()
5858 return -EINVAL; in led_set_status()
5860 return -EPERM; in led_set_status()
5872 return -EINVAL; in led_set_status()
5874 return -EPERM; in led_set_status()
5877 return -EIO; in led_set_status()
5880 return -ENXIO; in led_set_status()
5898 else if (tpacpi_led_state_cache[data->led] != TPACPI_LED_BLINK) in led_sysfs_set()
5903 return led_set_status(data->led, new_state); in led_sysfs_set()
5918 return -EINVAL; in led_sysfs_blink_set()
5920 return led_set_status(data->led, TPACPI_LED_BLINK); in led_sysfs_blink_set()
5930 rc = led_get_status(data->led); in led_sysfs_get()
5964 return led_classdev_register(&tpacpi_pdev->dev, &tpacpi_leds[led].led_classdev); in tpacpi_init_led()
5992 /* (1) - may have excess leds enabled on MSB */
6022 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ in led_init_detect_mode()
6068 return -ENOMEM; in led_init()
6072 tpacpi_leds[i].led = -1; in led_init()
6107 return -EIO; in led_read()
6113 seq_printf(m, "commands:\t<led> on, <led> off, <led> blink (<led> is 0-15)\n"); in led_read()
6125 return -ENODEV; in led_write()
6129 return -EINVAL; in led_write()
6131 if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1)) in led_write()
6132 return -ENODEV; in led_write()
6135 return -ENODEV; in led_write()
6144 return -EINVAL; in led_write()
6172 TPACPI_Q_IBM('I', 'U', TPACPI_BEEP_Q1), /* 570E - unverified */
6200 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n"); in beep_read()
6212 return -ENODEV; in beep_write()
6219 return -EINVAL; in beep_write()
6223 return -EIO; in beep_write()
6225 if (!acpi_evalf(beep_handle, NULL, NULL, "vd", in beep_write()
6227 return -EIO; in beep_write()
6246 TPACPI_THERMAL_ACPI_TMP07, /* Use ACPI TMP0-7 */
6247 TPACPI_THERMAL_ACPI_UPDT, /* Use ACPI TMP0-7 with UPDT */
6255 TP_EC_THERMAL_TMP_NA = -128, /* ACPI EC sensor not available */
6257 TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */
6268 /* idx is zero-based */
6282 idx -= 8; in thermal_get_sensor()
6289 return -EIO; in thermal_get_sensor()
6299 return -EIO; in thermal_get_sensor()
6301 return -EIO; in thermal_get_sensor()
6302 *value = (t - 2732) * 100; in thermal_get_sensor()
6311 return -EIO; in thermal_get_sensor()
6312 if (t > 127 || t < -127) in thermal_get_sensor()
6321 return -ENOSYS; in thermal_get_sensor()
6324 return -EINVAL; in thermal_get_sensor()
6336 return -EINVAL; in thermal_get_sensors()
6342 res = thermal_get_sensor(i, &s->temp[i]); in thermal_get_sensors()
6371 /* sysfs temp##_input -------------------------------------------------- */
6379 int idx = sensor_attr->index; in thermal_temp_input_show()
6387 return -ENXIO; in thermal_temp_input_show()
6449 /* --------------------------------------------------------------------- */
6465 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for in thermal_init()
6466 * non-implemented, thermal sensors return 0x80 when in thermal_init()
6519 res = sysfs_create_group(&tpacpi_hwmon->kobj, in thermal_init()
6527 res = sysfs_create_group(&tpacpi_hwmon->kobj, in thermal_init()
6544 sysfs_remove_group(&tpacpi_hwmon->kobj, in thermal_exit()
6550 sysfs_remove_group(&tpacpi_hwmon->kobj, in thermal_exit()
6571 for (i = 0; i < (n - 1); i++) in thermal_read()
6594 * CMOS NVRAM byte 0x5E, bits 0-3.
6601 * Bit 3-0: backlight brightness level
6622 TPACPI_BRGHT_MODE_UCMS_STEP, /* UCMS step-based control */
6701 return -EIO; in tpacpi_brightness_get_raw()
6705 return -ENXIO; in tpacpi_brightness_get_raw()
6716 return -EIO; in tpacpi_brightness_set_ec()
6721 return -EIO; in tpacpi_brightness_set_ec()
6740 inc = (value > current_value) ? 1 : -1; in tpacpi_brightness_set_ucmsstep()
6744 return -EIO; in tpacpi_brightness_set_ucmsstep()
6755 return -EINVAL; in brightness_set()
6773 res = -ENXIO; in brightness_set()
6780 /* sysfs backlight class ----------------------------------------------- */
6785 (bd->props.fb_blank == FB_BLANK_UNBLANK && in brightness_update_status()
6786 bd->props.power == FB_BLANK_UNBLANK) ? in brightness_update_status()
6787 bd->props.brightness : 0; in brightness_update_status()
6827 /* --------------------------------------------------------------------- */
6845 list_for_each_entry(child, &device->children, node) { in tpacpi_query_bcl_levels()
6846 acpi_status status = acpi_evaluate_object(child->handle, "_BCL", in tpacpi_query_bcl_levels()
6854 if (!obj || (obj->type != ACPI_TYPE_PACKAGE)) { in tpacpi_query_bcl_levels()
6859 rc = obj->package.count; in tpacpi_query_bcl_levels()
6883 return (bcl_levels > 2) ? (bcl_levels - 2) : 0; in tpacpi_check_std_acpi_brightness_support()
6900 TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), /* R50,51 T40-42 */
6946 bright_maxlvl = b - 1; in tpacpi_detect_brightness_capabilities()
6997 return -EINVAL; in brightness_init()
7008 "driver auto-selected brightness_mode=%d\n", in brightness_init()
7016 return -EINVAL; in brightness_init()
7090 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in brightness_read()
7113 level--; in brightness_write()
7118 return -EINVAL; in brightness_write()
7132 return (rc == -EINTR) ? -ERESTARTSYS : rc; in brightness_write()
7157 * Bit 3-0: Volume
7161 * bits 3-0 (volume). Other bits in NVRAM may have other functions,
7173 * To avoid confusing userspace, we simply disable all EC-based mute
7184 #define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1)
7186 #define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1)
7217 TPACPI_VOL_MODE_UCMS_STEP, /* UCMS step-based control: N/A */
7247 * TP_NVRAM_ADDR_MIXER, as we need to do read-modify-write
7303 return -EIO; in volume_get_status_ec()
7320 return -EIO; in volume_set_status_ec()
7345 return -EINTR; in __volume_set_mute_ec()
7390 return -EINVAL; in __volume_set_volume_ec()
7393 return -EINTR; in __volume_set_volume_ec()
7417 return -ENODEV; in volume_set_software_mute()
7422 return -EIO; in volume_set_software_mute()
7431 return -EIO; in volume_set_software_mute()
7440 * startup. Just on case there are SAUM-capable ThinkPads in volume_set_software_mute()
7474 if (alsa_card && alsa_card->private_data) { in volume_alsa_notify_change()
7475 d = alsa_card->private_data; in volume_alsa_notify_change()
7476 if (d->ctl_mute_id) in volume_alsa_notify_change()
7479 d->ctl_mute_id); in volume_alsa_notify_change()
7480 if (d->ctl_vol_id) in volume_alsa_notify_change()
7483 d->ctl_vol_id); in volume_alsa_notify_change()
7490 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in volume_alsa_vol_info()
7491 uinfo->count = 1; in volume_alsa_vol_info()
7492 uinfo->value.integer.min = 0; in volume_alsa_vol_info()
7493 uinfo->value.integer.max = TP_EC_VOLUME_MAX; in volume_alsa_vol_info()
7507 ucontrol->value.integer.value[0] = s & TP_EC_AUDIO_LVL_MSK; in volume_alsa_vol_get()
7515 ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7516 return volume_alsa_set_volume(ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7531 ucontrol->value.integer.value[0] = in volume_alsa_mute_get()
7540 ucontrol->value.integer.value[0] ? in volume_alsa_mute_put()
7542 return volume_alsa_set_mute(!ucontrol->value.integer.value[0]); in volume_alsa_mute_put()
7604 rc = snd_card_new(&tpacpi_pdev->dev, in volume_create_alsa_mixer()
7612 BUG_ON(!card->private_data); in volume_create_alsa_mixer()
7613 data = card->private_data; in volume_create_alsa_mixer()
7614 data->card = card; in volume_create_alsa_mixer()
7616 strlcpy(card->driver, TPACPI_ALSA_DRVNAME, in volume_create_alsa_mixer()
7617 sizeof(card->driver)); in volume_create_alsa_mixer()
7618 strlcpy(card->shortname, TPACPI_ALSA_SHRTNAME, in volume_create_alsa_mixer()
7619 sizeof(card->shortname)); in volume_create_alsa_mixer()
7620 snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s", in volume_create_alsa_mixer()
7623 snprintf(card->longname, sizeof(card->longname), in volume_create_alsa_mixer()
7624 "%s at EC reg 0x%02x, fw %s", card->shortname, TP_EC_AUDIO, in volume_create_alsa_mixer()
7646 data->ctl_vol_id = &ctl_vol->id; in volume_create_alsa_mixer()
7655 data->ctl_mute_id = &ctl_mute->id; in volume_create_alsa_mixer()
7671 #define TPACPI_VOL_Q_MUTEONLY 0x0001 /* Mute-only control available */
7690 /* Whitelist mute-only on all Lenovo by default */
7712 return -EINVAL; in volume_init()
7721 return -EINVAL; in volume_init()
7757 "using user-supplied volume_capabilities=%d\n", in volume_init()
7765 "driver auto-selected volume_mode=%d\n", in volume_init()
7769 "using user-supplied volume_mode=%d\n", in volume_init()
7822 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in volume_read()
7849 return -EPERM; in volume_write()
7871 new_level--; in volume_write()
7884 return -EINVAL; in volume_write()
7899 return (rc == -EINTR) ? -ERESTARTSYS : rc; in volume_write()
7972 * Speeds up fan to 100% duty-cycle, which is far above
7975 * 5-3 unused in some models. Extra bits for fan level
7978 * 2-0 fan level (0..7 usually)
7991 * ----
7996 * This register is present on all ThinkPads with a new-style EC, and
8002 * Unfortunately a lot of ThinkPads with new-style ECs but whose firmware
8016 * ----
8028 * So far, only the firmware for the X60/X61 non-tablet versions
8029 * seem to support this (firmware TP-7M).
8063 TPACPI_FAN_LAST_LEVEL = 0x100, /* Use cached last-seen fan level */
8069 TPACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */
8107 "JFNS", /* 770x-JL */
8122 * Enable for TP-1Y (T43), TP-78 (R51e), TP-76 (R52),
8123 * TP-70 (T43, R52), which are known to be buggy.
8209 return -EIO; in fan_get_status()
8219 return -EIO; in fan_get_status()
8229 return -ENXIO; in fan_get_status()
8241 return -ERESTARTSYS; in fan_get_status_safe()
8263 return -EIO; in fan_get_speed()
8266 return -EIO; in fan_get_speed()
8274 return -ENXIO; in fan_get_speed()
8289 return -EIO; in fan2_get_speed()
8294 return -EIO; in fan2_get_speed()
8302 return -ENXIO; in fan2_get_speed()
8311 return -EPERM; in fan_set_level()
8316 return -EINVAL; in fan_set_level()
8320 !acpi_evalf(sfan_handle, NULL, NULL, "vd", level)) { in fan_set_level()
8326 if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", level)) in fan_set_level()
8327 return -EIO; in fan_set_level()
8335 return -EINVAL; in fan_set_level()
8354 return -EIO; in fan_set_level()
8360 return -ENXIO; in fan_set_level()
8373 return -EPERM; in fan_set_level_safe()
8376 return -ERESTARTSYS; in fan_set_level_safe()
8395 return -EPERM; in fan_set_enable()
8398 return -ERESTARTSYS; in fan_set_enable()
8414 rc = -EIO; in fan_set_enable()
8431 if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", s)) in fan_set_enable()
8432 rc = -EIO; in fan_set_enable()
8438 rc = -ENXIO; in fan_set_enable()
8455 return -EPERM; in fan_set_disable()
8458 return -ERESTARTSYS; in fan_set_disable()
8465 rc = -EIO; in fan_set_disable()
8473 if (!acpi_evalf(sfan_handle, NULL, NULL, "vd", 0x00)) in fan_set_disable()
8474 rc = -EIO; in fan_set_disable()
8480 rc = -ENXIO; in fan_set_disable()
8496 return -EPERM; in fan_set_speed()
8499 return -ERESTARTSYS; in fan_set_speed()
8507 rc = -EIO; in fan_set_speed()
8509 rc = -EINVAL; in fan_set_speed()
8513 rc = -ENXIO; in fan_set_speed()
8571 /* sysfs fan pwm1_enable ----------------------------------------------- */
8601 return -EINVAL; in fan_pwm1_enable_store()
8617 /* reserved for software-controlled auto mode */ in fan_pwm1_enable_store()
8618 return -ENOSYS; in fan_pwm1_enable_store()
8620 return -EINVAL; in fan_pwm1_enable_store()
8624 if (res == -ENXIO) in fan_pwm1_enable_store()
8625 return -EINVAL; in fan_pwm1_enable_store()
8637 /* sysfs fan pwm1 ------------------------------------------------------ */
8668 return -EINVAL; in fan_pwm1_store()
8673 /* scale down from 0-255 to 0-7 */ in fan_pwm1_store()
8677 return -ERESTARTSYS; in fan_pwm1_store()
8683 if (rc == -ENXIO) in fan_pwm1_store()
8684 rc = -EINVAL; in fan_pwm1_store()
8697 /* sysfs fan fan1_input ------------------------------------------------ */
8714 /* sysfs fan fan2_input ------------------------------------------------ */
8731 /* sysfs fan fan_watchdog (hwmon driver) ------------------------------- */
8743 return -EINVAL; in fan_watchdog_store()
8746 return -EPERM; in fan_watchdog_store()
8757 /* --------------------------------------------------------------------- */
8822 /* all other ThinkPads: note that even old-style in fan_init()
8845 /* 570, 770x-JL */ in fan_init()
8893 fan_attributes[ARRAY_SIZE(fan_attributes)-2] = in fan_init()
8896 rc = sysfs_create_group(&tpacpi_hwmon->kobj, in fan_init()
8904 sysfs_remove_group(&tpacpi_hwmon->kobj, in fan_init()
8919 sysfs_remove_group(&tpacpi_hwmon->kobj, &fan_attr_group); in fan_exit()
9054 seq_printf(m, " (<level> is 0-7)\n"); in fan_read()
9058 seq_printf(m, " (<level> is 0-7, auto, disengaged, full-speed)\n"); in fan_read()
9065 "commands:\twatchdog <timeout> (<timeout> is 0 (off), 1-120 (seconds))\n"); in fan_read()
9068 seq_printf(m, "commands:\tspeed <speed> (<speed> is 0-65535)\n"); in fan_read()
9080 (strlencmp(cmd, "level full-speed") == 0)) in fan_write_cmd_level()
9086 if (*rc == -ENXIO) in fan_write_cmd_level()
9102 if (*rc == -ENXIO) in fan_write_cmd_enable()
9117 if (*rc == -ENXIO) in fan_write_cmd_disable()
9137 if (*rc == -ENXIO) in fan_write_cmd_speed()
9155 *rc = -EINVAL; in fan_write_cmd_watchdog()
9181 rc = -EINVAL; in fan_write()
9229 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_on_off()
9230 pr_warn("Thinkpad ACPI has no %s interface.\n", t->name); in mute_led_on_off()
9231 return -EIO; in mute_led_on_off()
9234 if (!acpi_evalf(hkey_handle, &output, t->name, "dd", in mute_led_on_off()
9235 state ? t->on_value : t->off_value)) in mute_led_on_off()
9236 return -EIO; in mute_led_on_off()
9238 t->state = state; in mute_led_on_off()
9247 if (t->state < 0 || t->state == on) in tpacpi_led_set()
9248 return t->state; in tpacpi_led_set()
9269 .default_trigger = "audio-mute",
9275 .default_trigger = "audio-micmute",
9286 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_init()
9287 t->state = -ENODEV; in mute_led_init()
9292 err = led_classdev_register(&tpacpi_pdev->dev, &mute_led_cdev[i]); in mute_led_init()
9294 while (i--) in mute_led_init()
9318 if (t->state >= 0) in mute_led_resume()
9319 mute_led_on_off(t, t->state); in mute_led_resume()
9401 return -ENODEV; in tpacpi_battery_get()
9408 return -ENODEV; in tpacpi_battery_get()
9422 return -EINVAL; in tpacpi_battery_get()
9431 /* The battery ID is in bits 8-9, 2 bits */ in tpacpi_battery_set()
9439 return -ENODEV; in tpacpi_battery_set()
9445 return -ENODEV; in tpacpi_battery_set()
9450 return -EINVAL; in tpacpi_battery_set()
9470 return -ENODEV; in tpacpi_battery_probe()
9479 return -ENODEV; in tpacpi_battery_probe()
9483 return -ENODEV; in tpacpi_battery_probe()
9489 return -ENODEV; in tpacpi_battery_probe()
9495 return -ENODEV; in tpacpi_battery_probe()
9499 return -ENODEV; in tpacpi_battery_probe()
9535 struct power_supply *supply = to_power_supply(dev); in tpacpi_battery_store() local
9551 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_store()
9562 return -ENODEV; in tpacpi_battery_store()
9565 return -EINVAL; in tpacpi_battery_store()
9567 return -EINVAL; in tpacpi_battery_store()
9569 return -ENODEV; in tpacpi_battery_store()
9575 return -ENODEV; in tpacpi_battery_store()
9578 return -EINVAL; in tpacpi_battery_store()
9580 return -EINVAL; in tpacpi_battery_store()
9590 return -EINVAL; in tpacpi_battery_store()
9594 return -EINVAL; in tpacpi_battery_store()
9603 struct power_supply *supply = to_power_supply(dev); in tpacpi_battery_show() local
9618 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_show()
9622 return -ENODEV; in tpacpi_battery_show()
9683 int batteryid = tpacpi_battery_get_id(battery->desc->name); in tpacpi_battery_add()
9686 return -ENODEV; in tpacpi_battery_add()
9687 if (device_add_groups(&battery->dev, tpacpi_battery_groups)) in tpacpi_battery_add()
9688 return -ENODEV; in tpacpi_battery_add()
9694 device_remove_groups(&battery->dev, tpacpi_battery_groups); in tpacpi_battery_remove()
9754 return -EIO; in lcdshadow_on_off()
9758 return -EIO; in lcdshadow_on_off()
9779 lcdshadow_state = -ENODEV; in tpacpi_lcdshadow_init()
9784 lcdshadow_state = -EIO; in tpacpi_lcdshadow_init()
9785 return -EIO; in tpacpi_lcdshadow_init()
9788 lcdshadow_state = -ENODEV; in tpacpi_lcdshadow_init()
9817 int res, state = -EINVAL; in lcdshadow_write()
9820 return -ENODEV; in lcdshadow_write()
9829 return -EINVAL; in lcdshadow_write()
9852 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "dytc_lapmode"); in dytc_lapmode_notify_change()
9861 return -ENODEV; in dytc_command()
9864 return -EIO; in dytc_command()
9919 if (err == -ENODEV) in tpacpi_dytc_init()
9925 /* Platform supports this feature - create the group */ in tpacpi_dytc_init()
9926 err = sysfs_create_group(&tpacpi_pdev->dev.kobj, &dytc_attr_group); in tpacpi_dytc_init()
9932 sysfs_remove_group(&tpacpi_pdev->dev.kobj, &dytc_attr_group); in dytc_exit()
9998 /* --------------------------------------------------------------------- */
10020 dbg_printk(TPACPI_DBG_EXIT, "removing %s\n", ibm->name); in ibm_exit()
10022 list_del_init(&ibm->all_drivers); in ibm_exit()
10024 if (ibm->flags.acpi_notify_installed) { in ibm_exit()
10026 "%s: acpi_remove_notify_handler\n", ibm->name); in ibm_exit()
10027 BUG_ON(!ibm->acpi); in ibm_exit()
10028 acpi_remove_notify_handler(*ibm->acpi->handle, in ibm_exit()
10029 ibm->acpi->type, in ibm_exit()
10031 ibm->flags.acpi_notify_installed = 0; in ibm_exit()
10034 if (ibm->flags.proc_created) { in ibm_exit()
10036 "%s: remove_proc_entry\n", ibm->name); in ibm_exit()
10037 remove_proc_entry(ibm->name, proc_dir); in ibm_exit()
10038 ibm->flags.proc_created = 0; in ibm_exit()
10041 if (ibm->flags.acpi_driver_registered) { in ibm_exit()
10043 "%s: acpi_bus_unregister_driver\n", ibm->name); in ibm_exit()
10044 BUG_ON(!ibm->acpi); in ibm_exit()
10045 acpi_bus_unregister_driver(ibm->acpi->driver); in ibm_exit()
10046 kfree(ibm->acpi->driver); in ibm_exit()
10047 ibm->acpi->driver = NULL; in ibm_exit()
10048 ibm->flags.acpi_driver_registered = 0; in ibm_exit()
10051 if (ibm->flags.init_called && ibm->exit) { in ibm_exit()
10052 ibm->exit(); in ibm_exit()
10053 ibm->flags.init_called = 0; in ibm_exit()
10056 dbg_printk(TPACPI_DBG_INIT, "finished removing %s\n", ibm->name); in ibm_exit()
10062 struct ibm_struct *ibm = iibm->data; in ibm_init()
10067 INIT_LIST_HEAD(&ibm->all_drivers); in ibm_init()
10069 if (ibm->flags.experimental && !experimental) in ibm_init()
10073 "probing for %s\n", ibm->name); in ibm_init()
10075 if (iibm->init) { in ibm_init()
10076 ret = iibm->init(iibm); in ibm_init()
10082 ibm->flags.init_called = 1; in ibm_init()
10085 if (ibm->acpi) { in ibm_init()
10086 if (ibm->acpi->hid) { in ibm_init()
10092 if (ibm->acpi->notify) { in ibm_init()
10094 if (ret == -ENODEV) { in ibm_init()
10096 ibm->name); in ibm_init()
10106 "%s installed\n", ibm->name); in ibm_init()
10108 if (ibm->read) { in ibm_init()
10109 umode_t mode = iibm->base_procfs_mode; in ibm_init()
10113 if (ibm->write) in ibm_init()
10115 entry = proc_create_data(ibm->name, mode, proc_dir, in ibm_init()
10118 pr_err("unable to create proc entry %s\n", ibm->name); in ibm_init()
10119 ret = -ENODEV; in ibm_init()
10122 ibm->flags.proc_created = 1; in ibm_init()
10125 list_add_tail(&ibm->all_drivers, &tpacpi_all_drivers); in ibm_init()
10132 ibm->name, ret); in ibm_init()
10155 * Ancient 570/600 and -SL lacks (#.##c) in tpacpi_parse_fw_id()
10181 * ---------------------------------------------------- in find_new_ec_fwstr()
10194 if (dm->type != 140 || dm->length < 0x0F || in find_new_ec_fwstr()
10204 /* returns 0 - probe ok, or < 0 - probe error.
10206 * On error, kfree() cleanup on tp->* is not performed, caller must do it */
10216 return -EINVAL; in get_thinkpad_model_data()
10221 tp->vendor = PCI_VENDOR_ID_IBM; in get_thinkpad_model_data()
10223 tp->vendor = PCI_VENDOR_ID_LENOVO; in get_thinkpad_model_data()
10228 tp->bios_version_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
10229 if (s && !tp->bios_version_str) in get_thinkpad_model_data()
10230 return -ENOMEM; in get_thinkpad_model_data()
10233 t = tpacpi_parse_fw_id(tp->bios_version_str, in get_thinkpad_model_data()
10234 &tp->bios_model, &tp->bios_release); in get_thinkpad_model_data()
10241 * up-to-date BIOS or they will not be detected. in get_thinkpad_model_data()
10246 if (sscanf(dev->name, in get_thinkpad_model_data()
10247 "IBM ThinkPad Embedded Controller -[%17c", in get_thinkpad_model_data()
10249 ec_fw_string[sizeof(ec_fw_string) - 1] = 0; in get_thinkpad_model_data()
10260 tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL); in get_thinkpad_model_data()
10261 if (!tp->ec_version_str) in get_thinkpad_model_data()
10262 return -ENOMEM; in get_thinkpad_model_data()
10265 &tp->ec_model, &tp->ec_release); in get_thinkpad_model_data()
10275 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
10276 if (!tp->model_str) in get_thinkpad_model_data()
10277 return -ENOMEM; in get_thinkpad_model_data()
10281 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
10282 if (!tp->model_str) in get_thinkpad_model_data()
10283 return -ENOMEM; in get_thinkpad_model_data()
10288 tp->nummodel_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
10289 if (s && !tp->nummodel_str) in get_thinkpad_model_data()
10290 return -ENOMEM; in get_thinkpad_model_data()
10300 return -ENODEV; in probe_for_thinkpad()
10304 return -ENODEV; in probe_for_thinkpad()
10307 * Non-ancient models have better DMI tagging, but very old models in probe_for_thinkpad()
10319 return -ENODEV; in probe_for_thinkpad()
10323 return -ENODEV; in probe_for_thinkpad()
10440 if (!kp || !kp->name || !val) in set_ibm_param()
10441 return -EINVAL; in set_ibm_param()
10447 if (!ibm || !ibm->name) in set_ibm_param()
10450 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { in set_ibm_param()
10451 if (strlen(val) > sizeof(ibms_init[i].param) - 1) in set_ibm_param()
10452 return -ENOSPC; in set_ibm_param()
10458 return -EINVAL; in set_ibm_param()
10463 "Enables experimental features when non-zero");
10466 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
10470 "Attempts to load the driver even on a mis-identified ThinkPad when true");
10513 …MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command at module load, see documentatio…
10612 /* Driver-level probe */ in thinkpad_acpi_module_init()
10637 return -ENOMEM; in thinkpad_acpi_module_init()
10644 return -ENODEV; in thinkpad_acpi_module_init()
10678 tpacpi_pdev = platform_device_register_simple(TPACPI_DRVR_NAME, -1, in thinkpad_acpi_module_init()
10689 -1, NULL, 0); in thinkpad_acpi_module_init()
10699 &tpacpi_sensors_pdev->dev, TPACPI_NAME, NULL, NULL); in thinkpad_acpi_module_init()
10712 return -ENOMEM; in thinkpad_acpi_module_init()
10715 tpacpi_inputdev->name = "ThinkPad Extra Buttons"; in thinkpad_acpi_module_init()
10716 tpacpi_inputdev->phys = TPACPI_DRVR_NAME "/input0"; in thinkpad_acpi_module_init()
10717 tpacpi_inputdev->id.bustype = BUS_HOST; in thinkpad_acpi_module_init()
10718 tpacpi_inputdev->id.vendor = thinkpad_id.vendor; in thinkpad_acpi_module_init()
10719 tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT; in thinkpad_acpi_module_init()
10720 tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION; in thinkpad_acpi_module_init()
10721 tpacpi_inputdev->dev.parent = &tpacpi_pdev->dev; in thinkpad_acpi_module_init()
10731 ret = ibms_init[i].data->write(ibms_init[i].param); in thinkpad_acpi_module_init()