diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-07-18 14:53:26 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-08-06 13:55:03 +0200 |
commit | afc8ed054de6e8839a745fd5520828c50711629f (patch) | |
tree | 1249d28d31fdc36936f639fc0c914152f82b9c97 /common | |
parent | 61b0b210a81fef51eeca861b5886837beb2e7cd6 (diff) | |
download | barebox-afc8ed054de6e8839a745fd5520828c50711629f.tar.gz barebox-afc8ed054de6e8839a745fd5520828c50711629f.tar.xz |
mtd: nand-mxs: change API between NAND driver and fcb code
The imx-bbu-nand-fcb update handler code calls into the NAND driver
to get the ecc strength and bad block marker position. Change the
API so that only a single function is necessary and not three functions.
Also in future the ecc strength will be configurable via device tree.
This means static parameters like page size / oob size are no longer
enough to calculate the ecc strength and so we store a pointer to our
mtd_info struct in a static global variable.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/imx-bbu-nand-fcb.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/common/imx-bbu-nand-fcb.c b/common/imx-bbu-nand-fcb.c index 6d773b59df..e28ce6b9ea 100644 --- a/common/imx-bbu-nand-fcb.c +++ b/common/imx-bbu-nand-fcb.c @@ -486,15 +486,22 @@ err: static int fcb_create(struct imx_nand_fcb_bbu_handler *imx_handler, struct fcb_block *fcb, struct mtd_info *mtd) { + int ecc_strength; + int bb_mark_bit_offset; + int ret; + fcb->FingerPrint = 0x20424346; fcb->Version = 0x01000000; fcb->PageDataSize = mtd->writesize; fcb->TotalPageSize = mtd->writesize + mtd->oobsize; fcb->SectorsPerBlock = mtd->erasesize / mtd->writesize; + ret = mxs_nand_get_geo(&ecc_strength, &bb_mark_bit_offset); + if (ret) + return ret; + /* 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->EccBlock0EccType = ecc_strength >> 1; fcb->EccBlockNEccType = fcb->EccBlock0EccType; fcb->EccBlock0Size = 0x00000200; @@ -505,8 +512,8 @@ static int fcb_create(struct imx_nand_fcb_bbu_handler *imx_handler, /* DBBT search area starts at second page on first block */ fcb->DBBTSearchAreaStartAddress = 1; - fcb->BadBlockMarkerByte = mxs_nand_mark_byte_offset(mtd); - fcb->BadBlockMarkerStartBit = mxs_nand_mark_bit_offset(mtd); + fcb->BadBlockMarkerByte = bb_mark_bit_offset >> 3; + fcb->BadBlockMarkerStartBit = bb_mark_bit_offset & 0x7; fcb->BBMarkerPhysicalOffset = mtd->writesize; |