| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * RTC driver for the Armada 38x Marvell SoCs |
|---|
| 3 | 4 | * |
|---|
| 4 | 5 | * Copyright (C) 2015 Marvell |
|---|
| 5 | 6 | * |
|---|
| 6 | 7 | * Gregory Clement <gregory.clement@free-electrons.com> |
|---|
| 7 | | - * |
|---|
| 8 | | - * This program is free software; you can redistribute it and/or |
|---|
| 9 | | - * modify it under the terms of the GNU General Public License as |
|---|
| 10 | | - * published by the Free Software Foundation; either version 2 of the |
|---|
| 11 | | - * License, or (at your option) any later version. |
|---|
| 12 | | - * |
|---|
| 13 | 8 | */ |
|---|
| 14 | 9 | |
|---|
| 15 | 10 | #include <linux/delay.h> |
|---|
| .. | .. |
|---|
| 79 | 74 | int irq; |
|---|
| 80 | 75 | bool initialized; |
|---|
| 81 | 76 | struct value_to_freq *val_to_freq; |
|---|
| 82 | | - struct armada38x_rtc_data *data; |
|---|
| 77 | + const struct armada38x_rtc_data *data; |
|---|
| 83 | 78 | }; |
|---|
| 84 | 79 | |
|---|
| 85 | 80 | #define ALARM1 0 |
|---|
| .. | .. |
|---|
| 224 | 219 | time = rtc->data->read_rtc_reg(rtc, RTC_TIME); |
|---|
| 225 | 220 | spin_unlock_irqrestore(&rtc->lock, flags); |
|---|
| 226 | 221 | |
|---|
| 227 | | - rtc_time_to_tm(time, tm); |
|---|
| 222 | + rtc_time64_to_tm(time, tm); |
|---|
| 228 | 223 | |
|---|
| 229 | 224 | return 0; |
|---|
| 230 | 225 | } |
|---|
| .. | .. |
|---|
| 249 | 244 | static int armada38x_rtc_set_time(struct device *dev, struct rtc_time *tm) |
|---|
| 250 | 245 | { |
|---|
| 251 | 246 | struct armada38x_rtc *rtc = dev_get_drvdata(dev); |
|---|
| 252 | | - int ret = 0; |
|---|
| 253 | 247 | unsigned long time, flags; |
|---|
| 254 | 248 | |
|---|
| 255 | | - ret = rtc_tm_to_time(tm, &time); |
|---|
| 256 | | - |
|---|
| 257 | | - if (ret) |
|---|
| 258 | | - goto out; |
|---|
| 249 | + time = rtc_tm_to_time64(tm); |
|---|
| 259 | 250 | |
|---|
| 260 | 251 | if (!rtc->initialized) |
|---|
| 261 | 252 | armada38x_rtc_reset(rtc); |
|---|
| .. | .. |
|---|
| 264 | 255 | rtc_delayed_write(time, rtc, RTC_TIME); |
|---|
| 265 | 256 | spin_unlock_irqrestore(&rtc->lock, flags); |
|---|
| 266 | 257 | |
|---|
| 267 | | -out: |
|---|
| 268 | | - return ret; |
|---|
| 258 | + return 0; |
|---|
| 269 | 259 | } |
|---|
| 270 | 260 | |
|---|
| 271 | 261 | static int armada38x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
|---|
| .. | .. |
|---|
| 284 | 274 | spin_unlock_irqrestore(&rtc->lock, flags); |
|---|
| 285 | 275 | |
|---|
| 286 | 276 | alrm->enabled = val ? 1 : 0; |
|---|
| 287 | | - rtc_time_to_tm(time, &alrm->time); |
|---|
| 277 | + rtc_time64_to_tm(time, &alrm->time); |
|---|
| 288 | 278 | |
|---|
| 289 | 279 | return 0; |
|---|
| 290 | 280 | } |
|---|
| .. | .. |
|---|
| 295 | 285 | u32 reg = ALARM_REG(RTC_ALARM1, rtc->data->alarm); |
|---|
| 296 | 286 | u32 reg_irq = ALARM_REG(RTC_IRQ1_CONF, rtc->data->alarm); |
|---|
| 297 | 287 | unsigned long time, flags; |
|---|
| 298 | | - int ret = 0; |
|---|
| 299 | 288 | |
|---|
| 300 | | - ret = rtc_tm_to_time(&alrm->time, &time); |
|---|
| 301 | | - |
|---|
| 302 | | - if (ret) |
|---|
| 303 | | - goto out; |
|---|
| 289 | + time = rtc_tm_to_time64(&alrm->time); |
|---|
| 304 | 290 | |
|---|
| 305 | 291 | spin_lock_irqsave(&rtc->lock, flags); |
|---|
| 306 | 292 | |
|---|
| .. | .. |
|---|
| 313 | 299 | |
|---|
| 314 | 300 | spin_unlock_irqrestore(&rtc->lock, flags); |
|---|
| 315 | 301 | |
|---|
| 316 | | -out: |
|---|
| 317 | | - return ret; |
|---|
| 302 | + return 0; |
|---|
| 318 | 303 | } |
|---|
| 319 | 304 | |
|---|
| 320 | 305 | static int armada38x_rtc_alarm_irq_enable(struct device *dev, |
|---|
| .. | .. |
|---|
| 516 | 501 | { |
|---|
| 517 | 502 | struct resource *res; |
|---|
| 518 | 503 | struct armada38x_rtc *rtc; |
|---|
| 519 | | - const struct of_device_id *match; |
|---|
| 520 | | - int ret; |
|---|
| 521 | | - |
|---|
| 522 | | - match = of_match_device(armada38x_rtc_of_match_table, &pdev->dev); |
|---|
| 523 | | - if (!match) |
|---|
| 524 | | - return -ENODEV; |
|---|
| 525 | 504 | |
|---|
| 526 | 505 | rtc = devm_kzalloc(&pdev->dev, sizeof(struct armada38x_rtc), |
|---|
| 527 | 506 | GFP_KERNEL); |
|---|
| 528 | 507 | if (!rtc) |
|---|
| 529 | 508 | return -ENOMEM; |
|---|
| 509 | + |
|---|
| 510 | + rtc->data = of_device_get_match_data(&pdev->dev); |
|---|
| 530 | 511 | |
|---|
| 531 | 512 | rtc->val_to_freq = devm_kcalloc(&pdev->dev, SAMPLE_NR, |
|---|
| 532 | 513 | sizeof(struct value_to_freq), GFP_KERNEL); |
|---|
| .. | .. |
|---|
| 545 | 526 | return PTR_ERR(rtc->regs_soc); |
|---|
| 546 | 527 | |
|---|
| 547 | 528 | rtc->irq = platform_get_irq(pdev, 0); |
|---|
| 548 | | - |
|---|
| 549 | | - if (rtc->irq < 0) { |
|---|
| 550 | | - dev_err(&pdev->dev, "no irq\n"); |
|---|
| 529 | + if (rtc->irq < 0) |
|---|
| 551 | 530 | return rtc->irq; |
|---|
| 552 | | - } |
|---|
| 553 | 531 | |
|---|
| 554 | 532 | rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev); |
|---|
| 555 | 533 | if (IS_ERR(rtc->rtc_dev)) |
|---|
| .. | .. |
|---|
| 572 | 550 | */ |
|---|
| 573 | 551 | rtc->rtc_dev->ops = &armada38x_rtc_ops_noirq; |
|---|
| 574 | 552 | } |
|---|
| 575 | | - rtc->data = (struct armada38x_rtc_data *)match->data; |
|---|
| 576 | 553 | |
|---|
| 577 | 554 | /* Update RTC-MBUS bridge timing parameters */ |
|---|
| 578 | 555 | rtc->data->update_mbus_timing(rtc); |
|---|
| 579 | 556 | |
|---|
| 580 | | - ret = rtc_register_device(rtc->rtc_dev); |
|---|
| 581 | | - if (ret) |
|---|
| 582 | | - dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); |
|---|
| 557 | + rtc->rtc_dev->range_max = U32_MAX; |
|---|
| 583 | 558 | |
|---|
| 584 | | - return ret; |
|---|
| 559 | + return rtc_register_device(rtc->rtc_dev); |
|---|
| 585 | 560 | } |
|---|
| 586 | 561 | |
|---|
| 587 | 562 | #ifdef CONFIG_PM_SLEEP |
|---|