Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3714606pxb; Mon, 24 Jan 2022 16:08:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwP6wM+1ufSVC0LyVJ8TiW2kIW6RhEoX54+atZAV6rRq3ZWtzqW+m9hzrqUbMfXFluUHqe X-Received: by 2002:a17:903:41cf:b0:14a:f1af:15cc with SMTP id u15-20020a17090341cf00b0014af1af15ccmr16406941ple.122.1643069284333; Mon, 24 Jan 2022 16:08:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643069284; cv=none; d=google.com; s=arc-20160816; b=qVHGRNaZVWMidgos2Kabeh7SO8CfRITAu0BERZtcVw0ZdKyzsdmR/1+QvTY/uVuhba uXfWwoZYEPNFNWXSTNS8OodeixMgWZ6L9DB57e3r4vsEaqOuzrIxuFtTGbCag8kGYFd4 cW46YLp+kb0qXcVcScpmtPHmMUAqV7mo+UOOu7olYTjezIPfxGY6aARGdYA/H8xmbwSv esU/aYBaYi0lQl4qZnLBbGU7N8R7gcDVXOfPWNZyCIP0U2FLIV4w7T6ud8fx+m33XM/I j2/3Ztjbq95+6oIVg2XeVT293EolPmOyZtmhd7udHgfk5uqdfQE5eowdgtKSOuRAySva 0XTQ== 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=4G35qYmNI5QHpYxVpX1vVDrZjf6Iwag8VOGZR/87XbM=; b=XqkBdXLOiuyWWoh1WshBlUl+htV6H1VMIOdwn+1d25sUKRAmUV/9r9TbuSuOnvmkW/ XJ9upJVNX5/5GJmjtcume/j1VVsYNktsqXE9xM6VGuyN7gi+NGA+uJtA7le3bLmkddmT yTuqPxp4cwhmumFJkcF3pcPOpNtEdwna37JNhI7bUoR6SknvAa47QsBnViJJh2zKKRFY RXF5KRIM2Om73SuPC1N6Tq2Qr9MdA7ZDRgX3FrKtu01kdZ7O6gezUPeGLzvvZvVl8hsg G15XC3a4YRb8IhIQnUjv+9fVYbwnLFRiWJZfb5Rf10FIttrH0GxbKg7i8L0SIo6PPYpt 6xeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2Lb6tpTZ; 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 j11si13971393plh.260.2022.01.24.16.07.51; Mon, 24 Jan 2022 16:08:04 -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=2Lb6tpTZ; 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 S2368884AbiAYAAY (ORCPT + 99 others); Mon, 24 Jan 2022 19:00:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1847692AbiAXXUX (ORCPT ); Mon, 24 Jan 2022 18:20:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1523C028C33; Mon, 24 Jan 2022 13:28:25 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 7003761583; Mon, 24 Jan 2022 21:28:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55749C340EC; Mon, 24 Jan 2022 21:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643059704; bh=dXBOlCuoOPukKy5ijeo0ko66jl0mtrClLVGnUYITNaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2Lb6tpTZ09g38vloY7V9Uv0X9S458Gjse6J0F+D4l1++2kau3ynChQJB0Cwtg1psg /2k9ssOUCUzvHCNPGNKSBsAVpMWSRsdhUXgFNbKaYIWtPG6saemMfHop8VzABQzlxZ cUIZmLoxDEW2p3P/E6VNJOZO4bGa+6G53wEXQjpw= 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.16 0706/1039] ACPI: battery: Add the ThinkPad "Not Charging" quirk Date: Mon, 24 Jan 2022 19:41:35 +0100 Message-Id: <20220124184149.069081921@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 8afa85d6eb6a7..ead0114f27c9f 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -53,6 +53,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"); @@ -217,6 +218,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; @@ -1111,6 +1114,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 */ @@ -1155,6 +1164,19 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = { DMI_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