From c935508c0591138ca058b7914a04070188bead46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ya=C3=ABl=20Boutreux?= Date: Wed, 24 Jul 2019 16:18:57 +0200 Subject: [PATCH] drivers: spi: spi_ll_stm32: set NSS before mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit solves an issue where the NSS must be set before the mode on the stm32mp157c_dk2, else LL_SPI_SetMode won't affect the mode registry. stm32mp1x (and stm32h7) LL function SPI_Init seems to also define first the NSS then the mode, unlike other STM32 boards where this is not specified. Changing the order shouldn't have bad repercussions on other boards, ZephyrnSPI driver test has been passed successfully on disco_l475_iot1 board. Signed-off-by: Yaƫl Boutreux Signed-off-by: Arnaud Pouliquen Signed-off-by: Alexandre Torgue --- drivers/spi/spi_ll_stm32.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi_ll_stm32.c b/drivers/spi/spi_ll_stm32.c index 8e1b55bbb50..b96a501a912 100644 --- a/drivers/spi/spi_ll_stm32.c +++ b/drivers/spi/spi_ll_stm32.c @@ -307,12 +307,6 @@ static int spi_stm32_configure(struct device *dev, LL_SPI_DisableCRC(spi); - if (config->operation & SPI_OP_MODE_SLAVE) { - LL_SPI_SetMode(spi, LL_SPI_MODE_SLAVE); - } else { - LL_SPI_SetMode(spi, LL_SPI_MODE_MASTER); - } - if (config->cs || !IS_ENABLED(CONFIG_SPI_STM32_USE_HW_SS)) { LL_SPI_SetNSSMode(spi, LL_SPI_NSS_SOFT); } else { @@ -323,6 +317,12 @@ static int spi_stm32_configure(struct device *dev, } } + if (config->operation & SPI_OP_MODE_SLAVE) { + LL_SPI_SetMode(spi, LL_SPI_MODE_SLAVE); + } else { + LL_SPI_SetMode(spi, LL_SPI_MODE_MASTER); + } + if (SPI_WORD_SIZE_GET(config->operation) == 8) { LL_SPI_SetDataWidth(spi, LL_SPI_DATAWIDTH_8BIT); } else {