diff options
author | Huang Shijie <b32955@freescale.com> | 2013-11-15 14:54:29 +0800 |
---|---|---|
committer | Huang Shijie <b32955@freescale.com> | 2013-11-15 15:46:49 +0800 |
commit | e7feac26f75e641b7ec183d59684be18edd95b46 (patch) | |
tree | 34801d01018c351f5db332fef908dd502d828287 | |
parent | e505325b92b26fda58b30a42fc21ca57791ae9e7 (diff) | |
download | u-boot-imx-e7feac26f75e641b7ec183d59684be18edd95b46.zip u-boot-imx-e7feac26f75e641b7ec183d59684be18edd95b46.tar.gz u-boot-imx-e7feac26f75e641b7ec183d59684be18edd95b46.tar.bz2 |
ENGR00288171 gpmi: use the same ECC strength as used in the kernel
Current code use the hardcoded ECC strength which is not aligned with
the kernel.
This patch use the same ECC strength as used in the kernel.
We do not support the NAND whose OOB size is larger then 512bytes.
Signed-off-by: Huang Shijie <b32955@freescale.com>
-rw-r--r-- | drivers/mtd/nand/mxs_nand.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/drivers/mtd/nand/mxs_nand.c b/drivers/mtd/nand/mxs_nand.c index 398e4dd..7091c6b 100644 --- a/drivers/mtd/nand/mxs_nand.c +++ b/drivers/mtd/nand/mxs_nand.c @@ -7,7 +7,7 @@ * Based on code from LTIB: * Freescale GPMI NFC NAND Flash Driver * - * Copyright (C) 2010 Freescale Semiconductor, Inc. + * Copyright (C) 2010-2013 Freescale Semiconductor, Inc. * Copyright (C) 2008 Embedded Alley Solutions, Inc. * * This program is free software; you can redistribute it and/or modify @@ -158,18 +158,14 @@ static uint32_t mxs_nand_aux_status_offset(void) static inline uint32_t mxs_nand_get_ecc_strength(uint32_t page_data_size, uint32_t page_oob_size) { - if (page_data_size == 2048) - return 8; + int ecc_strength; - if (page_data_size == 4096) { - if (page_oob_size == 128) - return 8; + ecc_strength = ((page_oob_size - MXS_NAND_METADATA_SIZE) * 8) + / (13 * mxs_nand_ecc_chunk_cnt(page_data_size)); - if (page_oob_size == 218) - return 16; - } - - return 0; + /* We need the minor even number. */ + ecc_strength -= ecc_strength & 1; + return ecc_strength; } static inline uint32_t mxs_nand_get_mark_offset(uint32_t page_data_size, @@ -978,6 +974,12 @@ static int mxs_nand_scan_bbt(struct mtd_info *mtd) struct mxs_bch_regs *bch_regs = (struct mxs_bch_regs *)MXS_BCH_BASE; uint32_t tmp; + if (mtd->oobsize > MXS_NAND_CHUNK_DATA_CHUNK_SIZE) { + printf("we do not support the NAND whose OOB size is" + "larger then 512 bytes!\n"); + return -EINVAL; + } + /* Configure BCH and set NFC geometry */ mxs_reset_block(&bch_regs->hw_bch_ctrl_reg); |