blob: b6914ce7e46cf21459713f5e8ef773cb55ab45a7 [file] [log] [blame]
developer5d148cb2023-06-02 13:08:11 +08001From 5cea72055a3bce2b8b5a1f8cb6d46165eeccd8b9 Mon Sep 17 00:00:00 2001
2From: Sam Shih <sam.shih@mediatek.com>
3Date: Fri, 2 Jun 2023 13:06:13 +0800
4Subject: [PATCH]
5 [spi-and-storage][999-2325-mtd-spinand-micron-Add-support-for-MT29F2G01AAAED.patch]
developer41370d52022-03-16 16:01:59 +08006
developer41370d52022-03-16 16:01:59 +08007---
8 drivers/mtd/nand/spi/micron.c | 64 +++++++++++++++++++++++++++++++++++
9 1 file changed, 64 insertions(+)
10
11diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
developer5d148cb2023-06-02 13:08:11 +080012index afe3ba37d..50b7295bc 100644
developer41370d52022-03-16 16:01:59 +080013--- a/drivers/mtd/nand/spi/micron.c
14+++ b/drivers/mtd/nand/spi/micron.c
15@@ -44,6 +44,19 @@ static SPINAND_OP_VARIANTS(x4_update_cache_variants,
16 SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
17 SPINAND_PROG_LOAD(false, 0, NULL, 0));
18
19+/* Micron MT29F2G01AAAED Device */
20+static SPINAND_OP_VARIANTS(x4_read_cache_variants,
21+ SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
22+ SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
23+ SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
24+ SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
25+
26+static SPINAND_OP_VARIANTS(x1_write_cache_variants,
27+ SPINAND_PROG_LOAD(true, 0, NULL, 0));
28+
29+static SPINAND_OP_VARIANTS(x1_update_cache_variants,
30+ SPINAND_PROG_LOAD(false, 0, NULL, 0));
31+
32 static int micron_8_ooblayout_ecc(struct mtd_info *mtd, int section,
33 struct mtd_oob_region *region)
34 {
35@@ -74,6 +87,47 @@ static const struct mtd_ooblayout_ops micron_8_ooblayout = {
36 .free = micron_8_ooblayout_free,
37 };
38
39+static int micron_4_ooblayout_ecc(struct mtd_info *mtd, int section,
40+ struct mtd_oob_region *region)
41+{
42+ struct spinand_device *spinand = mtd_to_spinand(mtd);
43+
44+ if (section >= spinand->base.memorg.pagesize /
45+ mtd->ecc_step_size)
46+ return -ERANGE;
47+
48+ region->offset = (section * 16) + 8;
49+ region->length = 8;
50+
51+ return 0;
52+}
53+
54+static int micron_4_ooblayout_free(struct mtd_info *mtd, int section,
55+ struct mtd_oob_region *region)
56+{
57+ struct spinand_device *spinand = mtd_to_spinand(mtd);
58+
59+ if (section >= spinand->base.memorg.pagesize /
60+ mtd->ecc_step_size)
61+ return -ERANGE;
62+
63+ if (section) {
64+ region->offset = 16 * section;
65+ region->length = 8;
66+ } else {
67+ /* section 0 has two bytes reserved for the BBM */
68+ region->offset = 2;
69+ region->length = 6;
70+ }
71+
72+ return 0;
73+}
74+
75+static const struct mtd_ooblayout_ops micron_4_ooblayout = {
76+ .ecc = micron_4_ooblayout_ecc,
77+ .free = micron_4_ooblayout_free,
78+};
79+
80 static int micron_select_target(struct spinand_device *spinand,
81 unsigned int target)
82 {
83@@ -217,6 +271,16 @@ static const struct spinand_info micron_spinand_table[] = {
84 SPINAND_ECCINFO(&micron_8_ooblayout,
85 micron_8_ecc_get_status),
86 SPINAND_SELECT_TARGET(micron_select_target)),
87+ /* M69A 2Gb 3.3V */
88+ SPINAND_INFO("MT29F2G01AAAED",
89+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x9F),
90+ NAND_MEMORG(1, 2048, 64, 64, 2048, 80, 2, 1, 1),
91+ NAND_ECCREQ(4, 512),
92+ SPINAND_INFO_OP_VARIANTS(&x4_read_cache_variants,
93+ &x1_write_cache_variants,
94+ &x1_update_cache_variants),
95+ 0,
96+ SPINAND_ECCINFO(&micron_4_ooblayout, NULL)),
97 };
98
99 static int micron_spinand_init(struct spinand_device *spinand)
developer5d148cb2023-06-02 13:08:11 +0800100--
1012.34.1
102