diff options
Diffstat (limited to 'drivers/rtc/rtc-abx80x.c')
-rw-r--r-- | drivers/rtc/rtc-abx80x.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c index d8e94edcb0ba..4d24f7288ad7 100644 --- a/drivers/rtc/rtc-abx80x.c +++ b/drivers/rtc/rtc-abx80x.c | |||
@@ -38,6 +38,7 @@ | |||
38 | 38 | ||
39 | #define ABX8XX_REG_STATUS 0x0f | 39 | #define ABX8XX_REG_STATUS 0x0f |
40 | #define ABX8XX_STATUS_AF BIT(2) | 40 | #define ABX8XX_STATUS_AF BIT(2) |
41 | #define ABX8XX_STATUS_BLF BIT(4) | ||
41 | #define ABX8XX_STATUS_WDT BIT(6) | 42 | #define ABX8XX_STATUS_WDT BIT(6) |
42 | 43 | ||
43 | #define ABX8XX_REG_CTRL1 0x10 | 44 | #define ABX8XX_REG_CTRL1 0x10 |
@@ -507,12 +508,49 @@ static int abx80x_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
507 | return err; | 508 | return err; |
508 | } | 509 | } |
509 | 510 | ||
511 | static int abx80x_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
512 | { | ||
513 | struct i2c_client *client = to_i2c_client(dev); | ||
514 | int status, tmp; | ||
515 | |||
516 | switch (cmd) { | ||
517 | case RTC_VL_READ: | ||
518 | status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS); | ||
519 | if (status < 0) | ||
520 | return status; | ||
521 | |||
522 | tmp = !!(status & ABX8XX_STATUS_BLF); | ||
523 | |||
524 | if (copy_to_user((void __user *)arg, &tmp, sizeof(int))) | ||
525 | return -EFAULT; | ||
526 | |||
527 | return 0; | ||
528 | |||
529 | case RTC_VL_CLR: | ||
530 | status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS); | ||
531 | if (status < 0) | ||
532 | return status; | ||
533 | |||
534 | status &= ~ABX8XX_STATUS_BLF; | ||
535 | |||
536 | tmp = i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS, 0); | ||
537 | if (tmp < 0) | ||
538 | return tmp; | ||
539 | |||
540 | return 0; | ||
541 | |||
542 | default: | ||
543 | return -ENOIOCTLCMD; | ||
544 | } | ||
545 | } | ||
546 | |||
510 | static const struct rtc_class_ops abx80x_rtc_ops = { | 547 | static const struct rtc_class_ops abx80x_rtc_ops = { |
511 | .read_time = abx80x_rtc_read_time, | 548 | .read_time = abx80x_rtc_read_time, |
512 | .set_time = abx80x_rtc_set_time, | 549 | .set_time = abx80x_rtc_set_time, |
513 | .read_alarm = abx80x_read_alarm, | 550 | .read_alarm = abx80x_read_alarm, |
514 | .set_alarm = abx80x_set_alarm, | 551 | .set_alarm = abx80x_set_alarm, |
515 | .alarm_irq_enable = abx80x_alarm_irq_enable, | 552 | .alarm_irq_enable = abx80x_alarm_irq_enable, |
553 | .ioctl = abx80x_ioctl, | ||
516 | }; | 554 | }; |
517 | 555 | ||
518 | static int abx80x_dt_trickle_cfg(struct device_node *np) | 556 | static int abx80x_dt_trickle_cfg(struct device_node *np) |