Thread (20 messages) 20 messages, 6 authors, 2024-11-04

Re: [PATCH v2 2/4] rtc: s32g: add NXP S32G2/S32G3 SoC support

From: Nobuhiro Iwamatsu <hidden>
Date: 2024-10-17 08:34:35
Also in: linux-devicetree, linux-rtc, lkml

Hello,

2024年10月15日(火) 19:52 Ciprian Costea [off-list ref]:
quoted hunk ↗ jump to hunk
From: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>

Add a RTC driver for NXP S32G2/S32G3 SoCs.

The RTC module is used to enable Suspend to RAM (STR) support
on NXP S32G2/S32G3 SoC based boards.
RTC tracks clock time during system suspend.

RTC from S32G2/S32G3 is not battery-powered and it is not
kept alive during system reset.

Co-developed-by: Bogdan Hamciuc <redacted>
Signed-off-by: Bogdan Hamciuc <redacted>
Co-developed-by: Ghennadi Procopciuc <redacted>
Signed-off-by: Ghennadi Procopciuc <redacted>
Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
---
 drivers/rtc/Kconfig    |  11 +
 drivers/rtc/Makefile   |   1 +
 drivers/rtc/rtc-s32g.c | 778 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 790 insertions(+)
 create mode 100644 drivers/rtc/rtc-s32g.c
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig
index e87c3d74565c..18fc3577f6cd 100644
--- a/drivers/rtc/Kconfig
+++ b/drivers/rtc/Kconfig
@@ -2054,4 +2054,15 @@ config RTC_DRV_SSD202D
          This driver can also be built as a module, if so, the module
          will be called "rtc-ssd20xd".

+config RTC_DRV_S32G
+       tristate "RTC driver for S32G2/S32G3 SoCs"
+       depends on ARCH_S32 || COMPILE_TEST
+       depends on COMMON_CLK
+       help
+         Say yes to enable RTC driver for platforms based on the
+         S32G2/S32G3 SoC family.
+
+         This RTC module can be used as a wakeup source.
+         Please note that it is not battery-powered.
+
 endif # RTC_CLASS
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
index 8ee79cb18322..a63d010a753c 100644
--- a/drivers/rtc/Makefile
+++ b/drivers/rtc/Makefile
@@ -158,6 +158,7 @@ obj-$(CONFIG_RTC_DRV_RX8025)        += rtc-rx8025.o
 obj-$(CONFIG_RTC_DRV_RX8111)   += rtc-rx8111.o
 obj-$(CONFIG_RTC_DRV_RX8581)   += rtc-rx8581.o
 obj-$(CONFIG_RTC_DRV_RZN1)     += rtc-rzn1.o
+obj-$(CONFIG_RTC_DRV_S32G)     += rtc-s32g.o
 obj-$(CONFIG_RTC_DRV_S35390A)  += rtc-s35390a.o
 obj-$(CONFIG_RTC_DRV_S3C)      += rtc-s3c.o
 obj-$(CONFIG_RTC_DRV_S5M)      += rtc-s5m.o
diff --git a/drivers/rtc/rtc-s32g.c b/drivers/rtc/rtc-s32g.c
new file mode 100644
index 000000000000..d6502d8bf616
--- /dev/null
+++ b/drivers/rtc/rtc-s32g.c
[...]
+enum {
+       DIV1 = 1,
+       DIV32 = 32,
+       DIV512 = 512,
+       DIV512_32 = 16384
+};
+
+struct rtc_time_base {
+       s64 sec;
+       u64 cycles;
+       u64 rollovers;
+       struct rtc_time tm;
+};
+
+struct rtc_priv {
+       struct rtc_device *rdev;
+       struct device *dev;
You don't have to have 'struct device' here. You can refer to 'struct
device' from
member variable dev.parent of 'struct rtc_device'.

Best regards,
  Nobuhiro

-- 
Nobuhiro Iwamatsu
   iwamatsu at {nigauri.org / debian.org / kernel.org}
   GPG ID: 32247FBB40AD1FA6
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help