Lines Matching refs:rtc

64 static inline void ftm_counter_enable(struct ftm_rtc *rtc)  in ftm_counter_enable()  argument
69 val = rtc_readl(rtc, FTM_SC); in ftm_counter_enable()
72 rtc_writel(rtc, FTM_SC, val); in ftm_counter_enable()
75 static inline void ftm_counter_disable(struct ftm_rtc *rtc) in ftm_counter_disable() argument
80 val = rtc_readl(rtc, FTM_SC); in ftm_counter_disable()
82 rtc_writel(rtc, FTM_SC, val); in ftm_counter_disable()
85 static inline void ftm_irq_acknowledge(struct ftm_rtc *rtc) in ftm_irq_acknowledge() argument
110 while ((FTM_SC_TOF & rtc_readl(rtc, FTM_SC)) && timeout--) in ftm_irq_acknowledge()
111 rtc_writel(rtc, FTM_SC, rtc_readl(rtc, FTM_SC) & (~FTM_SC_TOF)); in ftm_irq_acknowledge()
114 static inline void ftm_irq_enable(struct ftm_rtc *rtc) in ftm_irq_enable() argument
118 val = rtc_readl(rtc, FTM_SC); in ftm_irq_enable()
120 rtc_writel(rtc, FTM_SC, val); in ftm_irq_enable()
123 static inline void ftm_irq_disable(struct ftm_rtc *rtc) in ftm_irq_disable() argument
127 val = rtc_readl(rtc, FTM_SC); in ftm_irq_disable()
129 rtc_writel(rtc, FTM_SC, val); in ftm_irq_disable()
132 static inline void ftm_reset_counter(struct ftm_rtc *rtc) in ftm_reset_counter() argument
139 rtc_writel(rtc, FTM_CNT, 0x00); in ftm_reset_counter()
142 static void ftm_clean_alarm(struct ftm_rtc *rtc) in ftm_clean_alarm() argument
144 ftm_counter_disable(rtc); in ftm_clean_alarm()
146 rtc_writel(rtc, FTM_CNTIN, 0x00); in ftm_clean_alarm()
147 rtc_writel(rtc, FTM_MOD, ~0U); in ftm_clean_alarm()
149 ftm_reset_counter(rtc); in ftm_clean_alarm()
154 struct ftm_rtc *rtc = dev; in ftm_rtc_alarm_interrupt() local
156 rtc_update_irq(rtc->rtc_dev, 1, RTC_IRQF | RTC_AF); in ftm_rtc_alarm_interrupt()
158 ftm_irq_acknowledge(rtc); in ftm_rtc_alarm_interrupt()
159 ftm_irq_disable(rtc); in ftm_rtc_alarm_interrupt()
160 ftm_clean_alarm(rtc); in ftm_rtc_alarm_interrupt()
168 struct ftm_rtc *rtc = dev_get_drvdata(dev); in ftm_rtc_alarm_irq_enable() local
171 ftm_irq_enable(rtc); in ftm_rtc_alarm_irq_enable()
173 ftm_irq_disable(rtc); in ftm_rtc_alarm_irq_enable()
212 struct ftm_rtc *rtc = dev_get_drvdata(dev); in ftm_rtc_set_alarm() local
216 ftm_clean_alarm(rtc); in ftm_rtc_set_alarm()
217 cycle = (alm_time - ktime_get_real_seconds()) * rtc->alarm_freq; in ftm_rtc_set_alarm()
223 ftm_irq_disable(rtc); in ftm_rtc_set_alarm()
231 rtc_writel(rtc, FTM_MOD, cycle - 1); in ftm_rtc_set_alarm()
233 ftm_counter_enable(rtc); in ftm_rtc_set_alarm()
234 ftm_irq_enable(rtc); in ftm_rtc_set_alarm()
251 struct ftm_rtc *rtc; in ftm_rtc_probe() local
253 rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); in ftm_rtc_probe()
254 if (unlikely(!rtc)) { in ftm_rtc_probe()
259 platform_set_drvdata(pdev, rtc); in ftm_rtc_probe()
261 rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev); in ftm_rtc_probe()
262 if (IS_ERR(rtc->rtc_dev)) in ftm_rtc_probe()
263 return PTR_ERR(rtc->rtc_dev); in ftm_rtc_probe()
265 rtc->base = devm_platform_ioremap_resource(pdev, 0); in ftm_rtc_probe()
266 if (IS_ERR(rtc->base)) { in ftm_rtc_probe()
268 return PTR_ERR(rtc->base); in ftm_rtc_probe()
276 0, dev_name(&pdev->dev), rtc); in ftm_rtc_probe()
282 rtc->big_endian = in ftm_rtc_probe()
285 rtc->alarm_freq = (u32)FIXED_FREQ_CLK / (u32)MAX_FREQ_DIV; in ftm_rtc_probe()
286 rtc->rtc_dev->ops = &ftm_rtc_ops; in ftm_rtc_probe()
293 ret = devm_rtc_register_device(rtc->rtc_dev); in ftm_rtc_probe()