コード例 #1
0
ファイル: hwtimer.c プロジェクト: Basavaraja-MS/ec_local
int __hw_clock_source_init(uint32_t start_t)
{
	/* Set the reload and current value. */
	GR_TIMEHS_BGLOAD(0, 1) = 0xffffffff;
	GR_TIMEHS_LOAD(0, 1) = 0xffffffff;

	/* HW Timer enabled, periodic, interrupt enabled, 32-bit, wrapping */
	GR_TIMEHS_CONTROL(0, 1) = 0xe2;
	/* Event timer disabled */
	__hw_clock_event_clear();

	/* Account for the clock speed. */
	update_prescaler();

	/* Clear any pending interrupts */
	GR_TIMEHS_INTCLR(0, 1) = 0x1;

	/* Force the time to whatever we're told it is */
	__hw_clock_source_set(start_t);

	/* Here we go... */
	task_enable_irq(GC_IRQNUM_TIMEHS0_TIMINT1);
	task_enable_irq(GC_IRQNUM_TIMEHS0_TIMINT2);

	/* Return the Event timer IRQ number (NOT the HW timer IRQ) */
	return GC_IRQNUM_TIMEHS0_TIMINT2;
}
コード例 #2
0
int __hw_clock_source_init(uint32_t start_t)
{
	/* bit3, timer 3 and timer 4 combinational mode */
	IT83XX_ETWD_ETXCTRL(FREE_EXT_TIMER_L) |= (1 << 3);
	/* init free running timer (timer 4, TIMER_H), clock source is 8mhz */
	ext_timer_ms(FREE_EXT_TIMER_H, EXT_PSR_8M_HZ, 0, 1, 0xffffffff, 1, 1);
	/* 1us counter settiing (timer 3, TIMER_L) */
	ext_timer_ms(FREE_EXT_TIMER_L, EXT_PSR_8M_HZ, 1, 0, 7, 1, 1);
	__hw_clock_source_set(start_t);
	/* init event timer */
	ext_timer_ms(EVENT_EXT_TIMER, EXT_PSR_8M_HZ, 0, 0, 0xffffffff, 1, 1);
	/* returns the IRQ number of event timer */
	return et_ctrl_regs[EVENT_EXT_TIMER].irq;
}
コード例 #3
0
ファイル: hwtimer.c プロジェクト: coreboot/chrome-ec
int __hw_clock_source_init(uint32_t start_t)
{
#ifdef BOARD_REI
	/* reload_val = (0xFFFFFFFF / SECOND) * clock_get_freq(); */
	/* reload_val = 0xFFFFFFFF; */
#endif /* defined(BOARD_REI) */
	/*
	 * Use Timer 0 as the clock.  The clock source for the timer block
	 * cannot be prescaled down to 1MHz, therefore, we'll have to handle the
	 * rollovers.
	 *
	 * There's also no match functionality, so set up an additional timer,
	 * Timer 1, to handle events.
	 */

	/* Disable the timers. */
	ROTOR_MCU_TMR_TNCR(0) &= ~(1 << 0);
	ROTOR_MCU_TMR_TNCR(1) &= ~(1 << 0);

	/*
	 * Timer 0
	 *
	 * Unmask interrupt, set user-defined count mode, and disable PWM.
	 */
	ROTOR_MCU_TMR_TNCR(0) = (1 << 1);

	/* Use the specified start timer value and start the timer. */
	__hw_clock_source_set(start_t);

	/*
	 * Timer 1
	 *
	 * Unmask interrupt, set user-defined count mode, and disable PWM.
	 */
	ROTOR_MCU_TMR_TNCR(1) = (1 << 1);

	/* Enable interrupts. */
	task_enable_irq(ROTOR_MCU_IRQ_TIMER_0);
	task_enable_irq(ROTOR_MCU_IRQ_TIMER_1);

	/* Return event timer IRQ number. */
	return ROTOR_MCU_IRQ_TIMER_1;
}