Skip to content

Commit e96c119

Browse files
t-8chrafaeljw
authored andcommitted
ACPI: battery: Add the ThinkPad "Not Charging" quirk
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>
1 parent fc74e0a commit e96c119

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

drivers/acpi/battery.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ static int battery_bix_broken_package;
5353
static int battery_notification_delay_ms;
5454
static int battery_ac_is_broken;
5555
static int battery_check_pmic = 1;
56+
static int battery_quirk_notcharging;
5657
static unsigned int cache_time = 1000;
5758
module_param(cache_time, uint, 0644);
5859
MODULE_PARM_DESC(cache_time, "cache time in milliseconds");
@@ -217,6 +218,8 @@ static int acpi_battery_get_property(struct power_supply *psy,
217218
val->intval = POWER_SUPPLY_STATUS_CHARGING;
218219
else if (acpi_battery_is_charged(battery))
219220
val->intval = POWER_SUPPLY_STATUS_FULL;
221+
else if (battery_quirk_notcharging)
222+
val->intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
220223
else
221224
val->intval = POWER_SUPPLY_STATUS_UNKNOWN;
222225
break;
@@ -1111,6 +1114,12 @@ battery_do_not_check_pmic_quirk(const struct dmi_system_id *d)
11111114
return 0;
11121115
}
11131116

1117+
static int __init battery_quirk_not_charging(const struct dmi_system_id *d)
1118+
{
1119+
battery_quirk_notcharging = 1;
1120+
return 0;
1121+
}
1122+
11141123
static const struct dmi_system_id bat_dmi_table[] __initconst = {
11151124
{
11161125
/* NEC LZ750/LS */
@@ -1155,6 +1164,19 @@ static const struct dmi_system_id bat_dmi_table[] __initconst = {
11551164
DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 320-10ICR"),
11561165
},
11571166
},
1167+
{
1168+
/*
1169+
* On Lenovo ThinkPads the BIOS specification defines
1170+
* a state when the bits for charging and discharging
1171+
* are both set to 0. That state is "Not Charging".
1172+
*/
1173+
.callback = battery_quirk_not_charging,
1174+
.ident = "Lenovo ThinkPad",
1175+
.matches = {
1176+
DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"),
1177+
DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad"),
1178+
},
1179+
},
11581180
{},
11591181
};
11601182

0 commit comments

Comments
 (0)