nand: mxs: Fix for calculating ecc strength on some types of NAND flash
Was tested on NAND with {writesize=4096, oobsize=224} and {writesize=2048, oobsize=64}. This patch will not break any NAND that was working before. Implemented calculation way may be used for other NAND chips with writesize == 2048 but oobsize != 64. Signed-off-by: Dmitry Lavnikevich <d.lavnikevich@sam-solutions.com> Signed-off-by: Grigory Milev <g.milev@sam-solutions.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
c15680099e
commit
3676454f5c
|
@ -234,18 +234,31 @@ 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)
|
||||
{
|
||||
int ecc_chunk_count = mxs_nand_ecc_chunk_cnt(page_data_size);
|
||||
int ecc_strength = 0;
|
||||
int gf_len = 13; /* length of Galois Field for non-DDR nand */
|
||||
|
||||
/*
|
||||
* Possibly this if-else calculation may be removed since
|
||||
* ecc_strength calculated after it is taken from kernel driver
|
||||
* and therefore should work for all cases. But it was tested only
|
||||
* on devices with {data_size = 2046, oob_size = 64} and
|
||||
* {data_size = 4096, oob_size = 224} configuration.
|
||||
*/
|
||||
if (page_data_size == 2048)
|
||||
return 8;
|
||||
|
||||
if (page_data_size == 4096) {
|
||||
else if (page_data_size == 4096) {
|
||||
if (page_oob_size == 128)
|
||||
return 8;
|
||||
|
||||
if (page_oob_size == 218)
|
||||
return 16;
|
||||
}
|
||||
|
||||
return 0;
|
||||
ecc_strength = ((page_oob_size - MXS_NAND_METADATA_SIZE) * 8)
|
||||
/ (gf_len * ecc_chunk_count);
|
||||
|
||||
/* We need the minor even number. */
|
||||
return rounddown(ecc_strength, 2);
|
||||
}
|
||||
|
||||
static inline uint32_t mxs_nand_get_mark_offset(uint32_t page_data_size,
|
||||
|
|
Loading…
Reference in New Issue