Re: [PATCH 3/7] rtc: rzn1: Add new RTC driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Alex,

alexandre.belloni@xxxxxxxxxxx wrote on Wed, 13 Apr 2022 17:48:45 +0200:

> Hi Miquèl,
> 
> On 13/04/2022 17:23:27+0200, Miquel Raynal wrote:
> > > > +static int rzn1_rtc_probe(struct platform_device *pdev)
> > > > +{
> > > > +	struct rzn1_rtc *rtc;
> > > > +	int ret;
> > > > +
> > > > +	rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL);
> > > > +	if (!rtc)
> > > > +		return -ENOMEM;
> > > > +
> > > > +	platform_set_drvdata(pdev, rtc);
> > > > +
> > > > +	rtc->clk = devm_clk_get(&pdev->dev, "hclk");
> > > > +	if (IS_ERR(rtc->clk))
> > > > +		return dev_err_probe(&pdev->dev, PTR_ERR(rtc->clk), "Missing hclk\n");
> > > > +
> > > > +	rtc->base = devm_platform_ioremap_resource(pdev, 0);
> > > > +	if (IS_ERR(rtc->base))
> > > > +		return dev_err_probe(&pdev->dev, PTR_ERR(rtc->base), "Missing reg\n");
> > > > +
> > > > +	rtc->rtcdev = devm_rtc_allocate_device(&pdev->dev);
> > > > +	if (IS_ERR(rtc->rtcdev))
> > > > +		return PTR_ERR(rtc);
> > > > +
> > > > +	rtc->rtcdev->range_max = 3178591199UL; /* 100 years */    
> > > 
> > > I'm not sure how you came to this value, this is 2070-09-22T05:59:59.
> > > I'm pretty sure the RTC will not fail at that time. Also, the comment
> > > seems fishy.  
> > 
> > The RTC itself as no "starting point", but just a counter that can
> > count up to 100. So the max range is start-year + 100 years. But at
> > this point I don't yet have access to the start-year value. What's
> > your advise?  
> 
> The question is why is this limited to 100 years? My guess is that it
> doesn't handle leap years properly if this is the case, there is only
> one range that works, this is 2000-01-01 to 2099-12-31 like many other
> RTCs.

I don't know the real reason, actually there is just written that the
"year" register counts up from 00 to 99 (in bcd).

> You can run rtc-range from rtc-tools after removing range_max to find
> out.

Here is the result. It fails at 2069, which I believe means "100 years"
from 1970. So what do you conclude with this? Shall I use
rtc_time64_to_tm(2069-12-31 23:59:59) as the range_max value?

# rtc-range 

Testing 2000-02-28 23:59:59.
OK

Testing 2038-01-19 03:14:07.
OK

Testing 2069-12-31 23:59:59.
KO RTC_RD_TIME returned 22 (line 124)

Thanks,
Miquèl




[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux