2024-01-11 13:22:58

by Hector Palacios

[permalink] [raw]
Subject: [PATCH 0/2] support i.MX93 truly available GPIO pins

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



2024-01-11 13:54:09

by Hector Palacios

[permalink] [raw]
Subject: [PATCH 2/2] arm64: dts: imx93: specify available 'ngpios' per GPIO port

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 <[email protected]>
---
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 {

2024-01-11 13:54:20

by Hector Palacios

[permalink] [raw]
Subject: [PATCH 1/2] gpio: vf610: add support to DT 'ngpios' property

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 <[email protected]>
---
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;

2024-01-11 13:56:12

by Bartosz Golaszewski

[permalink] [raw]
Subject: Re: [PATCH 0/2] support i.MX93 truly available GPIO pins

On Thu, Jan 11, 2024 at 2:23 PM Hector Palacios
<[email protected]> 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

2024-01-11 14:26:44

by Alexander Stein

[permalink] [raw]
Subject: Re: [PATCH 2/2] arm64: dts: imx93: specify available 'ngpios' per GPIO port

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 <[email protected]>
> ---
> 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/



2024-01-11 14:30:09

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH 1/2] gpio: vf610: add support to DT 'ngpios' property

On Thu, Jan 11, 2024 at 2:20 PM Hector Palacios
<[email protected]> 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 <[email protected]>

Looks correct to me.
Reviewed-by: Linus Walleij <[email protected]>

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