15 #include <linux/module.h>
17 #include <linux/rtc.h>
22 #define rtc_err(da9052, fmt, ...) \
23 dev_err(da9052->dev, "%s: " fmt, __func__, ##__VA_ARGS__)
39 rtc_err(da9052,
"Failed to enable ALM: %d\n", ret);
44 rtc_err(da9052,
"Write error: %d\n", ret);
61 da9052_rtc_enable_alarm(rtc->
da9052, 0);
69 static int da9052_read_alarm(
struct da9052 *da9052,
struct rtc_time *rtc_tm)
76 rtc_err(da9052,
"Failed to group read ALM: %d\n", ret);
92 static int da9052_set_alarm(
struct da9052 *da9052,
struct rtc_time *rtc_tm)
101 DA9052_RTC_MIN, rtc_tm->
tm_min);
103 rtc_err(da9052,
"Failed to write ALRM MIN: %d\n", ret);
118 rtc_err(da9052,
"Failed to write ALRM YEAR: %d\n", ret);
123 static int da9052_rtc_get_alarm_status(
struct da9052 *da9052)
129 rtc_err(da9052,
"Failed to read ALM: %d\n", ret);
133 return (ret > 0) ? 1 : 0;
181 static int da9052_rtc_read_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
187 ret = da9052_read_alarm(rtc->
da9052, tm);
197 static int da9052_rtc_set_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
203 ret = da9052_rtc_enable_alarm(rtc->
da9052, 0);
207 ret = da9052_set_alarm(rtc->
da9052, tm);
211 ret = da9052_rtc_enable_alarm(rtc->
da9052, 1);
216 static int da9052_rtc_alarm_irq_enable(
struct device *dev,
unsigned int enabled)
220 return da9052_rtc_enable_alarm(rtc->
da9052, enabled);
224 .read_time = da9052_rtc_read_time,
225 .set_time = da9052_rtc_set_time,
226 .read_alarm = da9052_rtc_read_alarm,
227 .set_alarm = da9052_rtc_set_alarm,
228 .alarm_irq_enable = da9052_rtc_alarm_irq_enable,
241 platform_set_drvdata(pdev, rtc);
253 if (IS_ERR(rtc->
rtc)) {
254 ret = PTR_ERR(rtc->
rtc);
271 platform_set_drvdata(pdev,
NULL);
277 .probe = da9052_rtc_probe,
280 .name =
"da9052-rtc",