Re: [PATCH 1/2] rtc: omap: Fix selecting external osc

2016-11-04 Thread Alexandre Belloni
On 27/10/2016 at 11:27:25 +0530, Keerthy wrote :
> From: Lokesh Vutla 
> 
> RTC can be clocked from an external 32KHz oscillator, or from the
> Peripheral PLL. The RTC has an internal oscillator buffer to support
> direct operation with a crystal.
> 
> 
> |   Device  -   |
> |   |   |   |
> |   | RTCSS |   |
> |   -   |   |   |
> OSC |<--| RTC   |   |   |   |
> |-->| OSC   |---|   |   |
> |      ||   |   |
> |   |clk|   |
> |      ||   |   |
> |   | PRCM  |---|   |   |
> |   |
> 
> 
> The RTC functional clock is sourced by default from the clock derived
> from the Peripheral PLL. In order to select source as external osc clk
> the following changes needs to be done:
> - Enable the RTC OSC (RTC_OSC_REG[4]OSC32K_GZ = 0)
> - Enable the clock mux(RTC_OSC_REG[6]K32CLK_EN = 1)
> - Select the external clock source (RTC_OSC_REG[3]32KCLK_SEL = 1)
> 
> Fixes: 399cf0f63f6f2 ("rtc: omap: Add external clock enabling support")
> Signed-off-by: Keerthy 
> Signed-off-by: Lokesh Vutla 
> Signed-off-by: Dave Gerlach 
> ---
> 
> Boot tested and checked for rtc ticking on am335x-boneblack, am335x-bone
> am437x-gp-evm, dra7-evm, dra72-evm.
> 
>  drivers/rtc/rtc-omap.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
Both applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


Re: [PATCH 1/2] rtc: omap: Fix selecting external osc

2016-11-04 Thread Alexandre Belloni
On 27/10/2016 at 11:27:25 +0530, Keerthy wrote :
> From: Lokesh Vutla 
> 
> RTC can be clocked from an external 32KHz oscillator, or from the
> Peripheral PLL. The RTC has an internal oscillator buffer to support
> direct operation with a crystal.
> 
> 
> |   Device  -   |
> |   |   |   |
> |   | RTCSS |   |
> |   -   |   |   |
> OSC |<--| RTC   |   |   |   |
> |-->| OSC   |---|   |   |
> |      ||   |   |
> |   |clk|   |
> |      ||   |   |
> |   | PRCM  |---|   |   |
> |   |
> 
> 
> The RTC functional clock is sourced by default from the clock derived
> from the Peripheral PLL. In order to select source as external osc clk
> the following changes needs to be done:
> - Enable the RTC OSC (RTC_OSC_REG[4]OSC32K_GZ = 0)
> - Enable the clock mux(RTC_OSC_REG[6]K32CLK_EN = 1)
> - Select the external clock source (RTC_OSC_REG[3]32KCLK_SEL = 1)
> 
> Fixes: 399cf0f63f6f2 ("rtc: omap: Add external clock enabling support")
> Signed-off-by: Keerthy 
> Signed-off-by: Lokesh Vutla 
> Signed-off-by: Dave Gerlach 
> ---
> 
> Boot tested and checked for rtc ticking on am335x-boneblack, am335x-bone
> am437x-gp-evm, dra7-evm, dra72-evm.
> 
>  drivers/rtc/rtc-omap.c | 6 --
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
Both applied, thanks.

-- 
Alexandre Belloni, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com


[PATCH 1/2] rtc: omap: Fix selecting external osc

2016-10-26 Thread Keerthy
From: Lokesh Vutla 

RTC can be clocked from an external 32KHz oscillator, or from the
Peripheral PLL. The RTC has an internal oscillator buffer to support
direct operation with a crystal.


|   Device  -   |
|   |   |   |
|   | RTCSS |   |
|   -   |   |   |
OSC |<--| RTC   |   |   |   |
|-->| OSC   |---|   |   |
|      ||   |   |
|   |clk|   |
|      ||   |   |
|   | PRCM  |---|   |   |
|   |


The RTC functional clock is sourced by default from the clock derived
from the Peripheral PLL. In order to select source as external osc clk
the following changes needs to be done:
- Enable the RTC OSC (RTC_OSC_REG[4]OSC32K_GZ = 0)
- Enable the clock mux(RTC_OSC_REG[6]K32CLK_EN = 1)
- Select the external clock source (RTC_OSC_REG[3]32KCLK_SEL = 1)

Fixes: 399cf0f63f6f2 ("rtc: omap: Add external clock enabling support")
Signed-off-by: Keerthy 
Signed-off-by: Lokesh Vutla 
Signed-off-by: Dave Gerlach 
---

Boot tested and checked for rtc ticking on am335x-boneblack, am335x-bone
am437x-gp-evm, dra7-evm, dra72-evm.

 drivers/rtc/rtc-omap.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index b04ea9b..dddaa60 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -113,6 +113,7 @@
 /* OMAP_RTC_OSC_REG bit fields: */
 #define OMAP_RTC_OSC_32KCLK_EN BIT(6)
 #define OMAP_RTC_OSC_SEL_32KCLK_SRCBIT(3)
+#define OMAP_RTC_OSC_OSC32K_GZ_DISABLE BIT(4)
 
 /* OMAP_RTC_IRQWAKEEN bit fields: */
 #define OMAP_RTC_IRQWAKEEN_ALARM_WAKEENBIT(1)
@@ -786,8 +787,9 @@ static int omap_rtc_probe(struct platform_device *pdev)
 */
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);
+   reg &= ~OMAP_RTC_OSC_OSC32K_GZ_DISABLE;
+   reg |= OMAP_RTC_OSC_32KCLK_EN | OMAP_RTC_OSC_SEL_32KCLK_SRC;
+   rtc_writel(rtc, OMAP_RTC_OSC_REG, reg);
}
 
rtc->type->lock(rtc);
-- 
1.9.1



[PATCH 1/2] rtc: omap: Fix selecting external osc

2016-10-26 Thread Keerthy
From: Lokesh Vutla 

RTC can be clocked from an external 32KHz oscillator, or from the
Peripheral PLL. The RTC has an internal oscillator buffer to support
direct operation with a crystal.


|   Device  -   |
|   |   |   |
|   | RTCSS |   |
|   -   |   |   |
OSC |<--| RTC   |   |   |   |
|-->| OSC   |---|   |   |
|      ||   |   |
|   |clk|   |
|      ||   |   |
|   | PRCM  |---|   |   |
|   |


The RTC functional clock is sourced by default from the clock derived
from the Peripheral PLL. In order to select source as external osc clk
the following changes needs to be done:
- Enable the RTC OSC (RTC_OSC_REG[4]OSC32K_GZ = 0)
- Enable the clock mux(RTC_OSC_REG[6]K32CLK_EN = 1)
- Select the external clock source (RTC_OSC_REG[3]32KCLK_SEL = 1)

Fixes: 399cf0f63f6f2 ("rtc: omap: Add external clock enabling support")
Signed-off-by: Keerthy 
Signed-off-by: Lokesh Vutla 
Signed-off-by: Dave Gerlach 
---

Boot tested and checked for rtc ticking on am335x-boneblack, am335x-bone
am437x-gp-evm, dra7-evm, dra72-evm.

 drivers/rtc/rtc-omap.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index b04ea9b..dddaa60 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -113,6 +113,7 @@
 /* OMAP_RTC_OSC_REG bit fields: */
 #define OMAP_RTC_OSC_32KCLK_EN BIT(6)
 #define OMAP_RTC_OSC_SEL_32KCLK_SRCBIT(3)
+#define OMAP_RTC_OSC_OSC32K_GZ_DISABLE BIT(4)
 
 /* OMAP_RTC_IRQWAKEEN bit fields: */
 #define OMAP_RTC_IRQWAKEEN_ALARM_WAKEENBIT(1)
@@ -786,8 +787,9 @@ static int omap_rtc_probe(struct platform_device *pdev)
 */
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);
+   reg &= ~OMAP_RTC_OSC_OSC32K_GZ_DISABLE;
+   reg |= OMAP_RTC_OSC_32KCLK_EN | OMAP_RTC_OSC_SEL_32KCLK_SRC;
+   rtc_writel(rtc, OMAP_RTC_OSC_REG, reg);
}
 
rtc->type->lock(rtc);
-- 
1.9.1