Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: zynq: Fixed broken wakeup implementation

Use of unmask/mask in set_wake was an incorrect implementation. The new
implementation correctly sets wakeup for the gpio chip's IRQ so the gpio chip
will not sleep while wakeup-enabled gpio are in use.

Signed-off-by: Ezra Savard <ezra.savard@xilinx.com>
Reviewed-by: Soren Brinkmann <soren.brinkmann@xilinx.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Ezra Savard and committed by
Linus Walleij
59e22114 a1946778

+20 -14
+20 -14
drivers/gpio/gpio-zynq.c
··· 88 88 * @chip: instance of the gpio_chip 89 89 * @base_addr: base address of the GPIO device 90 90 * @clk: clock resource for this controller 91 + * @irq: interrupt for the GPIO device 91 92 */ 92 93 struct zynq_gpio { 93 94 struct gpio_chip chip; 94 95 void __iomem *base_addr; 95 96 struct clk *clk; 97 + int irq; 96 98 }; 97 99 98 100 static struct irq_chip zynq_gpio_level_irqchip; 99 101 static struct irq_chip zynq_gpio_edge_irqchip; 100 - 101 102 /** 102 103 * zynq_gpio_get_bank_pin - Get the bank number and pin number within that bank 103 104 * for a given pin in the GPIO device ··· 435 434 436 435 static int zynq_gpio_set_wake(struct irq_data *data, unsigned int on) 437 436 { 438 - if (on) 439 - zynq_gpio_irq_unmask(data); 440 - else 441 - zynq_gpio_irq_mask(data); 437 + struct zynq_gpio *gpio = irq_data_get_irq_chip_data(data); 438 + 439 + irq_set_irq_wake(gpio->irq, on); 442 440 443 441 return 0; 444 442 } ··· 518 518 519 519 static int __maybe_unused zynq_gpio_suspend(struct device *dev) 520 520 { 521 - if (!device_may_wakeup(dev)) 521 + struct platform_device *pdev = to_platform_device(dev); 522 + int irq = platform_get_irq(pdev, 0); 523 + struct irq_data *data = irq_get_irq_data(irq); 524 + 525 + if (!irqd_is_wakeup_set(data)) 522 526 return pm_runtime_force_suspend(dev); 523 527 524 528 return 0; ··· 530 526 531 527 static int __maybe_unused zynq_gpio_resume(struct device *dev) 532 528 { 533 - if (!device_may_wakeup(dev)) 529 + struct platform_device *pdev = to_platform_device(dev); 530 + int irq = platform_get_irq(pdev, 0); 531 + struct irq_data *data = irq_get_irq_data(irq); 532 + 533 + if (!irqd_is_wakeup_set(data)) 534 534 return pm_runtime_force_resume(dev); 535 535 536 536 return 0; ··· 595 587 */ 596 588 static int zynq_gpio_probe(struct platform_device *pdev) 597 589 { 598 - int ret, bank_num, irq; 590 + int ret, bank_num; 599 591 struct zynq_gpio *gpio; 600 592 struct gpio_chip *chip; 601 593 struct resource *res; ··· 611 603 if (IS_ERR(gpio->base_addr)) 612 604 return PTR_ERR(gpio->base_addr); 613 605 614 - irq = platform_get_irq(pdev, 0); 615 - if (irq < 0) { 606 + gpio->irq = platform_get_irq(pdev, 0); 607 + if (gpio->irq < 0) { 616 608 dev_err(&pdev->dev, "invalid IRQ\n"); 617 - return irq; 609 + return gpio->irq; 618 610 } 619 611 620 612 /* configure the gpio chip */ ··· 662 654 goto err_rm_gpiochip; 663 655 } 664 656 665 - gpiochip_set_chained_irqchip(chip, &zynq_gpio_edge_irqchip, irq, 657 + gpiochip_set_chained_irqchip(chip, &zynq_gpio_edge_irqchip, gpio->irq, 666 658 zynq_gpio_irqhandler); 667 659 668 660 pm_runtime_set_active(&pdev->dev); 669 661 pm_runtime_enable(&pdev->dev); 670 - 671 - device_set_wakeup_capable(&pdev->dev, 1); 672 662 673 663 return 0; 674 664