Skip to contentSkip to conversation

rtc: Add APM X-Gene SoC RTC driver

PATCH Superseded Loc Ho 4 participants 7 messages Mar 31, 2014 – Apr 10, 2014

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Loc Ho

author
#0 lore raw

v2 cover rtc: Add APM X-Gene SoC RTC driver

This patch adds support for the APM X-Gene SoC RTC driver.

v2
* Change function xgene_rtc_read_time to return rtc_valid_tm(tm) instead 0

v1
* Initial version

---
Loc Ho (3):
Documentation: Add documentation for the APM X-Gene SoC RTC DTS
binding
rtc: Add APM X-Gene SoC RTC driver
arm64: Add APM X-Gene SoC RTC DTS entry

 .../devicetree/bindings/rtc/xgene-rtc.txt          |   28 ++
 arch/arm64/boot/dts/apm-storm.dtsi                 |   21 ++
 drivers/rtc/Kconfig                                |    9 +
 drivers/rtc/Makefile                               |    1 +
 drivers/rtc/rtc-xgene.c                            |  278 ++++++++++++++++++++
 5 files changed, 337 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/xgene-rtc.txt
 create mode 100644 drivers/rtc/rtc-xgene.c
author
#1 lore raw

PATCH v2 1/3 Documentation: Add documentation for the APM X-Gene SoC RTC DTS binding

This patch adds documentation for the APM X-Gene SoC RTC DTS binding.

---
 .../devicetree/bindings/rtc/xgene-rtc.txt          |   28 ++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/xgene-rtc.txt
Documentation/devicetree/bindings/rtc/xgene-rtc.txt new file +28 -0
new file mode 100644
index 0000000..fd195c3
@@ -0,0 +1,28 @@
+* APM X-Gene Real Time Clock
+
+RTC controller for the APM X-Gene Real Time Clock
+
+Required properties:
+- compatible : Should be "apm,xgene-rtc"
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- interrupts: IRQ line for the RTC.
+- #clock-cells: Should be 1.
+- clocks: Reference to the clock entry.
+
+Example:
+
+rtcclk: rtcclk {
+	compatible = "fixed-clock";
+	#clock-cells = <1>;
+	clock-frequency = <100000000>;
+	clock-output-names = "rtcclk";
+};
+
+rtc: rtc at 10510000 {
+	compatible = "apm,xgene-rtc";
+	reg = <0x0 0x10510000 0x0 0x400>;
+	interrupts = <0x0 0x46 0x4>;
+	#clock-cells = <1>;
+	clocks = <&rtcclk 0>;
+};
Signature · 1 line
1.5.5
author
#2 lore raw

PATCH v2 2/3 rtc: Add APM X-Gene SoC RTC driver

This patch adds support for the APM X-Gene SoC RTC driver.

---
 drivers/rtc/Kconfig     |    9 ++
 drivers/rtc/Makefile    |    1 +
 drivers/rtc/rtc-xgene.c |  278 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 288 insertions(+), 0 deletions(-)
 create mode 100644 drivers/rtc/rtc-xgene.c
drivers/rtc/Kconfig +9 -0
index db933de..4e3a683 100644
@@ -1315,6 +1315,15 @@ config RTC_DRV_MOXART
 	   This driver can also be built as a module. If so, the module
 	   will be called rtc-moxart
 
+config RTC_DRV_XGENE
+	tristate "APM X-Gene RTC"
+	help
+	  If you say yes here you get support for the APM X-Gene SoC real time
+	  clock.
+
+	  This driver can also be built as a module, if so, the module
+	  will be called "rtc-xgene".
+
 comment "HID Sensor RTC drivers"
 
 config RTC_DRV_HID_SENSOR_TIME
drivers/rtc/Makefile +1 -0
index b427bf7..ceccd46 100644
@@ -134,5 +134,6 @@ obj-$(CONFIG_RTC_DRV_VT8500)	+= rtc-vt8500.o
 obj-$(CONFIG_RTC_DRV_WM831X)	+= rtc-wm831x.o
 obj-$(CONFIG_RTC_DRV_WM8350)	+= rtc-wm8350.o
 obj-$(CONFIG_RTC_DRV_X1205)	+= rtc-x1205.o
+obj-$(CONFIG_RTC_DRV_XGENE)	+= rtc-xgene.o
 obj-$(CONFIG_RTC_DRV_SIRFSOC)	+= rtc-sirfsoc.o
 obj-$(CONFIG_RTC_DRV_MOXART)	+= rtc-moxart.o
drivers/rtc/rtc-xgene.c new file +278 -0

278 lines not on this page · raw message

Signature · 1 line
1.5.5
author
#3 lore raw

PATCH v2 3/3 arm64: Add APM X-Gene SoC RTC DTS entry

This patch adds APM X-Gene SoC RTC DTS entry

---
 arch/arm64/boot/dts/apm-storm.dtsi |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
arch/arm64/boot/dts/apm-storm.dtsi +21 -0
index 93f4b2d..4917f3b 100644
@@ -257,6 +257,19 @@
 				enable-offset = <0x0>;
 				enable-mask = <0x39>;
 			};
+
+			rtcclk: rtcclk at 17000000 {
+				compatible = "apm,xgene-device-clock";
+				#clock-cells = <1>;
+				clocks = <&socplldiv2 0>;
+				reg = <0x0 0x17000000 0x0 0x2000>;
+				reg-names = "csr-reg";
+				csr-offset = <0xc>;
+				csr-mask = <0x2>;
+				enable-offset = <0x10>;
+				enable-mask = <0x2>;
+				clock-output-names = "rtcclk";
+			};
 		};
 
 		serial0: serial at 1c020000 {
@@ -339,5 +352,13 @@
 			phys = <&phy3 0>;
 			phy-names = "sata-phy";
 		};
+
+		rtc: rtc at 10510000 {
+			compatible = "apm,xgene-rtc";
+			reg = <0x0 0x10510000 0x0 0x400>;
+			interrupts = <0x0 0x46 0x4>;
+			#clock-cells = <1>;
+			clocks = <&rtcclk 0>;
+		};
 	};
 };
Signature · 1 line
1.5.5
#4 lore raw

PATCH v2 2/3 rtc: Add APM X-Gene SoC RTC driver

In reply to Loc Ho
Quoted 35 lines · On Mon, 31 Mar 2014 11:36:09 -0600 Loc Ho <[email protected]> wrote:

This patch adds support for the APM X-Gene SoC RTC driver.

...

drivers/rtc/rtc-xgene.c new file +31 -0
+static int xgene_rtc_probe(struct platform_device *pdev)
+{
+	struct xgene_rtc_dev *pdata;
+	struct resource *res;
+	int ret;
+	int irq;
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata)
+		return -ENOMEM;
+	platform_set_drvdata(pdev, pdata);
+	pdata->dev = &pdev->dev;
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	pdata->csr_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(pdata->csr_base))
+		return PTR_ERR(pdata->csr_base);
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(&pdev->dev, "No IRQ resource\n");
+		return irq;
+	}
+	ret = devm_request_irq(&pdev->dev, irq, xgene_rtc_interrupt, 0,
+			       dev_name(&pdev->dev), pdata);
+	if (ret) {
+		dev_err(&pdev->dev, "Could not request IRQ\n");
+		return ret;
+	}
+
+	pdata->clk = devm_clk_get(&pdev->dev, NULL);

drivers/rtc/rtc-xgene.c line 188

Quoted 10 lines
drivers/rtc/rtc-xgene.c new file +10 -0
+	if (IS_ERR(pdata->clk)) {
+		dev_err(&pdev->dev, "Couldn't get the clock for RTC\n");
+		return -ENODEV;
+	}
+	clk_prepare_enable(pdata->clk);
+
+	/* Turn on the clock and the crystal */
+	writel(RTC_CCR_EN, pdata->csr_base + RTC_CCR);
+
+	device_init_wakeup(&pdev->dev, 1);

Forgot to check the returns values from clk_prepare_enable() and device_init_wakeup()?

drivers/rtc/rtc-xgene.c line 201

Quoted 12 lines
drivers/rtc/rtc-xgene.c new file +12 -0
+	pdata->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
+					 &xgene_rtc_ops, THIS_MODULE);
+	if (IS_ERR(pdata->rtc)) {
+		clk_disable_unprepare(pdata->clk);
+		return PTR_ERR(pdata->rtc);
+	}
+
+	/* HW does not support update faster than 1 seconds */
+	pdata->rtc->uie_unsupported = 1;
+
+	return 0;
+}

Otherwise it looks OK to me - I queued all three patches, thanks.

#5 lore raw

PATCH v2 1/3 Documentation: Add documentation for the APM X-Gene SoC RTC DTS binding

In reply to Loc Ho
Quoted 15 lines · Loc Ho

This patch adds documentation for the APM X-Gene SoC RTC DTS binding.

---
 .../devicetree/bindings/rtc/xgene-rtc.txt          |   28 ++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/xgene-rtc.txt
Documentation/devicetree/bindings/rtc/xgene-rtc.txt new file +0 -0
new file mode 100644
index 0000000..fd195c3

Documentation/devicetree/bindings/rtc/xgene-rtc.txt line 10

Quoted 10 lines
Documentation/devicetree/bindings/rtc/xgene-rtc.txt new file +10 -0
@@ -0,0 +1,28 @@
+* APM X-Gene Real Time Clock
+
+RTC controller for the APM X-Gene Real Time Clock
+
+Required properties:
+- compatible : Should be "apm,xgene-rtc"
+- reg: physical base address of the controller and length of memory mapped
+  region.
+- interrupts: IRQ line for the RTC.
+- #clock-cells: Should be 1.

This does not belong here.

Quoted 26 lines
Documentation/devicetree/bindings/rtc/xgene-rtc.txt new file +18 -1
+- clocks: Reference to the clock entry.
+
+Example:
+
+rtcclk: rtcclk {
+       compatible = "fixed-clock";
+       #clock-cells = <1>;
+       clock-frequency = <100000000>;
+       clock-output-names = "rtcclk";
+};
+
+rtc: rtc at 10510000 {
+       compatible = "apm,xgene-rtc";
+       reg = <0x0 0x10510000 0x0 0x400>;
+       interrupts = <0x0 0x46 0x4>;
+       #clock-cells = <1>;
+       clocks = <&rtcclk 0>;
+};
--

1.5.5

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#6 lore raw

v2 cover rtc: Add APM X-Gene SoC RTC driver

In reply to Loc Ho
Quoted 31 lines · Loc Ho

This patch adds support for the APM X-Gene SoC RTC driver.

v2
* Change function xgene_rtc_read_time to return rtc_valid_tm(tm) instead 0

v1
* Initial version

---
Loc Ho (3):
Documentation: Add documentation for the APM X-Gene SoC RTC DTS
binding
rtc: Add APM X-Gene SoC RTC driver
arm64: Add APM X-Gene SoC RTC DTS entry

 .../devicetree/bindings/rtc/xgene-rtc.txt          |   28 ++
 arch/arm64/boot/dts/apm-storm.dtsi                 |   21 ++
 drivers/rtc/Kconfig                                |    9 +
 drivers/rtc/Makefile                               |    1 +
 drivers/rtc/rtc-xgene.c                            |  278 ++++++++++++++++++++
 5 files changed, 337 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/rtc/xgene-rtc.txt
 create mode 100644 drivers/rtc/rtc-xgene.c

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel