Lines Matching +full:signal +full:- +full:guard
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Intel PPS signal Generator Driver
14 #include <linux/io-64-nonatomic-hi-lo.h>
39 #define MAGIC_CONST (NSEC_PER_SEC - SAFE_TIME_NS)
54 return readl(tio->base + offset); in pps_tio_read()
59 writel(value, tio->base + TIOCTL); in pps_ctl_write()
64 * higher 32-bit followed by lower 32-bit
68 hi_lo_writeq(value, tio->base + TIOCOMPV); in pps_compv_write()
85 tio->pps_gen->enabled = false; in pps_tio_disable()
86 tio->prev_count = 0; in pps_tio_disable()
97 tio->pps_gen->enabled = true; in pps_tio_enable()
127 pps_compv_write(art - ART_HW_DELAY_CYCLES, tio); in pps_generate_next_pulse()
137 guard(spinlock)(&tio->lock); in hrtimer_callback()
144 if (tio->prev_count && tio->prev_count == event_count) in hrtimer_callback()
146 tio->prev_count = event_count; in hrtimer_callback()
151 if (now - expires >= SAFE_TIME_NS) in hrtimer_callback()
154 tio->pps_gen->enabled = pps_generate_next_pulse(expires + SAFE_TIME_NS, tio); in hrtimer_callback()
155 if (!tio->pps_gen->enabled) in hrtimer_callback()
162 dev_err(tio->dev, "Event missed, Disabling Timed I/O"); in hrtimer_callback()
164 pps_gen_event(tio->pps_gen, PPS_GEN_EVENT_MISSEDPULSE, NULL); in hrtimer_callback()
170 struct pps_tio *tio = container_of(pps_gen->info, struct pps_tio, gen_info); in pps_tio_gen_enable()
173 dev_err_once(tio->dev, "PPS cannot be used as clock is not related to ART"); in pps_tio_gen_enable()
174 return -ENODEV; in pps_tio_gen_enable()
177 guard(spinlock_irqsave)(&tio->lock); in pps_tio_gen_enable()
178 if (enable && !pps_gen->enabled) { in pps_tio_gen_enable()
180 hrtimer_start(&tio->timer, first_event(tio), HRTIMER_MODE_ABS); in pps_tio_gen_enable()
181 } else if (!enable && pps_gen->enabled) { in pps_tio_gen_enable()
182 hrtimer_cancel(&tio->timer); in pps_tio_gen_enable()
202 struct device *dev = &pdev->dev; in pps_gen_tio_probe()
208 return -ENODEV; in pps_gen_tio_probe()
213 return -ENOMEM; in pps_gen_tio_probe()
215 tio->gen_info.use_system_clock = true; in pps_gen_tio_probe()
216 tio->gen_info.enable = pps_tio_gen_enable; in pps_gen_tio_probe()
217 tio->gen_info.get_time = pps_tio_get_time; in pps_gen_tio_probe()
218 tio->gen_info.owner = THIS_MODULE; in pps_gen_tio_probe()
220 tio->pps_gen = pps_gen_register_source(&tio->gen_info); in pps_gen_tio_probe()
221 if (IS_ERR(tio->pps_gen)) in pps_gen_tio_probe()
222 return PTR_ERR(tio->pps_gen); in pps_gen_tio_probe()
224 tio->dev = dev; in pps_gen_tio_probe()
225 tio->base = devm_platform_ioremap_resource(pdev, 0); in pps_gen_tio_probe()
226 if (IS_ERR(tio->base)) in pps_gen_tio_probe()
227 return PTR_ERR(tio->base); in pps_gen_tio_probe()
230 hrtimer_setup(&tio->timer, hrtimer_callback, CLOCK_REALTIME, in pps_gen_tio_probe()
232 spin_lock_init(&tio->lock); in pps_gen_tio_probe()
242 hrtimer_cancel(&tio->timer); in pps_gen_tio_remove()
244 pps_gen_unregister_source(tio->pps_gen); in pps_gen_tio_remove()
260 .name = "intel-pps-gen-tio",
271 MODULE_DESCRIPTION("Intel PMC Time-Aware IO Generator Driver");