From 31d02f9c611d7ad984b8622fe61062e08d81373d Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 14 Nov 2026 19:22:01 +0700 Subject: [PATCH 1/2] dt-bindings: hwmon: apple,smc-hwmon: Name the SoC die thermal sensor A node with apple,discover-temperatures has no stable channel indices, so a thermal zone cannot name one of its temperature channels. Let such a node be a thermal sensor provider for one sensor, 1000: the hottest of its apple,soc-die-keys readings. A zone on it comes in addition to the driver's tripless macsmc_soc_die zone, which in-kernel users look up by name. Signed-off-by: Nick --- .../devicetree/bindings/hwmon/apple,smc-hwmon.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml b/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml index b0b1dac1225ee..b01f2607731d0 100644 --- a/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml +++ b/Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml @@ -90,7 +90,11 @@ 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 comes in addition to the macsmc_soc_die zone, + which is still registered for the users that look it up by name. "#cooling-cells": const: 3 From dfdafea293695de1715b45d92bf9335c48aee4d4 Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 14 Nov 2026 19:22:52 +0700 Subject: [PATCH 2/2] hwmon: macsmc: offer the SoC die zone to a device tree thermal zone A board that discovers its SMC temperatures (apple,discover-temperatures, as the M5 Airs do) has no stable channel indices, so a device tree thermal zone cannot name one of its temperature channels, and the hottest-die zone is registered without trips. Such a board then has no thermal policy of its own. When the node is a thermal sensor provider, offer the hottest-die reading as sensor 1000, above any channel index the hwmon core registers. A zone on it gets the board's trips and cooling maps. The tripless macsmc_soc_die zone is still registered in every case: the asahi GPU drivers' governors (g17 and m3) read the SoC hotspot from that zone by name, and a device tree zone's name cannot be macsmc_soc_die (no '_' in a node name). Discovered channels are not bounded at build time, so a node with 1000 or more of them keeps the tripless zone, with a warning. No board uses it yet: the J815 zone waits for limits the boot loader reads from the machine. Signed-off-by: Nick --- drivers/hwmon/macsmc-hwmon.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/hwmon/macsmc-hwmon.c b/drivers/hwmon/macsmc-hwmon.c index 50591b3d1d55b..69d12ceb859ff 100644 --- a/drivers/hwmon/macsmc-hwmon.c +++ b/drivers/hwmon/macsmc-hwmon.c @@ -1354,6 +1354,13 @@ 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 + * must stay above every temperature channel index the hwmon core registers; + * discovered channels are not bounded at build time, so probe checks it. + */ +#define MACSMC_SOC_DIE_SENSOR_ID 1000 #define MACSMC_DIE_MIN_MC -40000 #define MACSMC_DIE_MAX_MC 150000 @@ -1425,6 +1432,27 @@ 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. The named tripless zone below + * is registered either way: the GPU drivers' governors look it up by its name. + */ + if (of_property_present(hwmon->dev->of_node, "#thermal-sensor-cells") && + hwmon->temp.count >= MACSMC_SOC_DIE_SENSOR_ID) { + dev_warn(hwmon->dev, "%u temperature channels reach the SoC die sensor ID %u\n", + hwmon->temp.count, MACSMC_SOC_DIE_SENSOR_ID); + } else 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); + else 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)) {