Implement battery management sysctl. This will provide a set of sysctls
authorkettenis <kettenis@openbsd.org>
Wed, 17 May 2023 22:12:51 +0000 (22:12 +0000)
committerkettenis <kettenis@openbsd.org>
Wed, 17 May 2023 22:12:51 +0000 (22:12 +0000)
commit22acc011e208b6ae1e8e1d6e3c143e8ae968e310
tree09d90405766302ee73ec76d86d099c21085841fd
parentaf684d81575045d75197f2cbc21289eb3aad6405
Implement battery management sysctl.  This will provide a set of sysctls
to control the charging of laptop batteries:

* hw.battery.chargemode (int)

  -1: force discharge
   0: inhibit charge
   1: auto

In auto mode charging may be controlled by:

* hw.battery.chargestop (int)

  Percentage (0-100) of last full capacity at which the battery should
  stop charging.

* hw.battery.chargestart (int)

  Percentage (0-100) of last full capacity at which the battery should
  start charging.

The idea is that with

  hw.battery.chargemode=1
  hw.battery.chargestop=80
  hw.battery.chargestart=75

the battery would be kept charged within the range between 75% and 80%.

Allowable settings and some details of the behavior may differ between
hardware implementations.

Committing this early to easy testing of further diffs that implement this
functionality in acpithinkpad(4) and aplsmc(4).

ok kn@
sbin/sysctl/sysctl.c
sys/kern/kern_sysctl.c
sys/sys/sysctl.h