platform/x86: Battery charge mode in toshiba_acpi (internals)
authorArvid Norlander <lkml@vorpal.se>
Fri, 2 Sep 2022 18:00:35 +0000 (20:00 +0200)
committerHans de Goede <hdegoede@redhat.com>
Fri, 9 Sep 2022 19:58:16 +0000 (21:58 +0200)
commit89655fbb396aff20bd5247fa6b13a689e2f10f9c
tree4ff387f530c3682b42cca22139d7d1680ec5fea2
parentc727ba4cd95a12d8e43b02963d3ba4daddbd100c
platform/x86: Battery charge mode in toshiba_acpi (internals)

This commit adds the internal functions to control the Toshiba laptop.

Unlike for example ThinkPads where this control is granular here it is
just off/on. When off it charges to 100%. When on it charges to about 80%.

Controlling this setting is done via HCI register 0x00ba. Setting to value
1 will result in limiting the charing to 80% of the battery capacity,
while setting it to 0 will allow charging to 100%.

Reading the current state is a bit weird, and needs a 1 set in the last
position of the query for whatever reason. In addition, the read may
return 0x8d20 (Data not available) rarely, so a retry mechanism is needed.

According to the Windows program used to control the feature the setting
will not take effect until the battery has been discharged to around 50%.
However, in my testing it takes effect as soon as the charge drops below
80%. On Windows Toshiba branded this feature as "Eco charging".

Signed-off-by: Arvid Norlander <lkml@vorpal.se>
Link: https://lore.kernel.org/r/20220902180037.1728546-2-lkml@vorpal.se
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
drivers/platform/x86/toshiba_acpi.c