diff options
author | Stefan Christ <s.christ@phytec.de> | 2015-01-28 11:11:15 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2015-01-29 07:58:00 +0100 |
commit | a114e9b00c6c3f73be8f9de4c4722a6320399252 (patch) | |
tree | 615e7d0fc0ca00b98bb0410ebfc61d0766c7b442 /arch/arm/mach-imx/imx6-bbu-nand.c | |
parent | 41e3d1c92a17e4a5c76c2c6ddfed5bdbe0603529 (diff) | |
download | barebox-a114e9b00c6c3f73be8f9de4c4722a6320399252.tar.gz barebox-a114e9b00c6c3f73be8f9de4c4722a6320399252.tar.xz |
ARM: i.MX6: use generic calculation in nand bbu handler
The parameters ECC Strength, BadBlockMarkerByte and BadBlockMarkerStartBit in
the FCB structure depends on the nand chip's pagesize and oobsize. Instead of
hardcoding these values into the imx6 bbu handler calculate these values on the
fly. Therefore we export the necessary functions from the nand_mxs driver to
use them in the bbu handler.
Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/mach-imx/imx6-bbu-nand.c')
-rw-r--r-- | arch/arm/mach-imx/imx6-bbu-nand.c | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/arch/arm/mach-imx/imx6-bbu-nand.c b/arch/arm/mach-imx/imx6-bbu-nand.c index 2a54979fcb..d2bfedbad5 100644 --- a/arch/arm/mach-imx/imx6-bbu-nand.c +++ b/arch/arm/mach-imx/imx6-bbu-nand.c @@ -30,6 +30,7 @@ #include <fs.h> #include <mach/bbu.h> #include <linux/mtd/mtd-abi.h> +#include <linux/mtd/nand_mxs.h> #include <linux/mtd/mtd.h> #include <linux/stat.h> @@ -235,22 +236,9 @@ static int fcb_create(struct fcb_block *fcb, struct mtd_info *mtd) fcb->TotalPageSize = mtd->writesize + mtd->oobsize; fcb->SectorsPerBlock = mtd->erasesize / mtd->writesize; - if (mtd->writesize == 2048) { - fcb->EccBlock0EccType = 4; - } else if (mtd->writesize == 4096) { - if (mtd->oobsize == 218) { - fcb->EccBlock0EccType = 8; - } else if (mtd->oobsize == 128) { - fcb->EccBlock0EccType = 4; - } else { - pr_err("Illegal oobsize %d\n", mtd->oobsize); - return -EINVAL; - } - } else { - pr_err("Illegal writesize %d\n", mtd->writesize); - return -EINVAL; - } - + /* Divide ECC strength by two and save the value into FCB structure. */ + fcb->EccBlock0EccType = + mxs_nand_get_ecc_strength(mtd->writesize, mtd->oobsize) >> 1; fcb->EccBlockNEccType = fcb->EccBlock0EccType; /* Also hardcoded in kobs-ng */ @@ -267,12 +255,8 @@ static int fcb_create(struct fcb_block *fcb, struct mtd_info *mtd) /* DBBT search area starts at third block */ fcb->DBBTSearchAreaStartAddress = mtd->erasesize / mtd->writesize * 2; - if (mtd->writesize == 2048) { - fcb->BadBlockMarkerByte = 0x000007cf; - } else { - pr_err("BadBlockMarkerByte unknown for writesize %d\n", mtd->writesize); - return -EINVAL; - } + fcb->BadBlockMarkerByte = mxs_nand_mark_byte_offset(mtd); + fcb->BadBlockMarkerStartBit = mxs_nand_mark_bit_offset(mtd); fcb->BBMarkerPhysicalOffset = mtd->writesize; |