diff mbox series

[v3,11/12] gpio: rockchip: Set input direction when request irq

Message ID 20240903073649.237362-12-ye.zhang@rock-chips.com (mailing list archive)
State New
Headers show
Series gpio: rockchip: Update the GPIO driver | expand

Commit Message

Ye Zhang Sept. 3, 2024, 7:36 a.m. UTC
Since the GPIO can only generate interrupts when its direction is set to
input, it is set to input before requesting the interrupt resources.

Signed-off-by: Ye Zhang <ye.zhang@rock-chips.com>
---
 drivers/gpio/gpio-rockchip.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Andy Shevchenko Sept. 3, 2024, 4:08 p.m. UTC | #1
On Tue, Sep 03, 2024 at 03:36:48PM +0800, Ye Zhang wrote:
> Since the GPIO can only generate interrupts when its direction is set to
> input, it is set to input before requesting the interrupt resources.

...

>  static int rockchip_irq_reqres(struct irq_data *d)
>  {

> +	irq_hw_number_t hwirq;
>  	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
>  	struct rockchip_pin_bank *bank = gc->private;
>  
> -	return gpiochip_reqres_irq(&bank->gpio_chip, d->hwirq);
> +	hwirq = irqd_to_hwirq(d);
> +	rockchip_gpio_direction_input(&bank->gpio_chip, hwirq);

	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
	struct rockchip_pin_bank *bank = gc->private;
	irq_hw_number_t hwirq = irqd_to_hwirq(d);

	rockchip_gpio_direction_input(&bank->gpio_chip, hwirq);

> +	return gpiochip_reqres_irq(&bank->gpio_chip, hwirq);
>  }
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index 6deebf1dd9dd..73e57efb46fc 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -476,10 +476,14 @@  static int rockchip_irq_set_type(struct irq_data *d, unsigned int type)
 
 static int rockchip_irq_reqres(struct irq_data *d)
 {
+	irq_hw_number_t hwirq;
 	struct irq_chip_generic *gc = irq_data_get_irq_chip_data(d);
 	struct rockchip_pin_bank *bank = gc->private;
 
-	return gpiochip_reqres_irq(&bank->gpio_chip, d->hwirq);
+	hwirq = irqd_to_hwirq(d);
+	rockchip_gpio_direction_input(&bank->gpio_chip, hwirq);
+
+	return gpiochip_reqres_irq(&bank->gpio_chip, hwirq);
 }
 
 static void rockchip_irq_relres(struct irq_data *d)