On Thu, 2024-04-25 at 21:54 -0400, Malte Dehling wrote: > Hi, > > I've added some things to the thinkpad acpi driver to allow modifying > battery charging behavior: keep charge within a range, force > discharge, > disable charging on AC. I think something like this would be good to > have in NetBSD, but not necessarily how I implemented it. So this is > mainly a request for discussion :) > > I've attached patches for reference and in case anyone wants to use > them > -- tested on my old X230 and W530 but based on my reading and > studying > acpidumps the same should work on most newer models. > > On Linux and FreeBSD people just make acpi calls from userspace it > seems, usually hidden away in tools like TLP. > > OpenBSD recently added sysctls hw.battery.{chargestart,chargestop, > chargemode} to provide this functionality (supported currently only > by > the thinkpad and apple silicon drivers.) The approach is simple, but > not as flexible as I would like: > - It doesn't let you control charging behavior of individual > batteries. > - There are reasons to want to control charge_inhibit and > force_discharge modes separately. > > Finally, a question: The ACPI standard has for a long time had > (optional) _BMD & _BMC methods to control charging of control method > batteries. Has anyone seen these implemented in the wild? > > Cheers,
Hi Malte, I applied your patch to NetBSD-10.0_STABLE successfully and tested the kernel on a thinkpad T420s. I set charge_stop=85 and charge_start=15. With the laptop on mains it stopped charging the battery at the 85% value. I switched force_discharge=1 and ran a build release to put some load on, the battery level dropped down and sailed past 15% towards zero - the thinkpad alarm alerted me and a quick unplug/replug of the power lead started recharging it. I had vaguely hoped that as the 15% level was breached the charging of the battery might restart automatically, i.e force_discharge would reset to zero :-) I think this is a really useful feature as there seems to be a view that charging li-ion cells to 100% reduces their life and it is best to avoid discharging them below 15%. These figures are what Samsung recommend on mobiles phones. Cheers, Dave