Skip to content

Commit 53f91ea

Browse files
arthur-mmlwkartben
authored andcommitted
drivers: spi: spi_ll_stm32: add support for IO swap
This commit adds a new property in the device-tree bindings for swapping the MISO and MOSI pins of the SPI/I2S peripheral for STM32 microcontrollers that support it. Signed-off-by: Arthur Gay <[email protected]>
1 parent e7aa49c commit 53f91ea

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

drivers/spi/spi_ll_stm32.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,12 @@ static int spi_stm32_configure(const struct device *dev,
692692
LL_SPI_Disable(spi);
693693
LL_SPI_SetBaudRatePrescaler(spi, scaler[br - 1]);
694694

695+
#if defined(SPI_CFG2_IOSWP)
696+
if (cfg->ioswp) {
697+
LL_SPI_EnableIOSwap(cfg->spi);
698+
}
699+
#endif
700+
695701
if (SPI_MODE_GET(config->operation) & SPI_MODE_CPOL) {
696702
LL_SPI_SetClockPolarity(spi, LL_SPI_POLARITY_HIGH);
697703
} else {
@@ -1595,6 +1601,7 @@ static const struct spi_stm32_config spi_stm32_cfg_##id = { \
15951601
.pclk_len = DT_INST_NUM_CLOCKS(id), \
15961602
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(id), \
15971603
.fifo_enabled = SPI_FIFO_ENABLED(id), \
1604+
.ioswp = DT_INST_PROP(id, ioswp), \
15981605
STM32_SPI_IRQ_HANDLER_FUNC(id) \
15991606
IF_ENABLED(DT_HAS_COMPAT_STATUS_OKAY(st_stm32_spi_subghz), \
16001607
(.use_subghzspi_nss = \

drivers/spi/spi_ll_stm32.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ struct spi_stm32_config {
3737
#endif
3838
size_t pclk_len;
3939
const struct stm32_pclken *pclken;
40-
bool fifo_enabled;
40+
bool fifo_enabled: 1;
41+
bool ioswp: 1;
4142
};
4243

4344
#ifdef CONFIG_SPI_STM32_DMA

dts/bindings/spi/st,stm32-spi-common.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,7 @@ properties:
1717

1818
pinctrl-names:
1919
required: true
20+
21+
ioswp:
22+
type: boolean
23+
description: Swap SPI MOSI and MISO pins

0 commit comments

Comments
 (0)