ARM: OMAP2+: nand: Acquire CS in gpmc_nand_init
authorAfzal Mohammed <afzal@ti.com>
Wed, 29 Feb 2012 12:41:56 +0000 (18:11 +0530)
committerPhilip, Avinash <avinashphilip@ti.com>
Thu, 8 Mar 2012 11:55:40 +0000 (17:25 +0530)
Prerequisite to merging different board nand functions to one

Signed-off-by: Afzal Mohammed <afzal@ti.com>
arch/arm/mach-omap2/common-board-devices.c
arch/arm/mach-omap2/gpmc-nand.c

index 2d1d775f2c3e1fbe4d2b40c1b5caa8b9662421ed..f23a601af8eb10ff9a27fd63b1728f4437da9373 100644 (file)
@@ -98,38 +98,13 @@ static struct omap_nand_platform_data nand_data;
 void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
                                 int nr_parts)
 {
-       u8 cs = 0;
-       u8 nandcs = GPMC_CS_NUM + 1;
-
-       /* find out the chip-select on which NAND exists */
-       while (cs < GPMC_CS_NUM) {
-               u32 ret = 0;
-               ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
-
-               if ((ret & 0xC00) == 0x800) {
-                       printk(KERN_INFO "Found NAND on CS%d\n", cs);
-                       if (nandcs > GPMC_CS_NUM)
-                               nandcs = cs;
-               }
-               cs++;
-       }
-
-       if (nandcs > GPMC_CS_NUM) {
-               printk(KERN_INFO "NAND: Unable to find configuration "
-                                "in GPMC\n ");
-               return;
-       }
-
-       if (nandcs < GPMC_CS_NUM) {
-               nand_data.cs = nandcs;
-               nand_data.parts = parts;
-               nand_data.nr_parts = nr_parts;
-               nand_data.devsize = options;
+       nand_data.cs = GPMC_CS_NUM + 1;
+       nand_data.parts = parts;
+       nand_data.nr_parts = nr_parts;
+       nand_data.devsize = options;
 
-               printk(KERN_INFO "Registering NAND on CS%d\n", nandcs);
-               if (gpmc_nand_init(&nand_data) < 0)
-                       printk(KERN_ERR "Unable to register NAND device\n");
-       }
+       if (gpmc_nand_init(&nand_data) < 0)
+               printk(KERN_ERR "Unable to register NAND device\n");
 }
 #else
 void __init omap_nand_flash_init(int options, struct mtd_partition *parts,
index 8ad210bda9a996072df12625382875fee0b75c26..2de65d11069ea833cfb596f89b8b2cfded2bddc4 100644 (file)
@@ -84,10 +84,33 @@ static int omap2_nand_gpmc_retime(struct omap_nand_platform_data *gpmc_nand_data
 int __init gpmc_nand_init(struct omap_nand_platform_data *gpmc_nand_data)
 {
        int err = 0;
+       u8 cs = 0;
        struct device *dev = &gpmc_nand_device.dev;
 
+       /* if cs not provided, find out the chip-select on which NAND exist */
+       if (gpmc_nand_data->cs > GPMC_CS_NUM)
+               while (cs < GPMC_CS_NUM) {
+                       u32 ret = 0;
+                       ret = gpmc_cs_read_reg(cs, GPMC_CS_CONFIG1);
+
+                       if ((ret & 0xC00) == 0x800) {
+                               printk(KERN_INFO "Found NAND on CS%d\n", cs);
+                               gpmc_nand_data->cs = cs;
+                               break;
+                       }
+                       cs++;
+               }
+
+       if (gpmc_nand_data->cs > GPMC_CS_NUM) {
+               printk(KERN_INFO "NAND: Unable to find configuration "
+                                "in GPMC\n ");
+               return -ENODEV;
+       }
+
        gpmc_nand_device.dev.platform_data = gpmc_nand_data;
 
+       printk(KERN_INFO "Registering NAND on CS%d\n", gpmc_nand_data->cs);
+
        err = gpmc_cs_request(gpmc_nand_data->cs, NAND_IO_SIZE,
                                &gpmc_nand_data->phys_base);
        if (err < 0) {