2 * Copyright (c) 2013-2014 Samsung Electronics Co., Ltd
3 * http://www.samsung.com
5 * Copyright (C) 2013 Google, Inc
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
18 #include <linux/module.h>
19 #include <linux/i2c.h>
20 #include <linux/bcd.h>
21 #include <linux/regmap.h>
22 #include <linux/rtc.h>
23 #include <linux/platform_device.h>
24 #include <linux/mfd/samsung/core.h>
25 #include <linux/mfd/samsung/irq.h>
26 #include <linux/mfd/samsung/rtc.h>
27 #include <linux/mfd/samsung/s2mps14.h>
30 * Maximum number of retries for checking changes in UDR field
31 * of S5M_RTC_UDR_CON register (to limit possible endless loop).
33 * After writing to RTC registers (setting time or alarm) read the UDR field
34 * in S5M_RTC_UDR_CON register. UDR is auto-cleared when data have
37 #define UDR_READ_RETRY_CNT 5
39 /* Registers used by the driver which are different between chipsets. */
40 struct s5m_rtc_reg_config
{
41 /* Number of registers used for setting time/alarm0/alarm1 */
42 unsigned int regs_count
;
43 /* First register for time, seconds */
45 /* RTC control register */
47 /* First register for alarm 0, seconds */
49 /* First register for alarm 1, seconds */
51 /* SMPL/WTSR register */
52 unsigned int smpl_wtsr
;
54 * Register for update flag (UDR). Typically setting UDR field to 1
55 * will enable update of time or alarm register. Then it will be
56 * auto-cleared after successful update.
58 unsigned int rtc_udr_update
;
59 /* Mask for UDR field in 'rtc_udr_update' register */
60 unsigned int rtc_udr_mask
;
63 /* Register map for S5M8763 and S5M8767 */
64 static const struct s5m_rtc_reg_config s5m_rtc_regs
= {
67 .ctrl
= S5M_ALARM1_CONF
,
68 .alarm0
= S5M_ALARM0_SEC
,
69 .alarm1
= S5M_ALARM1_SEC
,
70 .smpl_wtsr
= S5M_WTSR_SMPL_CNTL
,
71 .rtc_udr_update
= S5M_RTC_UDR_CON
,
72 .rtc_udr_mask
= S5M_RTC_UDR_MASK
,
76 * Register map for S2MPS14.
77 * It may be also suitable for S2MPS11 but this was not tested.
79 static const struct s5m_rtc_reg_config s2mps_rtc_regs
= {
81 .time
= S2MPS_RTC_SEC
,
82 .ctrl
= S2MPS_RTC_CTRL
,
83 .alarm0
= S2MPS_ALARM0_SEC
,
84 .alarm1
= S2MPS_ALARM1_SEC
,
85 .smpl_wtsr
= S2MPS_WTSR_SMPL_CNTL
,
86 .rtc_udr_update
= S2MPS_RTC_UDR_CON
,
87 .rtc_udr_mask
= S2MPS_RTC_WUDR_MASK
,
92 struct i2c_client
*i2c
;
93 struct sec_pmic_dev
*s5m87xx
;
94 struct regmap
*regmap
;
95 struct rtc_device
*rtc_dev
;
100 const struct s5m_rtc_reg_config
*regs
;
103 static const struct regmap_config s5m_rtc_regmap_config
= {
107 .max_register
= S5M_RTC_REG_MAX
,
110 static const struct regmap_config s2mps14_rtc_regmap_config
= {
114 .max_register
= S2MPS_RTC_REG_MAX
,
117 static void s5m8767_data_to_tm(u8
*data
, struct rtc_time
*tm
,
120 tm
->tm_sec
= data
[RTC_SEC
] & 0x7f;
121 tm
->tm_min
= data
[RTC_MIN
] & 0x7f;
123 tm
->tm_hour
= data
[RTC_HOUR
] & 0x1f;
125 tm
->tm_hour
= data
[RTC_HOUR
] & 0x0f;
126 if (data
[RTC_HOUR
] & HOUR_PM_MASK
)
130 tm
->tm_wday
= ffs(data
[RTC_WEEKDAY
] & 0x7f);
131 tm
->tm_mday
= data
[RTC_DATE
] & 0x1f;
132 tm
->tm_mon
= (data
[RTC_MONTH
] & 0x0f) - 1;
133 tm
->tm_year
= (data
[RTC_YEAR1
] & 0x7f) + 100;
138 static int s5m8767_tm_to_data(struct rtc_time
*tm
, u8
*data
)
140 data
[RTC_SEC
] = tm
->tm_sec
;
141 data
[RTC_MIN
] = tm
->tm_min
;
143 if (tm
->tm_hour
>= 12)
144 data
[RTC_HOUR
] = tm
->tm_hour
| HOUR_PM_MASK
;
146 data
[RTC_HOUR
] = tm
->tm_hour
& ~HOUR_PM_MASK
;
148 data
[RTC_WEEKDAY
] = 1 << tm
->tm_wday
;
149 data
[RTC_DATE
] = tm
->tm_mday
;
150 data
[RTC_MONTH
] = tm
->tm_mon
+ 1;
151 data
[RTC_YEAR1
] = tm
->tm_year
> 100 ? (tm
->tm_year
- 100) : 0;
153 if (tm
->tm_year
< 100) {
154 pr_err("s5m8767 RTC cannot handle the year %d.\n",
163 * Read RTC_UDR_CON register and wait till UDR field is cleared.
164 * This indicates that time/alarm update ended.
166 static inline int s5m8767_wait_for_udr_update(struct s5m_rtc_info
*info
)
168 int ret
, retry
= UDR_READ_RETRY_CNT
;
172 ret
= regmap_read(info
->regmap
, info
->regs
->rtc_udr_update
,
174 } while (--retry
&& (data
& info
->regs
->rtc_udr_mask
) && !ret
);
177 dev_err(info
->dev
, "waiting for UDR update, reached max number of retries\n");
182 static inline int s5m_check_peding_alarm_interrupt(struct s5m_rtc_info
*info
,
183 struct rtc_wkalrm
*alarm
)
188 switch (info
->device_type
) {
191 ret
= regmap_read(info
->regmap
, S5M_RTC_STATUS
, &val
);
192 val
&= S5M_ALARM0_STATUS
;
195 ret
= regmap_read(info
->s5m87xx
->regmap_pmic
, S2MPS14_REG_ST2
,
197 val
&= S2MPS_ALARM0_STATUS
;
213 static inline int s5m8767_rtc_set_time_reg(struct s5m_rtc_info
*info
)
218 ret
= regmap_read(info
->regmap
, info
->regs
->rtc_udr_update
, &data
);
220 dev_err(info
->dev
, "failed to read update reg(%d)\n", ret
);
224 data
|= info
->regs
->rtc_udr_mask
;
225 if (info
->device_type
== S5M8763X
|| info
->device_type
== S5M8767X
)
226 data
|= S5M_RTC_TIME_EN_MASK
;
228 ret
= regmap_write(info
->regmap
, info
->regs
->rtc_udr_update
, data
);
230 dev_err(info
->dev
, "failed to write update reg(%d)\n", ret
);
234 ret
= s5m8767_wait_for_udr_update(info
);
239 static inline int s5m8767_rtc_set_alarm_reg(struct s5m_rtc_info
*info
)
244 ret
= regmap_read(info
->regmap
, info
->regs
->rtc_udr_update
, &data
);
246 dev_err(info
->dev
, "%s: fail to read update reg(%d)\n",
251 data
|= info
->regs
->rtc_udr_mask
;
252 switch (info
->device_type
) {
255 data
&= ~S5M_RTC_TIME_EN_MASK
;
258 data
|= S2MPS_RTC_RUDR_MASK
;
264 ret
= regmap_write(info
->regmap
, info
->regs
->rtc_udr_update
, data
);
266 dev_err(info
->dev
, "%s: fail to write update reg(%d)\n",
271 ret
= s5m8767_wait_for_udr_update(info
);
276 static void s5m8763_data_to_tm(u8
*data
, struct rtc_time
*tm
)
278 tm
->tm_sec
= bcd2bin(data
[RTC_SEC
]);
279 tm
->tm_min
= bcd2bin(data
[RTC_MIN
]);
281 if (data
[RTC_HOUR
] & HOUR_12
) {
282 tm
->tm_hour
= bcd2bin(data
[RTC_HOUR
] & 0x1f);
283 if (data
[RTC_HOUR
] & HOUR_PM
)
286 tm
->tm_hour
= bcd2bin(data
[RTC_HOUR
] & 0x3f);
289 tm
->tm_wday
= data
[RTC_WEEKDAY
] & 0x07;
290 tm
->tm_mday
= bcd2bin(data
[RTC_DATE
]);
291 tm
->tm_mon
= bcd2bin(data
[RTC_MONTH
]);
292 tm
->tm_year
= bcd2bin(data
[RTC_YEAR1
]) + bcd2bin(data
[RTC_YEAR2
]) * 100;
296 static void s5m8763_tm_to_data(struct rtc_time
*tm
, u8
*data
)
298 data
[RTC_SEC
] = bin2bcd(tm
->tm_sec
);
299 data
[RTC_MIN
] = bin2bcd(tm
->tm_min
);
300 data
[RTC_HOUR
] = bin2bcd(tm
->tm_hour
);
301 data
[RTC_WEEKDAY
] = tm
->tm_wday
;
302 data
[RTC_DATE
] = bin2bcd(tm
->tm_mday
);
303 data
[RTC_MONTH
] = bin2bcd(tm
->tm_mon
);
304 data
[RTC_YEAR1
] = bin2bcd(tm
->tm_year
% 100);
305 data
[RTC_YEAR2
] = bin2bcd((tm
->tm_year
+ 1900) / 100);
308 static int s5m_rtc_read_time(struct device
*dev
, struct rtc_time
*tm
)
310 struct s5m_rtc_info
*info
= dev_get_drvdata(dev
);
311 u8 data
[info
->regs
->regs_count
];
314 if (info
->device_type
== S2MPS14X
) {
315 ret
= regmap_update_bits(info
->regmap
,
316 info
->regs
->rtc_udr_update
,
317 S2MPS_RTC_RUDR_MASK
, S2MPS_RTC_RUDR_MASK
);
320 "Failed to prepare registers for time reading: %d\n",
325 ret
= regmap_bulk_read(info
->regmap
, info
->regs
->time
, data
,
326 info
->regs
->regs_count
);
330 switch (info
->device_type
) {
332 s5m8763_data_to_tm(data
, tm
);
337 s5m8767_data_to_tm(data
, tm
, info
->rtc_24hr_mode
);
344 dev_dbg(dev
, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__
,
345 1900 + tm
->tm_year
, 1 + tm
->tm_mon
, tm
->tm_mday
,
346 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
, tm
->tm_wday
);
348 return rtc_valid_tm(tm
);
351 static int s5m_rtc_set_time(struct device
*dev
, struct rtc_time
*tm
)
353 struct s5m_rtc_info
*info
= dev_get_drvdata(dev
);
354 u8 data
[info
->regs
->regs_count
];
357 switch (info
->device_type
) {
359 s5m8763_tm_to_data(tm
, data
);
363 ret
= s5m8767_tm_to_data(tm
, data
);
372 dev_dbg(dev
, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__
,
373 1900 + tm
->tm_year
, 1 + tm
->tm_mon
, tm
->tm_mday
,
374 tm
->tm_hour
, tm
->tm_min
, tm
->tm_sec
, tm
->tm_wday
);
376 ret
= regmap_raw_write(info
->regmap
, info
->regs
->time
, data
,
377 info
->regs
->regs_count
);
381 ret
= s5m8767_rtc_set_time_reg(info
);
386 static int s5m_rtc_read_alarm(struct device
*dev
, struct rtc_wkalrm
*alrm
)
388 struct s5m_rtc_info
*info
= dev_get_drvdata(dev
);
389 u8 data
[info
->regs
->regs_count
];
393 ret
= regmap_bulk_read(info
->regmap
, info
->regs
->alarm0
, data
,
394 info
->regs
->regs_count
);
398 switch (info
->device_type
) {
400 s5m8763_data_to_tm(data
, &alrm
->time
);
401 ret
= regmap_read(info
->regmap
, S5M_ALARM0_CONF
, &val
);
405 alrm
->enabled
= !!val
;
410 s5m8767_data_to_tm(data
, &alrm
->time
, info
->rtc_24hr_mode
);
412 for (i
= 0; i
< info
->regs
->regs_count
; i
++) {
413 if (data
[i
] & ALARM_ENABLE_MASK
) {
424 dev_dbg(dev
, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__
,
425 1900 + alrm
->time
.tm_year
, 1 + alrm
->time
.tm_mon
,
426 alrm
->time
.tm_mday
, alrm
->time
.tm_hour
,
427 alrm
->time
.tm_min
, alrm
->time
.tm_sec
,
430 ret
= s5m_check_peding_alarm_interrupt(info
, alrm
);
435 static int s5m_rtc_stop_alarm(struct s5m_rtc_info
*info
)
437 u8 data
[info
->regs
->regs_count
];
441 ret
= regmap_bulk_read(info
->regmap
, info
->regs
->alarm0
, data
,
442 info
->regs
->regs_count
);
446 s5m8767_data_to_tm(data
, &tm
, info
->rtc_24hr_mode
);
447 dev_dbg(info
->dev
, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__
,
448 1900 + tm
.tm_year
, 1 + tm
.tm_mon
, tm
.tm_mday
,
449 tm
.tm_hour
, tm
.tm_min
, tm
.tm_sec
, tm
.tm_wday
);
451 switch (info
->device_type
) {
453 ret
= regmap_write(info
->regmap
, S5M_ALARM0_CONF
, 0);
458 for (i
= 0; i
< info
->regs
->regs_count
; i
++)
459 data
[i
] &= ~ALARM_ENABLE_MASK
;
461 ret
= regmap_raw_write(info
->regmap
, info
->regs
->alarm0
, data
,
462 info
->regs
->regs_count
);
466 ret
= s5m8767_rtc_set_alarm_reg(info
);
477 static int s5m_rtc_start_alarm(struct s5m_rtc_info
*info
)
480 u8 data
[info
->regs
->regs_count
];
484 ret
= regmap_bulk_read(info
->regmap
, info
->regs
->alarm0
, data
,
485 info
->regs
->regs_count
);
489 s5m8767_data_to_tm(data
, &tm
, info
->rtc_24hr_mode
);
490 dev_dbg(info
->dev
, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__
,
491 1900 + tm
.tm_year
, 1 + tm
.tm_mon
, tm
.tm_mday
,
492 tm
.tm_hour
, tm
.tm_min
, tm
.tm_sec
, tm
.tm_wday
);
494 switch (info
->device_type
) {
497 ret
= regmap_write(info
->regmap
, S5M_ALARM0_CONF
, alarm0_conf
);
502 data
[RTC_SEC
] |= ALARM_ENABLE_MASK
;
503 data
[RTC_MIN
] |= ALARM_ENABLE_MASK
;
504 data
[RTC_HOUR
] |= ALARM_ENABLE_MASK
;
505 data
[RTC_WEEKDAY
] &= ~ALARM_ENABLE_MASK
;
506 if (data
[RTC_DATE
] & 0x1f)
507 data
[RTC_DATE
] |= ALARM_ENABLE_MASK
;
508 if (data
[RTC_MONTH
] & 0xf)
509 data
[RTC_MONTH
] |= ALARM_ENABLE_MASK
;
510 if (data
[RTC_YEAR1
] & 0x7f)
511 data
[RTC_YEAR1
] |= ALARM_ENABLE_MASK
;
513 ret
= regmap_raw_write(info
->regmap
, info
->regs
->alarm0
, data
,
514 info
->regs
->regs_count
);
517 ret
= s5m8767_rtc_set_alarm_reg(info
);
528 static int s5m_rtc_set_alarm(struct device
*dev
, struct rtc_wkalrm
*alrm
)
530 struct s5m_rtc_info
*info
= dev_get_drvdata(dev
);
531 u8 data
[info
->regs
->regs_count
];
534 switch (info
->device_type
) {
536 s5m8763_tm_to_data(&alrm
->time
, data
);
541 s5m8767_tm_to_data(&alrm
->time
, data
);
548 dev_dbg(dev
, "%s: %d/%d/%d %d:%d:%d(%d)\n", __func__
,
549 1900 + alrm
->time
.tm_year
, 1 + alrm
->time
.tm_mon
,
550 alrm
->time
.tm_mday
, alrm
->time
.tm_hour
, alrm
->time
.tm_min
,
551 alrm
->time
.tm_sec
, alrm
->time
.tm_wday
);
553 ret
= s5m_rtc_stop_alarm(info
);
557 ret
= regmap_raw_write(info
->regmap
, info
->regs
->alarm0
, data
,
558 info
->regs
->regs_count
);
562 ret
= s5m8767_rtc_set_alarm_reg(info
);
567 ret
= s5m_rtc_start_alarm(info
);
572 static int s5m_rtc_alarm_irq_enable(struct device
*dev
,
573 unsigned int enabled
)
575 struct s5m_rtc_info
*info
= dev_get_drvdata(dev
);
578 return s5m_rtc_start_alarm(info
);
580 return s5m_rtc_stop_alarm(info
);
583 static irqreturn_t
s5m_rtc_alarm_irq(int irq
, void *data
)
585 struct s5m_rtc_info
*info
= data
;
587 rtc_update_irq(info
->rtc_dev
, 1, RTC_IRQF
| RTC_AF
);
592 static const struct rtc_class_ops s5m_rtc_ops
= {
593 .read_time
= s5m_rtc_read_time
,
594 .set_time
= s5m_rtc_set_time
,
595 .read_alarm
= s5m_rtc_read_alarm
,
596 .set_alarm
= s5m_rtc_set_alarm
,
597 .alarm_irq_enable
= s5m_rtc_alarm_irq_enable
,
600 static void s5m_rtc_enable_wtsr(struct s5m_rtc_info
*info
, bool enable
)
603 ret
= regmap_update_bits(info
->regmap
, info
->regs
->smpl_wtsr
,
605 enable
? WTSR_ENABLE_MASK
: 0);
607 dev_err(info
->dev
, "%s: fail to update WTSR reg(%d)\n",
611 static void s5m_rtc_enable_smpl(struct s5m_rtc_info
*info
, bool enable
)
614 ret
= regmap_update_bits(info
->regmap
, info
->regs
->smpl_wtsr
,
616 enable
? SMPL_ENABLE_MASK
: 0);
618 dev_err(info
->dev
, "%s: fail to update SMPL reg(%d)\n",
622 static int s5m8767_rtc_init_reg(struct s5m_rtc_info
*info
)
627 switch (info
->device_type
) {
630 /* UDR update time. Default of 7.32 ms is too long. */
631 ret
= regmap_update_bits(info
->regmap
, S5M_RTC_UDR_CON
,
632 S5M_RTC_UDR_T_MASK
, S5M_RTC_UDR_T_450_US
);
634 dev_err(info
->dev
, "%s: fail to change UDR time: %d\n",
637 /* Set RTC control register : Binary mode, 24hour mode */
638 data
[0] = (1 << BCD_EN_SHIFT
) | (1 << MODEL24_SHIFT
);
639 data
[1] = (0 << BCD_EN_SHIFT
) | (1 << MODEL24_SHIFT
);
641 ret
= regmap_raw_write(info
->regmap
, S5M_ALARM0_CONF
, data
, 2);
645 data
[0] = (0 << BCD_EN_SHIFT
) | (1 << MODEL24_SHIFT
);
646 ret
= regmap_write(info
->regmap
, info
->regs
->ctrl
, data
[0]);
653 info
->rtc_24hr_mode
= 1;
655 dev_err(info
->dev
, "%s: fail to write controlm reg(%d)\n",
663 static int s5m_rtc_probe(struct platform_device
*pdev
)
665 struct sec_pmic_dev
*s5m87xx
= dev_get_drvdata(pdev
->dev
.parent
);
666 struct sec_platform_data
*pdata
= s5m87xx
->pdata
;
667 struct s5m_rtc_info
*info
;
668 const struct regmap_config
*regmap_cfg
;
672 dev_err(pdev
->dev
.parent
, "Platform data not supplied\n");
676 info
= devm_kzalloc(&pdev
->dev
, sizeof(*info
), GFP_KERNEL
);
680 switch (pdata
->device_type
) {
682 regmap_cfg
= &s2mps14_rtc_regmap_config
;
683 info
->regs
= &s2mps_rtc_regs
;
684 alarm_irq
= S2MPS14_IRQ_RTCA0
;
687 regmap_cfg
= &s5m_rtc_regmap_config
;
688 info
->regs
= &s5m_rtc_regs
;
689 alarm_irq
= S5M8763_IRQ_ALARM0
;
692 regmap_cfg
= &s5m_rtc_regmap_config
;
693 info
->regs
= &s5m_rtc_regs
;
694 alarm_irq
= S5M8767_IRQ_RTCA1
;
697 dev_err(&pdev
->dev
, "Device type is not supported by RTC driver\n");
701 info
->i2c
= i2c_new_dummy(s5m87xx
->i2c
->adapter
, RTC_I2C_ADDR
);
703 dev_err(&pdev
->dev
, "Failed to allocate I2C for RTC\n");
707 info
->regmap
= devm_regmap_init_i2c(info
->i2c
, regmap_cfg
);
708 if (IS_ERR(info
->regmap
)) {
709 ret
= PTR_ERR(info
->regmap
);
710 dev_err(&pdev
->dev
, "Failed to allocate RTC register map: %d\n",
715 info
->dev
= &pdev
->dev
;
716 info
->s5m87xx
= s5m87xx
;
717 info
->device_type
= s5m87xx
->device_type
;
718 info
->wtsr_smpl
= s5m87xx
->wtsr_smpl
;
720 if (s5m87xx
->irq_data
) {
721 info
->irq
= regmap_irq_get_virq(s5m87xx
->irq_data
, alarm_irq
);
722 if (info
->irq
<= 0) {
724 dev_err(&pdev
->dev
, "Failed to get virtual IRQ %d\n",
730 platform_set_drvdata(pdev
, info
);
732 ret
= s5m8767_rtc_init_reg(info
);
734 if (info
->wtsr_smpl
) {
735 s5m_rtc_enable_wtsr(info
, true);
736 s5m_rtc_enable_smpl(info
, true);
739 device_init_wakeup(&pdev
->dev
, 1);
741 info
->rtc_dev
= devm_rtc_device_register(&pdev
->dev
, "s5m-rtc",
742 &s5m_rtc_ops
, THIS_MODULE
);
744 if (IS_ERR(info
->rtc_dev
)) {
745 ret
= PTR_ERR(info
->rtc_dev
);
750 dev_info(&pdev
->dev
, "Alarm IRQ not available\n");
754 ret
= devm_request_threaded_irq(&pdev
->dev
, info
->irq
, NULL
,
755 s5m_rtc_alarm_irq
, 0, "rtc-alarm0",
758 dev_err(&pdev
->dev
, "Failed to request alarm IRQ: %d: %d\n",
766 i2c_unregister_device(info
->i2c
);
771 static void s5m_rtc_shutdown(struct platform_device
*pdev
)
773 struct s5m_rtc_info
*info
= platform_get_drvdata(pdev
);
775 unsigned int val
= 0;
776 if (info
->wtsr_smpl
) {
777 for (i
= 0; i
< 3; i
++) {
778 s5m_rtc_enable_wtsr(info
, false);
779 regmap_read(info
->regmap
, info
->regs
->smpl_wtsr
, &val
);
780 pr_debug("%s: WTSR_SMPL reg(0x%02x)\n", __func__
, val
);
781 if (val
& WTSR_ENABLE_MASK
)
782 pr_emerg("%s: fail to disable WTSR\n",
785 pr_info("%s: success to disable WTSR\n",
791 /* Disable SMPL when power off */
792 s5m_rtc_enable_smpl(info
, false);
795 static int s5m_rtc_remove(struct platform_device
*pdev
)
797 struct s5m_rtc_info
*info
= platform_get_drvdata(pdev
);
799 /* Perform also all shutdown steps when removing */
800 s5m_rtc_shutdown(pdev
);
801 i2c_unregister_device(info
->i2c
);
806 #ifdef CONFIG_PM_SLEEP
807 static int s5m_rtc_resume(struct device
*dev
)
809 struct s5m_rtc_info
*info
= dev_get_drvdata(dev
);
812 if (info
->irq
&& device_may_wakeup(dev
))
813 ret
= disable_irq_wake(info
->irq
);
818 static int s5m_rtc_suspend(struct device
*dev
)
820 struct s5m_rtc_info
*info
= dev_get_drvdata(dev
);
823 if (info
->irq
&& device_may_wakeup(dev
))
824 ret
= enable_irq_wake(info
->irq
);
828 #endif /* CONFIG_PM_SLEEP */
830 static SIMPLE_DEV_PM_OPS(s5m_rtc_pm_ops
, s5m_rtc_suspend
, s5m_rtc_resume
);
832 static const struct platform_device_id s5m_rtc_id
[] = {
833 { "s5m-rtc", S5M8767X
},
834 { "s2mps14-rtc", S2MPS14X
},
837 static struct platform_driver s5m_rtc_driver
= {
840 .owner
= THIS_MODULE
,
841 .pm
= &s5m_rtc_pm_ops
,
843 .probe
= s5m_rtc_probe
,
844 .remove
= s5m_rtc_remove
,
845 .shutdown
= s5m_rtc_shutdown
,
846 .id_table
= s5m_rtc_id
,
849 module_platform_driver(s5m_rtc_driver
);
851 /* Module information */
852 MODULE_AUTHOR("Sangbeom Kim <sbkim73@samsung.com>");
853 MODULE_DESCRIPTION("Samsung S5M/S2MPS14 RTC driver");
854 MODULE_LICENSE("GPL");
855 MODULE_ALIAS("platform:s5m-rtc");