linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] support i.MX93 truly available GPIO pins
@ 2024-01-11 13:19 Hector Palacios
  2024-01-11 13:19 ` [PATCH 1/2] gpio: vf610: add support to DT 'ngpios' property Hector Palacios
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Hector Palacios @ 2024-01-11 13:19 UTC (permalink / raw)
  To: bartosz.golaszewski, linus.walleij
  Cc: linux-gpio, linux-kernel, haibo.chen, peng.fan, hector.palacios

All four GPIO ports of i.MX93 SoC show 32 pins available, but
not every port has 32 pins.
Add support on the GPIO driver to 'ngpios' property and set
the truly available pins on the SoC device tree.

Hector Palacios (2):
      gpio: vf610: add support to DT 'ngpios' property
      arm64: dts: imx93: specify available 'ngpios' per GPIO port

 arch/arm64/boot/dts/freescale/imx93.dtsi | 4 ++++
 drivers/gpio/gpio-vf610.c                | 7 ++++++-
 2 files changed, 10 insertions(+), 1 deletion(-)


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] gpio: vf610: add support to DT 'ngpios' property
  2024-01-11 13:19 [PATCH 0/2] support i.MX93 truly available GPIO pins Hector Palacios
@ 2024-01-11 13:19 ` Hector Palacios
  2024-01-11 14:22   ` Linus Walleij
  2024-01-11 13:19 ` [PATCH 2/2] arm64: dts: imx93: specify available 'ngpios' per GPIO port Hector Palacios
  2024-01-11 13:53 ` [PATCH 0/2] support i.MX93 truly available GPIO pins Bartosz Golaszewski
  2 siblings, 1 reply; 6+ messages in thread
From: Hector Palacios @ 2024-01-11 13:19 UTC (permalink / raw)
  To: bartosz.golaszewski, linus.walleij
  Cc: linux-gpio, linux-kernel, haibo.chen, peng.fan, hector.palacios

Default to hardcoded VF610_GPIO_PER_PORT (32 pins) but allow optional
generic 'ngpios' property to be specified from the device tree.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
---
 drivers/gpio/gpio-vf610.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c
index 07e5e6323e86..4abdf75e9a0a 100644
--- a/drivers/gpio/gpio-vf610.c
+++ b/drivers/gpio/gpio-vf610.c
@@ -276,6 +276,7 @@ static int vf610_gpio_probe(struct platform_device *pdev)
 	struct vf610_gpio_port *port;
 	struct gpio_chip *gc;
 	struct gpio_irq_chip *girq;
+	u32 ngpios;
 	int i;
 	int ret;
 	bool dual_base;
@@ -353,7 +354,11 @@ static int vf610_gpio_probe(struct platform_device *pdev)
 	gc = &port->gc;
 	gc->parent = dev;
 	gc->label = dev_name(dev);
-	gc->ngpio = VF610_GPIO_PER_PORT;
+	ret = device_property_read_u32(dev, "ngpios", &ngpios);
+	if (ret || ngpios > VF610_GPIO_PER_PORT)
+		gc->ngpio = VF610_GPIO_PER_PORT;
+	else
+		gc->ngpio = (u16)ngpios;
 	gc->base = -1;
 
 	gc->request = gpiochip_generic_request;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] arm64: dts: imx93: specify available 'ngpios' per GPIO port
  2024-01-11 13:19 [PATCH 0/2] support i.MX93 truly available GPIO pins Hector Palacios
  2024-01-11 13:19 ` [PATCH 1/2] gpio: vf610: add support to DT 'ngpios' property Hector Palacios
@ 2024-01-11 13:19 ` Hector Palacios
  2024-01-11 14:26   ` Alexander Stein
  2024-01-11 13:53 ` [PATCH 0/2] support i.MX93 truly available GPIO pins Bartosz Golaszewski
  2 siblings, 1 reply; 6+ messages in thread
From: Hector Palacios @ 2024-01-11 13:19 UTC (permalink / raw)
  To: bartosz.golaszewski, linus.walleij
  Cc: linux-gpio, linux-kernel, haibo.chen, peng.fan, hector.palacios

According to NXP HRM for i.MX93, the following GPIO pins are available:
- GPIO1: 16 pins (0..15)
- GPIO2: 30 pins (0..29)
- GPIO3: 32 pins (0..31)
- GPIO4: 30 pins (0..29)

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
---
 arch/arm64/boot/dts/freescale/imx93.dtsi | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/arm64/boot/dts/freescale/imx93.dtsi b/arch/arm64/boot/dts/freescale/imx93.dtsi
index 34c0540276d1..7eb2cab7c749 100644
--- a/arch/arm64/boot/dts/freescale/imx93.dtsi
+++ b/arch/arm64/boot/dts/freescale/imx93.dtsi
@@ -970,6 +970,7 @@ gpio2: gpio@43810000 {
 				 <&clk IMX93_CLK_GPIO2_GATE>;
 			clock-names = "gpio", "port";
 			gpio-ranges = <&iomuxc 0 4 30>;
+			ngpios = <30>;
 		};
 
 		gpio3: gpio@43820000 {
@@ -986,6 +987,7 @@ gpio3: gpio@43820000 {
 			clock-names = "gpio", "port";
 			gpio-ranges = <&iomuxc 0 84 8>, <&iomuxc 8 66 18>,
 				      <&iomuxc 26 34 2>, <&iomuxc 28 0 4>;
+			ngpios = <32>;
 		};
 
 		gpio4: gpio@43830000 {
@@ -1001,6 +1003,7 @@ gpio4: gpio@43830000 {
 				 <&clk IMX93_CLK_GPIO4_GATE>;
 			clock-names = "gpio", "port";
 			gpio-ranges = <&iomuxc 0 38 28>, <&iomuxc 28 36 2>;
+			ngpios = <30>;
 		};
 
 		gpio1: gpio@47400000 {
@@ -1016,6 +1019,7 @@ gpio1: gpio@47400000 {
 				 <&clk IMX93_CLK_GPIO1_GATE>;
 			clock-names = "gpio", "port";
 			gpio-ranges = <&iomuxc 0 92 16>;
+			ngpios = <16>;
 		};
 
 		ocotp: efuse@47510000 {

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] support i.MX93 truly available GPIO pins
  2024-01-11 13:19 [PATCH 0/2] support i.MX93 truly available GPIO pins Hector Palacios
  2024-01-11 13:19 ` [PATCH 1/2] gpio: vf610: add support to DT 'ngpios' property Hector Palacios
  2024-01-11 13:19 ` [PATCH 2/2] arm64: dts: imx93: specify available 'ngpios' per GPIO port Hector Palacios
@ 2024-01-11 13:53 ` Bartosz Golaszewski
  2 siblings, 0 replies; 6+ messages in thread
From: Bartosz Golaszewski @ 2024-01-11 13:53 UTC (permalink / raw)
  To: Hector Palacios
  Cc: bartosz.golaszewski, linus.walleij, linux-gpio, linux-kernel,
	haibo.chen, peng.fan

On Thu, Jan 11, 2024 at 2:23 PM Hector Palacios
<hector.palacios@digi.com> wrote:
>
> All four GPIO ports of i.MX93 SoC show 32 pins available, but
> not every port has 32 pins.
> Add support on the GPIO driver to 'ngpios' property and set
> the truly available pins on the SoC device tree.
>
> Hector Palacios (2):
>       gpio: vf610: add support to DT 'ngpios' property
>       arm64: dts: imx93: specify available 'ngpios' per GPIO port
>
>  arch/arm64/boot/dts/freescale/imx93.dtsi | 4 ++++
>  drivers/gpio/gpio-vf610.c                | 7 ++++++-
>  2 files changed, 10 insertions(+), 1 deletion(-)
>
>

This is not my email address that comes up when using
get_maintainer.pl, please use it when sending patches.

Bartosz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] gpio: vf610: add support to DT 'ngpios' property
  2024-01-11 13:19 ` [PATCH 1/2] gpio: vf610: add support to DT 'ngpios' property Hector Palacios
@ 2024-01-11 14:22   ` Linus Walleij
  0 siblings, 0 replies; 6+ messages in thread
From: Linus Walleij @ 2024-01-11 14:22 UTC (permalink / raw)
  To: Hector Palacios
  Cc: bartosz.golaszewski, linux-gpio, linux-kernel, haibo.chen,
	peng.fan

On Thu, Jan 11, 2024 at 2:20 PM Hector Palacios
<hector.palacios@digi.com> wrote:

> Default to hardcoded VF610_GPIO_PER_PORT (32 pins) but allow optional
> generic 'ngpios' property to be specified from the device tree.
>
> Signed-off-by: Hector Palacios <hector.palacios@digi.com>

Looks correct to me.
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

NB: this only makes sense when you use GPIOs 0...n where n < 31.

We also have the .valid_mask and .init_valid_mask() callback if
you want to mask out GPIOs in the middle or beginning or so.

Yours,
Linus Walleij

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] arm64: dts: imx93: specify available 'ngpios' per GPIO port
  2024-01-11 13:19 ` [PATCH 2/2] arm64: dts: imx93: specify available 'ngpios' per GPIO port Hector Palacios
@ 2024-01-11 14:26   ` Alexander Stein
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Stein @ 2024-01-11 14:26 UTC (permalink / raw)
  To: bartosz.golaszewski, linus.walleij, Hector Palacios
  Cc: linux-gpio, linux-kernel, haibo.chen, peng.fan, hector.palacios

Am Donnerstag, 11. Januar 2024, 14:19:04 CET schrieb Hector Palacios:
> According to NXP HRM for i.MX93, the following GPIO pins are available:
> - GPIO1: 16 pins (0..15)
> - GPIO2: 30 pins (0..29)
> - GPIO3: 32 pins (0..31)
> - GPIO4: 30 pins (0..29)
> 
> Signed-off-by: Hector Palacios <hector.palacios@digi.com>
> ---
>  arch/arm64/boot/dts/freescale/imx93.dtsi | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/freescale/imx93.dtsi
> b/arch/arm64/boot/dts/freescale/imx93.dtsi index 34c0540276d1..7eb2cab7c749
> 100644
> --- a/arch/arm64/boot/dts/freescale/imx93.dtsi
> +++ b/arch/arm64/boot/dts/freescale/imx93.dtsi
> @@ -970,6 +970,7 @@ gpio2: gpio@43810000 {
>  				 <&clk IMX93_CLK_GPIO2_GATE>;
>  			clock-names = "gpio", "port";
>  			gpio-ranges = <&iomuxc 0 4 30>;
> +			ngpios = <30>;
>  		};
> 
>  		gpio3: gpio@43820000 {
> @@ -986,6 +987,7 @@ gpio3: gpio@43820000 {
>  			clock-names = "gpio", "port";
>  			gpio-ranges = <&iomuxc 0 84 8>, <&iomuxc 8 66 
18>,
>  				      <&iomuxc 26 34 2>, <&iomuxc 28 0 
4>;
> +			ngpios = <32>;
>  		};
> 
>  		gpio4: gpio@43830000 {
> @@ -1001,6 +1003,7 @@ gpio4: gpio@43830000 {
>  				 <&clk IMX93_CLK_GPIO4_GATE>;
>  			clock-names = "gpio", "port";
>  			gpio-ranges = <&iomuxc 0 38 28>, <&iomuxc 28 36 
2>;
> +			ngpios = <30>;
>  		};
> 
>  		gpio1: gpio@47400000 {
> @@ -1016,6 +1019,7 @@ gpio1: gpio@47400000 {
>  				 <&clk IMX93_CLK_GPIO1_GATE>;
>  			clock-names = "gpio", "port";
>  			gpio-ranges = <&iomuxc 0 92 16>;
> +			ngpios = <16>;
>  		};
> 
>  		ocotp: efuse@47510000 {

This leads to warnings upon dtbs_check, e.g.
arch/arm64/boot/dts/freescale/imx93-tqma9352-mba93xxla.dtb: gpio@43810000: 
'ngpios' does not match any of the regexes: '^.+-hog(-[0-9]+)?$', 'pinctrl-
[0-9]+'
  from schema $id: http://devicetree.org/schemas/gpio/gpio-vf610.yaml#

Please address this as well.

Best regards,
Alexander
-- 
TQ-Systems GmbH | Mühlstraße 2, Gut Delling | 82229 Seefeld, Germany
Amtsgericht München, HRB 105018
Geschäftsführer: Detlef Schneider, Rüdiger Stahl, Stefan Schneider
http://www.tq-group.com/



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-11 14:26 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-11 13:19 [PATCH 0/2] support i.MX93 truly available GPIO pins Hector Palacios
2024-01-11 13:19 ` [PATCH 1/2] gpio: vf610: add support to DT 'ngpios' property Hector Palacios
2024-01-11 14:22   ` Linus Walleij
2024-01-11 13:19 ` [PATCH 2/2] arm64: dts: imx93: specify available 'ngpios' per GPIO port Hector Palacios
2024-01-11 14:26   ` Alexander Stein
2024-01-11 13:53 ` [PATCH 0/2] support i.MX93 truly available GPIO pins Bartosz Golaszewski

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).