* [PATCH 0/3] gpio: rcar: Fix wake up using gpio-keys with PM domain @ 2015-03-18 18:41 Geert Uytterhoeven 2015-03-18 18:41 ` [PATCH 1/3] gpio: rcar: Use local variable gpio_chip in gpio_rcar_probe() Geert Uytterhoeven ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Geert Uytterhoeven @ 2015-03-18 18:41 UTC (permalink / raw) To: Linus Walleij, Alexandre Courbot; +Cc: linux-gpio, linux-sh, Geert Uytterhoeven Hi, This patch series contains a few cleanups and updates for the Renesas R-Car GPIO driver, and fixes wake-up from s2ram using gpio-keys when using a PM Domain to manage the module clock. It was tested on r8a7791/koelsch. Thanks! Geert Uytterhoeven (3): gpio: rcar: Use local variable gpio_chip in gpio_rcar_probe() gpio: rcar: Add more register documentation gpio: rcar: Prevent module clock disable when wake-up is enabled drivers/gpio/gpio-rcar.c | 63 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 17 deletions(-) -- 1.9.1 Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/3] gpio: rcar: Use local variable gpio_chip in gpio_rcar_probe() 2015-03-18 18:41 [PATCH 0/3] gpio: rcar: Fix wake up using gpio-keys with PM domain Geert Uytterhoeven @ 2015-03-18 18:41 ` Geert Uytterhoeven 2015-03-26 9:18 ` Linus Walleij 2015-03-18 18:41 ` [PATCH 2/3] gpio: rcar: Add more register documentation Geert Uytterhoeven 2015-03-18 18:41 ` [PATCH 3/3] gpio: rcar: Prevent module clock disable when wake-up is enabled Geert Uytterhoeven 2 siblings, 1 reply; 7+ messages in thread From: Geert Uytterhoeven @ 2015-03-18 18:41 UTC (permalink / raw) To: Linus Walleij, Alexandre Courbot; +Cc: linux-gpio, linux-sh, Geert Uytterhoeven The existing variable gpio_chip already points to the gpiochip instance, hence use it everywhere. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/gpio/gpio-rcar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index c49522efa7b3bce4..e67d578ac07c45d5 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -413,7 +413,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) goto err0; } - ret = gpiochip_irqchip_add(&p->gpio_chip, irq_chip, p->config.irq_base, + ret = gpiochip_irqchip_add(gpio_chip, irq_chip, p->config.irq_base, handle_level_irq, IRQ_TYPE_NONE); if (ret) { dev_err(dev, "cannot add irqchip\n"); @@ -431,7 +431,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) /* warn in case of mismatch if irq base is specified */ if (p->config.irq_base) { - ret = irq_find_mapping(p->gpio_chip.irqdomain, 0); + ret = irq_find_mapping(gpio_chip->irqdomain, 0); if (p->config.irq_base != ret) dev_warn(dev, "irq base mismatch (%u/%u)\n", p->config.irq_base, ret); @@ -447,7 +447,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) return 0; err1: - gpiochip_remove(&p->gpio_chip); + gpiochip_remove(gpio_chip); err0: pm_runtime_put(dev); pm_runtime_disable(dev); -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 1/3] gpio: rcar: Use local variable gpio_chip in gpio_rcar_probe() 2015-03-18 18:41 ` [PATCH 1/3] gpio: rcar: Use local variable gpio_chip in gpio_rcar_probe() Geert Uytterhoeven @ 2015-03-26 9:18 ` Linus Walleij 0 siblings, 0 replies; 7+ messages in thread From: Linus Walleij @ 2015-03-26 9:18 UTC (permalink / raw) To: Geert Uytterhoeven Cc: Alexandre Courbot, linux-gpio@vger.kernel.org, linux-sh@vger.kernel.org On Wed, Mar 18, 2015 at 7:41 PM, Geert Uytterhoeven <geert+renesas@glider.be> wrote: > The existing variable gpio_chip already points to the gpiochip instance, > hence use it everywhere. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Patch applied. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/3] gpio: rcar: Add more register documentation 2015-03-18 18:41 [PATCH 0/3] gpio: rcar: Fix wake up using gpio-keys with PM domain Geert Uytterhoeven 2015-03-18 18:41 ` [PATCH 1/3] gpio: rcar: Use local variable gpio_chip in gpio_rcar_probe() Geert Uytterhoeven @ 2015-03-18 18:41 ` Geert Uytterhoeven 2015-03-26 9:19 ` Linus Walleij 2015-03-18 18:41 ` [PATCH 3/3] gpio: rcar: Prevent module clock disable when wake-up is enabled Geert Uytterhoeven 2 siblings, 1 reply; 7+ messages in thread From: Geert Uytterhoeven @ 2015-03-18 18:41 UTC (permalink / raw) To: Linus Walleij, Alexandre Courbot; +Cc: linux-gpio, linux-sh, Geert Uytterhoeven Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- drivers/gpio/gpio-rcar.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index e67d578ac07c45d5..d96166ca1b42f93e 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -39,18 +39,18 @@ struct gpio_rcar_priv { struct irq_chip irq_chip; }; -#define IOINTSEL 0x00 -#define INOUTSEL 0x04 -#define OUTDT 0x08 -#define INDT 0x0c -#define INTDT 0x10 -#define INTCLR 0x14 -#define INTMSK 0x18 -#define MSKCLR 0x1c -#define POSNEG 0x20 -#define EDGLEVEL 0x24 -#define FILONOFF 0x28 -#define BOTHEDGE 0x4c +#define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */ +#define INOUTSEL 0x04 /* General Input/Output Switching Register */ +#define OUTDT 0x08 /* General Output Register */ +#define INDT 0x0c /* General Input Register */ +#define INTDT 0x10 /* Interrupt Display Register */ +#define INTCLR 0x14 /* Interrupt Clear Register */ +#define INTMSK 0x18 /* Interrupt Mask Register */ +#define MSKCLR 0x1c /* Interrupt Mask Clear Register */ +#define POSNEG 0x20 /* Positive/Negative Logic Select Register */ +#define EDGLEVEL 0x24 /* Edge/level Select Register */ +#define FILONOFF 0x28 /* Chattering Prevention On/Off Register */ +#define BOTHEDGE 0x4c /* One Edge/Both Edge Select Register */ #define RCAR_MAX_GPIO_PER_BANK 32 -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/3] gpio: rcar: Add more register documentation 2015-03-18 18:41 ` [PATCH 2/3] gpio: rcar: Add more register documentation Geert Uytterhoeven @ 2015-03-26 9:19 ` Linus Walleij 0 siblings, 0 replies; 7+ messages in thread From: Linus Walleij @ 2015-03-26 9:19 UTC (permalink / raw) To: Geert Uytterhoeven Cc: Alexandre Courbot, linux-gpio@vger.kernel.org, linux-sh@vger.kernel.org On Wed, Mar 18, 2015 at 7:41 PM, Geert Uytterhoeven <geert+renesas@glider.be> wrote: > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Patch applied. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/3] gpio: rcar: Prevent module clock disable when wake-up is enabled 2015-03-18 18:41 [PATCH 0/3] gpio: rcar: Fix wake up using gpio-keys with PM domain Geert Uytterhoeven 2015-03-18 18:41 ` [PATCH 1/3] gpio: rcar: Use local variable gpio_chip in gpio_rcar_probe() Geert Uytterhoeven 2015-03-18 18:41 ` [PATCH 2/3] gpio: rcar: Add more register documentation Geert Uytterhoeven @ 2015-03-18 18:41 ` Geert Uytterhoeven 2015-03-26 9:26 ` Linus Walleij 2 siblings, 1 reply; 7+ messages in thread From: Geert Uytterhoeven @ 2015-03-18 18:41 UTC (permalink / raw) To: Linus Walleij, Alexandre Courbot; +Cc: linux-gpio, linux-sh, Geert Uytterhoeven When the GPIO module is needed for wake-up, it's module clock must not be disabled. Hence implement irq_chip.irq_set_wake(), which increments/decrements the clock's enable_count when needed, and forwards the wake-up state to the upstream interrupt controller. This fixes wake-up from s2ram using gpio-keys when using a PM Domain to manage the module clock. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> --- To avoid ugly warning messages during resume, this depends on the GIC driver setting "gic_chip.flags = IRQCHIP_SKIP_SET_WAKE". (cfr. http://marc.info/?l=linux-sh&m=142669263324586&w=2). --- drivers/gpio/gpio-rcar.c | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index d96166ca1b42f93e..fd39774659484fa6 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -14,6 +14,7 @@ * GNU General Public License for more details. */ +#include <linux/clk.h> #include <linux/err.h> #include <linux/gpio.h> #include <linux/init.h> @@ -37,6 +38,8 @@ struct gpio_rcar_priv { struct platform_device *pdev; struct gpio_chip gpio_chip; struct irq_chip irq_chip; + unsigned int irq_parent; + struct clk *clk; }; #define IOINTSEL 0x00 /* General IO/Interrupt Switching Register */ @@ -169,6 +172,25 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) return 0; } +static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on) +{ + struct gpio_chip *gc = irq_data_get_irq_chip_data(d); + struct gpio_rcar_priv *p = container_of(gc, struct gpio_rcar_priv, + gpio_chip); + + irq_set_irq_wake(p->irq_parent, on); + + if (!p->clk) + return 0; + + if (on) + clk_enable(p->clk); + else + clk_disable(p->clk); + + return 0; +} + static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id) { struct gpio_rcar_priv *p = dev_id; @@ -367,6 +389,12 @@ static int gpio_rcar_probe(struct platform_device *pdev) platform_set_drvdata(pdev, p); + p->clk = devm_clk_get(dev, NULL); + if (IS_ERR(p->clk)) { + dev_warn(dev, "unable to get clock\n"); + p->clk = NULL; + } + pm_runtime_enable(dev); pm_runtime_get_sync(dev); @@ -404,8 +432,8 @@ static int gpio_rcar_probe(struct platform_device *pdev) irq_chip->irq_mask = gpio_rcar_irq_disable; irq_chip->irq_unmask = gpio_rcar_irq_enable; irq_chip->irq_set_type = gpio_rcar_irq_set_type; - irq_chip->flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_SET_TYPE_MASKED - | IRQCHIP_MASK_ON_SUSPEND; + irq_chip->irq_set_wake = gpio_rcar_irq_set_wake; + irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND; ret = gpiochip_add(gpio_chip); if (ret) { @@ -420,6 +448,7 @@ static int gpio_rcar_probe(struct platform_device *pdev) goto err1; } + p->irq_parent = irq->start; if (devm_request_irq(dev, irq->start, gpio_rcar_irq_handler, IRQF_SHARED, name, p)) { dev_err(dev, "failed to request IRQ\n"); -- 1.9.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 3/3] gpio: rcar: Prevent module clock disable when wake-up is enabled 2015-03-18 18:41 ` [PATCH 3/3] gpio: rcar: Prevent module clock disable when wake-up is enabled Geert Uytterhoeven @ 2015-03-26 9:26 ` Linus Walleij 0 siblings, 0 replies; 7+ messages in thread From: Linus Walleij @ 2015-03-26 9:26 UTC (permalink / raw) To: Geert Uytterhoeven Cc: Alexandre Courbot, linux-gpio@vger.kernel.org, linux-sh@vger.kernel.org On Wed, Mar 18, 2015 at 7:41 PM, Geert Uytterhoeven <geert+renesas@glider.be> wrote: > When the GPIO module is needed for wake-up, it's module clock must not > be disabled. Hence implement irq_chip.irq_set_wake(), which > increments/decrements the clock's enable_count when needed, and forwards > the wake-up state to the upstream interrupt controller. > > This fixes wake-up from s2ram using gpio-keys when using a PM Domain to > manage the module clock. > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Patch applied. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-03-26 9:26 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-03-18 18:41 [PATCH 0/3] gpio: rcar: Fix wake up using gpio-keys with PM domain Geert Uytterhoeven 2015-03-18 18:41 ` [PATCH 1/3] gpio: rcar: Use local variable gpio_chip in gpio_rcar_probe() Geert Uytterhoeven 2015-03-26 9:18 ` Linus Walleij 2015-03-18 18:41 ` [PATCH 2/3] gpio: rcar: Add more register documentation Geert Uytterhoeven 2015-03-26 9:19 ` Linus Walleij 2015-03-18 18:41 ` [PATCH 3/3] gpio: rcar: Prevent module clock disable when wake-up is enabled Geert Uytterhoeven 2015-03-26 9:26 ` Linus Walleij
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).