* [PATCH 1/1] pinctrl: st: add irq_request_resources callback
@ 2017-02-27 13:49 ` patrice.chotard at st.com
0 siblings, 0 replies; 6+ messages in thread
From: patrice.chotard @ 2017-02-27 13:49 UTC (permalink / raw)
To: linux-kernel, Linus Walleij, linux-arm-kernel
Cc: patrice.chotard, peter.griffin, lee.jones
From: Patrice Chotard <patrice.chotard@st.com>
When using GPIO as IRQ source, the GPIO must be configured
in INPUT. The callback dedicated for this was missing in
pinctrl-st driver.
This fix the following kernel error when trying to lock a gpio
as IRQ:
[ 7.521095] gpio gpiochip7: (PIO11): gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ
[ 7.526018] gpio gpiochip7: (PIO11): unable to lock HW IRQ 6 for IRQ
[ 7.529405] genirq: Failed to request resources for 0-0053 (irq 81) on irqchip GPIO
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---
drivers/pinctrl/pinctrl-st.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index 676efcc..84c2af8 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -1285,6 +1285,14 @@ static void st_gpio_irq_unmask(struct irq_data *d)
writel(BIT(d->hwirq), bank->base + REG_PIO_SET_PMASK);
}
+static int st_gpio_irq_request_resources(struct irq_data *d)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+ int pin = d->hwirq;
+
+ return st_gpio_direction_input(gc, pin);
+}
+
static int st_gpio_irq_set_type(struct irq_data *d, unsigned type)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
@@ -1438,12 +1446,13 @@ static void st_gpio_irqmux_handler(struct irq_desc *desc)
};
static struct irq_chip st_gpio_irqchip = {
- .name = "GPIO",
- .irq_disable = st_gpio_irq_mask,
- .irq_mask = st_gpio_irq_mask,
- .irq_unmask = st_gpio_irq_unmask,
- .irq_set_type = st_gpio_irq_set_type,
- .flags = IRQCHIP_SKIP_SET_WAKE,
+ .name = "GPIO",
+ .irq_request_resources = st_gpio_irq_request_resources,
+ .irq_disable = st_gpio_irq_mask,
+ .irq_mask = st_gpio_irq_mask,
+ .irq_unmask = st_gpio_irq_unmask,
+ .irq_set_type = st_gpio_irq_set_type,
+ .flags = IRQCHIP_SKIP_SET_WAKE,
};
static int st_gpiolib_register_bank(struct st_pinctrl *info,
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 1/1] pinctrl: st: add irq_request_resources callback
@ 2017-02-27 13:49 ` patrice.chotard at st.com
0 siblings, 0 replies; 6+ messages in thread
From: patrice.chotard at st.com @ 2017-02-27 13:49 UTC (permalink / raw)
To: linux-arm-kernel
From: Patrice Chotard <patrice.chotard@st.com>
When using GPIO as IRQ source, the GPIO must be configured
in INPUT. The callback dedicated for this was missing in
pinctrl-st driver.
This fix the following kernel error when trying to lock a gpio
as IRQ:
[ 7.521095] gpio gpiochip7: (PIO11): gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ
[ 7.526018] gpio gpiochip7: (PIO11): unable to lock HW IRQ 6 for IRQ
[ 7.529405] genirq: Failed to request resources for 0-0053 (irq 81) on irqchip GPIO
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
---
drivers/pinctrl/pinctrl-st.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c
index 676efcc..84c2af8 100644
--- a/drivers/pinctrl/pinctrl-st.c
+++ b/drivers/pinctrl/pinctrl-st.c
@@ -1285,6 +1285,14 @@ static void st_gpio_irq_unmask(struct irq_data *d)
writel(BIT(d->hwirq), bank->base + REG_PIO_SET_PMASK);
}
+static int st_gpio_irq_request_resources(struct irq_data *d)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+ int pin = d->hwirq;
+
+ return st_gpio_direction_input(gc, pin);
+}
+
static int st_gpio_irq_set_type(struct irq_data *d, unsigned type)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
@@ -1438,12 +1446,13 @@ static void st_gpio_irqmux_handler(struct irq_desc *desc)
};
static struct irq_chip st_gpio_irqchip = {
- .name = "GPIO",
- .irq_disable = st_gpio_irq_mask,
- .irq_mask = st_gpio_irq_mask,
- .irq_unmask = st_gpio_irq_unmask,
- .irq_set_type = st_gpio_irq_set_type,
- .flags = IRQCHIP_SKIP_SET_WAKE,
+ .name = "GPIO",
+ .irq_request_resources = st_gpio_irq_request_resources,
+ .irq_disable = st_gpio_irq_mask,
+ .irq_mask = st_gpio_irq_mask,
+ .irq_unmask = st_gpio_irq_unmask,
+ .irq_set_type = st_gpio_irq_set_type,
+ .flags = IRQCHIP_SKIP_SET_WAKE,
};
static int st_gpiolib_register_bank(struct st_pinctrl *info,
--
1.9.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] pinctrl: st: add irq_request_resources callback
2017-02-27 13:49 ` patrice.chotard at st.com
@ 2017-03-14 14:05 ` Linus Walleij
-1 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2017-03-14 14:05 UTC (permalink / raw)
To: Patrice CHOTARD; +Cc: linux-kernel, linux-arm-kernel, Peter Griffin, Lee Jones
On Mon, Feb 27, 2017 at 2:49 PM, <patrice.chotard@st.com> wrote:
> From: Patrice Chotard <patrice.chotard@st.com>
>
> When using GPIO as IRQ source, the GPIO must be configured
> in INPUT. The callback dedicated for this was missing in
> pinctrl-st driver.
>
> This fix the following kernel error when trying to lock a gpio
> as IRQ:
>
> [ 7.521095] gpio gpiochip7: (PIO11): gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ
> [ 7.526018] gpio gpiochip7: (PIO11): unable to lock HW IRQ 6 for IRQ
> [ 7.529405] genirq: Failed to request resources for 0-0053 (irq 81) on irqchip GPIO
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
I see what problem you are trying to solve.
> +static int st_gpio_irq_request_resources(struct irq_data *d)
> +{
> + struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> + int pin = d->hwirq;
> +
> + return st_gpio_direction_input(gc, pin);
> +}
(...)
> + .irq_request_resources = st_gpio_irq_request_resources,
But this is just hiding the problem I'm afraid.
Now thay you override .irq_request_resources()
gpiochip_irq_reqres() will not be called, so then you have
to lock the irq in the driver, with something like:
ret = gpiochip_lock_as_irq(&chip->gc, d->hwirq);
if (ret)
goto out;
You also have to implement the .irq_release_resources()
callback and unlock the IRQ there.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] pinctrl: st: add irq_request_resources callback
@ 2017-03-14 14:05 ` Linus Walleij
0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2017-03-14 14:05 UTC (permalink / raw)
To: linux-arm-kernel
On Mon, Feb 27, 2017 at 2:49 PM, <patrice.chotard@st.com> wrote:
> From: Patrice Chotard <patrice.chotard@st.com>
>
> When using GPIO as IRQ source, the GPIO must be configured
> in INPUT. The callback dedicated for this was missing in
> pinctrl-st driver.
>
> This fix the following kernel error when trying to lock a gpio
> as IRQ:
>
> [ 7.521095] gpio gpiochip7: (PIO11): gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ
> [ 7.526018] gpio gpiochip7: (PIO11): unable to lock HW IRQ 6 for IRQ
> [ 7.529405] genirq: Failed to request resources for 0-0053 (irq 81) on irqchip GPIO
>
> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
I see what problem you are trying to solve.
> +static int st_gpio_irq_request_resources(struct irq_data *d)
> +{
> + struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> + int pin = d->hwirq;
> +
> + return st_gpio_direction_input(gc, pin);
> +}
(...)
> + .irq_request_resources = st_gpio_irq_request_resources,
But this is just hiding the problem I'm afraid.
Now thay you override .irq_request_resources()
gpiochip_irq_reqres() will not be called, so then you have
to lock the irq in the driver, with something like:
ret = gpiochip_lock_as_irq(&chip->gc, d->hwirq);
if (ret)
goto out;
You also have to implement the .irq_release_resources()
callback and unlock the IRQ there.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/1] pinctrl: st: add irq_request_resources callback
2017-03-14 14:05 ` Linus Walleij
@ 2017-03-16 15:39 ` Patrice CHOTARD
-1 siblings, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2017-03-16 15:39 UTC (permalink / raw)
To: Linus Walleij; +Cc: linux-kernel, linux-arm-kernel, Peter Griffin, Lee Jones
On 03/14/2017 03:05 PM, Linus Walleij wrote:
> On Mon, Feb 27, 2017 at 2:49 PM, <patrice.chotard@st.com> wrote:
>
>> From: Patrice Chotard <patrice.chotard@st.com>
>>
>> When using GPIO as IRQ source, the GPIO must be configured
>> in INPUT. The callback dedicated for this was missing in
>> pinctrl-st driver.
>>
>> This fix the following kernel error when trying to lock a gpio
>> as IRQ:
>>
>> [ 7.521095] gpio gpiochip7: (PIO11): gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ
>> [ 7.526018] gpio gpiochip7: (PIO11): unable to lock HW IRQ 6 for IRQ
>> [ 7.529405] genirq: Failed to request resources for 0-0053 (irq 81) on irqchip GPIO
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
>
> I see what problem you are trying to solve.
>
>> +static int st_gpio_irq_request_resources(struct irq_data *d)
>> +{
>> + struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
>> + int pin = d->hwirq;
>> +
>> + return st_gpio_direction_input(gc, pin);
>> +}
> (...)
>> + .irq_request_resources = st_gpio_irq_request_resources,
>
> But this is just hiding the problem I'm afraid.
>
Hi Linus
> Now thay you override .irq_request_resources()
> gpiochip_irq_reqres() will not be called, so then you have
> to lock the irq in the driver, with something like:
>
> ret = gpiochip_lock_as_irq(&chip->gc, d->hwirq);
> if (ret)
> goto out;
>
Ah yes, i didn't noticed that point, thanks for the tips.
> You also have to implement the .irq_release_resources()
> callback and unlock the IRQ there.
In this case, yes the release becomes mandatory.
I will send a v2.
Thanks
Patrice
>
> Yours,
> Linus Walleij
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/1] pinctrl: st: add irq_request_resources callback
@ 2017-03-16 15:39 ` Patrice CHOTARD
0 siblings, 0 replies; 6+ messages in thread
From: Patrice CHOTARD @ 2017-03-16 15:39 UTC (permalink / raw)
To: linux-arm-kernel
On 03/14/2017 03:05 PM, Linus Walleij wrote:
> On Mon, Feb 27, 2017 at 2:49 PM, <patrice.chotard@st.com> wrote:
>
>> From: Patrice Chotard <patrice.chotard@st.com>
>>
>> When using GPIO as IRQ source, the GPIO must be configured
>> in INPUT. The callback dedicated for this was missing in
>> pinctrl-st driver.
>>
>> This fix the following kernel error when trying to lock a gpio
>> as IRQ:
>>
>> [ 7.521095] gpio gpiochip7: (PIO11): gpiochip_lock_as_irq: tried to flag a GPIO set as output for IRQ
>> [ 7.526018] gpio gpiochip7: (PIO11): unable to lock HW IRQ 6 for IRQ
>> [ 7.529405] genirq: Failed to request resources for 0-0053 (irq 81) on irqchip GPIO
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
>
> I see what problem you are trying to solve.
>
>> +static int st_gpio_irq_request_resources(struct irq_data *d)
>> +{
>> + struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
>> + int pin = d->hwirq;
>> +
>> + return st_gpio_direction_input(gc, pin);
>> +}
> (...)
>> + .irq_request_resources = st_gpio_irq_request_resources,
>
> But this is just hiding the problem I'm afraid.
>
Hi Linus
> Now thay you override .irq_request_resources()
> gpiochip_irq_reqres() will not be called, so then you have
> to lock the irq in the driver, with something like:
>
> ret = gpiochip_lock_as_irq(&chip->gc, d->hwirq);
> if (ret)
> goto out;
>
Ah yes, i didn't noticed that point, thanks for the tips.
> You also have to implement the .irq_release_resources()
> callback and unlock the IRQ there.
In this case, yes the release becomes mandatory.
I will send a v2.
Thanks
Patrice
>
> Yours,
> Linus Walleij
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-03-16 15:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-27 13:49 [PATCH 1/1] pinctrl: st: add irq_request_resources callback patrice.chotard
2017-02-27 13:49 ` patrice.chotard at st.com
2017-03-14 14:05 ` Linus Walleij
2017-03-14 14:05 ` Linus Walleij
2017-03-16 15:39 ` Patrice CHOTARD
2017-03-16 15:39 ` Patrice CHOTARD
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.