Lines Matching refs:pxa_rtc

69 #define rtc_readl(pxa_rtc, reg)	\  argument
70 __raw_readl((pxa_rtc)->base + (reg))
71 #define rtc_writel(pxa_rtc, reg, value) \ argument
72 __raw_writel((value), (pxa_rtc)->base + (reg))
74 struct pxa_rtc { struct
110 static void rtsr_clear_bits(struct pxa_rtc *pxa_rtc, u32 mask) in rtsr_clear_bits() argument
114 rtsr = rtc_readl(pxa_rtc, RTSR); in rtsr_clear_bits()
117 rtc_writel(pxa_rtc, RTSR, rtsr); in rtsr_clear_bits()
120 static void rtsr_set_bits(struct pxa_rtc *pxa_rtc, u32 mask) in rtsr_set_bits() argument
124 rtsr = rtc_readl(pxa_rtc, RTSR); in rtsr_set_bits()
127 rtc_writel(pxa_rtc, RTSR, rtsr); in rtsr_set_bits()
132 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev_id); in pxa_rtc_irq() local
136 spin_lock(&pxa_rtc->lock); in pxa_rtc_irq()
139 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_irq()
140 rtc_writel(pxa_rtc, RTSR, rtsr); in pxa_rtc_irq()
143 rtsr_clear_bits(pxa_rtc, RTSR_RDALE1 | RTSR_PIALE | RTSR_HZE); in pxa_rtc_irq()
157 rtc_update_irq(pxa_rtc->rtc, 1, events); in pxa_rtc_irq()
160 rtc_writel(pxa_rtc, RTSR, rtsr & ~RTSR_TRIG_MASK); in pxa_rtc_irq()
162 spin_unlock(&pxa_rtc->lock); in pxa_rtc_irq()
168 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_open() local
171 ret = request_irq(pxa_rtc->sa1100_rtc.irq_1hz, pxa_rtc_irq, 0, in pxa_rtc_open()
175 pxa_rtc->sa1100_rtc.irq_1hz, ret); in pxa_rtc_open()
178 ret = request_irq(pxa_rtc->sa1100_rtc.irq_alarm, pxa_rtc_irq, 0, in pxa_rtc_open()
182 pxa_rtc->sa1100_rtc.irq_alarm, ret); in pxa_rtc_open()
189 free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev); in pxa_rtc_open()
196 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_release() local
198 spin_lock_irq(&pxa_rtc->lock); in pxa_rtc_release()
199 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); in pxa_rtc_release()
200 spin_unlock_irq(&pxa_rtc->lock); in pxa_rtc_release()
202 free_irq(pxa_rtc->sa1100_rtc.irq_1hz, dev); in pxa_rtc_release()
203 free_irq(pxa_rtc->sa1100_rtc.irq_alarm, dev); in pxa_rtc_release()
208 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_alarm_irq_enable() local
210 spin_lock_irq(&pxa_rtc->lock); in pxa_alarm_irq_enable()
213 rtsr_set_bits(pxa_rtc, RTSR_RDALE1); in pxa_alarm_irq_enable()
215 rtsr_clear_bits(pxa_rtc, RTSR_RDALE1); in pxa_alarm_irq_enable()
217 spin_unlock_irq(&pxa_rtc->lock); in pxa_alarm_irq_enable()
223 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_read_time() local
226 rycr = rtc_readl(pxa_rtc, RYCR); in pxa_rtc_read_time()
227 rdcr = rtc_readl(pxa_rtc, RDCR); in pxa_rtc_read_time()
235 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_set_time() local
237 rtc_writel(pxa_rtc, RYCR, ryxr_calc(tm)); in pxa_rtc_set_time()
238 rtc_writel(pxa_rtc, RDCR, rdxr_calc(tm)); in pxa_rtc_set_time()
245 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_read_alarm() local
248 ryar = rtc_readl(pxa_rtc, RYAR1); in pxa_rtc_read_alarm()
249 rdar = rtc_readl(pxa_rtc, RDAR1); in pxa_rtc_read_alarm()
252 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_read_alarm()
260 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_set_alarm() local
263 spin_lock_irq(&pxa_rtc->lock); in pxa_rtc_set_alarm()
265 rtc_writel(pxa_rtc, RYAR1, ryxr_calc(&alrm->time)); in pxa_rtc_set_alarm()
266 rtc_writel(pxa_rtc, RDAR1, rdxr_calc(&alrm->time)); in pxa_rtc_set_alarm()
268 rtsr = rtc_readl(pxa_rtc, RTSR); in pxa_rtc_set_alarm()
273 rtc_writel(pxa_rtc, RTSR, rtsr); in pxa_rtc_set_alarm()
275 spin_unlock_irq(&pxa_rtc->lock); in pxa_rtc_set_alarm()
282 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_proc() local
284 seq_printf(seq, "trim/divider\t: 0x%08x\n", rtc_readl(pxa_rtc, RTTR)); in pxa_rtc_proc()
286 (rtc_readl(pxa_rtc, RTSR) & RTSR_HZE) ? "yes" : "no"); in pxa_rtc_proc()
288 (rtc_readl(pxa_rtc, RTSR) & RTSR_PIALE) ? "yes" : "no"); in pxa_rtc_proc()
289 seq_printf(seq, "periodic_freq\t: %u\n", rtc_readl(pxa_rtc, PIAR)); in pxa_rtc_proc()
306 struct pxa_rtc *pxa_rtc; in pxa_rtc_probe() local
310 pxa_rtc = devm_kzalloc(dev, sizeof(*pxa_rtc), GFP_KERNEL); in pxa_rtc_probe()
311 if (!pxa_rtc) in pxa_rtc_probe()
313 sa1100_rtc = &pxa_rtc->sa1100_rtc; in pxa_rtc_probe()
315 spin_lock_init(&pxa_rtc->lock); in pxa_rtc_probe()
316 platform_set_drvdata(pdev, pxa_rtc); in pxa_rtc_probe()
318 pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0); in pxa_rtc_probe()
319 if (!pxa_rtc->ress) { in pxa_rtc_probe()
335 pxa_rtc->base = devm_ioremap(dev, pxa_rtc->ress->start, in pxa_rtc_probe()
336 resource_size(pxa_rtc->ress)); in pxa_rtc_probe()
337 if (!pxa_rtc->base) { in pxa_rtc_probe()
344 sa1100_rtc->rcnr = pxa_rtc->base + 0x0; in pxa_rtc_probe()
345 sa1100_rtc->rtsr = pxa_rtc->base + 0x8; in pxa_rtc_probe()
346 sa1100_rtc->rtar = pxa_rtc->base + 0x4; in pxa_rtc_probe()
347 sa1100_rtc->rttr = pxa_rtc->base + 0xc; in pxa_rtc_probe()
354 rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE); in pxa_rtc_probe()
356 pxa_rtc->rtc = devm_rtc_device_register(&pdev->dev, "pxa-rtc", in pxa_rtc_probe()
358 if (IS_ERR(pxa_rtc->rtc)) { in pxa_rtc_probe()
359 ret = PTR_ERR(pxa_rtc->rtc); in pxa_rtc_probe()
388 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_suspend() local
391 enable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm); in pxa_rtc_suspend()
397 struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); in pxa_rtc_resume() local
400 disable_irq_wake(pxa_rtc->sa1100_rtc.irq_alarm); in pxa_rtc_resume()