Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: haibo.chen@oss.nxp.com
Cc: imx@lists.linux.dev, Frank.Li@kernel.org
Subject: Re: [PATCH] spi: spi-nxp-fspi: exit stop mode before waiting for DLL lock
Date: Mon, 28 Sep 2026 11:59:07 +0000	[thread overview]
Message-ID: <20260928115907.F1D431F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260928-fspi-fix-v1-1-a0f9288cd5c8@nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] spi: nxp-fspi: DLL registers programmed outside stop mode
--

commit 51952120b76fbf34aadd629657697e2fb0e3c938
Author: Haibo Chen <haibo.chen@nxp.com>

spi: spi-nxp-fspi: exit stop mode before waiting for DLL lock

This commit addresses an issue where the DLL lock polling times out because
the serial root clock is gated in stop mode. To fix this, it moves the
exit from stop mode ahead of the DLL calibration step. However, this
causes the DLL control registers to be programmed while the module is active.

> diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
> index 67d991dd249d2..66cb58f95fdb1 100644
> --- a/drivers/spi/spi-nxp-fspi.c
> +++ b/drivers/spi/spi-nxp-fspi.c
> @@ -898,10 +898,10 @@ static int nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi,
>  	dev_dbg(f->dev, "Target device [CS:%x] selected\n", spi_get_chipselect(spi, 0));
>  
>  	/*
> -	 * Per the FlexSPI reference manual (initialization sequence), MCR0 and
> -	 * the DLL control registers should be configured while the module is in
> -	 * stop mode (MCR0[MDIS] = 1). Enter stop mode before reconfiguring the
> -	 * RX sample clock source and the DLL, then exit stop mode afterwards.
> +	 * Per the FlexSPI reference manual (initialization sequence), MCR0
> +	 * should be configured while the module is in stop mode (MCR0[MDIS] = 1).
> +	 * Enter stop mode before reconfiguring the RX sample clock source, then
> +	 * exit stop mode afterwards.
>  	 */
>  	reg = fspi_readl(f, f->iobase + FSPI_MCR0);
>  	fspi_writel(f, reg | FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0);

[ ... ]

> @@ -936,6 +936,16 @@ static int nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi,
>  	if (ret)
>  		return ret;
>  
> +	/*
> +	 * Exit stop mode before running the DLL calibration. The DLL
> +	 * reference clock is derived from the module clock domain, which is
> +	 * gated while MCR0[MDIS] = 1. Calibrating the DLL in stop mode leaves
> +	 * the STS2 lock bits stuck at 0 (the DLL never runs), so clear MDIS
> +	 * first and let the module and reference clock run.
> +	 */
> +	reg = fspi_readl(f, f->iobase + FSPI_MCR0);
> +	fspi_writel(f, reg & ~FSPI_MCR0_MDIS, f->iobase + FSPI_MCR0);
> +
>  	/*
>  	 * If clock rate > 100MHz, then switch from DLL override mode to
>  	 * DLL calibration mode.
>  	 */
>  	if (rate > 100000000)
>  		nxp_fspi_dll_calibration(f);
>  	else
>  		nxp_fspi_dll_override(f);

[Severity: High]
Since stop mode is exited before calling nxp_fspi_dll_calibration(), does
this result in the DLL registers being programmed while the module and
clocks are active?

Looking at nxp_fspi_dll_calibration(), it writes to the DLL control registers
(FSPI_DLLACR and FSPI_DLLBCR) before polling for the lock:

static void nxp_fspi_dll_calibration(struct nxp_fspi *f)
{
	...
	/* Reset the DLL, set the DLLRESET to 1 and then set to 0 */
	fspi_writel(f, FSPI_DLLACR_DLLRESET, f->iobase + FSPI_DLLACR);
	...
	/* Enable the DLL calibration mode. */
	fspi_writel(f, FSPI_DLLACR_DLLEN | FSPI_DLLACR_SLVDLY(0xF),
		    f->iobase + FSPI_DLLACR);
	...
}

Will writing to the DLL control registers outside of stop mode violate the
hardware constraints or inject severe jitter into the sampling clock domain?

Should the register configuration part of the DLL calibration remain in
stop mode, with only the STS2 lock polling delayed until after stop mode
is exited?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260928-fspi-fix-v1-1-a0f9288cd5c8@nxp.com?part=1

  reply	other threads:[~2026-09-28 11:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 11:53 [PATCH] spi: spi-nxp-fspi: exit stop mode before waiting for DLL lock haibo.chen
2026-09-28 11:59 ` sashiko-bot [this message]
2026-10-04 20:23 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260928115907.F1D431F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=haibo.chen@oss.nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox