Skip to content

Commit

Permalink
boards: arm: stm32mp157c_dk2: Add SPI support
Browse files Browse the repository at this point in the history
Add SPI support for stm32mp157c_dk2 board. If SPI is selected, SPI4
(Arduino connector compatible SPI) and SPI5 (on front 2x20 GPIO
expander) will be enable by default on stm32mp157c_dk2 board.

Signed-off-by: Yaël Boutreux <[email protected]>
Signed-off-by: Arnaud Pouliquen <[email protected]>
Signed-off-by: Alexandre Torgue <[email protected]>
  • Loading branch information
yboutreux authored and MaureenHelm committed Aug 5, 2019
1 parent e0d6534 commit 57a166a
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 1 deletion.
10 changes: 10 additions & 0 deletions boards/arm/stm32mp157c_dk2/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion boards/arm/stm32mp157c_dk2/arduino_r3_connector.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@

arduino_i2c: &i2c5 {};
arduino_serial: &uart7 {};
/* arduino_spi: SPI is not yet supported on STM32MP1 */
arduino_spi: &spi4 {};
4 changes: 4 additions & 0 deletions boards/arm/stm32mp157c_dk2/doc/stm32mp157_dk2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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``
Expand All @@ -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
------------
Expand Down
18 changes: 18 additions & 0 deletions boards/arm/stm32mp157c_dk2/pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.dts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@
};
};

&spi4{
status = "okay";
};

&spi5{
status = "okay";
};

&usart3 {
current-speed = <115200>;
pinctrl-0 = <&usart3_pins_a>;
Expand Down
1 change: 1 addition & 0 deletions boards/arm/stm32mp157c_dk2/stm32mp157c_dk2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ supported:
- gpio
- shell
- i2c
- spi
testing:
ignore_tags:
- cmsis_rtos_v2
Expand Down
8 changes: 8 additions & 0 deletions tests/drivers/spi/spi_loopback/boards/stm32mp157c_dk2.conf
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 57a166a

Please sign in to comment.