[PATCH RFC v2 18/35] spi: nxp-fspi: Consume dummy cycles directly
Miquel Raynal
miquel.raynal at bootlin.com
Wed Dec 2 03:57:36 PST 2026
On 30/11/2026 at 19:31:25 +08, Bough Chen <haibo.chen at oss.nxp.com> wrote:
> On Fri, Nov 27, 2026 at 02:50:31PM +0000, sashiko-bot at kernel.org wrote:
>> Thank you for your contribution! Sashiko AI review found 1 potential
>> issue to consider:
>> - [High] spi: nxp-fspi: LUT_DUMMY_DDR operand halved in
>> nxp_fspi_prepare_lut()
>> --
>>
>> commit 1599225157c651da7c372805ec30cf72cfe8b69c
>> Author: Miquel Raynal <miquel.raynal at bootlin.com>
>>
>> spi: nxp-fspi: Consume dummy cycles directly
>>
>> This commit enables the dummy_cycles capability in the NXP FlexSPI driver
>> and replaces the dummy byte-to-cycle conversions with op->dummy.ncycles.
>>
>> > diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
>> > index 66cb58f95fdb1..e6fdded67a00e 100644
>> > --- a/drivers/spi/spi-nxp-fspi.c
>> > +++ b/drivers/spi/spi-nxp-fspi.c
>> [ ... ]
>> > @@ -567,8 +567,7 @@ static bool nxp_fspi_supports_op(struct spi_mem *mem,
>> > return false;
>> >
>> > /* Max 64 dummy clock cycles supported */
>> > - if (op->dummy.buswidth &&
>> > - (op->dummy.nbytes * 8 / op->dummy.buswidth > 64))
>> > + if (op->dummy.ncycles > 64)
>> > return false;
>> >
>> > /* Max data length, check controller limits and alignment */
>> > @@ -652,16 +651,15 @@ static void nxp_fspi_prepare_lut(struct nxp_fspi *f,
>> > lutidx++;
>> > }
>> >
>> > - /* dummy bytes, if needed */
>> > - if (op->dummy.nbytes) {
>> > + /* dummy cycles, if needed */
>> > + if (op->dummy.ncycles) {
>> > lutval[lutidx / 2] |= LUT_DEF(lutidx, op->dummy.dtr ? LUT_DUMMY_DDR : LUT_DUMMY,
>> > /*
>> > * Due to FlexSPI controller limitation number of PAD for dummy
>> > * buswidth needs to be programmed as equal to data buswidth.
>> > */
>> > LUT_PAD(op->data.buswidth),
>> > - op->dummy.nbytes * 8 /
>> > - op->dummy.buswidth);
>> > + op->dummy.ncycles);
>> > lutidx++;
>> > }
>>
>> [Severity: High]
>> Does passing op->dummy.ncycles directly to LUT_DUMMY_DDR halve the dummy
>> cycles programmed in DTR mode?
>>
>> In DTR mode, FlexSPI runs the serial root clock at 2x the flash SCLK rate
>> and LUT_DUMMY_DDR counts DDR half-cycles (2 * ncycles). Previously, DTR
>> callers doubled op->dummy.nbytes to account for two transfers per clock,
>> and op->dummy.nbytes * 8 / op->dummy.buswidth intentionally did not divide
>> by 2, yielding 2 * ncycles. With .dummy_cycles set,
>> spi_mem_dummy_bytes_to_cycles() divides by 2 * op->dummy.buswidth when
>> op->dummy.dtr is true (and direct ncycles callers pass full SCLK cycles),
>> so nxp_fspi_prepare_lut() now programs half the required LUT_DUMMY_DDR
>> operand and breaks DTR flash reads.
>
> Correct, I double check the RM, the value here in LUT should be 2 * op->dummy.ncycles.
I will correct it.
> But the value here do not impact the sample result, because current flexspi use external
> DQS to sample the data for OCT DTR mode.
I sent a DQS series, maybe you would like to have a look and enable the
DQS capability for you controllers there. As of today there is no
official handling of DQS, so chips may or may not enable it. This series
clarifies it.
https://lore.kernel.org/linux-spi/179554764437.947306.7383226666322227871.b4-ty@b4/
Thanks,
Miquèl
More information about the linux-amlogic
mailing list