@@ -41,6 +41,7 @@ struct stm32_exti_bank {
41
41
struct stm32_desc_irq {
42
42
u32 exti ;
43
43
u32 irq_parent ;
44
+ struct irq_chip * chip ;
44
45
};
45
46
46
47
struct stm32_exti_drv_data {
@@ -165,27 +166,41 @@ static const struct stm32_exti_bank *stm32mp1_exti_banks[] = {
165
166
& stm32mp1_exti_b3 ,
166
167
};
167
168
169
+ static struct irq_chip stm32_exti_h_chip ;
170
+ static struct irq_chip stm32_exti_h_chip_direct ;
171
+
168
172
static const struct stm32_desc_irq stm32mp1_desc_irq [] = {
169
- { .exti = 0 , .irq_parent = 6 },
170
- { .exti = 1 , .irq_parent = 7 },
171
- { .exti = 2 , .irq_parent = 8 },
172
- { .exti = 3 , .irq_parent = 9 },
173
- { .exti = 4 , .irq_parent = 10 },
174
- { .exti = 5 , .irq_parent = 23 },
175
- { .exti = 6 , .irq_parent = 64 },
176
- { .exti = 7 , .irq_parent = 65 },
177
- { .exti = 8 , .irq_parent = 66 },
178
- { .exti = 9 , .irq_parent = 67 },
179
- { .exti = 10 , .irq_parent = 40 },
180
- { .exti = 11 , .irq_parent = 42 },
181
- { .exti = 12 , .irq_parent = 76 },
182
- { .exti = 13 , .irq_parent = 77 },
183
- { .exti = 14 , .irq_parent = 121 },
184
- { .exti = 15 , .irq_parent = 127 },
185
- { .exti = 16 , .irq_parent = 1 },
186
- { .exti = 65 , .irq_parent = 144 },
187
- { .exti = 68 , .irq_parent = 143 },
188
- { .exti = 73 , .irq_parent = 129 },
173
+ { .exti = 0 , .irq_parent = 6 , .chip = & stm32_exti_h_chip },
174
+ { .exti = 1 , .irq_parent = 7 , .chip = & stm32_exti_h_chip },
175
+ { .exti = 2 , .irq_parent = 8 , .chip = & stm32_exti_h_chip },
176
+ { .exti = 3 , .irq_parent = 9 , .chip = & stm32_exti_h_chip },
177
+ { .exti = 4 , .irq_parent = 10 , .chip = & stm32_exti_h_chip },
178
+ { .exti = 5 , .irq_parent = 23 , .chip = & stm32_exti_h_chip },
179
+ { .exti = 6 , .irq_parent = 64 , .chip = & stm32_exti_h_chip },
180
+ { .exti = 7 , .irq_parent = 65 , .chip = & stm32_exti_h_chip },
181
+ { .exti = 8 , .irq_parent = 66 , .chip = & stm32_exti_h_chip },
182
+ { .exti = 9 , .irq_parent = 67 , .chip = & stm32_exti_h_chip },
183
+ { .exti = 10 , .irq_parent = 40 , .chip = & stm32_exti_h_chip },
184
+ { .exti = 11 , .irq_parent = 42 , .chip = & stm32_exti_h_chip },
185
+ { .exti = 12 , .irq_parent = 76 , .chip = & stm32_exti_h_chip },
186
+ { .exti = 13 , .irq_parent = 77 , .chip = & stm32_exti_h_chip },
187
+ { .exti = 14 , .irq_parent = 121 , .chip = & stm32_exti_h_chip },
188
+ { .exti = 15 , .irq_parent = 127 , .chip = & stm32_exti_h_chip },
189
+ { .exti = 16 , .irq_parent = 1 , .chip = & stm32_exti_h_chip },
190
+ { .exti = 19 , .irq_parent = 3 , .chip = & stm32_exti_h_chip_direct },
191
+ { .exti = 21 , .irq_parent = 31 , .chip = & stm32_exti_h_chip_direct },
192
+ { .exti = 22 , .irq_parent = 33 , .chip = & stm32_exti_h_chip_direct },
193
+ { .exti = 23 , .irq_parent = 72 , .chip = & stm32_exti_h_chip_direct },
194
+ { .exti = 24 , .irq_parent = 95 , .chip = & stm32_exti_h_chip_direct },
195
+ { .exti = 25 , .irq_parent = 107 , .chip = & stm32_exti_h_chip_direct },
196
+ { .exti = 30 , .irq_parent = 52 , .chip = & stm32_exti_h_chip_direct },
197
+ { .exti = 47 , .irq_parent = 93 , .chip = & stm32_exti_h_chip_direct },
198
+ { .exti = 54 , .irq_parent = 135 , .chip = & stm32_exti_h_chip_direct },
199
+ { .exti = 61 , .irq_parent = 100 , .chip = & stm32_exti_h_chip_direct },
200
+ { .exti = 65 , .irq_parent = 144 , .chip = & stm32_exti_h_chip },
201
+ { .exti = 68 , .irq_parent = 143 , .chip = & stm32_exti_h_chip },
202
+ { .exti = 70 , .irq_parent = 62 , .chip = & stm32_exti_h_chip_direct },
203
+ { .exti = 73 , .irq_parent = 129 , .chip = & stm32_exti_h_chip },
189
204
};
190
205
191
206
static const struct stm32_exti_drv_data stm32mp1_drv_data = {
@@ -195,22 +210,23 @@ static const struct stm32_exti_drv_data stm32mp1_drv_data = {
195
210
.irq_nr = ARRAY_SIZE (stm32mp1_desc_irq ),
196
211
};
197
212
198
- static int stm32_exti_to_irq (const struct stm32_exti_drv_data * drv_data ,
199
- irq_hw_number_t hwirq )
213
+ static const struct
214
+ stm32_desc_irq * stm32_exti_get_desc (const struct stm32_exti_drv_data * drv_data ,
215
+ irq_hw_number_t hwirq )
200
216
{
201
- const struct stm32_desc_irq * desc_irq ;
217
+ const struct stm32_desc_irq * desc = NULL ;
202
218
int i ;
203
219
204
220
if (!drv_data -> desc_irqs )
205
- return - EINVAL ;
221
+ return NULL ;
206
222
207
223
for (i = 0 ; i < drv_data -> irq_nr ; i ++ ) {
208
- desc_irq = & drv_data -> desc_irqs [i ];
209
- if (desc_irq -> exti == hwirq )
210
- return desc_irq -> irq_parent ;
224
+ desc = & drv_data -> desc_irqs [i ];
225
+ if (desc -> exti == hwirq )
226
+ break ;
211
227
}
212
228
213
- return - EINVAL ;
229
+ return desc ;
214
230
}
215
231
216
232
static unsigned long stm32_exti_pending (struct irq_chip_generic * gc )
@@ -603,30 +619,47 @@ static struct irq_chip stm32_exti_h_chip = {
603
619
.irq_set_affinity = IS_ENABLED (CONFIG_SMP ) ? stm32_exti_h_set_affinity : NULL ,
604
620
};
605
621
622
+ static struct irq_chip stm32_exti_h_chip_direct = {
623
+ .name = "stm32-exti-h-direct" ,
624
+ .irq_eoi = irq_chip_eoi_parent ,
625
+ .irq_ack = irq_chip_ack_parent ,
626
+ .irq_mask = irq_chip_mask_parent ,
627
+ .irq_unmask = irq_chip_unmask_parent ,
628
+ .irq_retrigger = irq_chip_retrigger_hierarchy ,
629
+ .irq_set_type = irq_chip_set_type_parent ,
630
+ .irq_set_wake = stm32_exti_h_set_wake ,
631
+ .flags = IRQCHIP_MASK_ON_SUSPEND ,
632
+ .irq_set_affinity = IS_ENABLED (CONFIG_SMP ) ? irq_chip_set_affinity_parent : NULL ,
633
+ };
634
+
606
635
static int stm32_exti_h_domain_alloc (struct irq_domain * dm ,
607
636
unsigned int virq ,
608
637
unsigned int nr_irqs , void * data )
609
638
{
610
639
struct stm32_exti_host_data * host_data = dm -> host_data ;
611
640
struct stm32_exti_chip_data * chip_data ;
641
+ const struct stm32_desc_irq * desc ;
612
642
struct irq_fwspec * fwspec = data ;
613
643
struct irq_fwspec p_fwspec ;
614
644
irq_hw_number_t hwirq ;
615
- int p_irq , bank ;
645
+ int bank ;
616
646
617
647
hwirq = fwspec -> param [0 ];
618
648
bank = hwirq / IRQS_PER_BANK ;
619
649
chip_data = & host_data -> chips_data [bank ];
620
650
621
- irq_domain_set_hwirq_and_chip (dm , virq , hwirq ,
622
- & stm32_exti_h_chip , chip_data );
623
651
624
- p_irq = stm32_exti_to_irq (host_data -> drv_data , hwirq );
625
- if (p_irq >= 0 ) {
652
+ desc = stm32_exti_get_desc (host_data -> drv_data , hwirq );
653
+ if (!desc )
654
+ return - EINVAL ;
655
+
656
+ irq_domain_set_hwirq_and_chip (dm , virq , hwirq , desc -> chip ,
657
+ chip_data );
658
+ if (desc -> irq_parent ) {
626
659
p_fwspec .fwnode = dm -> parent -> fwnode ;
627
660
p_fwspec .param_count = 3 ;
628
661
p_fwspec .param [0 ] = GIC_SPI ;
629
- p_fwspec .param [1 ] = p_irq ;
662
+ p_fwspec .param [1 ] = desc -> irq_parent ;
630
663
p_fwspec .param [2 ] = IRQ_TYPE_LEVEL_HIGH ;
631
664
632
665
return irq_domain_alloc_irqs_parent (dm , virq , 1 , & p_fwspec );
0 commit comments