[PATCH 4/5 fix] mtd: nand: parse out the JEDEC compliant nand

Brian Norris computersforpeace at gmail.com
Fri Jan 31 13:23:17 EST 2014


On Fri, Dec 27, 2013 at 05:51:10PM +0800, Huang Shijie wrote:
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -3038,6 +3038,95 @@ static int nand_flash_detect_onfi(struct mtd_info *mtd, struct nand_chip *chip,
>  }
>  
>  /*
> + * Check if the NAND chip is JEDEC compliant, returns 1 if it is, 0 otherwise.
> + */
> +static int nand_flash_detect_jedec(struct mtd_info *mtd, struct nand_chip *chip,
> +					int *busw)
> +{
...
> +	/*
> +	 * JEDEC must be probed in 8-bit mode or with NAND_BUSWIDTH_AUTO, not
> +	 * with NAND_BUSWIDTH_16
> +	 */
> +	if (chip->options & NAND_BUSWIDTH_16) {
> +		pr_err("JEDEC cannot be probed in 16-bit mode; aborting\n");
> +		return 0;
> +	}

According to the patches that recently went in for ONFI, I think we can
support x16 devices. See my comment below.

> +	chip->cmdfunc(mtd, NAND_CMD_PARAM, 0x40, -1);
> +	for (i = 0; i < 3; i++) {
> +		chip->read_buf(mtd, (uint8_t *)p, sizeof(*p));

Rather than using read_buf(), can you run read_byte() in a loop? That
will solve our problems with x16 bus devices, I think.

> +		if (onfi_crc16(ONFI_CRC_BASE, (uint8_t *)p, 510) ==
> +				le16_to_cpu(p->crc))
> +			break;
> +	}
> +
...

I have yet to look closely at the JEDEC spec, so I can't comment much
more yet.

Thanks,
Brian



More information about the linux-mtd mailing list