Lines Matching refs:rtc
62 static void pcf2rtc_time(struct rtc_time *rtc, struct pcf50633_time *pcf) in pcf2rtc_time() argument
64 rtc->tm_sec = bcd2bin(pcf->time[PCF50633_TI_SEC]); in pcf2rtc_time()
65 rtc->tm_min = bcd2bin(pcf->time[PCF50633_TI_MIN]); in pcf2rtc_time()
66 rtc->tm_hour = bcd2bin(pcf->time[PCF50633_TI_HOUR]); in pcf2rtc_time()
67 rtc->tm_wday = bcd2bin(pcf->time[PCF50633_TI_WKDAY]); in pcf2rtc_time()
68 rtc->tm_mday = bcd2bin(pcf->time[PCF50633_TI_DAY]); in pcf2rtc_time()
69 rtc->tm_mon = bcd2bin(pcf->time[PCF50633_TI_MONTH]) - 1; in pcf2rtc_time()
70 rtc->tm_year = bcd2bin(pcf->time[PCF50633_TI_YEAR]) + 100; in pcf2rtc_time()
73 static void rtc2pcf_time(struct pcf50633_time *pcf, struct rtc_time *rtc) in rtc2pcf_time() argument
75 pcf->time[PCF50633_TI_SEC] = bin2bcd(rtc->tm_sec); in rtc2pcf_time()
76 pcf->time[PCF50633_TI_MIN] = bin2bcd(rtc->tm_min); in rtc2pcf_time()
77 pcf->time[PCF50633_TI_HOUR] = bin2bcd(rtc->tm_hour); in rtc2pcf_time()
78 pcf->time[PCF50633_TI_WKDAY] = bin2bcd(rtc->tm_wday); in rtc2pcf_time()
79 pcf->time[PCF50633_TI_DAY] = bin2bcd(rtc->tm_mday); in rtc2pcf_time()
80 pcf->time[PCF50633_TI_MONTH] = bin2bcd(rtc->tm_mon + 1); in rtc2pcf_time()
81 pcf->time[PCF50633_TI_YEAR] = bin2bcd(rtc->tm_year % 100); in rtc2pcf_time()
87 struct pcf50633_rtc *rtc = dev_get_drvdata(dev); in pcf50633_rtc_alarm_irq_enable() local
91 err = pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM); in pcf50633_rtc_alarm_irq_enable()
93 err = pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM); in pcf50633_rtc_alarm_irq_enable()
98 rtc->alarm_enabled = enabled; in pcf50633_rtc_alarm_irq_enable()
105 struct pcf50633_rtc *rtc; in pcf50633_rtc_read_time() local
109 rtc = dev_get_drvdata(dev); in pcf50633_rtc_read_time()
111 ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSC, in pcf50633_rtc_read_time()
136 struct pcf50633_rtc *rtc; in pcf50633_rtc_set_time() local
140 rtc = dev_get_drvdata(dev); in pcf50633_rtc_set_time()
155 alarm_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_ALARM); in pcf50633_rtc_set_time()
158 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM); in pcf50633_rtc_set_time()
161 ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSC, in pcf50633_rtc_set_time()
166 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM); in pcf50633_rtc_set_time()
173 struct pcf50633_rtc *rtc; in pcf50633_rtc_read_alarm() local
177 rtc = dev_get_drvdata(dev); in pcf50633_rtc_read_alarm()
179 alrm->enabled = rtc->alarm_enabled; in pcf50633_rtc_read_alarm()
180 alrm->pending = rtc->alarm_pending; in pcf50633_rtc_read_alarm()
182 ret = pcf50633_read_block(rtc->pcf, PCF50633_REG_RTCSCA, in pcf50633_rtc_read_alarm()
196 struct pcf50633_rtc *rtc; in pcf50633_rtc_set_alarm() local
200 rtc = dev_get_drvdata(dev); in pcf50633_rtc_set_alarm()
207 alarm_masked = pcf50633_irq_mask_get(rtc->pcf, PCF50633_IRQ_ALARM); in pcf50633_rtc_set_alarm()
211 pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_ALARM); in pcf50633_rtc_set_alarm()
214 ret = pcf50633_write_block(rtc->pcf, PCF50633_REG_RTCSCA, in pcf50633_rtc_set_alarm()
217 rtc->alarm_pending = 0; in pcf50633_rtc_set_alarm()
220 pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_ALARM); in pcf50633_rtc_set_alarm()
221 rtc->alarm_enabled = alrm->enabled; in pcf50633_rtc_set_alarm()
236 struct pcf50633_rtc *rtc = data; in pcf50633_rtc_irq() local
238 rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF); in pcf50633_rtc_irq()
239 rtc->alarm_pending = 1; in pcf50633_rtc_irq()
244 struct pcf50633_rtc *rtc; in pcf50633_rtc_probe() local
246 rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); in pcf50633_rtc_probe()
247 if (!rtc) in pcf50633_rtc_probe()
250 rtc->pcf = dev_to_pcf50633(pdev->dev.parent); in pcf50633_rtc_probe()
251 platform_set_drvdata(pdev, rtc); in pcf50633_rtc_probe()
252 rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, "pcf50633-rtc", in pcf50633_rtc_probe()
255 if (IS_ERR(rtc->rtc_dev)) in pcf50633_rtc_probe()
256 return PTR_ERR(rtc->rtc_dev); in pcf50633_rtc_probe()
258 pcf50633_register_irq(rtc->pcf, PCF50633_IRQ_ALARM, in pcf50633_rtc_probe()
259 pcf50633_rtc_irq, rtc); in pcf50633_rtc_probe()
265 struct pcf50633_rtc *rtc; in pcf50633_rtc_remove() local
267 rtc = platform_get_drvdata(pdev); in pcf50633_rtc_remove()
268 pcf50633_free_irq(rtc->pcf, PCF50633_IRQ_ALARM); in pcf50633_rtc_remove()