[PATCH v3 2/3] rtc: s3c: support for exynosautov9 on-chip RTC

Devang Tailor posted 3 patches 4 days, 10 hours ago
[PATCH v3 2/3] rtc: s3c: support for exynosautov9 on-chip RTC
Posted by Devang Tailor 4 days, 10 hours ago
The on-chip RTC of this SoC is almost similar to the previous version of
SoCs except for S3C2410_TICNT tick time counter, which is used in this
driver but not applicable for exynosautov9. So re-use the existing driver
skipping disablement of S3C2410_TICNT in s3c24xx_rtc_disable() callback
via a new boolean member of s3c_rtc_data.

This has been tested with 'hwclock' & 'date' utilities

Suggested-by: Henrik Grimler <henrik@grimler.se>
Signed-off-by: Devang Tailor <dev.tailor@samsung.com>
---
 drivers/rtc/rtc-s3c.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
index 79b2a16f15ad..8fc5b4582b6d 100644
--- a/drivers/rtc/rtc-s3c.c
+++ b/drivers/rtc/rtc-s3c.c
@@ -48,6 +48,7 @@ struct s3c_rtc {
 
 struct s3c_rtc_data {
 	bool needs_src_clk;
+	bool use_s3c2410_ticnt;
 
 	void (*irq_handler) (struct s3c_rtc *info, int mask);
 	void (*enable) (struct s3c_rtc *info);
@@ -369,9 +370,11 @@ static void s3c24xx_rtc_disable(struct s3c_rtc *info)
 	con &= ~S3C2410_RTCCON_RTCEN;
 	writew(con, info->base + S3C2410_RTCCON);
 
-	con = readb(info->base + S3C2410_TICNT);
-	con &= ~S3C2410_TICNT_ENABLE;
-	writeb(con, info->base + S3C2410_TICNT);
+	if (info->data->use_s3c2410_ticnt) {
+		con = readb(info->base + S3C2410_TICNT);
+		con &= ~S3C2410_TICNT_ENABLE;
+		writeb(con, info->base + S3C2410_TICNT);
+	}
 }
 
 static void s3c6410_rtc_disable(struct s3c_rtc *info)
@@ -550,18 +553,21 @@ static void s3c6410_rtc_irq(struct s3c_rtc *info, int mask)
 }
 
 static const struct s3c_rtc_data s3c2410_rtc_data = {
+	.use_s3c2410_ticnt	= true,
 	.irq_handler		= s3c24xx_rtc_irq,
 	.enable			= s3c24xx_rtc_enable,
 	.disable		= s3c24xx_rtc_disable,
 };
 
 static const struct s3c_rtc_data s3c2416_rtc_data = {
+	.use_s3c2410_ticnt	= true,
 	.irq_handler		= s3c24xx_rtc_irq,
 	.enable			= s3c24xx_rtc_enable,
 	.disable		= s3c24xx_rtc_disable,
 };
 
 static const struct s3c_rtc_data s3c2443_rtc_data = {
+	.use_s3c2410_ticnt	= true,
 	.irq_handler		= s3c24xx_rtc_irq,
 	.enable			= s3c24xx_rtc_enable,
 	.disable		= s3c24xx_rtc_disable,
@@ -574,6 +580,12 @@ static const struct s3c_rtc_data s3c6410_rtc_data = {
 	.disable		= s3c6410_rtc_disable,
 };
 
+static const struct s3c_rtc_data exynosautov9_rtc_data = {
+	.irq_handler		= s3c6410_rtc_irq,
+	.enable			= s3c24xx_rtc_enable,
+	.disable		= s3c24xx_rtc_disable,
+};
+
 static const __maybe_unused struct of_device_id s3c_rtc_dt_match[] = {
 	{
 		.compatible = "samsung,s3c2410-rtc",
@@ -590,6 +602,9 @@ static const __maybe_unused struct of_device_id s3c_rtc_dt_match[] = {
 	}, {
 		.compatible = "samsung,exynos3250-rtc",
 		.data = &s3c6410_rtc_data,
+	}, {
+		.compatible = "samsung,exynosautov9-rtc",
+		.data = &exynosautov9_rtc_data,
 	},
 	{ /* sentinel */ },
 };
-- 
2.34.1
Re: [PATCH v3 2/3] rtc: s3c: support for exynosautov9 on-chip RTC
Posted by Henrik Grimler 4 days, 7 hours ago
Hi Devang,

On Fri, Sep 05, 2025 at 04:35:53PM +0530, Devang Tailor wrote:
> The on-chip RTC of this SoC is almost similar to the previous version of
> SoCs except for S3C2410_TICNT tick time counter, which is used in this
> driver but not applicable for exynosautov9. So re-use the existing driver
> skipping disablement of S3C2410_TICNT in s3c24xx_rtc_disable() callback
> via a new boolean member of s3c_rtc_data.
> 
> This has been tested with 'hwclock' & 'date' utilities
> 
> Suggested-by: Henrik Grimler <henrik@grimler.se>
> Signed-off-by: Devang Tailor <dev.tailor@samsung.com>

Reviewed-by: Henrik Grimler <henrik@grimler.se>

Thank you, looks good!

Best regards,
Henrik Grimler

> ---
>  drivers/rtc/rtc-s3c.c | 21 ++++++++++++++++++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c
> index 79b2a16f15ad..8fc5b4582b6d 100644
> --- a/drivers/rtc/rtc-s3c.c
> +++ b/drivers/rtc/rtc-s3c.c
> @@ -48,6 +48,7 @@ struct s3c_rtc {
>  
>  struct s3c_rtc_data {
>  	bool needs_src_clk;
> +	bool use_s3c2410_ticnt;
>  
>  	void (*irq_handler) (struct s3c_rtc *info, int mask);
>  	void (*enable) (struct s3c_rtc *info);
> @@ -369,9 +370,11 @@ static void s3c24xx_rtc_disable(struct s3c_rtc *info)
>  	con &= ~S3C2410_RTCCON_RTCEN;
>  	writew(con, info->base + S3C2410_RTCCON);
>  
> -	con = readb(info->base + S3C2410_TICNT);
> -	con &= ~S3C2410_TICNT_ENABLE;
> -	writeb(con, info->base + S3C2410_TICNT);
> +	if (info->data->use_s3c2410_ticnt) {
> +		con = readb(info->base + S3C2410_TICNT);
> +		con &= ~S3C2410_TICNT_ENABLE;
> +		writeb(con, info->base + S3C2410_TICNT);
> +	}
>  }
>  
>  static void s3c6410_rtc_disable(struct s3c_rtc *info)
> @@ -550,18 +553,21 @@ static void s3c6410_rtc_irq(struct s3c_rtc *info, int mask)
>  }
>  
>  static const struct s3c_rtc_data s3c2410_rtc_data = {
> +	.use_s3c2410_ticnt	= true,
>  	.irq_handler		= s3c24xx_rtc_irq,
>  	.enable			= s3c24xx_rtc_enable,
>  	.disable		= s3c24xx_rtc_disable,
>  };
>  
>  static const struct s3c_rtc_data s3c2416_rtc_data = {
> +	.use_s3c2410_ticnt	= true,
>  	.irq_handler		= s3c24xx_rtc_irq,
>  	.enable			= s3c24xx_rtc_enable,
>  	.disable		= s3c24xx_rtc_disable,
>  };
>  
>  static const struct s3c_rtc_data s3c2443_rtc_data = {
> +	.use_s3c2410_ticnt	= true,
>  	.irq_handler		= s3c24xx_rtc_irq,
>  	.enable			= s3c24xx_rtc_enable,
>  	.disable		= s3c24xx_rtc_disable,
> @@ -574,6 +580,12 @@ static const struct s3c_rtc_data s3c6410_rtc_data = {
>  	.disable		= s3c6410_rtc_disable,
>  };
>  
> +static const struct s3c_rtc_data exynosautov9_rtc_data = {
> +	.irq_handler		= s3c6410_rtc_irq,
> +	.enable			= s3c24xx_rtc_enable,
> +	.disable		= s3c24xx_rtc_disable,
> +};
> +
>  static const __maybe_unused struct of_device_id s3c_rtc_dt_match[] = {
>  	{
>  		.compatible = "samsung,s3c2410-rtc",
> @@ -590,6 +602,9 @@ static const __maybe_unused struct of_device_id s3c_rtc_dt_match[] = {
>  	}, {
>  		.compatible = "samsung,exynos3250-rtc",
>  		.data = &s3c6410_rtc_data,
> +	}, {
> +		.compatible = "samsung,exynosautov9-rtc",
> +		.data = &exynosautov9_rtc_data,
>  	},
>  	{ /* sentinel */ },
>  };
> -- 
> 2.34.1
>