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
The following commit(s) were added to refs/heads/master by this push:
new 2567b729cf8 arch/risc-v/espressif: fix SPI IOMUX false positive
without SPI2
2567b729cf8 is described below
commit 2567b729cf83f46f3ca1807fa09323dd49908e15
Author: Filipe Cavalcanti <[email protected]>
AuthorDate: Tue Jul 28 18:32:09 2026 -0300
arch/risc-v/espressif: fix SPI IOMUX false positive without SPI2
SPI_VIA_IOMUX used SPI2 IOMUX pin macros that are undefined when SPI2
is disabled or on chips without IOMUX SPI pins (e.g. ESP32-P4), so the
driver took the IOMUX path and never routed SPI3 via the GPIO matrix.
Signed-off-by: Filipe Cavalcanti <[email protected]>
---
arch/risc-v/src/common/espressif/esp_spi.c | 28 ++++++++++++++++++----------
1 file changed, 18 insertions(+), 10 deletions(-)
diff --git a/arch/risc-v/src/common/espressif/esp_spi.c
b/arch/risc-v/src/common/espressif/esp_spi.c
index 589d299d2b6..1a80e473de1 100644
--- a/arch/risc-v/src/common/espressif/esp_spi.c
+++ b/arch/risc-v/src/common/espressif/esp_spi.c
@@ -127,18 +127,26 @@
#endif
/* Verify whether SPI has been assigned IOMUX pins.
- * Otherwise, SPI signals will be routed via GPIO Matrix.
+ * Otherwise, SPI signals will be routed via GPIO Matrix. Chips without
+ * SPI2_IOMUX_* definitions (e.g. ESP32-P4) have no IOMUX pins for SPI and
+ * are always routed via GPIO Matrix.
*/
-#define SPI_IS_CS_IOMUX (CONFIG_ESPRESSIF_SPI2_CSPIN == SPI2_IOMUX_CSPIN)
-#define SPI_IS_CLK_IOMUX (CONFIG_ESPRESSIF_SPI2_CLKPIN == SPI2_IOMUX_CLKPIN)
-#define SPI_IS_MOSI_IOMUX (CONFIG_ESPRESSIF_SPI2_MOSIPIN == SPI2_IOMUX_MOSIPIN)
-#define SPI_IS_MISO_IOMUX (CONFIG_ESPRESSIF_SPI2_MISOPIN == SPI2_IOMUX_MISOPIN)
-
-#define SPI_VIA_IOMUX ((SPI_IS_CS_IOMUX || SPI_HAVE_SWCS) && \
- (SPI_IS_CLK_IOMUX) && \
- (SPI_IS_MOSI_IOMUX) && \
- (SPI_IS_MISO_IOMUX)) ? 1 : 0
+#if defined(CONFIG_ESPRESSIF_SPI2) && defined(SPI2_IOMUX_CSPIN)
+# define SPI_IS_CS_IOMUX (CONFIG_ESPRESSIF_SPI2_CSPIN == SPI2_IOMUX_CSPIN)
+# define SPI_IS_CLK_IOMUX (CONFIG_ESPRESSIF_SPI2_CLKPIN == SPI2_IOMUX_CLKPIN)
+# define SPI_IS_MOSI_IOMUX (CONFIG_ESPRESSIF_SPI2_MOSIPIN == \
+ SPI2_IOMUX_MOSIPIN)
+# define SPI_IS_MISO_IOMUX (CONFIG_ESPRESSIF_SPI2_MISOPIN == \
+ SPI2_IOMUX_MISOPIN)
+
+# define SPI_VIA_IOMUX ((SPI_IS_CS_IOMUX || SPI_HAVE_SWCS) && \
+ (SPI_IS_CLK_IOMUX) && \
+ (SPI_IS_MOSI_IOMUX) && \
+ (SPI_IS_MISO_IOMUX)) ? 1 : 0
+#else
+# define SPI_VIA_IOMUX 0
+#endif
/* SPI default frequency (limited by clock divider) */