All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Lukasz Majewski <lukma@denx.de>
Cc: Alessandro Zummo <a.zummo@towertech.it>,
	linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rtc: Add support for century bits to m41t62 (rv4162) RTC devices
Date: Thu, 3 Oct 2019 23:34:52 +0200	[thread overview]
Message-ID: <20191003213452.GT4106@piout.net> (raw)
In-Reply-To: <20191003164906.2f4a1676@jawa>

On 03/10/2019 16:49:06+0200, Lukasz Majewski wrote:
> Hi Alexandre,
> 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.
> 

No, you can't because you simply don't know if you still need to
correct the time or if you already did it the last time the system was
started.

Example:

Date is set to 2100-02-28, some time pass, the rtc now thinks it is
2100-02-29. You correct it to 2100-03-01, fine.
Now, date is set to 2100-02-28, the system is shutdown, some time pass,
it starts on 2100-03-02, the rtc thinks 2100-03-01 you can't correct it
because you can't know whether a day has been missed.


> > The only useful range for an RTC is its fully contiguous range. 
> 
> Does the automatic increment of century bits count to "contiguous
> range" ?
> 

No, because of the leap day issue.


-- 
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

      reply	other threads:[~2019-10-03 21:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-11 15:48 [PATCH] rtc: Add support for century bits to m41t62 (rv4162) RTC devices Lukasz Majewski
2019-09-30  7:56 ` Lukasz Majewski
2019-10-03 11:48 ` Alexandre Belloni
2019-10-03 12:21   ` Lukasz Majewski
2019-10-03 12:35     ` Alexandre Belloni
2019-10-03 13:14       ` Lukasz Majewski
2019-10-03 13:43         ` Alexandre Belloni
2019-10-03 14:10           ` Lukasz Majewski
2019-10-03 14:23             ` Alexandre Belloni
2019-10-03 14:49               ` Lukasz Majewski
2019-10-03 21:34                 ` Alexandre Belloni [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191003213452.GT4106@piout.net \
    --to=alexandre.belloni@bootlin.com \
    --cc=a.zummo@towertech.it \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=lukma@denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.