diff options
Diffstat (limited to 'drivers/gpio/gpio-altera.c')
-rw-r--r-- | drivers/gpio/gpio-altera.c | 65 |
1 files changed, 29 insertions, 36 deletions
diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c index e088b908c2c1..9f2e6b04c361 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c @@ -30,6 +30,7 @@ struct altera_gpio_chip { 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) @@ -101,15 +102,6 @@ static unsigned int altera_gpio_irq_startup(struct irq_data *d) return 0; } -static struct irq_chip altera_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, -}; - static int altera_gpio_get(struct gpio_chip *gc, unsigned offset) { struct of_mm_gpio_chip *mm_gc; @@ -246,6 +238,7 @@ static int altera_gpio_probe(struct platform_device *pdev) struct device_node *node = pdev->dev.of_node; int reg, ret; struct altera_gpio_chip *altera_gc; + struct gpio_irq_chip *girq; altera_gc = devm_kzalloc(&pdev->dev, sizeof(*altera_gc), GFP_KERNEL); if (!altera_gc) @@ -273,50 +266,50 @@ static int altera_gpio_probe(struct platform_device *pdev) altera_gc->mmchip.gc.owner = THIS_MODULE; altera_gc->mmchip.gc.parent = &pdev->dev; - ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc); - if (ret) { - dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n"); - return ret; - } - - platform_set_drvdata(pdev, altera_gc); - altera_gc->mapped_irq = platform_get_irq(pdev, 0); if (altera_gc->mapped_irq < 0) goto skip_irq; if (of_property_read_u32(node, "altr,interrupt-type", ®)) { - ret = -EINVAL; dev_err(&pdev->dev, "altr,interrupt-type value not set in device tree\n"); - goto teardown; + return -EINVAL; } altera_gc->interrupt_trigger = reg; - ret = gpiochip_irqchip_add(&altera_gc->mmchip.gc, &altera_irq_chip, 0, - handle_bad_irq, IRQ_TYPE_NONE); + 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; + if (altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH) + girq->parent_handler = altera_gpio_irq_leveL_high_handler; + else + girq->parent_handler = altera_gpio_irq_edge_handler; + girq->num_parents = 1; + girq->parents = devm_kcalloc(&pdev->dev, 1, sizeof(*girq->parents), + GFP_KERNEL); + if (!girq->parents) + return -ENOMEM; + girq->default_type = IRQ_TYPE_NONE; + girq->handler = handle_bad_irq; + girq->parents[0] = altera_gc->mapped_irq; +skip_irq: + ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc); if (ret) { - dev_err(&pdev->dev, "could not add irqchip\n"); - goto teardown; + dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n"); + return ret; } - gpiochip_set_chained_irqchip(&altera_gc->mmchip.gc, - &altera_irq_chip, - altera_gc->mapped_irq, - altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH ? - altera_gpio_irq_leveL_high_handler : - altera_gpio_irq_edge_handler); + platform_set_drvdata(pdev, altera_gc); -skip_irq: return 0; -teardown: - of_mm_gpiochip_remove(&altera_gc->mmchip); - pr_err("%pOF: registration failed with status %d\n", - node, ret); - - return ret; } static int altera_gpio_remove(struct platform_device *pdev) |