Linux-mtd Archive on lore.kernel.org
 help / color / mirror / Atom feed
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 <jaimeliao.tw@gmail.com>
Subject: [PATCH v1 2/3] mtd: spi-nor: Add features support by parse sfdp
Date: Thu, 13 Jul 2023 18:50:57 +0800	[thread overview]
Message-ID: <20230713105058.101321-3-jaimeliao.tw@gmail.com> (raw)
In-Reply-To: <20230713105058.101321-1-jaimeliao.tw@gmail.com>

From: JaimeLiao <jaimeliao.tw@gmail.com>

Add SECT_4K, DUAL_READ, QUAD_READ, OCTAL_DTR_READ feature
checking by parsing sfdp tables.

Signed-off-by: JaimeLiao <jaimeliao.tw@gmail.com>
---
 drivers/mtd/spi-nor/sfdp.c | 25 +++++++++++++++++++++++++
 drivers/mtd/spi-nor/sfdp.h |  2 ++
 2 files changed, 27 insertions(+)

diff --git a/drivers/mtd/spi-nor/sfdp.c b/drivers/mtd/spi-nor/sfdp.c
index b3b11dfed789..cff3e9d6d061 100644
--- a/drivers/mtd/spi-nor/sfdp.c
+++ b/drivers/mtd/spi-nor/sfdp.c
@@ -463,6 +463,24 @@ static int spi_nor_parse_bfpt(struct spi_nor *nor,
 	/* Fix endianness of the BFPT DWORDs. */
 	le32_to_cpu_array(bfpt.dwords, BFPT_DWORD_MAX);
 
+	/* Checking Sector Size 4K */
+	switch (bfpt.dwords[SFDP_DWORD(1)] & BFPT_DWORD1_SECT_SIZE_MASK ) {
+	case BFPT_DWORD1_SUPPORT_SECT_4K:
+		nor->flags |= SNOR_F_SECT_4K;
+	default:
+		break;
+	}
+
+	/* Checking 1-1-2 Fast Read */
+	if (bfpt.dwords[SFDP_DWORD(1)] & BFPT_DWORD1_FAST_READ_1_1_2) {
+		nor->flags |= SNOR_F_DUAL_READ;
+	}
+
+	/* Checking 1-1-4 Fast Read */
+	if (bfpt.dwords[SFDP_DWORD(1)] & BFPT_DWORD1_FAST_READ_1_1_4) {
+		nor->flags |= SNOR_F_QUAD_READ;
+	}
+
 	/* Number of address bytes. */
 	switch (bfpt.dwords[SFDP_DWORD(1)] & BFPT_DWORD1_ADDRESS_BYTES_MASK) {
 	case BFPT_DWORD1_ADDRESS_BYTES_3_ONLY:
@@ -1218,6 +1236,7 @@ static int spi_nor_parse_profile1(struct spi_nor *nor,
 }
 
 #define SCCR_DWORD22_OCTAL_DTR_EN_VOLATILE		BIT(31)
+#define SCCR_DWORD22_OCTAL_DTR_MODE			BIT(23)
 
 /**
  * spi_nor_parse_sccr() - Parse the Status, Control and Configuration Register
@@ -1264,6 +1283,12 @@ static int spi_nor_parse_sccr(struct spi_nor *nor,
 		      dwords[SFDP_DWORD(22)]))
 		nor->flags |= SNOR_F_IO_MODE_EN_VOLATILE;
 
+	if (FIELD_GET(SCCR_DWORD22_OCTAL_DTR_MODE,
+		      dwords[SFDP_DWORD(22)])) {
+		nor->flags |= SNOR_F_OCTAL_DTR_READ;
+		nor->flags |= SNOR_F_OCTAL_DTR_PP;
+	}
+
 out:
 	kfree(dwords);
 	return ret;
diff --git a/drivers/mtd/spi-nor/sfdp.h b/drivers/mtd/spi-nor/sfdp.h
index 6eb99e1cdd61..84a98e3f8710 100644
--- a/drivers/mtd/spi-nor/sfdp.h
+++ b/drivers/mtd/spi-nor/sfdp.h
@@ -31,6 +31,8 @@ struct sfdp_bfpt {
 #define BFPT_DWORD_MAX_JESD216B			16
 
 /* 1st DWORD. */
+#define BFPT_DWORD1_SECT_SIZE_MASK		GENMASK(1, 0)
+#define BFPT_DWORD1_SUPPORT_SECT_4K		(0x1UL << 0)
 #define BFPT_DWORD1_FAST_READ_1_1_2		BIT(16)
 #define BFPT_DWORD1_ADDRESS_BYTES_MASK		GENMASK(18, 17)
 #define BFPT_DWORD1_ADDRESS_BYTES_3_ONLY	(0x0UL << 17)
-- 
2.25.1


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

  parent reply	other threads:[~2023-07-13 10:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-13 10:50 [PATCH v1 0/3] mtd: spi-nor: Modify rule of parse SFDP Jaime Liao
2023-07-13 10:50 ` [PATCH v1 1/3] mtd: spi-nor: Modify rule for parse sfdp Jaime Liao
2023-07-13 11:25   ` Tudor Ambarus
2023-07-17  1:10     ` liao jaime
2023-07-13 10:50 ` Jaime Liao [this message]
2023-07-13 10:50 ` [PATCH v1 3/3] mtd: spi-nor: change MACRO for flash ID tables Jaime Liao

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=20230713105058.101321-3-jaimeliao.tw@gmail.com \
    --to=jaimeliao.tw@gmail.com \
    --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