From 4d26cd886aafc5e221d22904e1f75c8a6ed503e9 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Fri, 5 Feb 2021 16:48:12 +0000 Subject: [PATCH] gpio: tegra: Ensure pinctrl input-enable is set for interrupts If the default pin configuration for a Tegra GPIO does not have the input-enable bit set, then when using a GPIO as an interrupt, external events will not be seen. Fix this by calling tegra_gpio_direction_input() when requesting the IRQ resources because this function will in turn call pinctrl_gpio_direction_input() to set the input-enable bit for the pin. Note that given the tegra_gpio_direction_input() also sets the GPIO OE (output-enable) register, we no longer need to set this register in tegra_gpio_irq_set_type(). Signed-off-by: Jon Hunter --- drivers/gpio/gpio-tegra.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/gpio/gpio-tegra.c b/drivers/gpio/gpio-tegra.c index 18b1d54b539eda..68b12014d22583 100644 --- a/drivers/gpio/gpio-tegra.c +++ b/drivers/gpio/gpio-tegra.c @@ -345,8 +345,6 @@ static int tegra_gpio_irq_set_type(struct irq_data *d, unsigned int type) raw_spin_unlock_irqrestore(&bank->lvl_lock[port], flags); - tegra_gpio_mask_write(tgi, GPIO_MSK_OE(tgi, gpio), gpio, 0); - ret = gpiochip_lock_as_irq(&tgi->gc, gpio); if (ret) { dev_err(tgi->dev, @@ -585,8 +583,11 @@ static int tegra_gpio_irq_request_resources(struct irq_data *d) { struct gpio_chip *chip = irq_data_get_irq_chip_data(d); struct tegra_gpio_info *tgi = gpiochip_get_data(chip); + int ret; - tegra_gpio_enable(tgi, d->hwirq); + ret = tegra_gpio_direction_input(chip, d->hwirq); + if (ret < 0) + return ret; ret = gpiochip_reqres_irq(chip, d->hwirq); if (ret < 0)