All of lore.kernel.org
 help / color / mirror / Atom feed
From: JaimeLiao <jaimeliao.tw@gmail.com>
To: u-boot@lists.denx.de, jagan@amarulasolutions.com,
	vigneshr@ti.com, p.yadav@ti.com
Cc: zhengxunli@mxic.com.tw, ycllin@mxic.com.tw,
	jaimeliao@mxic.com.tw, JaimeLiao <jaimeliao.tw@gmail.com>
Subject: [PATCH 2/4] mtd: spi-nor-core: Adding different type of command extension in Soft Reset
Date: Fri, 13 Aug 2021 15:25:50 +0800	[thread overview]
Message-ID: <20210813072552.21772-3-jaimeliao.tw@gmail.com> (raw)
In-Reply-To: <20210813072552.21772-1-jaimeliao.tw@gmail.com>

Power-on-Reset is a method to restore flash back to 1S-1S-1S mode from 8D-8D-8D
in the begging of probe.

Command extension type is not standardized across flash vendors in DTR mode.

For suiting different vendor flash devices, having second times Softreset with
different types is clumsy but useful in the begging of probe.

Signed-off-by: JaimeLiao <jaimeliao.tw@gmail.com>
---
 drivers/mtd/spi/spi-nor-core.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 6b195b1fd3..be6c58ad40 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -3684,6 +3684,36 @@ static int spi_nor_soft_reset(struct spi_nor *nor)
 	 */
 	udelay(SPI_NOR_SRST_SLEEP_LEN);
 
+	/* Manufacturers with different command extension type. For suitting
+	 * different flash devices, using command extension type is equal "INVERT"
+	 * when second time Software Reset.
+	 */
+
+	nor->cmd_ext_type = SPI_NOR_EXT_INVERT;
+	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;
+	}
+
+	udelay(SPI_NOR_SRST_SLEEP_LEN);
+
 out:
 	nor->cmd_ext_type = ext;
 	return ret;
-- 
2.17.1


  parent reply	other threads:[~2021-08-13 12:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-13  7:25 [PATCH 0/4] Add octal DTR support for Macronix flash JaimeLiao
2021-08-13  7:25 ` [PATCH 1/4] mtd: spi-nor: macronix: add support for Macronix octaflash JaimeLiao
2021-08-13 18:06   ` Pratyush Yadav
2021-08-23  1:12     ` liao jaime
2021-08-13  7:25 ` JaimeLiao [this message]
2021-08-13  7:25 ` [PATCH 3/4] mtd: spi-nor-core: set 4byte opcode when possible JaimeLiao
2021-08-13  7:25 ` [PATCH 4/4] mtd: spi-nor-core: Add support for Macronix Octal flash 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=20210813072552.21772-3-jaimeliao.tw@gmail.com \
    --to=jaimeliao.tw@gmail.com \
    --cc=jagan@amarulasolutions.com \
    --cc=jaimeliao@mxic.com.tw \
    --cc=p.yadav@ti.com \
    --cc=u-boot@lists.denx.de \
    --cc=vigneshr@ti.com \
    --cc=ycllin@mxic.com.tw \
    --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.