Skip to content

Commit 33c56e5

Browse files
author
Linus Walleij
committed
pinctrl: pistachio: Convert to immutable irq_chip
Convert the driver to immutable irq-chip with a bit of intuition. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20230414-immutable-irqchips-2-v1-2-6b59a5186b00@linaro.org
1 parent a0a53f1 commit 33c56e5

1 file changed

Lines changed: 25 additions & 10 deletions

File tree

drivers/pinctrl/pinctrl-pistachio.c

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/pinctrl/pinmux.h>
1818
#include <linux/platform_device.h>
1919
#include <linux/property.h>
20+
#include <linux/seq_file.h>
2021
#include <linux/slab.h>
2122
#include <linux/spinlock.h>
2223

@@ -93,10 +94,10 @@ struct pistachio_pin_group {
9394
struct pistachio_gpio_bank {
9495
struct pistachio_pinctrl *pctl;
9596
void __iomem *base;
97+
int instance;
9698
unsigned int pin_base;
9799
unsigned int npins;
98100
struct gpio_chip gpio_chip;
99-
struct irq_chip irq_chip;
100101
};
101102

102103
struct pistachio_pinctrl {
@@ -1228,12 +1229,14 @@ static void pistachio_gpio_irq_mask(struct irq_data *data)
12281229
struct pistachio_gpio_bank *bank = irqd_to_bank(data);
12291230

12301231
gpio_mask_writel(bank, GPIO_INTERRUPT_EN, data->hwirq, 0);
1232+
gpiochip_disable_irq(&bank->gpio_chip, irqd_to_hwirq(data));
12311233
}
12321234

12331235
static void pistachio_gpio_irq_unmask(struct irq_data *data)
12341236
{
12351237
struct pistachio_gpio_bank *bank = irqd_to_bank(data);
12361238

1239+
gpiochip_enable_irq(&bank->gpio_chip, irqd_to_hwirq(data));
12371240
gpio_mask_writel(bank, GPIO_INTERRUPT_EN, data->hwirq, 1);
12381241
}
12391242

@@ -1312,6 +1315,7 @@ static void pistachio_gpio_irq_handler(struct irq_desc *desc)
13121315

13131316
#define GPIO_BANK(_bank, _pin_base, _npins) \
13141317
{ \
1318+
.instance = (_bank), \
13151319
.pin_base = _pin_base, \
13161320
.npins = _npins, \
13171321
.gpio_chip = { \
@@ -1326,14 +1330,6 @@ static void pistachio_gpio_irq_handler(struct irq_desc *desc)
13261330
.base = _pin_base, \
13271331
.ngpio = _npins, \
13281332
}, \
1329-
.irq_chip = { \
1330-
.name = "GPIO" #_bank, \
1331-
.irq_startup = pistachio_gpio_irq_startup, \
1332-
.irq_ack = pistachio_gpio_irq_ack, \
1333-
.irq_mask = pistachio_gpio_irq_mask, \
1334-
.irq_unmask = pistachio_gpio_irq_unmask, \
1335-
.irq_set_type = pistachio_gpio_irq_set_type, \
1336-
}, \
13371333
}
13381334

13391335
static struct pistachio_gpio_bank pistachio_gpio_banks[] = {
@@ -1345,6 +1341,25 @@ static struct pistachio_gpio_bank pistachio_gpio_banks[] = {
13451341
GPIO_BANK(5, PISTACHIO_PIN_MFIO(80), 10),
13461342
};
13471343

1344+
static void pistachio_gpio_irq_print_chip(struct irq_data *data,
1345+
struct seq_file *p)
1346+
{
1347+
struct pistachio_gpio_bank *bank = irqd_to_bank(data);
1348+
1349+
seq_printf(p, "GPIO%d", bank->instance);
1350+
}
1351+
1352+
static const struct irq_chip pistachio_gpio_irq_chip = {
1353+
.irq_startup = pistachio_gpio_irq_startup,
1354+
.irq_ack = pistachio_gpio_irq_ack,
1355+
.irq_mask = pistachio_gpio_irq_mask,
1356+
.irq_unmask = pistachio_gpio_irq_unmask,
1357+
.irq_set_type = pistachio_gpio_irq_set_type,
1358+
.irq_print_chip = pistachio_gpio_irq_print_chip,
1359+
.flags = IRQCHIP_IMMUTABLE,
1360+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
1361+
};
1362+
13481363
static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
13491364
{
13501365
struct pistachio_gpio_bank *bank;
@@ -1394,7 +1409,7 @@ static int pistachio_gpio_register(struct pistachio_pinctrl *pctl)
13941409
bank->gpio_chip.fwnode = child;
13951410

13961411
girq = &bank->gpio_chip.irq;
1397-
girq->chip = &bank->irq_chip;
1412+
gpio_irq_chip_set_chip(girq, &pistachio_gpio_irq_chip);
13981413
girq->parent_handler = pistachio_gpio_irq_handler;
13991414
girq->num_parents = 1;
14001415
girq->parents = devm_kcalloc(pctl->dev, 1,

0 commit comments

Comments
 (0)