* [PATCH 0/2] ARM: AM437X: Add rtc clock handling
@ 2015-08-13 7:07 Keerthy
[not found] ` <1439449668-32301-1-git-send-email-j-keerthy-l0cyMroinI0@public.gmane.org>
0 siblings, 1 reply; 6+ messages in thread
From: Keerthy @ 2015-08-13 7:07 UTC (permalink / raw)
To: linux-omap-u79uwXL29TY76Z2rM5mHXA,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
Cc: tony-4v6yS6AI5VpBDgjK7y7TUQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
johan-DgEjT+Ai2ygdnm+yROfE0A, grygorii.strashko-l0cyMroinI0,
bcousson-rdvid1DuHRBWk0Htik3J/w,
devicetree-u79uwXL29TY76Z2rM5mHXA, t-kristo-l0cyMroinI0,
j-keerthy-l0cyMroinI0
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
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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] ARM: dts: AM437x: Add the internal and external clock nodes for rtc
[not found] ` <1439449668-32301-1-git-send-email-j-keerthy-l0cyMroinI0@public.gmane.org>
@ 2015-08-13 7:07 ` Keerthy
2015-08-13 7:07 ` [PATCH 2/2] rtc: omap: Add external clock enabling support Keerthy
1 sibling, 0 replies; 6+ messages in thread
From: Keerthy @ 2015-08-13 7:07 UTC (permalink / raw)
To: linux-omap-u79uwXL29TY76Z2rM5mHXA,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
Cc: tony-4v6yS6AI5VpBDgjK7y7TUQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
johan-DgEjT+Ai2ygdnm+yROfE0A, grygorii.strashko-l0cyMroinI0,
bcousson-rdvid1DuHRBWk0Htik3J/w,
devicetree-u79uwXL29TY76Z2rM5mHXA, t-kristo-l0cyMroinI0,
j-keerthy-l0cyMroinI0
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-l0cyMroinI0@public.gmane.org>
---
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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] rtc: omap: Add external clock enabling support
[not found] ` <1439449668-32301-1-git-send-email-j-keerthy-l0cyMroinI0@public.gmane.org>
2015-08-13 7:07 ` [PATCH 1/2] ARM: dts: AM437x: Add the internal and external clock nodes for rtc Keerthy
@ 2015-08-13 7:07 ` Keerthy
[not found] ` <1439449668-32301-3-git-send-email-j-keerthy-l0cyMroinI0@public.gmane.org>
1 sibling, 1 reply; 6+ messages in thread
From: Keerthy @ 2015-08-13 7:07 UTC (permalink / raw)
To: linux-omap-u79uwXL29TY76Z2rM5mHXA,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw
Cc: tony-4v6yS6AI5VpBDgjK7y7TUQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
johan-DgEjT+Ai2ygdnm+yROfE0A, grygorii.strashko-l0cyMroinI0,
bcousson-rdvid1DuHRBWk0Htik3J/w,
devicetree-u79uwXL29TY76Z2rM5mHXA, t-kristo-l0cyMroinI0,
j-keerthy-l0cyMroinI0
Configure the clock source to either internal clock
or external clock based on the availability of the clocks.
External clock is preferred as it can be ticking during suspend.
Signed-off-by: Keerthy <j-keerthy-l0cyMroinI0@public.gmane.org>
---
drivers/rtc/rtc-omap.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 8b6355f..479f730 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
@@ -107,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)
@@ -136,6 +138,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;
};
@@ -525,6 +528,7 @@ static int omap_rtc_probe(struct platform_device *pdev)
{
struct omap_rtc *rtc;
struct resource *res;
+ struct clk *ext_clk, *int_clk;
u8 reg, mask, new_ctrl;
const struct platform_device_id *id_entry;
const struct of_device_id *of_id;
@@ -553,6 +557,17 @@ static int omap_rtc_probe(struct platform_device *pdev)
if (rtc->irq_alarm <= 0)
return -ENOENT;
+ ext_clk = devm_clk_get(&pdev->dev, "ext-clk");
+ if (!IS_ERR(ext_clk)) {
+ rtc->has_ext_clk = true;
+ clk_prepare(ext_clk);
+ } else {
+ int_clk = devm_clk_get(&pdev->dev, "int-clk");
+
+ if (!IS_ERR(int_clk))
+ clk_prepare(int_clk);
+ }
+
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
rtc->base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(rtc->base))
@@ -627,6 +642,17 @@ 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 external clock so we can keep ticking
+ * acorss 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);
@@ -672,6 +698,8 @@ err:
static int __exit omap_rtc_remove(struct platform_device *pdev)
{
struct omap_rtc *rtc = platform_get_drvdata(pdev);
+ struct clk *ext_clk, *int_clk;
+ u8 reg;
if (pm_power_off == omap_rtc_power_off &&
omap_rtc_power_off_rtc == rtc) {
@@ -681,10 +709,26 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, 0);
+ ext_clk = devm_clk_get(&pdev->dev, "ext-clk");
+ if (!IS_ERR(ext_clk)) {
+ clk_unprepare(ext_clk);
+ } else {
+ int_clk = devm_clk_get(&pdev->dev, "int-clk");
+
+ if (!IS_ERR(int_clk))
+ clk_unprepare(int_clk);
+ }
+
rtc->type->unlock(rtc);
/* 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
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] rtc: omap: Add external clock enabling support
[not found] ` <1439449668-32301-3-git-send-email-j-keerthy-l0cyMroinI0@public.gmane.org>
@ 2015-08-14 8:33 ` Alexandre Belloni
[not found] ` <20150814083319.GG22269-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org>
2015-08-14 10:54 ` Johan Hovold
1 sibling, 1 reply; 6+ messages in thread
From: Alexandre Belloni @ 2015-08-14 8:33 UTC (permalink / raw)
To: Keerthy
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw, tony-4v6yS6AI5VpBDgjK7y7TUQ,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
johan-DgEjT+Ai2ygdnm+yROfE0A, grygorii.strashko-l0cyMroinI0,
bcousson-rdvid1DuHRBWk0Htik3J/w,
devicetree-u79uwXL29TY76Z2rM5mHXA, t-kristo-l0cyMroinI0
On 13/08/2015 at 12:37:48 +0530, Keerthy wrote :
> Configure the clock source to either internal clock
> or external clock based on the availability of the clocks.
> External clock is preferred as it can be ticking during suspend.
>
> Signed-off-by: Keerthy <j-keerthy-l0cyMroinI0@public.gmane.org>
> ---
> drivers/rtc/rtc-omap.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 44 insertions(+)
>
> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
> index 8b6355f..479f730 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
> @@ -107,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)
> @@ -136,6 +138,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;
> };
>
> @@ -525,6 +528,7 @@ static int omap_rtc_probe(struct platform_device *pdev)
> {
> struct omap_rtc *rtc;
> struct resource *res;
> + struct clk *ext_clk, *int_clk;
> u8 reg, mask, new_ctrl;
> const struct platform_device_id *id_entry;
> const struct of_device_id *of_id;
> @@ -553,6 +557,17 @@ static int omap_rtc_probe(struct platform_device *pdev)
> if (rtc->irq_alarm <= 0)
> return -ENOENT;
>
> + ext_clk = devm_clk_get(&pdev->dev, "ext-clk");
> + if (!IS_ERR(ext_clk)) {
> + rtc->has_ext_clk = true;
> + clk_prepare(ext_clk);
I'd say this has to be prepare_enable because you are not enabling those
clocks anywhere
> + } else {
> + int_clk = devm_clk_get(&pdev->dev, "int-clk");
> +
> + if (!IS_ERR(int_clk))
> + clk_prepare(int_clk);
> + }
> +
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> rtc->base = devm_ioremap_resource(&pdev->dev, res);
> if (IS_ERR(rtc->base))
> @@ -627,6 +642,17 @@ 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 external clock so we can keep ticking
> + * acorss 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);
> @@ -672,6 +698,8 @@ err:
> static int __exit omap_rtc_remove(struct platform_device *pdev)
> {
> struct omap_rtc *rtc = platform_get_drvdata(pdev);
> + struct clk *ext_clk, *int_clk;
> + u8 reg;
>
> if (pm_power_off == omap_rtc_power_off &&
> omap_rtc_power_off_rtc == rtc) {
> @@ -681,10 +709,26 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
>
> device_init_wakeup(&pdev->dev, 0);
>
> + ext_clk = devm_clk_get(&pdev->dev, "ext-clk");
> + if (!IS_ERR(ext_clk)) {
> + clk_unprepare(ext_clk);
> + } else {
> + int_clk = devm_clk_get(&pdev->dev, "int-clk");
> +
> + if (!IS_ERR(int_clk))
> + clk_unprepare(int_clk);
> + }
> +
You can probably add ext_clk and int_clk to struct omap_rtc and avoid
those devm_clk_get.
> rtc->type->unlock(rtc);
> /* leave rtc running, but disable irqs */
> rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, 0);
>
> + if (rtc->has_ext_clk) {
Then you could also avoid has_ext_clk and simply test rtc->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
>
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] rtc: omap: Add external clock enabling support
[not found] ` <20150814083319.GG22269-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org>
@ 2015-08-14 8:36 ` Vaibhav Hiremath
0 siblings, 0 replies; 6+ messages in thread
From: Vaibhav Hiremath @ 2015-08-14 8:36 UTC (permalink / raw)
To: Alexandre Belloni, Keerthy
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw, tony-4v6yS6AI5VpBDgjK7y7TUQ,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
johan-DgEjT+Ai2ygdnm+yROfE0A, grygorii.strashko-l0cyMroinI0,
bcousson-rdvid1DuHRBWk0Htik3J/w,
devicetree-u79uwXL29TY76Z2rM5mHXA, t-kristo-l0cyMroinI0
On Friday 14 August 2015 02:03 PM, Alexandre Belloni wrote:
> On 13/08/2015 at 12:37:48 +0530, Keerthy wrote :
>> Configure the clock source to either internal clock
>> or external clock based on the availability of the clocks.
>> External clock is preferred as it can be ticking during suspend.
>>
>> Signed-off-by: Keerthy <j-keerthy-l0cyMroinI0@public.gmane.org>
>> ---
>> drivers/rtc/rtc-omap.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 44 insertions(+)
>>
>> diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
>> index 8b6355f..479f730 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
>> @@ -107,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)
>> @@ -136,6 +138,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;
>> };
>>
>> @@ -525,6 +528,7 @@ static int omap_rtc_probe(struct platform_device *pdev)
>> {
>> struct omap_rtc *rtc;
>> struct resource *res;
>> + struct clk *ext_clk, *int_clk;
>> u8 reg, mask, new_ctrl;
>> const struct platform_device_id *id_entry;
>> const struct of_device_id *of_id;
>> @@ -553,6 +557,17 @@ static int omap_rtc_probe(struct platform_device *pdev)
>> if (rtc->irq_alarm <= 0)
>> return -ENOENT;
>>
>> + ext_clk = devm_clk_get(&pdev->dev, "ext-clk");
>> + if (!IS_ERR(ext_clk)) {
>> + rtc->has_ext_clk = true;
>> + clk_prepare(ext_clk);
>
> I'd say this has to be prepare_enable because you are not enabling those
> clocks anywhere
>
>> + } else {
>> + int_clk = devm_clk_get(&pdev->dev, "int-clk");
>> +
>> + if (!IS_ERR(int_clk))
>> + clk_prepare(int_clk);
>> + }
>> +
>> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>> rtc->base = devm_ioremap_resource(&pdev->dev, res);
>> if (IS_ERR(rtc->base))
>> @@ -627,6 +642,17 @@ 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 external clock so we can keep ticking
>> + * acorss 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);
>> @@ -672,6 +698,8 @@ err:
>> static int __exit omap_rtc_remove(struct platform_device *pdev)
>> {
>> struct omap_rtc *rtc = platform_get_drvdata(pdev);
>> + struct clk *ext_clk, *int_clk;
>> + u8 reg;
>>
>> if (pm_power_off == omap_rtc_power_off &&
>> omap_rtc_power_off_rtc == rtc) {
>> @@ -681,10 +709,26 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
>>
>> device_init_wakeup(&pdev->dev, 0);
>>
>> + ext_clk = devm_clk_get(&pdev->dev, "ext-clk");
>> + if (!IS_ERR(ext_clk)) {
>> + clk_unprepare(ext_clk);
>> + } else {
>> + int_clk = devm_clk_get(&pdev->dev, "int-clk");
>> +
>> + if (!IS_ERR(int_clk))
>> + clk_unprepare(int_clk);
>> + }
>> +
>
> You can probably add ext_clk and int_clk to struct omap_rtc and avoid
> those devm_clk_get.
>
Since both int_clk and ext_clk are mutual exclusive, you can have only
one variable.
Thanks,
Vaibhav
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] rtc: omap: Add external clock enabling support
[not found] ` <1439449668-32301-3-git-send-email-j-keerthy-l0cyMroinI0@public.gmane.org>
2015-08-14 8:33 ` Alexandre Belloni
@ 2015-08-14 10:54 ` Johan Hovold
1 sibling, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2015-08-14 10:54 UTC (permalink / raw)
To: Keerthy
Cc: linux-omap-u79uwXL29TY76Z2rM5mHXA,
rtc-linux-/JYPxA39Uh5TLH3MbocFFw, tony-4v6yS6AI5VpBDgjK7y7TUQ,
alexandre.belloni-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8,
akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
johan-DgEjT+Ai2ygdnm+yROfE0A, grygorii.strashko-l0cyMroinI0,
bcousson-rdvid1DuHRBWk0Htik3J/w,
devicetree-u79uwXL29TY76Z2rM5mHXA, t-kristo-l0cyMroinI0
On Thu, Aug 13, 2015 at 12:37:48PM +0530, Keerthy wrote:
> Configure the clock source to either internal clock
> or external clock based on the availability of the clocks.
> External clock is preferred as it can be ticking during suspend.
>
> Signed-off-by: Keerthy <j-keerthy-l0cyMroinI0@public.gmane.org>
> @@ -627,6 +642,17 @@ 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 external clock so we can keep ticking
> + * acorss suspend
> + */
You should fix up the comment (e.g. stray capitalisation and typo) as
well.
Perhaps reword as
/*
* If we have an external clock then switch to it so we can keep
* ticking across suspend.
*/
Johan
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2015-08-14 10:54 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-13 7:07 [PATCH 0/2] ARM: AM437X: Add rtc clock handling Keerthy
[not found] ` <1439449668-32301-1-git-send-email-j-keerthy-l0cyMroinI0@public.gmane.org>
2015-08-13 7:07 ` [PATCH 1/2] ARM: dts: AM437x: Add the internal and external clock nodes for rtc Keerthy
2015-08-13 7:07 ` [PATCH 2/2] rtc: omap: Add external clock enabling support Keerthy
[not found] ` <1439449668-32301-3-git-send-email-j-keerthy-l0cyMroinI0@public.gmane.org>
2015-08-14 8:33 ` Alexandre Belloni
[not found] ` <20150814083319.GG22269-m++hUPXGwpdeoWH0uzbU5w@public.gmane.org>
2015-08-14 8:36 ` Vaibhav Hiremath
2015-08-14 10:54 ` Johan Hovold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).