.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0 |
---|
1 | 2 | /* |
---|
2 | 3 | * pcap rtc code for Motorola EZX phones |
---|
3 | 4 | * |
---|
.. | .. |
---|
5 | 6 | * Copyright (c) 2009 Daniel Ribeiro <drwyrm@gmail.com> |
---|
6 | 7 | * |
---|
7 | 8 | * Based on Motorola's rtc.c Copyright (c) 2003-2005 Motorola |
---|
8 | | - * |
---|
9 | | - * This program is free software; you can redistribute it and/or modify |
---|
10 | | - * it under the terms of the GNU General Public License version 2 as |
---|
11 | | - * published by the Free Software Foundation. |
---|
12 | | - * |
---|
13 | 9 | */ |
---|
14 | 10 | |
---|
15 | 11 | #include <linux/kernel.h> |
---|
.. | .. |
---|
55 | 51 | ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAYA, &days); |
---|
56 | 52 | secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY; |
---|
57 | 53 | |
---|
58 | | - rtc_time_to_tm(secs, tm); |
---|
| 54 | + rtc_time64_to_tm(secs, tm); |
---|
59 | 55 | |
---|
60 | 56 | return 0; |
---|
61 | 57 | } |
---|
.. | .. |
---|
63 | 59 | static int pcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
---|
64 | 60 | { |
---|
65 | 61 | struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev); |
---|
66 | | - struct rtc_time *tm = &alrm->time; |
---|
67 | | - unsigned long secs; |
---|
| 62 | + unsigned long secs = rtc_tm_to_time64(&alrm->time); |
---|
68 | 63 | u32 tod, days; |
---|
69 | | - |
---|
70 | | - rtc_tm_to_time(tm, &secs); |
---|
71 | 64 | |
---|
72 | 65 | tod = secs % SEC_PER_DAY; |
---|
73 | 66 | ezx_pcap_write(pcap_rtc->pcap, PCAP_REG_RTC_TODA, tod); |
---|
.. | .. |
---|
90 | 83 | ezx_pcap_read(pcap_rtc->pcap, PCAP_REG_RTC_DAY, &days); |
---|
91 | 84 | secs += (days & PCAP_RTC_DAY_MASK) * SEC_PER_DAY; |
---|
92 | 85 | |
---|
93 | | - rtc_time_to_tm(secs, tm); |
---|
| 86 | + rtc_time64_to_tm(secs, tm); |
---|
94 | 87 | |
---|
95 | 88 | return 0; |
---|
96 | 89 | } |
---|
97 | 90 | |
---|
98 | | -static int pcap_rtc_set_mmss(struct device *dev, unsigned long secs) |
---|
| 91 | +static int pcap_rtc_set_time(struct device *dev, struct rtc_time *tm) |
---|
99 | 92 | { |
---|
100 | 93 | struct pcap_rtc *pcap_rtc = dev_get_drvdata(dev); |
---|
| 94 | + unsigned long secs = rtc_tm_to_time64(tm); |
---|
101 | 95 | u32 tod, days; |
---|
102 | 96 | |
---|
103 | 97 | tod = secs % SEC_PER_DAY; |
---|
.. | .. |
---|
128 | 122 | |
---|
129 | 123 | static const struct rtc_class_ops pcap_rtc_ops = { |
---|
130 | 124 | .read_time = pcap_rtc_read_time, |
---|
| 125 | + .set_time = pcap_rtc_set_time, |
---|
131 | 126 | .read_alarm = pcap_rtc_read_alarm, |
---|
132 | 127 | .set_alarm = pcap_rtc_set_alarm, |
---|
133 | | - .set_mmss = pcap_rtc_set_mmss, |
---|
134 | 128 | .alarm_irq_enable = pcap_rtc_alarm_irq_enable, |
---|
135 | 129 | }; |
---|
136 | 130 | |
---|
.. | .. |
---|
149 | 143 | |
---|
150 | 144 | platform_set_drvdata(pdev, pcap_rtc); |
---|
151 | 145 | |
---|
152 | | - pcap_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pcap", |
---|
153 | | - &pcap_rtc_ops, THIS_MODULE); |
---|
| 146 | + pcap_rtc->rtc = devm_rtc_allocate_device(&pdev->dev); |
---|
154 | 147 | if (IS_ERR(pcap_rtc->rtc)) |
---|
155 | 148 | return PTR_ERR(pcap_rtc->rtc); |
---|
| 149 | + |
---|
| 150 | + pcap_rtc->rtc->ops = &pcap_rtc_ops; |
---|
| 151 | + pcap_rtc->rtc->range_max = (1 << 14) * 86400ULL - 1; |
---|
156 | 152 | |
---|
157 | 153 | timer_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_1HZ); |
---|
158 | 154 | alarm_irq = pcap_to_irq(pcap_rtc->pcap, PCAP_IRQ_TODA); |
---|
.. | .. |
---|
167 | 163 | if (err) |
---|
168 | 164 | return err; |
---|
169 | 165 | |
---|
170 | | - return 0; |
---|
| 166 | + return rtc_register_device(pcap_rtc->rtc); |
---|
171 | 167 | } |
---|
172 | 168 | |
---|
173 | 169 | static int __exit pcap_rtc_remove(struct platform_device *pdev) |
---|