Lines Matching refs:pxa_rtc

83 #define rtc_readl(pxa_rtc, reg)	\  argument
84 __raw_readl((pxa_rtc)->base + (reg))
85 #define rtc_writel(pxa_rtc, reg, value) \ argument
86 __raw_writel((value), (pxa_rtc)->base + (reg))
88 struct pxa_rtc { struct
125 static void rtsr_clear_bits(struct pxa_rtc *pxa_rtc, u32 mask) in rtsr_clear_bits() argument
129 rtsr = rtc_readl(pxa_rtc, RTSR); in rtsr_clear_bits()
132 rtc_writel(pxa_rtc, RTSR, rtsr); in rtsr_clear_bits()
135 static void rtsr_set_bits(struct pxa_rtc *pxa_rtc, u32 mask) in rtsr_set_bits() argument
139 rtsr = rtc_readl(pxa_rtc, RTSR); in rtsr_set_bits()
142 rtc_writel(pxa_rtc, RTSR, rtsr); in rtsr_set_bits()
148 struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); in pxa_rtc_irq() local
152 spin_lock(&pxa_rtc->lock); in pxa_rtc_irq()
155 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_irq()
156 rtc_writel(pxa_rtc, RTSR, rtsr); in pxa_rtc_irq()
159 rtsr_clear_bits(pxa_rtc, RTSR_RDALE1 | RTSR_PIALE | RTSR_HZE); in pxa_rtc_irq()
173 rtc_update_irq(pxa_rtc->rtc, 1, events); in pxa_rtc_irq()
176 rtc_writel(pxa_rtc, RTSR, rtsr & ~RTSR_TRIG_MASK); in pxa_rtc_irq()
178 spin_unlock(&pxa_rtc->lock); in pxa_rtc_irq()
184 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_open() local
187 ret = request_irq(pxa_rtc->irq_1Hz, pxa_rtc_irq, 0, in pxa_rtc_open()
190 dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_1Hz, in pxa_rtc_open()
194 ret = request_irq(pxa_rtc->irq_Alrm, pxa_rtc_irq, 0, in pxa_rtc_open()
197 dev_err(dev, "can't get irq %i, err %d\n", pxa_rtc->irq_Alrm, in pxa_rtc_open()
205 free_irq(pxa_rtc->irq_1Hz, dev); in pxa_rtc_open()
212 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_release() local
214 spin_lock_irq(&pxa_rtc->lock); in pxa_rtc_release()
215 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); in pxa_rtc_release()
216 spin_unlock_irq(&pxa_rtc->lock); in pxa_rtc_release()
218 free_irq(pxa_rtc->irq_Alrm, dev); in pxa_rtc_release()
219 free_irq(pxa_rtc->irq_1Hz, dev); in pxa_rtc_release()
224 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_alarm_irq_enable() local
226 spin_lock_irq(&pxa_rtc->lock); in pxa_alarm_irq_enable()
229 rtsr_set_bits(pxa_rtc, RTSR_RDALE1); in pxa_alarm_irq_enable()
231 rtsr_clear_bits(pxa_rtc, RTSR_RDALE1); in pxa_alarm_irq_enable()
233 spin_unlock_irq(&pxa_rtc->lock); in pxa_alarm_irq_enable()
239 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_read_time() local
242 rycr = rtc_readl(pxa_rtc, RYCR); in pxa_rtc_read_time()
243 rdcr = rtc_readl(pxa_rtc, RDCR); in pxa_rtc_read_time()
251 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_set_time() local
253 rtc_writel(pxa_rtc, RYCR, ryxr_calc(tm)); in pxa_rtc_set_time()
254 rtc_writel(pxa_rtc, RDCR, rdxr_calc(tm)); in pxa_rtc_set_time()
261 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_read_alarm() local
264 ryar = rtc_readl(pxa_rtc, RYAR1); in pxa_rtc_read_alarm()
265 rdar = rtc_readl(pxa_rtc, RDAR1); in pxa_rtc_read_alarm()
268 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_read_alarm()
276 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_set_alarm() local
279 spin_lock_irq(&pxa_rtc->lock); in pxa_rtc_set_alarm()
281 rtc_writel(pxa_rtc, RYAR1, ryxr_calc(&alrm->time)); in pxa_rtc_set_alarm()
282 rtc_writel(pxa_rtc, RDAR1, rdxr_calc(&alrm->time)); in pxa_rtc_set_alarm()
284 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_set_alarm()
289 rtc_writel(pxa_rtc, RTSR, rtsr); in pxa_rtc_set_alarm()
291 spin_unlock_irq(&pxa_rtc->lock); in pxa_rtc_set_alarm()
298 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_proc() local
300 seq_printf(seq, "trim/divider\t: 0x%08x\n", rtc_readl(pxa_rtc, RTTR)); in pxa_rtc_proc()
302 (rtc_readl(pxa_rtc, RTSR) & RTSR_HZE) ? "yes" : "no"); in pxa_rtc_proc()
304 (rtc_readl(pxa_rtc, RTSR) & RTSR_PIALE) ? "yes" : "no"); in pxa_rtc_proc()
305 seq_printf(seq, "periodic_freq\t: %u\n", rtc_readl(pxa_rtc, PIAR)); in pxa_rtc_proc()
322 struct pxa_rtc *pxa_rtc; in pxa_rtc_probe() local
326 pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL); in pxa_rtc_probe()
327 if (!pxa_rtc) in pxa_rtc_probe()
330 spin_lock_init(&pxa_rtc->lock); in pxa_rtc_probe()
331 platform_set_drvdata(pdev, pxa_rtc); in pxa_rtc_probe()
333 pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); in pxa_rtc_probe()
334 if (!pxa_rtc->ress) { in pxa_rtc_probe()
339 pxa_rtc->irq_1Hz = platform_get_irq(pdev, 0); in pxa_rtc_probe()
340 if (pxa_rtc->irq_1Hz < 0) { in pxa_rtc_probe()
344 pxa_rtc->irq_Alrm = platform_get_irq(pdev, 1); in pxa_rtc_probe()
345 if (pxa_rtc->irq_Alrm < 0) { in pxa_rtc_probe()
350 pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start, in pxa_rtc_probe()
351 resource_size(pxa_rtc->ress)); in pxa_rtc_probe()
352 if (!pxa_rtc->base) { in pxa_rtc_probe()
361 if (rtc_readl(pxa_rtc, RTTR) == 0) { in pxa_rtc_probe()
363 rtc_writel(pxa_rtc, RTTR, rttr); in pxa_rtc_probe()
368 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); in pxa_rtc_probe()
370 pxa_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pxa-rtc", in pxa_rtc_probe()
372 if (IS_ERR(pxa_rtc->rtc)) { in pxa_rtc_probe()
373 ret = PTR_ERR(pxa_rtc->rtc); in pxa_rtc_probe()
402 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_suspend() local
405 enable_irq_wake(pxa_rtc->irq_Alrm); in pxa_rtc_suspend()
411 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_resume() local
414 disable_irq_wake(pxa_rtc->irq_Alrm); in pxa_rtc_resume()