diff options
| author | Linus Walleij <linus.walleij@linaro.org> | 2019-06-25 07:35:32 -0400 |
|---|---|---|
| committer | Linus Walleij <linus.walleij@linaro.org> | 2019-07-03 04:24:12 -0400 |
| commit | 2617790f0f94422d9773a3f34c694bc3be09ce8b (patch) | |
| tree | d9e8992842061313d98b1a9f1b15a06291f934ea /drivers/gpio/gpio-altera.c | |
| parent | 8b29450437d7e3a507d8421621b02fcaa2368637 (diff) | |
gpio: altera: Pass irqchip when adding gpiochip
We need to convert all old gpio irqchips to pass the irqchip
setup along when adding the gpio_chip.
For chained irqchips this is a pretty straight-forward
conversion.
Cc: Ley Foon Tan <lftan@altera.com>
Cc: Tien Hock Loh <thloh@altera.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpio-altera.c')
| -rw-r--r-- | drivers/gpio/gpio-altera.c | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/drivers/gpio/gpio-altera.c b/drivers/gpio/gpio-altera.c index a266d8796ee5..9f2e6b04c361 100644 --- a/drivers/gpio/gpio-altera.c +++ b/drivers/gpio/gpio-altera.c | |||
| @@ -238,6 +238,7 @@ static int altera_gpio_probe(struct platform_device *pdev) | |||
| 238 | struct device_node *node = pdev->dev.of_node; | 238 | struct device_node *node = pdev->dev.of_node; |
| 239 | int reg, ret; | 239 | int reg, ret; |
| 240 | struct altera_gpio_chip *altera_gc; | 240 | struct altera_gpio_chip *altera_gc; |
| 241 | struct gpio_irq_chip *girq; | ||
| 241 | 242 | ||
| 242 | altera_gc = devm_kzalloc(&pdev->dev, sizeof(*altera_gc), GFP_KERNEL); | 243 | altera_gc = devm_kzalloc(&pdev->dev, sizeof(*altera_gc), GFP_KERNEL); |
| 243 | if (!altera_gc) | 244 | if (!altera_gc) |
| @@ -265,24 +266,15 @@ static int altera_gpio_probe(struct platform_device *pdev) | |||
| 265 | altera_gc->mmchip.gc.owner = THIS_MODULE; | 266 | altera_gc->mmchip.gc.owner = THIS_MODULE; |
| 266 | altera_gc->mmchip.gc.parent = &pdev->dev; | 267 | altera_gc->mmchip.gc.parent = &pdev->dev; |
| 267 | 268 | ||
| 268 | ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc); | ||
| 269 | if (ret) { | ||
| 270 | dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n"); | ||
| 271 | return ret; | ||
| 272 | } | ||
| 273 | |||
| 274 | platform_set_drvdata(pdev, altera_gc); | ||
| 275 | |||
| 276 | altera_gc->mapped_irq = platform_get_irq(pdev, 0); | 269 | altera_gc->mapped_irq = platform_get_irq(pdev, 0); |
| 277 | 270 | ||
| 278 | if (altera_gc->mapped_irq < 0) | 271 | if (altera_gc->mapped_irq < 0) |
| 279 | goto skip_irq; | 272 | goto skip_irq; |
| 280 | 273 | ||
| 281 | if (of_property_read_u32(node, "altr,interrupt-type", ®)) { | 274 | if (of_property_read_u32(node, "altr,interrupt-type", ®)) { |
| 282 | ret = -EINVAL; | ||
| 283 | dev_err(&pdev->dev, | 275 | dev_err(&pdev->dev, |
| 284 | "altr,interrupt-type value not set in device tree\n"); | 276 | "altr,interrupt-type value not set in device tree\n"); |
| 285 | goto teardown; | 277 | return -EINVAL; |
| 286 | } | 278 | } |
| 287 | altera_gc->interrupt_trigger = reg; | 279 | altera_gc->interrupt_trigger = reg; |
| 288 | 280 | ||
| @@ -293,29 +285,31 @@ static int altera_gpio_probe(struct platform_device *pdev) | |||
| 293 | altera_gc->irq_chip.irq_startup = altera_gpio_irq_startup; | 285 | altera_gc->irq_chip.irq_startup = altera_gpio_irq_startup; |
| 294 | altera_gc->irq_chip.irq_shutdown = altera_gpio_irq_mask; | 286 | altera_gc->irq_chip.irq_shutdown = altera_gpio_irq_mask; |
| 295 | 287 | ||
| 296 | ret = gpiochip_irqchip_add(&altera_gc->mmchip.gc, &altera_gc->irq_chip, | 288 | girq = &altera_gc->mmchip.gc.irq; |
| 297 | 0, handle_bad_irq, IRQ_TYPE_NONE); | 289 | girq->chip = &altera_gc->irq_chip; |
| 290 | if (altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH) | ||
| 291 | girq->parent_handler = altera_gpio_irq_leveL_high_handler; | ||
| 292 | else | ||
| 293 | girq->parent_handler = altera_gpio_irq_edge_handler; | ||
| 294 | girq->num_parents = 1; | ||
| 295 | girq->parents = devm_kcalloc(&pdev->dev, 1, sizeof(*girq->parents), | ||
| 296 | GFP_KERNEL); | ||
| 297 | if (!girq->parents) | ||
| 298 | return -ENOMEM; | ||
| 299 | girq->default_type = IRQ_TYPE_NONE; | ||
| 300 | girq->handler = handle_bad_irq; | ||
| 301 | girq->parents[0] = altera_gc->mapped_irq; | ||
| 298 | 302 | ||
| 303 | skip_irq: | ||
| 304 | ret = of_mm_gpiochip_add_data(node, &altera_gc->mmchip, altera_gc); | ||
| 299 | if (ret) { | 305 | if (ret) { |
| 300 | dev_err(&pdev->dev, "could not add irqchip\n"); | 306 | dev_err(&pdev->dev, "Failed adding memory mapped gpiochip\n"); |
| 301 | goto teardown; | 307 | return ret; |
| 302 | } | 308 | } |
| 303 | 309 | ||
| 304 | gpiochip_set_chained_irqchip(&altera_gc->mmchip.gc, | 310 | platform_set_drvdata(pdev, altera_gc); |
| 305 | &altera_gc->irq_chip, | ||
| 306 | altera_gc->mapped_irq, | ||
| 307 | altera_gc->interrupt_trigger == IRQ_TYPE_LEVEL_HIGH ? | ||
| 308 | altera_gpio_irq_leveL_high_handler : | ||
| 309 | altera_gpio_irq_edge_handler); | ||
| 310 | 311 | ||
| 311 | skip_irq: | ||
| 312 | return 0; | 312 | return 0; |
| 313 | teardown: | ||
| 314 | of_mm_gpiochip_remove(&altera_gc->mmchip); | ||
| 315 | pr_err("%pOF: registration failed with status %d\n", | ||
| 316 | node, ret); | ||
| 317 | |||
| 318 | return ret; | ||
| 319 | } | 313 | } |
| 320 | 314 | ||
| 321 | static int altera_gpio_remove(struct platform_device *pdev) | 315 | static int altera_gpio_remove(struct platform_device *pdev) |
