[U-Boot] [PATCH 2/5] NetStar: Fix NAND

Scott Wood scottwood at freescale.com
Tue Mar 17 18:17:30 CET 2009


On Mon, Mar 16, 2009 at 11:28:24PM +0100, Ladislav Michl wrote:
> Fix NAND support broken during new NAND code merge. Move those few lines of
> code to board/netstar/netstar.c

What was the breakage?

> -/*
> - *	hardware specific access to control-lines
> - */
> -#define	MASK_CLE	0x02
> -#define	MASK_ALE	0x04
> -
> -static void netstar_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
> -{
> -	struct nand_chip *this = mtd->priv;
> -	ulong IO_ADDR_W = (ulong) this->IO_ADDR_W;
> -
> -	IO_ADDR_W &= ~(MASK_ALE|MASK_CLE);
> -	if (ctrl & NAND_CTRL_CHANGE) {
> -		if ( ctrl & NAND_CLE )
> -			IO_ADDR_W |= MASK_CLE;
> -		if ( ctrl & NAND_ALE )
> -			IO_ADDR_W |= MASK_ALE;
> -	}
> -	this->IO_ADDR_W = (void __iomem *) IO_ADDR_W;
> -
> -	if (cmd != NAND_CMD_NONE)
> -		writeb(cmd, this->IO_ADDR_W);
> -}
[snip]
> +#if defined(CONFIG_CMD_NAND)
> +/*
> + *	hardware specific access to control-lines
> + *
> + *	NAND_NCE: bit 0 - don't care
> + *	NAND_CLE: bit 1 -> bit 1  (0x0002)
> + *	NAND_ALE: bit 2 -> bit 2  (0x0004)
> + */
> +static void netstar_nand_hwcontrol(struct mtd_info *mtd, int cmd, unsigned int ctrl)
> +{
> +	struct nand_chip *chip = mtd->priv;
> +	unsigned long mask;
> +
> +	if (cmd == NAND_CMD_NONE)
> +		return;
> +
> +	mask = (ctrl & NAND_CLE) ? 0x02 : 0;
> +	if (ctrl & NAND_ALE)
> +		mask |= 0x04;
> +	writeb(cmd, (unsigned long)chip->IO_ADDR_W | mask);
> +}

Do not pass integers as addresses.

The new function looks functionally identical to the old one (except that
it ignores the interface in a couple of ways that it didn't before, but
which don't really matter).  Why the change?  Why the difference between
CLE using ?: and ALE using an if-statement?

-Scott


More information about the U-Boot mailing list