Commit 785205fd authored by James Calligeros's avatar James Calligeros Committed by Guenter Roeck
Browse files

hwmon: Add Apple Silicon SMC hwmon driver



The System Management Controller on Apple Silicon devices is responsible
for integrating and exposing the data reported by the vast array of
hardware monitoring sensors present on these devices. It is also
responsible for fan control, and allows users to manually set fan
speeds if they so desire. Add a hwmon driver to expose current,
power, temperature, and voltage monitoring sensors, as well as
fan speed monitoring and control via the SMC on Apple Silicon devices.

The SMC firmware has no consistency between devices, even when they
share an SoC. The FourCC keys used to access sensors are almost
random. An M1 Mac mini will have different FourCCs for its CPU core
temperature sensors to an M1 MacBook Pro, for example. For this
reason, the valid sensors for a given device are specified in a
child of the SMC Devicetree node. The driver uses this information
to determine which sensors to make available at runtime.

Reviewed-by: default avatarNeal Gompa <neal@gompa.dev>
Acked-by: default avatarGuenter Roeck <linux@roeck-us.net>
Co-developed-by: default avatarJanne Grunau <j@jannau.net>
Signed-off-by: default avatarJanne Grunau <j@jannau.net>
Signed-off-by: default avatarJames Calligeros <jcalligeros99@gmail.com>
Link: https://lore.kernel.org/r/20251112-macsmc-subdevs-v5-6-728e4b91fe81@gmail.com


[groeck: Added Documentation to index]
Signed-off-by: default avatarGuenter Roeck <linux@roeck-us.net>
parent d5c0ae87
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -144,6 +144,7 @@ Hardware Monitoring Kernel Drivers
   ltc4261
   ltc4282
   ltc4286
   macsmc-hwmon
   max127
   max15301
   max16064
+71 −0
Original line number Diff line number Diff line
.. SPDX-License-Identifier: GPL-2.0-only

Kernel driver macsmc-hwmon
==========================

Supported hardware

    * Apple Silicon Macs (M1 and up)

Author: James Calligeros <jcalligeros99@gmail.com>

Description
-----------

macsmc-hwmon exposes the Apple System Management controller's
temperature, voltage, current and power sensors, as well as
fan speed and control capabilities, via hwmon.

Because each Apple Silicon Mac exposes a different set of sensors
(e.g. the MacBooks expose battery telemetry that is not present on
the desktop Macs), sensors present on any given machine are described
via Devicetree. The driver picks these up and registers them with
hwmon when probed.

Manual fan speed is supported via the fan_control module parameter. This
is disabled by default and marked as unsafe, as it cannot be proven that
the system will fail safe if overheating due to manual fan control being
used.

sysfs interface
---------------

currX_input
    Ammeter value

currX_label
    Ammeter label

fanX_input
    Current fan speed

fanX_label
    Fan label

fanX_min
    Minimum possible fan speed

fanX_max
    Maximum possible fan speed

fanX_target
    Current fan setpoint

inX_input
    Voltmeter value

inX_label
    Voltmeter label

powerX_input
    Power meter value

powerX_label
    Power meter label

tempX_input
    Temperature sensor value

tempX_label
    Temperature sensor label
+2 −0
Original line number Diff line number Diff line
@@ -2438,12 +2438,14 @@ F: Documentation/devicetree/bindings/pwm/apple,s5l-fpwm.yaml
F:	Documentation/devicetree/bindings/spi/apple,spi.yaml
F:	Documentation/devicetree/bindings/spmi/apple,spmi.yaml
F:	Documentation/devicetree/bindings/watchdog/apple,wdt.yaml
F:	Documentation/hwmon/macsmc-hwmon.rst
F:	arch/arm64/boot/dts/apple/
F:	drivers/bluetooth/hci_bcm4377.c
F:	drivers/clk/clk-apple-nco.c
F:	drivers/cpufreq/apple-soc-cpufreq.c
F:	drivers/dma/apple-admac.c
F:	drivers/gpio/gpio-macsmc.c
F:	drivers/hwmon/macsmc-hwmon.c
F:	drivers/pmdomain/apple/
F:	drivers/i2c/busses/i2c-pasemi-core.c
F:	drivers/i2c/busses/i2c-pasemi-platform.c
+12 −0
Original line number Diff line number Diff line
@@ -1174,6 +1174,18 @@ config SENSORS_LTQ_CPUTEMP
	  If you say yes here you get support for the temperature
	  sensor inside your CPU.

config SENSORS_MACSMC_HWMON
	tristate "Apple SMC (Apple Silicon)"
	depends on MFD_MACSMC && OF
	help
	  This driver enables hwmon support for current, power, temperature,
	  and voltage sensors, as well as fan speed reporting and control
	  on Apple Silicon devices. Say Y here if you have an Apple Silicon
	  device.

	  This driver can also be built as a module. If so, the module will
	  be called macsmc-hwmon.

config SENSORS_MAX1111
	tristate "Maxim MAX1111 Serial 8-bit ADC chip and compatibles"
	depends on SPI_MASTER
+1 −0
Original line number Diff line number Diff line
@@ -148,6 +148,7 @@ obj-$(CONFIG_SENSORS_LTC4260) += ltc4260.o
obj-$(CONFIG_SENSORS_LTC4261)	+= ltc4261.o
obj-$(CONFIG_SENSORS_LTC4282)	+= ltc4282.o
obj-$(CONFIG_SENSORS_LTQ_CPUTEMP) += ltq-cputemp.o
obj-$(CONFIG_SENSORS_MACSMC_HWMON)	+= macsmc-hwmon.o
obj-$(CONFIG_SENSORS_MAX1111)	+= max1111.o
obj-$(CONFIG_SENSORS_MAX127)	+= max127.o
obj-$(CONFIG_SENSORS_MAX16065)	+= max16065.o
Loading