[RFC 3/3] mtd omap nand: reconfigure buswidth

Jan Weitzel j.weitzel at phytec.de
Wed Jul 18 08:37:13 EDT 2012


If nand_scan_ident fail try to reconfigure buswidth from 8bit to 16bit or
the other way around.

There are still the ugly debug messages like:
NAND device: Manufacturer ID: 0x2c, Chip ID: 0xb3 (Micron NAND 1GiB 1,8V 16-bit)
NAND bus width 8 instead 16 bit
No NAND device found (-22)!
NAND device: Manufacturer ID: 0x2c, Chip ID: 0xb3 (Micron NAND 1GiB 1,8V 16-bit)

Signed-off-by: Jan Weitzel <j.weitzel at phytec.de>
---
 drivers/mtd/nand/nand_omap_gpmc.c |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/nand_omap_gpmc.c b/drivers/mtd/nand/nand_omap_gpmc.c
index d55dcaa..b80ac14 100644
--- a/drivers/mtd/nand/nand_omap_gpmc.c
+++ b/drivers/mtd/nand/nand_omap_gpmc.c
@@ -803,6 +803,27 @@ static int omap_gpmc_eccmode_set(struct device_d *dev, struct param_d *param, co
 	return omap_gpmc_eccmode(oinfo, i);
 }
 
+void gpmc_reconfigure_buswidth(struct gpmc_nand_info *oinfo)
+{
+	struct nand_chip *nand = &oinfo->nand;
+	struct gpmc_config cfg;
+
+	gpmc_get_config(oinfo->gpmc_cs, &cfg);
+
+	if (nand->options & NAND_BUSWIDTH_16) {
+		cfg.cfg[0] = GPMC_CONFIG1_DEVICETYPE_NAND;
+		nand->options ^= NAND_BUSWIDTH_16;
+	} else {
+		cfg.cfg[0] = GPMC_CONFIG1_DEVICETYPE_NAND |
+				GPMC_CONFIG1_DEVICESIZE_16;
+		nand->options |= NAND_BUSWIDTH_16;
+	}
+	debug("reconfigure buswidth to %d bit\n",
+		(nand->options & NAND_BUSWIDTH_16) ? 16 : 8);
+
+	gpmc_cs_config(oinfo->gpmc_cs, &cfg);
+}
+
 /**
  * @brief nand device probe.
  *
@@ -924,8 +945,13 @@ static int gpmc_nand_probe(struct device_d *pdev)
 
 	/* first scan to find the device and get the page size */
 	if (nand_scan_ident(minfo, 1)) {
-		err = -ENXIO;
-		goto out_release_mem;
+		/* retry with changed buswidth*/
+		gpmc_reconfigure_buswidth(oinfo);
+
+		if (nand_scan_ident(minfo, 1)) {
+			err = -ENXIO;
+			goto out_release_mem;
+		}
 	}
 
 	switch (pdata->device_width) {
-- 
1.7.0.4




More information about the barebox mailing list