• Andres Salomon's avatar
    platform/x86:dell-laptop: Add knobs to change battery charge settings · ab58016c
    Andres Salomon authored
    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: default avatarAndres Salomon <dilinger@queued.net>
    Reviewed-by: default avatarPali Rohár <pali@kernel.org>
    Link: https://lore.kernel.org/r/20240820033005.09e03af1@5400Reviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    ab58016c
dell-laptop.c 66.7 KB