Lines Matching defs:tio

52 static inline u32 pps_tio_read(u32 offset, struct pps_tio *tio)
54 return readl(tio->base + offset);
57 static inline void pps_ctl_write(u32 value, struct pps_tio *tio)
59 writel(value, tio->base + TIOCTL);
66 static inline void pps_compv_write(u64 value, struct pps_tio *tio)
68 hi_lo_writeq(value, tio->base + TIOCOMPV);
71 static inline ktime_t first_event(struct pps_tio *tio)
76 static u32 pps_tio_disable(struct pps_tio *tio)
80 ctrl = pps_tio_read(TIOCTL, tio);
81 pps_compv_write(0, tio);
84 pps_ctl_write(ctrl, tio);
85 tio->pps_gen->enabled = false;
86 tio->prev_count = 0;
90 static void pps_tio_enable(struct pps_tio *tio)
94 ctrl = pps_tio_read(TIOCTL, tio);
96 pps_ctl_write(ctrl, tio);
97 tio->pps_gen->enabled = true;
100 static void pps_tio_direction_output(struct pps_tio *tio)
104 ctrl = pps_tio_disable(tio);
110 pps_compv_write(0, tio);
114 pps_ctl_write(ctrl, tio);
115 pps_tio_enable(tio);
118 static bool pps_generate_next_pulse(ktime_t expires, struct pps_tio *tio)
123 pps_tio_disable(tio);
127 pps_compv_write(art - ART_HW_DELAY_CYCLES, tio);
135 struct pps_tio *tio = container_of(timer, struct pps_tio, timer);
137 guard(spinlock)(&tio->lock);
143 event_count = pps_tio_read(TIOEC, tio);
144 if (tio->prev_count && tio->prev_count == event_count)
146 tio->prev_count = event_count;
154 tio->pps_gen->enabled = pps_generate_next_pulse(expires + SAFE_TIME_NS, tio);
155 if (!tio->pps_gen->enabled)
162 dev_err(tio->dev, "Event missed, Disabling Timed I/O");
163 pps_tio_disable(tio);
164 pps_gen_event(tio->pps_gen, PPS_GEN_EVENT_MISSEDPULSE, NULL);
170 struct pps_tio *tio = container_of(pps_gen->info, struct pps_tio, gen_info);
173 dev_err_once(tio->dev, "PPS cannot be used as clock is not related to ART");
177 guard(spinlock_irqsave)(&tio->lock);
179 pps_tio_direction_output(tio);
180 hrtimer_start(&tio->timer, first_event(tio), HRTIMER_MODE_ABS);
182 hrtimer_cancel(&tio->timer);
183 pps_tio_disable(tio);
203 struct pps_tio *tio;
211 tio = devm_kzalloc(dev, sizeof(*tio), GFP_KERNEL);
212 if (!tio)
215 tio->gen_info.use_system_clock = true;
216 tio->gen_info.enable = pps_tio_gen_enable;
217 tio->gen_info.get_time = pps_tio_get_time;
218 tio->gen_info.owner = THIS_MODULE;
220 tio->pps_gen = pps_gen_register_source(&tio->gen_info);
221 if (IS_ERR(tio->pps_gen))
222 return PTR_ERR(tio->pps_gen);
224 tio->dev = dev;
225 tio->base = devm_platform_ioremap_resource(pdev, 0);
226 if (IS_ERR(tio->base))
227 return PTR_ERR(tio->base);
229 pps_tio_disable(tio);
230 hrtimer_setup(&tio->timer, hrtimer_callback, CLOCK_REALTIME,
232 spin_lock_init(&tio->lock);
233 platform_set_drvdata(pdev, tio);
240 struct pps_tio *tio = platform_get_drvdata(pdev);
242 hrtimer_cancel(&tio->timer);
243 pps_tio_disable(tio);
244 pps_gen_unregister_source(tio->pps_gen);
260 .name = "intel-pps-gen-tio",