Lines Matching refs:pxa_rtc
71 #define rtc_readl(pxa_rtc, reg) \ argument
72 __raw_readl((pxa_rtc)->base + (reg))
73 #define rtc_writel(pxa_rtc, reg, value) \ argument
74 __raw_writel((value), (pxa_rtc)->base + (reg))
76 struct pxa_rtc { struct
112 static void rtsr_clear_bits(struct pxa_rtc *pxa_rtc, u32 mask) in rtsr_clear_bits() argument
116 rtsr = rtc_readl(pxa_rtc, RTSR); in rtsr_clear_bits()
119 rtc_writel(pxa_rtc, RTSR, rtsr); in rtsr_clear_bits()
122 static void rtsr_set_bits(struct pxa_rtc *pxa_rtc, u32 mask) in rtsr_set_bits() argument
126 rtsr = rtc_readl(pxa_rtc, RTSR); in rtsr_set_bits()
129 rtc_writel(pxa_rtc, RTSR, rtsr); in rtsr_set_bits()
134 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev_id); in pxa_rtc_irq() local
138 spin_lock(&pxa_rtc->lock); in pxa_rtc_irq()
141 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_irq()
142 rtc_writel(pxa_rtc, RTSR, rtsr); in pxa_rtc_irq()
145 rtsr_clear_bits(pxa_rtc, RTSR_RDALE1 | RTSR_PIALE | RTSR_HZE); in pxa_rtc_irq()
159 rtc_update_irq(pxa_rtc->rtc, 1, events); in pxa_rtc_irq()
162 rtc_writel(pxa_rtc, RTSR, rtsr & ~RTSR_TRIG_MASK); in pxa_rtc_irq()
164 spin_unlock(&pxa_rtc->lock); in pxa_rtc_irq()
170 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_open() local
173 ret = request_irq(pxa_rtc->sa1100_rtc.irq_1hz, pxa_rtc_irq, 0, in pxa_rtc_open()
177 pxa_rtc->sa1100_rtc.irq_1hz, ret); in pxa_rtc_open()
180 ret = request_irq(pxa_rtc->sa1100_rtc.irq_alarm, pxa_rtc_irq, 0, in pxa_rtc_open()
184 pxa_rtc->sa1100_rtc.irq_alarm, ret); in pxa_rtc_open()
191 free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev); in pxa_rtc_open()
198 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_release() local
200 spin_lock_irq(&pxa_rtc->lock); in pxa_rtc_release()
201 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); in pxa_rtc_release()
202 spin_unlock_irq(&pxa_rtc->lock); in pxa_rtc_release()
204 free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev); in pxa_rtc_release()
205 free_irq(pxa_rtc->sa1100_rtc.irq_alarm, dev); in pxa_rtc_release()
210 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_alarm_irq_enable() local
212 spin_lock_irq(&pxa_rtc->lock); in pxa_alarm_irq_enable()
215 rtsr_set_bits(pxa_rtc, RTSR_RDALE1); in pxa_alarm_irq_enable()
217 rtsr_clear_bits(pxa_rtc, RTSR_RDALE1); in pxa_alarm_irq_enable()
219 spin_unlock_irq(&pxa_rtc->lock); in pxa_alarm_irq_enable()
225 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_read_time() local
228 rycr = rtc_readl(pxa_rtc, RYCR); in pxa_rtc_read_time()
229 rdcr = rtc_readl(pxa_rtc, RDCR); in pxa_rtc_read_time()
237 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_set_time() local
239 rtc_writel(pxa_rtc, RYCR, ryxr_calc(tm)); in pxa_rtc_set_time()
240 rtc_writel(pxa_rtc, RDCR, rdxr_calc(tm)); in pxa_rtc_set_time()
247 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_read_alarm() local
250 ryar = rtc_readl(pxa_rtc, RYAR1); in pxa_rtc_read_alarm()
251 rdar = rtc_readl(pxa_rtc, RDAR1); in pxa_rtc_read_alarm()
254 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_read_alarm()
262 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_set_alarm() local
265 spin_lock_irq(&pxa_rtc->lock); in pxa_rtc_set_alarm()
267 rtc_writel(pxa_rtc, RYAR1, ryxr_calc(&alrm->time)); in pxa_rtc_set_alarm()
268 rtc_writel(pxa_rtc, RDAR1, rdxr_calc(&alrm->time)); in pxa_rtc_set_alarm()
270 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_set_alarm()
275 rtc_writel(pxa_rtc, RTSR, rtsr); in pxa_rtc_set_alarm()
277 spin_unlock_irq(&pxa_rtc->lock); in pxa_rtc_set_alarm()
284 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_proc() local
286 seq_printf(seq, "trim/divider\t: 0x%08x\n", rtc_readl(pxa_rtc, RTTR)); in pxa_rtc_proc()
288 (rtc_readl(pxa_rtc, RTSR) & RTSR_HZE) ? "yes" : "no"); in pxa_rtc_proc()
290 (rtc_readl(pxa_rtc, RTSR) & RTSR_PIALE) ? "yes" : "no"); in pxa_rtc_proc()
291 seq_printf(seq, "periodic_freq\t: %u\n", rtc_readl(pxa_rtc, PIAR)); in pxa_rtc_proc()
308 struct pxa_rtc *pxa_rtc; in pxa_rtc_probe() local
312 pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL); in pxa_rtc_probe()
313 if (!pxa_rtc) in pxa_rtc_probe()
315 sa1100_rtc = &pxa_rtc->sa1100_rtc; in pxa_rtc_probe()
317 spin_lock_init(&pxa_rtc->lock); in pxa_rtc_probe()
318 platform_set_drvdata(pdev, pxa_rtc); in pxa_rtc_probe()
320 pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); in pxa_rtc_probe()
321 if (!pxa_rtc->ress) { in pxa_rtc_probe()
333 pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start, in pxa_rtc_probe()
334 resource_size(pxa_rtc->ress)); in pxa_rtc_probe()
335 if (!pxa_rtc->base) { in pxa_rtc_probe()
342 sa1100_rtc->rcnr = pxa_rtc->base + 0x0; in pxa_rtc_probe()
343 sa1100_rtc->rtsr = pxa_rtc->base + 0x8; in pxa_rtc_probe()
344 sa1100_rtc->rtar = pxa_rtc->base + 0x4; in pxa_rtc_probe()
345 sa1100_rtc->rttr = pxa_rtc->base + 0xc; in pxa_rtc_probe()
352 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); in pxa_rtc_probe()
354 pxa_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pxa-rtc", in pxa_rtc_probe()
356 if (IS_ERR(pxa_rtc->rtc)) { in pxa_rtc_probe()
357 ret = PTR_ERR(pxa_rtc->rtc); in pxa_rtc_probe()
386 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_suspend() local
389 enable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm); in pxa_rtc_suspend()
395 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_resume() local
398 disable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm); in pxa_rtc_resume()