Lines Matching +full:single +full:- +full:shot
1 /*-
2 * SPDX-License-Identifier: BSD-2-Clause
51 bus_space_write_4((_sc)->sc_iot, (_sc)->sc_ioh, (_r), (_v))
53 bus_space_read_4((_sc)->sc_iot, (_sc)->sc_ioh, (_r))
97 { -1, 0 }
101 {"fsl,imx6dl-gpt", 1},
102 {"fsl,imx6q-gpt", 1},
103 {"fsl,imx6ul-gpt", 1},
104 {"fsl,imx53-gpt", 1},
105 {"fsl,imx51-gpt", 1},
106 {"fsl,imx31-gpt", 1},
107 {"fsl,imx27-gpt", 1},
108 {"fsl,imx25-gpt", 1},
120 * We only support a single unit, because the only thing this driver in imx_gpt_probe()
128 if (ofw_bus_search_compatible(dev, compat_data)->ocd_data != 0) { in imx_gpt_probe()
145 if (bus_alloc_resources(dev, imx_gpt_spec, sc->res)) { in imx_gpt_attach()
150 sc->sc_dev = dev; in imx_gpt_attach()
151 sc->sc_iot = rman_get_bustag(sc->res[0]); in imx_gpt_attach()
152 sc->sc_ioh = rman_get_bushandle(sc->res[0]); in imx_gpt_attach()
159 sc->sc_clksrc = GPT_CR_CLKSRC_IPG; in imx_gpt_attach()
163 switch (sc->sc_clksrc) { in imx_gpt_attach()
181 sc->sc_clksrc); in imx_gpt_attach()
194 /* Choose the clock and the power-saving behaviors. */ in imx_gpt_attach()
196 sc->sc_clksrc | /* Use selected clock */ in imx_gpt_attach()
219 sc->clkfreq = basefreq; in imx_gpt_attach()
222 sc->clkfreq = basefreq / prescale; in imx_gpt_attach()
223 prescale -= 1; /* 1..n range is 0..n-1 in hardware. */ in imx_gpt_attach()
235 sc->clkfreq / 1000, basefreq, READ4(sc, IMX_GPT_CR), READ4(sc, IMX_GPT_PR)); in imx_gpt_attach()
238 err = bus_setup_intr(dev, sc->res[1], INTR_TYPE_CLK, imx_gpt_intr, in imx_gpt_attach()
239 NULL, sc, &sc->sc_ih); in imx_gpt_attach()
241 bus_release_resources(dev, imx_gpt_spec, sc->res); in imx_gpt_attach()
248 * Measure how many clock ticks it takes to setup a one-shot event (it's in imx_gpt_attach()
257 setup_ticks = ((t2 - t1 + 1) * 3) / 2; in imx_gpt_attach()
260 sc->et.et_name = "iMXGPT"; in imx_gpt_attach()
261 sc->et.et_flags = ET_FLAGS_ONESHOT | ET_FLAGS_PERIODIC; in imx_gpt_attach()
262 sc->et.et_quality = 800; in imx_gpt_attach()
263 sc->et.et_frequency = sc->clkfreq; in imx_gpt_attach()
264 sc->et.et_min_period = ((uint64_t)setup_ticks << 32) / sc->clkfreq; in imx_gpt_attach()
265 sc->et.et_max_period = ((uint64_t)0xfffffffe << 32) / sc->clkfreq; in imx_gpt_attach()
266 sc->et.et_start = imx_gpt_timer_start; in imx_gpt_attach()
267 sc->et.et_stop = imx_gpt_timer_stop; in imx_gpt_attach()
268 sc->et.et_priv = sc; in imx_gpt_attach()
269 et_register(&sc->et); in imx_gpt_attach()
272 imx_gpt_timecounter.tc_frequency = sc->clkfreq; in imx_gpt_attach()
290 sc = (struct imx_gpt_softc *)et->et_priv; in imx_gpt_timer_start()
293 sc->sc_period = ((uint32_t)et->et_frequency * period) >> 32; in imx_gpt_timer_start()
295 WRITE4(sc, IMX_GPT_OCR2, READ4(sc, IMX_GPT_CNT) + sc->sc_period); in imx_gpt_timer_start()
297 sc->ir_reg |= GPT_IR_OF2; in imx_gpt_timer_start()
298 WRITE4(sc, IMX_GPT_IR, sc->ir_reg); in imx_gpt_timer_start()
302 if ((sc->ir_reg & GPT_IR_OF3) == 0) { in imx_gpt_timer_start()
303 sc->ir_reg |= GPT_IR_OF3; in imx_gpt_timer_start()
304 WRITE4(sc, IMX_GPT_IR, sc->ir_reg); in imx_gpt_timer_start()
306 ticks = ((uint32_t)et->et_frequency * first) >> 32; in imx_gpt_timer_start()
324 sc = (struct imx_gpt_softc *)et->et_priv; in imx_gpt_timer_stop()
327 sc->ir_reg &= ~(GPT_IR_OF2 | GPT_IR_OF3); in imx_gpt_timer_stop()
328 WRITE4(sc, IMX_GPT_IR, sc->ir_reg); in imx_gpt_timer_stop()
330 sc->sc_period = 0; in imx_gpt_timer_stop()
347 * often sets up a new one-shot timer event and if the interval is short in imx_gpt_intr()
353 /* Handle one-shot timer events. */ in imx_gpt_intr()
355 if (sc->et.et_active) { in imx_gpt_intr()
356 sc->et.et_event_cb(&sc->et, sc->et.et_arg); in imx_gpt_intr()
362 if (sc->et.et_active) in imx_gpt_intr()
363 sc->et.et_event_cb(&sc->et, sc->et.et_arg); in imx_gpt_intr()
364 if (sc->sc_period != 0) in imx_gpt_intr()
366 sc->sc_period); in imx_gpt_intr()
377 sc = tc->tc_priv; in imx_gpt_get_timecount()
403 * Calculate the tick count with 64-bit values so that it works for any in imx_gpt_do_delay()
405 * If the 32-bit hardware count rolls over while we're looping, just in imx_gpt_do_delay()
407 * that doing this on each loop iteration is inefficient -- we're trying in imx_gpt_do_delay()
410 ticks = 1 + ((uint64_t)usec * sc->clkfreq) / 1000000; in imx_gpt_do_delay()