Skip to content

Commit 01b9813

Browse files
Tomasz Bursztykacarlescufi
Tomasz Bursztyka
authored andcommitted
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 <[email protected]>
1 parent 20b8d74 commit 01b9813

20 files changed

+98
-0
lines changed

drivers/spi/spi_b91.c

+5
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,11 @@ static void spi_b91_txrx(const struct device *dev, uint32_t len)
242242
static bool spi_b91_is_config_supported(const struct spi_config *config,
243243
struct spi_b91_cfg *b91_config)
244244
{
245+
if (config->operation & SPI_HALF_DUPLEX) {
246+
LOG_ERR("Half-duplex not supported");
247+
return false;
248+
}
249+
245250
/* check for loop back */
246251
if (config->operation & SPI_MODE_LOOP) {
247252
LOG_ERR("Loop back mode not supported");

drivers/spi/spi_cc13xx_cc26xx.c

+5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ static int spi_cc13xx_cc26xx_configure(const struct device *dev,
5959
return 0;
6060
}
6161

62+
if (config->operation & SPI_HALF_DUPLEX) {
63+
LOG_ERR("Half-duplex not supported");
64+
return -ENOTSUP;
65+
}
66+
6267
/* Slave mode has not been implemented */
6368
if (SPI_OP_MODE_GET(config->operation) != SPI_OP_MODE_MASTER) {
6469
LOG_ERR("Slave mode is not supported");

drivers/spi/spi_dw.c

+5
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ static int spi_dw_configure(const struct spi_dw_config *info,
207207
return 0;
208208
}
209209

210+
if (config->operation & SPI_HALF_DUPLEX) {
211+
LOG_ERR("Half-duplex not supported");
212+
return -ENOTSUP;
213+
}
214+
210215
/* Verify if requested op mode is relevant to this controller */
211216
if (config->operation & SPI_OP_MODE_SLAVE) {
212217
if (!(info->op_modes & SPI_CTX_RUNTIME_OP_MODE_SLAVE)) {

drivers/spi/spi_esp32_spim.c

+5
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,11 @@ static int IRAM_ATTR spi_esp32_configure(const struct device *dev,
235235

236236
ctx->config = spi_cfg;
237237

238+
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
239+
LOG_ERR("Half-duplex not supported");
240+
return -ENOTSUP;
241+
}
242+
238243
if (spi_cfg->operation & SPI_OP_MODE_SLAVE) {
239244
LOG_ERR("Slave mode not supported");
240245
return -ENOTSUP;

drivers/spi/spi_gecko.c

+5
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ static int spi_config(const struct device *dev,
5757
const struct spi_gecko_config *gecko_config = dev->config;
5858
struct spi_gecko_data *data = DEV_DATA(dev);
5959

60+
if (config->operation & SPI_HALF_DUPLEX) {
61+
LOG_ERR("Half-duplex not supported");
62+
return -ENOTSUP;
63+
}
64+
6065
if (SPI_WORD_SIZE_GET(config->operation) != SPI_WORD_SIZE) {
6166
LOG_ERR("Word size must be %d", SPI_WORD_SIZE);
6267
return -ENOTSUP;

drivers/spi/spi_litespi.c

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ static int spi_config(const struct spi_config *config, uint16_t *control)
2525
cs = (uint8_t)(config->slave);
2626
}
2727

28+
if (config->operation & SPI_HALF_DUPLEX) {
29+
LOG_ERR("Half-duplex not supported");
30+
return -ENOTSUP;
31+
}
32+
2833
if (SPI_WORD_SIZE_GET(config->operation) != 8) {
2934
LOG_ERR("Word size must be %d", SPI_WORD_SIZE);
3035
return -ENOTSUP;

drivers/spi/spi_mcux_dspi.c

+5
Original file line numberDiff line numberDiff line change
@@ -575,6 +575,11 @@ static int spi_mcux_configure(const struct device *dev,
575575
return 0;
576576
}
577577

578+
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
579+
LOG_ERR("Half-duplex not supported");
580+
return -ENOTSUP;
581+
}
582+
578583
DSPI_MasterGetDefaultConfig(&master_config);
579584

580585
master_config.whichPcs = spi_cfg->slave;

drivers/spi/spi_mcux_flexcomm.c

+5
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,11 @@ static int spi_mcux_configure(const struct device *dev,
157157
return 0;
158158
}
159159

160+
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
161+
LOG_ERR("Half-duplex not supported");
162+
return -ENOTSUP;
163+
}
164+
160165
word_size = SPI_WORD_SIZE_GET(spi_cfg->operation);
161166
if (word_size > SPI_MAX_DATA_WIDTH) {
162167
LOG_ERR("Word size %d is greater than %d",

drivers/spi/spi_mcux_lpspi.c

+5
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,11 @@ static int spi_mcux_configure(const struct device *dev,
139139
return 0;
140140
}
141141

142+
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
143+
LOG_ERR("Half-duplex not supported");
144+
return -ENOTSUP;
145+
}
146+
142147
LPSPI_MasterGetDefaultConfig(&master_config);
143148

144149
if (spi_cfg->slave > CHIP_SELECT_COUNT) {

drivers/spi/spi_nrfx_spi.c

+5
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ static int configure(const struct device *dev,
100100
return 0;
101101
}
102102

103+
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
104+
LOG_ERR("Half-duplex not supported");
105+
return -ENOTSUP;
106+
}
107+
103108
if (SPI_OP_MODE_GET(spi_cfg->operation) != SPI_OP_MODE_MASTER) {
104109
LOG_ERR("Slave mode is not supported on %s", dev->name);
105110
return -EINVAL;

drivers/spi/spi_nrfx_spim.c

+5
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ static int configure(const struct device *dev,
132132
return 0;
133133
}
134134

135+
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
136+
LOG_ERR("Half-duplex not supported");
137+
return -ENOTSUP;
138+
}
139+
135140
if (SPI_OP_MODE_GET(spi_cfg->operation) != SPI_OP_MODE_MASTER) {
136141
LOG_ERR("Slave mode is not supported on %s", dev->name);
137142
return -EINVAL;

drivers/spi/spi_nrfx_spis.c

+5
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ static int configure(const struct device *dev,
6969
return 0;
7070
}
7171

72+
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
73+
LOG_ERR("Half-duplex not supported");
74+
return -ENOTSUP;
75+
}
76+
7277
if (SPI_OP_MODE_GET(spi_cfg->operation) == SPI_OP_MODE_MASTER) {
7378
LOG_ERR("Master mode is not supported on %s", dev->name);
7479
return -EINVAL;

drivers/spi/spi_oc_simple.c

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ static int spi_oc_simple_configure(const struct spi_oc_simple_cfg *info,
4242
return 0;
4343
}
4444

45+
if (config->operation & SPI_HALF_DUPLEX) {
46+
LOG_ERR("Half-duplex not supported");
47+
return -ENOTSUP;
48+
}
49+
4550
/* Simple SPI only supports master mode */
4651
if (spi_context_is_slave(&spi->ctx)) {
4752
LOG_ERR("Slave mode not supported");

drivers/spi/spi_psoc6.c

+5
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ static int spi_psoc6_configure(const struct device *dev,
216216
return 0;
217217
}
218218

219+
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
220+
LOG_ERR("Half-duplex not supported");
221+
return -ENOTSUP;
222+
}
223+
219224
word_size = SPI_WORD_SIZE_GET(spi_cfg->operation);
220225
if (word_size > SPI_MAX_DATA_WIDTH) {
221226
LOG_ERR("Word size %d is greater than %d",

drivers/spi/spi_rv32m1_lpspi.c

+5
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ static int spi_mcux_configure(const struct device *dev,
140140
return 0;
141141
}
142142

143+
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
144+
LOG_ERR("Half-duplex not supported");
145+
return -ENOTSUP;
146+
}
147+
143148
LPSPI_MasterGetDefaultConfig(&master_config);
144149

145150
if (spi_cfg->slave > CHIP_SELECT_COUNT) {

drivers/spi/spi_sam.c

+5
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ static int spi_sam_configure(const struct device *dev,
6161
return 0;
6262
}
6363

64+
if (config->operation & SPI_HALF_DUPLEX) {
65+
LOG_ERR("Half-duplex not supported");
66+
return -ENOTSUP;
67+
}
68+
6469
if (SPI_OP_MODE_GET(config->operation) != SPI_OP_MODE_MASTER) {
6570
/* Slave mode is not implemented. */
6671
return -ENOTSUP;

drivers/spi/spi_sam0.c

+5
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ static int spi_sam0_configure(const struct device *dev,
7979
return 0;
8080
}
8181

82+
if (config->operation & SPI_HALF_DUPLEX) {
83+
LOG_ERR("Half-duplex not supported");
84+
return -ENOTSUP;
85+
}
86+
8287
if (SPI_OP_MODE_GET(config->operation) != SPI_OP_MODE_MASTER) {
8388
/* Slave mode is not implemented. */
8489
return -ENOTSUP;

drivers/spi/spi_sifive.c

+4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ int spi_config(const struct device *dev, uint32_t frequency,
3232
uint32_t div;
3333
uint32_t fmt_len;
3434

35+
if (operation & SPI_HALF_DUPLEX) {
36+
return -ENOTSUP;
37+
}
38+
3539
if (SPI_OP_MODE_GET(operation) != SPI_OP_MODE_MASTER) {
3640
return -ENOTSUP;
3741
}

drivers/spi/spi_xec_qmspi.c

+4
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@ static int qmspi_configure(const struct device *dev,
181181
return 0;
182182
}
183183

184+
if (config->operation & SPI_HALF_DUPLEX) {
185+
return -ENOTSUP;
186+
}
187+
184188
if (config->operation & (SPI_TRANSFER_LSB | SPI_OP_MODE_SLAVE
185189
| SPI_MODE_LOOP)) {
186190
return -ENOTSUP;

drivers/spi/spi_xlnx_axi_quadspi.c

+5
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ static int xlnx_quadspi_configure(const struct device *dev,
150150
return 0;
151151
}
152152

153+
if (spi_cfg->operation & SPI_HALF_DUPLEX) {
154+
LOG_ERR("Half-duplex not supported");
155+
return -ENOTSUP;
156+
}
157+
153158
if (spi_cfg->slave >= config->num_ss_bits) {
154159
LOG_ERR("unsupported slave %d, num_ss_bits %d",
155160
spi_cfg->slave, config->num_ss_bits);

0 commit comments

Comments
 (0)