This is an automated email from the ASF dual-hosted git repository. xiaoxiang781216 pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 7b8632abe5b2065326fabb29220320f3853cfe33 Author: raiden00pl <[email protected]> AuthorDate: Tue Nov 17 15:38:19 2026 +0100 arch/arm/stm32: Add the STM32N6 GPIO I/O delay. STM32N6 GPIOs can delay the input or the output path of a pin, which RGMII needs to skew the transmit clock from the data. A pinset now carries the delay and its path, and stm32_configgpio() programs the DELAYR and ADVCFGR registers on chips that have them. Assisted-by: Claude:claude-opus-5-5 Signed-off-by: raiden00pl <[email protected]> --- arch/arm/src/common/stm32/Kconfig.have | 3 +++ .../common/stm32/hardware/stm32_gpio_m33m55_v1.h | 15 +++++++++++++ arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.c | 25 ++++++++++++++++++++++ arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.h | 24 +++++++++++++++++++++ arch/arm/src/stm32n6/Kconfig | 1 + 5 files changed, 68 insertions(+) diff --git a/arch/arm/src/common/stm32/Kconfig.have b/arch/arm/src/common/stm32/Kconfig.have index 81101e0f394..b58f1fd1533 100644 --- a/arch/arm/src/common/stm32/Kconfig.have +++ b/arch/arm/src/common/stm32/Kconfig.have @@ -38,6 +38,9 @@ config STM32_HAVE_IP_GPIO_M33M55_V1 bool +config STM32_HAVE_GPIO_DELAY + bool + config STM32_HAVE_IP_EXTI_M33M55_V1 bool diff --git a/arch/arm/src/common/stm32/hardware/stm32_gpio_m33m55_v1.h b/arch/arm/src/common/stm32/hardware/stm32_gpio_m33m55_v1.h index 734207bd779..aeb5dbcd10e 100644 --- a/arch/arm/src/common/stm32/hardware/stm32_gpio_m33m55_v1.h +++ b/arch/arm/src/common/stm32/hardware/stm32_gpio_m33m55_v1.h @@ -51,6 +51,10 @@ #define STM32_GPIO_SECCFGR_OFFSET 0x0030 /* GPIO secure configuration register */ #define STM32_GPIO_PRIVCFGR_OFFSET 0x0034 /* GPIO privilege configuration register */ #define STM32_GPIO_RCFGLOCKR_OFFSET 0x0038 /* GPIO RIF configuration lock register */ +#define STM32_GPIO_DELAYRL_OFFSET 0x0040 /* GPIO delay register, pins 0-7 (STM32N6) */ +#define STM32_GPIO_DELAYRH_OFFSET 0x0044 /* GPIO delay register, pins 8-15 (STM32N6) */ +#define STM32_GPIO_ADVCFGRL_OFFSET 0x0048 /* GPIO advanced configuration register, pins 0-7 (STM32N6) */ +#define STM32_GPIO_ADVCFGRH_OFFSET 0x004c /* GPIO advanced configuration register, pins 8-15 (STM32N6) */ /* Register Addresses *******************************************************/ @@ -865,4 +869,15 @@ #define GPIO_SECCFGR_SET(n) (1 << (n)) +/* GPIO delay and advanced configuration registers: 4 bits per pin, pins + * 0-7 in the L and pins 8-15 in the H register (STM32N6) + */ + +#define GPIO_DELAYR_SHIFT(n) ((n) << 2) +#define GPIO_DELAYR_MASK(n) (0xf << GPIO_DELAYR_SHIFT(n)) + +#define GPIO_ADVCFGR_SHIFT(n) ((n) << 2) +#define GPIO_ADVCFGR_MASK(n) (0xf << GPIO_ADVCFGR_SHIFT(n)) +#define GPIO_ADVCFGR_DLYPATH(n) (1 << GPIO_ADVCFGR_SHIFT(n)) /* Delay on the input path */ + #endif /* __ARCH_ARM_SRC_COMMON_STM32_HARDWARE_STM32_GPIO_M33M55_V1_H */ diff --git a/arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.c b/arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.c index 135e9f946d0..0a3ceca33d1 100644 --- a/arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.c +++ b/arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.c @@ -339,6 +339,31 @@ int stm32_configgpio(uint32_t cfgset) putreg32(regval, base + STM32_GPIO_OTYPER_OFFSET); +#ifdef CONFIG_STM32_HAVE_GPIO_DELAY + /* Set the I/O delay and the path that it applies to */ + + setting = (cfgset & GPIO_DELAY_MASK) >> GPIO_DELAY_SHIFT; + pos = pin & 7; + + regoffset = pin < 8 ? STM32_GPIO_DELAYRL_OFFSET : + STM32_GPIO_DELAYRH_OFFSET; + regval = getreg32(base + regoffset); + regval &= ~GPIO_DELAYR_MASK(pos); + regval |= setting << GPIO_DELAYR_SHIFT(pos); + putreg32(regval, base + regoffset); + + regoffset = pin < 8 ? STM32_GPIO_ADVCFGRL_OFFSET : + STM32_GPIO_ADVCFGRH_OFFSET; + regval = getreg32(base + regoffset); + regval &= ~GPIO_ADVCFGR_DLYPATH(pos); + if ((cfgset & GPIO_DELAY_INPUT) != 0) + { + regval |= GPIO_ADVCFGR_DLYPATH(pos); + } + + putreg32(regval, base + regoffset); +#endif + spin_unlock_irqrestore(&g_configgpio_lock, flags); return OK; } diff --git a/arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.h b/arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.h index 1163cc8e013..f5ef309a0f9 100644 --- a/arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.h +++ b/arch/arm/src/common/stm32/stm32_gpio_m33m55_v1.h @@ -67,6 +67,30 @@ * Analog: MM.. .... .... PPPP BBBB */ +/* I/O delay (STM32N6 only), above the 20-bit encoding: + * + * Bits 20-23: Delay code, 0 for none + * Bit 24: Delay the input path instead of the output path + */ + +#define GPIO_DELAY_SHIFT (20) /* Bits 20-23: I/O delay */ +#define GPIO_DELAY_MASK (15 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_NONE (0 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_300PS (1 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_500PS (2 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_750PS (3 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_1000PS (4 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_1250PS (5 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_1500PS (6 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_1750PS (7 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_2000PS (8 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_2250PS (9 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_2500PS (10 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_2750PS (11 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_3000PS (12 << GPIO_DELAY_SHIFT) +# define GPIO_DELAY_3250PS (13 << GPIO_DELAY_SHIFT) +#define GPIO_DELAY_INPUT (1 << 24) /* Bit 24: Delay the input path */ + /* Mode: * * 1111 1111 1100 0000 0000 diff --git a/arch/arm/src/stm32n6/Kconfig b/arch/arm/src/stm32n6/Kconfig index 3dd38762635..58fe02030bb 100644 --- a/arch/arm/src/stm32n6/Kconfig +++ b/arch/arm/src/stm32n6/Kconfig @@ -34,6 +34,7 @@ config STM32_N6_PERIPHERALS select STM32_HAVE_IP_DMA_GPDMA select STM32_HAVE_IP_EXTI_M33M55_V1 select STM32_HAVE_IP_GPIO_M33M55_V1 + select STM32_HAVE_GPIO_DELAY select STM32_HAVE_IP_I2C_M33M55_V2 select STM32_HAVE_IP_TIMERS_V3 select STM32_HAVE_IP_USART_M33M55_V3
