diff options
author | Krzysztof Kozlowski <k.kozlowski@samsung.com> | 2015-04-16 15:45:45 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-04-17 09:04:01 -0400 |
commit | 5281f94ae7f54d2d1a48dbc10223fd12d2aea716 (patch) | |
tree | 05e530ad0d0f25c3546e3fd305b92be6687dbec0 /drivers/rtc/rtc-s5m.c | |
parent | 7c6f84f8df02a17ad3da5e38abc8b8abff122d39 (diff) |
drivers/rtc/rtc-s5m.c: add support for S2MPS13 RTC
The S2MPS13 RTC is almost the same as S2MPS14. The differences when
updating alarm are:
1. Set WUDR+AUDR field instead of WUDR+RUDR.
2. Clear the AUDR field later (it is not auto-cleared).
Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc/rtc-s5m.c')
-rw-r--r-- | drivers/rtc/rtc-s5m.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/drivers/rtc/rtc-s5m.c b/drivers/rtc/rtc-s5m.c index 4008b84246ca..f0cb0ecb3d8d 100644 --- a/drivers/rtc/rtc-s5m.c +++ b/drivers/rtc/rtc-s5m.c | |||
@@ -187,6 +187,7 @@ static inline int s5m_check_peding_alarm_interrupt(struct s5m_rtc_info *info, | |||
187 | val &= S5M_ALARM0_STATUS; | 187 | val &= S5M_ALARM0_STATUS; |
188 | break; | 188 | break; |
189 | case S2MPS14X: | 189 | case S2MPS14X: |
190 | case S2MPS13X: | ||
190 | ret = regmap_read(info->s5m87xx->regmap_pmic, S2MPS14_REG_ST2, | 191 | ret = regmap_read(info->s5m87xx->regmap_pmic, S2MPS14_REG_ST2, |
191 | &val); | 192 | &val); |
192 | val &= S2MPS_ALARM0_STATUS; | 193 | val &= S2MPS_ALARM0_STATUS; |
@@ -252,6 +253,9 @@ static inline int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info) | |||
252 | case S2MPS14X: | 253 | case S2MPS14X: |
253 | data |= S2MPS_RTC_RUDR_MASK; | 254 | data |= S2MPS_RTC_RUDR_MASK; |
254 | break; | 255 | break; |
256 | case S2MPS13X: | ||
257 | data |= S2MPS13_RTC_AUDR_MASK; | ||
258 | break; | ||
255 | default: | 259 | default: |
256 | return -EINVAL; | 260 | return -EINVAL; |
257 | } | 261 | } |
@@ -265,6 +269,11 @@ static inline int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info *info) | |||
265 | 269 | ||
266 | ret = s5m8767_wait_for_udr_update(info); | 270 | ret = s5m8767_wait_for_udr_update(info); |
267 | 271 | ||
272 | /* On S2MPS13 the AUDR is not auto-cleared */ | ||
273 | if (info->device_type == S2MPS13X) | ||
274 | regmap_update_bits(info->regmap, info->regs->rtc_udr_update, | ||
275 | S2MPS13_RTC_AUDR_MASK, 0); | ||
276 | |||
268 | return ret; | 277 | return ret; |
269 | } | 278 | } |
270 | 279 | ||
@@ -306,7 +315,7 @@ static int s5m_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
306 | u8 data[info->regs->regs_count]; | 315 | u8 data[info->regs->regs_count]; |
307 | int ret; | 316 | int ret; |
308 | 317 | ||
309 | if (info->device_type == S2MPS14X) { | 318 | if (info->device_type == S2MPS14X || info->device_type == S2MPS13X) { |
310 | ret = regmap_update_bits(info->regmap, | 319 | ret = regmap_update_bits(info->regmap, |
311 | info->regs->rtc_udr_update, | 320 | info->regs->rtc_udr_update, |
312 | S2MPS_RTC_RUDR_MASK, S2MPS_RTC_RUDR_MASK); | 321 | S2MPS_RTC_RUDR_MASK, S2MPS_RTC_RUDR_MASK); |
@@ -329,6 +338,7 @@ static int s5m_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
329 | 338 | ||
330 | case S5M8767X: | 339 | case S5M8767X: |
331 | case S2MPS14X: | 340 | case S2MPS14X: |
341 | case S2MPS13X: | ||
332 | s5m8767_data_to_tm(data, tm, info->rtc_24hr_mode); | 342 | s5m8767_data_to_tm(data, tm, info->rtc_24hr_mode); |
333 | break; | 343 | break; |
334 | 344 | ||
@@ -355,6 +365,7 @@ static int s5m_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
355 | break; | 365 | break; |
356 | case S5M8767X: | 366 | case S5M8767X: |
357 | case S2MPS14X: | 367 | case S2MPS14X: |
368 | case S2MPS13X: | ||
358 | ret = s5m8767_tm_to_data(tm, data); | 369 | ret = s5m8767_tm_to_data(tm, data); |
359 | break; | 370 | break; |
360 | default: | 371 | default: |
@@ -402,6 +413,7 @@ static int s5m_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
402 | 413 | ||
403 | case S5M8767X: | 414 | case S5M8767X: |
404 | case S2MPS14X: | 415 | case S2MPS14X: |
416 | case S2MPS13X: | ||
405 | s5m8767_data_to_tm(data, &alrm->time, info->rtc_24hr_mode); | 417 | s5m8767_data_to_tm(data, &alrm->time, info->rtc_24hr_mode); |
406 | alrm->enabled = 0; | 418 | alrm->enabled = 0; |
407 | for (i = 0; i < info->regs->regs_count; i++) { | 419 | for (i = 0; i < info->regs->regs_count; i++) { |
@@ -450,6 +462,7 @@ static int s5m_rtc_stop_alarm(struct s5m_rtc_info *info) | |||
450 | 462 | ||
451 | case S5M8767X: | 463 | case S5M8767X: |
452 | case S2MPS14X: | 464 | case S2MPS14X: |
465 | case S2MPS13X: | ||
453 | for (i = 0; i < info->regs->regs_count; i++) | 466 | for (i = 0; i < info->regs->regs_count; i++) |
454 | data[i] &= ~ALARM_ENABLE_MASK; | 467 | data[i] &= ~ALARM_ENABLE_MASK; |
455 | 468 | ||
@@ -494,6 +507,7 @@ static int s5m_rtc_start_alarm(struct s5m_rtc_info *info) | |||
494 | 507 | ||
495 | case S5M8767X: | 508 | case S5M8767X: |
496 | case S2MPS14X: | 509 | case S2MPS14X: |
510 | case S2MPS13X: | ||
497 | data[RTC_SEC] |= ALARM_ENABLE_MASK; | 511 | data[RTC_SEC] |= ALARM_ENABLE_MASK; |
498 | data[RTC_MIN] |= ALARM_ENABLE_MASK; | 512 | data[RTC_MIN] |= ALARM_ENABLE_MASK; |
499 | data[RTC_HOUR] |= ALARM_ENABLE_MASK; | 513 | data[RTC_HOUR] |= ALARM_ENABLE_MASK; |
@@ -533,6 +547,7 @@ static int s5m_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
533 | 547 | ||
534 | case S5M8767X: | 548 | case S5M8767X: |
535 | case S2MPS14X: | 549 | case S2MPS14X: |
550 | case S2MPS13X: | ||
536 | s5m8767_tm_to_data(&alrm->time, data); | 551 | s5m8767_tm_to_data(&alrm->time, data); |
537 | break; | 552 | break; |
538 | 553 | ||
@@ -615,6 +630,7 @@ static int s5m8767_rtc_init_reg(struct s5m_rtc_info *info) | |||
615 | break; | 630 | break; |
616 | 631 | ||
617 | case S2MPS14X: | 632 | case S2MPS14X: |
633 | case S2MPS13X: | ||
618 | data[0] = (0 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT); | 634 | data[0] = (0 << BCD_EN_SHIFT) | (1 << MODEL24_SHIFT); |
619 | ret = regmap_write(info->regmap, info->regs->ctrl, data[0]); | 635 | ret = regmap_write(info->regmap, info->regs->ctrl, data[0]); |
620 | break; | 636 | break; |
@@ -652,6 +668,7 @@ static int s5m_rtc_probe(struct platform_device *pdev) | |||
652 | 668 | ||
653 | switch (pdata->device_type) { | 669 | switch (pdata->device_type) { |
654 | case S2MPS14X: | 670 | case S2MPS14X: |
671 | case S2MPS13X: | ||
655 | regmap_cfg = &s2mps14_rtc_regmap_config; | 672 | regmap_cfg = &s2mps14_rtc_regmap_config; |
656 | info->regs = &s2mps_rtc_regs; | 673 | info->regs = &s2mps_rtc_regs; |
657 | alarm_irq = S2MPS14_IRQ_RTCA0; | 674 | alarm_irq = S2MPS14_IRQ_RTCA0; |
@@ -772,6 +789,7 @@ static SIMPLE_DEV_PM_OPS(s5m_rtc_pm_ops, s5m_rtc_suspend, s5m_rtc_resume); | |||
772 | 789 | ||
773 | static const struct platform_device_id s5m_rtc_id[] = { | 790 | static const struct platform_device_id s5m_rtc_id[] = { |
774 | { "s5m-rtc", S5M8767X }, | 791 | { "s5m-rtc", S5M8767X }, |
792 | { "s2mps13-rtc", S2MPS13X }, | ||
775 | { "s2mps14-rtc", S2MPS14X }, | 793 | { "s2mps14-rtc", S2MPS14X }, |
776 | { }, | 794 | { }, |
777 | }; | 795 | }; |