Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Arseniy Krasnov <avkrasnov@sberdevices.ru>
To: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Liang Yang <liang.yang@amlogic.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzysztof.kozlowski+dt@linaro.org>,
	Neil Armstrong <neil.armstrong@linaro.org>,
	Kevin Hilman <khilman@baylibre.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	<oxffffaa@gmail.com>, <kernel@sberdevices.ru>,
	<linux-mtd@lists.infradead.org>, <devicetree@vger.kernel.org>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-amlogic@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v3 2/2] mtd: rawnand: meson: waiting w/o wired ready/busy pin
Date: Tue, 4 Jul 2023 20:32:13 +0300	[thread overview]
Message-ID: <59246d83-7c4b-8b34-3173-71bdb698c2aa@sberdevices.ru> (raw)
In-Reply-To: <73849b9c-0700-4946-84a2-428f98f0a6d6@sberdevices.ru>



On 04.07.2023 16:07, Arseniy Krasnov wrote:
> 
> 
> On 04.07.2023 16:12, Miquel Raynal wrote:
>> Hi Arseniy,
>>
>> avkrasnov@sberdevices.ru wrote on Tue, 4 Jul 2023 15:46:18 +0300:
>>
>>> On 04.07.2023 15:43, Miquel Raynal wrote:
>>>> Hi Arseniy,
>>>>
>>>> AVKrasnov@sberdevices.ru wrote on Thu, 8 Jun 2023 07:47:28 +0300:
>>>>   
>>>>> If there is no wired ready/busy pin, classic way to wait for command
>>>>> completion is to use function 'nand_soft_waitrdy()'. Meson NAND has
>>>>> special command which allows to wait for NAND_STATUS_READY bit without
>>>>> reading status in a software loop (as 'nand_soft_waitrdy()' does). To
>>>>> use it send this command along with NAND_CMD_STATUS, then wait for an
>>>>> interrupt, and after interrupt send NAND_CMD_READ0. So this feature
>>>>> allows to use interrupt driven waiting without wired ready/busy pin.
>>>>>
>>>>> Suggested-by: Liang Yang <liang.yang@amlogic.com>
>>>>> Signed-off-by: Arseniy Krasnov <AVKrasnov@sberdevices.ru>
>>>>> ---
>>>>>  drivers/mtd/nand/raw/meson_nand.c | 77 +++++++++++++++++++++++++++++--
>>>>>  1 file changed, 73 insertions(+), 4 deletions(-)
>>>>>
>>>>> diff --git a/drivers/mtd/nand/raw/meson_nand.c b/drivers/mtd/nand/raw/meson_nand.c
>>>>> index 074e14225c06..9f05e113b4ea 100644
>>>>> --- a/drivers/mtd/nand/raw/meson_nand.c
>>>>> +++ b/drivers/mtd/nand/raw/meson_nand.c
>>>>> @@ -38,6 +38,7 @@
>>>>>  #define NFC_CMD_SCRAMBLER_DISABLE	0
>>>>>  #define NFC_CMD_SHORTMODE_DISABLE	0
>>>>>  #define NFC_CMD_RB_INT		BIT(14)
>>>>> +#define NFC_CMD_RB_INT_NO_PIN	((0xb << 10) | BIT(18) | BIT(16))
>>>>>  
>>>>>  #define NFC_CMD_GET_SIZE(x)	(((x) >> 22) & GENMASK(4, 0))
>>>>>  
>>>>> @@ -179,6 +180,7 @@ struct meson_nfc {
>>>>>  	u32 info_bytes;
>>>>>  
>>>>>  	unsigned long assigned_cs;
>>>>> +	bool no_rb_pin;
>>>>>  };
>>>>>  
>>>>>  enum {
>>>>> @@ -392,7 +394,42 @@ static void meson_nfc_set_data_oob(struct nand_chip *nand,
>>>>>  	}
>>>>>  }
>>>>>  
>>>>> -static int meson_nfc_queue_rb(struct meson_nfc *nfc, int timeout_ms)
>>>>> +static int meson_nfc_wait_no_rb_pin(struct meson_nfc *nfc, int timeout_ms,
>>>>> +				    bool need_cmd_read0)
>>>>> +{
>>>>> +	u32 cmd, cfg;
>>>>> +
>>>>> +	meson_nfc_cmd_idle(nfc, nfc->timing.twb);
>>>>> +	meson_nfc_drain_cmd(nfc);
>>>>> +	meson_nfc_wait_cmd_finish(nfc, CMD_FIFO_EMPTY_TIMEOUT);
>>>>> +
>>>>> +	cfg = readl(nfc->reg_base + NFC_REG_CFG);
>>>>> +	cfg |= NFC_RB_IRQ_EN;
>>>>> +	writel(cfg, nfc->reg_base + NFC_REG_CFG);
>>>>> +
>>>>> +	reinit_completion(&nfc->completion);
>>>>> +	cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_STATUS;
>>>>> +	writel(cmd, nfc->reg_base + NFC_REG_CMD);
>>>>> +
>>>>> +	/* use the max erase time as the maximum clock for waiting R/B */
>>>>> +	cmd = NFC_CMD_RB | NFC_CMD_RB_INT_NO_PIN | nfc->timing.tbers_max;
>>>>> +	writel(cmd, nfc->reg_base + NFC_REG_CMD);
>>>>> +
>>>>> +	if (!wait_for_completion_timeout(&nfc->completion,
>>>>> +					 msecs_to_jiffies(timeout_ms)))
>>>>> +		return -ETIMEDOUT;
>>>>> +
>>>>> +	if (need_cmd_read0) {
>>>>> +		cmd = nfc->param.chip_select | NFC_CMD_CLE | NAND_CMD_READ0;
>>>>> +		writel(cmd, nfc->reg_base + NFC_REG_CMD);
>>>>> +		meson_nfc_drain_cmd(nfc);
>>>>> +		meson_nfc_wait_cmd_finish(nfc, CMD_FIFO_EMPTY_TIMEOUT);
>>>>> +	}  
>>>>
>>>> I forgot about this, you should avoid open coding core helpers, can you
>>>> please send a followup patch to use nand_status_op() and
>>>> nand_exit_status_op() ?  
>>>
>>> A ok, so:
>>> 1) Sending NAND_CMD_STATUS goes to nand_status_op()
>>> 2) Sending NAND_CMD_READ0 goes to nand_exit_status_op()
>>>
>>> Ok, no problem! I'll prepare and send it on this week!
>>
>> Exactly. Sorry I had this in mind but I likely forgot to write it
>> down.
> 
> Ok, got it!

Hm, seems 'int nand_exit_status_op(struct nand_chip *chip)' is not exported,
so I can't use it in the Meson module. While 'nand_status_op()' works ok.
May I can export 'nand_exit_status_op()?'

Thanks, Arseniy


> 
> Thanks, Arseniy
> 
>>
>> Thanks,
>> Miquèl

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2023-07-04 17:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08  4:47 [PATCH v3 0/2] Meson NAND: waiting w/o wired ready/busy pin Arseniy Krasnov
2023-06-08  4:47 ` [PATCH v3 1/2] dt-bindings: nand: meson: Fix 'nand-rb' property Arseniy Krasnov
2023-06-08 12:01   ` Krzysztof Kozlowski
2023-06-09 15:25   ` Miquel Raynal
2023-06-08  4:47 ` [PATCH v3 2/2] mtd: rawnand: meson: waiting w/o wired ready/busy pin Arseniy Krasnov
2023-06-09 15:24   ` Miquel Raynal
2023-07-04 12:43   ` Miquel Raynal
2023-07-04 12:46     ` Arseniy Krasnov
2023-07-04 13:12       ` Miquel Raynal
2023-07-04 13:07         ` Arseniy Krasnov
2023-07-04 17:32           ` Arseniy Krasnov [this message]
2023-07-05  7:07             ` Miquel Raynal

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=59246d83-7c4b-8b34-3173-71bdb698c2aa@sberdevices.ru \
    --to=avkrasnov@sberdevices.ru \
    --cc=devicetree@vger.kernel.org \
    --cc=jbrunet@baylibre.com \
    --cc=kernel@sberdevices.ru \
    --cc=khilman@baylibre.com \
    --cc=krzysztof.kozlowski+dt@linaro.org \
    --cc=liang.yang@amlogic.com \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=neil.armstrong@linaro.org \
    --cc=oxffffaa@gmail.com \
    --cc=richard@nod.at \
    --cc=robh+dt@kernel.org \
    --cc=vigneshr@ti.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