diff options
Diffstat (limited to 'drivers/rtc/rtc-vr41xx.c')
-rw-r--r-- | drivers/rtc/rtc-vr41xx.c | 70 |
1 files changed, 18 insertions, 52 deletions
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index c3244244e8cf..c5698cda366a 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c | |||
@@ -207,59 +207,9 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | 209 | ||
210 | static int vr41xx_rtc_irq_set_freq(struct device *dev, int freq) | ||
211 | { | ||
212 | u64 count; | ||
213 | |||
214 | if (!is_power_of_2(freq)) | ||
215 | return -EINVAL; | ||
216 | count = RTC_FREQUENCY; | ||
217 | do_div(count, freq); | ||
218 | |||
219 | spin_lock_irq(&rtc_lock); | ||
220 | |||
221 | periodic_count = count; | ||
222 | rtc1_write(RTCL1LREG, periodic_count); | ||
223 | rtc1_write(RTCL1HREG, periodic_count >> 16); | ||
224 | |||
225 | spin_unlock_irq(&rtc_lock); | ||
226 | |||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static int vr41xx_rtc_irq_set_state(struct device *dev, int enabled) | ||
231 | { | ||
232 | if (enabled) | ||
233 | enable_irq(pie_irq); | ||
234 | else | ||
235 | disable_irq(pie_irq); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | 210 | static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) |
241 | { | 211 | { |
242 | switch (cmd) { | 212 | switch (cmd) { |
243 | case RTC_AIE_ON: | ||
244 | spin_lock_irq(&rtc_lock); | ||
245 | |||
246 | if (!alarm_enabled) { | ||
247 | enable_irq(aie_irq); | ||
248 | alarm_enabled = 1; | ||
249 | } | ||
250 | |||
251 | spin_unlock_irq(&rtc_lock); | ||
252 | break; | ||
253 | case RTC_AIE_OFF: | ||
254 | spin_lock_irq(&rtc_lock); | ||
255 | |||
256 | if (alarm_enabled) { | ||
257 | disable_irq(aie_irq); | ||
258 | alarm_enabled = 0; | ||
259 | } | ||
260 | |||
261 | spin_unlock_irq(&rtc_lock); | ||
262 | break; | ||
263 | case RTC_EPOCH_READ: | 213 | case RTC_EPOCH_READ: |
264 | return put_user(epoch, (unsigned long __user *)arg); | 214 | return put_user(epoch, (unsigned long __user *)arg); |
265 | case RTC_EPOCH_SET: | 215 | case RTC_EPOCH_SET: |
@@ -275,6 +225,24 @@ static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long | |||
275 | return 0; | 225 | return 0; |
276 | } | 226 | } |
277 | 227 | ||
228 | static int vr41xx_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
229 | { | ||
230 | spin_lock_irq(&rtc_lock); | ||
231 | if (enabled) { | ||
232 | if (!alarm_enabled) { | ||
233 | enable_irq(aie_irq); | ||
234 | alarm_enabled = 1; | ||
235 | } | ||
236 | } else { | ||
237 | if (alarm_enabled) { | ||
238 | disable_irq(aie_irq); | ||
239 | alarm_enabled = 0; | ||
240 | } | ||
241 | } | ||
242 | spin_unlock_irq(&rtc_lock); | ||
243 | return 0; | ||
244 | } | ||
245 | |||
278 | static irqreturn_t elapsedtime_interrupt(int irq, void *dev_id) | 246 | static irqreturn_t elapsedtime_interrupt(int irq, void *dev_id) |
279 | { | 247 | { |
280 | struct platform_device *pdev = (struct platform_device *)dev_id; | 248 | struct platform_device *pdev = (struct platform_device *)dev_id; |
@@ -310,8 +278,6 @@ static const struct rtc_class_ops vr41xx_rtc_ops = { | |||
310 | .set_time = vr41xx_rtc_set_time, | 278 | .set_time = vr41xx_rtc_set_time, |
311 | .read_alarm = vr41xx_rtc_read_alarm, | 279 | .read_alarm = vr41xx_rtc_read_alarm, |
312 | .set_alarm = vr41xx_rtc_set_alarm, | 280 | .set_alarm = vr41xx_rtc_set_alarm, |
313 | .irq_set_freq = vr41xx_rtc_irq_set_freq, | ||
314 | .irq_set_state = vr41xx_rtc_irq_set_state, | ||
315 | }; | 281 | }; |
316 | 282 | ||
317 | static int __devinit rtc_probe(struct platform_device *pdev) | 283 | static int __devinit rtc_probe(struct platform_device *pdev) |