summaryrefslogtreecommitdiff
path: root/drivers/platform/x86/oxpec.c
AgeCommit message (Collapse)Author
2025-05-08platform/x86: oxpec: Add support for the OneXPlayer G1Antheas Kapenekakis
The OneXPlayer G1 is a new clamshell formfactor by OneXPlayer. It has the same registers as an OneXPlayer X1, with the only difference being the lack of a turbo led. Tested-by: Joshua Tam <csinaction@pm.me> Suggested-by: Joshua Tam <csinaction@pm.me> Signed-off-by: Joshua Tam <csinaction@pm.me> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250426172955.13957-3-lkml@antheas.dev Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-05-08platform/x86: oxpec: Make turbo val apply a bitmaskAntheas Kapenekakis
On the OneXPlayer G1, the turbo register is multiplexed and contains an extra bit (0x02) which is set on boot. Therefore, we should only change the 0x40 bit to not affect other behavior. Collapse the disable and enable functions, and apply a mask for the turbo bit instead. Tested-by: Joshua Tam <csinaction@pm.me> Suggested-by: Joshua Tam <csinaction@pm.me> Signed-off-by: Joshua Tam <csinaction@pm.me> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250426172955.13957-2-lkml@antheas.dev Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-05-08platform/x86: oxpec: Add a lower bounds check in oxp_psy_ext_set_prop()Dan Carpenter
The "val->intval" variable is an integer which comes from the user. This code has an upper bounds check but the lower bounds check was accidentally omitted. The write_to_ec() take a u8 value as a parameter so negative values would be truncated to positive values in the 0-255 range. Return -EINVAL if the user passes a negative value. Fixes: 202593d1e86b ("platform/x86: oxpec: Add charge threshold and behaviour to OneXPlayer") Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org> Reviewed-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/aBSE71VKfBlQg_fZ@stanley.mountain Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Convert defines to using tabsAntheas Kapenekakis
The defines used spaces previously. Convert all of them to use tabs. Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-17-lkml@antheas.dev Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Rename rval to ret in tt_toggleAntheas Kapenekakis
Rename the variable `rval` to `ret` in the function for consistency. Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-16-lkml@antheas.dev Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Add charge threshold and behaviour to OneXPlayerAntheas Kapenekakis
With the X1 (AMD), OneXPlayer added a charge limit and charge inhibit feature to their devices. Charge limit allows for choosing an arbitrary battery charge setpoint in percentages. Charge ihibit allows to instruct the device to stop charging either when it is awake or always. This feature was then extended for the F1Pro as well. OneXPlayer also released BIOS updates for the X1 Mini, X1 (Intel), and F1 devices that add support for this feature. Therefore, enable it for all F1 and X1 devices. Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-15-lkml@antheas.dev Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Follow reverse xmas convention for tt_toggleAntheas Kapenekakis
Since the rest of the driver follows this convention, apply it to the tt_toggle attribute as well. Suggested-by: Derek J. Clark <derekjohn.clark@gmail.com> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-13-lkml@antheas.dev Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Adhere to sysfs-class-hwmon and enable pwm on 2Antheas Kapenekakis
Currently, the driver does not adhere to the sysfs-class-hwmon specification: 0 is used for auto fan control and 1 is used for manual control. However, it is expected that 0 sets the fan to full speed, 1 sets the fan to manual, and then 2 is used for automatic control. Therefore, change the sysfs API to reflect this and enable pwm on 2. As we are breaking the ABI for this driver, rename oxpec to oxp_ec, reflecting the naming convention used by other drivers, to allow for a smooth migration in current userspace programs. Closes: https://lore.kernel.org/linux-hwmon/20241027174836.8588-1-derekjohn.clark@gmail.com/ Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-12-lkml@antheas.dev Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Move fan speed read to separate functionAntheas Kapenekakis
While not necessary for fixing the ABI hwmon issue, fan speed will be the only remaining value without a function. Therefore, finish the refactor by moving it to a separate function. Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-11-lkml@antheas.dev Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Move pwm value read/write to separate functionsAntheas Kapenekakis
Currently, this driver breaks hwmon ABI by using auto as 0 and manual as 1. However, for pwm_enable, 0 is full speed, 1 is manual, and 2 is auto. For the correction to be possible, this means that the pwm_enable endpoint will need access to both pwm enable and value (as for the 0th value, the fan needs to be set to full power). Therefore, move the pwm value read/write to separate functions. Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-10-lkml@antheas.dev Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Move pwm_enable read to its own functionAntheas Kapenekakis
Currently, this driver breaks ABI by using auto as 0 and manual as 1. However, for pwm_enable, 0 is full speed, 1 is manual, and 2 is auto. For the correction to be possible, this means that the pwm_enable endpoint will need access to both pwm enable and value (as for the 0th value, the fan needs to be set to full power). Therefore, begin by moving the current pwm_enable read to its own function, oxp_pwm_enable. Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-9-lkml@antheas.dev Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Add turbo led support to X1 devicesAntheas Kapenekakis
The X1 and X1 mini lineups feature an LED nested within their turbo button. When turbo takeover is not enabled, the turbo button allows the device to switch from 18W to 25W TDP. When the device is in the 25W TDP mode, the LED is turned on. However, when we engage turbo takeover, the turbo led remains on its last state, which might be illuminated and cannot be currently controlled. Therefore, add the register that controls it under sysfs, to allow userspace to turn it off once engaging turbo takeover and then control it as they wish. 2024 OneXPlayer devices, other than the X1s, do not have a turbo LED. However, earlier models do, so this can be extended to them as well when the register for it is found. Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-8-lkml@antheas.dev Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Rename ec group to tt_toggleAntheas Kapenekakis
Currently, the EC group is used for the turbo button. However, the next patch in the series adds support for the LED button in X1 devices, which is only applicable for X1 devices. Therefore, rename it to prepare for adding the second group. And make it const while at it. Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-7-lkml@antheas.dev Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
2025-04-30platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86Antheas Kapenekakis
The EC of OneXPlayer devices used to only control the fan. This is no longer the case, with the EC of OneXPlayer gaining additional functionality (turbo button, turbo led, battery controls). As it will be beneficial from a complexity perspective to retain this driver as a single unit, move it out of hwmon, and into platform/x86. Also, remove the hwmon documentation to prepare moving it to Documentation/ABI/. While at it, add myself to the maintainer's file. Acked-by: Guenter Roeck <linux@roeck-us.net> Reviewed-by: Thomas Weißschuh <linux@weissschuh.net> Reviewed-by: Derek J. Clark <derekjohn.clark@gmail.com> Signed-off-by: Antheas Kapenekakis <lkml@antheas.dev> Link: https://lore.kernel.org/r/20250425111821.88746-4-lkml@antheas.dev Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>