Example #1
0
static void __init hub_rt_clocksource_init(void)
{
	struct clocksource *cs = &hub_rt_clocksource;

	clocksource_set_clock(cs, CYCLES_PER_SEC);
	clocksource_register(cs);
}
Example #2
0
void __init dec_ioasic_clocksource_init(void)
{
	unsigned int freq;
	u32 start, end;
	int i = HZ / 10;


	while (!ds1287_timer_state())
		;

	start = dec_ioasic_hpt_read();

	while (i--)
		while (!ds1287_timer_state())
			;

	end = dec_ioasic_hpt_read();

	freq = (end - start) * 10;
	printk(KERN_INFO "I/O ASIC clock frequency %dHz\n", freq);

	clocksource_dec.rating = 200 + freq / 10000000;
	clocksource_set_clock(&clocksource_dec, freq);

	clocksource_register(&clocksource_dec);
}
Example #3
0
int __init ra_systick_clocksource_init(void)
{
	ra_systick_clocksource.rating = 350;
#if LINUX_VERSION_CODE > KERNEL_VERSION(3,10,13)
	clocksource_register_hz(&ra_systick_clocksource, 50000);
#else
    clocksource_set_clock(&ra_systick_clocksource, 50000);
    clocksource_register(&ra_systick_clocksource);
#endif    

	return 0;
}
Example #4
0
int __init init_r4k_clocksource(void)
{
	if (!cpu_has_counter || !mips_hpt_frequency)
		return -ENXIO;

	/* Calculate a somewhat reasonable rating value */
	clocksource_mips.rating = 200 + mips_hpt_frequency / 10000000;

	clocksource_set_clock(&clocksource_mips, mips_hpt_frequency);

	clocksource_register(&clocksource_mips);

	return 0;
}
Example #5
0
void __init txx9_clocksource_init(unsigned long baseaddr,
				  unsigned int imbusclk)
{
	struct txx9_tmr_reg __iomem *tmrptr;

	clocksource_set_clock(&txx9_clocksource, TIMER_CLK(imbusclk));
	clocksource_register(&txx9_clocksource);

	tmrptr = ioremap(baseaddr, sizeof(struct txx9_tmr_reg));
	__raw_writel(TCR_BASE, &tmrptr->tcr);
	__raw_writel(0, &tmrptr->tisr);
	__raw_writel(TIMER_CCD, &tmrptr->ccdr);
	__raw_writel(TXx9_TMITMR_TZCE, &tmrptr->itmr);
	__raw_writel(1 << TXX9_CLOCKSOURCE_BITS, &tmrptr->cpra);
	__raw_writel(TCR_BASE | TXx9_TMTCR_TCE, &tmrptr->tcr);
	txx9_cs_tmrptr = tmrptr;
}
Example #6
0
void __init plat_time_init(void)
{
    int ret;
    uint32_t clk_rate;
    uint16_t ctrl;

    jz4740_timer_init();

    clk_rate = jz4740_clock_bdata.ext_rate >> 4;
    jz4740_jiffies_per_tick = DIV_ROUND_CLOSEST(clk_rate, HZ);

    clockevent_set_clock(&jz4740_clockevent, clk_rate);
    jz4740_clockevent.min_delta_ns = clockevent_delta2ns(100, &jz4740_clockevent);
    jz4740_clockevent.max_delta_ns = clockevent_delta2ns(0xffff, &jz4740_clockevent);
    jz4740_clockevent.cpumask = cpumask_of(0);

    clockevents_register_device(&jz4740_clockevent);

    clocksource_set_clock(&jz4740_clocksource, clk_rate);
    ret = clocksource_register(&jz4740_clocksource);

    if (ret)
        printk(KERN_ERR "Failed to register clocksource: %d\n", ret);

    setup_irq(JZ4740_IRQ_TCU0, &timer_irqaction);

    ctrl = JZ_TIMER_CTRL_PRESCALE_16 | JZ_TIMER_CTRL_SRC_EXT;

    jz4740_timer_set_ctrl(TIMER_CLOCKEVENT, ctrl);
    jz4740_timer_set_ctrl(TIMER_CLOCKSOURCE, ctrl);

    jz4740_timer_set_period(TIMER_CLOCKEVENT, jz4740_jiffies_per_tick);
    jz4740_timer_irq_full_enable(TIMER_CLOCKEVENT);

    jz4740_timer_set_period(TIMER_CLOCKSOURCE, 0xffff);

    jz4740_timer_enable(TIMER_CLOCKEVENT);
    jz4740_timer_enable(TIMER_CLOCKSOURCE);
}
Example #7
0
void __init plat_time_init(void)
{
	struct clock_event_device *cd = &au1x_rtcmatch2_clockdev;
	unsigned long t;

	/* Check if firmware (YAMON, ...) has enabled 32kHz and clock
	 * has been detected.  If so install the rtcmatch2 clocksource,
	 * otherwise don't bother.  Note that both bits being set is by
	 * no means a definite guarantee that the counters actually work
	 * (the 32S bit seems to be stuck set to 1 once a single clock-
	 * edge is detected, hence the timeouts).
	 */
	if (CNTR_OK != (au_readl(SYS_COUNTER_CNTRL) & CNTR_OK))
		goto cntr_err;

	/*
	 * setup counter 1 (RTC) to tick at full speed
	 */
	t = 0xffffff;
	while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_T1S) && --t)
		asm volatile ("nop");
	if (!t)
		goto cntr_err;

	au_writel(0, SYS_RTCTRIM);	/* 32.768 kHz */
	au_sync();

	t = 0xffffff;
	while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S) && --t)
		asm volatile ("nop");
	if (!t)
		goto cntr_err;
	au_writel(0, SYS_RTCWRITE);
	au_sync();

	t = 0xffffff;
	while ((au_readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_C1S) && --t)
		asm volatile ("nop");
	if (!t)
		goto cntr_err;

	/* register counter1 clocksource and event device */
	clocksource_set_clock(&au1x_counter1_clocksource, 32768);
	clocksource_register(&au1x_counter1_clocksource);

	cd->shift = 32;
	cd->mult = div_sc(32768, NSEC_PER_SEC, cd->shift);
	cd->max_delta_ns = clockevent_delta2ns(0xffffffff, cd);
	cd->min_delta_ns = clockevent_delta2ns(8, cd);	/* ~0.25ms */
	clockevents_register_device(cd);
	setup_irq(AU1000_RTC_MATCH2_INT, &au1x_rtcmatch2_irqaction);

	printk(KERN_INFO "Alchemy clocksource installed\n");

	/* can now use 'wait' */
	allow_au1k_wait = 1;
	return;

cntr_err:
	/* counters unusable, use C0 counter */
	r4k_clockevent_init();
	init_r4k_clocksource();
	allow_au1k_wait = 0;
}