[PATCH] rtc: ds1307: Handle oscillator-stop bit correctly

Simon Glass sjg at chromium.org
Wed Sep 22 18:19:06 CEST 2021


Hi Mark,

On Mon, 20 Sept 2021 at 19:17, Mark Tomlinson
<mark.tomlinson at alliedtelesis.co.nz> wrote:
>
> The DS1307 driver was originally based on the DS1337 driver. However,
> the functionality of the clock set/get functions has diverged. In the
> original DS1337 driver, the set/get functions did the following:
>   1) Setting the clock ensured the oscillator was enabled.
>   2) Getting the clock checked and reset the oscillator-stop flag.
> The DS1307 does not have and oscillator-stop flag, but the driver tried

an

> (incorrectly) to emulate this by ensuring the oscillator was running. It
> really makes no sense to start a stopped clock without setting it.
>
> This patch makes the DS1307 driver behave like the original DS1337
> driver again. For the DS1307 itself, this is just a removal of code,
> since there is no oscillator-fail bit to check or reset, and the clock
> is started when it is set. Since the DS1307 driver can now also be used
> for the DS1337 and DS1340 which do have this bit, add code to handle the
> oscillator-stop bit in the same was the original DS1337 driver did --
> i.e. report that the oscillator had stopped and clear the flag.
>
> This means that setting the date using the date command (which does both
> a get and a set) will now clear the oscillator-stop flag in addition to
> setting and starting the clock.
>
> The old-style (non-DM) code has also been updated. Note that this does
> not support the DS1337, as there is a separate driver for this. Also
> note that the original (DM) code used the wrong control-register address
> for the DS1337.

Please don't update the old-style code. Delete it (in a separate
patch) if it won't cause build errors.

>
> Signed-off-by: Mark Tomlinson <mark.tomlinson at alliedtelesis.co.nz>
> ---
> Note that this patch is based on 'next' rather than 'master' as it is
> dependent on a patch which has not yet made it to master.
>
>  drivers/rtc/ds1307.c | 106 ++++++++++++-------------------------------
>  1 file changed, 29 insertions(+), 77 deletions(-)
>

Regards,
Simon


More information about the U-Boot mailing list