mfd: macsmc: add rtc, hwmon and hid subdevices
Subsystems (8)
v4 cover mfd: macsmc: add rtc, hwmon and hid subdevices
Hi all,
This series adds support for the remaining SMC subdevices. These are the RTC, hwmon, and HID devices. They are being submitted together as the RTC and hwmon drivers both require changes to the SMC DT schema.
The RTC driver is responsible for getting and setting the system clock, and requires an NVMEM cell. This series replaces Sven's original RTC driver submission [1].
The hwmon function is an interesting one. While each Apple Silicon device exposes pretty similar sets of sensors, these all seem to be paired to different SMC keys in the firmware interface. This is true even when the sensors are on the SoC. For example, an M1 MacBook Pro will use different keys to access the LITTLE core temperature sensors to an M1 Mac mini. This necessitates describing which keys correspond to which sensors for each device individually, and populating the hwmon structs at runtime. We do this with a node in the device tree. This series includes only the keys for sensors which we know to be common to all devices. The SMC is also responsible for monitoring and controlling fan speeds on systems with fans, which we expose via the hwmon driver.
The SMC also handles the hardware power button and lid switch. Power button presses and lid opening/closing are emitted as HID events, so we add an input subdevice to handle them.
Since there are no real dependencies between the components of this series, it should be fine for each subsystem to take the relevant patches through their trees. The mfd one-liners should be taken in order to avoid trivial conflicts.
Regards,
James
---
Changes in v4:
- Added Rob's R-b to hwmon Devicetree schema
- Added missing include to hwmon driver
- Dropped superfluous dev_info() from hwmon probe
- Added Guenter's A-b to hwmon driver
- Renamed INPUT_MACSMC_INPUT to INPUT_MACSMC
- Dropped leftover mention of HID in input driver
- Reinstated input driver MODULE_ALIAS
- Trigger a hard wakeup on power button/lid switch when coming out of
s2idle
- Suppress KEY_POWER event on wakeup to prevent an immediate shutdown
when waking up
- Squashed hwmon Devicetree commits into one
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Renamed macsmc-hid to macsmc-input
- Switched to pm_wakeup_event in macsmc-input
- macsmc-input now configures its capabilities before registering the device
- Renamed macsmc_hwmon to macsmc-hwmon
- Dropped module aliases in macsmc-input and macsmc_hwmon
- Introduced new SMC FourCC macro to silence GCC errors
- Condensed hwmon binding using $defs
- Made label property optional for hwmon sensors
- Fixed incorrect hwmon is_visible implementation
- Dropped 64-bit math from SMC float ops
- Fixed incorrect use of error numbers in hwmon driver
- Replaced a number of non-fatal dev_errs with dev_dbgs in hwmon driver
- Added hwmon driver documentation
- Added hwmon subdevice directly to the DT SMC node
- Included "common" hwmon sensors in SoC .dtsi files
- Fixed typo in hwmon-common.dtsi
- Added Neal's R-b to series
- Added required nodes to t602x Devicetrees
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Added Rob's R-b tag to RTC DT binding
- Removed redundant nesting from hwmon DT binding
- Dedpulicated property definitions in hwmon DT schema
- Made label a required property for hwmon DT nodes
- Clarified semantics in hwmon DT schema definitions
- Split mfd tree changes into separate commits
- Fixed numerous style errors in hwmon driver
- Removed log messages sysfs read/write functions in hwmon driver
- Removed ignored errors from hwmon driver
- Removed uses of dev_err for non-errors in hwmon driver
- Made it more obvious that a number of hwmon fan properties are optional
- Modified hwmon driver to reflect DT schema changes
- Added compatible property to hwmon node
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Hector Martin (2):
rtc: Add new rtc-macsmc driver for Apple Silicon Macs
input: macsmc-input: New driver to handle the Apple Mac SMC buttons/lid
James Calligeros (7):
dt-bindings: hwmon: Add Apple System Management Controller hwmon schema
mfd: macsmc: Wire up Apple SMC RTC subdevice
mfd: macsmc: Add new __SMC_KEY macro
hwmon: Add Apple Silicon SMC hwmon driver
mfd: macsmc: Wire up Apple SMC hwmon subdevice
mfd: macsmc: Wire up Apple SMC input subdevice
arm64: dts: apple: t8103, t8112, t60xx: Add hwmon SMC subdevice
Sven Peter (2):
dt-bindings: rtc: Add Apple SMC RTC
arm64: dts: apple: t8103,t60xx,t8112: Add SMC RTC node
.../bindings/hwmon/apple,smc-hwmon.yaml | 86 +++ .../bindings/mfd/apple,smc.yaml | 45 ++ .../bindings/rtc/apple,smc-rtc.yaml | 35 + Documentation/hwmon/macsmc-hwmon.rst | 71 +++ MAINTAINERS | 6 + .../boot/dts/apple/hwmon-common.dtsi | 33 + .../boot/dts/apple/hwmon-fan-dual.dtsi | 22 + arch/arm64/boot/dts/apple/hwmon-fan.dtsi | 17 + .../boot/dts/apple/hwmon-laptop.dtsi | 33 + .../boot/dts/apple/hwmon-mac-mini.dtsi | 15 + .../arm64/boot/dts/apple/t6001-j375c.dts | 2 + arch/arm64/boot/dts/apple/t6001.dtsi | 2 + .../arm64/boot/dts/apple/t6002-j375d.dts | 2 + .../arm64/boot/dts/apple/t600x-die0.dtsi | 10 + .../boot/dts/apple/t600x-j314-j316.dtsi | 3 + .../arm64/boot/dts/apple/t602x-die0.dtsi | 10 + arch/arm64/boot/dts/apple/t8103-j274.dts | 2 + arch/arm64/boot/dts/apple/t8103-j293.dts | 3 + arch/arm64/boot/dts/apple/t8103-j313.dts | 2 + arch/arm64/boot/dts/apple/t8103-j456.dts | 2 + arch/arm64/boot/dts/apple/t8103-j457.dts | 2 + arch/arm64/boot/dts/apple/t8103.dtsi | 11 + arch/arm64/boot/dts/apple/t8112-j413.dts | 2 + arch/arm64/boot/dts/apple/t8112-j473.dts | 2 + arch/arm64/boot/dts/apple/t8112-j493.dts | 3 + arch/arm64/boot/dts/apple/t8112.dtsi | 11 + drivers/hwmon/Kconfig | 12 + drivers/hwmon/Makefile | 1 + drivers/hwmon/macsmc-hwmon.c | 851 +++++++++++++++++++++++++ drivers/input/misc/Kconfig | 11 + drivers/input/misc/Makefile | 1 + drivers/input/misc/macsmc-input.c | 208 ++++++ drivers/mfd/macsmc.c | 3 + drivers/rtc/Kconfig | 11 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-macsmc.c | 141 ++++ include/linux/mfd/macsmc.h | 1 + 37 files changed, 1673 insertions(+)
---
base-commit: c746c3b5169831d7fb032a1051d8b45592ae8d78
change-id: 20250816-macsmc-subdevs-87032c017d0c
Best regards,
Signature · 1 line
James Calligeros <[email protected]>
PATCH v4 1/11 dt-bindings: rtc: Add Apple SMC RTC
From: Sven Peter <[email protected]>
Apple Silicon Macs (M1, etc.) have an RTC that is part of the PMU IC, but most of the PMU functionality is abstracted out by the SMC. An additional RTC offset stored inside NVMEM is required to compute the current date/time.
--- .../bindings/mfd/apple,smc.yaml | 9 +++++++ .../bindings/rtc/apple,smc-rtc.yaml | 35 +++++++++++++++++++++++++ MAINTAINERS | 1 + 3 files changed, 45 insertions(+)
Documentation/devicetree/bindings/mfd/apple,smc.yaml +9 -0
@@ -46,6 +46,9 @@ properties: reboot: $ref: /schemas/power/reset/apple,smc-reboot.yaml + rtc: + $ref: /schemas/rtc/apple,smc-rtc.yaml + additionalProperties: false required:
@@ -80,5 +83,11 @@ examples: nvmem-cell-names = "shutdown_flag", "boot_stage", "boot_error_count", "panic_count"; }; + + rtc { + compatible = "apple,smc-rtc"; + nvmem-cells = <&rtc_offset>; + nvmem-cell-names = "rtc_offset"; + }; }; };
Documentation/devicetree/bindings/rtc/apple,smc-rtc.yaml new file +35 -0
@@ -0,0 +1,35 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/rtc/apple,smc-rtc.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple SMC RTC + +description: + Apple Silicon Macs (M1, etc.) have an RTC that is part of the PMU IC, + but most of the PMU functionality is abstracted out by the SMC. + An additional RTC offset stored inside NVMEM is required to compute + the current date/time. + +maintainers: + - Sven Peter <[email protected]> + +properties: + compatible: + const: apple,smc-rtc + + nvmem-cells: + items: + - description: 48bit RTC offset, specified in 32768 (2^15) Hz clock ticks + + nvmem-cell-names: + items: + - const: rtc_offset + +required: + - compatible + - nvmem-cells + - nvmem-cell-names + +additionalProperties: false
MAINTAINERS +1 -0
@@ -2435,6 +2435,7 @@ F: Documentation/devicetree/bindings/pinctrl/apple,pinctrl.yaml F: Documentation/devicetree/bindings/power/apple* F: Documentation/devicetree/bindings/power/reset/apple,smc-reboot.yaml F: Documentation/devicetree/bindings/pwm/apple,s5l-fpwm.yaml +F: Documentation/devicetree/bindings/rtc/apple,smc-rtc.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
Signature · 1 line
2.51.0
PATCH v4 2/11 dt-bindings: hwmon: Add Apple System Management Controller hwmon schema
In reply to James CalligerosApple 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.
--- .../bindings/hwmon/apple,smc-hwmon.yaml | 86 +++++++++++++++++++++++++ .../bindings/mfd/apple,smc.yaml | 36 +++++++++++ MAINTAINERS | 1 + 3 files changed, 123 insertions(+)
Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml new file +86 -0
@@ -0,0 +1,86 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/apple,smc-hwmon.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Apple SMC Hardware Monitoring + +description: + Apple's System Management Controller (SMC) exposes a vast array of + hardware monitoring sensors, including temperature probes, current and + voltage sense, power meters, and fan speeds. It also provides endpoints + to manually control the speed of each fan individually. Each Apple + Silicon device exposes a different set of endpoints via SMC keys. This + is true even when two machines share an SoC. The CPU core temperature + sensor keys on an M1 Mac mini are different to those on an M1 MacBook + Pro, for example. + +maintainers: + - James Calligeros <[email protected]> + +$defs: + sensor: + type: object + + properties: + apple,key-id: + $ref: /schemas/types.yaml#/definitions/string + pattern: "^[A-Za-z0-9]{4}$" + description: The SMC FourCC key of the desired sensor. + Must match the node's suffix. + + label: + description: Human-readable name for the sensor + + required: + - apple,key-id + +properties: + compatible: + const: apple,smc-hwmon + +patternProperties: + "^current-[A-Za-z0-9]{4}$": + $ref: "#/$defs/sensor" + unevaluatedProperties: false + + "^fan-[A-Za-z0-9]{4}$": + $ref: "#/$defs/sensor" + unevaluatedProperties: false + + properties: + apple,fan-minimum: + $ref: /schemas/types.yaml#/definitions/string + pattern: "^[A-Za-z0-9]{4}$" + description: SMC key containing the fan's minimum speed + + apple,fan-maximum: + $ref: /schemas/types.yaml#/definitions/string + pattern: "^[A-Za-z0-9]{4}$" + description: SMC key containing the fan's maximum speed + + apple,fan-target: + $ref: /schemas/types.yaml#/definitions/string + pattern: "^[A-Za-z0-9]{4}$" + description: Writeable endpoint for setting desired fan speed + + apple,fan-mode: + $ref: /schemas/types.yaml#/definitions/string + pattern: "^[A-Za-z0-9]{4}$" + description: Writeable key to enable/disable manual fan control + + + "^power-[A-Za-z0-9]{4}$": + $ref: "#/$defs/sensor" + unevaluatedProperties: false + + "^temperature-[A-Za-z0-9]{4}$": + $ref: "#/$defs/sensor" + unevaluatedProperties: false + + "^voltage-[A-Za-z0-9]{4}$": + $ref: "#/$defs/sensor" + unevaluatedProperties: false + +additionalProperties: false
Documentation/devicetree/bindings/mfd/apple,smc.yaml +36 -0
@@ -49,6 +49,9 @@ properties: rtc: $ref: /schemas/rtc/apple,smc-rtc.yaml + hwmon: + $ref: /schemas/hwmon/apple,smc-hwmon.yaml + additionalProperties: false required:
@@ -89,5 +92,38 @@ examples: nvmem-cells = <&rtc_offset>; nvmem-cell-names = "rtc_offset"; }; + + hwmon { + compatible = "apple,smc-hwmon"; + + current-ID0R { + apple,key-id = "ID0R"; + label = "AC Input Current"; + }; + + fan-F0Ac { + apple,key-id = "F0Ac"; + apple,fan-minimum = "F0Mn"; + apple,fan-maximum = "F0Mx"; + apple,fan-target = "F0Tg"; + apple,fan-mode = "F0Md"; + label = "Fan 1"; + }; + + power-PSTR { + apple,key-id = "PSTR"; + label = "Total System Power"; + }; + + temperature-TW0P { + apple,key-id = "TW0P"; + label = "WiFi/BT Module Temperature"; + }; + + voltage-VD0R { + apple,key-id = "VD0R"; + label = "AC Input Voltage"; + }; + }; }; };
MAINTAINERS +1 -0
@@ -2418,6 +2418,7 @@ F: Documentation/devicetree/bindings/cpufreq/apple,cluster-cpufreq.yaml F: Documentation/devicetree/bindings/dma/apple,admac.yaml F: Documentation/devicetree/bindings/gpio/apple,smc-gpio.yaml F: Documentation/devicetree/bindings/gpu/apple,agx.yaml +F: Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml F: Documentation/devicetree/bindings/i2c/apple,i2c.yaml F: Documentation/devicetree/bindings/input/touchscreen/apple,z2-multitouch.yaml F: Documentation/devicetree/bindings/interrupt-controller/apple,*
Signature · 1 line
2.51.0
PATCH v4 3/11 rtc: Add new rtc-macsmc driver for Apple Silicon Macs
In reply to James CalligerosFrom: Hector Martin <[email protected]>
Apple Silicon Macs (M1, etc.) have an RTC that is part of the PMU IC, but most of the PMU functionality is abstracted out by the SMC. On T600x machines, the RTC counter must be accessed via the SMC to get full functionality, and it seems likely that future machines will move towards making SMC handle all RTC functionality.
The SMC RTC counter access is implemented on all current machines as of the time of this writing, on firmware 12.x. However, the RTC offset (needed to set the time) is still only accessible via direct PMU access. To handle this, we expose the RTC offset as an NVMEM cell from the SPMI PMU device node, and this driver consumes that cell and uses it to compute/set the current time.
--- MAINTAINERS | 1 + drivers/rtc/Kconfig | 11 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-macsmc.c | 141 +++++++++++++++++++++++++ 4 files changed, 154 insertions(+)
MAINTAINERS +1 -0
@@ -2460,6 +2460,7 @@ F: drivers/nvmem/apple-spmi-nvmem.c F: drivers/pinctrl/pinctrl-apple-gpio.c F: drivers/power/reset/macsmc-reboot.c F: drivers/pwm/pwm-apple.c +F: drivers/rtc/rtc-macsmc.c F: drivers/soc/apple/* F: drivers/spi/spi-apple.c F: drivers/spmi/spmi-apple-controller.c
drivers/rtc/Kconfig +11 -0
@@ -2078,6 +2078,17 @@ config RTC_DRV_WILCO_EC This can also be built as a module. If so, the module will be named "rtc_wilco_ec". +config RTC_DRV_MACSMC + tristate "Apple Mac System Management Controller RTC" + depends on MFD_MACSMC + help + If you say yes here you get support for RTC functions + inside Apple SPMI PMUs accessed through the SoC's + System Management Controller + + To compile this driver as a module, choose M here: the + module will be called rtc-macsmc. + config RTC_DRV_MSC313 tristate "MStar MSC313 RTC" depends on ARCH_MSTARV7 || COMPILE_TEST
drivers/rtc/Makefile +1 -0
@@ -93,6 +93,7 @@ obj-$(CONFIG_RTC_DRV_M48T35) += rtc-m48t35.o obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o obj-$(CONFIG_RTC_DRV_MA35D1) += rtc-ma35d1.o +obj-$(CONFIG_RTC_DRV_MACSMC) += rtc-macsmc.o obj-$(CONFIG_RTC_DRV_MAX31335) += rtc-max31335.o obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o
drivers/rtc/rtc-macsmc.c new file +141 -0
141 lines not on this page · raw message
Signature · 1 line
2.51.0
Lee Jones
maintainerRe: [PATCH v4 03/11] rtc: Add new rtc-macsmc driver for Apple Silicon Macs
Quoted 78 lines · James Calligeros
From: Hector Martin <[email protected]>
Apple Silicon Macs (M1, etc.) have an RTC that is part of the PMU IC, but most of the PMU functionality is abstracted out by the SMC. On T600x machines, the RTC counter must be accessed via the SMC to get full functionality, and it seems likely that future machines will move towards making SMC handle all RTC functionality.
The SMC RTC counter access is implemented on all current machines as of the time of this writing, on firmware 12.x. However, the RTC offset (needed to set the time) is still only accessible via direct PMU access. To handle this, we expose the RTC offset as an NVMEM cell from the SPMI PMU device node, and this driver consumes that cell and uses it to compute/set the current time.
Reviewed-by Neal Gompa <[email protected]>Signed-off-by Hector Martin <[email protected]>Signed-off-by Sven Peter <[email protected]>Signed-off-by James Calligeros <[email protected]>--- MAINTAINERS | 1 + drivers/rtc/Kconfig | 11 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-macsmc.c | 141 +++++++++++++++++++++++++ 4 files changed, 154 insertions(+)MAINTAINERS +1
-0@@ -2460,6 +2460,7 @@ F: drivers/nvmem/apple-spmi-nvmem.c F: drivers/pinctrl/pinctrl-apple-gpio.c F: drivers/power/reset/macsmc-reboot.c F: drivers/pwm/pwm-apple.c +F: drivers/rtc/rtc-macsmc.c F: drivers/soc/apple/* F: drivers/spi/spi-apple.c F: drivers/spmi/spmi-apple-controller.cdrivers/rtc/Kconfig +11
-0@@ -2078,6 +2078,17 @@ config RTC_DRV_WILCO_EC This can also be built as a module. If so, the module will be named "rtc_wilco_ec". +config RTC_DRV_MACSMC + tristate "Apple Mac System Management Controller RTC" + depends on MFD_MACSMC + help + If you say yes here you get support for RTC functions + inside Apple SPMI PMUs accessed through the SoC's + System Management Controller + + To compile this driver as a module, choose M here: the + module will be called rtc-macsmc. + config RTC_DRV_MSC313 tristate "MStar MSC313 RTC" depends on ARCH_MSTARV7 || COMPILE_TESTdrivers/rtc/Makefile +1
-0@@ -93,6 +93,7 @@ obj-$(CONFIG_RTC_DRV_M48T35) += rtc-m48t35.o obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o obj-$(CONFIG_RTC_DRV_MA35D1) += rtc-ma35d1.o +obj-$(CONFIG_RTC_DRV_MACSMC) += rtc-macsmc.o obj-$(CONFIG_RTC_DRV_MAX31335) += rtc-max31335.o obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.odrivers/rtc/rtc-macsmc.c new file +0
-0
drivers/rtc/rtc-macsmc.c line 8
Quoted 8 lines
drivers/rtc/rtc-macsmc.c new file +8
-0@@ -0,0 +1,141 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* +* Apple SMC RTC driver +* Copyright The Asahi Linux Contributors +*/ + +#include <linux/bitops.h> +#include <linux/mfd/core.h>
Why is this here?
Quoted 7 lines
drivers/rtc/rtc-macsmc.c new file +7
-0+#include <linux/mfd/macsmc.h> +#include <linux/module.h> +#include <linux/nvmem-consumer.h> +#include <linux/of.h> +#include <linux/platform_device.h> +#include <linux/rtc.h> +#include <linux/slab.h>
Signature · 1 line
Lee Jones [李琼斯]
PATCH v4 4/11 mfd: macsmc: Wire up Apple SMC RTC subdevice
In reply to James CalligerosAdd the new SMC RTC function to the mfd device
--- drivers/mfd/macsmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/macsmc.c +1 -0
@@ -47,6 +47,7 @@static const struct mfd_cell apple_smc_devs[] = {MFD_CELL_OF ("macsmc-gpio" ,NULL ,NULL ,0 ,0 ,"apple,smc-gpio" ),MFD_CELL_OF ("macsmc-reboot" ,NULL ,NULL ,0 ,0 ,"apple,smc-reboot" ), +MFD_CELL_OF ("macsmc-rtc" ,NULL ,NULL ,0 ,0 ,"apple,smc-rtc" ), }; static int apple_smc_cmd_locked(struct apple_smc *smc, u64 cmd, u64 arg,
Signature · 1 line
2.51.0
PATCH v4 5/11 mfd: macsmc: Add new __SMC_KEY macro
In reply to James CalligerosWhen using the _SMC_KEY macro in switch/case statements, GCC 15.2.1 errors out with 'case label does not reduce to an integer constant'. Introduce a new __SMC_KEY macro that can be used instead.
--- include/linux/mfd/macsmc.h | 1 + 1 file changed, 1 insertion(+)
include/linux/mfd/macsmc.h +1 -0
@@ -41,6 +41,7 @@ typedef u32 smc_key;*/ #define SMC_KEY (s) (smc_key)(_SMC_KEY(#s))#define _SMC_KEY (s) (((s)[0] << 24) | ((s)[1] << 16) | ((s)[2] << 8) | (s)[3]) +#define __SMC_KEY (a, b, c, d) (((u32)(a) << 24) | ((u32)(b) << 16) | ((u32)(c) << 8) | ((u32)(d)))#define APPLE_SMC_READABLE BIT(7)#define APPLE_SMC_WRITABLE BIT(6)
Signature · 1 line
2.51.0
Re: (subset) [PATCH v4 05/11] mfd: macsmc: Add new __SMC_KEY macro
Quoted 5 lines · James Calligeros
When using the
_SMC_KEYmacro in switch/case statements, GCC 15.2.1 errors out with 'case label does not reduce to an integer constant'. Introduce a new__SMC_KEYmacro that can be used instead.
Applied, thanks!
[05/11] mfd: macsmc: Add new __SMC_KEY macro
commit: 8c3290b4c975e35a01aecfb51e0e004b6f7c0480
--
Lee Jones [李琼斯]
PATCH v4 6/11 hwmon: Add Apple Silicon SMC hwmon driver
In reply to James CalligerosThe 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.
--- Documentation/hwmon/macsmc-hwmon.rst | 71 +++ MAINTAINERS | 2 + drivers/hwmon/Kconfig | 12 + drivers/hwmon/Makefile | 1 + drivers/hwmon/macsmc-hwmon.c | 851 +++++++++++++++++++++++++ 5 files changed, 937 insertions(+)
Documentation/hwmon/macsmc-hwmon.rst new file +71 -0
@@ -0,0 +1,71 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +Kernel driver macsmc-hwmon +========================== + +Supported hardware + + * Apple Silicon Macs (M1 and up) + +Author: James Calligeros <[email protected]> + +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 +
MAINTAINERS +2 -0
@@ -2440,12 +2440,14 @@ F: Documentation/devicetree/bindings/rtc/apple,smc-rtc.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
drivers/hwmon/Kconfig +12 -0
@@ -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
drivers/hwmon/Makefile +1 -0
@@ -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
drivers/hwmon/macsmc-hwmon.c new file +851 -0
851 lines not on this page · raw message
Signature · 1 line
2.51.0
Lee Jones
maintainer[GIT PULL] Immutable branch between MFD and HWMON due for the v6.19 merge window
Whoever takes this driver will need to pull the following:
The following changes since commit 3a8660878839faadb4f1a6dd72c3179c1df56787:
Linux 6.18-rc1 (2025-10-12 13:42:36 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-hwmon-v6.19
for you to fetch changes up to b340412a3b22b60b5e19cce8726940c7b5b14439:
mfd: macsmc: Add new __SMC_KEY macro (2025-11-06 13:58:42 +0000)
----------------------------------------------------------------
Immutable branch between MFD and HWMON due for the v6.19 merge window
----------------------------------------------------------------
James Calligeros (1):
mfd: macsmc: Add new __SMC_KEY macro
include/linux/mfd/macsmc.h | 1 + 1 file changed, 1 insertion(+)
Signature · 1 line
Lee Jones [李琼斯]
PATCH v4 7/11 mfd: macsmc: Wire up Apple SMC hwmon subdevice
In reply to James CalligerosAdd the SMC hwmon functionality to the mfd device
--- drivers/mfd/macsmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/macsmc.c +1 -0
@@ -46,6 +46,7 @@static const struct mfd_cell apple_smc_devs[] = {MFD_CELL_OF ("macsmc-gpio" ,NULL ,NULL ,0 ,0 ,"apple,smc-gpio" ), +MFD_CELL_OF ("macsmc-hwmon" ,NULL ,NULL ,0 ,0 ,"apple,smc-hwmon" ),MFD_CELL_OF ("macsmc-reboot" ,NULL ,NULL ,0 ,0 ,"apple,smc-reboot" ),MFD_CELL_OF ("macsmc-rtc" ,NULL ,NULL ,0 ,0 ,"apple,smc-rtc" ), };
Signature · 1 line
2.51.0
PATCH v4 8/11 input: macsmc-input: New driver to handle the Apple Mac SMC buttons/lid
In reply to James CalligerosFrom: Hector Martin <[email protected]>
This driver implements power button and lid switch support for Apple Mac devices using SMC controllers driven by the macsmc driver.
In addition to basic input support, this also responds to the final shutdown warning (when the power button is held down long enough) by doing an emergency kernel poweroff. This allows the NVMe controller to be cleanly shut down, which prevents data loss for in-cache data.
--- MAINTAINERS | 1 + drivers/input/misc/Kconfig | 11 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/macsmc-input.c | 208 +++++++++++++++++++++++++ 4 files changed, 221 insertions(+)
MAINTAINERS +1 -0
@@ -2451,6 +2451,7 @@ 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 +F: drivers/input/misc/macsmc-input.c F: drivers/input/touchscreen/apple_z2.c F: drivers/iommu/apple-dart.c F: drivers/iommu/io-pgtable-dart.c
drivers/input/misc/Kconfig +11 -0
@@ -981,4 +981,15 @@ config INPUT_STPMIC1_ONKEY To compile this driver as a module, choose M here: the module will be called stpmic1_onkey. +config INPUT_MACSMC + tristate "Apple Mac SMC lid/buttons" + depends on MFD_MACSMC + help + Say Y here if you want to use the input events delivered via the + SMC controller on Apple Mac machines using the macsmc driver. + This includes lid open/close and the power button. + + To compile this driver as a module, choose M here: the + module will be called macsmc-input. + endif
drivers/input/misc/Makefile +1 -0
@@ -51,6 +51,7 @@ obj-$(CONFIG_INPUT_IQS7222) += iqs7222.o obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o +obj-$(CONFIG_INPUT_MACSMC_INPUT) += macsmc-input.o obj-$(CONFIG_INPUT_MAX7360_ROTARY) += max7360-rotary.o obj-$(CONFIG_INPUT_MAX77650_ONKEY) += max77650-onkey.o obj-$(CONFIG_INPUT_MAX77693_HAPTIC) += max77693-haptic.o
drivers/input/misc/macsmc-input.c new file +208 -0
208 lines not on this page · raw message
Signature · 1 line
2.51.0
Lee Jones
maintainerRe: [PATCH v4 08/11] input: macsmc-input: New driver to handle the Apple Mac SMC buttons/lid
Quoted 74 lines · James Calligeros
From: Hector Martin <[email protected]>
This driver implements power button and lid switch support for Apple Mac devices using SMC controllers driven by the macsmc driver.
In addition to basic input support, this also responds to the final shutdown warning (when the power button is held down long enough) by doing an emergency kernel poweroff. This allows the NVMe controller to be cleanly shut down, which prevents data loss for in-cache data.
Reviewed-by Neal Gompa <[email protected]>Signed-off-by Hector Martin <[email protected]>Co-developed-by Sven Peter <[email protected]>Signed-off-by Sven Peter <[email protected]>Signed-off-by James Calligeros <[email protected]>--- MAINTAINERS | 1 + drivers/input/misc/Kconfig | 11 ++ drivers/input/misc/Makefile | 1 + drivers/input/misc/macsmc-input.c | 208 +++++++++++++++++++++++++ 4 files changed, 221 insertions(+)MAINTAINERS +1
-0@@ -2451,6 +2451,7 @@ 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 +F: drivers/input/misc/macsmc-input.c F: drivers/input/touchscreen/apple_z2.c F: drivers/iommu/apple-dart.c F: drivers/iommu/io-pgtable-dart.cdrivers/input/misc/Kconfig +11
-0@@ -981,4 +981,15 @@ config INPUT_STPMIC1_ONKEY To compile this driver as a module, choose M here: the module will be called stpmic1_onkey. +config INPUT_MACSMC + tristate "Apple Mac SMC lid/buttons" + depends on MFD_MACSMC + help + Say Y here if you want to use the input events delivered via the + SMC controller on Apple Mac machines using the macsmc driver. + This includes lid open/close and the power button. + + To compile this driver as a module, choose M here: the + module will be called macsmc-input. + endifdrivers/input/misc/Makefile +1
-0@@ -51,6 +51,7 @@ obj-$(CONFIG_INPUT_IQS7222) += iqs7222.o obj-$(CONFIG_INPUT_KEYSPAN_REMOTE) += keyspan_remote.o obj-$(CONFIG_INPUT_KXTJ9) += kxtj9.o obj-$(CONFIG_INPUT_M68K_BEEP) += m68kspkr.o +obj-$(CONFIG_INPUT_MACSMC_INPUT) += macsmc-input.o obj-$(CONFIG_INPUT_MAX7360_ROTARY) += max7360-rotary.o obj-$(CONFIG_INPUT_MAX77650_ONKEY) += max77650-onkey.o obj-$(CONFIG_INPUT_MAX77693_HAPTIC) += max77693-haptic.odrivers/input/misc/macsmc-input.c new file +2
-0@@ -0,0 +1,208 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/*
drivers/input/misc/macsmc-input.c line 12
Quoted 10 lines
drivers/input/misc/macsmc-input.c new file +10
-0+* Apple SMC input event driver +* Copyright The Asahi Linux Contributors +* +* This driver exposes certain events from the SMC as an input device. +* This includes the lid open/close and power button notifications. +*/ + +#include <linux/device.h> +#include <linux/input.h> +#include <linux/mfd/core.h>
This looks like it shouldn't be there.
Quoted 3 lines
drivers/input/misc/macsmc-input.c new file +3
-0+#include <linux/mfd/macsmc.h> +#include <linux/module.h> +#include <linux/reboot.h>
Signature · 1 line
Lee Jones [李琼斯]
PATCH v4 9/11 mfd: macsmc: Wire up Apple SMC input subdevice
In reply to James CalligerosAdd the new SMC input function to the mfd device
--- drivers/mfd/macsmc.c | 1 + 1 file changed, 1 insertion(+)
drivers/mfd/macsmc.c +1 -0
@@ -45,6 +45,7 @@#define SMC_TIMEOUT_MS 500static const struct mfd_cell apple_smc_devs[] = { +MFD_CELL_NAME ("macsmc-input" ),MFD_CELL_OF ("macsmc-gpio" ,NULL ,NULL ,0 ,0 ,"apple,smc-gpio" ),MFD_CELL_OF ("macsmc-hwmon" ,NULL ,NULL ,0 ,0 ,"apple,smc-hwmon" ),MFD_CELL_OF ("macsmc-reboot" ,NULL ,NULL ,0 ,0 ,"apple,smc-reboot" ),
Signature · 1 line
2.51.0
PATCH v4 10/11 arm64: dts: apple: t8103,t60xx,t8112: Add SMC RTC node
In reply to James CalligerosFrom: Sven Peter <[email protected]>
The System Manager Controller of all M1/M2 SoCs supports the RTC sub-device.
--- .../arm64/boot/dts/apple/t600x-die0.dtsi | 6 ++++++ .../arm64/boot/dts/apple/t602x-die0.dtsi | 6 ++++++ arch/arm64/boot/dts/apple/t8103.dtsi | 6 ++++++ arch/arm64/boot/dts/apple/t8112.dtsi | 6 ++++++ 4 files changed, 24 insertions(+)
arch/arm64/boot/dts/apple/t600x-die0.dtsi +6 -0
@@ -44,6 +44,12 @@ smc_reboot: reboot { nvmem-cell-names = "shutdown_flag", "boot_stage", "boot_error_count", "panic_count"; }; + + rtc { + compatible = "apple,smc-rtc"; + nvmem-cells = <&rtc_offset>; + nvmem-cell-names = "rtc_offset"; + }; }; smc_mbox: mbox@290408000 {
arch/arm64/boot/dts/apple/t602x-die0.dtsi +6 -0
@@ -121,6 +121,12 @@ smc_reboot: reboot { nvmem-cell-names = "shutdown_flag", "boot_stage", "boot_error_count", "panic_count"; }; + + rtc { + compatible = "apple,smc-rtc"; + nvmem-cells = <&rtc_offset>; + nvmem-cell-names = "rtc_offset"; + }; }; pinctrl_smc: pinctrl@2a2820000 {
arch/arm64/boot/dts/apple/t8103.dtsi +6 -0
@@ -916,6 +916,12 @@ smc_reboot: reboot { nvmem-cell-names = "shutdown_flag", "boot_stage", "boot_error_count", "panic_count"; }; + + rtc { + compatible = "apple,smc-rtc"; + nvmem-cells = <&rtc_offset>; + nvmem-cell-names = "rtc_offset"; + }; }; smc_mbox: mbox@23e408000 {
arch/arm64/boot/dts/apple/t8112.dtsi +6 -0
@@ -919,6 +919,12 @@ smc_reboot: reboot { nvmem-cell-names = "shutdown_flag", "boot_stage", "boot_error_count", "panic_count"; }; + + rtc { + compatible = "apple,smc-rtc"; + nvmem-cells = <&rtc_offset>; + nvmem-cell-names = "rtc_offset"; + }; }; smc_mbox: mbox@23e408000 {
Signature · 1 line
2.51.0
PATCH v4 11/11 arm64: dts: apple: t8103, t8112, t60xx: Add hwmon SMC subdevice
In reply to James CalligerosApple's System Management Controller integrates numerous sensors that can be exposed via hwmon. Add the subdevice, compatible, and some common sensors that are exposed on every currently supported device as a starting point.
--- .../boot/dts/apple/hwmon-common.dtsi | 33 +++++++++++++++++++++++++ .../boot/dts/apple/hwmon-fan-dual.dtsi | 22 +++++++++++++++++ arch/arm64/boot/dts/apple/hwmon-fan.dtsi | 17 +++++++++++++ .../boot/dts/apple/hwmon-laptop.dtsi | 33 +++++++++++++++++++++++++ .../boot/dts/apple/hwmon-mac-mini.dtsi | 15 +++++++++++ .../arm64/boot/dts/apple/t6001-j375c.dts | 2 ++ arch/arm64/boot/dts/apple/t6001.dtsi | 2 ++ .../arm64/boot/dts/apple/t6002-j375d.dts | 2 ++ .../arm64/boot/dts/apple/t600x-die0.dtsi | 4 +++ .../boot/dts/apple/t600x-j314-j316.dtsi | 3 +++ .../arm64/boot/dts/apple/t602x-die0.dtsi | 4 +++ arch/arm64/boot/dts/apple/t8103-j274.dts | 2 ++ arch/arm64/boot/dts/apple/t8103-j293.dts | 3 +++ arch/arm64/boot/dts/apple/t8103-j313.dts | 2 ++ arch/arm64/boot/dts/apple/t8103-j456.dts | 2 ++ arch/arm64/boot/dts/apple/t8103-j457.dts | 2 ++ arch/arm64/boot/dts/apple/t8103.dtsi | 5 ++++ arch/arm64/boot/dts/apple/t8112-j413.dts | 2 ++ arch/arm64/boot/dts/apple/t8112-j473.dts | 2 ++ arch/arm64/boot/dts/apple/t8112-j493.dts | 3 +++ arch/arm64/boot/dts/apple/t8112.dtsi | 5 ++++ 21 files changed, 165 insertions(+)
arch/arm64/boot/dts/apple/hwmon-common.dtsi new file +33 -0
@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Hardware monitoring sensors expected to be found on all Apple Silicon devices + * + * Copyright The Asahi Linux Contributors + */ + +&smc_hwmon { + current-ID0R { + apple,key-id = "ID0R"; + label = "AC Input Current"; + }; + power-PSTR { + apple,key-id = "PSTR"; + label = "Total System Power"; + }; + power-PDTR { + apple,key-id = "PDTR"; + label = "AC Input Power"; + }; + power-PMVR { + apple,key-id = "PMVR"; + label = "3.8 V Rail Power"; + }; + temperature-TH0x { + apple,key-id = "TH0x"; + label = "NAND Flash Temperature"; + }; + voltage-VD0R { + apple,key-id = "VD0R"; + label = "AC Input Voltage"; + }; +};
arch/arm64/boot/dts/apple/hwmon-fan-dual.dtsi new file +22 -0
@@ -0,0 +1,22 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * SMC hwmon fan keys for Apple Silicon desktops/laptops with two fans + * + * Copyright The Asahi Linux Contributors + */ + +#include "hwmon-fan.dtsi" + +&smc_hwmon { + fan-F0Ac { + label = "Fan 1"; + }; + fan-F1Ac { + apple,key-id = "F1Ac"; + label = "Fan 2"; + apple,fan-minimum = "F1Mn"; + apple,fan-maximum = "F1Mx"; + apple,fan-target = "F1Tg"; + apple,fan-mode = "F1Md"; + }; +};
arch/arm64/boot/dts/apple/hwmon-fan.dtsi new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * hwmon fan keys for Apple Silicon desktops/laptops with a single fan. + * + * Copyright The Asahi Linux Contributors + */ + +&smc_hwmon { + fan-F0Ac { + apple,key-id = "F0Ac"; + label = "Fan"; + apple,fan-minimum = "F0Mn"; + apple,fan-maximum = "F0Mx"; + apple,fan-target = "F0Tg"; + apple,fan-mode = "F0Md"; + }; +};
arch/arm64/boot/dts/apple/hwmon-laptop.dtsi new file +33 -0
@@ -0,0 +1,33 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * Hardware monitoring sensors expected on all Apple Silicon laptops + * + * Copyright The Asahi Linux Contributors + */ + +&smc_hwmon { + power-PHPC { + apple,key-id = "PHPC"; + label = "Heatpipe Power"; + }; + temperature-TB0T { + apple,key-id = "TB0T"; + label = "Battery Hotspot Temperature"; + }; + temperature-TCHP { + apple,key-id = "TCHP"; + label = "Charge Regulator Temperature"; + }; + temperature-TW0P { + apple,key-id = "TW0P"; + label = "WiFi/BT Module Temperature"; + }; + voltage-SBAV { + apple,key-id = "SBAV"; + label = "Battery Voltage"; + }; + voltage-VD0R { + apple,key-id = "VD0R"; + label = "Charger Input Voltage"; + }; +};
arch/arm64/boot/dts/apple/hwmon-mac-mini.dtsi new file +15 -0
@@ -0,0 +1,15 @@ +// SPDX-License-Identifier: GPL-2.0-or-later OR MIT +/* + * hwmon sensors expected on all Mac mini models + * + * Copyright The Asahi Linux Contributors + */ + +#include "hwmon-fan.dtsi" + +&smc_hwmon { + temperature-TW0P { + apple,key-id = "TW0P"; + label = "WiFi/BT Module Temperature"; + }; +};
arch/arm64/boot/dts/apple/t6001-j375c.dts +2 -0
@@ -24,3 +24,5 @@ &wifi0 { &bluetooth0 { brcm,board-type = "apple,okinawa"; }; + +#include "hwmon-fan-dual.dtsi"
arch/arm64/boot/dts/apple/t6001.dtsi +2 -0
@@ -66,3 +66,5 @@ p-core-pmu-affinity { &gpu { compatible = "apple,agx-g13c", "apple,agx-g13s"; }; + +#include "hwmon-common.dtsi"
arch/arm64/boot/dts/apple/t6002-j375d.dts +2 -0
@@ -56,3 +56,5 @@ &bluetooth0 { /delete-node/ &ps_disp0_cpu0_die1; /delete-node/ &ps_disp0_fe_die1; + +#include "hwmon-fan-dual.dtsi"
arch/arm64/boot/dts/apple/t600x-die0.dtsi +4 -0
@@ -37,6 +37,10 @@ smc_gpio: gpio { #gpio-cells = <2>; }; + smc_hwmon: hwmon { + compatible = "apple,smc-hwmon"; + }; + smc_reboot: reboot { compatible = "apple,smc-reboot"; nvmem-cells = <&shutdown_flag>, <&boot_stage>,
arch/arm64/boot/dts/apple/t600x-j314-j316.dtsi +3 -0
@@ -131,3 +131,6 @@ &fpwm0 { }; #include "spi1-nvram.dtsi" + +#include "hwmon-laptop.dtsi" +#include "hwmon-fan-dual.dtsi"
arch/arm64/boot/dts/apple/t602x-die0.dtsi +4 -0
@@ -114,6 +114,10 @@ smc_gpio: gpio { #gpio-cells = <2>; }; + smc_hwmon: hwmon { + compatible = "apple,smc-hwmon"; + }; + smc_reboot: reboot { compatible = "apple,smc-reboot"; nvmem-cells = <&shutdown_flag>, <&boot_stage>,
arch/arm64/boot/dts/apple/t8103-j274.dts +2 -0
@@ -61,3 +61,5 @@ &pcie0_dart_2 { &i2c2 { status = "okay"; }; + +#include "hwmon-mac-mini.dtsi"
arch/arm64/boot/dts/apple/t8103-j293.dts +3 -0
@@ -119,3 +119,6 @@ dfr_panel_in: endpoint { &displaydfr_dart { status = "okay"; }; + +#include "hwmon-laptop.dtsi" +#include "hwmon-fan.dtsi"
arch/arm64/boot/dts/apple/t8103-j313.dts +2 -0
@@ -41,3 +41,5 @@ &wifi0 { &fpwm1 { status = "okay"; }; + +#include "hwmon-laptop.dtsi"
arch/arm64/boot/dts/apple/t8103-j456.dts +2 -0
@@ -75,3 +75,5 @@ &pcie0_dart_1 { &pcie0_dart_2 { status = "okay"; }; + +#include "hwmon-fan-dual.dtsi"
arch/arm64/boot/dts/apple/t8103-j457.dts +2 -0
@@ -56,3 +56,5 @@ ethernet0: ethernet@0,0 { &pcie0_dart_2 { status = "okay"; }; + +#include "hwmon-fan.dtsi"
arch/arm64/boot/dts/apple/t8103.dtsi +5 -0
@@ -909,6 +909,10 @@ smc_gpio: gpio { #gpio-cells = <2>; }; + smc_hwmon: hwmon { + compatible = "apple,smc-hwmon"; + }; + smc_reboot: reboot { compatible = "apple,smc-reboot"; nvmem-cells = <&shutdown_flag>, <&boot_stage>,
@@ -1141,3 +1145,4 @@ port02: pci@2,0 { }; #include "t8103-pmgr.dtsi" +#include "hwmon-common.dtsi"
arch/arm64/boot/dts/apple/t8112-j413.dts +2 -0
@@ -78,3 +78,5 @@ &i2c4 { &fpwm1 { status = "okay"; }; + +#include "hwmon-laptop.dtsi"
arch/arm64/boot/dts/apple/t8112-j473.dts +2 -0
@@ -52,3 +52,5 @@ &pcie1_dart { &pcie2_dart { status = "okay"; }; + +#include "hwmon-mac-mini.dtsi"
arch/arm64/boot/dts/apple/t8112-j493.dts +3 -0
@@ -133,3 +133,6 @@ touchbar0: touchbar@0 { touchscreen-inverted-y; }; }; + +#include "hwmon-laptop.dtsi" +#include "hwmon-fan.dtsi"
arch/arm64/boot/dts/apple/t8112.dtsi +5 -0
@@ -912,6 +912,10 @@ smc_gpio: gpio { #gpio-cells = <2>; }; + smc_hwmon: hwmon { + compatible = "apple,smc-hwmon"; + }; + smc_reboot: reboot { compatible = "apple,smc-reboot"; nvmem-cells = <&shutdown_flag>, <&boot_stage>,
@@ -1180,3 +1184,4 @@ port03: pci@3,0 { }; #include "t8112-pmgr.dtsi" +#include "hwmon-common.dtsi"
Signature · 1 line
2.51.0
Lee Jones
maintainerQuoted 22 lines · James Calligeros
Hi all,
This series adds support for the remaining SMC subdevices. These are the RTC, hwmon, and HID devices. They are being submitted together as the RTC and hwmon drivers both require changes to the SMC DT schema.
The RTC driver is responsible for getting and setting the system clock, and requires an NVMEM cell. This series replaces Sven's original RTC driver submission [1].
The hwmon function is an interesting one. While each Apple Silicon device exposes pretty similar sets of sensors, these all seem to be paired to different SMC keys in the firmware interface. This is true even when the sensors are on the SoC. For example, an M1 MacBook Pro will use different keys to access the LITTLE core temperature sensors to an M1 Mac mini. This necessitates describing which keys correspond to which sensors for each device individually, and populating the hwmon structs at runtime. We do this with a node in the device tree. This series includes only the keys for sensors which we know to be common to all devices. The SMC is also responsible for monitoring and controlling fan speeds on systems with fans, which we expose via the hwmon driver.
Quoted 8 lines
The SMC also handles the hardware power button and lid switch. Power button presses and lid opening/closing are emitted as HID events, so we add an input subdevice to handle them.
Since there are no real dependencies between the components of this series, it should be fine for each subsystem to take the relevant patches through their trees. The mfd one-liners should be taken in order to avoid trivial conflicts.
The MFD parts look okay. Let me know when the other drivers have been accepted and I'll apply them all.
Signature · 1 line
Lee Jones [李琼斯]