blob: b4fcfbc6d17b209b5d65c4f8f84efbaaaf3a348c [file] [log] [blame]
developer41370d52022-03-16 16:01:59 +08001From d3137043440fb1faaaf2481184f35b9ed0c1f2c2 Mon Sep 17 00:00:00 2001
2From: Shivamurthy Shastri <sshivamurthy@micron.com>
3Date: Wed, 11 Mar 2020 18:57:30 +0100
4Subject: [PATCH] mtd: spinand: micron: Generalize the OOB layout structure and
5 function names
6
7In order to add new Micron SPI NAND devices, we generalized the OOB
8layout structure and function names.
9
10Signed-off-by: Shivamurthy Shastri <sshivamurthy@micron.com>
11Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
12Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
13Link: https://lore.kernel.org/linux-mtd/20200311175735.2007-2-sshivamurthy@micron.com
14---
15 drivers/mtd/nand/spi/micron.c | 28 ++++++++++++++--------------
16 1 file changed, 14 insertions(+), 14 deletions(-)
17
18diff --git a/drivers/mtd/nand/spi/micron.c b/drivers/mtd/nand/spi/micron.c
19index f56f81325e10ac..cc1ee68421c8e1 100644
20--- a/drivers/mtd/nand/spi/micron.c
21+++ b/drivers/mtd/nand/spi/micron.c
22@@ -34,38 +34,38 @@ static SPINAND_OP_VARIANTS(update_cache_variants,
23 SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
24 SPINAND_PROG_LOAD(false, 0, NULL, 0));
25
26-static int mt29f2g01abagd_ooblayout_ecc(struct mtd_info *mtd, int section,
27- struct mtd_oob_region *region)
28+static int micron_8_ooblayout_ecc(struct mtd_info *mtd, int section,
29+ struct mtd_oob_region *region)
30 {
31 if (section)
32 return -ERANGE;
33
34- region->offset = 64;
35- region->length = 64;
36+ region->offset = mtd->oobsize / 2;
37+ region->length = mtd->oobsize / 2;
38
39 return 0;
40 }
41
42-static int mt29f2g01abagd_ooblayout_free(struct mtd_info *mtd, int section,
43- struct mtd_oob_region *region)
44+static int micron_8_ooblayout_free(struct mtd_info *mtd, int section,
45+ struct mtd_oob_region *region)
46 {
47 if (section)
48 return -ERANGE;
49
50 /* Reserve 2 bytes for the BBM. */
51 region->offset = 2;
52- region->length = 62;
53+ region->length = (mtd->oobsize / 2) - 2;
54
55 return 0;
56 }
57
58-static const struct mtd_ooblayout_ops mt29f2g01abagd_ooblayout = {
59- .ecc = mt29f2g01abagd_ooblayout_ecc,
60- .free = mt29f2g01abagd_ooblayout_free,
61+static const struct mtd_ooblayout_ops micron_8_ooblayout = {
62+ .ecc = micron_8_ooblayout_ecc,
63+ .free = micron_8_ooblayout_free,
64 };
65
66-static int mt29f2g01abagd_ecc_get_status(struct spinand_device *spinand,
67- u8 status)
68+static int micron_8_ecc_get_status(struct spinand_device *spinand,
69+ u8 status)
70 {
71 switch (status & MICRON_STATUS_ECC_MASK) {
72 case STATUS_ECC_NO_BITFLIPS:
73@@ -99,8 +99,8 @@ static const struct spinand_info micron_spinand_table[] = {
74 &write_cache_variants,
75 &update_cache_variants),
76 0,
77- SPINAND_ECCINFO(&mt29f2g01abagd_ooblayout,
78- mt29f2g01abagd_ecc_get_status)),
79+ SPINAND_ECCINFO(&micron_8_ooblayout,
80+ micron_8_ecc_get_status)),
81 };
82
83 static const struct spinand_manufacturer_ops micron_spinand_manuf_ops = {