Skip to content

Commit 0ee0a8d

Browse files
myguitarkartben
authored andcommitted
drivers: spi: dw: fix txftlr in HSSI controller
The TXFTLR register has 2 major fields which are TFT for triggering interrupt threshold and TXFTLR for starting transfer threshold. This is to ensure that sufficient data is ready for starting transfer. Signed-off-by: Younghyun Park <[email protected]>
1 parent 71d3703 commit 0ee0a8d

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

drivers/spi/spi_dw.c

+12
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,18 @@ static void spi_dw_update_txftlr(const struct device *dev,
323323
} else if (spi->ctx.tx_len < dw_spi_txftlr_dflt) {
324324
reg_data = spi->ctx.tx_len - 1;
325325
}
326+
} else {
327+
#if defined(CONFIG_SPI_DW_HSSI) && defined(CONFIG_SPI_EXTENDED_MODES)
328+
/*
329+
* TXFTLR field in the TXFTLR register is valid only for
330+
* Controller mode operation
331+
*/
332+
if (!spi->ctx.tx_len) {
333+
reg_data = 0U;
334+
} else if (spi->ctx.tx_len < dw_spi_txftlr_dflt) {
335+
reg_data = (spi->ctx.tx_len - 1) << DW_SPI_TXFTLR_TXFTLR_SHIFT;
336+
}
337+
#endif
326338
}
327339

328340
LOG_DBG("TxFTLR: %u", reg_data);

drivers/spi/spi_dw.h

+5
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,11 @@ static int reg_test_bit(uint8_t bit, mm_reg_t addr, uint32_t off)
194194
#define DW_SPI_CTRLR0_SRL_BIT (13)
195195
#endif
196196

197+
#if defined(CONFIG_SPI_DW_HSSI) && defined(CONFIG_SPI_EXTENDED_MODES)
198+
/* TXFTLR setting. Only valid for Controller operation mode. */
199+
#define DW_SPI_TXFTLR_TXFTLR_SHIFT (16)
200+
#endif
201+
197202
#define DW_SPI_CTRLR0_SCPH BIT(DW_SPI_CTRLR0_SCPH_BIT)
198203
#define DW_SPI_CTRLR0_SCPOL BIT(DW_SPI_CTRLR0_SCPOL_BIT)
199204
#define DW_SPI_CTRLR0_SRL BIT(DW_SPI_CTRLR0_SRL_BIT)

0 commit comments

Comments
 (0)