From: Pekon Gupta <pe...@ti.com>

Because the device bus can be 8-bit or 16-bit width, yet ONFI detection
cannot work in 16-bit mode, we need to set the NAND_BUSWIDTH_AUTO option
which allows proper initialization configuration.

Once the bus width is detected, nand_scan_ident() updates the nand_chip struct
'option' field to use the appropriate read/write functions and configure
the ECC engine.

Signed-off-by: Pekon Gupta <pe...@ti.com>
[rebased and clean-up a bit pekon's original work]
Signed-off-by: Ezequiel Garcia <ezequiel.gar...@free-electrons.com>
---
 drivers/mtd/nand/omap2.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/drivers/mtd/nand/omap2.c b/drivers/mtd/nand/omap2.c
index 4ecf0e5..e01a936 100644
--- a/drivers/mtd/nand/omap2.c
+++ b/drivers/mtd/nand/omap2.c
@@ -1855,8 +1855,7 @@ static int omap_nand_probe(struct platform_device *pdev)
        info->mtd.name          = dev_name(&pdev->dev);
        info->mtd.owner         = THIS_MODULE;
 
-       info->nand.options      = pdata->devsize;
-       info->nand.options      |= NAND_SKIP_BBTSCAN;
+       info->nand.options      |= NAND_SKIP_BBTSCAN | NAND_BUSWIDTH_AUTO;
 #ifdef CONFIG_MTD_NAND_OMAP_BCH
        info->of_node           = pdata->of_node;
 #endif
@@ -1903,6 +1902,10 @@ static int omap_nand_probe(struct platform_device *pdev)
                info->nand.chip_delay = 50;
        }
 
+       err = nand_scan_ident(&info->mtd, 1, NULL);
+       if (err < 0)
+               goto out_release_mem_region;
+
        switch (pdata->xfer_type) {
        case NAND_OMAP_PREFETCH_POLLED:
                info->nand.read_buf   = omap_read_buf_pref;
@@ -2013,17 +2016,6 @@ static int omap_nand_probe(struct platform_device *pdev)
                }
        }
 
-       /* DIP switches on some boards change between 8 and 16 bit
-        * bus widths for flash.  Try the other width if the first try fails.
-        */
-       if (nand_scan_ident(&info->mtd, 1, NULL)) {
-               info->nand.options ^= NAND_BUSWIDTH_16;
-               if (nand_scan_ident(&info->mtd, 1, NULL)) {
-                       err = -ENXIO;
-                       goto out_release_mem_region;
-               }
-       }
-
        /* rom code layout */
        if (pdata->ecc_opt == OMAP_ECC_HAMMING_CODE_HW_ROMCODE) {
 
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to