@@ -37,7 +37,7 @@ unsigned long leon3_gptimer_irq; /* interrupt controller irq number */
3737unsigned long leon3_gptimer_idx ; /* Timer Index (0..6) within Timer Core */
3838int leon3_ticker_irq ; /* Timer ticker IRQ */
3939unsigned int sparc_leon_eirq ;
40- #define LEON_IMASK (&leon3_irqctrl_regs->mask[0 ])
40+ #define LEON_IMASK ( cpu ) (&leon3_irqctrl_regs->mask[cpu ])
4141#define LEON_IACK (&leon3_irqctrl_regs->iclear)
4242#define LEON_DO_ACK_HW 1
4343
@@ -79,8 +79,8 @@ void leon_eirq_setup(unsigned int eirq)
7979 */
8080 irq_link (veirq );
8181 mask = 1 << eirq ;
82- oldmask = LEON3_BYPASS_LOAD_PA (LEON_IMASK );
83- LEON3_BYPASS_STORE_PA (LEON_IMASK , (oldmask | mask ));
82+ oldmask = LEON3_BYPASS_LOAD_PA (LEON_IMASK ( 0 ) );
83+ LEON3_BYPASS_STORE_PA (LEON_IMASK ( 0 ) , (oldmask | mask ));
8484 sparc_leon_eirq = eirq ;
8585}
8686
@@ -101,23 +101,23 @@ static inline unsigned long get_irqmask(unsigned int irq)
101101
102102static void leon_unmask_irq (struct irq_data * data )
103103{
104- unsigned long mask , flags ;
104+ unsigned long mask , oldmask , flags ;
105105
106106 mask = (unsigned long )data -> chip_data ;
107107 spin_lock_irqsave (& leon_irq_lock , flags );
108- LEON3_BYPASS_STORE_PA (LEON_IMASK ,
109- ( LEON3_BYPASS_LOAD_PA ( LEON_IMASK ) | ( mask ) ));
108+ oldmask = LEON3_BYPASS_LOAD_PA (LEON_IMASK ( 0 ));
109+ LEON3_BYPASS_STORE_PA ( LEON_IMASK ( 0 ), ( oldmask | mask ));
110110 spin_unlock_irqrestore (& leon_irq_lock , flags );
111111}
112112
113113static void leon_mask_irq (struct irq_data * data )
114114{
115- unsigned long mask , flags ;
115+ unsigned long mask , oldmask , flags ;
116116
117117 mask = (unsigned long )data -> chip_data ;
118118 spin_lock_irqsave (& leon_irq_lock , flags );
119- LEON3_BYPASS_STORE_PA (LEON_IMASK ,
120- ( LEON3_BYPASS_LOAD_PA ( LEON_IMASK ) & ~( mask ) ));
119+ oldmask = LEON3_BYPASS_LOAD_PA (LEON_IMASK ( 0 ));
120+ LEON3_BYPASS_STORE_PA ( LEON_IMASK ( 0 ), ( oldmask & ~mask ));
121121 spin_unlock_irqrestore (& leon_irq_lock , flags );
122122}
123123
@@ -261,92 +261,83 @@ void __init leon_init_timers(irq_handler_t counter_fn)
261261 leon3_gptimer_irq = * (unsigned int * )pp -> value ;
262262 } while (0 );
263263
264- if (leon3_gptimer_regs && leon3_irqctrl_regs && leon3_gptimer_irq ) {
265- LEON3_BYPASS_STORE_PA (
266- & leon3_gptimer_regs -> e [ leon3_gptimer_idx ]. val , 0 );
267- LEON3_BYPASS_STORE_PA (
268- & leon3_gptimer_regs -> e [leon3_gptimer_idx ].rld ,
269- (((1000000 / HZ ) - 1 )));
270- LEON3_BYPASS_STORE_PA (
264+ if (!( leon3_gptimer_regs && leon3_irqctrl_regs && leon3_gptimer_irq ))
265+ goto bad ;
266+
267+ LEON3_BYPASS_STORE_PA (& leon3_gptimer_regs -> e [ leon3_gptimer_idx ]. val , 0 );
268+ LEON3_BYPASS_STORE_PA ( & leon3_gptimer_regs -> e [leon3_gptimer_idx ].rld ,
269+ (((1000000 / HZ ) - 1 )));
270+ LEON3_BYPASS_STORE_PA (
271271 & leon3_gptimer_regs -> e [leon3_gptimer_idx ].ctrl , 0 );
272272
273273#ifdef CONFIG_SMP
274- leon3_ticker_irq = leon3_gptimer_irq + 1 + leon3_gptimer_idx ;
275-
276- if (!(LEON3_BYPASS_LOAD_PA (& leon3_gptimer_regs -> config ) &
277- (1 <<LEON3_GPTIMER_SEPIRQ ))) {
278- prom_printf ("irq timer not configured with separate irqs\n" );
279- BUG ();
280- }
274+ leon3_ticker_irq = leon3_gptimer_irq + 1 + leon3_gptimer_idx ;
281275
282- LEON3_BYPASS_STORE_PA (
283- & leon3_gptimer_regs -> e [leon3_gptimer_idx + 1 ].val , 0 );
284- LEON3_BYPASS_STORE_PA (
285- & leon3_gptimer_regs -> e [leon3_gptimer_idx + 1 ].rld ,
286- (((1000000 /HZ ) - 1 )));
287- LEON3_BYPASS_STORE_PA (
288- & leon3_gptimer_regs -> e [leon3_gptimer_idx + 1 ].ctrl , 0 );
289- # endif
290-
291- /*
292- * The IRQ controller may (if implemented) consist of multiple
293- * IRQ controllers, each mapped on a 4Kb boundary.
294- * Each CPU may be routed to different IRQCTRLs, however
295- * we assume that all CPUs (in SMP system) is routed to the
296- * same IRQ Controller, and for non-SMP only one IRQCTRL is
297- * accessed anyway.
298- * In AMP systems, Linux must run on CPU0 for the time being.
299- */
300- cpu = sparc_leon3_cpuid ();
301- icsel = LEON3_BYPASS_LOAD_PA (& leon3_irqctrl_regs -> icsel [cpu /8 ]);
302- icsel = (icsel >> ((7 - (cpu & 0x7 )) * 4 )) & 0xf ;
303- leon3_irqctrl_regs += icsel ;
304-
305- /* Probe extended IRQ controller */
306- eirq = (LEON3_BYPASS_LOAD_PA (& leon3_irqctrl_regs -> mpstatus )
307- >> 16 ) & 0xf ;
308- if (eirq != 0 )
309- leon_eirq_setup (eirq );
310- } else {
311- goto bad ;
276+ if (!(LEON3_BYPASS_LOAD_PA (& leon3_gptimer_regs -> config ) &
277+ (1 <<LEON3_GPTIMER_SEPIRQ ))) {
278+ printk (KERN_ERR "timer not configured with separate irqs\n" );
279+ BUG ();
312280 }
313281
282+ LEON3_BYPASS_STORE_PA (& leon3_gptimer_regs -> e [leon3_gptimer_idx + 1 ].val ,
283+ 0 );
284+ LEON3_BYPASS_STORE_PA (& leon3_gptimer_regs -> e [leon3_gptimer_idx + 1 ].rld ,
285+ (((1000000 /HZ ) - 1 )));
286+ LEON3_BYPASS_STORE_PA (& leon3_gptimer_regs -> e [leon3_gptimer_idx + 1 ].ctrl ,
287+ 0 );
288+ #endif
289+
290+ /*
291+ * The IRQ controller may (if implemented) consist of multiple
292+ * IRQ controllers, each mapped on a 4Kb boundary.
293+ * Each CPU may be routed to different IRQCTRLs, however
294+ * we assume that all CPUs (in SMP system) is routed to the
295+ * same IRQ Controller, and for non-SMP only one IRQCTRL is
296+ * accessed anyway.
297+ * In AMP systems, Linux must run on CPU0 for the time being.
298+ */
299+ cpu = sparc_leon3_cpuid ();
300+ icsel = LEON3_BYPASS_LOAD_PA (& leon3_irqctrl_regs -> icsel [cpu /8 ]);
301+ icsel = (icsel >> ((7 - (cpu & 0x7 )) * 4 )) & 0xf ;
302+ leon3_irqctrl_regs += icsel ;
303+
304+ /* Probe extended IRQ controller */
305+ eirq = (LEON3_BYPASS_LOAD_PA (& leon3_irqctrl_regs -> mpstatus )
306+ >> 16 ) & 0xf ;
307+ if (eirq != 0 )
308+ leon_eirq_setup (eirq );
309+
314310 irq = _leon_build_device_irq (NULL , leon3_gptimer_irq + leon3_gptimer_idx );
315311 err = request_irq (irq , counter_fn , IRQF_TIMER , "timer" , NULL );
316-
317312 if (err ) {
318- printk (KERN_ERR "leon_time_init: unable to attach IRQ%d\n" ,
319- irq );
313+ printk (KERN_ERR "unable to attach timer IRQ%d\n" , irq );
320314 prom_halt ();
321315 }
322316
323- if ( leon3_gptimer_regs ) {
324- LEON3_BYPASS_STORE_PA ( & leon3_gptimer_regs -> e [ leon3_gptimer_idx ]. ctrl ,
325- LEON3_GPTIMER_EN |
326- LEON3_GPTIMER_RL |
327- LEON3_GPTIMER_LD | LEON3_GPTIMER_IRQEN );
317+ LEON3_BYPASS_STORE_PA ( & leon3_gptimer_regs -> e [ leon3_gptimer_idx ]. ctrl ,
318+ LEON3_GPTIMER_EN |
319+ LEON3_GPTIMER_RL |
320+ LEON3_GPTIMER_LD |
321+ LEON3_GPTIMER_IRQEN );
328322
329323#ifdef CONFIG_SMP
330- /* Install per-cpu IRQ handler for broadcasted ticker */
331- irq = leon_build_device_irq (leon3_ticker_irq ,
332- handle_percpu_irq , "per-cpu" ,
333- 0 );
334- err = request_irq (irq , leon_percpu_timer_interrupt ,
335- IRQF_PERCPU | IRQF_TIMER , "ticker" ,
336- NULL );
337- if (err ) {
338- printk (KERN_ERR "unable to attach ticker IRQ%d\n" , irq );
339- prom_halt ();
340- }
324+ /* Install per-cpu IRQ handler for broadcasted ticker */
325+ irq = leon_build_device_irq (leon3_ticker_irq , handle_percpu_irq ,
326+ "per-cpu" , 0 );
327+ err = request_irq (irq , leon_percpu_timer_interrupt ,
328+ IRQF_PERCPU | IRQF_TIMER , "ticker" ,
329+ NULL );
330+ if (err ) {
331+ printk (KERN_ERR "unable to attach ticker IRQ%d\n" , irq );
332+ prom_halt ();
333+ }
341334
342- LEON3_BYPASS_STORE_PA (& leon3_gptimer_regs -> e [leon3_gptimer_idx + 1 ].ctrl ,
343- LEON3_GPTIMER_EN |
344- LEON3_GPTIMER_RL |
345- LEON3_GPTIMER_LD |
346- LEON3_GPTIMER_IRQEN );
335+ LEON3_BYPASS_STORE_PA (& leon3_gptimer_regs -> e [leon3_gptimer_idx + 1 ].ctrl ,
336+ LEON3_GPTIMER_EN |
337+ LEON3_GPTIMER_RL |
338+ LEON3_GPTIMER_LD |
339+ LEON3_GPTIMER_IRQEN );
347340#endif
348-
349- }
350341 return ;
351342bad :
352343 printk (KERN_ERR "No Timer/irqctrl found\n" );
@@ -363,9 +354,6 @@ void leon_load_profile_irq(int cpu, unsigned int limit)
363354 BUG ();
364355}
365356
366-
367-
368-
369357void __init leon_trans_init (struct device_node * dp )
370358{
371359 if (strcmp (dp -> type , "cpu" ) == 0 && strcmp (dp -> name , "<NULL>" ) == 0 ) {
@@ -420,8 +408,8 @@ void leon_enable_irq_cpu(unsigned int irq_nr, unsigned int cpu)
420408 unsigned long mask , flags , * addr ;
421409 mask = get_irqmask (irq_nr );
422410 spin_lock_irqsave (& leon_irq_lock , flags );
423- addr = (unsigned long * )& ( leon3_irqctrl_regs -> mask [ cpu ] );
424- LEON3_BYPASS_STORE_PA (addr , (LEON3_BYPASS_LOAD_PA (addr ) | ( mask ) ));
411+ addr = (unsigned long * )LEON_IMASK ( cpu );
412+ LEON3_BYPASS_STORE_PA (addr , (LEON3_BYPASS_LOAD_PA (addr ) | mask ));
425413 spin_unlock_irqrestore (& leon_irq_lock , flags );
426414}
427415
0 commit comments