Skip to content

Commit e8c51b1

Browse files
DhruvaG2000broonie
authored andcommitted
spi: cadence-quadspi: Add flag for direct mode writes
Create new flag inorder to avoid playing with use_direct_mode flag currently being used throughout the driver. Disable DAC write if auto polling is disabled or CQSPI_DISABLE_DAC_MODE is set. Signed-off-by: Dhruva Gole <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent d4f43a2 commit e8c51b1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

drivers/spi/spi-cadence-quadspi.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ struct cqspi_st {
8484
u32 trigger_address;
8585
u32 wr_delay;
8686
bool use_direct_mode;
87+
bool use_direct_mode_wr;
8788
struct cqspi_flash_pdata f_pdata[CQSPI_MAX_CHIPSELECT];
8889
bool use_dma_read;
8990
u32 pd_dev_id;
@@ -945,6 +946,12 @@ static int cqspi_write_setup(struct cqspi_flash_pdata *f_pdata,
945946
reg = readl(reg_base + CQSPI_REG_WR_COMPLETION_CTRL);
946947
reg |= CQSPI_REG_WR_DISABLE_AUTO_POLL;
947948
writel(reg, reg_base + CQSPI_REG_WR_COMPLETION_CTRL);
949+
/*
950+
* DAC mode require auto polling as flash needs to be polled
951+
* for write completion in case of bubble in SPI transaction
952+
* due to slow CPU/DMA master.
953+
*/
954+
cqspi->use_direct_mode_wr = false;
948955
}
949956

950957
reg = readl(reg_base + CQSPI_REG_SIZE);
@@ -1230,7 +1237,7 @@ static ssize_t cqspi_write(struct cqspi_flash_pdata *f_pdata,
12301237
* data.
12311238
*/
12321239
if (!op->cmd.dtr && cqspi->use_direct_mode &&
1233-
((to + len) <= cqspi->ahb_size)) {
1240+
cqspi->use_direct_mode_wr && ((to + len) <= cqspi->ahb_size)) {
12341241
memcpy_toio(cqspi->ahb_base + to, buf, len);
12351242
return cqspi_wait_idle(cqspi);
12361243
}
@@ -1700,8 +1707,10 @@ static int cqspi_probe(struct platform_device *pdev)
17001707
cqspi->master_ref_clk_hz);
17011708
if (ddata->hwcaps_mask & CQSPI_SUPPORTS_OCTAL)
17021709
master->mode_bits |= SPI_RX_OCTAL | SPI_TX_OCTAL;
1703-
if (!(ddata->quirks & CQSPI_DISABLE_DAC_MODE))
1710+
if (!(ddata->quirks & CQSPI_DISABLE_DAC_MODE)) {
17041711
cqspi->use_direct_mode = true;
1712+
cqspi->use_direct_mode_wr = true;
1713+
}
17051714
if (ddata->quirks & CQSPI_SUPPORT_EXTERNAL_DMA)
17061715
cqspi->use_dma_read = true;
17071716
if (ddata->quirks & CQSPI_NO_SUPPORT_WR_COMPLETION)

0 commit comments

Comments
 (0)