From patchwork Sun May 13 15:30:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ognjen Galic X-Patchwork-Id: 10396271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0ED8060236 for ; Sun, 13 May 2018 15:30:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F050928F5F for ; Sun, 13 May 2018 15:30:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4C4529073; Sun, 13 May 2018 15:30:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E62928F5F for ; Sun, 13 May 2018 15:30:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751638AbeEMPaa (ORCPT ); Sun, 13 May 2018 11:30:30 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:34287 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751584AbeEMPa3 (ORCPT ); Sun, 13 May 2018 11:30:29 -0400 Received: by mail-wr0-f196.google.com with SMTP id p18-v6so9746675wrm.1; Sun, 13 May 2018 08:30:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=b4AFft7dWRsBVzGCA3E0pS1HQqSACjozw8cGz+L3hng=; b=eiweDP19VyfQwfVUENM9DX5HwxVPnyXvZLAQI9DFbrlpRnZTIUPcsiNo0OacL4fhU2 hKelpcC37foQlRlQcfKY2lZjr48hWwapuJGIuNOPKmrtgCcSUuVavyrmiCfL1RrTh+W1 Y0P85pKwtbPgos+03CRZtVPaKMsfP3p3b17gj4e0GSFVG+uExyRgojgB4dUplBP7ceqi FgQW5HYe49SlcJ2DH6BWvhUD1nN0T4WGburIvOfFo1EM6iNU2ytpHCuX+vk7yNZQhXO7 0BLxYZBBJNr8zvfLWpI5jigEUBGVIIwXkP9jnEuoqBIWyBv9GoO+ktd4eUbyGaFPjnum 4Agw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=b4AFft7dWRsBVzGCA3E0pS1HQqSACjozw8cGz+L3hng=; b=W3fuzqk+JLhFKURnWirVvwY9nxDHjLFvP0awKlsJLdQNIr6lJcbxl8ZsySWhvfokF7 87CDILomo136YMqdsbd+sGLyAa5RpxEa07oddy68eOlPRsoVlsTh+QK+UN9j5rRXzu9L CagRSUBAkb3G6fKbhGxNgkXtoTG/f0jUXMxaD9EjAWa/oNXTuzEAwBc6mGVteOPHvlqT yzgXuUy6rwM2KT6NMcV+e+sUXonwAmXyIEhAz1FhwQKBZB85uk3CySfEXoEP3MIFoF17 I7TNo/j4zuE2sxnT+WzoQW5ZN61W0pPHq1DJUApWVRLifApX3GVESdAC3paeEF3UpObh 3fDw== X-Gm-Message-State: ALKqPwcKMZHTnyU6NoHnotLh0ItIg41UqN4scnhxkwSqCce+yxVkdpg9 i/7VNda541nRq1YxreLAFUo= X-Google-Smtp-Source: AB8JxZo8Y+PuGmtnYENijPOf9eG+51pOtpl29i1KJcJpbGwAC7cXbWTcxfKqdYYmzlYXnOwiHt4qxQ== X-Received: by 2002:adf:b11a:: with SMTP id l26-v6mr4844672wra.258.1526225428020; Sun, 13 May 2018 08:30:28 -0700 (PDT) Received: from thinkpad (pppoe-46-239-10-213.teol.net. [46.239.10.213]) by smtp.googlemail.com with ESMTPSA id 140-v6sm6807977wmi.9.2018.05.13.08.30.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 13 May 2018 08:30:27 -0700 (PDT) Date: Sun, 13 May 2018 17:30:24 +0200 From: Ognjen Galic To: Andy Shevchenko , "Rafael J. Wysocki" , Ognjen =?utf-8?B?R2FsacSH?= , "Rafael J. Wysocki" , Len Brown , Robert Moore , ACPI Devel Maling List , devel@acpica.org, Darren Hart , Andy Shevchenko , Henrique de Moraes Holschuh , Sebastian Reichel , Platform Driver , ibm-acpi-devel@lists.sourceforge.net, Linux PM , Christoph =?iso-8859-1?Q?B=F6hmwalder?= , Kevin Locke Subject: [PATCH 3/3] thinkpad_acpi: document the battery controls Message-ID: <20180513153024.GA5142@thinkpad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This documents the new battery controls and wear leveling support for Lenovo ThinkPad laptops. Signed-off-by: Ognjen Galic --- 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 @@ -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.