Skip to content

Commit 870d6fd

Browse files
Larisa Grigorebroonie
authored andcommitted
spi: spi-fsl-dspi: Use DMA for S32G controller in target mode
Switch to DMA for target mode otherwise the controller is too slow to feed TX FIFO and UNDERFLOW occurs frequently. DMA can work only with 8 and 16 bits per word. 32bits per word is not supported, this is a hardware limitation, so we keep the controller mode in TCFQ mode. Signed-off-by: Larisa Grigore <larisa.grigore@nxp.com> Signed-off-by: Ciprian Marian Costea <ciprianmarian.costea@nxp.com> Signed-off-by: James Clark <james.clark@linaro.org> Link: https://patch.msgid.link/20250522-james-nxp-spi-v2-9-bea884630cfb@linaro.org Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent cac7e50 commit 870d6fd

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

drivers/spi/spi-fsl-dspi.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ enum {
139139
MCF5441X,
140140
VF610,
141141
S32G,
142+
S32G_TARGET,
142143
};
143144

144145
static const struct regmap_range dspi_yes_ranges[] = {
@@ -183,6 +184,7 @@ static const struct regmap_access_table dspi_volatile_table = {
183184

184185
enum {
185186
DSPI_REGMAP,
187+
S32G_DSPI_REGMAP,
186188
DSPI_XSPI_REGMAP,
187189
S32G_DSPI_XSPI_REGMAP,
188190
DSPI_PUSHR,
@@ -198,6 +200,15 @@ static const struct regmap_config dspi_regmap_config[] = {
198200
.rd_table = &dspi_access_table,
199201
.wr_table = &dspi_access_table,
200202
},
203+
[S32G_DSPI_REGMAP] = {
204+
.reg_bits = 32,
205+
.val_bits = 32,
206+
.reg_stride = 4,
207+
.max_register = SPI_RXFR4,
208+
.volatile_table = &dspi_volatile_table,
209+
.wr_table = &s32g_dspi_access_table,
210+
.rd_table = &s32g_dspi_access_table,
211+
},
201212
[DSPI_XSPI_REGMAP] = {
202213
.reg_bits = 32,
203214
.val_bits = 32,
@@ -296,6 +307,12 @@ static const struct fsl_dspi_devtype_data devtype_data[] = {
296307
.fifo_size = 5,
297308
.regmap = &dspi_regmap_config[S32G_DSPI_XSPI_REGMAP],
298309
},
310+
[S32G_TARGET] = {
311+
.trans_mode = DSPI_DMA_MODE,
312+
.max_clock_factor = 1,
313+
.fifo_size = 5,
314+
.regmap = &dspi_regmap_config[S32G_DSPI_REGMAP],
315+
},
299316
};
300317

301318
struct fsl_dspi_dma {
@@ -351,6 +368,12 @@ struct fsl_dspi {
351368
void (*dev_to_host)(struct fsl_dspi *dspi, u32 rxdata);
352369
};
353370

371+
static bool is_s32g_dspi(struct fsl_dspi *data)
372+
{
373+
return data->devtype_data == &devtype_data[S32G] ||
374+
data->devtype_data == &devtype_data[S32G_TARGET];
375+
}
376+
354377
static void dspi_native_host_to_dev(struct fsl_dspi *dspi, u32 *txdata)
355378
{
356379
switch (dspi->oper_word_size) {
@@ -1426,6 +1449,9 @@ static int dspi_probe(struct platform_device *pdev)
14261449
dspi->pushr_tx = 0;
14271450
}
14281451

1452+
if (spi_controller_is_target(ctlr) && is_s32g_dspi(dspi))
1453+
dspi->devtype_data = &devtype_data[S32G_TARGET];
1454+
14291455
if (dspi->devtype_data->trans_mode == DSPI_XSPI_MODE)
14301456
ctlr->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
14311457
else

0 commit comments

Comments
 (0)