Re: [PATCH 3/8] rtc: omap: Add external clock enabling support
On Thursday 06 August 2015 03:21 PM, Tony Lindgren wrote: * Alexandre Belloni alexandre.bell...@free-electrons.com [150806 02:50]: On 06/08/2015 at 12:36:54 +0300, Grygorii Strashko wrote : Pls, correct me if I'm not right. Is below what you propose? Doard dts: / { rtc_32k_ext_clk: rtc_osc_xi_clkin32_ext { #clock-cells = 0; compatible = fixed-clock; clock-frequency = 32000; clock-output-names = rtc_osc_xi_clkin32; }; } rtc { status = okay; clocks = sys_32k_ck, rtc_32k_ext_clk; [optional] clock-names = int-clk, ext-clk; }; Driver: 1) clk0 is mandatory, internal clock source 2) clk1 is optional, external clock source, so if present - RTC driver can switch to use ext clock source Thanks Grygorii. I will implement it this way. Absolutely! Sounds good to me too. Tony -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/8] rtc: omap: Add external clock enabling support
Hi Alexandre, On 08/05/2015 02:43 PM, Alexandre Belloni wrote: On 05/08/2015 at 13:41:19 +0200, Alexandre Belloni wrote : Hi, On 05/08/2015 at 04:13:17 -0700, Tony Lindgren wrote : * Keerthy j-keer...@ti.com [150805 03:53]: Based on the board property switch the source from internal to external clock. Switching to external source is needed for rtcwake to work in low power modes. I think this is better handled based on the compatible string in the device driver rather than introducing a custom dts property for it. You can just set the quirk flag in the driver probe based on the compatible. Why not use the clocks property? Then you can pass an external clock. If it is present you can even get its rate if this is needed at some point in the future. You could also disable it when going to suspend. Actually, that was already my suggestion back in april: http://patchwork.ozlabs.org/patch/445631/ (Please Cc: the rtc mailing list for RTC related patches so that they get picked up by patchwork). Pls, correct me if I'm not right. Is below what you propose? Doard dts: / { rtc_32k_ext_clk: rtc_osc_xi_clkin32_ext { #clock-cells = 0; compatible = fixed-clock; clock-frequency = 32000; clock-output-names = rtc_osc_xi_clkin32; }; } rtc { status = okay; clocks = sys_32k_ck, rtc_32k_ext_clk; [optional] clock-names = int-clk, ext-clk; }; Driver: 1) clk0 is mandatory, internal clock source 2) clk1 is optional, external clock source, so if present - RTC driver can switch to use ext clock source -- regards, -grygorii -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/8] rtc: omap: Add external clock enabling support
* Alexandre Belloni alexandre.bell...@free-electrons.com [150806 02:50]: On 06/08/2015 at 12:36:54 +0300, Grygorii Strashko wrote : Pls, correct me if I'm not right. Is below what you propose? Doard dts: / { rtc_32k_ext_clk: rtc_osc_xi_clkin32_ext { #clock-cells = 0; compatible = fixed-clock; clock-frequency = 32000; clock-output-names = rtc_osc_xi_clkin32; }; } rtc { status = okay; clocks = sys_32k_ck, rtc_32k_ext_clk; [optional] clock-names = int-clk, ext-clk; }; Driver: 1) clk0 is mandatory, internal clock source 2) clk1 is optional, external clock source, so if present - RTC driver can switch to use ext clock source Absolutely! Sounds good to me too. Tony -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/8] rtc: omap: Add external clock enabling support
On 06/08/2015 at 07:39:52 +0530, Keerthy wrote : On Wednesday 05 August 2015 06:05 PM, Alexandre Belloni wrote: On 05/08/2015 at 17:31:22 +0530, Keerthy wrote : This is a special one where in the enable bit is present in the rtc register space and not in the prcm register space. Since there was a concern on the external clock not being present i added a board dts flag. So you mean this external clock is coming internally from the SoC? No what i meant is external clock is coming from Oscillator OSC1 @32.768KHz but the controlling bits are part of rtc register space. TRM: http://www.ti.com/lit/ug/spruhl7c/spruhl7c.pdf Section: 19.4.3.2 Clock Source Page 2836 Also register details: 19.4.5.19 RTCSS_OSC_REG Register (offset = 54h) [reset = 10h] Page 2865. This confirms what I'm saying. Your issue here is that the driver is not properly taking the clocks so when the PRCM is disabling CLK_32KHZ, you end up without any clock. You can use the clocks property in the device tree and pass two clocks, the prcm one and the external crystal/external oscillator. In the driver, you get both clock, clk_get_rate on the external one will help you know whether it is populated or not (this will be 0 or 32768). It is is populated, use it by writing 32KCLK_SEL. Bonus points if you use the clock-accuracy and decide to switch between PRCM and the external clock when going to suspend and resuming. I guess an external RC oscillator is quite bad versus the PRCM. -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/8] rtc: omap: Add external clock enabling support
On 06/08/2015 at 12:36:54 +0300, Grygorii Strashko wrote : Pls, correct me if I'm not right. Is below what you propose? Doard dts: / { rtc_32k_ext_clk: rtc_osc_xi_clkin32_ext { #clock-cells = 0; compatible = fixed-clock; clock-frequency = 32000; clock-output-names = rtc_osc_xi_clkin32; }; } rtc { status = okay; clocks = sys_32k_ck, rtc_32k_ext_clk; [optional] clock-names = int-clk, ext-clk; }; Driver: 1) clk0 is mandatory, internal clock source 2) clk1 is optional, external clock source, so if present - RTC driver can switch to use ext clock source Absolutely! -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/8] rtc: omap: Add external clock enabling support
Based on the board property switch the source from internal to external clock. Switching to external source is needed for rtcwake to work in low power modes. Signed-off-by: Keerthy j-keer...@ti.com --- Documentation/devicetree/bindings/rtc/rtc-omap.txt | 2 ++ drivers/rtc/rtc-omap.c | 10 ++ 2 files changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/rtc/rtc-omap.txt b/Documentation/devicetree/bindings/rtc/rtc-omap.txt index 4ba4dbd..0c44755 100644 --- a/Documentation/devicetree/bindings/rtc/rtc-omap.txt +++ b/Documentation/devicetree/bindings/rtc/rtc-omap.txt @@ -15,6 +15,7 @@ Required properties: Optional properties: - system-power-controller: whether the rtc is controlling the system power through pmic_power_en +- ext-clk-src: Whether the rtc can be sourced by external clock Example: @@ -25,4 +26,5 @@ rtc@1c23000 { 19; interrupt-parent = intc; system-power-controller; + ext-clk-src; }; diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 8b6355f..cb8936a 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c @@ -107,6 +107,7 @@ /* OMAP_RTC_OSC_REG bit fields: */ #define OMAP_RTC_OSC_32KCLK_EN BIT(6) +#define OMAP_RTC_OSC_SEL_32KCLK_SRCBIT(3) /* OMAP_RTC_IRQWAKEEN bit fields: */ #define OMAP_RTC_IRQWAKEEN_ALARM_WAKEENBIT(1) @@ -136,6 +137,7 @@ struct omap_rtc { int irq_timer; u8 interrupts_reg; bool is_pmic_controller; + bool is_ext_src; const struct omap_rtc_device_type *type; }; @@ -540,6 +542,8 @@ static int omap_rtc_probe(struct platform_device *pdev) rtc-is_pmic_controller = rtc-type-has_pmic_mode of_property_read_bool(pdev-dev.of_node, system-power-controller); + rtc-is_ext_src = of_property_read_bool(pdev-dev.of_node, + ext-clk-src); } else { id_entry = platform_get_device_id(pdev); rtc-type = (void *)id_entry-driver_data; @@ -627,6 +631,12 @@ static int omap_rtc_probe(struct platform_device *pdev) if (reg != new_ctrl) rtc_write(rtc, OMAP_RTC_CTRL_REG, new_ctrl); + if (rtc-is_ext_src) { + reg = rtc_read(rtc, OMAP_RTC_OSC_REG); + rtc_writel(rtc, OMAP_RTC_OSC_REG, + reg | OMAP_RTC_OSC_SEL_32KCLK_SRC); + } + rtc-type-lock(rtc); device_init_wakeup(pdev-dev, true); -- 1.9.1 -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/8] rtc: omap: Add external clock enabling support
On 05/08/2015 at 13:41:19 +0200, Alexandre Belloni wrote : Hi, On 05/08/2015 at 04:13:17 -0700, Tony Lindgren wrote : * Keerthy j-keer...@ti.com [150805 03:53]: Based on the board property switch the source from internal to external clock. Switching to external source is needed for rtcwake to work in low power modes. I think this is better handled based on the compatible string in the device driver rather than introducing a custom dts property for it. You can just set the quirk flag in the driver probe based on the compatible. Why not use the clocks property? Then you can pass an external clock. If it is present you can even get its rate if this is needed at some point in the future. You could also disable it when going to suspend. Actually, that was already my suggestion back in april: http://patchwork.ozlabs.org/patch/445631/ (Please Cc: the rtc mailing list for RTC related patches so that they get picked up by patchwork). -- Alexandre Belloni, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/8] rtc: omap: Add external clock enabling support
On Wednesday 05 August 2015 05:13 PM, Alexandre Belloni wrote: On 05/08/2015 at 13:41:19 +0200, Alexandre Belloni wrote : Hi, On 05/08/2015 at 04:13:17 -0700, Tony Lindgren wrote : * Keerthy j-keer...@ti.com [150805 03:53]: Based on the board property switch the source from internal to external clock. Switching to external source is needed for rtcwake to work in low power modes. I think this is better handled based on the compatible string in the device driver rather than introducing a custom dts property for it. You can just set the quirk flag in the driver probe based on the compatible. Why not use the clocks property? Then you can pass an external clock. If it is present you can even get its rate if this is needed at some point in the future. You could also disable it when going to suspend. Actually, that was already my suggestion back in april: http://patchwork.ozlabs.org/patch/445631/ (Please Cc: the rtc mailing list for RTC related patches so that they get picked up by patchwork). Hi Alexandre, This is a special one where in the enable bit is present in the rtc register space and not in the prcm register space. Since there was a concern on the external clock not being present i added a board dts flag. Regards, Keerthy -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/8] rtc: omap: Add external clock enabling support
On Wednesday 05 August 2015 06:05 PM, Alexandre Belloni wrote: On 05/08/2015 at 17:31:22 +0530, Keerthy wrote : This is a special one where in the enable bit is present in the rtc register space and not in the prcm register space. Since there was a concern on the external clock not being present i added a board dts flag. So you mean this external clock is coming internally from the SoC? No what i meant is external clock is coming from Oscillator OSC1 @32.768KHz but the controlling bits are part of rtc register space. TRM: http://www.ti.com/lit/ug/spruhl7c/spruhl7c.pdf Section: 19.4.3.2 Clock Source Page 2836 Also register details: 19.4.5.19 RTCSS_OSC_REG Register (offset = 54h) [reset = 10h] Page 2865. Regards, Keerthy Do you have a link to the datasheet? -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html