* [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe
@ 2025-10-23 9:30 Kartik Rajput
2025-10-23 9:30 ` [PATCH v3 2/3] rtc: tegra: Add ACPI support Kartik Rajput
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
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 [flat|nested] 6+ messages in thread* [PATCH v3 2/3] rtc: tegra: Add ACPI support
2025-10-23 9:30 [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Kartik Rajput
@ 2025-10-23 9:30 ` Kartik Rajput
2025-10-23 18:04 ` Andy Shevchenko
2025-10-23 9:30 ` [PATCH v3 3/3] rtc: tegra: Drop deprecated SIMPLE_DEV_PM_OPS Kartik Rajput
2025-10-23 18:05 ` [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Andy Shevchenko
2 siblings, 1 reply; 6+ messages in thread
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
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 [flat|nested] 6+ messages in thread* Re: [PATCH v3 2/3] rtc: tegra: Add ACPI support
2025-10-23 9:30 ` [PATCH v3 2/3] rtc: tegra: Add ACPI support Kartik Rajput
@ 2025-10-23 18:04 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
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
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 [flat|nested] 6+ messages in thread
* [PATCH v3 3/3] rtc: tegra: Drop deprecated SIMPLE_DEV_PM_OPS
2025-10-23 9:30 [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Kartik Rajput
2025-10-23 9:30 ` [PATCH v3 2/3] rtc: tegra: Add ACPI support Kartik Rajput
@ 2025-10-23 9:30 ` Kartik Rajput
2025-10-23 18:04 ` Andy Shevchenko
2025-10-23 18:05 ` [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Andy Shevchenko
2 siblings, 1 reply; 6+ messages in thread
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
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 [flat|nested] 6+ messages in thread* Re: [PATCH v3 3/3] rtc: tegra: Drop deprecated SIMPLE_DEV_PM_OPS
2025-10-23 9:30 ` [PATCH v3 3/3] rtc: tegra: Drop deprecated SIMPLE_DEV_PM_OPS Kartik Rajput
@ 2025-10-23 18:04 ` Andy Shevchenko
0 siblings, 0 replies; 6+ messages in thread
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
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 [flat|nested] 6+ messages in thread
* Re: [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe
2025-10-23 9:30 [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Kartik Rajput
2025-10-23 9:30 ` [PATCH v3 2/3] rtc: tegra: Add ACPI support Kartik Rajput
2025-10-23 9:30 ` [PATCH v3 3/3] rtc: tegra: Drop deprecated SIMPLE_DEV_PM_OPS Kartik Rajput
@ 2025-10-23 18:05 ` Andy Shevchenko
2 siblings, 0 replies; 6+ messages in thread
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
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 [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-10-23 18:06 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-23 9:30 [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Kartik Rajput
2025-10-23 9:30 ` [PATCH v3 2/3] rtc: tegra: Add ACPI support Kartik Rajput
2025-10-23 18:04 ` Andy Shevchenko
2025-10-23 9:30 ` [PATCH v3 3/3] rtc: tegra: Drop deprecated SIMPLE_DEV_PM_OPS Kartik Rajput
2025-10-23 18:04 ` Andy Shevchenko
2025-10-23 18:05 ` [PATCH v3 1/3] rtc: tegra: Use devm_clk_get_enabled() in probe Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).