Skip to content

Commit 5f96ba5

Browse files
jwrdegoederafaeljw
authored andcommitted
ACPI: PMIC: xpower: Fix _TMP ACPI errors
On some devices with a X-Powers AXP288 PMIC the LPAT tables in the ACPI node for the AXP288 PMIC for some reason only describe a small temperature range, e.g. 27° - 37° Celcius (assuming the entries are in millidegrees). When the tablet is idle in a room at 21° degrees this is causing values outside the LPAT table to be read, causing e.g. the following 2 errors to get spammed to the logs every 4 seconds! : [ 7512.791316] ACPI Error: AE_ERROR, Returned by Handler for [UserDefinedRegion] (20210930/evregion-281) [ 7512.791611] ACPI Error: Aborting method \_SB.SXP1._TMP due to previous error (AE_ERROR) (20210930/psparse-529) Fix this by clamping the raw value to the LPAT table range before passing it to acpi_lpat_raw_to_temp(). Note clamping has been chosen rather then extrapolating because it is unknown how other parts of the ACPI tables will respond to temperature values outside of the LPAT range. Signed-off-by: Hans de Goede <[email protected]> Reviewed-by: Andy Shevchenko <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent c520060 commit 5f96ba5

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

drivers/acpi/pmic/intel_pmic_xpower.c

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,33 @@ static int intel_xpower_exec_mipi_pmic_seq_element(struct regmap *regmap,
293293
return ret;
294294
}
295295

296+
static int intel_xpower_lpat_raw_to_temp(struct acpi_lpat_conversion_table *lpat_table,
297+
int raw)
298+
{
299+
struct acpi_lpat first = lpat_table->lpat[0];
300+
struct acpi_lpat last = lpat_table->lpat[lpat_table->lpat_count - 1];
301+
302+
/*
303+
* Some LPAT tables in the ACPI Device for the AXP288 PMIC for some
304+
* reason only describe a small temperature range, e.g. 27° - 37°
305+
* Celcius. Resulting in errors when the tablet is idle in a cool room.
306+
*
307+
* To avoid these errors clamp the raw value to be inside the LPAT.
308+
*/
309+
if (first.raw < last.raw)
310+
raw = clamp(raw, first.raw, last.raw);
311+
else
312+
raw = clamp(raw, last.raw, first.raw);
313+
314+
return acpi_lpat_raw_to_temp(lpat_table, raw);
315+
}
316+
296317
static const struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
297318
.get_power = intel_xpower_pmic_get_power,
298319
.update_power = intel_xpower_pmic_update_power,
299320
.get_raw_temp = intel_xpower_pmic_get_raw_temp,
300321
.exec_mipi_pmic_seq_element = intel_xpower_exec_mipi_pmic_seq_element,
301-
.lpat_raw_to_temp = acpi_lpat_raw_to_temp,
322+
.lpat_raw_to_temp = intel_xpower_lpat_raw_to_temp,
302323
.power_table = power_table,
303324
.power_table_count = ARRAY_SIZE(power_table),
304325
.thermal_table = thermal_table,

0 commit comments

Comments
 (0)