public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Alex Waterman <awaterman@dawning.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] RFC: porting u-boot to sequoia based nand booting board
Date: Tue, 17 May 2011 13:49:44 -0400	[thread overview]
Message-ID: <4DD2B538.9040604@dawning.com> (raw)
In-Reply-To: <20110517120523.23109215@schlenkerla.am.freescale.net>


Scott,

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

  reply	other threads:[~2011-05-17 17:49 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-17 13:00 [U-Boot] RFC: porting u-boot to sequoia based nand booting board Alex Waterman
2011-05-17 13:41 ` Stefan Roese
2011-05-17 14:11   ` Alex Waterman
2011-05-17 15:37     ` Stefan Roese
2011-05-17 17:05     ` Scott Wood
2011-05-17 17:49       ` Alex Waterman [this message]
2011-05-17 19:20         ` Scott Wood
2011-05-17 21:15           ` Alex Waterman
2011-05-17 21:32             ` Scott Wood
2011-05-18 12:49               ` Alex Waterman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DD2B538.9040604@dawning.com \
    --to=awaterman@dawning.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox