summaryrefslogtreecommitdiff
path: root/drivers/acpi/pmic
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2021-11-26 18:21:09 +0300
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2021-12-08 17:34:57 +0300
commit5f96ba56552121f4297874d0accf29b9b4a1ae93 (patch)
tree0cbf12fc22ae7fe22ec174628935ad4b844ab268 /drivers/acpi/pmic
parentc5200609c9176482ea96ac73e52bd466b622f385 (diff)
downloadlinux-5f96ba56552121f4297874d0accf29b9b4a1ae93.tar.xz
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 <hdegoede@redhat.com> Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/pmic')
-rw-r--r--drivers/acpi/pmic/intel_pmic_xpower.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/drivers/acpi/pmic/intel_pmic_xpower.c b/drivers/acpi/pmic/intel_pmic_xpower.c
index e844bc1f3df5..61bbe4c24d87 100644
--- a/drivers/acpi/pmic/intel_pmic_xpower.c
+++ b/drivers/acpi/pmic/intel_pmic_xpower.c
@@ -293,12 +293,33 @@ static int intel_xpower_exec_mipi_pmic_seq_element(struct regmap *regmap,
return ret;
}
+static int intel_xpower_lpat_raw_to_temp(struct acpi_lpat_conversion_table *lpat_table,
+ int raw)
+{
+ struct acpi_lpat first = lpat_table->lpat[0];
+ struct acpi_lpat last = lpat_table->lpat[lpat_table->lpat_count - 1];
+
+ /*
+ * Some LPAT tables in the ACPI Device for the AXP288 PMIC for some
+ * reason only describe a small temperature range, e.g. 27° - 37°
+ * Celcius. Resulting in errors when the tablet is idle in a cool room.
+ *
+ * To avoid these errors clamp the raw value to be inside the LPAT.
+ */
+ if (first.raw < last.raw)
+ raw = clamp(raw, first.raw, last.raw);
+ else
+ raw = clamp(raw, last.raw, first.raw);
+
+ return acpi_lpat_raw_to_temp(lpat_table, raw);
+}
+
static const struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
.get_power = intel_xpower_pmic_get_power,
.update_power = intel_xpower_pmic_update_power,
.get_raw_temp = intel_xpower_pmic_get_raw_temp,
.exec_mipi_pmic_seq_element = intel_xpower_exec_mipi_pmic_seq_element,
- .lpat_raw_to_temp = acpi_lpat_raw_to_temp,
+ .lpat_raw_to_temp = intel_xpower_lpat_raw_to_temp,
.power_table = power_table,
.power_table_count = ARRAY_SIZE(power_table),
.thermal_table = thermal_table,