pinctrl: at91: Minor cleanups
v2 cover pinctrl: at91: Minor cleanups
A few cleanups for the at91 driver, making the GPIO irqchip immutable and removing an unused member from the driver data. The driver is still using statically assigned GPIO numbers, we can't just remove that since the driver itself is still relying on them even if there are no longer board files for this platform.
Changes in v2:
- Rebased onto Linus' devel branch.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Mark Brown (2):
pinctrl: at91: Make the irqchip immutable
pinctrl: at91: Remove pioc_index from struct at91_gpio_chip
drivers/pinctrl/pinctrl-at91.c | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-)
---
base-commit: 00408f28c344fd1cafe6e66fe0f454607a2605f9
change-id: 20230216-gpio-at91-immutable-53fcb995b285
Best regards,
Signature · 1 line
Mark Brown <[email protected]>
PATCH v2 1/2 pinctrl: at91: Make the irqchip immutable
To help gpiolib not fiddle around with the internals of the irqchip flag the chip as immutable, adding the calls into the gpiolib core required to do so.
--- drivers/pinctrl/pinctrl-at91.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-)
drivers/pinctrl/pinctrl-at91.c +24 -1
@@ -1526,6 +1526,20 @@ static void at91_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)#define at91_gpio_dbg_show NULL#endif +static int gpio_irq_request_resources (struct irq_data *d) +{ +struct at91_gpio_chip *at91_gpio =irq_data_get_irq_chip_data (d); + +return gpiochip_lock_as_irq (&at91_gpio->chip,irqd_to_hwirq (d)); +} + +static void gpio_irq_release_resources (struct irq_data *d) +{ +struct at91_gpio_chip *at91_gpio =irq_data_get_irq_chip_data (d); + +gpiochip_unlock_as_irq (&at91_gpio->chip,irqd_to_hwirq (d)); +} +/* Several AIC controller irqs are dispatched through this GPIO handler. * To use any AT91_PIN_* as an externally triggered IRQ, first call * at91_set_gpio_input() then maybe enable its glitch filter.
@@ -1545,6 +1559,9 @@ static void gpio_irq_mask(struct irq_data *d)struct at91_gpio_chip *at91_gpio =irq_data_get_irq_chip_data (d);void __iomem *pio = at91_gpio->regbase;unsigned mask =1 << d->hwirq; +unsigned gpio =irqd_to_hwirq (d); + +gpiochip_disable_irq (&at91_gpio->chip, gpio);if (pio)writel_relaxed (mask, pio +PIO_IDR );
@@ -1555,6 +1572,9 @@ static void gpio_irq_unmask(struct irq_data *d)struct at91_gpio_chip *at91_gpio =irq_data_get_irq_chip_data (d);void __iomem *pio = at91_gpio->regbase;unsigned mask =1 << d->hwirq; +unsigned gpio =irqd_to_hwirq (d); + +gpiochip_enable_irq (&at91_gpio->chip, gpio);if (pio)writel_relaxed (mask, pio +PIO_IER );
@@ -1721,12 +1741,15 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev, at91_gpio->pioc_hwirq =irqd_to_hwirq (d); gpio_irqchip->name ="GPIO" ; + gpio_irqchip->irq_request_resources = gpio_irq_request_resources; + gpio_irqchip->irq_release_resources = gpio_irq_release_resources; gpio_irqchip->irq_ack = gpio_irq_ack; gpio_irqchip->irq_disable = gpio_irq_mask; gpio_irqchip->irq_mask = gpio_irq_mask; gpio_irqchip->irq_unmask = gpio_irq_unmask; gpio_irqchip->irq_set_wake =pm_ptr (gpio_irq_set_wake); gpio_irqchip->irq_set_type = at91_gpio->ops->irq_type; + gpio_irqchip->flags =IRQCHIP_IMMUTABLE ;/* Disable irqs of this PIO controller */ writel_relaxed (~0 , at91_gpio->regbase +PIO_IDR );
@@ -1737,7 +1760,7 @@ static int at91_gpio_of_irq_setup(struct platform_device *pdev,* interrupt. */ girq = &at91_gpio->chip.irq; - girq->chip = gpio_irqchip; +gpio_irq_chip_set_chip (girq, gpio_irqchip); girq->default_type =IRQ_TYPE_NONE ; girq->handler = handle_edge_irq;
Signature · 1 line
2.30.2
PATCH v2 2/2 pinctrl: at91: Remove pioc_index from struct at91_gpio_chip
In reply to Mark BrownThe pioc_idx member of struct at91_gpio_chip is write only, just remove it.
--- drivers/pinctrl/pinctrl-at91.c | 3 --- 1 file changed, 3 deletions(-)
drivers/pinctrl/pinctrl-at91.c +0 -3
@@ -42,7 +42,6 @@ struct at91_pinctrl_mux_ops;* @next: bank sharing same clock * @pioc_hwirq: PIO bank interrupt identifier on AIC * @pioc_virq: PIO bank Linux virtual interrupt -* @pioc_idx: PIO bank index * @regbase: PIO bank virtual address * @clock: associated clock * @ops: at91 pinctrl mux ops
@@ -56,7 +55,6 @@ struct at91_gpio_chip {struct at91_gpio_chip *next;int pioc_hwirq;int pioc_virq; -int pioc_idx;void __iomem *regbase;struct clk *clock;const struct at91_pinctrl_mux_ops *ops;
@@ -1849,7 +1847,6 @@ static int at91_gpio_probe(struct platform_device *pdev) at91_chip->ops =of_device_get_match_data (dev); at91_chip->pioc_virq = irq; - at91_chip->pioc_idx = alias_idx; at91_chip->clock =devm_clk_get_enabled (dev,NULL );if (IS_ERR (at91_chip->clock))
Signature · 1 line
2.30.2
Quoted 6 lines · Mark Brown
A few cleanups for the at91 driver, making the GPIO irqchip immutable and removing an unused member from the driver data. The driver is still using statically assigned GPIO numbers, we can't just remove that since the driver itself is still relying on them even if there are no longer board files for this platform.
Patches applied, thanks Mark!
Yours,
Linus Walleij