summaryrefslogtreecommitdiffstats
path: root/drivers/platform/x86/ideapad-laptop.c
AgeCommit message (Collapse)AuthorFilesLines
2022-12-27platform/x86: ideapad-laptop: Add Legion 5 15ARH05 DMI id to ↵Hans de Goede1-0/+6
set_fn_lock_led_list[] The Lenovo Legion 5 15ARH05 needs ideapad-laptop to call SALS_FNLOCK_ON / SALS_FNLOCK_OFF on Fn-lock state change to get the LED in the Fn key to correctly reflect the Fn-lock state. Add a DMI match for the Legion 5 15ARH05 to the set_fn_lock_led_list[] table for this. Fixes: 81a5603a0f50 ("platform/x86: ideapad-laptop: Fix interrupt storm on fn-lock toggle on some Yoga laptops") Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20221215154357.123876-1-hdegoede@redhat.com
2022-11-21platform/x86: ideapad-laptop: Make touchpad_ctrl_via_ec a module optionHans de Goede1-26/+7
Remove the ACPI-HID + DMI-id deny-lists for touchpad_ctrl_via_ec and instead make it a module option which defaults to false. The touchpad sysfs attribute allowing directly writing VPCCMD_W_TOUCHPAD from userspace has been leading to a lot of bug-reports / patches adding both ACPI HID + dmi-id based deny-lists for it which then need to be expanded all the time going forward leading to a high maintenance load. At the same time the touchpad sysfs attribute is not a standard Linux userspace API. So it is not used in standard desktop-enviroments, instead it is only used in the following 2 rare circumstances: 1. Ideapad specific control-panel like applets 2. Custom scripts written by users For 1. these applets need to already deal with the touchpad sysfs attr sometimes not being there because of the existing deny lists so hiding it be default should not cause an issue; and most desktop environments already have a touchpad-disable option in their native control-panel, so having an ideapad specific toggle for this is not necessary. For 2. since these users are already customizing their systems they can add the module option if they want to keep using the touchpad sysfs attribute. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Maxim Mikityanskiy <maxtram95@gmail.com> Link: https://lore.kernel.org/r/20221117110244.67811-7-hdegoede@redhat.com
2022-11-21platform/x86: ideapad-laptop: Stop writing VPCCMD_W_TOUCHPAD at probe timeHans de Goede1-4/+0
Commit d69cd7eea93e ("platform/x86: ideapad-laptop: Disable touchpad_switch for ELAN0634") from Janary 2021 added a flag hiding the touchpad sysfs-attr and disabling ideapad_sync_touchpad_state() because some devices "do not use EC to switch touchpad". At the same time this added a write(VPCCMD_W_TOUCHPAD, 1) call at probe time on these same devices. This seems to be copied from the rfkill code which does something similar when hw rfkill support is disabled. But for the rfkill code this is known to be necessary on some models, where as for the touchpad control no motivation is given for doing this and prior to this patch there were no reports of needing to do this. So this seems unnecessary; and it is best to avoid poking the hardware unnecessary to avoid unwanted side effects, so remove this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Maxim Mikityanskiy <maxtram95@gmail.com> Link: https://lore.kernel.org/r/20221117110244.67811-6-hdegoede@redhat.com
2022-11-21platform/x86: ideapad-laptop: Send KEY_TOUCHPAD_TOGGLE on some modelsHans de Goede1-5/+19
On recent Ideapad models the EC does not control the touchpad at all, so instead of sending KEY_TOUCHPAD_ON/ _OFF on touchpad toggle hotkey events, ideapad-laptop should send KEY_TOUCHPAD_TOGGLE and let userspace handle the toggling. Check for this by checking if the value read from VPCCMD_R_TOUCHPAD actually changes when receiving a touchpad-toggle hotkey event; and if it does not change send KEY_TOUCHPAD_TOGGLE to userspace to let userspace enable/disable the touchpad in software. Note this also drops the priv->features.touchpad_ctrl_via_ec check from ideapad_sync_touchpad_state() so that KEY_TOUCHPAD_TOGGLE will be send on laptops where this is not set too. This can be safely dropped now because the i8042_command(I8042_CMD_AUX_ENABLE/_DISABLE) call is now guarded by its own feature flag. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Maxim Mikityanskiy <maxtram95@gmail.com> Link: https://lore.kernel.org/r/20221117110244.67811-5-hdegoede@redhat.com
2022-11-21platform/x86: ideapad-laptop: Only toggle ps2 aux port on/off on select modelsHans de Goede1-1/+28
Recently there have been multiple patches to disable the ideapad-laptop's touchpad control code, because it is causing issues on various laptops: Commit d69cd7eea93e ("platform/x86: ideapad-laptop: Disable touchpad_switch for ELAN0634") Commit a231224a601c ("platform/x86: ideapad-laptop: Disable touchpad_switch") The turning on/off of the ps2 aux port was added specifically for the IdeaPad Z570, where the EC does toggle the touchpad on/off LED and toggles the value returned by reading VPCCMD_R_TOUCHPAD, but it does not actually turn on/off the touchpad. The ideapad-laptop code really should not be messing with the i8042 controller on all devices just for this special case. Add a new ctrl_ps2_aux_port flag set based on a DMI based allow-list for devices which need this workaround, populating it with just the Ideapad Z570 for now. This also adds a module parameter so that this behavior can easily be enabled on other models which may need it. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Maxim Mikityanskiy <maxtram95@gmail.com> Link: https://lore.kernel.org/r/20221117110244.67811-4-hdegoede@redhat.com
2022-11-21platform/x86: ideapad-laptop: Do not send KEY_TOUCHPAD* events on probe / resumeHans de Goede1-6/+9
The sending of KEY_TOUCHPAD* events is causing spurious touchpad OSD showing on resume. Disable the sending of events on probe / resume to fix this. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Maxim Mikityanskiy <maxtram95@gmail.com> Link: https://lore.kernel.org/r/20221117110244.67811-3-hdegoede@redhat.com
2022-11-21platform/x86: ideapad-laptop: Refactor ideapad_sync_touchpad_state()Hans de Goede1-12/+15
Add an error exit for read_ec_data() failing instead of putting the main body in an if (success) block. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Tested-by: Maxim Mikityanskiy <maxtram95@gmail.com> Link: https://lore.kernel.org/r/20221117110244.67811-2-hdegoede@redhat.com
2022-11-16platform/x86: ideapad-laptop: support for more special keys in WMIPhilipp Jungkamp1-59/+202
The event data of the WMI event 0xD0, which is assumed to be the fn_lock, is used to indicate several special keys on newer Yoga 7/9 laptops. The notify_id 0xD0 is non-unique in the DSDT of the Yoga 9 14IAP7, this causes wmi_get_event_data() to report wrong values. Port the ideapad-laptop WMI code to the wmi bus infrastructure which does not suffer from the shortcomings of wmi_get_event_data(). Signed-off-by: Philipp Jungkamp <p.jungkamp@gmx.net> Link: https://lore.kernel.org/r/20221116110647.3438-1-p.jungkamp@gmx.net Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-11-16platform/x86: ideapad-laptop: Add new _CFG bit numbers for future useEray Orçunus1-4/+29
Later IdeaPads report various things in last 8 bits of _CFG, at least 5 of them represent supported on-screen-displays. Add those bit numbers to the enum, and use CFG_OSD_ as prefix of their names. Also expose the values of these bits to debugfs, since they can be useful. Signed-off-by: Eray Orçunus <erayorcunus@gmail.com> Acked-by: Ike Panhc <ike.pan@canonical.com> Link: https://lore.kernel.org/r/20221029120311.11152-5-erayorcunus@gmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-11-16platform/x86: ideapad-laptop: Revert "check for touchpad support in _CFG"Eray Orçunus1-9/+5
Last 8 bit of _CFG started being used in later IdeaPads, thus 30th bit doesn't always show whether device supports touchpad or touchpad switch. Remove checking bit 30 of _CFG, so older IdeaPads like S10-3 can switch touchpad again via touchpad attribute. This reverts commit b3ed1b7fe378 ("platform/x86: ideapad-laptop: check for touchpad support in _CFG"). Signed-off-by: Eray Orçunus <erayorcunus@gmail.com> Acked-by: Ike Panhc <ike.pan@canonical.com> Link: https://lore.kernel.org/r/20221029120311.11152-2-erayorcunus@gmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-11-16platform/x86: ideapad-laptop: Add module parameters to match DMI quirk tablesHans de Goede1-3/+19
Add module parameters to allow setting the hw_rfkill_switch and set_fn_lock_led feature flags for testing these on laptops which are not on the DMI-id based allow lists for these 2 flags. Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20221115193400.376159-1-hdegoede@redhat.com
2022-11-16platform/x86: ideapad-laptop: Fix interrupt storm on fn-lock toggle on some ↵Arnav Rawat1-0/+17
Yoga laptops Commit 3ae86d2d4704 ("platform/x86: ideapad-laptop: Fix Legion 5 Fn lock LED") uses the WMI event-id for the fn-lock event on some Legion 5 laptops to manually toggle the fn-lock LED because the EC does not do it itself. However, the same WMI ID is also sent on some Yoga laptops. Here, setting the fn-lock state is not valid behavior, and causes the EC to spam interrupts until the laptop is rebooted. Add a set_fn_lock_led_list[] DMI-id list and only enable the workaround to manually set the LED on models on this list. Link: https://bugzilla.kernel.org/show_bug.cgi?id=212671 Cc: Meng Dong <whenov@gmail.com> Signed-off-by: Arnav Rawat <arnavr3@illinois.edu> Link: https://lore.kernel.org/r/12093851.O9o76ZdvQC@fedora [hdegoede@redhat.com: Check DMI-id list only once and store the result] Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-11-07platform/x86: ideapad-laptop: Disable touchpad_switchManyi Li1-1/+24
Ideapads for "Lenovo Yoga 3 Pro 1370" and "ZhaoYang K4e-IML" do not use EC to switch touchpad. Reading VPCCMD_R_TOUCHPAD will return zero thus touchpad may be blocked unexpectedly. Signed-off-by: Manyi Li <limanyi@uniontech.com> Link: https://lore.kernel.org/r/20221018095323.14591-1-limanyi@uniontech.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2022-06-27platform/x86: ideapad-laptop: Add Ideapad 5 15ITL05 to ↵Hans de Goede1-1/+7
ideapad_dytc_v4_allow_table[] The Ideapad 5 15ITL05 uses DYTC version 4 for platform-profile control. This has been tested successfully with the ideapad-laptop DYTC version 5 code; Add the Ideapad 5 15ITL05 to the ideapad_dytc_v4_allow_table[]. Fixes: 599482c58ebd ("platform/x86: ideapad-laptop: Add platform support for Ideapad 5 Pro 16ACH6-82L5") Link: https://bugzilla.kernel.org/show_bug.cgi?id=213297 Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20220627130850.313537-1-hdegoede@redhat.com
2022-06-27platform/x86: ideapad-laptop: Add allow_v4_dytc module parameterHans de Goede1-7/+14
Add an allow_v4_dytc module parameter to allow users to easily test if DYTC version 4 platform-profiles work on their laptop. Fixes: 599482c58ebd ("platform/x86: ideapad-laptop: Add platform support for Ideapad 5 Pro 16ACH6-82L5") Link: https://bugzilla.kernel.org/show_bug.cgi?id=213297 Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20220623115914.103001-1-hdegoede@redhat.com
2021-10-19platform: x86: ideapad-laptop: Use ACPI_COMPANION() directlyRafael J. Wysocki1-6/+2
The ACPI_HANDLE() macro is a wrapper arond the ACPI_COMPANION() macro and the ACPI handle produced by the former comes from the ACPI device object produced by the latter, so it is way more straightforward to evaluate the latter directly instead of passing the handle produced by the former to acpi_bus_get_device(). Modify ideapad_acpi_add() accordingly (no intentional functional impact). Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Link: https://lore.kernel.org/r/8000884.T7Z3S40VBb@kreacher Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-09-28platform/x86: ideapad-laptop: Add platform support for Ideapad 5 Pro 16ACH6-82L5Kelly Anderson1-3/+24
Adding support specifically for Ideapad 5 Pro 16ACH6-82L5 by adding a allow list that can validate notebooks for which dytc_version is less than 5, and seem to work fine at dytc_version 4. This code has been tested to work properly on the specified system. Signed-off-by: Kelly Anderson <kelly@xilka.com> Link: https://lore.kernel.org/r/11840239.O9o76ZdvQC@comer.internal Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-08-20platform/x86: ideapad-laptop: Fix Legion 5 Fn lock LEDMeng Dong1-0/+9
This patch fixes the bug 212671. Althrough the Fn lock (Fn + Esc) works on Legion 5 (R7000P), its LED light does not change with the state. This modification sets the Fn lock state to its current value on receiving the wmi event 8FC0DE0C-B4E4-43FD-B0F3-8871711C1294 to update the LED state. Signed-off-by: Meng Dong <whenov@gmail.com> Link: https://lore.kernel.org/r/20210817171203.12855-1-whenov@gmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-06-16platform/x86: ideapad-laptop: Ignore VPC event bit 10Hans de Goede1-0/+12
VPC event bit 10 gets set on a Yoga 300-11IBR when the EC believes that the device has changed between laptop/tent/stand/tablet mode. The EC relies on getting angle info from 2 accelerometers through a special windows service calling a DSM on the DUAL250E ACPI-device. Linux does not do this, making the laptop/tent/stand/tablet mode info unreliable. Ignore VPC event bit 10 to avoid the warnings triggered by the default case in ideapad_acpi_notify(). Note that the plan for Linux is to have iio-sensor-proxy read the 2 accelerometers and have it provide info about which mode 360° hinges 2-in-1s to the rest of userspace: https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/-/issues/216 Signed-off-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20210523172331.177834-1-hdegoede@redhat.com
2021-05-11platform/x86: ideapad-laptop: fix method name typoBarnabás Pőcze1-5/+5
"smbc" should be "sbmc". `eval_smbc()` incorrectly called the SMBC ACPI method instead of SBMC. This resulted in partial loss of functionality. Rectify that by calling the correct ACPI method (SBMC), and also rename methods and constants. BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=212985 Fixes: 0b765671cb80 ("platform/x86: ideapad-laptop: group and separate (un)related constants into enums") Fixes: ff36b0d953dc ("platform/x86: ideapad-laptop: rework and create new ACPI helpers") Cc: stable@vger.kernel.org # 5.12 Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210507235333.286505-1-pobrn@protonmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-05-11platform/x86: ideapad-laptop: fix a NULL pointer dereferenceQiu Wenbo1-1/+2
The third parameter of dytc_cql_command should not be NULL since it will be dereferenced immediately. Fixes: ff36b0d953dc4 ("platform/x86: ideapad-laptop: rework and create new ACPI helpers") Signed-off-by: Qiu Wenbo <qiuwenbo@kylinos.com.cn> Acked-by: Ike Panhc <ike.pan@canonical.com> Link: https://lore.kernel.org/r/20210428050636.8003-1-qiuwenbo@kylinos.com.cn Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: add "always on USB charging" control supportBarnabás Pőcze1-9/+56
Certain models have a so-called "always on USB charging" feature, which enables USB charging even when the computer is turned off or suspended, and which may be controlled/queried using the SALS/HALS ACPI methods. Expose this functionality via a new device attribute (usb_charging). Tested on: Lenovo YOGA 520-14IKB 80X8 Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-28-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: add keyboard backlight control supportBarnabás Pőcze1-1/+132
On certain models it is possible to control/query the keyboard backlight via the SALS/HALS ACPI methods. Add support for that, and register an LED class device to expose this functionality. Tested on: Lenovo YOGA 520-14IKB 80X8 Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-27-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: send notification about touchpad state change ↵Barnabás Pőcze1-0/+1
to sysfs Consumers can determine if the value of an attribute changed much more easily if changes are broadcast using sysfs_notify(), so utilize it. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-26-pobrn@protonmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: fix checkpatch warnings, more consistent styleBarnabás Pőcze1-198/+256
Fix all checkpatch warnings. Reorder variable definitions from longest to shortest. Add more whitespaces for better readability. Rename variables named `ret` to `err` where appropriate. Reorder sysfs attributes show/store callbacks and the `ideapad_attributes` array in lexicographic order. And other minor formatting changes. No significant functional changes are intended. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-25-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04Revert "platform/x86: ideapad-laptop: Switch touchpad attribute to be RO"Barnabás Pőcze1-5/+4
The touchpad can be enabled/disabled via this attribute on a Lenovo Yoga 520-14IKB. Allow writing as it provides legitimate functionality. This reverts commit 7f363145992cebf4ea760447f1cfdf6f81459683. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-24-pobrn@protonmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: change 'cfg' debugfs file formatBarnabás Pőcze1-15/+18
Minor formatting changes. Use seq_puts() where possible. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-23-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: change 'status' debugfs file formatBarnabás Pőcze1-22/+15
Remove conservation mode reporting since it is already reported via the appropriate device attribute, and its state can be deduced from the value of GBMD. Add the return value of the GBMD and HALS ACPI methods to the output. Use seq_puts() where possible. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-22-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: check for touchpad support in _CFGBarnabás Pőcze1-5/+9
Bit 30 of _CFG is set if the device has a touchpad, check that in is_visible() for the touchpad attribute. Show 'touchpad', if supported, in the list of capabilities in the 'cfg' debugfs file. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-21-pobrn@protonmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: check for Fn-lock support in HALSBarnabás Pőcze1-3/+9
Bit 9 in the return value of the HALS ACPI method is set if Fn-lock is supported. Change ideapad_check_features() to check it. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-20-pobrn@protonmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: rework is_visible() logicBarnabás Pőcze1-25/+55
Store the supported features in the driver private data, and modify the is_visible() callback to use it, and create ideapad_check_features() to populate it. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-19-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: rework and create new ACPI helpersBarnabás Pőcze1-95/+77
Create dedicated helper functions for accessing the main ACPI methods: GBMD, SMBC, HALS, SALS; and utilize them. Use `unsigned long` consistently in every ACPI helper wherever possible. Change names to better express purpose. Do not assign values to output parameters in case of failure. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-18-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: group and separate (un)related constants into ↵Barnabás Pőcze1-27/+37
enums Group and rename constants depending on which ACPI interface they pertain to, and rename CFG_X constants to CFG_CAP_X. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-17-pobrn@protonmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: misc. device attribute changesBarnabás Pőcze1-15/+15
Do not handle zero length buffer separately. Use kstrtouint() instead of sscanf(). Use kstrtobool() in store_ideapad_cam(). These introduce minor ABI changes, but it is expected that no users rely on the previous behavior. Thus the change is deemed justifed. Additionally, use `!!` to convert to `int` and use the "%d" format specifier in sysfs_emit() for boolean-like attributes. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-16-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: always propagate error codes from device ↵Barnabás Pőcze1-9/+17
attributes' show() callback Consumers can differentiate an error from a successful read much more easily if the read() call fails with an appropriate errno instead of returning a magic string like "-1". This introduces an ABI change, but not many users are expected to be relying on the previous behavior, and this change makes this module conforming to the standard behavior that sysfs attribute show/store callbacks return an appropriate errno in case of failure. Thus the ABI breakage is deemed justified. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-15-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: convert ACPI helpers to return -EIO in case of ↵Barnabás Pőcze1-46/+62
failure ACPI helpers returned -1 in case of failure. Convert these functions to return appropriate error codes, and convert their users to propagate these error codes accordingly. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-14-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: use dev_{err,warn} or appropriate variant to ↵Barnabás Pőcze1-9/+17
display log messages Having the device name in the log message makes it easier to determine in the context of which device the message was printed, so utilize the appropriate variants of dev_{err,warn,...} when printing log messages. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-12-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: use msecs_to_jiffies() helper instead of ↵Barnabás Pőcze1-4/+7
hand-crafted formula The current code used a hand-crafted formula to convert milliseconds to jiffies, replace it with the msecs_to_jiffies() function. Furthermore, use a while loop instead of for loop for shorter lines and simplicity. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-11-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: use for_each_set_bit() helper to simplify ↵Barnabás Pőcze1-55/+53
event processing The current code used the combination of a for loop + test_bit, which can be simplified using for_each_set_bit(), so utilize that. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-10-pobrn@protonmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: use kobj_to_dev()Barnabás Pőcze1-1/+1
Use kobj_to_dev() instead of open-coding the container_of() macro. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-9-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: use device_{add,remove}_groupBarnabás Pőcze1-4/+4
Use device_{add,remove}_group instead of sysfs_{add,remove}_group. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-8-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: use sysfs_emit()Barnabás Pőcze1-10/+11
sysfs_emit() has been introduced to make it less ambiguous which function is preferred when writing to the output buffer in a device attribute's show() callback. Convert the ideapad-laptop module to utilize this new helper function. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-7-pobrn@protonmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: add missing call to submodule destructorBarnabás Pőcze1-0/+1
ideapad_dytc_profile_exit() is not called in ideapad_acpi_add() in the error path. Add the missing call. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-6-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: sort includes lexicographicallyBarnabás Pőcze1-12/+13
Managing includes is easier when they are sorted, so sort them lexicographically. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-5-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: use appropriately typed variable to store the ↵Barnabás Pőcze1-7/+13
return value of ACPI methods Use a variable with type `acpi_status` to store the return value of ACPI methods instead of a plain `int`. And use ACPI_{SUCCESS,FAILURE} macros where possible instead of direct comparison. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-4-pobrn@protonmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: remove unnecessary NULL checksBarnabás Pőcze1-47/+31
The checks that are removed test pointers which should not be NULL. If they are NULL, that indicates a bug in a different part of the kernel. Instead of silently bailing out, let it fail loudly. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-3-pobrn@protonmail.com Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-04platform/x86: ideapad-laptop: remove unnecessary dev_set_drvdata() callBarnabás Pőcze1-1/+0
The driver core already sets the driver specific data on bind failure or removal. Thus the call is unnecessary. Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Link: https://lore.kernel.org/r/20210203215403.290792-2-pobrn@protonmail.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-02-02platform/x86: ideapad-laptop: DYTC Platform profile supportJiaxun Yang1-0/+289
Add support to ideapad-laptop for Lenovo platforms that have DYTC version 5 support or newer to use the platform profile feature. Mostly based on Mark Pearson <markpearson@lenovo.com>'s thinkpad-acpi work but massaged to fit ideapad driver. Note that different from ThinkPads, IdeaPads's Thermal Hotkey won't trigger profile switch itself, we'll leave it for userspace programs. Tested on Lenovo Yoga-14S ARE Chinese Edition. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Link: https://lore.kernel.org/r/20210105131447.38036-3-jiaxun.yang@flygoat.com [hdegoede@redhat.com s/QUIET/LOW_POWER/] Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2021-01-13platform/x86: ideapad-laptop: Disable touchpad_switch for ELAN0634Jiaxun Yang1-1/+14
Newer ideapads (e.g.: Yoga 14s, 720S 14) come with ELAN0634 touchpad do not use EC to switch touchpad. Reading VPCCMD_R_TOUCHPAD will return zero thus touchpad may be blocked unexpectedly. Writing VPCCMD_W_TOUCHPAD may cause a spurious key press. Add has_touchpad_switch to workaround these machines. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> Cc: stable@vger.kernel.org # 5.4+ -- v2: Specify touchpad to ELAN0634 v3: Stupid missing ! in v2 v4: Correct acpi_dev_present usage (Hans) Link: https://lore.kernel.org/r/20210107144438.12605-1-jiaxun.yang@flygoat.com Signed-off-by: Hans de Goede <hdegoede@redhat.com>
2019-07-14Merge tag 'platform-drivers-x86-v5.3-1' of ↵Linus Torvalds1-29/+7
git://git.infradead.org/linux-platform-drivers-x86 Pull x86 platform driver updates from Andy Shevchenko: "Gathered a bunch of x86 platform driver changes. It's rather big, since includes two big refactors and completely new driver: - ASUS WMI driver got a big refactoring in order to support the TUF Gaming laptops. Besides that, the regression with backlight being permanently off on various EeePC laptops has been fixed. - Accelerometer on HP ProBook 450 G0 shows wrong measurements due to X axis being inverted. This has been fixed. - Intel PMC core driver has been extended to be ACPI enumerated if the DSDT provides device with _HID "INT33A1". This allows to convert the driver to be pure platform and support new hardware purely based on ACPI DSDT. - From now on the Intel Speed Select Technology is supported thru a corresponding driver. This driver provides an access to the features of the ISST, such as Performance Profile, Core Power, Base frequency and Turbo Frequency. - Mellanox platform drivers has been refactored and now extended to support more systems, including new coming ones. - The OLPC XO-1.75 platform is now supported. - CB4063 Beckhoff Automation board is using PMC clocks, provided via pmc_atom driver, for ethernet controllers in a way that they can't be managed by the clock driver. The quirk has been extended to cover this case. - Touchscreen on Chuwi Hi10 Plus tablet has been enabled. Meanwhile the information of Chuwi Hi10 Air has been fixed to cover more models based on the same platform. - Xiaomi notebooks have WMI interface enabled. Thus, the driver to support it has been provided. It required some extension of the generic WMI library, which allows to propagate opaque context to the ->probe() of the individual drivers. This release includes debugfs clean up from Greg KH for several drivers that drop return code check and make debugfs absence or failure non-fatal. Also miscellaneous fixes here and there, mostly for Acer WMI and various Intel drivers" * tag 'platform-drivers-x86-v5.3-1' of git://git.infradead.org/linux-platform-drivers-x86: (74 commits) platform/x86: Fix PCENGINES_APU2 Kconfig warning tools/power/x86/intel-speed-select: Add .gitignore file platform/x86: mlx-platform: Fix error handling in mlxplat_init() platform/x86: intel_pmc_core: Attach using APCI HID "INT33A1" platform/x86: intel_pmc_core: transform Pkg C-state residency from TSC ticks into microseconds platform/x86: asus-wmi: Use dev_get_drvdata() Documentation/ABI: Add new attribute for mlxreg-io sysfs interfaces platform/x86: mlx-platform: Add more reset cause attributes platform/x86: mlx-platform: Modify DMI matching order platform/x86: mlx-platform: Add regmap structure for the next generation systems platform/x86: mlx-platform: Change API for i2c-mlxcpld driver activation platform/x86: mlx-platform: Move regmap initialization before all drivers activation MAINTAINERS: Update for Intel Speed Select Technology tools/power/x86: A tool to validate Intel Speed Select commands platform/x86: ISST: Restore state on resume platform/x86: ISST: Add Intel Speed Select PUNIT MSR interface platform/x86: ISST: Add Intel Speed Select mailbox interface via MSRs platform/x86: ISST: Add Intel Speed Select mailbox interface via PCI platform/x86: ISST: Add Intel Speed Select mmio interface platform/x86: ISST: Add IOCTL to Translate Linux logical CPU to PUNIT CPU number ...