summaryrefslogtreecommitdiff
path: root/target/linux/leon/patches/001-find_irq_and_timer_via_of.patch
blob: 035543db6d298557e3a26de944a8f14de7d8b8d7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
From af1da1d5a8701f39cdbae4a0ab8e04b450eef298 Mon Sep 17 00:00:00 2001
From: Daniel Hellstrom <daniel@gaisler.com>
Date: Wed, 8 Sep 2010 18:05:38 +0200
Subject: [PATCH] SPARC/LEON: find IRQ and Timer via OF-Tree, instead of hardcoded.

Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
---
 arch/sparc/kernel/leon_kernel.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

--- a/arch/sparc/kernel/leon_kernel.c
+++ b/arch/sparc/kernel/leon_kernel.c
@@ -105,13 +105,34 @@ static void leon_disable_irq(unsigned in
 void __init leon_init_timers(irq_handler_t counter_fn)
 {
 	int irq;
+	struct device_node *rootnp, *np;
+	struct property *pp;
+	int len;
 
 	leondebug_irq_disable = 0;
 	leon_debug_irqout = 0;
 	master_l10_counter = (unsigned int *)&dummy_master_l10_counter;
 	dummy_master_l10_counter = 0;
 
-	if (leon3_gptimer_regs && leon3_irqctrl_regs) {
+	/* Find IRQMP IRQ Controller Registers base address otherwise bail out. */
+	rootnp = of_find_node_by_path("/ambapp0");
+	if (rootnp && (np=of_find_node_by_name(rootnp, "GAISLER_IRQMP"))) {
+		pp = of_find_property(np, "reg", &len);
+		if (pp)
+			leon3_irqctrl_regs = *(struct leon3_irqctrl_regs_map **)pp->value;
+	}
+
+	/* Find GPTIMER Timer Registers base address otherwise bail out. */
+	if (rootnp && (np=of_find_node_by_name(rootnp, "GAISLER_GPTIMER"))) {
+		pp = of_find_property(np, "reg", &len);
+		if (pp)
+			leon3_gptimer_regs = *(struct leon3_gptimer_regs_map **)pp->value;
+		pp = of_find_property(np, "interrupts", &len);
+		if (pp)
+			leon3_gptimer_irq = *(unsigned int *)pp->value;
+	}
+
+	if (leon3_gptimer_regs && leon3_irqctrl_regs && leon3_gptimer_irq) {
 		LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].val, 0);
 		LEON3_BYPASS_STORE_PA(&leon3_gptimer_regs->e[0].rld,
 				      (((1000000 / 100) - 1)));