void setstatclockrate(int schz) { /* Stop the timer from counting, but keep the timer module working. */ bus_space_write_4(stat_sc->sc_iot, stat_sc->sc_ioh, MPU_CNTL_TIMER, MPU_CLOCK_ENABLE); timer_factors tf; calc_timer_factors(schz, &tf); /* Set the reload value. */ bus_space_write_4(stat_sc->sc_iot, stat_sc->sc_ioh, MPU_LOAD_TIMER, tf.reload); /* Set the PTV and the other required bits and pieces. */ bus_space_write_4(stat_sc->sc_iot, stat_sc->sc_ioh, MPU_CNTL_TIMER, ( MPU_CLOCK_ENABLE | (tf.ptv << MPU_PTV_SHIFT) | MPU_AR | MPU_ST)); }
void omapmputmr_attach(struct device *parent, struct device *self, void *aux) { struct omapmputmr_softc *sc = (struct omapmputmr_softc*)self; struct tipb_attach_args *tipb = aux; int ints_per_sec; sc->sc_iot = tipb->tipb_iot; sc->sc_intr = tipb->tipb_intr; if (bus_space_map(tipb->tipb_iot, tipb->tipb_addr, tipb->tipb_size, 0, &sc->sc_ioh)) panic("%s: Cannot map registers", self->dv_xname); switch (self->dv_unit) { case 0: clock_sc = sc; ints_per_sec = hz; break; case 1: stat_sc = sc; ints_per_sec = profhz = stathz = STATHZ; break; case 2: ref_sc = sc; ints_per_sec = hz; /* Same rate as clock */ break; default: ints_per_sec = hz; /* Better value? */ break; } aprint_normal(": OMAP MPU Timer\n"); aprint_naive("\n"); /* Stop the timer from counting, but keep the timer module working. */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, MPU_CNTL_TIMER, MPU_CLOCK_ENABLE); timer_factors tf; calc_timer_factors(ints_per_sec, &tf); switch (self->dv_unit) { case 0: counts_per_hz = tf.reload + 1; counts_per_usec = tf.counts_per_usec; break; case 2: /* * The microtime reference clock for all practical purposes * just wraps around as an unsigned int. */ tf.reload = 0xffffffff; break; default: break; } /* Set the reload value. */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, MPU_LOAD_TIMER, tf.reload); /* Set the PTV and the other required bits and pieces. */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, MPU_CNTL_TIMER, ( MPU_CLOCK_ENABLE | (tf.ptv << MPU_PTV_SHIFT) | MPU_AR | MPU_ST)); /* The clock is now running, but is not generating interrupts. */ }
void obiomputmr_attach(device_t parent, device_t self, void *aux) { struct mputmr_softc *sc = device_private(self); struct obio_attach_args *obio = aux; int ints_per_sec; sc->sc_dev = self; sc->sc_iot = obio->obio_iot; sc->sc_intr = obio->obio_intr; if (bus_space_map(obio->obio_iot, obio->obio_addr, obio->obio_size, 0, &sc->sc_ioh)) panic("%s: Cannot map registers", device_xname(self)); switch (device_unit(self)) { /* XXX broken */ case 0: clock_sc = sc; ints_per_sec = hz; break; case 1: stat_sc = sc; ints_per_sec = profhz = stathz = STATHZ; break; case 2: ref_sc = sc; ints_per_sec = hz; /* Same rate as clock */ break; default: ints_per_sec = hz; /* Better value? */ break; } aprint_normal(": OMAP MPU Timer"); gpt_enable(sc, obio, gpt_lookup(obio)); aprint_normal("\n"); aprint_naive("\n"); #if defined(OMAP_2430) || defined(OMAP_2420) /* Stop the timer from counting, but keep the timer module working. */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, MPU_CNTL_TIMER, MPU_CLOCK_ENABLE); #endif timer_factors tf; calc_timer_factors(ints_per_sec, &tf); switch (device_unit(self)) { /* XXX broken */ case 0: #ifndef ARM11_PMC counts_per_hz = tf.reload + 1; counts_per_usec = tf.counts_per_usec; #endif break; case 2: /* * The microtime reference clock for all practical purposes * just wraps around as an unsigned int. */ tf.reload = 0xffffffff; break; default: break; } #if defined(OMAP_2430) || defined(OMAP_2420) /* Set the reload value. */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, MPU_LOAD_TIMER, tf.reload); /* Set the PTV and the other required bits and pieces. */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, MPU_CNTL_TIMER, ( MPU_CLOCK_ENABLE | (tf.ptv << MPU_PTV_SHIFT) | MPU_AR | MPU_ST)); /* The clock is now running, but is not generating interrupts. */ #endif }