linux-mtd.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mtd: spi-nor: core: Discard HW capabilities if no enable function
@ 2023-12-19 10:21 Jaime Liao
  2023-12-19 10:21 ` [PATCH v3] mtd: spi-nor: sfdp: Get the 1-1-8 and 1-8-8 protocol from SFDP Jaime Liao
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Jaime Liao @ 2023-12-19 10:21 UTC (permalink / raw)
  To: linux-mtd, tudor.ambarus, pratyush, mwalle, miquel.raynal
  Cc: leoyu, jaimeliao

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

Discard corresponding HW capabilities to prevent carrying the
wrong protocol if no QUAD/Octal DTR enable function hooked.

Signed-off-by: JaimeLiao <jaimeliao@mxic.com.tw>
---
changes in v2
 - Add SNOR_HWCAPS_8_8_8_DTR
 - Restore the enable function judgement in spi_nor_set_octal_dtr()
 - Restore the enable function judgement in spi_nor_quad_enable()
---
 drivers/mtd/spi-nor/core.c  | 7 +++++++
 include/linux/mtd/spi-nor.h | 6 ++++++
 2 files changed, 13 insertions(+)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 1c443fe568cf..14359101c6cf 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2621,6 +2621,13 @@ static int spi_nor_default_setup(struct spi_nor *nor,
 	 */
 	shared_mask = hwcaps->mask & params->hwcaps.mask;
 
+	/* Mask out Octal DTR if no enable function */
+	if (!params->set_octal_dtr)
+		shared_mask &= ~SNOR_HWCAPS_8_8_8_DTR;
+
+	if (!params->quad_enable)
+		shared_mask &= ~SNOR_HWCAPS_4_4_4;
+
 	if (nor->spimem) {
 		/*
 		 * When called from spi_nor_probe(), all caps are set and we
diff --git a/include/linux/mtd/spi-nor.h b/include/linux/mtd/spi-nor.h
index cdcfe0fd2e7d..78a119192ee0 100644
--- a/include/linux/mtd/spi-nor.h
+++ b/include/linux/mtd/spi-nor.h
@@ -266,6 +266,12 @@ struct spi_nor_hwcaps {
 #define SNOR_HWCAPS_PP_8_8_8		BIT(22)
 #define SNOR_HWCAPS_PP_8_8_8_DTR	BIT(23)
 
+#define SNOR_HWCAPS_4_4_4	(SNOR_HWCAPS_READ_4_4_4 |	\
+				 SNOR_HWCAPS_PP_4_4_4)
+
+#define SNOR_HWCAPS_8_8_8_DTR	(SNOR_HWCAPS_READ_8_8_8_DTR |	\
+				 SNOR_HWCAPS_PP_8_8_8_DTR)
+
 #define SNOR_HWCAPS_X_X_X	(SNOR_HWCAPS_READ_2_2_2 |	\
 				 SNOR_HWCAPS_READ_4_4_4 |	\
 				 SNOR_HWCAPS_READ_8_8_8 |	\
-- 
2.25.1


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

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-12-20  9:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-12-19 10:21 [PATCH v2] mtd: spi-nor: core: Discard HW capabilities if no enable function Jaime Liao
2023-12-19 10:21 ` [PATCH v3] mtd: spi-nor: sfdp: Get the 1-1-8 and 1-8-8 protocol from SFDP Jaime Liao
2023-12-19 12:15   ` Michael Walle
2023-12-20  8:42   ` Tudor Ambarus
2023-12-20  8:51   ` Re (subset): " Tudor Ambarus
2023-12-19 12:12 ` [PATCH v2] mtd: spi-nor: core: Discard HW capabilities if no enable function Michael Walle
2023-12-20  8:07 ` Tudor Ambarus
2023-12-20  8:43   ` Michael Walle
2023-12-20  8:20 ` Tudor Ambarus
2023-12-20  8:50   ` Michael Walle
2023-12-20  8:58     ` Tudor Ambarus
2023-12-20  9:02       ` Michael Walle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).