/* * Copyright (C) 2007-2013 Michal Simek <monstr@monstr.eu> * Copyright (C) 2012-2013 Xilinx, Inc. * Copyright (C) 2007-2009 PetaLogix * Copyright (C) 2006 Atmark Techno, Inc. * * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details.
*/
staticinlinevoid xilinx_timer0_start_periodic(unsignedlong load_val)
{ if (!load_val)
load_val = 1; /* loading value to timer reg */
write_fn(load_val, timer_baseaddr + TLR0);
/* load the initial value */
write_fn(TCSR_LOAD, timer_baseaddr + TCSR0);
/* see timer data sheet for detail * !ENALL - don't enable 'em all * !PWMA - disable pwm * TINT - clear interrupt status * ENT- enable timer itself * ENIT - enable interrupt * !LOAD - clear the bit to let go * ARHT - auto reload * !CAPT - no external trigger * !GENT - no external signal * UDT - set the timer as down counter * !MDT0 - generate mode
*/
write_fn(TCSR_TINT|TCSR_ENIT|TCSR_ENT|TCSR_ARHT|TCSR_UDT,
timer_baseaddr + TCSR0);
}
staticinlinevoid xilinx_timer0_start_oneshot(unsignedlong load_val)
{ if (!load_val)
load_val = 1; /* loading value to timer reg */
write_fn(load_val, timer_baseaddr + TLR0);
/* load the initial value */
write_fn(TCSR_LOAD, timer_baseaddr + TCSR0);
irq = irq_of_parse_and_map(timer, 0); if (irq <= 0) {
pr_err("Failed to parse and map irq"); return -EINVAL;
}
of_property_read_u32(timer, "xlnx,one-timer-only", &timer_num); if (timer_num) {
pr_err("Please enable two timers in HW\n"); return -EINVAL;
}
pr_info("%pOF: irq=%d\n", timer, irq);
clk = of_clk_get(timer, 0); if (IS_ERR(clk)) {
pr_err("ERROR: timer CCF input clock not found\n"); /* If there is clock-frequency property than use it */
of_property_read_u32(timer, "clock-frequency",
&timer_clock_freq);
} else {
timer_clock_freq = clk_get_rate(clk);
}
if (!timer_clock_freq) {
pr_err("ERROR: Using CPU clock frequency\n");
timer_clock_freq = cpuinfo.cpu_clock_freq;
}
freq_div_hz = timer_clock_freq / HZ;
ret = request_irq(irq, timer_interrupt, IRQF_TIMER, "timer",
&clockevent_xilinx_timer); if (ret) {
pr_err("Failed to setup IRQ"); return ret;
}
ret = xilinx_clocksource_init(); if (ret) return ret;
ret = xilinx_clockevent_init(); 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.