From aa464a9d6705eb4fac9dd7432b6454117256c143 Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Fri, 12 Nov 2021 22:54:19 +0100 Subject: [PATCH] spi: Fix the Pcs setup for NXP's K6xF processors Without this change, when DTS SPI device node has node ID = <0>, the value of 0 is assigned during SPI configuration and written to whichPcs member in master_config structure. This value wrongly overrides the default value read from NXP's DSPI HAL (kDSPI_Pcs0 = 1U << 0). Such situation occurs on ip_k66f board, where the DSA device - controlled via SPI has the node ID equal to 0 (i.e. reg = <0>). Signed-off-by: Lukasz Majewski --- drivers/spi/spi_mcux_dspi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi_mcux_dspi.c b/drivers/spi/spi_mcux_dspi.c index 607b37f49f4..601d2589626 100644 --- a/drivers/spi/spi_mcux_dspi.c +++ b/drivers/spi/spi_mcux_dspi.c @@ -582,7 +582,7 @@ static int spi_mcux_configure(const struct device *dev, DSPI_MasterGetDefaultConfig(&master_config); - master_config.whichPcs = spi_cfg->slave; + master_config.whichPcs = 1U << spi_cfg->slave; master_config.whichCtar = config->which_ctar; master_config.pcsActiveHighOrLow = (spi_cfg->operation & SPI_CS_ACTIVE_HIGH) ? @@ -646,7 +646,7 @@ static int spi_mcux_configure(const struct device *dev, /* record frame_size setting for DMA */ data->frame_size = word_size; /* keep the pcs settings */ - data->which_pcs = spi_cfg->slave; + data->which_pcs = 1U << spi_cfg->slave; #ifdef CONFIG_MCUX_DSPI_EDMA_SHUFFLE_DATA mcux_init_inner_buffer_with_cmd(dev, 0); #endif