Skip to content

hwmon: macsmc: Move SoC die and pressure key data into DT - #642

Merged
RyanTheTide merged 6 commits into
aurora-wipfrom
hwmon/macsmc-die-pressure-dt
Oct 30, 2026
Merged

RyanTheTide merged 6 commits into
aurora-wipfrom
hwmon/macsmc-die-pressure-dt

Conversation

@RyanTheTide

Copy link
Copy Markdown
Contributor

The remaining macsmc-hwmon board fallback moves into DT. J516s, J516c and J514c now describe their SoC die keys in their board files; J516s also describes its mTPL thermal pressure key. The driver consumes that data and removes macsmc_hwmon_boards[], board_keys and soc_die_keys.

Depends on #639. This branch includes its three commits unchanged, followed by three new commits for the binding, board data and driver. Merge #639 first. The fan implementation from #639 and the fan curves discussed in #579 are unchanged.

apple,soc-die-keys is an ordered string list on the hwmon node. Its channels follow the existing temperature children, retaining the old labels, key validation, hottest-sensor zone and failed-read behavior. apple,thermal-pressure-key now has a binding and no board fallback. These two features follow DT data without an M3-compatible gate. The existing M3 sensor-export validation and debugfs policy remain unchanged.

Migrated board Die keys preserved, in order Pressure key
J516s / T6030 14 mTPL
J516c / T6031 25 none
J514c / T6031 25 none

The J516s list retains its unconfirmed status; J514c retains its assumption that it matches J516c. Missing or unsupported firmware keys continue to be skipped. Install the matching DTB with the new kernel: older DTBs no longer receive the removed C fallback.

The mainline v7.3 driver and Documentation/hwmon/macsmc-hwmon.rst expose and document fan_control, but neither soc_die_keys nor board_keys. The documented fan_control override therefore stays exactly as in #639. With it unset, DT decides fan writability.

Validation completed:

  • Strict checkpatch passes on each of the three new commits, with zero errors, warnings or checks. git diff --check passes.
  • dt-doc-validate passes for the updated binding.
  • DTValidator passes the 40 hwmon nodes reconstructed from preprocessed source, with zero schema errors.
  • A source inventory comparison covers every one of the 117 Apple DTB targets in the Makefile. It resolves hwmon overrides and deletions and adds the old C fallback to the baseline. Before and after inventories are identical, including channel order, fan properties, all 64 die keys and the pressure key. Firmware-dependent discovery is recorded as a property; this does not claim runtime enumeration.

Pending validation: kernel compilation, make dt_binding_check and full dtbs_check on all Apple DTBs. The controller refused the worker's buildbox request and lease acquisition because a buildbox lease requires an operator. No buildbox SSH workaround was used. This PR remains a draft until those checks run. No target machine was accessed and no hardware test below was executed.

Owner read-only checks, with the new kernel and matching DTB installed and fan_control unset:

read_only_checks() {
    expected=$1
    tr '\0' '\n' < /proc/device-tree/compatible | grep -Fx "$expected" || return 1
    uname -r
    cat /sys/module/macsmc_hwmon/parameters/fan_control
    ls -l /sys/class/hwmon/*/fan*_target 2>/dev/null || true

    for h in /sys/class/hwmon/hwmon*; do
        [ -r "$h/name" ] || continue
        [ "$(cat "$h/name")" = macsmc_hwmon ] || continue
        for label in "$h"/temp*_label; do
            [ -r "$label" ] || continue
            printf '%s: ' "$(cat "$label")"
            cat "${label%_label}_input"
        done
        if [ -r "$h/thermal_pressure_level" ]; then
            printf 'thermal_pressure_level: '
            cat "$h/thermal_pressure_level"
        else
            printf 'thermal_pressure_level: absent\n'
        fi
    done

    aggregate=absent
    for z in /sys/class/thermal/thermal_zone*; do
        [ -r "$z/type" ] || continue
        type=$(cat "$z/type")
        printf '%s: ' "$type"
        cat "$z/temp" || printf 'temperature read failed\n'
        [ "$type" != macsmc_soc_die ] || aggregate=present
    done
    printf 'macsmc_soc_die: %s\n' "$aggregate"
}

# Run only the command matching the machine being checked:
read_only_checks apple,j616s
read_only_checks apple,j316s
read_only_checks apple,j413
read_only_checks apple,j700

# Also verify each migrated board when available:
read_only_checks apple,j516s
read_only_checks apple,j516c
read_only_checks apple,j514c
Machine Expected fan target permissions with override unset Die/zone check
J616s / T6040 two 0644 targets, from #639 Read cpu-die-thermal and all other existing zones above. No new macsmc_soc_die zone.
J316s / T6000 two 0444 targets Record existing zones and temperatures; macsmc_soc_die remains absent.
J413 / T8112 no fan targets Record existing zones and temperatures; macsmc_soc_die remains absent.
J700 / T8140 no fan targets Read existing cpu-e0-thermal and cpu-p*-thermal temperatures above. No new macsmc_soc_die zone.

These four boards had no entries in the removed table. Their static hwmon inventory is unchanged: J616s 480 channels, J316s 13, J413 11, J700 205. On the three migrated M3 boards, check the SoC die <key> channels and macsmc_soc_die temperature; J516s should also expose thermal_pressure_level if its firmware supplies a valid mTPL key. Counts of live channels can be lower when firmware keys are missing.

J616s owner-only manual fan test, as root, after the read-only checks confirm identity, both writable targets and the default fan_control=N. Test each fan and drop each request with echo 0; the trap also drops both requests on exit or interruption:

tr '\0' '\n' < /proc/device-tree/compatible | grep -Fx apple,j616s || exit 1
h=
for candidate in /sys/class/hwmon/hwmon*; do
    [ -r "$candidate/name" ] || continue
    if [ "$(cat "$candidate/name")" = macsmc_hwmon ]; then
        h=$candidate
        break
    fi
done
test -n "$h" || exit 1
test "$(cat /sys/module/macsmc_hwmon/parameters/fan_control)" = N || exit 1
test -w "$h/fan1_target" && test -w "$h/fan2_target" || exit 1
(
    set -e
    trap 'echo 0 > "$h/fan1_target"; echo 0 > "$h/fan2_target"' EXIT
    trap 'exit 1' HUP INT TERM
    for fan in 1 2; do
        echo 3000 > "$h/fan${fan}_target"
        sleep 8
        cat "$h/fan${fan}_target" "$h/fan${fan}_input"
        echo 0 > "$h/fan${fan}_target"
        sleep 8
        cat "$h/fan${fan}_target" "$h/fan${fan}_input"
    done
)

Rollback is echo 0 to both targets. This drops the manual requests and restores the existing thermal/firmware control path; an active thermal cooling request can still keep a fan running. No reboot is required for this rollback.

🤖 Generated with Claude Code

Whether a Mac's SMC firmware accepts a manual fan speed from the host,
and hands the fan back when asked, is a property of that machine. Add a
boolean, apple,fan-manual-control, for the fan nodes that have it. It
needs the fan's target and mode keys.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
fanX_target is only writable with the unsafe fan_control parameter, so a
machine whose SMC is known to take manual speeds still needs a kernel
parameter for it. Make fanX_target writable on the fans whose node has
apple,fan-manual-control, and warn when the property is set on a fan
without target and mode keys.

fan_control stays. It is the documented mainline interface for this,
and dropping it would leave existing command lines and modprobe options
with an unknown-parameter warning and without the speeds they ask for.
It now only adds fans the device tree does not allow. Nothing changes
for machines without the property, the thermal cooling device path or
the unlock and restore sequence.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
The J616s SMC keeps its fans in system mode, takes a manual speed once
the fan test key unlocks them (hwmon: macsmc: Unlock fan control on
firmware that keeps fans in system mode), and returns both fans to
system mode when the request is dropped. The batch1 fan test showed
both fans following the requested targets and going back to firmware
control with no warnings. Mark both fans apple,fan-manual-control so
this works without the fan_control parameter.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Describe an ordered list of SoC die temperature keys and the optional
firmware thermal pressure key on the SMC hwmon node. Specify the key
formats and preserve the temperature child indices used by thermal zones.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Move the J516s, J516c and J514c die key lists from the hwmon board table
into their board device trees, retaining every key and its order. Add the
J516s mTPL pressure key and keep the existing qualification of the
unconfirmed J516s and assumed J514c sensor lists.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
Use apple,soc-die-keys to append validated die temperature channels after
the existing temperature children. Register the hottest-sensor zone and
pressure attribute from DT data without a machine-compatible gate. Keep
the current validation and failed-read behavior.

All three board table entries now have matching DT data, so remove the
table and the downstream soc_die_keys and board_keys parameters. Neither
parameter is present in the mainline v7.3 driver or its documentation.
Keep the documented fan_control override and DT fan support from the
preceding fan-control series unchanged.

Document the new properties and the requirement to update the DTB with
the kernel when replacing the former board fallback.

Assisted-by: LLM
Signed-off-by: Ryan Murray <ryan@aurorasilicon.org>
@RyanTheTide
RyanTheTide marked this pull request as ready for review October 30, 2026 17:13
@RyanTheTide
RyanTheTide merged commit 8a8805d into aurora-wip Oct 30, 2026
1 check passed
@RyanTheTide
RyanTheTide deleted the hwmon/macsmc-die-pressure-dt branch October 30, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant