drivers: spi: Update unsupported bit width in SPI driver

Add condition to check the unsupported bit width for Renesas
RA spi and spi_b driver

Signed-off-by: Quy Tran <quy.tran.pz@renesas.com>
This commit is contained in:
Quy Tran 2025-06-02 11:50:22 +07:00 committed by Dan Kalowsky
commit 452f2b150c
2 changed files with 13 additions and 0 deletions

View file

@ -86,6 +86,7 @@ static int ra_spi_b_configure(const struct device *dev, const struct spi_config
{
struct ra_spi_data *data = dev->data;
fsp_err_t fsp_err;
uint8_t word_size = SPI_WORD_SIZE_GET(config->operation);
if (spi_context_configured(&data->ctx, config)) {
/* Nothing to do */
@ -100,6 +101,11 @@ static int ra_spi_b_configure(const struct device *dev, const struct spi_config
return -ENOTSUP;
}
if (word_size < 4 || word_size > 32) {
LOG_ERR("Unsupported SPI word size: %u", word_size);
return -ENOTSUP;
}
if (config->operation & SPI_OP_MODE_SLAVE) {
data->fsp_config.operating_mode = SPI_MODE_SLAVE;
} else {

View file

@ -82,6 +82,7 @@ static int ra_spi_configure(const struct device *dev, const struct spi_config *c
{
struct ra_spi_data *data = dev->data;
fsp_err_t fsp_err;
uint8_t word_size = SPI_WORD_SIZE_GET(config->operation);
if (spi_context_configured(&data->ctx, config)) {
/* Nothing to do */
@ -96,6 +97,12 @@ static int ra_spi_configure(const struct device *dev, const struct spi_config *c
return -ENOTSUP;
}
if (!((word_size >= 8 && word_size <= 16) || word_size == 20 || word_size == 24 ||
word_size == 32)) {
LOG_ERR("Unsupported SPI word size: %u", word_size);
return -ENOTSUP;
}
if (config->operation & SPI_OP_MODE_SLAVE) {
data->fsp_config.operating_mode = SPI_MODE_SLAVE;
} else {