Bug 216176 - ideapad-laptop doesn't expose rapid charge
Summary: ideapad-laptop doesn't expose rapid charge
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Platform_x86 (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_platform_x86@kernel-bugs.osdl.org
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-06-26 15:56 UTC by tinozzo123
Modified: 2024-02-06 14:34 UTC (History)
4 users (show)

See Also:
Kernel Version: 5.18.5
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description tinozzo123 2022-06-26 15:56:42 UTC
Lenovo IdeaPad laptops support a feature named "Rapid Charge", normally usable on Windows via Lenovo Vantage. However, this feature isn't exposed on idepad-laptop.c.
According to the Arch Wiki, this feature is still usable via ACPI commands:

To enable:
# echo '\_SB.PCI0.LPC0.EC0.VPC0.SBMC 0x07' > /proc/acpi/call

To disable:
# echo '\_SB.PCI0.LPC0.EC0.VPC0.SBMC 0x08' > /proc/acpi/call

To check, the wiki uses different commands for different laptops. Three of them are (on all of them, 0x0 stands for off and 0x1 stands for on):
Lenovo IdeaPad 5 14are05
# echo '\_SB.PCI0.LPC0.EC0.FCGM' | tee /proc/acpi/call
# cat /proc/acpi/call; printf '\n'

Lenovo IdeaPad 5 15are05
# echo '\_SB.PCI0.LPC0.EC0.QCHO' > /proc/acpi/call
# cat /proc/acpi/call; printf '\n'

Lenovo IdeaPad Flex 5 14alc05
# echo '\_SB.PCI0.LPC0.EC0.QKCM' | tee /proc/acpi/call
# cat /proc/acpi/call | cut -d '' -f1

Small note, on Lenovo Vantage enabling Rapid Charge disables Battery Conservation automatically, and enabling Battery Conservation disables Rapid Charge automatically. The ACPI commands don't have this limitation.
Comment 1 Hans de Goede 2022-06-26 19:34:39 UTC
Link to arch wiki page?
Comment 3 Barnabás Pőcze 2022-06-27 13:49:03 UTC
I have a device that supports this (YOGA 520-14IKB), so I think I can prepare a patch until the next merge window. The biggest question - I think - is where should this be exposed? Another attribute on the platform device, or maybe on the battery power supply device somehow?
Comment 4 tinozzo123 2022-06-27 19:47:59 UTC
My take on where it should be exposed.

Something related to the battery, which are charge thresholds, are supported in multiple laptop brands (Lenovo ThinkPad, ASUS, System76...) and are thus are exposed in the battery power supply device (/sys/class/power_supply/BAT0/charge_control_{start,end}_threshold)

conservation_mode is basically an equivalent with a fixed value (60%) that is exclusive to IdeaPads, and it's exposed in the platform device (/sys/bus/platform/drivers/ideapad_acpi/VPC2004:00/conservation_mode).

I guess that my the verdict is that, because rapid charging is supported on multiple laptop series (both ThinkPads and IdeaPads, which use different drivers, and maybe there are more brands, though I couldn't find anything on Google), so it should be exposed in the battery power supply device.
Comment 5 Hans de Goede 2022-06-29 19:49:22 UTC
I agree that this should be a new userspace API under:
/sys/class/power_supply/<BAT-name>/<some-sysfs-attribute>

The best way to go about this is to first propose a new uAPI for this in the form of a patch to:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/sysfs-class-power

I think the best thing to do here is to add this as a 4th option to the /sys/class/power_supply/<supply_name>/charge_behaviour attribute:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/ABI/testing/sysfs-class-power#n462

All the modes there are exclusive (so only mode can be active at a time) and I think it would make sense to add a fast-charge option for this "rapid-charge" mode.

Note for the driver patch that there are some helpers for implementing the charge_behaviour attribute:

ssize_t power_supply_charge_behaviour_show(struct device *dev,
                                           unsigned int available_behaviours,
                                           enum power_supply_charge_behaviour behaviour,
                                           char *buf);

int power_supply_charge_behaviour_parse(unsigned int available_behaviours, const char *buf);

Notice the "unsigned int available_behaviours" this is a bit mask of supported modes from the enum power_supply_charge_behaviour.
Comment 6 Barnabás Pőcze 2022-06-29 20:04:41 UTC
My concern is that there is already a "charge_type" attribute which can take the "Fast" value among others: Unknown, N/A, Trickle, Fast, Standard, Adaptive, Custom, Long Life, Bypass.

It might even make sense to wire up the so-called "conservation mode" to this attribute as well ("Long Life") .
Comment 7 Hans de Goede 2022-06-29 21:10:37 UTC
(In reply to Barnabás Pőcze from comment #6)
> My concern is that there is already a "charge_type" attribute which can take
> the "Fast" value among others: Unknown, N/A, Trickle, Fast, Standard,
> Adaptive, Custom, Long Life, Bypass.
> 
> It might even make sense to wire up the so-called "conservation mode" to
> this attribute as well ("Long Life") .

That is a good point, although AFAIK that is more intended for charger-type power_supply devices then for batteries...

Either way I think it is best to just write a proposal in the form of a Documentation patch to Documentation/ABI/testing/sysfs-class-power and then discuss this further on the mailinglist.
Comment 8 Hans de Goede 2022-09-19 09:07:31 UTC
A quick update on the conversation-mode thing. Since the conversation-mode in essence sets a charge star/end threshold it really should just use that interface. This is what has been done for the similar eco mode on toshiba laptops:

https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?id=18ef1bb093ab1e0a74d146cbf4a9d132d01374d8
https://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86.git/commit/?id=8ef5db9eb084f6212345a7b09355c78ce05f71e2

Note there this is setting the end-threshold, not sure what this does in ideapad-laptop.

Also we may want to add some extension to the start/end threshold API to query valid values, so that we can e.g. do:

# cat /sys/class/power_supply/BAT1/charge_control_end_threshold_supported_values
80,100

In the Toshiba case.
Comment 9 Swapnil Devesh 2023-07-20 21:16:43 UTC
Is there any progress on this ? I think exposing rapid change in ideapad-laptop makes sense similar to conservation_mode until a better api is implemented.
Comment 10 Amir Khayatzadeh 2024-02-06 14:34:23 UTC
Any news on this? please if you can do anything let us know. thanks!

Note You need to log in before you can comment on or make changes to this bug.