All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 3/3] thinkpad_acpi: document the battery controls
@ 2018-05-13 15:30 Ognjen Galic
  2018-05-14 12:03 ` Henrique de Moraes Holschuh
  0 siblings, 1 reply; 3+ messages in thread
From: Ognjen Galic @ 2018-05-13 15:30 UTC (permalink / raw)
  To: Andy Shevchenko, Rafael J. Wysocki, Ognjen Galić,
	Rafael J. Wysocki, Len Brown, Robert Moore,
	ACPI Devel Maling List, devel-E0kO6a4B6psdnm+yROfE0A,
	Darren Hart, Andy Shevchenko, Henrique de Moraes Holschuh,
	Sebastian Reichel, Platform Driver,
	ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Linux PM,
	Christoph Böhmwalder, Kevin Locke

This documents the new battery controls and wear leveling support
for Lenovo ThinkPad laptops.

Signed-off-by: Ognjen Galic <smclt30p@gmail.com>
---
 Documentation/laptops/thinkpad-acpi.txt | 70 ++++++++++++++++++++++++-
 1 file changed, 69 insertions(+), 1 deletion(-)

diff --git a/Documentation/laptops/thinkpad-acpi.txt b/Documentation/laptops/thinkpad-acpi.txt
index 00b6dfed..3491d46f 100644
--- a/Documentation/laptops/thinkpad-acpi.txt
+++ b/Documentation/laptops/thinkpad-acpi.txt
@@ -1,6 +1,6 @@
 		     ThinkPad ACPI Extras Driver
 
-                            Version 0.25
+                            Version 0.27
                         October 16th,  2013
 
                Borislav Deianov <borislav@users.sf.net>
@@ -46,6 +46,9 @@ detailed description):
 	- Fan control and monitoring: fan speed, fan enable/disable
 	- WAN enable and disable
 	- UWB enable and disable
+	- Battery wear control (battery start and stop threshold)
+	- Battery inhibit charge
+	- Battery force discharge
 
 A compatibility table by model and feature is maintained on the web
 site, http://ibm-acpi.sf.net/. I appreciate any success or failure
@@ -1483,3 +1486,68 @@ Sysfs interface changelog:
 0x030000:	Thermal and fan sysfs attributes were moved to the hwmon
 		device instead of being attached to the backing platform
 		device.
+
+
+Battery wear control (charge and stop thresholds)
+--------------------------------------------------
+
+Since Linux 4.17 tpacpi supports setting of charge start and stop thresholds on certain
+Lenovo ThinkPad laptops. This feature is exposed via a new API from the ACPI battery driver
+also new in Linux 4.17.
+
+The new battery API allows developers to extended the standard attributes offered by the
+generic ACPI battery driver and add custom attributes from other drivers. thinkpad_acpi
+leverages this API and exposes a few custom attributes for wear control of the battery.
+
+Wear control is designed to stop the charging of the battery at a certain threshold and thus
+stop the cell from wearing out from constant charge cycles. So if you put the threshold at
+50%, the charge will only charge the battery when it is below 50% and it will stop at 50%.
+
+A lower level is also exposed, thus creating a charger "dead zone", a zone where the charger does
+nothing and the battery is in idle as if it was removed from the Thinkpad.
+
+For example, this is what happens when you set the values to 40% and 65%:
+
+            ┌      Discharging      ┐
+	    │                       │
+[0%--------40%       65%-----------100%] Battery 1
+ │                    │
+ └      Charging      ┘
+
+When plugged into AC and if the percentage is between 40% and 100% the battery is in idle.
+
+The attributes:
+---------------
+
+/sys/class/power_supply/BATx/charge_start_threshold [int, <0, >99]
+
+This sets the lower charge stop threshold for the battery. Its a integer and valid values are from
+0% to 99%.
+
+/sys/class/power_supply/BATx/charge_stop_threshold [int, <1, >100]
+
+This sets the upper charge threshold for the battery. Its a integer and the value values are from
+1% to 100%.
+
+Setting the lower limit to 0% and the upper limit to 100% disables the wear leveling control feature.
+
+
+Battery charge inhibiting
+--------------------------
+
+Preventing the battery from charging is also available as a manual override over the settings. Its exposed via
+the generic ACPI driver:
+
+/sys/class/power_supply/BATx/inhibit_charge [int, 1, 0]
+
+Setting it to 1 prevents the battery from charging.
+
+Battery force discharging
+--------------------------
+
+There is also support for AC overriding. This means that you can force the battery to discharge
+even when AC is attached. This is also exposed via the generic ACPI driver:
+
+/sys/class/power_supply/BATx/force_discharge [int, 1, 0]
+
+Setting it to 1 forces the battery to discharge on AC.
-- 
2.17.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
ibm-acpi-devel mailing list
ibm-acpi-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ibm-acpi-devel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 3/3] thinkpad_acpi: document the battery controls
  2018-05-13 15:30 [PATCH 3/3] thinkpad_acpi: document the battery controls Ognjen Galic
@ 2018-05-14 12:03 ` Henrique de Moraes Holschuh
       [not found]   ` <20180514120302.knhohskga6x6ji3s-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Henrique de Moraes Holschuh @ 2018-05-14 12:03 UTC (permalink / raw)
  To: Ognjen Galic
  Cc: Platform Driver, Rafael J. Wysocki, Henrique de Moraes Holschuh,
	Linux PM, Rafael J. Wysocki, Robert Moore, Sebastian Reichel,
	ACPI Devel Maling List, Andy Shevchenko,
	Christoph Böhmwalder, Kevin Locke, Darren Hart,
	devel-E0kO6a4B6psdnm+yROfE0A,
	ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko,
	Len Brown

On Sun, 13 May 2018, Ognjen Galic wrote:
> +Battery force discharging
> +--------------------------
> +
> +There is also support for AC overriding. This means that you can force the battery to discharge
> +even when AC is attached. This is also exposed via the generic ACPI driver:
> +
> +/sys/class/power_supply/BATx/force_discharge [int, 1, 0]
> +
> +Setting it to 1 forces the battery to discharge on AC.

This is used to run a battery "fuel gauge" callibration cycle.

One has to set the limits to 0,100 (i.e. disable the anti-wear
limiters), trigger a force_discharge, and wait until it discharges to
zero.  At that point, the EC is supposed to reset the force_discharge
bit by itself, and then you have to wait the battery to charge back to
full.

(and at least on older thinkpads, where you had to use SMAPI to do the
above, it didn't need much help from the operating system.  Once a
couple years you could just set force_discharge on both batteries (with
the thing connected to AC), shutdown the operating system, and go to
sleep.  By morning, it would be fully charged and both gauges
calibrated, still powered off, ready to go :P ).

-- 
  Henrique Holschuh

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 3/3] thinkpad_acpi: document the battery controls
       [not found]   ` <20180514120302.knhohskga6x6ji3s-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
@ 2018-05-14 13:41     ` Ognjen Galić
  0 siblings, 0 replies; 3+ messages in thread
From: Ognjen Galić @ 2018-05-14 13:41 UTC (permalink / raw)
  To: Henrique de Moraes Holschuh
  Cc: Platform Driver, Rafael J. Wysocki, Henrique de Moraes Holschuh,
	Linux PM, Rafael J. Wysocki, Robert Moore, Sebastian Reichel,
	ACPI Devel Maling List, Andy Shevchenko,
	Christoph Böhmwalder, Kevin Locke, Darren Hart,
	devel-E0kO6a4B6psdnm+yROfE0A,
	ibm-acpi-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f, Andy Shevchenko,
	Len Brown

On Mon, May 14, 2018 at 09:03:02AM -0300, Henrique de Moraes Holschuh wrote:
> On Sun, 13 May 2018, Ognjen Galic wrote:
> > +Battery force discharging
> > +--------------------------
> > +
> > +There is also support for AC overriding. This means that you can force the battery to discharge
> > +even when AC is attached. This is also exposed via the generic ACPI driver:
> > +
> > +/sys/class/power_supply/BATx/force_discharge [int, 1, 0]
> > +
> > +Setting it to 1 forces the battery to discharge on AC.
> 
> This is used to run a battery "fuel gauge" callibration cycle.
> 
> One has to set the limits to 0,100 (i.e. disable the anti-wear
> limiters), trigger a force_discharge, and wait until it discharges to
> zero.  At that point, the EC is supposed to reset the force_discharge
> bit by itself, and then you have to wait the battery to charge back to
> full.

That's the intended use case for this patches via an upcoming program I
am writing for userspace.

> 
> (and at least on older thinkpads, where you had to use SMAPI to do the
> above, it didn't need much help from the operating system.  Once a
> couple years you could just set force_discharge on both batteries (with
> the thing connected to AC), shutdown the operating system, and go to
> sleep.  By morning, it would be fully charged and both gauges
> calibrated, still powered off, ready to go :P ).
> 
> -- 
>   Henrique Holschuh

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-05-14 13:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-13 15:30 [PATCH 3/3] thinkpad_acpi: document the battery controls Ognjen Galic
2018-05-14 12:03 ` Henrique de Moraes Holschuh
     [not found]   ` <20180514120302.knhohskga6x6ji3s-ZGHd14iZgfaRjzvQDGKj+xxZW9W5cXbT@public.gmane.org>
2018-05-14 13:41     ` Ognjen Galić

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.