APPLE_SMC(4)

NAME
apple_smc - Apple System Management Controller driver

SYNOPSIS
To compile this driver into the kernel, place the following line in your kernel configuration file:

device apple_smc

Alternatively, to load the driver as a module at boot time, place the following line in loader.conf(5):

    apple_smc_load="YES"

DESCRIPTION
The apple_smc driver provides support for the System Management Controller (SMC) found in Apple Macintosh computers. The SMC manages fans, temperature sensors, keyboard backlight, ambient light sensors, the Sudden Motion Sensor (SMS), and various system state keys.

The driver supports two hardware backends:

•   ISA I/O port (port 0x300) on Intel Macs through iMac13,x.

•   MMIO register window on newer Intel Macs (iMac14,x and later), including those with an Apple T2 security chip.

The MMIO backend is probed first. If a memory-mapped BAR is present and responds, the driver uses MMIO; otherwise it falls back to ISA port I/O. T2 Macs are identified by an RGEN key value of 3.

All sensor values and controls are exposed through the sysctl(8) interface under dev.apple_smc.0.

SYSCTL VARIABLES

  Fan Controls
Each fan is exposed under dev.apple_smc.0.fan.<N> where <N> is the fan number starting from 0.

dev.apple_smc.0.fan.<N>.id
    (read-only) Fan model identification string.

dev.apple_smc.0.fan.<N>.speed
    (read-only) Current fan speed in RPM.

dev.apple_smc.0.fan.<N>.safespeed
    (read-only) Fan safe speed in RPM. Only present if the hardware reports a safe speed key.

dev.apple_smc.0.fan.<N>.minspeed
    Minimum fan speed in RPM.

dev.apple_smc.0.fan.<N>.maxspeed
    Maximum fan speed in RPM.

dev.apple_smc.0.fan.<N>.targetspeed
    Target fan speed in RPM.

dev.apple_smc.0.fan.<N>.manual
    Fan manual mode. Set to 1 to disable automatic fan control, 0 to re-enable it. On T2 Macs this uses the per-fan F<N>Md key; on older Macs it uses the global FS! bitmask.

  Temperature Sensors
Temperature sensors are auto-detected at attach time by scanning the SMC key namespace for keys in the ‘T’ range with sp78 type (signed 8.8 fixed-point, millidegrees Celsius).

Sensors whose probe read returns a value below -10000 millidegrees are classified as Intel DTS (distance-to-Tj,max) sensors and placed under a separate dts subtree. The sysctl handler converts DTS readings to absolute temperature using the Tj,max value read from MSR 0x1A2 at attach time. Sensors returning -120000 or below are treated as disconnected and are not registered.

dev.apple_smc.0.temp.<KEY>
    (read-only) Absolute temperature in millidegrees Celsius. <KEY> is the 4-character SMC key name, e.g. ‘TC0D’ for CPU die temperature.

dev.apple_smc.0.temp.dts.<KEY>
    (read-only) DTS sensor converted to absolute temperature.

  Voltage, Current, and Power Sensors
Voltage, current, and power sensors are auto-detected by scanning the ‘V’, ‘I’, and ‘P’ key ranges respectively. Values are reported in millivolts, milliamps, or milliwatts.

dev.apple_smc.0.voltage.<KEY>
    (read-only) Voltage in millivolts.

dev.apple_smc.0.current.<KEY>
    (read-only) Current in milliamps.

dev.apple_smc.0.power.<KEY>
    (read-only) Power in milliwatts.

  Ambient Light Sensors

dev.apple_smc.0.ambient.<KEY>
    (read-only) Ambient light sensor reading. Keys are typically ‘ALV0’, ‘ALV1’, etc.

  Keyboard Backlight

dev.apple_smc.0.light.left
    (read-only) Left ambient light sensor value used for keyboard backlight. On newer models with 10-byte payloads, a dedicated decoder is used.

dev.apple_smc.0.light.right
    (read-only) Right ambient light sensor value. Only present on models with a separate right sensor and 6-byte payloads.

dev.apple_smc.0.light.control
    Keyboard backlight brightness, 0 (off) to 255 (maximum). The value is cached and restored on resume from suspend.

  Sudden Motion Sensor (SMS)
The SMS provides three-axis accelerometer data. It is only present on MacBook and MacBook Pro models with a built-in hard disk motion sensor.

SMS events are delivered to devd(8) with system ‘ACPI’, subsystem ‘apple_smc’, and type ‘SMS’. The notify value encodes the event type: 0 = shock, 1 = high acceleration, 2 = free fall.

dev.apple_smc.0.sms.x
    (read-only) Accelerometer X axis value.

dev.apple_smc.0.sms.y
    (read-only) Accelerometer Y axis value.

dev.apple_smc.0.sms.z
    (read-only) Accelerometer Z axis value.

  System State
These sysctls are only present if the corresponding SMC key exists on the hardware.

dev.apple_smc.0.system.shutdown_cause
    (read-only) Last shutdown cause as reported by the MSSD key, decoded to a human-readable string where known (e.g. “5 (good-shutdown)”).

dev.apple_smc.0.system.sleep_cause
    (read-only) Last sleep cause (MSSP).

dev.apple_smc.0.system.thermal_status
    (read-only) Thermal subsystem alert flags (MSAL). Decoded bits include TSS, thermal validity, calibration validity, PROCHOT assertion, and power limits.

dev.apple_smc.0.system.time_of_day
    (read-only) SMC clock: seconds since midnight (CLKT).

dev.apple_smc.0.system.wake_time
    Scheduled wake time: seconds since midnight, 0 to disable (CLWK). On write, the driver verifies the value stuck by reading it back; if the SMC uses little-endian encoding on a particular model, a LE retry is attempted automatically.

dev.apple_smc.0.system.power_state
    (read-only) SMC power state index (MSPS).

dev.apple_smc.0.system.board_id
    (read-only) Apple board codename, e.g. ‘Mac-27ADBB7B4CEE8E61’ (RPlt).

dev.apple_smc.0.system.chip_gen
    (read-only) Apple chip generation; a value of 3 indicates a T2 coprocessor (RGEN).

dev.apple_smc.0.system.prochot_override
    Only present when the driver overrode a PROCHOT# assertion at attach time. Set to 1 to keep BD_PROCHOT cleared (CPU ignores external PROCHOT#), 0 to restore it and return fans to SMC automatic control. See PROCHOT OVERRIDE below.

dev.apple_smc.0.system.g3_poweron_time
    Scheduled power-on from S5 (mechanical-off) as a Unix timestamp; 0 disables the timer (G3AO).

dev.apple_smc.0.system.g3_watchdog
    G3 watchdog flag paired with g3_poweron_time (G3WD).

dev.apple_smc.0.system.ac_wake_timer
    Delay in seconds before auto power-on after AC reconnect (AUWT). Only effective when always_up is enabled.

dev.apple_smc.0.system.display_brightness_raw
    (read-only) Raw display brightness value from the SMC (DPBR). Returns 0xffff on machines without an internal display.

dev.apple_smc.0.system.chassis_state
    (read-only) Chassis/environment state byte (ENV0).

dev.apple_smc.0.system.sw_thermal_throttle_disable
    Software thermal throttle disable flag (STFD). Set to 1 to disable SMC software thermal throttling.

  Battery Charge Limit (T2 only)

dev.apple_smc.0.battery_charge_limit
    Battery charge limit percentage, 0 to 100 (BCLM). Only present on T2 Macs.

  Always-Up

dev.apple_smc.0.always_up
    Prevent the machine from staying powered off. The machine will automatically power on after any shutdown. Set to 1 to enable, 0 to disable (AUPO).

  Thermal Governor
When the driver overrides PROCHOT and takes fans into manual mode (see PROCHOT OVERRIDE), a thermal governor kernel thread is started to manage fan speeds based on CPU temperature. The governor is only active when fans are under manual override.

The governor implements a linear fan curve between configurable low and high temperature thresholds. Below temp_low, fans run at their minimum speed. Above temp_high, fans run at their maximum speed. A hysteresis deadband prevents oscillation near the thresholds. Fan ramp-down is rate-limited to 200 RPM per governor tick to avoid abrupt speed changes, while ramp-up is immediate.

An emergency threshold forces all fans to maximum speed regardless of the fan curve. If a temperature sensor read fails, the governor assumes the worst case and sets fans to maximum (fail-hot).

dev.apple_smc.0.thermal.enabled
    Enable (1) or disable (0) the thermal governor. Disabling it sets all override fans to maximum speed for safety.

dev.apple_smc.0.thermal.interval
    Poll interval in seconds (default: 5).

dev.apple_smc.0.thermal.temp_low
    Temperature in millidegrees Celsius below which fans run at minimum speed (default: 55000, i.e. 55°C).

dev.apple_smc.0.thermal.temp_high
    Temperature in millidegrees Celsius above which fans run at maximum speed (default: 80000, i.e. 80°C).

dev.apple_smc.0.thermal.hysteresis
    Hysteresis deadband in millidegrees Celsius to prevent fan speed oscillation (default: 3000, i.e. 3°C).

dev.apple_smc.0.thermal.emergency
    Emergency temperature in millidegrees Celsius; if any sensor exceeds this, all fans are forced to maximum (default: 90000, i.e. 90°C).

  Raw Key Access
A raw SMC key access interface is available under dev.apple_smc.0.raw for diagnostics and exploration of undocumented keys.

dev.apple_smc.0.raw.key
    Write a 4-character SMC key name to select it. The key's value, length, and type are read automatically.

dev.apple_smc.0.raw.value
    Read or write the selected key's value as a hexadecimal string.

dev.apple_smc.0.raw.len
    (read-only) Length of the selected key's value in bytes.

dev.apple_smc.0.raw.type
    (read-only) 4-character type code of the selected key.

dev.apple_smc.0.raw.index
    Write a numeric key index (0 to nkeys-1) to look up the key at that position in the SMC key table. Sets the raw key, value, length, and type fields accordingly.

PROCHOT OVERRIDE
The SMC may assert the external PROCHOT# signal when temperature sensors report disconnect sentinel values, or when the battery is absent. This throttles the CPU to its minimum frequency even though no real thermal event has occurred.

At attach time, the driver checks the SPHT key for an active PROCHOT# assertion. If a known benign cause is found (disconnected LCD sensors or absent/dead battery), the driver clears BD_PROCHOT (bit 0) in MSR 0x1FC (IA32_POWER_CTL) so the CPU ignores the external throttle signal. All other thermal protections (TCC, thermal monitor) remain active.

When PROCHOT is overridden, the driver also takes fans running at or above 90% of maximum (SMC failsafe) into manual mode. The FS! bitmask is read-modify-written to preserve internal SMC flag bits. The thermal governor reasserts manual mode on every poll tick, as the SMC periodically reclaims automatic control.

On S3 resume the driver re-applies the override (the MSR resets) and reasserts fan manual mode.

The override can be toggled at runtime via dev.apple_smc.0.system.prochot_override. Setting it to 0 restores BD_PROCHOT, sets fans to maximum, releases manual mode, and stops the thermal governor.

HARDWARE
The apple_smc driver supports any Intel Mac with ACPI device ‘APP0001’.

EXAMPLES
Read the CPU die temperature:

    sysctl dev.apple_smc.0.temp.TC0D

Set fan 0 to manual mode at 2000 RPM:

    sysctl dev.apple_smc.0.fan.0.manual=1
    sysctl dev.apple_smc.0.fan.0.targetspeed=2000

Check the last shutdown cause:

    sysctl dev.apple_smc.0.system.shutdown_cause

Limit battery charge to 80% on a T2 Mac:

    sysctl dev.apple_smc.0.battery_charge_limit=80

Schedule a power-on from S5 in one hour:

    sysctl dev.apple_smc.0.system.g3_poweron_time=$(date -v+1H +%s)

Adjust the thermal governor temperature range:

    sysctl dev.apple_smc.0.thermal.temp_low=50000
    sysctl dev.apple_smc.0.thermal.temp_high=75000

Look up SMC key by index:

    sysctl dev.apple_smc.0.raw.index=42
    sysctl dev.apple_smc.0.raw.key
    sysctl dev.apple_smc.0.raw.value

SEE ALSO
acpi(4), apple_fw(4), sysctl.conf(5), devd(8), sysctl(8)

HISTORY
The apple_smc driver first appeared in DragonFly 6.5.

AUTHORS
The apple_smc driver and this manual page were written by Abdelkader Boudih <dragonflybsd@seuros.com>.

CAVEATS
The thermal governor is only started when a PROCHOT override is active and fans are detected in SMC failsafe mode. On machines where PROCHOT is not asserted, fans remain under full SMC automatic control.

The CLWK key encoding (big-endian vs little-endian) varies by model. The driver attempts BE first and falls back to LE if the readback does not match.

Disabling the thermal governor via dev.apple_smc.0.thermal.enabled sets all override fans to maximum speed as a safety measure.