staticint __init pit_clocksource_init(unsignedlong rate)
{ /* set the max load value and start the clock source counter */
writel(0, clksrc_base + PITTCTRL);
writel(~0UL, clksrc_base + PITLDVAL);
writel(PITTCTRL_TEN, clksrc_base + PITTCTRL);
staticint pit_set_next_event(unsignedlong delta, struct clock_event_device *unused)
{ /* * set a new value to PITLDVAL register will not restart the timer, * to abort the current cycle and start a timer period with the new * value, the timer must be disabled and enabled again. * and the PITLAVAL should be set to delta minus one according to pit * hardware requirement.
*/
pit_timer_disable();
writel(delta - 1, clkevt_base + PITLDVAL);
pit_timer_enable();
/* * pit hardware doesn't support oneshot, it will generate an interrupt * and reload the counter value from PITLDVAL when PITCVAL reach zero, * and start the counter again. So software need to disable the timer * to stop the counter loop in ONESHOT mode.
*/ if (likely(clockevent_state_oneshot(evt)))
pit_timer_disable();
clockevent_pit.cpumask = cpumask_of(0);
clockevent_pit.irq = irq; /* * The value for the LDVAL register trigger is calculated as: * LDVAL trigger = (period / clock period) - 1 * The pit is a 32-bit down count timer, when the counter value * reaches 0, it will generate an interrupt, thus the minimal * LDVAL trigger value is 1. And then the min_delta is * minimal LDVAL trigger value + 1, and the max_delta is full 32-bit.
*/
clockevents_config_and_register(&clockevent_pit, rate, 2, 0xffffffff);
timer_base = of_iomap(np, 0); if (!timer_base) {
pr_err("Failed to iomap\n"); return -ENXIO;
}
/* * PIT0 and PIT1 can be chained to build a 64-bit timer, * so choose PIT2 as clocksource, PIT3 as clockevent device, * and leave PIT0 and PIT1 unused for anyone else who needs them.
*/
clksrc_base = timer_base + PITn_OFFSET(2);
clkevt_base = timer_base + PITn_OFFSET(3);
irq = irq_of_parse_and_map(np, 0); if (irq <= 0) return -EINVAL;
pit_clk = of_clk_get(np, 0); if (IS_ERR(pit_clk)) return PTR_ERR(pit_clk);
ret = clk_prepare_enable(pit_clk); if (ret) return ret;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.