AnsweredAssumed Answered

iMX28 RTC clock and 32kHz oscillator

Question asked by Paolo Messina on Oct 30, 2013
Latest reply on Oct 30, 2013 by Paolo Messina

I have a custom design where I want to run the RTC from an external 32.768kHz crystal

So I modified the mxs-rtc driver this way:

@@ -246,6 +246,11 @@ static int mxs_rtc_probe(struct platform_device *pdev)

            (hwversion >> 16) & 0xFF,

            hwversion & 0xFFFF);

 

+    // enable 32kHz oscillator in power off mode, source RTC with 32kHz clock

+    __raw_writel(BM_RTC_PERSISTENT0_XTAL32KHZ_PWRUP |

+            BM_RTC_PERSISTENT0_CLOCKSOURCE,

+             rtc_data->base + HW_RTC_PERSISTENT0_SET);

+

     rtc_data->rtc = rtc_device_register(pdev->name, &pdev->dev,

                 &mxs_rtc_ops, THIS_MODULE);

     if (IS_ERR(rtc_data->rtc)) {

This apparently worked on another custom design we made. I could see the 32kHz oscillation on a scope even after poweroff and measured roughly 11uA consumption from the battery.

 

Now this is acting strangely on a similar custom design. Sometimes I can't see any oscillation with a scope, but I can tell the oscillator has been turned on, because I see a positive DC level on the XTAL pins roughly at 500mV. Sometimes the probe seems to help the oscillation, which starts slowly but it's not stable. Sometimes it seems the opposite: as soon as I connect the probe the oscillation seems to shut off.

 

The weird fact is that the "date" command still works in all scenarios, whatever clock source I set in the RTC and whether or not the external crystal is populated. How can this happen?

Running "date" in a loop with 1 second delay shows that time is correclty updated.

Where does the "date" command get the current time of day? Does the RTC automatically fall back to the 24MHz clock source if the 32kHz is not found oscillating?

Any clues?

 

Thanks,

Paolo

Outcomes