1 From 1dffe06838c26b7c3fc99f9ddb7db78e378f6908 Mon Sep 17 00:00:00 2001
2 From: Daniel Hellstrom <daniel@gaisler.com>
3 Date: Wed, 22 Sep 2010 13:21:13 +0200
4 Subject: [PATCH] SPARC/LEON: added support for selecting Timer Core and Timer within core, useful for AMP systems.
6 Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
8 arch/sparc/kernel/leon_kernel.c | 41 +++++++++++++++++++++++++-------------
9 1 files changed, 27 insertions(+), 14 deletions(-)
11 --- a/arch/sparc/kernel/leon_kernel.c
12 +++ b/arch/sparc/kernel/leon_kernel.c
17 -struct leon3_irqctrl_regs_map *leon3_irqctrl_regs; /* interrupt controller base address, initialized by amba_init() */
18 -struct leon3_gptimer_regs_map *leon3_gptimer_regs; /* timer controller base address, initialized by amba_init() */
19 +struct leon3_irqctrl_regs_map *leon3_irqctrl_regs = NULL; /* interrupt controller base address, initialized by amba_init() */
20 +struct leon3_gptimer_regs_map *leon3_gptimer_regs = NULL; /* timer controller base address, initialized by amba_init() */
21 struct amba_apb_device leon_percpu_timer_dev[16];
23 int leondebug_irq_disable;
24 int leon_debug_irqout;
25 static int dummy_master_l10_counter;
27 -unsigned long leon3_gptimer_irq; /* interrupt controller irq number, initialized by amba_init() */
28 +unsigned long leon3_gptimer_irq = 0; /* interrupt controller irq number, initialized by amba_init() */
29 +unsigned long leon3_gptimer_idx = 0; /* Timer Index (starting at 0) with Timer Core */
30 unsigned int sparc_leon_eirq;
31 #define LEON_IMASK ((&leon3_irqctrl_regs->mask[0]))
33 @@ -109,6 +110,7 @@ void __init leon_init_timers(irq_handler
39 leondebug_irq_disable = 0;
40 leon_debug_irqout = 0;
41 @@ -124,24 +126,35 @@ void __init leon_init_timers(irq_handler
44 /* Find GPTIMER Timer Registers base address otherwise bail out. */
45 - if (rootnp && (np=of_find_node_by_name(rootnp, "GAISLER_GPTIMER"))) {
47 + while (np && (np=of_find_node_by_name(np, "GAISLER_GPTIMER"))) {
49 + pp = of_find_property(np, "ampopts", &len);
50 + if ( pp && ((ampopts = *(int *)pp->value) == 0) ) {
51 + /* Skip this instance, resource already allocated by other OS */
54 + /* Select Timer-Instance on Timer Core. Default is zero */
55 + leon3_gptimer_idx = ampopts & 0x7;
57 pp = of_find_property(np, "reg", &len);
59 leon3_gptimer_regs = *(struct leon3_gptimer_regs_map **)pp->value;
60 pp = of_find_property(np, "interrupts", &len);
62 leon3_gptimer_irq = *(unsigned int *)pp->value;
66 if (leon3_gptimer_regs && leon3_irqctrl_regs && leon3_gptimer_irq) {
67 - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].val, 0);
68 - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].rld,
69 + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].val, 0);
70 + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].rld,
71 (((1000000 / 100) - 1)));
72 - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl, 0);
73 + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl, 0);
76 leon_percpu_timer_dev[0].start = (int)leon3_gptimer_regs;
77 - leon_percpu_timer_dev[0].irq = leon3_gptimer_irq+1;
78 + leon_percpu_timer_dev[0].irq = leon3_gptimer_irq+1+leon3_gptimer_idx;
80 if (!(LEON3_BYPASS_LOAD_PA(&leon3_gptimer_regs->config) &
81 (1<<LEON3_GPTIMER_SEPIRQ))) {
82 @@ -149,9 +162,9 @@ void __init leon_init_timers(irq_handler
86 - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].val, 0);
87 - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].rld, (((1000000/100) - 1)));
88 - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl, 0);
89 + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].val, 0);
90 + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].rld, (((1000000/100) - 1)));
91 + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].ctrl, 0);
94 /* The IRQ controller may (if implemented) consist of multiple
95 @@ -178,7 +191,7 @@ void __init leon_init_timers(irq_handler
99 - irq = request_irq(leon3_gptimer_irq,
100 + irq = request_irq(leon3_gptimer_irq+leon3_gptimer_idx,
102 (IRQF_DISABLED | SA_STATIC_ALLOC), "timer", NULL);
104 @@ -210,13 +223,13 @@ void __init leon_init_timers(irq_handler
107 if (leon3_gptimer_regs) {
108 - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].ctrl,
109 + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx].ctrl,
112 LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN);
115 - LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[1].ctrl,
116 + LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[leon3_gptimer_idx+1].ctrl,