Example #1
0
static void test_operation(void)
{
    if (opcode == 0) {
        dump_timer_regs();
    } else if (opcode == 1) {
        write_cntp_tval(op1);
        write_cntp_ctl(op2);
    }
}
Example #2
0
static int generic_timer_set_next_event(unsigned long evt,
			struct clock_event_device *unused)
{
    write_cntp_tval(evt);
    write_cntp_ctl(CNTP_CTL_ENABLE);

    save_localtimer_info(evt, 0);

	return 0;
}
Example #3
0
status_t platform_set_oneshot_timer(platform_timer_callback callback, void *arg, lk_time_t interval)
{
	uint64_t cntpct_interval = lk_time_to_cntpct(interval);

	ASSERT(arg == NULL);

	t_callback = callback;
	if (cntpct_interval <= INT_MAX)
		write_cntp_tval(cntpct_interval);
	else
		write_cntp_cval(read_cntpct() + cntpct_interval);
	write_cntp_ctl(1);

	return 0;
}
static void test_start_timer(void)
{
    uint32_t ctl;
    uint32_t tval;
    uint64_t pct;
    HVMM_TRACE_ENTER();
    /* every second */
    tval = read_cntfrq();
    write_cntp_tval(tval);
    pct = read_cntpct();
    uart_print("cntpct:");
    uart_print_hex64(pct);
    uart_print("\n\r");
    uart_print("cntp_tval:");
    uart_print_hex32(tval);
    uart_print("\n\r");
    /* enable timer */
    ctl = read_cntp_ctl();
    ctl |= 0x1;
    write_cntp_ctl(ctl);
    HVMM_TRACE_EXIT();
}
Example #5
0
static void __cpuinit generic_timer_calibrate_rate(void)
{
	unsigned long count;
	u64 waitjiffies;

	/*
	 * If this is the first time round, we need to work out how fast
	 * the timer ticks
	 */
	if (generic_timer_rate == 0) {
		printk("Calibrating local timer... ");

		/* Wait for a tick to start */
		waitjiffies = get_jiffies_64() + 1;

		while (get_jiffies_64() < waitjiffies)
			udelay(10);

		/* OK, now the tick has started, let's get the timer going */
		waitjiffies += 5;

		/* enable, no interrupt or reload */
        write_cntp_ctl(CNTP_CTL_ENABLE | CNTP_CTL_IMASK);

		/* maximum value */
        write_cntp_tval(0xFFFFFFFFU);

		while (get_jiffies_64() < waitjiffies)
			udelay(10);

        read_cntp_tval(count);
		generic_timer_rate = (0xFFFFFFFFU - count) * (HZ / 5);

		printk("%lu.%02luMHz.\n", generic_timer_rate / 1000000,
			(generic_timer_rate / 10000) % 100);
	}
}
Example #6
0
static void arm_generic_timer_resume_cpu(uint level)
{
	/* Always trigger a timer interrupt on each cpu for now */
	write_cntp_tval(0);
	write_cntp_ctl(1);
}