No subject


Fri Jan 23 11:48:37 CET 2009


> > But it looks like buffer 1 is used for data with large page flash.
> >   
> 
> Well, we save first word of the buffer and then recover it.

So then there's no longer any special reason to use buffer 1 for status,
and that comment is misleading...

> +static u_char mxc_nand_read_byte(struct mtd_info *mtd)
> +{
> +	struct nand_chip *nand_chip = mtd->priv;
> +	struct mxc_nand_host *host = nand_chip->priv;
> +	uint8_t ret = 0;
> +	uint16_t col, rd_word;
> +	uint16_t __iomem *main_buf =
> +		(uint16_t __iomem *)host->regs->main_area0;
> +	uint16_t __iomem *spare_buf =
> +		(uint16_t __iomem *)host->regs->spare_area0;
> +
> +	/* Check for status request */
> +	if (host->status_request)
> +		return get_dev_status(host) & 0xFF;
> +
> +	/* Get column for 16-bit access */
> +	col = host->col_addr >> 1;
> +
> +	/* If we are accessing the spare region */
> +	if (host->spare_only)
> +		rd_word = readw(&spare_buf[col]);
> +	else
> +		rd_word = readw(&main_buf[col]);
> +
> +	/* Pick upper/lower byte of word from RAM buffer */
> +	if (host->col_addr & 0x1)
> +		ret = (rd_word >> 8) & 0xFF;
> +	else
> +		ret = rd_word & 0xFF;

Use a union, as in read_buf().  Otherwise, this breaks on big-endian --
you may not care, but it's better to not have such dependencies lurking
in the code that could be reused who-knows-where.

> +	if (col & 1) {
> +		rd_word = readw(p);
> +		ret = (rd_word >> 8) & 0xff;
> +		rd_word = readw(&p[1]);
> +		ret |= (rd_word << 8) & 0xff00;

Again, this is unnecessary, but if you insist, use a union.

> +#ifdef CONFIG_MTD_NAND_MXC_FORCE_CE
> +	if (chip > 0) {
> +		MTDDEBUG(MTD_DEBUG_LEVEL0,
> +		      "ERROR:  Illegal chip select (chip = %d)\n", chip);

If it's an error, that's not exactly debug (especially since there's no
way to propagate the error upwards)...

> +		return;
> +	}
> +
> +	if (chip == -1) {
> +		writew(readw(&host->regs->nfc_config1) & ~NFC_CE,
> +				&host->regs->nfc_config1);
> +		return;
> +	}
> +
> +	writew(readw(&host->regs->nfc_config1) | NFC_CE,
> +			&host->regs->nfc_config1);
> +#endif

#else?

> +		if (column >= mtd->writesize) {
> +			/*
> +			 * before sending SEQIN command for partial write,
> +			 * we need read one page out. FSL NFC does not support
> +			 * partial write. It alway send out 512+ecc+512+ecc ...
> +			 * for large page nand flash. But for small page nand
> +			 * flash, it does support SPARE ONLY operation.
> +			 */
> +			if (host->pagesize_2k) {
> +				/* call ourself to read a page */
> +				mxc_nand_command(mtd, NAND_CMD_READ0, 0,
> +						page_addr);
> +			}

#ifdef CONFIG_MXC_NAND_HWECC?

> +	/* 50 us command delay time */
> +	this->chip_delay = 5;

5 or 50?

> +	host->pagesize_2k = 0;

Make this board-configurable.  Has large page been tested?  If not,
perhaps it should stay out for now, given how weird it is on this
controller.

-Scott


More information about the U-Boot mailing list