This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit d031d074125aef6cf6098e8682c99daf39995447
Author: raiden00pl <[email protected]>
AuthorDate: Sun Nov 22 10:35:45 2026 +0100

    arch/arm/src/stm32n6: fix I2C on VDDIO4 pins and in sleep mode.
    
    Pads in VDDIO4 stay isolated until PWR_SVMCR1 VDDIO4SV is set, and
    nothing set it.  Set the board's BOARD_PWR_VDDIO4 bits and apply the
    ES0620 compensation mitigation to VDDIO4CCCR, as done for VDDIO5.
    
    The RCC LPENR bits reset to 0, so the I2C kernel clock stopped in WFI
    and multi-byte transfers failed mid-transfer.  Set I2CnLPEN for each
    enabled instance, as done for the U(S)ARTs and timers.
    
    Assisted-by: Claude Code:claude-opus-5-5
    Signed-off-by: raiden00pl <[email protected]>
---
 arch/arm/src/stm32n6/hardware/stm32n6xxx_syscfg.h |  2 ++
 arch/arm/src/stm32n6/stm32_start.c                | 26 ++++++++++++++++++++---
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/arch/arm/src/stm32n6/hardware/stm32n6xxx_syscfg.h 
b/arch/arm/src/stm32n6/hardware/stm32n6xxx_syscfg.h
index 98494990bc9..c9eeeecc0cc 100644
--- a/arch/arm/src/stm32n6/hardware/stm32n6xxx_syscfg.h
+++ b/arch/arm/src/stm32n6/hardware/stm32n6xxx_syscfg.h
@@ -37,6 +37,7 @@
 /* Register Offsets *********************************************************/
 
 #define STM32_SYSCFG_INITSVTORCR_OFFSET  0x010 /* Secure vector table base 
address register */
+#define STM32_SYSCFG_VDDIO4CCCR_OFFSET   0x044 /* VDDIO4 compensation cell 
control register */
 #define STM32_SYSCFG_VDDIO5CCCR_OFFSET   0x04c /* VDDIO5 compensation cell 
control register */
 #define STM32_SYSCFG_VDDIO2CCCR_OFFSET   0x054 /* VDDIO2 compensation cell 
control register */
 #define STM32_SYSCFG_VDDIO3CCCR_OFFSET   0x05c /* VDDIO3 compensation cell 
control register */
@@ -45,6 +46,7 @@
 /* Register Addresses *******************************************************/
 
 #define STM32_SYSCFG_INITSVTORCR         (STM32_SYSCFG_BASE + 
STM32_SYSCFG_INITSVTORCR_OFFSET)
+#define STM32_SYSCFG_VDDIO4CCCR          (STM32_SYSCFG_BASE + 
STM32_SYSCFG_VDDIO4CCCR_OFFSET)
 #define STM32_SYSCFG_VDDIO5CCCR          (STM32_SYSCFG_BASE + 
STM32_SYSCFG_VDDIO5CCCR_OFFSET)
 #define STM32_SYSCFG_VDDIO2CCCR          (STM32_SYSCFG_BASE + 
STM32_SYSCFG_VDDIO2CCCR_OFFSET)
 #define STM32_SYSCFG_VDDIO3CCCR          (STM32_SYSCFG_BASE + 
STM32_SYSCFG_VDDIO3CCCR_OFFSET)
diff --git a/arch/arm/src/stm32n6/stm32_start.c 
b/arch/arm/src/stm32n6/stm32_start.c
index 038253f2701..05876f80ff4 100644
--- a/arch/arm/src/stm32n6/stm32_start.c
+++ b/arch/arm/src/stm32n6/stm32_start.c
@@ -318,6 +318,18 @@ void __start_c(void)
 #ifdef CONFIG_STM32_USART10
   putreg32(RCC_APB2LPENR_USART10LPEN, STM32_RCC_APB2LPENSR);
 #endif
+#ifdef CONFIG_STM32_I2C1
+  putreg32(RCC_APB1LLPENR_I2C1LPEN, STM32_RCC_APB1LLPENSR);
+#endif
+#ifdef CONFIG_STM32_I2C2
+  putreg32(RCC_APB1LLPENR_I2C2LPEN, STM32_RCC_APB1LLPENSR);
+#endif
+#ifdef CONFIG_STM32_I2C3
+  putreg32(RCC_APB1LLPENR_I2C3LPEN, STM32_RCC_APB1LLPENSR);
+#endif
+#ifdef CONFIG_STM32_I2C4
+  putreg32(RCC_APB4LLPENR_I2C4LPEN, STM32_RCC_APB4LLPENSR);
+#endif
 #ifdef CONFIG_STM32_TIM
   putreg32(RCC_APB1LLPENR_ALLTIM, STM32_RCC_APB1LLPENSR);
   putreg32(RCC_APB2LPENR_ALLTIM, STM32_RCC_APB2LPENSR);
@@ -334,22 +346,30 @@ void __start_c(void)
 
   stm32_pwr_enablevddio(BOARD_PWR_VDDIO);
 
-  /* VDDIO5 (SDMMC2 pads) is validated in PWR SVMCR2 when the board
-   * provides BOARD_PWR_VDDIO5 (PWR_SVMCR2_* bits).
+  /* VDDIO4 and VDDIO5 (SDMMC2 pads) are validated in PWR SVMCR1 and
+   * SVMCR2 when the board provides BOARD_PWR_VDDIO4 (PWR_SVMCR1_* bits)
+   * and BOARD_PWR_VDDIO5 (PWR_SVMCR2_* bits).
    */
 
+#ifdef BOARD_PWR_VDDIO4
+  modifyreg32(STM32_PWR_SVMCR1, 0, BOARD_PWR_VDDIO4);
+#endif
+
 #ifdef BOARD_PWR_VDDIO5
   modifyreg32(STM32_PWR_SVMCR2, 0, BOARD_PWR_VDDIO5);
 #endif
 
   /* Apply the ES0620 I/O-compensation mitigation (write 0x287) to the
-   * domains we use.  Only VDDIO2, VDDIO3 and the board's VDDIO5 are
+   * domains we use.  Only VDDIO2, VDDIO3 and the board's VDDIO4/5 are
    * touched: the other VDDIOxCCCR registers cannot be accessed without
    * their VDDIOxSV bit set first (separate ES0620 erratum).
    */
 
   putreg32(SYSCFG_CCCR_ES0620_MANUAL, STM32_SYSCFG_VDDIO2CCCR);
   putreg32(SYSCFG_CCCR_ES0620_MANUAL, STM32_SYSCFG_VDDIO3CCCR);
+#ifdef BOARD_PWR_VDDIO4
+  putreg32(SYSCFG_CCCR_ES0620_MANUAL, STM32_SYSCFG_VDDIO4CCCR);
+#endif
 #ifdef BOARD_PWR_VDDIO5
   putreg32(SYSCFG_CCCR_ES0620_MANUAL, STM32_SYSCFG_VDDIO5CCCR);
 #endif

Reply via email to