diff mbox series

[v2] gpio: pca953x: Add wake-up support

Message ID 20190213131503.26801-1-geert+renesas@glider.be (mailing list archive)
State Accepted
Delegated to: Geert Uytterhoeven
Headers show
Series [v2] gpio: pca953x: Add wake-up support | expand

Commit Message

Geert Uytterhoeven Feb. 13, 2019, 1:15 p.m. UTC
Implement the irq_set_wake() method in the (optional) irq_chip of the
GPIO expander, and propagate wake-up settings to the upstream interrupt
controller.  This allows GPIOs connected to a PCA953X GPIO expander to
serve as wake-up sources.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Tested with a PCA9654 and gpio-keys on an R-Car Ebisu-4D board.

v2:
  - Just propagate irq_set_irq_wake().  As pca953x_irq_set_wake()
    doesn't need to do anything else, there's no reason for making it
    conditional.
---
 drivers/gpio/gpio-pca953x.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Niklas Söderlund Feb. 13, 2019, 5:27 p.m. UTC | #1
Hi Geert,

Thanks for your patch,

On 2019-02-13 14:15:03 +0100, Geert Uytterhoeven wrote:
> Implement the irq_set_wake() method in the (optional) irq_chip of the
> GPIO expander, and propagate wake-up settings to the upstream interrupt
> controller.  This allows GPIOs connected to a PCA953X GPIO expander to
> serve as wake-up sources.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>

> ---
> Tested with a PCA9654 and gpio-keys on an R-Car Ebisu-4D board.
> 
> v2:
>   - Just propagate irq_set_irq_wake().  As pca953x_irq_set_wake()
>     doesn't need to do anything else, there's no reason for making it
>     conditional.
> ---
>  drivers/gpio/gpio-pca953x.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
> index de52f63863dbe59b..86c00a3980c47c3b 100644
> --- a/drivers/gpio/gpio-pca953x.c
> +++ b/drivers/gpio/gpio-pca953x.c
> @@ -513,6 +513,14 @@ static void pca953x_irq_unmask(struct irq_data *d)
>  	chip->irq_mask[d->hwirq / BANK_SZ] |= 1 << (d->hwirq % BANK_SZ);
>  }
>  
> +static int pca953x_irq_set_wake(struct irq_data *d, unsigned int on)
> +{
> +	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> +	struct pca953x_chip *chip = gpiochip_get_data(gc);
> +
> +	return irq_set_irq_wake(chip->client->irq, on);
> +}
> +
>  static void pca953x_irq_bus_lock(struct irq_data *d)
>  {
>  	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> @@ -732,6 +740,7 @@ static int pca953x_irq_setup(struct pca953x_chip *chip,
>  	irq_chip->name = dev_name(&chip->client->dev);
>  	irq_chip->irq_mask = pca953x_irq_mask;
>  	irq_chip->irq_unmask = pca953x_irq_unmask;
> +	irq_chip->irq_set_wake = pca953x_irq_set_wake;
>  	irq_chip->irq_bus_lock = pca953x_irq_bus_lock;
>  	irq_chip->irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock;
>  	irq_chip->irq_set_type = pca953x_irq_set_type;
> -- 
> 2.17.1
>
Linus Walleij Feb. 20, 2019, 9:31 a.m. UTC | #2
On Wed, Feb 13, 2019 at 2:15 PM Geert Uytterhoeven
<geert+renesas@glider.be> wrote:

> Implement the irq_set_wake() method in the (optional) irq_chip of the
> GPIO expander, and propagate wake-up settings to the upstream interrupt
> controller.  This allows GPIOs connected to a PCA953X GPIO expander to
> serve as wake-up sources.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
> ---
> Tested with a PCA9654 and gpio-keys on an R-Car Ebisu-4D board.
>
> v2:
>   - Just propagate irq_set_irq_wake().  As pca953x_irq_set_wake()
>     doesn't need to do anything else, there's no reason for making it
>     conditional.

Patch applied with Niklas' review tag.

Yours,
Linus Walleij
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-pca953x.c b/drivers/gpio/gpio-pca953x.c
index de52f63863dbe59b..86c00a3980c47c3b 100644
--- a/drivers/gpio/gpio-pca953x.c
+++ b/drivers/gpio/gpio-pca953x.c
@@ -513,6 +513,14 @@  static void pca953x_irq_unmask(struct irq_data *d)
 	chip->irq_mask[d->hwirq / BANK_SZ] |= 1 << (d->hwirq % BANK_SZ);
 }
 
+static int pca953x_irq_set_wake(struct irq_data *d, unsigned int on)
+{
+	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+	struct pca953x_chip *chip = gpiochip_get_data(gc);
+
+	return irq_set_irq_wake(chip->client->irq, on);
+}
+
 static void pca953x_irq_bus_lock(struct irq_data *d)
 {
 	struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
@@ -732,6 +740,7 @@  static int pca953x_irq_setup(struct pca953x_chip *chip,
 	irq_chip->name = dev_name(&chip->client->dev);
 	irq_chip->irq_mask = pca953x_irq_mask;
 	irq_chip->irq_unmask = pca953x_irq_unmask;
+	irq_chip->irq_set_wake = pca953x_irq_set_wake;
 	irq_chip->irq_bus_lock = pca953x_irq_bus_lock;
 	irq_chip->irq_bus_sync_unlock = pca953x_irq_bus_sync_unlock;
 	irq_chip->irq_set_type = pca953x_irq_set_type;