[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191003164906.2f4a1676@jawa>
Date: Thu, 3 Oct 2019 16:49:06 +0200
From: Lukasz Majewski <lukma@...x.de>
To: Alexandre Belloni <alexandre.belloni@...tlin.com>
Cc: Alessandro Zummo <a.zummo@...ertech.it>, linux-rtc@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] rtc: Add support for century bits to m41t62 (rv4162)
RTC devices
Hi Alexandre,
> On 03/10/2019 16:10:53+0200, Lukasz Majewski wrote:
> > Sorry, but I do see some inconsistency here.
> >
> > The application note [1] says that the correction shall be done in
> > application SW.
> >
> > The rtc-range.c program [2] sets and reads the time via ioctl (e.g.
> > RTC_SET_TIME, RTC_RD_TIME).
> >
> > To pass your tests one needs to do the correction in linux kernel
> > driver for drivers/rtc/rtc-m41t80.c.
> >
> > Please correct me if I'm wrong, but IMHO it shall be enough to
> > adjust 2100, 2200, 2300, years in this driver (the submitted patch
> > shall be adjusted to support it - I can prepare proper v2).
> >
>
> There is no way you will be able to know when to adjust the date
> because Linux may or may not be running when the boundary is crossed.
>
I'm rather thinking about following use cases:
I. Adjusting time:
1. I start with time < 01.01.2099
2. I issue ioctl to set the time to e.g. 2100
- When driver receives such request I setup century bits
- and also perform in kernel driver time correction (and store
corrected time in RTC)
3. Subsequent reads from rtc use century bits to provide the time
(after year 2100). Century bits are set, so the correction may be
performed if needed.
II. The system is started at year 2098 and is supposed to run for e.g. 3
years:
1. The time is read from the rtc - the "passing" of centuries need to
be detected.
From the documentation [1] (point 4.5):
"The two century bits, CB1 and CB0, are bits 7 and 6, respectively, in
the Month / Century register at address 06h. Together, they comprise a
2 - bit counter which increments at the turn of each century. CB1 is
the most significant bit."
If those bits increment when we pass century boundaries, we can detect
this fact and correct time when ioctl is issued.
> The only useful range for an RTC is its fully contiguous range.
Does the automatic increment of century bits count to "contiguous
range" ?
> If it
> needs software to run to support an extended range, it can't be used
> in the context of Linux.
>
[1] -
https://www.microcrystal.com/fileadmin/Media/Products/RTC/App.Manual/RV-4162-C7_App-Manual.pdf
Best regards,
Lukasz Majewski
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: lukma@...x.de
Content of type "application/pgp-signature" skipped
Powered by blists - more mailing lists