[xburst] Refresh patches for 2.6.37.1
[openwrt.git] / target / linux / leon / patches / 007-amp_timer.patch
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.
5
6 Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
7 ---
8 arch/sparc/kernel/leon_kernel.c | 41 +++++++++++++++++++++++++-------------
9 1 files changed, 27 insertions(+), 14 deletions(-)
10
11 --- a/arch/sparc/kernel/leon_kernel.c
12 +++ b/arch/sparc/kernel/leon_kernel.c
13 @@ -23,15 +23,16 @@
14 #include "prom.h"
15 #include "irq.h"
16
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];
22
23 int leondebug_irq_disable;
24 int leon_debug_irqout;
25 static int dummy_master_l10_counter;
26
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]))
32
33 @@ -109,6 +110,7 @@ void __init leon_init_timers(irq_handler
34 struct property *pp;
35 int len;
36 int cpu, icsel;
37 + int ampopts;
38
39 leondebug_irq_disable = 0;
40 leon_debug_irqout = 0;
41 @@ -124,24 +126,35 @@ void __init leon_init_timers(irq_handler
42 }
43
44 /* Find GPTIMER Timer Registers base address otherwise bail out. */
45 - if (rootnp && (np=of_find_node_by_name(rootnp, "GAISLER_GPTIMER"))) {
46 + np = rootnp;
47 + while (np && (np=of_find_node_by_name(np, "GAISLER_GPTIMER"))) {
48 + ampopts = 0;
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 */
52 + continue;
53 + }
54 + /* Select Timer-Instance on Timer Core. Default is zero */
55 + leon3_gptimer_idx = ampopts & 0x7;
56 +
57 pp = of_find_property(np, "reg", &len);
58 if (pp)
59 leon3_gptimer_regs = *(struct leon3_gptimer_regs_map **)pp->value;
60 pp = of_find_property(np, "interrupts", &len);
61 if (pp)
62 leon3_gptimer_irq = *(unsigned int *)pp->value;
63 + break;
64 }
65
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);
74
75 #ifdef CONFIG_SMP
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;
79
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
83 BUG();
84 }
85
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);
92 # endif
93
94 /* The IRQ controller may (if implemented) consist of multiple
95 @@ -178,7 +191,7 @@ void __init leon_init_timers(irq_handler
96 BUG();
97 }
98
99 - irq = request_irq(leon3_gptimer_irq,
100 + irq = request_irq(leon3_gptimer_irq+leon3_gptimer_idx,
101 counter_fn,
102 (IRQF_DISABLED | SA_STATIC_ALLOC), "timer", NULL);
103
104 @@ -210,13 +223,13 @@ void __init leon_init_timers(irq_handler
105 # endif
106
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,
110 LEON3_GPTIMER_EN |
111 LEON3_GPTIMER_RL |
112 LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN);
113
114 #ifdef CONFIG_SMP
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,
117 LEON3_GPTIMER_EN |
118 LEON3_GPTIMER_RL |
119 LEON3_GPTIMER_LD |
This page took 0.073738 seconds and 5 git commands to generate.