Hi ,
I was testing H/W 4-bit ECC correction in DM365 and I found the correction code in kernel 2.6.18 is different from the one in 2.6.32 and the UBL code in post http://e2e.ti.com/support/dsp/davinci_digital_media_processors/f/100/p/182730/708236.aspx#708236.
In function nand_davinci_4bit_compare_ecc() in Linux kernel 2.6.18, the code for checking NAND_FSR is
/*
* Wait for the corr_state field (bits 8 to 11)in the
* NAND Flash Status register to be equal to 0x0, 0x1, 0x2, or 0x3.
*/
do {
iserror = __raw_readl(info->emifregs + NANDFSR);
iserror &= EMIF_NANDFSR_ECC_STATE_MASK;
iserror = iserror >> 8;
} while ((0x0 != iserror) &&
(0x1 != iserror) &&
(0x2 != iserror) &&
(0x3 != iserror));
But the correction code in Kernel 2.6.32 and UBL is,
/*
* ECC_STATE field reads 0x3 (Error correction complete) immediately
* after setting the 4BITECC_ADD_CALC_START bit. So if you immediately
* begin trying to poll for the state, you may fall right out of your
* loop without any of the correction calculations having taken place.
* The recommendation from the hardware team is to wait till ECC_STATE
* reads less than 4, which means ECC HW has entered correction state.
*/
do {
ecc_state = (davinci_nand_readl(info,
NANDFSR_OFFSET) >> 8) & 0x0f;
cpu_relax();
} while (ecc_state < 4);
They are totally different. I think the first one is wrong and the second one is right.
Could somebody please help to tell me which one is the right one?
Thanks and Best Regards,
Ivy