[linux-yocto][v6.1/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g][PATCH] gpio: s32: set direction of eirq pin as input

2024-06-11 Thread quanyang.wang via lists.yoctoproject.org
From: Quanyang Wang 

When an gpio pin is requested as "eirq" in dts file as following:

pmic {
...
interrupt-parent = <&gpio>;
interrupts = <35 IRQ_TYPE_EDGE_FALLING>;
...
};

the direction of this pin should be set as "input" by calling
siul2_gpio_dir_in. Unfortunately, the function siul2_gpio_dir_in
is using mutex_lock/unlock(), so it can't be called in irq_unmask
or irq_set_type. The irq_chip::irq_request_resources callback isn't
running under the atomic context, it's safe to call siul2_gpio_dir_in.

Signed-off-by: Quanyang Wang 
---
Hi Bruce,
Would you please help merge this patch to the branches:
v6.1/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g
v6.1/standard/nxp-sdk-5.15/nxp-s32g
Thanks,
Quanyang
---
 drivers/gpio/gpio-siul2-s32cc.c | 19 ++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-siul2-s32cc.c b/drivers/gpio/gpio-siul2-s32cc.c
index aed63d3a0fdbf..041c182374297 100644
--- a/drivers/gpio/gpio-siul2-s32cc.c
+++ b/drivers/gpio/gpio-siul2-s32cc.c
@@ -401,6 +401,22 @@ static int siul2_gpio_irq_set_type(struct irq_data *d, 
unsigned int type)
return ret;
 }
 
+static int suil2_gpio_irq_reqres(struct irq_data *d)
+{
+   struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+   irq_hw_number_t gpio = irqd_to_hwirq(d);
+   int ret;
+
+   ret = siul2_gpio_dir_in(gc, gpio);
+   if (ret) {
+   dev_err(gc->parent, "Failed to configure GPIO %lu as input\n",
+   gpio);
+   return ret;
+   }
+
+   return gpiochip_reqres_irq(gc, d->hwirq);
+}
+
 static irqreturn_t siul2_gpio_irq_handler(int irq, void *data)
 {
struct siul2_gpio_dev *gpio_dev = data;
@@ -1116,8 +1132,9 @@ static const struct irq_chip siul2_irqchip = {
.irq_mask   = siul2_gpio_irq_mask,
.irq_unmask = siul2_gpio_irq_unmask,
.irq_set_type   = siul2_gpio_irq_set_type,
+   .irq_request_resources  = suil2_gpio_irq_reqres,
+   .irq_release_resources  = gpiochip_irq_relres,
.flags = IRQCHIP_IMMUTABLE,
-   GPIOCHIP_IRQ_RESOURCE_HELPERS,
 };
 
 static int siul2_gpio_probe(struct platform_device *pdev)
-- 
2.36.1


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#14022): 
https://lists.yoctoproject.org/g/linux-yocto/message/14022
Mute This Topic: https://lists.yoctoproject.org/mt/106609417/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-



Re: [linux-yocto][v6.1/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g][PATCH] gpio: s32: set direction of eirq pin as input

2024-06-11 Thread Bruce Ashfield
In message: 
[linux-yocto][v6.1/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g][PATCH] gpio: s32: 
set direction of eirq pin as input
on 11/06/2024 quanyang.w...@windriver.com wrote:

> From: Quanyang Wang 
> 
> When an gpio pin is requested as "eirq" in dts file as following:
> 
> pmic {
>   ...
>   interrupt-parent = <&gpio>;
>   interrupts = <35 IRQ_TYPE_EDGE_FALLING>;
>   ...
> };
> 
> the direction of this pin should be set as "input" by calling
> siul2_gpio_dir_in. Unfortunately, the function siul2_gpio_dir_in
> is using mutex_lock/unlock(), so it can't be called in irq_unmask
> or irq_set_type. The irq_chip::irq_request_resources callback isn't
> running under the atomic context, it's safe to call siul2_gpio_dir_in.
> 
> Signed-off-by: Quanyang Wang 
> ---
> Hi Bruce,
> Would you please help merge this patch to the branches:
>   v6.1/standard/preempt-rt/nxp-sdk-5.15/nxp-s32g
>   v6.1/standard/nxp-sdk-5.15/nxp-s32g

merged.

Bruce

> Thanks,
> Quanyang
> ---
>  drivers/gpio/gpio-siul2-s32cc.c | 19 ++-
>  1 file changed, 18 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpio/gpio-siul2-s32cc.c b/drivers/gpio/gpio-siul2-s32cc.c
> index aed63d3a0fdbf..041c182374297 100644
> --- a/drivers/gpio/gpio-siul2-s32cc.c
> +++ b/drivers/gpio/gpio-siul2-s32cc.c
> @@ -401,6 +401,22 @@ static int siul2_gpio_irq_set_type(struct irq_data *d, 
> unsigned int type)
>   return ret;
>  }
>  
> +static int suil2_gpio_irq_reqres(struct irq_data *d)
> +{
> + struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
> + irq_hw_number_t gpio = irqd_to_hwirq(d);
> + int ret;
> +
> + ret = siul2_gpio_dir_in(gc, gpio);
> + if (ret) {
> + dev_err(gc->parent, "Failed to configure GPIO %lu as input\n",
> + gpio);
> + return ret;
> + }
> +
> + return gpiochip_reqres_irq(gc, d->hwirq);
> +}
> +
>  static irqreturn_t siul2_gpio_irq_handler(int irq, void *data)
>  {
>   struct siul2_gpio_dev *gpio_dev = data;
> @@ -1116,8 +1132,9 @@ static const struct irq_chip siul2_irqchip = {
>   .irq_mask   = siul2_gpio_irq_mask,
>   .irq_unmask = siul2_gpio_irq_unmask,
>   .irq_set_type   = siul2_gpio_irq_set_type,
> + .irq_request_resources  = suil2_gpio_irq_reqres,
> + .irq_release_resources  = gpiochip_irq_relres,
>   .flags = IRQCHIP_IMMUTABLE,
> - GPIOCHIP_IRQ_RESOURCE_HELPERS,
>  };
>  
>  static int siul2_gpio_probe(struct platform_device *pdev)
> -- 
> 2.36.1
> 

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#14027): 
https://lists.yoctoproject.org/g/linux-yocto/message/14027
Mute This Topic: https://lists.yoctoproject.org/mt/106609417/21656
Group Owner: linux-yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/linux-yocto/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-