gpio: Introduce gpio-delay driver and enable it on Kria
Subsystems (3)
Michal Simek
maintainercover 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
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 | 133 +++++++++++++++++++++++++ 9 files changed, 196 insertions(+), 16 deletions(-) create mode 100644 drivers/gpio/gpio-delay.c
Signature · 4 lines
2.43.0 base-commit: 1b94b48043bd77fcb837704cba4385e14a4a694e branch: debian-sent3
Michal Simek
maintainerPATCH 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.
---
drivers/gpio/Kconfig | 8 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-delay.c | 133 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+) create mode 100644 drivers/gpio/gpio-delay.c
drivers/gpio/Kconfig +8 -0
@@ -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
@@ -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 +133 -0
133 lines not on this page · raw message
Signature · 1 line
2.43.0
Michal Simek
maintainerPATCH 2/3 xilinx: Enable GPIO delay driver on Kria platforms
In reply to Michal SimekGPIO delay driver is necessary to use to extend delay times for USB hubs available on the Kria platforms.
---
configs/xilinx_zynqmp_kria_defconfig | 1 + 1 file changed, 1 insertion(+)
configs/xilinx_zynqmp_kria_defconfig +1 -0
@@ -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
Michal Simek
maintainerPATCH 3/3 arm64: zynqmp: Wire gpio-delay driver for USB hub reset
In reply to Michal SimekUSB hub requires longer delay to get out of the reason to work properly that's why use gpio-delay to ensure enough waiting time.
---
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
RE: [PATCH 3/3] arm64: zynqmp: Wire gpio-delay driver for USB hub reset
[AMD Official Use Only - AMD Internal Distribution Only]
Quoted 9 lines
-----Original Message-----
From: Michal Simek <[email protected]>
Sent: Thursday, January 22, 2026 6:21 PM
To: [email protected]; git (AMD-Xilinx) <[email protected]>
Cc: Naroju, Nithish Kumar <[email protected]>; Visavalia, Rohit <[email protected]>; Tom Rini <[email protected]>
Subject: [PATCH 3/3] arm64: zynqmp: Wire gpio-delay driver for USB hub resetUSB hub requires longer delay to get out of the reason to work properly that's why
Nit - reason -> reset
Quoted 3 lines
use gpio-delay to ensure enough waiting time.
Signed-off-by Michal Simek <[email protected]>
Quoted 248 lines
---
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- renamed from arch/arm/dts/zynqmp-sck-kd-g-revA.dtso +0
-0revA.dtso
index832dc5ab2458..8342479b108a100644arch/arm/dts/zynqmp-sck-kd-g-revA.dtso +10
-3@@ -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- renamed from arch/arm/dts/zynqmp-sck-kr-g-revA.dtso +0
-0revA.dtso
index532f6bf92bc5..db042ffb4f36100644arch/arm/dts/zynqmp-sck-kr-g-revA.dtso +8
-0@@ -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>;arch/arm/dts/zynqmp-sck-kr-g-revA.dtso +4
-4- 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- renamed from arch/arm/dts/zynqmp-sck-kr-g-revB.dtso +0
-0revB.dtso
index458d79e81192..e3567d0abfe0100644arch/arm/dts/zynqmp-sck-kr-g-revB.dtso +8
-0@@ -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>;arch/arm/dts/zynqmp-sck-kr-g-revB.dtso +4
-4- 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- renamed from arch/arm/dts/zynqmp-sck-kv-g-revA.dtso +0
-0revA.dtso
indexe7417af8ae01..f93c7460a552100644arch/arm/dts/zynqmp-sck-kv-g-revA.dtso +8
-1@@ -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>;arch/arm/dts/zynqmp-sck-kv-g-revA.dtso +2
-2- 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- renamed from arch/arm/dts/zynqmp-sck-kv-g-revB.dtso +0
-0revB.dtso
index7a05180e58b4..70de6933600e100644arch/arm/dts/zynqmp-sck-kv-g-revB.dtso +7
-0@@ -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>;arch/arm/dts/zynqmp-sck-kv-g-revB.dtso +2
-3- 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>; }; }; --2.43.0
Re: [PATCH 1/3] gpio: Add GPIO delay driver
In reply to Michal SimekHi Michal,
Quoted 24 lines · Michal Simek
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.
Signed-off-by Michal Simek <[email protected]>---
drivers/gpio/Kconfig | 8 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-delay.c | 133 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+)create mode 100644
drivers/gpio/gpio-delay.cdrivers/gpio/Kconfig +0
-0
drivers/gpio/Kconfig line 8
Quoted 8 lines
drivers/gpio/Kconfig +8
-0@@ -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.
Add an entry for SPL?
Quoted 21 lines
drivers/gpio/Kconfig +0
-0# # GPIO infrastructure and drivers #drivers/gpio/Makefile +0
-0@@ -21,6 +21,7 @@ obj-$(CONFIG_ATMEL_PIO4) += atmel_pio4.oobj-$(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.odrivers/gpio/gpio-delay.c new file +0
-0
drivers/gpio/gpio-delay.c line 3
Quoted 3 lines
drivers/gpio/gpio-delay.c new file +3
-0@@ -0,0 +1,133 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2025 - 2026, Advanced Micro Devices, Inc.
Drop 2025?
Quoted 27 lines
drivers/gpio/gpio-delay.c new file +27
-0+* +* Michal Simek <[email protected]> +*/ + +#include <dm.h> +#include <dm/device_compat.h> +#include <dm/devres.h> +#include <asm/gpio.h> +#include <linux/delay.h> + +struct gpio_delay_desc { +struct gpio_desc real_gpio; +u32 ramp_up_us; +u32 ramp_down_us; +}; + +struct gpio_delay_priv { +struct gpio_delay_desc *descs; +}; + +static int gpio_delay_direction_input (struct udevice *dev,unsigned int offset) +{ +return -ENOSYS ; +} + +static int gpio_delay_get_value (struct udevice *dev,unsigned int offset) +{
drivers/gpio/gpio-delay.c line 40
Quoted 10 lines
drivers/gpio/gpio-delay.c new file +10
-0+return -ENOSYS ; +} + +static int gpio_delay_set_value (struct udevice *dev,unsigned int offset, +int value) +{ +struct gpio_delay_priv *priv =dev_get_priv (dev); +struct gpio_delay_desc *desc = &priv->descs[offset]; +int ret =dm_gpio_set_value (&desc->real_gpio, value); +u32 wait;
Check return value.
if (ret) {
dev_err(dev, "Failed to set gpio %d\n", offset);
}Quoted 63 lines
drivers/gpio/gpio-delay.c new file +63
-0+ +dev_dbg (dev,"gpio %d set to %d\n" , offset, value); + +if (value) + wait = desc->ramp_up_us; +else + wait = desc->ramp_down_us; + +udelay (wait); + +dev_dbg (dev,"waited for %d us\n" , wait); + +return ret; +} + +static int gpio_delay_direction_output (struct udevice *dev,unsigned int offset, +int value) +{ +return gpio_delay_set_value (dev, offset, value); +} + +static int gpio_delay_xlate (struct udevice *dev,struct gpio_desc *desc, +struct ofnode_phandle_args *args) +{ +struct gpio_delay_priv *priv =dev_get_priv (dev); + +if (args->args_count <3 ) +return -EINVAL ; + +if (args->args[0 ] >=32 ) +return -EINVAL ; + +struct gpio_delay_desc *d = &priv->descs[args->args[0 ]]; + + d->ramp_up_us = args->args[1 ]; + d->ramp_down_us = args->args[2 ]; + +dev_dbg (dev,"pin: %d, ramp_up_us: %d, ramp_down_us: %d\n" , + args->args[0 ], d->ramp_up_us, d->ramp_down_us); + +return 0 ; +} + +static const struct dm_gpio_ops gpio_delay_ops = { + .direction_output = gpio_delay_direction_output, + .direction_input = gpio_delay_direction_input, + .get_value = gpio_delay_get_value, + .set_value = gpio_delay_set_value, + .xlate = gpio_delay_xlate, +}; + +static int gpio_delay_probe (struct udevice *dev) +{ +struct gpio_delay_priv *priv =dev_get_priv (dev); +struct gpio_delay_desc *d; +ofnode node =dev_ofnode (dev); +int i =0 , ret, ngpio; + + ngpio =gpio_get_list_count (dev,"gpios" ); +if (ngpio <0 ) +return ngpio; + +dev_dbg (dev,"gpios: %d\n" , ngpio);
drivers/gpio/gpio-delay.c line 113
Quoted 10 lines
drivers/gpio/gpio-delay.c new file +10
-0+ + priv->descs =devm_kmalloc_array (dev, ngpio,sizeof (*d),GFP_KERNEL ); +if (!priv->descs) +return -ENOMEM ; + +/* Request all GPIOs described in the controller node */ +for (i =0 ; i < ngpio; i++) { + d = &priv->descs[i]; + ret =gpio_request_by_name_nodev (node,"gpios" , i, + &d->real_gpio,GPIOD_IS_OUT );
This will configure the GPIO as output and ACTIVE high/low flag will also be used per my understanding.
Should the dir and value be deferred until set_value is invoked?
Regards,
Peng
Quoted 23 lines
drivers/gpio/gpio-delay.c new file +20
-0+if (ret) +return ret; + } + +return 0 ; +} + +static const struct udevice_id gpio_delay_ids[] = { + { .compatible ="gpio-delay" }, + { } +}; + +U_BOOT_DRIVER (gpio_delay) = { + .name ="gpio-delay" , + .id =UCLASS_GPIO , + .of_match = gpio_delay_ids, + .ops = &gpio_delay_ops, + .priv_auto =sizeof (struct gpio_delay_priv ), + .probe = gpio_delay_probe, +};Signature · 1 line
2.43.0
Michal Simek
maintainerRe: [PATCH 1/3] gpio: Add GPIO delay driver
Quoted 22 lines · Peng Fan
Hi Michal,
Quoted 19 lines · Michal Simek
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.
Signed-off-by Michal Simek <[email protected]>---
drivers/gpio/Kconfig | 8 +++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-delay.c | 133 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 142 insertions(+)create mode 100644
drivers/gpio/gpio-delay.c
Quoted 15 lines
drivers/gpio/Kconfig line 8
Quoted 13 lines
drivers/gpio/Kconfig +8
-0@@ -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.Add an entry for SPL?
Why? I don't have a need for it and someone should test it if this should be used in SPL. That can be done on the top of this when tested.
Quoted 18 lines
Quoted 18 lines
drivers/gpio/Kconfig +0
-0# # GPIO infrastructure and drivers #drivers/gpio/Makefile +0
-0@@ -21,6 +21,7 @@ obj-$(CONFIG_ATMEL_PIO4) += atmel_pio4.oobj-$(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.odrivers/gpio/gpio-delay.c new file +0
-0
Quoted 8 lines
drivers/gpio/gpio-delay.c line 3
Quoted 6 lines
drivers/gpio/gpio-delay.c new file +3
-0@@ -0,0 +1,133 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2025 - 2026, Advanced Micro Devices, Inc. Drop 2025?
Why? Driver was developed in 2025 but upstreaming happens in 2026.
Quoted 41 lines
Quoted 28 lines
drivers/gpio/gpio-delay.c new file +27
-0+* +* Michal Simek <[email protected]> +*/ + +#include <dm.h> +#include <dm/device_compat.h> +#include <dm/devres.h> +#include <asm/gpio.h> +#include <linux/delay.h> + +struct gpio_delay_desc { +struct gpio_desc real_gpio; +u32 ramp_up_us; +u32 ramp_down_us; +}; + +struct gpio_delay_priv { +struct gpio_delay_desc *descs; +}; + +static int gpio_delay_direction_input (struct udevice *dev,unsigned int offset) +{ +return -ENOSYS ; +} + +static int gpio_delay_get_value (struct udevice *dev,unsigned int offset) +{drivers/gpio/gpio-delay.c line 40
Quoted 10 lines
drivers/gpio/gpio-delay.c new file +10
-0+return -ENOSYS ; +} + +static int gpio_delay_set_value (struct udevice *dev,unsigned int offset, +int value) +{ +struct gpio_delay_priv *priv =dev_get_priv (dev); +struct gpio_delay_desc *desc = &priv->descs[offset]; +int ret =dm_gpio_set_value (&desc->real_gpio, value); +u32 wait;Check return value.
Quoted 3 lines
if (ret) {
dev_err(dev, "Failed to set gpio %d\n", offset);
}will add.
Quoted 78 lines
Quoted 64 lines
drivers/gpio/gpio-delay.c new file +63
-0+ +dev_dbg (dev,"gpio %d set to %d\n" , offset, value); + +if (value) + wait = desc->ramp_up_us; +else + wait = desc->ramp_down_us; + +udelay (wait); + +dev_dbg (dev,"waited for %d us\n" , wait); + +return ret; +} + +static int gpio_delay_direction_output (struct udevice *dev,unsigned int offset, +int value) +{ +return gpio_delay_set_value (dev, offset, value); +} + +static int gpio_delay_xlate (struct udevice *dev,struct gpio_desc *desc, +struct ofnode_phandle_args *args) +{ +struct gpio_delay_priv *priv =dev_get_priv (dev); + +if (args->args_count <3 ) +return -EINVAL ; + +if (args->args[0 ] >=32 ) +return -EINVAL ; + +struct gpio_delay_desc *d = &priv->descs[args->args[0 ]]; + + d->ramp_up_us = args->args[1 ]; + d->ramp_down_us = args->args[2 ]; + +dev_dbg (dev,"pin: %d, ramp_up_us: %d, ramp_down_us: %d\n" , + args->args[0 ], d->ramp_up_us, d->ramp_down_us); + +return 0 ; +} + +static const struct dm_gpio_ops gpio_delay_ops = { + .direction_output = gpio_delay_direction_output, + .direction_input = gpio_delay_direction_input, + .get_value = gpio_delay_get_value, + .set_value = gpio_delay_set_value, + .xlate = gpio_delay_xlate, +}; + +static int gpio_delay_probe (struct udevice *dev) +{ +struct gpio_delay_priv *priv =dev_get_priv (dev); +struct gpio_delay_desc *d; +ofnode node =dev_ofnode (dev); +int i =0 , ret, ngpio; + + ngpio =gpio_get_list_count (dev,"gpios" ); +if (ngpio <0 ) +return ngpio; + +dev_dbg (dev,"gpios: %d\n" , ngpio);drivers/gpio/gpio-delay.c line 113
Quoted 10 lines
drivers/gpio/gpio-delay.c new file +10
-0+ + priv->descs =devm_kmalloc_array (dev, ngpio,sizeof (*d),GFP_KERNEL ); +if (!priv->descs) +return -ENOMEM ; + +/* Request all GPIOs described in the controller node */ +for (i =0 ; i < ngpio; i++) { + d = &priv->descs[i]; + ret =gpio_request_by_name_nodev (node,"gpios" , i, + &d->real_gpio,GPIOD_IS_OUT );This will configure the GPIO as output and ACTIVE high/low flag will also be used per my understanding.
Quoted 1 line
Should the dir and value be deferred until
set_valueis invoked?
It is clear that it should be output because you just setting it up later. But I don't have any issue not to pass any flag here.
Please let me know if you want me to change it to 0.
Thanks,
Michal
Re: [PATCH 1/3] gpio: Add GPIO delay driver
Hi Michal,
Quoted 7 lines · Michal Simek
Quoted 4 lines
Add an entry for SPL?
Why? I don't have a need for it and someone should test it if this should be used in SPL. That can be done on the top of this when tested.
I see.
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines
#
+ * Copyright (C) 2025 - 2026, Advanced Micro Devices, Inc.Drop 2025?
Why? Driver was developed in 2025 but upstreaming happens in 2026.
I think the year should start from the day of upstreaming. Not sure. Tom may comment.
Quoted 13 lines
Quoted 13 lines
drivers/gpio/gpio-delay.c line 113
Quoted 9 lines
+ *
drivers/gpio/gpio-delay.c new file +6
-0+ +/* Request all GPIOs described in the controller node */ +for (i =0 ; i < ngpio; i++) { + d = &priv->descs[i]; + ret =gpio_request_by_name_nodev (node,"gpios" , i, + &d->real_gpio,GPIOD_IS_OUT );This will configure the GPIO as output and ACTIVE high/low flag will also be used per my understanding.
Quoted 5 lines
Quoted 1 line
Should the dir and value be deferred until
set_valueis invoked?It is clear that it should be output because you just setting it up later. But I don't have any issue not to pass any flag here.
Please let me know if you want me to change it to 0.
Yes, please. Configure it only when user request.
Thanks,
Peng
Quoted 5 lines
Thanks,
Michal
Re: [PATCH 1/3] gpio: Add GPIO delay driver
Quoted 18 lines · Peng Fan
Hi Michal,
Quoted 7 lines · Michal Simek
Quoted 4 lines
Add an entry for SPL?
Why? I don't have a need for it and someone should test it if this should be used in SPL. That can be done on the top of this when tested.
I see.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
#
+ * Copyright (C) 2025 - 2026, Advanced Micro Devices, Inc.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Drop 2025?
Why? Driver was developed in 2025 but upstreaming happens in 2026.
I think the year should start from the day of upstreaming. Not sure. Tom may comment.
I saw https://daniel.haxx.se/blog/2023/01/08/copyright-without-years/ go by around January 1st and it's somewhere on my TODO list to ask what SFC thinks about it.
So to be clear, I don't have an opinion either way on what date this uses when upstreaming. But it might be good for the project if we can just drop the years, which is very clearly out of scope for this patch.
Signature · 1 line
Tom
Michal Simek
maintainerRe: [PATCH 1/3] gpio: Add GPIO delay driver
Quoted 26 lines · Tom Rini
Quoted 18 lines · Peng Fan
Hi Michal,
Quoted 7 lines · Michal Simek
Quoted 4 lines
Add an entry for SPL?
Why? I don't have a need for it and someone should test it if this should be used in SPL. That can be done on the top of this when tested.
I see.
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines
#
+ * Copyright (C) 2025 - 2026, Advanced Micro Devices, Inc.Quoted 6 lines
Quoted 3 lines
Quoted 1 line
Drop 2025?
Why? Driver was developed in 2025 but upstreaming happens in 2026.
I think the year should start from the day of upstreaming. Not sure. Tom may comment.
Quoted 8 lines
I saw https://daniel.haxx.se/blog/2023/01/08/copyright-without-years/ go by around January 1st and it's somewhere on my TODO list to ask what SFC thinks about it.
So to be clear, I don't have an opinion either way on what date this uses when upstreaming. But it might be good for the project if we can just drop the years, which is very clearly out of scope for this patch.
Driver was developed 2025 and sent 2026. We have a lot of downstream patches which were developed some time ago and then later sent but I can't remember any ask to drop previous years. Definitely people are asking to update year to match year when driver was sent. And there could be a lot of development done before too.
If driver is taken from 3rd party/contributor likely you have to keep their origin copyright and years too. You can't remove their copyright with old date too.
I don't think there is a need to remove previous year or asking to do it.
Thanks,
Michal