Lines Matching +full:battery +full:- +full:profile

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>
74 #include <acpi/battery.h>
120 /* Misc NVRAM-related */
159 /* Hotkey-related */
175 TP_HKEY_EV_WKUP_S3_BATLOW = 0x2313, /* battery empty, S3 */
176 TP_HKEY_EV_WKUP_S4_BATLOW = 0x2413, /* battery empty, S4 */
178 /* Auto-sleep after eject request */
195 /* User-interface events */
207 /* Key-related user-interface events */
213 TP_HKEY_EV_ALARM_BAT_HOT = 0x6011, /* battery too hot */
214 TP_HKEY_EV_ALARM_BAT_XHOT = 0x6012, /* battery critically hot */
224 /* AC-related events */
227 /* Further user-interface events */
242 #define TPACPI_URL "http://ibm-acpi.sf.net/"
243 #define TPACPI_MAIL "ibm-acpi-devel@lists.sourceforge.net"
270 * Driver-wide structs and misc. variables
367 char *ec_version_str; /* Something like 1ZHT51WW-1.04a */
375 char *nummodel_str; /* 9384A9C for a 9384-A9C model */
456 * two or three characters from the set [0-9A-Z], i.e. base 36.
508 * tpacpi_check_quirks() - search BIOS/EC version on a list
525 if ((qlist->vendor == thinkpad_id.vendor || in tpacpi_check_quirks()
526 qlist->vendor == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
527 (qlist->bios == thinkpad_id.bios_model || in tpacpi_check_quirks()
528 qlist->bios == TPACPI_MATCH_ANY) && in tpacpi_check_quirks()
529 (qlist->ec == thinkpad_id.ec_model || in tpacpi_check_quirks()
530 qlist->ec == TPACPI_MATCH_ANY)) in tpacpi_check_quirks()
531 return qlist->quirks; in tpacpi_check_quirks()
533 qlist_size--; in tpacpi_check_quirks()
575 "\\CMOS", /* A3x, G4x, R32, T23, T30, X22-24, X30 */
701 return -ENXIO; in issue_thinkpad_cmos_command()
704 return -EIO; in issue_thinkpad_cmos_command()
793 if (!ibm || !ibm->acpi || !ibm->acpi->notify) in dispatch_acpi_notify()
796 ibm->acpi->notify(ibm, event); in dispatch_acpi_notify()
803 BUG_ON(!ibm->acpi); in setup_acpi_notify()
805 if (!*ibm->acpi->handle) in setup_acpi_notify()
809 "setting up ACPI notify for %s\n", ibm->name); in setup_acpi_notify()
811 ibm->acpi->device = acpi_fetch_acpi_dev(*ibm->acpi->handle); in setup_acpi_notify()
812 if (!ibm->acpi->device) { in setup_acpi_notify()
813 pr_err("acpi_fetch_acpi_dev(%s) failed\n", ibm->name); in setup_acpi_notify()
814 return -ENODEV; in setup_acpi_notify()
817 ibm->acpi->device->driver_data = ibm; in setup_acpi_notify()
818 sprintf(acpi_device_class(ibm->acpi->device), "%s/%s", in setup_acpi_notify()
820 ibm->name); in setup_acpi_notify()
822 status = acpi_install_notify_handler(*ibm->acpi->handle, in setup_acpi_notify()
823 ibm->acpi->type, dispatch_acpi_notify, ibm); in setup_acpi_notify()
827 ibm->name); in setup_acpi_notify()
830 ibm->name, acpi_format_exception(status)); in setup_acpi_notify()
832 return -ENODEV; in setup_acpi_notify()
834 ibm->flags.acpi_notify_installed = 1; in setup_acpi_notify()
848 "registering %s as an ACPI driver\n", ibm->name); in register_tpacpi_subdriver()
850 BUG_ON(!ibm->acpi); in register_tpacpi_subdriver()
852 ibm->acpi->driver = kzalloc(sizeof(struct acpi_driver), GFP_KERNEL); in register_tpacpi_subdriver()
853 if (!ibm->acpi->driver) { in register_tpacpi_subdriver()
854 pr_err("failed to allocate memory for ibm->acpi->driver\n"); in register_tpacpi_subdriver()
855 return -ENOMEM; in register_tpacpi_subdriver()
858 sprintf(ibm->acpi->driver->name, "%s_%s", TPACPI_NAME, ibm->name); in register_tpacpi_subdriver()
859 ibm->acpi->driver->ids = ibm->acpi->hid; in register_tpacpi_subdriver()
861 ibm->acpi->driver->ops.add = &tpacpi_device_add; in register_tpacpi_subdriver()
863 rc = acpi_bus_register_driver(ibm->acpi->driver); in register_tpacpi_subdriver()
866 ibm->name, rc); in register_tpacpi_subdriver()
867 kfree(ibm->acpi->driver); in register_tpacpi_subdriver()
868 ibm->acpi->driver = NULL; in register_tpacpi_subdriver()
870 ibm->flags.acpi_driver_registered = 1; in register_tpacpi_subdriver()
886 struct ibm_struct *ibm = m->private; in dispatch_proc_show()
888 if (!ibm || !ibm->read) in dispatch_proc_show()
889 return -EINVAL; in dispatch_proc_show()
890 return ibm->read(m); in dispatch_proc_show()
906 if (!ibm || !ibm->write) in dispatch_proc_write()
907 return -EINVAL; in dispatch_proc_write()
908 if (count > PAGE_SIZE - 1) in dispatch_proc_write()
909 return -EINVAL; in dispatch_proc_write()
914 ret = ibm->write(kernbuf); in dispatch_proc_write()
954 if (ibm->suspend) in tpacpi_suspend_handler()
955 (ibm->suspend)(); in tpacpi_suspend_handler()
968 if (ibm->resume) in tpacpi_resume_handler()
969 (ibm->resume)(); in tpacpi_resume_handler()
986 if (ibm->shutdown) in tpacpi_shutdown_handler()
987 (ibm->shutdown)(); in tpacpi_shutdown_handler()
1003 return -EINVAL; in parse_strtoul()
1027 * ThinkPad-ACPI firmware handling model:
1029 * WLSW (master wireless switch) is event-driven, and is common to all
1030 * firmware-controlled radios. It cannot be controlled, just monitored,
1033 * The kernel, a masked-off hotkey, and WLSW can change the radio state
1037 * masked-off hotkeys are used.
1066 /* ThinkPad-ACPI rfkill subdriver */
1087 return -ENODEV; in tpacpi_rfk_update_swstate()
1089 status = (tp_rfk->ops->get_status)(); in tpacpi_rfk_update_swstate()
1093 rfkill_set_sw_state(tp_rfk->rfkill, in tpacpi_rfk_update_swstate()
1100 * Sync the HW-blocking state of all rfkill switches,
1111 if (rfkill_set_hw_state(tp_rfk->rfkill, in tpacpi_rfk_update_hwblock_state()
1113 /* ignore -- we track sw block */ in tpacpi_rfk_update_hwblock_state()
1148 res = (tp_rfk->ops->set_status)(blocked ? in tpacpi_rfk_hook_set_block()
1177 atp_rfk->rfkill = rfkill_alloc(name, in tpacpi_new_rfkill()
1178 &tpacpi_pdev->dev, in tpacpi_new_rfkill()
1182 if (!atp_rfk || !atp_rfk->rfkill) { in tpacpi_new_rfkill()
1185 return -ENOMEM; in tpacpi_new_rfkill()
1188 atp_rfk->id = id; in tpacpi_new_rfkill()
1189 atp_rfk->ops = tp_rfkops; in tpacpi_new_rfkill()
1191 sw_status = (tp_rfkops->get_status)(); in tpacpi_new_rfkill()
1200 rfkill_init_sw_state(atp_rfk->rfkill, sw_state); in tpacpi_new_rfkill()
1204 rfkill_set_hw_state(atp_rfk->rfkill, hw_state); in tpacpi_new_rfkill()
1206 res = rfkill_register(atp_rfk->rfkill); in tpacpi_new_rfkill()
1209 rfkill_destroy(atp_rfk->rfkill); in tpacpi_new_rfkill()
1229 rfkill_unregister(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1230 rfkill_destroy(tp_rfk->rfkill); in tpacpi_destroy_rfkill()
1242 /* sysfs <radio> enable ------------------------------------------------ */
1249 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_show()
1271 printk_deprecated_rfkill_attribute(attr->attr.name); in tpacpi_rfk_sysfs_enable_store()
1274 return -EINVAL; in tpacpi_rfk_sysfs_enable_store()
1276 tpacpi_disclose_usertask(attr->attr.name, "set to %ld\n", t); in tpacpi_rfk_sysfs_enable_store()
1280 return -EPERM; in tpacpi_rfk_sysfs_enable_store()
1282 res = tpacpi_rfkill_switches[id]->ops->set_status((!!t) ? in tpacpi_rfk_sysfs_enable_store()
1289 /* procfs -------------------------------------------------------------- */
1317 int status = -1; in tpacpi_rfk_procfs_write()
1321 return -ENODEV; in tpacpi_rfk_procfs_write()
1329 return -EINVAL; in tpacpi_rfk_procfs_write()
1332 if (status != -1) { in tpacpi_rfk_procfs_write()
1336 res = (tpacpi_rfkill_switches[id]->ops->set_status)(status); in tpacpi_rfk_procfs_write()
1344 * thinkpad-acpi driver attributes
1347 /* interface_version --------------------------------------------------- */
1354 /* debug_level --------------------------------------------------------- */
1366 return -EINVAL; in debug_level_store()
1374 /* version ------------------------------------------------------------- */
1382 /* --------------------------------------------------------------------- */
1386 /* wlsw_emulstate ------------------------------------------------------ */
1398 return -EINVAL; in wlsw_emulstate_store()
1409 /* bluetooth_emulstate ------------------------------------------------- */
1421 return -EINVAL; in bluetooth_emulstate_store()
1429 /* wwan_emulstate ------------------------------------------------- */
1441 return -EINVAL; in wwan_emulstate_store()
1449 /* uwb_emulstate ------------------------------------------------- */
1461 return -EINVAL; in uwb_emulstate_store()
1547 /* Numeric models ------------------ */
1559 /* A-series ------------------------- */
1573 /* G-series ------------------------- */
1578 /* R-series, T-series --------------- */
1608 /* X-series ------------------------- */
1621 /* (0) - older versions lack DMI EC fw string and functionality */
1622 /* (1) - older versions known to lack functionality */
1678 * thinkpad-acpi metadata subdriver
1713 * Unlike other classes, hotkey-class events have mask/unmask control on
1714 * non-ancient firmware. However, how it behaves changes a lot with the
1938 return -ENODEV; in hotkey_get_wlsw()
1947 return -EIO; in hotkey_get_wlsw()
2041 return -EIO; in hotkey_get_tablet_mode()
2047 return -EIO; in hotkey_get_tablet_mode()
2072 return -EIO; in hotkey_mask_get()
2080 /* sync userspace-visible mask */ in hotkey_mask_get()
2118 rc = -EIO; in hotkey_mask_set()
2159 …pr_notice("please consider using the driver defaults, and refer to up-to-date thinkpad-acpi docume… in hotkey_user_mask_set()
2208 return -EIO; in hotkey_status_get()
2216 return -EIO; in hotkey_status_set()
2280 n->thinkpad_toggle = !!(d & TP_NVRAM_MASK_HKT_THINKPAD); in hotkey_read_nvram()
2281 n->zoom_toggle = !!(d & TP_NVRAM_MASK_HKT_ZOOM); in hotkey_read_nvram()
2282 n->display_toggle = !!(d & TP_NVRAM_MASK_HKT_DISPLAY); in hotkey_read_nvram()
2283 n->hibernate_toggle = !!(d & TP_NVRAM_MASK_HKT_HIBERNATE); in hotkey_read_nvram()
2287 n->thinklight_toggle = !!(d & TP_NVRAM_MASK_THINKLIGHT); in hotkey_read_nvram()
2291 n->displayexp_toggle = in hotkey_read_nvram()
2296 n->brightness_level = (d & TP_NVRAM_MASK_LEVEL_BRIGHTNESS) in hotkey_read_nvram()
2298 n->brightness_toggle = in hotkey_read_nvram()
2303 n->volume_level = (d & TP_NVRAM_MASK_LEVEL_VOLUME) in hotkey_read_nvram()
2305 n->mute = !!(d & TP_NVRAM_MASK_MUTE); in hotkey_read_nvram()
2306 n->volume_toggle = !!(d & TP_NVRAM_MASK_HKT_VOLUME); in hotkey_read_nvram()
2313 oldn->__member != newn->__member) \
2331 i--; in issue_volchange()
2347 i--; in issue_brightnesschange()
2373 * - Pressing MUTE issues mute hotkey message, even when already mute in hotkey_compare_and_issue_event()
2374 * - Pressing Volume up/down issues volume up/down hotkey messages, in hotkey_compare_and_issue_event()
2376 * - The act of unmuting issues volume up/down notification, in hotkey_compare_and_issue_event()
2386 if (newn->mute) { in hotkey_compare_and_issue_event()
2388 if (!oldn->mute || in hotkey_compare_and_issue_event()
2389 oldn->volume_toggle != newn->volume_toggle || in hotkey_compare_and_issue_event()
2390 oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2393 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2399 if (oldn->mute) { in hotkey_compare_and_issue_event()
2403 if (oldn->volume_level != newn->volume_level) { in hotkey_compare_and_issue_event()
2404 issue_volchange(oldn->volume_level, newn->volume_level, in hotkey_compare_and_issue_event()
2406 } else if (oldn->volume_toggle != newn->volume_toggle) { in hotkey_compare_and_issue_event()
2408 if (newn->volume_level == 0) in hotkey_compare_and_issue_event()
2410 else if (newn->volume_level >= TP_NVRAM_LEVEL_VOLUME_MAX) in hotkey_compare_and_issue_event()
2416 if (oldn->brightness_level != newn->brightness_level) { in hotkey_compare_and_issue_event()
2417 issue_brightnesschange(oldn->brightness_level, in hotkey_compare_and_issue_event()
2418 newn->brightness_level, event_mask); in hotkey_compare_and_issue_event()
2419 } else if (oldn->brightness_toggle != newn->brightness_toggle) { in hotkey_compare_and_issue_event()
2421 if (newn->brightness_level == 0) in hotkey_compare_and_issue_event()
2423 else if (newn->brightness_level >= bright_maxlvl in hotkey_compare_and_issue_event()
2436 * most of them are edge-based. We only issue those requested by
2530 (poll_user_mask && tpacpi_inputdev->users > 0))) { in hotkey_poll_setup()
2586 return -EBUSY; in hotkey_inputdev_open()
2591 return -EBUSY; in hotkey_inputdev_open()
2602 /* sysfs hotkey enable ------------------------------------------------- */
2629 return -EINVAL; in hotkey_enable_store()
2632 return -EPERM; in hotkey_enable_store()
2639 /* sysfs hotkey mask --------------------------------------------------- */
2655 return -EINVAL; in hotkey_mask_store()
2658 return -ERESTARTSYS; in hotkey_mask_store()
2675 /* sysfs hotkey bios_enabled ------------------------------------------- */
2685 /* sysfs hotkey bios_mask ---------------------------------------------- */
2697 /* sysfs hotkey all_mask ----------------------------------------------- */
2708 /* sysfs hotkey all_mask ----------------------------------------------- */
2719 /* sysfs hotkey recommended_mask --------------------------------------- */
2733 /* sysfs hotkey hotkey_source_mask ------------------------------------- */
2751 return -EINVAL; in hotkey_source_mask_store()
2754 return -ERESTARTSYS; in hotkey_source_mask_store()
2784 /* sysfs hotkey hotkey_poll_freq --------------------------------------- */
2799 return -EINVAL; in hotkey_poll_freq_store()
2802 return -ERESTARTSYS; in hotkey_poll_freq_store()
2818 /* sysfs hotkey radio_sw (pollable) ------------------------------------ */
2840 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_radio_sw_notify_change()
2844 /* sysfs hotkey tablet mode (pollable) --------------------------------- */
2862 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_tablet_mode_notify_change()
2866 /* sysfs wakeup reason (pollable) -------------------------------------- */
2878 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_reason_notify_change()
2882 /* sysfs wakeup hotunplug_complete (pollable) -------------------------- */
2895 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, in hotkey_wakeup_hotunplug_complete_notify_change()
2899 /* sysfs adaptive kbd mode --------------------------------------------- */
2933 return -EINVAL; in adaptive_kbd_mode_store()
2949 return tp_features.has_adaptive_kbd ? attr->mode : 0; in hadaptive_kbd_attr_is_visible()
2957 /* --------------------------------------------------------------------- */
2989 return attr->mode; in hotkey_attr_is_visible()
3017 /* Sync hw blocking state first if it is hw-blocked */ in tpacpi_send_radiosw_update()
3021 /* Sync hw blocking state last if it is hw-unblocked */ in tpacpi_send_radiosw_update()
3064 tpacpi_inputdev->keybit); in hotkey_unmap()
3148 * firmware at driver load time, which means the firm- in hotkey_init()
3152 * 2. You must be subscribed to the linux-thinkpad and in hotkey_init()
3153 * ibm-acpi-devel mailing lists, and you should read the in hotkey_init()
3156 * know the past history of problems with the thinkpad- in hotkey_init()
3160 * 3. Do not send thinkpad-acpi specific patches directly to in hotkey_init()
3161 * for merging, *ever*. Send them to the linux-acpi in hotkey_init()
3163 * through acpi-test and the ACPI maintainer. in hotkey_init()
3166 * Ask the thinkpad-acpi maintainer to do it, instead. in hotkey_init()
3198 * the built-in *extra* mixer. Never map it to control in hotkey_init()
3239 /* These should be enabled --only-- when ACPI video in hotkey_init()
3251 * react to it and reprograms the built-in *extra* mixer. in hotkey_init()
3255 * these over the regular keyboard, so these are no-ops, in hotkey_init()
3370 BUG_ON(tpacpi_inputdev->open != NULL || in hotkey_init()
3371 tpacpi_inputdev->close != NULL); in hotkey_init()
3388 return -ENODEV; in hotkey_init()
3396 A30, R30, R31, T20-22, X20-21, X22-24. Detected by checking in hotkey_init()
3415 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3432 /* Fallback: pre-init for FN+F3,F4,F12 */ in hotkey_init()
3512 return -ENOMEM; in hotkey_init()
3516 tpacpi_inputdev->keycodesize = TPACPI_HOTKEY_MAP_TYPESIZE; in hotkey_init()
3517 tpacpi_inputdev->keycodemax = TPACPI_HOTKEY_MAP_LEN; in hotkey_init()
3518 tpacpi_inputdev->keycode = hotkey_keycode_map; in hotkey_init()
3545 pr_notice("Disabling thinkpad-acpi brightness events by default...\n"); in hotkey_init()
3579 if (res < 0 && res != -ENXIO) { in hotkey_init()
3589 tpacpi_inputdev->open = &hotkey_inputdev_open; in hotkey_init()
3590 tpacpi_inputdev->close = &hotkey_inputdev_close; in hotkey_init()
3598 * mode, Web conference mode, Function mode and Lay-flat mode.
3627 return -EIO; in adaptive_keyboard_get_mode()
3637 return -EINVAL; in adaptive_keyboard_set_mode()
3641 return -EIO; in adaptive_keyboard_set_mode()
3650 size_t max_mode = ARRAY_SIZE(adaptive_keyboard_modes) - 1; in adaptive_keyboard_get_next_mode()
3704 TP_ACPI_HOTKEYSCAN_EXTENDED_START - in adaptive_keyboard_hotkey_notify_hotkey()
3710 keycode = hotkey_keycode_map[scancode - FIRST_ADAPTIVE_KEY + in adaptive_keyboard_hotkey_notify_hotkey()
3742 scancode = (hkey & 0xfff) - (0x300 - TP_ACPI_HOTKEYSCAN_EXTENDED_START); in hotkey_notify_extended_hotkey()
3756 /* 0x1000-0x1FFF: key presses */ in hotkey_notify_hotkey()
3771 scancode--; in hotkey_notify_hotkey()
3796 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify_wakeup()
3813 case TP_HKEY_EV_WKUP_S3_BATLOW: /* Battery on critical low level/S3 */ in hotkey_notify_wakeup()
3814 case TP_HKEY_EV_WKUP_S4_BATLOW: /* Battery on critical low level/S4 */ in hotkey_notify_wakeup()
3815 pr_alert("EMERGENCY WAKEUP: battery almost empty\n"); in hotkey_notify_wakeup()
3816 /* how to auto-heal: */ in hotkey_notify_wakeup()
3826 pr_info("woke up due to a hot-unplug request...\n"); in hotkey_notify_wakeup()
3836 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify_dockevent()
3857 * duplicates from intel-vbtn, which already emits SW_TABLET_MODE events in hotkey_notify_dockevent()
3864 * https://lore.kernel.org/platform-driver-x86/38cb8265-1e30-d547-9e12-b4ae290be737@a-kobel.de/ in hotkey_notify_dockevent()
3881 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify_usrevent()
3890 case TP_HKEY_EV_TABLET_TABLET: /* X41t-X61t: tablet mode */ in hotkey_notify_usrevent()
3891 case TP_HKEY_EV_TABLET_NOTEBOOK: /* X41t-X61t: normal mode */ in hotkey_notify_usrevent()
3916 /* 0x6000-0x6FFF: thermal alarms/notices and keyboard events */ in hotkey_notify_6xxx()
3928 /* Thermal event - pass on to event handler */ in hotkey_notify_6xxx()
3937 pr_crit("THERMAL ALARM: battery is too hot!\n"); in hotkey_notify_6xxx()
3941 pr_alert("THERMAL EMERGENCY: battery is extremely hot!\n"); in hotkey_notify_6xxx()
3983 /* palm detected - pass on to event handler */ in hotkey_notify_6xxx()
4007 ibm->acpi->device->pnp.device_class, in hotkey_notify()
4008 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4029 /* 0x1000-0x1FFF: key presses */ in hotkey_notify()
4034 /* 0x2000-0x2FFF: Wakeup reason */ in hotkey_notify()
4039 /* 0x3000-0x3FFF: bay-related wakeups */ in hotkey_notify()
4056 /* 0x4000-0x4FFF: dock-related events */ in hotkey_notify()
4061 /* 0x5000-0x5FFF: human interface helpers */ in hotkey_notify()
4066 /* 0x6000-0x6FFF: thermal alarms/notices and in hotkey_notify()
4072 /* 0x7000-0x7FFF: misc */ in hotkey_notify()
4093 ibm->acpi->device->pnp.device_class, in hotkey_notify()
4094 dev_name(&ibm->acpi->device->dev), in hotkey_notify()
4141 /* procfs -------------------------------------------------------------- */
4152 return -ERESTARTSYS; in hotkey_read()
4187 return -ENODEV; in hotkey_write()
4190 return -ERESTARTSYS; in hotkey_write()
4200 res = -EPERM; in hotkey_write()
4209 res = -EINVAL; in hotkey_write()
4264 TP_ACPI_BLTH_GET_PWR_ON_RESUME = 0x01, /* Get power-on-resume state */
4283 return -EIO; in bluetooth_get_status()
4310 return -EIO; in bluetooth_set_status()
4315 /* sysfs bluetooth enable ---------------------------------------------- */
4334 /* --------------------------------------------------------------------- */
4344 return tp_features.bluetooth ? attr->mode : 0; in bluetooth_attr_is_visible()
4392 .ident = "ThinkPad A285 - 20MW",
4400 .ident = "ThinkPad A285 - 20MX",
4408 .ident = "ThinkPad A485 - 20MU",
4416 .ident = "ThinkPad A485 - 20MV",
4440 if (tp_features.quirks && tp_features.quirks->btusb_bug && in have_bt_fwbug()
4460 G4x, R30, R31, R40e, R50e, T20-22, X20-21 */ in bluetooth_init()
4484 return -ENODEV; in bluetooth_init()
4494 /* procfs -------------------------------------------------------------- */
4538 return -EIO; in wan_get_status()
4565 return -EIO; in wan_set_status()
4570 /* sysfs wan enable ---------------------------------------------------- */
4590 /* --------------------------------------------------------------------- */
4600 return tp_features.wan ? attr->mode : 0; in wan_attr_is_visible()
4663 return -ENODEV; in wan_init()
4673 /* procfs -------------------------------------------------------------- */
4715 return -EIO; in uwb_get_status()
4741 return -EIO; in uwb_set_status()
4746 /* --------------------------------------------------------------------- */
4791 return -ENODEV; in uwb_init()
4884 return (video_supported != TPACPI_VIDEO_NONE) ? 0 : -ENODEV; in video_init()
4904 return -EIO; in video_outputsw_get()
4909 return -EIO; in video_outputsw_get()
4913 return -EIO; in video_outputsw_get()
4920 return -EIO; in video_outputsw_get()
4926 return -EIO; in video_outputsw_get()
4930 return -EIO; in video_outputsw_get()
4935 return -ENOSYS; in video_outputsw_get()
4964 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_set()
4965 return -EIO; in video_outputsw_set()
4973 return -ENOSYS; in video_outputsw_set()
4976 return (res) ? 0 : -EIO; in video_outputsw_set()
4986 return -EIO; in video_autosw_get()
4991 return -EIO; in video_autosw_get()
4994 return -ENOSYS; in video_autosw_get()
5003 return -EIO; in video_autosw_set()
5030 return -ENOSYS; in video_outputsw_cycle()
5033 pr_err("video auto-switch left enabled due to error\n"); in video_outputsw_cycle()
5034 return -EIO; in video_outputsw_cycle()
5037 return (res) ? 0 : -EIO; in video_outputsw_cycle()
5045 0 : -EIO; in video_expand_toggle()
5048 0 : -EIO; in video_expand_toggle()
5051 0 : -EIO; in video_expand_toggle()
5053 return -ENOSYS; in video_expand_toggle()
5069 return -EPERM; in video_read()
5102 return -ENODEV; in video_write()
5106 return -EPERM; in video_write()
5143 return -EINVAL; in video_write()
5179 return -ENXIO; in kbdlight_set_level()
5184 ret = -EIO; in kbdlight_set_level()
5198 return -ENXIO; in kbdlight_get_level()
5201 return -EIO; in kbdlight_get_level()
5236 * b010100000010000000XX - ThinkPad X1 Carbon 3rd in kbdlight_is_supported()
5237 * b110100010010000000XX - ThinkPad x230 in kbdlight_is_supported()
5238 * b010100000010000000XX - ThinkPad x240 in kbdlight_is_supported()
5239 * b010100000010000000XX - ThinkPad W541 in kbdlight_is_supported()
5243 * b10100001000000000000 - ThinkPad x230 in kbdlight_is_supported()
5244 * b10110001000000000000 - ThinkPad E430 in kbdlight_is_supported()
5245 * b00000000000000000000 - ThinkPad E450 in kbdlight_is_supported()
5292 return -ENODEV; in kbdlight_init()
5298 rc = led_classdev_register(&tpacpi_pdev->dev, in kbdlight_init()
5323 if (ret == 0 && !(led_cdev->flags & LED_SUSPENDED)) in kbdlight_set_level_and_update()
5324 led_cdev->brightness = level; in kbdlight_set_level_and_update()
5350 int res, level = -EINVAL; in kbdlight_write()
5353 return -ENODEV; in kbdlight_write()
5362 return -EINVAL; in kbdlight_write()
5400 TPACPI_HANDLE(lght, root, "\\LGHT"); /* A21e, A2xm/p, T20-22, X20-21 */
5409 return -EIO; in light_get_status()
5413 return -ENXIO; in light_get_status()
5430 return (rc) ? 0 : -EIO; in light_set_status()
5433 return -ENXIO; in light_set_status()
5483 return -ENODEV; in light_init()
5485 rc = led_classdev_register(&tpacpi_pdev->dev, in light_init()
5529 return -ENODEV; in light_write()
5537 return -EINVAL; in light_write()
5554 /* sysfs cmos_command -------------------------------------------------- */
5563 return -EINVAL; in cmos_command_store()
5579 return cmos_handle ? attr->mode : 0; in cmos_attr_is_visible()
5587 /* --------------------------------------------------------------------- */
5599 return cmos_handle ? 0 : -ENODEV; in cmos_init()
5605 R30, R31, T20-22, X20-21 */ in cmos_read()
5610 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-21)\n"); in cmos_read()
5626 return -EINVAL; in cmos_write()
5649 TPACPI_LED_OLD, /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */
5702 return -EIO; in led_get_status()
5711 return -ENXIO; in led_get_status()
5730 return -EINVAL; in led_set_status()
5732 return -EPERM; in led_set_status()
5735 return -EIO; in led_set_status()
5738 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20 */ in led_set_status()
5740 return -EINVAL; in led_set_status()
5742 return -EPERM; in led_set_status()
5754 return -EINVAL; in led_set_status()
5756 return -EPERM; in led_set_status()
5759 return -EIO; in led_set_status()
5762 return -ENXIO; in led_set_status()
5780 else if (tpacpi_led_state_cache[data->led] != TPACPI_LED_BLINK) in led_sysfs_set()
5785 return led_set_status(data->led, new_state); in led_sysfs_set()
5800 return -EINVAL; in led_sysfs_blink_set()
5802 return led_set_status(data->led, TPACPI_LED_BLINK); in led_sysfs_blink_set()
5812 rc = led_get_status(data->led); in led_sysfs_get()
5847 return led_classdev_register(&tpacpi_pdev->dev, &tpacpi_leds[led].led_classdev); in tpacpi_init_led()
5875 /* (1) - may have excess leds enabled on MSB */
5905 /* 600e/x, 770e, 770x, A21e, A2xm/p, T20-22, X20-21 */ in led_init_detect_mode()
5945 return -ENODEV; in led_init()
5951 return -ENOMEM; in led_init()
5955 tpacpi_leds[i].led = -1; in led_init()
5988 return -EIO; in led_read()
5993 seq_printf(m, "commands:\t<led> on, <led> off, <led> blink (<led> is 0-15)\n"); in led_read()
6005 return -ENODEV; in led_write()
6009 return -EINVAL; in led_write()
6011 if (led < 0 || led > (TPACPI_LED_NUMLEDS - 1)) in led_write()
6012 return -ENODEV; in led_write()
6015 return -ENODEV; in led_write()
6024 return -EINVAL; in led_write()
6052 TPACPI_Q_IBM('I', 'U', TPACPI_BEEP_Q1), /* 570E - unverified */
6071 return (beep_handle) ? 0 : -ENODEV; in beep_init()
6080 seq_printf(m, "commands:\t<cmd> (<cmd> is 0-17)\n"); in beep_read()
6092 return -ENODEV; in beep_write()
6099 return -EINVAL; in beep_write()
6103 return -EIO; in beep_write()
6107 return -EIO; in beep_write()
6126 TPACPI_THERMAL_ACPI_TMP07, /* Use ACPI TMP0-7 */
6127 TPACPI_THERMAL_ACPI_UPDT, /* Use ACPI TMP0-7 with UPDT */
6136 TP_EC_THERMAL_TMP_NA = -128, /* ACPI EC sensor not available */
6138 TPACPI_THERMAL_SENSOR_NA = -128000, /* Sensor not available */
6150 /* idx is zero-based */
6164 idx -= 8; in thermal_get_sensor()
6171 return -EIO; in thermal_get_sensor()
6181 return -EIO; in thermal_get_sensor()
6183 return -EIO; in thermal_get_sensor()
6184 *value = (t - 2732) * 100; in thermal_get_sensor()
6193 return -EIO; in thermal_get_sensor()
6194 if (t > 127 || t < -127) in thermal_get_sensor()
6203 return -ENOSYS; in thermal_get_sensor()
6206 return -EINVAL; in thermal_get_sensor()
6218 return -EINVAL; in thermal_get_sensors()
6224 res = thermal_get_sensor(i, &s->temp[i]); in thermal_get_sensors()
6253 /* sysfs temp##_input -------------------------------------------------- */
6261 int idx = sensor_attr->index; in thermal_temp_input_show()
6269 return -ENXIO; in thermal_temp_input_show()
6334 return attr->mode; in thermal_attr_is_visible()
6366 return thermal_use_labels ? attr->mode : 0; in temp_label_attr_is_visible()
6374 /* --------------------------------------------------------------------- */
6389 * 0x78-0x7F, 0xC0-0xC7. Registers return 0x00 for in thermal_init()
6390 * non-implemented, thermal sensors return 0x80 when in thermal_init()
6395 * version 3 the Lenovo firmware team confirmed that registers 0xC0-0xC7 in thermal_init()
6455 return thermal_read_mode != TPACPI_THERMAL_NONE ? 0 : -ENODEV; in thermal_init()
6470 for (i = 0; i < (n - 1); i++) in thermal_read()
6492 * CMOS NVRAM byte 0x5E, bits 0-3.
6499 * Bit 3-0: backlight brightness level
6520 TPACPI_BRGHT_MODE_UCMS_STEP, /* UCMS step-based control */
6601 return -EIO; in tpacpi_brightness_get_raw()
6605 return -ENXIO; in tpacpi_brightness_get_raw()
6617 return -EIO; in tpacpi_brightness_set_ec()
6622 return -EIO; in tpacpi_brightness_set_ec()
6642 inc = (value > current_value) ? 1 : -1; in tpacpi_brightness_set_ucmsstep()
6646 return -EIO; in tpacpi_brightness_set_ucmsstep()
6657 return -EINVAL; in brightness_set()
6675 res = -ENXIO; in brightness_set()
6682 /* sysfs backlight class ----------------------------------------------- */
6726 /* --------------------------------------------------------------------- */
6735 status = acpi_evaluate_object(adev->handle, "_BCL", NULL, &buffer); in tpacpi_evaluate_bcl()
6740 if (!obj || obj->type != ACPI_TYPE_PACKAGE) { in tpacpi_evaluate_bcl()
6741 acpi_handle_info(adev->handle, in tpacpi_evaluate_bcl()
6746 rc = obj->package.count; in tpacpi_evaluate_bcl()
6784 return (bcl_levels > 2) ? (bcl_levels - 2) : 0; in tpacpi_check_std_acpi_brightness_support()
6801 TPACPI_Q_IBM('1', 'R', TPACPI_BRGHT_Q_EC), /* R50,51 T40-42 */
6847 bright_maxlvl = b - 1; in tpacpi_detect_brightness_capabilities()
6869 return -ENODEV; in brightness_init()
6874 return -ENODEV; in brightness_init()
6880 return -ENODEV; in brightness_init()
6883 return -ENODEV; in brightness_init()
6887 return -ENODEV; in brightness_init()
6898 return -EINVAL; in brightness_init()
6909 "driver auto-selected brightness_mode=%d\n", in brightness_init()
6917 return -EINVAL; in brightness_init()
6920 return -ENODEV; in brightness_init()
6991 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in brightness_read()
7014 level--; in brightness_write()
7019 return -EINVAL; in brightness_write()
7033 return (rc == -EINTR) ? -ERESTARTSYS : rc; in brightness_write()
7058 * Bit 3-0: Volume
7062 * bits 3-0 (volume). Other bits in NVRAM may have other functions,
7074 * To avoid confusing userspace, we simply disable all EC-based mute
7085 #define DEFAULT_ALSA_IDX ~((1 << (SNDRV_CARDS - 3)) - 1)
7087 #define DEFAULT_ALSA_IDX ~((1 << (32 - 3)) - 1)
7118 TPACPI_VOL_MODE_UCMS_STEP, /* UCMS step-based control: N/A */
7148 * TP_NVRAM_ADDR_MIXER, as we need to do read-modify-write
7204 return -EIO; in volume_get_status_ec()
7221 return -EIO; in volume_set_status_ec()
7246 return -EINTR; in __volume_set_mute_ec()
7291 return -EINVAL; in __volume_set_volume_ec()
7294 return -EINTR; in __volume_set_volume_ec()
7318 return -ENODEV; in volume_set_software_mute()
7323 return -EIO; in volume_set_software_mute()
7332 return -EIO; in volume_set_software_mute()
7341 * startup. Just on case there are SAUM-capable ThinkPads in volume_set_software_mute()
7375 if (alsa_card && alsa_card->private_data) { in volume_alsa_notify_change()
7376 d = alsa_card->private_data; in volume_alsa_notify_change()
7377 if (d->ctl_mute_id) in volume_alsa_notify_change()
7380 d->ctl_mute_id); in volume_alsa_notify_change()
7381 if (d->ctl_vol_id) in volume_alsa_notify_change()
7384 d->ctl_vol_id); in volume_alsa_notify_change()
7391 uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; in volume_alsa_vol_info()
7392 uinfo->count = 1; in volume_alsa_vol_info()
7393 uinfo->value.integer.min = 0; in volume_alsa_vol_info()
7394 uinfo->value.integer.max = TP_EC_VOLUME_MAX; in volume_alsa_vol_info()
7408 ucontrol->value.integer.value[0] = s & TP_EC_AUDIO_LVL_MSK; in volume_alsa_vol_get()
7416 ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7417 return volume_alsa_set_volume(ucontrol->value.integer.value[0]); in volume_alsa_vol_put()
7432 ucontrol->value.integer.value[0] = in volume_alsa_mute_get()
7441 ucontrol->value.integer.value[0] ? in volume_alsa_mute_put()
7443 return volume_alsa_set_mute(!ucontrol->value.integer.value[0]); in volume_alsa_mute_put()
7505 rc = snd_card_new(&tpacpi_pdev->dev, in volume_create_alsa_mixer()
7510 return -ENODEV; in volume_create_alsa_mixer()
7513 BUG_ON(!card->private_data); in volume_create_alsa_mixer()
7514 data = card->private_data; in volume_create_alsa_mixer()
7515 data->card = card; in volume_create_alsa_mixer()
7517 strscpy(card->driver, TPACPI_ALSA_DRVNAME, in volume_create_alsa_mixer()
7518 sizeof(card->driver)); in volume_create_alsa_mixer()
7519 strscpy(card->shortname, TPACPI_ALSA_SHRTNAME, in volume_create_alsa_mixer()
7520 sizeof(card->shortname)); in volume_create_alsa_mixer()
7521 snprintf(card->mixername, sizeof(card->mixername), "ThinkPad EC %s", in volume_create_alsa_mixer()
7524 snprintf(card->longname, sizeof(card->longname), in volume_create_alsa_mixer()
7525 "%s at EC reg 0x%02x, fw %s", card->shortname, TP_EC_AUDIO, in volume_create_alsa_mixer()
7547 data->ctl_vol_id = &ctl_vol->id; in volume_create_alsa_mixer()
7556 data->ctl_mute_id = &ctl_mute->id; in volume_create_alsa_mixer()
7569 return -ENODEV; in volume_create_alsa_mixer()
7572 #define TPACPI_VOL_Q_MUTEONLY 0x0001 /* Mute-only control available */
7591 /* Whitelist mute-only on all Lenovo by default */
7613 return -EINVAL; in volume_init()
7618 return -ENODEV; in volume_init()
7622 return -EINVAL; in volume_init()
7631 return -ENODEV; in volume_init()
7644 return -ENODEV; /* no mixer */ in volume_init()
7653 return -ENODEV; in volume_init()
7658 "using user-supplied volume_capabilities=%d\n", in volume_init()
7666 "driver auto-selected volume_mode=%d\n", in volume_init()
7670 "using user-supplied volume_mode=%d\n", in volume_init()
7722 seq_printf(m, "commands:\tlevel <level> (<level> is 0-%d)\n", in volume_read()
7749 return -EPERM; in volume_write()
7771 new_level--; in volume_write()
7784 return -EINVAL; in volume_write()
7799 return (rc == -EINTR) ? -ERESTARTSYS : rc; in volume_write()
7824 return -ENODEV; in volume_init()
7872 * Speeds up fan to 100% duty-cycle, which is far above
7875 * 5-3 unused in some models. Extra bits for fan level
7878 * 2-0 fan level (0..7 usually)
7891 * ----
7896 * This register is present on all ThinkPads with a new-style EC, and
7902 * Unfortunately a lot of ThinkPads with new-style ECs but whose firmware
7916 * ----
7928 * So far, only the firmware for the X60/X61 non-tablet versions
7929 * seem to support this (firmware TP-7M).
7963 TPACPI_FAN_LAST_LEVEL = 0x100, /* Use cached last-seen fan level */
7969 TPACPI_FAN_RD_TPEC, /* Use ACPI EC regs 0x2f, 0x84-0x85 */
8007 "JFNS", /* 770x-JL */
8022 * Enable for TP-1Y (T43), TP-78 (R51e), TP-76 (R52),
8023 * TP-70 (T43, R52), which are known to be buggy.
8108 return -EIO; in fan_get_status()
8118 return -EIO; in fan_get_status()
8128 return -ENXIO; in fan_get_status()
8140 return -ERESTARTSYS; in fan_get_status_safe()
8162 return -EIO; in fan_get_speed()
8165 return -EIO; in fan_get_speed()
8173 return -ENXIO; in fan_get_speed()
8188 return -EIO; in fan2_get_speed()
8193 return -EIO; in fan2_get_speed()
8201 return -ENXIO; in fan2_get_speed()
8210 return -EPERM; in fan_set_level()
8215 return -EINVAL; in fan_set_level()
8226 return -EIO; in fan_set_level()
8234 return -EINVAL; in fan_set_level()
8253 return -EIO; in fan_set_level()
8259 return -ENXIO; in fan_set_level()
8272 return -EPERM; in fan_set_level_safe()
8275 return -ERESTARTSYS; in fan_set_level_safe()
8294 return -EPERM; in fan_set_enable()
8297 return -ERESTARTSYS; in fan_set_enable()
8313 rc = -EIO; in fan_set_enable()
8331 rc = -EIO; in fan_set_enable()
8337 rc = -ENXIO; in fan_set_enable()
8354 return -EPERM; in fan_set_disable()
8357 return -ERESTARTSYS; in fan_set_disable()
8364 rc = -EIO; in fan_set_disable()
8373 rc = -EIO; in fan_set_disable()
8379 rc = -ENXIO; in fan_set_disable()
8395 return -EPERM; in fan_set_speed()
8398 return -ERESTARTSYS; in fan_set_speed()
8406 rc = -EIO; in fan_set_speed()
8408 rc = -EINVAL; in fan_set_speed()
8412 rc = -ENXIO; in fan_set_speed()
8470 /* sysfs fan pwm1_enable ----------------------------------------------- */
8500 return -EINVAL; in fan_pwm1_enable_store()
8516 /* reserved for software-controlled auto mode */ in fan_pwm1_enable_store()
8517 return -ENOSYS; in fan_pwm1_enable_store()
8519 return -EINVAL; in fan_pwm1_enable_store()
8523 if (res == -ENXIO) in fan_pwm1_enable_store()
8524 return -EINVAL; in fan_pwm1_enable_store()
8536 /* sysfs fan pwm1 ------------------------------------------------------ */
8567 return -EINVAL; in fan_pwm1_store()
8572 /* scale down from 0-255 to 0-7 */ in fan_pwm1_store()
8576 return -ERESTARTSYS; in fan_pwm1_store()
8582 if (rc == -ENXIO) in fan_pwm1_store()
8583 rc = -EINVAL; in fan_pwm1_store()
8596 /* sysfs fan fan1_input ------------------------------------------------ */
8613 /* sysfs fan fan2_input ------------------------------------------------ */
8630 /* sysfs fan fan_watchdog (hwmon driver) ------------------------------- */
8642 return -EINVAL; in fan_watchdog_store()
8645 return -EPERM; in fan_watchdog_store()
8656 /* --------------------------------------------------------------------- */
8678 return attr->mode; in fan_attr_is_visible()
8749 return -ENODEV; in fan_init()
8756 /* all other ThinkPads: note that even old-style in fan_init()
8770 /* It responded - so let's assume it's there */ in fan_init()
8775 /* Fan not auto-detected */ in fan_init()
8789 return -ENODEV; in fan_init()
8794 /* 570, 770x-JL */ in fan_init()
8840 return -ENODEV; in fan_init()
8980 seq_printf(m, " (<level> is 0-7)\n"); in fan_read()
8984 seq_printf(m, " (<level> is 0-7, auto, disengaged, full-speed)\n"); in fan_read()
8991 "commands:\twatchdog <timeout> (<timeout> is 0 (off), 1-120 (seconds))\n"); in fan_read()
8994 seq_printf(m, "commands:\tspeed <speed> (<speed> is 0-65535)\n"); in fan_read()
9005 else if (strstarts(cmd, "level disengaged") || strstarts(cmd, "level full-speed")) in fan_write_cmd_level()
9011 if (*rc == -ENXIO) in fan_write_cmd_level()
9027 if (*rc == -ENXIO) in fan_write_cmd_enable()
9042 if (*rc == -ENXIO) in fan_write_cmd_disable()
9062 if (*rc == -ENXIO) in fan_write_cmd_speed()
9080 *rc = -EINVAL; in fan_write_cmd_watchdog()
9106 rc = -EINVAL; in fan_write()
9154 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_on_off()
9155 pr_warn("Thinkpad ACPI has no %s interface.\n", t->name); in mute_led_on_off()
9156 return -EIO; in mute_led_on_off()
9159 if (!acpi_evalf(hkey_handle, &output, t->name, "dd", in mute_led_on_off()
9160 state ? t->on_value : t->off_value)) in mute_led_on_off()
9161 return -EIO; in mute_led_on_off()
9163 t->state = state; in mute_led_on_off()
9172 if (t->state < 0 || t->state == on) in tpacpi_led_set()
9173 return t->state; in tpacpi_led_set()
9194 .default_trigger = "audio-mute",
9200 .default_trigger = "audio-micmute",
9211 if (ACPI_FAILURE(acpi_get_handle(hkey_handle, t->name, &temp))) { in mute_led_init()
9212 t->state = -ENODEV; in mute_led_init()
9217 err = led_classdev_register(&tpacpi_pdev->dev, &mute_led_cdev[i]); in mute_led_init()
9219 while (i--) in mute_led_init()
9243 if (t->state >= 0) in mute_led_resume()
9244 mute_led_on_off(t, t->state); in mute_led_resume()
9255 * Battery Wear Control Driver
9307 * This evaluates a ACPI method call specific to the battery
9328 static int tpacpi_battery_get(int what, int battery, int *ret) in tpacpi_battery_get() argument
9332 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_START, ret, battery)) in tpacpi_battery_get()
9333 return -ENODEV; in tpacpi_battery_get()
9339 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_STOP, ret, battery)) in tpacpi_battery_get()
9340 return -ENODEV; in tpacpi_battery_get()
9353 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_DISCHARGE, ret, battery)) in tpacpi_battery_get()
9354 return -ENODEV; in tpacpi_battery_get()
9359 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_INHIBIT, ret, battery)) in tpacpi_battery_get()
9360 return -ENODEV; in tpacpi_battery_get()
9366 return -EINVAL; in tpacpi_battery_get()
9370 static int tpacpi_battery_set(int what, int battery, int value) in tpacpi_battery_set() argument
9375 /* The battery ID is in bits 8-9, 2 bits */ in tpacpi_battery_set()
9376 param |= battery << 8; in tpacpi_battery_set()
9381 pr_err("failed to set charge threshold on battery %d", in tpacpi_battery_set()
9382 battery); in tpacpi_battery_set()
9383 return -ENODEV; in tpacpi_battery_set()
9388 pr_err("failed to set stop threshold: %d", battery); in tpacpi_battery_set()
9389 return -ENODEV; in tpacpi_battery_set()
9395 * battery ID is in bits 8-9, 2 bits. in tpacpi_battery_set()
9398 pr_err("failed to set force discharge on %d", battery); in tpacpi_battery_set()
9399 return -ENODEV; in tpacpi_battery_set()
9406 * The battery ID is in bits 4-5, 2 bits, in tpacpi_battery_set()
9407 * the effective time is in bits 8-23, 2 bytes. in tpacpi_battery_set()
9411 param |= battery << 4; in tpacpi_battery_set()
9414 pr_err("failed to set inhibit charge on %d", battery); in tpacpi_battery_set()
9415 return -ENODEV; in tpacpi_battery_set()
9420 return -EINVAL; in tpacpi_battery_set()
9424 static int tpacpi_battery_set_validate(int what, int battery, int value) in tpacpi_battery_set_validate() argument
9428 ret = tpacpi_battery_set(what, battery, value); in tpacpi_battery_set_validate()
9432 ret = tpacpi_battery_get(what, battery, &v); in tpacpi_battery_set_validate()
9441 ret = tpacpi_battery_get(what, battery, &v); in tpacpi_battery_set_validate()
9448 return -EIO; in tpacpi_battery_set_validate()
9451 static int tpacpi_battery_probe(int battery) in tpacpi_battery_probe() argument
9455 memset(&battery_info.batteries[battery], 0, in tpacpi_battery_probe()
9456 sizeof(battery_info.batteries[battery])); in tpacpi_battery_probe()
9469 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_START, &ret, battery)) { in tpacpi_battery_probe()
9470 pr_err("Error probing battery %d\n", battery); in tpacpi_battery_probe()
9471 return -ENODEV; in tpacpi_battery_probe()
9478 battery_info.batteries[battery].start_support = 1; in tpacpi_battery_probe()
9480 return -ENODEV; in tpacpi_battery_probe()
9481 if (tpacpi_battery_get(THRESHOLD_START, battery, in tpacpi_battery_probe()
9482 &battery_info.batteries[battery].charge_start)) { in tpacpi_battery_probe()
9483 pr_err("Error probing battery %d\n", battery); in tpacpi_battery_probe()
9484 return -ENODEV; in tpacpi_battery_probe()
9488 if ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_STOP, &ret, battery)) { in tpacpi_battery_probe()
9489 pr_err("Error probing battery stop; %d\n", battery); in tpacpi_battery_probe()
9490 return -ENODEV; in tpacpi_battery_probe()
9494 battery_info.batteries[battery].stop_support = 1; in tpacpi_battery_probe()
9496 return -ENODEV; in tpacpi_battery_probe()
9497 if (tpacpi_battery_get(THRESHOLD_STOP, battery, in tpacpi_battery_probe()
9498 &battery_info.batteries[battery].charge_stop)) { in tpacpi_battery_probe()
9499 pr_err("Error probing battery stop: %d\n", battery); in tpacpi_battery_probe()
9500 return -ENODEV; in tpacpi_battery_probe()
9504 if (ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_DISCHARGE, &ret, battery))) { in tpacpi_battery_probe()
9505 pr_err("Error probing battery discharge; %d\n", battery); in tpacpi_battery_probe()
9506 return -ENODEV; in tpacpi_battery_probe()
9510 battery_info.batteries[battery].charge_behaviours |= in tpacpi_battery_probe()
9514 if (ACPI_FAILURE(tpacpi_battery_acpi_eval(GET_INHIBIT, &ret, battery))) { in tpacpi_battery_probe()
9515 pr_err("Error probing battery inhibit charge; %d\n", battery); in tpacpi_battery_probe()
9516 return -ENODEV; in tpacpi_battery_probe()
9520 battery_info.batteries[battery].charge_behaviours |= in tpacpi_battery_probe()
9524 battery_info.batteries[battery].charge_behaviours |= in tpacpi_battery_probe()
9527 pr_info("battery %d registered (start %d, stop %d, behaviours: 0x%x)\n", in tpacpi_battery_probe()
9528 battery, in tpacpi_battery_probe()
9529 battery_info.batteries[battery].charge_start, in tpacpi_battery_probe()
9530 battery_info.batteries[battery].charge_stop, in tpacpi_battery_probe()
9531 battery_info.batteries[battery].charge_behaviours); in tpacpi_battery_probe()
9547 * If for some reason the battery is not BAT0 nor is it in tpacpi_battery_get_id()
9548 * BAT1, we will assume it's the default, first battery, in tpacpi_battery_get_id()
9551 pr_warn("unknown battery %s, assuming primary", battery_name); in tpacpi_battery_get_id()
9563 int battery, rval; in tpacpi_battery_store() local
9566 * one battery. If that is the case, in tpacpi_battery_store()
9573 * with "Any Battery" as the parameter. in tpacpi_battery_store()
9577 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_store()
9579 battery = BAT_PRIMARY; in tpacpi_battery_store()
9587 if (!battery_info.batteries[battery].start_support) in tpacpi_battery_store()
9588 return -ENODEV; in tpacpi_battery_store()
9591 return -EINVAL; in tpacpi_battery_store()
9592 if (value > battery_info.batteries[battery].charge_stop) in tpacpi_battery_store()
9593 return -EINVAL; in tpacpi_battery_store()
9594 if (tpacpi_battery_set(THRESHOLD_START, battery, value)) in tpacpi_battery_store()
9595 return -ENODEV; in tpacpi_battery_store()
9596 battery_info.batteries[battery].charge_start = value; in tpacpi_battery_store()
9600 if (!battery_info.batteries[battery].stop_support) in tpacpi_battery_store()
9601 return -ENODEV; in tpacpi_battery_store()
9604 return -EINVAL; in tpacpi_battery_store()
9605 if (value < battery_info.batteries[battery].charge_start) in tpacpi_battery_store()
9606 return -EINVAL; in tpacpi_battery_store()
9607 battery_info.batteries[battery].charge_stop = value; in tpacpi_battery_store()
9615 if (tpacpi_battery_set(THRESHOLD_STOP, battery, value)) in tpacpi_battery_store()
9616 return -EINVAL; in tpacpi_battery_store()
9620 return -EINVAL; in tpacpi_battery_store()
9630 int ret, battery; in tpacpi_battery_show() local
9633 * one battery. If that is the case, in tpacpi_battery_show()
9640 * with "Any Battery" as the parameter. in tpacpi_battery_show()
9644 battery = tpacpi_battery_get_id(supply->desc->name); in tpacpi_battery_show()
9646 battery = BAT_PRIMARY; in tpacpi_battery_show()
9647 if (tpacpi_battery_get(what, battery, &ret)) in tpacpi_battery_show()
9648 return -ENODEV; in tpacpi_battery_show()
9673 int ret, battery; in charge_behaviour_show() local
9675 battery = tpacpi_battery_get_id(supply->desc->name); in charge_behaviour_show()
9676 available = battery_info.batteries[battery].charge_behaviours; in charge_behaviour_show()
9679 if (tpacpi_battery_get(FORCE_DISCHARGE, battery, &ret)) in charge_behaviour_show()
9680 return -ENODEV; in charge_behaviour_show()
9688 if (tpacpi_battery_get(INHIBIT_CHARGE, battery, &ret)) in charge_behaviour_show()
9689 return -ENODEV; in charge_behaviour_show()
9719 int selected, battery, ret = 0; in charge_behaviour_store() local
9722 battery = tpacpi_battery_get_id(supply->desc->name); in charge_behaviour_store()
9723 available = battery_info.batteries[battery].charge_behaviours; in charge_behaviour_store()
9732 ret = tpacpi_battery_set_validate(FORCE_DISCHARGE, battery, 0); in charge_behaviour_store()
9734 ret = min(ret, tpacpi_battery_set_validate(INHIBIT_CHARGE, battery, 0)); in charge_behaviour_store()
9740 ret = tpacpi_battery_set_validate(INHIBIT_CHARGE, battery, 0); in charge_behaviour_store()
9741 ret = min(ret, tpacpi_battery_set_validate(FORCE_DISCHARGE, battery, 1)); in charge_behaviour_store()
9747 ret = tpacpi_battery_set_validate(FORCE_DISCHARGE, battery, 0); in charge_behaviour_store()
9748 ret = min(ret, tpacpi_battery_set_validate(INHIBIT_CHARGE, battery, 1)); in charge_behaviour_store()
9754 return -EINVAL; in charge_behaviour_store()
9787 /* ACPI battery hooking */
9789 static int tpacpi_battery_add(struct power_supply *battery, struct acpi_battery_hook *hook) in tpacpi_battery_add() argument
9791 int batteryid = tpacpi_battery_get_id(battery->desc->name); in tpacpi_battery_add()
9794 return -ENODEV; in tpacpi_battery_add()
9795 if (device_add_groups(&battery->dev, tpacpi_battery_groups)) in tpacpi_battery_add()
9796 return -ENODEV; in tpacpi_battery_add()
9800 static int tpacpi_battery_remove(struct power_supply *battery, struct acpi_battery_hook *hook) in tpacpi_battery_remove() argument
9802 device_remove_groups(&battery->dev, tpacpi_battery_groups); in tpacpi_battery_remove()
9809 .name = "ThinkPad Battery Extension",
9817 * primary battery as BAT1.
9845 .name = "battery",
9862 if (WARN_ON(!mutex_is_locked(&priv->lock))) in lcdshadow_set_sw_state()
9863 return -EIO; in lcdshadow_set_sw_state()
9866 return -EIO; in lcdshadow_set_sw_state()
9868 priv->hw_state = priv->sw_state = state; in lcdshadow_set_sw_state()
9879 priv->hw_state = priv->sw_state = output & 0x1; in lcdshadow_get_hw_state()
9898 return -EIO; in tpacpi_lcdshadow_init()
9903 lcdshadow_dev = drm_privacy_screen_register(&tpacpi_pdev->dev, in tpacpi_lcdshadow_init()
9921 mutex_lock(&lcdshadow_dev->lock); in lcdshadow_resume()
9922 lcdshadow_set_sw_state(lcdshadow_dev, lcdshadow_dev->sw_state); in lcdshadow_resume()
9923 mutex_unlock(&lcdshadow_dev->lock); in lcdshadow_resume()
9931 seq_printf(m, "status:\t\t%d\n", lcdshadow_dev->hw_state); in lcdshadow_read()
9941 int res, state = -EINVAL; in lcdshadow_write()
9944 return -ENODEV; in lcdshadow_write()
9953 return -EINVAL; in lcdshadow_write()
9955 mutex_lock(&lcdshadow_dev->lock); in lcdshadow_write()
9957 mutex_unlock(&lcdshadow_dev->lock); in lcdshadow_write()
9976 #define DYTC_CMD_QUERY 0 /* To get DYTC status - enable/revision */
9977 #define DYTC_QUERY_ENABLE_BIT 8 /* Bit 8 - 0 = disabled, 1 = enabled */
9978 #define DYTC_QUERY_SUBREV_BIT 16 /* Bits 16 - 27 - sub revision */
9979 #define DYTC_QUERY_REV_BIT 28 /* Bits 28 - 31 - revision */
9999 return -ENODEV; in dytc_command()
10002 return -EIO; in dytc_command()
10027 return -ENODEV; in palmsensor_get()
10029 return -EIO; in palmsensor_get()
10047 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "dytc_lapmode"); in lapsensor_refresh()
10063 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "palmsensor"); in palmsensor_refresh()
10109 return attr->mode; in proxsensor_attr_is_visible()
10123 /* If support isn't available for both devices return -ENODEV */ in tpacpi_proxsensor_init()
10124 if ((palm_err == -ENODEV) && (lap_err == -ENODEV)) in tpacpi_proxsensor_init()
10125 return -ENODEV; in tpacpi_proxsensor_init()
10127 if (palm_err && (palm_err != -ENODEV)) in tpacpi_proxsensor_init()
10129 if (lap_err && (lap_err != -ENODEV)) in tpacpi_proxsensor_init()
10136 .name = "proximity-sensor",
10140 * DYTC Platform Profile interface
10152 #define DYTC_GET_FUNCTION_BIT 8 /* Bits 8-11 - function setting */
10153 #define DYTC_GET_MODE_BIT 12 /* Bits 12-15 - mode setting */
10155 #define DYTC_SET_FUNCTION_BIT 12 /* Bits 12-15 - function setting */
10156 #define DYTC_SET_MODE_BIT 16 /* Bits 16-19 - mode setting */
10157 #define DYTC_SET_VALID_BIT 20 /* Bit 20 - 1 = on, 0 = off */
10177 #define DYTC_ERR_MASK 0xF /* Bits 0-3 in cmd result are the error result */
10198 enum platform_profile_option *profile) in convert_dytc_to_profile() argument
10204 *profile = PLATFORM_PROFILE_LOW_POWER; in convert_dytc_to_profile()
10208 *profile = PLATFORM_PROFILE_BALANCED; in convert_dytc_to_profile()
10211 *profile = PLATFORM_PROFILE_PERFORMANCE; in convert_dytc_to_profile()
10214 return -EINVAL; in convert_dytc_to_profile()
10220 *profile = PLATFORM_PROFILE_LOW_POWER; in convert_dytc_to_profile()
10223 *profile = PLATFORM_PROFILE_BALANCED; in convert_dytc_to_profile()
10226 *profile = PLATFORM_PROFILE_PERFORMANCE; in convert_dytc_to_profile()
10229 return -EINVAL; in convert_dytc_to_profile()
10234 *profile = PLATFORM_PROFILE_BALANCED; in convert_dytc_to_profile()
10238 return -EOPNOTSUPP; in convert_dytc_to_profile()
10243 static int convert_profile_to_dytc(enum platform_profile_option profile, int *perfmode) in convert_profile_to_dytc() argument
10245 switch (profile) { in convert_profile_to_dytc()
10264 default: /* Unknown profile */ in convert_profile_to_dytc()
10265 return -EOPNOTSUPP; in convert_profile_to_dytc()
10272 * handler. Returns current platform profile.
10275 enum platform_profile_option *profile) in dytc_profile_get() argument
10277 *profile = dytc_current_profile; in dytc_profile_get()
10289 return -ENODEV; in dytc_control_amt()
10306 * Helper function - check if we are in CQL mode and if we are
10307 * - disable CQL,
10308 * - run the command
10309 * - enable CQL
10347 * handler. Sets current platform profile.
10350 enum platform_profile_option profile) in dytc_profile_set() argument
10360 err = convert_profile_to_dytc(profile, &perfmode); in dytc_profile_set()
10365 if (profile == PLATFORM_PROFILE_BALANCED) { in dytc_profile_set()
10368 * Note we still need to disable CQL mode before hand and re-enable in dytc_profile_set()
10389 dytc_control_amt(profile == PLATFORM_PROFILE_BALANCED); in dytc_profile_set()
10391 /* Success - update current profile */ in dytc_profile_set()
10392 dytc_current_profile = profile; in dytc_profile_set()
10400 enum platform_profile_option profile; in dytc_profile_refresh() local
10415 } else { /* Unknown profile mode */ in dytc_profile_refresh()
10416 err = -ENODEV; in dytc_profile_refresh()
10423 convert_dytc_to_profile(funcmode, perfmode, &profile); in dytc_profile_refresh()
10424 if (profile != dytc_current_profile) { in dytc_profile_refresh()
10425 dytc_current_profile = profile; in dytc_profile_refresh()
10453 return -ENODEV; in tpacpi_dytc_profile_init()
10460 /* Check if user wants to override the profile selection */ in tpacpi_dytc_profile_init()
10463 case -1: in tpacpi_dytc_profile_init()
10473 pr_debug("Profile selection forced: 0x%x\n", dytc_capabilities); in tpacpi_dytc_profile_init()
10491 return -ENODEV; in tpacpi_dytc_profile_init()
10504 return -ENODEV; in tpacpi_dytc_profile_init()
10522 .name = "dytc-profile",
10544 {"fr-ch", 0x100c},
10564 return -ENODEV; in set_keyboard_lang_command()
10568 return -EIO; in set_keyboard_lang_command()
10580 return -ENODEV; in get_keyboard_lang()
10584 return -EIO; in get_keyboard_lang()
10588 * '(' and ')') keys which use layout dependent key-press emulation. in get_keyboard_lang()
10591 return -ENODEV; in get_keyboard_lang()
10648 dev_err(&tpacpi_pdev->dev, "Unknown Keyboard language. Ignoring\n"); in keyboard_lang_store()
10649 return -EINVAL; in keyboard_lang_store()
10652 tpacpi_disclose_usertask(attr->attr.name, in keyboard_lang_store()
10655 sysfs_notify(&tpacpi_pdev->dev.kobj, NULL, "keyboard_lang"); in keyboard_lang_store()
10669 return tp_features.kbd_lang ? attr->mode : 0; in kbdlang_attr_is_visible()
10706 return -ENODEV; in dprc_command()
10710 return -EIO; in dprc_command()
10718 return -ENODEV; in dprc_command()
10737 return -ENODEV; in get_wwan_antenna()
10753 return -ENODATA; in wwan_antenna_type_show()
10766 return has_antennatype ? attr->mode : 0; in dprc_attr_is_visible()
10790 /* --------------------------------------------------------------------- */
10823 return attr->mode; in tpacpi_attr_is_visible()
10939 if (!atomic_add_unless(&dytc_ignore_event, -1, 0)) in tpacpi_driver_event()
10947 mutex_lock(&lcdshadow_dev->lock); in tpacpi_driver_event()
10948 old_hw_state = lcdshadow_dev->hw_state; in tpacpi_driver_event()
10950 changed = lcdshadow_dev->hw_state != old_hw_state; in tpacpi_driver_event()
10951 mutex_unlock(&lcdshadow_dev->lock); in tpacpi_driver_event()
10972 /* --------------------------------------------------------------------- */
10994 dbg_printk(TPACPI_DBG_EXIT, "removing %s\n", ibm->name); in ibm_exit()
10996 list_del_init(&ibm->all_drivers); in ibm_exit()
10998 if (ibm->flags.acpi_notify_installed) { in ibm_exit()
11000 "%s: acpi_remove_notify_handler\n", ibm->name); in ibm_exit()
11001 BUG_ON(!ibm->acpi); in ibm_exit()
11002 acpi_remove_notify_handler(*ibm->acpi->handle, in ibm_exit()
11003 ibm->acpi->type, in ibm_exit()
11005 ibm->flags.acpi_notify_installed = 0; in ibm_exit()
11008 if (ibm->flags.proc_created) { in ibm_exit()
11010 "%s: remove_proc_entry\n", ibm->name); in ibm_exit()
11011 remove_proc_entry(ibm->name, proc_dir); in ibm_exit()
11012 ibm->flags.proc_created = 0; in ibm_exit()
11015 if (ibm->flags.acpi_driver_registered) { in ibm_exit()
11017 "%s: acpi_bus_unregister_driver\n", ibm->name); in ibm_exit()
11018 BUG_ON(!ibm->acpi); in ibm_exit()
11019 acpi_bus_unregister_driver(ibm->acpi->driver); in ibm_exit()
11020 kfree(ibm->acpi->driver); in ibm_exit()
11021 ibm->acpi->driver = NULL; in ibm_exit()
11022 ibm->flags.acpi_driver_registered = 0; in ibm_exit()
11025 if (ibm->flags.init_called && ibm->exit) { in ibm_exit()
11026 ibm->exit(); in ibm_exit()
11027 ibm->flags.init_called = 0; in ibm_exit()
11030 dbg_printk(TPACPI_DBG_INIT, "finished removing %s\n", ibm->name); in ibm_exit()
11036 struct ibm_struct *ibm = iibm->data; in ibm_init()
11041 INIT_LIST_HEAD(&ibm->all_drivers); in ibm_init()
11043 if (ibm->flags.experimental && !experimental) in ibm_init()
11047 "probing for %s\n", ibm->name); in ibm_init()
11049 if (iibm->init) { in ibm_init()
11050 ret = iibm->init(iibm); in ibm_init()
11051 if (ret > 0 || ret == -ENODEV) in ibm_init()
11056 ibm->flags.init_called = 1; in ibm_init()
11059 if (ibm->acpi) { in ibm_init()
11060 if (ibm->acpi->hid) { in ibm_init()
11066 if (ibm->acpi->notify) { in ibm_init()
11068 if (ret == -ENODEV) { in ibm_init()
11070 ibm->name); in ibm_init()
11080 "%s installed\n", ibm->name); in ibm_init()
11082 if (ibm->read) { in ibm_init()
11083 umode_t mode = iibm->base_procfs_mode; in ibm_init()
11087 if (ibm->write) in ibm_init()
11089 entry = proc_create_data(ibm->name, mode, proc_dir, in ibm_init()
11092 pr_err("unable to create proc entry %s\n", ibm->name); in ibm_init()
11093 ret = -ENODEV; in ibm_init()
11096 ibm->flags.proc_created = 1; in ibm_init()
11099 list_add_tail(&ibm->all_drivers, &tpacpi_all_drivers); in ibm_init()
11106 ibm->name, ret); in ibm_init()
11129 * Ancient 570/600 and -SL lacks (#.##c) in tpacpi_parse_fw_id()
11155 * ---------------------------------------------------- in find_new_ec_fwstr()
11168 if (dm->type != 140 || dm->length < 0x0F || in find_new_ec_fwstr()
11178 /* returns 0 - probe ok, or < 0 - probe error.
11180 * On error, kfree() cleanup on tp->* is not performed, caller must do it */
11190 return -EINVAL; in get_thinkpad_model_data()
11195 tp->vendor = PCI_VENDOR_ID_IBM; in get_thinkpad_model_data()
11197 tp->vendor = PCI_VENDOR_ID_LENOVO; in get_thinkpad_model_data()
11202 tp->bios_version_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11203 if (s && !tp->bios_version_str) in get_thinkpad_model_data()
11204 return -ENOMEM; in get_thinkpad_model_data()
11207 t = tpacpi_parse_fw_id(tp->bios_version_str, in get_thinkpad_model_data()
11208 &tp->bios_model, &tp->bios_release); in get_thinkpad_model_data()
11215 * up-to-date BIOS or they will not be detected. in get_thinkpad_model_data()
11220 if (sscanf(dev->name, in get_thinkpad_model_data()
11221 "IBM ThinkPad Embedded Controller -[%17c", in get_thinkpad_model_data()
11223 ec_fw_string[sizeof(ec_fw_string) - 1] = 0; in get_thinkpad_model_data()
11234 tp->ec_version_str = kstrdup(ec_fw_string, GFP_KERNEL); in get_thinkpad_model_data()
11235 if (!tp->ec_version_str) in get_thinkpad_model_data()
11236 return -ENOMEM; in get_thinkpad_model_data()
11239 &tp->ec_model, &tp->ec_release); in get_thinkpad_model_data()
11249 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11250 if (!tp->model_str) in get_thinkpad_model_data()
11251 return -ENOMEM; in get_thinkpad_model_data()
11255 tp->model_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11256 if (!tp->model_str) in get_thinkpad_model_data()
11257 return -ENOMEM; in get_thinkpad_model_data()
11262 tp->nummodel_str = kstrdup(s, GFP_KERNEL); in get_thinkpad_model_data()
11263 if (s && !tp->nummodel_str) in get_thinkpad_model_data()
11264 return -ENOMEM; in get_thinkpad_model_data()
11274 return -ENODEV; in probe_for_thinkpad()
11278 return -ENODEV; in probe_for_thinkpad()
11281 * Non-ancient models have better DMI tagging, but very old models in probe_for_thinkpad()
11293 return -ENODEV; in probe_for_thinkpad()
11297 return -ENODEV; in probe_for_thinkpad()
11426 if (!kp || !kp->name || !val) in set_ibm_param()
11427 return -EINVAL; in set_ibm_param()
11431 if (!ibm || !ibm->name) in set_ibm_param()
11434 if (strcmp(ibm->name, kp->name) == 0 && ibm->write) { in set_ibm_param()
11435 if (strlen(val) > sizeof(ibms_init[i].param) - 1) in set_ibm_param()
11436 return -ENOSPC; in set_ibm_param()
11442 return -EINVAL; in set_ibm_param()
11447 "Enables experimental features when non-zero");
11450 MODULE_PARM_DESC(debug, "Sets debug level bit-mask");
11454 "Attempts to load the driver even on a mis-identified ThinkPad when true");
11497 …MODULE_PARM_DESC(feature, "Simulates thinkpad-acpi procfs command at module load, see documentatio…
11537 MODULE_PARM_DESC(profile_force, "Force profile mode. -1=off, 1=MMC, 2=PSC");
11592 /* Driver-level probe */ in thinkpad_acpi_module_init()
11632 return -ENOMEM; in thinkpad_acpi_module_init()
11639 return -ENODEV; in thinkpad_acpi_module_init()
11644 tp_features.quirks = dmi_id->driver_data; in thinkpad_acpi_module_init()
11671 return -ENOMEM; in thinkpad_acpi_module_init()
11674 tpacpi_inputdev->name = "ThinkPad Extra Buttons"; in thinkpad_acpi_module_init()
11675 tpacpi_inputdev->phys = TPACPI_DRVR_NAME "/input0"; in thinkpad_acpi_module_init()
11676 tpacpi_inputdev->id.bustype = BUS_HOST; in thinkpad_acpi_module_init()
11677 tpacpi_inputdev->id.vendor = thinkpad_id.vendor; in thinkpad_acpi_module_init()
11678 tpacpi_inputdev->id.product = TPACPI_HKEY_INPUT_PRODUCT; in thinkpad_acpi_module_init()
11679 tpacpi_inputdev->id.version = TPACPI_HKEY_INPUT_VERSION; in thinkpad_acpi_module_init()
11680 tpacpi_inputdev->dev.parent = &tpacpi_pdev->dev; in thinkpad_acpi_module_init()
11690 ret = ibms_init[i].data->write(ibms_init[i].param); in thinkpad_acpi_module_init()
11716 &tpacpi_sensors_pdev->dev, TPACPI_NAME, NULL, tpacpi_hwmon_groups); in thinkpad_acpi_module_init()