• Thierry Reding's avatar
    rtc: tegra: Implement clock handling · 5fa40869
    Thierry Reding authored
    Accessing the registers of the RTC block on Tegra requires the module
    clock to be enabled. This only works because the RTC module clock will
    be enabled by default during early boot. However, because the clock is
    unused, the CCF will disable it at late_init time. This causes the RTC
    to become unusable afterwards. This can easily be reproduced by trying
    to use the RTC:
    
    	$ hwclock --rtc /dev/rtc1
    
    This will hang the system. I ran into this by following up on a report
    by Martin Michlmayr that reboot wasn't working on Tegra210 systems. It
    turns out that the rtc-tegra driver's ->shutdown() implementation will
    hang the CPU, because of the disabled clock, before the system can be
    rebooted.
    
    What confused me for a while is that the same driver is used on prior
    Tegra generations where the hang can not be observed. However, as Peter
    De Schrijver pointed out, this is because on 32-bit Tegra chips the RTC
    clock is enabled by the tegra20_timer.c clocksource driver, which uses
    the RTC to provide a persistent clock. This code is never enabled on
    64-bit Tegra because the persistent clock infrastructure does not exist
    on 64-bit ARM.
    
    The proper fix for this is to add proper clock handling to the RTC
    driver in order to ensure that the clock is enabled when the driver
    requires it. All device trees contain the clock already, therefore
    no additional changes are required.
    Reported-by: Martin Michlmayr's avatarMartin Michlmayr <tbm@cyrius.com>
    Acked-By Peter De Schrijver <pdeschrijver@nvidia.com>
    Signed-off-by: default avatarThierry Reding <treding@nvidia.com>
    Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
    5fa40869
rtc-tegra.c 12.3 KB