• Joshua Clayton's avatar
    rtc: pcf2123: avoid resetting the clock if possible · f07fa924
    Joshua Clayton authored
    pcf2123 data sheet recommends a software reset when the chip
    is first powered on. This change avoids resetting the chip
    every time the driver is loaded, which has some negative effects.
    
    There are several registers including a clock rate adjustment that really
    should survive a reload of the driver (or reboot).
    
    In addition, stopping and restarting the clock to verify the chip is
    there is not a good thing once the time is set.
    
    According to the data sheet, the seconds register has a 1 in
    the high bit when the voltage has gotten low. We check for this
    condition, as well as whether the time retrieved from the chip is
    valid. We reset the rtc only if the time is not reliable and valid.
    This is sufficient for checking for the presence of the chip,
    as either all zeros or all 0xff will result in an invalid time/date
    Signed-off-by: default avatarJoshua Clayton <stillcompiling@gmail.com>
    Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@free-electrons.com>
    f07fa924
rtc-pcf2123.c 10.5 KB