aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-rs5c372.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/rtc/rtc-rs5c372.c')
-rw-r--r--drivers/rtc/rtc-rs5c372.c50
1 files changed, 9 insertions, 41 deletions
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
index 90cf0a6ff23e..85c1b848dd72 100644
--- a/drivers/rtc/rtc-rs5c372.c
+++ b/drivers/rtc/rtc-rs5c372.c
@@ -207,7 +207,7 @@ static int rs5c372_get_datetime(struct i2c_client *client, struct rtc_time *tm)
207static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm) 207static int rs5c372_set_datetime(struct i2c_client *client, struct rtc_time *tm)
208{ 208{
209 struct rs5c372 *rs5c = i2c_get_clientdata(client); 209 struct rs5c372 *rs5c = i2c_get_clientdata(client);
210 unsigned char buf[8]; 210 unsigned char buf[7];
211 int addr; 211 int addr;
212 212
213 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d " 213 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d "
@@ -281,10 +281,8 @@ static int rs5c372_rtc_set_time(struct device *dev, struct rtc_time *tm)
281 return rs5c372_set_datetime(to_i2c_client(dev), tm); 281 return rs5c372_set_datetime(to_i2c_client(dev), tm);
282} 282}
283 283
284#if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE)
285 284
286static int 285static int rs5c_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
287rs5c_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
288{ 286{
289 struct i2c_client *client = to_i2c_client(dev); 287 struct i2c_client *client = to_i2c_client(dev);
290 struct rs5c372 *rs5c = i2c_get_clientdata(client); 288 struct rs5c372 *rs5c = i2c_get_clientdata(client);
@@ -292,45 +290,19 @@ rs5c_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
292 int status, addr; 290 int status, addr;
293 291
294 buf = rs5c->regs[RS5C_REG_CTRL1]; 292 buf = rs5c->regs[RS5C_REG_CTRL1];
295 switch (cmd) { 293
296 case RTC_UIE_OFF: 294 if (!rs5c->has_irq)
297 case RTC_UIE_ON: 295 return -EINVAL;
298 /* some 327a modes use a different IRQ pin for 1Hz irqs */
299 if (rs5c->type == rtc_rs5c372a
300 && (buf & RS5C372A_CTRL1_SL1))
301 return -ENOIOCTLCMD;
302 case RTC_AIE_OFF:
303 case RTC_AIE_ON:
304 /* these irq management calls only make sense for chips
305 * which are wired up to an IRQ.
306 */
307 if (!rs5c->has_irq)
308 return -ENOIOCTLCMD;
309 break;
310 default:
311 return -ENOIOCTLCMD;
312 }
313 296
314 status = rs5c_get_regs(rs5c); 297 status = rs5c_get_regs(rs5c);
315 if (status < 0) 298 if (status < 0)
316 return status; 299 return status;
317 300
318 addr = RS5C_ADDR(RS5C_REG_CTRL1); 301 addr = RS5C_ADDR(RS5C_REG_CTRL1);
319 switch (cmd) { 302 if (enabled)
320 case RTC_AIE_OFF: /* alarm off */
321 buf &= ~RS5C_CTRL1_AALE;
322 break;
323 case RTC_AIE_ON: /* alarm on */
324 buf |= RS5C_CTRL1_AALE; 303 buf |= RS5C_CTRL1_AALE;
325 break; 304 else
326 case RTC_UIE_OFF: /* update off */ 305 buf &= ~RS5C_CTRL1_AALE;
327 buf &= ~RS5C_CTRL1_CT_MASK;
328 break;
329 case RTC_UIE_ON: /* update on */
330 buf &= ~RS5C_CTRL1_CT_MASK;
331 buf |= RS5C_CTRL1_CT4;
332 break;
333 }
334 306
335 if (i2c_smbus_write_byte_data(client, addr, buf) < 0) { 307 if (i2c_smbus_write_byte_data(client, addr, buf) < 0) {
336 printk(KERN_WARNING "%s: can't update alarm\n", 308 printk(KERN_WARNING "%s: can't update alarm\n",
@@ -342,10 +314,6 @@ rs5c_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
342 return status; 314 return status;
343} 315}
344 316
345#else
346#define rs5c_rtc_ioctl NULL
347#endif
348
349 317
350/* NOTE: Since RTC_WKALM_{RD,SET} were originally defined for EFI, 318/* NOTE: Since RTC_WKALM_{RD,SET} were originally defined for EFI,
351 * which only exposes a polled programming interface; and since 319 * which only exposes a polled programming interface; and since
@@ -461,11 +429,11 @@ static int rs5c372_rtc_proc(struct device *dev, struct seq_file *seq)
461 429
462static const struct rtc_class_ops rs5c372_rtc_ops = { 430static const struct rtc_class_ops rs5c372_rtc_ops = {
463 .proc = rs5c372_rtc_proc, 431 .proc = rs5c372_rtc_proc,
464 .ioctl = rs5c_rtc_ioctl,
465 .read_time = rs5c372_rtc_read_time, 432 .read_time = rs5c372_rtc_read_time,
466 .set_time = rs5c372_rtc_set_time, 433 .set_time = rs5c372_rtc_set_time,
467 .read_alarm = rs5c_read_alarm, 434 .read_alarm = rs5c_read_alarm,
468 .set_alarm = rs5c_set_alarm, 435 .set_alarm = rs5c_set_alarm,
436 .alarm_irq_enable = rs5c_rtc_alarm_irq_enable,
469}; 437};
470 438
471#if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE) 439#if defined(CONFIG_RTC_INTF_SYSFS) || defined(CONFIG_RTC_INTF_SYSFS_MODULE)