.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * rtc-tps65910.c -- TPS65910 Real Time Clock interface |
---|
3 | 4 | * |
---|
.. | .. |
---|
7 | 8 | * Based on original TI driver rtc-twl.c |
---|
8 | 9 | * Copyright (C) 2007 MontaVista Software, Inc |
---|
9 | 10 | * Author: Alexandre Rusev <source@mvista.com> |
---|
10 | | - * |
---|
11 | | - * This program is free software; you can redistribute it and/or |
---|
12 | | - * modify it under the terms of the GNU General Public License |
---|
13 | | - * as published by the Free Software Foundation; either version |
---|
14 | | - * 2 of the License, or (at your option) any later version. |
---|
15 | 11 | */ |
---|
16 | 12 | |
---|
17 | 13 | #include <linux/kernel.h> |
---|
.. | .. |
---|
147 | 143 | struct tps65910 *tps = dev_get_drvdata(dev->parent); |
---|
148 | 144 | int ret; |
---|
149 | 145 | |
---|
150 | | - ret = regmap_bulk_read(tps->regmap, TPS65910_SECONDS, alarm_data, |
---|
| 146 | + ret = regmap_bulk_read(tps->regmap, TPS65910_ALARM_SECONDS, alarm_data, |
---|
151 | 147 | NUM_TIME_REGS); |
---|
152 | 148 | if (ret < 0) { |
---|
153 | 149 | dev_err(dev, "rtc_read_alarm error %d\n", ret); |
---|
.. | .. |
---|
365 | 361 | .set_offset = tps65910_set_offset, |
---|
366 | 362 | }; |
---|
367 | 363 | |
---|
| 364 | +static const struct rtc_class_ops tps65910_rtc_ops_noirq = { |
---|
| 365 | + .read_time = tps65910_rtc_read_time, |
---|
| 366 | + .set_time = tps65910_rtc_set_time, |
---|
| 367 | + .read_offset = tps65910_read_offset, |
---|
| 368 | + .set_offset = tps65910_set_offset, |
---|
| 369 | +}; |
---|
| 370 | + |
---|
368 | 371 | static int tps65910_rtc_probe(struct platform_device *pdev) |
---|
369 | 372 | { |
---|
370 | 373 | struct tps65910 *tps65910 = NULL; |
---|
.. | .. |
---|
418 | 421 | ret = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
---|
419 | 422 | tps65910_rtc_interrupt, IRQF_TRIGGER_LOW, |
---|
420 | 423 | dev_name(&pdev->dev), &pdev->dev); |
---|
421 | | - if (ret < 0) { |
---|
422 | | - dev_err(&pdev->dev, "IRQ is not free.\n"); |
---|
423 | | - return ret; |
---|
424 | | - } |
---|
425 | | - tps_rtc->irq = irq; |
---|
426 | | - device_set_wakeup_capable(&pdev->dev, 1); |
---|
| 424 | + if (ret < 0) |
---|
| 425 | + irq = -1; |
---|
427 | 426 | |
---|
428 | | - tps_rtc->rtc->ops = &tps65910_rtc_ops; |
---|
| 427 | + tps_rtc->irq = irq; |
---|
| 428 | + if (irq != -1) { |
---|
| 429 | + device_set_wakeup_capable(&pdev->dev, 1); |
---|
| 430 | + tps_rtc->rtc->ops = &tps65910_rtc_ops; |
---|
| 431 | + } else |
---|
| 432 | + tps_rtc->rtc->ops = &tps65910_rtc_ops_noirq; |
---|
| 433 | + |
---|
429 | 434 | tps_rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; |
---|
430 | 435 | tps_rtc->rtc->range_max = RTC_TIMESTAMP_END_2099; |
---|
431 | 436 | |
---|
432 | | - ret = rtc_register_device(tps_rtc->rtc); |
---|
433 | | - if (ret) { |
---|
434 | | - dev_err(&pdev->dev, "RTC device register: err %d\n", ret); |
---|
435 | | - return ret; |
---|
436 | | - } |
---|
437 | | - |
---|
438 | | - return 0; |
---|
| 437 | + return rtc_register_device(tps_rtc->rtc); |
---|
439 | 438 | } |
---|
440 | 439 | |
---|
441 | 440 | #ifdef CONFIG_PM_SLEEP |
---|