[U-Boot] [PATCH v2 8/8] mtd: vf610_nfc: enable ONFI detection

Stefan Agner stefan at agner.ch
Fri May 8 17:49:08 CEST 2015


On 2015-04-21 01:17, Scott Wood wrote:
> On Wed, 2015-04-08 at 16:44 +0200, Stefan Agner wrote:
>> +	case ALT_BUF_ONFI:
>> +		/* Reverse byte since the controller uses big endianness */
>> +		c = nfc->column % 4;
>> +		c = nfc->column - c + (3 - c);
> 
> These two lines can be simplified to "c = nfc->column ^ 3;"
> 
> Doesn't this driver run on some big-endian targets, in which case you
> wouldn't want to reverse?  I think you should instead be using in_be32()
> and then extracting the byte within the word after it's been put into
> cpu byte order.

Yes agreed, big endian platforms shouldn't be left out here, will fix
that.

>> +		tmp = *((u8 *)(nfc->regs + NFC_MAIN_AREA(0) + c));
>> +		break;
>> +	default:
>> +		tmp = *((u8 *)(nfc->regs + NFC_MAIN_AREA(0) + c));
>> +		break;
> 
> Why is the byte order different here?  I guess you've been writing data
> backwards onto the NAND chip?  Won't that mess up factory bad block
> markers?

Yes, the data end up backward in the NAND chip. I asked that myself to,
however, I have devices which definitely come with "naturally" looking
bad blocks. It seems that the whole pages are actually set to 0x00 on
those chips, although this is not specified in the data sheet. I will
try to figure out more...

--
Stefan


More information about the U-Boot mailing list