* [PATCH] gpio-rcar: .irq_set_wake() support to work with suspend_device_irqs()
@ 2014-11-07 9:22 Yoshihiro Kaneko
2014-11-14 9:53 ` Linus Walleij
0 siblings, 1 reply; 5+ messages in thread
From: Yoshihiro Kaneko @ 2014-11-07 9:22 UTC (permalink / raw)
To: linux-gpio
Cc: Linus Walleij, Alexandre Courbot, Simon Horman, Magnus Damm,
linux-sh
From: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
All IRQs in the kernel get disabled by PM core prior to .suspend_noirq()
step through kernel/irq/pm.c::suspend_device_irqs().
The SYSC hardware block in the R-Car SoCs, on the other hand, uses any
interrupt as wake-up source(es) and requires them to be unmasked during
the system is suspended.
This patch implements .irq_set_wake() which makes __disable_irq() call
a NOP when a GPIO port is claimed as a wake-up source.
Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
---
This patch is based on for-next branch of Linus Walleij's gpio tree.
drivers/gpio/gpio-rcar.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index bf6c094..ef71ca8 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -38,6 +38,7 @@ struct gpio_rcar_priv {
struct gpio_chip gpio_chip;
struct irq_chip irq_chip;
struct irq_domain *irq_domain;
+ u32 no_suspend; /* do not disable this GPIO port during suspend */
};
#define IOINTSEL 0x00
@@ -83,6 +84,15 @@ static void gpio_rcar_irq_disable(struct irq_data *d)
{
struct gpio_rcar_priv *p = irq_data_get_irq_chip_data(d);
+ if (p->no_suspend & BIT(irqd_to_hwirq(d))) {
+ /*
+ * This GPIO port is claimed as a wake-up source and
+ * currently in a no-suspend-requested state. Don't
+ * disable this IRQ during suspend.
+ */
+ return;
+ }
+
gpio_rcar_write(p, INTMSK, ~BIT(irqd_to_hwirq(d)));
}
@@ -164,6 +174,20 @@ 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_rcar_priv *p = irq_data_get_irq_chip_data(d);
+ unsigned int hwirq = irqd_to_hwirq(d);
+
+ dev_dbg(&p->pdev->dev, "wake irq = %u %s\n", hwirq, on ? "on" : "off");
+
+ if (on)
+ p->no_suspend |= BIT(hwirq);
+ else
+ p->no_suspend &= ~BIT(hwirq);
+ return 0;
+}
+
static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id)
{
struct gpio_rcar_priv *p = dev_id;
@@ -416,6 +440,7 @@ 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->irq_set_wake = gpio_rcar_irq_set_wake;
irq_chip->flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_SET_TYPE_MASKED
| IRQCHIP_MASK_ON_SUSPEND;
--
1.9.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio-rcar: .irq_set_wake() support to work with suspend_device_irqs()
2014-11-07 9:22 [PATCH] gpio-rcar: .irq_set_wake() support to work with suspend_device_irqs() Yoshihiro Kaneko
@ 2014-11-14 9:53 ` Linus Walleij
2014-11-17 1:06 ` Magnus Damm
0 siblings, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2014-11-14 9:53 UTC (permalink / raw)
To: Yoshihiro Kaneko, Magnus Damm, Laurent Pinchart
Cc: linux-gpio@vger.kernel.org, Alexandre Courbot, Simon Horman,
linux-sh@vger.kernel.org
On Fri, Nov 7, 2014 at 10:22 AM, Yoshihiro Kaneko <ykaneko0929@gmail.com> wrote:
> From: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
>
> All IRQs in the kernel get disabled by PM core prior to .suspend_noirq()
> step through kernel/irq/pm.c::suspend_device_irqs().
>
> The SYSC hardware block in the R-Car SoCs, on the other hand, uses any
> interrupt as wake-up source(es) and requires them to be unmasked during
> the system is suspended.
>
> This patch implements .irq_set_wake() which makes __disable_irq() call
> a NOP when a GPIO port is claimed as a wake-up source.
>
> Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
> Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
Patch tentatively applied unless Magnus or Laurent starts complaining...
This driver should be simple to convert to GPIOLIB_IRQCHIP and get
rid of some code overhead.
Yoshihiro, can you look into this?
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio-rcar: .irq_set_wake() support to work with suspend_device_irqs()
2014-11-14 9:53 ` Linus Walleij
@ 2014-11-17 1:06 ` Magnus Damm
2014-11-17 12:05 ` Geert Uytterhoeven
0 siblings, 1 reply; 5+ messages in thread
From: Magnus Damm @ 2014-11-17 1:06 UTC (permalink / raw)
To: Linus Walleij
Cc: Yoshihiro Kaneko, Laurent Pinchart, linux-gpio@vger.kernel.org,
Alexandre Courbot, Simon Horman, linux-sh@vger.kernel.org,
Geert Uytterhoeven
Hi Linus, Kaneko-san,
On Fri, Nov 14, 2014 at 6:53 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Fri, Nov 7, 2014 at 10:22 AM, Yoshihiro Kaneko <ykaneko0929@gmail.com> wrote:
>
>> From: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
>>
>> All IRQs in the kernel get disabled by PM core prior to .suspend_noirq()
>> step through kernel/irq/pm.c::suspend_device_irqs().
>>
>> The SYSC hardware block in the R-Car SoCs, on the other hand, uses any
>> interrupt as wake-up source(es) and requires them to be unmasked during
>> the system is suspended.
>>
>> This patch implements .irq_set_wake() which makes __disable_irq() call
>> a NOP when a GPIO port is claimed as a wake-up source.
>>
>> Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
>> Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
>> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
>
> Patch tentatively applied unless Magnus or Laurent starts complaining...
I'll bite. =)
Thanks for the efforts, but I doubt that this patch is needed. Unless
I'm mistaken this feature is implemented already in the following
commits:
4039611 gpio: rcar: Enable mask on suspend
fba968a gpio: rcar: Use lazy disable
> This driver should be simple to convert to GPIOLIB_IRQCHIP and get
> rid of some code overhead.
Perhaps Geert [CC:ed] can have a look at this in the not so distant future?
Thanks,
/ magnus
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpio-rcar: .irq_set_wake() support to work with suspend_device_irqs()
2014-11-17 1:06 ` Magnus Damm
@ 2014-11-17 12:05 ` Geert Uytterhoeven
2014-11-27 14:01 ` Linus Walleij
0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2014-11-17 12:05 UTC (permalink / raw)
To: Magnus Damm
Cc: Linus Walleij, Yoshihiro Kaneko, Laurent Pinchart,
linux-gpio@vger.kernel.org, Alexandre Courbot, Simon Horman,
linux-sh@vger.kernel.org, Geert Uytterhoeven
Hi Magnus, Kaneko-san,
On Mon, Nov 17, 2014 at 2:06 AM, Magnus Damm <magnus.damm@gmail.com> wrote:
> On Fri, Nov 14, 2014 at 6:53 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
>> On Fri, Nov 7, 2014 at 10:22 AM, Yoshihiro Kaneko <ykaneko0929@gmail.com> wrote:
>>> From: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
>>>
>>> All IRQs in the kernel get disabled by PM core prior to .suspend_noirq()
>>> step through kernel/irq/pm.c::suspend_device_irqs().
>>>
>>> The SYSC hardware block in the R-Car SoCs, on the other hand, uses any
>>> interrupt as wake-up source(es) and requires them to be unmasked during
>>> the system is suspended.
>>>
>>> This patch implements .irq_set_wake() which makes __disable_irq() call
>>> a NOP when a GPIO port is claimed as a wake-up source.
>>>
>>> Signed-off-by: Shinya Kuribayashi <shinya.kuribayashi.px@renesas.com>
>>> Signed-off-by: Koji Matsuoka <koji.matsuoka.xm@renesas.com>
>>> Signed-off-by: Yoshihiro Kaneko <ykaneko0929@gmail.com>
>>
>> Patch tentatively applied unless Magnus or Laurent starts complaining...
>
> I'll bite. =)
>
> Thanks for the efforts, but I doubt that this patch is needed. Unless
> I'm mistaken this feature is implemented already in the following
> commits:
>
> 4039611 gpio: rcar: Enable mask on suspend
> fba968a gpio: rcar: Use lazy disable
Good to see you (as the author of the driver and those two fixes) have some
reservations. I also had my doubts about this patch, but I didn't get to
testing it earlier...
I can confirm resume from s2ram works without and with this patch.
So unless this patch is meant to fix something else (is it?), I think it can be
dropped.
>> This driver should be simple to convert to GPIOLIB_IRQCHIP and get
>> rid of some code overhead.
>
> Perhaps Geert [CC:ed] can have a look at this in the not so distant future?
Sure. Will do.
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] 5+ messages in thread
* Re: [PATCH] gpio-rcar: .irq_set_wake() support to work with suspend_device_irqs()
2014-11-17 12:05 ` Geert Uytterhoeven
@ 2014-11-27 14:01 ` Linus Walleij
0 siblings, 0 replies; 5+ messages in thread
From: Linus Walleij @ 2014-11-27 14:01 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Magnus Damm, Yoshihiro Kaneko, Laurent Pinchart,
linux-gpio@vger.kernel.org, Alexandre Courbot, Simon Horman,
linux-sh@vger.kernel.org, Geert Uytterhoeven
On Mon, Nov 17, 2014 at 1:05 PM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> I can confirm resume from s2ram works without and with this patch.
> So unless this patch is meant to fix something else (is it?), I think it can be
> dropped.
OK patch is dropped from my queue.
>>> This driver should be simple to convert to GPIOLIB_IRQCHIP and get
>>> rid of some code overhead.
>>
>> Perhaps Geert [CC:ed] can have a look at this in the not so distant future?
>
> Sure. Will do.
THANKS!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-11-27 14:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-07 9:22 [PATCH] gpio-rcar: .irq_set_wake() support to work with suspend_device_irqs() Yoshihiro Kaneko
2014-11-14 9:53 ` Linus Walleij
2014-11-17 1:06 ` Magnus Damm
2014-11-17 12:05 ` Geert Uytterhoeven
2014-11-27 14:01 ` 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).