@@ -147,6 +147,16 @@ static u32 mpic_infos[][MPIC_IDX_END] = {
147147
148148#endif /* CONFIG_MPIC_WEIRD */
149149
150+ static inline unsigned int mpic_processor_id (struct mpic * mpic )
151+ {
152+ unsigned int cpu = 0 ;
153+
154+ if (mpic -> flags & MPIC_PRIMARY )
155+ cpu = hard_smp_processor_id ();
156+
157+ return cpu ;
158+ }
159+
150160/*
151161 * Register accessor functions
152162 */
@@ -210,19 +220,14 @@ static inline void _mpic_ipi_write(struct mpic *mpic, unsigned int ipi, u32 valu
210220
211221static inline u32 _mpic_cpu_read (struct mpic * mpic , unsigned int reg )
212222{
213- unsigned int cpu = 0 ;
223+ unsigned int cpu = mpic_processor_id ( mpic ) ;
214224
215- if (mpic -> flags & MPIC_PRIMARY )
216- cpu = hard_smp_processor_id ();
217225 return _mpic_read (mpic -> reg_type , & mpic -> cpuregs [cpu ], reg );
218226}
219227
220228static inline void _mpic_cpu_write (struct mpic * mpic , unsigned int reg , u32 value )
221229{
222- unsigned int cpu = 0 ;
223-
224- if (mpic -> flags & MPIC_PRIMARY )
225- cpu = hard_smp_processor_id ();
230+ unsigned int cpu = mpic_processor_id (mpic );
226231
227232 _mpic_write (mpic -> reg_type , & mpic -> cpuregs [cpu ], reg , value );
228233}
@@ -913,6 +918,20 @@ void mpic_set_vector(unsigned int virq, unsigned int vector)
913918 mpic_irq_write (src , MPIC_INFO (IRQ_VECTOR_PRI ), vecpri );
914919}
915920
921+ void mpic_set_destination (unsigned int virq , unsigned int cpuid )
922+ {
923+ struct mpic * mpic = mpic_from_irq (virq );
924+ unsigned int src = mpic_irq_to_hw (virq );
925+
926+ DBG ("mpic: set_destination(mpic:@%p,virq:%d,src:%d,cpuid:0x%x)\n" ,
927+ mpic , virq , src , cpuid );
928+
929+ if (src >= mpic -> irq_count )
930+ return ;
931+
932+ mpic_irq_write (src , MPIC_INFO (IRQ_DESTINATION ), 1 << cpuid );
933+ }
934+
916935static struct irq_chip mpic_irq_chip = {
917936 .irq_mask = mpic_mask_irq ,
918937 .irq_unmask = mpic_unmask_irq ,
@@ -993,6 +1012,16 @@ static int mpic_host_map(struct irq_host *h, unsigned int virq,
9931012 /* Set default irq type */
9941013 set_irq_type (virq , IRQ_TYPE_NONE );
9951014
1015+ /* If the MPIC was reset, then all vectors have already been
1016+ * initialized. Otherwise, a per source lazy initialization
1017+ * is done here.
1018+ */
1019+ if (!mpic_is_ipi (mpic , hw ) && (mpic -> flags & MPIC_NO_RESET )) {
1020+ mpic_set_vector (virq , hw );
1021+ mpic_set_destination (virq , mpic_processor_id (mpic ));
1022+ mpic_irq_set_priority (virq , 8 );
1023+ }
1024+
9961025 return 0 ;
9971026}
9981027
@@ -1040,6 +1069,11 @@ static struct irq_host_ops mpic_host_ops = {
10401069 .xlate = mpic_host_xlate ,
10411070};
10421071
1072+ static int mpic_reset_prohibited (struct device_node * node )
1073+ {
1074+ return node && of_get_property (node , "pic-no-reset" , NULL );
1075+ }
1076+
10431077/*
10441078 * Exported functions
10451079 */
@@ -1160,7 +1194,15 @@ struct mpic * __init mpic_alloc(struct device_node *node,
11601194 mpic_map (mpic , node , paddr , & mpic -> tmregs , MPIC_INFO (TIMER_BASE ), 0x1000 );
11611195
11621196 /* Reset */
1163- if (flags & MPIC_WANTS_RESET ) {
1197+
1198+ /* When using a device-node, reset requests are only honored if the MPIC
1199+ * is allowed to reset.
1200+ */
1201+ if (mpic_reset_prohibited (node ))
1202+ mpic -> flags |= MPIC_NO_RESET ;
1203+
1204+ if ((flags & MPIC_WANTS_RESET ) && !(mpic -> flags & MPIC_NO_RESET )) {
1205+ printk (KERN_DEBUG "mpic: Resetting\n" );
11641206 mpic_write (mpic -> gregs , MPIC_INFO (GREG_GLOBAL_CONF_0 ),
11651207 mpic_read (mpic -> gregs , MPIC_INFO (GREG_GLOBAL_CONF_0 ))
11661208 | MPIC_GREG_GCONF_RESET );
@@ -1320,22 +1362,21 @@ void __init mpic_init(struct mpic *mpic)
13201362
13211363 mpic_pasemi_msi_init (mpic );
13221364
1323- if (mpic -> flags & MPIC_PRIMARY )
1324- cpu = hard_smp_processor_id ();
1325- else
1326- cpu = 0 ;
1365+ cpu = mpic_processor_id (mpic );
13271366
1328- for (i = 0 ; i < mpic -> num_sources ; i ++ ) {
1329- /* start with vector = source number, and masked */
1330- u32 vecpri = MPIC_VECPRI_MASK | i |
1331- (8 << MPIC_VECPRI_PRIORITY_SHIFT );
1367+ if (!(mpic -> flags & MPIC_NO_RESET )) {
1368+ for (i = 0 ; i < mpic -> num_sources ; i ++ ) {
1369+ /* start with vector = source number, and masked */
1370+ u32 vecpri = MPIC_VECPRI_MASK | i |
1371+ (8 << MPIC_VECPRI_PRIORITY_SHIFT );
13321372
1333- /* check if protected */
1334- if (mpic -> protected && test_bit (i , mpic -> protected ))
1335- continue ;
1336- /* init hw */
1337- mpic_irq_write (i , MPIC_INFO (IRQ_VECTOR_PRI ), vecpri );
1338- mpic_irq_write (i , MPIC_INFO (IRQ_DESTINATION ), 1 << cpu );
1373+ /* check if protected */
1374+ if (mpic -> protected && test_bit (i , mpic -> protected ))
1375+ continue ;
1376+ /* init hw */
1377+ mpic_irq_write (i , MPIC_INFO (IRQ_VECTOR_PRI ), vecpri );
1378+ mpic_irq_write (i , MPIC_INFO (IRQ_DESTINATION ), 1 << cpu );
1379+ }
13391380 }
13401381
13411382 /* Init spurious vector */
0 commit comments