Message ID | 20180604141528.15635-3-alexandre.belloni@bootlin.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Mon, 4 Jun 2018, Alexandre Belloni wrote: > The current range handling is highly suspicious. Anyway, let the core > handle it. > The RTC has a 32 bit counter on top of days + hh:mm:ss registers. > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> > --- > drivers/rtc/rtc-ftrtc010.c | 13 ++++++++++--- > 1 file changed, 10 insertions(+), 3 deletions(-) > > diff --git a/drivers/rtc/rtc-ftrtc010.c b/drivers/rtc/rtc-ftrtc010.c > index 2cdc78ffeb17..61f798c6101f 100644 > --- a/drivers/rtc/rtc-ftrtc010.c > +++ b/drivers/rtc/rtc-ftrtc010.c > @@ -95,9 +95,6 @@ static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm) > u32 sec, min, hour, day, offset; > timeu64_t time; > > - if (tm->tm_year >= 2148) /* EPOCH Year + 179 */ > - return -EINVAL; > - > time = rtc_tm_to_time64(tm); > > sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); > @@ -120,6 +117,7 @@ static const struct rtc_class_ops ftrtc010_rtc_ops = { > > static int ftrtc010_rtc_probe(struct platform_device *pdev) > { > + u32 days, hour, min, sec; > struct ftrtc010_rtc *rtc; > struct device *dev = &pdev->dev; > struct resource *res; > @@ -172,6 +170,15 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev) > > rtc->rtc_dev->ops = &ftrtc010_rtc_ops; > > + sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); > + min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE); > + hour = readl(rtc->rtc_base + FTRTC010_RTC_HOUR); > + days = readl(rtc->rtc_base + FTRTC010_RTC_DAYS); > + > + rtc->rtc_dev->range_min = (u64)days * 86400 + hour * 3600 + > + min * 60 + sec; > + rtc->rtc_dev->range_max = U32_MAX + rtc->rtc_dev->range_min; > + > ret = devm_request_irq(dev, rtc->rtc_irq, ftrtc010_rtc_interrupt, > IRQF_SHARED, pdev->name, dev); > if (unlikely(ret)) > -- > 2.17.1 > > Acked-by: Hans Ulli Kroll <ulli.kroll@googlemail.com>
On Mon, Jun 4, 2018 at 4:15 PM, Alexandre Belloni <alexandre.belloni@bootlin.com> wrote: > The current range handling is highly suspicious. Anyway, let the core > handle it. Hmmm. I have datasheets, do you need some input about the hardware? Something I should patch? > The RTC has a 32 bit counter on top of days + hh:mm:ss registers. > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Linus Walleij <linus.walleij@linaro.org> Yours, Linus Walleij
On 13/06/2018 11:10:35+0200, Linus Walleij wrote: > On Mon, Jun 4, 2018 at 4:15 PM, Alexandre Belloni > <alexandre.belloni@bootlin.com> wrote: > > The current range handling is highly suspicious. Anyway, let the core > > handle it. > > Hmmm. I have datasheets, do you need some input about the hardware? > Something I should patch? > Nothing to do as you seemed to confirm what I did was OK. I could find why it was set to 2148 in the first place. Maybe it correspond to the default days, hours minutes, second values on the SoC. > > The RTC has a 32 bit counter on top of days + hh:mm:ss registers. > > > > Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> > > Acked-by: Linus Walleij <linus.walleij@linaro.org> > > Yours, > Linus Walleij
diff --git a/drivers/rtc/rtc-ftrtc010.c b/drivers/rtc/rtc-ftrtc010.c index 2cdc78ffeb17..61f798c6101f 100644 --- a/drivers/rtc/rtc-ftrtc010.c +++ b/drivers/rtc/rtc-ftrtc010.c @@ -95,9 +95,6 @@ static int ftrtc010_rtc_set_time(struct device *dev, struct rtc_time *tm) u32 sec, min, hour, day, offset; timeu64_t time; - if (tm->tm_year >= 2148) /* EPOCH Year + 179 */ - return -EINVAL; - time = rtc_tm_to_time64(tm); sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); @@ -120,6 +117,7 @@ static const struct rtc_class_ops ftrtc010_rtc_ops = { static int ftrtc010_rtc_probe(struct platform_device *pdev) { + u32 days, hour, min, sec; struct ftrtc010_rtc *rtc; struct device *dev = &pdev->dev; struct resource *res; @@ -172,6 +170,15 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev) rtc->rtc_dev->ops = &ftrtc010_rtc_ops; + sec = readl(rtc->rtc_base + FTRTC010_RTC_SECOND); + min = readl(rtc->rtc_base + FTRTC010_RTC_MINUTE); + hour = readl(rtc->rtc_base + FTRTC010_RTC_HOUR); + days = readl(rtc->rtc_base + FTRTC010_RTC_DAYS); + + rtc->rtc_dev->range_min = (u64)days * 86400 + hour * 3600 + + min * 60 + sec; + rtc->rtc_dev->range_max = U32_MAX + rtc->rtc_dev->range_min; + ret = devm_request_irq(dev, rtc->rtc_irq, ftrtc010_rtc_interrupt, IRQF_SHARED, pdev->name, dev); if (unlikely(ret))
The current range handling is highly suspicious. Anyway, let the core handle it. The RTC has a 32 bit counter on top of days + hh:mm:ss registers. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> --- drivers/rtc/rtc-ftrtc010.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-)