aad82dcf7abfe02f9201656a45e08e10f92a0de3
[openwrt/staging/thess.git] /
1 From db214513f62fd13c0a9af3bd5c5d634dba37e65d Mon Sep 17 00:00:00 2001
2 From: Yoshio Furuyama <tmcmc-mb-yfuruyama7@ml.toshiba.co.jp>
3 Date: Wed, 16 Jan 2019 14:53:19 +0900
4 Subject: [PATCH 7/8] mtd: spinand: Add support for all Toshiba Memory products
5
6 Add device table for Toshiba Memory products.
7 Also, generalize OOB layout structure and function names.
8
9 Signed-off-by: Yoshio Furuyama <tmcmc-mb-yfuruyama7@ml.toshiba.co.jp>
10 Reviewed-by: Frieder Schrempf <frieder.schrempf@kontron.de>
11 Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
12 ---
13 drivers/mtd/nand/spi/toshiba.c | 79 ++++++++++++++++++++++++++++------
14 1 file changed, 65 insertions(+), 14 deletions(-)
15
16 --- a/drivers/mtd/nand/spi/toshiba.c
17 +++ b/drivers/mtd/nand/spi/toshiba.c
18 @@ -25,19 +25,19 @@ static SPINAND_OP_VARIANTS(write_cache_v
19 static SPINAND_OP_VARIANTS(update_cache_variants,
20 SPINAND_PROG_LOAD(false, 0, NULL, 0));
21
22 -static int tc58cvg2s0h_ooblayout_ecc(struct mtd_info *mtd, int section,
23 +static int tc58cxgxsx_ooblayout_ecc(struct mtd_info *mtd, int section,
24 struct mtd_oob_region *region)
25 {
26 - if (section > 7)
27 + if (section > 0)
28 return -ERANGE;
29
30 - region->offset = 128 + 16 * section;
31 - region->length = 16;
32 + region->offset = mtd->oobsize / 2;
33 + region->length = mtd->oobsize / 2;
34
35 return 0;
36 }
37
38 -static int tc58cvg2s0h_ooblayout_free(struct mtd_info *mtd, int section,
39 +static int tc58cxgxsx_ooblayout_free(struct mtd_info *mtd, int section,
40 struct mtd_oob_region *region)
41 {
42 if (section > 0)
43 @@ -45,17 +45,17 @@ static int tc58cvg2s0h_ooblayout_free(st
44
45 /* 2 bytes reserved for BBM */
46 region->offset = 2;
47 - region->length = 126;
48 + region->length = (mtd->oobsize / 2) - 2;
49
50 return 0;
51 }
52
53 -static const struct mtd_ooblayout_ops tc58cvg2s0h_ooblayout = {
54 - .ecc = tc58cvg2s0h_ooblayout_ecc,
55 - .free = tc58cvg2s0h_ooblayout_free,
56 +static const struct mtd_ooblayout_ops tc58cxgxsx_ooblayout = {
57 + .ecc = tc58cxgxsx_ooblayout_ecc,
58 + .free = tc58cxgxsx_ooblayout_free,
59 };
60
61 -static int tc58cvg2s0h_ecc_get_status(struct spinand_device *spinand,
62 +static int tc58cxgxsx_ecc_get_status(struct spinand_device *spinand,
63 u8 status)
64 {
65 struct nand_device *nand = spinand_to_nand(spinand);
66 @@ -94,15 +94,66 @@ static int tc58cvg2s0h_ecc_get_status(st
67 }
68
69 static const struct spinand_info toshiba_spinand_table[] = {
70 - SPINAND_INFO("TC58CVG2S0H", 0xCD,
71 + /* 3.3V 1Gb */
72 + SPINAND_INFO("TC58CVG0S3", 0xC2,
73 + NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1),
74 + NAND_ECCREQ(8, 512),
75 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
76 + &write_cache_variants,
77 + &update_cache_variants),
78 + 0,
79 + SPINAND_ECCINFO(&tc58cxgxsx_ooblayout,
80 + tc58cxgxsx_ecc_get_status)),
81 + /* 3.3V 2Gb */
82 + SPINAND_INFO("TC58CVG1S3", 0xCB,
83 + NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1),
84 + NAND_ECCREQ(8, 512),
85 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
86 + &write_cache_variants,
87 + &update_cache_variants),
88 + 0,
89 + SPINAND_ECCINFO(&tc58cxgxsx_ooblayout,
90 + tc58cxgxsx_ecc_get_status)),
91 + /* 3.3V 4Gb */
92 + SPINAND_INFO("TC58CVG2S0", 0xCD,
93 + NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1),
94 + NAND_ECCREQ(8, 512),
95 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
96 + &write_cache_variants,
97 + &update_cache_variants),
98 + 0,
99 + SPINAND_ECCINFO(&tc58cxgxsx_ooblayout,
100 + tc58cxgxsx_ecc_get_status)),
101 + /* 1.8V 1Gb */
102 + SPINAND_INFO("TC58CYG0S3", 0xB2,
103 + NAND_MEMORG(1, 2048, 128, 64, 1024, 1, 1, 1),
104 + NAND_ECCREQ(8, 512),
105 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
106 + &write_cache_variants,
107 + &update_cache_variants),
108 + 0,
109 + SPINAND_ECCINFO(&tc58cxgxsx_ooblayout,
110 + tc58cxgxsx_ecc_get_status)),
111 + /* 1.8V 2Gb */
112 + SPINAND_INFO("TC58CYG1S3", 0xBB,
113 + NAND_MEMORG(1, 2048, 128, 64, 2048, 1, 1, 1),
114 + NAND_ECCREQ(8, 512),
115 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
116 + &write_cache_variants,
117 + &update_cache_variants),
118 + 0,
119 + SPINAND_ECCINFO(&tc58cxgxsx_ooblayout,
120 + tc58cxgxsx_ecc_get_status)),
121 + /* 1.8V 4Gb */
122 + SPINAND_INFO("TC58CYG2S0", 0xBD,
123 NAND_MEMORG(1, 4096, 256, 64, 2048, 1, 1, 1),
124 NAND_ECCREQ(8, 512),
125 SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
126 &write_cache_variants,
127 &update_cache_variants),
128 - SPINAND_HAS_QE_BIT,
129 - SPINAND_ECCINFO(&tc58cvg2s0h_ooblayout,
130 - tc58cvg2s0h_ecc_get_status)),
131 + 0,
132 + SPINAND_ECCINFO(&tc58cxgxsx_ooblayout,
133 + tc58cxgxsx_ecc_get_status)),
134 };
135
136 static int toshiba_spinand_detect(struct spinand_device *spinand)