From 9bf32b9701ddabb3a584f47247416b4a16d1902b Mon Sep 17 00:00:00 2001 From: Raul E Rangel Date: Wed, 12 May 2021 17:03:40 -0600 Subject: drivers/acpi: Add a chip driver to generate thermal zone Given the following device tree entry: chip drivers/acpi/thermal_zone register "description" = ""CPU"" use chrome_ec as temperature_controller register "sensor_id" = "0" register "polling_period" = "10" register "critical_temperature" = "91" register "passive_config" = "{ .temperature = 85, }" register "use_acpi1_thermal_zone_scope" = "true" device generic 0 on end end It will generate the following: Scope (\_TZ) { ThermalZone (TM00) { Name (_STR, "CPU") // _STR: Description String Name (_RTV, Zero) // _RTV: Relative Temperature Values Name (_TZP, 0x64) // _TZP: Thermal Zone Polling Name (_CRT, 0x0E39) // _CRT: Critical Temperature Name (_PSV, 0x0DFD) // _PSV: Passive Temperature Name (_PSL, Package (0x10) // _PSL: Passive List { \_SB.CP00, \_SB.CP01, \_SB.CP02, \_SB.CP03, \_SB.CP04, \_SB.CP05, \_SB.CP06, \_SB.CP07, \_SB.CP08, \_SB.CP09, }) Name (_TC1, 0x02) // _TC1: Thermal Constant 1 Name (_TC2, 0x05) // _TC2: Thermal Constant 2 Name (_TSP, 0x14) // _TSP: Thermal Sampling Period Method (_TMP, 0, Serialized) // _TMP: Temperature { Return (\_SB.PCI0.LPCB.EC0.CREC.TMP (Zero)) } } } BUG=b:186166365 TEST=Boot guybrush to OS and verify thermal zone works Signed-off-by: Raul E Rangel Change-Id: Iee2a42db749f18eef6c3f73cdbb3441567301e5d Reviewed-on: https://review.coreboot.org/c/coreboot/+/54132 Tested-by: build bot (Jenkins) Reviewed-by: Karthik Ramasubramanian --- src/drivers/acpi/thermal_zone/chip.h | 63 ++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 src/drivers/acpi/thermal_zone/chip.h (limited to 'src/drivers/acpi/thermal_zone/chip.h') diff --git a/src/drivers/acpi/thermal_zone/chip.h b/src/drivers/acpi/thermal_zone/chip.h new file mode 100644 index 0000000000..5792e4c961 --- /dev/null +++ b/src/drivers/acpi/thermal_zone/chip.h @@ -0,0 +1,63 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __DRIVERS_ACPI_THERMAL_ZONE_H__ +#define __DRIVERS_ACPI_THERMAL_ZONE_H__ + +#include + +/* + * All temperature units are in Celsius. + * All time units are in seconds. + */ +struct drivers_acpi_thermal_zone_config { + /* Description of the thermal zone */ + const char *description; + + /* + * Device that will provide the temperature reading + * + * This device must have an ACPI method named `TMP` that accepts the + * sensor ID as the first argument. It must then return an Integer containing the + * sensor's temperature in deci-Kelvin. + */ + DEVTREE_CONST struct device *temperature_controller; + + /* Used to identify the temperature sensor */ + unsigned int sensor_id; + + /* The polling period in seconds for this thermal zone. */ + unsigned int polling_period; + + /* The temperature (_CRT) at which the OS must shutdown the system. */ + unsigned int critical_temperature; + + /* The temperature (_HOT) at which the OS may choose to hibernate the system */ + unsigned int hibernate_temperature; + + struct acpi_thermal_zone_passive_config { + /* + * The temperature (_PSV) at which the OS must activate passive cooling (i.e., + * throttle the CPUs). + */ + unsigned int temperature; + + /** + * DeltaP[%] = _TC1 * (Tn - Tn-1) + _TC2 * (Tn - Tt) + * Where: + * Tn = current temperature + * Tt = target temperature (_PSV) + * + * If any of these values are 0, then one of the following defaults will be + * used: TC1: 2, TC2: 5, TSP: 10 + */ + unsigned int time_constant_1; + unsigned int time_constant_2; + unsigned int time_sampling_period; + + } passive_config; + + /* Place the ThermalZone in the \_TZ scope */ + bool use_acpi1_thermal_zone_scope; +}; + +#endif /* __DRIVERS_ACPI_THERMAL_ZONE_H__ */ -- cgit v1.2.3