| .. | .. |
|---|
| 1 | | -/* rtc-da9063.c - Real time clock device driver for DA9063 |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0+ |
|---|
| 2 | +/* |
|---|
| 3 | + * Real time clock device driver for DA9063 |
|---|
| 2 | 4 | * Copyright (C) 2013-2015 Dialog Semiconductor Ltd. |
|---|
| 3 | | - * |
|---|
| 4 | | - * This program is free software; you can redistribute it and/or |
|---|
| 5 | | - * modify it under the terms of the GNU General Public License |
|---|
| 6 | | - * as published by the Free Software Foundation; either version 2 |
|---|
| 7 | | - * of the License, or (at your option) any later version. |
|---|
| 8 | | - * |
|---|
| 9 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 10 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 11 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 12 | | - * GNU General Public License for more details. |
|---|
| 13 | 5 | */ |
|---|
| 14 | 6 | |
|---|
| 15 | 7 | #include <linux/delay.h> |
|---|
| .. | .. |
|---|
| 247 | 239 | |
|---|
| 248 | 240 | da9063_data_to_tm(data, tm, rtc); |
|---|
| 249 | 241 | |
|---|
| 250 | | - rtc_tm_to_time(tm, &tm_secs); |
|---|
| 251 | | - rtc_tm_to_time(&rtc->alarm_time, &al_secs); |
|---|
| 242 | + tm_secs = rtc_tm_to_time64(tm); |
|---|
| 243 | + al_secs = rtc_tm_to_time64(&rtc->alarm_time); |
|---|
| 252 | 244 | |
|---|
| 253 | 245 | /* handle the rtc synchronisation delay */ |
|---|
| 254 | 246 | if (rtc->rtc_sync == true && al_secs - tm_secs == 1) |
|---|
| .. | .. |
|---|
| 472 | 464 | |
|---|
| 473 | 465 | platform_set_drvdata(pdev, rtc); |
|---|
| 474 | 466 | |
|---|
| 475 | | - rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, DA9063_DRVNAME_RTC, |
|---|
| 476 | | - &da9063_rtc_ops, THIS_MODULE); |
|---|
| 467 | + rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev); |
|---|
| 477 | 468 | if (IS_ERR(rtc->rtc_dev)) |
|---|
| 478 | 469 | return PTR_ERR(rtc->rtc_dev); |
|---|
| 470 | + |
|---|
| 471 | + rtc->rtc_dev->ops = &da9063_rtc_ops; |
|---|
| 472 | + rtc->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000; |
|---|
| 473 | + rtc->rtc_dev->range_max = RTC_TIMESTAMP_END_2063; |
|---|
| 479 | 474 | |
|---|
| 480 | 475 | da9063_data_to_tm(data, &rtc->alarm_time, rtc); |
|---|
| 481 | 476 | rtc->rtc_sync = false; |
|---|
| .. | .. |
|---|
| 488 | 483 | rtc->rtc_dev->uie_unsupported = 1; |
|---|
| 489 | 484 | |
|---|
| 490 | 485 | irq_alarm = platform_get_irq_byname(pdev, "ALARM"); |
|---|
| 486 | + if (irq_alarm < 0) |
|---|
| 487 | + return irq_alarm; |
|---|
| 488 | + |
|---|
| 491 | 489 | ret = devm_request_threaded_irq(&pdev->dev, irq_alarm, NULL, |
|---|
| 492 | 490 | da9063_alarm_event, |
|---|
| 493 | 491 | IRQF_TRIGGER_LOW | IRQF_ONESHOT, |
|---|
| .. | .. |
|---|
| 496 | 494 | dev_err(&pdev->dev, "Failed to request ALARM IRQ %d: %d\n", |
|---|
| 497 | 495 | irq_alarm, ret); |
|---|
| 498 | 496 | |
|---|
| 499 | | - return ret; |
|---|
| 497 | + return rtc_register_device(rtc->rtc_dev); |
|---|
| 500 | 498 | } |
|---|
| 501 | 499 | |
|---|
| 502 | 500 | static struct platform_driver da9063_rtc_driver = { |
|---|