Lines Matching refs:rtc
51 static void cpcap2rtc_time(struct rtc_time *rtc, struct cpcap_time *cpcap) in cpcap2rtc_time() argument
59 rtc_time64_to_tm(time, rtc); in cpcap2rtc_time()
62 static void rtc2cpcap_time(struct cpcap_time *cpcap, struct rtc_time *rtc) in rtc2cpcap_time() argument
66 time = rtc_tm_to_time64(rtc); in rtc2cpcap_time()
76 struct cpcap_rtc *rtc = dev_get_drvdata(dev); in cpcap_rtc_alarm_irq_enable() local
78 if (rtc->alarm_enabled == enabled) in cpcap_rtc_alarm_irq_enable()
82 enable_irq(rtc->alarm_irq); in cpcap_rtc_alarm_irq_enable()
84 disable_irq(rtc->alarm_irq); in cpcap_rtc_alarm_irq_enable()
86 rtc->alarm_enabled = !!enabled; in cpcap_rtc_alarm_irq_enable()
93 struct cpcap_rtc *rtc; in cpcap_rtc_read_time() local
98 rtc = dev_get_drvdata(dev); in cpcap_rtc_read_time()
100 ret = regmap_read(rtc->regmap, CPCAP_REG_TOD2, &temp_tod2); in cpcap_rtc_read_time()
101 ret |= regmap_read(rtc->regmap, CPCAP_REG_DAY, &cpcap_tm.day); in cpcap_rtc_read_time()
102 ret |= regmap_read(rtc->regmap, CPCAP_REG_TOD1, &cpcap_tm.tod1); in cpcap_rtc_read_time()
103 ret |= regmap_read(rtc->regmap, CPCAP_REG_TOD2, &cpcap_tm.tod2); in cpcap_rtc_read_time()
106 ret |= regmap_read(rtc->regmap, CPCAP_REG_DAY, &cpcap_tm.day); in cpcap_rtc_read_time()
120 struct cpcap_rtc *rtc; in cpcap_rtc_set_time() local
124 rtc = dev_get_drvdata(dev); in cpcap_rtc_set_time()
128 if (rtc->alarm_enabled) in cpcap_rtc_set_time()
129 disable_irq(rtc->alarm_irq); in cpcap_rtc_set_time()
130 if (rtc->update_enabled) in cpcap_rtc_set_time()
131 disable_irq(rtc->update_irq); in cpcap_rtc_set_time()
133 if (rtc->vendor == CPCAP_VENDOR_ST) { in cpcap_rtc_set_time()
137 ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TOD1, in cpcap_rtc_set_time()
139 ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TOD2, in cpcap_rtc_set_time()
141 ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_DAY, in cpcap_rtc_set_time()
151 ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TOD1, in cpcap_rtc_set_time()
153 ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_DAY, in cpcap_rtc_set_time()
155 ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TOD2, in cpcap_rtc_set_time()
157 ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TOD1, in cpcap_rtc_set_time()
161 if (rtc->update_enabled) in cpcap_rtc_set_time()
162 enable_irq(rtc->update_irq); in cpcap_rtc_set_time()
163 if (rtc->alarm_enabled) in cpcap_rtc_set_time()
164 enable_irq(rtc->alarm_irq); in cpcap_rtc_set_time()
171 struct cpcap_rtc *rtc; in cpcap_rtc_read_alarm() local
175 rtc = dev_get_drvdata(dev); in cpcap_rtc_read_alarm()
177 alrm->enabled = rtc->alarm_enabled; in cpcap_rtc_read_alarm()
179 ret = regmap_read(rtc->regmap, CPCAP_REG_DAYA, &cpcap_tm.day); in cpcap_rtc_read_alarm()
180 ret |= regmap_read(rtc->regmap, CPCAP_REG_TODA2, &cpcap_tm.tod2); in cpcap_rtc_read_alarm()
181 ret |= regmap_read(rtc->regmap, CPCAP_REG_TODA1, &cpcap_tm.tod1); in cpcap_rtc_read_alarm()
194 struct cpcap_rtc *rtc; in cpcap_rtc_set_alarm() local
198 rtc = dev_get_drvdata(dev); in cpcap_rtc_set_alarm()
202 if (rtc->alarm_enabled) in cpcap_rtc_set_alarm()
203 disable_irq(rtc->alarm_irq); in cpcap_rtc_set_alarm()
205 ret = regmap_update_bits(rtc->regmap, CPCAP_REG_DAYA, DAY_MASK, in cpcap_rtc_set_alarm()
207 ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TODA2, TOD2_MASK, in cpcap_rtc_set_alarm()
209 ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TODA1, TOD1_MASK, in cpcap_rtc_set_alarm()
213 enable_irq(rtc->alarm_irq); in cpcap_rtc_set_alarm()
214 rtc->alarm_enabled = true; in cpcap_rtc_set_alarm()
230 struct cpcap_rtc *rtc = data; in cpcap_rtc_alarm_irq() local
232 rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF); in cpcap_rtc_alarm_irq()
238 struct cpcap_rtc *rtc = data; in cpcap_rtc_update_irq() local
240 rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF); in cpcap_rtc_update_irq()
247 struct cpcap_rtc *rtc; in cpcap_rtc_probe() local
250 rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL); in cpcap_rtc_probe()
251 if (!rtc) in cpcap_rtc_probe()
254 rtc->regmap = dev_get_regmap(dev->parent, NULL); in cpcap_rtc_probe()
255 if (!rtc->regmap) in cpcap_rtc_probe()
258 platform_set_drvdata(pdev, rtc); in cpcap_rtc_probe()
259 rtc->rtc_dev = devm_rtc_allocate_device(dev); in cpcap_rtc_probe()
260 if (IS_ERR(rtc->rtc_dev)) in cpcap_rtc_probe()
261 return PTR_ERR(rtc->rtc_dev); in cpcap_rtc_probe()
263 rtc->rtc_dev->ops = &cpcap_rtc_ops; in cpcap_rtc_probe()
264 rtc->rtc_dev->range_max = (timeu64_t) (DAY_MASK + 1) * SECS_PER_DAY - 1; in cpcap_rtc_probe()
266 err = cpcap_get_vendor(dev, rtc->regmap, &rtc->vendor); in cpcap_rtc_probe()
270 rtc->alarm_irq = platform_get_irq(pdev, 0); in cpcap_rtc_probe()
271 err = devm_request_threaded_irq(dev, rtc->alarm_irq, NULL, in cpcap_rtc_probe()
274 "rtc_alarm", rtc); in cpcap_rtc_probe()
279 disable_irq(rtc->alarm_irq); in cpcap_rtc_probe()
287 rtc->update_irq = platform_get_irq(pdev, 1); in cpcap_rtc_probe()
288 err = devm_request_threaded_irq(dev, rtc->update_irq, NULL, in cpcap_rtc_probe()
291 "rtc_1hz", rtc); in cpcap_rtc_probe()
296 disable_irq(rtc->update_irq); in cpcap_rtc_probe()
304 return devm_rtc_register_device(rtc->rtc_dev); in cpcap_rtc_probe()