]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mtd: nand: omap_gpmc: Make ready/busy pins configurable
authorMichal Sojka <sojka@merica.cz>
Tue, 17 Feb 2015 16:08:37 +0000 (17:08 +0100)
committerLothar Waßmann <LW@KARO-electronics.de>
Tue, 1 Sep 2015 12:24:11 +0000 (14:24 +0200)
Commit fb384c4720ca7496775d6578f184bf628db73456 introduced the use of
WAIT0 pin for determining whether the NAND is ready or not. This only
works if all NAND chips are connected to WAIT0. If some chips are
connected to the other available pin WAIT1, nand_wait() does not really
wait and prints a WARN_ON message.

This patch allows the board to provide configuration of which chip is
connected to which WAITx signal. For example, one can define in
include/configs/foo.h:

    #define CONFIG_NAND_OMAP_GPMC_WSCFG     0,0,1,1

This would mean that chips using to CS0 and 1 are connected to WAIT0 and
chips with CS2 and 3 are connected to WAIT1.

Signed-off-by: Michal Sojka <sojka@merica.cz>
Acked-by: Stefan Roese <sr@denx.de>
Tested-by: Michal Vokáč <michal.vokac@comap.cz>
Cc: Tom Rini <trini@ti.com>
drivers/mtd/nand/omap_gpmc.c

index 6b1e0eaee2da5fddeb2377a490cf5960f0e2be8e..966fdbf81f5941026c90bc111fd8c1d1bc55f8c3 100644 (file)
@@ -30,13 +30,22 @@ static u8  bch8_polynomial[] = {0xef, 0x51, 0x2e, 0x09, 0xed, 0x93, 0x9a, 0xc2,
 static uint8_t cs_next;
 static __maybe_unused struct nand_ecclayout omap_ecclayout;
 
+#if defined(CONFIG_NAND_OMAP_GPMC_WSCFG)
+static const int8_t wscfg[CONFIG_SYS_MAX_NAND_DEVICE] =
+       { CONFIG_NAND_OMAP_GPMC_WSCFG };
+#else
+/* wscfg is preset to zero since its a static variable */
+static const int8_t wscfg[CONFIG_SYS_MAX_NAND_DEVICE];
+#endif
+
 /*
  * Driver configurations
  */
 struct omap_nand_info {
        struct bch_control *control;
        enum omap_ecc ecc_scheme;
-       int cs;
+       uint8_t cs;
+       uint8_t ws;             /* wait status pin (0,1) */
 };
 
 /* We are wasting a bit of memory but al least we are safe */
@@ -260,7 +269,7 @@ static void omap_nand_hwcontrol(struct mtd_info *mtd, int32_t cmd,
 /* Check wait pin as dev ready indicator */
 static int omap_dev_ready(struct mtd_info *mtd)
 {
-       return readl(&gpmc_cfg->status) & (1 << 8);
+       return !!(readl(&gpmc_cfg->status) & (1 << (8 + info->ws)));
 }
 
 /*
@@ -1151,6 +1160,7 @@ int board_nand_init(struct nand_chip *nand)
        nand->IO_ADDR_W = (void __iomem *)&gpmc_cfg->cs[cs].nand_cmd;
        omap_nand_info[cs].control = NULL;
        omap_nand_info[cs].cs = cs;
+       omap_nand_info[cs].ws = wscfg[cs];
        nand->priv      = &omap_nand_info[cs];
        nand->cmd_ctrl  = omap_nand_hwcontrol;
        nand->options   |= NAND_NO_PADDING | NAND_CACHEPRG;