From: Pratyush Yadav <p.yadav@ti.com>
To: <jaimeliao@mxic.com.tw>
Cc: <chris.packham@alliedtelesis.co.nz>, <jagan@amarulasolutions.com>,
<vigneshr@ti.com>, <ryder.lee@mediatek.com>,
<weijie.gao@mediatek.com>, <chunfeng.yun@mediatek.com>,
<GSS_MTK_Uboot_upstream@mediatek.com>, <u-boot@lists.denx.de>,
<zhengxunli@mxic.com.tw>
Subject: Re: [v9,23/28] mtd: spi-nor-core: Perform a Soft Reset on shutdown
Date: Fri, 18 Jun 2021 14:55:14 +0530 [thread overview]
Message-ID: <20210618092512.grudqq6vjawt3y5w@ti.com> (raw)
In-Reply-To: <OFA9A848D7.46FE824E-ON482586F8.002F19B3-482586F8.00310A01@mxic.com.tw>
Hi,
On 18/06/21 04:55PM, jaimeliao@mxic.com.tw wrote:
>
> Hi Pratyush
>
>
> +#ifdef CONFIG_SPI_FLASH_SOFT_RESET
> +/**
> + * spi_nor_soft_reset() - perform the JEDEC Software Reset sequence
> + * @nor: the spi_nor structure
> + *
> + * This function can be used to switch from Octal DTR mode to legacy mode
> on a
> + * flash that supports it. The soft reset is executed in Octal DTR mode.
> + *
> + * Return: 0 for success, -errno for failure.
> + */
> +static int spi_nor_soft_reset(struct spi_nor *nor)
> +{
> + struct spi_mem_op op;
> + int ret;
> + enum spi_nor_cmd_ext ext;
> +
> + ext = nor->cmd_ext_type;
> + nor->cmd_ext_type = SPI_NOR_EXT_REPEAT;
> According JEDEC, cmd_ext_type has two different types, REPEAT and INVERT.
> Some Flash vendor using "INVERT" as cmd_ext_type so that it is not
> suitable for hard coding the type as REPEAT.
> Sending twice reset command with different types is clumsy but useful
> before read ID for getting Flash information.
> It would be great if you have any other ideas for this part.
It is possible to discover the extension type from BFPT (if the flash
supports it, that is). But this function is supposed to be called before
anything else to make sure the flash is in a sane state. For that
reason, I don't think SFDP would be a viable approach.
Executing it twice might be a viable option. We need to see how flash
that expect invert react to a repeat opcode, and vice versa.
Anyway, I don't think this is a problem for now. Both the 8D-8D-8D
capable flashes supported with this series expect a repeat opcode.
>
> +
> + op = (struct
> spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRSTEN, 0),
> + SPI_MEM_OP_NO_DUMMY,
> + SPI_MEM_OP_NO_ADDR,
> + SPI_MEM_OP_NO_DATA);
> + spi_nor_setup_op(nor, &op, SNOR_PROTO_8_8_8_DTR);
> + ret = spi_mem_exec_op(nor->spi, &op);
> + if (ret) {
> + dev_warn(nor->dev, "Software reset enable
> failed: %d\n", ret);
> + goto out;
> + }
> +
> + op = (struct
> spi_mem_op)SPI_MEM_OP(SPI_MEM_OP_CMD(SPINOR_OP_SRST, 0),
> + SPI_MEM_OP_NO_DUMMY,
> + SPI_MEM_OP_NO_ADDR,
> + SPI_MEM_OP_NO_DATA);
> + spi_nor_setup_op(nor, &op, SNOR_PROTO_8_8_8_DTR);
> + ret = spi_mem_exec_op(nor->spi, &op);
> + if (ret) {
> + dev_warn(nor->dev, "Software reset
> failed: %d\n", ret);
> + goto out;
> + }
> +
> + /*
> + * Software Reset is not instant, and the delay varies
> from flash to
> + * flash. Looking at a few flashes, most range somewhere
> below 100
> + * microseconds. So, wait for 200ms just to be sure.
> + */
> + udelay(SPI_NOR_SRST_SLEEP_LEN);
> +
> +out:
> + nor->cmd_ext_type = ext;
> + return ret;
> +}
>
>
> Thanks
> Jaime
--
Regards,
Pratyush Yadav
Texas Instruments Inc.
next prev parent reply other threads:[~2021-06-18 9:25 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-18 8:55 Re:[v9,23/28] mtd: spi-nor-core: Perform a Soft Reset on shutdown jaimeliao
2021-06-18 9:25 ` Pratyush Yadav [this message]
2021-06-21 1:59 ` 回信: Re: [v9,23/28] " jaimeliao
2021-06-21 9:55 ` Pratyush Yadav
[not found] ` <OF35AF3B0B.C67AB0B0-ON482586FB.0009A5FD-482586FB.000AF0B8@LocalDomain>
2021-06-21 2:18 ` jaimeliao
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=20210618092512.grudqq6vjawt3y5w@ti.com \
--to=p.yadav@ti.com \
--cc=GSS_MTK_Uboot_upstream@mediatek.com \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=chunfeng.yun@mediatek.com \
--cc=jagan@amarulasolutions.com \
--cc=jaimeliao@mxic.com.tw \
--cc=ryder.lee@mediatek.com \
--cc=u-boot@lists.denx.de \
--cc=vigneshr@ti.com \
--cc=weijie.gao@mediatek.com \
--cc=zhengxunli@mxic.com.tw \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.