* [PATCH] gpio: mxc: implement get_direction callback
@ 2023-11-12 19:24 ` Stefan Wahren
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Wahren @ 2023-11-12 19:24 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Shawn Guo,
Sascha Hauer, kernel, Fabio Estevam
Cc: linux-imx, linux-arm-kernel, linux-gpio, Stefan Wahren
gpiolib's gpiod_get_direction() function returns an erro if
.get_direction callback is not defined.
The patch implements the callback for IMX platform which is useful
for debugging and also the kernel docs about struct gpio_chip
recommends it.
Inspired by drivers/gpio/gpio-mxs.c
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
drivers/gpio/gpio-mxc.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 4cb455b2bdee..ad8a4c73d47b 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -418,6 +418,18 @@ static void mxc_update_irq_chained_handler(struct mxc_gpio_port *port, bool enab
}
}
+static int mxc_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
+{
+ struct mxc_gpio_port *port = gpiochip_get_data(gc);
+ u32 dir;
+
+ dir = readl(port->base + GPIO_GDIR);
+ if (dir & BIT(offset))
+ return GPIO_LINE_DIRECTION_OUT;
+
+ return GPIO_LINE_DIRECTION_IN;
+}
+
static int mxc_gpio_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
@@ -490,6 +502,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
port->gc.request = mxc_gpio_request;
port->gc.free = mxc_gpio_free;
port->gc.to_irq = mxc_gpio_to_irq;
+ port->gc.get_direction = mxc_gpio_get_direction;
port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
pdev->id * 32;
--
2.34.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] gpio: mxc: implement get_direction callback
@ 2023-11-12 19:24 ` Stefan Wahren
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Wahren @ 2023-11-12 19:24 UTC (permalink / raw)
To: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Shawn Guo,
Sascha Hauer, kernel, Fabio Estevam
Cc: linux-imx, linux-arm-kernel, linux-gpio, Stefan Wahren
gpiolib's gpiod_get_direction() function returns an erro if
.get_direction callback is not defined.
The patch implements the callback for IMX platform which is useful
for debugging and also the kernel docs about struct gpio_chip
recommends it.
Inspired by drivers/gpio/gpio-mxs.c
Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
---
drivers/gpio/gpio-mxc.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
index 4cb455b2bdee..ad8a4c73d47b 100644
--- a/drivers/gpio/gpio-mxc.c
+++ b/drivers/gpio/gpio-mxc.c
@@ -418,6 +418,18 @@ static void mxc_update_irq_chained_handler(struct mxc_gpio_port *port, bool enab
}
}
+static int mxc_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
+{
+ struct mxc_gpio_port *port = gpiochip_get_data(gc);
+ u32 dir;
+
+ dir = readl(port->base + GPIO_GDIR);
+ if (dir & BIT(offset))
+ return GPIO_LINE_DIRECTION_OUT;
+
+ return GPIO_LINE_DIRECTION_IN;
+}
+
static int mxc_gpio_probe(struct platform_device *pdev)
{
struct device_node *np = pdev->dev.of_node;
@@ -490,6 +502,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
port->gc.request = mxc_gpio_request;
port->gc.free = mxc_gpio_free;
port->gc.to_irq = mxc_gpio_to_irq;
+ port->gc.get_direction = mxc_gpio_get_direction;
port->gc.base = (pdev->id < 0) ? of_alias_get_id(np, "gpio") * 32 :
pdev->id * 32;
--
2.34.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: mxc: implement get_direction callback
2023-11-12 19:24 ` Stefan Wahren
@ 2023-11-13 7:04 ` Sascha Hauer
-1 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2023-11-13 7:04 UTC (permalink / raw)
To: Stefan Wahren
Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Shawn Guo,
kernel, Fabio Estevam, linux-imx, linux-arm-kernel, linux-gpio
Hi Stefan,
On Sun, Nov 12, 2023 at 08:24:28PM +0100, Stefan Wahren wrote:
> gpiolib's gpiod_get_direction() function returns an erro if
> .get_direction callback is not defined.
>
> The patch implements the callback for IMX platform which is useful
> for debugging and also the kernel docs about struct gpio_chip
> recommends it.
>
> Inspired by drivers/gpio/gpio-mxs.c
>
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> ---
> drivers/gpio/gpio-mxc.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
> index 4cb455b2bdee..ad8a4c73d47b 100644
> --- a/drivers/gpio/gpio-mxc.c
> +++ b/drivers/gpio/gpio-mxc.c
> @@ -418,6 +418,18 @@ static void mxc_update_irq_chained_handler(struct mxc_gpio_port *port, bool enab
> }
> }
>
> +static int mxc_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
> +{
> + struct mxc_gpio_port *port = gpiochip_get_data(gc);
> + u32 dir;
> +
> + dir = readl(port->base + GPIO_GDIR);
> + if (dir & BIT(offset))
> + return GPIO_LINE_DIRECTION_OUT;
> +
> + return GPIO_LINE_DIRECTION_IN;
> +}
> +
> static int mxc_gpio_probe(struct platform_device *pdev)
> {
> struct device_node *np = pdev->dev.of_node;
> @@ -490,6 +502,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
> port->gc.request = mxc_gpio_request;
> port->gc.free = mxc_gpio_free;
> port->gc.to_irq = mxc_gpio_to_irq;
> + port->gc.get_direction = mxc_gpio_get_direction;
The driver passes port->base + GPIO_GDIR as *dirout argument to
bgpio_init(). This should result in the .get_direction hook already
being set to bgpio_get_dir() in the bgpio code. Doesn't this work as
expected?
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: mxc: implement get_direction callback
@ 2023-11-13 7:04 ` Sascha Hauer
0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2023-11-13 7:04 UTC (permalink / raw)
To: Stefan Wahren
Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Shawn Guo,
kernel, Fabio Estevam, linux-imx, linux-arm-kernel, linux-gpio
Hi Stefan,
On Sun, Nov 12, 2023 at 08:24:28PM +0100, Stefan Wahren wrote:
> gpiolib's gpiod_get_direction() function returns an erro if
> .get_direction callback is not defined.
>
> The patch implements the callback for IMX platform which is useful
> for debugging and also the kernel docs about struct gpio_chip
> recommends it.
>
> Inspired by drivers/gpio/gpio-mxs.c
>
> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
> ---
> drivers/gpio/gpio-mxc.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
> index 4cb455b2bdee..ad8a4c73d47b 100644
> --- a/drivers/gpio/gpio-mxc.c
> +++ b/drivers/gpio/gpio-mxc.c
> @@ -418,6 +418,18 @@ static void mxc_update_irq_chained_handler(struct mxc_gpio_port *port, bool enab
> }
> }
>
> +static int mxc_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
> +{
> + struct mxc_gpio_port *port = gpiochip_get_data(gc);
> + u32 dir;
> +
> + dir = readl(port->base + GPIO_GDIR);
> + if (dir & BIT(offset))
> + return GPIO_LINE_DIRECTION_OUT;
> +
> + return GPIO_LINE_DIRECTION_IN;
> +}
> +
> static int mxc_gpio_probe(struct platform_device *pdev)
> {
> struct device_node *np = pdev->dev.of_node;
> @@ -490,6 +502,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
> port->gc.request = mxc_gpio_request;
> port->gc.free = mxc_gpio_free;
> port->gc.to_irq = mxc_gpio_to_irq;
> + port->gc.get_direction = mxc_gpio_get_direction;
The driver passes port->base + GPIO_GDIR as *dirout argument to
bgpio_init(). This should result in the .get_direction hook already
being set to bgpio_get_dir() in the bgpio code. Doesn't this work as
expected?
Sascha
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: mxc: implement get_direction callback
2023-11-13 7:04 ` Sascha Hauer
@ 2023-11-13 12:29 ` Stefan Wahren
-1 siblings, 0 replies; 6+ messages in thread
From: Stefan Wahren @ 2023-11-13 12:29 UTC (permalink / raw)
To: Sascha Hauer
Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Shawn Guo,
kernel, Fabio Estevam, linux-imx, linux-arm-kernel, linux-gpio
Hi Sascha,
Am 13.11.23 um 08:04 schrieb Sascha Hauer:
> Hi Stefan,
>
> On Sun, Nov 12, 2023 at 08:24:28PM +0100, Stefan Wahren wrote:
>> gpiolib's gpiod_get_direction() function returns an erro if
>> .get_direction callback is not defined.
>>
>> The patch implements the callback for IMX platform which is useful
>> for debugging and also the kernel docs about struct gpio_chip
>> recommends it.
>>
>> Inspired by drivers/gpio/gpio-mxs.c
>>
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> ---
>> drivers/gpio/gpio-mxc.c | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
>> index 4cb455b2bdee..ad8a4c73d47b 100644
>> --- a/drivers/gpio/gpio-mxc.c
>> +++ b/drivers/gpio/gpio-mxc.c
>> @@ -418,6 +418,18 @@ static void mxc_update_irq_chained_handler(struct mxc_gpio_port *port, bool enab
>> }
>> }
>>
>> +static int mxc_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>> +{
>> + struct mxc_gpio_port *port = gpiochip_get_data(gc);
>> + u32 dir;
>> +
>> + dir = readl(port->base + GPIO_GDIR);
>> + if (dir & BIT(offset))
>> + return GPIO_LINE_DIRECTION_OUT;
>> +
>> + return GPIO_LINE_DIRECTION_IN;
>> +}
>> +
>> static int mxc_gpio_probe(struct platform_device *pdev)
>> {
>> struct device_node *np = pdev->dev.of_node;
>> @@ -490,6 +502,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
>> port->gc.request = mxc_gpio_request;
>> port->gc.free = mxc_gpio_free;
>> port->gc.to_irq = mxc_gpio_to_irq;
>> + port->gc.get_direction = mxc_gpio_get_direction;
> The driver passes port->base + GPIO_GDIR as *dirout argument to
> bgpio_init(). This should result in the .get_direction hook already
> being set to bgpio_get_dir() in the bgpio code. Doesn't this work as
> expected?
oh dear, i missed that. What a shame. Sorry, for the noise and thanks
for pointing out.
Regards
Stefan
>
> Sascha
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] gpio: mxc: implement get_direction callback
@ 2023-11-13 12:29 ` Stefan Wahren
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Wahren @ 2023-11-13 12:29 UTC (permalink / raw)
To: Sascha Hauer
Cc: Linus Walleij, Bartosz Golaszewski, Andy Shevchenko, Shawn Guo,
kernel, Fabio Estevam, linux-imx, linux-arm-kernel, linux-gpio
Hi Sascha,
Am 13.11.23 um 08:04 schrieb Sascha Hauer:
> Hi Stefan,
>
> On Sun, Nov 12, 2023 at 08:24:28PM +0100, Stefan Wahren wrote:
>> gpiolib's gpiod_get_direction() function returns an erro if
>> .get_direction callback is not defined.
>>
>> The patch implements the callback for IMX platform which is useful
>> for debugging and also the kernel docs about struct gpio_chip
>> recommends it.
>>
>> Inspired by drivers/gpio/gpio-mxs.c
>>
>> Signed-off-by: Stefan Wahren <wahrenst@gmx.net>
>> ---
>> drivers/gpio/gpio-mxc.c | 13 +++++++++++++
>> 1 file changed, 13 insertions(+)
>>
>> diff --git a/drivers/gpio/gpio-mxc.c b/drivers/gpio/gpio-mxc.c
>> index 4cb455b2bdee..ad8a4c73d47b 100644
>> --- a/drivers/gpio/gpio-mxc.c
>> +++ b/drivers/gpio/gpio-mxc.c
>> @@ -418,6 +418,18 @@ static void mxc_update_irq_chained_handler(struct mxc_gpio_port *port, bool enab
>> }
>> }
>>
>> +static int mxc_gpio_get_direction(struct gpio_chip *gc, unsigned int offset)
>> +{
>> + struct mxc_gpio_port *port = gpiochip_get_data(gc);
>> + u32 dir;
>> +
>> + dir = readl(port->base + GPIO_GDIR);
>> + if (dir & BIT(offset))
>> + return GPIO_LINE_DIRECTION_OUT;
>> +
>> + return GPIO_LINE_DIRECTION_IN;
>> +}
>> +
>> static int mxc_gpio_probe(struct platform_device *pdev)
>> {
>> struct device_node *np = pdev->dev.of_node;
>> @@ -490,6 +502,7 @@ static int mxc_gpio_probe(struct platform_device *pdev)
>> port->gc.request = mxc_gpio_request;
>> port->gc.free = mxc_gpio_free;
>> port->gc.to_irq = mxc_gpio_to_irq;
>> + port->gc.get_direction = mxc_gpio_get_direction;
> The driver passes port->base + GPIO_GDIR as *dirout argument to
> bgpio_init(). This should result in the .get_direction hook already
> being set to bgpio_get_dir() in the bgpio code. Doesn't this work as
> expected?
oh dear, i missed that. What a shame. Sorry, for the noise and thanks
for pointing out.
Regards
Stefan
>
> Sascha
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2023-11-13 12:30 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-12 19:24 [PATCH] gpio: mxc: implement get_direction callback Stefan Wahren
2023-11-12 19:24 ` Stefan Wahren
2023-11-13 7:04 ` Sascha Hauer
2023-11-13 7:04 ` Sascha Hauer
2023-11-13 12:29 ` Stefan Wahren
2023-11-13 12:29 ` Stefan Wahren
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.