Commit c145e5f4 authored by Alexandre Belloni's avatar Alexandre Belloni

rtc: pic32: let the core handle range

Let the core handle the RTC range instead of open coding it.
Signed-off-by: default avatarAlexandre Belloni <alexandre.belloni@bootlin.com>
parent 6515e23b
...@@ -180,22 +180,16 @@ static int pic32_rtc_settime(struct device *dev, struct rtc_time *tm) ...@@ -180,22 +180,16 @@ static int pic32_rtc_settime(struct device *dev, struct rtc_time *tm)
{ {
struct pic32_rtc_dev *pdata = dev_get_drvdata(dev); struct pic32_rtc_dev *pdata = dev_get_drvdata(dev);
void __iomem *base = pdata->reg_base; void __iomem *base = pdata->reg_base;
int year = tm->tm_year - 100;
dev_dbg(dev, "set time %ptR\n", tm); dev_dbg(dev, "set time %ptR\n", tm);
if (year < 0 || year >= 100) {
dev_err(dev, "rtc only supports 100 years\n");
return -EINVAL;
}
clk_enable(pdata->clk); clk_enable(pdata->clk);
writeb(bin2bcd(tm->tm_sec), base + PIC32_RTCSEC); writeb(bin2bcd(tm->tm_sec), base + PIC32_RTCSEC);
writeb(bin2bcd(tm->tm_min), base + PIC32_RTCMIN); writeb(bin2bcd(tm->tm_min), base + PIC32_RTCMIN);
writeb(bin2bcd(tm->tm_hour), base + PIC32_RTCHOUR); writeb(bin2bcd(tm->tm_hour), base + PIC32_RTCHOUR);
writeb(bin2bcd(tm->tm_mday), base + PIC32_RTCDAY); writeb(bin2bcd(tm->tm_mday), base + PIC32_RTCDAY);
writeb(bin2bcd(tm->tm_mon + 1), base + PIC32_RTCMON); writeb(bin2bcd(tm->tm_mon + 1), base + PIC32_RTCMON);
writeb(bin2bcd(year), base + PIC32_RTCYEAR); writeb(bin2bcd(tm->tm_year - 100), base + PIC32_RTCYEAR);
clk_disable(pdata->clk); clk_disable(pdata->clk);
return 0; return 0;
...@@ -353,6 +347,8 @@ static int pic32_rtc_probe(struct platform_device *pdev) ...@@ -353,6 +347,8 @@ static int pic32_rtc_probe(struct platform_device *pdev)
return PTR_ERR(pdata->rtc); return PTR_ERR(pdata->rtc);
pdata->rtc->ops = &pic32_rtcops; pdata->rtc->ops = &pic32_rtcops;
pdata->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000;
pdata->rtc->range_max = RTC_TIMESTAMP_END_2099;
ret = rtc_register_device(pdata->rtc); ret = rtc_register_device(pdata->rtc);
if (ret) if (ret)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment