rtc: Add APM X-Gene SoC RTC driver
Subsystems (2)
v3 cover rtc: Add APM X-Gene SoC RTC driver
This patch adds support for the APM X-Gene SoC RTC driver.
v3
* Remove #clock-cell from binding documentation
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 | 27 ++ 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, 336 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/rtc/xgene-rtc.txt create mode 100644 drivers/rtc/rtc-xgene.c
PATCH v3 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 | 27 ++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) create mode 100644 Documentation/devicetree/bindings/rtc/xgene-rtc.txt
Documentation/devicetree/bindings/rtc/xgene-rtc.txt new file +27 -0
@@ -0,0 +1,27 @@ +* 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. +- 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
PATCH v3 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
@@ -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
@@ -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
PATCH v3 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
@@ -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
PATCH v3 2/3 rtc: Add APM X-Gene SoC RTC driver
In reply to Loc HoQuoted 4 lines · Loc Ho
drivers/rtc/rtc-xgene.c new file +4
-0+static int xgene_rtc_suspend (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct xgene_rtc_dev *pdata =platform_get_drvdata (pdev);
drivers/rtc/rtc-xgene.c line 227
Quoted 10 lines
drivers/rtc/rtc-xgene.c new file +10
-0+int irq; + + irq =platform_get_irq (pdev,0 ); +if (device_may_wakeup (&pdev->dev)) { +if (!enable_irq_wake (irq)) + pdata->irq_wake =1 ; + }else { +xgene_rtc_alarm_irq_enable (dev,0 ); +clk_disable (pdata->clk); + }
Why does the driver only disable the clock over suspend rather than also unpreparing it?
drivers/rtc/rtc-xgene.c line 245
Quoted 7 lines
drivers/rtc/rtc-xgene.c new file +7
-0+if (device_may_wakeup (&pdev->dev)) { +if (pdata->irq_wake) { +disable_irq_wake (irq); + pdata->irq_wake =0 ; + } + }else { +clk_enable (pdata->clk);
It's also not checking for errors here.
Review
Quoted 2 lines
(quoted diff) +2
-0+ xgene_rtc_alarm_irq_enable(dev, 1); + }
Won't this unconditionally enable the interrupt regardless of what the
setting was prior to suspend?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140403/031f94a7/attachment.sig>
PATCH v3 2/3 rtc: Add APM X-Gene SoC RTC driver
Hi,
Quoted 9 lines
Quoted 9 lines
drivers/rtc/rtc-xgene.c new file +9
-0+static int xgene_rtc_suspend (struct device *dev) +{ +struct platform_device *pdev =to_platform_device (dev); +struct xgene_rtc_dev *pdata =platform_get_drvdata (pdev); +int irq; + + irq =platform_get_irq (pdev,0 ); +if (device_may_wakeup (&pdev->dev)) { +if (!enable_irq_wake (irq))
Quoted 8 lines
drivers/rtc/rtc-xgene.c line 227
Quoted 5 lines
drivers/rtc/rtc-xgene.c new file +5
-0+ pdata->irq_wake =1 ; + }else { +xgene_rtc_alarm_irq_enable (dev,0 ); +clk_disable (pdata->clk); + }Why does the driver only disable the clock over suspend rather than also unpreparing it?
This was modeled after rtc-spear.c. Is this or rtc-spear in-correct?
Quoted 10 lines
drivers/rtc/rtc-xgene.c line 245
Quoted 8 lines
drivers/rtc/rtc-xgene.c new file +7
-0+if (device_may_wakeup (&pdev->dev)) { +if (pdata->irq_wake) { +disable_irq_wake (irq); + pdata->irq_wake =0 ; + } + }else { +clk_enable (pdata->clk);It's also not checking for errors here.
This was also modeled after rtc-spear. I guess I can check and print an warning but don't believe it matter.
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ xgene_rtc_alarm_irq_enable(dev, 1); + }Won't this unconditionally enable the interrupt regardless of what the setting was prior to suspend?
This was also modeled after rtc-spear.c. Is this or rtc-spear in-correct?
-Loc
PATCH v3 2/3 rtc: Add APM X-Gene SoC RTC driver
Quoted 11 lines · Loc Ho
Quoted 9 lines
drivers/rtc/rtc-xgene.c line 227
Quoted 6 lines
drivers/rtc/rtc-xgene.c new file +5
-0+static int xgene_rtc_suspend(struct device *dev) + }else { +xgene_rtc_alarm_irq_enable (dev,0 ); +clk_disable (pdata->clk); + }Why does the driver only disable the clock over suspend rather than also unpreparing it?
This was modeled after
rtc-spear.c. Is this or rtc-spear in-correct?
They're both broken, looks like a bad conversion to prepare clocks.
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
drivers/rtc/rtc-xgene.c new file +7
-0+if (device_may_wakeup (&pdev->dev)) { +if (pdata->irq_wake) { +disable_irq_wake (irq); + pdata->irq_wake =0 ; + } + }else { +clk_enable (pdata->clk);
Quoted 4 lines
Quoted 1 line
It's also not checking for errors here.
This was also modeled after rtc-spear. I guess I can check and print an warning but don't believe it matter.
You should return an error if the operation failed.
Quoted 7 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ xgene_rtc_alarm_irq_enable(dev, 1); + }Won't this unconditionally enable the interrupt regardless of what the setting was prior to suspend?
This was also modeled after
rtc-spear.c. Is this or rtc-spear in-correct?
I would expct they're both broken here.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140409/5f65346d/attachment-0001.sig>