Re: [PATCH v11 11/19] spi: cadence-quadspi: enable PHY for direct reads

From: Mark Brown

Date: Sun Nov 15 2026 - 14:02:42 EST


> Add cqspi_tune_phy_read() to toggle PHY mode around a direct-mode DMA
> read. On enable: reprogram the DLL from the per-CS calibration result
> when the hardware values differ (handles alternating PHY reads across
> chip selects with different calibration), configure read-capture for
> the tuned delay, assert PHY_EN and PHY_PIPELINE in CONFIG, and reduce
> the dummy cycle count by one since the PHY data-capture pipeline
> absorbs that latency. The controller is confirmed idle before CONFIG
> or RD_INSTR is touched in either direction -- including on disable,
> since the preceding read may still be draining.

> +static int cqspi_tune_phy_read(struct cqspi_flash_pdata *f_pdata, bool enable)
> +{

> + ret = cqspi_phy_reprogram_dll(f_pdata);

If we fail here should we just give up on using tuned mode?

> + cqspi_readdata_capture(cqspi, !f_pdata->use_dqs, f_pdata->use_dqs,

Calibration runs the capture with CQSPI_REG_READCAPTURE_EDGE_LSB but
that's not set for actual transfers - is that not going to be an issue
for SDR?

> +static int cqspi_direct_read_fallback(struct cqspi_flash_pdata *f_pdata,
> + const struct spi_mem_op *op,
> + unsigned long max_speed_hz,
> + u32 post_config_max_speed_hz)
> +{
> + struct cqspi_st *cqspi = f_pdata->cqspi;
> + loff_t from = op->addr.val;
> + size_t len = op->data.nbytes;
> + u_char *buf = op->data.buf.in;
> + unsigned long configured_sclk = cqspi->sclk;
> + bool reclock = op->max_freq == post_config_max_speed_hz &&
> + configured_sclk != max_speed_hz;
> + int ret = 0;
> +
> + /* Drop to the safe rate for this untuned transfer; PHY isn't used. */
> + if (reclock)
> + cqspi_configure(f_pdata, max_speed_hz);

Does this DTRT when we get here from cqspi_phy_check_pattern()?

--
Mark Brown <broonie@xxxxxxxxxx>