diff --git a/arch/arm/include/asm/arch-spear/hardware.h b/arch/arm/include/asm/arch-spear/hardware.h
index 818f36c..a6517b2 100644
--- a/arch/arm/include/asm/arch-spear/hardware.h
+++ b/arch/arm/include/asm/arch-spear/hardware.h
@@ -37,15 +37,15 @@

 #if defined(CONFIG_SPEAR600)
 #define CONFIG_SYS_I2C_BASE                    (0xD0200000)
-#define CONFIG_SPEAR_FSMCBASE                  (0xD1800000)
+#define CONFIG_SYS_FSMC_BASE                   (0xD1800000)

 #elif defined(CONFIG_SPEAR300)
 #define CONFIG_SYS_I2C_BASE                    (0xD0180000)
-#define CONFIG_SPEAR_FSMCBASE                  (0x94000000)
+#define CONFIG_SYS_FSMC_BASE                   (0x94000000)

 #elif defined(CONFIG_SPEAR310)
 #define CONFIG_SYS_I2C_BASE                    (0xD0180000)
-#define CONFIG_SPEAR_FSMCBASE                  (0x44000000)
+#define CONFIG_SYS_FSMC_BASE                   (0x44000000)

 #undef CONFIG_SYS_NAND_CLE
 #undef CONFIG_SYS_NAND_ALE
@@ -57,7 +57,7 @@

 #elif defined(CONFIG_SPEAR320)
 #define CONFIG_SYS_I2C_BASE                    (0xD0180000)
-#define CONFIG_SPEAR_FSMCBASE                  (0x4C000000)
+#define CONFIG_SYS_FSMC_BASE                   (0x4C000000)

 #define CONFIG_SPEAR_EMIBASE                   (0x40000000)
 #define CONFIG_SPEAR_RASBASE                   (0xB3000000)
diff --git a/board/spear/spear300/spear300.c b/board/spear/spear300/spear300.c
index 60ee544..32bcb77 100644
--- a/board/spear/spear300/spear300.c
+++ b/board/spear/spear300/spear300.c
@@ -24,10 +24,10 @@
 #include <common.h>
 #include <nand.h>
 #include <asm/io.h>
+#include <linux/mtd/fsmc_nand.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>

 int board_init(void)
 {
@@ -46,13 +46,14 @@ int board_nand_init(struct nand_chip *nand)
        struct misc_regs *const misc_regs_p =
            (struct misc_regs *)CONFIG_SPEAR_MISCBASE;

+#if defined(CONFIG_NAND_FSMC)
        if (((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
             MISC_SOCCFG30) ||
            ((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
             MISC_SOCCFG31)) {

-               return spear_nand_init(nand);
+               return fsmc_nand_init(nand);
        }
-
+#endif
        return -1;
 }
diff --git a/board/spear/spear310/spear310.c b/board/spear/spear310/spear310.c
index 03dfe16..8b58218 100644
--- a/board/spear/spear310/spear310.c
+++ b/board/spear/spear310/spear310.c
@@ -25,10 +25,10 @@
 #include <common.h>
 #include <nand.h>
 #include <asm/io.h>
+#include <linux/mtd/fsmc_nand.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>

 int board_init(void)
 {
@@ -47,13 +47,14 @@ int board_nand_init(struct nand_chip *nand)
        struct misc_regs *const misc_regs_p =
            (struct misc_regs *)CONFIG_SPEAR_MISCBASE;

+#if defined(CONFIG_NAND_FSMC)
        if (((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
             MISC_SOCCFG30) ||
            ((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
             MISC_SOCCFG31)) {

-               return spear_nand_init(nand);
+               return fsmc_nand_init(nand);
        }
-
+#endif
        return -1;
 }
diff --git a/board/spear/spear320/spear320.c b/board/spear/spear320/spear320.c
index 2ba2dbb..172ad35 100644
--- a/board/spear/spear320/spear320.c
+++ b/board/spear/spear320/spear320.c
@@ -25,10 +25,10 @@
 #include <common.h>
 #include <nand.h>
 #include <asm/io.h>
+#include <linux/mtd/fsmc_nand.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>

 int board_init(void)
 {
@@ -47,13 +47,14 @@ int board_nand_init(struct nand_chip *nand)
        struct misc_regs *const misc_regs_p =
            (struct misc_regs *)CONFIG_SPEAR_MISCBASE;

+#if defined(CONFIG_NAND_FSMC)
        if (((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
             MISC_SOCCFG30) ||
            ((readl(&misc_regs_p->auto_cfg_reg) & MISC_SOCCFGMSK) ==
             MISC_SOCCFG31)) {

-               return spear_nand_init(nand);
+               return fsmc_nand_init(nand);
        }
-
+#endif
        return -1;
 }
diff --git a/board/spear/spear600/spear600.c b/board/spear/spear600/spear600.c
index eef9a37..7cf63d6 100644
--- a/board/spear/spear600/spear600.c
+++ b/board/spear/spear600/spear600.c
@@ -24,10 +24,10 @@
 #include <common.h>
 #include <nand.h>
 #include <asm/io.h>
+#include <linux/mtd/fsmc_nand.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/spr_defs.h>
 #include <asm/arch/spr_misc.h>
-#include <asm/arch/spr_nand.h>

 int board_init(void)
 {
@@ -46,8 +46,9 @@ int board_nand_init(struct nand_chip *nand)
        struct misc_regs *const misc_regs_p =
            (struct misc_regs *)CONFIG_SPEAR_MISCBASE;

+#if defined(CONFIG_NAND_FSMC)
        if (!(readl(&misc_regs_p->auto_cfg_reg) & MISC_NANDDIS))
-               return spear_nand_init(nand);
-
+               return fsmc_nand_init(nand);
+#endif
        return -1;
 }
diff --git a/include/configs/spear-common.h b/include/configs/spear-common.h
index 516b78e..c37305f 100644
--- a/include/configs/spear-common.h
+++ b/include/configs/spear-common.h
@@ -90,7 +90,7 @@
 /* NAND FLASH Configuration */
 #define CONFIG_MTD_DEVICE
 #define CONFIG_MTD_PARTITIONS
-#define CONFIG_NAND_SPEAR                      1
+#define CONFIG_NAND_FSMC
 #define CONFIG_SYS_MAX_NAND_DEVICE             1
 #define CONFIG_MTD_NAND_VERIFY_WRITE

diff --git a/include/configs/spear3xx.h b/include/configs/spear3xx.h
index bd5d111..5bdd874 100644
--- a/include/configs/spear3xx.h
+++ b/include/configs/spear3xx.h
@@ -117,6 +117,10 @@

 #endif

+/* NAND flash configuration */
+#define CONFIG_SYS_FSMC_NAND_SP
+#define CONFIG_SYS_FSMC_NAND_8BIT
+
 #if defined(CONFIG_SPEAR300)
 #define CONFIG_SYS_NAND_BASE                   0x80000000

diff --git a/include/configs/spear6xx.h b/include/configs/spear6xx.h
index 8de7ebd..1e06c72 100644
--- a/include/configs/spear6xx.h
+++ b/include/configs/spear6xx.h
@@ -38,6 +38,9 @@
 #define CONFIG_PL01x_PORTS                     { (void *)CONFIG_SYS_SERIAL0, \
                                                (void *)CONFIG_SYS_SERIAL1 }

+/* NAND flash configuration */
+#define CONFIG_SYS_FSMC_NAND_SP
+#define CONFIG_SYS_FSMC_NAND_8BIT
 #define CONFIG_SYS_NAND_BASE                   (0xD2000000)

 #endif  /* __CONFIG_H */
--
1.7.2.2



------------------------------

Message: 2
Date: Mon, 27 Feb 2012 15:08:24 +0530
From: Amit Virdi <amit.virdi@st.com>
Subject: [U-Boot] [PATCH 3/3] mtd/NAND: Remove obsolete SPEAr specific
        NAND    drivers
To: <u-boot@lists.denx.de>
Cc: armando.visconti@st.com, shiraz.hashim@st.com,      Amit Virdi
        <amit.virdi@st.com>, scottwood@freescale.com, sr@denx.de
Message-ID: <1330335504-32226-4-git-send-email-amit.virdi@st.com>
Content-Type: text/plain

From: Vipin KUMAR <vipin.kumar@st.com>

Since, SPEAr platform uses generic FSMC driver now, so spear specific files
drivers/mtd/nand/spr_nand.c, arch/arm/include/asm/arch-spear/spr_nand.h are
removed

Signed-off-by: Vipin Kumar <vipin.kumar@st.com>
Signed-off-by: Amit Virdi <amit.virdi@st.com>
---
 arch/arm/include/asm/arch-spear/spr_nand.h |   57 -------------
 drivers/mtd/nand/spr_nand.c                |  124 ----------------------------
 2 files changed, 0 insertions(+), 181 deletions(-)
 delete mode 100644 arch/arm/include/asm/arch-spear/spr_nand.h
 delete mode 100644 drivers/mtd/nand/spr_nand.c

diff --git a/arch/arm/include/asm/arch-spear/spr_nand.h b/arch/arm/include/asm/arch-spear/spr_nand.h
deleted file mode 100644
index 2b63dc7..0000000
--- a/arch/arm/include/asm/arch-spear/spr_nand.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * (C) Copyright 2009
- * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#ifndef __SPR_NAND_H__
-#define __SPR_NAND_H__
-
-struct fsmc_regs {
-       u32 reserved_1[0x10];
-       u32 genmemctrl_pc;
-       u32 reserved_2;
-       u32 genmemctrl_comm;
-       u32 genmemctrl_attrib;
-       u32 reserved_3;
-       u32 genmemctrl_ecc;
-};
-
-/* genmemctrl_pc register definitions */
-#define FSMC_RESET             (1 << 0)
-#define FSMC_WAITON            (1 << 1)
-#define FSMC_ENABLE            (1 << 2)
-#define FSMC_DEVTYPE_NAND      (1 << 3)
-#define FSMC_DEVWID_8          (0 << 4)
-#define FSMC_DEVWID_16         (1 << 4)
-#define FSMC_ECCEN             (1 << 6)
-#define FSMC_ECCPLEN_512       (0 << 7)
-#define FSMC_ECCPLEN_256       (1 << 7)
-#define FSMC_TCLR_1            (1 << 9)
-#define FSMC_TAR_1             (1 << 13)
-
-/* genmemctrl_comm register definitions */
-#define FSMC_TSET_0            (0 << 0)
-#define FSMC_TWAIT_6           (6 << 8)
-#define FSMC_THOLD_4           (4 << 16)
-#define FSMC_THIZ_1            (1 << 24)
-
-extern int spear_nand_init(struct nand_chip *nand);
-#endif
diff --git a/drivers/mtd/nand/spr_nand.c b/drivers/mtd/nand/spr_nand.c
deleted file mode 100644
index 097d0c6..0000000
--- a/drivers/mtd/nand/spr_nand.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * (C) Copyright 2009
- * Vipin Kumar, ST Micoelectronics, vipin.kumar@st.com.
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
- */
-
-#include <common.h>
-#include <nand.h>
-#include <linux/mtd/nand_ecc.h>
-#include <asm/io.h>
-#include <asm/arch/hardware.h>
-#include <asm/arch/spr_nand.h>
-
-static struct fsmc_regs *const fsmc_regs_p =
-    (struct fsmc_regs *)CONFIG_SPEAR_FSMCBASE;
-
-static struct nand_ecclayout spear_nand_ecclayout = {
-       .eccbytes = 24,
-       .eccpos = {2, 3, 4, 18, 19, 20, 34, 35, 36, 50, 51, 52,
-                  66, 67, 68, 82, 83, 84, 98, 99, 100, 114, 115, 116},
-       .oobfree = {
-                   {.offset = 8, .length = 8},
-                   {.offset = 24, .length = 8},
-                   {.offset = 40, .length = 8},
-                   {.offset = 56, .length = 8},
-                   {.offset = 72, .length = 8},
-                   {.offset = 88, .length = 8},
-                   {.offset = 104, .length = 8},
-                   {.offset = 120, .length = 8}
-                   }
-};
-
-static void spear_nand_hwcontrol(struct mtd_info *mtd, int cmd, uint ctrl)
-{
-       struct nand_chip *this = mtd->priv;
-       ulong IO_ADDR_W;
-
-       if (ctrl & NAND_CTRL_CHANGE) {
-               IO_ADDR_W = (ulong)this->IO_ADDR_W;
-
-               IO_ADDR_W &= ~(CONFIG_SYS_NAND_CLE | CONFIG_SYS_NAND_ALE);
-               if (ctrl & NAND_CLE)
-                       IO_ADDR_W |= CONFIG_SYS_NAND_CLE;
-               if (ctrl & NAND_ALE)
-                       IO_ADDR_W |= CONFIG_SYS_NAND_ALE;
-
-               if (ctrl & NAND_NCE) {
-                       writel(readl(&fsmc_regs_p->genmemctrl_pc) |
-                              FSMC_ENABLE, &fsmc_regs_p->genmemctrl_pc);
-               } else {
-                       writel(readl(&fsmc_regs_p->genmemctrl_pc) &
-                              ~FSMC_ENABLE, &fsmc_regs_p->genmemctrl_pc);
-               }
-               this->IO_ADDR_W = (void *)IO_ADDR_W;
-       }
-
-       if (cmd != NAND_CMD_NONE)
-               writeb(cmd, this->IO_ADDR_W);
-}
-
-static int spear_read_hwecc(struct mtd_info *mtd,
-                           const u_char *data, u_char ecc[3])
-{
-       u_int ecc_tmp;
-
-       /* read the h/w ECC */
-       ecc_tmp = readl(&fsmc_regs_p->genmemctrl_ecc);
-
-       ecc[0] = (u_char) (ecc_tmp & 0xFF);
-       ecc[1] = (u_char) ((ecc_tmp & 0xFF00) >> 8);
-       ecc[2] = (u_char) ((ecc_tmp & 0xFF0000) >> 16);
-
-       return 0;
-}
-
-void spear_enable_hwecc(struct mtd_info *mtd, int mode)
-{
-       writel(readl(&fsmc_regs_p->genmemctrl_pc) & ~0x80,
-              &fsmc_regs_p->genmemctrl_pc);
-       writel(readl(&fsmc_regs_p->genmemctrl_pc) & ~FSMC_ECCEN,
-              &fsmc_regs_p->genmemctrl_pc);
-       writel(readl(&fsmc_regs_p->genmemctrl_pc) | FSMC_ECCEN,
-              &fsmc_regs_p->genmemctrl_pc);
-}
-
-int spear_nand_init(struct nand_chip *nand)
-{
-       writel(FSMC_DEVWID_8 | FSMC_DEVTYPE_NAND | FSMC_ENABLE | FSMC_WAITON,
-              &fsmc_regs_p->genmemctrl_pc);
-       writel(readl(&fsmc_regs_p->genmemctrl_pc) | FSMC_TCLR_1 | FSMC_TAR_1,
-              &fsmc_regs_p->genmemctrl_pc);
-       writel(FSMC_THIZ_1 | FSMC_THOLD_4 | FSMC_TWAIT_6 | FSMC_TSET_0,
-              &fsmc_regs_p->genmemctrl_comm);
-       writel(FSMC_THIZ_1 | FSMC_THOLD_4 | FSMC_TWAIT_6 | FSMC_TSET_0,
-              &fsmc_regs_p->genmemctrl_attrib);
-
-       nand->options = 0;
-       nand->ecc.mode = NAND_ECC_HW;
-       nand->ecc.layout = &spear_nand_ecclayout;
-       nand->ecc.size = 512;
-       nand->ecc.bytes = 3;
-       nand->ecc.calculate = spear_read_hwecc;
-       nand->ecc.hwctl = spear_enable_hwecc;
-       nand->ecc.correct = nand_correct_data;
-       nand->cmd_ctrl = spear_nand_hwcontrol;
-       return 0;
-}
