Skip to content

Commit b26a719

Browse files
geertulinusw
authored andcommitted
gpio: rcar: Add Runtime PM handling for interrupts
The R-Car GPIO driver handles Runtime PM for requested GPIOs only. When using a GPIO purely as an interrupt source, no Runtime PM handling is done, and the GPIO module's clock may not be enabled. To fix this: - Add .irq_request_resources() and .irq_release_resources() callbacks to handle Runtime PM when an interrupt is requested, - Add irq_bus_lock() and sync_unlock() callbacks to handle Runtime PM when e.g. disabling/enabling an interrupt, or configuring the interrupt type. Fixes: d5c3d84 "net: phy: Avoid polling PHY with PHY_IGNORE_INTERRUPTS" Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 81f70ba commit b26a719

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

drivers/gpio/gpio-rcar.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,44 @@ static int gpio_rcar_irq_set_wake(struct irq_data *d, unsigned int on)
196196
return 0;
197197
}
198198

199+
static void gpio_rcar_irq_bus_lock(struct irq_data *d)
200+
{
201+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
202+
struct gpio_rcar_priv *p = gpiochip_get_data(gc);
203+
204+
pm_runtime_get_sync(&p->pdev->dev);
205+
}
206+
207+
static void gpio_rcar_irq_bus_sync_unlock(struct irq_data *d)
208+
{
209+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
210+
struct gpio_rcar_priv *p = gpiochip_get_data(gc);
211+
212+
pm_runtime_put(&p->pdev->dev);
213+
}
214+
215+
216+
static int gpio_rcar_irq_request_resources(struct irq_data *d)
217+
{
218+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
219+
struct gpio_rcar_priv *p = gpiochip_get_data(gc);
220+
int error;
221+
222+
error = pm_runtime_get_sync(&p->pdev->dev);
223+
if (error < 0)
224+
return error;
225+
226+
return 0;
227+
}
228+
229+
static void gpio_rcar_irq_release_resources(struct irq_data *d)
230+
{
231+
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
232+
struct gpio_rcar_priv *p = gpiochip_get_data(gc);
233+
234+
pm_runtime_put(&p->pdev->dev);
235+
}
236+
199237
static irqreturn_t gpio_rcar_irq_handler(int irq, void *dev_id)
200238
{
201239
struct gpio_rcar_priv *p = dev_id;
@@ -450,6 +488,10 @@ static int gpio_rcar_probe(struct platform_device *pdev)
450488
irq_chip->irq_unmask = gpio_rcar_irq_enable;
451489
irq_chip->irq_set_type = gpio_rcar_irq_set_type;
452490
irq_chip->irq_set_wake = gpio_rcar_irq_set_wake;
491+
irq_chip->irq_bus_lock = gpio_rcar_irq_bus_lock;
492+
irq_chip->irq_bus_sync_unlock = gpio_rcar_irq_bus_sync_unlock;
493+
irq_chip->irq_request_resources = gpio_rcar_irq_request_resources;
494+
irq_chip->irq_release_resources = gpio_rcar_irq_release_resources;
453495
irq_chip->flags = IRQCHIP_SET_TYPE_MASKED | IRQCHIP_MASK_ON_SUSPEND;
454496

455497
ret = gpiochip_add_data(gpio_chip, p);

0 commit comments

Comments
 (0)