.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Motorola CPCAP PMIC RTC driver |
---|
3 | 4 | * |
---|
.. | .. |
---|
12 | 13 | * - remove custom "secure clock daemon" helpers |
---|
13 | 14 | * |
---|
14 | 15 | * Copyright (C) 2017 Sebastian Reichel <sre@kernel.org> |
---|
15 | | - * |
---|
16 | | - * This program is free software; you can redistribute it and/or modify |
---|
17 | | - * it under the terms of the GNU General Public License version 2 as |
---|
18 | | - * published by the Free Software Foundation. |
---|
19 | | - * |
---|
20 | | - * This program is distributed in the hope that it will be useful, |
---|
21 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
22 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
23 | | - * GNU General Public License for more details. |
---|
24 | 16 | */ |
---|
25 | 17 | #include <linux/kernel.h> |
---|
26 | 18 | #include <linux/module.h> |
---|
.. | .. |
---|
64 | 56 | tod = (cpcap->tod1 & TOD1_MASK) | ((cpcap->tod2 & TOD2_MASK) << 8); |
---|
65 | 57 | time = tod + ((cpcap->day & DAY_MASK) * SECS_PER_DAY); |
---|
66 | 58 | |
---|
67 | | - rtc_time_to_tm(time, rtc); |
---|
| 59 | + rtc_time64_to_tm(time, rtc); |
---|
68 | 60 | } |
---|
69 | 61 | |
---|
70 | 62 | static void rtc2cpcap_time(struct cpcap_time *cpcap, struct rtc_time *rtc) |
---|
71 | 63 | { |
---|
72 | 64 | unsigned long time; |
---|
73 | 65 | |
---|
74 | | - rtc_tm_to_time(rtc, &time); |
---|
| 66 | + time = rtc_tm_to_time64(rtc); |
---|
75 | 67 | |
---|
76 | 68 | cpcap->day = time / SECS_PER_DAY; |
---|
77 | 69 | time %= SECS_PER_DAY; |
---|
.. | .. |
---|
264 | 256 | return -ENODEV; |
---|
265 | 257 | |
---|
266 | 258 | platform_set_drvdata(pdev, rtc); |
---|
267 | | - rtc->rtc_dev = devm_rtc_device_register(dev, "cpcap_rtc", |
---|
268 | | - &cpcap_rtc_ops, THIS_MODULE); |
---|
269 | | - |
---|
| 259 | + rtc->rtc_dev = devm_rtc_allocate_device(dev); |
---|
270 | 260 | if (IS_ERR(rtc->rtc_dev)) |
---|
271 | 261 | return PTR_ERR(rtc->rtc_dev); |
---|
| 262 | + |
---|
| 263 | + rtc->rtc_dev->ops = &cpcap_rtc_ops; |
---|
| 264 | + rtc->rtc_dev->range_max = (timeu64_t) (DAY_MASK + 1) * SECS_PER_DAY - 1; |
---|
272 | 265 | |
---|
273 | 266 | err = cpcap_get_vendor(dev, rtc->regmap, &rtc->vendor); |
---|
274 | 267 | if (err) |
---|
.. | .. |
---|
306 | 299 | /* ignore error and continue without wakeup support */ |
---|
307 | 300 | } |
---|
308 | 301 | |
---|
309 | | - return 0; |
---|
| 302 | + return rtc_register_device(rtc->rtc_dev); |
---|
310 | 303 | } |
---|
311 | 304 | |
---|
312 | 305 | static const struct of_device_id cpcap_rtc_of_match[] = { |
---|