On Tue, 17 May 2011 13:49:44 -0400 Alex Waterman <awater...@dawning.com> wrote:
> > Scott, > > On 05/17/2011 01:05 PM, Scott Wood wrote: > > On Tue, 17 May 2011 10:11:14 -0400 > > Alex Waterman <awater...@dawning.com> wrote: > > > >> I have seen issues with the nand_read_byte16() function in nand_base.c; it > >> seems like the cpu_to_le16() should be the other way around: > >> le16_to_cpu(). Other than that no bugs as far as I am aware. > > > > What is the specific problem you're seeing? The use of these endian macros > > is a bit abusive and ugly (what's really wanted is native-endian I/O > > accessors -- readw() has an implicit le16_to_cpu()), and should have been > > done internally to the read_word() implementation rather than made part of > > the API, but functionally it should be correct. > > When I was getting our NAND to work, it seemed like that function was always > returning 0. I fixed it by writing a read_byte() function like this: > > /* > * Read a byte from the NDFC. > */ > static uint8_t tiger_read_byte(struct mtd_info *mtd){ > > uint16_t word; > struct nand_chip *chip = mtd->priv; > > word = readw(chip->IO_ADDR_R); > > return (uint8_t) word; > > } > > It looked to me like the readw() function was returning the data in the > correct CPU endianness (at least for PPC) and that the cpu_to_le16() was > swapping the bytes such that the cast down to a uint8_t was getting the unset > high order byte from the 16 bit read. If readw() is returning the bytes in the correct endianness, then that means the register is little-endian. It's not clear to me what the default assumption in nand_base.c is, though. read_byte16() suggests the default is native endian, but read_buf() and read_word() suggest it's little endian. :-( Is there any currently working host-big-endian platform with 16-bit NAND that doesn't override these functions? BTW, as for read_word(), looking at its only user, I think nand_block_bad() should be checking a 16-bit bad block marker on 16-bit NAND, rather than the low byte. Why is there a separate mechanism for checking bad block markers than the one in nand_bbt.c (not the bbt itself, but the code used to read the markers to create the bbt)? As long as a BBT is used, I don't think read_word() will ever matter. -Scott _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot