From patchwork Wed Feb 19 13:41:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13982216 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 3DE9E1EB19A; Wed, 19 Feb 2025 13:43:16 +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=1739972597; cv=none; b=iGlMYK0ewS4VUrwI7/MGUelZyWbrqUTAFTk21qQIBtSKnJRE9kZPEbbfe4FpdveaAzj6dCh8E4P5gbX3iwuHymDOKB9chwQhSFnhYF7q68RplJVy4CNVo7mglshlYQg5qcB9OXNo9g293u+Z6CLfx6gwGC+rNXwJFgnA2UyPj3o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739972597; c=relaxed/simple; bh=oiRjy3yU3iR8pNoPEhJPyx535ffRUMg7nWD73L8N/VY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xr5dBGPFCWNeBdrEBeyvEjv+oVcrIaiCm+NqYdqA7gdYUhelKwjDzdla4e8AXMb9F+E1b6VAITpBSZY3uTJzg93Y8QA6bDIE2PShJeOIF1o21ThVlFKouhFORu5sxsWXkMwp6USacqe7Ez/VowxduavsG6PmKgR4GjqJ8cFb6mE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PLSRBOMn; 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="PLSRBOMn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A0B17C4CEE8; Wed, 19 Feb 2025 13:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739972596; bh=oiRjy3yU3iR8pNoPEhJPyx535ffRUMg7nWD73L8N/VY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PLSRBOMnuNXWMpdqe0Xn5B0WSNE9dVrYu0EOAmohcv1IdHPlvRjciBeaED+v6oPmB v1ToO7nVkYcxmCOrOAndVyyh78gDHOjsLT4nVumTjnUTLXIP1ZAoTEfMqW/Vu/8mHJ nb/Fl7tAKcMQjTZFcBqA4VFExerFYcar4N37c2EhMWocW/od80Xn8qeOhqtsx4+G9I +1VPbdXj4HocGKQ6qcDQdRWHAs90iMY8m4WWzmgOpxMJK7qWBw6tTdttcdQ6lsloGR dvkieQagK4oMeHT4G6Zl38+05qjSzvPR5Z5xIjxDADsYdGYHz+l0QPGRiuN6Pm9/O8 3mrNQenSSqFvA== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1tkkMI-0000000086Y-04Kt; Wed, 19 Feb 2025 14:43:26 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Konrad Dybcio , Jonathan Marek , Ard Biesheuvel , Maximilian Luz , Jens Glathe , Joel Stanley , Sebastian Reichel , Steev Klimaszewski , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 1/6] dt-bindings: rtc: qcom-pm8xxx: document qcom,no-alarm flag Date: Wed, 19 Feb 2025 14:41:13 +0100 Message-ID: <20250219134118.31017-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250219134118.31017-1-johan+linaro@kernel.org> References: <20250219134118.31017-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Marek Qualcomm x1e80100 firmware sets the ownership of the RTC alarm to ADSP. Thus writing to RTC alarm registers and receiving alarm interrupts is not possible. Add a qcom,no-alarm flag to support RTC on this platform. Signed-off-by: Jonathan Marek Link: https://lore.kernel.org/r/20241015004945.3676-3-jonathan@marek.ca [ johan: move vendor property; use boolean; reword description ] Acked-by: Rob Herring (Arm) Signed-off-by: Johan Hovold --- Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml b/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml index d274bb7a534b..68ef3208c886 100644 --- a/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml +++ b/Documentation/devicetree/bindings/rtc/qcom-pm8xxx-rtc.yaml @@ -50,6 +50,11 @@ properties: items: - const: offset + qcom,no-alarm: + type: boolean + description: + RTC alarm is not owned by the OS + wakeup-source: true required: From patchwork Wed Feb 19 13:41:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13982218 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 3DFE51EB19C; Wed, 19 Feb 2025 13:43:16 +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=1739972597; cv=none; b=ol0SAvBdiPWdunIMv032jSYGR99TfR8BbkVEsR7niNgyECLuIuWZ6ISpwgqBK8US+u5ZpXoZqqJPz4UyuY9VzJikjuw++y3bQH5JrPt0CudwNyqr5qmdDV6SLlZNKICuTm47LWLgqvJsW8cTOCQz1zWj3k9JoJR2KcS/tTTuE4w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739972597; c=relaxed/simple; bh=67YcT/JtMeOJVzv0hcH+YNMQnhqLpKWigz/mRmSfnyY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AOkvvxTU2wyMXTbtwpDhVYQlQJWJXotU7tspwQIFIP8yxdM+qqG2UD8E+AF1bavarb+hZlGe9Z0qYj59Ui3efLE5uz3RM2tV2iBZcX/xe8L27j+pthyDEkz+BCseamuRpwqPhO9WkDPkN0FiukvqHU4iOPeIDGQfcPLBx1h11iA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XYMizj9a; 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="XYMizj9a" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9D8C3C4CEE7; Wed, 19 Feb 2025 13:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739972596; bh=67YcT/JtMeOJVzv0hcH+YNMQnhqLpKWigz/mRmSfnyY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XYMizj9aZgRai+1A3oskApPkehmYFChTyqMgZ4iBH3gXiV7Vsr/7Lbg7DSKXV+ADS V7/VuPaba8gEkvz/q1P7Yr0sCQgipQSCWcuJ2rFxGEpg6bpswc30VTnDunQGJXg5B+ rRf65X24IlhPx4mCrKSvdGWY4+zKiQZgNxBpQVNRCnEGA0ugNLbetFI0Vk5fT0/hGo Zzu7l1bjskEtNDHJysYYcd4ARbgDXLrC0P56ry/lyD+W5i1ToQqbBWSMK5x+/RwoPE hJ2xKx1V3RNFD1adId4TGN5ayuCBFBDhIDGSos+YJEErKWzd7j+XPmGHfcprcWMsp5 LkkgMurLS/Edg== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1tkkMI-0000000086a-0Upx; Wed, 19 Feb 2025 14:43:26 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Konrad Dybcio , Jonathan Marek , Ard Biesheuvel , Maximilian Luz , Jens Glathe , Joel Stanley , Sebastian Reichel , Steev Klimaszewski , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 2/6] rtc: pm8xxx: add support for uefi offset Date: Wed, 19 Feb 2025 14:41:14 +0100 Message-ID: <20250219134118.31017-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250219134118.31017-1-johan+linaro@kernel.org> References: <20250219134118.31017-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which the driver can take into account. Add support for storing a 32-bit offset from the GPS time epoch in a UEFI variable so that the RTC time can be set on such platforms. The UEFI variable is 882f8c2b-9646-435f-8de5-f208ff80c1bd-RTCInfo and holds a 12-byte structure where the first four bytes is a GPS time offset in little-endian byte order. Note that this format is not arbitrary as the variable is shared with the UEFI firmware (and Windows). Tested-by: Jens Glathe Tested-by: Steev Klimaszewski Tested-by: Joel Stanley Tested-by: Sebastian Reichel # Lenovo T14s Gen6 Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 156 +++++++++++++++++++++++++++++++++------ include/linux/rtc.h | 1 + 2 files changed, 133 insertions(+), 24 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index b2518aea4218..e68b10aa5352 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -5,6 +5,7 @@ * Copyright (c) 2010-2011, Code Aurora Forum. All rights reserved. * Copyright (c) 2023, Linaro Limited */ +#include #include #include #include @@ -16,9 +17,10 @@ #include #include #include - #include +#include + /* RTC_CTRL register bit fields */ #define PM8xxx_RTC_ENABLE BIT(7) #define PM8xxx_RTC_ALARM_CLEAR BIT(0) @@ -46,14 +48,21 @@ struct pm8xxx_rtc_regs { unsigned int alarm_en; }; +struct qcom_uefi_rtc_info { + __le32 offset_gps; + u8 reserved[8]; +} __packed; + /** * struct pm8xxx_rtc - RTC driver internal structure * @rtc: RTC device * @regmap: regmap used to access registers * @allow_set_time: whether the time can be set + * @use_uefi: use UEFI variable as fallback for offset * @alarm_irq: alarm irq number * @regs: register description * @dev: device structure + * @rtc_info: qcom uefi rtc-info structure * @nvmem_cell: nvmem cell for offset * @offset: offset from epoch in seconds */ @@ -61,13 +70,101 @@ struct pm8xxx_rtc { struct rtc_device *rtc; struct regmap *regmap; bool allow_set_time; + bool use_uefi; int alarm_irq; const struct pm8xxx_rtc_regs *regs; struct device *dev; + struct qcom_uefi_rtc_info rtc_info; struct nvmem_cell *nvmem_cell; u32 offset; }; +#ifdef CONFIG_EFI + +MODULE_IMPORT_NS("EFIVAR"); + +#define QCOM_UEFI_NAME L"RTCInfo" +#define QCOM_UEFI_GUID EFI_GUID(0x882f8c2b, 0x9646, 0x435f, \ + 0x8d, 0xe5, 0xf2, 0x08, 0xff, 0x80, 0xc1, 0xbd) +#define QCOM_UEFI_ATTRS (EFI_VARIABLE_NON_VOLATILE | \ + EFI_VARIABLE_BOOTSERVICE_ACCESS | \ + EFI_VARIABLE_RUNTIME_ACCESS) + +static int pm8xxx_rtc_read_uefi_offset(struct pm8xxx_rtc *rtc_dd) +{ + struct qcom_uefi_rtc_info *rtc_info = &rtc_dd->rtc_info; + unsigned long size = sizeof(*rtc_info); + struct device *dev = rtc_dd->dev; + efi_status_t status; + u32 offset_gps; + int rc; + + rc = efivar_lock(); + if (rc) + return rc; + + status = efivar_get_variable(QCOM_UEFI_NAME, &QCOM_UEFI_GUID, NULL, + &size, rtc_info); + efivar_unlock(); + + if (status != EFI_SUCCESS) { + dev_dbg(dev, "failed to read UEFI offset: %lu\n", status); + return efi_status_to_err(status); + } + + if (size != sizeof(*rtc_info)) { + dev_dbg(dev, "unexpected UEFI structure size %lu\n", size); + return -EINVAL; + } + + dev_dbg(dev, "uefi_rtc_info = %*ph\n", (int)size, rtc_info); + + /* Convert from GPS to Unix time offset */ + offset_gps = le32_to_cpu(rtc_info->offset_gps); + rtc_dd->offset = offset_gps + (u32)RTC_TIMESTAMP_EPOCH_GPS; + + return 0; +} + +static int pm8xxx_rtc_write_uefi_offset(struct pm8xxx_rtc *rtc_dd, u32 offset) +{ + struct qcom_uefi_rtc_info *rtc_info = &rtc_dd->rtc_info; + unsigned long size = sizeof(*rtc_info); + struct device *dev = rtc_dd->dev; + efi_status_t status; + u32 offset_gps; + + /* Convert from Unix to GPS time offset */ + offset_gps = offset - (u32)RTC_TIMESTAMP_EPOCH_GPS; + + rtc_info->offset_gps = cpu_to_le32(offset_gps); + + dev_dbg(dev, "efi_rtc_info = %*ph\n", (int)size, rtc_info); + + status = efivar_set_variable(QCOM_UEFI_NAME, &QCOM_UEFI_GUID, + QCOM_UEFI_ATTRS, size, rtc_info); + if (status != EFI_SUCCESS) { + dev_dbg(dev, "failed to write UEFI offset: %lx\n", status); + return efi_status_to_err(status); + } + + return 0; +} + +#else /* CONFIG_EFI */ + +static int pm8xxx_rtc_read_uefi_offset(struct pm8xxx_rtc *rtc_dd) +{ + return -ENODEV; +} + +static int pm8xxx_rtc_write_uefi_offset(struct pm8xxx_rtc *rtc_dd, u32 offset) +{ + return -ENODEV; +} + +#endif /* CONFIG_EFI */ + static int pm8xxx_rtc_read_nvmem_offset(struct pm8xxx_rtc *rtc_dd) { size_t len; @@ -110,14 +207,6 @@ static int pm8xxx_rtc_write_nvmem_offset(struct pm8xxx_rtc *rtc_dd, u32 offset) return 0; } -static int pm8xxx_rtc_read_offset(struct pm8xxx_rtc *rtc_dd) -{ - if (!rtc_dd->nvmem_cell) - return 0; - - return pm8xxx_rtc_read_nvmem_offset(rtc_dd); -} - static int pm8xxx_rtc_read_raw(struct pm8xxx_rtc *rtc_dd, u32 *secs) { const struct pm8xxx_rtc_regs *regs = rtc_dd->regs; @@ -155,7 +244,7 @@ static int pm8xxx_rtc_update_offset(struct pm8xxx_rtc *rtc_dd, u32 secs) u32 offset; int rc; - if (!rtc_dd->nvmem_cell) + if (!rtc_dd->nvmem_cell && !rtc_dd->use_uefi) return -ENODEV; rc = pm8xxx_rtc_read_raw(rtc_dd, &raw_secs); @@ -167,7 +256,11 @@ static int pm8xxx_rtc_update_offset(struct pm8xxx_rtc *rtc_dd, u32 secs) if (offset == rtc_dd->offset) return 0; - rc = pm8xxx_rtc_write_nvmem_offset(rtc_dd, offset); + if (rtc_dd->nvmem_cell) + rc = pm8xxx_rtc_write_nvmem_offset(rtc_dd, offset); + else + rc = pm8xxx_rtc_write_uefi_offset(rtc_dd, offset); + if (rc) return rc; @@ -455,6 +548,30 @@ static const struct of_device_id pm8xxx_id_table[] = { }; MODULE_DEVICE_TABLE(of, pm8xxx_id_table); +static int pm8xxx_rtc_probe_offset(struct pm8xxx_rtc *rtc_dd) +{ + int rc; + + rtc_dd->nvmem_cell = devm_nvmem_cell_get(rtc_dd->dev, "offset"); + if (IS_ERR(rtc_dd->nvmem_cell)) { + rc = PTR_ERR(rtc_dd->nvmem_cell); + if (rc != -ENOENT) + return rc; + rtc_dd->nvmem_cell = NULL; + } else { + return pm8xxx_rtc_read_nvmem_offset(rtc_dd); + } + + /* Use UEFI storage as fallback if available */ + if (efivar_is_available()) { + rc = pm8xxx_rtc_read_uefi_offset(rtc_dd); + if (rc == 0) + rtc_dd->use_uefi = true; + } + + return 0; +} + static int pm8xxx_rtc_probe(struct platform_device *pdev) { const struct of_device_id *match; @@ -469,6 +586,9 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) if (rtc_dd == NULL) return -ENOMEM; + rtc_dd->regs = match->data; + rtc_dd->dev = &pdev->dev; + rtc_dd->regmap = dev_get_regmap(pdev->dev.parent, NULL); if (!rtc_dd->regmap) return -ENXIO; @@ -479,20 +599,8 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) rtc_dd->allow_set_time = of_property_read_bool(pdev->dev.of_node, "allow-set-time"); - - rtc_dd->nvmem_cell = devm_nvmem_cell_get(&pdev->dev, "offset"); - if (IS_ERR(rtc_dd->nvmem_cell)) { - rc = PTR_ERR(rtc_dd->nvmem_cell); - if (rc != -ENOENT) - return rc; - rtc_dd->nvmem_cell = NULL; - } - - rtc_dd->regs = match->data; - rtc_dd->dev = &pdev->dev; - if (!rtc_dd->allow_set_time) { - rc = pm8xxx_rtc_read_offset(rtc_dd); + rc = pm8xxx_rtc_probe_offset(rtc_dd); if (rc) return rc; } diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 3f4d315aaec9..95da051fb155 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h @@ -170,6 +170,7 @@ struct rtc_device { /* useful timestamps */ #define RTC_TIMESTAMP_BEGIN_0000 -62167219200ULL /* 0000-01-01 00:00:00 */ #define RTC_TIMESTAMP_BEGIN_1900 -2208988800LL /* 1900-01-01 00:00:00 */ +#define RTC_TIMESTAMP_EPOCH_GPS 315964800LL /* 1980-01-06 00:00:00 */ #define RTC_TIMESTAMP_BEGIN_2000 946684800LL /* 2000-01-01 00:00:00 */ #define RTC_TIMESTAMP_END_2063 2966371199LL /* 2063-12-31 23:59:59 */ #define RTC_TIMESTAMP_END_2079 3471292799LL /* 2079-12-31 23:59:59 */ From patchwork Wed Feb 19 13:41:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13982217 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 3DE351EB199; Wed, 19 Feb 2025 13:43:16 +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=1739972597; cv=none; b=MVXAgKfdjJ81cVjtMg7wioGLSt4MreYw1rECRG/HH0bBpB/TV1EEYzqFQ2CvR5cfpQk6Y9kK1HUo81f65ymtAJkTeBLTfQqmL8tHTfEEhAGvkD7UPDaeuvbKOHuzwA3HlBcD9Enod7CkjLGg5sajQkQSkC40eiyS5Zs9b9cprCA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739972597; c=relaxed/simple; bh=+hqwnea+N3U31REJn0l5qVy0S4iocm8Dcsv7Phxfmtc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KNeu8HBFJAlv4ro3G9yazXL0mHXU5Jb1RhNuCOdxS8QBvtTljeyHA69p+UBYwS7op9JLBrCHeNIEC4rX27xgGGS4QRpU1EpBgfglyo2ORA3oq3/aq1ICaiVv2FV4XL1ImmlDRw7Fmaqc+Fyt19oHNJ0v3pSxH0C+Vb3oo6/lT2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q0Lrzukf; 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="q0Lrzukf" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A396DC4CEDD; Wed, 19 Feb 2025 13:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739972596; bh=+hqwnea+N3U31REJn0l5qVy0S4iocm8Dcsv7Phxfmtc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q0LrzukfkV43bKqHt1Z58YQCiwlg5Vssu5Gufc2/3y5+mwx9y7BpZjAiyLCX+glP9 w+Ba28L4JQPkQh3ynNMiKxTjYl72hWzzQw6EphTaMhcWj92EcsabMc249jTseMkAE8 Lrwz2T9gfhVg2baSMgHCZQNFLVTdQZtbKOZawKzDhSr2pRTvFI1Xcl51rxulFGZ6Z5 /ms1Q7LG3U1zj7gZQuxun8sHuhUeCNChUCJIlEcQvgGVGbWqADzwBztUw5GR6VfWky cMkmPlf1irlToscnA3b1wIL1lXS9cUyWax+/ZFmnPXzuBhXP7viQwha5aHQEtBTHLL CFUAjpeTiHskQ== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1tkkMI-0000000086c-0ojs; Wed, 19 Feb 2025 14:43:26 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Konrad Dybcio , Jonathan Marek , Ard Biesheuvel , Maximilian Luz , Jens Glathe , Joel Stanley , Sebastian Reichel , Steev Klimaszewski , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 3/6] rtc: pm8xxx: mitigate flash wear Date: Wed, 19 Feb 2025 14:41:15 +0100 Message-ID: <20250219134118.31017-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250219134118.31017-1-johan+linaro@kernel.org> References: <20250219134118.31017-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which the driver can take into account. On machines like the Lenovo ThinkPad X13s the PMIC RTC drifts about one second every 3.5 hours, something which leads to repeated updates of the offset when NTP synchronisation is enabled. Reduce wear of the underlying flash storage (used for UEFI variables) by deferring writes until shutdown in case they appear to be due to clock drift. As an example, deferring writes when the new offset differs up to 30 s from the previous one reduces the number of writes on the X13s during a ten day session with the machine not suspending for more than four days in a row from up to 68 writes (every 3.5 h) to at most two (boot and shutdown). Tested-by: Jens Glathe Tested-by: Steev Klimaszewski Tested-by: Joel Stanley Tested-by: Sebastian Reichel # Lenovo T14s Gen6 Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index e68b10aa5352..68140ac39365 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -65,6 +65,7 @@ struct qcom_uefi_rtc_info { * @rtc_info: qcom uefi rtc-info structure * @nvmem_cell: nvmem cell for offset * @offset: offset from epoch in seconds + * @offset_dirty: offset needs to be stored on shutdown */ struct pm8xxx_rtc { struct rtc_device *rtc; @@ -77,6 +78,7 @@ struct pm8xxx_rtc { struct qcom_uefi_rtc_info rtc_info; struct nvmem_cell *nvmem_cell; u32 offset; + bool offset_dirty; }; #ifdef CONFIG_EFI @@ -256,6 +258,15 @@ static int pm8xxx_rtc_update_offset(struct pm8xxx_rtc *rtc_dd, u32 secs) if (offset == rtc_dd->offset) return 0; + /* + * Reduce flash wear by deferring updates due to clock drift until + * shutdown. + */ + if (abs_diff(offset, rtc_dd->offset) < 30) { + rtc_dd->offset_dirty = true; + goto out; + } + if (rtc_dd->nvmem_cell) rc = pm8xxx_rtc_write_nvmem_offset(rtc_dd, offset); else @@ -264,6 +275,8 @@ static int pm8xxx_rtc_update_offset(struct pm8xxx_rtc *rtc_dd, u32 secs) if (rc) return rc; + rtc_dd->offset_dirty = false; +out: rtc_dd->offset = offset; return 0; @@ -643,9 +656,22 @@ static void pm8xxx_remove(struct platform_device *pdev) dev_pm_clear_wake_irq(&pdev->dev); } +static void pm8xxx_shutdown(struct platform_device *pdev) +{ + struct pm8xxx_rtc *rtc_dd = platform_get_drvdata(pdev); + + if (rtc_dd->offset_dirty) { + if (rtc_dd->nvmem_cell) + pm8xxx_rtc_write_nvmem_offset(rtc_dd, rtc_dd->offset); + else + pm8xxx_rtc_write_uefi_offset(rtc_dd, rtc_dd->offset); + } +} + static struct platform_driver pm8xxx_rtc_driver = { .probe = pm8xxx_rtc_probe, .remove = pm8xxx_remove, + .shutdown = pm8xxx_shutdown, .driver = { .name = "rtc-pm8xxx", .of_match_table = pm8xxx_id_table, From patchwork Wed Feb 19 13:41:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13982215 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 141551EB187; Wed, 19 Feb 2025 13:43:16 +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=1739972597; cv=none; b=Bn958lxgAXEtySNv3wkqDKhsZYvMBI4qWEuHboZRL4D1q6tVFiW+n3ECJ5lhOl8DPPmC1lCahlpfa1csgr3jJRcfr2pcoeUzHotYcqbg5rNEN2rCuMiWR9ue7gxZg0aIepmbo08WWJgaL/toE6xHw3vMQaIuwJfgxSlel/W3kw4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739972597; c=relaxed/simple; bh=+jVESXZjW+dQ6ogYvit07tGCXuExIHzEYBT/vq3CdkE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=q4c8Q5Q1CInvqm/lYX15j06aR+RF5WIy3DziglWqf/IkcvLVLJg5FohxTCPRTEWCV4YWxwKdBJCafd4HLZpKZ9Dv3PLDldITdtiLn9zAFLRmB20h9kMkf3H1cX+sB68dc/MaHwhf0n2xKppKUdZDryYgiAEi/S0dPVfmi/+L1dQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZBhKkPCn; 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="ZBhKkPCn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B20D4C4CEEB; Wed, 19 Feb 2025 13:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739972596; bh=+jVESXZjW+dQ6ogYvit07tGCXuExIHzEYBT/vq3CdkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZBhKkPCng5u4EaonnatZ6e97dhItGbW1ssKnoNHvbZX6b/JIGgPeGhXQE/mbGS6Ob LsEZGumgnTrlqnSYtfEG8wRFeYklLZRdjMAjECuO2tR16RcSmWsjgLEd0cnhWvdJnc cVzOeFcHe+Jr548urDs4+vY8ixTBVFhGGG9ULjFlpWEsAduI+TtbQStAwFDz4EU8vu GCz8G15tybg1CJTdkcmzjO5UrfgLTri/IpaPhbLDNPkzM4FyBh9pIwydyvxga4rtgP WZMBNMITvwcstlAkGmDBZpMC4YFIGlu/NzR0Ku8NK7TUdvrrrFWVs4bmopDoABwAor HSj8GYlLFR7yg== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1tkkMI-0000000086e-1F5Y; Wed, 19 Feb 2025 14:43:26 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Konrad Dybcio , Jonathan Marek , Ard Biesheuvel , Maximilian Luz , Jens Glathe , Joel Stanley , Sebastian Reichel , Steev Klimaszewski , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH v2 4/6] rtc: pm8xxx: implement qcom,no-alarm flag for non-HLOS owned alarm Date: Wed, 19 Feb 2025 14:41:16 +0100 Message-ID: <20250219134118.31017-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250219134118.31017-1-johan+linaro@kernel.org> References: <20250219134118.31017-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Jonathan Marek Qualcomm x1e80100 firmware sets the ownership of the RTC alarm to ADSP. Thus writing to RTC alarm registers and receiving alarm interrupts is not possible. Add a qcom,no-alarm flag to support RTC on this platform. Signed-off-by: Jonathan Marek Link: https://lore.kernel.org/r/20241015004945.3676-2-jonathan@marek.ca [ johan: drop no_alarm flag and restructure probe() ] Tested-by: Jens Glathe Tested-by: Steev Klimaszewski Tested-by: Joel Stanley Tested-by: Sebastian Reichel # Lenovo T14s Gen6 Signed-off-by: Johan Hovold --- drivers/rtc/rtc-pm8xxx.c | 43 ++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/drivers/rtc/rtc-pm8xxx.c b/drivers/rtc/rtc-pm8xxx.c index 68140ac39365..14707e21f343 100644 --- a/drivers/rtc/rtc-pm8xxx.c +++ b/drivers/rtc/rtc-pm8xxx.c @@ -606,9 +606,11 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) if (!rtc_dd->regmap) return -ENXIO; - rtc_dd->alarm_irq = platform_get_irq(pdev, 0); - if (rtc_dd->alarm_irq < 0) - return -ENXIO; + if (!of_property_read_bool(pdev->dev.of_node, "qcom,no-alarm")) { + rtc_dd->alarm_irq = platform_get_irq(pdev, 0); + if (rtc_dd->alarm_irq < 0) + return -ENXIO; + } rtc_dd->allow_set_time = of_property_read_bool(pdev->dev.of_node, "allow-set-time"); @@ -624,8 +626,6 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rtc_dd); - device_init_wakeup(&pdev->dev, true); - rtc_dd->rtc = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(rtc_dd->rtc)) return PTR_ERR(rtc_dd->rtc); @@ -633,27 +633,32 @@ static int pm8xxx_rtc_probe(struct platform_device *pdev) rtc_dd->rtc->ops = &pm8xxx_rtc_ops; rtc_dd->rtc->range_max = U32_MAX; - rc = devm_request_any_context_irq(&pdev->dev, rtc_dd->alarm_irq, - pm8xxx_alarm_trigger, - IRQF_TRIGGER_RISING, - "pm8xxx_rtc_alarm", rtc_dd); - if (rc < 0) - return rc; + if (rtc_dd->alarm_irq) { + rc = devm_request_any_context_irq(&pdev->dev, rtc_dd->alarm_irq, + pm8xxx_alarm_trigger, + IRQF_TRIGGER_RISING, + "pm8xxx_rtc_alarm", rtc_dd); + if (rc < 0) + return rc; - rc = devm_rtc_register_device(rtc_dd->rtc); - if (rc) - return rc; + rc = dev_pm_set_wake_irq(&pdev->dev, rtc_dd->alarm_irq); + if (rc) + return rc; - rc = dev_pm_set_wake_irq(&pdev->dev, rtc_dd->alarm_irq); - if (rc) - return rc; + device_init_wakeup(&pdev->dev, true); + } else { + clear_bit(RTC_FEATURE_ALARM, rtc_dd->rtc->features); + } - return 0; + return devm_rtc_register_device(rtc_dd->rtc); } static void pm8xxx_remove(struct platform_device *pdev) { - dev_pm_clear_wake_irq(&pdev->dev); + struct pm8xxx_rtc *rtc_dd = platform_get_drvdata(pdev); + + if (rtc_dd->alarm_irq) + dev_pm_clear_wake_irq(&pdev->dev); } static void pm8xxx_shutdown(struct platform_device *pdev) From patchwork Wed Feb 19 13:41:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13982219 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 5E07C1E7C23; Wed, 19 Feb 2025 13:43:17 +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=1739972597; cv=none; b=pHWn0Igwh28VwxrciecMBZCf5JeHbk+SsB9JrK1LDBpp85AXlVHQAXU7izixGELHUeq/+S/QVZcapSzuuJxf8Kk4uq9Ad3Dcwq6WfL1Fw1UMarbVXYN0suPCcfSwO3BkPSUerYYJfyTQuB1ubzrbhKcjSc/qu01WflbM1XG9AIc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739972597; c=relaxed/simple; bh=nwsj4CidURS/EZrbUuMzdATKYlm1Szt4afCfuzWKh8w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Uq8gkrTlwam+qOowwopUPYvHtaBjILzQuHSFBcQg5LyijcFIbE9Xla3LiXkUode9qsJ/dDzugBXS85H6uGDDtvQyyM4+kSAfoLWFzn8+lQeGk7zkg6sJGFQjnWfvawMPz7tp2SP8wWNCdE5hMwxmp2CTEkvbsV304CQQbFeeQTw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=V8cTVUV0; 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="V8cTVUV0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D6BBDC4CEFB; Wed, 19 Feb 2025 13:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739972596; bh=nwsj4CidURS/EZrbUuMzdATKYlm1Szt4afCfuzWKh8w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V8cTVUV0A08OVk8hDrK05zy8mj/oVhFOTq0CCgvqhwMDk7yPJ0QlNezVMSOEnCEkO I0ta7hG34cnQfg9JlepjjfeDwY6AUXAJLE16UjOpUzk3HFFnVP/zrr6O3KdLDekxve WDRHiVPjfway0x3VMOK79NErelGvGIv0vYe5YM+NWHUxNil4VB6rbs78ZPJaFo/bTD JJitjEAvW0/eaeREhFB8y3OJHtSZ1PqG+we58IqK0ItT6Egoh/jH8IBXp2mzmSscZD 8BptSCq6ln6QoXvdMhtlSUnyTF5L8YeQOzwJkIlMb+qArM6/xzUcbfTZOPymSAGbij xMmuRLsetkDmg== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1tkkMI-0000000086h-1ex3; Wed, 19 Feb 2025 14:43:26 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Konrad Dybcio , Jonathan Marek , Ard Biesheuvel , Maximilian Luz , Jens Glathe , Joel Stanley , Sebastian Reichel , Steev Klimaszewski , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Konrad Dybcio Subject: [PATCH v2 5/6] arm64: dts: qcom: sc8280xp-x13s: switch to uefi rtc offset Date: Wed, 19 Feb 2025 14:41:17 +0100 Message-ID: <20250219134118.31017-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250219134118.31017-1-johan+linaro@kernel.org> References: <20250219134118.31017-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account. Switch to using the Qualcomm specific UEFI variable that is used by the UEFI firmware (and Windows) to store the RTC offset. This specifically means that the RTC time will be synchronised between the UEFI firmware setup (or UEFI shell), Windows and Linux. Note however that Windows stores the RTC time in local time by default, while Linux typically uses UTC (i.e. as on X86). Tested-by: Jens Glathe Tested-by: Steev Klimaszewski Reviewed-by: Konrad Dybcio Signed-off-by: Johan Hovold --- .../boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts index 38d911992475..8000254f4db5 100644 --- a/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts +++ b/arch/arm64/boot/dts/qcom/sc8280xp-lenovo-thinkpad-x13s.dts @@ -1090,18 +1090,7 @@ &pmk8280_pon_resin { }; &pmk8280_rtc { - nvmem-cells = <&rtc_offset>; - nvmem-cell-names = "offset"; - - status = "okay"; -}; - -&pmk8280_sdam_6 { status = "okay"; - - rtc_offset: rtc-offset@bc { - reg = <0xbc 0x4>; - }; }; &pmk8280_vadc { From patchwork Wed Feb 19 13:41:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 13982220 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 9D3541F130C; Wed, 19 Feb 2025 13:43:17 +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=1739972598; cv=none; b=h/vwF6V6paUu0iYTzwAiPNfzm8hAaLICzi4/XXjFEb9pRuuW7l0CVRHBuxLt0xt6vxl96hjTD4n8BsCg3p4ZhOS7jp+oc/rIPLFGWC7li6A30XAKUVUG1EQOzEJv9eOnbE4x4NG6eBA94kqEfUps/72fCC5MnbjuLjxg7Tom4jw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739972598; c=relaxed/simple; bh=TXZhVpYKgO10ZCx7g7qCUdIYO/DTpFUKjvq9lXUUZqU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pWz2bUF9WjHQU2DCJWcdlwKErrLQJ7Zt8fu7EbCww2d/Hc4kpkYq+HZ/JIukZOG2PeIL44OA4EKH7DmHhSFj4grDXAt08WaptAbnAq/TbW7XG7zqHYtSMlXf8e/GmNC1YGmNtckjyX6W2pzWnX79dWkqFQQeGX01Mme1hWj/a/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=MWJzavO3; 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="MWJzavO3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26A66C4CED1; Wed, 19 Feb 2025 13:43:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1739972597; bh=TXZhVpYKgO10ZCx7g7qCUdIYO/DTpFUKjvq9lXUUZqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MWJzavO3+oOZWuEasl4/8m7aTr+4LSnSIQf8z+3NXVJXF2Cy+R+djX/U0geUS7IOs uErfK+ehMpkYMVCnwyxyRidrMlGf8274ow7wKalpUIaNqa/JniqayV3u9jgIUA3e2f IAgV0cocm1vbv/+8zve4N3F9NfwJQJmUHp4HicJnrsPnncVLsjo6AvoRzCu7kpMI7D cjIgRLP5goqNQ6K6H08f54Eapb4xretT71O+E14b0ibRDi4EfOu/IE8AZNph19WO6O EIvy6NIO0UOgKuz1qiAS9SOy0DImXfw1bhic6PiZpCIHdsvQ/c4erKCsFZBrneZ5o3 U/8cA5suQOq9g== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1tkkMI-0000000086k-26QM; Wed, 19 Feb 2025 14:43:26 +0100 From: Johan Hovold To: Alexandre Belloni , Bjorn Andersson Cc: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Konrad Dybcio , Jonathan Marek , Ard Biesheuvel , Maximilian Luz , Jens Glathe , Joel Stanley , Sebastian Reichel , Steev Klimaszewski , linux-arm-msm@vger.kernel.org, linux-rtc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Johan Hovold , Konrad Dybcio Subject: [PATCH v2 6/6] arm64: dts: qcom: x1e80100: enable rtc Date: Wed, 19 Feb 2025 14:41:18 +0100 Message-ID: <20250219134118.31017-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.45.3 In-Reply-To: <20250219134118.31017-1-johan+linaro@kernel.org> References: <20250219134118.31017-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On many Qualcomm platforms the PMIC RTC control and time registers are read-only so that the RTC time can not be updated. Instead an offset needs be stored in some machine-specific non-volatile memory, which a driver can take into account. On X1E based Windows on Arm machines the offset is stored in a Qualcomm specific UEFI variable. Unlike on previous platforms the alarm registers are also unaccessible on X1E as they are owned by the ADSP. Assume all X1E machines use similar firmware and enable the RTC in the PMIC dtsi for now. Based on a patch by Jonathan Marek. [1] Link: https://lore.kernel.org/r/20241015004945.3676-4-jonathan@marek.ca # [1] Tested-by: Jens Glathe Tested-by: Joel Stanley Tested-by: Sebastian Reichel # Lenovo T14s Gen6 Reviewed-by: Konrad Dybcio Signed-off-by: Johan Hovold --- arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi b/arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi index d7a2a2b8fc6c..a59aa8e7642d 100644 --- a/arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi +++ b/arch/arm64/boot/dts/qcom/x1e80100-pmics.dtsi @@ -223,8 +223,7 @@ pmk8550_rtc: rtc@6100 { reg = <0x6100>, <0x6200>; reg-names = "rtc", "alarm"; interrupts = <0x0 0x62 0x1 IRQ_TYPE_EDGE_RISING>; - /* Not yet sure what blocks access */ - status = "reserved"; + qcom,no-alarm; /* alarm owned by ADSP */ }; pmk8550_sdam_2: nvram@7100 {