Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3597732pxb; Mon, 24 Jan 2022 13:09:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7KgXfZ4qrQQPo+gFW5LgovRUN7arSz7lZpb9AeO8/JWl67yNUScdVDCA9Q9GSmTfMOlCJ X-Received: by 2002:a05:6a00:174f:b0:4c2:3cc8:d7c2 with SMTP id j15-20020a056a00174f00b004c23cc8d7c2mr15265852pfc.81.1643058584180; Mon, 24 Jan 2022 13:09:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643058584; cv=none; d=google.com; s=arc-20160816; b=M/aIZ6kbaOahrSyEAsLMvC6me3zqR5dmx4ATo0Z9WbcHO6hGrS6u7LMtMpsRJtrcdf d5klBCaleuJaMJc3yuFjjdPzCw0BeyZhkkmYp+trC4VvZuj1v2l+xMbmUKy4t0WrIBXG R/RnNi426PbuMWrIOcJ8iah/4sv9UPx89f8s/V2uSw92SQZX8Ayx+wCSPyZ1LQTat0Du H4AqjCvFqu6XPmHZkEtQsPAOaGfKFmf5zws+Haz0nsTokd+xHV/9qjp/R6t55hIlfdBT mlRf8VWrSRSy6rwFT80lz5RskXXASja5fNlepoN/PlgSHc2SQiQGcpsONeLJHDfpItOL vsyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cuuHR26ZuXHxwbsndbgm5cU/eAhMGjosKcFQ9L9M9zs=; b=eXsafP9cEM+T9FWfYKiy1nxE6UrwMvDTOdGFBOYdv9vaXDfX5NopjV1+lbGJEnQ2F2 86w3x1FLpdGrSz7XvctehjbgWWqDjS2eSyEt8oXzILDiOs4TUpn2tMyfs3D2EhBdEJS+ mxPTAYSC2pyby/HZhZHQGOtKp4TCg3BuhbY1DzAW4THlnxujCDAme5XMiY9UDU6y43CB cStv778PQ7QNBnQWi+9C+FnsYGutSti0fPY8BYvFbmin/JOM5efbRGcXx/0U3z/EyYic +4yPcD2Zp0aWyh/feUkVRBJtyGSpeowRKi/voy34nEwTHW/nDF2bFxs8Qj2BZ+3cEmo2 +3zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0+Ca3Mzl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d9si12567989pla.578.2022.01.24.13.09.28; Mon, 24 Jan 2022 13:09:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0+Ca3Mzl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1385945AbiAXUet (ORCPT + 99 others); Mon, 24 Jan 2022 15:34:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355449AbiAXUNl (ORCPT ); Mon, 24 Jan 2022 15:13:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45665C06177D; Mon, 24 Jan 2022 11:36:44 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0C53AB80FA1; Mon, 24 Jan 2022 19:36:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3848AC340E5; Mon, 24 Jan 2022 19:36:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643053001; bh=pAudh+TsOSpSnD0nYfPANG+aRUPcTOqHL2dBB7d7S30=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0+Ca3MzlY+4e4erCPR5HI8bgVqtzrzIxCZwHR5tfN+NaWDIwKq/DmB4xFnzHBKiRi 8+E4zC69pxwT0RqQMF8zv2ABLwY8yrdX/LBUKSbSKsF8stoYQDPyIbmJoBLi/9wmbk cHWRSMDTgYvHDkIjG5SlpmqNt0sbf8AhX1RUwk7U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Hans de Goede , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 5.4 210/320] ACPI: battery: Add the ThinkPad "Not Charging" quirk Date: Mon, 24 Jan 2022 19:43:14 +0100 Message-Id: <20220124184000.766334316@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183953.750177707@linuxfoundation.org> References: <20220124183953.750177707@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Weißschuh [ Upstream commit e96c1197aca628f7d2480a1cc3214912b40b3414 ] 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. Signed-off-by: Thomas Weißschuh Reviewed-by: Hans de Goede Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/battery.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 6e96ed68b3379..4e0aea5f008e3 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -65,6 +65,7 @@ static int battery_bix_broken_package; static int battery_notification_delay_ms; static int battery_ac_is_broken; static int battery_check_pmic = 1; +static int battery_quirk_notcharging; static unsigned int cache_time = 1000; module_param(cache_time, uint, 0644); MODULE_PARM_DESC(cache_time, "cache time in milliseconds"); @@ -233,6 +234,8 @@ 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; + else if (battery_quirk_notcharging) + val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING; else val->intval = POWER_SUPPLY_STATUS_UNKNOWN; break; @@ -1337,6 +1340,12 @@ battery_do_not_check_pmic_quirk(const struct dmi_system_id *d) return 0; } +static int __init battery_quirk_not_charging(const struct dmi_system_id *d) +{ + battery_quirk_notcharging = 1; + return 0; +} + static const struct dmi_system_id bat_dmi_table[] __initconst = { { /* NEC LZ750/LS */ @@ -1381,6 +1390,19 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = { DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"), }, }, + { + /* + * On Lenovo ThinkPads the BIOS specification defines + * a state when the bits for charging and discharging + * are both set to 0. That state is "Not Charging". + */ + .callback = battery_quirk_not_charging, + .ident = "Lenovo ThinkPad", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad"), + }, + }, {}, }; -- 2.34.1