Lines Matching full:rtc

12 #include <linux/rtc.h>
19 #define rtc_err(rtc, fmt, ...) \ argument
20 dev_err(rtc->da9052->dev, "%s: " fmt, __func__, ##__VA_ARGS__)
25 struct rtc_device *rtc; member
29 static int da9052_rtc_enable_alarm(struct da9052_rtc *rtc, bool enable) in da9052_rtc_enable_alarm() argument
33 ret = da9052_reg_update(rtc->da9052, DA9052_ALARM_Y_REG, in da9052_rtc_enable_alarm()
37 rtc_err(rtc, "Failed to enable ALM: %d\n", ret); in da9052_rtc_enable_alarm()
39 ret = da9052_reg_update(rtc->da9052, DA9052_ALARM_Y_REG, in da9052_rtc_enable_alarm()
42 rtc_err(rtc, "Write error: %d\n", ret); in da9052_rtc_enable_alarm()
49 struct da9052_rtc *rtc = data; in da9052_rtc_irq() local
51 rtc_update_irq(rtc->rtc, 1, RTC_IRQF | RTC_AF); in da9052_rtc_irq()
56 static int da9052_read_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm) in da9052_read_alarm() argument
63 ret = da9052_group_read(rtc->da9052, DA9052_ALARM_MI_REG, 5, &v[0][0]); in da9052_read_alarm()
65 rtc_err(rtc, "Failed to group read ALM: %d\n", ret); in da9052_read_alarm()
70 ret = da9052_group_read(rtc->da9052, in da9052_read_alarm()
73 rtc_err(rtc, "Failed to group read ALM: %d\n", ret); in da9052_read_alarm()
94 rtc_err(rtc, "Timed out reading alarm time\n"); in da9052_read_alarm()
99 static int da9052_set_alarm(struct da9052_rtc *rtc, struct rtc_time *rtc_tm) in da9052_set_alarm() argument
101 struct da9052 *da9052 = rtc->da9052; in da9052_set_alarm()
120 rtc_err(rtc, "Failed to write ALRM MIN: %d\n", ret); in da9052_set_alarm()
135 rtc_err(rtc, "Failed to write ALRM YEAR: %d\n", ret); in da9052_set_alarm()
140 static int da9052_rtc_get_alarm_status(struct da9052_rtc *rtc) in da9052_rtc_get_alarm_status() argument
144 ret = da9052_reg_read(rtc->da9052, DA9052_ALARM_Y_REG); in da9052_rtc_get_alarm_status()
146 rtc_err(rtc, "Failed to read ALM: %d\n", ret); in da9052_rtc_get_alarm_status()
155 struct da9052_rtc *rtc = dev_get_drvdata(dev); in da9052_rtc_read_time() local
161 ret = da9052_group_read(rtc->da9052, DA9052_COUNT_S_REG, 6, &v[0][0]); in da9052_rtc_read_time()
163 rtc_err(rtc, "Failed to read RTC time : %d\n", ret); in da9052_rtc_read_time()
168 ret = da9052_group_read(rtc->da9052, in da9052_rtc_read_time()
171 rtc_err(rtc, "Failed to read RTC time : %d\n", ret); in da9052_rtc_read_time()
191 rtc_err(rtc, "Timed out reading time\n"); in da9052_rtc_read_time()
198 struct da9052_rtc *rtc; in da9052_rtc_set_time() local
206 rtc = dev_get_drvdata(dev); in da9052_rtc_set_time()
215 ret = da9052_group_write(rtc->da9052, DA9052_COUNT_S_REG, 6, v); in da9052_rtc_set_time()
217 rtc_err(rtc, "failed to set RTC time: %d\n", ret); in da9052_rtc_set_time()
225 struct da9052_rtc *rtc = dev_get_drvdata(dev); in da9052_rtc_read_alarm() local
227 ret = da9052_read_alarm(rtc, tm); in da9052_rtc_read_alarm()
229 rtc_err(rtc, "failed to read RTC alarm: %d\n", ret); in da9052_rtc_read_alarm()
233 alrm->enabled = da9052_rtc_get_alarm_status(rtc); in da9052_rtc_read_alarm()
241 struct da9052_rtc *rtc = dev_get_drvdata(dev); in da9052_rtc_set_alarm() local
247 ret = da9052_rtc_enable_alarm(rtc, 0); in da9052_rtc_set_alarm()
251 ret = da9052_set_alarm(rtc, tm); in da9052_rtc_set_alarm()
255 ret = da9052_rtc_enable_alarm(rtc, 1); in da9052_rtc_set_alarm()
261 struct da9052_rtc *rtc = dev_get_drvdata(dev); in da9052_rtc_alarm_irq_enable() local
263 return da9052_rtc_enable_alarm(rtc, enabled); in da9052_rtc_alarm_irq_enable()
276 struct da9052_rtc *rtc; in da9052_rtc_probe() local
279 rtc = devm_kzalloc(&pdev->dev, sizeof(struct da9052_rtc), GFP_KERNEL); in da9052_rtc_probe()
280 if (!rtc) in da9052_rtc_probe()
283 rtc->da9052 = dev_get_drvdata(pdev->dev.parent); in da9052_rtc_probe()
284 platform_set_drvdata(pdev, rtc); in da9052_rtc_probe()
286 ret = da9052_reg_write(rtc->da9052, DA9052_BBAT_CONT_REG, 0xFE); in da9052_rtc_probe()
288 rtc_err(rtc, in da9052_rtc_probe()
289 "Failed to setup RTC battery charging: %d\n", ret); in da9052_rtc_probe()
293 ret = da9052_reg_update(rtc->da9052, DA9052_ALARM_Y_REG, in da9052_rtc_probe()
296 rtc_err(rtc, "Failed to disable TICKS: %d\n", ret); in da9052_rtc_probe()
299 rtc->rtc = devm_rtc_allocate_device(&pdev->dev); in da9052_rtc_probe()
300 if (IS_ERR(rtc->rtc)) in da9052_rtc_probe()
301 return PTR_ERR(rtc->rtc); in da9052_rtc_probe()
303 rtc->rtc->ops = &da9052_rtc_ops; in da9052_rtc_probe()
304 rtc->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; in da9052_rtc_probe()
305 rtc->rtc->range_max = RTC_TIMESTAMP_END_2063; in da9052_rtc_probe()
307 ret = devm_rtc_register_device(rtc->rtc); in da9052_rtc_probe()
311 ret = da9052_request_irq(rtc->da9052, DA9052_IRQ_ALARM, "ALM", in da9052_rtc_probe()
312 da9052_rtc_irq, rtc); in da9052_rtc_probe()
314 rtc_err(rtc, "irq registration failed: %d\n", ret); in da9052_rtc_probe()
324 .name = "da9052-rtc",
331 MODULE_DESCRIPTION("RTC driver for Dialog DA9052 PMIC");
333 MODULE_ALIAS("platform:da9052-rtc");