19 #include <linux/kernel.h>
20 #include <linux/errno.h>
22 #include <linux/module.h>
23 #include <linux/types.h>
24 #include <linux/rtc.h>
37 #define NUM_TIME_REGS (RC5T583_RTC_YEAR - RC5T583_RTC_SEC + 1)
40 #define NUM_YAL_REGS (RC5T583_RTC_AY_YEAR - RC5T583_RTC_AY_MIN + 1)
43 #define SET_YAL BIT(5)
46 #define GET_YAL_STATUS BIT(3)
48 static int rc5t583_rtc_alarm_irq_enable(
struct device *
dev,
unsigned enabled)
78 dev_err(dev,
"RTC read time failed with err:%d\n", ret);
93 static int rc5t583_rtc_set_time(
struct device *dev,
struct rtc_time *tm)
110 dev_err(dev,
"RTC set time failed with error %d\n", ret);
117 static int rc5t583_rtc_read_alarm(
struct device *dev,
struct rtc_wkalrm *alm)
121 u32 interrupt_enable;
127 dev_err(dev,
"rtc_read_alarm error %d\n", ret);
142 if (interrupt_enable &
SET_YAL)
148 static int rc5t583_rtc_set_alarm(
struct device *dev,
struct rtc_wkalrm *alm)
154 ret = rc5t583_rtc_alarm_irq_enable(dev, 0);
167 dev_err(dev,
"rtc_set_alarm error %d\n", ret);
172 ret = rc5t583_rtc_alarm_irq_enable(dev, 1);
193 rtc_reg &= ~GET_YAL_STATUS;
207 .read_time = rc5t583_rtc_read_time,
208 .set_time = rc5t583_rtc_set_time,
209 .read_alarm = rc5t583_rtc_read_alarm,
210 .set_alarm = rc5t583_rtc_set_alarm,
211 .alarm_irq_enable = rc5t583_rtc_alarm_irq_enable,
217 struct rc5t583_rtc *ricoh_rtc;
227 platform_set_drvdata(pdev, ricoh_rtc);
237 dev_err(&pdev->
dev,
"unable to program rtc_adjust reg\n");
241 pmic_plat_data = dev_get_platdata(rc5t583->
dev);
244 dev_warn(&pdev->
dev,
"Wake up is not possible as irq = %d\n",
252 "rtc-rc5t583", &pdev->
dev);
261 if (IS_ERR(ricoh_rtc->
rtc)) {
262 ret = PTR_ERR(ricoh_rtc->
rtc);
263 dev_err(&pdev->
dev,
"RTC device register: err %d\n", ret);
278 rc5t583_rtc_alarm_irq_enable(&rc5t583_rtc->
rtc->dev, 0);
284 #ifdef CONFIG_PM_SLEEP
286 static int rc5t583_rtc_suspend(
struct device *dev)
294 &rc5t583_rtc->
irqen);
298 static int rc5t583_rtc_resume(
struct device *dev)
308 static const struct dev_pm_ops rc5t583_rtc_pm_ops = {
309 .
suspend = rc5t583_rtc_suspend,
310 .resume = rc5t583_rtc_resume,
313 #define DEV_PM_OPS (&rc5t583_rtc_pm_ops)
315 #define DEV_PM_OPS NULL
319 .probe = rc5t583_rtc_probe,
323 .name =
"rtc-rc5t583",