aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2013-01-25 01:04:07 -0500
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-02-04 03:27:59 -0500
commit9ff16f0833806b6b59aaf0cc158fa6e42f24d7e4 (patch)
tree179db9e57e721cb0c779b97bbfc9d7a6db8c27dc
parentc80e572c029263687b8175f1ba71d425548cafcf (diff)
mtd: gpmi: set the Golois Field bit for mx6q's BCH
The GF13 can be only used in the following case: The ECC data chunk is less then 1K bytes. In mx23/mx28, the ecc data chunk is 512 bytes. So it is okay. But in mx6q, we begin to use some large nand chip whose ecc data chunk maybe 1K bytes long. So when the data chunk is 1K bytes, we have to use the GF14. This patch sets the Golois Field bit when the GF14 is needed. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
-rw-r--r--drivers/mtd/nand/gpmi-nand/bch-regs.h20
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-lib.c4
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.c6
3 files changed, 28 insertions, 2 deletions
diff --git a/drivers/mtd/nand/gpmi-nand/bch-regs.h b/drivers/mtd/nand/gpmi-nand/bch-regs.h
index d67bca5174bc..588f5374047c 100644
--- a/drivers/mtd/nand/gpmi-nand/bch-regs.h
+++ b/drivers/mtd/nand/gpmi-nand/bch-regs.h
@@ -61,6 +61,16 @@
61 & BM_BCH_FLASH0LAYOUT0_ECC0) \ 61 & BM_BCH_FLASH0LAYOUT0_ECC0) \
62 ) 62 )
63 63
64#define MX6Q_BP_BCH_FLASH0LAYOUT0_GF_13_14 10
65#define MX6Q_BM_BCH_FLASH0LAYOUT0_GF_13_14 \
66 (0x1 << MX6Q_BP_BCH_FLASH0LAYOUT0_GF_13_14)
67#define BF_BCH_FLASH0LAYOUT0_GF(v, x) \
68 ((GPMI_IS_MX6Q(x) && ((v) == 14)) \
69 ? (((1) << MX6Q_BP_BCH_FLASH0LAYOUT0_GF_13_14) \
70 & MX6Q_BM_BCH_FLASH0LAYOUT0_GF_13_14) \
71 : 0 \
72 )
73
64#define BP_BCH_FLASH0LAYOUT0_DATA0_SIZE 0 74#define BP_BCH_FLASH0LAYOUT0_DATA0_SIZE 0
65#define BM_BCH_FLASH0LAYOUT0_DATA0_SIZE \ 75#define BM_BCH_FLASH0LAYOUT0_DATA0_SIZE \
66 (0xfff << BP_BCH_FLASH0LAYOUT0_DATA0_SIZE) 76 (0xfff << BP_BCH_FLASH0LAYOUT0_DATA0_SIZE)
@@ -93,6 +103,16 @@
93 & BM_BCH_FLASH0LAYOUT1_ECCN) \ 103 & BM_BCH_FLASH0LAYOUT1_ECCN) \
94 ) 104 )
95 105
106#define MX6Q_BP_BCH_FLASH0LAYOUT1_GF_13_14 10
107#define MX6Q_BM_BCH_FLASH0LAYOUT1_GF_13_14 \
108 (0x1 << MX6Q_BP_BCH_FLASH0LAYOUT1_GF_13_14)
109#define BF_BCH_FLASH0LAYOUT1_GF(v, x) \
110 ((GPMI_IS_MX6Q(x) && ((v) == 14)) \
111 ? (((1) << MX6Q_BP_BCH_FLASH0LAYOUT1_GF_13_14) \
112 & MX6Q_BM_BCH_FLASH0LAYOUT1_GF_13_14) \
113 : 0 \
114 )
115
96#define BP_BCH_FLASH0LAYOUT1_DATAN_SIZE 0 116#define BP_BCH_FLASH0LAYOUT1_DATAN_SIZE 0
97#define BM_BCH_FLASH0LAYOUT1_DATAN_SIZE \ 117#define BM_BCH_FLASH0LAYOUT1_DATAN_SIZE \
98 (0xfff << BP_BCH_FLASH0LAYOUT1_DATAN_SIZE) 118 (0xfff << BP_BCH_FLASH0LAYOUT1_DATAN_SIZE)
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
index 01cc570e98aa..4f8857fa48a7 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-lib.c
@@ -237,6 +237,7 @@ int bch_set_geometry(struct gpmi_nand_data *this)
237 unsigned int metadata_size; 237 unsigned int metadata_size;
238 unsigned int ecc_strength; 238 unsigned int ecc_strength;
239 unsigned int page_size; 239 unsigned int page_size;
240 unsigned int gf_len;
240 int ret; 241 int ret;
241 242
242 if (common_nfc_set_geometry(this)) 243 if (common_nfc_set_geometry(this))
@@ -247,6 +248,7 @@ int bch_set_geometry(struct gpmi_nand_data *this)
247 metadata_size = bch_geo->metadata_size; 248 metadata_size = bch_geo->metadata_size;
248 ecc_strength = bch_geo->ecc_strength >> 1; 249 ecc_strength = bch_geo->ecc_strength >> 1;
249 page_size = bch_geo->page_size; 250 page_size = bch_geo->page_size;
251 gf_len = bch_geo->gf_len;
250 252
251 ret = gpmi_enable_clk(this); 253 ret = gpmi_enable_clk(this);
252 if (ret) 254 if (ret)
@@ -268,11 +270,13 @@ int bch_set_geometry(struct gpmi_nand_data *this)
268 writel(BF_BCH_FLASH0LAYOUT0_NBLOCKS(block_count) 270 writel(BF_BCH_FLASH0LAYOUT0_NBLOCKS(block_count)
269 | BF_BCH_FLASH0LAYOUT0_META_SIZE(metadata_size) 271 | BF_BCH_FLASH0LAYOUT0_META_SIZE(metadata_size)
270 | BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this) 272 | BF_BCH_FLASH0LAYOUT0_ECC0(ecc_strength, this)
273 | BF_BCH_FLASH0LAYOUT0_GF(gf_len, this)
271 | BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size, this), 274 | BF_BCH_FLASH0LAYOUT0_DATA0_SIZE(block_size, this),
272 r->bch_regs + HW_BCH_FLASH0LAYOUT0); 275 r->bch_regs + HW_BCH_FLASH0LAYOUT0);
273 276
274 writel(BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(page_size) 277 writel(BF_BCH_FLASH0LAYOUT1_PAGE_SIZE(page_size)
275 | BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this) 278 | BF_BCH_FLASH0LAYOUT1_ECCN(ecc_strength, this)
279 | BF_BCH_FLASH0LAYOUT1_GF(gf_len, this)
276 | BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this), 280 | BF_BCH_FLASH0LAYOUT1_DATAN_SIZE(block_size, this),
277 r->bch_regs + HW_BCH_FLASH0LAYOUT1); 281 r->bch_regs + HW_BCH_FLASH0LAYOUT1);
278 282
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 38c8b8bfc428..25216785f180 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -112,10 +112,12 @@ int common_nfc_set_geometry(struct gpmi_nand_data *this)
112 /* The default for the length of Galois Field. */ 112 /* The default for the length of Galois Field. */
113 geo->gf_len = 13; 113 geo->gf_len = 13;
114 114
115 /* The default for chunk size. There is no oobsize greater then 512. */ 115 /* The default for chunk size. */
116 geo->ecc_chunk_size = 512; 116 geo->ecc_chunk_size = 512;
117 while (geo->ecc_chunk_size < mtd->oobsize) 117 while (geo->ecc_chunk_size < mtd->oobsize) {
118 geo->ecc_chunk_size *= 2; /* keep C >= O */ 118 geo->ecc_chunk_size *= 2; /* keep C >= O */
119 geo->gf_len = 14;
120 }
119 121
120 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size; 122 geo->ecc_chunk_count = mtd->writesize / geo->ecc_chunk_size;
121 123