Skip to content

Commit 9d6a5fe

Browse files
atorgueMarc Zyngier
authored andcommitted
irqchip/stm32-exti: Map direct event to irq parent
EXTI lines are mainly used to wake-up system from CStop low power mode. Currently, if a device wants to use a EXTI (direct) line as wakeup line, it has to declare 2 interrupts: - one for EXTI used to wake-up system (with dedicated_wake_irq api). - one for GIC used to get the wake up reason inside the concerned IP. This split is not really needed as each EXTI line is actually "linked " to a GIC. So to avoid this useless double interrupt management in each wake-up driver, this patch lets the STM32 EXTI driver abstract it by mapping each EXTI line to his corresponding GIC. Signed-off-by: Alexandre Torgue <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 920ecb8 commit 9d6a5fe

File tree

1 file changed

+67
-34
lines changed

1 file changed

+67
-34
lines changed

drivers/irqchip/irq-stm32-exti.c

Lines changed: 67 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ struct stm32_exti_bank {
4141
struct stm32_desc_irq {
4242
u32 exti;
4343
u32 irq_parent;
44+
struct irq_chip *chip;
4445
};
4546

4647
struct stm32_exti_drv_data {
@@ -165,27 +166,41 @@ static const struct stm32_exti_bank *stm32mp1_exti_banks[] = {
165166
&stm32mp1_exti_b3,
166167
};
167168

169+
static struct irq_chip stm32_exti_h_chip;
170+
static struct irq_chip stm32_exti_h_chip_direct;
171+
168172
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 },
189204
};
190205

191206
static const struct stm32_exti_drv_data stm32mp1_drv_data = {
@@ -195,22 +210,23 @@ static const struct stm32_exti_drv_data stm32mp1_drv_data = {
195210
.irq_nr = ARRAY_SIZE(stm32mp1_desc_irq),
196211
};
197212

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)
200216
{
201-
const struct stm32_desc_irq *desc_irq;
217+
const struct stm32_desc_irq *desc = NULL;
202218
int i;
203219

204220
if (!drv_data->desc_irqs)
205-
return -EINVAL;
221+
return NULL;
206222

207223
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;
211227
}
212228

213-
return -EINVAL;
229+
return desc;
214230
}
215231

216232
static unsigned long stm32_exti_pending(struct irq_chip_generic *gc)
@@ -603,30 +619,47 @@ static struct irq_chip stm32_exti_h_chip = {
603619
.irq_set_affinity = IS_ENABLED(CONFIG_SMP) ? stm32_exti_h_set_affinity : NULL,
604620
};
605621

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+
606635
static int stm32_exti_h_domain_alloc(struct irq_domain *dm,
607636
unsigned int virq,
608637
unsigned int nr_irqs, void *data)
609638
{
610639
struct stm32_exti_host_data *host_data = dm->host_data;
611640
struct stm32_exti_chip_data *chip_data;
641+
const struct stm32_desc_irq *desc;
612642
struct irq_fwspec *fwspec = data;
613643
struct irq_fwspec p_fwspec;
614644
irq_hw_number_t hwirq;
615-
int p_irq, bank;
645+
int bank;
616646

617647
hwirq = fwspec->param[0];
618648
bank = hwirq / IRQS_PER_BANK;
619649
chip_data = &host_data->chips_data[bank];
620650

621-
irq_domain_set_hwirq_and_chip(dm, virq, hwirq,
622-
&stm32_exti_h_chip, chip_data);
623651

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) {
626659
p_fwspec.fwnode = dm->parent->fwnode;
627660
p_fwspec.param_count = 3;
628661
p_fwspec.param[0] = GIC_SPI;
629-
p_fwspec.param[1] = p_irq;
662+
p_fwspec.param[1] = desc->irq_parent;
630663
p_fwspec.param[2] = IRQ_TYPE_LEVEL_HIGH;
631664

632665
return irq_domain_alloc_irqs_parent(dm, virq, 1, &p_fwspec);

0 commit comments

Comments
 (0)