| .. | .. |
|---|
| 15 | 15 | #include <linux/irq.h> |
|---|
| 16 | 16 | #include <linux/irqdomain.h> |
|---|
| 17 | 17 | #include <linux/irqchip/chained_irq.h> |
|---|
| 18 | +#include <linux/module.h> |
|---|
| 18 | 19 | #include <linux/platform_device.h> |
|---|
| 19 | 20 | #include <linux/slab.h> |
|---|
| 20 | 21 | #include <linux/syscore_ops.h> |
|---|
| .. | .. |
|---|
| 158 | 159 | { .compatible = "fsl,imx7d-gpio", .data = &mxc_gpio_devtype[IMX35_GPIO], }, |
|---|
| 159 | 160 | { /* sentinel */ } |
|---|
| 160 | 161 | }; |
|---|
| 162 | +MODULE_DEVICE_TABLE(of, mxc_gpio_dt_ids); |
|---|
| 161 | 163 | |
|---|
| 162 | 164 | /* |
|---|
| 163 | 165 | * MX2 has one interrupt *for all* gpio ports. The list is used |
|---|
| .. | .. |
|---|
| 359 | 361 | ct->chip.irq_unmask = irq_gc_mask_set_bit; |
|---|
| 360 | 362 | ct->chip.irq_set_type = gpio_set_irq_type; |
|---|
| 361 | 363 | ct->chip.irq_set_wake = gpio_set_wake_irq; |
|---|
| 362 | | - ct->chip.flags = IRQCHIP_MASK_ON_SUSPEND; |
|---|
| 364 | + ct->chip.flags = IRQCHIP_MASK_ON_SUSPEND | IRQCHIP_ENABLE_WAKEUP_ON_SUSPEND; |
|---|
| 363 | 365 | ct->regs.ack = GPIO_ISR; |
|---|
| 364 | 366 | ct->regs.mask = GPIO_IMR; |
|---|
| 365 | 367 | |
|---|
| .. | .. |
|---|
| 411 | 413 | { |
|---|
| 412 | 414 | struct device_node *np = pdev->dev.of_node; |
|---|
| 413 | 415 | struct mxc_gpio_port *port; |
|---|
| 414 | | - struct resource *iores; |
|---|
| 416 | + int irq_count; |
|---|
| 415 | 417 | int irq_base; |
|---|
| 416 | 418 | int err; |
|---|
| 417 | 419 | |
|---|
| .. | .. |
|---|
| 423 | 425 | |
|---|
| 424 | 426 | port->dev = &pdev->dev; |
|---|
| 425 | 427 | |
|---|
| 426 | | - iores = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 427 | | - port->base = devm_ioremap_resource(&pdev->dev, iores); |
|---|
| 428 | + port->base = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 428 | 429 | if (IS_ERR(port->base)) |
|---|
| 429 | 430 | return PTR_ERR(port->base); |
|---|
| 430 | 431 | |
|---|
| 431 | | - port->irq_high = platform_get_irq(pdev, 1); |
|---|
| 432 | | - if (port->irq_high < 0) |
|---|
| 433 | | - port->irq_high = 0; |
|---|
| 432 | + irq_count = platform_irq_count(pdev); |
|---|
| 433 | + if (irq_count < 0) |
|---|
| 434 | + return irq_count; |
|---|
| 435 | + |
|---|
| 436 | + if (irq_count > 1) { |
|---|
| 437 | + port->irq_high = platform_get_irq(pdev, 1); |
|---|
| 438 | + if (port->irq_high < 0) |
|---|
| 439 | + port->irq_high = 0; |
|---|
| 440 | + } |
|---|
| 434 | 441 | |
|---|
| 435 | 442 | port->irq = platform_get_irq(pdev, 0); |
|---|
| 436 | 443 | if (port->irq < 0) |
|---|
| 437 | 444 | return port->irq; |
|---|
| 438 | 445 | |
|---|
| 439 | 446 | /* the controller clock is optional */ |
|---|
| 440 | | - port->clk = devm_clk_get(&pdev->dev, NULL); |
|---|
| 441 | | - if (IS_ERR(port->clk)) { |
|---|
| 442 | | - if (PTR_ERR(port->clk) == -EPROBE_DEFER) |
|---|
| 443 | | - return -EPROBE_DEFER; |
|---|
| 444 | | - port->clk = NULL; |
|---|
| 445 | | - } |
|---|
| 447 | + port->clk = devm_clk_get_optional(&pdev->dev, NULL); |
|---|
| 448 | + if (IS_ERR(port->clk)) |
|---|
| 449 | + return PTR_ERR(port->clk); |
|---|
| 446 | 450 | |
|---|
| 447 | 451 | err = clk_prepare_enable(port->clk); |
|---|
| 448 | 452 | if (err) { |
|---|
| .. | .. |
|---|
| 483 | 487 | if (err) |
|---|
| 484 | 488 | goto out_bgio; |
|---|
| 485 | 489 | |
|---|
| 486 | | - if (of_property_read_bool(np, "gpio-ranges")) { |
|---|
| 487 | | - port->gc.request = gpiochip_generic_request; |
|---|
| 488 | | - port->gc.free = gpiochip_generic_free; |
|---|
| 489 | | - } |
|---|
| 490 | | - |
|---|
| 490 | + port->gc.request = gpiochip_generic_request; |
|---|
| 491 | + port->gc.free = gpiochip_generic_free; |
|---|
| 491 | 492 | port->gc.to_irq = mxc_gpio_to_irq; |
|---|
| 492 | 493 | port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 : |
|---|
| 493 | 494 | pdev->id * 32; |
|---|
| .. | .. |
|---|
| 605 | 606 | return platform_driver_register(&mxc_gpio_driver); |
|---|
| 606 | 607 | } |
|---|
| 607 | 608 | subsys_initcall(gpio_mxc_init); |
|---|
| 609 | + |
|---|
| 610 | +MODULE_AUTHOR("Shawn Guo <shawn.guo@linaro.org>"); |
|---|
| 611 | +MODULE_DESCRIPTION("i.MX GPIO Driver"); |
|---|
| 612 | +MODULE_LICENSE("GPL"); |
|---|