Lines Matching +full:switch +full:- +full:freq +full:- +full:select

1 /*-
2 * SPDX-License-Identifier: BSD-3-Clause
84 TUNABLE_INT("hw.i8254.freq", &i8254_freq);
111 static int timer0_period = -2;
141 if (i8254_timecounter && sc->period != 0) { in clkintr()
153 if (sc->et.et_active && sc->mode != MODE_STOP) in clkintr()
154 sc->et.et_event_cb(&sc->et, sc->et.et_arg); in clkintr()
167 return (-1); in timer_spkr_acquire()
173 * knew the rate. Use of splclock() limits glitches to 10-100us, in timer_spkr_acquire()
188 return (-1); in timer_spkr_release()
197 timer_spkr_setfreq(int freq) in timer_spkr_setfreq() argument
200 freq = i8254_freq / freq; in timer_spkr_setfreq()
202 outb(TIMER_CNTR2, freq & 0xff); in timer_spkr_setfreq()
203 outb(TIMER_CNTR2, freq >> 8); in timer_spkr_setfreq()
214 /* Select timer0 and latch counter value. */ in getit()
265 n -= 0; /* XXX actually guess no initial overhead */ in i8254_delay()
279 ticks_left = ((u_int)n * 39099 + (1 << 15) - 1) >> 15; in i8254_delay()
282 * Don't bother using fixed point, although gcc-2.7.2 in i8254_delay()
294 tick = prev_tick - 1; in i8254_delay()
303 delta = prev_tick - tick; in i8254_delay()
316 ticks_left -= delta; in i8254_delay()
336 new_count = -1; in set_i8254_freq()
344 timer0_period = (mode == MODE_PERIODIC) ? new_count : -1; in set_i8254_freq()
345 switch (mode) { in set_i8254_freq()
385 timer0_period = -2; in i8254_restore()
389 set_i8254_freq(attimer_sc->mode, attimer_sc->period); in i8254_restore()
440 u_int freq; in sysctl_machdep_i8254_freq() local
446 freq = i8254_freq; in sysctl_machdep_i8254_freq()
447 error = sysctl_handle_int(oidp, &freq, 0, req); in sysctl_machdep_i8254_freq()
448 if (error == 0 && req->newptr != NULL) { in sysctl_machdep_i8254_freq()
449 i8254_freq = freq; in sysctl_machdep_i8254_freq()
451 set_i8254_freq(attimer_sc->mode, attimer_sc->period); in sysctl_machdep_i8254_freq()
452 attimer_sc->tc.tc_frequency = freq; in sysctl_machdep_i8254_freq()
468 device_t dev = (device_t)tc->tc_priv; in i8254_get_timecount()
474 if (sc->period == 0) in i8254_get_timecount()
475 return (i8254_max_count - getit()); in i8254_get_timecount()
484 /* Select timer0 and latch counter value. */ in i8254_get_timecount()
489 count = i8254_max_count - ((high << 8) | low); in i8254_get_timecount()
507 device_t dev = (device_t)et->et_priv; in attimer_start()
511 sc->mode = MODE_PERIODIC; in attimer_start()
512 sc->period = period; in attimer_start()
514 sc->mode = MODE_ONESHOT; in attimer_start()
515 sc->period = first; in attimer_start()
517 if (!sc->intr_en) { in attimer_start()
518 i8254_intsrc->is_pic->pic_enable_source(i8254_intsrc); in attimer_start()
519 sc->intr_en = 1; in attimer_start()
521 set_i8254_freq(sc->mode, sc->period); in attimer_start()
528 device_t dev = (device_t)et->et_priv; in attimer_stop()
531 sc->mode = MODE_STOP; in attimer_stop()
532 sc->period = 0; in attimer_stop()
533 set_i8254_freq(sc->mode, sc->period); in attimer_stop()
552 /* ENOENT means no PnP-ID, device is hinted. */ in attimer_probe()
569 if (!(sc->port_res = bus_alloc_resource(dev, SYS_RES_IOPORT, in attimer_attach()
570 &sc->port_rid, IO_TIMER1, IO_TIMER1 + 3, 4, RF_ACTIVE))) in attimer_attach()
574 i8254_pending = i8254_intsrc->is_pic->pic_source_pending; in attimer_attach()
579 sc->tc.tc_get_timecount = i8254_get_timecount; in attimer_attach()
580 sc->tc.tc_counter_mask = 0xffff; in attimer_attach()
581 sc->tc.tc_frequency = i8254_freq; in attimer_attach()
582 sc->tc.tc_name = "i8254"; in attimer_attach()
583 sc->tc.tc_quality = 0; in attimer_attach()
584 sc->tc.tc_priv = dev; in attimer_attach()
585 tc_init(&sc->tc); in attimer_attach()
589 sc->intr_rid = 0; in attimer_attach()
590 while (bus_get_resource(dev, SYS_RES_IRQ, sc->intr_rid, in attimer_attach()
592 sc->intr_rid++; in attimer_attach()
593 if (!(sc->intr_res = bus_alloc_resource(dev, SYS_RES_IRQ, in attimer_attach()
594 &sc->intr_rid, 0, 0, 1, RF_ACTIVE))) { in attimer_attach()
599 i8254_intsrc->is_handlers++; in attimer_attach()
600 if ((bus_setup_intr(dev, sc->intr_res, in attimer_attach()
603 sc, &sc->intr_handler))) { in attimer_attach()
605 i8254_intsrc->is_handlers--; in attimer_attach()
608 i8254_intsrc->is_handlers--; in attimer_attach()
609 i8254_intsrc->is_pic->pic_enable_intr(i8254_intsrc); in attimer_attach()
610 sc->et.et_name = "i8254"; in attimer_attach()
611 sc->et.et_flags = ET_FLAGS_PERIODIC; in attimer_attach()
613 sc->et.et_flags |= ET_FLAGS_ONESHOT; in attimer_attach()
614 sc->et.et_quality = 100; in attimer_attach()
615 sc->et.et_frequency = i8254_freq; in attimer_attach()
616 sc->et.et_min_period = (0x0002LLU << 32) / i8254_freq; in attimer_attach()
617 sc->et.et_max_period = (0xfffeLLU << 32) / i8254_freq; in attimer_attach()
618 sc->et.et_start = attimer_start; in attimer_attach()
619 sc->et.et_stop = attimer_stop; in attimer_attach()
620 sc->et.et_priv = dev; in attimer_attach()
621 et_register(&sc->et); in attimer_attach()