From patchwork Fri Dec 15 16:57:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ognjen Galic X-Patchwork-Id: 10115569 X-Patchwork-Delegate: andy.shevchenko@gmail.com 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 406A56019C for ; Fri, 15 Dec 2017 16:57:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F3792A009 for ; Fri, 15 Dec 2017 16:57:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 206742A08A; Fri, 15 Dec 2017 16:57:58 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI 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 CB8A22A009 for ; Fri, 15 Dec 2017 16:57:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932519AbdLOQ5z (ORCPT ); Fri, 15 Dec 2017 11:57:55 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:45995 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932348AbdLOQ5y (ORCPT ); Fri, 15 Dec 2017 11:57:54 -0500 Received: by mail-wr0-f196.google.com with SMTP id h1so8580336wre.12; Fri, 15 Dec 2017 08:57:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:user-agent; bh=O3q0zmh2J/sPG3ujPqA/08PbHef4c9YuaN6/p0xNzGw=; b=CJqtcf82v0F7dA/YpibAb+IMOVfAMv9gqK36yt05NZvpkP9rrUofiiJt7TCvhtwQzD 87zf1vQfxWK33gavCa6tnxWXnDZP+wAGBSMI3C9pQ9lJlAz6gBn30rAgrfmV2x3w5eKI rnw0xiynwU5GzwdmpToPvyQwNx7lQEAJ2yE8Z2OmC9L7PBzJt+tgvOUmvMbQgW12LNM/ N4or4pffan3dmUTJL6y075mmzWNapNx2JpENVq7TBDOF/hln32wZ6fbjMoJTU3/BTqlK if+M51LT8AGMKFwjkPH+Ia4wfDE14A95WZrK8J5RXPi1DuGwEFVphcFs1q0KeOzAiO3K ELLw== 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:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:user-agent; bh=O3q0zmh2J/sPG3ujPqA/08PbHef4c9YuaN6/p0xNzGw=; b=rhxzOxSvYD44ACniWWaOSb3Wm8v/RWGdTaCrHLXgG/aGuuwkcFE7mycxqv0tKu7JJx gdxb494cFaDjBpbvC0E4yOYkD4sCd7WSDzS4RbEH6FWqU9CQFV+f7fIWyDBz0Zmptdni wWNmXN48jnTj5Exbgx6UMu2qUl/d94DQGpqD9ZXOc1AgFtryU0t93cbgoYoRvwuIGAoE LheIBTP7HSgu4tz+yu9Vp7E2LOrgHlzsMTSOuKiIiAVO+Qc3Jcfy8pjqpWH8GIuc43W1 Uh7LEaYz15CF7TcETUJAK6gO1/8oFK/IUMmG0U+wsGDdXo2aL20VNP/7jkJeN7rW6Hco t1Wg== X-Gm-Message-State: AKGB3mLF6OgjeQScHfUnUM/RMa5BsBksODIW7Ixx4AIAO0fRUR9eh7gD SftoDiIhM3/KCXBtv5kpiKMtqgK6 X-Google-Smtp-Source: ACJfBotz4gMvMoD4viPRBVBbpHzVLzh01y3Cz1w1f8/rP5lBYeLEHlFNJw3mxtnBV0WRc/pd85fDSw== X-Received: by 10.223.158.147 with SMTP id a19mr11041161wrf.179.1513357072368; Fri, 15 Dec 2017 08:57:52 -0800 (PST) Received: from thinkpad (pppoe-46-239-11-134.teol.net. [46.239.11.134]) by smtp.gmail.com with ESMTPSA id o16sm7352222wmi.29.2017.12.15.08.57.51 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 15 Dec 2017 08:57:51 -0800 (PST) Date: Fri, 15 Dec 2017 17:57:50 +0100 From: Ognjen Galic To: "Rafael J. Wysocki" , Len Brown , Robert Moore , Lv Zheng , linux-acpi@vger.kernel.org, devel@acpica.org Cc: Darren Hart , Andy Shevchenko , Henrique de Moraes Holschuh , Sebastian Reichel , platform-driver-x86@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net, linux-pm@vger.kernel.org Subject: [PATCH 2/3 v6] battery: Add the ThinkPad "Not Charging" quirk Message-ID: <20171215165750.GA6282@thinkpad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: platform-driver-x86-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The EC/ACPI firmware on Lenovo ThinkPads used to report a status of "Unknown" when the battery is between the charge start and charge stop thresholds. On Windows, it reports "Not Charging" so the quirk has been added to also report correctly. Now the "status" attribute returns "Not Charging" when the battery on ThinkPads is not physicaly charging. Tested-by: Kevin Locke Tested-by: Christoph Böhmwalder Signed-off-by: Ognjen Galic --- drivers/acpi/battery.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 2951d07..81e9b4e 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -71,6 +71,7 @@ static async_cookie_t async_cookie; static bool battery_driver_registered; static int battery_bix_broken_package; static int battery_notification_delay_ms; +static int battery_quirk_thinkpad_notcharging; static unsigned int cache_time = 1000; module_param(cache_time, uint, 0644); MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); @@ -222,6 +223,13 @@ static int acpi_battery_get_property(struct power_supply *psy, val->intval = POWER_SUPPLY_STATUS_CHARGING; else if (acpi_battery_is_charged(battery)) val->intval = POWER_SUPPLY_STATUS_FULL; + /* + * On the Lenovo ThinkPad ACPI implementation, when + * neither bits 0 or 1 are set, that state is + * considered as "Not Charging". + */ + else if (battery_quirk_thinkpad_notcharging) + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; else val->intval = POWER_SUPPLY_STATUS_UNKNOWN; break; @@ -1301,6 +1309,13 @@ battery_notification_delay_quirk(const struct dmi_system_id *d) return 0; } +static int __init +battery_quirk_not_charging(const struct dmi_system_id *d) +{ + battery_quirk_thinkpad_notcharging = 1; + return 0; +} + static const struct dmi_system_id bat_dmi_table[] __initconst = { { .callback = battery_bix_broken_package_quirk, @@ -1318,6 +1333,14 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = { DMI_MATCH(DMI_PRODUCT_NAME, "Aspire V5-573G"), }, }, + { + .callback = battery_quirk_not_charging, + .ident = "Lenovo ThinkPad", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad"), + }, + }, {}, };