Skip to content

Commit 43f9a8d

Browse files
chadmedjannau
authored andcommitted
dt-bindings: hwmon: Add Apple System Management Controller hwmon schema
Apple Silicon devices integrate a vast array of sensors, monitoring current, power, temperature, and voltage across almost every part of the system. The sensors themselves are all connected to the System Management Controller (SMC). The SMC firmware exposes the data reported by these sensors via its standard FourCC-based key-value API. The SMC is also responsible for monitoring and controlling any fans connected to the system, exposing them in the same way. For reasons known only to Apple, each device exposes its sensors with an almost totally unique set of keys. This is true even for devices which share an SoC. An M1 Mac mini, for example, will report its core temperatures on different keys to an M1 MacBook Pro. Worse still, the SMC does not provide a way to enumerate the available keys at runtime, nor do the keys follow any sort of reasonable or consistent naming rules that could be used to deduce their purpose. We must therefore know which keys are present on any given device, and which function they serve, ahead of time. Add a schema so that we can describe the available sensors for a given Apple Silicon device in the Devicetree. Reviewed-by: Neal Gompa <neal@gompa.dev> Signed-off-by: James Calligeros <jcalligeros99@gmail.com> Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
1 parent 5b1173b commit 43f9a8d

3 files changed

Lines changed: 123 additions & 0 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/hwmon/apple,smc-hwmon.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Apple SMC Hardware Monitoring
8+
9+
description:
10+
Apple's System Management Controller (SMC) exposes a vast array of
11+
hardware monitoring sensors, including temperature probes, current and
12+
voltage sense, power meters, and fan speeds. It also provides endpoints
13+
to manually control the speed of each fan individually. Each Apple
14+
Silicon device exposes a different set of endpoints via SMC keys. This
15+
is true even when two machines share an SoC. The CPU core temperature
16+
sensor keys on an M1 Mac mini are different to those on an M1 MacBook
17+
Pro, for example.
18+
19+
maintainers:
20+
- James Calligeros <jcalligeros99@gmail.com>
21+
22+
$defs:
23+
sensor:
24+
type: object
25+
26+
properties:
27+
apple,key-id:
28+
$ref: /schemas/types.yaml#/definitions/string
29+
pattern: "^[A-Za-z0-9]{4}$"
30+
description: The SMC FourCC key of the desired sensor.
31+
Must match the node's suffix.
32+
33+
label:
34+
description: Human-readable name for the sensor
35+
36+
required:
37+
- apple,key-id
38+
39+
properties:
40+
compatible:
41+
const: apple,smc-hwmon
42+
43+
patternProperties:
44+
"^current-[A-Za-z0-9]{4}$":
45+
$ref: "#/$defs/sensor"
46+
unevaluatedProperties: false
47+
48+
"^fan-[A-Za-z0-9]{4}$":
49+
$ref: "#/$defs/sensor"
50+
unevaluatedProperties: false
51+
52+
properties:
53+
apple,fan-minimum:
54+
$ref: /schemas/types.yaml#/definitions/string
55+
pattern: "^[A-Za-z0-9]{4}$"
56+
description: SMC key containing the fan's minimum speed
57+
58+
apple,fan-maximum:
59+
$ref: /schemas/types.yaml#/definitions/string
60+
pattern: "^[A-Za-z0-9]{4}$"
61+
description: SMC key containing the fan's maximum speed
62+
63+
apple,fan-target:
64+
$ref: /schemas/types.yaml#/definitions/string
65+
pattern: "^[A-Za-z0-9]{4}$"
66+
description: Writeable endpoint for setting desired fan speed
67+
68+
apple,fan-mode:
69+
$ref: /schemas/types.yaml#/definitions/string
70+
pattern: "^[A-Za-z0-9]{4}$"
71+
description: Writeable key to enable/disable manual fan control
72+
73+
74+
"^power-[A-Za-z0-9]{4}$":
75+
$ref: "#/$defs/sensor"
76+
unevaluatedProperties: false
77+
78+
"^temperature-[A-Za-z0-9]{4}$":
79+
$ref: "#/$defs/sensor"
80+
unevaluatedProperties: false
81+
82+
"^voltage-[A-Za-z0-9]{4}$":
83+
$ref: "#/$defs/sensor"
84+
unevaluatedProperties: false
85+
86+
additionalProperties: false

Documentation/devicetree/bindings/mfd/apple,smc.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ properties:
4444
rtc:
4545
$ref: /schemas/rtc/apple,smc-rtc.yaml
4646

47+
hwmon:
48+
$ref: /schemas/hwmon/apple,smc-hwmon.yaml
49+
4750
additionalProperties: false
4851

4952
required:
@@ -84,5 +87,38 @@ examples:
8487
nvmem-cells = <&rtc_offset>;
8588
nvmem-cell-names = "rtc_offset";
8689
};
90+
91+
hwmon {
92+
compatible = "apple,smc-hwmon";
93+
94+
current-ID0R {
95+
apple,key-id = "ID0R";
96+
label = "AC Input Current";
97+
};
98+
99+
fan-F0Ac {
100+
apple,key-id = "F0Ac";
101+
apple,fan-minimum = "F0Mn";
102+
apple,fan-maximum = "F0Mx";
103+
apple,fan-target = "F0Tg";
104+
apple,fan-mode = "F0Md";
105+
label = "Fan 1";
106+
};
107+
108+
power-PSTR {
109+
apple,key-id = "PSTR";
110+
label = "Total System Power";
111+
};
112+
113+
temperature-TW0P {
114+
apple,key-id = "TW0P";
115+
label = "WiFi/BT Module Temperature";
116+
};
117+
118+
voltage-VD0R {
119+
apple,key-id = "VD0R";
120+
label = "AC Input Voltage";
121+
};
122+
};
87123
};
88124
};

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2378,6 +2378,7 @@ F: Documentation/devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml
23782378
F: Documentation/devicetree/bindings/dma/apple,admac.yaml
23792379
F: Documentation/devicetree/bindings/gpio/apple,smc-gpio.yaml
23802380
F: Documentation/devicetree/bindings/gpu/apple,agx.yaml
2381+
F: Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml
23812382
F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml
23822383
F: Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml
23832384
F: Documentation/devicetree/bindings/interrupt-controller/apple,*

0 commit comments

Comments
 (0)