Skip to content

Commit

Permalink
pinmux: stm32: l4: Make SPI SCK and MOSI pins Very High Speed
Browse files Browse the repository at this point in the history
Ensure that the SPI SCK and MOSI pins are set to very high as slower
SPI speeds will cause device hangs when used. This is due to the state
changing too fast for hardware, causing RXE to never fire and thus
hang.

Signed-off-by: Pushpal Sidhu <[email protected]>
  • Loading branch information
psidhu authored and MaureenHelm committed Jan 17, 2020
1 parent 275d855 commit 74f9c23
Showing 1 changed file with 32 additions and 13 deletions.
45 changes: 32 additions & 13 deletions drivers/pinmux/stm32/pinmux_stm32l4x.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
* @file Header for STM32L4X pin multiplexing helper
*/

/*
* Note: The SPIx_SCK and MOSI pin speeds must be set to VERY_HIGH to
* avoid device hangs during boot with higher SPI speeds (e.g. 40MHz
* on L4+)
*/

/* Port A */
#define STM32L4X_PINMUX_FUNC_PA0_PWM2_CH1 \
(STM32_PINMUX_ALT_FUNC_1 | STM32_PUSHPULL_NOPULL)
Expand Down Expand Up @@ -43,7 +49,8 @@
#define STM32L4X_PINMUX_FUNC_PA5_PWM2_CH1 \
(STM32_PINMUX_ALT_FUNC_1 | STM32_PUSHPULL_NOPULL)
#define STM32L4X_PINMUX_FUNC_PA5_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
#define STM32L4X_PINMUX_FUNC_PA5_ADC12_IN10 STM32_MODER_ANALOG_MODE

#define STM32L4X_PINMUX_FUNC_PA6_SPI1_MISO \
Expand All @@ -59,7 +66,8 @@
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)
#endif /* CONFIG_SOC_STM32L496XX */
#define STM32L4X_PINMUX_FUNC_PA7_SPI1_MOSI \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUPDR_PULL_DOWN)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUPDR_PULL_DOWN | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
#define STM32L4X_PINMUX_FUNC_PA7_ADC12_IN12 STM32_MODER_ANALOG_MODE

#define STM32L4X_PINMUX_FUNC_PA9_USART1_TX \
Expand Down Expand Up @@ -105,9 +113,11 @@
#define STM32L4X_PINMUX_FUNC_PB1_ADC12_IN16 STM32_MODER_ANALOG_MODE

#define STM32L4X_PINMUX_FUNC_PB3_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
#define STM32L4X_PINMUX_FUNC_PB3_SPI3_SCK \
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)

#if defined(CONFIG_SOC_STM32L496XX)
#define STM32L4X_PINMUX_FUNC_PB4_I2C3_SDA \
Expand All @@ -123,9 +133,11 @@
#define STM32L4X_PINMUX_FUNC_PB5_PWM3_CH2 \
(STM32_PINMUX_ALT_FUNC_2 | STM32_PUSHPULL_NOPULL)
#define STM32L4X_PINMUX_FUNC_PB5_SPI1_MOSI \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUPDR_PULL_DOWN)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUPDR_PULL_DOWN | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
#define STM32L4X_PINMUX_FUNC_PB5_SPI3_MOSI \
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUPDR_PULL_DOWN)
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUPDR_PULL_DOWN | \
STM32_OSPEEDR_VERY_HIGH_SPEED)

#define STM32L4X_PINMUX_FUNC_PB6_I2C1_SCL \
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)
Expand All @@ -146,7 +158,8 @@
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)

#define STM32L4X_PINMUX_FUNC_PB10_SPI2_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
#define STM32L4X_PINMUX_FUNC_PB10_I2C2_SCL \
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)
#define STM32L4X_PINMUX_FUNC_PB10_USART3_TX \
Expand All @@ -171,7 +184,8 @@
#define STM32L4X_PINMUX_FUNC_PB13_USART3_CTS \
(STM32_PINMUX_ALT_FUNC_7 | STM32_OPENDRAIN_PULLUP)
#define STM32L4X_PINMUX_FUNC_PB13_SPI2_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)

#define STM32L4X_PINMUX_FUNC_PB14_I2C2_SDA \
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)
Expand All @@ -183,7 +197,8 @@
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUPDR_PULL_DOWN)

#define STM32L4X_PINMUX_FUNC_PB15_SPI2_MOSI \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUPDR_PULL_DOWN)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUPDR_PULL_DOWN | \
STM32_OSPEEDR_VERY_HIGH_SPEED)

/* Port C */
#define STM32L4X_PINMUX_FUNC_PC0_I2C3_SCL \
Expand Down Expand Up @@ -217,7 +232,8 @@
(STM32_PINMUX_ALT_FUNC_8 | STM32_PUPDR_NO_PULL)

#define STM32L4X_PINMUX_FUNC_PC10_SPI3_SCK \
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
#define STM32L4X_PINMUX_FUNC_PC10_USART3_TX \
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUSHPULL_PULLUP)
#define STM32L4X_PINMUX_FUNC_PC10_UART4_TX \
Expand All @@ -231,7 +247,8 @@
(STM32_PINMUX_ALT_FUNC_8 | STM32_PUPDR_NO_PULL)

#define STM32L4X_PINMUX_FUNC_PC12_SPI3_MOSI \
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUPDR_PULL_DOWN)
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUPDR_PULL_DOWN | \
STM32_OSPEEDR_VERY_HIGH_SPEED)

/* Port D */
#define STM32L4X_PINMUX_FUNC_PD2_USART3_RTS \
Expand Down Expand Up @@ -280,13 +297,15 @@
#define STM32L4X_PINMUX_FUNC_PE13_PWM1_CH3 \
(STM32_PINMUX_ALT_FUNC_1 | STM32_PUSHPULL_NOPULL)
#define STM32L4X_PINMUX_FUNC_PE13_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)

#define STM32L4X_PINMUX_FUNC_PE14_SPI1_MISO \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)

#define STM32L4X_PINMUX_FUNC_PE15_SPI1_MOSI \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)

/* Port F */
#define STM32L4X_PINMUX_FUNC_PF0_I2C3_SDA \
Expand Down

0 comments on commit 74f9c23

Please sign in to comment.