Commit 216f3736 authored by Nikita Shubin's avatar Nikita Shubin Committed by Bartosz Golaszewski

gpio: ep93xx: Make irqchip immutable

This turns the Cirrus ep93xx gpio irqchip immutable.

Preserve per-chip labels by adding an ->irq_print_chip() callback.
Signed-off-by: default avatarNikita Shubin <nikita.shubin@maquefel.me>
Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@linaro.org>
parent 0f04cdbd
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/gpio/driver.h> #include <linux/gpio/driver.h>
#include <linux/bitops.h> #include <linux/bitops.h>
#include <linux/seq_file.h>
#define EP93XX_GPIO_F_INT_STATUS 0x5c #define EP93XX_GPIO_F_INT_STATUS 0x5c
#define EP93XX_GPIO_A_INT_STATUS 0xa0 #define EP93XX_GPIO_A_INT_STATUS 0xa0
...@@ -40,7 +41,6 @@ ...@@ -40,7 +41,6 @@
#define EP93XX_GPIO_F_IRQ_BASE 80 #define EP93XX_GPIO_F_IRQ_BASE 80
struct ep93xx_gpio_irq_chip { struct ep93xx_gpio_irq_chip {
struct irq_chip ic;
u8 irq_offset; u8 irq_offset;
u8 int_unmasked; u8 int_unmasked;
u8 int_enabled; u8 int_enabled;
...@@ -185,6 +185,7 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d) ...@@ -185,6 +185,7 @@ static void ep93xx_gpio_irq_mask_ack(struct irq_data *d)
ep93xx_gpio_update_int_params(epg, eic); ep93xx_gpio_update_int_params(epg, eic);
writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET); writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET);
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
} }
static void ep93xx_gpio_irq_mask(struct irq_data *d) static void ep93xx_gpio_irq_mask(struct irq_data *d)
...@@ -195,6 +196,7 @@ static void ep93xx_gpio_irq_mask(struct irq_data *d) ...@@ -195,6 +196,7 @@ static void ep93xx_gpio_irq_mask(struct irq_data *d)
eic->int_unmasked &= ~BIT(d->irq & 7); eic->int_unmasked &= ~BIT(d->irq & 7);
ep93xx_gpio_update_int_params(epg, eic); ep93xx_gpio_update_int_params(epg, eic);
gpiochip_disable_irq(gc, irqd_to_hwirq(d));
} }
static void ep93xx_gpio_irq_unmask(struct irq_data *d) static void ep93xx_gpio_irq_unmask(struct irq_data *d)
...@@ -203,6 +205,7 @@ static void ep93xx_gpio_irq_unmask(struct irq_data *d) ...@@ -203,6 +205,7 @@ static void ep93xx_gpio_irq_unmask(struct irq_data *d)
struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc);
struct ep93xx_gpio *epg = gpiochip_get_data(gc); struct ep93xx_gpio *epg = gpiochip_get_data(gc);
gpiochip_enable_irq(gc, irqd_to_hwirq(d));
eic->int_unmasked |= BIT(d->irq & 7); eic->int_unmasked |= BIT(d->irq & 7);
ep93xx_gpio_update_int_params(epg, eic); ep93xx_gpio_update_int_params(epg, eic);
} }
...@@ -320,15 +323,25 @@ static int ep93xx_gpio_set_config(struct gpio_chip *gc, unsigned offset, ...@@ -320,15 +323,25 @@ static int ep93xx_gpio_set_config(struct gpio_chip *gc, unsigned offset,
return 0; return 0;
} }
static void ep93xx_init_irq_chip(struct device *dev, struct irq_chip *ic) static void ep93xx_irq_print_chip(struct irq_data *data, struct seq_file *p)
{ {
ic->irq_ack = ep93xx_gpio_irq_ack; struct gpio_chip *gc = irq_data_get_irq_chip_data(data);
ic->irq_mask_ack = ep93xx_gpio_irq_mask_ack;
ic->irq_mask = ep93xx_gpio_irq_mask; seq_printf(p, dev_name(gc->parent));
ic->irq_unmask = ep93xx_gpio_irq_unmask;
ic->irq_set_type = ep93xx_gpio_irq_type;
} }
static const struct irq_chip gpio_eic_irq_chip = {
.name = "ep93xx-gpio-eic",
.irq_ack = ep93xx_gpio_irq_ack,
.irq_mask = ep93xx_gpio_irq_mask,
.irq_unmask = ep93xx_gpio_irq_unmask,
.irq_mask_ack = ep93xx_gpio_irq_mask_ack,
.irq_set_type = ep93xx_gpio_irq_type,
.irq_print_chip = ep93xx_irq_print_chip,
.flags = IRQCHIP_IMMUTABLE,
GPIOCHIP_IRQ_RESOURCE_HELPERS,
};
static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc, static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc,
struct platform_device *pdev, struct platform_device *pdev,
struct ep93xx_gpio *epg, struct ep93xx_gpio *epg,
...@@ -359,12 +372,7 @@ static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc, ...@@ -359,12 +372,7 @@ static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc,
if (!egc->eic) if (!egc->eic)
return -ENOMEM; return -ENOMEM;
egc->eic->irq_offset = bank->irq; egc->eic->irq_offset = bank->irq;
ic = &egc->eic->ic; gpio_irq_chip_set_chip(girq, &gpio_eic_irq_chip);
ic->name = devm_kasprintf(dev, GFP_KERNEL, "gpio-irq-%s", bank->label);
if (!ic->name)
return -ENOMEM;
ep93xx_init_irq_chip(dev, ic);
girq->chip = ic;
} }
if (bank->has_irq) { if (bank->has_irq) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment