drivers/spi: Return an error on SPI_HALF_DUPLEX for relevant drivers
This feature will need to be, however, implemented driver by driver afterwards. Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
parent
20b8d74d42
commit
01b9813d73
20 changed files with 98 additions and 0 deletions
|
@ -242,6 +242,11 @@ static void spi_b91_txrx(const struct device *dev, uint32_t len)
|
|||
static bool spi_b91_is_config_supported(const struct spi_config *config,
|
||||
struct spi_b91_cfg *b91_config)
|
||||
{
|
||||
if (config->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check for loop back */
|
||||
if (config->operation & SPI_MODE_LOOP) {
|
||||
LOG_ERR("Loop back mode not supported");
|
||||
|
|
|
@ -59,6 +59,11 @@ static int spi_cc13xx_cc26xx_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (config->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Slave mode has not been implemented */
|
||||
if (SPI_OP_MODE_GET(config->operation) != SPI_OP_MODE_MASTER) {
|
||||
LOG_ERR("Slave mode is not supported");
|
||||
|
|
|
@ -207,6 +207,11 @@ static int spi_dw_configure(const struct spi_dw_config *info,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (config->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Verify if requested op mode is relevant to this controller */
|
||||
if (config->operation & SPI_OP_MODE_SLAVE) {
|
||||
if (!(info->op_modes & SPI_CTX_RUNTIME_OP_MODE_SLAVE)) {
|
||||
|
|
|
@ -235,6 +235,11 @@ static int IRAM_ATTR spi_esp32_configure(const struct device *dev,
|
|||
|
||||
ctx->config = spi_cfg;
|
||||
|
||||
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (spi_cfg->operation & SPI_OP_MODE_SLAVE) {
|
||||
LOG_ERR("Slave mode not supported");
|
||||
return -ENOTSUP;
|
||||
|
|
|
@ -57,6 +57,11 @@ static int spi_config(const struct device *dev,
|
|||
const struct spi_gecko_config *gecko_config = dev->config;
|
||||
struct spi_gecko_data *data = DEV_DATA(dev);
|
||||
|
||||
if (config->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (SPI_WORD_SIZE_GET(config->operation) != SPI_WORD_SIZE) {
|
||||
LOG_ERR("Word size must be %d", SPI_WORD_SIZE);
|
||||
return -ENOTSUP;
|
||||
|
|
|
@ -25,6 +25,11 @@ static int spi_config(const struct spi_config *config, uint16_t *control)
|
|||
cs = (uint8_t)(config->slave);
|
||||
}
|
||||
|
||||
if (config->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (SPI_WORD_SIZE_GET(config->operation) != 8) {
|
||||
LOG_ERR("Word size must be %d", SPI_WORD_SIZE);
|
||||
return -ENOTSUP;
|
||||
|
|
|
@ -575,6 +575,11 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
DSPI_MasterGetDefaultConfig(&master_config);
|
||||
|
||||
master_config.whichPcs = spi_cfg->slave;
|
||||
|
|
|
@ -157,6 +157,11 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
word_size = SPI_WORD_SIZE_GET(spi_cfg->operation);
|
||||
if (word_size > SPI_MAX_DATA_WIDTH) {
|
||||
LOG_ERR("Word size %d is greater than %d",
|
||||
|
|
|
@ -139,6 +139,11 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
LPSPI_MasterGetDefaultConfig(&master_config);
|
||||
|
||||
if (spi_cfg->slave > CHIP_SELECT_COUNT) {
|
||||
|
|
|
@ -100,6 +100,11 @@ static int configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (SPI_OP_MODE_GET(spi_cfg->operation) != SPI_OP_MODE_MASTER) {
|
||||
LOG_ERR("Slave mode is not supported on %s", dev->name);
|
||||
return -EINVAL;
|
||||
|
|
|
@ -132,6 +132,11 @@ static int configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (SPI_OP_MODE_GET(spi_cfg->operation) != SPI_OP_MODE_MASTER) {
|
||||
LOG_ERR("Slave mode is not supported on %s", dev->name);
|
||||
return -EINVAL;
|
||||
|
|
|
@ -69,6 +69,11 @@ static int configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (SPI_OP_MODE_GET(spi_cfg->operation) == SPI_OP_MODE_MASTER) {
|
||||
LOG_ERR("Master mode is not supported on %s", dev->name);
|
||||
return -EINVAL;
|
||||
|
|
|
@ -42,6 +42,11 @@ static int spi_oc_simple_configure(const struct spi_oc_simple_cfg *info,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (config->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
/* Simple SPI only supports master mode */
|
||||
if (spi_context_is_slave(&spi->ctx)) {
|
||||
LOG_ERR("Slave mode not supported");
|
||||
|
|
|
@ -216,6 +216,11 @@ static int spi_psoc6_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
word_size = SPI_WORD_SIZE_GET(spi_cfg->operation);
|
||||
if (word_size > SPI_MAX_DATA_WIDTH) {
|
||||
LOG_ERR("Word size %d is greater than %d",
|
||||
|
|
|
@ -140,6 +140,11 @@ static int spi_mcux_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
LPSPI_MasterGetDefaultConfig(&master_config);
|
||||
|
||||
if (spi_cfg->slave > CHIP_SELECT_COUNT) {
|
||||
|
|
|
@ -61,6 +61,11 @@ static int spi_sam_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (config->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (SPI_OP_MODE_GET(config->operation) != SPI_OP_MODE_MASTER) {
|
||||
/* Slave mode is not implemented. */
|
||||
return -ENOTSUP;
|
||||
|
|
|
@ -79,6 +79,11 @@ static int spi_sam0_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (config->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (SPI_OP_MODE_GET(config->operation) != SPI_OP_MODE_MASTER) {
|
||||
/* Slave mode is not implemented. */
|
||||
return -ENOTSUP;
|
||||
|
|
|
@ -32,6 +32,10 @@ int spi_config(const struct device *dev, uint32_t frequency,
|
|||
uint32_t div;
|
||||
uint32_t fmt_len;
|
||||
|
||||
if (operation & SPI_HALF_DUPLEX) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (SPI_OP_MODE_GET(operation) != SPI_OP_MODE_MASTER) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
|
|
@ -181,6 +181,10 @@ static int qmspi_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (config->operation & SPI_HALF_DUPLEX) {
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (config->operation & (SPI_TRANSFER_LSB | SPI_OP_MODE_SLAVE
|
||||
| SPI_MODE_LOOP)) {
|
||||
return -ENOTSUP;
|
||||
|
|
|
@ -150,6 +150,11 @@ static int xlnx_quadspi_configure(const struct device *dev,
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
|
||||
LOG_ERR("Half-duplex not supported");
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
if (spi_cfg->slave >= config->num_ss_bits) {
|
||||
LOG_ERR("unsupported slave %d, num_ss_bits %d",
|
||||
spi_cfg->slave, config->num_ss_bits);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue