Skip to content

Commit d33e6a7

Browse files
chadmedjannau
authored andcommitted
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: Neal Gompa <neal@gompa.dev> Co-developed-by: Janne Grunau <j@jannau.net> Signed-off-by: James Calligeros <jcalligeros99@gmail.com> Acked-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Janne Grunau <j@jannau.net>
1 parent 705516f commit d33e6a7

5 files changed

Lines changed: 936 additions & 0 deletions

File tree

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
.. SPDX-License-Identifier: GPL-2.0-only
2+
3+
Kernel driver macsmc-hwmon
4+
==========================
5+
6+
Supported hardware
7+
8+
* Apple Silicon Macs (M1 and up)
9+
10+
Author: James Calligeros <jcalligeros99@gmail.com>
11+
12+
Description
13+
-----------
14+
15+
macsmc-hwmon exposes the Apple System Management controller's
16+
temperature, voltage, current and power sensors, as well as
17+
fan speed and control capabilities, via hwmon.
18+
19+
Because each Apple Silicon Mac exposes a different set of sensors
20+
(e.g. the MacBooks expose battery telemetry that is not present on
21+
the desktop Macs), sensors present on any given machine are described
22+
via Devicetree. The driver picks these up and registers them with
23+
hwmon when probed.
24+
25+
Manual fan speed is supported via the fan_control module parameter. This
26+
is disabled by default and marked as unsafe, as it cannot be proven that
27+
the system will fail safe if overheating due to manual fan control being
28+
used.
29+
30+
sysfs interface
31+
---------------
32+
33+
currX_input
34+
Ammeter value
35+
36+
currX_label
37+
Ammeter label
38+
39+
fanX_input
40+
Current fan speed
41+
42+
fanX_label
43+
Fan label
44+
45+
fanX_min
46+
Minimum possible fan speed
47+
48+
fanX_max
49+
Maximum possible fan speed
50+
51+
fanX_target
52+
Current fan setpoint
53+
54+
inX_input
55+
Voltmeter value
56+
57+
inX_label
58+
Voltmeter label
59+
60+
powerX_input
61+
Power meter value
62+
63+
powerX_label
64+
Power meter label
65+
66+
tempX_input
67+
Temperature sensor value
68+
69+
tempX_label
70+
Temperature sensor label
71+

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,12 +2445,14 @@ F: Documentation/devicetree/bindings/rtc/apple,smc-rtc.yaml
24452445
F: Documentation/devicetree/bindings/spi/apple,spi.yaml
24462446
F: Documentation/devicetree/bindings/spmi/apple,spmi.yaml
24472447
F: Documentation/devicetree/bindings/watchdog/apple,wdt.yaml
2448+
F: Documentation/hwmon/macsmc-hwmon.rst
24482449
F: arch/arm64/boot/dts/apple/
24492450
F: drivers/bluetooth/hci_bcm4377.c
24502451
F: drivers/clk/clk-apple-nco.c
24512452
F: drivers/cpufreq/apple-soc-cpufreq.c
24522453
F: drivers/dma/apple-admac.c
24532454
F: drivers/gpio/gpio-macsmc.c
2455+
F: drivers/hwmon/macsmc-hwmon.c
24542456
F: drivers/pmdomain/apple/
24552457
F: drivers/i2c/busses/i2c-pasemi-core.c
24562458
F: drivers/i2c/busses/i2c-pasemi-platform.c

drivers/hwmon/Kconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,6 +1174,18 @@ config SENSORS_LTQ_CPUTEMP
11741174
If you say yes here you get support for the temperature
11751175
sensor inside your CPU.
11761176

1177+
config SENSORS_MACSMC_HWMON
1178+
tristate "Apple SMC (Apple Silicon)"
1179+
depends on MFD_MACSMC && OF
1180+
help
1181+
This driver enables hwmon support for current, power, temperature,
1182+
and voltage sensors, as well as fan speed reporting and control
1183+
on Apple Silicon devices. Say Y here if you have an Apple Silicon
1184+
device.
1185+
1186+
This driver can also be built as a module. If so, the module will
1187+
be called macsmc-hwmon.
1188+
11771189
config SENSORS_MAX1111
11781190
tristate "Maxim MAX1111 Serial 8-bit ADC chip and compatibles"
11791191
depends on SPI_MASTER

drivers/hwmon/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ obj-$(CONFIG_SENSORS_LTC4260) += ltc4260.o
148148
obj-$(CONFIG_SENSORS_LTC4261) += ltc4261.o
149149
obj-$(CONFIG_SENSORS_LTC4282) += ltc4282.o
150150
obj-$(CONFIG_SENSORS_LTQ_CPUTEMP) += ltq-cputemp.o
151+
obj-$(CONFIG_SENSORS_MACSMC_HWMON) += macsmc-hwmon.o
151152
obj-$(CONFIG_SENSORS_MAX1111) += max1111.o
152153
obj-$(CONFIG_SENSORS_MAX127) += max127.o
153154
obj-$(CONFIG_SENSORS_MAX16065) += max16065.o

0 commit comments

Comments
 (0)