FreeBSD/sys/arm/xscale/ixp425/ixp425_timer.c
/*
 * cpu_initclocks:
 *
 *	Initialize the clock and get them going.
 */
Initialize the clock and get them going.
Initialize the clock and get them going .
void
cpu_initclocks(void)
{
	struct ixpclk_softc* sc = ixpclk_sc;
	struct resource *irq;
	device_t dev = sc->sc_dev;
	u_int oldirqstate;
	int rid = 0;
	void *ihl;
	if (hz < 50 || COUNTS_PER_SEC % hz) {
		printf("Cannot get %d Hz clock; using 100 Hz\n", hz);
		hz = 100;
	}
	tick = 1000000 / hz;	
	if (stathz != 0)
		printf("Cannot get %d Hz statclock\n", stathz);
	stathz = 0;
	if (profhz != 0)
		printf("Cannot get %d Hz profclock\n", profhz);
	profhz = 0;
	oldirqstate = disable_interrupts(PSR_I);
	irq = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, IXP425_INT_TMR0,
	    IXP425_INT_TMR0, 1, RF_ACTIVE);
	if (!irq)
		panic("Unable to setup the clock irq handler.\n");
	else
		bus_setup_intr(dev, irq, INTR_TYPE_CLK, ixpclk_intr, NULL,
		    NULL, &ihl);
	bus_space_write_4(sc->sc_iot, sc->sc_ioh, IXP425_OST_STATUS,
			  OST_WARM_RESET | OST_WDOG_INT | OST_TS_INT |
			  OST_TIM1_INT | OST_TIM0_INT);
	counts_per_hz = COUNTS_PER_SEC / hz;
	bus_space_write_4(sc->sc_iot, sc->sc_ioh, IXP425_OST_TIM0_RELOAD,
			  (counts_per_hz & TIMERRELOAD_MASK) | OST_TIMER_EN);
	tc_init(&ixp425_timer_timecounter);
	restore_interrupts(oldirqstate);
	rid = 0;
}
void cpu_initclocks ( void ) { struct ixpclk_softc * sc = ixpclk_sc ; struct resource * irq ; device_t dev = sc -> sc_dev ; u_int oldirqstate ; int rid = 0 ; void * ihl ; if ( hz < 50 || COUNTS_PER_SEC % hz ) { printf ( " \n " , hz ) ; hz = 100 ; } tick = 1000000 / hz ; if ( stathz != 0 ) printf ( " \n " , stathz ) ; stathz = 0 ; if ( profhz != 0 ) printf ( " \n " , profhz ) ; profhz = 0 ; oldirqstate = disable_interrupts ( PSR_I ) ; irq = bus_alloc_resource ( dev , SYS_RES_IRQ , & rid , IXP425_INT_TMR0 , IXP425_INT_TMR0 , 1 , RF_ACTIVE ) ; if ( ! irq ) panic ( " \n " ) ; else bus_setup_intr ( dev , irq , INTR_TYPE_CLK , ixpclk_intr , NULL , NULL , & ihl ) ; bus_space_write_4 ( sc -> sc_iot , sc -> sc_ioh , IXP425_OST_STATUS , OST_WARM_RESET | OST_WDOG_INT | OST_TS_INT | OST_TIM1_INT | OST_TIM0_INT ) ; counts_per_hz = COUNTS_PER_SEC / hz ; bus_space_write_4 ( sc -> sc_iot , sc -> sc_ioh , IXP425_OST_TIM0_RELOAD , ( counts_per_hz & TIMERRELOAD_MASK ) | OST_TIMER_EN ) ; tc_init ( & ixp425_timer_timecounter ) ; restore_interrupts ( oldirqstate ) ; rid = 0 ; }
cpu_initclocks:
      Initialize the clock and get them going.
cpu_initclocks : Initialize the clock and get them going .
/* number of microseconds between interrupts */ /*
	 * We only have one timer available; stathz and profhz are
	 * always left as 0 (the upper-layer clock code deals with
	 * this situation).
	 */ /* Report the clock frequency. */ /* Set up the new clock parameters. */ /* clear interrupt */ /* reload value & Timer enable */