Skip to content

Commit 659f476

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 05f7e89 commit 659f476

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
@@ -49,6 +49,9 @@ properties:
4949
rtc:
5050
$ref: /schemas/rtc/apple,smc-rtc.yaml
5151

52+
hwmon:
53+
$ref: /schemas/hwmon/apple,smc-hwmon.yaml
54+
5255
additionalProperties: false
5356

5457
required:
@@ -89,5 +92,38 @@ examples:
8992
nvmem-cells = <&rtc_offset>;
9093
nvmem-cell-names = "rtc_offset";
9194
};
95+
96+
hwmon {
97+
compatible = "apple,smc-hwmon";
98+
99+
current-ID0R {
100+
apple,key-id = "ID0R";
101+
label = "AC Input Current";
102+
};
103+
104+
fan-F0Ac {
105+
apple,key-id = "F0Ac";
106+
apple,fan-minimum = "F0Mn";
107+
apple,fan-maximum = "F0Mx";
108+
apple,fan-target = "F0Tg";
109+
apple,fan-mode = "F0Md";
110+
label = "Fan 1";
111+
};
112+
113+
power-PSTR {
114+
apple,key-id = "PSTR";
115+
label = "Total System Power";
116+
};
117+
118+
temperature-TW0P {
119+
apple,key-id = "TW0P";
120+
label = "WiFi/BT Module Temperature";
121+
};
122+
123+
voltage-VD0R {
124+
apple,key-id = "VD0R";
125+
label = "AC Input Voltage";
126+
};
127+
};
92128
};
93129
};

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2460,6 +2460,7 @@ F: Documentation/devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml
24602460
F: Documentation/devicetree/bindings/dma/apple,admac.yaml
24612461
F: Documentation/devicetree/bindings/gpio/apple,smc-gpio.yaml
24622462
F: Documentation/devicetree/bindings/gpu/apple,agx.yaml
2463+
F: Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml
24632464
F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml
24642465
F: Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml
24652466
F: Documentation/devicetree/bindings/interrupt-controller/apple,*

0 commit comments

Comments
 (0)