From: Jaime Liao <jaimeliao.tw@gmail.com>
To: linux-mtd@lists.infradead.org, tudor.ambarus@linaro.org,
pratyush@kernel.org, michael@walle.cc, miquel.raynal@bootlin.com
Cc: leoyu@mxic.com.tw, jaimeliao@mxic.com.tw
Subject: [PATCH] mtd: spi-nor: core: Introduce spi_nor_abort_octal_dtr()
Date: Thu, 7 Dec 2023 15:51:47 +0800 [thread overview]
Message-ID: <20231207075147.21851-1-jaimeliao.tw@gmail.com> (raw)
From: JaimeLiao <jaimeliao@mxic.com.tw>
Some flashes contains 8D_8D_8D information in SFDP but did not enter
octal DTR mode if conditions are not satisfied.
However, still carry the opcode and dummy cycle for the octal DTR
protocol.
So that spi_nor_abort_octal_dtr() could abort octal DTR capability
then recall spi_nor_select_read/pp() for re-select a suitable
protocol.
Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
---
drivers/mtd/spi-nor/core.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 1c443fe568cf..7cefab1d29d5 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3083,6 +3083,29 @@ static int spi_nor_init_params(struct spi_nor *nor)
return spi_nor_late_init_params(nor);
}
+/** spi_nor_abort_octal_dtr() - abort octal dtr capability
+ * @nor: pointer to a 'struct spi_nor'
+ *
+ * Return: 0 on success, -errno otherwise.
+ */
+static int spi_nor_abort_octal_dtr(struct spi_nor *nor)
+{
+ int err;
+
+ /* Abort octal dtr capability and re-select read and pp */
+ nor->params->hwcaps.mask &= ~SNOR_HWCAPS_X_X_X_DTR;
+ err = spi_nor_select_read(nor, nor->params->hwcaps.mask);
+ if (err)
+ return err;
+
+ err = spi_nor_select_pp(nor, nor->params->hwcaps.mask);
+ if (err)
+ return err;
+
+ return 0;
+
+}
+
/** spi_nor_set_octal_dtr() - enable or disable Octal DTR I/O.
* @nor: pointer to a 'struct spi_nor'
* @enable: whether to enable or disable Octal DTR
@@ -3094,14 +3117,14 @@ static int spi_nor_set_octal_dtr(struct spi_nor *nor, bool enable)
int ret;
if (!nor->params->set_octal_dtr)
- return 0;
+ return spi_nor_abort_octal_dtr(nor);
if (!(nor->read_proto == SNOR_PROTO_8_8_8_DTR &&
nor->write_proto == SNOR_PROTO_8_8_8_DTR))
- return 0;
+ return spi_nor_abort_octal_dtr(nor);
if (!(nor->flags & SNOR_F_IO_MODE_EN_VOLATILE))
- return 0;
+ return spi_nor_abort_octal_dtr(nor);
ret = nor->params->set_octal_dtr(nor, enable);
if (ret)
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next reply other threads:[~2023-12-07 7:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-07 7:51 Jaime Liao [this message]
2023-12-11 10:51 ` [PATCH] mtd: spi-nor: core: Introduce spi_nor_abort_octal_dtr() Michael Walle
2023-12-12 9:05 ` liao jaime
2023-12-12 13:37 ` Michael Walle
2023-12-13 2:37 ` liao jaime
2023-12-13 8:48 ` Michael Walle
2023-12-13 9:05 ` liao jaime
2023-12-13 9:10 ` Michael Walle
2023-12-13 9:16 ` liao jaime
2024-01-29 13:01 ` Pratyush Yadav
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=20231207075147.21851-1-jaimeliao.tw@gmail.com \
--to=jaimeliao.tw@gmail.com \
--cc=jaimeliao@mxic.com.tw \
--cc=leoyu@mxic.com.tw \
--cc=linux-mtd@lists.infradead.org \
--cc=michael@walle.cc \
--cc=miquel.raynal@bootlin.com \
--cc=pratyush@kernel.org \
--cc=tudor.ambarus@linaro.org \
/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