Skip to contentSkip to conversation

RFC: RTC v5

PATCH New Ben Dooks 3 participants 8 messages Aug 22, 2016 – Sep 8, 2016

Subsystems (3)
lore
Share & tools
lore

Ben Dooks

author
#0 lore raw

I've reworked the rtc patches, but have no way of testing them until I get back from "holiday". Is anyone able to test so that they can be submitted?

git at github.com:bendooks/amlogic-kenel.git bjdooks/v48-rc3/rtc-v5

author
#1 lore raw

PATCH 1/5 rtc: support for amlogic meson rtc

From: Ben Dooks <[email protected]>

Add support for the AMLogic meson8b/meson6 RTC block.

---
Changes v5:
- fixed spacing error
- fixed spelling errors
- added MESON_STATIC_DEFAULT to reduce over 80-col lines
- fixed use of unsigned by moving to unsigned int
- remove unused meson_rtc_prep_bus() function
- moved to using time64_t

Changes since V3:
<[email protected]>
- Added Kevin's tested by

Changes since V1:
<[email protected]>

- Fixed checkpatch and sparse errors
- Fixed minor locking bug when writing static-control register
- Updated the code ordering in the rtc-meson.c driver
- Fixed alphanumeric ordering in on-cpu rtc block
- Added Rob Hering's ack for the DT binding documentation
- Added better description to the RTC driver header.

---
 drivers/rtc/Kconfig     |  11 ++
 drivers/rtc/Makefile    |   1 +
 drivers/rtc/rtc-meson.c | 341 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 353 insertions(+)
 create mode 100644 drivers/rtc/rtc-meson.c
drivers/rtc/Kconfig +11 -0
index e215f50..40faca1 100644
@@ -1228,6 +1228,17 @@ config RTC_DRV_IMXDI
 	   This driver can also be built as a module, if so, the module
 	   will be called "rtc-imxdi".
 
+config RTC_DRV_MESON
+	tristate "AMLogic Meson Real Time Clock"
+	depends on ARCH_MESON || COMPILE_TEST
+	help
+	   Support for AMLogic Meson RTC block in many of the Meson SoC
+	   devices. The driver supports basic read/write of the time.
+
+	   This driver can also be built as a module, if so, the module
+	   will be called "rtc-meson".
+
+
 config RTC_DRV_OMAP
 	tristate "TI OMAP Real Time Clock"
 	depends on ARCH_OMAP || ARCH_DAVINCI || COMPILE_TEST
drivers/rtc/Makefile +1 -0
index 7cf7ad5..e1bf77c 100644
@@ -94,6 +94,7 @@ obj-$(CONFIG_RTC_DRV_MAX8997)	+= rtc-max8997.o
 obj-$(CONFIG_RTC_DRV_MAX8998)	+= rtc-max8998.o
 obj-$(CONFIG_RTC_DRV_MC13XXX)	+= rtc-mc13xxx.o
 obj-$(CONFIG_RTC_DRV_MCP795)	+= rtc-mcp795.o
+obj-$(CONFIG_RTC_DRV_MESON)	+= rtc-meson.o
 obj-$(CONFIG_RTC_DRV_MOXART)	+= rtc-moxart.o
 obj-$(CONFIG_RTC_DRV_MPC5121)	+= rtc-mpc5121.o
 obj-$(CONFIG_RTC_DRV_VRTC)	+= rtc-mrst.o
drivers/rtc/rtc-meson.c new file +341 -0

341 lines not on this page · raw message

Signature · 1 line
2.9.3
author
#2 lore raw

PATCH 2/5 ARM: dts: amlogic: add rtc node for meson8b

In reply to Ben Dooks

From: Ben Dooks <[email protected]>

Add the DT node for the RTC support.

---
 arch/arm/boot/dts/meson8b.dtsi | 7 +++++++
 1 file changed, 7 insertions(+)
arch/arm/boot/dts/meson8b.dtsi +7 -0
index fc4080d..15a9d8d 100644
@@ -156,6 +156,13 @@
 			status = "disabled";
 		};
 
+		rtc: rtc at c8100740 {
+			compatible = "amlogic,meson8b-rtc";
+			reg = <0xc8100740 0x14>;
+			resets = <&reset RESET_RTC>;
+			status = "disabled";
+		};
+
 		clkc: clock-controller at c1104000 {
 			#clock-cells = <1>;
 			compatible = "amlogic,meson8b-clkc";
Signature · 1 line
2.9.3
author
#3 lore raw

PATCH 3/5 meson-rtc: add device-tree binding

In reply to Ben Dooks

From: Ben Dooks <[email protected]>

Add documentation for the AMLogic Meson RTC.

---
 .../devicetree/bindings/rtc/rtc-amlogic.txt         | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/rtc-amlogic.txt
Documentation/devicetree/bindings/rtc/rtc-amlogic.txt new file +21 -0
new file mode 100644
index 0000000..efc7672
@@ -0,0 +1,21 @@
+* AMlogic Meson RTC
+
+Required properties:
+- compatible: should be one of the following describing the hardware:
+	* "amlogic,meson6-rtc"
+	* "amlogic,meson8-rtc"
+	* "amlogic,meson8b-rtc"
+
+- reg: physical register space for the controller's memory mapped registers.
+
+Optional properties:
+- resets: reset controller reference to allow reset of the controller
+- interrupts: single interrupt reference if interrupt support needed
+
+Example:
+
+	rtc: rtc at c8100740 {
+		compatible = "amlogic,meson6-rtc";
+		reg = <0xc8100740 0x14>;
+		status = "disabled";
+	};
Signature · 1 line
2.9.3
author
#4 lore raw

PATCH 4/5 ARM: meson: enable RTC for ODRoid-C1

In reply to Ben Dooks

From: Ben Dooks <[email protected]>

Now the RTC node has been added, enable it on the ODroid-C1 board.

---
 arch/arm/boot/dts/meson8b-odroidc1.dts | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm/boot/dts/meson8b-odroidc1.dts +5 -0
index e50f1a1..5c7826f 100644
@@ -76,3 +76,8 @@
 	pinctrl-0 = <&uart_ao_a_pins>;
 	pinctrl-names = "default";
 };
+
+&rtc {
+	status = "okay";
+};
+
Signature · 1 line
2.9.3
author
#5 lore raw

PATCH 5/5 rtc: warn if rtc_tm_to_time64 overflows in rtc_tm_to_time

In reply to Ben Dooks

The addition of the compatibility layer for rtc_tm_to_time() to bridge the move to rtc_tm_to_time64() does not check if the value will overflow the old call's use of unsigned long to restore the result.

This means that if the result is bigger than the arch's use of unsigned long then the result will be silently truncated to whatever the maximum value of the unsigned long. Since the call does not have an option of returning an error, at least have an WARN_ON() to show if the value is out of range.

---
 include/linux/rtc.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
include/linux/rtc.h +4 -1
index b693ada..ef7bb2c 100644
@@ -45,7 +45,10 @@ static inline void rtc_time_to_tm(unsigned long time, struct rtc_time *tm)
  */
 static inline int rtc_tm_to_time(struct rtc_time *tm, unsigned long *time)
 {
-	*time = rtc_tm_to_time64(tm);
+	time64_t tt = rtc_tm_to_time64(tm);
+
+	WARN_ON(tt > ~(0UL));
+	*time = tt;
 
 	return 0;
 }
Signature · 1 line
2.9.3
maintainer
#6 lore raw
In reply to Ben Dooks
Quoted 5 lines · Ben Dooks

I've reworked the rtc patches, but have no way of testing them until I get back from "holiday". Is anyone able to test so that they can be submitted?

git at github.com:bendooks/amlogic-kenel.git bjdooks/v48-rc3/rtc-v5

Just gave it a quick test on meson8b-odroidc1. Something's not right, but didn't debug further:

/ # ./rtctest

RTC Driver Test Example.

...Update IRQs not supported.

Current RTC date/time is 7-9-2016, 21:05:06.
RTC_ALM_READ ioctl: Invalid argument

Kevin

#7 lore raw
Quoted 10 lines · Kevin Hilman
Quoted 5 lines · Ben Dooks

I've reworked the rtc patches, but have no way of testing them until I get back from "holiday". Is anyone able to test so that they can be submitted?

git at github.com:bendooks/amlogic-kenel.git bjdooks/v48-rc3/rtc-v5

Just gave it a quick test on meson8b-odroidc1. Something's not right, but didn't debug further:

Thanks, I'll try and get some time this week to see if this can be fixed.

Signature · 2 lines
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius