Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions drivers/hwmon/macsmc-hwmon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)) {
Expand Down
Loading