11/*
22 * SH-X3 SMP
33 *
4- * Copyright (C) 2007 Paul Mundt
4+ * Copyright (C) 2007 - 2008 Paul Mundt
55 * Copyright (C) 2007 Magnus Damm
66 *
77 * This file is subject to the terms and conditions of the GNU General Public
1414#include <linux/interrupt.h>
1515#include <linux/io.h>
1616
17+ static irqreturn_t ipi_interrupt_handler (int irq , void * arg )
18+ {
19+ unsigned int message = (unsigned int )(long )arg ;
20+ unsigned int cpu = hard_smp_processor_id ();
21+ unsigned int offs = 4 * cpu ;
22+ unsigned int x ;
23+
24+ x = ctrl_inl (0xfe410070 + offs ); /* C0INITICI..CnINTICI */
25+ x &= (1 << (message << 2 ));
26+ ctrl_outl (x , 0xfe410080 + offs ); /* C0INTICICLR..CnINTICICLR */
27+
28+ smp_message_recv (message );
29+
30+ return IRQ_HANDLED ;
31+ }
32+
1733void __init plat_smp_setup (void )
1834{
1935 unsigned int cpu = 0 ;
@@ -40,6 +56,13 @@ void __init plat_smp_setup(void)
4056
4157void __init plat_prepare_cpus (unsigned int max_cpus )
4258{
59+ int i ;
60+
61+ BUILD_BUG_ON (SMP_MSG_NR >= 8 );
62+
63+ for (i = 0 ; i < SMP_MSG_NR ; i ++ )
64+ request_irq (104 + i , ipi_interrupt_handler , IRQF_DISABLED ,
65+ "IPI" , (void * )(long )i );
4366}
4467
4568#define STBCR_REG (phys_id ) (0xfe400004 | (phys_id << 12))
@@ -75,46 +98,6 @@ void plat_send_ipi(unsigned int cpu, unsigned int message)
7598 unsigned long addr = 0xfe410070 + (cpu * 4 );
7699
77100 BUG_ON (cpu >= 4 );
78- BUG_ON (message >= SMP_MSG_NR );
79101
80102 ctrl_outl (1 << (message << 2 ), addr ); /* C0INTICI..CnINTICI */
81103}
82-
83- struct ipi_data {
84- void (* handler )(void * );
85- void * arg ;
86- unsigned int message ;
87- };
88-
89- static irqreturn_t ipi_interrupt_handler (int irq , void * arg )
90- {
91- struct ipi_data * id = arg ;
92- unsigned int cpu = hard_smp_processor_id ();
93- unsigned int offs = 4 * cpu ;
94- unsigned int x ;
95-
96- x = ctrl_inl (0xfe410070 + offs ); /* C0INITICI..CnINTICI */
97- x &= (1 << (id -> message << 2 ));
98- ctrl_outl (x , 0xfe410080 + offs ); /* C0INTICICLR..CnINTICICLR */
99-
100- id -> handler (id -> arg );
101-
102- return IRQ_HANDLED ;
103- }
104-
105- static struct ipi_data ipi_handlers [SMP_MSG_NR ];
106-
107- int plat_register_ipi_handler (unsigned int message ,
108- void (* handler )(void * ), void * arg )
109- {
110- struct ipi_data * id = & ipi_handlers [message ];
111-
112- BUG_ON (SMP_MSG_NR >= 8 );
113- BUG_ON (message >= SMP_MSG_NR );
114-
115- id -> handler = handler ;
116- id -> arg = arg ;
117- id -> message = message ;
118-
119- return request_irq (104 + message , ipi_interrupt_handler , 0 , "IPI" , id );
120- }
0 commit comments