Skip to content

Commit 4dbaa33

Browse files
committed
drivers: spi: litex: support SPI_HOLD_ON_CS
support SPI_HOLD_ON_CS. Signed-off-by: Fin Maaß <f.maass@vogl-electronic.com>
1 parent 5325565 commit 4dbaa33

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

drivers/spi/spi_litex_litespi.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,9 @@ static int spi_litex_xfer(const struct device *dev, const struct spi_config *con
236236
spi_litex_spi_do_rx(dev);
237237
} while (spi_context_tx_on(ctx) || spi_context_rx_on(ctx));
238238

239-
litex_write32(0, dev_config->master_cs_addr);
239+
if ((config->operation & SPI_HOLD_ON_CS) == 0) {
240+
litex_write32(0, dev_config->master_cs_addr);
241+
}
240242

241243
spi_context_complete(ctx, dev, 0);
242244

@@ -305,6 +307,13 @@ static int spi_litex_transceive_async(const struct device *dev,
305307
static int spi_litex_release(const struct device *dev, const struct spi_config *config)
306308
{
307309
struct spi_litex_data *data = dev->data;
310+
const struct spi_litex_dev_config *dev_config = dev->config;
311+
312+
if (!spi_context_configured(&data->ctx, config)) {
313+
return -EINVAL;
314+
}
315+
316+
litex_write32(0, dev_config->master_cs_addr);
308317

309318
spi_context_unlock_unconditionally(&data->ctx);
310319
return 0;
@@ -328,7 +337,9 @@ static void spi_litex_irq_handler(const struct device *dev)
328337
} else {
329338
litex_write8(0, dev_config->master_ev_enable_addr);
330339

331-
litex_write32(0, dev_config->master_cs_addr);
340+
if ((ctx->config->operation & SPI_HOLD_ON_CS) == 0) {
341+
litex_write32(0, dev_config->master_cs_addr);
342+
}
332343

333344
spi_context_complete(ctx, dev, 0);
334345
}

0 commit comments

Comments
 (0)