Mass convert GPIO IRQ chips to be immutable
Subsystems (9)
v3 cover Mass convert GPIO IRQ chips to be immutable
We are getting tired of these irq_chips not getting converted to be immutable, so I just take out the big hammer and fix some that I deem not too complex as best I can.
I stopped after doing some, I will take another sweep at some point I guess.
This is v6.4 material.
The last two patches to pci-idio-* (patch 15 and 16) can be omitted if William's patches to convert this driver to regmap GPIO are merged first.
---
Changes in v3:
- Deleted the irq_chip->name assignment in the Aspeed driver
- Fold in a patch from Joel to make aspeed IRQs compulsory
- Link to v2: https://lore.kernel.org/r/20230215-immutable-chips-v2-0-d6b0e3f2d991 at linaro.org
Changes in v2:
- Rebased on v6.3-rc1
- Collected some test and ACK tags
- Link to v1: https://lore.kernel.org/r/20230215-immutable-chips-v1-0-51a8f224a5d0 at linaro.org
---
Joel Stanley (1):
gpio: aspeed: Always register the irqchip
Linus Walleij (16):
gpio: altera: Convert to immutable irq_chip
gpio: adnp: Convert to immutable irq_chip
gpio: aspeed: Convert to immutable irq_chip
gpio: aspeed-sgpio: Convert to immutable irq_chip
gpio: ath79: Convert to immutable irq_chip
gpio: cadence: Convert to immutable irq_chip
gpio: hisi: Convert to immutable irq_chip
gpio: hlwd: Convert to immutable irq_chip
gpio: idt3243x: Convert to immutable irq_chip
gpio: msc313: Convert to immutable irq_chip
gpio: mlxbf2: Convert to immutable irq_chip
gpio: max732x: Convert to immutable irq_chip
gpio: omap: Drop irq_base
gpio: omap: Convert to immutable irq_chip
gpio: pci-idio-16: Convert to immutable irq_chip
gpio: pcie-idio-24: Convert to immutable irq_chip
drivers/gpio/gpio-adnp.c | 9 ++++- drivers/gpio/gpio-altera.c | 25 +++++++----- drivers/gpio/gpio-aspeed-sgpio.c | 44 +++++++++++++++++---- drivers/gpio/gpio-aspeed.c | 82 ++++++++++++++++++++++++++------------- drivers/gpio/gpio-ath79.c | 8 +++- drivers/gpio/gpio-cadence.c | 10 +++-- drivers/gpio/gpio-hisi.c | 25 +++++++----- drivers/gpio/gpio-hlwd.c | 33 ++++++++++++---- drivers/gpio/gpio-idt3243x.c | 11 ++++-- drivers/gpio/gpio-max732x.c | 8 +++- drivers/gpio/gpio-mlxbf2.c | 32 ++++++++++++---- drivers/gpio/gpio-msc313.c | 26 +++++++++++-- drivers/gpio/gpio-omap.c | 83 ++++++++++++++++++++++------------------ drivers/gpio/gpio-pci-idio-16.c | 12 ++++-- drivers/gpio/gpio-pcie-idio-24.c | 12 ++++-- 15 files changed, 290 insertions(+), 130 deletions(-)
---
base-commit: fe15c26ee26efa11741a7b632e9f23b01aca4cc6
change-id: 20230215-immutable-chips-762922277f1e
Best regards,
Signature · 1 line
Linus Walleij <[email protected]>
PATCH v3 1/17 gpio: altera: Convert to immutable irq_chip
Convert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-altera.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/gpio/gpio-altera.c +15 -10
@@ -24,14 +24,12 @@* @interrupt_trigger : specifies the hardware configured IRQ trigger type * (rising, falling, both, high) * @mapped_irq : kernel mapped irq number. -* @irq_chip : IRQ chip configuration */ struct altera_gpio_chip {struct of_mm_gpio_chip mmchip;raw_spinlock_t gpio_lock;int interrupt_trigger;int mapped_irq; -struct irq_chip irq_chip; };static void altera_gpio_irq_unmask (struct irq_data *d)
@@ -43,6 +41,7 @@ static void altera_gpio_irq_unmask(struct irq_data *d) altera_gc =gpiochip_get_data (irq_data_get_irq_chip_data (d)); mm_gc = &altera_gc->mmchip; +gpiochip_enable_irq (&mm_gc->gc,irqd_to_hwirq (d));raw_spin_lock_irqsave (&altera_gc->gpio_lock, flags); intmask =readl (mm_gc->regs +ALTERA_GPIO_IRQ_MASK );
@@ -68,6 +67,7 @@ static void altera_gpio_irq_mask(struct irq_data *d) intmask &= ~BIT (irqd_to_hwirq (d));writel (intmask, mm_gc->regs +ALTERA_GPIO_IRQ_MASK );raw_spin_unlock_irqrestore (&altera_gc->gpio_lock, flags); +gpiochip_disable_irq (&mm_gc->gc,irqd_to_hwirq (d)); }/*
@@ -233,6 +233,17 @@ static void altera_gpio_irq_leveL_high_handler(struct irq_desc *desc)chained_irq_exit (chip, desc); } +static const struct irq_chip altera_gpio_irq_chip = { + .name ="altera-gpio" , + .irq_mask = altera_gpio_irq_mask, + .irq_unmask = altera_gpio_irq_unmask, + .irq_set_type = altera_gpio_irq_set_type, + .irq_startup = altera_gpio_irq_startup, + .irq_shutdown = altera_gpio_irq_mask, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , +}; +static int altera_gpio_probe (struct platform_device *pdev) {struct device_node *node = pdev->dev.of_node;
@@ -278,15 +289,9 @@ static int altera_gpio_probe(struct platform_device *pdev) } altera_gc->interrupt_trigger = reg; - altera_gc->irq_chip.name ="altera-gpio" ; - altera_gc->irq_chip.irq_mask = altera_gpio_irq_mask; - altera_gc->irq_chip.irq_unmask = altera_gpio_irq_unmask; - altera_gc->irq_chip.irq_set_type = altera_gpio_irq_set_type; - altera_gc->irq_chip.irq_startup = altera_gpio_irq_startup; - altera_gc->irq_chip.irq_shutdown = altera_gpio_irq_mask; - girq = &altera_gc->mmchip.gc.irq; - girq->chip = &altera_gc->irq_chip; +gpio_irq_chip_set_chip (girq, &altera_gpio_irq_chip); +if (altera_gc->interrupt_trigger ==IRQ_TYPE_LEVEL_HIGH ) girq->parent_handler = altera_gpio_irq_leveL_high_handler;else
Signature · 1 line
2.34.1
PATCH v3 2/17 gpio: adnp: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-adnp.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpio/gpio-adnp.c +7 -2
@@ -307,6 +307,7 @@ static void adnp_irq_mask(struct irq_data *d)unsigned int pos = d->hwirq &7 ; adnp->irq_enable[reg] &= ~BIT (pos); +gpiochip_disable_irq (gc,irqd_to_hwirq (d)); }static void adnp_irq_unmask (struct irq_data *d)
@@ -316,6 +317,7 @@ static void adnp_irq_unmask(struct irq_data *d)unsigned int reg = d->hwirq >> adnp->reg_shift;unsigned int pos = d->hwirq &7 ; +gpiochip_enable_irq (gc,irqd_to_hwirq (d)); adnp->irq_enable[reg] |=BIT (pos); }
@@ -372,13 +374,15 @@ static void adnp_irq_bus_unlock(struct irq_data *d)mutex_unlock (&adnp->irq_lock); } -static struct irq_chip adnp_irq_chip = { +static const struct irq_chip adnp_irq_chip = { .name ="gpio-adnp" , .irq_mask = adnp_irq_mask, .irq_unmask = adnp_irq_unmask, .irq_set_type = adnp_irq_set_type, .irq_bus_lock = adnp_irq_bus_lock, .irq_bus_sync_unlock = adnp_irq_bus_unlock, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , };static int adnp_irq_setup (struct adnp *adnp)
@@ -469,7 +473,8 @@ static int adnp_gpio_setup(struct adnp *adnp, unsigned int num_gpios,return err; girq = &chip->irq; - girq->chip = &adnp_irq_chip; +gpio_irq_chip_set_chip (girq, &adnp_irq_chip); +/* This will let us handle the parent IRQ in the driver */ girq->parent_handler =NULL ; girq->num_parents =0 ;
Signature · 1 line
2.34.1
PATCH v3 3/17 gpio: aspeed: Always register the irqchip
In reply to Linus WalleijFrom: Joel Stanley <[email protected]>
The driver was implemented in a way that made the irqchip optional, if a irq was not present in the device tree. However, all of the device trees have always had an irq, so the optional-ness has never been used.
--- drivers/gpio/gpio-aspeed.c | 49 ++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 26 deletions(-)
drivers/gpio/gpio-aspeed.c +23 -26
@@ -1137,8 +1137,9 @@ MODULE_DEVICE_TABLE(of, aspeed_gpio_of_table);static int __init aspeed_gpio_probe (struct platform_device *pdev) {const struct of_device_id *gpio_id; +struct gpio_irq_chip *girq;struct aspeed_gpio *gpio; -int rc, i, banks, err; +int rc, irq, i, banks, err;u32 ngpio; gpio =devm_kzalloc (&pdev->dev,sizeof (*gpio),GFP_KERNEL );
@@ -1201,31 +1202,27 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)aspeed_gpio_change_cmd_source (gpio, bank,3 ,GPIO_CMDSRC_ARM ); } -/* Optionally set up an irqchip if there is an IRQ */ - rc =platform_get_irq (pdev,0 ); -if (rc >0 ) { -struct gpio_irq_chip *girq; - - gpio->irq = rc; - girq = &gpio->chip.irq; - girq->chip = &gpio->irqc; - girq->chip->name =dev_name (&pdev->dev); - girq->chip->irq_ack = aspeed_gpio_irq_ack; - girq->chip->irq_mask = aspeed_gpio_irq_mask; - girq->chip->irq_unmask = aspeed_gpio_irq_unmask; - girq->chip->irq_set_type = aspeed_gpio_set_type; - girq->parent_handler = aspeed_gpio_irq_handler; - girq->num_parents =1 ; - girq->parents =devm_kcalloc (&pdev->dev,1 , -sizeof (*girq->parents), -GFP_KERNEL ); -if (!girq->parents) -return -ENOMEM ; - girq->parents[0 ] = gpio->irq; - girq->default_type =IRQ_TYPE_NONE ; - girq->handler = handle_bad_irq; - girq->init_valid_mask = aspeed_init_irq_valid_mask; - } +/* Set up an irqchip */ + irq =platform_get_irq (pdev,0 ); +if (irq <0 ) +return irq; + gpio->irq = irq; + girq = &gpio->chip.irq; + girq->chip = &gpio->irqc; + girq->chip->name =dev_name (&pdev->dev); + girq->chip->irq_ack = aspeed_gpio_irq_ack; + girq->chip->irq_mask = aspeed_gpio_irq_mask; + girq->chip->irq_unmask = aspeed_gpio_irq_unmask; + girq->chip->irq_set_type = aspeed_gpio_set_type; + girq->parent_handler = aspeed_gpio_irq_handler; + girq->num_parents =1 ; + girq->parents =devm_kcalloc (&pdev->dev,1 ,sizeof (*girq->parents),GFP_KERNEL ); +if (!girq->parents) +return -ENOMEM ; + girq->parents[0 ] = gpio->irq; + girq->default_type =IRQ_TYPE_NONE ; + girq->handler = handle_bad_irq; + girq->init_valid_mask = aspeed_init_irq_valid_mask; gpio->offset_timer =devm_kzalloc (&pdev->dev, gpio->chip.ngpio,GFP_KERNEL );
Signature · 1 line
2.34.1
PATCH v3 4/17 gpio: aspeed: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
---
ChangeLog v1->v2:
- Rebase on v6.3-rc1
- Collect ACKs
ChangeLog v2->v3:
- Drop chip->name = dev_name() assignment.
- Rebase on top of Joels patch to make irqchip compulsory
--- drivers/gpio/gpio-aspeed.c | 45 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-)
drivers/gpio/gpio-aspeed.c +38 -7
@@ -15,6 +15,7 @@#include <linux/module.h> #include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> +#include <linux/seq_file.h> #include <linux/spinlock.h> #include <linux/string.h>
@@ -53,7 +54,7 @@ struct aspeed_gpio_config {*/ struct aspeed_gpio {struct gpio_chip chip; -struct irq_chip irqc; +struct device *dev;raw_spinlock_t lock;void __iomem *base;int irq;
@@ -566,6 +567,10 @@ static void aspeed_gpio_irq_set_mask(struct irq_data *d, bool set) addr =bank_reg (gpio, bank, reg_irq_enable); +/* Unmasking the IRQ */ +if (set) +gpiochip_enable_irq (&gpio->chip,irqd_to_hwirq (d)); +raw_spin_lock_irqsave (&gpio->lock, flags); copro =aspeed_gpio_copro_request (gpio, offset);
@@ -579,6 +584,10 @@ static void aspeed_gpio_irq_set_mask(struct irq_data *d, bool set)if (copro)aspeed_gpio_copro_release (gpio, offset);raw_spin_unlock_irqrestore (&gpio->lock, flags); + +/* Masking the IRQ */ +if (!set) +gpiochip_disable_irq (&gpio->chip,irqd_to_hwirq (d)); }static void aspeed_gpio_irq_mask (struct irq_data *d)
@@ -1080,6 +1089,30 @@ int aspeed_gpio_copro_release_gpio(struct gpio_desc *desc) }EXPORT_SYMBOL_GPL (aspeed_gpio_copro_release_gpio); +static void aspeed_gpio_irq_print_chip (struct irq_data *d,struct seq_file *p) +{ +const struct aspeed_gpio_bank *bank; +struct aspeed_gpio *gpio; +u32 bit; +int rc, offset; + + rc =irqd_to_aspeed_gpio_data (d, &gpio, &bank, &bit, &offset); +if (rc) +return ; + +seq_printf (p,dev_name (gpio->dev)); +} + +static const struct irq_chip aspeed_gpio_irq_chip = { + .irq_ack = aspeed_gpio_irq_ack, + .irq_mask = aspeed_gpio_irq_mask, + .irq_unmask = aspeed_gpio_irq_unmask, + .irq_set_type = aspeed_gpio_set_type, + .irq_print_chip = aspeed_gpio_irq_print_chip, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , +}; +/* * Any banks not specified in a struct aspeed_bank_props array are assumed to * have the properties:
@@ -1150,6 +1183,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)if (IS_ERR (gpio->base))return PTR_ERR (gpio->base); + gpio->dev = &pdev->dev; +raw_spin_lock_init (&gpio->lock); gpio_id =of_match_node (aspeed_gpio_of_table, pdev->dev.of_node);
@@ -1208,12 +1243,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)return irq; gpio->irq = irq; girq = &gpio->chip.irq; - girq->chip = &gpio->irqc; - girq->chip->name =dev_name (&pdev->dev); - girq->chip->irq_ack = aspeed_gpio_irq_ack; - girq->chip->irq_mask = aspeed_gpio_irq_mask; - girq->chip->irq_unmask = aspeed_gpio_irq_unmask; - girq->chip->irq_set_type = aspeed_gpio_set_type; +gpio_irq_chip_set_chip (girq, &aspeed_gpio_irq_chip); + girq->parent_handler = aspeed_gpio_irq_handler; girq->num_parents =1 ; girq->parents =devm_kcalloc (&pdev->dev,1 ,sizeof (*girq->parents),GFP_KERNEL );
Signature · 1 line
2.34.1
PATCH v3 5/17 gpio: aspeed-sgpio: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-aspeed-sgpio.c | 44 ++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-)
drivers/gpio/gpio-aspeed-sgpio.c +36 -8
@@ -14,6 +14,7 @@#include <linux/kernel.h> #include <linux/module.h> #include <linux/platform_device.h> +#include <linux/seq_file.h> #include <linux/spinlock.h> #include <linux/string.h>
@@ -29,7 +30,7 @@ struct aspeed_sgpio_pdata {struct aspeed_sgpio {struct gpio_chip chip; -struct irq_chip intc; +struct device *dev;struct clk *pclk;raw_spinlock_t lock;void __iomem *base;
@@ -296,6 +297,10 @@ static void aspeed_sgpio_irq_set_mask(struct irq_data *d, bool set)irqd_to_aspeed_sgpio_data (d, &gpio, &bank, &bit, &offset); addr =bank_reg (gpio, bank, reg_irq_enable); +/* Unmasking the IRQ */ +if (set) +gpiochip_enable_irq (&gpio->chip,irqd_to_hwirq (d)); +raw_spin_lock_irqsave (&gpio->lock, flags); reg =ioread32 (addr);
@@ -307,6 +312,12 @@ static void aspeed_sgpio_irq_set_mask(struct irq_data *d, bool set)iowrite32 (reg, addr);raw_spin_unlock_irqrestore (&gpio->lock, flags); + +/* Masking the IRQ */ +if (!set) +gpiochip_disable_irq (&gpio->chip,irqd_to_hwirq (d)); + + }static void aspeed_sgpio_irq_mask (struct irq_data *d)
@@ -401,6 +412,27 @@ static void aspeed_sgpio_irq_handler(struct irq_desc *desc)chained_irq_exit (ic, desc); } +static void aspeed_sgpio_irq_print_chip (struct irq_data *d,struct seq_file *p) +{ +const struct aspeed_sgpio_bank *bank; +struct aspeed_sgpio *gpio; +u32 bit; +int offset; + +irqd_to_aspeed_sgpio_data (d, &gpio, &bank, &bit, &offset); +seq_printf (p,dev_name (gpio->dev)); +} + +static const struct irq_chip aspeed_sgpio_irq_chip = { + .irq_ack = aspeed_sgpio_irq_ack, + .irq_mask = aspeed_sgpio_irq_mask, + .irq_unmask = aspeed_sgpio_irq_unmask, + .irq_set_type = aspeed_sgpio_set_type, + .irq_print_chip = aspeed_sgpio_irq_print_chip, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , +}; +static int aspeed_sgpio_setup_irqs (struct aspeed_sgpio *gpio,struct platform_device *pdev) {
@@ -423,14 +455,8 @@ static int aspeed_sgpio_setup_irqs(struct aspeed_sgpio *gpio,iowrite32 (0xffffffff ,bank_reg (gpio, bank, reg_irq_status)); } - gpio->intc.name =dev_name (&pdev->dev); - gpio->intc.irq_ack = aspeed_sgpio_irq_ack; - gpio->intc.irq_mask = aspeed_sgpio_irq_mask; - gpio->intc.irq_unmask = aspeed_sgpio_irq_unmask; - gpio->intc.irq_set_type = aspeed_sgpio_set_type; - irq = &gpio->chip.irq; - irq->chip = &gpio->intc; +gpio_irq_chip_set_chip (irq, &aspeed_sgpio_irq_chip); irq->init_valid_mask = aspeed_sgpio_irq_init_valid_mask; irq->handler = handle_bad_irq; irq->default_type =IRQ_TYPE_NONE ;
@@ -524,6 +550,8 @@ static int __init aspeed_sgpio_probe(struct platform_device *pdev)if (IS_ERR (gpio->base))return PTR_ERR (gpio->base); + gpio->dev = &pdev->dev; + pdata =device_get_match_data (&pdev->dev);if (!pdata)return -EINVAL ;
Signature · 1 line
2.34.1
PATCH v3 6/17 gpio: ath79: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-ath79.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpio/gpio-ath79.c +6 -2
@@ -71,6 +71,7 @@ static void ath79_gpio_irq_unmask(struct irq_data *data)u32 mask =BIT (irqd_to_hwirq (data));unsigned long flags; +gpiochip_enable_irq (&ctrl->gc,irqd_to_hwirq (data));raw_spin_lock_irqsave (&ctrl->lock, flags);ath79_gpio_update_bits (ctrl,AR71XX_GPIO_REG_INT_MASK , mask, mask);raw_spin_unlock_irqrestore (&ctrl->lock, flags);
@@ -85,6 +86,7 @@ static void ath79_gpio_irq_mask(struct irq_data *data)raw_spin_lock_irqsave (&ctrl->lock, flags);ath79_gpio_update_bits (ctrl,AR71XX_GPIO_REG_INT_MASK , mask,0 );raw_spin_unlock_irqrestore (&ctrl->lock, flags); +gpiochip_disable_irq (&ctrl->gc,irqd_to_hwirq (data)); }static void ath79_gpio_irq_enable (struct irq_data *data)
@@ -169,13 +171,15 @@ static int ath79_gpio_irq_set_type(struct irq_data *data,return 0 ; } -static struct irq_chip ath79_gpio_irqchip = { +static const struct irq_chip ath79_gpio_irqchip = { .name ="gpio-ath79" , .irq_enable = ath79_gpio_irq_enable, .irq_disable = ath79_gpio_irq_disable, .irq_mask = ath79_gpio_irq_mask, .irq_unmask = ath79_gpio_irq_unmask, .irq_set_type = ath79_gpio_irq_set_type, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , };static void ath79_gpio_irq_handler (struct irq_desc *desc)
@@ -274,7 +278,7 @@ static int ath79_gpio_probe(struct platform_device *pdev)/* Optional interrupt setup */ if (!np ||of_property_read_bool (np,"interrupt-controller" )) { girq = &ctrl->gc.irq; - girq->chip = &ath79_gpio_irqchip; +gpio_irq_chip_set_chip (girq, &ath79_gpio_irqchip); girq->parent_handler = ath79_gpio_irq_handler; girq->num_parents =1 ; girq->parents = devm_kcalloc(dev, 1, sizeof(*girq->parents),
Signature · 1 line
2.34.1
PATCH v3 7/17 gpio: cadence: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-cadence.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)
drivers/gpio/gpio-cadence.c +7 -3
@@ -70,6 +70,7 @@ static void cdns_gpio_irq_mask(struct irq_data *d)struct cdns_gpio_chip *cgpio =gpiochip_get_data (chip);iowrite32 (BIT (d->hwirq), cgpio->regs +CDNS_GPIO_IRQ_DIS ); +gpiochip_disable_irq (chip,irqd_to_hwirq (d)); }static void cdns_gpio_irq_unmask (struct irq_data *d)
@@ -77,6 +78,7 @@ static void cdns_gpio_irq_unmask(struct irq_data *d)struct gpio_chip *chip =irq_data_get_irq_chip_data (d);struct cdns_gpio_chip *cgpio =gpiochip_get_data (chip); +gpiochip_enable_irq (chip,irqd_to_hwirq (d));iowrite32 (BIT (d->hwirq), cgpio->regs +CDNS_GPIO_IRQ_EN ); }
@@ -138,11 +140,13 @@ static void cdns_gpio_irq_handler(struct irq_desc *desc)chained_irq_exit (irqchip, desc); } -static struct irq_chip cdns_gpio_irqchip = { +static const struct irq_chip cdns_gpio_irqchip = { .name ="cdns-gpio" , .irq_mask = cdns_gpio_irq_mask, .irq_unmask = cdns_gpio_irq_unmask, - .irq_set_type = cdns_gpio_irq_set_type + .irq_set_type = cdns_gpio_irq_set_type, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , };static int cdns_gpio_probe (struct platform_device *pdev)
@@ -222,7 +226,7 @@ static int cdns_gpio_probe(struct platform_device *pdev)struct gpio_irq_chip *girq; girq = &cgpio->gc.irq; - girq->chip = &cdns_gpio_irqchip; +gpio_irq_chip_set_chip (girq, &cdns_gpio_irqchip); girq->parent_handler = cdns_gpio_irq_handler; girq->num_parents =1 ; girq->parents = devm_kcalloc(&pdev->dev, 1,
Signature · 1 line
2.34.1
PATCH v3 8/17 gpio: hisi: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
The IRQ chip was unnamed which seems unwise, so we just assign the name "HISI-GPIO".
--- drivers/gpio/gpio-hisi.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/gpio/gpio-hisi.c +15 -10
@@ -37,7 +37,6 @@ struct hisi_gpio {struct device *dev;void __iomem *reg_base;unsigned int line_num; -struct irq_chip irq_chip;int irq; };
@@ -100,12 +99,14 @@ static void hisi_gpio_irq_set_mask(struct irq_data *d)struct gpio_chip *chip =irq_data_get_irq_chip_data (d);hisi_gpio_write_reg (chip,HISI_GPIO_INTMASK_SET_WX ,BIT (irqd_to_hwirq (d))); +gpiochip_disable_irq (chip,irqd_to_hwirq (d)); }static void hisi_gpio_irq_clr_mask (struct irq_data *d) {struct gpio_chip *chip =irq_data_get_irq_chip_data (d); +gpiochip_enable_irq (chip,irqd_to_hwirq (d));hisi_gpio_write_reg (chip,HISI_GPIO_INTMASK_CLR_WX ,BIT (irqd_to_hwirq (d))); }
@@ -191,20 +192,24 @@ static void hisi_gpio_irq_handler(struct irq_desc *desc)chained_irq_exit (irq_c, desc); } +static const struct irq_chip hisi_gpio_irq_chip = { + .name ="HISI-GPIO" , + .irq_ack = hisi_gpio_set_ack, + .irq_mask = hisi_gpio_irq_set_mask, + .irq_unmask = hisi_gpio_irq_clr_mask, + .irq_set_type = hisi_gpio_irq_set_type, + .irq_enable = hisi_gpio_irq_enable, + .irq_disable = hisi_gpio_irq_disable, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , +}; +static void hisi_gpio_init_irq (struct hisi_gpio *hisi_gpio) {struct gpio_chip *chip = &hisi_gpio->chip;struct gpio_irq_chip *girq_chip = &chip->irq; -/* Set hooks for irq_chip */ - hisi_gpio->irq_chip.irq_ack = hisi_gpio_set_ack; - hisi_gpio->irq_chip.irq_mask = hisi_gpio_irq_set_mask; - hisi_gpio->irq_chip.irq_unmask = hisi_gpio_irq_clr_mask; - hisi_gpio->irq_chip.irq_set_type = hisi_gpio_irq_set_type; - hisi_gpio->irq_chip.irq_enable = hisi_gpio_irq_enable; - hisi_gpio->irq_chip.irq_disable = hisi_gpio_irq_disable; - - girq_chip->chip = &hisi_gpio->irq_chip; +gpio_irq_chip_set_chip (girq_chip, &hisi_gpio_irq_chip); girq_chip->default_type =IRQ_TYPE_NONE ; girq_chip->num_parents =1 ; girq_chip->parents = &hisi_gpio->irq;
Signature · 1 line
2.34.1
PATCH v3 9/17 gpio: hlwd: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-hlwd.c | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-)
drivers/gpio/gpio-hlwd.c +25 -8
@@ -11,6 +11,7 @@#include <linux/module.h> #include <linux/of.h> #include <linux/of_platform.h> +#include <linux/seq_file.h> #include <linux/slab.h> /*
@@ -48,7 +49,7 @@struct hlwd_gpio {struct gpio_chip gpioc; -struct irq_chip irqc; +struct device *dev;void __iomem *regs;int irq;u32 edge_emulation;
@@ -123,6 +124,7 @@ static void hlwd_gpio_irq_mask(struct irq_data *data) mask &= ~BIT (data->hwirq);iowrite32be (mask, hlwd->regs +HW_GPIOB_INTMASK );raw_spin_unlock_irqrestore (&hlwd->gpioc.bgpio_lock, flags); +gpiochip_disable_irq (&hlwd->gpioc,irqd_to_hwirq (data)); }static void hlwd_gpio_irq_unmask (struct irq_data *data)
@@ -132,6 +134,7 @@ static void hlwd_gpio_irq_unmask(struct irq_data *data)unsigned long flags;u32 mask; +gpiochip_enable_irq (&hlwd->gpioc,irqd_to_hwirq (data));raw_spin_lock_irqsave (&hlwd->gpioc.bgpio_lock, flags); mask =ioread32be (hlwd->regs +HW_GPIOB_INTMASK ); mask |=BIT (data->hwirq);
@@ -202,6 +205,24 @@ static int hlwd_gpio_irq_set_type(struct irq_data *data, unsigned int flow_type)return 0 ; } +static void hlwd_gpio_irq_print_chip (struct irq_data *data,struct seq_file *p) +{ +struct hlwd_gpio *hlwd = +gpiochip_get_data (irq_data_get_irq_chip_data (data)); + +seq_printf (p,dev_name (hlwd->dev)); +} + +static const struct irq_chip hlwd_gpio_irq_chip = { + .irq_mask = hlwd_gpio_irq_mask, + .irq_unmask = hlwd_gpio_irq_unmask, + .irq_enable = hlwd_gpio_irq_enable, + .irq_set_type = hlwd_gpio_irq_set_type, + .irq_print_chip = hlwd_gpio_irq_print_chip, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , +}; +static int hlwd_gpio_probe (struct platform_device *pdev) {struct hlwd_gpio *hlwd;
@@ -216,6 +237,8 @@ static int hlwd_gpio_probe(struct platform_device *pdev)if (IS_ERR (hlwd->regs))return PTR_ERR (hlwd->regs); + hlwd->dev = &pdev->dev; +/* * Claim all GPIOs using the OWNER register. This will not work on * systems where the AHBPROT memory firewall hasn't been configured to
@@ -259,14 +282,8 @@ static int hlwd_gpio_probe(struct platform_device *pdev)return hlwd->irq; } - hlwd->irqc.name =dev_name (&pdev->dev); - hlwd->irqc.irq_mask = hlwd_gpio_irq_mask; - hlwd->irqc.irq_unmask = hlwd_gpio_irq_unmask; - hlwd->irqc.irq_enable = hlwd_gpio_irq_enable; - hlwd->irqc.irq_set_type = hlwd_gpio_irq_set_type; - girq = &hlwd->gpioc.irq; - girq->chip = &hlwd->irqc; +gpio_irq_chip_set_chip (girq, &hlwd_gpio_irq_chip); girq->parent_handler = hlwd_gpio_irqhandler; girq->num_parents =1 ; girq->parents = devm_kcalloc(&pdev->dev, 1,
Signature · 1 line
2.34.1
PATCH v3 10/17 gpio: idt3243x: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-idt3243x.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/gpio/gpio-idt3243x.c +8 -3
@@ -92,6 +92,8 @@ static void idt_gpio_mask(struct irq_data *d)writel (ctrl->mask_cache, ctrl->pic +IDT_PIC_IRQ_MASK );raw_spin_unlock_irqrestore (&gc->bgpio_lock, flags); + +gpiochip_disable_irq (gc,irqd_to_hwirq (d)); }static void idt_gpio_unmask (struct irq_data *d)
@@ -100,6 +102,7 @@ static void idt_gpio_unmask(struct irq_data *d)struct idt_gpio_ctrl *ctrl =gpiochip_get_data (gc);unsigned long flags; +gpiochip_enable_irq (gc,irqd_to_hwirq (d));raw_spin_lock_irqsave (&gc->bgpio_lock, flags); ctrl->mask_cache &= ~BIT (d->hwirq);
@@ -119,12 +122,14 @@ static int idt_gpio_irq_init_hw(struct gpio_chip *gc)return 0 ; } -static struct irq_chip idt_gpio_irqchip = { +static const struct irq_chip idt_gpio_irqchip = { .name ="IDTGPIO" , .irq_mask = idt_gpio_mask, .irq_ack = idt_gpio_ack, .irq_unmask = idt_gpio_unmask, - .irq_set_type = idt_gpio_irq_set_type + .irq_set_type = idt_gpio_irq_set_type, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , };static int idt_gpio_probe (struct platform_device *pdev)
@@ -168,7 +173,7 @@ static int idt_gpio_probe(struct platform_device *pdev)return parent_irq; girq = &ctrl->gc.irq; - girq->chip = &idt_gpio_irqchip; +gpio_irq_chip_set_chip (girq, &idt_gpio_irqchip); girq->init_hw = idt_gpio_irq_init_hw; girq->parent_handler = idt_gpio_dispatch; girq->num_parents =1 ;
Signature · 1 line
2.34.1
PATCH v3 11/17 gpio: msc313: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
This conversion follows the pattern of the gpio-ixp4xx hierarchical GPIO interrupt driver.
--- drivers/gpio/gpio-msc313.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)
drivers/gpio/gpio-msc313.c +22 -4
@@ -532,17 +532,35 @@ static int msc313_gpio_direction_output(struct gpio_chip *chip, unsigned int offreturn 0 ; } +static void msc313_gpio_irq_mask (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); + +irq_chip_mask_parent (d); +gpiochip_disable_irq (gc, d->hwirq); +} + +static void msc313_gpio_irq_unmask (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); + +gpiochip_enable_irq (gc, d->hwirq); +irq_chip_unmask_parent (d); +} +/* * The interrupt handling happens in the parent interrupt controller, * we don't do anything here. */ -static struct irq_chip msc313_gpio_irqchip = { +static const struct irq_chip msc313_gpio_irqchip = { .name ="GPIO" , .irq_eoi = irq_chip_eoi_parent, - .irq_mask = irq_chip_mask_parent, - .irq_unmask = irq_chip_unmask_parent, + .irq_mask = msc313_gpio_irq_mask, + .irq_unmask = msc313_gpio_irq_unmask, .irq_set_type = irq_chip_set_type_parent, .irq_set_affinity = irq_chip_set_affinity_parent, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , };/*
@@ -644,7 +662,7 @@ static int msc313_gpio_probe(struct platform_device *pdev) gpiochip->names = gpio->gpio_data->names; gpioirqchip = &gpiochip->irq; - gpioirqchip->chip = &msc313_gpio_irqchip; +gpio_irq_chip_set_chip (gpioirqchip, &msc313_gpio_irqchip); gpioirqchip->fwnode =of_node_to_fwnode (dev->of_node); gpioirqchip->parent_domain = parent_domain; gpioirqchip->child_to_parent_hwirq = msc313e_gpio_child_to_parent_hwirq;
Signature · 1 line
2.34.1
Re: [PATCH v3 11/17] gpio: msc313: Convert to immutable irq_chip
Le jeu. 9 mars 2023 ? 08:46, Linus Walleij <[email protected]> a ?crit :
Quoted 6 lines
Convert the driver to immutable irq-chip with a bit of intuition.
This conversion follows the pattern of the gpio-ixp4xx hierarchical GPIO interrupt driver.
Hi,
lgtm
Quoted 4 lines
Cc Marc Zyngier <[email protected]>Acked-by Marc Zyngier <[email protected]>Signed-off-by Linus Walleij <[email protected]>
Quoted 60 lines
--- drivers/gpio/gpio-msc313.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-)drivers/gpio/gpio-msc313.c +22
-5@@ -532,17 +532,35 @@ static int msc313_gpio_direction_output(struct gpio_chip *chip, unsigned int offreturn 0 ; } +static void msc313_gpio_irq_mask (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); + +irq_chip_mask_parent (d); +gpiochip_disable_irq (gc, d->hwirq); +} + +static void msc313_gpio_irq_unmask (struct irq_data *d) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (d); + +gpiochip_enable_irq (gc, d->hwirq); +irq_chip_unmask_parent (d); +} +/* * The interrupt handling happens in the parent interrupt controller, * we don't do anything here. */ -static struct irq_chip msc313_gpio_irqchip = { +static const struct irq_chip msc313_gpio_irqchip = { .name ="GPIO" , .irq_eoi = irq_chip_eoi_parent, - .irq_mask = irq_chip_mask_parent, - .irq_unmask = irq_chip_unmask_parent, + .irq_mask = msc313_gpio_irq_mask, + .irq_unmask = msc313_gpio_irq_unmask, .irq_set_type = irq_chip_set_type_parent, .irq_set_affinity = irq_chip_set_affinity_parent, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , };/* @@ -644,7 +662,7 @@ static int msc313_gpio_probe(struct platform_device *pdev) gpiochip->names = gpio->gpio_data->names; gpioirqchip = &gpiochip->irq; - gpioirqchip->chip = &msc313_gpio_irqchip; +gpio_irq_chip_set_chip (gpioirqchip, &msc313_gpio_irqchip); gpioirqchip->fwnode =of_node_to_fwnode (dev->of_node); gpioirqchip->parent_domain = parent_domain; gpioirqchip->child_to_parent_hwirq = msc313e_gpio_child_to_parent_hwirq; --2.34.1
PATCH v3 12/17 gpio: mlxbf2: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-mlxbf2.c | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-)
drivers/gpio/gpio-mlxbf2.c +25 -7
@@ -17,6 +17,7 @@#include <linux/platform_device.h> #include <linux/pm.h> #include <linux/resource.h> +#include <linux/seq_file.h> #include <linux/spinlock.h> #include <linux/types.h>
@@ -65,10 +66,10 @@ struct mlxbf2_gpio_context_save_regs {/* BlueField-2 gpio block context structure. */ struct mlxbf2_gpio_context {struct gpio_chip gc; -struct irq_chip irq_chip;/* YU GPIO blocks address */ void __iomem *gpio_io; +struct device *dev;struct mlxbf2_gpio_context_save_regs *csave_regs; };
@@ -237,6 +238,7 @@ static void mlxbf2_gpio_irq_enable(struct irq_data *irqd)unsigned long flags;u32 val; +gpiochip_enable_irq (gc,irqd_to_hwirq (irqd));raw_spin_lock_irqsave (&gs->gc.bgpio_lock, flags); val =readl (gs->gpio_io +YU_GPIO_CAUSE_OR_CLRCAUSE ); val |=BIT (offset);
@@ -261,6 +263,7 @@ static void mlxbf2_gpio_irq_disable(struct irq_data *irqd) val &= ~BIT (offset);writel (val, gs->gpio_io +YU_GPIO_CAUSE_OR_EVTEN0 );raw_spin_unlock_irqrestore (&gs->gc.bgpio_lock, flags); +gpiochip_disable_irq (gc,irqd_to_hwirq (irqd)); }static irqreturn_t mlxbf2_gpio_irq_handler (int irq,void *ptr)
@@ -322,6 +325,24 @@ mlxbf2_gpio_irq_set_type(struct irq_data *irqd, unsigned int type)return 0 ; } +static void mlxbf2_gpio_irq_print_chip (struct irq_data *irqd, +struct seq_file *p) +{ +struct gpio_chip *gc =irq_data_get_irq_chip_data (irqd); +struct mlxbf2_gpio_context *gs =gpiochip_get_data (gc); + +seq_printf (p,dev_name (gs->dev)); +} + +static const struct irq_chip mlxbf2_gpio_irq_chip = { + .irq_set_type = mlxbf2_gpio_irq_set_type, + .irq_enable = mlxbf2_gpio_irq_enable, + .irq_disable = mlxbf2_gpio_irq_disable, + .irq_print_chip = mlxbf2_gpio_irq_print_chip, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , +}; +/* BlueField-2 GPIO driver initialization routine. */ static int mlxbf2_gpio_probe (struct platform_device *pdev)
@@ -340,6 +361,8 @@ mlxbf2_gpio_probe(struct platform_device *pdev)if (!gs)return -ENOMEM ; + gs->dev = dev; +/* YU GPIO block address */ gs->gpio_io =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (gs->gpio_io))
@@ -376,13 +399,8 @@ mlxbf2_gpio_probe(struct platform_device *pdev) irq =platform_get_irq (pdev,0 );if (irq >=0 ) { - gs->irq_chip.name = name; - gs->irq_chip.irq_set_type = mlxbf2_gpio_irq_set_type; - gs->irq_chip.irq_enable = mlxbf2_gpio_irq_enable; - gs->irq_chip.irq_disable = mlxbf2_gpio_irq_disable; - girq = &gs->gc.irq; - girq->chip = &gs->irq_chip; +gpio_irq_chip_set_chip (girq, &mlxbf2_gpio_irq_chip); girq->handler = handle_simple_irq; girq->default_type =IRQ_TYPE_NONE ;/* This will let us handle the parent IRQ in the driver */
Signature · 1 line
2.34.1
PATCH v3 13/17 gpio: max732x: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-max732x.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpio/gpio-max732x.c +6 -2
@@ -351,6 +351,7 @@ static void max732x_irq_mask(struct irq_data *d)struct max732x_chip *chip =gpiochip_get_data (gc); chip->irq_mask_cur &= ~(1 << d->hwirq); +gpiochip_disable_irq (gc,irqd_to_hwirq (d)); }static void max732x_irq_unmask (struct irq_data *d)
@@ -358,6 +359,7 @@ static void max732x_irq_unmask(struct irq_data *d)struct gpio_chip *gc =irq_data_get_irq_chip_data (d);struct max732x_chip *chip =gpiochip_get_data (gc); +gpiochip_enable_irq (gc,irqd_to_hwirq (d)); chip->irq_mask_cur |=1 << d->hwirq; }
@@ -429,7 +431,7 @@ static int max732x_irq_set_wake(struct irq_data *data, unsigned int on)return 0 ; } -static struct irq_chip max732x_irq_chip = { +static const struct irq_chip max732x_irq_chip = { .name ="max732x" , .irq_mask = max732x_irq_mask, .irq_unmask = max732x_irq_unmask,
@@ -437,6 +439,8 @@ static struct irq_chip max732x_irq_chip = { .irq_bus_sync_unlock = max732x_irq_bus_sync_unlock, .irq_set_type = max732x_irq_set_type, .irq_set_wake = max732x_irq_set_wake, + .flags = IRQCHIP_IMMUTABLE, + GPIOCHIP_IRQ_RESOURCE_HELPERS, };static uint8_t max732x_irq_pending (struct max732x_chip *chip)
@@ -517,7 +521,7 @@ static int max732x_irq_setup(struct max732x_chip *chip, } girq = &chip->gpio_chip.irq; - girq->chip = &max732x_irq_chip; +gpio_irq_chip_set_chip (girq, &max732x_irq_chip);/* This will let us handle the parent IRQ in the driver */ girq->parent_handler =NULL ; girq->num_parents =0 ;
Signature · 1 line
2.34.1
PATCH v3 14/17 gpio: omap: Drop irq_base
In reply to Linus WalleijThe OMAP1 at one point was using static irqs but that time is gone, OMAP1 uses sparse irqs like all other multiplatform targets so this static allocation of descriptors should just go.
--- drivers/gpio/gpio-omap.c | 15 --------------- 1 file changed, 15 deletions(-)
drivers/gpio/gpio-omap.c +0 -15
@@ -992,7 +992,6 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc,struct gpio_irq_chip *irq;static int gpio;const char *label; -int irq_base =0 ;int ret;/*
@@ -1024,19 +1023,6 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc, } bank->chip.ngpio = bank->width; -#ifdef CONFIG_ARCH_OMAP1 -/* -* REVISIT: Once we have OMAP1 supporting SPARSE_IRQ, we can drop -* irq_alloc_descs() since a base IRQ offset will no longer be needed. -*/ - irq_base =devm_irq_alloc_descs (bank->chip.parent, --1 ,0 , bank->width,0 ); -if (irq_base <0 ) { -dev_err (bank->chip.parent,"Couldn't allocate IRQ numbers\n" ); -return -ENODEV ; - } -#endif -/* MPUIO is a bit different, reading IRQ status clears it */ if (bank->is_mpuio && !bank->regs->wkup_en) irqc->irq_set_wake =NULL ;
@@ -1047,7 +1033,6 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc, irq->default_type =IRQ_TYPE_NONE ; irq->num_parents =1 ; irq->parents = &bank->irq; - irq->first = irq_base; ret =gpiochip_add_data (&bank->chip, bank);if (ret)
Signature · 1 line
2.34.1
PATCH v3 15/17 gpio: omap: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
This driver require some special care: .irq_ack() was copied from dummy_irq_chip where it was defined as noop. This only makes sense if using handle_edge_irq() that will unconditionally call .irq_ack() to avoid a crash, but this driver is not ever using handle_edge_irq() so just avoid assigning .irq_ack().
A separate chip had to be created for the non-wakeup instance.
--- drivers/gpio/gpio-omap.c | 68 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 45 insertions(+), 23 deletions(-)
drivers/gpio/gpio-omap.c +45 -23
@@ -12,6 +12,7 @@#include <linux/init.h> #include <linux/module.h> #include <linux/interrupt.h> +#include <linux/seq_file.h> #include <linux/syscore_ops.h> #include <linux/err.h> #include <linux/clk.h>
@@ -47,6 +48,7 @@ struct gpio_regs {struct gpio_bank {void __iomem *base;const struct omap_gpio_reg_offs *regs; +struct device *dev;int irq;u32 non_wakeup_gpios;
@@ -681,6 +683,7 @@ static void omap_gpio_mask_irq(struct irq_data *d)omap_set_gpio_triggering (bank, offset,IRQ_TYPE_NONE );omap_set_gpio_irqenable (bank, offset,0 );raw_spin_unlock_irqrestore (&bank->lock, flags); +gpiochip_disable_irq (&bank->chip, offset); }static void omap_gpio_unmask_irq (struct irq_data *d)
@@ -690,6 +693,7 @@ static void omap_gpio_unmask_irq(struct irq_data *d)u32 trigger =irqd_get_trigger_type (d);unsigned long flags; +gpiochip_enable_irq (&bank->chip, offset);raw_spin_lock_irqsave (&bank->lock, flags);omap_set_gpio_irqenable (bank, offset,1 );
@@ -708,6 +712,40 @@ static void omap_gpio_unmask_irq(struct irq_data *d)raw_spin_unlock_irqrestore (&bank->lock, flags); } +static void omap_gpio_irq_print_chip (struct irq_data *d,struct seq_file *p) +{ +struct gpio_bank *bank =omap_irq_data_get_bank (d); + +seq_printf (p,dev_name (bank->dev)); +} + +static const struct irq_chip omap_gpio_irq_chip = { + .irq_startup = omap_gpio_irq_startup, + .irq_shutdown = omap_gpio_irq_shutdown, + .irq_mask = omap_gpio_mask_irq, + .irq_unmask = omap_gpio_unmask_irq, + .irq_set_type = omap_gpio_irq_type, + .irq_set_wake = omap_gpio_wake_enable, + .irq_bus_lock = omap_gpio_irq_bus_lock, + .irq_bus_sync_unlock = gpio_irq_bus_sync_unlock, + .irq_print_chip = omap_gpio_irq_print_chip, + .flags =IRQCHIP_MASK_ON_SUSPEND |IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , +}; + +static const struct irq_chip omap_gpio_irq_chip_nowake = { + .irq_startup = omap_gpio_irq_startup, + .irq_shutdown = omap_gpio_irq_shutdown, + .irq_mask = omap_gpio_mask_irq, + .irq_unmask = omap_gpio_unmask_irq, + .irq_set_type = omap_gpio_irq_type, + .irq_bus_lock = omap_gpio_irq_bus_lock, + .irq_bus_sync_unlock = gpio_irq_bus_sync_unlock, + .irq_print_chip = omap_gpio_irq_print_chip, + .flags =IRQCHIP_MASK_ON_SUSPEND |IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , +}; +/*---------------------------------------------------------------------*/ static int omap_mpuio_suspend_noirq (struct device *dev)
@@ -986,8 +1024,7 @@ static void omap_gpio_mod_init(struct gpio_bank *bank)writel_relaxed (0 , base + bank->regs->ctrl); } -static int omap_gpio_chip_init (struct gpio_bank *bank,struct irq_chip *irqc, -struct device *pm_dev) +static int omap_gpio_chip_init (struct gpio_bank *bank,struct device *pm_dev) {struct gpio_irq_chip *irq;static int gpio;
@@ -1023,12 +1060,12 @@ static int omap_gpio_chip_init(struct gpio_bank *bank, struct irq_chip *irqc, } bank->chip.ngpio = bank->width; + irq = &bank->chip.irq;/* MPUIO is a bit different, reading IRQ status clears it */ if (bank->is_mpuio && !bank->regs->wkup_en) - irqc->irq_set_wake =NULL ; - - irq = &bank->chip.irq; - irq->chip = irqc; +gpio_irq_chip_set_chip (irq, &omap_gpio_irq_chip_nowake); +else +gpio_irq_chip_set_chip (irq, &omap_gpio_irq_chip); irq->handler = handle_bad_irq; irq->default_type =IRQ_TYPE_NONE ; irq->num_parents =1 ;
@@ -1361,7 +1398,6 @@ static int omap_gpio_probe(struct platform_device *pdev)struct device_node *node = dev->of_node;const struct omap_gpio_platform_data *pdata;struct gpio_bank *bank; -struct irq_chip *irqc;int ret; pdata =device_get_match_data (dev);
@@ -1374,21 +1410,7 @@ static int omap_gpio_probe(struct platform_device *pdev)if (!bank)return -ENOMEM ; - irqc =devm_kzalloc (dev,sizeof (*irqc),GFP_KERNEL ); -if (!irqc) -return -ENOMEM ; - - irqc->irq_startup = omap_gpio_irq_startup, - irqc->irq_shutdown = omap_gpio_irq_shutdown, - irqc->irq_ack = dummy_irq_chip.irq_ack, - irqc->irq_mask = omap_gpio_mask_irq, - irqc->irq_unmask = omap_gpio_unmask_irq, - irqc->irq_set_type = omap_gpio_irq_type, - irqc->irq_set_wake = omap_gpio_wake_enable, - irqc->irq_bus_lock = omap_gpio_irq_bus_lock, - irqc->irq_bus_sync_unlock = gpio_irq_bus_sync_unlock, - irqc->name =dev_name (&pdev->dev); - irqc->flags =IRQCHIP_MASK_ON_SUSPEND ; + bank->dev = dev; bank->irq =platform_get_irq (pdev,0 );if (bank->irq <=0 ) {
@@ -1452,7 +1474,7 @@ static int omap_gpio_probe(struct platform_device *pdev)omap_gpio_mod_init (bank); - ret =omap_gpio_chip_init (bank, irqc, dev); + ret =omap_gpio_chip_init (bank, dev);if (ret) {pm_runtime_put_sync (dev);pm_runtime_disable (dev);
Signature · 1 line
2.34.1
PATCH v3 16/17 gpio: pci-idio-16: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-pci-idio-16.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpio/gpio-pci-idio-16.c +9 -3
@@ -107,6 +107,8 @@ static void idio_16_irq_mask(struct irq_data *data)raw_spin_unlock_irqrestore (&idio16gpio->lock, flags); } + +gpiochip_disable_irq (chip,irqd_to_hwirq (data)); }static void idio_16_irq_unmask (struct irq_data *data)
@@ -117,6 +119,8 @@ static void idio_16_irq_unmask(struct irq_data *data)const unsigned long prev_irq_mask = idio16gpio->irq_mask;unsigned long flags; +gpiochip_enable_irq (chip,irqd_to_hwirq (data)); + idio16gpio->irq_mask |= mask;if (!prev_irq_mask) {
@@ -138,12 +142,14 @@ static int idio_16_irq_set_type(struct irq_data *data, unsigned int flow_type)return 0 ; } -static struct irq_chip idio_16_irqchip = { +static const struct irq_chip idio_16_irqchip = { .name ="pci-idio-16" , .irq_ack = idio_16_irq_ack, .irq_mask = idio_16_irq_mask, .irq_unmask = idio_16_irq_unmask, - .irq_set_type = idio_16_irq_set_type + .irq_set_type = idio_16_irq_set_type, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , };static irqreturn_t idio_16_irq_handler (int irq,void *dev_id)
@@ -242,7 +248,7 @@ static int idio_16_probe(struct pci_dev *pdev, const struct pci_device_id *id)idio_16_state_init (&idio16gpio->state); girq = &idio16gpio->chip.irq; - girq->chip = &idio_16_irqchip; +gpio_irq_chip_set_chip (girq, &idio_16_irqchip);/* This will let us handle the parent IRQ in the driver */ girq->parent_handler =NULL ; girq->num_parents =0 ;
Signature · 1 line
2.34.1
PATCH v3 17/17 gpio: pcie-idio-24: Convert to immutable irq_chip
In reply to Linus WalleijConvert the driver to immutable irq-chip with a bit of intuition.
--- drivers/gpio/gpio-pcie-idio-24.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
drivers/gpio/gpio-pcie-idio-24.c +9 -3
@@ -396,6 +396,8 @@ static void idio_24_irq_mask(struct irq_data *data) }raw_spin_unlock_irqrestore (&idio24gpio->lock, flags); + +gpiochip_disable_irq (chip,irqd_to_hwirq (data)); }static void idio_24_irq_unmask (struct irq_data *data)
@@ -408,6 +410,8 @@ static void idio_24_irq_unmask(struct irq_data *data)const unsigned long bank_offset = bit_offset /8 ;unsigned char cos_enable_state; +gpiochip_enable_irq (chip,irqd_to_hwirq (data)); +raw_spin_lock_irqsave (&idio24gpio->lock, flags); prev_irq_mask = idio24gpio->irq_mask >> bank_offset *8 ;
@@ -437,12 +441,14 @@ static int idio_24_irq_set_type(struct irq_data *data, unsigned int flow_type)return 0 ; } -static struct irq_chip idio_24_irqchip = { +static const struct irq_chip idio_24_irqchip = { .name ="pcie-idio-24" , .irq_ack = idio_24_irq_ack, .irq_mask = idio_24_irq_mask, .irq_unmask = idio_24_irq_unmask, - .irq_set_type = idio_24_irq_set_type + .irq_set_type = idio_24_irq_set_type, + .flags =IRQCHIP_IMMUTABLE , +GPIOCHIP_IRQ_RESOURCE_HELPERS , };static irqreturn_t idio_24_irq_handler (int irq,void *dev_id)
@@ -535,7 +541,7 @@ static int idio_24_probe(struct pci_dev *pdev, const struct pci_device_id *id) idio24gpio->chip.set_multiple = idio_24_gpio_set_multiple; girq = &idio24gpio->chip.irq; - girq->chip = &idio_24_irqchip; +gpio_irq_chip_set_chip (girq, &idio_24_irqchip);/* This will let us handle the parent IRQ in the driver */ girq->parent_handler =NULL ; girq->num_parents =0 ;
Signature · 1 line
2.34.1
Quoted 64 lines · On Thu, Mar 9, 2023 at 8:45?AM Linus Walleij <[email protected]> wrote:
We are getting tired of these
irq_chipsnot getting converted to be immutable, so I just take out the big hammer and fix some that I deem not too complex as best I can.I stopped after doing some, I will take another sweep at some point I guess.
This is v6.4 material.
The last two patches to pci-idio-* (patch 15 and 16) can be omitted if William's patches to convert this driver to regmap GPIO are merged first.
Signed-off-by Linus Walleij <[email protected]>---
Changes in v3:
- Deleted theirq_chip->nameassignment in the Aspeed driver
- Fold in a patch from Joel to make aspeed IRQs compulsory
- Link to v2: https://lore.kernel.org/r/20230215-immutable-chips-v2-0-d6b0e3f2d991 at linaro.orgChanges in v2:
- Rebased on v6.3-rc1
- Collected some test and ACK tags
- Link to v1: https://lore.kernel.org/r/20230215-immutable-chips-v1-0-51a8f224a5d0 at linaro.org---
Joel Stanley (1):
gpio: aspeed: Always register the irqchipLinus Walleij (16):
gpio: altera: Convert to immutableirq_chip
gpio: adnp: Convert to immutableirq_chip
gpio: aspeed: Convert to immutableirq_chip
gpio: aspeed-sgpio: Convert to immutableirq_chip
gpio: ath79: Convert to immutableirq_chip
gpio: cadence: Convert to immutableirq_chip
gpio: hisi: Convert to immutableirq_chip
gpio: hlwd: Convert to immutableirq_chip
gpio: idt3243x: Convert to immutableirq_chip
gpio: msc313: Convert to immutableirq_chip
gpio: mlxbf2: Convert to immutableirq_chip
gpio: max732x: Convert to immutableirq_chip
gpio: omap: Dropirq_base
gpio: omap: Convert to immutableirq_chip
gpio: pci-idio-16: Convert to immutableirq_chip
gpio: pcie-idio-24: Convert to immutableirq_chipdrivers/gpio/gpio-adnp.c | 9 ++++- drivers/gpio/gpio-altera.c | 25 +++++++----- drivers/gpio/gpio-aspeed-sgpio.c | 44 +++++++++++++++++---- drivers/gpio/gpio-aspeed.c | 82 ++++++++++++++++++++++++++------------- drivers/gpio/gpio-ath79.c | 8 +++- drivers/gpio/gpio-cadence.c | 10 +++-- drivers/gpio/gpio-hisi.c | 25 +++++++----- drivers/gpio/gpio-hlwd.c | 33 ++++++++++++---- drivers/gpio/gpio-idt3243x.c | 11 ++++-- drivers/gpio/gpio-max732x.c | 8 +++- drivers/gpio/gpio-mlxbf2.c | 32 ++++++++++++---- drivers/gpio/gpio-msc313.c | 26 +++++++++++-- drivers/gpio/gpio-omap.c | 83 ++++++++++++++++++++++------------------ drivers/gpio/gpio-pci-idio-16.c | 12 ++++-- drivers/gpio/gpio-pcie-idio-24.c | 12 ++++-- 15 files changed, 290 insertions(+), 130 deletions(-)
Quoted 8 lines
---
base-commit:fe15c26ee26efa11741a7b632e9f23b01aca4cc6
change-id: 20230215-immutable-chips-762922277f1eBest regards,
--
Linus Walleij <[email protected]>
Normally these irq_chip conversions would go upstream as fixes but this time there are too many at once. I applied them to my gpio/for-next branch. Let's give them some time in next and later we can backport them if necessary.
Bartosz
Quoted 6 lines · On Fri, Mar 10, 2023 at 4:25?PM Bartosz Golaszewski <[email protected]> wrote:
Quoted 5 lines · On Thu, Mar 9, 2023 at 8:45?AM Linus Walleij <[email protected]> wrote:
We are getting tired of these
irq_chipsnot getting converted to be immutable, so I just take out the big hammer and fix some that I deem not too complex as best I can.
Quoted 7 lines
Quoted 2 lines
I stopped after doing some, I will take another sweep at some point I guess.
Normally these
irq_chipconversions would go upstream as fixes but this time there are too many at once. I applied them to my gpio/for-next branch. Let's give them some time in next and later we can backport them if necessary.
That's fine since the maintainers didn't get around to fixing it themselves yet anyway it can't be that important to them.
I will try to take a second sweep and see what is left on the floor, and then I guess a sweep over the gpio_chips in pinctrl as well.
Yours,
Linus Walleij