Skip to contentSkip to conversation

arm64: Realtek RTD1295 RTC

PATCH Superseded Andreas Färber 2 participants 5 messages Aug 28, 2017

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover arm64: Realtek RTD1295 RTC

Hello,

This series adds the RTC for the Realtek RTD1295 SoC. Based on my RTD1295 clk series.

There being no public source code for RTD1295, the implementation is based on register offsets seen in the vendor DT, as well as older mach-rtk119x code published by QNAP.

v3 drops a redundant spinlock and refactors a helper.

The DT node depends on the clk series for clock index and header.

More experimental patches at:
https://github.com/afaerber/linux/commits/rtd1295-next

Have a lot of fun!

Cheers,
Andreas

v2 -> v3:
* Dropped spinlock (Andrew)
* Improved year_days vs. days_in_year readability

v1 -> v2:
* Updated rtc driver to no longer use open/release (Alexandre)
* Cleaned up debug output (Andrew)
* Avoided COMPILE_TEST division errors (kbuild)
* Various cleanups and extensions

Cc Alessandro Zummo <[email protected]>
Cc Alexandre Belloni <[email protected]>
Cc linux-rtc at vger.kernel.org
Cc Roc He <[email protected]>
Cc devicetree at vger.kernel.org
Cc Andrew Lunn <[email protected]>

Andreas F?rber (3):
dt-bindings: rtc: Add Realtek RTD1295
rtc: Add Realtek RTD1295
arm64: dts: realtek: Add RTD1295 RTC node

 .../devicetree/bindings/rtc/realtek,rtd119x.txt    |  16 ++
 arch/arm64/boot/dts/realtek/rtd1295.dtsi           |   6 +
 drivers/rtc/Kconfig                                |   8 +
 drivers/rtc/Makefile                               |   1 +
 drivers/rtc/rtc-rtd119x.c                          | 241 +++++++++++++++++++++
 5 files changed, 272 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/realtek,rtd119x.txt
 create mode 100644 drivers/rtc/rtc-rtd119x.c
Signature · 1 line
2.12.3
#1 lore raw

PATCH v3 1/3 dt-bindings: rtc: Add Realtek RTD1295

Add a binding for the RTC on the Realtek RTD119x/RTD129x SoC families.

---
v1 -> v2 -> v3: Unchanged

 .../devicetree/bindings/rtc/realtek,rtd119x.txt          | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/rtc/realtek,rtd119x.txt
Documentation/devicetree/bindings/rtc/realtek,rtd119x.txt new file +16 -0
new file mode 100644
index 000000000000..bbf1ccb5df31
@@ -0,0 +1,16 @@
+Realtek RTD129x Real-Time Clock
+===============================
+
+Required properties:
+- compatible :  Should be "realtek,rtd1295-rtc"
+- reg        :  Specifies the physical base address and size
+- clocks     :  Specifies the clock gate
+
+
+Example:
+
+	rtc at 9801b600 {
+		compatible = "realtek,rtd1295-clk";
+		reg = <0x9801b600 0x100>;
+		clocks = <&clkc RTD1295_CLK_EN_MISC_RTC>;
+	};
Signature · 1 line
2.12.3
#2 lore raw

PATCH v3 2/3 rtc: Add Realtek RTD1295

In reply to Andreas Färber

Based on QNAP's arch/arm/mach-rtk119x/driver/rtk_rtc_drv.c code and mach-rtk119x/driver/dc2vo/fpga/include/mis_reg.h register definitions.

The base year 2014 was observed on all of Zidoo X9S, ProBox2 Ava and Beelink Lake I.

---
v2 -> v3:
* Dropped spinlock (Andrew)
* Refactored days-in-year helper to avoid rtc_year_days()

v1 -> v2:
* Dropped open/release in favor of probe/remove (Alexandre)
* read_time: Reordered register accesses (Alexandre)
* read_time/set_time: Refactored day calculations to avoid time64_t (Alexandre)
* read_time: Retry if seconds change (Alexandre)
* probe: Added missing RTCACR initialization code
* set_time: Fixed year check (off by 1900)
* set_time: Fixed new seconds (off by factor two)
* Cleaned up debug output (Andrew)
* Added spinlocks around register accesses
* Added masks for register fields

 drivers/rtc/Kconfig       |   8 ++
 drivers/rtc/Makefile      |   1 +
 drivers/rtc/rtc-rtd119x.c | 241 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 250 insertions(+)
 create mode 100644 drivers/rtc/rtc-rtd119x.c
drivers/rtc/Kconfig +8 -0
index 22efa21b1d81..d5a46f311ecb 100644
@@ -1765,6 +1765,14 @@ config RTC_DRV_CPCAP
 	   Say y here for CPCAP rtc found on some Motorola phones
 	   and tablets such as Droid 4.
 
+config RTC_DRV_RTD119X
+	bool "Realtek RTD129x RTC"
+	depends on ARCH_REALTEK || COMPILE_TEST
+	default ARCH_REALTEK
+	help
+	  If you say yes here, you get support for the RTD1295 SoC
+	  Real Time Clock.
+
 comment "HID Sensor RTC drivers"
 
 config RTC_DRV_HID_SENSOR_TIME
drivers/rtc/Makefile +1 -0
index acd366b41c85..55a0a5ca45b0 100644
@@ -131,6 +131,7 @@ obj-$(CONFIG_RTC_DRV_RP5C01)	+= rtc-rp5c01.o
 obj-$(CONFIG_RTC_DRV_RS5C313)	+= rtc-rs5c313.o
 obj-$(CONFIG_RTC_DRV_RS5C348)	+= rtc-rs5c348.o
 obj-$(CONFIG_RTC_DRV_RS5C372)	+= rtc-rs5c372.o
+obj-$(CONFIG_RTC_DRV_RTD119X)	+= rtc-rtd119x.o
 obj-$(CONFIG_RTC_DRV_RV3029C2)	+= rtc-rv3029c2.o
 obj-$(CONFIG_RTC_DRV_RV8803)	+= rtc-rv8803.o
 obj-$(CONFIG_RTC_DRV_RX4581)	+= rtc-rx4581.o
drivers/rtc/rtc-rtd119x.c new file +241 -0

241 lines not on this page · raw message

Signature · 1 line
2.12.3
#3 lore raw

Re: [PATCH v3 2/3] rtc: Add Realtek RTD1295

Hi,

Seems fine to me, one small comment:

drivers/rtc/rtc-rtd119x.c line 228

Quoted 7 lines · Andreas F?rber
drivers/rtc/rtc-rtd119x.c new file +7 -0
+static int rtd119x_rtc_remove(struct platform_device *pdev)
+{
+	struct rtd119x_rtc *data = platform_get_drvdata(pdev);
+
+	rtd119x_rtc_set_enabled(&pdev->dev, false);
+
+	clk_disable_unprepare(data->clk);

Missing clk_put ?

Quoted 16 lines
drivers/rtc/rtc-rtd119x.c new file +13 -0
+
+	return 0;
+}
+
+static struct platform_driver rtd119x_rtc_driver = {
+	.probe = rtd119x_rtc_probe,
+	.remove = rtd119x_rtc_remove,
+	.driver = {
+		.name = "rtd1295-rtc",
+		.of_match_table	= rtd119x_rtc_dt_ids,
+	},
+};
+builtin_platform_driver(rtd119x_rtc_driver);
Signature · 1 line
2.12.3
Signature · 3 lines
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#4 lore raw

PATCH v3 3/3 arm64: dts: realtek: Add RTD1295 RTC node

In reply to Andreas Färber

Add RTC node to the Realtek RTD1295 Device Tree.

---
v2 -> v3:
* Rebased to no longer depend on reset controller series

v1 -> v2: Unchanged

Depends on the pending clock bindings.

 arch/arm64/boot/dts/realtek/rtd1295.dtsi | 6 ++++++
 1 file changed, 6 insertions(+)
arch/arm64/boot/dts/realtek/rtd1295.dtsi +6 -0
index ab72255f843f..fbbd6456079e 100644
@@ -164,6 +164,12 @@
 			status = "disabled";
 		};
 
+		rtc at 9801b600 {
+			compatible = "realtek,rtd1295-rtc";
+			reg = <0x9801b600 0x100>;
+			clocks = <&clkc RTD1295_CLK_EN_MISC_RTC>;
+		};
+
 		gic: interrupt-controller at ff011000 {
 			compatible = "arm,gic-400";
 			reg = <0xff011000 0x1000>,
Signature · 1 line
2.12.3