[PATCH v3 2/3] mtd: nand: add new parsing rule for Hynix's H27UBG8T2CTR

Brian Norris computersforpeace at gmail.com
Fri Mar 7 02:46:57 EST 2014


On Fri, Jan 03, 2014 at 04:08:37PM +0800, Huang Shijie wrote:
> The H27UBG8T2CTR is produced by the 20nm technology, and Hynix uses
> different ID rules for it.
> 
> In order to parse out the correct information, we should check the
> process technology and the Device ID, and then determine whether to
> use a new parsing rule for this chip.
> 
> This patch adds the new parsing rule for the H27UBG8T2CTR.
> 
> Tested with H27UBG8T2CTR(8192 + 640).
> 
> Signed-off-by: Huang Shijie <b32955 at freescale.com>
> ---
>  drivers/mtd/nand/nand_base.c |   90 +++++++++++++++++++++++++++++++-----------
>  1 files changed, 67 insertions(+), 23 deletions(-)
> 
> diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c
> index d6b7dc3..2c2f7af 100644
> --- a/drivers/mtd/nand/nand_base.c
> +++ b/drivers/mtd/nand/nand_base.c
> @@ -3204,34 +3204,78 @@ static void nand_parse_hynix(struct mtd_info *mtd, struct nand_chip *chip,
>  {
>  	int extid = id_data[3];
>  	unsigned int tmp;
> +	bool new_rule;
>  
> +	/*
> +	 * The ((id_data[5] & 0x7) < 4) means the nand uses >20nm technology;
> +	 * The ((id_data[5] & 0x7) >= 4) means the nand uses <=20nm technology;
> +	 *
> +	 * Please reference to the H27UBG8T2B (p.23) and H27UBG8T2C (p.23).
> +	 *
> +	 * The new parsing rule is used in the H27UBG8T2C, we have to use the
> +	 * process technology and the Device ID to distinguish this new rule.
> +	 */
> +	new_rule = ((id_data[5] & 0x7) >= 4) && (id_data[1] == 0xd7);

Are you sure you need to use the device ID (0xD7)? It's best if we don't
have to constrain ourselves to particular flash sizes here... Are there
Hynix MLC that don't follow the id_data[5] pattern for differentiating
technology types (>20nm vs <=20nm)? I'll have to check my datasheets
when I get back in the office.

> +
> +	tmp = new_rule ? SZ_4K : SZ_2K;

You forgot to include <linux/sizes.h> again :)

>  	/* Calc pagesize */
> -	mtd->writesize = 2048 << (extid & 0x03);
> +	mtd->writesize = tmp << (extid & 0x03);
>  	extid >>= 2;
>  
>  	/* Calc oobsize */
> -	switch (((extid >> 2) & 0x04) | (extid & 0x03)) {
> -	case 0:
> -		mtd->oobsize = 128;
> -		break;
> -	case 1:
> -		mtd->oobsize = 224;
> -		break;
> -	case 2:
> -		mtd->oobsize = 448;
> -		break;
> -	case 3:
> -		mtd->oobsize = 64;
> -		break;
> -	case 4:
> -		mtd->oobsize = 32;
> -		break;
> -	case 5:
> -		mtd->oobsize = 16;
> -		break;
> -	default:
> -		mtd->oobsize = 640;
> -		break;
> +	tmp = ((extid >> 2) & 0x04) | (extid & 0x03);
> +
> +	if (!new_rule) {
> +		switch (tmp) {
> +		case 0:
> +			mtd->oobsize = 128;
> +			break;
> +		case 1:
> +			mtd->oobsize = 224;
> +			break;
> +		case 2:
> +			mtd->oobsize = 448;
> +			break;
> +		case 3:
> +			mtd->oobsize = 64;
> +			break;
> +		case 4:
> +			mtd->oobsize = 32;
> +			break;
> +		case 5:
> +			mtd->oobsize = 16;
> +			break;
> +		default:
> +			mtd->oobsize = 640;
> +			break;
> +		}
> +	} else {
> +		switch (tmp) {
> +		case 0:
> +			mtd->oobsize = 640;
> +			break;
> +		case 1:
> +			mtd->oobsize = 448;
> +			break;
> +		case 2:
> +			mtd->oobsize = 224;
> +			break;
> +		case 3:
> +			mtd->oobsize = 128;
> +			break;
> +		case 4:
> +			mtd->oobsize = 64;
> +			break;
> +		case 5:
> +			mtd->oobsize = 32;
> +			break;
> +		case 6:
> +			mtd->oobsize = 16;
> +			break;
> +		default:
> +			mtd->oobsize = 640;
> +			break;
> +		}
>  	}
>  	extid >>= 2;
>  

Brian



More information about the linux-mtd mailing list