diff options
Diffstat (limited to 'drivers/rtc/rtc-omap.c')
-rw-r--r-- | drivers/rtc/rtc-omap.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index bbff0e2deb84..32994b0dd139 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -1,3 +1,4 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0+ | ||
1 | /* | 2 | /* |
2 | * TI OMAP Real Time Clock interface for Linux | 3 | * TI OMAP Real Time Clock interface for Linux |
3 | * | 4 | * |
@@ -6,11 +7,6 @@ | |||
6 | * | 7 | * |
7 | * Copyright (C) 2006 David Brownell (new RTC framework) | 8 | * Copyright (C) 2006 David Brownell (new RTC framework) |
8 | * Copyright (C) 2014 Johan Hovold <johan@kernel.org> | 9 | * Copyright (C) 2014 Johan Hovold <johan@kernel.org> |
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | ||
11 | * modify it under the terms of the GNU General Public License | ||
12 | * as published by the Free Software Foundation; either version | ||
13 | * 2 of the License, or (at your option) any later version. | ||
14 | */ | 10 | */ |
15 | 11 | ||
16 | #include <dt-bindings/gpio/gpio.h> | 12 | #include <dt-bindings/gpio/gpio.h> |
@@ -271,7 +267,7 @@ static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
271 | } | 267 | } |
272 | 268 | ||
273 | /* this hardware doesn't support "don't care" alarm fields */ | 269 | /* this hardware doesn't support "don't care" alarm fields */ |
274 | static int tm2bcd(struct rtc_time *tm) | 270 | static void tm2bcd(struct rtc_time *tm) |
275 | { | 271 | { |
276 | tm->tm_sec = bin2bcd(tm->tm_sec); | 272 | tm->tm_sec = bin2bcd(tm->tm_sec); |
277 | tm->tm_min = bin2bcd(tm->tm_min); | 273 | tm->tm_min = bin2bcd(tm->tm_min); |
@@ -279,13 +275,7 @@ static int tm2bcd(struct rtc_time *tm) | |||
279 | tm->tm_mday = bin2bcd(tm->tm_mday); | 275 | tm->tm_mday = bin2bcd(tm->tm_mday); |
280 | 276 | ||
281 | tm->tm_mon = bin2bcd(tm->tm_mon + 1); | 277 | tm->tm_mon = bin2bcd(tm->tm_mon + 1); |
282 | |||
283 | /* epoch == 1900 */ | ||
284 | if (tm->tm_year < 100 || tm->tm_year > 199) | ||
285 | return -EINVAL; | ||
286 | tm->tm_year = bin2bcd(tm->tm_year - 100); | 278 | tm->tm_year = bin2bcd(tm->tm_year - 100); |
287 | |||
288 | return 0; | ||
289 | } | 279 | } |
290 | 280 | ||
291 | static void bcd2tm(struct rtc_time *tm) | 281 | static void bcd2tm(struct rtc_time *tm) |
@@ -328,8 +318,7 @@ static int omap_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
328 | { | 318 | { |
329 | struct omap_rtc *rtc = dev_get_drvdata(dev); | 319 | struct omap_rtc *rtc = dev_get_drvdata(dev); |
330 | 320 | ||
331 | if (tm2bcd(tm) < 0) | 321 | tm2bcd(tm); |
332 | return -EINVAL; | ||
333 | 322 | ||
334 | local_irq_disable(); | 323 | local_irq_disable(); |
335 | rtc_wait_not_busy(rtc); | 324 | rtc_wait_not_busy(rtc); |
@@ -378,8 +367,7 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
378 | struct omap_rtc *rtc = dev_get_drvdata(dev); | 367 | struct omap_rtc *rtc = dev_get_drvdata(dev); |
379 | u8 reg, irqwake_reg = 0; | 368 | u8 reg, irqwake_reg = 0; |
380 | 369 | ||
381 | if (tm2bcd(&alm->time) < 0) | 370 | tm2bcd(&alm->time); |
382 | return -EINVAL; | ||
383 | 371 | ||
384 | local_irq_disable(); | 372 | local_irq_disable(); |
385 | rtc_wait_not_busy(rtc); | 373 | rtc_wait_not_busy(rtc); |
@@ -441,14 +429,10 @@ again: | |||
441 | omap_rtc_read_time_raw(rtc, &tm); | 429 | omap_rtc_read_time_raw(rtc, &tm); |
442 | seconds = tm.tm_sec; | 430 | seconds = tm.tm_sec; |
443 | bcd2tm(&tm); | 431 | bcd2tm(&tm); |
444 | rtc_tm_to_time(&tm, &now); | 432 | now = rtc_tm_to_time64(&tm); |
445 | rtc_time_to_tm(now + 1, &tm); | 433 | rtc_time64_to_tm(now + 1, &tm); |
446 | 434 | ||
447 | if (tm2bcd(&tm) < 0) { | 435 | tm2bcd(&tm); |
448 | dev_err(&rtc->rtc->dev, "power off failed\n"); | ||
449 | rtc->type->lock(rtc); | ||
450 | return; | ||
451 | } | ||
452 | 436 | ||
453 | rtc_wait_not_busy(rtc); | 437 | rtc_wait_not_busy(rtc); |
454 | 438 | ||
@@ -845,6 +829,8 @@ static int omap_rtc_probe(struct platform_device *pdev) | |||
845 | } | 829 | } |
846 | 830 | ||
847 | rtc->rtc->ops = &omap_rtc_ops; | 831 | rtc->rtc->ops = &omap_rtc_ops; |
832 | rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; | ||
833 | rtc->rtc->range_max = RTC_TIMESTAMP_END_2099; | ||
848 | omap_rtc_nvmem_config.priv = rtc; | 834 | omap_rtc_nvmem_config.priv = rtc; |
849 | 835 | ||
850 | /* handle periodic and alarm irqs */ | 836 | /* handle periodic and alarm irqs */ |