diff --git a/boards/arm/stm32mp157c_dk2/Kconfig.defconfig b/boards/arm/stm32mp157c_dk2/Kconfig.defconfig index 99099b44246f8b..ede61360cca61e 100644 --- a/boards/arm/stm32mp157c_dk2/Kconfig.defconfig +++ b/boards/arm/stm32mp157c_dk2/Kconfig.defconfig @@ -31,4 +31,14 @@ config I2C_5 endif # I2C +if SPI + +config SPI_STM32_INTERRUPT + default y + +config SPI_4 + default y + +endif # SPI + endif # BOARD_STM32MP157_Dk2 diff --git a/boards/arm/stm32mp157c_dk2/arduino_r3_connector.dtsi b/boards/arm/stm32mp157c_dk2/arduino_r3_connector.dtsi index da8f81e09b4583..300a71b6c19cab 100644 --- a/boards/arm/stm32mp157c_dk2/arduino_r3_connector.dtsi +++ b/boards/arm/stm32mp157c_dk2/arduino_r3_connector.dtsi @@ -35,4 +35,4 @@ arduino_i2c: &i2c5 {}; arduino_serial: &uart7 {}; -/* arduino_spi: SPI is not yet supported on STM32MP1 */ +arduino_spi: &spi4 {}; diff --git a/boards/arm/stm32mp157c_dk2/doc/stm32mp157_dk2.rst b/boards/arm/stm32mp157c_dk2/doc/stm32mp157_dk2.rst index 4d5e0f58c59a83..69851c09b4e77f 100644 --- a/boards/arm/stm32mp157c_dk2/doc/stm32mp157_dk2.rst +++ b/boards/arm/stm32mp157c_dk2/doc/stm32mp157_dk2.rst @@ -177,6 +177,8 @@ features: +-----------+------------+-------------------------------------+ | I2C | on-chip | i2c | +-----------+------------+-------------------------------------+ +| SPI | on-chip | spi | ++-----------+------------+-------------------------------------+ The default configuration can be found in the defconfig file: ``boards/arm/stm32mp157c_dk2/stm32mp157c_dk2_defconfig`` @@ -195,6 +197,8 @@ Default Zephyr Peripheral Mapping: - USART_3 TX/RX : PB10/PB12 (UART console) - UART_7 TX/RX : PE8/PE7 (Arduino Serial) - I2C5 SCL/SDA : PA11/PA12 (Arduino I2C) +- SPI4 SCK/MISO/MOSI : PE12/PE13/PE14 (Arduino SPI) +- SPI5 SCK/MISO/MOSI : PF7/PF8/PF9 System Clock ------------ diff --git a/boards/arm/stm32mp157c_dk2/pinmux.c b/boards/arm/stm32mp157c_dk2/pinmux.c index 332d002c04e32e..dcffe9ebb559a4 100644 --- a/boards/arm/stm32mp157c_dk2/pinmux.c +++ b/boards/arm/stm32mp157c_dk2/pinmux.c @@ -26,6 +26,24 @@ static const struct pin_config pinconf[] = { { STM32_PIN_PA11, STM32MP1X_PINMUX_FUNC_PA11_I2C5_SCL }, { STM32_PIN_PA12, STM32MP1X_PINMUX_FUNC_PA12_I2C5_SDA }, #endif /* CONFIG_I2C_5 */ +#ifdef CONFIG_SPI_4 +#ifdef CONFIG_SPI_STM32_USE_HW_SS + {STM32_PIN_PE11, STM32MP1X_PINMUX_FUNC_PE11_SPI4_NSS}, +#endif /* CONFIG_SPI_STM32_USE_HW_SS */ + {STM32_PIN_PE12, STM32MP1X_PINMUX_FUNC_PE12_SPI4_SCK}, + {STM32_PIN_PE13, STM32MP1X_PINMUX_FUNC_PE13_SPI4_MISO | + STM32_OSPEEDR_VERY_HIGH_SPEED}, + {STM32_PIN_PE14, STM32MP1X_PINMUX_FUNC_PE14_SPI4_MOSI}, +#endif /* CONFIG_SPI_4 */ +#ifdef CONFIG_SPI_5 +#ifdef CONFIG_SPI_STM32_USE_HW_SS + {STM32_PIN_PF6, STM32MP1X_PINMUX_FUNC_PF6_SPI5_NSS}, +#endif /* CONFIG_SPI_STM32_USE_HW_SS */ + {STM32_PIN_PF7, STM32MP1X_PINMUX_FUNC_PF7_SPI5_SCK}, + {STM32_PIN_PF8, STM32MP1X_PINMUX_FUNC_PF8_SPI5_MISO | + STM32_OSPEEDR_VERY_HIGH_SPEED}, + {STM32_PIN_PF9, STM32MP1X_PINMUX_FUNC_PF9_SPI5_MOSI}, +#endif /* CONFIG_SPI_5 */ }; static int pinmux_stm32_init(struct device *port) diff --git a/boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.dts b/boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.dts index 539f90f59e97a6..8b0d631335e05a 100644 --- a/boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.dts +++ b/boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.dts @@ -26,6 +26,14 @@ }; }; +&spi4{ + status = "okay"; +}; + +&spi5{ + status = "okay"; +}; + &usart3 { current-speed = <115200>; pinctrl-0 = <&usart3_pins_a>; diff --git a/boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.yaml b/boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.yaml index f44ba6a1092e1c..c59bf43cb64850 100644 --- a/boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.yaml +++ b/boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.yaml @@ -10,6 +10,7 @@ supported: - gpio - shell - i2c + - spi testing: ignore_tags: - cmsis_rtos_v2 diff --git a/tests/drivers/spi/spi_loopback/boards/stm32mp157c_dk2.conf b/tests/drivers/spi/spi_loopback/boards/stm32mp157c_dk2.conf new file mode 100644 index 00000000000000..66d1c3d5bb4a82 --- /dev/null +++ b/tests/drivers/spi/spi_loopback/boards/stm32mp157c_dk2.conf @@ -0,0 +1,8 @@ +# +# Copyright (c) 2019, STMicroelectronics +# +# SPDX-License-Identifier: Apache-2.0 +# + +CONFIG_SPI_4=y +CONFIG_SPI_LOOPBACK_DRV_NAME="SPI_4"