Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions Documentation/devicetree/bindings/hwmon/apple,smc-hwmon.yaml
Original file line number Diff line number Diff line change
@@ -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 <jcalligeros99@gmail.com>

$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
45 changes: 45 additions & 0 deletions Documentation/devicetree/bindings/mfd/apple,smc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ properties:
reboot:
$ref: /schemas/power/reset/apple,smc-reboot.yaml

rtc:
$ref: /schemas/rtc/apple,smc-rtc.yaml

hwmon:
$ref: /schemas/hwmon/apple,smc-hwmon.yaml

additionalProperties: false

required:
Expand Down Expand Up @@ -80,5 +86,44 @@ 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";
};

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";
};
};
};
};
35 changes: 35 additions & 0 deletions Documentation/devicetree/bindings/rtc/apple,smc-rtc.yaml
Original file line number Diff line number Diff line change
@@ -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 <sven@kernel.org>

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
71 changes: 71 additions & 0 deletions Documentation/hwmon/macsmc-hwmon.rst
Original file line number Diff line number Diff line change
@@ -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 <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

6 changes: 6 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -2423,6 +2423,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,*
Expand All @@ -2440,18 +2441,22 @@ 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
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
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
Expand All @@ -2463,6 +2468,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
Expand Down
12 changes: 12 additions & 0 deletions drivers/hwmon/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions drivers/hwmon/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading