* [PATCH] pinctrl: ingenic: Add irq_{request,release}_resources callbacks
@ 2020-05-03 16:45 Paul Cercueil
2020-05-12 12:39 ` Linus Walleij
0 siblings, 1 reply; 2+ messages in thread
From: Paul Cercueil @ 2020-05-03 16:45 UTC (permalink / raw)
To: Linus Walleij; +Cc: od, linux-gpio, linux-kernel, Paul Cercueil
These are called when a GPIO is to be used as IRQ.
Without these custom callbacks, when an interrupt is requested directly
and not through gpiod_to_irq(), the request fails because the GPIO is
not necesarily in input mode. These callbacks simply enforce that the
requested GPIO is in input mode.
Signed-off-by: Paul Cercueil <paul@crapouillou.net>
---
drivers/pinctrl/pinctrl-ingenic.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c
index 96f04d121ebd..f2b95ee31ffe 100644
--- a/drivers/pinctrl/pinctrl-ingenic.c
+++ b/drivers/pinctrl/pinctrl-ingenic.c
@@ -1933,6 +1933,25 @@ static const struct pinctrl_ops ingenic_pctlops = {
.dt_free_map = pinconf_generic_dt_free_map,
};
+static int ingenic_gpio_irq_request(struct irq_data *data)
+{
+ struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
+ int ret;
+
+ ret = ingenic_gpio_direction_input(gpio_chip, data->hwirq);
+ if (ret)
+ return ret;
+
+ return gpiochip_reqres_irq(gpio_chip, data->hwirq);
+}
+
+static void ingenic_gpio_irq_release(struct irq_data *data)
+{
+ struct gpio_chip *gpio_chip = irq_data_get_irq_chip_data(data);
+
+ return gpiochip_relres_irq(gpio_chip, data->hwirq);
+}
+
static int ingenic_pinmux_set_pin_fn(struct ingenic_pinctrl *jzpc,
int pin, int func)
{
@@ -2296,6 +2315,8 @@ static int __init ingenic_gpio_probe(struct ingenic_pinctrl *jzpc,
jzgc->irq_chip.irq_ack = ingenic_gpio_irq_ack;
jzgc->irq_chip.irq_set_type = ingenic_gpio_irq_set_type;
jzgc->irq_chip.irq_set_wake = ingenic_gpio_irq_set_wake;
+ jzgc->irq_chip.irq_request_resources = ingenic_gpio_irq_request;
+ jzgc->irq_chip.irq_release_resources = ingenic_gpio_irq_release;
jzgc->irq_chip.flags = IRQCHIP_MASK_ON_SUSPEND;
girq = &jzgc->gc.irq;
--
2.26.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] pinctrl: ingenic: Add irq_{request,release}_resources callbacks
2020-05-03 16:45 [PATCH] pinctrl: ingenic: Add irq_{request,release}_resources callbacks Paul Cercueil
@ 2020-05-12 12:39 ` Linus Walleij
0 siblings, 0 replies; 2+ messages in thread
From: Linus Walleij @ 2020-05-12 12:39 UTC (permalink / raw)
To: Paul Cercueil; +Cc: od, open list:GPIO SUBSYSTEM, linux-kernel
On Sun, May 3, 2020 at 6:45 PM Paul Cercueil <paul@crapouillou.net> wrote:
> These are called when a GPIO is to be used as IRQ.
>
> Without these custom callbacks, when an interrupt is requested directly
> and not through gpiod_to_irq(), the request fails because the GPIO is
> not necesarily in input mode. These callbacks simply enforce that the
> requested GPIO is in input mode.
>
> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-05-12 12:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-03 16:45 [PATCH] pinctrl: ingenic: Add irq_{request,release}_resources callbacks Paul Cercueil
2020-05-12 12:39 ` 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).