aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHuang Shijie <b32955@freescale.com>2013-09-25 02:58:15 -0400
committerNitin Garg <nitin.garg@freescale.com>2014-04-16 09:05:59 -0400
commitad9880d3b2246b42047e106864cf8b990e4aa646 (patch)
tree93f19230c876bcdc50adf080d3afa43d5432b251
parentd189e7f8fafbeaff234b933653d985d20928bfb7 (diff)
mtd: gpmi: rewrite the gpmi_ecc_write_oob() to support the jffs2
When we use the ECC info which is get from the nand chip's datasheet, we may have some freed oob area now. This patch rewrites the gpmi_ecc_write_oob() to implement the ecc.write_oob(). We also update the comment for gpmi_hw_ecclayout. Yes! We can support the JFFS2 for the SLC nand now. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
-rw-r--r--drivers/mtd/nand/gpmi-nand/gpmi-nand.c29
1 files changed, 20 insertions, 9 deletions
diff --git a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
index 5c54fb22d463..86dc852539eb 100644
--- a/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
+++ b/drivers/mtd/nand/gpmi-nand/gpmi-nand.c
@@ -45,7 +45,10 @@ static struct nand_bbt_descr gpmi_bbt_descr = {
45 .pattern = scan_ff_pattern 45 .pattern = scan_ff_pattern
46}; 46};
47 47
48/* We will use all the (page + OOB). */ 48/*
49 * We may change the layout if we can get the ECC info from the datasheet,
50 * else we will use all the (page + OOB).
51 */
49static struct nand_ecclayout gpmi_hw_ecclayout = { 52static struct nand_ecclayout gpmi_hw_ecclayout = {
50 .eccbytes = 0, 53 .eccbytes = 0,
51 .eccpos = { 0, }, 54 .eccpos = { 0, },
@@ -1263,14 +1266,22 @@ static int gpmi_ecc_read_oob(struct mtd_info *mtd, struct nand_chip *chip,
1263static int 1266static int
1264gpmi_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *chip, int page) 1267gpmi_ecc_write_oob(struct mtd_info *mtd, struct nand_chip *chip, int page)
1265{ 1268{
1266 /* 1269 struct nand_oobfree *of = mtd->ecclayout->oobfree;
1267 * The BCH will use all the (page + oob). 1270 int status = 0;
1268 * Our gpmi_hw_ecclayout can only prohibit the JFFS2 to write the oob. 1271
1269 * But it can not stop some ioctls such MEMWRITEOOB which uses 1272 /* Do we have available oob area? */
1270 * MTD_OPS_PLACE_OOB. So We have to implement this function to prohibit 1273 if (!of->length)
1271 * these ioctls too. 1274 return -EPERM;
1272 */ 1275
1273 return -EPERM; 1276 if (!nand_is_slc(chip))
1277 return -EPERM;
1278
1279 chip->cmdfunc(mtd, NAND_CMD_SEQIN, mtd->writesize + of->offset, page);
1280 chip->write_buf(mtd, chip->oob_poi + of->offset, of->length);
1281 chip->cmdfunc(mtd, NAND_CMD_PAGEPROG, -1, -1);
1282
1283 status = chip->waitfunc(mtd, chip);
1284 return status & NAND_STATUS_FAIL ? -EIO : 0;
1274} 1285}
1275 1286
1276static int gpmi_block_markbad(struct mtd_info *mtd, loff_t ofs) 1287static int gpmi_block_markbad(struct mtd_info *mtd, loff_t ofs)