Skip to contentSkip to conversation

gpio: Introduce gpio-delay driver and enable it on Kria

PATCH Applied Michal Simek 3 participants 10 messages Feb 3 – Feb 12

Subsystems (3)
lore
Share & tools
lore

Michal Simek

author maintainer
#0 lore raw

v2 cover gpio: Introduce gpio-delay driver and enable it on Kria

Hi,

we need to wait more time for getting USB hub out of reset to be able to do initialiation over i2c that's why use gpio-delay driver instead of changing waiting time in usb hub driver. Waiting time depends on gpio wiring on the board which is in some of our case going via SLG programmable device.

Thanks,
Michal

Changes in v2:
- Check return value from dm_gpio_set_value()
- Do not use GPIOD_IS_OUT when requesting gpio
- fix commit message

Michal Simek (3):
gpio: Add GPIO delay driver
xilinx: Enable GPIO delay driver on Kria platforms
arm64: zynqmp: Wire gpio-delay driver for USB hub reset

 arch/arm/dts/zynqmp-sck-kd-g-revA.dtso |  13 ++-
 arch/arm/dts/zynqmp-sck-kr-g-revA.dtso |  16 ++-
 arch/arm/dts/zynqmp-sck-kr-g-revB.dtso |  16 ++-
 arch/arm/dts/zynqmp-sck-kv-g-revA.dtso |  13 ++-
 arch/arm/dts/zynqmp-sck-kv-g-revB.dtso |  11 +-
 configs/xilinx_zynqmp_kria_defconfig   |   1 +
 drivers/gpio/Kconfig                   |   8 ++
 drivers/gpio/Makefile                  |   1 +
 drivers/gpio/gpio-delay.c              | 139 +++++++++++++++++++++++++
 9 files changed, 202 insertions(+), 16 deletions(-)
 create mode 100644 drivers/gpio/gpio-delay.c
Signature · 3 lines
2.43.0

base-commit: bc3e36d5bbfe1cc3cd3bf8b0e5ddcc261fbfa14d
author maintainer
#1 lore raw

PATCH v2 1/3 gpio: Add GPIO delay driver

Add a GPIO controller driver that provides configurable delays when setting GPIO output values. This is useful for hardware that requires specific timing delays during power sequencing or GPIO state changes.

The driver wraps underlying GPIO controllers and adds programmable ramp-up and ramp-down delays specified in microseconds through the device tree. Each GPIO can have independent delay timings.

Device tree binding matches Linux.

---

Changes in v2:
- Check return value from dm_gpio_set_value()
- Do not use GPIOD_IS_OUT when requesting gpio

 drivers/gpio/Kconfig      |   8 +++
 drivers/gpio/Makefile     |   1 +
 drivers/gpio/gpio-delay.c | 139 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 148 insertions(+)
 create mode 100644 drivers/gpio/gpio-delay.c
drivers/gpio/Kconfig +8 -0
index 60c5c54688e6..f69919abc05b 100644
@@ -1,3 +1,11 @@
+config GPIO_DELAY
+	bool "GPIO delay driver"
+	depends on DM_GPIO
+	help
+	  Enable the GPIO delay driver.
+	  This driver allows wrapping another GPIO controller and inserting
+	  ramp-up/ramp-down delays on output changes, as described in the
+	  Linux gpio-delay binding.
 #
 # GPIO infrastructure and drivers
 #
drivers/gpio/Makefile +1 -0
index 910478c0c7a9..fec258f59f52 100644
@@ -21,6 +21,7 @@ obj-$(CONFIG_ATMEL_PIO4)	+= atmel_pio4.o
 obj-$(CONFIG_BCM6345_GPIO)	+= bcm6345_gpio.o
 obj-$(CONFIG_CORTINA_GPIO)      += cortina_gpio.o
 obj-$(CONFIG_FXL6408_GPIO)	+= gpio-fxl6408.o
+obj-$(CONFIG_GPIO_DELAY)	+= gpio-delay.o
 obj-$(CONFIG_INTEL_GPIO)	+= intel_gpio.o
 obj-$(CONFIG_INTEL_ICH6_GPIO)	+= intel_ich6_gpio.o
 obj-$(CONFIG_INTEL_BROADWELL_GPIO)	+= intel_broadwell_gpio.o
drivers/gpio/gpio-delay.c new file +139 -0

139 lines not on this page · raw message

Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH v2 2/3 xilinx: Enable GPIO delay driver on Kria platforms

In reply to Michal Simek

GPIO delay driver is necessary to use to extend delay times for USB hubs available on the Kria platforms.

---

(no changes since v1)

 configs/xilinx_zynqmp_kria_defconfig | 1 +
 1 file changed, 1 insertion(+)
configs/xilinx_zynqmp_kria_defconfig +1 -0
index 8ad05e371892..1e0728fa4f3f 100644
@@ -136,6 +136,7 @@ CONFIG_XILINX_DPDMA=y
 CONFIG_ARM_FFA_TRANSPORT=y
 CONFIG_FPGA_XILINX=y
 CONFIG_FPGA_ZYNQMPPL=y
+CONFIG_GPIO_DELAY=y
 CONFIG_GPIO_HOG=y
 CONFIG_XILINX_GPIO=y
 CONFIG_DM_PCA953X=y
Signature · 1 line
2.43.0
author maintainer
#3 lore raw

PATCH v2 3/3 arm64: zynqmp: Wire gpio-delay driver for USB hub reset

In reply to Michal Simek

USB hub requires longer delay to get out of the reset to work properly that's why use gpio-delay to ensure enough waiting time.

---

Changes in v2:
- fix commit message

 arch/arm/dts/zynqmp-sck-kd-g-revA.dtso | 13 ++++++++++---
 arch/arm/dts/zynqmp-sck-kr-g-revA.dtso | 16 ++++++++++++----
 arch/arm/dts/zynqmp-sck-kr-g-revB.dtso | 16 ++++++++++++----
 arch/arm/dts/zynqmp-sck-kv-g-revA.dtso | 13 ++++++++++---
 arch/arm/dts/zynqmp-sck-kv-g-revB.dtso | 11 +++++++++--
 5 files changed, 53 insertions(+), 16 deletions(-)
arch/arm/dts/zynqmp-sck-kd-g-revA.dtso +10 -3
index 832dc5ab2458..8342479b108a 100644
@@ -3,7 +3,7 @@
  * dts file for KD240 revA Carrier Card
  *
  * Copyright (C) 2021 - 2022, Xilinx, Inc.
- * Copyright (C) 2022 - 2023, Advanced Micro Devices, Inc.
+ * Copyright (C) 2022 - 2026, Advanced Micro Devices, Inc.
  *
  * Michal Simek <[email protected]>
  */
@@ -43,6 +43,13 @@
 		#clock-cells = <0>;
 		clock-frequency = <25000000>;
 	};
+
+	slg_delay: enable-delay {
+		compatible = "gpio-delay";
+		#gpio-cells = <3>;
+		gpio-controller;
+		gpios = <&slg7xl45106 3 GPIO_ACTIVE_LOW>;
+	};
 };
 
 &can0 {
@@ -116,7 +123,7 @@
 		reg = <1>;
 		peer-hub = <&hub_3_0>;
 		i2c-bus = <&hub>;
-		reset-gpios = <&slg7xl45106 3 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 0 10000 10000>;
 	};
 
 	/* 3.0 hub on port 2 */
@@ -125,7 +132,7 @@
 		reg = <2>;
 		peer-hub = <&hub_2_0>;
 		i2c-bus = <&hub>;
-		reset-gpios = <&slg7xl45106 3 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 0 10000 10000>;
 	};
 };
 
arch/arm/dts/zynqmp-sck-kr-g-revA.dtso +12 -4
index 532f6bf92bc5..db042ffb4f36 100644
@@ -77,6 +77,14 @@
 			};
 		};
 	};
+
+	slg_delay: enable-delay {
+		compatible = "gpio-delay";
+		#gpio-cells = <3>;
+		gpio-controller;
+		gpios = <&slg7xl45106 3 GPIO_ACTIVE_LOW>,
+			<&slg7xl45106 4 GPIO_ACTIVE_LOW>;
+	};
 };
 
 &i2c1 { /* I2C_SCK C26/C27 - MIO from SOM */
@@ -187,7 +195,7 @@
 		reg = <1>;
 		peer-hub = <&hub_3_0>;
 		i2c-bus = <&hub_1>;
-		reset-gpios = <&slg7xl45106 3 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 0 10000 10000>;
 	};
 
 	/* 3.0 hub on port 2 */
@@ -196,7 +204,7 @@
 		reg = <2>;
 		peer-hub = <&hub_2_0>;
 		i2c-bus = <&hub_1>;
-		reset-gpios = <&slg7xl45106 3 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 0 10000 10000>;
 	};
 };
 
@@ -224,7 +232,7 @@
 		reg = <1>;
 		peer-hub = <&hub1_3_0>;
 		i2c-bus = <&hub_2>;
-		reset-gpios = <&slg7xl45106 4 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 1 10000 10000>;
 	};
 
 	/* 3.0 hub on port 2 */
@@ -233,7 +241,7 @@
 		reg = <2>;
 		peer-hub = <&hub1_2_0>;
 		i2c-bus = <&hub_2>;
-		reset-gpios = <&slg7xl45106 4 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 1 10000 10000>;
 	};
 };
 
arch/arm/dts/zynqmp-sck-kr-g-revB.dtso +12 -4
index 458d79e81192..e3567d0abfe0 100644
@@ -78,6 +78,14 @@
 			};
 		};
 	};
+
+	slg_delay: enable-delay {
+		compatible = "gpio-delay";
+		#gpio-cells = <3>;
+		gpio-controller;
+		gpios = <&slg7xl45106 3 GPIO_ACTIVE_LOW>,
+			<&slg7xl45106 4 GPIO_ACTIVE_LOW>;
+	};
 };
 
 &i2c1 { /* I2C_SCK C26/C27 - MIO from SOM */
@@ -188,7 +196,7 @@
 		reg = <1>;
 		peer-hub = <&hub_3_0>;
 		i2c-bus = <&hub_1>;
-		reset-gpios = <&slg7xl45106 3 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 0 10000 10000>;
 	};
 
 	/* 3.0 hub on port 2 */
@@ -197,7 +205,7 @@
 		reg = <2>;
 		peer-hub = <&hub_2_0>;
 		i2c-bus = <&hub_1>;
-		reset-gpios = <&slg7xl45106 3 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 0 10000 10000>;
 	};
 };
 
@@ -225,7 +233,7 @@
 		reg = <1>;
 		peer-hub = <&hub1_3_0>;
 		i2c-bus = <&hub_2>;
-		reset-gpios = <&slg7xl45106 4 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 1 10000 10000>;
 	};
 
 	/* 3.0 hub on port 2 */
@@ -234,7 +242,7 @@
 		reg = <2>;
 		peer-hub = <&hub1_2_0>;
 		i2c-bus = <&hub_2>;
-		reset-gpios = <&slg7xl45106 4 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 1 10000 10000>;
 	};
 };
 
arch/arm/dts/zynqmp-sck-kv-g-revA.dtso +10 -3
index e7417af8ae01..f93c7460a552 100644
@@ -3,7 +3,7 @@
  * dts file for KV260 revA Carrier Card
  *
  * (C) Copyright 2020 - 2022, Xilinx, Inc.
- * (C) Copyright 2022 - 2025, Advanced Micro Devices, Inc.
+ * (C) Copyright 2022 - 2026, Advanced Micro Devices, Inc.
  *
  * SD level shifter:
  * "A" - A01 board un-modified (NXP)
@@ -78,6 +78,13 @@
 			};
 		};
 	};
+
+	slg_delay: enable-delay {
+		compatible = "gpio-delay";
+		#gpio-cells = <3>;
+		gpio-controller;
+		gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
+	};
 };
 
 &i2c1 { /* I2C_SCK C23/C24 - MIO from SOM */
@@ -161,7 +168,7 @@
 		compatible = "usb424,2744";
 		reg = <1>;
 		peer-hub = <&hub_3_0>;
-		reset-gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 0 10000 10000>;
 	};
 
 	/* 3.0 hub on port 2 */
@@ -169,7 +176,7 @@
 		compatible = "usb424,5744";
 		reg = <2>;
 		peer-hub = <&hub_2_0>;
-		reset-gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 0 10000 10000>;
 	};
 };
 
arch/arm/dts/zynqmp-sck-kv-g-revB.dtso +9 -2
index 7a05180e58b4..70de6933600e 100644
@@ -74,6 +74,13 @@
 			};
 		};
 	};
+
+	slg_delay: enable-delay {
+		compatible = "gpio-delay";
+		#gpio-cells = <3>;
+		gpio-controller;
+		gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
+	};
 };
 
 &i2c1 { /* I2C_SCK C23/C24 - MIO from SOM */
@@ -148,7 +155,7 @@
 		reg = <1>;
 		peer-hub = <&hub_3_0>;
 		i2c-bus = <&hub>;
-		reset-gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 0 10000 10000>;
 	};
 
 	/* 3.0 hub on port 2 */
@@ -157,7 +164,7 @@
 		reg = <2>;
 		peer-hub = <&hub_2_0>;
 		i2c-bus = <&hub>;
-		reset-gpios = <&gpio 44 GPIO_ACTIVE_LOW>;
+		reset-gpios = <&slg_delay 0 10000 10000>;
 	};
 };
 
Signature · 1 line
2.43.0
#4 lore raw
In reply to Michal Simek
Quoted 6 lines · Michal Simek

Hi,

we need to wait more time for getting USB hub out of reset to be able to do initialiation over i2c that's why use gpio-delay driver instead of changing waiting time in usb hub driver. Waiting time depends on gpio wiring on the board which is in some of our case going via SLG programmable device.

Can you not use some regulator or make the reset assert/deassert time configurable via DT property ?

author maintainer
#5 lore raw
Quoted 8 lines · Marek Vasut
Quoted 6 lines · Michal Simek

Hi,

we need to wait more time for getting USB hub out of reset to be able to do initialiation over i2c that's why use gpio-delay driver instead of changing waiting time in usb hub driver. Waiting time depends on gpio wiring on the board which is in some of our case going via SLG programmable device.

Can you not use some regulator or make the reset assert/deassert time configurable via DT property ?

Sorry not following. delay is configurable via DT now - the patch 3/3 for example. This avoid a need to change usb5744 driver to wait longer time which is what we discussed in past.

M

#6 lore raw
Quoted 6 lines · Michal Simek
Quoted 3 lines · Marek Vasut
Quoted 2 lines · Michal Simek

Hi,

Quoted 7 lines
Quoted 5 lines
Quoted 4 lines

we need to wait more time for getting USB hub out of reset to be able to do initialiation over i2c that's why use gpio-delay driver instead of changing waiting time in usb hub driver. Waiting time depends on gpio wiring on the board which is in some of our case going via SLG programmable device.

Can you not use some regulator or make the reset assert/deassert time configurable via DT property ?

Sorry not following. delay is configurable via DT now - the patch 3/3 for example.

3/3 never arrived in my mailbox, I think I was CCed only on 0 and 2 .

Quoted 1 line

This avoid a need to change usb5744 driver to wait longer time which is what we discussed in past.

If the delay is configurable via DT, why would the driver have to be changed ?

#7 lore raw

Hi Marek,

Quoted 11 lines · Marek Vasut
Quoted 10 lines · Michal Simek
Quoted 7 lines · Marek Vasut
Quoted 6 lines · Michal Simek

Hi,

we need to wait more time for getting USB hub out of reset to be able to do initialiation over i2c that's why use gpio-delay driver instead of changing waiting time in usb hub driver. Waiting time depends on gpio wiring on the board which is in some of our case going via SLG programmable device.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

Can you not use some regulator or make the reset assert/deassert time configurable via DT property ?

Sorry not following. delay is configurable via DT now - the patch 3/3 for example.

3/3 never arrived in my mailbox, I think I was CCed only on 0 and 2 .

Quoted 1 line

This avoid a need to change usb5744 driver to wait longer time which is what we discussed in past.

If the delay is configurable via DT, why would the driver have to be changed ?

Delay is configurable via DT for the GPIO delay device. The delay is NOT configurable via DT for the USB onboard hub device. Because of the latter, the former is added as GPIO controller for adding delay to the latter driver's reset line.

#8 lore raw
Quoted 16 lines · Quentin Schulz

Hi Marek,

Quoted 13 lines · Marek Vasut
Quoted 12 lines · Michal Simek
Quoted 8 lines · Marek Vasut
Quoted 6 lines · Michal Simek

Hi,

we need to wait more time for getting USB hub out of reset to be able to do initialiation over i2c that's why use gpio-delay driver instead of changing waiting time in usb hub driver. Waiting time depends on gpio wiring on the board which is in some of our case going via SLG programmable device.

Can you not use some regulator or make the reset assert/deassert time configurable via DT property ?

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Sorry not following. delay is configurable via DT now - the patch 3/3 for example.

3/3 never arrived in my mailbox, I think I was CCed only on 0 and 2 .

Quoted 1 line

This avoid a need to change usb5744 driver to wait longer time which is what we discussed in past.

If the delay is configurable via DT, why would the driver have to be changed ?

Delay is configurable via DT for the GPIO delay device. The delay is NOT configurable via DT for the USB onboard hub device. Because of the latter, the former is added as GPIO controller for adding delay to the latter driver's reset line.

Oh, I see, thank you for the clarification.

author maintainer Applied
#9 lore raw
In reply to Michal Simek
Quoted 30 lines · Michal Simek

Hi,

we need to wait more time for getting USB hub out of reset to be able to do initialiation over i2c that's why use gpio-delay driver instead of changing waiting time in usb hub driver. Waiting time depends on gpio wiring on the board which is in some of our case going via SLG programmable device.

Thanks,
Michal

Changes in v2:
- Check return value from dm_gpio_set_value()
- Do not use GPIOD_IS_OUT when requesting gpio
- fix commit message

Michal Simek (3):
gpio: Add GPIO delay driver
xilinx: Enable GPIO delay driver on Kria platforms
arm64: zynqmp: Wire gpio-delay driver for USB hub reset

  arch/arm/dts/zynqmp-sck-kd-g-revA.dtso |  13 ++-
  arch/arm/dts/zynqmp-sck-kr-g-revA.dtso |  16 ++-
  arch/arm/dts/zynqmp-sck-kr-g-revB.dtso |  16 ++-
  arch/arm/dts/zynqmp-sck-kv-g-revA.dtso |  13 ++-
  arch/arm/dts/zynqmp-sck-kv-g-revB.dtso |  11 +-
  configs/xilinx_zynqmp_kria_defconfig   |   1 +
  drivers/gpio/Kconfig                   |   8 ++
  drivers/gpio/Makefile                  |   1 +
  drivers/gpio/gpio-delay.c              | 139 +++++++++++++++++++++++++
  9 files changed, 202 insertions(+), 16 deletions(-)
Quoted 2 lines

create mode 100644 drivers/gpio/gpio-delay.c

Applied.
M