* [PATCH] gpio: rcar: Fine-grained Runtime PM support
@ 2015-06-25 14:45 Geert Uytterhoeven
2015-07-16 8:43 ` Linus Walleij
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2015-06-25 14:45 UTC (permalink / raw)
To: Linus Walleij, Alexandre Courbot
Cc: Magnus Damm, linux-gpio, linux-pm, linux-sh, Geert Uytterhoeven
Currently gpio modules are runtime-resumed at probe time. This means the
gpio module will be active all the time (except during system suspend,
if not configured as a wake-up source).
While an R-Car Gen2 gpio module retains pins configured for output at
the requested level while put in standby mode, gpio registercannot be
accessed while suspended. Unfortunately pm_runtime_get_sync() cannot be
called from all contexts where gpio register access is needed. Hence
move the Runtime PM handling from probe/remove time to gpio request/free
time, which is probably the best we can do.
On r8a7791/koelsch, gpio modules 0, 1, 3, and 4 are now suspended during
normal use (gpio2 is used for LEDs and regulators, gpio5 for keys, gpio6
for SD-Card CD & WP, gpio7 for keys and regulators).
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
drivers/gpio/gpio-rcar.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c
index 29089ef6969fd33f..099a6f508f867821 100644
--- a/drivers/gpio/gpio-rcar.c
+++ b/drivers/gpio/gpio-rcar.c
@@ -251,17 +251,32 @@ static void gpio_rcar_config_general_input_output_mode(struct gpio_chip *chip,
static int gpio_rcar_request(struct gpio_chip *chip, unsigned offset)
{
- return pinctrl_request_gpio(chip->base + offset);
+ struct gpio_rcar_priv *p = gpio_to_priv(chip);
+ int error;
+
+ error = pm_runtime_get_sync(&p->pdev->dev);
+ if (error < 0)
+ return error;
+
+ error = pinctrl_request_gpio(chip->base + offset);
+ if (error)
+ pm_runtime_put(&p->pdev->dev);
+
+ return error;
}
static void gpio_rcar_free(struct gpio_chip *chip, unsigned offset)
{
+ struct gpio_rcar_priv *p = gpio_to_priv(chip);
+
pinctrl_free_gpio(chip->base + offset);
/* Set the GPIO as an input to ensure that the next GPIO request won't
* drive the GPIO pin as an output.
*/
gpio_rcar_config_general_input_output_mode(chip, offset, false);
+
+ pm_runtime_put(&p->pdev->dev);
}
static int gpio_rcar_direction_input(struct gpio_chip *chip, unsigned offset)
@@ -405,7 +420,6 @@ static int gpio_rcar_probe(struct platform_device *pdev)
}
pm_runtime_enable(dev);
- pm_runtime_get_sync(dev);
io = platform_get_resource(pdev, IORESOURCE_MEM, 0);
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -488,7 +502,6 @@ static int gpio_rcar_probe(struct platform_device *pdev)
err1:
gpiochip_remove(gpio_chip);
err0:
- pm_runtime_put(dev);
pm_runtime_disable(dev);
return ret;
}
@@ -499,7 +512,6 @@ static int gpio_rcar_remove(struct platform_device *pdev)
gpiochip_remove(&p->gpio_chip);
- pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev);
return 0;
}
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: rcar: Fine-grained Runtime PM support
2015-06-25 14:45 [PATCH] gpio: rcar: Fine-grained Runtime PM support Geert Uytterhoeven
@ 2015-07-16 8:43 ` Linus Walleij
2015-07-16 9:05 ` Magnus Damm
0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2015-07-16 8:43 UTC (permalink / raw)
To: Geert Uytterhoeven
Cc: Alexandre Courbot, Magnus Damm, linux-gpio@vger.kernel.org,
linux-pm@vger.kernel.org, linux-sh@vger.kernel.org
On Thu, Jun 25, 2015 at 4:45 PM, Geert Uytterhoeven
<geert+renesas@glider.be> wrote:
> Currently gpio modules are runtime-resumed at probe time. This means the
> gpio module will be active all the time (except during system suspend,
> if not configured as a wake-up source).
>
> While an R-Car Gen2 gpio module retains pins configured for output at
> the requested level while put in standby mode, gpio registercannot be
> accessed while suspended. Unfortunately pm_runtime_get_sync() cannot be
> called from all contexts where gpio register access is needed. Hence
> move the Runtime PM handling from probe/remove time to gpio request/free
> time, which is probably the best we can do.
>
> On r8a7791/koelsch, gpio modules 0, 1, 3, and 4 are now suspended during
> normal use (gpio2 is used for LEDs and regulators, gpio5 for keys, gpio6
> for SD-Card CD & WP, gpio7 for keys and regulators).
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Patch applied unless Magnus complains.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] gpio: rcar: Fine-grained Runtime PM support
2015-07-16 8:43 ` Linus Walleij
@ 2015-07-16 9:05 ` Magnus Damm
0 siblings, 0 replies; 3+ messages in thread
From: Magnus Damm @ 2015-07-16 9:05 UTC (permalink / raw)
To: Linus Walleij
Cc: Geert Uytterhoeven, Alexandre Courbot, linux-gpio@vger.kernel.org,
linux-pm@vger.kernel.org, linux-sh@vger.kernel.org
Hi Linus,
On Thu, Jul 16, 2015 at 5:43 PM, Linus Walleij <linus.walleij@linaro.org> wrote:
> On Thu, Jun 25, 2015 at 4:45 PM, Geert Uytterhoeven
> <geert+renesas@glider.be> wrote:
>
>> Currently gpio modules are runtime-resumed at probe time. This means the
>> gpio module will be active all the time (except during system suspend,
>> if not configured as a wake-up source).
>>
>> While an R-Car Gen2 gpio module retains pins configured for output at
>> the requested level while put in standby mode, gpio registercannot be
>> accessed while suspended. Unfortunately pm_runtime_get_sync() cannot be
>> called from all contexts where gpio register access is needed. Hence
>> move the Runtime PM handling from probe/remove time to gpio request/free
>> time, which is probably the best we can do.
>>
>> On r8a7791/koelsch, gpio modules 0, 1, 3, and 4 are now suspended during
>> normal use (gpio2 is used for LEDs and regulators, gpio5 for keys, gpio6
>> for SD-Card CD & WP, gpio7 for keys and regulators).
>>
>> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Patch applied unless Magnus complains.
No complaints, just happy Magnus!
Thanks,
/ magnus
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-16 9:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-25 14:45 [PATCH] gpio: rcar: Fine-grained Runtime PM support Geert Uytterhoeven
2015-07-16 8:43 ` Linus Walleij
2015-07-16 9:05 ` Magnus Damm
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).