Skip to content

Commit 44cbd2a

Browse files
t-8chgregkh
authored andcommitted
ACPI: battery: Add the ThinkPad "Not Charging" quirk
[ Upstream commit e96c119 ] 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 <linux@weissschuh.net> Reviewed-by: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7b6dc07 commit 44cbd2a

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

‎drivers/acpi/battery.c‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ static int battery_bix_broken_package;
5959
static int battery_notification_delay_ms;
6060
static int battery_ac_is_broken;
6161
static int battery_check_pmic = 1;
62+
static int battery_quirk_notcharging;
6263
static unsigned int cache_time = 1000;
6364
module_param(cache_time, uint, 0644);
6465
MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -222,6 +223,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
222223
val->intval = POWER_SUPPLY_STATUS_CHARGING;
223224
else if (acpi_battery_is_charged(battery))
224225
val->intval = POWER_SUPPLY_STATUS_FULL;
226+
else if (battery_quirk_notcharging)
227+
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
225228
else
226229
val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
227230
break;
@@ -1105,6 +1108,12 @@ battery_do_not_check_pmic_quirk(const struct dmi_system_id *d)
11051108
return 0;
11061109
}
11071110

1111+
static int __init battery_quirk_not_charging(const struct dmi_system_id *d)
1112+
{
1113+
battery_quirk_notcharging = 1;
1114+
return 0;
1115+
}
1116+
11081117
static const struct dmi_system_id bat_dmi_table[] __initconst = {
11091118
{
11101119
/* NEC LZ750/LS */
@@ -1149,6 +1158,19 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
11491158
DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
11501159
},
11511160
},
1161+
{
1162+
/*
1163+
* On Lenovo ThinkPads the BIOS specification defines
1164+
* a state when the bits for charging and discharging
1165+
* are both set to 0. That state is "Not Charging".
1166+
*/
1167+
.callback = battery_quirk_not_charging,
1168+
.ident = "Lenovo ThinkPad",
1169+
.matches = {
1170+
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1171+
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad"),
1172+
},
1173+
},
11521174
{},
11531175
};
11541176

0 commit comments

Comments
 (0)