rtc: ls2x: Add support for the Loongson-2K/LS7A RTC
Subsystems (5)
cover rtc: ls2x: Add support for the Loongson-2K/LS7A RTC
Hi all:
The initial DT-base ls2x rtc driver was written by Wang Xuerui, he has released five versions of patchset before, and all related mail records are shown below if you are interested:
https://lore.kernel.org/all/?q=ls2x-rtc
In this series of patches, based on the code above, I have added the following support:
1. Add ACPI-related support, as Loongson-3 + LS7A is now ACPI-base by default on LoonArch;
2. Add rtc alarm/walarm related functions.
Unfortunately, I have only tested the Loongson-3A4000+LS7A1000/LS7A2000 under LoongArch architecture.
NOTE:
The related functions of rtc alarm/walarm depend on ACPI registers, so rtc alarm may not be available on the DT-base environment. Such as Loongson-2k/3 under MIPS.
Thanks.
Binbin Zhou (2):
rtc: ls2x: Add support for the Loongson-2K/LS7A RTC
LoongArch: Enable LS2X RTC in loongson3_defconfig
WANG Xuerui (5):
dt-bindings: rtc: Add bindings for LS2X RTC
MIPS: Loongson64: DTS: Add RTC support to LS7A
MIPS: Loongson: Enable LS2X RTC in loongson3_defconfig
MIPS: Loongson64: DTS: Add RTC support to Loongson-2K
MIPS: Loongson: Enable LS2X RTC in loongson2k_defconfig
.../devicetree/bindings/rtc/trivial-rtc.yaml | 2 + arch/loongarch/configs/loongson3_defconfig | 1 + .../boot/dts/loongson/loongson64-2k1000.dtsi | 5 + arch/mips/boot/dts/loongson/ls7a-pch.dtsi | 5 + arch/mips/configs/loongson2k_defconfig | 1 + arch/mips/configs/loongson3_defconfig | 1 + drivers/rtc/Kconfig | 11 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-ls2x.c | 366 ++++++++++++++++++ 9 files changed, 393 insertions(+) create mode 100644 drivers/rtc/rtc-ls2x.c
Signature · 1 line
2.31.1
PATCH 1/7 rtc: ls2x: Add support for the Loongson-2K/LS7A RTC
This RTC module is integrated into the Loongson-2K SoC and the LS7A bridge chip. This version is almost entirely rewritten to make use of current kernel API, and it supports both ACPI and DT.
--- drivers/rtc/Kconfig | 11 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-ls2x.c | 366 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 378 insertions(+) create mode 100644 drivers/rtc/rtc-ls2x.c
drivers/rtc/Kconfig +11 -0
@@ -1338,6 +1338,17 @@ config RTC_DRV_NTXEC embedded controller found in certain e-book readers designed by the original design manufacturer Netronix. +config RTC_DRV_LS2X + tristate "Loongson LS2X RTC" + depends on (ACPI || OF) && MACH_LOONGSON64 || COMPILE_TEST + select REGMAP_MMIO + help + If you say yes here you get support for the RTC on the Loongson-2K + SoC and LS7A bridge, which first appeared on the Loongson-2H. + + This driver can also be built as a module. If so, the module + will be called rtc-ls2x. + comment "on-CPU RTC drivers" config RTC_DRV_ASM9260
drivers/rtc/Makefile +1 -0
@@ -83,6 +83,7 @@ obj-$(CONFIG_RTC_DRV_LOONGSON1) += rtc-ls1x.o obj-$(CONFIG_RTC_DRV_LP8788) += rtc-lp8788.o obj-$(CONFIG_RTC_DRV_LPC24XX) += rtc-lpc24xx.o obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o +obj-$(CONFIG_RTC_DRV_LS2X) += rtc-ls2x.o obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o obj-$(CONFIG_RTC_DRV_M41T93) += rtc-m41t93.o obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o
drivers/rtc/rtc-ls2x.c new file +366 -0
366 lines not on this page · raw message
Signature · 1 line
2.31.1
PATCH 2/7 LoongArch: Enable LS2X RTC in loongson3_defconfig
In reply to Binbin ZhouThis is now supported, enable for Loongson-3 systems. Other systems are unaffected.
--- arch/loongarch/configs/loongson3_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/loongarch/configs/loongson3_defconfig +1 -0
@@ -660,6 +660,7 @@ CONFIG_USB_GADGET=y CONFIG_INFINIBAND=m CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_EFI=y +CONFIG_RTC_DRV_LS2X=y CONFIG_DMADEVICES=y CONFIG_UIO=m CONFIG_UIO_PDRV_GENIRQ=m
Signature · 1 line
2.31.1
Re: [PATCH 2/7] LoongArch: Enable LS2X RTC in loongson3_defconfig
Quoted 17 lines · Binbin Zhou
This is now supported, enable for Loongson-3 systems. Other systems are unaffected.
Signed-off-by Binbin Zhou <[email protected]>Cc Huacai Chen <[email protected]>Cc WANG Xuerui <[email protected]>---
arch/loongarch/configs/loongson3_defconfig | 1 +1 file changed, 1 insertion(+)arch/loongarch/configs/loongson3_defconfig +0
-0@@ -660,6 +660,7 @@ CONFIG_USB_GADGET=y
Quoted 4 lines
CONFIG_INFINIBAND=m
CONFIG_RTC_CLASS=y
CONFIG_RTC_DRV_EFI=y
+CONFIG_RTC_DRV_LS2X=y
We already have RTC_DRV_EFI=y, IIUC this means we leave LS7A RTC for the firmware to drive and operate it through EFI service. So is this really needed for LoongArch systems? And if we enable both RTC_DRV_EFI and RTC_DRV_LS2X, will some bad thing (a conflict) happen?
Signature · 2 lines
Xi Ruoyao <[email protected]> School of Aerospace Science and Technology, Xidian University
Huacai Chen
maintainerRe: [PATCH 2/7] LoongArch: Enable LS2X RTC in loongson3_defconfig
Hi, Ruoyao,
Quoted 13 lines · Xi Ruoyao
Quoted 11 lines · Binbin Zhou
This is now supported, enable for Loongson-3 systems. Other systems are unaffected.
Signed-off-by Binbin Zhou <[email protected]>Cc Huacai Chen <[email protected]>Cc WANG Xuerui <[email protected]>--- arch/loongarch/configs/loongson3_defconfig | 1 + 1 file changed, 1 insertion(+)
Quoted 15 lines
arch/loongarch/configs/loongson3_defconfig CONFIG_USB_GADGET=y · line 663
Quoted 10 lines
arch/loongarch/configs/loongson3_defconfig +1
-0@@ -660,6 +660,7 @@ CONFIG_USB_GADGET=y CONFIG_INFINIBAND=m CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_EFI=y +CONFIG_RTC_DRV_LS2X=yWe already have RTC_DRV_EFI=y, IIUC this means we leave LS7A RTC for the firmware to drive and operate it through EFI service. So is this really needed for LoongArch systems? And if we enable both
RTC_DRV_EFIandRTC_DRV_LS2X, will some bad thing (a conflict) happen?
Don't worry, please. EFI RTC depends on EFI runtime, so we need an available RTC if EFI runtime is disabled (by command line or any other reasons). On the other hand, multi RTCs can perfectly co-exist, they will be rtc0 and rtc1 under sysfs and rtc0 is the default one.
Huacai
Quoted 5 lines
--
Xi Ruoyao <[email protected]>
School of Aerospace Science and Technology, Xidian University
PATCH 3/7 dt-bindings: rtc: Add bindings for LS2X RTC
In reply to Binbin ZhouFrom: WANG Xuerui <[email protected]>
Document the binding for the LS2X RTC block found on the Loongson-2K SoC and the LS7A bridge, originally appearing on the Loongson-2H.
--- Documentation/devicetree/bindings/rtc/trivial-rtc.yaml | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/rtc/trivial-rtc.yaml +2 -0
@@ -47,6 +47,8 @@ properties: - isil,isl1218 # Intersil ISL12022 Real-time Clock - isil,isl12022 + # Loongson LS2X RTC + - loongson,ls2x-rtc # Real Time Clock Module with I2C-Bus - microcrystal,rv3028 # Real Time Clock Module with I2C-Bus
Signature · 1 line
2.31.1
PATCH 4/7 MIPS: Loongson64: DTS: Add RTC support to LS7A
In reply to Binbin ZhouFrom: WANG Xuerui <[email protected]>
The LS7A RTC module is now supported, enable it.
--- arch/mips/boot/dts/loongson/ls7a-pch.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/mips/boot/dts/loongson/ls7a-pch.dtsi +5 -0
@@ -19,6 +19,11 @@ pic: interrupt-controller@10000000 { #interrupt-cells = <2>; }; + rtc0: rtc@100d0100 { + compatible = "loongson,ls2x-rtc"; + reg = <0 0x100d0100 0 0x78>; + }; + ls7a_uart0: serial@10080000 { compatible = "ns16550a"; reg = <0 0x10080000 0 0x100>;
Signature · 1 line
2.31.1
PATCH 5/7 MIPS: Loongson: Enable LS2X RTC in loongson3_defconfig
In reply to Binbin ZhouFrom: WANG Xuerui <[email protected]>
This is now supported, enable for Loongson-3 systems. Other systems are unaffected.
--- arch/mips/configs/loongson3_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/mips/configs/loongson3_defconfig +1 -0
@@ -321,6 +321,7 @@ CONFIG_USB_SERIAL_OPTION=m CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_CMOS=y CONFIG_RTC_DRV_GOLDFISH=y +CONFIG_RTC_DRV_LS2X=y CONFIG_DMADEVICES=y CONFIG_VIRTIO_PCI=y CONFIG_VIRTIO_BALLOON=m
Signature · 1 line
2.31.1
PATCH 6/7 MIPS: Loongson64: DTS: Add RTC support to Loongson-2K
In reply to Binbin ZhouFrom: WANG Xuerui <[email protected]>
The Loongson-2K RTC module is now supported, enable it.
The MMIO address is unclear from the Loongson 2K1000 user manual, I took it from Loongson's out-of-tree fork of Linux 4.19.
--- arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi | 5 +++++ 1 file changed, 5 insertions(+)
arch/mips/boot/dts/loongson/loongson64-2k1000.dtsi +5 -0
@@ -57,6 +57,11 @@ pm: reset-controller@1fe07000 { reg = <0 0x1fe07000 0 0x422>; }; + rtc0: rtc@1fe07800 { + compatible = "loongson,ls2x-rtc"; + reg = <0 0x1fe07800 0 0x78>; + }; + liointc0: interrupt-controller@1fe11400 { compatible = "loongson,liointc-2.0"; reg = <0 0x1fe11400 0 0x40>,
Signature · 1 line
2.31.1
PATCH 7/7 MIPS: Loongson: Enable LS2X RTC in loongson2k_defconfig
In reply to Binbin ZhouFrom: WANG Xuerui <[email protected]>
This is now supported, enable for Loongson-2K systems. Other systems are unaffected.
--- arch/mips/configs/loongson2k_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/mips/configs/loongson2k_defconfig +1 -0
@@ -280,6 +280,7 @@ CONFIG_USB_SERIAL=m CONFIG_USB_SERIAL_OPTION=m CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_CMOS=y +CONFIG_RTC_DRV_LS2X=y CONFIG_DMADEVICES=y # CONFIG_CPU_HWMON is not set CONFIG_PM_DEVFREQ=y
Signature · 1 line
2.31.1
Huacai Chen
maintainerHi, Binbin,
Quoted 12 lines · Binbin Zhou
Hi all:
The initial DT-base ls2x rtc driver was written by Wang Xuerui, he has released five versions of patchset before, and all related mail records are shown below if you are interested:
https://lore.kernel.org/all/?q=ls2x-rtc
In this series of patches, based on the code above, I have added the following support:
Quoted 6 lines
1. Add ACPI-related support, as Loongson-3 + LS7A is now ACPI-base by default on LoonArch;
2. Add rtc alarm/walarm related functions.Unfortunately, I have only tested the Loongson-3A4000+LS7A1000/LS7A2000 under LoongArch architecture.
I think Loongson-3A4000 should be Loongson-3A5000 here. And I think Qing Zhang can help us to test on Loongson-2K platform.
Huacai
Quoted 35 lines
NOTE:
The related functions of rtc alarm/walarm depend on ACPI registers, so rtc alarm may not be available on the DT-base environment. Such as Loongson-2k/3 under MIPS.Thanks.
Binbin Zhou (2):
rtc: ls2x: Add support for the Loongson-2K/LS7A RTC
LoongArch: Enable LS2X RTC inloongson3_defconfigWANG Xuerui (5):
dt-bindings: rtc: Add bindings for LS2X RTC
MIPS: Loongson64: DTS: Add RTC support to LS7A
MIPS: Loongson: Enable LS2X RTC inloongson3_defconfig
MIPS: Loongson64: DTS: Add RTC support to Loongson-2K
MIPS: Loongson: Enable LS2X RTC inloongson2k_defconfig.../devicetree/bindings/rtc/trivial-rtc.yaml | 2 + arch/loongarch/configs/loongson3_defconfig | 1 + .../boot/dts/loongson/loongson64-2k1000.dtsi | 5 + arch/mips/boot/dts/loongson/ls7a-pch.dtsi | 5 + arch/mips/configs/loongson2k_defconfig | 1 + arch/mips/configs/loongson3_defconfig | 1 + drivers/rtc/Kconfig | 11 + drivers/rtc/Makefile | 1 + drivers/rtc/rtc-ls2x.c | 366 ++++++++++++++++++ 9 files changed, 393 insertions(+) create mode 100644 drivers/rtc/rtc-ls2x.c--
2.31.1