Skip to contentSkip to conversation

rtc: Add a driver for Cadence RTC

PATCH Superseded Jan Kotas 3 participants 6 messages Jan 11, 2019 – Jan 17, 2019

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jan Kotas

author
#0 lore raw

v2 cover rtc: Add a driver for Cadence RTC

This patchset adds a driver support for Cadence RTC IP. It supports time, date and wakeups from sleep.

Changes since v1:
Added devm_rtc_allocate_device before requesting an IRQ Added range_min, range_max values
Return -EINVAL for read_time() if RTC is disabled Fixed some typos

Jan Kotas (2):
dt-bindings: rtc: Add bindings for Cadence RTC
rtc: Add Cadence RTC driver

 Documentation/devicetree/bindings/rtc/cdns,rtc.txt |  25 ++
 drivers/rtc/Kconfig                                |  10 +
 drivers/rtc/Makefile                               |   1 +
 drivers/rtc/rtc-cadence.c                          | 423 +++++++++++++++++++++
 4 files changed, 459 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/cdns,rtc.txt
 create mode 100644 drivers/rtc/rtc-cadence.c
Signature · 1 line
2.15.0
author
#1 lore raw

PATCH v2 1/2 dt-bindings: rtc: Add bindings for Cadence RTC

This patch adds a DT binding documentation for
Cadence RTC controller.

---
 Documentation/devicetree/bindings/rtc/cdns,rtc.txt | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/cdns,rtc.txt
Documentation/devicetree/bindings/rtc/cdns,rtc.txt new file +25 -0
new file mode 100644
index 000000000..40713bbbe
@@ -0,0 +1,25 @@
+Cadence Real Time Clock
+
+The Cadence RTC controller with date, time and alarm capabilities.
+The alarm may wake the system from low-power state.
+
+Required properties:
+- compatible: Should be "cdns,rtc-r109v3"
+- reg: Specifies base physical address and size of the register area.
+- interrupts: A single interrupt specifier.
+- clocks: Must contain two entries:
+	- pclk: APB registers clock
+	- ref_clk: reference 1Hz of 100Hz clock, depending on IP configuration
+	See ../clocks/clock-bindings.txt for details.
+
+Example:
+        rtc0: rtc@fd080000 {
+        	compatible = "cdns,rtc-r109v3";
+        	reg = <0xfd080000 0x1000>;
+
+        	clock-names = "pclk", "ref_clk";
+        	clocks = <&sysclock>, <&refclock>;
+
+        	interrupt-parent = <&gic>;
+        	interrupts = <0 6 IRQ_TYPE_LEVEL_HIGH>;
+        };
Signature · 1 line
2.15.0
maintainer
#2 lore raw

Re: [PATCH v2 1/2] dt-bindings: rtc: Add bindings for Cadence RTC

Quoted 17 lines · Jan Kotas

This patch adds a DT binding documentation for
Cadence RTC controller.

---
 Documentation/devicetree/bindings/rtc/cdns,rtc.txt | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/cdns,rtc.txt
Documentation/devicetree/bindings/rtc/cdns,rtc.txt new file +2 -0
new file mode 100644
index 000000000..40713bbbe
@@ -0,0 +1,25 @@
+Cadence Real Time Clock
+

Documentation/devicetree/bindings/rtc/cdns,rtc.txt line 12

Quoted 10 lines
Documentation/devicetree/bindings/rtc/cdns,rtc.txt new file +10 -0
+The Cadence RTC controller with date, time and alarm capabilities.
+The alarm may wake the system from low-power state.
+
+Required properties:
+- compatible: Should be "cdns,rtc-r109v3"
+- reg: Specifies base physical address and size of the register area.
+- interrupts: A single interrupt specifier.
+- clocks: Must contain two entries:
+	- pclk: APB registers clock
+	- ref_clk: reference 1Hz of 100Hz clock, depending on IP configuration

1Hz OR 100Hz?

Quoted 16 lines
Documentation/devicetree/bindings/rtc/cdns,rtc.txt new file +13 -0
+	See ../clocks/clock-bindings.txt for details.
+
+Example:
+        rtc0: rtc@fd080000 {
+        	compatible = "cdns,rtc-r109v3";
+        	reg = <0xfd080000 0x1000>;
+
+        	clock-names = "pclk", "ref_clk";
+        	clocks = <&sysclock>, <&refclock>;
+
+        	interrupt-parent = <&gic>;
+        	interrupts = <0 6 IRQ_TYPE_LEVEL_HIGH>;
+        };
Signature · 1 line
2.15.0
author
#3 lore raw

Re: [PATCH v2 1/2] dt-bindings: rtc: Add bindings for Cadence RTC

Quoted 16 lines · Rob Herring

Documentation/devicetree/bindings/rtc/cdns,rtc.txt line 12

Quoted 9 lines · Jan Kotas

This patch adds a DT binding documentation for
Cadence RTC controller.

Documentation/devicetree/bindings/rtc/cdns,rtc.txt new file +7 -0
+Required properties:
+- compatible: Should be "cdns,rtc-r109v3"
+- reg: Specifies base physical address and size of the register area.
+- interrupts: A single interrupt specifier.
+- clocks: Must contain two entries:
+	- pclk: APB registers clock
+	- ref_clk: reference 1Hz of 100Hz clock, depending on IP configuration

1Hz OR 100Hz?

Hi,

The IP has a configuration parameter at build time, which selects the reference clock frequency.

It cannot be changed later, and there’s no register which tells the software which option was selected.

In this version of the patch, both values are accepted. If it makes sense I can add a bool property, like refclock-100hz, which can be used to check the clock frequency.

Regards,
Jan

#4 lore raw

Re: [PATCH v2 1/2] dt-bindings: rtc: Add bindings for Cadence RTC

Quoted 22 lines · Jan Kotas
Quoted 16 lines · Rob Herring

Documentation/devicetree/bindings/rtc/cdns,rtc.txt line 12

Quoted 9 lines · Jan Kotas

This patch adds a DT binding documentation for
Cadence RTC controller.

Documentation/devicetree/bindings/rtc/cdns,rtc.txt new file +7 -0
+Required properties:
+- compatible: Should be "cdns,rtc-r109v3"
+- reg: Specifies base physical address and size of the register area.
+- interrupts: A single interrupt specifier.
+- clocks: Must contain two entries:
+	- pclk: APB registers clock
+	- ref_clk: reference 1Hz of 100Hz clock, depending on IP configuration

1Hz OR 100Hz?

Hi,

The IP has a configuration parameter at build time, which selects the reference clock frequency.

Quoted 7 lines

It cannot be changed later, and there’s no register which tells the software which option was selected.

In this version of the patch, both values are accepted. If it makes sense I can add a bool property, like refclock-100hz, which can be used to check the clock frequency.

I guess what rob suggested was s/of/or/

Signature · 3 lines
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
author
#5 lore raw

PATCH v2 2/2 rtc: Add Cadence RTC driver

In reply to Jan Kotas

This patch adds a driver for Cadence RTC controller.

It can be enabled with RTC_DRV_CADENCE Kconfig option. It supports waking system from sleep modes.

---
 drivers/rtc/Kconfig       |  10 ++
 drivers/rtc/Makefile      |   1 +
 drivers/rtc/rtc-cadence.c | 423 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 434 insertions(+)
 create mode 100644 drivers/rtc/rtc-cadence.c
drivers/rtc/Kconfig +10 -0
index 225b0b851..0aba341ad 100644
@@ -1508,6 +1508,16 @@ config RTC_DRV_ARMADA38X
 	  This driver can also be built as a module. If so, the module
 	  will be called armada38x-rtc.
 
+config RTC_DRV_CADENCE
+	tristate "Cadence RTC driver"
+	depends on OF && HAS_IOMEM
+	help
+	  If you say Y here you will get access to Cadence RTC IP
+	  found on certain SOCs.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called rtc-cadence.
+
 config RTC_DRV_FTRTC010
 	tristate "Faraday Technology FTRTC010 RTC"
 	depends on HAS_IOMEM
drivers/rtc/Makefile +1 -0
index df022d820..5adb41b45 100644
@@ -39,6 +39,7 @@ obj-$(CONFIG_RTC_DRV_AU1XXX)	+= rtc-au1xxx.o
 obj-$(CONFIG_RTC_DRV_BQ32K)	+= rtc-bq32k.o
 obj-$(CONFIG_RTC_DRV_BQ4802)	+= rtc-bq4802.o
 obj-$(CONFIG_RTC_DRV_BRCMSTB)	+= rtc-brcmstb-waketimer.o
+obj-$(CONFIG_RTC_DRV_CADENCE)	+= rtc-cadence.o
 obj-$(CONFIG_RTC_DRV_CMOS)	+= rtc-cmos.o
 obj-$(CONFIG_RTC_DRV_COH901331)	+= rtc-coh901331.o
 obj-$(CONFIG_RTC_DRV_CPCAP)	+= rtc-cpcap.o
drivers/rtc/rtc-cadence.c new file +423 -0

423 lines not on this page · raw message

Signature · 1 line
2.15.0