aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ab3100.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-ab3100.c')
-rw-r--r--drivers/rtc/rtc-ab3100.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/drivers/rtc/rtc-ab3100.c b/drivers/rtc/rtc-ab3100.c
index 1d0340fdb820..9b725c553058 100644
--- a/drivers/rtc/rtc-ab3100.c
+++ b/drivers/rtc/rtc-ab3100.c
@@ -43,21 +43,21 @@
43/* 43/*
44 * RTC clock functions and device struct declaration 44 * RTC clock functions and device struct declaration
45 */ 45 */
46static int ab3100_rtc_set_mmss(struct device *dev, unsigned long secs) 46static int ab3100_rtc_set_mmss(struct device *dev, time64_t secs)
47{ 47{
48 u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2, 48 u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2,
49 AB3100_TI3, AB3100_TI4, AB3100_TI5}; 49 AB3100_TI3, AB3100_TI4, AB3100_TI5};
50 unsigned char buf[6]; 50 unsigned char buf[6];
51 u64 fat_time = (u64) secs * AB3100_RTC_CLOCK_RATE * 2; 51 u64 hw_counter = secs * AB3100_RTC_CLOCK_RATE * 2;
52 int err = 0; 52 int err = 0;
53 int i; 53 int i;
54 54
55 buf[0] = (fat_time) & 0xFF; 55 buf[0] = (hw_counter) & 0xFF;
56 buf[1] = (fat_time >> 8) & 0xFF; 56 buf[1] = (hw_counter >> 8) & 0xFF;
57 buf[2] = (fat_time >> 16) & 0xFF; 57 buf[2] = (hw_counter >> 16) & 0xFF;
58 buf[3] = (fat_time >> 24) & 0xFF; 58 buf[3] = (hw_counter >> 24) & 0xFF;
59 buf[4] = (fat_time >> 32) & 0xFF; 59 buf[4] = (hw_counter >> 32) & 0xFF;
60 buf[5] = (fat_time >> 40) & 0xFF; 60 buf[5] = (hw_counter >> 40) & 0xFF;
61 61
62 for (i = 0; i < 6; i++) { 62 for (i = 0; i < 6; i++) {
63 err = abx500_set_register_interruptible(dev, 0, 63 err = abx500_set_register_interruptible(dev, 0,
@@ -75,7 +75,7 @@ static int ab3100_rtc_set_mmss(struct device *dev, unsigned long secs)
75 75
76static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm) 76static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm)
77{ 77{
78 unsigned long time; 78 time64_t time;
79 u8 rtcval; 79 u8 rtcval;
80 int err; 80 int err;
81 81
@@ -88,7 +88,7 @@ static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm)
88 dev_info(dev, "clock not set (lost power)"); 88 dev_info(dev, "clock not set (lost power)");
89 return -EINVAL; 89 return -EINVAL;
90 } else { 90 } else {
91 u64 fat_time; 91 u64 hw_counter;
92 u8 buf[6]; 92 u8 buf[6];
93 93
94 /* Read out time registers */ 94 /* Read out time registers */
@@ -98,22 +98,21 @@ static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm)
98 if (err != 0) 98 if (err != 0)
99 return err; 99 return err;
100 100
101 fat_time = ((u64) buf[5] << 40) | ((u64) buf[4] << 32) | 101 hw_counter = ((u64) buf[5] << 40) | ((u64) buf[4] << 32) |
102 ((u64) buf[3] << 24) | ((u64) buf[2] << 16) | 102 ((u64) buf[3] << 24) | ((u64) buf[2] << 16) |
103 ((u64) buf[1] << 8) | (u64) buf[0]; 103 ((u64) buf[1] << 8) | (u64) buf[0];
104 time = (unsigned long) (fat_time / 104 time = hw_counter / (u64) (AB3100_RTC_CLOCK_RATE * 2);
105 (u64) (AB3100_RTC_CLOCK_RATE * 2));
106 } 105 }
107 106
108 rtc_time_to_tm(time, tm); 107 rtc_time64_to_tm(time, tm);
109 108
110 return rtc_valid_tm(tm); 109 return rtc_valid_tm(tm);
111} 110}
112 111
113static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) 112static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
114{ 113{
115 unsigned long time; 114 time64_t time;
116 u64 fat_time; 115 u64 hw_counter;
117 u8 buf[6]; 116 u8 buf[6];
118 u8 rtcval; 117 u8 rtcval;
119 int err; 118 int err;
@@ -134,11 +133,11 @@ static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
134 AB3100_AL0, buf, 4); 133 AB3100_AL0, buf, 4);
135 if (err) 134 if (err)
136 return err; 135 return err;
137 fat_time = ((u64) buf[3] << 40) | ((u64) buf[2] << 32) | 136 hw_counter = ((u64) buf[3] << 40) | ((u64) buf[2] << 32) |
138 ((u64) buf[1] << 24) | ((u64) buf[0] << 16); 137 ((u64) buf[1] << 24) | ((u64) buf[0] << 16);
139 time = (unsigned long) (fat_time / (u64) (AB3100_RTC_CLOCK_RATE * 2)); 138 time = hw_counter / (u64) (AB3100_RTC_CLOCK_RATE * 2);
140 139
141 rtc_time_to_tm(time, &alarm->time); 140 rtc_time64_to_tm(time, &alarm->time);
142 141
143 return rtc_valid_tm(&alarm->time); 142 return rtc_valid_tm(&alarm->time);
144} 143}
@@ -147,17 +146,17 @@ static int ab3100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
147{ 146{
148 u8 regs[] = {AB3100_AL0, AB3100_AL1, AB3100_AL2, AB3100_AL3}; 147 u8 regs[] = {AB3100_AL0, AB3100_AL1, AB3100_AL2, AB3100_AL3};
149 unsigned char buf[4]; 148 unsigned char buf[4];
150 unsigned long secs; 149 time64_t secs;
151 u64 fat_time; 150 u64 hw_counter;
152 int err; 151 int err;
153 int i; 152 int i;
154 153
155 rtc_tm_to_time(&alarm->time, &secs); 154 secs = rtc_tm_to_time64(&alarm->time);
156 fat_time = (u64) secs * AB3100_RTC_CLOCK_RATE * 2; 155 hw_counter = secs * AB3100_RTC_CLOCK_RATE * 2;
157 buf[0] = (fat_time >> 16) & 0xFF; 156 buf[0] = (hw_counter >> 16) & 0xFF;
158 buf[1] = (fat_time >> 24) & 0xFF; 157 buf[1] = (hw_counter >> 24) & 0xFF;
159 buf[2] = (fat_time >> 32) & 0xFF; 158 buf[2] = (hw_counter >> 32) & 0xFF;
160 buf[3] = (fat_time >> 40) & 0xFF; 159 buf[3] = (hw_counter >> 40) & 0xFF;
161 160
162 /* Set the alarm */ 161 /* Set the alarm */
163 for (i = 0; i < 4; i++) { 162 for (i = 0; i < 4; i++) {
@@ -193,7 +192,7 @@ static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled)
193 192
194static const struct rtc_class_ops ab3100_rtc_ops = { 193static const struct rtc_class_ops ab3100_rtc_ops = {
195 .read_time = ab3100_rtc_read_time, 194 .read_time = ab3100_rtc_read_time,
196 .set_mmss = ab3100_rtc_set_mmss, 195 .set_mmss64 = ab3100_rtc_set_mmss,
197 .read_alarm = ab3100_rtc_read_alarm, 196 .read_alarm = ab3100_rtc_read_alarm,
198 .set_alarm = ab3100_rtc_set_alarm, 197 .set_alarm = ab3100_rtc_set_alarm,
199 .alarm_irq_enable = ab3100_rtc_irq_enable, 198 .alarm_irq_enable = ab3100_rtc_irq_enable,