hwmon: (oxpsensors) Add devices, features, fix ABI and move to platform/x86
Subsystems (5)
Antheas Kapenekakis
maintainerv2 cover hwmon: (oxpsensors) Add devices, features, fix ABI and move to platform/x86
This four part series updates the oxpsensors module to bring it in line with its Windows OneXPlayer counterpart. First, it adds support for all 2024, 2025 OneXPlayer handhelds and their special variants.
Then, it adds the new charge limiting and bypass features that were first introduced in the X1 and retrofit to older OneXFly variants and for controlling the turbo led found in the X1 models. For Bypass, it adds a new bypass variant BypassS0 that is only active while the device is in the S0 state.
Then, it performs a minor refactor by moving around switch statements into their own functions, in order to allow for fixing the pwm1_enable ABI in the final patch. Currently, pwm1_enable sets the fan to auto with the value 0 and allows manual control with the value 1. This patch makes it so 0 sets the fan to full speed, 1 sets the fan to manual control, and 2 sets the fan to auto. This requires both setting enable and the fan speed when the enable sysfs is written to as 0, hence the refactor.
As this is a breaking ABI change and there is userspace software relying on this previous behavior, the last patch also changes the /name of the hwmon endpoint to "oxp_ec" from "oxpec" (mirroring WMI module conventions) such that userspace software that relied on the previous behavior can be retrofit to the new kernel while enabling correct functionality on old and new kernels. Failing that, software that is not updated will just stop controlling the fans, ensuring no malignant behavior.
Finally, the oxp-sensors module is converted into the oxpec platform driver in order for it to stay as a single unit. Then, the appropriate documentation for it is added.
Changes since V1:
- Add X1 Pro, F1 Pro variants
- Fix minor typo in initial patches
- Convert oxp-sensors into a platform driver, as it is no longer considered a hwmon driver.
- Add sysfs documentation and myself to the MAINTAINERS file
- Update documentation to state that this is the OneXPlayer/AOKZOE platform driver, and that support for Ayaneo/OPI is provided until they gain their own platform driver.
Antheas Kapenekakis (12):
hwmon: (oxp-sensors) Distinguish the X1 variants
hwmon: (oxp-sensors) Add all OneXFly variants
ABI: testing: sysfs-class-power: add BypassS0 charge_type
hwmon: (oxp-sensors) Add charge threshold and bypass to OneXPlayer
hwmon: (oxp-sensors) Rename ec group to tt_toggle
hwmon: (oxp-sensors) Add turbo led support to X1 devices
hwmon: (oxp-sensors) Move pwm_enable read to its own function
hwmon: (oxp-sensors) Move pwm value read/write to separate functions
hwmon: (oxp-sensors) Move fan speed read to separate function
hwmon: (oxp-sensors) Adhere to sysfs-class-hwmon and enable pwm on 2 platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86
ABI: testing: add tt_toggle and tt_led entries
Documentation/ABI/testing/sysfs-class-power | 6 +-
Documentation/ABI/testing/sysfs-platform-oxp | 29 +
Documentation/hwmon/index.rst | 2 +-
Documentation/hwmon/oxp-sensors.rst | 89 ---
Documentation/hwmon/oxpec.rst | 67 ++
MAINTAINERS | 7 +-
drivers/hwmon/Kconfig | 11 -
drivers/hwmon/Makefile | 1 -
drivers/platform/x86/Kconfig | 11 +
drivers/platform/x86/Makefile | 3 +
.../oxp-sensors.c => platform/x86/oxpec.c} | 664 ++++++++++++++----
11 files changed, 649 insertions(+), 241 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-platform-oxp
delete mode 100644 Documentation/hwmon/oxp-sensors.rst
create mode 100644 Documentation/hwmon/oxpec.rst
rename drivers/{hwmon/oxp-sensors.c => platform/x86/oxpec.c} (52%)Signature · 1 line
2.48.1
Antheas Kapenekakis
maintainerPATCH v2 1/12 hwmon: (oxp-sensors) Distinguish the X1 variants
Currently, the oxp-sensors driver fuzzy matches the X1 variants. Luckily, X1 and X1 mini share most hardware features so this works. However, they are completely different product lines, and there is an expectation that OneXPlayer will release more devices in the X1 line that may have differences.
Therefore, distinguish the 3 devices that currently exist in the market. These are the OneXPlayer X1 AMD and Intel variants, and the X1 mini which only has an AMD variant. As far as registers go, all three support the current driver functionality.
--- drivers/hwmon/oxp-sensors.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
drivers/hwmon/oxp-sensors.c +22 -1
@@ -205,7 +205,28 @@ static const struct dmi_system_id dmi_table[] = { { .matches = { DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), - DMI_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 A"), + }, + .driver_data = (void *)oxp_x1, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 i"), + }, + .driver_data = (void *)oxp_x1, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1 mini"), + }, + .driver_data = (void *)oxp_x1, + }, + { + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER X1Pro"), }, .driver_data = (void *)oxp_x1, },
Signature · 1 line
2.48.1
Antheas Kapenekakis
maintainerPATCH v2 2/12 hwmon: (oxp-sensors) Add all OneXFly variants
In reply to Antheas KapenekakisCurrently, the driver only has the F1 OneXFly variant, which was based on the 7000 AMD platform. Add its special editions: F1 EVA-01, F1 OLED. F1 OLED might have been a dev unit, but it is supported by OneXConsole with the same features so add it. Then add the F1L variant which is based on the 8000 AMD platform and the F1Pro and its special edition EVA-02.
One might ask why not just fuzzy match. Well, EVA-02 is a variant of F1Pro which is a Strix Point handheld, but does not have F1Pro in its name. This makes it risky to fuzzy match, as special variants in the future from different platforms might not have the same feature set or registers.
By happenstance, all current devices use the same registers. For the charge limitting feature on this series, only F1Pro/X1 (AMD) were released with it, but OneXPlayer is providing bios updates for F1, F1L, X1 Mini units that use the same register, so treat all of them the same.
--- drivers/hwmon/oxp-sensors.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
drivers/hwmon/oxp-sensors.c +35 -0
@@ -188,6 +188,41 @@ static const struct dmi_system_id dmi_table[] = { }, .driver_data = (void *)oxp_fly, }, + { + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"ONE-NETBOOK" ), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 EVA-01"), + }, + .driver_data = (void *)oxp_fly, + }, + { + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"ONE-NETBOOK" ), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 OLED"), + }, + .driver_data = (void *)oxp_fly, + }, + { + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"ONE-NETBOOK" ), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1L"), + }, + .driver_data = (void *)oxp_fly, + }, + { + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"ONE-NETBOOK" ), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1Pro"), + }, + .driver_data = (void *)oxp_fly, + }, + { + .matches = { +DMI_MATCH (DMI_BOARD_VENDOR ,"ONE-NETBOOK" ), + DMI_EXACT_MATCH(DMI_BOARD_NAME, "ONEXPLAYER F1 EVA-02"), + }, + .driver_data = (void *)oxp_fly, + }, { .matches = { DMI_MATCH(DMI_BOARD_VENDOR, "ONE-NETBOOK"),
Signature · 1 line
2.48.1
Antheas Kapenekakis
maintainerPATCH v2 3/12 ABI: testing: sysfs-class-power: add BypassS0 charge_type
In reply to Antheas KapenekakisOneXPlayer devices support a conditional bypass type, in which the device will only perform the battery bypass while in the S0 state. Therefore, add BypassS0, which is a state in which the device conditionally bypasses the battery only in the S0 state.
--- Documentation/ABI/testing/sysfs-class-power | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/ABI/testing/sysfs-class-power +5 -1
@@ -404,6 +404,10 @@ Description: The charger bypasses the charging path around the integrated converter allowing for a "smart" wall adaptor to perform the power conversion externally. + BypassS0: + Same as Bypass, but the device automatically enables + bypass only while on the S0 state and disables it when + it powers off or during sleep. Access: Read, Write
@@ -412,7 +416,7 @@ Description: Valid values: "Unknown", "N/A", "Trickle", "Fast", "Standard", - "Adaptive", "Custom", "Long Life", "Bypass" + "Adaptive", "Custom", "Long Life", "Bypass", "BypassS0" What: /sys/class/power_supply/<supply_name>/charge_types Date: December 2024
Signature · 1 line
2.48.1
Antheas Kapenekakis
maintainerPATCH v2 4/12 hwmon: (oxp-sensors) Add charge threshold and bypass to OneXPlayer
In reply to Antheas KapenekakisWith the X1 (AMD), OneXPlayer added a charge limit and charge bypass to their devices. Charge limit allows for choosing an arbitrary battery charge setpoint in percentages. Charge bypass allows to instruct the device to stop charging either when its on 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.
Add both of these under the standard sysfs battery endpoints for them, by looking for the battery. OneXPlayer devices have a single battery.
--- drivers/hwmon/oxp-sensors.c | 206 ++++++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+)
drivers/hwmon/oxp-sensors.c +206 -0
@@ -26,6 +26,7 @@#include <linux/module.h> #include <linux/platform_device.h> #include <linux/processor.h> +#include <acpi/battery.h> /* Handle ACPI lock mechanism */ static u32 oxp_mutex;
@@ -89,6 +90,35 @@ static enum oxp_board board;#define OXP_TURBO_RETURN_VAL 0x00/* Common return val */ +#define OXP_X1_CHARGE_LIMIT_REG 0xA3/* X1 charge limit (%) */ +#define OXP_X1_CHARGE_BYPASS_REG 0xA4/* X1 bypass charging */ + +#define OXP_X1_CHARGE_BYPASS_MASK_S0 0x01 +/* +* Cannot control S3, S5 individually. +* X1 Mask is 0x0A, OneXFly F1Pro is just 0x02 +* but the extra bit on the X1 does nothing. +*/ +#define OXP_X1_CHARGE_BYPASS_MASK_S3S5 0x02 + +enum charge_type_value_index { +CT_OFF , +CT_S0 , +CT_S5 , +}; + +static u8 charge_type_values_x1[] = { + [CT_OFF ] =0x00 , + [CT_S0 ] =OXP_X1_CHARGE_BYPASS_MASK_S0 , + [CT_S5 ] =OXP_X1_CHARGE_BYPASS_MASK_S0 |OXP_X1_CHARGE_BYPASS_MASK_S3S5 , +}; + +static const char *const charge_type_strings[] = { + [CT_OFF ] ="Standard" , + [CT_S0 ] ="BypassS0" , + [CT_S5 ] ="Bypass" , +}; +static const struct dmi_system_id dmi_table[] = { { .matches = {
@@ -436,6 +466,177 @@ static ssize_t tt_toggle_show(struct device *dev,static DEVICE_ATTR_RW (tt_toggle); +/* Callbacks for turbo toggle attribute */ +static bool charge_control_supported (void ) +{ +switch (board) { +case oxp_x1: +case oxp_fly: +return 1 ; +default : +break ; + } +return 0 ; +} + +static ssize_t charge_type_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) +{ +u64 val, reg; +int ret; + + ret =__sysfs_match_string (charge_type_strings, +ARRAY_SIZE (charge_type_strings), buf); +if (ret <0 ) +return ret; + +switch (board) { +case oxp_x1: +case oxp_fly: + val = charge_type_values_x1[ret]; + reg =OXP_X1_CHARGE_BYPASS_REG ; +break ; +default : +return -EINVAL ; + } + + ret =write_to_ec (reg, val); +if (ret <0 ) +return ret; + +return count; +} + +static ssize_t charge_type_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +int ret; +u8 reg; +long val; +const u8 *vals; +char *str; + +switch (board) { +case oxp_x1: +case oxp_fly: + vals = charge_type_values_x1; + reg =OXP_X1_CHARGE_BYPASS_REG ; +break ; +default : +return -EINVAL ; + } + + ret =read_from_ec (reg,1 , &val); +if (ret <0 ) +return ret; + + str = (char *) charge_type_strings[0 ]; +for (ret =0 ; ret <ARRAY_SIZE (charge_type_strings); ret++) { +if (val == vals[ret]) { + str = (char *) charge_type_strings[ret]; +break ; + } + } + +return sysfs_emit (buf,"%s\n" , str); +} + +static DEVICE_ATTR_RW (charge_type); + +static ssize_t charge_control_end_threshold_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) +{ +u64 val, reg; +int ret; + + ret =kstrtou64 (buf,10 , &val); +if (ret <0 ) +return ret; + +if (val >100 ) +return -EINVAL ; + +switch (board) { +case oxp_x1: +case oxp_fly: + reg =OXP_X1_CHARGE_LIMIT_REG ; +break ; +default : +return -EINVAL ; + } + + ret =write_to_ec (reg, val); +if (ret <0 ) +return ret; + +return count; +} + +static ssize_t charge_control_end_threshold_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +int ret; +u8 reg; +long val; + +switch (board) { +case oxp_x1: +case oxp_fly: + reg =OXP_X1_CHARGE_LIMIT_REG ; +break ; +default : +return -EINVAL ; + } + + ret =read_from_ec (reg,1 , &val); +if (ret <0 ) +return ret; + +return sysfs_emit (buf,"%ld\n" , val); +} + +static DEVICE_ATTR_RW (charge_control_end_threshold); + +static int oxp_battery_add (struct power_supply *battery,struct acpi_battery_hook *hook) +{ +/* OneXPlayer devices only have one battery. */ +if (strcmp (battery->desc->name,"BAT0" ) !=0 && +strcmp (battery->desc->name,"BAT1" ) !=0 && +strcmp (battery->desc->name,"BATC" ) !=0 && +strcmp (battery->desc->name,"BATT" ) !=0 ) +return -ENODEV ; + +if (device_create_file (&battery->dev, + &dev_attr_charge_control_end_threshold)) +return -ENODEV ; + +if (device_create_file (&battery->dev, + &dev_attr_charge_type)) { +device_remove_file (&battery->dev, + &dev_attr_charge_control_end_threshold); +return -ENODEV ; + } + +return 0 ; +} + +static int oxp_battery_remove (struct power_supply *battery,struct acpi_battery_hook *hook) +{ +device_remove_file (&battery->dev, + &dev_attr_charge_control_end_threshold); +device_remove_file (&battery->dev, + &dev_attr_charge_type); +return 0 ; +} + +static struct acpi_battery_hook battery_hook = { + .add_battery = oxp_battery_add, + .remove_battery = oxp_battery_remove, + .name ="OneXPlayer Battery" , +}; +/* PWM enable/disable functions */ static int oxp_pwm_enable (void ) {
@@ -753,6 +954,9 @@ static int __init oxp_platform_init(void)platform_create_bundle (&oxp_platform_driver, oxp_platform_probe,NULL ,0 ,NULL ,0 ); +if (charge_control_supported ()) +battery_hook_register (&battery_hook); +return PTR_ERR_OR_ZERO (oxp_platform_device); }
@@ -760,6 +964,8 @@ static void __exit oxp_platform_exit(void) {platform_device_unregister (oxp_platform_device);platform_driver_unregister (&oxp_platform_driver); +if (charge_control_supported ()) +battery_hook_unregister (&battery_hook); }MODULE_DEVICE_TABLE (dmi, dmi_table);
Signature · 1 line
2.48.1
Antheas Kapenekakis
maintainerPATCH v2 5/12 hwmon: (oxp-sensors) Rename ec group to tt_toggle
In reply to Antheas KapenekakisCurrently, 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.
--- drivers/hwmon/oxp-sensors.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/oxp-sensors.c +4 -4
@@ -884,18 +884,18 @@ static const struct hwmon_channel_info * const oxp_platform_sensors[] = { NULL, }; -static struct attribute *oxp_ec_attrs[] = { +static struct attribute *oxp_tt_toggle_attrs[] = { &dev_attr_tt_toggle.attr,NULL }; -static struct attribute_group oxp_ec_attribute_group = { +static struct attribute_group oxp_tt_toggle_attribute_group = { .is_visible = tt_toggle_is_visible, - .attrs = oxp_ec_attrs, + .attrs = oxp_tt_toggle_attrs, };static const struct attribute_group *oxp_ec_groups[] = { - &oxp_ec_attribute_group, + &oxp_tt_toggle_attribute_group,NULL };
Signature · 1 line
2.48.1
Antheas Kapenekakis
maintainerPATCH v2 6/12 hwmon: (oxp-sensors) Add turbo led support to X1 devices
In reply to Antheas KapenekakisThe 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.
As part of researching this topic, I verified that other OneXPlayer devices do not have a turbo led, which makes this feature only applicable to X1 and X1 mini devices.
--- drivers/hwmon/oxp-sensors.c | 84 +++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+)
drivers/hwmon/oxp-sensors.c +84 -0
@@ -101,6 +101,12 @@ static enum oxp_board board;*/ #define OXP_X1_CHARGE_BYPASS_MASK_S3S5 0x02 +/* X1 Turbo LED */ +#define OXP_X1_TURBO_LED_REG 0x57 + +#define OXP_X1_TURBO_LED_OFF 0x01 +#define OXP_X1_TURBO_LED_ON 0x02 +enum charge_type_value_index {CT_OFF ,CT_S0 ,
@@ -466,6 +472,73 @@ static ssize_t tt_toggle_show(struct device *dev,static DEVICE_ATTR_RW (tt_toggle); +/* Callbacks for turbo toggle attribute */ +static umode_t tt_led_is_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ +switch (board) { +case oxp_x1: +return attr->mode; +default : +break ; + } +return 0 ; +} + +static ssize_t tt_led_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) +{ +u8 reg, val; +int rval; +bool value; + + rval =kstrtobool (buf, &value); +if (rval) +return rval; + +switch (board) { +case oxp_x1: + reg =OXP_X1_TURBO_LED_REG ; + val = value ?OXP_X1_TURBO_LED_ON :OXP_X1_TURBO_LED_OFF ; +break ; +default : +return -EINVAL ; + } + rval =write_to_ec (reg, val); + +if (rval) +return rval; + +return count; +} + +static ssize_t tt_led_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +int retval; +u8 reg; +long enval; +long val; + +switch (board) { +case oxp_x1: + reg =OXP_2_TURBO_SWITCH_REG ; + enval =OXP_X1_TURBO_LED_ON ; +break ; +default : +return -EINVAL ; + } + + retval =read_from_ec (reg,1 , &val); +if (retval) +return retval; + +return sysfs_emit (buf,"%d\n" , val == enval); +} + +static DEVICE_ATTR_RW (tt_led); +/* Callbacks for turbo toggle attribute */ static bool charge_control_supported (void ) {
@@ -894,8 +967,19 @@ static struct attribute_group oxp_tt_toggle_attribute_group = { .attrs = oxp_tt_toggle_attrs, }; +static struct attribute *oxp_tt_led_attrs[] = { + &dev_attr_tt_led.attr, +NULL +}; + +static struct attribute_group oxp_tt_led_attribute_group = { + .is_visible = tt_led_is_visible, + .attrs = oxp_tt_led_attrs, +}; +static const struct attribute_group *oxp_ec_groups[] = { &oxp_tt_toggle_attribute_group, + &oxp_tt_led_attribute_group,NULL };
Signature · 1 line
2.48.1
Derek J. Clark
maintainerRe: [PATCH v2 06/12] hwmon: (oxp-sensors) Add turbo led support to X1 devices
Quoted 11 lines · Antheas 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.
Quoted 3 lines
As part of researching this topic, I verified that other OneXPlayer devices do not have a turbo led, which makes this feature only applicable to X1 and X1 mini devices.
Antheas,
Do you mean a turbo LED That can be set via EC? OXP devices have had an LED to indicate turbo all the way back to the 1S and mini AMD. I'm not sure if they can be set prior to X1, but this is incorrect as posted.
Quoted 10 lines
Signed-off-by Antheas Kapenekakis <[email protected]>---
drivers/hwmon/oxp-sensors.c| 84 +++++++++++++++++++++++++++++++++++++1 file changed, 84 insertions(+)drivers/hwmon/oxp-sensors.c +0
-0
drivers/hwmon/oxp-sensors.c static enum oxp_board board; · line 109
Quoted 9 lines
drivers/hwmon/oxp-sensors.c +6
-0@@ -101,6 +101,12 @@ static enum oxp_board board;*/ #define OXP_X1_CHARGE_BYPASS_MASK_S3S5 0x02 +/* X1 Turbo LED */ +#define OXP_X1_TURBO_LED_REG 0x57 + +#define OXP_X1_TURBO_LED_OFF 0x01 +#define OXP_X1_TURBO_LED_ON 0x02 +
Not a blocker for me on this series, but we should consider looking at creating some enums in the future to capture functionality in a more concise way. There are quite a few define's at this point and enums offer a little bit of value validation.
Quoted 87 lines
drivers/hwmon/oxp-sensors.c +73
-0enum charge_type_value_index {CT_OFF ,CT_S0 ,@@ -466,6 +472,73 @@ static ssize_t tt_toggle_show(struct device *dev,static DEVICE_ATTR_RW (tt_toggle); +/* Callbacks for turbo toggle attribute */ +static umode_t tt_led_is_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ +switch (board) { +case oxp_x1: +return attr->mode; +default : +break ; + } +return 0 ; +} + +static ssize_t tt_led_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) +{ +u8 reg, val; +int rval; +bool value; + + rval =kstrtobool (buf, &value); +if (rval) +return rval; + +switch (board) { +case oxp_x1: + reg =OXP_X1_TURBO_LED_REG ; + val = value ?OXP_X1_TURBO_LED_ON :OXP_X1_TURBO_LED_OFF ; +break ; +default : +return -EINVAL ; + } + rval =write_to_ec (reg, val); + +if (rval) +return rval; + +return count; +} + +static ssize_t tt_led_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +int retval; +u8 reg; +long enval; +long val; + +switch (board) { +case oxp_x1: + reg =OXP_2_TURBO_SWITCH_REG ; + enval =OXP_X1_TURBO_LED_ON ; +break ; +default : +return -EINVAL ; + } + + retval =read_from_ec (reg,1 , &val); +if (retval) +return retval; + +return sysfs_emit (buf,"%d\n" , val == enval); +} + +static DEVICE_ATTR_RW (tt_led); +/* Callbacks for turbo toggle attribute */ static bool charge_control_supported (void ) {@@ -894,8 +967,19 @@ static struct attribute_group oxp_tt_toggle_attribute_group = { .attrs = oxp_tt_toggle_attrs, }; +static struct attribute *oxp_tt_led_attrs[] = { + &dev_attr_tt_led.attr, +NULL +}; + +static struct attribute_group oxp_tt_led_attribute_group = {
drivers/hwmon/oxp-sensors.c static struct attribute_group oxp_tt_toggle_attribute_group = { · line 985
Quoted 10 lines
drivers/hwmon/oxp-sensors.c +5
-0+ .is_visible = tt_led_is_visible, + .attrs = oxp_tt_led_attrs, +}; +static const struct attribute_group *oxp_ec_groups[] = { &oxp_tt_toggle_attribute_group, + &oxp_tt_led_attribute_group,NULL };
- Derek
Antheas Kapenekakis
maintainerRe: [PATCH v2 06/12] hwmon: (oxp-sensors) Add turbo led support to X1 devices
Quoted 15 lines · Derek J. Clark
Quoted 11 lines · Antheas 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.
Quoted 7 lines
Quoted 3 lines
As part of researching this topic, I verified that other OneXPlayer devices do not have a turbo led, which makes this feature only applicable to X1 and X1 mini devices.
Antheas,
Do you mean a turbo LED That can be set via EC? OXP devices have had an LED to indicate turbo all the way back to the 1S and mini AMD. I'm not sure if they can be set prior to X1, but this is incorrect as posted.
Do not confuse the keyboard LED button with the turbo button. The X1 has two LEDs. Only the turbo one can be controlled.
Quoted 13 lines
Quoted 13 lines
Signed-off-by Antheas Kapenekakis <[email protected]>---
drivers/hwmon/oxp-sensors.c| 84 +++++++++++++++++++++++++++++++++++++1 file changed, 84 insertions(+)drivers/hwmon/oxp-sensors.c +0
-0@@ -101,6 +101,12 @@ static enum oxp_board board;*/ #define OXP_X1_CHARGE_BYPASS_MASK_S3S5 0x02
Quoted 8 lines
drivers/hwmon/oxp-sensors.c static enum oxp_board board; · line 109
Quoted 6 lines
drivers/hwmon/oxp-sensors.c +6
-0+/* X1 Turbo LED */ +#define OXP_X1_TURBO_LED_REG 0x57 + +#define OXP_X1_TURBO_LED_OFF 0x01 +#define OXP_X1_TURBO_LED_ON 0x02 +Not a blocker for me on this series, but we should consider looking at creating some enums in the future to capture functionality in a more concise way. There are quite a few define's at this point and enums offer a little bit of value validation.
There should probably be a refactor in the future. Yes. I would tend towards using a driver struct...
Quoted 98 lines
Quoted 87 lines
drivers/hwmon/oxp-sensors.c +73
-0enum charge_type_value_index {CT_OFF ,CT_S0 ,@@ -466,6 +472,73 @@ static ssize_t tt_toggle_show(struct device *dev,static DEVICE_ATTR_RW (tt_toggle); +/* Callbacks for turbo toggle attribute */ +static umode_t tt_led_is_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ +switch (board) { +case oxp_x1: +return attr->mode; +default : +break ; + } +return 0 ; +} + +static ssize_t tt_led_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) +{ +u8 reg, val; +int rval; +bool value; + + rval =kstrtobool (buf, &value); +if (rval) +return rval; + +switch (board) { +case oxp_x1: + reg =OXP_X1_TURBO_LED_REG ; + val = value ?OXP_X1_TURBO_LED_ON :OXP_X1_TURBO_LED_OFF ; +break ; +default : +return -EINVAL ; + } + rval =write_to_ec (reg, val); + +if (rval) +return rval; + +return count; +} + +static ssize_t tt_led_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +int retval; +u8 reg; +long enval; +long val; + +switch (board) { +case oxp_x1: + reg =OXP_2_TURBO_SWITCH_REG ; + enval =OXP_X1_TURBO_LED_ON ; +break ; +default : +return -EINVAL ; + } + + retval =read_from_ec (reg,1 , &val); +if (retval) +return retval; + +return sysfs_emit (buf,"%d\n" , val == enval); +} + +static DEVICE_ATTR_RW (tt_led); +/* Callbacks for turbo toggle attribute */ static bool charge_control_supported (void ) {@@ -894,8 +967,19 @@ static struct attribute_group oxp_tt_toggle_attribute_group = { .attrs = oxp_tt_toggle_attrs, }; +static struct attribute *oxp_tt_led_attrs[] = { + &dev_attr_tt_led.attr, +NULL +}; + +static struct attribute_group oxp_tt_led_attribute_group = {drivers/hwmon/oxp-sensors.c static struct attribute_group oxp_tt_toggle_attribute_group = { · line 985
Quoted 10 lines
drivers/hwmon/oxp-sensors.c +5
-0+ .is_visible = tt_led_is_visible, + .attrs = oxp_tt_led_attrs, +}; +static const struct attribute_group *oxp_ec_groups[] = { &oxp_tt_toggle_attribute_group, + &oxp_tt_led_attribute_group,NULL };- Derek
Derek J. Clark
maintainerRe: [PATCH v2 06/12] hwmon: (oxp-sensors) Add turbo led support to X1 devices
Quoted 20 lines · Antheas Kapenekakis
Quoted 19 lines · Derek J. Clark
Quoted 14 lines · Antheas 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.
As part of researching this topic, I verified that other OneXPlayer devices do not have a turbo led, which makes this feature only applicable to X1 and X1 mini devices.
Quoted 7 lines
Quoted 3 lines
Antheas,
Do you mean a turbo LED That can be set via EC? OXP devices have had an LED to indicate turbo all the way back to the 1S and mini AMD. I'm not sure if they can be set prior to X1, but this is incorrect as posted.
Do not confuse the keyboard LED button with the turbo button. The X1 has two LEDs. Only the turbo one can be controlled.
This would be pretty difficult to do. On the 1S it has the text TURBO. This video shows it at 09:40
https://youtu.be/AYrVKLD2J_k?si=bnwwQKY7MdqbbnCY
It would be better to just point out that it became configurable on the X1.
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Signed-off-by Antheas Kapenekakis <[email protected]>---
drivers/hwmon/oxp-sensors.c| 84 +++++++++++++++++++++++++++++++++++++1 file changed, 84 insertions(+)drivers/hwmon/oxp-sensors.c +0
-0@@ -101,6 +101,12 @@ static enum oxp_board board;*/ #define OXP_X1_CHARGE_BYPASS_MASK_S3S5 0x02Quoted 8 lines
drivers/hwmon/oxp-sensors.c static enum oxp_board board; · line 109
Quoted 6 lines
drivers/hwmon/oxp-sensors.c +6
-0+/* X1 Turbo LED */ +#define OXP_X1_TURBO_LED_REG 0x57 + +#define OXP_X1_TURBO_LED_OFF 0x01 +#define OXP_X1_TURBO_LED_ON 0x02 +Not a blocker for me on this series, but we should consider looking at creating some enums in the future to capture functionality in a more concise way. There are quite a few define's at this point and enums offer a little bit of value validation.
Quoted 101 lines
There should probably be a refactor in the future. Yes. I would tend towards using a driver struct...
Quoted 98 lines
Quoted 87 lines
drivers/hwmon/oxp-sensors.c +73
-0enum charge_type_value_index {CT_OFF ,CT_S0 ,@@ -466,6 +472,73 @@ static ssize_t tt_toggle_show(struct device *dev,static DEVICE_ATTR_RW (tt_toggle); +/* Callbacks for turbo toggle attribute */ +static umode_t tt_led_is_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ +switch (board) { +case oxp_x1: +return attr->mode; +default : +break ; + } +return 0 ; +} + +static ssize_t tt_led_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) +{ +u8 reg, val; +int rval; +bool value; + + rval =kstrtobool (buf, &value); +if (rval) +return rval; + +switch (board) { +case oxp_x1: + reg =OXP_X1_TURBO_LED_REG ; + val = value ?OXP_X1_TURBO_LED_ON :OXP_X1_TURBO_LED_OFF ; +break ; +default : +return -EINVAL ; + } + rval =write_to_ec (reg, val); + +if (rval) +return rval; + +return count; +} + +static ssize_t tt_led_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +int retval; +u8 reg; +long enval; +long val; + +switch (board) { +case oxp_x1: + reg =OXP_2_TURBO_SWITCH_REG ; + enval =OXP_X1_TURBO_LED_ON ; +break ; +default : +return -EINVAL ; + } + + retval =read_from_ec (reg,1 , &val); +if (retval) +return retval; + +return sysfs_emit (buf,"%d\n" , val == enval); +} + +static DEVICE_ATTR_RW (tt_led); +/* Callbacks for turbo toggle attribute */ static bool charge_control_supported (void ) {@@ -894,8 +967,19 @@ static struct attribute_group oxp_tt_toggle_attribute_group = { .attrs = oxp_tt_toggle_attrs, }; +static struct attribute *oxp_tt_led_attrs[] = { + &dev_attr_tt_led.attr, +NULL +}; + +static struct attribute_group oxp_tt_led_attribute_group = {drivers/hwmon/oxp-sensors.c static struct attribute_group oxp_tt_toggle_attribute_group = { · line 985
Quoted 10 lines
drivers/hwmon/oxp-sensors.c +5
-0+ .is_visible = tt_led_is_visible, + .attrs = oxp_tt_led_attrs, +}; +static const struct attribute_group *oxp_ec_groups[] = { &oxp_tt_toggle_attribute_group, + &oxp_tt_led_attribute_group,NULL };- Derek
- Derek
Antheas Kapenekakis
maintainerRe: [PATCH v2 06/12] hwmon: (oxp-sensors) Add turbo led support to X1 devices
Quoted 32 lines · Derek J. Clark
Quoted 20 lines · Antheas Kapenekakis
Quoted 19 lines · Derek J. Clark
Quoted 14 lines · Antheas 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.
As part of researching this topic, I verified that other OneXPlayer devices do not have a turbo led, which makes this feature only applicable to X1 and X1 mini devices.
Quoted 7 lines
Quoted 3 lines
Antheas,
Do you mean a turbo LED That can be set via EC? OXP devices have had an LED to indicate turbo all the way back to the 1S and mini AMD. I'm not sure if they can be set prior to X1, but this is incorrect as posted.
Do not confuse the keyboard LED button with the turbo button. The X1 has two LEDs. Only the turbo one can be controlled.
Quoted 5 lines
This would be pretty difficult to do. On the 1S it has the text TURBO. This video shows it at 09:40
https://youtu.be/AYrVKLD2J_k?si=bnwwQKY7MdqbbnCY
It would be better to just point out that it became configurable on the X1.
I asked around and I think the OXP 2, MiniPro, and OneXFly models do not have it. I can edit the comment and say I added it for the X1.
If you have an 1S, can you use rweverything and find the register for it?
Quoted 125 lines
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Signed-off-by Antheas Kapenekakis <[email protected]>---
drivers/hwmon/oxp-sensors.c| 84 +++++++++++++++++++++++++++++++++++++1 file changed, 84 insertions(+)drivers/hwmon/oxp-sensors.c +0
-0@@ -101,6 +101,12 @@ static enum oxp_board board;*/ #define OXP_X1_CHARGE_BYPASS_MASK_S3S5 0x02Quoted 8 lines
drivers/hwmon/oxp-sensors.c static enum oxp_board board; · line 109
Quoted 6 lines
drivers/hwmon/oxp-sensors.c +6
-0+/* X1 Turbo LED */ +#define OXP_X1_TURBO_LED_REG 0x57 + +#define OXP_X1_TURBO_LED_OFF 0x01 +#define OXP_X1_TURBO_LED_ON 0x02 +Not a blocker for me on this series, but we should consider looking at creating some enums in the future to capture functionality in a more concise way. There are quite a few define's at this point and enums offer a little bit of value validation.
Quoted 101 lines
There should probably be a refactor in the future. Yes. I would tend towards using a driver struct...
Quoted 98 lines
Quoted 87 lines
drivers/hwmon/oxp-sensors.c +73
-0enum charge_type_value_index {CT_OFF ,CT_S0 ,@@ -466,6 +472,73 @@ static ssize_t tt_toggle_show(struct device *dev,static DEVICE_ATTR_RW (tt_toggle); +/* Callbacks for turbo toggle attribute */ +static umode_t tt_led_is_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ +switch (board) { +case oxp_x1: +return attr->mode; +default : +break ; + } +return 0 ; +} + +static ssize_t tt_led_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) +{ +u8 reg, val; +int rval; +bool value; + + rval =kstrtobool (buf, &value); +if (rval) +return rval; + +switch (board) { +case oxp_x1: + reg =OXP_X1_TURBO_LED_REG ; + val = value ?OXP_X1_TURBO_LED_ON :OXP_X1_TURBO_LED_OFF ; +break ; +default : +return -EINVAL ; + } + rval =write_to_ec (reg, val); + +if (rval) +return rval; + +return count; +} + +static ssize_t tt_led_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +int retval; +u8 reg; +long enval; +long val; + +switch (board) { +case oxp_x1: + reg =OXP_2_TURBO_SWITCH_REG ; + enval =OXP_X1_TURBO_LED_ON ; +break ; +default : +return -EINVAL ; + } + + retval =read_from_ec (reg,1 , &val); +if (retval) +return retval; + +return sysfs_emit (buf,"%d\n" , val == enval); +} + +static DEVICE_ATTR_RW (tt_led); +/* Callbacks for turbo toggle attribute */ static bool charge_control_supported (void ) {@@ -894,8 +967,19 @@ static struct attribute_group oxp_tt_toggle_attribute_group = { .attrs = oxp_tt_toggle_attrs, }; +static struct attribute *oxp_tt_led_attrs[] = { + &dev_attr_tt_led.attr, +NULL +}; + +static struct attribute_group oxp_tt_led_attribute_group = {drivers/hwmon/oxp-sensors.c static struct attribute_group oxp_tt_toggle_attribute_group = { · line 985
Quoted 10 lines
drivers/hwmon/oxp-sensors.c +5
-0+ .is_visible = tt_led_is_visible, + .attrs = oxp_tt_led_attrs, +}; +static const struct attribute_group *oxp_ec_groups[] = { &oxp_tt_toggle_attribute_group, + &oxp_tt_led_attribute_group,NULL };- Derek
- Derek
Derek J. Clark
maintainerRe: [PATCH v2 06/12] hwmon: (oxp-sensors) Add turbo led support to X1 devices
Quoted 35 lines · Antheas Kapenekakis
Quoted 34 lines · Derek J. Clark
Quoted 20 lines · Antheas Kapenekakis
Quoted 19 lines · Derek J. Clark
Quoted 14 lines · Antheas 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.
As part of researching this topic, I verified that other OneXPlayer devices do not have a turbo led, which makes this feature only applicable to X1 and X1 mini devices.
Quoted 7 lines
Quoted 3 lines
Antheas,
Do you mean a turbo LED That can be set via EC? OXP devices have had an LED to indicate turbo all the way back to the 1S and mini AMD. I'm not sure if they can be set prior to X1, but this is incorrect as posted.
Do not confuse the keyboard LED button with the turbo button. The X1 has two LEDs. Only the turbo one can be controlled.
This would be pretty difficult to do. On the 1S it has the text TURBO. This video shows it at 09:40
Quoted 8 lines
Quoted 3 lines
https://youtu.be/AYrVKLD2J_k?si=bnwwQKY7MdqbbnCY
It would be better to just point out that it became configurable on the X1.
I asked around and I think the OXP 2, MiniPro, and OneXFly models do not have it. I can edit the comment and say I added it for the X1.
If you have an 1S, can you use rweverything and find the register for it?
Not necessary, 1S EC predates the one they started using in the Mini AMD and has no configurable options. The original mini AMD is also unlikely to support this as only my unit with an experimental BIOS nobody else installed can even do the takeover. X1+ should be fine.
- Derek
Quoted 125 lines
Quoted 125 lines
Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
Signed-off-by Antheas Kapenekakis <[email protected]>---
drivers/hwmon/oxp-sensors.c| 84 +++++++++++++++++++++++++++++++++++++1 file changed, 84 insertions(+)drivers/hwmon/oxp-sensors.c +0
-0@@ -101,6 +101,12 @@ static enum oxp_board board;*/ #define OXP_X1_CHARGE_BYPASS_MASK_S3S5 0x02Quoted 8 lines
drivers/hwmon/oxp-sensors.c static enum oxp_board board; · line 109
Quoted 6 lines
drivers/hwmon/oxp-sensors.c +6
-0+/* X1 Turbo LED */ +#define OXP_X1_TURBO_LED_REG 0x57 + +#define OXP_X1_TURBO_LED_OFF 0x01 +#define OXP_X1_TURBO_LED_ON 0x02 +Not a blocker for me on this series, but we should consider looking at creating some enums in the future to capture functionality in a more concise way. There are quite a few define's at this point and enums offer a little bit of value validation.
Quoted 101 lines
There should probably be a refactor in the future. Yes. I would tend towards using a driver struct...
Quoted 98 lines
Quoted 87 lines
drivers/hwmon/oxp-sensors.c +73
-0enum charge_type_value_index {CT_OFF ,CT_S0 ,@@ -466,6 +472,73 @@ static ssize_t tt_toggle_show(struct device *dev,static DEVICE_ATTR_RW (tt_toggle); +/* Callbacks for turbo toggle attribute */ +static umode_t tt_led_is_visible (struct kobject *kobj, +struct attribute *attr,int n) +{ +switch (board) { +case oxp_x1: +return attr->mode; +default : +break ; + } +return 0 ; +} + +static ssize_t tt_led_store (struct device *dev, +struct device_attribute *attr,const char *buf, +size_t count) +{ +u8 reg, val; +int rval; +bool value; + + rval =kstrtobool (buf, &value); +if (rval) +return rval; + +switch (board) { +case oxp_x1: + reg =OXP_X1_TURBO_LED_REG ; + val = value ?OXP_X1_TURBO_LED_ON :OXP_X1_TURBO_LED_OFF ; +break ; +default : +return -EINVAL ; + } + rval =write_to_ec (reg, val); + +if (rval) +return rval; + +return count; +} + +static ssize_t tt_led_show (struct device *dev, +struct device_attribute *attr,char *buf) +{ +int retval; +u8 reg; +long enval; +long val; + +switch (board) { +case oxp_x1: + reg =OXP_2_TURBO_SWITCH_REG ; + enval =OXP_X1_TURBO_LED_ON ; +break ; +default : +return -EINVAL ; + } + + retval =read_from_ec (reg,1 , &val); +if (retval) +return retval; + +return sysfs_emit (buf,"%d\n" , val == enval); +} + +static DEVICE_ATTR_RW (tt_led); +/* Callbacks for turbo toggle attribute */ static bool charge_control_supported (void ) {@@ -894,8 +967,19 @@ static struct attribute_group oxp_tt_toggle_attribute_group = { .attrs = oxp_tt_toggle_attrs, }; +static struct attribute *oxp_tt_led_attrs[] = { + &dev_attr_tt_led.attr, +NULL +}; + +static struct attribute_group oxp_tt_led_attribute_group = {drivers/hwmon/oxp-sensors.c static struct attribute_group oxp_tt_toggle_attribute_group = { · line 985
Quoted 10 lines
drivers/hwmon/oxp-sensors.c +5
-0+ .is_visible = tt_led_is_visible, + .attrs = oxp_tt_led_attrs, +}; +static const struct attribute_group *oxp_ec_groups[] = { &oxp_tt_toggle_attribute_group, + &oxp_tt_led_attribute_group,NULL };- Derek
- Derek
Antheas Kapenekakis
maintainerPATCH v2 7/12 hwmon: (oxp-sensors) Move pwm_enable read to its own function
In reply to Antheas KapenekakisCurrently, this driver breaks sysfs 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.
--- drivers/hwmon/oxp-sensors.c | 50 ++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 23 deletions(-)
drivers/hwmon/oxp-sensors.c +27 -23
@@ -762,6 +762,32 @@ static int oxp_pwm_disable(void) } } +static int oxp_pwm_read (long *val) +{ +switch (board) { +case orange_pi_neo: +return read_from_ec (ORANGEPI_SENSOR_PWM_ENABLE_REG ,1 , val); +case aok_zoe_a1: +case aya_neo_2: +case aya_neo_air: +case aya_neo_air_1s: +case aya_neo_air_plus_mendo: +case aya_neo_air_pro: +case aya_neo_flip: +case aya_neo_geek: +case aya_neo_kun: +case oxp_2: +case oxp_fly: +case oxp_mini_amd: +case oxp_mini_amd_a07: +case oxp_mini_amd_pro: +case oxp_x1: +return read_from_ec (OXP_SENSOR_PWM_ENABLE_REG ,1 , val); +default : +return -EOPNOTSUPP ; + } +} +/* Callbacks for hwmon interface */ static umode_t oxp_ec_hwmon_is_visible (const void *drvdata,enum hwmon_sensor_types type,u32 attr,int channel)
@@ -859,29 +885,7 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type, }return 0 ;case hwmon_pwm_enable: -switch (board) { -case orange_pi_neo: -return read_from_ec (ORANGEPI_SENSOR_PWM_ENABLE_REG ,1 , val); -case aok_zoe_a1: -case aya_neo_2: -case aya_neo_air: -case aya_neo_air_1s: -case aya_neo_air_plus_mendo: -case aya_neo_air_pro: -case aya_neo_flip: -case aya_neo_geek: -case aya_neo_kun: -case oxp_2: -case oxp_fly: -case oxp_mini_amd: -case oxp_mini_amd_a07: -case oxp_mini_amd_pro: -case oxp_x1: -return read_from_ec (OXP_SENSOR_PWM_ENABLE_REG ,1 , val); -default : -break ; - } -break ; +return oxp_pwm_read (val);default :break ; }
Signature · 1 line
2.48.1
Derek J. Clark
maintainerRe: [PATCH v2 07/12] hwmon: (oxp-sensors) Move pwm_enable read to its own function
Quoted 1 line · Antheas Kapenekakis
Currently, this driver breaks sysfs by using auto as 0 and manual as 1.
It breaks hwmon ABI convention, the sysfs is fully functional. Please be more accurate as maintainers may misunderstand the problem here. This comment applies to 8/12 as well. You should probably link the discussion where this was identified as well for context.
<https://lore.kernel.org/linux-hwmon/[email protected]/T/#u>
Quoted 71 lines
However, for
pwm_enable, 0 is full speed, 1 is manual, and 2 is auto. For the correction to be possible, this means that thepwm_enableendpoint 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_enableread to its own function,oxp_pwm_enable.Signed-off-by Antheas Kapenekakis <[email protected]>---
drivers/hwmon/oxp-sensors.c| 50 ++++++++++++++++++++-----------------1 file changed, 27 insertions(+), 23 deletions(-)drivers/hwmon/oxp-sensors.c +26
-17@@ -762,6 +762,32 @@ static int oxp_pwm_disable(void) } } +static int oxp_pwm_read (long *val) +{ +switch (board) { +case orange_pi_neo: +return read_from_ec (ORANGEPI_SENSOR_PWM_ENABLE_REG ,1 , val); +case aok_zoe_a1: +case aya_neo_2: +case aya_neo_air: +case aya_neo_air_1s: +case aya_neo_air_plus_mendo: +case aya_neo_air_pro: +case aya_neo_flip: +case aya_neo_geek: +case aya_neo_kun: +case oxp_2: +case oxp_fly: +case oxp_mini_amd: +case oxp_mini_amd_a07: +case oxp_mini_amd_pro: +case oxp_x1: +return read_from_ec (OXP_SENSOR_PWM_ENABLE_REG ,1 , val); +default : +return -EOPNOTSUPP ; + } +} +/* Callbacks for hwmon interface */ static umode_t oxp_ec_hwmon_is_visible (const void *drvdata,enum hwmon_sensor_types type,u32 attr,int channel)@@ -859,29 +885,7 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type, }return 0 ;case hwmon_pwm_enable: -switch (board) { -case orange_pi_neo: -return read_from_ec (ORANGEPI_SENSOR_PWM_ENABLE_REG ,1 , val); -case aok_zoe_a1: -case aya_neo_2: -case aya_neo_air: -case aya_neo_air_1s: -case aya_neo_air_plus_mendo: -case aya_neo_air_pro: -case aya_neo_flip: -case aya_neo_geek: -case aya_neo_kun: -case oxp_2: -case oxp_fly: -case oxp_mini_amd: -case oxp_mini_amd_a07: -case oxp_mini_amd_pro:
drivers/hwmon/oxp-sensors.c static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type, · line 891
Quoted 10 lines
drivers/hwmon/oxp-sensors.c +1
-6-case oxp_x1: -return read_from_ec (OXP_SENSOR_PWM_ENABLE_REG ,1 , val); -default : -break ; - } -break ; +return oxp_pwm_read (val);default :break ; }
- Derek
Antheas Kapenekakis
maintainerRe: [PATCH v2 07/12] hwmon: (oxp-sensors) Move pwm_enable read to its own function
Quoted 9 lines · Derek J. Clark
Quoted 1 line · Antheas Kapenekakis
Currently, this driver breaks sysfs by using auto as 0 and manual as 1.
It breaks hwmon ABI convention, the sysfs is fully functional. Please be more accurate as maintainers may misunderstand the problem here. This comment applies to 8/12 as well. You should probably link the discussion where this was identified as well for context.
<https://lore.kernel.org/linux-hwmon/[email protected]/T/#u>
Sure, I can add a closes and tweak the wording.
Quoted 83 lines
Quoted 71 lines
However, for
pwm_enable, 0 is full speed, 1 is manual, and 2 is auto. For the correction to be possible, this means that thepwm_enableendpoint 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_enableread to its own function,oxp_pwm_enable.Signed-off-by Antheas Kapenekakis <[email protected]>---
drivers/hwmon/oxp-sensors.c| 50 ++++++++++++++++++++-----------------1 file changed, 27 insertions(+), 23 deletions(-)drivers/hwmon/oxp-sensors.c +26
-17@@ -762,6 +762,32 @@ static int oxp_pwm_disable(void) } } +static int oxp_pwm_read (long *val) +{ +switch (board) { +case orange_pi_neo: +return read_from_ec (ORANGEPI_SENSOR_PWM_ENABLE_REG ,1 , val); +case aok_zoe_a1: +case aya_neo_2: +case aya_neo_air: +case aya_neo_air_1s: +case aya_neo_air_plus_mendo: +case aya_neo_air_pro: +case aya_neo_flip: +case aya_neo_geek: +case aya_neo_kun: +case oxp_2: +case oxp_fly: +case oxp_mini_amd: +case oxp_mini_amd_a07: +case oxp_mini_amd_pro: +case oxp_x1: +return read_from_ec (OXP_SENSOR_PWM_ENABLE_REG ,1 , val); +default : +return -EOPNOTSUPP ; + } +} +/* Callbacks for hwmon interface */ static umode_t oxp_ec_hwmon_is_visible (const void *drvdata,enum hwmon_sensor_types type,u32 attr,int channel)@@ -859,29 +885,7 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type, }return 0 ;case hwmon_pwm_enable: -switch (board) { -case orange_pi_neo: -return read_from_ec (ORANGEPI_SENSOR_PWM_ENABLE_REG ,1 , val); -case aok_zoe_a1: -case aya_neo_2: -case aya_neo_air: -case aya_neo_air_1s: -case aya_neo_air_plus_mendo: -case aya_neo_air_pro: -case aya_neo_flip: -case aya_neo_geek: -case aya_neo_kun: -case oxp_2: -case oxp_fly: -case oxp_mini_amd: -case oxp_mini_amd_a07: -case oxp_mini_amd_pro:drivers/hwmon/oxp-sensors.c static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type, · line 891
Quoted 10 lines
drivers/hwmon/oxp-sensors.c +1
-6-case oxp_x1: -return read_from_ec (OXP_SENSOR_PWM_ENABLE_REG ,1 , val); -default : -break ; - } -break ; +return oxp_pwm_read (val);default :break ; }- Derek
Antheas Kapenekakis
maintainerPATCH v2 8/12 hwmon: (oxp-sensors) Move pwm value read/write to separate functions
In reply to Antheas KapenekakisCurrently, this driver breaks sysfs 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.
--- drivers/hwmon/oxp-sensors.c | 162 +++++++++++++++++++----------------- 1 file changed, 87 insertions(+), 75 deletions(-)
drivers/hwmon/oxp-sensors.c +87 -75
@@ -802,6 +802,91 @@ static umode_t oxp_ec_hwmon_is_visible(const void *drvdata, } } +/* PWM input read/write functions */ +static int oxp_pwm_input_write (long val) +{ +if (val <0 || val >255 ) +return -EINVAL ; +switch (board) { +case orange_pi_neo: +/* scale to range [1-244] */ + val = ((val -1 ) *243 /254 ) +1 ; +return write_to_ec (ORANGEPI_SENSOR_PWM_REG , val); +case oxp_2: +case oxp_x1: +/* scale to range [0-184] */ + val = (val *184 ) /255 ; +return write_to_ec (OXP_SENSOR_PWM_REG , val); +case aya_neo_2: +case aya_neo_air: +case aya_neo_air_1s: +case aya_neo_air_plus_mendo: +case aya_neo_air_pro: +case aya_neo_flip: +case aya_neo_geek: +case aya_neo_kun: +case oxp_mini_amd: +case oxp_mini_amd_a07: +/* scale to range [0-100] */ + val = (val *100 ) /255 ; +return write_to_ec (OXP_SENSOR_PWM_REG , val); +case aok_zoe_a1: +case oxp_fly: +case oxp_mini_amd_pro: +return write_to_ec (OXP_SENSOR_PWM_REG , val); +default : +return -EOPNOTSUPP ; + } +} + +static int oxp_pwm_input_read (long *val) +{ +int ret; + +switch (board) { +case orange_pi_neo: + ret =read_from_ec (ORANGEPI_SENSOR_PWM_REG ,1 , val); +if (ret) +return ret; +/* scale from range [1-244] */ + *val = ((*val -1 ) *254 /243 ) +1 ; +break ; +case oxp_2: +case oxp_x1: + ret =read_from_ec (OXP_SENSOR_PWM_REG ,1 , val); +if (ret) +return ret; +/* scale from range [0-184] */ + *val = (*val *255 ) /184 ; +break ; +case aya_neo_2: +case aya_neo_air: +case aya_neo_air_1s: +case aya_neo_air_plus_mendo: +case aya_neo_air_pro: +case aya_neo_flip: +case aya_neo_geek: +case aya_neo_kun: +case oxp_mini_amd: +case oxp_mini_amd_a07: + ret =read_from_ec (OXP_SENSOR_PWM_REG ,1 , val); +if (ret) +return ret; +/* scale from range [0-100] */ + *val = (*val *255 ) /100 ; +break ; +case aok_zoe_a1: +case oxp_fly: +case oxp_mini_amd_pro: +default : + ret =read_from_ec (OXP_SENSOR_PWM_REG ,1 , val); +if (ret) +return ret; +break ; + } +return 0 ; +} +static int oxp_platform_read (struct device *dev,enum hwmon_sensor_types type,u32 attr,int channel,long *val) {
@@ -842,48 +927,7 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type,case hwmon_pwm:switch (attr) {case hwmon_pwm_input: -switch (board) { -case orange_pi_neo: - ret =read_from_ec (ORANGEPI_SENSOR_PWM_REG ,1 , val); -if (ret) -return ret; -/* scale from range [1-244] */ - *val = ((*val -1 ) *254 /243 ) +1 ; -break ; -case oxp_2: -case oxp_x1: - ret =read_from_ec (OXP_SENSOR_PWM_REG ,1 , val); -if (ret) -return ret; -/* scale from range [0-184] */ - *val = (*val *255 ) /184 ; -break ; -case aya_neo_2: -case aya_neo_air: -case aya_neo_air_1s: -case aya_neo_air_plus_mendo: -case aya_neo_air_pro: -case aya_neo_flip: -case aya_neo_geek: -case aya_neo_kun: -case oxp_mini_amd: -case oxp_mini_amd_a07: - ret =read_from_ec (OXP_SENSOR_PWM_REG ,1 , val); -if (ret) -return ret; -/* scale from range [0-100] */ - *val = (*val *255 ) /100 ; -break ; -case aok_zoe_a1: -case oxp_fly: -case oxp_mini_amd_pro: -default : - ret =read_from_ec (OXP_SENSOR_PWM_REG ,1 , val); -if (ret) -return ret; -break ; - } -return 0 ; +return oxp_pwm_input_read (val);case hwmon_pwm_enable:return oxp_pwm_read (val);default :
@@ -909,39 +953,7 @@ static int oxp_platform_write(struct device *dev, enum hwmon_sensor_types type,return oxp_pwm_disable ();return -EINVAL ;case hwmon_pwm_input: -if (val <0 || val >255 ) -return -EINVAL ; -switch (board) { -case orange_pi_neo: -/* scale to range [1-244] */ - val = ((val -1 ) *243 /254 ) +1 ; -return write_to_ec (ORANGEPI_SENSOR_PWM_REG , val); -case oxp_2: -case oxp_x1: -/* scale to range [0-184] */ - val = (val *184 ) /255 ; -return write_to_ec (OXP_SENSOR_PWM_REG , val); -case aya_neo_2: -case aya_neo_air: -case aya_neo_air_1s: -case aya_neo_air_plus_mendo: -case aya_neo_air_pro: -case aya_neo_flip: -case aya_neo_geek: -case aya_neo_kun: -case oxp_mini_amd: -case oxp_mini_amd_a07: -/* scale to range [0-100] */ - val = (val *100 ) /255 ; -return write_to_ec (OXP_SENSOR_PWM_REG , val); -case aok_zoe_a1: -case oxp_fly: -case oxp_mini_amd_pro: -return write_to_ec (OXP_SENSOR_PWM_REG , val); -default : -break ; - } -break ; +return oxp_pwm_input_write (val);default :break ; }
Signature · 1 line
2.48.1
Antheas Kapenekakis
maintainerPATCH v2 9/12 hwmon: (oxp-sensors) Move fan speed read to separate function
In reply to Antheas KapenekakisWhile not necessary for fixing the sysfs issue, fan speed will be the only remaining value without a function. Therefore, finish the refactor by moving it to a separate function.
--- drivers/hwmon/oxp-sensors.c | 53 ++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 24 deletions(-)
drivers/hwmon/oxp-sensors.c +29 -24
@@ -802,6 +802,34 @@ static umode_t oxp_ec_hwmon_is_visible(const void *drvdata, } } +/* Fan speed read function */ +static int oxp_pwm_fan_speed (long *val) +{ +switch (board) { +case orange_pi_neo: +return read_from_ec (ORANGEPI_SENSOR_FAN_REG ,2 , val); +case oxp_2: +case oxp_x1: +return read_from_ec (OXP_2_SENSOR_FAN_REG ,2 , val); +case aok_zoe_a1: +case aya_neo_2: +case aya_neo_air: +case aya_neo_air_1s: +case aya_neo_air_plus_mendo: +case aya_neo_air_pro: +case aya_neo_flip: +case aya_neo_geek: +case aya_neo_kun: +case oxp_fly: +case oxp_mini_amd: +case oxp_mini_amd_a07: +case oxp_mini_amd_pro: +return read_from_ec (OXP_SENSOR_FAN_REG ,2 , val); +default : +return -EOPNOTSUPP ; + } +} +/* PWM input read/write functions */ static int oxp_pwm_input_write (long val) {
@@ -896,30 +924,7 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type,case hwmon_fan:switch (attr) {case hwmon_fan_input: -switch (board) { -case orange_pi_neo: -return read_from_ec (ORANGEPI_SENSOR_FAN_REG ,2 , val); -case oxp_2: -case oxp_x1: -return read_from_ec (OXP_2_SENSOR_FAN_REG ,2 , val); -case aok_zoe_a1: -case aya_neo_2: -case aya_neo_air: -case aya_neo_air_1s: -case aya_neo_air_plus_mendo: -case aya_neo_air_pro: -case aya_neo_flip: -case aya_neo_geek: -case aya_neo_kun: -case oxp_fly: -case oxp_mini_amd: -case oxp_mini_amd_a07: -case oxp_mini_amd_pro: -return read_from_ec (OXP_SENSOR_FAN_REG ,2 , val); -default : -break ; - } -break ; +return oxp_pwm_fan_speed (val);default :break ; }
Signature · 1 line
2.48.1
Antheas Kapenekakis
maintainerPATCH v2 10/12 hwmon: (oxp-sensors) Adhere to sysfs-class-hwmon and enable pwm on 2
In reply to Antheas KapenekakisCurrently, 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.
--- drivers/hwmon/oxp-sensors.c | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-)
drivers/hwmon/oxp-sensors.c +33 -4
@@ -934,7 +934,27 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type,case hwmon_pwm_input:return oxp_pwm_input_read (val);case hwmon_pwm_enable: -return oxp_pwm_read (val); + ret =oxp_pwm_read (val); +if (ret) +return ret; + +/* Check for auto and return 2 */ +if (!*val) { + *val =2 ; +return 0 ; + } + +/* Return 0 if at full fan speed, 1 otherwise */ + ret =oxp_pwm_fan_speed (val); +if (ret) +return ret; + +if (*val ==255 ) + *val =0 ; +else + *val =1 ; + +return 0 ;default :break ; }
@@ -948,15 +968,24 @@ static int oxp_platform_read(struct device *dev, enum hwmon_sensor_types type,static int oxp_platform_write (struct device *dev,enum hwmon_sensor_types type,u32 attr,int channel,long val) { +int ret; +switch (type) {case hwmon_pwm:switch (attr) {case hwmon_pwm_enable:if (val ==1 )return oxp_pwm_enable (); -else if (val ==0 ) +else if (val ==2 )return oxp_pwm_disable (); -return -EINVAL ; +else if (val !=0 ) +return -EINVAL ; + +/* Enable PWM and set to max speed */ + ret =oxp_pwm_enable (); +if (ret) +return ret; +return oxp_pwm_input_write (255 );case hwmon_pwm_input:return oxp_pwm_input_write (val);default :
@@ -1021,7 +1050,7 @@ static int oxp_platform_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct device *hwdev; - hwdev =devm_hwmon_device_register_with_info (dev,"oxpec" ,NULL , + hwdev =devm_hwmon_device_register_with_info (dev,"oxp_ec" ,NULL , &oxp_ec_chip_info,NULL );return PTR_ERR_OR_ZERO (hwdev);
Signature · 1 line
2.48.1
Antheas Kapenekakis
maintainerPATCH v2 11/12 platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86
In reply to Antheas KapenekakisOnce upon a time, the platform EC of handheld devices only controlled the fan. This is no longer the case, with the EC of OneXPlayer gaining additional functionality.
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.
While at it, add myself to the maintainer's file.
---
Documentation/hwmon/index.rst | 2 +-
Documentation/hwmon/{oxp-sensors.rst => oxpec.rst} | 0
MAINTAINERS | 7 ++++---
drivers/hwmon/Kconfig | 11 -----------
drivers/hwmon/Makefile | 1 -
drivers/platform/x86/Kconfig | 11 +++++++++++
drivers/platform/x86/Makefile | 3 +++
drivers/{hwmon/oxp-sensors.c => platform/x86/oxpec.c} | 10 ++++------
8 files changed, 23 insertions(+), 22 deletions(-)
rename Documentation/hwmon/{oxp-sensors.rst => oxpec.rst} (100%)
rename drivers/{hwmon/oxp-sensors.c => platform/x86/oxpec.c} (98%)Documentation/hwmon/index.rst +1 -1
@@ -186,7 +186,7 @@ Hardware Monitoring Kernel Drivers nzxt-kraken3 nzxt-smart2 occ - oxp-sensors + oxpec pc87360 pc87427 pcf8591
Documentation/hwmon/oxpec.rst renamed from Documentation/hwmon/oxp-sensors.rst +0 -0
MAINTAINERS +4 -3
@@ -17629,12 +17629,13 @@ S: Maintained F: drivers/mtd/nand/onenand/ F: include/linux/mtd/onenand*.h -ONEXPLAYER FAN DRIVER +ONEXPLAYER PLATFORM EC DRIVER +M: Antheas Kapenekakis <[email protected]> M: Derek John Clark <[email protected]> M: Joaquín Ignacio Aramendía <[email protected]> -L: [email protected] +L: [email protected] S: Maintained -F: drivers/hwmon/oxp-sensors.c +F: drivers/platform/x86/oxpec.c ONIE TLV NVMEM LAYOUT DRIVER M: Miquel Raynal <[email protected]>
drivers/hwmon/Kconfig +0 -11
@@ -1774,17 +1774,6 @@ config SENSORS_NZXT_SMART2 source "drivers/hwmon/occ/Kconfig" -config SENSORS_OXP - tristate "OneXPlayer EC fan control" - depends on ACPI_EC - depends on X86 - help - If you say yes here you get support for fan readings and control over - OneXPlayer handheld devices. Only OneXPlayer mini AMD handheld variant - boards are supported. - - Can also be built as a module. In that case it will be called oxp-sensors. - config SENSORS_PCF8591 tristate "Philips PCF8591 ADC/DAC" depends on I2C
drivers/hwmon/Makefile +0 -1
@@ -181,7 +181,6 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR) += ntc_thermistor.o obj-$(CONFIG_SENSORS_NZXT_KRAKEN2) += nzxt-kraken2.o obj-$(CONFIG_SENSORS_NZXT_KRAKEN3) += nzxt-kraken3.o obj-$(CONFIG_SENSORS_NZXT_SMART2) += nzxt-smart2.o -obj-$(CONFIG_SENSORS_OXP) += oxp-sensors.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.o
drivers/platform/x86/Kconfig +11 -0
@@ -1186,6 +1186,17 @@ config SEL3350_PLATFORM To compile this driver as a module, choose M here: the module will be called sel3350-platform. +config OXP_EC + tristate "OneXPlayer EC platform control" + depends on ACPI_EC + depends on X86 + help + Enables support for the platform EC of OneXPlayer and AOKZOE + handheld devices. This includes fan speed, fan controls, and + disabling the default TDP behavior of the device. Due to legacy + reasons, this driver also provides hwmon functionality to Ayaneo + devices and the OrangePi Neo. + endif # X86_PLATFORM_DEVICES config P2SB
drivers/platform/x86/Makefile +3 -0
@@ -153,3 +153,6 @@ obj-$(CONFIG_WINMATE_FM07_KEYS) += winmate-fm07-keys.o # SEL obj-$(CONFIG_SEL3350_PLATFORM) += sel3350-platform.o + +# OneXPlayer +obj-$(CONFIG_OXP_EC) += oxpec.o
drivers/platform/x86/oxpec.c renamed from drivers/hwmon/oxp-sensors.c +4 -6
@@ -1,11 +1,8 @@// SPDX-License-Identifier: GPL-2.0+ /* -* Platform driver for OneXPlayer, AOKZOE, AYANEO, and OrangePi Handhelds -* that expose fan reading and control via hwmon sysfs. -* -* Old OXP boards have the same DMI strings and they are told apart by -* the boot cpu vendor (Intel/AMD). Of these older models only AMD is -* supported. +* Platform driver for OneXPlayer and AOKZOE devices. For the time being, +* it also exposes fan controls for AYANEO, and OrangePi Handhelds via +* hwmon sysfs. * * Fan control is provided via pwm interface in the range [0-255]. * Old AMD boards use [0-100] as range in the EC, the written value is
@@ -16,6 +13,7 @@* * Copyright (C) 2022 Joaquín I. Aramendía <[email protected]> * Copyright (C) 2024 Derek J. Clark <[email protected]> +* Copyright (C) 2025 Antheas Kapenekakis <[email protected]> */ #include <linux/acpi.h>
Signature · 1 line
2.48.1
kernel test robot
build botRe: [PATCH v2 11/12] platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86
kernel test robot noticed the following build errors:
Hi Antheas,
kernel test robot noticed the following build errors:
[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on sre-power-supply/for-next amd-pstate/linux-next amd-pstate/bleeding-edge rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v6.14-rc4 next-20250228] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Antheas-Kapenekakis/hwmon-oxp-sensors-Distinguish-the-X1-variants/20250223-003148 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next patch link: https://lore.kernel.org/r/20250222161824.172511-12-lkml%40antheas.dev patch subject: [PATCH v2 11/12] platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86 config: x86_64-randconfig-078-20250301 (https://download.01.org/0day-ci/archive/20250301/[email protected]/config) compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250301/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> ld.lld: error: undefined symbol: devm_hwmon_device_register_with_info >>> referenced by oxpec.c:1051 (drivers/platform/x86/oxpec.c:1051) >>> vmlinux.o:(oxp_platform_probe)
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Antheas Kapenekakis
maintainerRe: [PATCH v2 11/12] platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86
Quoted 26 lines · kernel test robot
Hi Antheas,
kernel test robot noticed the following build errors:
[auto build test ERROR on groeck-staging/hwmon-next]
[also build test ERROR on sre-power-supply/for-next amd-pstate/linux-next amd-pstate/bleeding-edge rafael-pm/linux-next rafael-pm/bleeding-edge linus/master v6.14-rc4 next-20250228] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Antheas-Kapenekakis/hwmon-oxp-sensors-Distinguish-the-X1-variants/20250223-003148 base: https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git hwmon-next patch link: https://lore.kernel.org/r/20250222161824.172511-12-lkml%40antheas.dev patch subject: [PATCH v2 11/12] platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86 config: x86_64-randconfig-078-20250301 (https://download.01.org/0day-ci/archive/20250301/[email protected]/config) compiler: clang version 19.1.7 (https://github.com/llvm/llvm-project cd708029e0b2869e80abe31ddb175f7c35361f90) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250301/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
ld.lld: error: undefined symbol:
devm_hwmon_device_register_with_infoQuoted 2 lines
referenced by oxpec.c:1051 (
drivers/platform/x86/oxpec.c:1051)
vmlinux.o:(oxp_platform_probe)--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Guess it doesn't merge anymore. I have two other nits I fixed so I was planning for a V2.
Question for the charge_type ABI. Should we switch to charge_behaviour since that also allows for autodiscovery?
Antheas
Re: [PATCH v2 11/12] platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86
In reply to Antheas KapenekakisQuoted 11 lines · Antheas Kapenekakis
Once upon a time, the platform EC of handheld devices only controlled the fan. This is no longer the case, with the EC of OneXPlayer gaining additional functionality.
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.
While at it, add myself to the maintainer's file.
Signed-off-by Antheas Kapenekakis <[email protected]>
This should really have been the first patch of the series.
Guenter
Quoted 149 lines
--- Documentation/hwmon/index.rst | 2 +- Documentation/hwmon/{oxp-sensors.rst => oxpec.rst} | 0 MAINTAINERS | 7 ++++--- drivers/hwmon/Kconfig | 11 ----------- drivers/hwmon/Makefile | 1 - drivers/platform/x86/Kconfig | 11 +++++++++++ drivers/platform/x86/Makefile | 3 +++ drivers/{hwmon/oxp-sensors.c => platform/x86/oxpec.c} | 10 ++++------ 8 files changed, 23 insertions(+), 22 deletions(-)rename
Documentation/hwmon/{oxp-sensors.rst=>oxpec.rst} (100%) renamedrivers/{hwmon/oxp-sensors.c=>platform/x86/oxpec.c} (98%)Documentation/hwmon/index.rst +1
-1@@ -186,7 +186,7 @@ Hardware Monitoring Kernel Drivers nzxt-kraken3 nzxt-smart2 occ - oxp-sensors + oxpec pc87360 pc87427 pcf8591Documentation/hwmon/oxpec.rst renamed from Documentation/hwmon/oxp-sensors.rst +0
-0MAINTAINERS +4
-3@@ -17629,12 +17629,13 @@ S: Maintained F: drivers/mtd/nand/onenand/ F: include/linux/mtd/onenand*.h -ONEXPLAYER FAN DRIVER +ONEXPLAYER PLATFORM EC DRIVER +M: Antheas Kapenekakis <[email protected]> M: Derek John Clark <[email protected]> M: Joaquín Ignacio Aramendía <[email protected]> -L: [email protected] +L: [email protected] S: Maintained -F: drivers/hwmon/oxp-sensors.c +F: drivers/platform/x86/oxpec.c ONIE TLV NVMEM LAYOUT DRIVER M: Miquel Raynal <[email protected]>drivers/hwmon/Kconfig +0
-11@@ -1774,17 +1774,6 @@ config SENSORS_NZXT_SMART2 source "drivers/hwmon/occ/Kconfig" -config SENSORS_OXP - tristate "OneXPlayer EC fan control" - depends on ACPI_EC - depends on X86 - help - If you say yes here you get support for fan readings and control over - OneXPlayer handheld devices. Only OneXPlayer mini AMD handheld variant - boards are supported. - - Can also be built as a module. In that case it will be called oxp-sensors. - config SENSORS_PCF8591 tristate "Philips PCF8591 ADC/DAC" depends on I2Cdrivers/hwmon/Makefile +0
-1@@ -181,7 +181,6 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR) += ntc_thermistor.o obj-$(CONFIG_SENSORS_NZXT_KRAKEN2) += nzxt-kraken2.o obj-$(CONFIG_SENSORS_NZXT_KRAKEN3) += nzxt-kraken3.o obj-$(CONFIG_SENSORS_NZXT_SMART2) += nzxt-smart2.o -obj-$(CONFIG_SENSORS_OXP) += oxp-sensors.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.odrivers/platform/x86/Kconfig +11
-0@@ -1186,6 +1186,17 @@ config SEL3350_PLATFORM To compile this driver as a module, choose M here: the module will be called sel3350-platform. +config OXP_EC + tristate "OneXPlayer EC platform control" + depends on ACPI_EC + depends on X86 + help + Enables support for the platform EC of OneXPlayer and AOKZOE + handheld devices. This includes fan speed, fan controls, and + disabling the default TDP behavior of the device. Due to legacy + reasons, this driver also provides hwmon functionality to Ayaneo + devices and the OrangePi Neo. + endif # X86_PLATFORM_DEVICES config P2SBdrivers/platform/x86/Makefile +3
-0@@ -153,3 +153,6 @@ obj-$(CONFIG_WINMATE_FM07_KEYS) += winmate-fm07-keys.o # SEL obj-$(CONFIG_SEL3350_PLATFORM) += sel3350-platform.o + +# OneXPlayer +obj-$(CONFIG_OXP_EC) += oxpec.odrivers/platform/x86/oxpec.c renamed from drivers/hwmon/oxp-sensors.c +4
-6@@ -1,11 +1,8 @@// SPDX-License-Identifier: GPL-2.0+ /* -* Platform driver for OneXPlayer, AOKZOE, AYANEO, and OrangePi Handhelds -* that expose fan reading and control via hwmon sysfs. -* -* Old OXP boards have the same DMI strings and they are told apart by -* the boot cpu vendor (Intel/AMD). Of these older models only AMD is -* supported. +* Platform driver for OneXPlayer and AOKZOE devices. For the time being, +* it also exposes fan controls for AYANEO, and OrangePi Handhelds via +* hwmon sysfs. * * Fan control is provided via pwm interface in the range [0-255]. * Old AMD boards use [0-100] as range in the EC, the written value is @@ -16,6 +13,7 @@* * Copyright (C) 2022 Joaquín I. Aramendía <[email protected]> * Copyright (C) 2024 Derek J. Clark <[email protected]> +* Copyright (C) 2025 Antheas Kapenekakis <[email protected]> */ #include <linux/acpi.h>
Antheas Kapenekakis
maintainerRe: [PATCH v2 11/12] platform/x86: oxpec: Move hwmon/oxp-sensors to platform/x86
Quoted 12 lines · Guenter Roeck
Quoted 10 lines · Antheas Kapenekakis
Once upon a time, the platform EC of handheld devices only controlled the fan. This is no longer the case, with the EC of OneXPlayer gaining additional functionality.
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.
While at it, add myself to the maintainer's file.
Quoted 7 lines
Quoted 1 line
Signed-off-by Antheas Kapenekakis <[email protected]>Acked-by Guenter Roeck <[email protected]>This should really have been the first patch of the series.
Guenter
You are right, I will try to for the V3. Hopefully its not too hairy to rebase the patches.
I will still keep the device additions first so they are possible to cherry pick to lts kernels.
Quoted 150 lines
Quoted 149 lines
--- Documentation/hwmon/index.rst | 2 +- Documentation/hwmon/{oxp-sensors.rst => oxpec.rst} | 0 MAINTAINERS | 7 ++++--- drivers/hwmon/Kconfig | 11 ----------- drivers/hwmon/Makefile | 1 - drivers/platform/x86/Kconfig | 11 +++++++++++ drivers/platform/x86/Makefile | 3 +++ drivers/{hwmon/oxp-sensors.c => platform/x86/oxpec.c} | 10 ++++------ 8 files changed, 23 insertions(+), 22 deletions(-)rename
Documentation/hwmon/{oxp-sensors.rst=>oxpec.rst} (100%) renamedrivers/{hwmon/oxp-sensors.c=>platform/x86/oxpec.c} (98%)Documentation/hwmon/index.rst +1
-1@@ -186,7 +186,7 @@ Hardware Monitoring Kernel Drivers nzxt-kraken3 nzxt-smart2 occ - oxp-sensors + oxpec pc87360 pc87427 pcf8591Documentation/hwmon/oxpec.rst renamed from Documentation/hwmon/oxp-sensors.rst +0
-0MAINTAINERS +4
-3@@ -17629,12 +17629,13 @@ S: Maintained F: drivers/mtd/nand/onenand/ F: include/linux/mtd/onenand*.h -ONEXPLAYER FAN DRIVER +ONEXPLAYER PLATFORM EC DRIVER +M: Antheas Kapenekakis <[email protected]> M: Derek John Clark <[email protected]> M: Joaquín Ignacio Aramendía <[email protected]> -L: [email protected] +L: [email protected] S: Maintained -F: drivers/hwmon/oxp-sensors.c +F: drivers/platform/x86/oxpec.c ONIE TLV NVMEM LAYOUT DRIVER M: Miquel Raynal <[email protected]>drivers/hwmon/Kconfig +0
-11@@ -1774,17 +1774,6 @@ config SENSORS_NZXT_SMART2 source "drivers/hwmon/occ/Kconfig" -config SENSORS_OXP - tristate "OneXPlayer EC fan control" - depends on ACPI_EC - depends on X86 - help - If you say yes here you get support for fan readings and control over - OneXPlayer handheld devices. Only OneXPlayer mini AMD handheld variant - boards are supported. - - Can also be built as a module. In that case it will be called oxp-sensors. - config SENSORS_PCF8591 tristate "Philips PCF8591 ADC/DAC" depends on I2Cdrivers/hwmon/Makefile +0
-1@@ -181,7 +181,6 @@ obj-$(CONFIG_SENSORS_NTC_THERMISTOR) += ntc_thermistor.o obj-$(CONFIG_SENSORS_NZXT_KRAKEN2) += nzxt-kraken2.o obj-$(CONFIG_SENSORS_NZXT_KRAKEN3) += nzxt-kraken3.o obj-$(CONFIG_SENSORS_NZXT_SMART2) += nzxt-smart2.o -obj-$(CONFIG_SENSORS_OXP) += oxp-sensors.o obj-$(CONFIG_SENSORS_PC87360) += pc87360.o obj-$(CONFIG_SENSORS_PC87427) += pc87427.o obj-$(CONFIG_SENSORS_PCF8591) += pcf8591.odrivers/platform/x86/Kconfig +11
-0@@ -1186,6 +1186,17 @@ config SEL3350_PLATFORM To compile this driver as a module, choose M here: the module will be called sel3350-platform. +config OXP_EC + tristate "OneXPlayer EC platform control" + depends on ACPI_EC + depends on X86 + help + Enables support for the platform EC of OneXPlayer and AOKZOE + handheld devices. This includes fan speed, fan controls, and + disabling the default TDP behavior of the device. Due to legacy + reasons, this driver also provides hwmon functionality to Ayaneo + devices and the OrangePi Neo. + endif # X86_PLATFORM_DEVICES config P2SBdrivers/platform/x86/Makefile +3
-0@@ -153,3 +153,6 @@ obj-$(CONFIG_WINMATE_FM07_KEYS) += winmate-fm07-keys.o # SEL obj-$(CONFIG_SEL3350_PLATFORM) += sel3350-platform.o + +# OneXPlayer +obj-$(CONFIG_OXP_EC) += oxpec.odrivers/platform/x86/oxpec.c renamed from drivers/hwmon/oxp-sensors.c +4
-6@@ -1,11 +1,8 @@// SPDX-License-Identifier: GPL-2.0+ /* -* Platform driver for OneXPlayer, AOKZOE, AYANEO, and OrangePi Handhelds -* that expose fan reading and control via hwmon sysfs. -* -* Old OXP boards have the same DMI strings and they are told apart by -* the boot cpu vendor (Intel/AMD). Of these older models only AMD is -* supported. +* Platform driver for OneXPlayer and AOKZOE devices. For the time being, +* it also exposes fan controls for AYANEO, and OrangePi Handhelds via +* hwmon sysfs. * * Fan control is provided via pwm interface in the range [0-255]. * Old AMD boards use [0-100] as range in the EC, the written value is @@ -16,6 +13,7 @@* * Copyright (C) 2022 Joaquín I. Aramendía <[email protected]> * Copyright (C) 2024 Derek J. Clark <[email protected]> +* Copyright (C) 2025 Antheas Kapenekakis <[email protected]> */ #include <linux/acpi.h>
Antheas Kapenekakis
maintainerPATCH v2 12/12 ABI: testing: add tt_toggle and tt_led entries
In reply to Antheas KapenekakisWhen tt_toggle was introduced, it was not added to the platform sysfs. Add it, then add documentation for tt_led. Remove the documentation from the hwmon entry, then update its readme to be current.
--- Documentation/ABI/testing/sysfs-platform-oxp | 29 +++++++++ Documentation/hwmon/oxpec.rst | 62 +++++++------------- 2 files changed, 49 insertions(+), 42 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-platform-oxp
Documentation/ABI/testing/sysfs-platform-oxp new file +29 -0
@@ -0,0 +1,29 @@ +What: /sys/devices/platform/<platform>/tt_toggle +Date: Jun 2023 +KernelVersion: 6.5 +Contact: "Antheas Kapenekakis" <[email protected]> +Description: + Takeover TDP controls from the device. OneXPlayer devices have a + turbo button that can be used to switch between two TDP modes + (usually 15W and 25W). By setting this attribute to 1, this + functionality is disabled, handing TDP control over to (Windows) + userspace software and the Turbo button turns into a keyboard + shortcut over the AT keyboard of the device. In addition, + using this setting is a prerequisite for PWM control for most + devices (otherwise it NOOPs). + + This attribute was originally introduced in 6.5, without a + corresponding documentation entry. + +What: /sys/devices/platform/<platform>/tt_led +Date: Feb 2025 +KernelVersion: 6.15 +Contact: "Antheas Kapenekakis" <[email protected]> +Description: + Some OneXPlayer devices (e.g., X1 series) feature a little LED + nested in the Turbo button. This LED is illuminated when the + device is in the higher TDP mode (e.g., 25W). Once tt_toggle + is engaged, this LED is left dangling to its last state. This + attribute allows userspace to control the LED state manually + (either with 1 or 0). Only a subset of devices contain this LED. +
Documentation/hwmon/oxpec.rst +20 -42
96 lines not on this page · raw message
Signature · 1 line
2.48.1