[U-Boot] RFC: porting u-boot to sequoia based nand booting board

Alex Waterman awaterman at dawning.com
Tue May 17 19:49:44 CEST 2011


Scott,

On 05/17/2011 01:05 PM, Scott Wood wrote:
> On Tue, 17 May 2011 10:11:14 -0400
> Alex Waterman <awaterman at 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.

Regards,
Alex

-- 
Alex Waterman
Computer Engineer
Phone: 215-896-4920
Email: awaterman at dawning.com



More information about the U-Boot mailing list