Skip to content

Commit

Permalink
drivers: spi: spi_mcux_ecspi: Ignore chip select channel with cs-gpios
Browse files Browse the repository at this point in the history
The internal chip selects are limited to 4, however when using GPIOS
does not pose this limitation.
Also set internal channel to 0 if GPIOS are used.

Signed-off-by: Pieter De Gendt <[email protected]>
(cherry picked from commit 7250e98)
  • Loading branch information
pdgendt authored and github-actions[bot] committed Jan 15, 2025
1 parent c861286 commit 19f66ec
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/spi/spi_mcux_ecspi.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static int spi_mcux_configure(const struct device *dev,
return -ENOTSUP;
}

if (spi_cfg->slave > kECSPI_Channel3) {
if (!spi_cs_is_gpio(spi_cfg) && spi_cfg->slave > kECSPI_Channel3) {
LOG_ERR("Slave %d is greater than %d", spi_cfg->slave, kECSPI_Channel3);
return -EINVAL;
}
Expand All @@ -181,7 +181,8 @@ static int spi_mcux_configure(const struct device *dev,

ECSPI_MasterGetDefaultConfig(&master_config);

master_config.channel = (ecspi_channel_source_t)spi_cfg->slave;
master_config.channel =
spi_cs_is_gpio(spi_cfg) ? kECSPI_Channel0 : (ecspi_channel_source_t)spi_cfg->slave;
master_config.channelConfig.polarity =
(SPI_MODE_GET(spi_cfg->operation) & SPI_MODE_CPOL)
? kECSPI_PolarityActiveLow
Expand Down

0 comments on commit 19f66ec

Please sign in to comment.