@@ -34,21 +34,15 @@ struct stm32_exti_bank {
34
34
u32 swier_ofst ;
35
35
u32 rpr_ofst ;
36
36
u32 fpr_ofst ;
37
+ u32 trg_ofst ;
37
38
};
38
39
39
40
#define UNDEF_REG ~0
40
41
41
- struct stm32_desc_irq {
42
- u32 exti ;
43
- u32 irq_parent ;
44
- struct irq_chip * chip ;
45
- };
46
-
47
42
struct stm32_exti_drv_data {
48
43
const struct stm32_exti_bank * * exti_banks ;
49
- const struct stm32_desc_irq * desc_irqs ;
44
+ const u8 * desc_irqs ;
50
45
u32 bank_nr ;
51
- u32 irq_nr ;
52
46
};
53
47
54
48
struct stm32_exti_chip_data {
@@ -78,6 +72,7 @@ static const struct stm32_exti_bank stm32f4xx_exti_b1 = {
78
72
.swier_ofst = 0x10 ,
79
73
.rpr_ofst = 0x14 ,
80
74
.fpr_ofst = UNDEF_REG ,
75
+ .trg_ofst = UNDEF_REG ,
81
76
};
82
77
83
78
static const struct stm32_exti_bank * stm32f4xx_exti_banks [] = {
@@ -97,6 +92,7 @@ static const struct stm32_exti_bank stm32h7xx_exti_b1 = {
97
92
.swier_ofst = 0x08 ,
98
93
.rpr_ofst = 0x88 ,
99
94
.fpr_ofst = UNDEF_REG ,
95
+ .trg_ofst = UNDEF_REG ,
100
96
};
101
97
102
98
static const struct stm32_exti_bank stm32h7xx_exti_b2 = {
@@ -107,6 +103,7 @@ static const struct stm32_exti_bank stm32h7xx_exti_b2 = {
107
103
.swier_ofst = 0x28 ,
108
104
.rpr_ofst = 0x98 ,
109
105
.fpr_ofst = UNDEF_REG ,
106
+ .trg_ofst = UNDEF_REG ,
110
107
};
111
108
112
109
static const struct stm32_exti_bank stm32h7xx_exti_b3 = {
@@ -117,6 +114,7 @@ static const struct stm32_exti_bank stm32h7xx_exti_b3 = {
117
114
.swier_ofst = 0x48 ,
118
115
.rpr_ofst = 0xA8 ,
119
116
.fpr_ofst = UNDEF_REG ,
117
+ .trg_ofst = UNDEF_REG ,
120
118
};
121
119
122
120
static const struct stm32_exti_bank * stm32h7xx_exti_banks [] = {
@@ -132,32 +130,35 @@ static const struct stm32_exti_drv_data stm32h7xx_drv_data = {
132
130
133
131
static const struct stm32_exti_bank stm32mp1_exti_b1 = {
134
132
.imr_ofst = 0x80 ,
135
- .emr_ofst = 0x84 ,
133
+ .emr_ofst = UNDEF_REG ,
136
134
.rtsr_ofst = 0x00 ,
137
135
.ftsr_ofst = 0x04 ,
138
136
.swier_ofst = 0x08 ,
139
137
.rpr_ofst = 0x0C ,
140
138
.fpr_ofst = 0x10 ,
139
+ .trg_ofst = 0x3EC ,
141
140
};
142
141
143
142
static const struct stm32_exti_bank stm32mp1_exti_b2 = {
144
143
.imr_ofst = 0x90 ,
145
- .emr_ofst = 0x94 ,
144
+ .emr_ofst = UNDEF_REG ,
146
145
.rtsr_ofst = 0x20 ,
147
146
.ftsr_ofst = 0x24 ,
148
147
.swier_ofst = 0x28 ,
149
148
.rpr_ofst = 0x2C ,
150
149
.fpr_ofst = 0x30 ,
150
+ .trg_ofst = 0x3E8 ,
151
151
};
152
152
153
153
static const struct stm32_exti_bank stm32mp1_exti_b3 = {
154
154
.imr_ofst = 0xA0 ,
155
- .emr_ofst = 0xA4 ,
155
+ .emr_ofst = UNDEF_REG ,
156
156
.rtsr_ofst = 0x40 ,
157
157
.ftsr_ofst = 0x44 ,
158
158
.swier_ofst = 0x48 ,
159
159
.rpr_ofst = 0x4C ,
160
160
.fpr_ofst = 0x50 ,
161
+ .trg_ofst = 0x3E4 ,
161
162
};
162
163
163
164
static const struct stm32_exti_bank * stm32mp1_exti_banks [] = {
@@ -169,126 +170,114 @@ static const struct stm32_exti_bank *stm32mp1_exti_banks[] = {
169
170
static struct irq_chip stm32_exti_h_chip ;
170
171
static struct irq_chip stm32_exti_h_chip_direct ;
171
172
172
- static const struct stm32_desc_irq stm32mp1_desc_irq [] = {
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 = 26 , .irq_parent = 37 , .chip = & stm32_exti_h_chip_direct },
197
- { .exti = 27 , .irq_parent = 38 , .chip = & stm32_exti_h_chip_direct },
198
- { .exti = 28 , .irq_parent = 39 , .chip = & stm32_exti_h_chip_direct },
199
- { .exti = 29 , .irq_parent = 71 , .chip = & stm32_exti_h_chip_direct },
200
- { .exti = 30 , .irq_parent = 52 , .chip = & stm32_exti_h_chip_direct },
201
- { .exti = 31 , .irq_parent = 53 , .chip = & stm32_exti_h_chip_direct },
202
- { .exti = 32 , .irq_parent = 82 , .chip = & stm32_exti_h_chip_direct },
203
- { .exti = 33 , .irq_parent = 83 , .chip = & stm32_exti_h_chip_direct },
204
- { .exti = 47 , .irq_parent = 93 , .chip = & stm32_exti_h_chip_direct },
205
- { .exti = 48 , .irq_parent = 138 , .chip = & stm32_exti_h_chip_direct },
206
- { .exti = 50 , .irq_parent = 139 , .chip = & stm32_exti_h_chip_direct },
207
- { .exti = 52 , .irq_parent = 140 , .chip = & stm32_exti_h_chip_direct },
208
- { .exti = 53 , .irq_parent = 141 , .chip = & stm32_exti_h_chip_direct },
209
- { .exti = 54 , .irq_parent = 135 , .chip = & stm32_exti_h_chip_direct },
210
- { .exti = 61 , .irq_parent = 100 , .chip = & stm32_exti_h_chip_direct },
211
- { .exti = 65 , .irq_parent = 144 , .chip = & stm32_exti_h_chip },
212
- { .exti = 68 , .irq_parent = 143 , .chip = & stm32_exti_h_chip },
213
- { .exti = 70 , .irq_parent = 62 , .chip = & stm32_exti_h_chip_direct },
214
- { .exti = 73 , .irq_parent = 129 , .chip = & stm32_exti_h_chip },
173
+ #define EXTI_INVALID_IRQ U8_MAX
174
+ #define STM32MP1_DESC_IRQ_SIZE (ARRAY_SIZE(stm32mp1_exti_banks) * IRQS_PER_BANK)
175
+
176
+ static const u8 stm32mp1_desc_irq [] = {
177
+ /* default value */
178
+ [0 ... (STM32MP1_DESC_IRQ_SIZE - 1 )] = EXTI_INVALID_IRQ ,
179
+
180
+ [0 ] = 6 ,
181
+ [1 ] = 7 ,
182
+ [2 ] = 8 ,
183
+ [3 ] = 9 ,
184
+ [4 ] = 10 ,
185
+ [5 ] = 23 ,
186
+ [6 ] = 64 ,
187
+ [7 ] = 65 ,
188
+ [8 ] = 66 ,
189
+ [9 ] = 67 ,
190
+ [10 ] = 40 ,
191
+ [11 ] = 42 ,
192
+ [12 ] = 76 ,
193
+ [13 ] = 77 ,
194
+ [14 ] = 121 ,
195
+ [15 ] = 127 ,
196
+ [16 ] = 1 ,
197
+ [19 ] = 3 ,
198
+ [21 ] = 31 ,
199
+ [22 ] = 33 ,
200
+ [23 ] = 72 ,
201
+ [24 ] = 95 ,
202
+ [25 ] = 107 ,
203
+ [26 ] = 37 ,
204
+ [27 ] = 38 ,
205
+ [28 ] = 39 ,
206
+ [29 ] = 71 ,
207
+ [30 ] = 52 ,
208
+ [31 ] = 53 ,
209
+ [32 ] = 82 ,
210
+ [33 ] = 83 ,
211
+ [47 ] = 93 ,
212
+ [48 ] = 138 ,
213
+ [50 ] = 139 ,
214
+ [52 ] = 140 ,
215
+ [53 ] = 141 ,
216
+ [54 ] = 135 ,
217
+ [61 ] = 100 ,
218
+ [65 ] = 144 ,
219
+ [68 ] = 143 ,
220
+ [70 ] = 62 ,
221
+ [73 ] = 129 ,
215
222
};
216
223
217
- static const struct stm32_desc_irq stm32mp13_desc_irq [] = {
218
- { .exti = 0 , .irq_parent = 6 , .chip = & stm32_exti_h_chip },
219
- { .exti = 1 , .irq_parent = 7 , .chip = & stm32_exti_h_chip },
220
- { .exti = 2 , .irq_parent = 8 , .chip = & stm32_exti_h_chip },
221
- { .exti = 3 , .irq_parent = 9 , .chip = & stm32_exti_h_chip },
222
- { .exti = 4 , .irq_parent = 10 , .chip = & stm32_exti_h_chip },
223
- { .exti = 5 , .irq_parent = 24 , .chip = & stm32_exti_h_chip },
224
- { .exti = 6 , .irq_parent = 65 , .chip = & stm32_exti_h_chip },
225
- { .exti = 7 , .irq_parent = 66 , .chip = & stm32_exti_h_chip },
226
- { .exti = 8 , .irq_parent = 67 , .chip = & stm32_exti_h_chip },
227
- { .exti = 9 , .irq_parent = 68 , .chip = & stm32_exti_h_chip },
228
- { .exti = 10 , .irq_parent = 41 , .chip = & stm32_exti_h_chip },
229
- { .exti = 11 , .irq_parent = 43 , .chip = & stm32_exti_h_chip },
230
- { .exti = 12 , .irq_parent = 77 , .chip = & stm32_exti_h_chip },
231
- { .exti = 13 , .irq_parent = 78 , .chip = & stm32_exti_h_chip },
232
- { .exti = 14 , .irq_parent = 106 , .chip = & stm32_exti_h_chip },
233
- { .exti = 15 , .irq_parent = 109 , .chip = & stm32_exti_h_chip },
234
- { .exti = 16 , .irq_parent = 1 , .chip = & stm32_exti_h_chip },
235
- { .exti = 19 , .irq_parent = 3 , .chip = & stm32_exti_h_chip_direct },
236
- { .exti = 21 , .irq_parent = 32 , .chip = & stm32_exti_h_chip_direct },
237
- { .exti = 22 , .irq_parent = 34 , .chip = & stm32_exti_h_chip_direct },
238
- { .exti = 23 , .irq_parent = 73 , .chip = & stm32_exti_h_chip_direct },
239
- { .exti = 24 , .irq_parent = 93 , .chip = & stm32_exti_h_chip_direct },
240
- { .exti = 25 , .irq_parent = 114 , .chip = & stm32_exti_h_chip_direct },
241
- { .exti = 26 , .irq_parent = 38 , .chip = & stm32_exti_h_chip_direct },
242
- { .exti = 27 , .irq_parent = 39 , .chip = & stm32_exti_h_chip_direct },
243
- { .exti = 28 , .irq_parent = 40 , .chip = & stm32_exti_h_chip_direct },
244
- { .exti = 29 , .irq_parent = 72 , .chip = & stm32_exti_h_chip_direct },
245
- { .exti = 30 , .irq_parent = 53 , .chip = & stm32_exti_h_chip_direct },
246
- { .exti = 31 , .irq_parent = 54 , .chip = & stm32_exti_h_chip_direct },
247
- { .exti = 32 , .irq_parent = 83 , .chip = & stm32_exti_h_chip_direct },
248
- { .exti = 33 , .irq_parent = 84 , .chip = & stm32_exti_h_chip_direct },
249
- { .exti = 44 , .irq_parent = 96 , .chip = & stm32_exti_h_chip_direct },
250
- { .exti = 47 , .irq_parent = 92 , .chip = & stm32_exti_h_chip_direct },
251
- { .exti = 48 , .irq_parent = 116 , .chip = & stm32_exti_h_chip_direct },
252
- { .exti = 50 , .irq_parent = 117 , .chip = & stm32_exti_h_chip_direct },
253
- { .exti = 52 , .irq_parent = 118 , .chip = & stm32_exti_h_chip_direct },
254
- { .exti = 53 , .irq_parent = 119 , .chip = & stm32_exti_h_chip_direct },
255
- { .exti = 68 , .irq_parent = 63 , .chip = & stm32_exti_h_chip_direct },
256
- { .exti = 70 , .irq_parent = 98 , .chip = & stm32_exti_h_chip_direct },
224
+ static const u8 stm32mp13_desc_irq [] = {
225
+ /* default value */
226
+ [0 ... (STM32MP1_DESC_IRQ_SIZE - 1 )] = EXTI_INVALID_IRQ ,
227
+
228
+ [0 ] = 6 ,
229
+ [1 ] = 7 ,
230
+ [2 ] = 8 ,
231
+ [3 ] = 9 ,
232
+ [4 ] = 10 ,
233
+ [5 ] = 24 ,
234
+ [6 ] = 65 ,
235
+ [7 ] = 66 ,
236
+ [8 ] = 67 ,
237
+ [9 ] = 68 ,
238
+ [10 ] = 41 ,
239
+ [11 ] = 43 ,
240
+ [12 ] = 77 ,
241
+ [13 ] = 78 ,
242
+ [14 ] = 106 ,
243
+ [15 ] = 109 ,
244
+ [16 ] = 1 ,
245
+ [19 ] = 3 ,
246
+ [21 ] = 32 ,
247
+ [22 ] = 34 ,
248
+ [23 ] = 73 ,
249
+ [24 ] = 93 ,
250
+ [25 ] = 114 ,
251
+ [26 ] = 38 ,
252
+ [27 ] = 39 ,
253
+ [28 ] = 40 ,
254
+ [29 ] = 72 ,
255
+ [30 ] = 53 ,
256
+ [31 ] = 54 ,
257
+ [32 ] = 83 ,
258
+ [33 ] = 84 ,
259
+ [44 ] = 96 ,
260
+ [47 ] = 92 ,
261
+ [48 ] = 116 ,
262
+ [50 ] = 117 ,
263
+ [52 ] = 118 ,
264
+ [53 ] = 119 ,
265
+ [68 ] = 63 ,
266
+ [70 ] = 98 ,
257
267
};
258
268
259
269
static const struct stm32_exti_drv_data stm32mp1_drv_data = {
260
270
.exti_banks = stm32mp1_exti_banks ,
261
271
.bank_nr = ARRAY_SIZE (stm32mp1_exti_banks ),
262
272
.desc_irqs = stm32mp1_desc_irq ,
263
- .irq_nr = ARRAY_SIZE (stm32mp1_desc_irq ),
264
273
};
265
274
266
275
static const struct stm32_exti_drv_data stm32mp13_drv_data = {
267
276
.exti_banks = stm32mp1_exti_banks ,
268
277
.bank_nr = ARRAY_SIZE (stm32mp1_exti_banks ),
269
278
.desc_irqs = stm32mp13_desc_irq ,
270
- .irq_nr = ARRAY_SIZE (stm32mp13_desc_irq ),
271
279
};
272
280
273
- static const struct
274
- stm32_desc_irq * stm32_exti_get_desc (const struct stm32_exti_drv_data * drv_data ,
275
- irq_hw_number_t hwirq )
276
- {
277
- const struct stm32_desc_irq * desc = NULL ;
278
- int i ;
279
-
280
- if (!drv_data -> desc_irqs )
281
- return NULL ;
282
-
283
- for (i = 0 ; i < drv_data -> irq_nr ; i ++ ) {
284
- desc = & drv_data -> desc_irqs [i ];
285
- if (desc -> exti == hwirq )
286
- break ;
287
- }
288
-
289
- return desc ;
290
- }
291
-
292
281
static unsigned long stm32_exti_pending (struct irq_chip_generic * gc )
293
282
{
294
283
struct stm32_exti_chip_data * chip_data = gc -> private ;
@@ -614,7 +603,7 @@ static int stm32_exti_h_set_affinity(struct irq_data *d,
614
603
if (d -> parent_data -> chip )
615
604
return irq_chip_set_affinity_parent (d , dest , force );
616
605
617
- return - EINVAL ;
606
+ return IRQ_SET_MASK_OK_DONE ;
618
607
}
619
608
620
609
static int __maybe_unused stm32_exti_h_suspend (void )
@@ -691,8 +680,8 @@ static struct irq_chip stm32_exti_h_chip_direct = {
691
680
.name = "stm32-exti-h-direct" ,
692
681
.irq_eoi = irq_chip_eoi_parent ,
693
682
.irq_ack = irq_chip_ack_parent ,
694
- .irq_mask = irq_chip_mask_parent ,
695
- .irq_unmask = irq_chip_unmask_parent ,
683
+ .irq_mask = stm32_exti_h_mask ,
684
+ .irq_unmask = stm32_exti_h_unmask ,
696
685
.irq_retrigger = irq_chip_retrigger_hierarchy ,
697
686
.irq_set_type = irq_chip_set_type_parent ,
698
687
.irq_set_wake = stm32_exti_h_set_wake ,
@@ -706,28 +695,36 @@ static int stm32_exti_h_domain_alloc(struct irq_domain *dm,
706
695
{
707
696
struct stm32_exti_host_data * host_data = dm -> host_data ;
708
697
struct stm32_exti_chip_data * chip_data ;
709
- const struct stm32_desc_irq * desc ;
698
+ u8 desc_irq ;
710
699
struct irq_fwspec * fwspec = data ;
711
700
struct irq_fwspec p_fwspec ;
712
701
irq_hw_number_t hwirq ;
713
702
int bank ;
703
+ u32 event_trg ;
704
+ struct irq_chip * chip ;
714
705
715
706
hwirq = fwspec -> param [0 ];
707
+ if (hwirq >= host_data -> drv_data -> bank_nr * IRQS_PER_BANK )
708
+ return - EINVAL ;
709
+
716
710
bank = hwirq / IRQS_PER_BANK ;
717
711
chip_data = & host_data -> chips_data [bank ];
718
712
713
+ event_trg = readl_relaxed (host_data -> base + chip_data -> reg_bank -> trg_ofst );
714
+ chip = (event_trg & BIT (hwirq % IRQS_PER_BANK )) ?
715
+ & stm32_exti_h_chip : & stm32_exti_h_chip_direct ;
716
+
717
+ irq_domain_set_hwirq_and_chip (dm , virq , hwirq , chip , chip_data );
719
718
720
- desc = stm32_exti_get_desc (host_data -> drv_data , hwirq );
721
- if (!desc )
719
+ if (!host_data -> drv_data || !host_data -> drv_data -> desc_irqs )
722
720
return - EINVAL ;
723
721
724
- irq_domain_set_hwirq_and_chip (dm , virq , hwirq , desc -> chip ,
725
- chip_data );
726
- if (desc -> irq_parent ) {
722
+ desc_irq = host_data -> drv_data -> desc_irqs [hwirq ];
723
+ if (desc_irq != EXTI_INVALID_IRQ ) {
727
724
p_fwspec .fwnode = dm -> parent -> fwnode ;
728
725
p_fwspec .param_count = 3 ;
729
726
p_fwspec .param [0 ] = GIC_SPI ;
730
- p_fwspec .param [1 ] = desc -> irq_parent ;
727
+ p_fwspec .param [1 ] = desc_irq ;
731
728
p_fwspec .param [2 ] = IRQ_TYPE_LEVEL_HIGH ;
732
729
733
730
return irq_domain_alloc_irqs_parent (dm , virq , 1 , & p_fwspec );
@@ -792,7 +789,8 @@ stm32_exti_chip_data *stm32_exti_chip_init(struct stm32_exti_host_data *h_data,
792
789
* clear registers to avoid residue
793
790
*/
794
791
writel_relaxed (0 , base + stm32_bank -> imr_ofst );
795
- writel_relaxed (0 , base + stm32_bank -> emr_ofst );
792
+ if (stm32_bank -> emr_ofst != UNDEF_REG )
793
+ writel_relaxed (0 , base + stm32_bank -> emr_ofst );
796
794
797
795
pr_info ("%pOF: bank%d\n" , node , bank_idx );
798
796
0 commit comments