[MTD] [NAND] pxa3xx_nand: allow to define flash types in the platform data
authorEnrico Scholz <enrico.scholz@sigma-chemnitz.de>
Fri, 29 Aug 2008 10:59:48 +0000 (12:59 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Mon, 1 Sep 2008 20:31:34 +0000 (21:31 +0100)
This patch adds 'flash' and 'num_flash' attributes to the platform data.
There was added code in the driver to iterate across these attributes in the
detect-flash routine.  This is done similarly to the existing method
which uses a 'builtin_flash_types' field.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
arch/arm/mach-pxa/include/mach/pxa3xx_nand.h
drivers/mtd/nand/pxa3xx_nand.c

index 0dc50d82ea7342a6bb16e587786730f1d1364e0c..6ac9aea0b0b539dd65a19a97f642a95c4f7d6b09 100644 (file)
@@ -58,6 +58,9 @@ struct pxa3xx_nand_platform_data {
 
        struct mtd_partition *parts;
        unsigned int    nr_parts;
+
+       struct pxa3xx_nand_flash * const        flash;
+       size_t                                  num_flash;
 };
 
 extern void pxa3xx_set_nand_info(struct pxa3xx_nand_platform_data *info);
index 203e8efefb302828e6875468476c36670dd988b6..1906aba7e73c400c3910193a44f58af621c4a176 100644 (file)
@@ -911,12 +911,26 @@ static int pxa3xx_nand_config_flash(struct pxa3xx_nand_info *info,
        return 0;
 }
 
-static int pxa3xx_nand_detect_flash(struct pxa3xx_nand_info *info)
+static int pxa3xx_nand_detect_flash(struct pxa3xx_nand_info *info,
+                                   const struct pxa3xx_nand_platform_data *pdata)
 {
        struct pxa3xx_nand_flash *f;
        uint32_t id;
        int i;
 
+       for (i = 0; i<pdata->num_flash; ++i) {
+               f = pdata->flash + i;
+
+               if (pxa3xx_nand_config_flash(info, f))
+                       continue;
+
+               if (__readid(info, &id))
+                       continue;
+
+               if (id == f->chip_id)
+                       return 0;
+       }
+
        for (i = 0; i < ARRAY_SIZE(builtin_flash_types); i++) {
 
                f = builtin_flash_types[i];
@@ -1114,7 +1128,7 @@ static int pxa3xx_nand_probe(struct platform_device *pdev)
                goto fail_free_buf;
        }
 
-       ret = pxa3xx_nand_detect_flash(info);
+       ret = pxa3xx_nand_detect_flash(info, pdata);
        if (ret) {
                dev_err(&pdev->dev, "failed to detect flash\n");
                ret = -ENODEV;