Browse Source

add nand_scan_ident support.

Change-Id: If2df01af5240d063926b6a65188dc58d31cb2f76
Signed-off-by: QiaoChong <qiaochong@loongson.cn>
master
QiaoChong 6 years ago
committed by Chong Qiao
parent
commit
8b5cf54c8c
  1. 71
      sys/dev/nand/nand_base.c
  2. 3
      sys/dev/nand/spinand_lld.c

71
sys/dev/nand/nand_base.c

@ -2371,32 +2371,22 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
#endif #endif
/** /**
* nand_scan - [NAND Interface] Scan for the NAND device * nand_scan_ident - [NAND Interface] Scan for the NAND device
* @mtd: MTD device structure * @mtd: MTD device structure
* @maxchips: Number of chips to scan for * @maxchips: Number of chips to scan for
* *
* This fills out all the uninitialized function pointers * This is the first phase of the normal nand_scan() function. It
* with the defaults. * reads the flash ID and sets up MTD fields accordingly.
* The flash ID is read and the mtd/chip structures are
* filled with the appropriate values.
* The mtd->owner field must be set to the module of the caller
* *
* The mtd->owner field must be set to the module of the caller.
*/ */
int nand_scan(struct mtd_info *mtd, int maxchips) int nand_scan_ident(struct mtd_info *mtd, int maxchips)
{ {
int i, busw, nand_maf_id; int i, busw, nand_maf_id;
struct nand_chip *chip = mtd->priv; struct nand_chip *chip = mtd->priv;
struct nand_flash_dev *type; struct nand_flash_dev *type;
struct nand_ecc_ctrl *ecc = &chip->ecc; struct nand_ecc_ctrl *ecc = &chip->ecc;
/* Many callers got this wrong, so check for it for a while... */
#if 0
if (!mtd->owner && caller_is_module()) {
printk(KERN_CRIT "nand_scan() called with NULL mtd->owner!\n");
BUG();
}
#endif
/* Get buswidth to select the correct functions */ /* Get buswidth to select the correct functions */
busw = chip->options & NAND_BUSWIDTH_16; busw = chip->options & NAND_BUSWIDTH_16;
/* Set the default functions */ /* Set the default functions */
@ -2428,6 +2418,24 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
chip->numchips = i; chip->numchips = i;
mtd->size = i * chip->chipsize; mtd->size = i * chip->chipsize;
return 0;
}
/**
* nand_scan_tail - [NAND Interface] Scan for the NAND device
* @mtd: MTD device structure
* @maxchips: Number of chips to scan for
*
* This is the second phase of the normal nand_scan() function. It
* fills out all the uninitialized function pointers with the defaults
* and scans for a bad block table if appropriate.
*/
int nand_scan_tail(struct mtd_info *mtd)
{
int i;
struct nand_chip *chip = mtd->priv;
struct nand_ecc_ctrl *ecc = &chip->ecc;
/* Preset the internal oob write buffer */ /* Preset the internal oob write buffer */
memset(chip->buffers.oobwbuf, 0xff, mtd->oobsize); memset(chip->buffers.oobwbuf, 0xff, mtd->oobsize);
@ -2620,6 +2628,35 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
return chip->scan_bbt(mtd); return chip->scan_bbt(mtd);
} }
/**
* nand_scan - [NAND Interface] Scan for the NAND device
* @mtd: MTD device structure
* @maxchips: Number of chips to scan for
*
* This fills out all the uninitialized function pointers
* with the defaults.
* The flash ID is read and the mtd/chip structures are
* filled with the appropriate values.
* The mtd->owner field must be set to the module of the caller
*
*/
int nand_scan(struct mtd_info *mtd, int maxchips)
{
int ret;
/* Many callers got this wrong, so check for it for a while... */
/* if (!mtd->owner && caller_is_module()) {
printk(KERN_CRIT "nand_scan() called with NULL mtd->owner!\n");
BUG();
}*/
ret = nand_scan_ident(mtd, maxchips);
if (!ret)
ret = nand_scan_tail(mtd);
return ret;
}
/** /**
* nand_release - [NAND Interface] Free resources held by the NAND device * nand_release - [NAND Interface] Free resources held by the NAND device
* @mtd: MTD device structure * @mtd: MTD device structure

3
sys/dev/nand/spinand_lld.c

@ -935,9 +935,6 @@ int spinand_probe(struct spi_device *spi_nand)
if(info->gd_ctype == 1) { if(info->gd_ctype == 1) {
spinand_driver_strength(info->spi); spinand_driver_strength(info->spi);
mtd->oobsize = 128;
} else {
mtd->oobsize = 64;
} }
#ifdef NOUSED_MTD_SPINAND_ONDIEECC #ifdef NOUSED_MTD_SPINAND_ONDIEECC

Loading…
Cancel
Save