From patchwork Sun Dec 10 18:05:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ognjen Galic X-Patchwork-Id: 10103937 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 EDD7960329 for ; Sun, 10 Dec 2017 18:05:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E881528DED for ; Sun, 10 Dec 2017 18:05:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DA1D428F42; Sun, 10 Dec 2017 18:05:36 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham 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 B04CB28DED for ; Sun, 10 Dec 2017 18:05:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752208AbdLJSFe (ORCPT ); Sun, 10 Dec 2017 13:05:34 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:38665 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752165AbdLJSFd (ORCPT ); Sun, 10 Dec 2017 13:05:33 -0500 Received: by mail-wm0-f68.google.com with SMTP id 64so10407768wme.3; Sun, 10 Dec 2017 10:05:32 -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=Ci1yAjYnW9VvB/KtD9EEPbPkJtkjEuhDb+EAkclKbobkhqb3kbZm9rmK7tVz3kt75y Z8i0pfc+GO8ChNp9me7ujqVuUsw736aNcrijqCDmzlohTK3xiVgQqP9PahF2k9ktST6u wut7j1BWZxzwQ0uKuFvA2cJvP1T1fIVJ/vqR3RsO13oXhhRM9nDW2g7ieg0NmTNcsXXo 3Z44jZhZ8ZtbciEEJY+WyiLd5grOj2kno/FBRwV7kcTZiR2kQZsS/HE7IhuK1gK34abZ 0C5ILqLYLDgbxBRyJMwAmol/SJHKsVCWLRRHampOQQ7VeCUPlAoe/VTQirLKfJ1be/w4 HDuA== 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=fRS/S32ZYEC3VvNjCKB/gyVP/VqczG+JwMhvtlDg+s5bTkDIJl4djX08MHAREjhQdH gLw+ddkHzGCavyriiip8zkax6R8SegMOmfp/QCIW0b1rFTeZfOJPKUYFEqF7stB86djJ zZkRa20tCi5jTt46J4loorg9JgMD5MNPzEa8YvgzOYzSzZJ3Tb9kXranoRSSo2sQr3sW SQLi3Wh5M3ZWVi5sKFCjxBYy6qgMGWsq5fKMjqznRP1b+IQJnZsZZ2mUKYDR0ZSVEK6U B4ThsL7X07UVpwZFlYuyoyQIG4LdW6y4/dEKNLNNfbxEEhoKEd4K9MakRPjGOpgyxrQC snxQ== X-Gm-Message-State: AKGB3mIBPL1tqgJsK+GA1QSidmTiTBE0cR8JVF4GTSl9K19GS9zf4UCs 54Xhd35yrRkExUv5d8Fbcb0= X-Google-Smtp-Source: AGs4zMZLaerGEB62CfNiwuDySCJVjAcgF0LAV8LKSxb7tFHML4tHelxbSHeYjij43TgUAGGDpRhpDg== X-Received: by 10.28.198.75 with SMTP id w72mr9388419wmf.2.1512929131903; Sun, 10 Dec 2017 10:05:31 -0800 (PST) Received: from thinkpad (pppoe-46-239-10-89.teol.net. [46.239.10.89]) by smtp.gmail.com with ESMTPSA id 26sm15149241wrw.19.2017.12.10.10.05.29 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 10 Dec 2017 10:05:30 -0800 (PST) Date: Sun, 10 Dec 2017 19:05:29 +0100 From: Ognjen Galic To: "Rafael J. Wysocki" , Len Brown , Robert Moore , Lv Zheng , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, devel@acpica.org Cc: Darren Hart , Andy Shevchenko , Henrique de Moraes Holschuh , platform-driver-x86@vger.kernel.org, ibm-acpi-devel@lists.sourceforge.net Subject: [PATCH 2/3 v5] battery: Add the ThinkPad "Not Charging" quirk Message-ID: <20171210180529.GA2016@thinkpad> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) 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 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"), + }, + }, {}, };