platform/x86: uniwill-laptop: Charging-related improvements
Subsystems (3)
Armin Wolf
maintainerv3 cover platform/x86: uniwill-laptop: Charging-related improvements
This patch series contains various charging-related improvements for the uniwill-laptop driver. The first two patches fix some minor issues inside the charging threshold code, while the third patch fixes an issue inside the module initialization code. The next two patches contain some preparations for the main patch. Said patch introduces support for controlling the charging modes available on many Uniwill-based devices not sold by Intel. The last patch whitelists most Tuxedo devices for using the battery charge modes.
All patches have been tested on a Tuxedo InfinityBook Pro 15 Gen10 AMD and work just fine.
Changes since v2:
- add Reviewed-by tags
- rework first patch to use a common helper function
- add last patch from Werner
Changes since v1:
- add Reviewed-by tags
- fix spelling errors
- split third patch into two separate patches
- restructure code for battery initialization
Armin Wolf (7):
platform/x86: uniwill-laptop: Properly initialize charging threshold platform/x86: uniwill-laptop: Accept charging threshold of 0 platform/x86: uniwill-laptop: Fix behavior of "force" module param platform/x86: uniwill-laptop: Do not enable the charging limit even
when forced
platform/x86: uniwill-laptop: Rework FN lock/super key suspend
handling
platform/x86: uniwill-laptop: Mark EC_ADDR_OEM_4 as volatile platform/x86: uniwill-laptop: Add support for battery charge modes
Werner Sembach (1):
platform/x86: uniwill-laptop: Enable battery charge modes on supported
devices
.../admin-guide/laptops/uniwill-laptop.rst | 25 +- drivers/platform/x86/uniwill/uniwill-acpi.c | 443 ++++++++++++++---- drivers/platform/x86/uniwill/uniwill-wmi.c | 5 +- 3 files changed, 384 insertions(+), 89 deletions(-)
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH v3 1/8 platform/x86: uniwill-laptop: Properly initialize charging threshold
The EC might initialize the charge threshold with 0 to signal that said threshold is uninitialized. Detect this and replace said value with 100 to signal the EC that we want to take control of battery charging. Also set the threshold to 100 if the EC-provided value is invalid.
--- drivers/platform/x86/uniwill/uniwill-acpi.c | 35 ++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-)
drivers/platform/x86/uniwill/uniwill-acpi.c +34 -1
@@ -1359,6 +1359,16 @@ static int uniwill_led_init(struct uniwill_data *data) &init_data); } +static unsigned int uniwill_sanitize_battery_threshold (unsigned int value) +{ +/* 0 means "charging threshold not active" */ +if (!value) +return 100 ; + +/* Guard against invalid values */ +return min (value,100 ); +} +static int uniwill_get_property (struct power_supply *psy,const struct power_supply_ext *ext,void *drvdata,enum power_supply_property psp,union power_supply_propval *val)
@@ -1405,7 +1415,8 @@ static int uniwill_get_property(struct power_supply *psy, const struct power_supif (ret <0 )return ret; - val->intval =clamp_val (FIELD_GET (CHARGE_CTRL_MASK , regval),0 ,100 ); + regval =FIELD_GET (CHARGE_CTRL_MASK , regval); + val->intval =uniwill_sanitize_battery_threshold (regval);return 0 ;default :return -EINVAL ;
@@ -1500,11 +1511,33 @@ static int uniwill_remove_battery(struct power_supply *battery, struct acpi_battstatic int uniwill_battery_init (struct uniwill_data *data) { +unsigned int value, threshold, sanitized;int ret;if (!uniwill_device_supports (data,UNIWILL_FEATURE_BATTERY ))return 0 ; + ret =regmap_read (data->regmap,EC_ADDR_CHARGE_CTRL , &value); +if (ret <0 ) +return ret; + +/* +* The charge control threshold might be initialized with 0 by +* the EC to signal that said threshold is uninitialized. We thus +* need to replace this placeholder value with a valid one (100) +* to signal that we want to take control of battery charging. +* For the sake of completeness we also apply this to other +* invalid threshold values. +*/ + threshold =FIELD_GET (CHARGE_CTRL_MASK , value); + sanitized =uniwill_sanitize_battery_threshold (threshold); +if (threshold != sanitized) { +FIELD_MODIFY (CHARGE_CTRL_MASK , &value, sanitized); + ret =regmap_write (data->regmap,EC_ADDR_CHARGE_CTRL , value); +if (ret <0 ) +return ret; + } + ret =devm_mutex_init (data->dev, &data->battery_lock);if (ret <0 )return ret;
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH v3 2/8 platform/x86: uniwill-laptop: Accept charging threshold of 0
In reply to Armin WolfThe power supply sysfs ABI states that:
Not all hardware is capable of setting this to an arbitrary percentage. Drivers will round written values to the nearest supported value. Reading back the value will show the actual threshold set by the driver.
The driver currently violates this ABI by rejecting a charging threshold of 0. Fix this by clamping this value to 1.
--- drivers/platform/x86/uniwill/uniwill-acpi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/platform/x86/uniwill/uniwill-acpi.c +2 -2
@@ -1431,11 +1431,11 @@ static int uniwill_set_property(struct power_supply *psy, const struct power_supswitch (psp) {case POWER_SUPPLY_PROP_CHARGE_CONTROL_END_THRESHOLD : -if (val->intval <1 || val->intval >100 ) +if (val->intval <0 || val->intval >100 )return -EINVAL ;return regmap_update_bits (data->regmap,EC_ADDR_CHARGE_CTRL ,CHARGE_CTRL_MASK , - val->intval); +max (val->intval,1 ));default :return -EINVAL ; }
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH v3 3/8 platform/x86: uniwill-laptop: Fix behavior of "force" module param
In reply to Armin WolfUsers might want to force-enable all possible features even on machines with a valid device descriptor. Until now the "force" module param was ignored on such machines. Fix this to make it easier to test for support of new features.
--- drivers/platform/x86/uniwill/uniwill-acpi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/platform/x86/uniwill/uniwill-acpi.c +6 -2
@@ -2489,8 +2489,6 @@ static int __init uniwill_init(void)if (!force)return -ENODEV ; -/* Assume that the device supports all features */ - device_descriptor.features =UINT_MAX ;pr_warn ("Loading on a potentially unsupported device\n" ); }else {/*
@@ -2508,6 +2506,12 @@ static int __init uniwill_init(void) device_descriptor = *descriptor; } +if (force) { +/* Assume that the device supports all features */ + device_descriptor.features =UINT_MAX ; +pr_warn ("Enabling potentially unsupported features\n" ); + } + ret =platform_driver_register (&uniwill_driver);if (ret <0 )return ret;
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH v3 4/8 platform/x86: uniwill-laptop: Do not enable the charging limit even when forced
In reply to Armin WolfIt seems that on some older models (~2020) the battery charging limit can permanently damage the battery. Prevent users from enabling this feature thru the "force" module parameter to avoid causing permanent hardware damage on such devices.
--- Documentation/admin-guide/laptops/uniwill-laptop.rst | 10 ++++++++++ drivers/platform/x86/uniwill/uniwill-acpi.c | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-)
Documentation/admin-guide/laptops/uniwill-laptop.rst +10 -0
@@ -43,6 +43,11 @@ Support for changing the platform performance mode is currently not implemented. Battery Charging Control ------------------------ +.. warning:: Some devices do not properly implement the charging threshold interface. Forcing + the driver to enable access to said interface on such devices might damage the + battery [1]_. Because of this the driver will not enable said feature even when + using the ``force`` module parameter. + The ``uniwill-laptop`` driver supports controlling the battery charge limit. This happens over the standard ``charge_control_end_threshold`` power supply sysfs attribute. All values between 1 and 100 percent are supported.
@@ -70,3 +75,8 @@ The ``uniwill-laptop`` driver allows to set the configurable TGP for devices wit allow it. See Documentation/ABI/testing/sysfs-driver-uniwill-laptop for details. + +References +========== + +.. [1] https://www.reddit.com/r/XMG_gg/comments/ld9yyf/battery_limit_hidden_function_discovered_on/
drivers/platform/x86/uniwill/uniwill-acpi.c +2 -2
@@ -2507,8 +2507,8 @@ static int __init uniwill_init(void) }if (force) { -/* Assume that the device supports all features */ - device_descriptor.features =UINT_MAX ; +/* Assume that the device supports all features except the charge limit */ + device_descriptor.features =UINT_MAX & ~UNIWILL_FEATURE_BATTERY ;pr_warn ("Enabling potentially unsupported features\n" ); }
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH v3 5/8 platform/x86: uniwill-laptop: Rework FN lock/super key suspend handling
In reply to Armin WolfCurrently the suspend handling for the FN lock and super key enable features saves the whole values of the affected registers instead of the individual feature state. This duplicates the register access logic from the associated sysfs attributes.
Rework the suspend handling to reuse said register access logic and only store the individual feature state as a boolean value.
--- drivers/platform/x86/uniwill/uniwill-acpi.c | 117 ++++++++++++-------- 1 file changed, 73 insertions(+), 44 deletions(-)
drivers/platform/x86/uniwill/uniwill-acpi.c +73 -44
@@ -341,8 +341,8 @@ struct uniwill_data {struct acpi_battery_hook hook;unsigned int last_charge_ctrl;struct mutex battery_lock;/* Protects the list of currently registered batteries */ -unsigned int last_status; -unsigned int last_switch_status; +bool last_fn_lock_state; +bool last_super_key_enable_state;struct mutex super_key_lock;/* Protects the toggling of the super key lock state */ struct list_head batteries;struct mutex led_lock;/* Protects writes to the lightbar registers */
@@ -619,11 +619,22 @@ static const struct regmap_config uniwill_ec_config = { .use_single_write = true, }; +static int uniwill_write_fn_lock (struct uniwill_data *data,bool status) +{ +unsigned int value; + +if (status) + value =FN_LOCK_STATUS ; +else + value =0 ; + +return regmap_update_bits (data->regmap,EC_ADDR_BIOS_OEM ,FN_LOCK_STATUS , value); +} +static ssize_t fn_lock_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct uniwill_data *data =dev_get_drvdata (dev); -unsigned int value;bool enable;int ret;
@@ -631,21 +642,15 @@ static ssize_t fn_lock_store(struct device *dev, struct device_attribute *attr,if (ret <0 )return ret; -if (enable) - value =FN_LOCK_STATUS ; -else - value =0 ; - - ret =regmap_update_bits (data->regmap,EC_ADDR_BIOS_OEM ,FN_LOCK_STATUS , value); + ret =uniwill_write_fn_lock (data, enable);if (ret <0 )return ret;return count; } -static ssize_t fn_lock_show (struct device *dev,struct device_attribute *attr,char *buf) +static int uniwill_read_fn_lock (struct uniwill_data *data,bool *status) { -struct uniwill_data *data =dev_get_drvdata (dev);unsigned int value;int ret;
@@ -653,23 +658,31 @@ static ssize_t fn_lock_show(struct device *dev, struct device_attribute *attr, cif (ret <0 )return ret; -return sysfs_emit (buf,"%d\n" , !!(value &FN_LOCK_STATUS )); -} + *status = !!(value &FN_LOCK_STATUS ); -static DEVICE_ATTR_RW (fn_lock); +return 0 ; +} -static ssize_t super_key_enable_store (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count) +static ssize_t fn_lock_show (struct device *dev,struct device_attribute *attr,char *buf) {struct uniwill_data *data =dev_get_drvdata (dev); -unsigned int value; -bool enable; +bool status;int ret; - ret =kstrtobool (buf, &enable); + ret =uniwill_read_fn_lock (data, &status);if (ret <0 )return ret; +return sysfs_emit (buf,"%d\n" , status); +} + +static DEVICE_ATTR_RW (fn_lock); + +static int uniwill_write_super_key_enable (struct uniwill_data *data,bool status) +{ +unsigned int value; +int ret; +guard (mutex)(&data->super_key_lock); ret =regmap_read (data->regmap,EC_ADDR_SWITCH_STATUS , &value);
@@ -680,20 +693,33 @@ static ssize_t super_key_enable_store(struct device *dev, struct device_attribut* We can only toggle the super key lock, so we return early if the setting * is already in the correct state. */ -if (enable == !(value &SUPER_KEY_LOCK_STATUS )) -return count; +if (status == !(value &SUPER_KEY_LOCK_STATUS )) +return 0 ; + +return regmap_write_bits (data->regmap,EC_ADDR_TRIGGER ,TRIGGER_SUPER_KEY_LOCK , +TRIGGER_SUPER_KEY_LOCK ); +} + +static ssize_t super_key_enable_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count) +{ +struct uniwill_data *data =dev_get_drvdata (dev); +bool enable; +int ret; - ret =regmap_write_bits (data->regmap,EC_ADDR_TRIGGER ,TRIGGER_SUPER_KEY_LOCK , -TRIGGER_SUPER_KEY_LOCK ); + ret =kstrtobool (buf, &enable); +if (ret <0 ) +return ret; + + ret =uniwill_write_super_key_enable (data, enable);if (ret <0 )return ret;return count; } -static ssize_t super_key_enable_show (struct device *dev,struct device_attribute *attr,char *buf) +static int uniwill_read_super_key_enable (struct uniwill_data *data,bool *status) { -struct uniwill_data *data =dev_get_drvdata (dev);unsigned int value;int ret;
@@ -701,7 +727,22 @@ static ssize_t super_key_enable_show(struct device *dev, struct device_attributeif (ret <0 )return ret; -return sysfs_emit (buf,"%d\n" , !(value &SUPER_KEY_LOCK_STATUS )); + *status = !(value &SUPER_KEY_LOCK_STATUS ); + +return 0 ; +} + +static ssize_t super_key_enable_show (struct device *dev,struct device_attribute *attr,char *buf) +{ +struct uniwill_data *data =dev_get_drvdata (dev); +bool status; +int ret; + + ret =uniwill_read_super_key_enable (data, &status); +if (ret <0 ) +return ret; + +return sysfs_emit (buf,"%d\n" , status); }static DEVICE_ATTR_RW (super_key_enable);
@@ -1723,10 +1764,10 @@ static int uniwill_suspend_fn_lock(struct uniwill_data *data)return 0 ;/* -* The EC_ADDR_BIOS_OEM is marked as volatile, so we have to restore it +* EC_ADDR_BIOS_OEM is marked as volatile, so we have to restore it * ourselves. */ -return regmap_read (data->regmap,EC_ADDR_BIOS_OEM , &data->last_status); +return uniwill_read_fn_lock (data, &data->last_fn_lock_state); }static int uniwill_suspend_super_key (struct uniwill_data *data)
@@ -1735,10 +1776,10 @@ static int uniwill_suspend_super_key(struct uniwill_data *data)return 0 ;/* -* The EC_ADDR_SWITCH_STATUS is marked as volatile, so we have to restore it +* EC_ADDR_SWITCH_STATUS is marked as volatile, so we have to restore it * ourselves. */ -return regmap_read (data->regmap,EC_ADDR_SWITCH_STATUS , &data->last_switch_status); +return uniwill_read_super_key_enable (data, &data->last_super_key_enable_state); }static int uniwill_suspend_battery (struct uniwill_data *data)
@@ -1795,27 +1836,15 @@ static int uniwill_resume_fn_lock(struct uniwill_data *data)if (!uniwill_device_supports (data,UNIWILL_FEATURE_FN_LOCK ))return 0 ; -return regmap_update_bits (data->regmap,EC_ADDR_BIOS_OEM ,FN_LOCK_STATUS , - data->last_status); +return uniwill_write_fn_lock (data, data->last_fn_lock_state); }static int uniwill_resume_super_key (struct uniwill_data *data) { -unsigned int value; -int ret; -if (!uniwill_device_supports (data,UNIWILL_FEATURE_SUPER_KEY ))return 0 ; - ret =regmap_read (data->regmap,EC_ADDR_SWITCH_STATUS , &value); -if (ret <0 ) -return ret; - -if ((data->last_switch_status &SUPER_KEY_LOCK_STATUS ) == (value &SUPER_KEY_LOCK_STATUS )) -return 0 ; - -return regmap_write_bits (data->regmap,EC_ADDR_TRIGGER ,TRIGGER_SUPER_KEY_LOCK , -TRIGGER_SUPER_KEY_LOCK ); +return uniwill_write_super_key_enable (data, data->last_super_key_enable_state); }static int uniwill_resume_battery (struct uniwill_data *data)
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH v3 6/8 platform/x86: uniwill-laptop: Mark EC_ADDR_OEM_4 as volatile
In reply to Armin WolfIt turned out that EC_ADDR_OEM_4 also contains bits with a volatile nature. Mark the whole register as volatile to prepare for the usage of said bits. This also means that we now have to save/restore the touchpad toggle state ourself.
--- drivers/platform/x86/uniwill/uniwill-acpi.c | 70 ++++++++++++++++++--- 1 file changed, 60 insertions(+), 10 deletions(-)
drivers/platform/x86/uniwill/uniwill-acpi.c +60 -10
@@ -343,6 +343,7 @@ struct uniwill_data {struct mutex battery_lock;/* Protects the list of currently registered batteries */ bool last_fn_lock_state;bool last_super_key_enable_state; +bool last_touchpad_toggle_enable_state;struct mutex super_key_lock;/* Protects the toggling of the super key lock state */ struct list_head batteries;struct mutex led_lock;/* Protects writes to the lightbar registers */
@@ -598,6 +599,7 @@ static bool uniwill_volatile_reg(struct device *dev, unsigned int reg)case EC_ADDR_PWM_2 :case EC_ADDR_TRIGGER :case EC_ADDR_SWITCH_STATUS : +case EC_ADDR_OEM_4 :case EC_ADDR_CHARGE_CTRL :case EC_ADDR_USB_C_POWER_PRIORITY :return true;
@@ -747,11 +749,22 @@ static ssize_t super_key_enable_show(struct device *dev, struct device_attributestatic DEVICE_ATTR_RW (super_key_enable); +static int uniwill_write_touchpad_toggle_enable (struct uniwill_data *data,bool status) +{ +unsigned int value; + +if (status) + value =0 ; +else + value =TOUCHPAD_TOGGLE_OFF ; + +return regmap_update_bits (data->regmap,EC_ADDR_OEM_4 ,TOUCHPAD_TOGGLE_OFF , value); +} +static ssize_t touchpad_toggle_enable_store (struct device *dev,struct device_attribute *attr,const char *buf,size_t count) {struct uniwill_data *data =dev_get_drvdata (dev); -unsigned int value;bool enable;int ret;
@@ -759,30 +772,39 @@ static ssize_t touchpad_toggle_enable_store(struct device *dev, struct device_atif (ret <0 )return ret; -if (enable) - value =0 ; -else - value =TOUCHPAD_TOGGLE_OFF ; - - ret =regmap_update_bits (data->regmap,EC_ADDR_OEM_4 ,TOUCHPAD_TOGGLE_OFF , value); + ret =uniwill_write_touchpad_toggle_enable (data, enable);if (ret <0 )return ret;return count; } +static int uniwill_read_touchpad_toggle_enable (struct uniwill_data *data,bool *status) +{ +unsigned int value; +int ret; + + ret =regmap_read (data->regmap,EC_ADDR_OEM_4 , &value); +if (ret <0 ) +return ret; + + *status = !(value &TOUCHPAD_TOGGLE_OFF ); + +return 0 ; +} +static ssize_t touchpad_toggle_enable_show (struct device *dev,struct device_attribute *attr,char *buf) {struct uniwill_data *data =dev_get_drvdata (dev); -unsigned int value; +bool status;int ret; - ret =regmap_read (data->regmap,EC_ADDR_OEM_4 , &value); + ret =uniwill_read_touchpad_toggle_enable (data, &status);if (ret <0 )return ret; -return sysfs_emit (buf,"%d\n" , !(value &TOUCHPAD_TOGGLE_OFF )); +return sysfs_emit (buf,"%d\n" , status); }static DEVICE_ATTR_RW (touchpad_toggle_enable);
@@ -1782,6 +1804,18 @@ static int uniwill_suspend_super_key(struct uniwill_data *data)return uniwill_read_super_key_enable (data, &data->last_super_key_enable_state); } +static int uniwill_suspend_touchpad_toggle (struct uniwill_data *data) +{ +if (!uniwill_device_supports (data,UNIWILL_FEATURE_TOUCHPAD_TOGGLE )) +return 0 ; + +/* +* EC_ADDR_OEM_4 is marked as volatile, so we have to restore it +* ourselves. +*/ +return uniwill_read_touchpad_toggle_enable (data, &data->last_touchpad_toggle_enable_state); +} +static int uniwill_suspend_battery (struct uniwill_data *data) {if (!uniwill_device_supports (data,UNIWILL_FEATURE_BATTERY ))
@@ -1817,6 +1851,10 @@ static int uniwill_suspend(struct device *dev)if (ret <0 )return ret; + ret =uniwill_suspend_touchpad_toggle (data); +if (ret <0 ) +return ret; + ret =uniwill_suspend_battery (data);if (ret <0 )return ret;
@@ -1847,6 +1885,14 @@ static int uniwill_resume_super_key(struct uniwill_data *data)return uniwill_write_super_key_enable (data, data->last_super_key_enable_state); } +static int uniwill_resume_touchpad_toggle (struct uniwill_data *data) +{ +if (!uniwill_device_supports (data,UNIWILL_FEATURE_TOUCHPAD_TOGGLE )) +return 0 ; + +return uniwill_write_touchpad_toggle_enable (data, data->last_touchpad_toggle_enable_state); +} +static int uniwill_resume_battery (struct uniwill_data *data) {if (!uniwill_device_supports (data,UNIWILL_FEATURE_BATTERY ))
@@ -1892,6 +1938,10 @@ static int uniwill_resume(struct device *dev)if (ret <0 )return ret; + ret =uniwill_resume_touchpad_toggle (data); +if (ret <0 ) +return ret; + ret =uniwill_resume_battery (data);if (ret <0 )return ret;
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH v3 7/8 platform/x86: uniwill-laptop: Add support for battery charge modes
In reply to Armin WolfMany Uniwill-based devices do not supports the already existing charge limit functionality, but instead support an alternative interface for controlling the battery charge algorithm.
Add support for this interface and update the documentation.
--- .../admin-guide/laptops/uniwill-laptop.rst | 19 +- drivers/platform/x86/uniwill/uniwill-acpi.c | 244 ++++++++++++++---- drivers/platform/x86/uniwill/uniwill-wmi.c | 5 +- 3 files changed, 215 insertions(+), 53 deletions(-)
Documentation/admin-guide/laptops/uniwill-laptop.rst +14 -5
@@ -46,11 +46,20 @@ Battery Charging Control .. warning:: Some devices do not properly implement the charging threshold interface. Forcing the driver to enable access to said interface on such devices might damage the battery [1]_. Because of this the driver will not enable said feature even when - using the ``force`` module parameter. - -The ``uniwill-laptop`` driver supports controlling the battery charge limit. This happens over -the standard ``charge_control_end_threshold`` power supply sysfs attribute. All values -between 1 and 100 percent are supported. + using the ``force`` module parameter. The charging profile interface will be + available instead. + +The ``uniwill-laptop`` driver supports controlling the battery charge limit. This either happens +over the standard ``charge_control_end_threshold`` or ``charge_types`` power supply sysfs attribute, +depending on the device. When using the ``charge_control_end_threshold`` sysfs attribute, all values +between 1 and 100 percent are supported. When using the ``charge_types`` sysfs attribute, the driver +supports switching between the ``Standard``, ``Trickle`` and ``Long Life`` profiles. + +Keep in mind that when using the ``charge_types`` sysfs attribute, the EC firmware will hide the +true charging status of the battery from the operating system, potentially misleading users into +thinking that the charging profile does not work. Checking the ``current_now`` sysfs attribute +tells you the true charging status of the battery even when using the ``charge_types`` sysfs +attribute (0 means that the battery is currently not charging). Additionally the driver signals the presence of battery charging issues through the standard ``health`` power supply sysfs attribute.
drivers/platform/x86/uniwill/uniwill-acpi.c +197 -47
384 lines not on this page · raw message
drivers/platform/x86/uniwill/uniwill-wmi.c +4 -1
@@ -48,6 +48,7 @@ int devm_uniwill_wmi_register_notifier(struct device *dev, struct notifier_blockstatic void uniwill_wmi_notify (struct wmi_device *wdev,union acpi_object *obj) {u32 value; +int ret;if (obj->type !=ACPI_TYPE_INTEGER )return ;
@@ -56,7 +57,9 @@ static void uniwill_wmi_notify(struct wmi_device *wdev, union acpi_object *obj)dev_dbg (&wdev->dev,"Received WMI event %u\n" , value); -blocking_notifier_call_chain (&uniwill_wmi_chain_head, value,NULL ); + ret =blocking_notifier_call_chain (&uniwill_wmi_chain_head, value,NULL ); +if (notifier_to_errno (ret) <0 ) +dev_err (&wdev->dev,"Failed to handle event %u\n" , value); }/*
Signature · 1 line
2.39.5
Armin Wolf
maintainerPATCH v3 8/8 platform/x86: uniwill-laptop: Enable battery charge modes on supported devices
In reply to Armin WolfFrom: Werner Sembach <[email protected]>
Enable battery charge modes on supported TUXEDO devices by adding the feature bit to the respective device descriptors.
--- drivers/platform/x86/uniwill/uniwill-acpi.c | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/platform/x86/uniwill/uniwill-acpi.c +7 -0
@@ -2168,6 +2168,7 @@ static struct uniwill_device_descriptor lapkc71f_descriptor __initdata = {static struct uniwill_device_descriptor tux_featureset_1_descriptor__initdata = { .features =UNIWILL_FEATURE_FN_LOCK |UNIWILL_FEATURE_SUPER_KEY | +UNIWILL_FEATURE_BATTERY_CHARGE_MODES |UNIWILL_FEATURE_CPU_TEMP |UNIWILL_FEATURE_PRIMARY_FAN | UNIWILL_FEATURE_SECONDARY_FAN |
@@ -2177,6 +2178,7 @@ static struct uniwill_device_descriptor tux_featureset_1_descriptor __initdata =static struct uniwill_device_descriptor tux_featureset_1_nvidia_descriptor__initdata = { .features =UNIWILL_FEATURE_FN_LOCK |UNIWILL_FEATURE_SUPER_KEY | +UNIWILL_FEATURE_BATTERY_CHARGE_MODES |UNIWILL_FEATURE_CPU_TEMP |UNIWILL_FEATURE_GPU_TEMP | UNIWILL_FEATURE_PRIMARY_FAN |
@@ -2187,6 +2189,7 @@ static struct uniwill_device_descriptor tux_featureset_1_nvidia_descriptor __inistatic struct uniwill_device_descriptor tux_featureset_2_nvidia_descriptor__initdata = { .features =UNIWILL_FEATURE_FN_LOCK |UNIWILL_FEATURE_SUPER_KEY | +UNIWILL_FEATURE_BATTERY_CHARGE_MODES |UNIWILL_FEATURE_CPU_TEMP |UNIWILL_FEATURE_GPU_TEMP | UNIWILL_FEATURE_PRIMARY_FAN |
@@ -2198,6 +2201,7 @@ static struct uniwill_device_descriptor tux_featureset_2_nvidia_descriptor __inistatic struct uniwill_device_descriptor tux_featureset_3_descriptor__initdata = { .features =UNIWILL_FEATURE_FN_LOCK |UNIWILL_FEATURE_SUPER_KEY | +UNIWILL_FEATURE_BATTERY_CHARGE_MODES |UNIWILL_FEATURE_CPU_TEMP |UNIWILL_FEATURE_PRIMARY_FAN |UNIWILL_FEATURE_SECONDARY_FAN ,
@@ -2206,6 +2210,7 @@ static struct uniwill_device_descriptor tux_featureset_3_descriptor __initdata =static struct uniwill_device_descriptor tux_featureset_3_nvidia_descriptor__initdata = { .features =UNIWILL_FEATURE_FN_LOCK |UNIWILL_FEATURE_SUPER_KEY | +UNIWILL_FEATURE_BATTERY_CHARGE_MODES |UNIWILL_FEATURE_CPU_TEMP |UNIWILL_FEATURE_GPU_TEMP | UNIWILL_FEATURE_PRIMARY_FAN |
@@ -2231,6 +2236,7 @@ static int phxtxx1_probe(struct uniwill_data *data)static struct uniwill_device_descriptor phxtxx1_descriptor__initdata = { .features =UNIWILL_FEATURE_FN_LOCK |UNIWILL_FEATURE_SUPER_KEY | +UNIWILL_FEATURE_BATTERY_CHARGE_MODES |UNIWILL_FEATURE_CPU_TEMP |UNIWILL_FEATURE_PRIMARY_FAN |UNIWILL_FEATURE_USB_C_POWER_PRIORITY ,
@@ -2256,6 +2262,7 @@ static int phxarx1_phxaqf1_probe(struct uniwill_data *data)static struct uniwill_device_descriptor phxarx1_phxaqf1_descriptor__initdata = { .features =UNIWILL_FEATURE_FN_LOCK |UNIWILL_FEATURE_SUPER_KEY | +UNIWILL_FEATURE_BATTERY_CHARGE_MODES |UNIWILL_FEATURE_CPU_TEMP |UNIWILL_FEATURE_PRIMARY_FAN | UNIWILL_FEATURE_SECONDARY_FAN |
Signature · 1 line
2.39.5
Ilpo Järvinen
maintainerQuoted 10 lines · Armin Wolf
This patch series contains various charging-related improvements for the uniwill-laptop driver. The first two patches fix some minor issues inside the charging threshold code, while the third patch fixes an issue inside the module initialization code. The next two patches contain some preparations for the main patch. Said patch introduces support for controlling the charging modes available on many Uniwill-based devices not sold by Intel. The last patch whitelists most Tuxedo devices for using the battery charge modes.
[...]
Thank you for your contribution, it has been applied to my local review-ilpo-fixes branch. Note it will show up in the public platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my local branch there, which might take a while.
The list of commits applied:
[1/8] platform/x86: uniwill-laptop: Properly initialize charging threshold
commit: c12cc42dadd85dea210d5699d4f21def827382eb
[2/8] platform/x86: uniwill-laptop: Accept charging threshold of 0
commit: c16a4823cc60a32b891f7a148bb30c0f51d12cf4
[3/8] platform/x86: uniwill-laptop: Fix behavior of "force" module param
commit: fb4b67c44557cb4cbb15900083d4e1af22320339
[4/8] platform/x86: uniwill-laptop: Do not enable the charging limit even when forced
commit: 26cbe119f99c86dcb4a0136d2bc73c0c716d80e4[5/8] platform/x86: uniwill-laptop: Rework FN lock/super key suspend handling
(no commit info)
[6/8] platform/x86: uniwill-laptop: Mark EC_ADDR_OEM_4 as volatile
(no commit info)
[7/8] platform/x86: uniwill-laptop: Add support for battery charge modes
(no commit info)
[8/8] platform/x86: uniwill-laptop: Enable battery charge modes on supported devices
(no commit info)
--
i.
Armin Wolf
maintainerAm 19.05.26 um 16:45 schrieb Ilpo Järvinen:
Quoted 11 lines · Armin Wolf
Quoted 10 lines
This patch series contains various charging-related improvements for the uniwill-laptop driver. The first two patches fix some minor issues inside the charging threshold code, while the third patch fixes an issue inside the module initialization code. The next two patches contain some preparations for the main patch. Said patch introduces support for controlling the charging modes available on many Uniwill-based devices not sold by Intel. The last patch whitelists most Tuxedo devices for using the battery charge modes.
Quoted 6 lines
Quoted 1 line
[...]
Thank you for your contribution, it has been applied to my local review-ilpo-fixes branch. Note it will show up in the public platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my local branch there, which might take a while.
Thank you :)
Is there a special reason why only the first four commits are actually available on the fixes branch?
Thanks,
Armin Wolf
Quoted 23 lines
The list of commits applied:
[1/8] platform/x86: uniwill-laptop: Properly initialize charging thresholdcommit: c12cc42dadd85dea210d5699d4f21def827382eb [2/8] platform/x86: uniwill-laptop: Accept charging threshold of 0 commit: c16a4823cc60a32b891f7a148bb30c0f51d12cf4 [3/8] platform/x86: uniwill-laptop: Fix behavior of "force" module param commit: fb4b67c44557cb4cbb15900083d4e1af22320339 [4/8] platform/x86: uniwill-laptop: Do not enable the charging limit even when forced commit: 26cbe119f99c86dcb4a0136d2bc73c0c716d80e4[5/8] platform/x86: uniwill-laptop: Rework FN lock/super key suspend handling
(no commit info)
[6/8] platform/x86: uniwill-laptop: MarkEC_ADDR_OEM_4as volatile
(no commit info)
[7/8] platform/x86: uniwill-laptop: Add support for battery charge modes
(no commit info)
[8/8] platform/x86: uniwill-laptop: Enable battery charge modes on supported devices
(no commit info)--
i.
Ilpo Järvinen
maintainerQuoted 20 lines · Armin Wolf
Am 19.05.26 um 16:45 schrieb Ilpo Järvinen:
Quoted 11 lines · Armin Wolf
Quoted 10 lines
This patch series contains various charging-related improvements for the uniwill-laptop driver. The first two patches fix some minor issues inside the charging threshold code, while the third patch fixes an issue inside the module initialization code. The next two patches contain some preparations for the main patch. Said patch introduces support for controlling the charging modes available on many Uniwill-based devices not sold by Intel. The last patch whitelists most Tuxedo devices for using the battery charge modes.
Quoted 6 lines
Quoted 1 line
[...]
Thank you for your contribution, it has been applied to my local review-ilpo-fixes branch. Note it will show up in the public platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my local branch there, which might take a while.
Quoted 5 lines
Thank you :)
Is there a special reason why only the first four commits are actually available
on the fixes branch?
Yes, there is.
I was planning on merging the rest through for-next as I didn't categorize them as important fixes. I'll get to it some time this week.
--
i.
Quoted 24 lines
Thanks,
Armin WolfQuoted 21 lines
The list of commits applied:
[1/8] platform/x86: uniwill-laptop: Properly initialize charging thresholdcommit: c12cc42dadd85dea210d5699d4f21def827382eb [2/8] platform/x86: uniwill-laptop: Accept charging threshold of 0 commit: c16a4823cc60a32b891f7a148bb30c0f51d12cf4 [3/8] platform/x86: uniwill-laptop: Fix behavior of "force" module param commit: fb4b67c44557cb4cbb15900083d4e1af22320339 [4/8] platform/x86: uniwill-laptop: Do not enable the charging limit even when forced commit: 26cbe119f99c86dcb4a0136d2bc73c0c716d80e4[5/8] platform/x86: uniwill-laptop: Rework FN lock/super key suspend handling
(no commit info)
[6/8] platform/x86: uniwill-laptop: MarkEC_ADDR_OEM_4as volatile
(no commit info)
[7/8] platform/x86: uniwill-laptop: Add support for battery charge modes
(no commit info)
[8/8] platform/x86: uniwill-laptop: Enable battery charge modes on supported devices
(no commit info)
Ilpo Järvinen
maintainerQuoted 10 lines · Armin Wolf
This patch series contains various charging-related improvements for the uniwill-laptop driver. The first two patches fix some minor issues inside the charging threshold code, while the third patch fixes an issue inside the module initialization code. The next two patches contain some preparations for the main patch. Said patch introduces support for controlling the charging modes available on many Uniwill-based devices not sold by Intel. The last patch whitelists most Tuxedo devices for using the battery charge modes.
[...]
Thank you for your contribution, it has been applied to my local review-ilpo-next branch. Note it will show up in the public platform-drivers-x86/review-ilpo-next branch only once I've pushed my local branch there, which might take a while.
The list of commits applied:
[1/8] platform/x86: uniwill-laptop: Properly initialize charging threshold
(no commit info)
[2/8] platform/x86: uniwill-laptop: Accept charging threshold of 0
(no commit info)
[3/8] platform/x86: uniwill-laptop: Fix behavior of "force" module param
(no commit info)
[4/8] platform/x86: uniwill-laptop: Do not enable the charging limit even when forced
(no commit info)
[5/8] platform/x86: uniwill-laptop: Rework FN lock/super key suspend handling
commit: 4d86e384c164abeee17da09fe6cd24a37973e628
[6/8] platform/x86: uniwill-laptop: Mark EC_ADDR_OEM_4 as volatile
commit: f7bcba269143230923e40cd88b9169ed27f178ae
[7/8] platform/x86: uniwill-laptop: Add support for battery charge modes
commit: 73fa957a05e9fd43f204225497d4c98d7c0d0490
[8/8] platform/x86: uniwill-laptop: Enable battery charge modes on supported devices
commit: 2c5d91f35d0d564c8b4c062b67526e0d2d27fae9--
i.