hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/mtd/nand/spi/fmsh.c
....@@ -80,6 +80,31 @@
8080 .free = fm25s01_ooblayout_free,
8181 };
8282
83
+/*
84
+ * ecc bits: 0xC0[4,6]
85
+ * [0b000], No bit errors were detected;
86
+ * [0b001] and [0b011], 1~6 Bit errors were detected and corrected. Not
87
+ * reach Flipping Bits;
88
+ * [0b101], Bit error count equals the bit flip
89
+ * detection threshold
90
+ * [0b010], Multiple bit errors were detected and
91
+ * not corrected.
92
+ * others, Reserved.
93
+ */
94
+static int fm25s01bi3_ecc_ecc_get_status(struct spinand_device *spinand,
95
+ u8 status)
96
+{
97
+ struct nand_device *nand = spinand_to_nand(spinand);
98
+ u8 eccsr = (status & GENMASK(6, 4)) >> 4;
99
+
100
+ if (eccsr <= 1 || eccsr == 3)
101
+ return eccsr;
102
+ else if (eccsr == 5)
103
+ return nanddev_get_ecc_requirements(nand)->strength;
104
+ else
105
+ return -EBADMSG;
106
+}
107
+
83108 static const struct spinand_info fmsh_spinand_table[] = {
84109 SPINAND_INFO("FM25S01A",
85110 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xE4),
....@@ -97,11 +122,11 @@
97122 SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
98123 &write_cache_variants,
99124 &update_cache_variants),
100
- 1,
125
+ SPINAND_HAS_QE_BIT,
101126 SPINAND_ECCINFO(&fm25s01a_ooblayout, NULL)),
102127 SPINAND_INFO("FM25S01",
103128 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xA1),
104
- NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
129
+ NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
105130 NAND_ECCREQ(1, 512),
106131 SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
107132 &write_cache_variants,
....@@ -110,13 +135,22 @@
110135 SPINAND_ECCINFO(&fm25s01_ooblayout, NULL)),
111136 SPINAND_INFO("FM25LS01",
112137 SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xA5),
113
- NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1),
138
+ NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
114139 NAND_ECCREQ(1, 512),
115140 SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
116141 &write_cache_variants,
117142 &update_cache_variants),
118143 0,
119144 SPINAND_ECCINFO(&fm25s01_ooblayout, NULL)),
145
+ SPINAND_INFO("FM25S01BI3",
146
+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0xD4),
147
+ NAND_MEMORG(1, 2048, 128, 64, 1024, 20, 1, 1, 1),
148
+ NAND_ECCREQ(8, 512),
149
+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
150
+ &write_cache_variants,
151
+ &update_cache_variants),
152
+ SPINAND_HAS_QE_BIT,
153
+ SPINAND_ECCINFO(&fm25s01_ooblayout, fm25s01bi3_ecc_ecc_get_status)),
120154 };
121155
122156 static const struct spinand_manufacturer_ops fmsh_spinand_manuf_ops = {