linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael Walle <mwalle@kernel.org>
To: Bough Chen <haibo.chen@nxp.com>
Cc: broonie@kernel.org, Han Xu <han.xu@nxp.com>,
	dl-linux-imx <linux-imx@nxp.com>,
	linux-spi@vger.kernel.org, yogeshgaur.83@gmail.com
Subject: Re: [PATCH 3/5] spi: spi-nxp-fspi: add DTR mode support
Date: Thu, 14 Dec 2023 10:45:09 +0100	[thread overview]
Message-ID: <8d7892a37897520109cc8e609b63a1fc@kernel.org> (raw)
In-Reply-To: <DB7PR04MB4010647E3087EBF90E8BA7B1908CA@DB7PR04MB4010.eurprd04.prod.outlook.com>

Hi,

>> > diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
>> > index 9d6b4d22263c..2562d524149e 100644
>> > --- a/drivers/spi/spi-nxp-fspi.c
>> > +++ b/drivers/spi/spi-nxp-fspi.c
>> > @@ -552,12 +552,22 @@ static void nxp_fspi_prepare_lut(struct nxp_fspi *f,
>> >  	int lutidx = 1, i;
>> >
>> >  	/* cmd */
>> > -	lutval[0] |= LUT_DEF(0, LUT_CMD, LUT_PAD(op->cmd.buswidth),
>> > -			     op->cmd.opcode);
>> > +	if (op->cmd.dtr) {
>> > +		lutval[0] |= LUT_DEF(0, LUT_CMD_DDR,
>> LUT_PAD(op->cmd.buswidth),
>> > +				     op->cmd.opcode >> 8);
>> 
>> Shouldn't we check cmd.nbytes here? You seem to mix dtr with 
>> cmd.nbytes ==
>> 2 here.
> 
> Currently, for DTR mode, all cmd.nbytes == 2. Refer to
> drivers/mtd/spi-nor/core.c : spi_nor_spimem_setup_op()
> But better to check the cmd.nbytes here to make the code more strong.

I'm aware of that, but that might change.

>> > +		lutval[lutidx / 2] |= LUT_DEF(lutidx, LUT_CMD_DDR,
>> > +					      LUT_PAD(op->cmd.buswidth),
>> > +					      op->cmd.opcode & 0x00ff);
>> 
>> And you seem to assume dtr is always octal mode?
> 
> Currently, I only test the octa dtr mode(8D-8D-8D). but here, we config 
> the
> op->cmd.buswidth, op->addr.buswidth, op->dummy.buswidth, 
> op->data.buswidth.
> So I think current LUT config can cover other dts mode, like 1D-8D-8D,
> 1D-4D-4D, 1D-2D-2D, 1D-1D-1D.

Agreed, for the code that follows this. But the 16bit opcode, ie. the
LUT above only makes sense for 8d8d8d. There you have to have
16bit because thats what transferred in one clock cycle.

You could add that to your .supports_op(). I.e. restrict this
driver to only support 8d8d8d. I know that the default op will
already check that, but better be safe.

-michael

  reply	other threads:[~2023-12-14  9:45 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13  9:13 [PATCH 1/5] spi: spi-nxp-fspi: enable runtime pm for fspi haibo.chen
2023-12-13  9:13 ` [PATCH 2/5] spi: spi-nxp-fspi: change the default lut index haibo.chen
2023-12-13 16:24   ` Michael Walle
2023-12-14  2:10     ` Bough Chen
2023-12-14  3:04   ` Adam Ford
2023-12-14  4:00     ` Bough Chen
2023-12-13  9:13 ` [PATCH 3/5] spi: spi-nxp-fspi: add DTR mode support haibo.chen
2023-12-13 16:53   ` Michael Walle
2023-12-14  3:09     ` Bough Chen
2023-12-14  9:45       ` Michael Walle [this message]
2023-12-13  9:13 ` [PATCH 4/5] spi: spi-nxp-fspi: add function to select sample clock source for flash reading haibo.chen
2023-12-13 17:21   ` Michael Walle
2023-12-14  7:54     ` Bough Chen
2023-12-14  8:56       ` Michael Walle
2023-12-13  9:13 ` [PATCH 5/5] spi: spi-nxp-fspi: Add quirk to disable DTR support haibo.chen

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=8d7892a37897520109cc8e609b63a1fc@kernel.org \
    --to=mwalle@kernel.org \
    --cc=broonie@kernel.org \
    --cc=haibo.chen@nxp.com \
    --cc=han.xu@nxp.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-spi@vger.kernel.org \
    --cc=yogeshgaur.83@gmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).