Lines Matching refs:pxa_rtc
85 #define rtc_readl(pxa_rtc, reg) \ argument
86 __raw_readl((pxa_rtc)->base + (reg))
87 #define rtc_writel(pxa_rtc, reg, value) \ argument
88 __raw_writel((value), (pxa_rtc)->base + (reg))
90 struct pxa_rtc { struct
126 static void rtsr_clear_bits(struct pxa_rtc *pxa_rtc, u32 mask) in rtsr_clear_bits() argument
130 rtsr = rtc_readl(pxa_rtc, RTSR); in rtsr_clear_bits()
133 rtc_writel(pxa_rtc, RTSR, rtsr); in rtsr_clear_bits()
136 static void rtsr_set_bits(struct pxa_rtc *pxa_rtc, u32 mask) in rtsr_set_bits() argument
140 rtsr = rtc_readl(pxa_rtc, RTSR); in rtsr_set_bits()
143 rtc_writel(pxa_rtc, RTSR, rtsr); in rtsr_set_bits()
149 struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev); in pxa_rtc_irq() local
153 spin_lock(&pxa_rtc->lock); in pxa_rtc_irq()
156 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_irq()
157 rtc_writel(pxa_rtc, RTSR, rtsr); in pxa_rtc_irq()
160 rtsr_clear_bits(pxa_rtc, RTSR_RDALE1 | RTSR_PIALE | RTSR_HZE); in pxa_rtc_irq()
174 rtc_update_irq(pxa_rtc->rtc, 1, events); in pxa_rtc_irq()
177 rtc_writel(pxa_rtc, RTSR, rtsr & ~RTSR_TRIG_MASK); in pxa_rtc_irq()
179 spin_unlock(&pxa_rtc->lock); in pxa_rtc_irq()
185 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_open() local
188 ret = request_irq(pxa_rtc->sa1100_rtc.irq_1hz, pxa_rtc_irq, 0, in pxa_rtc_open()
192 pxa_rtc->sa1100_rtc.irq_1hz, ret); in pxa_rtc_open()
195 ret = request_irq(pxa_rtc->sa1100_rtc.irq_alarm, pxa_rtc_irq, 0, in pxa_rtc_open()
199 pxa_rtc->sa1100_rtc.irq_alarm, ret); in pxa_rtc_open()
206 free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev); in pxa_rtc_open()
213 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_release() local
215 spin_lock_irq(&pxa_rtc->lock); in pxa_rtc_release()
216 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); in pxa_rtc_release()
217 spin_unlock_irq(&pxa_rtc->lock); in pxa_rtc_release()
219 free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev); in pxa_rtc_release()
220 free_irq(pxa_rtc->sa1100_rtc.irq_alarm, dev); in pxa_rtc_release()
225 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_alarm_irq_enable() local
227 spin_lock_irq(&pxa_rtc->lock); in pxa_alarm_irq_enable()
230 rtsr_set_bits(pxa_rtc, RTSR_RDALE1); in pxa_alarm_irq_enable()
232 rtsr_clear_bits(pxa_rtc, RTSR_RDALE1); in pxa_alarm_irq_enable()
234 spin_unlock_irq(&pxa_rtc->lock); in pxa_alarm_irq_enable()
240 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_read_time() local
243 rycr = rtc_readl(pxa_rtc, RYCR); in pxa_rtc_read_time()
244 rdcr = rtc_readl(pxa_rtc, RDCR); in pxa_rtc_read_time()
252 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_set_time() local
254 rtc_writel(pxa_rtc, RYCR, ryxr_calc(tm)); in pxa_rtc_set_time()
255 rtc_writel(pxa_rtc, RDCR, rdxr_calc(tm)); in pxa_rtc_set_time()
262 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_read_alarm() local
265 ryar = rtc_readl(pxa_rtc, RYAR1); in pxa_rtc_read_alarm()
266 rdar = rtc_readl(pxa_rtc, RDAR1); in pxa_rtc_read_alarm()
269 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_read_alarm()
277 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_set_alarm() local
280 spin_lock_irq(&pxa_rtc->lock); in pxa_rtc_set_alarm()
282 rtc_writel(pxa_rtc, RYAR1, ryxr_calc(&alrm->time)); in pxa_rtc_set_alarm()
283 rtc_writel(pxa_rtc, RDAR1, rdxr_calc(&alrm->time)); in pxa_rtc_set_alarm()
285 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_set_alarm()
290 rtc_writel(pxa_rtc, RTSR, rtsr); in pxa_rtc_set_alarm()
292 spin_unlock_irq(&pxa_rtc->lock); in pxa_rtc_set_alarm()
299 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_proc() local
301 seq_printf(seq, "trim/divider\t: 0x%08x\n", rtc_readl(pxa_rtc, RTTR)); in pxa_rtc_proc()
303 (rtc_readl(pxa_rtc, RTSR) & RTSR_HZE) ? "yes" : "no"); in pxa_rtc_proc()
305 (rtc_readl(pxa_rtc, RTSR) & RTSR_PIALE) ? "yes" : "no"); in pxa_rtc_proc()
306 seq_printf(seq, "periodic_freq\t: %u\n", rtc_readl(pxa_rtc, PIAR)); in pxa_rtc_proc()
323 struct pxa_rtc *pxa_rtc; in pxa_rtc_probe() local
327 pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL); in pxa_rtc_probe()
328 if (!pxa_rtc) in pxa_rtc_probe()
330 sa1100_rtc = &pxa_rtc->sa1100_rtc; in pxa_rtc_probe()
332 spin_lock_init(&pxa_rtc->lock); in pxa_rtc_probe()
333 platform_set_drvdata(pdev, pxa_rtc); in pxa_rtc_probe()
335 pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); in pxa_rtc_probe()
336 if (!pxa_rtc->ress) { in pxa_rtc_probe()
352 pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start, in pxa_rtc_probe()
353 resource_size(pxa_rtc->ress)); in pxa_rtc_probe()
354 if (!pxa_rtc->base) { in pxa_rtc_probe()
359 sa1100_rtc->rcnr = pxa_rtc->base + 0x0; in pxa_rtc_probe()
360 sa1100_rtc->rtsr = pxa_rtc->base + 0x8; in pxa_rtc_probe()
361 sa1100_rtc->rtar = pxa_rtc->base + 0x4; in pxa_rtc_probe()
362 sa1100_rtc->rttr = pxa_rtc->base + 0xc; in pxa_rtc_probe()
369 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); in pxa_rtc_probe()
371 pxa_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pxa-rtc", in pxa_rtc_probe()
373 if (IS_ERR(pxa_rtc->rtc)) { in pxa_rtc_probe()
374 ret = PTR_ERR(pxa_rtc->rtc); in pxa_rtc_probe()
403 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_suspend() local
406 enable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm); in pxa_rtc_suspend()
412 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_resume() local
415 disable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm); in pxa_rtc_resume()