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.c41
1 files changed, 17 insertions, 24 deletions
diff --git a/drivers/rtc/rtc-ab3100.c b/drivers/rtc/rtc-ab3100.c
index 4704aac2b5af..d26780ea254b 100644
--- a/drivers/rtc/rtc-ab3100.c
+++ b/drivers/rtc/rtc-ab3100.c
@@ -9,7 +9,7 @@
9#include <linux/init.h> 9#include <linux/init.h>
10#include <linux/platform_device.h> 10#include <linux/platform_device.h>
11#include <linux/rtc.h> 11#include <linux/rtc.h>
12#include <linux/mfd/ab3100.h> 12#include <linux/mfd/abx500.h>
13 13
14/* Clock rate in Hz */ 14/* Clock rate in Hz */
15#define AB3100_RTC_CLOCK_RATE 32768 15#define AB3100_RTC_CLOCK_RATE 32768
@@ -45,7 +45,6 @@
45 */ 45 */
46static int ab3100_rtc_set_mmss(struct device *dev, unsigned long secs) 46static int ab3100_rtc_set_mmss(struct device *dev, unsigned long secs)
47{ 47{
48 struct ab3100 *ab3100_data = dev_get_drvdata(dev);
49 u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2, 48 u8 regs[] = {AB3100_TI0, AB3100_TI1, AB3100_TI2,
50 AB3100_TI3, AB3100_TI4, AB3100_TI5}; 49 AB3100_TI3, AB3100_TI4, AB3100_TI5};
51 unsigned char buf[6]; 50 unsigned char buf[6];
@@ -61,27 +60,26 @@ static int ab3100_rtc_set_mmss(struct device *dev, unsigned long secs)
61 buf[5] = (fat_time >> 40) & 0xFF; 60 buf[5] = (fat_time >> 40) & 0xFF;
62 61
63 for (i = 0; i < 6; i++) { 62 for (i = 0; i < 6; i++) {
64 err = ab3100_set_register_interruptible(ab3100_data, 63 err = abx500_set_register_interruptible(dev, 0,
65 regs[i], buf[i]); 64 regs[i], buf[i]);
66 if (err) 65 if (err)
67 return err; 66 return err;
68 } 67 }
69 68
70 /* Set the flag to mark that the clock is now set */ 69 /* Set the flag to mark that the clock is now set */
71 return ab3100_mask_and_set_register_interruptible(ab3100_data, 70 return abx500_mask_and_set_register_interruptible(dev, 0,
72 AB3100_RTC, 71 AB3100_RTC,
73 0xFE, 0x01); 72 0x01, 0x01);
74 73
75} 74}
76 75
77static 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)
78{ 77{
79 struct ab3100 *ab3100_data = dev_get_drvdata(dev);
80 unsigned long time; 78 unsigned long time;
81 u8 rtcval; 79 u8 rtcval;
82 int err; 80 int err;
83 81
84 err = ab3100_get_register_interruptible(ab3100_data, 82 err = abx500_get_register_interruptible(dev, 0,
85 AB3100_RTC, &rtcval); 83 AB3100_RTC, &rtcval);
86 if (err) 84 if (err)
87 return err; 85 return err;
@@ -94,7 +92,7 @@ static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm)
94 u8 buf[6]; 92 u8 buf[6];
95 93
96 /* Read out time registers */ 94 /* Read out time registers */
97 err = ab3100_get_register_page_interruptible(ab3100_data, 95 err = abx500_get_register_page_interruptible(dev, 0,
98 AB3100_TI0, 96 AB3100_TI0,
99 buf, 6); 97 buf, 6);
100 if (err != 0) 98 if (err != 0)
@@ -114,7 +112,6 @@ static int ab3100_rtc_read_time(struct device *dev, struct rtc_time *tm)
114 112
115static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) 113static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
116{ 114{
117 struct ab3100 *ab3100_data = dev_get_drvdata(dev);
118 unsigned long time; 115 unsigned long time;
119 u64 fat_time; 116 u64 fat_time;
120 u8 buf[6]; 117 u8 buf[6];
@@ -122,7 +119,7 @@ static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
122 int err; 119 int err;
123 120
124 /* Figure out if alarm is enabled or not */ 121 /* Figure out if alarm is enabled or not */
125 err = ab3100_get_register_interruptible(ab3100_data, 122 err = abx500_get_register_interruptible(dev, 0,
126 AB3100_RTC, &rtcval); 123 AB3100_RTC, &rtcval);
127 if (err) 124 if (err)
128 return err; 125 return err;
@@ -133,7 +130,7 @@ static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
133 /* No idea how this could be represented */ 130 /* No idea how this could be represented */
134 alarm->pending = 0; 131 alarm->pending = 0;
135 /* Read out alarm registers, only 4 bytes */ 132 /* Read out alarm registers, only 4 bytes */
136 err = ab3100_get_register_page_interruptible(ab3100_data, 133 err = abx500_get_register_page_interruptible(dev, 0,
137 AB3100_AL0, buf, 4); 134 AB3100_AL0, buf, 4);
138 if (err) 135 if (err)
139 return err; 136 return err;
@@ -148,7 +145,6 @@ static int ab3100_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm)
148 145
149static int ab3100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) 146static int ab3100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
150{ 147{
151 struct ab3100 *ab3100_data = dev_get_drvdata(dev);
152 u8 regs[] = {AB3100_AL0, AB3100_AL1, AB3100_AL2, AB3100_AL3}; 148 u8 regs[] = {AB3100_AL0, AB3100_AL1, AB3100_AL2, AB3100_AL3};
153 unsigned char buf[4]; 149 unsigned char buf[4];
154 unsigned long secs; 150 unsigned long secs;
@@ -165,21 +161,19 @@ static int ab3100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm)
165 161
166 /* Set the alarm */ 162 /* Set the alarm */
167 for (i = 0; i < 4; i++) { 163 for (i = 0; i < 4; i++) {
168 err = ab3100_set_register_interruptible(ab3100_data, 164 err = abx500_set_register_interruptible(dev, 0,
169 regs[i], buf[i]); 165 regs[i], buf[i]);
170 if (err) 166 if (err)
171 return err; 167 return err;
172 } 168 }
173 /* Then enable the alarm */ 169 /* Then enable the alarm */
174 return ab3100_mask_and_set_register_interruptible(ab3100_data, 170 return abx500_mask_and_set_register_interruptible(dev, 0,
175 AB3100_RTC, ~(1 << 2), 171 AB3100_RTC, (1 << 2),
176 alarm->enabled << 2); 172 alarm->enabled << 2);
177} 173}
178 174
179static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled) 175static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled)
180{ 176{
181 struct ab3100 *ab3100_data = dev_get_drvdata(dev);
182
183 /* 177 /*
184 * It's not possible to enable/disable the alarm IRQ for this RTC. 178 * It's not possible to enable/disable the alarm IRQ for this RTC.
185 * It does not actually trigger any IRQ: instead its only function is 179 * It does not actually trigger any IRQ: instead its only function is
@@ -188,12 +182,12 @@ static int ab3100_rtc_irq_enable(struct device *dev, unsigned int enabled)
188 * and need to be handled there instead. 182 * and need to be handled there instead.
189 */ 183 */
190 if (enabled) 184 if (enabled)
191 return ab3100_mask_and_set_register_interruptible(ab3100_data, 185 return abx500_mask_and_set_register_interruptible(dev, 0,
192 AB3100_RTC, ~(1 << 2), 186 AB3100_RTC, (1 << 2),
193 1 << 2); 187 1 << 2);
194 else 188 else
195 return ab3100_mask_and_set_register_interruptible(ab3100_data, 189 return abx500_mask_and_set_register_interruptible(dev, 0,
196 AB3100_RTC, ~(1 << 2), 190 AB3100_RTC, (1 << 2),
197 0); 191 0);
198} 192}
199 193
@@ -210,10 +204,9 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev)
210 int err; 204 int err;
211 u8 regval; 205 u8 regval;
212 struct rtc_device *rtc; 206 struct rtc_device *rtc;
213 struct ab3100 *ab3100_data = platform_get_drvdata(pdev);
214 207
215 /* The first RTC register needs special treatment */ 208 /* The first RTC register needs special treatment */
216 err = ab3100_get_register_interruptible(ab3100_data, 209 err = abx500_get_register_interruptible(&pdev->dev, 0,
217 AB3100_RTC, &regval); 210 AB3100_RTC, &regval);
218 if (err) { 211 if (err) {
219 dev_err(&pdev->dev, "unable to read RTC register\n"); 212 dev_err(&pdev->dev, "unable to read RTC register\n");
@@ -231,7 +224,7 @@ static int __init ab3100_rtc_probe(struct platform_device *pdev)
231 * This bit remains until RTC power is lost. 224 * This bit remains until RTC power is lost.
232 */ 225 */
233 regval = 1 | RTC_SETTING; 226 regval = 1 | RTC_SETTING;
234 err = ab3100_set_register_interruptible(ab3100_data, 227 err = abx500_set_register_interruptible(&pdev->dev, 0,
235 AB3100_RTC, regval); 228 AB3100_RTC, regval);
236 /* Ignore any error on this write */ 229 /* Ignore any error on this write */
237 } 230 }