2323#include "prom.h"
2424#include "irq.h"
2525
26- struct leon3_irqctrl_regs_map * leon3_irqctrl_regs ; /* interrupt controller base address, initialized by amba_init() */
27- struct leon3_gptimer_regs_map * leon3_gptimer_regs ; /* timer controller base address, initialized by amba_init() */
26+ struct leon3_irqctrl_regs_map * leon3_irqctrl_regs ; /* interrupt controller base address */
27+ struct leon3_gptimer_regs_map * leon3_gptimer_regs ; /* timer controller base address */
2828struct amba_apb_device leon_percpu_timer_dev [16 ];
2929
3030int leondebug_irq_disable ;
3131int leon_debug_irqout ;
3232static int dummy_master_l10_counter ;
3333
34- unsigned long leon3_gptimer_irq ; /* interrupt controller irq number, initialized by amba_init() */
34+ unsigned long leon3_gptimer_irq ; /* interrupt controller irq number */
3535unsigned int sparc_leon_eirq ;
3636#define LEON_IMASK ((&leon3_irqctrl_regs->mask[0]))
3737
@@ -105,13 +105,41 @@ static void leon_disable_irq(unsigned int irq_nr)
105105void __init leon_init_timers (irq_handler_t counter_fn )
106106{
107107 int irq ;
108+ struct device_node * rootnp , * np ;
109+ struct property * pp ;
110+ int len ;
108111
109112 leondebug_irq_disable = 0 ;
110113 leon_debug_irqout = 0 ;
111114 master_l10_counter = (unsigned int * )& dummy_master_l10_counter ;
112115 dummy_master_l10_counter = 0 ;
113116
114- if (leon3_gptimer_regs && leon3_irqctrl_regs ) {
117+ /*Find IRQMP IRQ Controller Registers base address otherwise bail out.*/
118+ rootnp = of_find_node_by_path ("/ambapp0" );
119+ if (!rootnp )
120+ goto bad ;
121+ np = of_find_node_by_name (rootnp , "GAISLER_IRQMP" );
122+ if (!np )
123+ goto bad ;
124+ pp = of_find_property (np , "reg" , & len );
125+ if (!pp )
126+ goto bad ;
127+ leon3_irqctrl_regs = * (struct leon3_irqctrl_regs_map * * )pp -> value ;
128+
129+ /* Find GPTIMER Timer Registers base address otherwise bail out. */
130+ np = of_find_node_by_name (rootnp , "GAISLER_GPTIMER" );
131+ if (!np )
132+ goto bad ;
133+ pp = of_find_property (np , "reg" , & len );
134+ if (!pp )
135+ goto bad ;
136+ leon3_gptimer_regs = * (struct leon3_gptimer_regs_map * * )pp -> value ;
137+ pp = of_find_property (np , "interrupts" , & len );
138+ if (!pp )
139+ goto bad ;
140+ leon3_gptimer_irq = * (unsigned int * )pp -> value ;
141+
142+ if (leon3_gptimer_regs && leon3_irqctrl_regs && leon3_gptimer_irq ) {
115143 LEON3_BYPASS_STORE_PA (& leon3_gptimer_regs -> e [0 ].val , 0 );
116144 LEON3_BYPASS_STORE_PA (& leon3_gptimer_regs -> e [0 ].rld ,
117145 (((1000000 / HZ ) - 1 )));
@@ -133,8 +161,7 @@ void __init leon_init_timers(irq_handler_t counter_fn)
133161# endif
134162
135163 } else {
136- printk (KERN_ERR "No Timer/irqctrl found\n" );
137- BUG ();
164+ goto bad ;
138165 }
139166
140167 irq = request_irq (leon3_gptimer_irq ,
@@ -183,6 +210,11 @@ void __init leon_init_timers(irq_handler_t counter_fn)
183210#endif
184211
185212 }
213+ return ;
214+ bad :
215+ printk (KERN_ERR "No Timer/irqctrl found\n" );
216+ BUG ();
217+ return ;
186218}
187219
188220void leon_clear_clock_irq (void )
0 commit comments