From nobody Sat Oct 4 20:52:48 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AB58C1EF38C; Tue, 12 Aug 2025 18:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755023129; cv=none; b=rIqvfnzgAnyFOy9/Mn6JfUV0r+dF6illpxzxVoAHb1Vze28LS6LUtbR74/i79xAZtwcmMky7k0UPc1T53E6B5b6bXhcrVDkbhb5EiSbCeMb2fqCmXlzLbt2e/8I+E+lfa0LHh40FFy24W6LIojgJg711rx/SgMMJnGE5mHLBwfY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755023129; c=relaxed/simple; bh=dp8uCVb8LD0lYnS4gp/nmqX07iPx3Lp8CElZzc5oZ9w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=W6IOBh4jX8ziidDvkUAmqJjyrFxmoauXOGMM7WYzwQzXHluz2n8klRcKGPRsQLtUslO+pYmKJ3hyOeJoP5CpawPsW9cN2C85B4UqdgOZEmc7M1mjWt6uWWUNHmOhnMaChIOHEdAIZXKDfgbLtqMtyI9DQ6domskjk8izLEDlzLI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=DZ7ogL+q; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="DZ7ogL+q" Received: by smtp.kernel.org (Postfix) with ESMTPS id 798D5C4CEF0; Tue, 12 Aug 2025 18:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755023129; bh=dp8uCVb8LD0lYnS4gp/nmqX07iPx3Lp8CElZzc5oZ9w=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=DZ7ogL+qgE00dLCMdHJEe+tUmi2xnlLw9iFhMilVpyw6QenSDCCMzRXsWQ9mOPqDg piZ8FnQEOz3w4WkGtOHodhyFKynAfbbghB4CeaCfBngYKrUiJ9STmfSCBSoij5A7vI jDq0B0iGDtWoVl1hriGB+BXFVWXiQL6NqnIgHV7RijZQipmHkPUdmLGx3weujXCXyR a7Jb8FH6U6pOCzfDnaKSdnKFBA2jbqIQ9doilM3sH5BkG6y6bdiiYUFRKfEAxQGvHh NX8b/k1rKvSc+/7XquExUS4lk8xp701ytWb2rDCJxPPrVozFT96ZmZl054/HxsUD/M 52RRJqW6nEV0A== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6AB0BCA0EDB; Tue, 12 Aug 2025 18:25:29 +0000 (UTC) From: Sven Peter Date: Tue, 12 Aug 2025 18:25:15 +0000 Subject: [PATCH 1/3] dt-bindings: rtc: Add Apple SMC RTC Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250812-wip-smc-rtc-v1-1-66a8e96dad60@kernel.org> References: <20250812-wip-smc-rtc-v1-0-66a8e96dad60@kernel.org> In-Reply-To: <20250812-wip-smc-rtc-v1-0-66a8e96dad60@kernel.org> To: Janne Grunau , Alyssa Rosenzweig , Neal Gompa , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Belloni Cc: asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Sven Peter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3344; i=sven@kernel.org; h=from:subject:message-id; bh=dp8uCVb8LD0lYnS4gp/nmqX07iPx3Lp8CElZzc5oZ9w=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8bsduEX7/Z6lM9Yvq0o43917LSnIVejivfbfJKYYiL3I DHj2H3hjlIWBjEOBlkxRZbt++1Nnzx8I7h006X3MHNYmUCGMHBxCsBEfr5m+F922LHmQ1id1jnz NrO9PLN+27Wcc3OO+3byXuD98xt/cX5gZLihr9tVlH6LWe/itZ8H+MU2ZCzZoTvlrlWRXotlvpb re14A X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 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. Signed-off-by: Sven Peter Reviewed-by: Neal Gompa --- .../devicetree/bindings/mfd/apple,smc.yaml | 9 ++++++ .../devicetree/bindings/rtc/apple,smc-rtc.yaml | 35 ++++++++++++++++++= ++++ MAINTAINERS | 1 + 3 files changed, 45 insertions(+) diff --git a/Documentation/devicetree/bindings/mfd/apple,smc.yaml b/Documen= tation/devicetree/bindings/mfd/apple,smc.yaml index 8a10e270d421ecd703848f64af597de351fcfd74..38f077867bdeedba8a486a63e36= 6e9c943a75681 100644 --- a/Documentation/devicetree/bindings/mfd/apple,smc.yaml +++ b/Documentation/devicetree/bindings/mfd/apple,smc.yaml @@ -41,6 +41,9 @@ properties: reboot: $ref: /schemas/power/reset/apple,smc-reboot.yaml =20 + rtc: + $ref: /schemas/rtc/apple,smc-rtc.yaml + additionalProperties: false =20 required: @@ -75,5 +78,11 @@ examples: nvmem-cell-names =3D "shutdown_flag", "boot_stage", "boot_error_count", "panic_count"; }; + + rtc { + compatible =3D "apple,smc-rtc"; + nvmem-cells =3D <&rtc_offset>; + nvmem-cell-names =3D "rtc_offset"; + }; }; }; diff --git a/Documentation/devicetree/bindings/rtc/apple,smc-rtc.yaml b/Doc= umentation/devicetree/bindings/rtc/apple,smc-rtc.yaml new file mode 100644 index 0000000000000000000000000000000000000000..607b610665a28b3ea2e86bd90cb= 5f3f28ebac726 --- /dev/null +++ b/Documentation/devicetree/bindings/rtc/apple,smc-rtc.yaml @@ -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 + +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 diff --git a/MAINTAINERS b/MAINTAINERS index fe168477caa45799dfe07de2f54de6d6a1ce0615..aaef8634985b35f54de1123ebb4= 176602066d177 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2397,6 +2397,7 @@ F: Documentation/devicetree/bindings/pinctrl/apple,pi= nctrl.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 --=20 2.34.1 From nobody Sat Oct 4 20:52:48 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BD1032E7BD4; Tue, 12 Aug 2025 18:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755023129; cv=none; b=BxogOLsYKFCJGGgPdxG4ko7vFb+l2BiUQD+CN96pSuHAJrOyTtrudB2uFcdN9QWYgXkN5cSG6GbibkFJaDTeKQSb2qNfDF8sJxGkNxcxCJNUJ6Ibt/oAFDxjJKJlAQq7HM3WFMhQPInSMeV05MVlrc1au8G5CMzVytgVK6KR+b0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755023129; c=relaxed/simple; bh=Wf0fYHpfI6G2lCj3FJWN2E65GypnHIoVBXamPywENFg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=B4uRkoQaAI9LRVO4RD3HQK8/lLnBTzVtCw82oaI1YerSkPUzom1IdqhKPDfxOb0KPTVmMDWPfswJ3cULTdAMpb3l+sQoncV1Q0lErpU1eKEg4FXz/rNGbACstCoYtVvBRfCzvjOYnJk/lnRtVlib/NTT9m/GrMw7DwEfgov5YsE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X3DOKO2j; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X3DOKO2j" Received: by smtp.kernel.org (Postfix) with ESMTPS id 8A4ECC4AF0B; Tue, 12 Aug 2025 18:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755023129; bh=Wf0fYHpfI6G2lCj3FJWN2E65GypnHIoVBXamPywENFg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=X3DOKO2juDb3rVM38jkwTejiPawmkAPJZftBmawycP64848LwEMUePNJPj5XVAzge nSWzAvsHc/LeS+r9g8onGtK4RKENjlshRr1PPVvsCX9D876Z2/unA3hAfcH49cjMD1 ilkk4RKdwrc4u3GkGvS8M+IAQHP55UBZ0Ws2i3TiPeRl+4+83CZq0bQBtwr+lyfrSQ u1+FDsdlhxn2WF34CiUaru3jQxqkLgV3XxZxR95iTavahsDDJoLKYztPxw6S9576YK bJmUTpxIaWRrwDUaHnjyA4qwIjcLk3GHmnaZR9CDt20wB6leP7U1V7Ss9Eh0Pi51DD 3oMAMJ5VyOZow== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7A43FCA0EE0; Tue, 12 Aug 2025 18:25:29 +0000 (UTC) From: Sven Peter Date: Tue, 12 Aug 2025 18:25:16 +0000 Subject: [PATCH 2/3] rtc: Add new rtc-macsmc driver for Apple Silicon Macs Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250812-wip-smc-rtc-v1-2-66a8e96dad60@kernel.org> References: <20250812-wip-smc-rtc-v1-0-66a8e96dad60@kernel.org> In-Reply-To: <20250812-wip-smc-rtc-v1-0-66a8e96dad60@kernel.org> To: Janne Grunau , Alyssa Rosenzweig , Neal Gompa , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Belloni Cc: asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Sven Peter , Hector Martin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=7647; i=sven@kernel.org; h=from:subject:message-id; bh=2e9+k7T8TkpKHlwNeDsIhFzyZwI6JK5Kg0MQEOA6b6U=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8bsdlHnfduDf3w12u/DYJH7MaJc4tks0YrvdxNiZh04s Vjb1Ke/o5SFQYyDQVZMkWX7fnvTJw/fCC7ddOk9zBxWJpAhDFycAjCRtGmMDHvz1CykSqP69c/t lrFvPfQiZ1HLz+T5vy6/ZNjVZ/qhWZ7hf80/T9ZHv0U0GMJ6zu10rVn2Y5eN74lpiUys3+NW7r2 znR0A X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 From: Hector Martin 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. Signed-off-by: Hector Martin Signed-off-by: Sven Peter Reviewed-by: Neal Gompa --- MAINTAINERS | 1 + drivers/mfd/macsmc.c | 1 + drivers/rtc/Kconfig | 11 ++++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-macsmc.c | 141 +++++++++++++++++++++++++++++++++++++++++++= ++++ 5 files changed, 155 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index aaef8634985b35f54de1123ebb4176602066d177..029117b921ea97d1276f5496ea0= 6a3f918929b20 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2421,6 +2421,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 diff --git a/drivers/mfd/macsmc.c b/drivers/mfd/macsmc.c index 870c8b2028a8fc0e905c8934c2636824cbe5d527..59be894460d33afa75492763088= 1532b548b7ad8 100644 --- a/drivers/mfd/macsmc.c +++ b/drivers/mfd/macsmc.c @@ -47,6 +47,7 @@ static const struct mfd_cell apple_smc_devs[] =3D { 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"), }; =20 static int apple_smc_cmd_locked(struct apple_smc *smc, u64 cmd, u64 arg, diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 64f6e9756aff4a1f6f6c50f9b4fc2140f66a8578..d28a46a89c85e6b30b402aec155= e8972ed2aaa8e 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig @@ -2068,6 +2068,17 @@ config RTC_DRV_WILCO_EC This can also be built as a module. If so, the module will be named "rtc_wilco_ec". =20 +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 diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 789bddfea99d8fcd024566891c37ee73e527cf93..bcb43b5878a562454986cbb9ab8= cc45cec248dda 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile @@ -93,6 +93,7 @@ obj-$(CONFIG_RTC_DRV_M48T35) +=3D rtc-m48t35.o obj-$(CONFIG_RTC_DRV_M48T59) +=3D rtc-m48t59.o obj-$(CONFIG_RTC_DRV_M48T86) +=3D rtc-m48t86.o obj-$(CONFIG_RTC_DRV_MA35D1) +=3D rtc-ma35d1.o +obj-$(CONFIG_RTC_DRV_MACSMC) +=3D rtc-macsmc.o obj-$(CONFIG_RTC_DRV_MAX31335) +=3D rtc-max31335.o obj-$(CONFIG_RTC_DRV_MAX6900) +=3D rtc-max6900.o obj-$(CONFIG_RTC_DRV_MAX6902) +=3D rtc-max6902.o diff --git a/drivers/rtc/rtc-macsmc.c b/drivers/rtc/rtc-macsmc.c new file mode 100644 index 0000000000000000000000000000000000000000..05e360277f630f3368b2856aade= f1f2b96426c37 --- /dev/null +++ b/drivers/rtc/rtc-macsmc.c @@ -0,0 +1,141 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* + * Apple SMC RTC driver + * Copyright The Asahi Linux Contributors + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* 48-bit RTC */ +#define RTC_BYTES 6 +#define RTC_BITS (8 * RTC_BYTES) + +/* 32768 Hz clock */ +#define RTC_SEC_SHIFT 15 + +struct macsmc_rtc { + struct device *dev; + struct apple_smc *smc; + struct rtc_device *rtc_dev; + struct nvmem_cell *rtc_offset; +}; + +static int macsmc_rtc_get_time(struct device *dev, struct rtc_time *tm) +{ + struct macsmc_rtc *rtc =3D dev_get_drvdata(dev); + u64 ctr =3D 0, off =3D 0; + time64_t now; + void *p_off; + size_t len; + int ret; + + ret =3D apple_smc_read(rtc->smc, SMC_KEY(CLKM), &ctr, RTC_BYTES); + if (ret < 0) + return ret; + if (ret !=3D RTC_BYTES) + return -EIO; + + p_off =3D nvmem_cell_read(rtc->rtc_offset, &len); + if (IS_ERR(p_off)) + return PTR_ERR(p_off); + if (len < RTC_BYTES) { + kfree(p_off); + return -EIO; + } + + memcpy(&off, p_off, RTC_BYTES); + kfree(p_off); + + /* Sign extend from 48 to 64 bits, then arithmetic shift right 15 bits to= get seconds */ + now =3D sign_extend64(ctr + off, RTC_BITS - 1) >> RTC_SEC_SHIFT; + rtc_time64_to_tm(now, tm); + + return ret; +} + +static int macsmc_rtc_set_time(struct device *dev, struct rtc_time *tm) +{ + struct macsmc_rtc *rtc =3D dev_get_drvdata(dev); + u64 ctr =3D 0, off =3D 0; + int ret; + + ret =3D apple_smc_read(rtc->smc, SMC_KEY(CLKM), &ctr, RTC_BYTES); + if (ret < 0) + return ret; + if (ret !=3D RTC_BYTES) + return -EIO; + + /* This sets the offset such that the set second begins now */ + off =3D (rtc_tm_to_time64(tm) << RTC_SEC_SHIFT) - ctr; + return nvmem_cell_write(rtc->rtc_offset, &off, RTC_BYTES); +} + +static const struct rtc_class_ops macsmc_rtc_ops =3D { + .read_time =3D macsmc_rtc_get_time, + .set_time =3D macsmc_rtc_set_time, +}; + +static int macsmc_rtc_probe(struct platform_device *pdev) +{ + struct apple_smc *smc =3D dev_get_drvdata(pdev->dev.parent); + struct macsmc_rtc *rtc; + + /* + * MFD will probe this device even without a node in the device tree, + * thus bail out early if the SMC on the current machines does not + * support RTC and has no node in the device tree. + */ + if (!pdev->dev.of_node) + return -ENODEV; + + rtc =3D devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); + if (!rtc) + return -ENOMEM; + + rtc->dev =3D &pdev->dev; + rtc->smc =3D smc; + + rtc->rtc_offset =3D devm_nvmem_cell_get(&pdev->dev, "rtc_offset"); + if (IS_ERR(rtc->rtc_offset)) + return dev_err_probe(&pdev->dev, PTR_ERR(rtc->rtc_offset), + "Failed to get rtc_offset NVMEM cell\n"); + + rtc->rtc_dev =3D devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(rtc->rtc_dev)) + return PTR_ERR(rtc->rtc_dev); + + rtc->rtc_dev->ops =3D &macsmc_rtc_ops; + rtc->rtc_dev->range_min =3D S64_MIN >> (RTC_SEC_SHIFT + (64 - RTC_BITS)); + rtc->rtc_dev->range_max =3D S64_MAX >> (RTC_SEC_SHIFT + (64 - RTC_BITS)); + + platform_set_drvdata(pdev, rtc); + + return devm_rtc_register_device(rtc->rtc_dev); +} + +static const struct of_device_id macsmc_rtc_of_table[] =3D { + { .compatible =3D "apple,smc-rtc", }, + {} +}; +MODULE_DEVICE_TABLE(of, macsmc_rtc_of_table); + +static struct platform_driver macsmc_rtc_driver =3D { + .driver =3D { + .name =3D "macsmc-rtc", + .of_match_table =3D macsmc_rtc_of_table, + }, + .probe =3D macsmc_rtc_probe, +}; +module_platform_driver(macsmc_rtc_driver); + +MODULE_LICENSE("Dual MIT/GPL"); +MODULE_DESCRIPTION("Apple SMC RTC driver"); +MODULE_AUTHOR("Hector Martin "); --=20 2.34.1 From nobody Sat Oct 4 20:52:48 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C8C842ECE93; Tue, 12 Aug 2025 18:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755023129; cv=none; b=dcElGuZCe2/xfbcNU8tJUD+PjnNTLPbPpl6mJFpcvNl3xLkUYWGU3ksMH+tUgSKI5B+y+UIprgL5vMkqwUryOsTYDkVdWe0nbJEpc/k+bA7smxTmywPGnmsDnes4G7FFUDWlUuQ5rHe2TB6XnCU5cE8OJh8pSPA4PdsPuzEJBpg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755023129; c=relaxed/simple; bh=63ifB2UNg7AJZpvKq4iGRrTwpRB8tb+yLkJzjM2n5lA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mcFKrIdTsW2sZu9GahrDcSvCZevtdjgvEANur/y2IZedI8z79Elyd/MaWQXmdAP95IMvY/IeiMwYk3AuwWxKGX6ZXVRHOQfGh/u+rkGsidzZ/VccdnB87febZIBk+a0xGaLInMfl3objZGq/WD2EhhJpNZ3CpTGY/jcBfKRKmU0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fk2zgRVr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fk2zgRVr" Received: by smtp.kernel.org (Postfix) with ESMTPS id 96EAEC4AF0C; Tue, 12 Aug 2025 18:25:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755023129; bh=63ifB2UNg7AJZpvKq4iGRrTwpRB8tb+yLkJzjM2n5lA=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Fk2zgRVrLT4mojGFu2aLBKsIMMTKCINompo7OsWLUwFRq0XC3D0b4ULuZrwavryGS ZCNN6RIZ+1EBp9FU8tIdgVEdHApW6D7NeYiE6E24td8WQsuoWXVoZPsdyIcoQ1dZBs 9fDdTgIapMkHSwe3tN5RXy7uUARwiOORJzZYtLz2o+U9b5b852/XpCxOMfgZ6faKNo 5tS0Y4yVp3TEoXqE4frEuwiGA60VTNXFgeR44GDh2XxHM3O9QY+D9HWAkRxuxhd5xW qw7ZUkJdSy6pzWoRPL4wGQZ8UvvqQzM7wtoSb/wZB4CWBs70/f+HCl+Z1hn64bU53d s/xQitVDbIJPA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87C6CCA0EC4; Tue, 12 Aug 2025 18:25:29 +0000 (UTC) From: Sven Peter Date: Tue, 12 Aug 2025 18:25:17 +0000 Subject: [PATCH 3/3] arm64: dts: apple: t8103,t600x,t8112: Add SMC RTC node Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250812-wip-smc-rtc-v1-3-66a8e96dad60@kernel.org> References: <20250812-wip-smc-rtc-v1-0-66a8e96dad60@kernel.org> In-Reply-To: <20250812-wip-smc-rtc-v1-0-66a8e96dad60@kernel.org> To: Janne Grunau , Alyssa Rosenzweig , Neal Gompa , Lee Jones , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Alexandre Belloni Cc: asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rtc@vger.kernel.org, Sven Peter X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2148; i=sven@kernel.org; h=from:subject:message-id; bh=63ifB2UNg7AJZpvKq4iGRrTwpRB8tb+yLkJzjM2n5lA=; b=owGbwMvMwCHmIlirolUq95LxtFoSQ8bsdrFXpbt80jVMT1u8Pu6utUjNomDqHVOZJv03zlH8d eJH7BZ3lLIwiHEwyIopsmzfb2/65OEbwaWbLr2HmcPKBDKEgYtTACaiaMXwP0q1O2n15tUtrhMK sxfIHuz9HJFxL9o7mSWXecluFj3jNEaG3ie6ZVHZ2RW734dYft+yN3UH283TK+7zW5luqSzmLNz IDwA= X-Developer-Key: i=sven@kernel.org; a=openpgp; fpr=A1E3E34A2B3C820DBC4955E5993B08092F131F93 X-Endpoint-Received: by B4 Relay for sven@kernel.org/default with auth_id=407 The System Manager Controller of all M1/M2 SoCs supports the RTC sub-device. Signed-off-by: Sven Peter Reviewed-by: Neal Gompa --- arch/arm64/boot/dts/apple/t600x-die0.dtsi | 6 ++++++ arch/arm64/boot/dts/apple/t8103.dtsi | 6 ++++++ arch/arm64/boot/dts/apple/t8112.dtsi | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/arch/arm64/boot/dts/apple/t600x-die0.dtsi b/arch/arm64/boot/dt= s/apple/t600x-die0.dtsi index 3603b276a2abcfa6a730f58d5c6b9914f22f00b0..f715b19efd1679e5cd384a967d6= e2a7c261ee679 100644 --- a/arch/arm64/boot/dts/apple/t600x-die0.dtsi +++ b/arch/arm64/boot/dts/apple/t600x-die0.dtsi @@ -44,6 +44,12 @@ smc_reboot: reboot { nvmem-cell-names =3D "shutdown_flag", "boot_stage", "boot_error_count", "panic_count"; }; + + rtc { + compatible =3D "apple,smc-rtc"; + nvmem-cells =3D <&rtc_offset>; + nvmem-cell-names =3D "rtc_offset"; + }; }; =20 smc_mbox: mbox@290408000 { diff --git a/arch/arm64/boot/dts/apple/t8103.dtsi b/arch/arm64/boot/dts/app= le/t8103.dtsi index 8b7b27887968741b745651e5133dffa7d8d20f6d..59f2678639cf47f469dc699c0ec= b5b9e50a45ab1 100644 --- a/arch/arm64/boot/dts/apple/t8103.dtsi +++ b/arch/arm64/boot/dts/apple/t8103.dtsi @@ -916,6 +916,12 @@ smc_reboot: reboot { nvmem-cell-names =3D "shutdown_flag", "boot_stage", "boot_error_count", "panic_count"; }; + + rtc { + compatible =3D "apple,smc-rtc"; + nvmem-cells =3D <&rtc_offset>; + nvmem-cell-names =3D "rtc_offset"; + }; }; =20 smc_mbox: mbox@23e408000 { diff --git a/arch/arm64/boot/dts/apple/t8112.dtsi b/arch/arm64/boot/dts/app= le/t8112.dtsi index 3f79878b25af1f7760088aa552589494d67347fb..6bc3f58b06f703ed79578e89a03= 0929a18d57796 100644 --- a/arch/arm64/boot/dts/apple/t8112.dtsi +++ b/arch/arm64/boot/dts/apple/t8112.dtsi @@ -919,6 +919,12 @@ smc_reboot: reboot { nvmem-cell-names =3D "shutdown_flag", "boot_stage", "boot_error_count", "panic_count"; }; + + rtc { + compatible =3D "apple,smc-rtc"; + nvmem-cells =3D <&rtc_offset>; + nvmem-cell-names =3D "rtc_offset"; + }; }; =20 smc_mbox: mbox@23e408000 { --=20 2.34.1