Skip to content

Commit a0a53f1

Browse files
author
Linus Walleij
committed
pinctrl: pic32: Convert to immutable irq_chip
Convert the driver to immutable irq-chip with a bit of intuition. Switch some call to use irqd_to_hwirq() in the process. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Link: https://lore.kernel.org/r/20230414-immutable-irqchips-2-v1-1-6b59a5186b00@linaro.org
1 parent df60325 commit a0a53f1

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

drivers/pinctrl/pinctrl-pic32.c

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

@@ -60,8 +61,8 @@ struct pic32_desc_function {
6061

6162
struct pic32_gpio_bank {
6263
void __iomem *reg_base;
64+
int instance;
6365
struct gpio_chip gpio_chip;
64-
struct irq_chip irq_chip;
6566
struct clk *clk;
6667
};
6768

@@ -2008,12 +2009,14 @@ static void pic32_gpio_irq_mask(struct irq_data *data)
20082009
struct pic32_gpio_bank *bank = irqd_to_bank(data);
20092010

20102011
writel(BIT(PIC32_CNCON_ON), bank->reg_base + PIC32_CLR(CNCON_REG));
2012+
gpiochip_disable_irq(&bank->gpio_chip, irqd_to_hwirq(data));
20112013
}
20122014

20132015
static void pic32_gpio_irq_unmask(struct irq_data *data)
20142016
{
20152017
struct pic32_gpio_bank *bank = irqd_to_bank(data);
20162018

2019+
gpiochip_enable_irq(&bank->gpio_chip, irqd_to_hwirq(data));
20172020
writel(BIT(PIC32_CNCON_ON), bank->reg_base + PIC32_SET(CNCON_REG));
20182021
}
20192022

@@ -2030,7 +2033,7 @@ static unsigned int pic32_gpio_irq_startup(struct irq_data *data)
20302033
static int pic32_gpio_irq_set_type(struct irq_data *data, unsigned int type)
20312034
{
20322035
struct pic32_gpio_bank *bank = irqd_to_bank(data);
2033-
u32 mask = BIT(data->hwirq);
2036+
u32 mask = irqd_to_hwirq(data);
20342037

20352038
switch (type & IRQ_TYPE_SENSE_MASK) {
20362039
case IRQ_TYPE_EDGE_RISING:
@@ -2122,14 +2125,7 @@ static void pic32_gpio_irq_handler(struct irq_desc *desc)
21222125
.owner = THIS_MODULE, \
21232126
.can_sleep = 0, \
21242127
}, \
2125-
.irq_chip = { \
2126-
.name = "GPIO" #_bank, \
2127-
.irq_startup = pic32_gpio_irq_startup, \
2128-
.irq_ack = pic32_gpio_irq_ack, \
2129-
.irq_mask = pic32_gpio_irq_mask, \
2130-
.irq_unmask = pic32_gpio_irq_unmask, \
2131-
.irq_set_type = pic32_gpio_irq_set_type, \
2132-
}, \
2128+
.instance = (_bank), \
21332129
}
21342130

21352131
static struct pic32_gpio_bank pic32_gpio_banks[] = {
@@ -2145,6 +2141,24 @@ static struct pic32_gpio_bank pic32_gpio_banks[] = {
21452141
GPIO_BANK(9, PINS_PER_BANK),
21462142
};
21472143

2144+
static void pic32_gpio_irq_print_chip(struct irq_data *data, struct seq_file *p)
2145+
{
2146+
struct pic32_gpio_bank *bank = irqd_to_bank(data);
2147+
2148+
seq_printf(p, "GPIO%d", bank->instance);
2149+
}
2150+
2151+
static const struct irq_chip pic32_gpio_irq_chip = {
2152+
.irq_startup = pic32_gpio_irq_startup,
2153+
.irq_ack = pic32_gpio_irq_ack,
2154+
.irq_mask = pic32_gpio_irq_mask,
2155+
.irq_unmask = pic32_gpio_irq_unmask,
2156+
.irq_set_type = pic32_gpio_irq_set_type,
2157+
.irq_print_chip = pic32_gpio_irq_print_chip,
2158+
.flags = IRQCHIP_IMMUTABLE,
2159+
GPIOCHIP_IRQ_RESOURCE_HELPERS,
2160+
};
2161+
21482162
static int pic32_pinctrl_probe(struct platform_device *pdev)
21492163
{
21502164
struct pic32_pinctrl *pctl;
@@ -2243,7 +2257,7 @@ static int pic32_gpio_probe(struct platform_device *pdev)
22432257
bank->gpio_chip.parent = &pdev->dev;
22442258

22452259
girq = &bank->gpio_chip.irq;
2246-
girq->chip = &bank->irq_chip;
2260+
gpio_irq_chip_set_chip(girq, &pic32_gpio_irq_chip);
22472261
girq->parent_handler = pic32_gpio_irq_handler;
22482262
girq->num_parents = 1;
22492263
girq->parents = devm_kcalloc(&pdev->dev, 1, sizeof(*girq->parents),

0 commit comments

Comments
 (0)