Skip to content

Commit

Permalink
drivers/pinmux: stm32: Use pull-up for _SPI_NSS pins
Browse files Browse the repository at this point in the history
To work efficiently, SPI_NSS pins require pull-up configuration.
Fix this for whole STM32 series.

Fixes zephyrproject-rtos#17998

Signed-off-by: Erwan Gouriou <[email protected]>
  • Loading branch information
erwango authored and MaureenHelm committed Sep 10, 2019
1 parent 916bf0e commit 90df6a3
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 31 deletions.
8 changes: 4 additions & 4 deletions drivers/pinmux/stm32/pinmux_stm32f0.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
(STM32_PINMUX_ALT_FUNC_1 | STM32_OPENDRAIN_PULLUP)

#define STM32F0_PINMUX_FUNC_PA4_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_PULLUP)
#define STM32F0_PINMUX_FUNC_PA5_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand All @@ -70,7 +70,7 @@
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUPDR_PULL_DOWN)

#define STM32F0_PINMUX_FUNC_PA15_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_PULLUP)
#define STM32F0_PINMUX_FUNC_PB3_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand All @@ -80,7 +80,7 @@
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUPDR_PULL_DOWN)

#define STM32F0_PINMUX_FUNC_PB12_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_PULLUP)
#define STM32F0_PINMUX_FUNC_PB13_SPI2_SCK \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand All @@ -91,7 +91,7 @@

/* Available on STM32F030xC devices only. */
#define STM32F0_PINMUX_FUNC_PB9_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_PULLUP)
#define STM32F0_PINMUX_FUNC_PB10_SPI2_SCK \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand Down
6 changes: 3 additions & 3 deletions drivers/pinmux/stm32/pinmux_stm32f3.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
#endif

#define STM32F3_PINMUX_FUNC_PA4_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32F3_PINMUX_FUNC_PA5_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand Down Expand Up @@ -115,7 +115,7 @@
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)

#define STM32F3_PINMUX_FUNC_PB12_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32F3_PINMUX_FUNC_PB13_SPI2_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand All @@ -126,7 +126,7 @@

#if CONFIG_SOC_STM32F302X8 || CONFIG_SOC_STM32F303XC || CONFIG_SOC_STM32F373XC
#define STM32F3_PINMUX_FUNC_PA15_SPI3_NSS \
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUSHPULL_PULLUP)
#define STM32F3_PINMUX_FUNC_PB3_SPI3_SCK \
(STM32_PINMUX_ALT_FUNC_6 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand Down
6 changes: 3 additions & 3 deletions drivers/pinmux/stm32/pinmux_stm32f4.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
STM32_MODER_ANALOG_MODE

#define STM32F4_PINMUX_FUNC_PA4_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32F4_PINMUX_FUNC_PA4_I2S1_WS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32F4_PINMUX_FUNC_PA4_I2S3_WS \
Expand Down Expand Up @@ -216,7 +216,7 @@
#define STM32F4_PINMUX_FUNC_PB9_UART5_TX \
(STM32_PINMUX_ALT_FUNC_11 | STM32_PUSHPULL_PULLUP)
#define STM32F4_PINMUX_FUNC_PB9_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)

#define STM32F4_PINMUX_FUNC_PB10_I2C2_SCL \
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)
Expand All @@ -235,7 +235,7 @@
STM32_OSPEEDR_VERY_HIGH_SPEED)

#define STM32F4_PINMUX_FUNC_PB12_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32F4_PINMUX_FUNC_PB12_I2S2_WS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32F4_PINMUX_FUNC_PB12_I2S4_WS \
Expand Down
10 changes: 5 additions & 5 deletions drivers/pinmux/stm32/pinmux_stm32f7.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
STM32_MODER_ANALOG_MODE

#define STM32F7_PINMUX_FUNC_PA4_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32F7_PINMUX_FUNC_PA4_LTDC_VSYNC \
(STM32_PINMUX_ALT_FUNC_14 | STM32_PUSHPULL_NOPULL)
#define STM32F7_PINMUX_FUNC_PA4_ADC12_IN4 \
Expand Down Expand Up @@ -192,7 +192,7 @@
#define STM32F7_PINMUX_FUNC_PB4_SPI1_MISO \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUPDR_PULL_DOWN)
#define STM32F7_PINMUX_FUNC_PB4_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUSHPULL_PULLUP)

#define STM32F7_PINMUX_FUNC_PB5_PWM3_CH2 \
(STM32_PINMUX_ALT_FUNC_2 | STM32_PUSHPULL_PULLUP)
Expand Down Expand Up @@ -231,7 +231,7 @@
#define STM32F7_PINMUX_FUNC_PB9_I2C1_SDA \
(STM32_PINMUX_ALT_FUNC_4 | STM32_OPENDRAIN_PULLUP)
#define STM32F7_PINMUX_FUNC_PB9_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32F7_PINMUX_FUNC_PB9_LTDC_B7 \
(STM32_PINMUX_ALT_FUNC_14 | STM32_PUSHPULL_NOPULL)

Expand Down Expand Up @@ -259,7 +259,7 @@
(STM32_PINMUX_ALT_FUNC_14 | STM32_PUSHPULL_NOPULL)

#define STM32F7_PINMUX_FUNC_PB12_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)

#define STM32F7_PINMUX_FUNC_PB13_PWM1_CH1N \
(STM32_PINMUX_ALT_FUNC_1 | STM32_PUSHPULL_PULLUP)
Expand Down Expand Up @@ -659,7 +659,7 @@
#define STM32F7_PINMUX_FUNC_PI0_PWM5_CH4 \
(STM32_PINMUX_ALT_FUNC_2 | STM32_PUSHPULL_PULLUP)
#define STM32F7_PINMUX_FUNC_PI0_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32F7_PINMUX_FUNC_PI0_LTDC_G5 \
(STM32_PINMUX_ALT_FUNC_14 | STM32_PUSHPULL_NOPULL)

Expand Down
8 changes: 4 additions & 4 deletions drivers/pinmux/stm32/pinmux_stm32l0.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
*/

#define STM32L0_PINMUX_FUNC_PA4_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_PULLUP)
#define STM32L0_PINMUX_FUNC_PA5_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand All @@ -80,7 +80,7 @@
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUPDR_PULL_DOWN)

#define STM32L0_PINMUX_FUNC_PA15_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_PULLUP)
#define STM32L0_PINMUX_FUNC_PB3_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand All @@ -90,7 +90,7 @@
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUPDR_PULL_DOWN)

#define STM32L0_PINMUX_FUNC_PB12_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_PULLUP)
#define STM32L0_PINMUX_FUNC_PB13_SPI2_SCK \
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand All @@ -100,7 +100,7 @@
(STM32_PINMUX_ALT_FUNC_0 | STM32_PUPDR_PULL_DOWN)

#define STM32L0_PINMUX_FUNC_PB9_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32L0_PINMUX_FUNC_PB10_SPI2_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL | \
STM32_OSPEEDR_VERY_HIGH_SPEED)
Expand Down
2 changes: 1 addition & 1 deletion drivers/pinmux/stm32/pinmux_stm32l1x.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#define STM32L1X_PINMUX_FUNC_PA3_USART2_RX \
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUPDR_NO_PULL)
#define STM32L1X_PINMUX_FUNC_PA4_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32L1X_PINMUX_FUNC_PA5_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32L1X_PINMUX_FUNC_PA6_SPI1_MISO \
Expand Down
4 changes: 2 additions & 2 deletions drivers/pinmux/stm32/pinmux_stm32l4x.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
#define STM32L4X_PINMUX_FUNC_PA2_ADC12_IN7 STM32_MODER_ANALOG_MODE

#define STM32L4X_PINMUX_FUNC_PA3_USART2_RX \
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUPDR_NO_PULL)
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUSHPULL_PULLUP)
#define STM32L4X_PINMUX_FUNC_PA3_ADC12_IN8 STM32_MODER_ANALOG_MODE

#define STM32L4X_PINMUX_FUNC_PA4_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32L4X_PINMUX_FUNC_PA4_ADC12_IN9 STM32_MODER_ANALOG_MODE

#define STM32L4X_PINMUX_FUNC_PA5_PWM2_CH1 \
Expand Down
4 changes: 2 additions & 2 deletions drivers/pinmux/stm32/pinmux_stm32mp1x.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#define STM32MP1X_PINMUX_FUNC_PE10_UART7_CTS \
(STM32_PINMUX_ALT_FUNC_7 | STM32_PUSHPULL_PULLUP)
#define STM32MP1X_PINMUX_FUNC_PE11_SPI4_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32MP1X_PINMUX_FUNC_PE12_SPI4_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32MP1X_PINMUX_FUNC_PE13_SPI4_MISO \
Expand All @@ -49,7 +49,7 @@

/* Port F */
#define STM32MP1X_PINMUX_FUNC_PF6_SPI5_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32MP1X_PINMUX_FUNC_PF7_SPI5_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32MP1X_PINMUX_FUNC_PF8_SPI5_MISO \
Expand Down
12 changes: 6 additions & 6 deletions drivers/pinmux/stm32/pinmux_stm32wbx.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#define STM32WBX_PINMUX_FUNC_PA1_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32WBX_PINMUX_FUNC_PA4_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32WBX_PINMUX_FUNC_PA5_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32WBX_PINMUX_FUNC_PA6_SPI1_MISO \
Expand All @@ -52,7 +52,7 @@
#define STM32WBX_PINMUX_FUNC_PA12_SPI1_MOSI \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUPDR_PULL_DOWN)
#define STM32WBX_PINMUX_FUNC_PA15_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)

/* SPI2 */
#define STM32WBX_PINMUX_FUNC_PA9_SPI2_SCK \
Expand Down Expand Up @@ -108,7 +108,7 @@

/* SPI1 */
#define STM32WBX_PINMUX_FUNC_PB2_SPI1_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32WBX_PINMUX_FUNC_PB3_SPI1_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32WBX_PINMUX_FUNC_PB4_SPI1_MISO \
Expand All @@ -118,11 +118,11 @@

/* SPI2 */
#define STM32WBX_PINMUX_FUNC_PB9_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32WBX_PINMUX_FUNC_PB10_SPI2_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32WBX_PINMUX_FUNC_PB12_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32WBX_PINMUX_FUNC_PB13_SPI2_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32WBX_PINMUX_FUNC_PB14_SPI2_MISO \
Expand Down Expand Up @@ -175,7 +175,7 @@
/* Port D */
/* SPI2 */
#define STM32WBX_PINMUX_FUNC_PD0_SPI2_NSS \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_PULLUP)
#define STM32WBX_PINMUX_FUNC_PD1_SPI2_SCK \
(STM32_PINMUX_ALT_FUNC_5 | STM32_PUSHPULL_NOPULL)
#define STM32WBX_PINMUX_FUNC_PD3_SPI2_SCK \
Expand Down
5 changes: 4 additions & 1 deletion include/dt-bindings/pinctrl/stm32-pinctrlf1.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,10 @@
/* Hardware master NSS output disabled */
#define STM32_PIN_SPI_MASTER_NSS (STM32_MODE_INPUT | STM32_CNF_IN_FLOAT)
/* Hardware master NSS output enabled */
#define STM32_PIN_SPI_MASTER_NSS_OE (STM32_MODE_OUTPUT | STM32_CNF_ALT_FUNC | STM32_CNF_PUSH_PULL)
#define STM32_PIN_SPI_MASTER_NSS_OE (STM32_MODE_OUTPUT | \
STM32_CNF_ALT_FUNC | \
STM32_CNF_PUSH_PULL | \
STM32_PUPD_PULL_UP)
#define STM32_PIN_SPI_SLAVE_NSS (STM32_MODE_INPUT | STM32_CNF_IN_FLOAT)
#define STM32_PIN_USB (STM32_MODE_INPUT | STM32_CNF_IN_PUPD)

Expand Down

0 comments on commit 90df6a3

Please sign in to comment.