diff options
| author | Tom Rini <trini@ti.com> | 2013-11-25 10:42:13 -0500 | 
|---|---|---|
| committer | Tom Rini <trini@ti.com> | 2013-11-25 10:42:13 -0500 | 
| commit | faca8ff55f4a2cf45fb906cc37f44601149fc00e (patch) | |
| tree | 181e94fa3326f2ec97f0287f3bbbe54ccd3b13d1 /drivers/mtd/nand/atmel_nand.c | |
| parent | 5a4fe1aaf1210b02bb98e347993ffbcffeb4ffaa (diff) | |
| parent | 2c17e6d1d996a1b8b9325de15f253a13d5877dee (diff) | |
| download | olio-uboot-2014.01-faca8ff55f4a2cf45fb906cc37f44601149fc00e.tar.xz olio-uboot-2014.01-faca8ff55f4a2cf45fb906cc37f44601149fc00e.zip | |
Merge branch 'master' of git://git.denx.de/u-boot-nand-flash
Diffstat (limited to 'drivers/mtd/nand/atmel_nand.c')
| -rw-r--r-- | drivers/mtd/nand/atmel_nand.c | 40 | 
1 files changed, 26 insertions, 14 deletions
| diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c index da83f06e4..16b7df0f7 100644 --- a/drivers/mtd/nand/atmel_nand.c +++ b/drivers/mtd/nand/atmel_nand.c @@ -412,7 +412,7 @@ static int pmecc_err_location(struct mtd_info *mtd)  	}  	if (!timeout) { -		printk(KERN_ERR "atmel_nand : Timeout to calculate PMECC error location\n"); +		dev_err(host->dev, "atmel_nand : Timeout to calculate PMECC error location\n");  		return -1;  	} @@ -452,7 +452,7 @@ static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc,  			*(buf + byte_pos) ^= (1 << bit_pos);  			pos = sector_num * host->pmecc_sector_size + byte_pos; -			printk(KERN_INFO "Bit flip in data area, byte_pos: %d, bit_pos: %d, 0x%02x -> 0x%02x\n", +			dev_dbg(host->dev, "Bit flip in data area, byte_pos: %d, bit_pos: %d, 0x%02x -> 0x%02x\n",  				pos, bit_pos, err_byte, *(buf + byte_pos));  		} else {  			/* Bit flip in OOB area */ @@ -462,7 +462,7 @@ static void pmecc_correct_data(struct mtd_info *mtd, uint8_t *buf, uint8_t *ecc,  			ecc[tmp] ^= (1 << bit_pos);  			pos = tmp + nand_chip->ecc.layout->eccpos[0]; -			printk(KERN_INFO "Bit flip in OOB, oob_byte_pos: %d, bit_pos: %d, 0x%02x -> 0x%02x\n", +			dev_dbg(host->dev, "Bit flip in OOB, oob_byte_pos: %d, bit_pos: %d, 0x%02x -> 0x%02x\n",  				pos, bit_pos, err_byte, ecc[tmp]);  		} @@ -500,7 +500,7 @@ normal_check:  			err_nbr = pmecc_err_location(mtd);  			if (err_nbr == -1) { -				printk(KERN_ERR "PMECC: Too many errors\n"); +				dev_err(host->dev, "PMECC: Too many errors\n");  				mtd->ecc_stats.failed++;  				return -EIO;  			} else { @@ -544,7 +544,7 @@ static int atmel_nand_pmecc_read_page(struct mtd_info *mtd,  	}  	if (!timeout) { -		printk(KERN_ERR "atmel_nand : Timeout to read PMECC page\n"); +		dev_err(host->dev, "atmel_nand : Timeout to read PMECC page\n");  		return -1;  	} @@ -584,7 +584,7 @@ static int atmel_nand_pmecc_write_page(struct mtd_info *mtd,  	}  	if (!timeout) { -		printk(KERN_ERR "atmel_nand : Timeout to read PMECC status, fail to write PMECC in oob\n"); +		dev_err(host->dev, "atmel_nand : Timeout to read PMECC status, fail to write PMECC in oob\n");  		goto out;  	} @@ -827,6 +827,7 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,  	switch (mtd->writesize) {  	case 2048:  	case 4096: +	case 8192:  		host->pmecc_degree = (sector_size == 512) ?  			PMECC_GF_DIMENSION_13 : PMECC_GF_DIMENSION_14;  		host->pmecc_cw_len = (1 << host->pmecc_degree) - 1; @@ -840,8 +841,15 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,  		nand->ecc.steps = 1;  		nand->ecc.bytes = host->pmecc_bytes_per_sector *  				       host->pmecc_sector_number; + +		if (nand->ecc.bytes > MTD_MAX_ECCPOS_ENTRIES_LARGE) { +			dev_err(host->dev, "too large eccpos entries. max support ecc.bytes is %d\n", +					MTD_MAX_ECCPOS_ENTRIES_LARGE); +			return -EINVAL; +		} +  		if (nand->ecc.bytes > mtd->oobsize - 2) { -			printk(KERN_ERR "No room for ECC bytes\n"); +			dev_err(host->dev, "No room for ECC bytes\n");  			return -EINVAL;  		}  		pmecc_config_ecc_layout(&atmel_pmecc_oobinfo, @@ -852,7 +860,7 @@ static int atmel_pmecc_nand_init_params(struct nand_chip *nand,  	case 512:  	case 1024:  		/* TODO */ -		printk(KERN_ERR "Unsupported page size for PMECC, use Software ECC\n"); +		dev_err(host->dev, "Unsupported page size for PMECC, use Software ECC\n");  	default:  		/* page size not handled by HW ECC */  		/* switching back to soft ECC */ @@ -1035,7 +1043,7 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,  		/* it doesn't seems to be a freshly  		 * erased block.  		 * We can't correct so many errors */ -		printk(KERN_WARNING "atmel_nand : multiple errors detected." +		dev_warn(host->dev, "atmel_nand : multiple errors detected."  				" Unable to correct.\n");  		return -EIO;  	} @@ -1045,12 +1053,12 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,  		/* there's nothing much to do here.  		 * the bit error is on the ECC itself.  		 */ -		printk(KERN_WARNING "atmel_nand : one bit error on ECC code." +		dev_warn(host->dev, "atmel_nand : one bit error on ECC code."  				" Nothing to correct\n");  		return 0;  	} -	printk(KERN_WARNING "atmel_nand : one bit error on data." +	dev_warn(host->dev, "atmel_nand : one bit error on data."  			" (word offset in the page :"  			" 0x%x bit offset : 0x%x)\n",  			ecc_word, ecc_bit); @@ -1062,7 +1070,7 @@ static int atmel_nand_correct(struct mtd_info *mtd, u_char *dat,  		/* 8 bits words */  		dat[ecc_word] ^= (1 << ecc_bit);  	} -	printk(KERN_WARNING "atmel_nand : error corrected\n"); +	dev_warn(host->dev, "atmel_nand : error corrected\n");  	return 1;  } @@ -1178,7 +1186,11 @@ int atmel_nand_chip_init(int devnum, ulong base_addr)  	mtd->priv = nand;  	nand->IO_ADDR_R = nand->IO_ADDR_W = (void  __iomem *)base_addr; +#ifdef CONFIG_NAND_ECC_BCH +	nand->ecc.mode = NAND_ECC_SOFT_BCH; +#else  	nand->ecc.mode = NAND_ECC_SOFT; +#endif  #ifdef CONFIG_SYS_NAND_DBW_16  	nand->options = NAND_BUSWIDTH_16;  #endif @@ -1186,7 +1198,7 @@ int atmel_nand_chip_init(int devnum, ulong base_addr)  #ifdef CONFIG_SYS_NAND_READY_PIN  	nand->dev_ready = at91_nand_ready;  #endif -	nand->chip_delay = 20; +	nand->chip_delay = 75;  	ret = nand_scan_ident(mtd, CONFIG_SYS_NAND_MAX_CHIPS, NULL);  	if (ret) @@ -1214,6 +1226,6 @@ void board_nand_init(void)  	int i;  	for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++)  		if (atmel_nand_chip_init(i, base_addr[i])) -			printk(KERN_ERR "atmel_nand: Fail to initialize #%d chip", +			dev_err(host->dev, "atmel_nand: Fail to initialize #%d chip",  				i);  } |