platform/x86:dell-laptop: Add knobs to change battery charge settings
authorAndres Salomon <dilinger@queued.net>
Tue, 20 Aug 2024 07:30:05 +0000 (03:30 -0400)
committerHans de Goede <hdegoede@redhat.com>
Wed, 4 Sep 2024 12:45:25 +0000 (14:45 +0200)
commitab58016c68cc5b8c3622e38b7db64994e4833d9f
tree73b21dd21ec0587d56577d77dc6da43e337fa4c4
parentc34068c8edad268bbd83feb39ef1b8b47b571dd6
platform/x86:dell-laptop: Add knobs to change battery charge settings

The Dell BIOS allows you to set custom charging modes, which is useful
in particular for extending battery life. This adds support for tweaking
those various settings from Linux via sysfs knobs. One might, for
example, have their laptop plugged into power at their desk the vast
majority of the time and choose fairly aggressive battery-saving
settings (eg, only charging once the battery drops below 50% and only
charging up to 80%). When leaving for a trip, it would be more useful
to instead switch to a standard charging mode (top off at 100%, charge
any time power is available). Rebooting into the BIOS to change the
charging mode settings is a hassle.

For the Custom charging type mode, we reuse the common
charge_control_{start,end}_threshold sysfs power_supply entries. The
BIOS also has a bunch of other charging modes (with varying levels of
usefulness), so this also adds a 'charge_type' sysfs entry that maps the
standard values to Dell-specific ones.

This work is based on a patch by Perry Yuan <perry_yuan@dell.com> and
Limonciello Mario <Mario_Limonciello@Dell.com> submitted back in 2020.

Hans de Goede:
s/charge_type/charge_types/ since charge_types_show() used the new
charge_types power-supply property output format.

Signed-off-by: Andres Salomon <dilinger@queued.net>
Reviewed-by: Pali Rohár <pali@kernel.org>
Link: https://lore.kernel.org/r/20240820033005.09e03af1@5400
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/dell/Kconfig
drivers/platform/x86/dell/dell-laptop.c
drivers/platform/x86/dell/dell-smbios.h