* [PATCH v4 2/3] rtc: tegra: Add ACPI support
2025-10-24 6:49 [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Kartik Rajput
@ 2025-10-24 6:49 ` Kartik Rajput
2025-10-24 10:48 ` Jon Hunter
2025-10-24 6:49 ` [PATCH v4 3/3] rtc: tegra: Replace deprecated SIMPLE_DEV_PM_OPS Kartik Rajput
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
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
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 [flat|nested] 7+ messages in thread* Re: [PATCH v4 2/3] rtc: tegra: Add ACPI support
2025-10-24 6:49 ` [PATCH v4 2/3] rtc: tegra: Add ACPI support Kartik Rajput
@ 2025-10-24 10:48 ` Jon Hunter
0 siblings, 0 replies; 7+ messages in thread
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
On 24/10/2025 07:49, 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.
>
> 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,
> },
> };
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Thanks!
Jon
--
nvpublic
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v4 3/3] rtc: tegra: Replace deprecated SIMPLE_DEV_PM_OPS
2025-10-24 6:49 [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Kartik Rajput
2025-10-24 6:49 ` [PATCH v4 2/3] rtc: tegra: Add ACPI support Kartik Rajput
@ 2025-10-24 6:49 ` Kartik Rajput
2025-10-24 10:48 ` Jon Hunter
2025-10-24 10:48 ` [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Jon Hunter
2025-12-08 22:09 ` Alexandre Belloni
3 siblings, 1 reply; 7+ messages in thread
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
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 [flat|nested] 7+ messages in thread* Re: [PATCH v4 3/3] rtc: tegra: Replace deprecated SIMPLE_DEV_PM_OPS
2025-10-24 6:49 ` [PATCH v4 3/3] rtc: tegra: Replace deprecated SIMPLE_DEV_PM_OPS Kartik Rajput
@ 2025-10-24 10:48 ` Jon Hunter
0 siblings, 0 replies; 7+ messages in thread
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
On 24/10/2025 07:49, 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.
>
> 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);
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Thanks!
Jon
--
nvpublic
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe
2025-10-24 6:49 [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Kartik Rajput
2025-10-24 6:49 ` [PATCH v4 2/3] rtc: tegra: Add ACPI support Kartik Rajput
2025-10-24 6:49 ` [PATCH v4 3/3] rtc: tegra: Replace deprecated SIMPLE_DEV_PM_OPS Kartik Rajput
@ 2025-10-24 10:48 ` Jon Hunter
2025-12-08 22:09 ` Alexandre Belloni
3 siblings, 0 replies; 7+ messages in thread
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
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 [flat|nested] 7+ messages in thread* Re: [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe
2025-10-24 6:49 [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Kartik Rajput
` (2 preceding siblings ...)
2025-10-24 10:48 ` [PATCH v4 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Jon Hunter
@ 2025-12-08 22:09 ` Alexandre Belloni
3 siblings, 0 replies; 7+ messages in thread
From: Alexandre Belloni @ 2025-12-08 22:09 UTC (permalink / raw)
To: thierry.reding, jonathanh, andriy.shevchenko, linux-rtc,
linux-tegra, linux-kernel, Kartik Rajput
On Fri, 24 Oct 2025 12:19:50 +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. Also remove tegra_rtc_remove() as the clock will
> automatically be disabled when the device is unbound from the bus.
>
>
Applied, thanks!
[1/3] rtc: tegra: Use devm_clk_get_enabled() in probe
https://git.kernel.org/abelloni/c/b665c1b620e7
[2/3] rtc: tegra: Add ACPI support
https://git.kernel.org/abelloni/c/0a293451030b
[3/3] rtc: tegra: Replace deprecated SIMPLE_DEV_PM_OPS
https://git.kernel.org/abelloni/c/bf5ef3ce42da
Best regards,
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 7+ messages in thread