On-chip RTC support for ExynosAutov9
Subsystems (3)
A message that is not in the archive (sent off-list or not yet received): CGME20250905105708epcas5p159281b73f87fae88e824b97889908649@epcas5p1.samsung.com
v3 cover On-chip RTC support for ExynosAutov9
Enable on-chip RTC support. The on-chip RTC of this SoC is similar to the previous version of Samsung SoCs except for TICNT tick time counter. So re-use the existing RTC driver with applicable call-backs for initialization and IRQ handling without accessing TICNT counter.
As suggested in review comment, instead of adding separate disable() call-back, re-used the existing s3c24xx_rtc_disable() by adding a new bool 'use_s3c2410_ticnt' in rtc_data to avoid accessing TICNT counter which is not valid for RTC of ExynosAutov9.
Setting and getting hardware clock has been tested using 'hwclock' and 'date' utilities.
Alarm interrupt has been checked with incrementing interrupt count via "cat /proc/interrupts | grep rtc" for 10sec wakeup time via "echo +10 > /sys/class/rtc/rtc0/wakealarm"
changelog
---
Changes in v3:
- 1/3 : Added Tag 'Reviewed-by'
- 2/3 : Fixed the review comment of v2 to re-use the existing disable()
instead of adding new one.
: Not adding Tag 'Reviewed-by' from V2 since the patch has been
changed
- 3/3 : Added Tag 'Reviewed-by'
link for v2 : https://lore.kernel.org/linux-rtc/[email protected]/
Changes in v2:
- Fixed the review comment of v1 for mis-aligmnent & asymmetry bit logic.
- link for v1 : https://lore.kernel.org/linux-rtc/[email protected]/
Devang Tailor (3):
dt-bindings: rtc: s3c-rtc: add compatible for exynosautov9
rtc: s3c: support for exynosautov9 on-chip RTC
arm64: dts: exynosautov9: add RTC DT node
.../devicetree/bindings/rtc/s3c-rtc.yaml | 1 + .../boot/dts/exynos/exynosautov9-sadk.dts | 4 ++++ arch/arm64/boot/dts/exynos/exynosautov9.dtsi | 10 +++++++++ drivers/rtc/rtc-s3c.c | 21 ++++++++++++++++--- 4 files changed, 33 insertions(+), 3 deletions(-)
base-commit: 4ac65880ebca1b68495bd8704263b26c050ac010
Signature · 1 line
2.34.1
PATCH v3 1/3 dt-bindings: rtc: s3c-rtc: add compatible for exynosautov9
Add "samsung,exynosautov9-rtc" dedicated compatible for on-chip RTC found in ExynosAutov9 SoC.
--- Documentation/devicetree/bindings/rtc/s3c-rtc.yaml | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/rtc/s3c-rtc.yaml +1 -0
@@ -13,6 +13,7 @@ properties: compatible: oneOf: - enum: + - samsung,exynosautov9-rtc - samsung,s3c2410-rtc - samsung,s3c2416-rtc - samsung,s3c2443-rtc
Signature · 1 line
2.34.1
PATCH v3 2/3 rtc: s3c: support for exynosautov9 on-chip RTC
In reply to Devang TailorThe 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
--- drivers/rtc/rtc-s3c.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
drivers/rtc/rtc-s3c.c +18 -3
@@ -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 */ }, };
Signature · 1 line
2.34.1
Re: [PATCH v3 2/3] rtc: s3c: support for exynosautov9 on-chip RTC
Hi Devang,
Quoted 10 lines · Devang Tailor
The on-chip RTC of this SoC is almost similar to the previous version of SoCs except for
S3C2410_TICNTtick time counter, which is used in this driver but not applicable for exynosautov9. So re-use the existing driver skipping disablement ofS3C2410_TICNTins3c24xx_rtc_disable()callback via a new boolean member ofs3c_rtc_data.This has been tested with 'hwclock' & 'date' utilities
Suggested-by Henrik Grimler <[email protected]>Signed-off-by Devang Tailor <[email protected]>
Thank you, looks good!
Best regards,
Henrik Grimler
Quoted 79 lines
--- drivers/rtc/rtc-s3c.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)drivers/rtc/rtc-s3c.c +18
-3@@ -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 */ }, };Signature · 1 line
2.34.1
PATCH v3 3/3 arm64: dts: exynosautov9: add RTC DT node
In reply to Devang TailorAdd DT node for on-chip RTC for ExynosAutov9
--- arch/arm64/boot/dts/exynos/exynosautov9-sadk.dts | 4 ++++ arch/arm64/boot/dts/exynos/exynosautov9.dtsi | 10 ++++++++++ 2 files changed, 14 insertions(+)
arch/arm64/boot/dts/exynos/exynosautov9-sadk.dts +4 -0
@@ -106,6 +106,10 @@ &pwm { status = "okay"; }; +&rtc { + status = "okay"; +}; + &serial_0 { pinctrl-0 = <&uart0_bus_dual>; status = "okay";
arch/arm64/boot/dts/exynos/exynosautov9.dtsi +10 -0
@@ -1633,6 +1633,16 @@ pwm: pwm@103f0000 { clock-names = "timers"; status = "disabled"; }; + + rtc: rtc@10540000 { + compatible = "samsung,exynosautov9-rtc"; + reg = <0x10540000 0x100>; + interrupts = <GIC_SPI 26 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 27 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&xtcxo>; + clock-names = "rtc"; + status = "disabled"; + }; }; };
Signature · 1 line
2.34.1
Alexandre Belloni
maintainerQuoted 39 lines · Devang Tailor
Enable on-chip RTC support. The on-chip RTC of this SoC is similar to the previous version of Samsung SoCs except for TICNT tick time counter. So re-use the existing RTC driver with applicable call-backs for initialization and IRQ handling without accessing TICNT counter.
As suggested in review comment, instead of adding separate
disable()call-back, re-used the existings3c24xx_rtc_disable()by adding a new bool 'use_s3c2410_ticnt' inrtc_datato avoid accessing TICNT counter which is not valid for RTC of ExynosAutov9.Setting and getting hardware clock has been tested using 'hwclock' and 'date' utilities.
Alarm interrupt has been checked with incrementing interrupt count via "cat
/proc/interrupts| grep rtc" for 10sec wakeup time via "echo +10 >/sys/class/rtc/rtc0/wakealarm"changelog
---
Changes in v3:
- 1/3 : Added Tag 'Reviewed-by'
- 2/3 : Fixed the review comment of v2 to re-use the existingdisable()
instead of adding new one.
: Not adding Tag 'Reviewed-by' from V2 since the patch has been
changed
- 3/3 : Added Tag 'Reviewed-by'
link for v2 : https://lore.kernel.org/linux-rtc/[email protected]/Changes in v2:
- Fixed the review comment of v1 for mis-aligmnent & asymmetry bit logic.
- link for v1 : https://lore.kernel.org/linux-rtc/[email protected]/Devang Tailor (3):
dt-bindings: rtc: s3c-rtc: add compatible for exynosautov9
rtc: s3c: support for exynosautov9 on-chip RTC
arm64: dts: exynosautov9: add RTC DT node
Quoted 8 lines
.../devicetree/bindings/rtc/s3c-rtc.yaml | 1 + .../boot/dts/exynos/exynosautov9-sadk.dts | 4 ++++ arch/arm64/boot/dts/exynos/exynosautov9.dtsi | 10 +++++++++ drivers/rtc/rtc-s3c.c | 21 ++++++++++++++++--- 4 files changed, 33 insertions(+), 3 deletions(-)base-commit:
4ac65880ebca1b68495bd8704263b26c050ac010
You should rebase on top of rtc-next as s3c2410 support has been removed.
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com