]> Git Repo - linux.git/commitdiff
thermal: ACPI: Move the ACPI thermal library to drivers/acpi/
authorRafael J. Wysocki <[email protected]>
Tue, 17 Oct 2023 20:05:23 +0000 (22:05 +0200)
committerRafael J. Wysocki <[email protected]>
Tue, 21 Nov 2023 14:04:08 +0000 (15:04 +0100)
The ACPI thermal library contains functions that can be used to
retrieve trip point temperature values through the platform firmware
for various types of trip points.  Each of these functions basically
evaluates a specific ACPI object, checks if the value produced by it
is reasonable and returns it (or THERMAL_TEMP_INVALID if anything
fails).

It made sense to hold it in drivers/thermal/ so long as it was only used
by the code in that directory, but since it is also going to be used by
the ACPI thermal driver located in drivers/acpi/, move it to the latter
in order to keep the code related to evaluating ACPI objects defined in
the specification proper together.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <[email protected]>
drivers/acpi/Kconfig
drivers/acpi/Makefile
drivers/acpi/thermal_lib.c [new file with mode: 0644]
drivers/thermal/Kconfig
drivers/thermal/Makefile
drivers/thermal/intel/Kconfig
drivers/thermal/intel/int340x_thermal/Kconfig
drivers/thermal/thermal_acpi.c [deleted file]
include/linux/acpi.h
include/linux/thermal.h

index f819e760ff195a902aba7e8fd5073c0dc4d67a4c..6f2bfcf7645ce6c94732bb0b43512feac90762e3 100644 (file)
@@ -61,6 +61,10 @@ config ACPI_CCA_REQUIRED
 config ACPI_TABLE_LIB
        bool
 
+config ACPI_THERMAL_LIB
+       depends on THERMAL
+       bool
+
 config ACPI_DEBUGGER
        bool "AML debugger interface"
        select ACPI_DEBUG
@@ -327,6 +331,7 @@ config ACPI_THERMAL
        tristate "Thermal Zone"
        depends on ACPI_PROCESSOR
        select THERMAL
+       select ACPI_THERMAL_LIB
        default y
        help
          This driver supports ACPI thermal zones.  Most mobile and
index eaa09bf52f17609ffbb24fef7d7fccf12afe4024..2a52083704e6a5ffbb589430597084aba2b1af85 100644 (file)
@@ -89,6 +89,7 @@ obj-$(CONFIG_ACPI_TAD)                += acpi_tad.o
 obj-$(CONFIG_ACPI_PCI_SLOT)    += pci_slot.o
 obj-$(CONFIG_ACPI_PROCESSOR)   += processor.o
 obj-$(CONFIG_ACPI)             += container.o
+obj-$(CONFIG_ACPI_THERMAL_LIB) += thermal_lib.o
 obj-$(CONFIG_ACPI_THERMAL)     += thermal.o
 obj-$(CONFIG_ACPI_PLATFORM_PROFILE)    += platform_profile.o
 obj-$(CONFIG_ACPI_NFIT)                += nfit/
diff --git a/drivers/acpi/thermal_lib.c b/drivers/acpi/thermal_lib.c
new file mode 100644 (file)
index 0000000..43eaf0f
--- /dev/null
@@ -0,0 +1,116 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * Copyright 2023 Linaro Limited
+ * Copyright 2023 Intel Corporation
+ *
+ * Library routines for populating a generic thermal trip point structure
+ * with data obtained by evaluating a specific object in the ACPI Namespace.
+ */
+#include <linux/acpi.h>
+#include <linux/units.h>
+#include <linux/thermal.h>
+
+/*
+ * Minimum temperature for full military grade is 218°K (-55°C) and
+ * max temperature is 448°K (175°C). We can consider those values as
+ * the boundaries for the [trips] temperature returned by the
+ * firmware. Any values out of these boundaries may be considered
+ * bogus and we can assume the firmware has no data to provide.
+ */
+#define TEMP_MIN_DECIK 2180
+#define TEMP_MAX_DECIK 4480
+
+static int thermal_acpi_trip_temp(struct acpi_device *adev, char *obj_name,
+                                 int *ret_temp)
+{
+       unsigned long long temp;
+       acpi_status status;
+
+       status = acpi_evaluate_integer(adev->handle, obj_name, NULL, &temp);
+       if (ACPI_FAILURE(status)) {
+               acpi_handle_debug(adev->handle, "%s evaluation failed\n", obj_name);
+               return -ENODATA;
+       }
+
+       if (temp >= TEMP_MIN_DECIK && temp <= TEMP_MAX_DECIK) {
+               *ret_temp = deci_kelvin_to_millicelsius(temp);
+       } else {
+               acpi_handle_debug(adev->handle, "%s result %llu out of range\n",
+                                 obj_name, temp);
+               *ret_temp = THERMAL_TEMP_INVALID;
+       }
+
+       return 0;
+}
+
+/**
+ * thermal_acpi_active_trip_temp - Retrieve active trip point temperature
+ * @adev: Target thermal zone ACPI device object.
+ * @id: Active cooling level (0 - 9).
+ * @ret_temp: Address to store the retrieved temperature value on success.
+ *
+ * Evaluate the _ACx object for the thermal zone represented by @adev to obtain
+ * the temperature of the active cooling trip point corresponding to the active
+ * cooling level given by @id.
+ *
+ * Return 0 on success or a negative error value on failure.
+ */
+int thermal_acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp)
+{
+       char obj_name[] = {'_', 'A', 'C', '0' + id, '\0'};
+
+       if (id < 0 || id > 9)
+               return -EINVAL;
+
+       return thermal_acpi_trip_temp(adev, obj_name, ret_temp);
+}
+EXPORT_SYMBOL_GPL(thermal_acpi_active_trip_temp);
+
+/**
+ * thermal_acpi_passive_trip_temp - Retrieve passive trip point temperature
+ * @adev: Target thermal zone ACPI device object.
+ * @ret_temp: Address to store the retrieved temperature value on success.
+ *
+ * Evaluate the _PSV object for the thermal zone represented by @adev to obtain
+ * the temperature of the passive cooling trip point.
+ *
+ * Return 0 on success or -ENODATA on failure.
+ */
+int thermal_acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp)
+{
+       return thermal_acpi_trip_temp(adev, "_PSV", ret_temp);
+}
+EXPORT_SYMBOL_GPL(thermal_acpi_passive_trip_temp);
+
+/**
+ * thermal_acpi_hot_trip_temp - Retrieve hot trip point temperature
+ * @adev: Target thermal zone ACPI device object.
+ * @ret_temp: Address to store the retrieved temperature value on success.
+ *
+ * Evaluate the _HOT object for the thermal zone represented by @adev to obtain
+ * the temperature of the trip point at which the system is expected to be put
+ * into the S4 sleep state.
+ *
+ * Return 0 on success or -ENODATA on failure.
+ */
+int thermal_acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp)
+{
+       return thermal_acpi_trip_temp(adev, "_HOT", ret_temp);
+}
+EXPORT_SYMBOL_GPL(thermal_acpi_hot_trip_temp);
+
+/**
+ * thermal_acpi_critical_trip_temp - Retrieve critical trip point temperature
+ * @adev: Target thermal zone ACPI device object.
+ * @ret_temp: Address to store the retrieved temperature value on success.
+ *
+ * Evaluate the _CRT object for the thermal zone represented by @adev to obtain
+ * the temperature of the critical cooling trip point.
+ *
+ * Return 0 on success or -ENODATA on failure.
+ */
+int thermal_acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp)
+{
+       return thermal_acpi_trip_temp(adev, "_CRT", ret_temp);
+}
+EXPORT_SYMBOL_GPL(thermal_acpi_critical_trip_temp);
index c81a00fbca7db936285d48f10a3bd2c437a1bc24..59883502eff48f03ec72e7b840f279f3f314d18f 100644 (file)
@@ -76,10 +76,6 @@ config THERMAL_OF
          Say 'Y' here if you need to build thermal infrastructure
          based on device tree.
 
-config THERMAL_ACPI
-       depends on ACPI
-       bool
-
 config THERMAL_WRITABLE_TRIPS
        bool "Enable writable trip points"
        help
index c934cab309ae0cbf5e7e94b6e2dc250bb21adbef..a8318d6710367c789a802d50d8b533608dec7177 100644 (file)
@@ -13,7 +13,6 @@ thermal_sys-$(CONFIG_THERMAL_NETLINK)         += thermal_netlink.o
 # interface to/from other layers providing sensors
 thermal_sys-$(CONFIG_THERMAL_HWMON)            += thermal_hwmon.o
 thermal_sys-$(CONFIG_THERMAL_OF)               += thermal_of.o
-thermal_sys-$(CONFIG_THERMAL_ACPI)             += thermal_acpi.o
 
 # governors
 CFLAGS_gov_power_allocator.o                   := -I$(src)
index ecd7e07eece0b49ba1c1037df3a9f37a459a3fe1..b43953b5539f6b718efbc4d8b180ba73a4668f8f 100644 (file)
@@ -85,7 +85,7 @@ config INTEL_BXT_PMIC_THERMAL
 config INTEL_PCH_THERMAL
        tristate "Intel PCH Thermal Reporting Driver"
        depends on X86 && PCI
-       select THERMAL_ACPI if ACPI
+       select ACPI_THERMAL_LIB if ACPI
        help
          Enable this to support thermal reporting on certain intel PCHs.
          Thermal reporting device will provide temperature reading,
index 300ea53e9b3327ad9f7d596afa329b428ee8a50b..e76b13e44d03fa896132e5d065db873a88efb588 100644 (file)
@@ -9,7 +9,7 @@ config INT340X_THERMAL
        select THERMAL_GOV_USER_SPACE
        select ACPI_THERMAL_REL
        select ACPI_FAN
-       select THERMAL_ACPI
+       select ACPI_THERMAL_LIB
        select INTEL_SOC_DTS_IOSF_CORE
        select INTEL_TCC
        select PROC_THERMAL_MMIO_RAPL if POWERCAP
diff --git a/drivers/thermal/thermal_acpi.c b/drivers/thermal/thermal_acpi.c
deleted file mode 100644 (file)
index 43eaf0f..0000000
+++ /dev/null
@@ -1,116 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright 2023 Linaro Limited
- * Copyright 2023 Intel Corporation
- *
- * Library routines for populating a generic thermal trip point structure
- * with data obtained by evaluating a specific object in the ACPI Namespace.
- */
-#include <linux/acpi.h>
-#include <linux/units.h>
-#include <linux/thermal.h>
-
-/*
- * Minimum temperature for full military grade is 218°K (-55°C) and
- * max temperature is 448°K (175°C). We can consider those values as
- * the boundaries for the [trips] temperature returned by the
- * firmware. Any values out of these boundaries may be considered
- * bogus and we can assume the firmware has no data to provide.
- */
-#define TEMP_MIN_DECIK 2180
-#define TEMP_MAX_DECIK 4480
-
-static int thermal_acpi_trip_temp(struct acpi_device *adev, char *obj_name,
-                                 int *ret_temp)
-{
-       unsigned long long temp;
-       acpi_status status;
-
-       status = acpi_evaluate_integer(adev->handle, obj_name, NULL, &temp);
-       if (ACPI_FAILURE(status)) {
-               acpi_handle_debug(adev->handle, "%s evaluation failed\n", obj_name);
-               return -ENODATA;
-       }
-
-       if (temp >= TEMP_MIN_DECIK && temp <= TEMP_MAX_DECIK) {
-               *ret_temp = deci_kelvin_to_millicelsius(temp);
-       } else {
-               acpi_handle_debug(adev->handle, "%s result %llu out of range\n",
-                                 obj_name, temp);
-               *ret_temp = THERMAL_TEMP_INVALID;
-       }
-
-       return 0;
-}
-
-/**
- * thermal_acpi_active_trip_temp - Retrieve active trip point temperature
- * @adev: Target thermal zone ACPI device object.
- * @id: Active cooling level (0 - 9).
- * @ret_temp: Address to store the retrieved temperature value on success.
- *
- * Evaluate the _ACx object for the thermal zone represented by @adev to obtain
- * the temperature of the active cooling trip point corresponding to the active
- * cooling level given by @id.
- *
- * Return 0 on success or a negative error value on failure.
- */
-int thermal_acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp)
-{
-       char obj_name[] = {'_', 'A', 'C', '0' + id, '\0'};
-
-       if (id < 0 || id > 9)
-               return -EINVAL;
-
-       return thermal_acpi_trip_temp(adev, obj_name, ret_temp);
-}
-EXPORT_SYMBOL_GPL(thermal_acpi_active_trip_temp);
-
-/**
- * thermal_acpi_passive_trip_temp - Retrieve passive trip point temperature
- * @adev: Target thermal zone ACPI device object.
- * @ret_temp: Address to store the retrieved temperature value on success.
- *
- * Evaluate the _PSV object for the thermal zone represented by @adev to obtain
- * the temperature of the passive cooling trip point.
- *
- * Return 0 on success or -ENODATA on failure.
- */
-int thermal_acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp)
-{
-       return thermal_acpi_trip_temp(adev, "_PSV", ret_temp);
-}
-EXPORT_SYMBOL_GPL(thermal_acpi_passive_trip_temp);
-
-/**
- * thermal_acpi_hot_trip_temp - Retrieve hot trip point temperature
- * @adev: Target thermal zone ACPI device object.
- * @ret_temp: Address to store the retrieved temperature value on success.
- *
- * Evaluate the _HOT object for the thermal zone represented by @adev to obtain
- * the temperature of the trip point at which the system is expected to be put
- * into the S4 sleep state.
- *
- * Return 0 on success or -ENODATA on failure.
- */
-int thermal_acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp)
-{
-       return thermal_acpi_trip_temp(adev, "_HOT", ret_temp);
-}
-EXPORT_SYMBOL_GPL(thermal_acpi_hot_trip_temp);
-
-/**
- * thermal_acpi_critical_trip_temp - Retrieve critical trip point temperature
- * @adev: Target thermal zone ACPI device object.
- * @ret_temp: Address to store the retrieved temperature value on success.
- *
- * Evaluate the _CRT object for the thermal zone represented by @adev to obtain
- * the temperature of the critical cooling trip point.
- *
- * Return 0 on success or -ENODATA on failure.
- */
-int thermal_acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp)
-{
-       return thermal_acpi_trip_temp(adev, "_CRT", ret_temp);
-}
-EXPORT_SYMBOL_GPL(thermal_acpi_critical_trip_temp);
index 54189e0e5f419a36f822d34f8b6021f6e7f50318..b63d7811c72873b52947c580bb049ef46e37e9df 100644 (file)
@@ -424,6 +424,13 @@ extern int acpi_blacklisted(void);
 extern void acpi_osi_setup(char *str);
 extern bool acpi_osi_is_win8(void);
 
+#ifdef CONFIG_ACPI_THERMAL_LIB
+int thermal_acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp);
+int thermal_acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp);
+int thermal_acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp);
+int thermal_acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp);
+#endif
+
 #ifdef CONFIG_ACPI_NUMA
 int acpi_map_pxm_to_node(int pxm);
 int acpi_get_node(acpi_handle handle);
index cee814d5d1accf632971eb1718f370cfd5a004c8..35f6200594569b55bee8583cb551ade1c68a94ca 100644 (file)
@@ -294,13 +294,6 @@ int thermal_zone_get_num_trips(struct thermal_zone_device *tz);
 
 int thermal_zone_get_crit_temp(struct thermal_zone_device *tz, int *temp);
 
-#ifdef CONFIG_THERMAL_ACPI
-int thermal_acpi_active_trip_temp(struct acpi_device *adev, int id, int *ret_temp);
-int thermal_acpi_passive_trip_temp(struct acpi_device *adev, int *ret_temp);
-int thermal_acpi_hot_trip_temp(struct acpi_device *adev, int *ret_temp);
-int thermal_acpi_critical_trip_temp(struct acpi_device *adev, int *ret_temp);
-#endif
-
 #ifdef CONFIG_THERMAL
 struct thermal_zone_device *thermal_zone_device_register_with_trips(
                                        const char *type,
This page took 0.072782 seconds and 4 git commands to generate.