diff --git a/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml b/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml index b0b1dac1225ee..7a52d89338b33 100644 --- a/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml +++ b/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml @@ -90,7 +90,10 @@ properties: const: 1 description: The cell is the zero-based index of a temperature channel, counting - the temperature-* child nodes in order. + the temperature-* child nodes in order. With + apple,discover-temperatures, whose channel indices are not stable, the + only sensor is 1000, the hottest of the apple,soc-die-keys readings; + a thermal zone on it replaces the macsmc_soc_die zone. "#cooling-cells": const: 3 diff --git a/arch/arm64/boot/dts/apple/t8142-j815.dts b/arch/arm64/boot/dts/apple/t8142-j815.dts index c45d185c87c4c..d90ff5c021768 100644 --- a/arch/arm64/boot/dts/apple/t8142-j815.dts +++ b/arch/arm64/boot/dts/apple/t8142-j815.dts @@ -20,6 +20,7 @@ /dts-v1/; #include "t8142.dtsi" +#include / { compatible = "apple,j815", "apple,t8142", "apple,arm-platform"; @@ -44,63 +45,139 @@ status = "disabled"; }; }; + + /* + * The J815 has no fan. One zone on the hottest SoC die reading (the 26 + * apple,soc-die-keys below) slows the CPU clusters as the die heats, + * with the power allocator and the clusters' energy model. + * + * Sustainable power is an estimate to be tuned by a soak: the J815 + * ADT's clpc pkg-sustainable-power-target is 12.5 W (0xc8000, 16.16), + * the J700's 5.5 W, where macOS holds the J700 CPUs at 4.1-4.3 W + * (about 76%, the J700 zones' 4200). The same share of 12.5 W gives + * the 9000 mW here. The control point is held below the 105 C the + * fanless J700 runs at, until a J815 soak under macOS gives its own + * value; the PMP and SMC still enforce the hardware limits. + */ + thermal-zones { + soc-die-thermal { + polling-delay-passive = <500>; + polling-delay = <1000>; + thermal-sensors = <&smc_hwmon 1000>; + sustainable-power = <9000>; + + trips { + soc_die_alert: trip-alert { + temperature = <60000>; + hysteresis = <2000>; + type = "passive"; + }; + + soc_die_control: trip-control { + temperature = <100000>; + hysteresis = <2000>; + type = "passive"; + }; + + trip-critical { + temperature = <115000>; + hysteresis = <0>; + type = "critical"; + }; + }; + + cooling-maps { + map-p { + trip = <&soc_die_control>; + cooling-device = + <&cpu6 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu7 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu8 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu9 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + contribution = <1024>; + }; + + map-e { + trip = <&soc_die_control>; + cooling-device = + <&cpu0 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu1 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu2 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu3 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu4 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>, + <&cpu5 THERMAL_NO_LIMIT THERMAL_NO_LIMIT>; + contribution = <3072>; + }; + }; + }; + }; }; &cpu0 { + #cooling-cells = <2>; operating-points-v2 = <&ecluster_opp>; performance-domains = <&cpufreq_e>; status = "okay"; }; &cpu1 { + #cooling-cells = <2>; operating-points-v2 = <&ecluster_opp>; performance-domains = <&cpufreq_e>; status = "okay"; }; &cpu2 { + #cooling-cells = <2>; operating-points-v2 = <&ecluster_opp>; performance-domains = <&cpufreq_e>; status = "okay"; }; &cpu3 { + #cooling-cells = <2>; operating-points-v2 = <&ecluster_opp>; performance-domains = <&cpufreq_e>; status = "okay"; }; &cpu4 { + #cooling-cells = <2>; operating-points-v2 = <&ecluster_opp>; performance-domains = <&cpufreq_e>; status = "okay"; }; &cpu5 { + #cooling-cells = <2>; operating-points-v2 = <&ecluster_opp>; performance-domains = <&cpufreq_e>; status = "okay"; }; &cpu6 { + #cooling-cells = <2>; operating-points-v2 = <&pcluster_opp>; performance-domains = <&cpufreq_p>; status = "okay"; }; &cpu7 { + #cooling-cells = <2>; operating-points-v2 = <&pcluster_opp>; performance-domains = <&cpufreq_p>; status = "okay"; }; &cpu8 { + #cooling-cells = <2>; operating-points-v2 = <&pcluster_opp>; performance-domains = <&cpufreq_p>; status = "okay"; }; &cpu9 { + #cooling-cells = <2>; operating-points-v2 = <&pcluster_opp>; performance-domains = <&cpufreq_p>; status = "okay"; @@ -236,7 +313,9 @@ * thermal zone. */ &smc { - hwmon { + smc_hwmon: hwmon { + /* Sensor 1000 is the hottest of the die keys (soc-die-thermal). */ + #thermal-sensor-cells = <1>; apple,soc-die-keys = "Te04", "Te08", "Te0C", "Te0R", "Tp00", "Tp04", "Tp0C", "Tp0G", "Tp0O", "Tp0R", "Tp0X", "Tp0a", "Tp0p", "Tp0u", diff --git a/drivers/hwmon/macsmc-hwmon.c b/drivers/hwmon/macsmc-hwmon.c index c519c70755c00..fa821387acdc7 100644 --- a/drivers/hwmon/macsmc-hwmon.c +++ b/drivers/hwmon/macsmc-hwmon.c @@ -1354,6 +1354,12 @@ static void macsmc_hwmon_populate_fan_configs(u32 *configs, const struct macsmc_ */ #if IS_ENABLED(CONFIG_THERMAL) #define MACSMC_SOC_DIE_ZONE "macsmc_soc_die" +/* + * The thermal sensor ID of the SoC die zone for a device tree thermal zone, on + * a node that discovers its temperatures and is a thermal sensor provider. It + * is above any temperature channel index, which the hwmon core registers. + */ +#define MACSMC_SOC_DIE_SENSOR_ID 1000 #define MACSMC_DIE_MIN_MC -40000 #define MACSMC_DIE_MAX_MC 150000 @@ -1425,6 +1431,24 @@ static int macsmc_hwmon_die_register(struct macsmc_hwmon *hwmon) key >> 24, (key >> 16) & 0xff, (key >> 8) & 0xff, key & 0xff); } + /* + * A board with a device tree zone on the die sensor gets that zone, with its trips and + * cooling maps. Its lifetime is managed by the OF helper. + */ + if (of_property_present(hwmon->dev->of_node, "#thermal-sensor-cells")) { + tz = devm_thermal_of_zone_register(hwmon->dev, MACSMC_SOC_DIE_SENSOR_ID, hwmon, + &macsmc_hwmon_die_ops); + if (!IS_ERR(tz)) { + dev_info(hwmon->dev, "SoC die zone %s (device tree): hottest of%s (%u of %u keys)\n", + thermal_zone_device_type(tz), keys, hwmon->die_count, + hwmon->die_listed); + return 0; + } + if (PTR_ERR(tz) != -ENODEV) + dev_warn(hwmon->dev, + "cannot register the device tree SoC die zone (%pe)\n", tz); + } + tz = thermal_tripless_zone_device_register(MACSMC_SOC_DIE_ZONE, hwmon, &macsmc_hwmon_die_ops, NULL); if (IS_ERR(tz)) {