devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: claudiu beznea <claudiu.beznea@tuxon.dev>
To: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: geert+renesas@glider.be, mturquette@baylibre.com,
	sboyd@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
	conor+dt@kernel.org, lee@kernel.org, magnus.damm@gmail.com,
	linux-renesas-soc@vger.kernel.org, linux-clk@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-rtc@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Subject: Re: [PATCH 06/12] rtc: renesas-rtca3: Add driver for RTCA-3 available on Renesas RZ/G3S SoC
Date: Mon, 17 Jun 2024 10:31:51 +0300	[thread overview]
Message-ID: <f3584295-b396-455a-b988-099443b58dba@tuxon.dev> (raw)
In-Reply-To: <20240617072551acf731aa@mail.local>



On 17.06.2024 10:25, Alexandre Belloni wrote:
> On 14/06/2024 14:06:38+0300, claudiu beznea wrote:
>>>> +	/*
>>>> +	 * Stop the RTC and set to 12 hours mode and calendar count mode.
>>>> +	 * RCR2.START initial value is undefined so we need to stop here
>>>> +	 * all the time.
>>>> +	 */
>>>
>>> Certainly not, if you stop the RTC on probe, you lose the time
>>> information, this must only be done when the RTC has never been
>>> initialised. The whole goal of the RTC is the keep time across reboots,
>>> its lifecycle is longer than the system.
>>
>> This was also my first thought when I read the HW manual.
>>
>> It has been done like this to follow the HW manual. According to HW manual
>> [1], chapter 22.3.19 RTC Control Register 2 (RCR2), initial value of START
>> bit is undefined.
>>
>> If it's 1 while probing but it has never been initialized, we can falsely
>> detect that RTC is started and skip the rest of the initialization steps.
>> W/o initialization configuration, the RTC will not be able to work.
>>
>> Even with this implementation we don't loose the time b/w reboots. Here is
>> the output on my board [2]. The steps I did were the following:
>> 1/ remove the power to the board (I don't have a battery for RTC installed
>>    at the moment)
>> 2/ boot the board and issue hwclock -w
>> 3/ reboot
>> 4/ check the systime and rtc time
>> 5/ poweroff
>> 6/ poweron
>> 7/ boot and check systime and RTC time
>>
>> As you can see the time is not lost but continue to increment. I presume
>> the hardware takes into account that time needs to increment when initial
>> configuration is executed.
> 
> I don't think so, I guess it stops ticking but the registers are not
> reset so when ts starts ticking again, you are not too far from the time
> that it should report.

I'll double check with hardware team on this and return with an answer.

Thank you for your review,
Claudiu Beznea

> 
>>
>> [1]
>> https://www.renesas.com/us/en/products/microcontrollers-microprocessors/rz-mpus/rzg3s-general-purpose-microprocessors-single-core-arm-cortex-a55-11-ghz-cpu-and-dual-core-cortex-m33-250
>> [2] https://p.fr33tux.org/585cd6
>>
>>>
>>> Also, why do you insist on 12H-mode? The proper thing to do is to support
>>> 12H-mode on read but always use 24H-mode when setting the time.
>>
>> OK, I wasn't aware of this. I think I followed this approach as it looked
>> to me the number of operation to update the hardware registers was lower
>> for 12h mode.
> 
> How come, using 12H-mode implies testing for the AM/PM bit and doing and
> addition while 24H-mode would simply be a read?
> 
>>>> +	priv->rtc_dev->ops = &rtca3_ops;
>>>> +	priv->rtc_dev->max_user_freq = 256;
>>>> +	priv->rtc_dev->range_min = mktime64(1999, 1, 1, 0, 0, 0);
>>>> +	priv->rtc_dev->range_max = mktime64(2098, 12, 31, 23, 59, 59);
>>>
>>> This very much looks like the range should be 2000 to 2099, why do you
>>> want to shift it?
>>
>> 2000-2099 was my first option for this but then I saw one of your old
>> commits on this topic and, since I'm not very familiar with RTC,
>> I took it as example. I'll adjust as you proposed.
>>
>> commit beee05dfbead
>> Author: Alexandre Belloni <alexandre.belloni@bootlin.com>
>> Date:   Wed Mar 20 12:30:10 2019 +0100
>>
>>     rtc: sh: set range
>>
>>     The SH RTC is a BCD RTC with some version having 4 digits for the year.
>>
>>     The range for the RTCs with only 2 digits for the year was unfortunately
>>     shifted to handle 1999 to 2098.
>>
>>     Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
>>     Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
> 
> This is because the sh driver predated the introduction of the range and
> was already shifting it.
> 
> 

  reply	other threads:[~2024-06-17  7:31 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-14  7:19 [PATCH 00/12] Add RTC support for the Renesas RZ/G3S SoC Claudiu
2024-06-14  7:19 ` [PATCH 01/12] clk: renesas: r9a08g045: Add clock, reset and power domain support for the VBATTB IP Claudiu
2024-06-26 12:09   ` Geert Uytterhoeven
2024-06-14  7:19 ` [PATCH 02/12] dt-bindings: clock: renesas,rzg3s-vbattb-clk: Document the VBATTB clock driver Claudiu
2024-06-15 12:17   ` Conor Dooley
2024-06-17  7:02     ` claudiu beznea
2024-06-17 15:19       ` Conor Dooley
2024-06-18  7:34         ` claudiu beznea
2024-06-18  7:56           ` Geert Uytterhoeven
2024-06-18  8:11             ` claudiu beznea
2024-06-16  7:38   ` Krzysztof Kozlowski
2024-06-17  7:34     ` claudiu beznea
2024-06-14  7:19 ` [PATCH 03/12] dt-bindings: mfd: renesas,rzg3s-vbattb: Document VBATTB Claudiu
2024-06-15 12:19   ` Conor Dooley
2024-06-17  7:04     ` claudiu beznea
2024-06-16  7:38   ` Krzysztof Kozlowski
2024-06-17  7:16     ` claudiu beznea
2024-06-17  7:25       ` claudiu beznea
2024-06-17  8:10       ` Krzysztof Kozlowski
2024-06-14  7:19 ` [PATCH 04/12] clk: renesas: clk-vbattb: Add VBATTB clock driver Claudiu
2024-06-15 22:25   ` kernel test robot
2024-06-16  0:19   ` kernel test robot
2024-06-14  7:19 ` [PATCH 05/12] dt-bindings: rtc: renesas,rzg3s-rtc: Document the Renesas RZ/G3S RTC Claudiu
2024-06-14  7:53   ` Biju Das
2024-06-14  8:16     ` claudiu beznea
2024-06-14  8:22       ` Biju Das
2024-06-15 12:16         ` Conor Dooley
2024-06-15 12:20   ` Conor Dooley
2024-06-17  7:19     ` claudiu beznea
2024-06-17 15:17       ` Conor Dooley
2024-06-16  7:40   ` Krzysztof Kozlowski
2024-06-17  7:24     ` claudiu beznea
2024-06-14  7:19 ` [PATCH 06/12] rtc: renesas-rtca3: Add driver for RTCA-3 available on Renesas RZ/G3S SoC Claudiu
2024-06-14  7:51   ` Biju Das
2024-06-14  9:21   ` Alexandre Belloni
2024-06-14 11:06     ` claudiu beznea
2024-06-17  7:25       ` Alexandre Belloni
2024-06-17  7:31         ` claudiu beznea [this message]
2024-07-16  8:01           ` claudiu beznea
2024-06-14  7:19 ` [PATCH 07/12] arm64: dts: renesas: r9a08g045: Add VBATTB node Claudiu
2024-06-14  7:19 ` [PATCH 08/12] arm64: dts: renesas: r9a08g045: Add RTC node Claudiu
2024-06-14  7:19 ` [PATCH 09/12] arm64: dts: renesas: rzg3s-smarc-som: Enable VBATTB clock Claudiu
2024-06-14  7:19 ` [PATCH 10/12] arm64: dts: renesas: rzg3s-smarc-som: Enable RTC Claudiu
2024-06-14  7:19 ` [PATCH 11/12] arm64: defconfig: Enable VBATTB clock flag Claudiu
2024-06-14  7:19 ` [PATCH 12/12] arm64: defconfig: Enable Renesas RTCA-3 flag Claudiu

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=f3584295-b396-455a-b988-099443b58dba@tuxon.dev \
    --to=claudiu.beznea@tuxon.dev \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea.uj@bp.renesas.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=krzk+dt@kernel.org \
    --cc=lee@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rtc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=mturquette@baylibre.com \
    --cc=robh@kernel.org \
    --cc=sboyd@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).