mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
mtd: nand: Allow caller to pass alternative ID table to nand_scan_ident()
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
9fc51a37a8
commit
5e81e88a4c
13 changed files with 30 additions and 26 deletions
|
@ -474,7 +474,7 @@ static int __init atmel_nand_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* first scan to find the device and get the page size */
|
/* first scan to find the device and get the page size */
|
||||||
if (nand_scan_ident(mtd, 1)) {
|
if (nand_scan_ident(mtd, 1, NULL)) {
|
||||||
res = -ENXIO;
|
res = -ENXIO;
|
||||||
goto err_scan_ident;
|
goto err_scan_ident;
|
||||||
}
|
}
|
||||||
|
|
|
@ -446,7 +446,7 @@ static int __devinit bcm_umi_nand_probe(struct platform_device *pdev)
|
||||||
* layout we'll be using.
|
* layout we'll be using.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
err = nand_scan_ident(board_mtd, 1);
|
err = nand_scan_ident(board_mtd, 1, NULL);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk(KERN_ERR "nand_scan failed: %d\n", err);
|
printk(KERN_ERR "nand_scan failed: %d\n", err);
|
||||||
iounmap(bcm_umi_io_base);
|
iounmap(bcm_umi_io_base);
|
||||||
|
|
|
@ -761,7 +761,7 @@ static int __devinit cafe_nand_probe(struct pci_dev *pdev,
|
||||||
cafe_readl(cafe, GLOBAL_CTRL), cafe_readl(cafe, GLOBAL_IRQ_MASK));
|
cafe_readl(cafe, GLOBAL_CTRL), cafe_readl(cafe, GLOBAL_IRQ_MASK));
|
||||||
|
|
||||||
/* Scan to find existence of the device */
|
/* Scan to find existence of the device */
|
||||||
if (nand_scan_ident(mtd, 2)) {
|
if (nand_scan_ident(mtd, 2, NULL)) {
|
||||||
err = -ENXIO;
|
err = -ENXIO;
|
||||||
goto out_irq;
|
goto out_irq;
|
||||||
}
|
}
|
||||||
|
|
|
@ -690,7 +690,7 @@ static int __init nand_davinci_probe(struct platform_device *pdev)
|
||||||
spin_unlock_irq(&davinci_nand_lock);
|
spin_unlock_irq(&davinci_nand_lock);
|
||||||
|
|
||||||
/* Scan to find existence of the device(s) */
|
/* Scan to find existence of the device(s) */
|
||||||
ret = nand_scan_ident(&info->mtd, pdata->mask_chipsel ? 2 : 1);
|
ret = nand_scan_ident(&info->mtd, pdata->mask_chipsel ? 2 : 1, NULL);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_dbg(&pdev->dev, "no NAND chip(s) found\n");
|
dev_dbg(&pdev->dev, "no NAND chip(s) found\n");
|
||||||
goto err_scan;
|
goto err_scan;
|
||||||
|
|
|
@ -891,7 +891,7 @@ static int __devinit fsl_elbc_chip_probe(struct fsl_elbc_ctrl *ctrl,
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
ret = nand_scan_ident(&priv->mtd, 1);
|
ret = nand_scan_ident(&priv->mtd, 1, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
|
@ -819,7 +819,7 @@ static int __init mxcnd_probe(struct platform_device *pdev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* first scan to find the device and get the page size */
|
/* first scan to find the device and get the page size */
|
||||||
if (nand_scan_ident(mtd, 1)) {
|
if (nand_scan_ident(mtd, 1, NULL)) {
|
||||||
err = -ENXIO;
|
err = -ENXIO;
|
||||||
goto escan;
|
goto escan;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2766,10 +2766,10 @@ static void nand_set_defaults(struct nand_chip *chip, int busw)
|
||||||
*/
|
*/
|
||||||
static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
|
static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
|
||||||
struct nand_chip *chip,
|
struct nand_chip *chip,
|
||||||
int busw, int *maf_id)
|
int busw, int *maf_id,
|
||||||
|
struct nand_flash_dev *type)
|
||||||
{
|
{
|
||||||
struct nand_flash_dev *type = NULL;
|
int dev_id, maf_idx;
|
||||||
int i, dev_id, maf_idx;
|
|
||||||
int tmp_id, tmp_manf;
|
int tmp_id, tmp_manf;
|
||||||
|
|
||||||
/* Select the device */
|
/* Select the device */
|
||||||
|
@ -2808,15 +2808,14 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
|
||||||
return ERR_PTR(-ENODEV);
|
return ERR_PTR(-ENODEV);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Lookup the flash id */
|
|
||||||
for (i = 0; nand_flash_ids[i].name != NULL; i++) {
|
|
||||||
if (dev_id == nand_flash_ids[i].id) {
|
|
||||||
type = &nand_flash_ids[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!type)
|
if (!type)
|
||||||
|
type = nand_flash_ids;
|
||||||
|
|
||||||
|
for (; type->name != NULL; type++)
|
||||||
|
if (dev_id == type->id)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (!type->name)
|
||||||
return ERR_PTR(-ENODEV);
|
return ERR_PTR(-ENODEV);
|
||||||
|
|
||||||
if (!mtd->name)
|
if (!mtd->name)
|
||||||
|
@ -2926,13 +2925,15 @@ static struct nand_flash_dev *nand_get_flash_type(struct mtd_info *mtd,
|
||||||
* nand_scan_ident - [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
|
||||||
|
* @table: Alternative NAND ID table
|
||||||
*
|
*
|
||||||
* This is the first phase of the normal nand_scan() function. It
|
* This is the first phase of the normal nand_scan() function. It
|
||||||
* reads the flash ID and sets up MTD fields accordingly.
|
* reads the flash ID and sets up MTD fields accordingly.
|
||||||
*
|
*
|
||||||
* 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_ident(struct mtd_info *mtd, int maxchips)
|
int nand_scan_ident(struct mtd_info *mtd, int maxchips,
|
||||||
|
struct nand_flash_dev *table)
|
||||||
{
|
{
|
||||||
int i, busw, nand_maf_id;
|
int i, busw, nand_maf_id;
|
||||||
struct nand_chip *chip = mtd->priv;
|
struct nand_chip *chip = mtd->priv;
|
||||||
|
@ -2944,7 +2945,7 @@ int nand_scan_ident(struct mtd_info *mtd, int maxchips)
|
||||||
nand_set_defaults(chip, busw);
|
nand_set_defaults(chip, busw);
|
||||||
|
|
||||||
/* Read the flash type */
|
/* Read the flash type */
|
||||||
type = nand_get_flash_type(mtd, chip, busw, &nand_maf_id);
|
type = nand_get_flash_type(mtd, chip, busw, &nand_maf_id, table);
|
||||||
|
|
||||||
if (IS_ERR(type)) {
|
if (IS_ERR(type)) {
|
||||||
if (!(chip->options & NAND_SCAN_SILENT_NODEV))
|
if (!(chip->options & NAND_SCAN_SILENT_NODEV))
|
||||||
|
@ -3235,7 +3236,7 @@ int nand_scan(struct mtd_info *mtd, int maxchips)
|
||||||
BUG();
|
BUG();
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = nand_scan_ident(mtd, maxchips);
|
ret = nand_scan_ident(mtd, maxchips, NULL);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = nand_scan_tail(mtd);
|
ret = nand_scan_tail(mtd);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -1013,7 +1013,8 @@ static int s3c24xx_nand_probe(struct platform_device *pdev)
|
||||||
s3c2410_nand_init_chip(info, nmtd, sets);
|
s3c2410_nand_init_chip(info, nmtd, sets);
|
||||||
|
|
||||||
nmtd->scan_res = nand_scan_ident(&nmtd->mtd,
|
nmtd->scan_res = nand_scan_ident(&nmtd->mtd,
|
||||||
(sets) ? sets->nr_chips : 1);
|
(sets) ? sets->nr_chips : 1,
|
||||||
|
NULL);
|
||||||
|
|
||||||
if (nmtd->scan_res == 0) {
|
if (nmtd->scan_res == 0) {
|
||||||
s3c2410_nand_update_chip(info, nmtd);
|
s3c2410_nand_update_chip(info, nmtd);
|
||||||
|
|
|
@ -825,7 +825,7 @@ static int __init flctl_probe(struct platform_device *pdev)
|
||||||
nand->select_chip = flctl_select_chip;
|
nand->select_chip = flctl_select_chip;
|
||||||
nand->cmdfunc = flctl_cmdfunc;
|
nand->cmdfunc = flctl_cmdfunc;
|
||||||
|
|
||||||
ret = nand_scan_ident(flctl_mtd, 1);
|
ret = nand_scan_ident(flctl_mtd, 1, NULL);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
|
|
|
@ -75,7 +75,7 @@ int sm_register_device(struct mtd_info *mtd)
|
||||||
chip->options |= NAND_SKIP_BBTSCAN | NAND_SMARTMEDIA;
|
chip->options |= NAND_SKIP_BBTSCAN | NAND_SMARTMEDIA;
|
||||||
|
|
||||||
/* Scan for card properties */
|
/* Scan for card properties */
|
||||||
ret = nand_scan_ident(mtd, 1);
|
ret = nand_scan_ident(mtd, 1, NULL);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -220,7 +220,7 @@ static int __devinit socrates_nand_probe(struct of_device *ofdev,
|
||||||
dev_set_drvdata(&ofdev->dev, host);
|
dev_set_drvdata(&ofdev->dev, host);
|
||||||
|
|
||||||
/* first scan to find the device and get the page size */
|
/* first scan to find the device and get the page size */
|
||||||
if (nand_scan_ident(mtd, 1)) {
|
if (nand_scan_ident(mtd, 1, NULL)) {
|
||||||
res = -ENXIO;
|
res = -ENXIO;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
|
@ -274,7 +274,7 @@ static int txx9ndfmc_nand_scan(struct mtd_info *mtd)
|
||||||
struct nand_chip *chip = mtd->priv;
|
struct nand_chip *chip = mtd->priv;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = nand_scan_ident(mtd, 1);
|
ret = nand_scan_ident(mtd, 1, NULL);
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
if (mtd->writesize >= 512) {
|
if (mtd->writesize >= 512) {
|
||||||
chip->ecc.size = mtd->writesize;
|
chip->ecc.size = mtd->writesize;
|
||||||
|
|
|
@ -25,11 +25,13 @@
|
||||||
#include <linux/mtd/bbm.h>
|
#include <linux/mtd/bbm.h>
|
||||||
|
|
||||||
struct mtd_info;
|
struct mtd_info;
|
||||||
|
struct nand_flash_dev;
|
||||||
/* Scan and identify a NAND device */
|
/* Scan and identify a NAND device */
|
||||||
extern int nand_scan (struct mtd_info *mtd, int max_chips);
|
extern int nand_scan (struct mtd_info *mtd, int max_chips);
|
||||||
/* Separate phases of nand_scan(), allowing board driver to intervene
|
/* Separate phases of nand_scan(), allowing board driver to intervene
|
||||||
* and override command or ECC setup according to flash type */
|
* and override command or ECC setup according to flash type */
|
||||||
extern int nand_scan_ident(struct mtd_info *mtd, int max_chips);
|
extern int nand_scan_ident(struct mtd_info *mtd, int max_chips,
|
||||||
|
struct nand_flash_dev *table);
|
||||||
extern int nand_scan_tail(struct mtd_info *mtd);
|
extern int nand_scan_tail(struct mtd_info *mtd);
|
||||||
|
|
||||||
/* Free resources held by the NAND device */
|
/* Free resources held by the NAND device */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue