All of lore.kernel.org
 help / color / mirror / Atom feed
* [rtc-linux] [PATCH v4 0/2]  ARM: AM437X: Add rtc clock handling
@ 2015-08-18  8:43 Keerthy
  2015-08-18  8:43 ` [rtc-linux] [PATCH v4 1/3] ARM: dts: AM437x: Add the internal and external clock nodes for rtc Keerthy
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Keerthy @ 2015-08-18  8:43 UTC (permalink / raw)
  To: alexandre.belloni, tony
  Cc: johan, linux-omap, rtc-linux, grygorii.strashko, j-keerthy

The series is applicable for all am437x series of processors.
It adds clock handling support. Boot tested on am437x-gp-evm.

Keerthy (2):
  ARM: dts: AM437x: Add the internal and external clock nodes for rtc
  rtc: omap: Add external clock enabling support

Changes in v4:

  * Optimized pointer checks for clk pointer.

Changes in v3:

  * Split internal and external clock enabling to separate patches.
  * Using one variable to store the clk info in omap_rtc struct.

 arch/arm/boot/dts/am4372.dtsi        |  2 ++
 arch/arm/boot/dts/am437x-gp-evm.dts  | 13 +++++++++++
 arch/arm/boot/dts/am437x-idk-evm.dts |  9 ++++++++
 arch/arm/boot/dts/am437x-sk-evm.dts  |  9 ++++++++
 drivers/rtc/rtc-omap.c               | 44 ++++++++++++++++++++++++++++++++++++
 5 files changed, 77 insertions(+)

-- 
1.9.1

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [rtc-linux] [PATCH v4 1/3] ARM: dts: AM437x: Add the internal and external clock nodes for rtc
  2015-08-18  8:43 [rtc-linux] [PATCH v4 0/2] ARM: AM437X: Add rtc clock handling Keerthy
@ 2015-08-18  8:43 ` Keerthy
  2015-08-18  8:43 ` [rtc-linux] [PATCH v4 2/3] rtc: omap: Add internal clock enabling support Keerthy
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Keerthy @ 2015-08-18  8:43 UTC (permalink / raw)
  To: alexandre.belloni, tony
  Cc: johan, linux-omap, rtc-linux, grygorii.strashko, j-keerthy

rtc can either be supplied from internal 32k clock or external crystal
generated 32k clock. Internal clock is SOC specific and the external
clock is board dependent. Adding the corresponding nodes.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 arch/arm/boot/dts/am4372.dtsi        |  2 ++
 arch/arm/boot/dts/am437x-gp-evm.dts  | 13 +++++++++++++
 arch/arm/boot/dts/am437x-idk-evm.dts |  9 +++++++++
 arch/arm/boot/dts/am437x-sk-evm.dts  |  9 +++++++++
 4 files changed, 33 insertions(+)

diff --git a/arch/arm/boot/dts/am4372.dtsi b/arch/arm/boot/dts/am4372.dtsi
index d99b2ee..484f092 100644
--- a/arch/arm/boot/dts/am4372.dtsi
+++ b/arch/arm/boot/dts/am4372.dtsi
@@ -336,6 +336,8 @@
 			interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH
 				      GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
 			ti,hwmods = "rtc";
+			clocks = <&clk_32768_ck>;
+			clock-names = "int-clk";
 			status = "disabled";
 		};
 
diff --git a/arch/arm/boot/dts/am437x-gp-evm.dts b/arch/arm/boot/dts/am437x-gp-evm.dts
index 215775d..22038f2 100644
--- a/arch/arm/boot/dts/am437x-gp-evm.dts
+++ b/arch/arm/boot/dts/am437x-gp-evm.dts
@@ -112,6 +112,13 @@
 		clock-frequency = <12000000>;
 	};
 
+	/* fixed 32k external oscillator clock */
+	clk_32k_rtc: clk_32k_rtc {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <32768>;
+	};
+
 	sound0: sound@0 {
 		compatible = "simple-audio-card";
 		simple-audio-card,name = "AM437x-GP-EVM";
@@ -941,3 +948,9 @@
 	tx-num-evt = <32>;
 	rx-num-evt = <32>;
 };
+
+&rtc {
+	clocks = <&clk_32k_rtc>, <&clk_32768_ck>;
+	clock-names = "ext-clk", "int-clk";
+	status = "okay";
+};
diff --git a/arch/arm/boot/dts/am437x-idk-evm.dts b/arch/arm/boot/dts/am437x-idk-evm.dts
index 37834427..af25801 100644
--- a/arch/arm/boot/dts/am437x-idk-evm.dts
+++ b/arch/arm/boot/dts/am437x-idk-evm.dts
@@ -110,6 +110,13 @@
 			gpios = <&gpio4 2 GPIO_ACTIVE_LOW>;
 		};
 	};
+
+	/* fixed 32k external oscillator clock */
+	clk_32k_rtc: clk_32k_rtc {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <32768>;
+	};
 };
 
 &am43xx_pinmux {
@@ -394,6 +401,8 @@
 };
 
 &rtc {
+	clocks = <&clk_32k_rtc>, <&clk_32768_ck>;
+	clock-names = "ext-clk", "int-clk";
 	status = "okay";
 };
 
diff --git a/arch/arm/boot/dts/am437x-sk-evm.dts b/arch/arm/boot/dts/am437x-sk-evm.dts
index 22af448..7da7c2d 100644
--- a/arch/arm/boot/dts/am437x-sk-evm.dts
+++ b/arch/arm/boot/dts/am437x-sk-evm.dts
@@ -24,6 +24,13 @@
 		display0 = &lcd0;
 	};
 
+	/* fixed 32k external oscillator clock */
+	clk_32k_rtc: clk_32k_rtc {
+		#clock-cells = <0>;
+		compatible = "fixed-clock";
+		clock-frequency = <32768>;
+	};
+
 	backlight {
 		compatible = "pwm-backlight";
 		pwms = <&ecap0 0 50000 PWM_POLARITY_INVERTED>;
@@ -697,6 +704,8 @@
 };
 
 &rtc {
+	clocks = <&clk_32k_rtc>, <&clk_32768_ck>;
+	clock-names = "ext-clk", "int-clk";
 	status = "okay";
 };
 
-- 
1.9.1

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [rtc-linux] [PATCH v4 2/3] rtc: omap: Add internal clock enabling support
  2015-08-18  8:43 [rtc-linux] [PATCH v4 0/2] ARM: AM437X: Add rtc clock handling Keerthy
  2015-08-18  8:43 ` [rtc-linux] [PATCH v4 1/3] ARM: dts: AM437x: Add the internal and external clock nodes for rtc Keerthy
@ 2015-08-18  8:43 ` Keerthy
  2015-08-18  8:43 ` [rtc-linux] [PATCH v4 3/3] rtc: omap: Add external " Keerthy
  2015-08-18  8:52 ` [rtc-linux] Re: [PATCH v4 0/2] ARM: AM437X: Add rtc clock handling Johan Hovold
  3 siblings, 0 replies; 6+ messages in thread
From: Keerthy @ 2015-08-18  8:43 UTC (permalink / raw)
  To: alexandre.belloni, tony
  Cc: johan, linux-omap, rtc-linux, grygorii.strashko, j-keerthy

The rtc can be clocked by an internal 32K clock. Adding the support
to enable the same.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 drivers/rtc/rtc-omap.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 8b6355f..f31c012 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -25,6 +25,7 @@
 #include <linux/of_device.h>
 #include <linux/pm_runtime.h>
 #include <linux/io.h>
+#include <linux/clk.h>
 
 /*
  * The OMAP RTC is a year/month/day/hours/minutes/seconds BCD clock
@@ -132,6 +133,7 @@ struct omap_rtc_device_type {
 struct omap_rtc {
 	struct rtc_device *rtc;
 	void __iomem *base;
+	struct clk *clk;
 	int irq_alarm;
 	int irq_timer;
 	u8 interrupts_reg;
@@ -553,6 +555,11 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	if (rtc->irq_alarm <= 0)
 		return -ENOENT;
 
+	rtc->clk = devm_clk_get(&pdev->dev, "int-clk");
+
+	if (!IS_ERR(rtc->clk))
+		clk_prepare_enable(rtc->clk);
+
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	rtc->base = devm_ioremap_resource(&pdev->dev, res);
 	if (IS_ERR(rtc->base))
@@ -681,6 +688,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
 
 	device_init_wakeup(&pdev->dev, 0);
 
+	if (!IS_ERR(rtc->clk))
+		clk_disable_unprepare(rtc->clk);
+
 	rtc->type->unlock(rtc);
 	/* leave rtc running, but disable irqs */
 	rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, 0);
-- 
1.9.1

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [rtc-linux] [PATCH v4 3/3] rtc: omap: Add external clock enabling support
  2015-08-18  8:43 [rtc-linux] [PATCH v4 0/2] ARM: AM437X: Add rtc clock handling Keerthy
  2015-08-18  8:43 ` [rtc-linux] [PATCH v4 1/3] ARM: dts: AM437x: Add the internal and external clock nodes for rtc Keerthy
  2015-08-18  8:43 ` [rtc-linux] [PATCH v4 2/3] rtc: omap: Add internal clock enabling support Keerthy
@ 2015-08-18  8:43 ` Keerthy
  2015-08-18  8:52 ` [rtc-linux] Re: [PATCH v4 0/2] ARM: AM437X: Add rtc clock handling Johan Hovold
  3 siblings, 0 replies; 6+ messages in thread
From: Keerthy @ 2015-08-18  8:43 UTC (permalink / raw)
  To: alexandre.belloni, tony
  Cc: johan, linux-omap, rtc-linux, grygorii.strashko, j-keerthy

Configure the clock source to external clock if available.
External clock is preferred as it can be ticking during suspend.

Signed-off-by: Keerthy <j-keerthy@ti.com>
---
 drivers/rtc/rtc-omap.c | 25 ++++++++++++++++++++++++-
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index f31c012..ec2e9c5 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -108,6 +108,7 @@
 
 /* OMAP_RTC_OSC_REG bit fields: */
 #define OMAP_RTC_OSC_32KCLK_EN		BIT(6)
+#define OMAP_RTC_OSC_SEL_32KCLK_SRC	BIT(3)
 
 /* OMAP_RTC_IRQWAKEEN bit fields: */
 #define OMAP_RTC_IRQWAKEEN_ALARM_WAKEEN	BIT(1)
@@ -138,6 +139,7 @@ struct omap_rtc {
 	int irq_timer;
 	u8 interrupts_reg;
 	bool is_pmic_controller;
+	bool has_ext_clk;
 	const struct omap_rtc_device_type *type;
 };
 
@@ -555,7 +557,11 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	if (rtc->irq_alarm <= 0)
 		return -ENOENT;
 
-	rtc->clk = devm_clk_get(&pdev->dev, "int-clk");
+	rtc->clk = devm_clk_get(&pdev->dev, "ext-clk");
+	if (!IS_ERR(rtc->clk))
+		rtc->has_ext_clk = true;
+	else
+		rtc->clk = devm_clk_get(&pdev->dev, "int-clk");
 
 	if (!IS_ERR(rtc->clk))
 		clk_prepare_enable(rtc->clk);
@@ -634,6 +640,16 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	if (reg != new_ctrl)
 		rtc_write(rtc, OMAP_RTC_CTRL_REG, new_ctrl);
 
+	/*
+	 * If we have the external clock then switch to it so we can keep
+	 * ticking across suspend.
+	 */
+	if (rtc->has_ext_clk) {
+		reg = rtc_read(rtc, OMAP_RTC_OSC_REG);
+		rtc_write(rtc, OMAP_RTC_OSC_REG,
+			  reg | OMAP_RTC_OSC_SEL_32KCLK_SRC);
+	}
+
 	rtc->type->lock(rtc);
 
 	device_init_wakeup(&pdev->dev, true);
@@ -679,6 +695,7 @@ err:
 static int __exit omap_rtc_remove(struct platform_device *pdev)
 {
 	struct omap_rtc *rtc = platform_get_drvdata(pdev);
+	u8 reg;
 
 	if (pm_power_off == omap_rtc_power_off &&
 			omap_rtc_power_off_rtc == rtc) {
@@ -695,6 +712,12 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
 	/* leave rtc running, but disable irqs */
 	rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, 0);
 
+	if (rtc->has_ext_clk) {
+		reg = rtc_read(rtc, OMAP_RTC_OSC_REG);
+		reg &= ~OMAP_RTC_OSC_SEL_32KCLK_SRC;
+		rtc_write(rtc, OMAP_RTC_OSC_REG, reg);
+	}
+
 	rtc->type->lock(rtc);
 
 	/* Disable the clock/module */
-- 
1.9.1

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [rtc-linux] Re: [PATCH v4 0/2]  ARM: AM437X: Add rtc clock handling
  2015-08-18  8:43 [rtc-linux] [PATCH v4 0/2] ARM: AM437X: Add rtc clock handling Keerthy
                   ` (2 preceding siblings ...)
  2015-08-18  8:43 ` [rtc-linux] [PATCH v4 3/3] rtc: omap: Add external " Keerthy
@ 2015-08-18  8:52 ` Johan Hovold
  2015-08-18  8:54   ` Keerthy
  3 siblings, 1 reply; 6+ messages in thread
From: Johan Hovold @ 2015-08-18  8:52 UTC (permalink / raw)
  To: Keerthy
  Cc: alexandre.belloni, tony, johan, linux-omap, rtc-linux, grygorii.strashko

On Tue, Aug 18, 2015 at 02:13:28PM +0530, Keerthy wrote:
> The series is applicable for all am437x series of processors.
> It adds clock handling support. Boot tested on am437x-gp-evm.
> 
> Keerthy (2):
>   ARM: dts: AM437x: Add the internal and external clock nodes for rtc
>   rtc: omap: Add external clock enabling support

Obsolete (2-patch) cover letter?

Either way, you should update the rtc-omap binding documentation with
the optional clocks as well.

Thanks,
Johan

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [rtc-linux] Re: [PATCH v4 0/2]  ARM: AM437X: Add rtc clock handling
  2015-08-18  8:52 ` [rtc-linux] Re: [PATCH v4 0/2] ARM: AM437X: Add rtc clock handling Johan Hovold
@ 2015-08-18  8:54   ` Keerthy
  0 siblings, 0 replies; 6+ messages in thread
From: Keerthy @ 2015-08-18  8:54 UTC (permalink / raw)
  To: Johan Hovold, Keerthy
  Cc: alexandre.belloni, tony, linux-omap, rtc-linux, grygorii.strashko



On Tuesday 18 August 2015 02:22 PM, Johan Hovold wrote:
> On Tue, Aug 18, 2015 at 02:13:28PM +0530, Keerthy wrote:
>> The series is applicable for all am437x series of processors.
>> It adds clock handling support. Boot tested on am437x-gp-evm.
>>
>> Keerthy (2):
>>    ARM: dts: AM437x: Add the internal and external clock nodes for rtc
>>    rtc: omap: Add external clock enabling support
>
> Obsolete (2-patch) cover letter?

oops yes!

>
> Either way, you should update the rtc-omap binding documentation with
> the optional clocks as well.

Thanks yes. I shall update that as well in the next version.

>
> Thanks,
> Johan
>

-- 
-- 
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
--- 
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-08-18  8:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-18  8:43 [rtc-linux] [PATCH v4 0/2] ARM: AM437X: Add rtc clock handling Keerthy
2015-08-18  8:43 ` [rtc-linux] [PATCH v4 1/3] ARM: dts: AM437x: Add the internal and external clock nodes for rtc Keerthy
2015-08-18  8:43 ` [rtc-linux] [PATCH v4 2/3] rtc: omap: Add internal clock enabling support Keerthy
2015-08-18  8:43 ` [rtc-linux] [PATCH v4 3/3] rtc: omap: Add external " Keerthy
2015-08-18  8:52 ` [rtc-linux] Re: [PATCH v4 0/2] ARM: AM437X: Add rtc clock handling Johan Hovold
2015-08-18  8:54   ` Keerthy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.