* Re: [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe
From: Jon Hunter @ 2025-10-24 10:48 UTC (permalink / raw)
To: Kartik Rajput, alexandre.belloni, thierry.reding,
andriy.shevchenko, linux-rtc, linux-tegra, linux-kernel
In-Reply-To: <20251024064952.775883-1-kkartik@nvidia.com>
On 24/10/2025 07:49, Kartik Rajput wrote:
> Simplify clock management by replacing devm_clk_get() and manual clock
> enable/disable with devm_clk_get_enabled(). This also simplifies the
> error handling logic. Also remove tegra_rtc_remove() as the clock will
> automatically be disabled when the device is unbound from the bus.
>
> Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> Changes in v4:
> * Removed tegra_rtc_remove() as this is not required now.
> * Updated commit message to specify this.
> ---
> drivers/rtc/rtc-tegra.c | 26 ++++----------------------
> 1 file changed, 4 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
> index 46788db89953..e8c83a6a96b3 100644
> --- a/drivers/rtc/rtc-tegra.c
> +++ b/drivers/rtc/rtc-tegra.c
> @@ -300,14 +300,10 @@ static int tegra_rtc_probe(struct platform_device *pdev)
> info->rtc->ops = &tegra_rtc_ops;
> info->rtc->range_max = U32_MAX;
>
> - info->clk = devm_clk_get(&pdev->dev, NULL);
> + info->clk = devm_clk_get_enabled(&pdev->dev, NULL);
> if (IS_ERR(info->clk))
> return PTR_ERR(info->clk);
>
> - ret = clk_prepare_enable(info->clk);
> - if (ret < 0)
> - return ret;
> -
> /* set context info */
> info->pdev = pdev;
> spin_lock_init(&info->lock);
> @@ -324,29 +320,16 @@ static int tegra_rtc_probe(struct platform_device *pdev)
> ret = devm_request_irq(&pdev->dev, info->irq, tegra_rtc_irq_handler,
> IRQF_TRIGGER_HIGH, dev_name(&pdev->dev),
> &pdev->dev);
> - if (ret) {
> - dev_err(&pdev->dev, "failed to request interrupt: %d\n", ret);
> - goto disable_clk;
> - }
> + if (ret)
> + return dev_err_probe(&pdev->dev, ret, "failed to request interrupt\n");
>
> ret = devm_rtc_register_device(info->rtc);
> if (ret)
> - goto disable_clk;
> + return ret;
>
> dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n");
>
> return 0;
> -
> -disable_clk:
> - clk_disable_unprepare(info->clk);
> - return ret;
> -}
> -
> -static void tegra_rtc_remove(struct platform_device *pdev)
> -{
> - struct tegra_rtc_info *info = platform_get_drvdata(pdev);
> -
> - clk_disable_unprepare(info->clk);
> }
>
> #ifdef CONFIG_PM_SLEEP
> @@ -399,7 +382,6 @@ static void tegra_rtc_shutdown(struct platform_device *pdev)
>
> static struct platform_driver tegra_rtc_driver = {
> .probe = tegra_rtc_probe,
> - .remove = tegra_rtc_remove,
> .shutdown = tegra_rtc_shutdown,
> .driver = {
> .name = "tegra_rtc",
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Thanks!
Jon
--
nvpublic
^ permalink raw reply
* [PATCH v1 2/2] rtc: Add support for MT6685 Clock IC's RTC over SPMI
From: AngeloGioacchino Del Regno @ 2025-10-24 8:33 UTC (permalink / raw)
To: alexandre.belloni
Cc: robh, krzk+dt, conor+dt, matthias.bgg, angelogioacchino.delregno,
linux-rtc, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, kernel
In-Reply-To: <20251024083318.25890-1-angelogioacchino.delregno@collabora.com>
The MT6685 Clock IC is connected over the SPMI bus and includes a
Real Time Clock (RTC) IP.
Like the IP found in the MT6323/57/58/97 PMICs, this RTC ranges
from year 1900 to 2027: for this reason, in this driver the start
date is set to 2/1/1968 instead, matching the intepretation that
is found in most MediaTek bootloaders (which, in too many cases,
cannot be replaced due to OEM signing) and in downstream drivers.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
drivers/rtc/Kconfig | 12 +
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-mt6685.c | 472 +++++++++++++++++++++++++++++++++++++++
3 files changed, 485 insertions(+)
create mode 100644 drivers/rtc/rtc-mt6685.c
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index 2933c41c77c8..5d14948b3abc 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -1937,6 +1937,18 @@ config RTC_DRV_MT6397
If you want to use MediaTek(R) RTC interface, select Y or M here.
+config RTC_DRV_MT6685
+ tristate "MediaTek MT6685 Clock IC based RTC"
+ depends on ARCH_MEDIATEK || COMPILE_TEST
+ depends on SPMI
+ select IRQ_DOMAIN
+ help
+ Say yes here to enable support for the Real Time Clock found
+ in the MediaTek MT6685 Clock IC communicating over SPMI.
+
+ This driver can also be built as a module. If so, the module
+ will be called rtc-mt6685.
+
config RTC_DRV_MT7622
tristate "MediaTek SoC based RTC"
depends on ARCH_MEDIATEK || COMPILE_TEST
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 8221bda6e6dc..5ccfb1e02e51 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -113,6 +113,7 @@ obj-$(CONFIG_RTC_DRV_SSD202D) += rtc-ssd202d.o
obj-$(CONFIG_RTC_DRV_MSM6242) += rtc-msm6242.o
obj-$(CONFIG_RTC_DRV_MT2712) += rtc-mt2712.o
obj-$(CONFIG_RTC_DRV_MT6397) += rtc-mt6397.o
+obj-$(CONFIG_RTC_DRV_MT6685) += rtc-mt6685.o
obj-$(CONFIG_RTC_DRV_MT7622) += rtc-mt7622.o
obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o
obj-$(CONFIG_RTC_DRV_MXC) += rtc-mxc.o
diff --git a/drivers/rtc/rtc-mt6685.c b/drivers/rtc/rtc-mt6685.c
new file mode 100644
index 000000000000..3e632a3edbb6
--- /dev/null
+++ b/drivers/rtc/rtc-mt6685.c
@@ -0,0 +1,472 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * MediaTek MT6685 Clock IC - Real Time Clock IP driver
+ *
+ * Copyright (C) 2020 MediaTek Inc.
+ * Copyright (C) 2025 Collabora Ltd.
+ * AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+ */
+
+#include <linux/clk.h>
+#include <linux/device.h>
+#include <linux/bitfield.h>
+#include <linux/err.h>
+#include <linux/interrupt.h>
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/of_device.h>
+#include <linux/of_irq.h>
+#include <linux/platform_device.h>
+#include <linux/regmap.h>
+#include <linux/rtc.h>
+#include <linux/spmi.h>
+
+#define RTC_REG_BBPU 0x8
+#define RTC_BBPU_PWREN BIT(0)
+#define RTC_BBPU_CLR BIT(1)
+#define RTC_BBPU_RESET_AL BIT(3)
+#define RTC_BBPU_RELOAD BIT(5)
+#define RTC_BBPU_CBUSY BIT(6)
+#define RTC_BBPU_WR_UNLOCK_KEY 0x4300
+
+#define RTC_REG_IRQ_STA 0xa
+#define RTC_REG_IRQ_EN 0xc
+#define RTC_IRQ_AL BIT(0)
+#define RTC_IRQ_ONESHOT BIT(2)
+#define RTC_IRQ_LP BIT(3)
+
+#define RTC_REG_AL_MASK 0x10
+#define RTC_AL_MASK_DOW BIT(4)
+
+#define RTC_REG_TC_SEC 0x12
+#define RTC_REG_AL_SEC 0x20
+#define RTC_AL_TC_YEAR GENMASK(6, 0)
+#define RTC_AL_TC_SEC_MIN GENMASK(5, 0)
+#define RTC_AL_TC_HOUR_DOM GENMASK(4, 0)
+#define RTC_AL_TC_MON GENMASK(3, 0)
+#define RTC_AL_TC_DOW GENMASK(2, 0)
+
+#define RTC_REG_PDN2 0x36
+#define RTC_PDN2_PWRON_ALARM BIT(4)
+
+#define MT6685_RTC_REG_WRTGR 0x42
+
+#define MT6685_RTC_POLL_DELAY_US 10
+#define MT6685_RTC_POLL_TIMEOUT_US 2500
+
+/**
+ * struct mt6885_rtc - Main driver structure
+ * @rdev: Pointer to RTC device
+ * @regmap: Regmap (SPMI) Handle
+ * @mclk: RTC MCLK clock for register write
+ * @irq: Alarm interrupt number
+ */
+struct mt6685_rtc {
+ struct rtc_device *rdev;
+ struct regmap *regmap;
+ struct clk *mclk;
+ int irq;
+};
+
+/* HW time registers index - please do *not* add or remove indices! */
+enum mt6685_timereg_index {
+ RTC_AL_TC_REGIDX_SEC,
+ RTC_AL_TC_REGIDX_MIN,
+ RTC_AL_TC_REGIDX_HOUR,
+ RTC_AL_TC_REGIDX_DOM,
+ RTC_AL_TC_REGIDX_DOW,
+ RTC_AL_TC_REGIDX_MON,
+ RTC_AL_TC_REGIDX_YEAR,
+ RTC_AL_TC_REGIDX_MAX
+};
+
+/**
+ * rtc_mt6685_write_trigger() - Synchronize registers to the HW
+ * @rtc: Main driver structure
+ *
+ * Writes to the Write Trigger (WRTGR) RTC register to start synchronizing
+ * all of the previous register writes to the hardware.
+ * This is done in order to avoid race conditions in case an alarm fires
+ * during the writing of time registers.
+ *
+ * Context: Mutex lock must be held before calling this function.
+ * Apart from interrupt handlers inside of this driver, that is
+ * already taken care of by the RTC API's ops_lock.
+ * Return: Zero for success or negative error number.
+ */
+static int rtc_mt6685_write_trigger(struct mt6685_rtc *rtc)
+{
+ const u16 val = 1;
+ u32 data;
+ int ret;
+
+ ret = regmap_bulk_write(rtc->regmap, MT6685_RTC_REG_WRTGR, &val, sizeof(val));
+ if (ret)
+ return ret;
+
+ /* The RTC usually takes 7-9uS to update: wait a bit before reading */
+ usleep_range(MT6685_RTC_POLL_DELAY_US, MT6685_RTC_POLL_DELAY_US + 10);
+
+ return regmap_read_poll_timeout(rtc->regmap, RTC_REG_BBPU, data,
+ !(data & RTC_BBPU_CBUSY),
+ MT6685_RTC_POLL_DELAY_US,
+ MT6685_RTC_POLL_TIMEOUT_US);
+}
+
+static irqreturn_t rtc_mt6685_irq_handler_thread(int irq, void *data)
+{
+ u16 irqsta, irqen = 0, bbpu = RTC_BBPU_WR_UNLOCK_KEY | RTC_BBPU_PWREN;
+ struct mt6685_rtc *rtc = data;
+ struct device *dev = &rtc->rdev->dev;
+ int ret;
+
+ ret = clk_prepare_enable(rtc->mclk);
+ if (ret)
+ return IRQ_NONE;
+
+ ret = regmap_bulk_read(rtc->regmap, RTC_REG_IRQ_STA, &irqsta, sizeof(irqsta));
+ if (ret)
+ goto end;
+
+ /* Only alarm interrupts are supported for now */
+ if (!(irqsta & RTC_IRQ_AL)) {
+ ret = -EINVAL;
+ goto end;
+ }
+
+ rtc_lock(rtc->rdev);
+
+ /* Enable BBPU power and clear the interrupt */
+ ret = regmap_bulk_write(rtc->regmap, RTC_REG_BBPU, &bbpu, sizeof(bbpu));
+ if (ret)
+ goto end;
+
+ ret = regmap_bulk_write(rtc->regmap, RTC_REG_IRQ_EN, &irqen, sizeof(irqen));
+ if (ret)
+ goto end;
+
+ /* Trigger reset of the RTC BBPU Alarm */
+ bbpu |= RTC_BBPU_RESET_AL;
+ ret = regmap_bulk_write(rtc->regmap, RTC_REG_BBPU, &bbpu, sizeof(bbpu));
+ if (ret) {
+ dev_err(dev, "Cannot reset alarm: %d\n", ret);
+ goto end;
+ }
+
+ /* Trigger write synchronization */
+ ret = rtc_mt6685_write_trigger(rtc);
+ if (ret) {
+ dev_err(dev, "Cannot synchronize write to RTC: %d\n", ret);
+ goto end;
+ }
+ rtc_update_irq(rtc->rdev, 1, RTC_IRQF | RTC_AF);
+end:
+ rtc_unlock(rtc->rdev);
+ clk_disable_unprepare(rtc->mclk);
+ return ret ? IRQ_NONE : IRQ_HANDLED;
+}
+
+static void rtc_mt6685_reload_bbpu(struct mt6685_rtc *rtc)
+{
+ u16 reload;
+
+ regmap_bulk_read(rtc->regmap, RTC_REG_BBPU, &reload, sizeof(reload));
+ reload |= RTC_BBPU_WR_UNLOCK_KEY | RTC_BBPU_RELOAD;
+ regmap_bulk_write(rtc->regmap, RTC_REG_BBPU, &reload, sizeof(reload));
+
+ rtc_mt6685_write_trigger(rtc);
+}
+
+static int rtc_mt6685_read_time_regs(struct mt6685_rtc *rtc, struct rtc_time *tm, u16 reg)
+{
+ u16 data[RTC_AL_TC_REGIDX_MAX];
+ int ret;
+
+ ret = regmap_bulk_read(rtc->regmap, reg, &data,
+ RTC_AL_TC_REGIDX_MAX * sizeof(data[0]));
+ if (ret) {
+ dev_err(&rtc->rdev->dev, "Cannot read time regs\n");
+ return ret;
+ }
+
+ tm->tm_sec = FIELD_GET(RTC_AL_TC_SEC_MIN, data[RTC_AL_TC_REGIDX_SEC]);
+ tm->tm_min = FIELD_GET(RTC_AL_TC_SEC_MIN, data[RTC_AL_TC_REGIDX_MIN]);
+ tm->tm_hour = FIELD_GET(RTC_AL_TC_HOUR_DOM, data[RTC_AL_TC_REGIDX_HOUR]);
+ tm->tm_mday = FIELD_GET(RTC_AL_TC_HOUR_DOM, data[RTC_AL_TC_REGIDX_DOM]);
+ tm->tm_wday = FIELD_GET(RTC_AL_TC_DOW, data[RTC_AL_TC_REGIDX_DOW]);
+ tm->tm_mon = FIELD_GET(RTC_AL_TC_MON, data[RTC_AL_TC_REGIDX_MON]);
+ tm->tm_year = FIELD_GET(RTC_AL_TC_YEAR, data[RTC_AL_TC_REGIDX_YEAR]);
+
+ /* HW register start mon/wday from one, but tm_mon/tm_wday start from zero. */
+ tm->tm_mon--;
+ tm->tm_wday--;
+
+ return 0;
+}
+
+static int rtc_mt6685_read_time(struct device *dev, struct rtc_time *tm)
+{
+ struct mt6685_rtc *rtc = dev_get_drvdata(dev);
+ u16 sec;
+ int ret;
+
+ ret = clk_prepare_enable(rtc->mclk);
+ if (ret)
+ return ret;
+
+ do {
+ rtc_mt6685_reload_bbpu(rtc);
+
+ ret = rtc_mt6685_read_time_regs(rtc, tm, RTC_REG_TC_SEC);
+ if (ret)
+ goto end;
+
+ ret = regmap_bulk_read(rtc->regmap, RTC_REG_TC_SEC, &sec, sizeof(sec));
+ if (ret)
+ goto end;
+ } while ((sec & RTC_AL_TC_SEC_MIN) < tm->tm_sec);
+
+end:
+ clk_disable_unprepare(rtc->mclk);
+ return ret;
+}
+
+static int rtc_mt6685_set_time(struct device *dev, struct rtc_time *tm)
+{
+ struct mt6685_rtc *rtc = dev_get_drvdata(dev);
+ u16 data[RTC_AL_TC_REGIDX_MAX];
+ int ret;
+
+ ret = clk_prepare_enable(rtc->mclk);
+ if (ret)
+ return ret;
+
+ tm->tm_mon++;
+ tm->tm_wday++;
+
+ data[RTC_AL_TC_REGIDX_SEC] = FIELD_PREP(RTC_AL_TC_SEC_MIN, tm->tm_sec);
+ data[RTC_AL_TC_REGIDX_MIN] = FIELD_PREP(RTC_AL_TC_SEC_MIN, tm->tm_min);
+ data[RTC_AL_TC_REGIDX_HOUR] = FIELD_PREP(RTC_AL_TC_HOUR_DOM, tm->tm_hour);
+ data[RTC_AL_TC_REGIDX_DOM] = FIELD_PREP(RTC_AL_TC_HOUR_DOM, tm->tm_mday);
+ data[RTC_AL_TC_REGIDX_DOW] = FIELD_PREP(RTC_AL_TC_DOW, tm->tm_wday);
+ data[RTC_AL_TC_REGIDX_MON] = FIELD_PREP(RTC_AL_TC_MON, tm->tm_mon);
+ data[RTC_AL_TC_REGIDX_YEAR] = FIELD_PREP(RTC_AL_TC_YEAR, tm->tm_year);
+
+ ret = regmap_bulk_write(rtc->regmap, RTC_REG_TC_SEC, data,
+ RTC_AL_TC_REGIDX_MAX * sizeof(data[0]));
+ if (ret)
+ goto end;
+
+ /* Wait until write is synchronized (means time was set in HW) */
+ ret = rtc_mt6685_write_trigger(rtc);
+end:
+ clk_disable_unprepare(rtc->mclk);
+ return ret;
+}
+
+static int rtc_mt6685_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
+{
+ struct mt6685_rtc *rtc = dev_get_drvdata(dev);
+ struct rtc_time *tm = &alm->time;
+ u16 irqen, pdn2;
+ int ret;
+
+ ret = regmap_bulk_read(rtc->regmap, RTC_REG_IRQ_EN, &irqen, sizeof(irqen));
+ if (ret)
+ return ret;
+
+ ret = regmap_bulk_read(rtc->regmap, RTC_REG_PDN2, &pdn2, sizeof(pdn2));
+ if (ret)
+ return ret;
+
+ ret = rtc_mt6685_read_time_regs(rtc, tm, RTC_REG_AL_SEC);
+ if (ret)
+ return ret;
+
+ alm->enabled = FIELD_GET(RTC_IRQ_AL, irqen);
+ alm->pending = FIELD_GET(RTC_PDN2_PWRON_ALARM, pdn2);
+ return 0;
+}
+
+static int rtc_mt6685_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
+{
+ struct mt6685_rtc *rtc = dev_get_drvdata(dev);
+ struct rtc_time *tm = &alm->time;
+ u16 data[RTC_AL_TC_REGIDX_MAX];
+ u16 irqen;
+ int ret;
+
+ /*
+ * Clocks must be enabled when writing and, if that cannot be done,
+ * reading fields is pointless as the alarm cannot finally be set.
+ */
+ ret = clk_prepare_enable(rtc->mclk);
+ if (ret)
+ return ret;
+
+ tm->tm_mon++;
+ tm->tm_wday++;
+
+ ret = regmap_bulk_read(rtc->regmap, RTC_REG_IRQ_EN, &irqen, sizeof(irqen));
+ if (ret)
+ goto end;
+
+ ret = regmap_bulk_read(rtc->regmap, RTC_REG_AL_SEC, data,
+ RTC_AL_TC_REGIDX_MAX * sizeof(data[0]));
+ if (ret)
+ goto end;
+
+ FIELD_MODIFY(RTC_IRQ_AL, &irqen, alm->enabled);
+ FIELD_MODIFY(RTC_AL_TC_SEC_MIN, &data[RTC_AL_TC_REGIDX_SEC], tm->tm_sec);
+ FIELD_MODIFY(RTC_AL_TC_SEC_MIN, &data[RTC_AL_TC_REGIDX_MIN], tm->tm_min);
+ FIELD_MODIFY(RTC_AL_TC_HOUR_DOM, &data[RTC_AL_TC_REGIDX_HOUR], tm->tm_hour);
+ FIELD_MODIFY(RTC_AL_TC_HOUR_DOM, &data[RTC_AL_TC_REGIDX_DOM], tm->tm_mday);
+ FIELD_MODIFY(RTC_AL_TC_DOW, &data[RTC_AL_TC_REGIDX_DOW], tm->tm_wday);
+ FIELD_MODIFY(RTC_AL_TC_MON, &data[RTC_AL_TC_REGIDX_MON], tm->tm_mon);
+ FIELD_MODIFY(RTC_AL_TC_YEAR, &data[RTC_AL_TC_REGIDX_YEAR], tm->tm_year);
+
+ if (alm->enabled) {
+ u16 val = RTC_AL_MASK_DOW;
+
+ ret = regmap_bulk_write(rtc->regmap, RTC_REG_AL_SEC, data,
+ RTC_AL_TC_REGIDX_MAX * sizeof(data[0]));
+ if (ret)
+ goto end;
+
+ ret = regmap_bulk_write(rtc->regmap,
+ RTC_REG_AL_MASK, &val, sizeof(val));
+ if (ret)
+ goto end;
+ }
+
+ ret = regmap_bulk_write(rtc->regmap, RTC_REG_IRQ_EN, &irqen, sizeof(irqen));
+ if (ret)
+ goto end;
+
+ ret = rtc_mt6685_write_trigger(rtc);
+end:
+ clk_disable_unprepare(rtc->mclk);
+ return ret;
+}
+
+static const struct rtc_class_ops rtc_mt6685_ops = {
+ .read_time = rtc_mt6685_read_time,
+ .set_time = rtc_mt6685_set_time,
+ .read_alarm = rtc_mt6685_read_alarm,
+ .set_alarm = rtc_mt6685_set_alarm,
+};
+
+static int rtc_mt6685_probe(struct platform_device *pdev)
+{
+ struct regmap_config mt6685_rtc_regmap_config = {
+ .reg_bits = 16,
+ .val_bits = 8,
+ .max_register = 0x60,
+ .fast_io = true,
+ .use_single_read = true,
+ .use_single_write = true,
+ };
+ struct device *dev = &pdev->dev;
+ struct spmi_subdevice *sub_sdev;
+ struct spmi_device *sparent;
+ struct mt6685_rtc *rtc;
+ int ret;
+
+ rtc = devm_kzalloc(dev, sizeof(struct mt6685_rtc), GFP_KERNEL);
+ if (!rtc)
+ return -ENOMEM;
+
+ sparent = to_spmi_device(dev->parent);
+ sub_sdev = devm_spmi_subdevice_alloc_and_add(dev, sparent);
+ if (IS_ERR(sub_sdev))
+ return PTR_ERR(sub_sdev);
+
+ ret = of_property_read_u32(pdev->dev.of_node, "reg",
+ &mt6685_rtc_regmap_config.reg_base);
+ if (ret)
+ return ret;
+
+ rtc->irq = platform_get_irq(pdev, 0);
+ if (rtc->irq < 0)
+ return rtc->irq;
+
+ rtc->mclk = devm_clk_get(dev, 0);
+ if (IS_ERR(rtc->mclk))
+ return PTR_ERR(rtc->mclk);
+
+ rtc->regmap = devm_regmap_init_spmi_ext(&sub_sdev->sdev, &mt6685_rtc_regmap_config);
+ if (IS_ERR(rtc->regmap))
+ return PTR_ERR(rtc->regmap);
+
+ rtc->rdev = devm_rtc_allocate_device(dev);
+ if (IS_ERR(rtc->rdev))
+ return PTR_ERR(rtc->rdev);
+
+ platform_set_drvdata(pdev, rtc);
+
+ /* Clock is required to auto-synchronize IRQ enable to RTC */
+ ret = clk_prepare_enable(rtc->mclk);
+ if (ret)
+ return ret;
+
+ ret = devm_request_threaded_irq(&pdev->dev, rtc->irq, NULL,
+ rtc_mt6685_irq_handler_thread,
+ IRQF_ONESHOT | IRQF_TRIGGER_HIGH,
+ "mt6685-rtc", rtc);
+ clk_disable_unprepare(rtc->mclk);
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "Cannot request alarm IRQ");
+
+ device_init_wakeup(&pdev->dev, true);
+
+ rtc->rdev->ops = &rtc_mt6685_ops;
+ rtc->rdev->range_min = RTC_TIMESTAMP_BEGIN_1900;
+ rtc->rdev->range_max = mktime64(2027, 12, 31, 23, 59, 59);
+ rtc->rdev->start_secs = mktime64(1968, 1, 1, 0, 0, 0);
+ rtc->rdev->set_start_time = true;
+
+ return devm_rtc_register_device(rtc->rdev);
+}
+
+static int __maybe_unused rtc_mt6685_suspend(struct device *dev)
+{
+ struct mt6685_rtc *rtc = dev_get_drvdata(dev);
+
+ if (device_may_wakeup(dev))
+ enable_irq_wake(rtc->irq);
+
+ return 0;
+}
+
+static int __maybe_unused rtc_mt6685_resume(struct device *dev)
+{
+ struct mt6685_rtc *rtc = dev_get_drvdata(dev);
+
+ if (device_may_wakeup(dev))
+ disable_irq_wake(rtc->irq);
+
+ return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(rtc_mt6685_pm_ops, rtc_mt6685_suspend, rtc_mt6685_resume);
+
+static const struct of_device_id rtc_mt6685_of_match[] = {
+ { .compatible = "mediatek,mt6685-rtc" },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, rtc_mt6685_of_match);
+
+static struct platform_driver rtc_mt6685_driver = {
+ .driver = {
+ .name = "rtc-mt6685",
+ .of_match_table = rtc_mt6685_of_match,
+ .pm = &rtc_mt6685_pm_ops,
+ },
+ .probe = rtc_mt6685_probe,
+};
+module_platform_driver(rtc_mt6685_driver);
+
+MODULE_AUTHOR("AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>");
+MODULE_DESCRIPTION("MediaTek MT6685 Clock IC RTC driver");
+MODULE_LICENSE("GPL");
+MODULE_IMPORT_NS("SPMI");
--
2.51.1
^ permalink raw reply related
* [PATCH v1 1/2] dt-bindings: rtc: Add MediaTek MT6685 PM/Clock IC Real Time Clock
From: AngeloGioacchino Del Regno @ 2025-10-24 8:33 UTC (permalink / raw)
To: alexandre.belloni
Cc: robh, krzk+dt, conor+dt, matthias.bgg, angelogioacchino.delregno,
linux-rtc, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, kernel
In-Reply-To: <20251024083318.25890-1-angelogioacchino.delregno@collabora.com>
The MediaTek MT6685 PM / Clock IC contains various SPMI sub
devices, of which two are Real Time Clock IPs, one usually
reserved for the secure world and one for the unsecured one,
reachable at different SPMI addresses.
Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
---
NOTE: This does not contain any example because the MT6685 RTC
will be added to the mfd binding for MediaTek SPMI PMICs
and examples will be there.
** For reviewing purposes, this is how the example will look like: **
- |
#include <dt-bindings/interrupt-controller/irq.h>
#include <dt-bindings/spmi/spmi.h>
spmi {
#address-cells = <2>;
#size-cells = <0>;
pmic@9 {
compatible = "mediatek,mt6363";
reg = <0x9 SPMI_USID>;
interrupts = <9 1 IRQ_TYPE_LEVEL_HIGH>;
interrupt-controller;
#address-cells = <1>;
#interrupt-cells = <3>;
#size-cells = <0>;
clock-controller@514 {
compatible = "mediatek,mt6685-sck-top";
reg = <0x514>;
#clock-cells = <1>;
};
rtc@580 {
compatible = "mediatek,mt6685-rtc";
reg = <0x580>;
interrupts = <9 0 IRQ_TYPE_LEVEL_HIGH>;
};
};
};
.../bindings/rtc/mediatek,mt6685-rtc.yaml | 33 +++++++++++++++++++
1 file changed, 33 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/mediatek,mt6685-rtc.yaml
diff --git a/Documentation/devicetree/bindings/rtc/mediatek,mt6685-rtc.yaml b/Documentation/devicetree/bindings/rtc/mediatek,mt6685-rtc.yaml
new file mode 100644
index 000000000000..1aec163b251a
--- /dev/null
+++ b/Documentation/devicetree/bindings/rtc/mediatek,mt6685-rtc.yaml
@@ -0,0 +1,33 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/rtc/mediatek,mt6685-rtc.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: MediaTek MT6685 PM/Clock IC Real Time Clock
+
+allOf:
+ - $ref: rtc.yaml#
+
+maintainers:
+ - AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
+
+properties:
+ compatible:
+ const: mediatek,mt6685-rtc
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ clocks:
+ maxItems: 1
+
+required:
+ - compatible
+ - reg
+ - interrupts
+
+unevaluatedProperties: false
--
2.51.1
^ permalink raw reply related
* [PATCH v1 0/2] rtc: Add support for MT6685 RTC
From: AngeloGioacchino Del Regno @ 2025-10-24 8:33 UTC (permalink / raw)
To: alexandre.belloni
Cc: robh, krzk+dt, conor+dt, matthias.bgg, angelogioacchino.delregno,
linux-rtc, devicetree, linux-kernel, linux-arm-kernel,
linux-mediatek, kernel
This series adds a driver for the Real Time Clock found in the MT6685
Clock/PM IC.
This chip has been used on a number of different MediaTek platforms
from around 2023 to the latest ones released in 2025 - and on both
Smartphones (Helio and Dimensity), Chromebooks (Kompanio Ultra) and
Genio boards.
This was tested on a MT8196 (Kompanio Ultra) Chromebook.
NOTE: This series depends on series [1] "SPMI: Implement sub-devices
and migrate drivers"
[1]: https://lore.kernel.org/all/20251021083219.17382-1-angelogioacchino.delregno@collabora.com
AngeloGioacchino Del Regno (2):
dt-bindings: rtc: Add MediaTek MT6685 PM/Clock IC Real Time Clock
rtc: Add support for MT6685 Clock IC's RTC over SPMI
.../bindings/rtc/mediatek,mt6685-rtc.yaml | 33 ++
drivers/rtc/Kconfig | 12 +
drivers/rtc/Makefile | 1 +
drivers/rtc/rtc-mt6685.c | 472 ++++++++++++++++++
4 files changed, 518 insertions(+)
create mode 100644 Documentation/devicetree/bindings/rtc/mediatek,mt6685-rtc.yaml
create mode 100644 drivers/rtc/rtc-mt6685.c
--
2.51.1
^ permalink raw reply
* [PATCH v4 3/3] rtc: tegra: Replace deprecated SIMPLE_DEV_PM_OPS
From: Kartik Rajput @ 2025-10-24 6:49 UTC (permalink / raw)
To: alexandre.belloni, thierry.reding, jonathanh, andriy.shevchenko,
linux-rtc, linux-tegra, linux-kernel
Cc: Kartik Rajput
In-Reply-To: <20251024064952.775883-1-kkartik@nvidia.com>
Replace deprecated SIMPLE_DEV_PM_OPS with DEFINE_SIMPLE_DEV_PM_OPS macro
and use pm_sleep_ptr() to initialize pm_ops. This also allows us to drop
the checks for CONFIG_PM_SLEEP.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
Changes in v4:
* Updated commit subject.
---
drivers/rtc/rtc-tegra.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index 9e4e9c88178f..528e32b7d101 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -340,7 +340,6 @@ static int tegra_rtc_probe(struct platform_device *pdev)
return 0;
}
-#ifdef CONFIG_PM_SLEEP
static int tegra_rtc_suspend(struct device *dev)
{
struct tegra_rtc_info *info = dev_get_drvdata(dev);
@@ -378,9 +377,8 @@ static int tegra_rtc_resume(struct device *dev)
return 0;
}
-#endif
-static SIMPLE_DEV_PM_OPS(tegra_rtc_pm_ops, tegra_rtc_suspend, tegra_rtc_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(tegra_rtc_pm_ops, tegra_rtc_suspend, tegra_rtc_resume);
static void tegra_rtc_shutdown(struct platform_device *pdev)
{
@@ -395,7 +393,7 @@ static struct platform_driver tegra_rtc_driver = {
.name = "tegra_rtc",
.of_match_table = tegra_rtc_dt_match,
.acpi_match_table = tegra_rtc_acpi_match,
- .pm = &tegra_rtc_pm_ops,
+ .pm = pm_sleep_ptr(&tegra_rtc_pm_ops),
},
};
module_platform_driver(tegra_rtc_driver);
--
2.43.0
^ permalink raw reply related
* [PATCH v4 2/3] rtc: tegra: Add ACPI support
From: Kartik Rajput @ 2025-10-24 6:49 UTC (permalink / raw)
To: alexandre.belloni, thierry.reding, jonathanh, andriy.shevchenko,
linux-rtc, linux-tegra, linux-kernel
Cc: Kartik Rajput
In-Reply-To: <20251024064952.775883-1-kkartik@nvidia.com>
Add ACPI support for Tegra RTC, which is available on Tegra241 and
Tegra410. Both Tegra241 and Tegra410 use the same ACPI ID 'NVDA0280'.
When ACPI boot is used, the RTC clock is configured by UEFI before
the kernel boots. On device-tree boot, the probe must fail if clocks are
not provided in the device-tree.
Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
Changes in v3:
* Add patch to use devm_clk_get_enabled().
* Add patch to use pm_sleep_ptr().
* Update commit message to specify clocks are requried for
device-tree boot.
Changes in v2:
* Dropped "linux/acpi.h" from includes.
* Dropped redundant ', 0' part from tegra_rtc_acpi_match.
* Replaced "is_of_node(dev_fwnode(&pdev->dev))" with
"dev_of_node(&pdev->dev)" to check device of node.
* Dropped redundant of_node checks before accessing clock
related APIs.
---
drivers/rtc/rtc-tegra.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index e8c83a6a96b3..9e4e9c88178f 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -274,6 +274,12 @@ static const struct of_device_id tegra_rtc_dt_match[] = {
};
MODULE_DEVICE_TABLE(of, tegra_rtc_dt_match);
+static const struct acpi_device_id tegra_rtc_acpi_match[] = {
+ { "NVDA0280" },
+ { }
+};
+MODULE_DEVICE_TABLE(acpi, tegra_rtc_acpi_match);
+
static int tegra_rtc_probe(struct platform_device *pdev)
{
struct tegra_rtc_info *info;
@@ -300,9 +306,11 @@ static int tegra_rtc_probe(struct platform_device *pdev)
info->rtc->ops = &tegra_rtc_ops;
info->rtc->range_max = U32_MAX;
- info->clk = devm_clk_get_enabled(&pdev->dev, NULL);
- if (IS_ERR(info->clk))
- return PTR_ERR(info->clk);
+ if (dev_of_node(&pdev->dev)) {
+ info->clk = devm_clk_get_enabled(&pdev->dev, NULL);
+ if (IS_ERR(info->clk))
+ return PTR_ERR(info->clk);
+ }
/* set context info */
info->pdev = pdev;
@@ -386,6 +394,7 @@ static struct platform_driver tegra_rtc_driver = {
.driver = {
.name = "tegra_rtc",
.of_match_table = tegra_rtc_dt_match,
+ .acpi_match_table = tegra_rtc_acpi_match,
.pm = &tegra_rtc_pm_ops,
},
};
--
2.43.0
^ permalink raw reply related
* [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe
From: Kartik Rajput @ 2025-10-24 6:49 UTC (permalink / raw)
To: alexandre.belloni, thierry.reding, jonathanh, andriy.shevchenko,
linux-rtc, linux-tegra, linux-kernel
Cc: Kartik Rajput
Simplify clock management by replacing devm_clk_get() and manual clock
enable/disable with devm_clk_get_enabled(). This also simplifies the
error handling logic. Also remove tegra_rtc_remove() as the clock will
automatically be disabled when the device is unbound from the bus.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
Changes in v4:
* Removed tegra_rtc_remove() as this is not required now.
* Updated commit message to specify this.
---
drivers/rtc/rtc-tegra.c | 26 ++++----------------------
1 file changed, 4 insertions(+), 22 deletions(-)
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index 46788db89953..e8c83a6a96b3 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -300,14 +300,10 @@ static int tegra_rtc_probe(struct platform_device *pdev)
info->rtc->ops = &tegra_rtc_ops;
info->rtc->range_max = U32_MAX;
- info->clk = devm_clk_get(&pdev->dev, NULL);
+ info->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(info->clk))
return PTR_ERR(info->clk);
- ret = clk_prepare_enable(info->clk);
- if (ret < 0)
- return ret;
-
/* set context info */
info->pdev = pdev;
spin_lock_init(&info->lock);
@@ -324,29 +320,16 @@ static int tegra_rtc_probe(struct platform_device *pdev)
ret = devm_request_irq(&pdev->dev, info->irq, tegra_rtc_irq_handler,
IRQF_TRIGGER_HIGH, dev_name(&pdev->dev),
&pdev->dev);
- if (ret) {
- dev_err(&pdev->dev, "failed to request interrupt: %d\n", ret);
- goto disable_clk;
- }
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "failed to request interrupt\n");
ret = devm_rtc_register_device(info->rtc);
if (ret)
- goto disable_clk;
+ return ret;
dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n");
return 0;
-
-disable_clk:
- clk_disable_unprepare(info->clk);
- return ret;
-}
-
-static void tegra_rtc_remove(struct platform_device *pdev)
-{
- struct tegra_rtc_info *info = platform_get_drvdata(pdev);
-
- clk_disable_unprepare(info->clk);
}
#ifdef CONFIG_PM_SLEEP
@@ -399,7 +382,6 @@ static void tegra_rtc_shutdown(struct platform_device *pdev)
static struct platform_driver tegra_rtc_driver = {
.probe = tegra_rtc_probe,
- .remove = tegra_rtc_remove,
.shutdown = tegra_rtc_shutdown,
.driver = {
.name = "tegra_rtc",
--
2.43.0
^ permalink raw reply related
* Re: [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe
From: Andy Shevchenko @ 2025-10-23 18:05 UTC (permalink / raw)
To: Kartik Rajput
Cc: alexandre.belloni, thierry.reding, jonathanh, linux-rtc,
linux-tegra, linux-kernel
In-Reply-To: <20251023093042.770798-1-kkartik@nvidia.com>
On Thu, Oct 23, 2025 at 03:00:40PM +0530, Kartik Rajput wrote:
> Simplify clock management by replacing devm_clk_get() and manual clock
> enable/disable with devm_clk_get_enabled(). This also simplifies the
> error handling logic.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
with the caveat that you need to remove ->remove() altogether as well.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v3 3/3] rtc: tegra: Drop deprecated SIMPLE_DEV_PM_OPS
From: Andy Shevchenko @ 2025-10-23 18:04 UTC (permalink / raw)
To: Kartik Rajput
Cc: alexandre.belloni, thierry.reding, jonathanh, linux-rtc,
linux-tegra, linux-kernel
In-Reply-To: <20251023093042.770798-3-kkartik@nvidia.com>
On Thu, Oct 23, 2025 at 03:00:42PM +0530, Kartik Rajput wrote:
> Replace deprecated SIMPLE_DEV_PM_OPS with DEFINE_SIMPLE_DEV_PM_OPS macro
> and use pm_sleep_ptr() to initialize pm_ops. This also allows us to drop
> the checks for CONFIG_PM_SLEEP.
Probably Subject also should be "Replace deprecated...".
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: [PATCH v3 2/3] rtc: tegra: Add ACPI support
From: Andy Shevchenko @ 2025-10-23 18:04 UTC (permalink / raw)
To: Kartik Rajput
Cc: alexandre.belloni, thierry.reding, jonathanh, linux-rtc,
linux-tegra, linux-kernel
In-Reply-To: <20251023093042.770798-2-kkartik@nvidia.com>
On Thu, Oct 23, 2025 at 03:00:41PM +0530, Kartik Rajput wrote:
> Add ACPI support for Tegra RTC, which is available on Tegra241 and
> Tegra410. Both Tegra241 and Tegra410 use the same ACPI ID 'NVDA0280'.
> When ACPI boot is used, the RTC clock is configured by UEFI before
> the kernel boots. On device-tree boot, the probe must fail if clocks are
> not provided in the device-tree.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: PROBLEM: hwclock busted w/ M48T59 RTC (regression)
From: Nick Bowler @ 2025-10-23 13:39 UTC (permalink / raw)
To: Esben Haabendal; +Cc: linux-kernel, regressions, linux-rtc, stable, sparclinux
In-Reply-To: <DmLaDrfp-izPBqLjB9SAGPy3WVKOPNgg9FInsykhNO3WPEWgltKF5GoDknld3l5xoJxovduV8xn8ygSupvyIFOCCZl0Q0aTXwKT2XhPM1n8=@geanix.com>
On Thu, Oct 23, 2025 at 07:21:21AM +0000, Esben Haabendal wrote:
> On Thursday, 23 October 2025 at 06:45, Nick Bowler <nbowler@draconx.ca> wrote:
>
> > After a stable kernel update, the hwclock command seems no longer
> > functional on my SPARC system with an ST M48T59Y-70PC1 RTC:
> >
> > # hwclock
> > [...long delay...]
>
> I assume this is 10 seconds long.
Yeah, about that.
> > hwclock: select() to /dev/rtc0 to wait for clock tick timed out
>
> And this is 100% reproducible, or does it sometimes work and sometimes fail?
It fails every time.
> Are you using the util-linux hwclock command? Which version?
hwclock from util-linux 2.40.2
> Do you have CONFIG_RTC_INTF_DEV_UIE_EMUL enabled?
No, this option is not enabled.
> Can you run `hwclock --verbose`, both with and without the reverted commit,
> and send the output from that?
6.18-rc2 (broken):
# hwclock --verbose
hwclock from util-linux 2.40.2
System Time: 1761226454.799573
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1657523820 seconds after 1969
Last calibration done at 1657523820 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
...synchronization failed
6.18-rc2 w/ revert (working):
# hwclock --verbose
hwclock from util-linux 2.40.2
System Time: 1761226685.238753
Trying to open: /dev/rtc0
Using the rtc interface to the clock.
Last drift adjustment done at 1657523820 seconds after 1969
Last calibration done at 1657523820 seconds after 1969
Hardware clock is on UTC time
Assuming hardware clock is kept in UTC time.
Waiting for clock tick...
ioctl(3, RTC_UIE_ON, 0): Input/output error
Waiting in loop for time from /dev/rtc0 to change
...got clock tick
Time read from Hardware Clock: 2025/10/23 13:38:06
Hw clock time : 2025/10/23 13:38:06 = 1761226686 seconds since 1969
Time since last adjustment is 103702866 seconds
Calculated Hardware Clock drift is 0.000000 seconds
2025-10-23 09:38:05.239100-04:00
Thanks,
Nick
^ permalink raw reply
* Re: [PATCH v2] rtc: tegra: Add ACPI support
From: Kartik Rajput @ 2025-10-23 9:32 UTC (permalink / raw)
To: Andy Shevchenko
Cc: alexandre.belloni, thierry.reding, jonathanh, linux-rtc,
linux-tegra, linux-kernel
In-Reply-To: <aPna3Q9L4Rc9Ufxt@smile.fi.intel.com>
On 23/10/25 13:05, Andy Shevchenko wrote:
> External email: Use caution opening links or attachments
>
>
> On Thu, Oct 23, 2025 at 12:14:13PM +0530, Kartik Rajput wrote:
>> On 22/10/25 22:38, Andy Shevchenko wrote:
>>> On Wed, Oct 22, 2025 at 12:06:45PM +0530, Kartik Rajput wrote:
>
> ...
>
>>>> - info->clk = devm_clk_get(&pdev->dev, NULL);
>>>> - if (IS_ERR(info->clk))
>>>> - return PTR_ERR(info->clk);
>>>> + if (dev_of_node(&pdev->dev)) {
>>>> + info->clk = devm_clk_get(&pdev->dev, NULL);
>>>> + if (IS_ERR(info->clk))
>>>> + return PTR_ERR(info->clk);
>>>> + }
>>>>
>>>> ret = clk_prepare_enable(info->clk);
>>>
>>> Since we still call CLK APIs unconditionally here, shouldn't be the whole
>>> approach just to move to _optional() CLK API?
>>>
>>> info->clk = devm_clk_get_optional(&pdev->dev, NULL);
>>>
>>> I haven't checked the code below, but maybe even one can incorporate _enabled
>>> to this as well (in a separate change as it's not related to this patch
>>> directly).
>>
>> The reason I did not use the _optional API is because the clocks are required
>> for the device-tree. Therefore, it must fail if clocks are not provided on
>> device-tree boot.
>
> I see, please mention this in the commit message. And perhaps add a patch to
> convert to devm_clk_get_enabled().
>
> On top of that you also can convert driver to use pm_sleep_ptr() and drop ugly
> ifdeffery. But this is really out of scope, and up to you to decide.
>
> --
> With Best Regards,
> Andy Shevchenko
>
>
Thanks for the suggestions, Andy! I have posted v3 with all these changes here:
https://lore.kernel.org/linux-tegra/20251023093042.770798-1-kkartik@nvidia.com/T/#t
Regards,
Kartik
^ permalink raw reply
* [PATCH v3 2/3] rtc: tegra: Add ACPI support
From: Kartik Rajput @ 2025-10-23 9:30 UTC (permalink / raw)
To: alexandre.belloni, thierry.reding, jonathanh, andriy.shevchenko,
linux-rtc, linux-tegra, linux-kernel
Cc: Kartik Rajput
In-Reply-To: <20251023093042.770798-1-kkartik@nvidia.com>
Add ACPI support for Tegra RTC, which is available on Tegra241 and
Tegra410. Both Tegra241 and Tegra410 use the same ACPI ID 'NVDA0280'.
When ACPI boot is used, the RTC clock is configured by UEFI before
the kernel boots. On device-tree boot, the probe must fail if clocks are
not provided in the device-tree.
Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
---
Changes in v3:
* Add patch to use devm_clk_get_enabled().
* Add patch to use pm_sleep_ptr().
* Update commit message to specify clocks are requried for
device-tree boot.
Changes in v2:
* Dropped "linux/acpi.h" from includes.
* Dropped redundant ', 0' part from tegra_rtc_acpi_match.
* Replaced "is_of_node(dev_fwnode(&pdev->dev))" with
"dev_of_node(&pdev->dev)" to check device of node.
* Dropped redundant of_node checks before accessing clock
related APIs.
---
drivers/rtc/rtc-tegra.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index 51f5bb55c176..ad0c57ce87df 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -274,6 +274,12 @@ static const struct of_device_id tegra_rtc_dt_match[] = {
};
MODULE_DEVICE_TABLE(of, tegra_rtc_dt_match);
+static const struct acpi_device_id tegra_rtc_acpi_match[] = {
+ { "NVDA0280" },
+ { }
+};
+MODULE_DEVICE_TABLE(acpi, tegra_rtc_acpi_match);
+
static int tegra_rtc_probe(struct platform_device *pdev)
{
struct tegra_rtc_info *info;
@@ -300,9 +306,11 @@ static int tegra_rtc_probe(struct platform_device *pdev)
info->rtc->ops = &tegra_rtc_ops;
info->rtc->range_max = U32_MAX;
- info->clk = devm_clk_get_enabled(&pdev->dev, NULL);
- if (IS_ERR(info->clk))
- return PTR_ERR(info->clk);
+ if (dev_of_node(&pdev->dev)) {
+ info->clk = devm_clk_get_enabled(&pdev->dev, NULL);
+ if (IS_ERR(info->clk))
+ return PTR_ERR(info->clk);
+ }
/* set context info */
info->pdev = pdev;
@@ -394,6 +402,7 @@ static struct platform_driver tegra_rtc_driver = {
.driver = {
.name = "tegra_rtc",
.of_match_table = tegra_rtc_dt_match,
+ .acpi_match_table = tegra_rtc_acpi_match,
.pm = &tegra_rtc_pm_ops,
},
};
--
2.43.0
^ permalink raw reply related
* [PATCH v3 3/3] rtc: tegra: Drop deprecated SIMPLE_DEV_PM_OPS
From: Kartik Rajput @ 2025-10-23 9:30 UTC (permalink / raw)
To: alexandre.belloni, thierry.reding, jonathanh, andriy.shevchenko,
linux-rtc, linux-tegra, linux-kernel
Cc: Kartik Rajput
In-Reply-To: <20251023093042.770798-1-kkartik@nvidia.com>
Replace deprecated SIMPLE_DEV_PM_OPS with DEFINE_SIMPLE_DEV_PM_OPS macro
and use pm_sleep_ptr() to initialize pm_ops. This also allows us to drop
the checks for CONFIG_PM_SLEEP.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
---
drivers/rtc/rtc-tegra.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index ad0c57ce87df..3ee8e1c97a5a 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -347,7 +347,6 @@ static void tegra_rtc_remove(struct platform_device *pdev)
clk_disable_unprepare(info->clk);
}
-#ifdef CONFIG_PM_SLEEP
static int tegra_rtc_suspend(struct device *dev)
{
struct tegra_rtc_info *info = dev_get_drvdata(dev);
@@ -385,9 +384,8 @@ static int tegra_rtc_resume(struct device *dev)
return 0;
}
-#endif
-static SIMPLE_DEV_PM_OPS(tegra_rtc_pm_ops, tegra_rtc_suspend, tegra_rtc_resume);
+static DEFINE_SIMPLE_DEV_PM_OPS(tegra_rtc_pm_ops, tegra_rtc_suspend, tegra_rtc_resume);
static void tegra_rtc_shutdown(struct platform_device *pdev)
{
@@ -403,7 +401,7 @@ static struct platform_driver tegra_rtc_driver = {
.name = "tegra_rtc",
.of_match_table = tegra_rtc_dt_match,
.acpi_match_table = tegra_rtc_acpi_match,
- .pm = &tegra_rtc_pm_ops,
+ .pm = pm_sleep_ptr(&tegra_rtc_pm_ops),
},
};
module_platform_driver(tegra_rtc_driver);
--
2.43.0
^ permalink raw reply related
* [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe
From: Kartik Rajput @ 2025-10-23 9:30 UTC (permalink / raw)
To: alexandre.belloni, thierry.reding, jonathanh, andriy.shevchenko,
linux-rtc, linux-tegra, linux-kernel
Cc: Kartik Rajput
Simplify clock management by replacing devm_clk_get() and manual clock
enable/disable with devm_clk_get_enabled(). This also simplifies the
error handling logic.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
---
drivers/rtc/rtc-tegra.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index 46788db89953..51f5bb55c176 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -300,14 +300,10 @@ static int tegra_rtc_probe(struct platform_device *pdev)
info->rtc->ops = &tegra_rtc_ops;
info->rtc->range_max = U32_MAX;
- info->clk = devm_clk_get(&pdev->dev, NULL);
+ info->clk = devm_clk_get_enabled(&pdev->dev, NULL);
if (IS_ERR(info->clk))
return PTR_ERR(info->clk);
- ret = clk_prepare_enable(info->clk);
- if (ret < 0)
- return ret;
-
/* set context info */
info->pdev = pdev;
spin_lock_init(&info->lock);
@@ -324,22 +320,16 @@ static int tegra_rtc_probe(struct platform_device *pdev)
ret = devm_request_irq(&pdev->dev, info->irq, tegra_rtc_irq_handler,
IRQF_TRIGGER_HIGH, dev_name(&pdev->dev),
&pdev->dev);
- if (ret) {
- dev_err(&pdev->dev, "failed to request interrupt: %d\n", ret);
- goto disable_clk;
- }
+ if (ret)
+ return dev_err_probe(&pdev->dev, ret, "failed to request interrupt\n");
ret = devm_rtc_register_device(info->rtc);
if (ret)
- goto disable_clk;
+ return ret;
dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n");
return 0;
-
-disable_clk:
- clk_disable_unprepare(info->clk);
- return ret;
}
static void tegra_rtc_remove(struct platform_device *pdev)
--
2.43.0
^ permalink raw reply related
* Re: [PATCH v2] rtc: tegra: Add ACPI support
From: Andy Shevchenko @ 2025-10-23 7:35 UTC (permalink / raw)
To: Kartik Rajput
Cc: alexandre.belloni, thierry.reding, jonathanh, linux-rtc,
linux-tegra, linux-kernel
In-Reply-To: <f4defdc9-2cc0-45a0-a391-cb8678eb1b23@nvidia.com>
On Thu, Oct 23, 2025 at 12:14:13PM +0530, Kartik Rajput wrote:
> On 22/10/25 22:38, Andy Shevchenko wrote:
> > On Wed, Oct 22, 2025 at 12:06:45PM +0530, Kartik Rajput wrote:
...
> > > - info->clk = devm_clk_get(&pdev->dev, NULL);
> > > - if (IS_ERR(info->clk))
> > > - return PTR_ERR(info->clk);
> > > + if (dev_of_node(&pdev->dev)) {
> > > + info->clk = devm_clk_get(&pdev->dev, NULL);
> > > + if (IS_ERR(info->clk))
> > > + return PTR_ERR(info->clk);
> > > + }
> > >
> > > ret = clk_prepare_enable(info->clk);
> >
> > Since we still call CLK APIs unconditionally here, shouldn't be the whole
> > approach just to move to _optional() CLK API?
> >
> > info->clk = devm_clk_get_optional(&pdev->dev, NULL);
> >
> > I haven't checked the code below, but maybe even one can incorporate _enabled
> > to this as well (in a separate change as it's not related to this patch
> > directly).
>
> The reason I did not use the _optional API is because the clocks are required
> for the device-tree. Therefore, it must fail if clocks are not provided on
> device-tree boot.
I see, please mention this in the commit message. And perhaps add a patch to
convert to devm_clk_get_enabled().
On top of that you also can convert driver to use pm_sleep_ptr() and drop ugly
ifdeffery. But this is really out of scope, and up to you to decide.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* Re: PROBLEM: hwclock busted w/ M48T59 RTC (regression)
From: Esben Haabendal @ 2025-10-23 7:21 UTC (permalink / raw)
To: Nick Bowler; +Cc: linux-kernel, regressions, linux-rtc, stable, sparclinux
In-Reply-To: <krmiwpwogrvpehlqdrugb5glcmsu54qpw3mteonqeqymrvzz37@dzt7mes7qgxt>
On Thursday, 23 October 2025 at 06:45, Nick Bowler <nbowler@draconx.ca> wrote:
> After a stable kernel update, the hwclock command seems no longer
> functional on my SPARC system with an ST M48T59Y-70PC1 RTC:
>
> # hwclock
> [...long delay...]
I assume this is 10 seconds long.
> hwclock: select() to /dev/rtc0 to wait for clock tick timed out
And this is 100% reproducible, or does it sometimes work and sometimes fail?
> On prior kernels, there is no problem:
>
> # hwclock
> 2025-10-22 22:21:04.806992-04:00
>
> I reproduced the same failure on 6.18-rc2 and bisected to this commit:
>
> commit 795cda8338eab036013314dbc0b04aae728880ab
> Author: Esben Haabendal esben@geanix.com
>
> Date: Fri May 16 09:23:35 2025 +0200
>
> rtc: interface: Fix long-standing race when setting alarm
>
> This commit was backported to all current 6.x stable branches,
> as well as 5.15.x, so they all have the same regression.
>
> Reverting this commit on top of 6.18-rc2 corrects the problem.
>
> Let me know if you need any more info!
Are you using the util-linux hwclock command? Which version?
Do you have CONFIG_RTC_INTF_DEV_UIE_EMUL enabled?
Can you run `hwclock --verbose`, both with and without the reverted commit,
and send the output from that?
/Esben
^ permalink raw reply
* Re: [PATCH v2] rtc: tegra: Add ACPI support
From: Kartik Rajput @ 2025-10-23 6:44 UTC (permalink / raw)
To: Andy Shevchenko
Cc: alexandre.belloni, thierry.reding, jonathanh, linux-rtc,
linux-tegra, linux-kernel
In-Reply-To: <aPkPkHr0Hp_MabPx@smile.fi.intel.com>
On 22/10/25 22:38, Andy Shevchenko wrote:
> External email: Use caution opening links or attachments
>
>
> On Wed, Oct 22, 2025 at 12:06:45PM +0530, Kartik Rajput wrote:
>> Add ACPI support for Tegra RTC, which is available on Tegra241 and
>> Tegra410. Both Tegra241 and Tegra410 use the same ACPI ID 'NVDA0280'.
>> The RTC clock is configured by UEFI before the kernel boots.
>
> Thanks for an update, looks much better now!
> A comment below, though.
>
> ...
>
>> - info->clk = devm_clk_get(&pdev->dev, NULL);
>> - if (IS_ERR(info->clk))
>> - return PTR_ERR(info->clk);
>> + if (dev_of_node(&pdev->dev)) {
>> + info->clk = devm_clk_get(&pdev->dev, NULL);
>> + if (IS_ERR(info->clk))
>> + return PTR_ERR(info->clk);
>> + }
>>
>> ret = clk_prepare_enable(info->clk);
>
> Since we still call CLK APIs unconditionally here, shouldn't be the whole
> approach just to move to _optional() CLK API?
>
> info->clk = devm_clk_get_optional(&pdev->dev, NULL);
>
> I haven't checked the code below, but maybe even one can incorporate _enabled
> to this as well (in a separate change as it's not related to this patch
> directly).
>
Hi Andy,
The reason I did not use the _optional API is because the clocks are required
for the device-tree. Therefore, it must fail if clocks are not provided on
device-tree boot.
Thanks,
Kartik
> --
> With Best Regards,
> Andy Shevchenko
>
>
^ permalink raw reply
* PROBLEM: hwclock busted w/ M48T59 RTC (regression)
From: Nick Bowler @ 2025-10-23 4:45 UTC (permalink / raw)
To: linux-kernel, regressions, linux-rtc; +Cc: Esben Haabendal, stable, sparclinux
Hi,
After a stable kernel update, the hwclock command seems no longer
functional on my SPARC system with an ST M48T59Y-70PC1 RTC:
# hwclock
[...long delay...]
hwclock: select() to /dev/rtc0 to wait for clock tick timed out
On prior kernels, there is no problem:
# hwclock
2025-10-22 22:21:04.806992-04:00
I reproduced the same failure on 6.18-rc2 and bisected to this commit:
commit 795cda8338eab036013314dbc0b04aae728880ab
Author: Esben Haabendal <esben@geanix.com>
Date: Fri May 16 09:23:35 2025 +0200
rtc: interface: Fix long-standing race when setting alarm
This commit was backported to all current 6.x stable branches,
as well as 5.15.x, so they all have the same regression.
Reverting this commit on top of 6.18-rc2 corrects the problem.
Let me know if you need any more info!
Thanks,
Nick
^ permalink raw reply
* Re: [PATCH v2 2/6] dt-bindings: rtc: renesas,rz-rtca3: Add RZ/V2H support
From: Conor Dooley @ 2025-10-22 17:42 UTC (permalink / raw)
To: Ovidiu Panait
Cc: claudiu.beznea.uj, alexandre.belloni, robh, krzk+dt, conor+dt,
geert+renesas, magnus.damm, mturquette, sboyd, p.zabel, linux-rtc,
linux-renesas-soc, devicetree, linux-kernel, linux-clk
In-Reply-To: <20251021080705.18116-3-ovidiu.panait.rb@renesas.com>
[-- Attachment #1: Type: text/plain, Size: 759 bytes --]
On Tue, Oct 21, 2025 at 08:07:01AM +0000, Ovidiu Panait wrote:
> The Renesas RZ/V2H RTC IP is based on the same RTCA3 IP as RZ/G3S
> (r9a08g045), with the following differences:
> - It lacks the time capture functionality
> - The maximum supported periodic interrupt frequency is 128Hz instead
> of 256Hz
> - It requires two reset lines instead of one
>
> Add new compatible string "renesas,r9a09g057-rtca3" for RZ/V2H and update
> the binding accordingly:
> - Allow "resets" to contain one or two entries depending on the SoC.
> - Add "reset-names" property, but make it required only for RZ/V2H.
>
> Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
pw-bot: not-applicable
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply
* Re: [PATCH v2] rtc: tegra: Add ACPI support
From: Andy Shevchenko @ 2025-10-22 17:08 UTC (permalink / raw)
To: Kartik Rajput
Cc: alexandre.belloni, thierry.reding, jonathanh, linux-rtc,
linux-tegra, linux-kernel
In-Reply-To: <20251022063645.765599-1-kkartik@nvidia.com>
On Wed, Oct 22, 2025 at 12:06:45PM +0530, Kartik Rajput wrote:
> Add ACPI support for Tegra RTC, which is available on Tegra241 and
> Tegra410. Both Tegra241 and Tegra410 use the same ACPI ID 'NVDA0280'.
> The RTC clock is configured by UEFI before the kernel boots.
Thanks for an update, looks much better now!
A comment below, though.
...
> - info->clk = devm_clk_get(&pdev->dev, NULL);
> - if (IS_ERR(info->clk))
> - return PTR_ERR(info->clk);
> + if (dev_of_node(&pdev->dev)) {
> + info->clk = devm_clk_get(&pdev->dev, NULL);
> + if (IS_ERR(info->clk))
> + return PTR_ERR(info->clk);
> + }
>
> ret = clk_prepare_enable(info->clk);
Since we still call CLK APIs unconditionally here, shouldn't be the whole
approach just to move to _optional() CLK API?
info->clk = devm_clk_get_optional(&pdev->dev, NULL);
I haven't checked the code below, but maybe even one can incorporate _enabled
to this as well (in a separate change as it's not related to this patch
directly).
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply
* [PATCH v2] rtc: tegra: Add ACPI support
From: Kartik Rajput @ 2025-10-22 6:36 UTC (permalink / raw)
To: alexandre.belloni, thierry.reding, jonathanh, andriy.shevchenko,
linux-rtc, linux-tegra, linux-kernel
Cc: Kartik Rajput
Add ACPI support for Tegra RTC, which is available on Tegra241 and
Tegra410. Both Tegra241 and Tegra410 use the same ACPI ID 'NVDA0280'.
The RTC clock is configured by UEFI before the kernel boots.
Signed-off-by: Kartik Rajput <kkartik@nvidia.com>
---
v1 -> v2:
* Dropped "linux/acpi.h" from includes.
* Dropped redundant ', 0' part from tegra_rtc_acpi_match.
* Replaced "is_of_node(dev_fwnode(&pdev->dev))" with
"dev_of_node(&pdev->dev)" to check device of node.
* Dropped redundant of_node checks before accessing clock
related APIs.
---
drivers/rtc/rtc-tegra.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c
index 46788db89953..a34f0c80fc37 100644
--- a/drivers/rtc/rtc-tegra.c
+++ b/drivers/rtc/rtc-tegra.c
@@ -274,6 +274,12 @@ static const struct of_device_id tegra_rtc_dt_match[] = {
};
MODULE_DEVICE_TABLE(of, tegra_rtc_dt_match);
+static const struct acpi_device_id tegra_rtc_acpi_match[] = {
+ { "NVDA0280" },
+ { }
+};
+MODULE_DEVICE_TABLE(acpi, tegra_rtc_acpi_match);
+
static int tegra_rtc_probe(struct platform_device *pdev)
{
struct tegra_rtc_info *info;
@@ -300,9 +306,11 @@ static int tegra_rtc_probe(struct platform_device *pdev)
info->rtc->ops = &tegra_rtc_ops;
info->rtc->range_max = U32_MAX;
- info->clk = devm_clk_get(&pdev->dev, NULL);
- if (IS_ERR(info->clk))
- return PTR_ERR(info->clk);
+ if (dev_of_node(&pdev->dev)) {
+ info->clk = devm_clk_get(&pdev->dev, NULL);
+ if (IS_ERR(info->clk))
+ return PTR_ERR(info->clk);
+ }
ret = clk_prepare_enable(info->clk);
if (ret < 0)
@@ -404,6 +412,7 @@ static struct platform_driver tegra_rtc_driver = {
.driver = {
.name = "tegra_rtc",
.of_match_table = tegra_rtc_dt_match,
+ .acpi_match_table = tegra_rtc_acpi_match,
.pm = &tegra_rtc_pm_ops,
},
};
--
2.43.0
^ permalink raw reply related
* Re: [PATCH v2] rtc: amlogic-a4: fix double free caused by devm
From: Xianwei Zhao @ 2025-10-22 5:48 UTC (permalink / raw)
To: Haotian Zhang, alexandre.belloni, yiting.deng
Cc: linux-amlogic, linux-rtc, linux-kernel
In-Reply-To: <20251021103559.1903-1-vulab@iscas.ac.cn>
Reviewed-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
On 2025/10/21 18:35, Haotian Zhang wrote:
> [Some people who received this message don't often get email from vulab@iscas.ac.cn. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> [ EXTERNAL EMAIL ]
>
> The clock obtained via devm_clk_get_enabled() is automatically managed
> by devres and will be disabled and freed on driver detach. Manually
> calling clk_disable_unprepare() in error path and remove function
> causes double free.
>
> Remove the redundant clk_disable_unprepare() calls from the probe
> error path and aml_rtc_remove(), allowing the devm framework to
> automatically manage the clock lifecycle.
>
> Fixes: c89ac9182ee2 ("rtc: support for the Amlogic on-chip RTC")
> Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
> ---
> v2: Also remove the now-unused local variable 'rtc' in aml_rtc_remove()
> ---
> drivers/rtc/rtc-amlogic-a4.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/drivers/rtc/rtc-amlogic-a4.c b/drivers/rtc/rtc-amlogic-a4.c
> index 1928b29c1045..a993d35e1d6b 100644
> --- a/drivers/rtc/rtc-amlogic-a4.c
> +++ b/drivers/rtc/rtc-amlogic-a4.c
> @@ -390,7 +390,6 @@ static int aml_rtc_probe(struct platform_device *pdev)
>
> return 0;
> err_clk:
> - clk_disable_unprepare(rtc->sys_clk);
> device_init_wakeup(dev, false);
>
> return ret;
> @@ -423,9 +422,6 @@ static SIMPLE_DEV_PM_OPS(aml_rtc_pm_ops,
>
> static void aml_rtc_remove(struct platform_device *pdev)
> {
> - struct aml_rtc_data *rtc = dev_get_drvdata(&pdev->dev);
> -
> - clk_disable_unprepare(rtc->sys_clk);
> device_init_wakeup(&pdev->dev, false);
> }
>
> --
> 2.25.1
>
^ permalink raw reply
* Re: [PATCH v2 07/11] input: macsmc-hid: New driver to handle the Apple Mac SMC buttons/lid
From: Janne Grunau @ 2025-10-21 21:35 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: James Calligeros, Sven Peter, Alyssa Rosenzweig, Neal Gompa,
Lee Jones, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Alexandre Belloni, Jean Delvare, Guenter Roeck, asahi,
linux-arm-kernel, devicetree, linux-kernel, linux-rtc,
linux-hwmon, linux-input, Hector Martin
In-Reply-To: <qffp7kadq3xojla5k6f5pr37irgytqfsqvabr6ydvulxnkcgnn@bv5mrraxrhhe>
On Fri, Aug 29, 2025 at 11:11:22AM +0000, Dmitry Torokhov wrote:
> Hi James,
>
> On Wed, Aug 27, 2025 at 09:22:41PM +1000, James Calligeros wrote:
> > +static void macsmc_hid_event_button(struct macsmc_hid *smchid, unsigned long event)
> > +{
> > + u8 button = (event >> 8) & 0xff;
> > + u8 state = !!(event & 0xff);
> > +
> > + switch (button) {
> > + case BTN_POWER:
> > + case BTN_TOUCHID:
> > + if (smchid->wakeup_mode) {
> > + if (state)
> > + pm_wakeup_hard_event(smchid->dev);
> > + } else {
> > + input_report_key(smchid->input, KEY_POWER, state);
> > + input_sync(smchid->input);
> > + }
>
> I believe you should be using pm_wakeup_event() in all cases so that
> pressing power would interrupt suspend even if resume() handler has not
> been run yet.
pm_wakeup_event() does not wake from s2idle. pm_wakeup_dev_event()'s
`hard` parameter is explicitily documented to wake from s2idle. So using
pm_wakeup_dev_event and use `smchid->wakeup_mode && state` as hard
parameter seems the correct thing to do.
> Also I do not think suppressing KEY_POWER is needed.
> Userspace should be smart and decide whether to shutdown the system or
> not when receiving KEY_POWER depending on the overall system state.
Not all user space. Using the power button to wake from s2idle while
showing agetty's login prompt on a tty results in an immediate shutdown.
Janne
^ permalink raw reply
* Re: [PATCH v2 1/6] clk: renesas: r9a09g057: Add clock and reset entries for RTC
From: Geert Uytterhoeven @ 2025-10-21 13:35 UTC (permalink / raw)
To: Ovidiu Panait
Cc: claudiu.beznea.uj, alexandre.belloni, robh, krzk+dt, conor+dt,
magnus.damm, mturquette, sboyd, p.zabel, linux-rtc,
linux-renesas-soc, devicetree, linux-kernel, linux-clk
In-Reply-To: <20251021080705.18116-2-ovidiu.panait.rb@renesas.com>
On Tue, 21 Oct 2025 at 10:07, Ovidiu Panait
<ovidiu.panait.rb@renesas.com> wrote:
> Add module clock and reset entries for the RTC module on the Renesas RZ/V2H
> (R9A09G057) SoC.
>
> Signed-off-by: Ovidiu Panait <ovidiu.panait.rb@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-clk for v6.19.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox