blob: 59a42348c3eb02e5fb4d6eb8121b512321fe65b4 [file] [log] [blame]
developer41370d52022-03-16 16:01:59 +08001From 0bc68af9137dc3f30b161de4ce546c7799f88d1e Mon Sep 17 00:00:00 2001
2From: Shivamurthy Shastri <sshivamurthy@micron.com>
3Date: Wed, 11 Mar 2020 18:57:33 +0100
4Subject: [PATCH] mtd: spinand: micron: identify SPI NAND device with
5 Continuous Read mode
6
7Add SPINAND_HAS_CR_FEAT_BIT flag to identify the SPI NAND device with
8the Continuous Read mode.
9
10Some of the Micron SPI NAND devices have the "Continuous Read" feature
11enabled by default, which does not fit the subsystem needs.
12
13In this mode, the READ CACHE command doesn't require the starting column
14address. The device always output the data starting from the first
15column of the cache register, and once the end of the cache register
16reached, the data output continues through the next page. With the
17continuous read mode, it is possible to read out the entire block using
18a single READ command, and once the end of the block reached, the output
19pins become High-Z state. However, during this mode the read command
20doesn't output the OOB area.
21
22Hence, we disable the feature at probe time.
23
24Signed-off-by: Shivamurthy Shastri <sshivamurthy@micron.com>
25Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
26Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
27Link: https://lore.kernel.org/linux-mtd/20200311175735.2007-5-sshivamurthy@micron.com
28---
29 drivers/mtd/nand/spi/micron.c | 16 ++++++++++++++++
30 include/linux/mtd/spinand.h | 1 +
31 2 files changed, 17 insertions(+)
32
33diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
34index 26925714a9fbac..956f7710aca263 100644
35--- a/drivers/mtd/nand/spi/micron.c
36+++ b/drivers/mtd/nand/spi/micron.c
37@@ -18,6 +18,8 @@
38 #define MICRON_STATUS_ECC_4TO6_BITFLIPS (3 << 4)
39 #define MICRON_STATUS_ECC_7TO8_BITFLIPS (5 << 4)
40
41+#define MICRON_CFG_CR BIT(0)
42+
43 static SPINAND_OP_VARIANTS(read_cache_variants,
44 SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 2, NULL, 0),
45 SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
46@@ -137,7 +139,21 @@ static const struct spinand_info micron_spinand_table[] = {
47 micron_8_ecc_get_status)),
48 };
49
50+static int micron_spinand_init(struct spinand_device *spinand)
51+{
52+ /*
53+ * M70A device series enable Continuous Read feature at Power-up,
54+ * which is not supported. Disable this bit to avoid any possible
55+ * failure.
56+ */
57+ if (spinand->flags & SPINAND_HAS_CR_FEAT_BIT)
58+ return spinand_upd_cfg(spinand, MICRON_CFG_CR, 0);
59+
60+ return 0;
61+}
62+
63 static const struct spinand_manufacturer_ops micron_spinand_manuf_ops = {
64+ .init = micron_spinand_init,
65 };
66
67 const struct spinand_manufacturer micron_spinand_manufacturer = {
68diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h
69index f4c4ae87181b27..1077c45721ff25 100644
70--- a/include/linux/mtd/spinand.h
71+++ b/include/linux/mtd/spinand.h
72@@ -284,6 +284,7 @@ struct spinand_ecc_info {
73 };
74
75 #define SPINAND_HAS_QE_BIT BIT(0)
76+#define SPINAND_HAS_CR_FEAT_BIT BIT(1)
77
78 /**
79 * struct spinand_info - Structure used to describe SPI NAND chips