summaryrefslogtreecommitdiff
path: root/drivers/mtd
diff options
context:
space:
mode:
authorHeiko Schocher <hs@denx.de>2016-06-07 08:55:41 +0200
committerTom Rini <trini@konsulko.com>2016-06-09 13:53:12 -0400
commit5d29e27eb93229f27d2c88d5538ad781c144c852 (patch)
tree6560b7d5f6ab21a745283ac000d4b6d1f34a002e /drivers/mtd
parentcddfc97d1fc892353d6616cd4287c34c454941e6 (diff)
downloadu-boot-imx-5d29e27eb93229f27d2c88d5538ad781c144c852.zip
u-boot-imx-5d29e27eb93229f27d2c88d5538ad781c144c852.tar.gz
u-boot-imx-5d29e27eb93229f27d2c88d5538ad781c144c852.tar.bz2
nand: add nand mtd concat support
add for nand devices mtd concat support. Generic MTD concat support is already ported to mainline, and used in the cfi_mtd driver. This patch adds it similiar for nand devices. Signed-off-by: Heiko Schocher <hs@denx.de>
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/nand/nand.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/drivers/mtd/nand/nand.c b/drivers/mtd/nand/nand.c
index f449316..0551241 100644
--- a/drivers/mtd/nand/nand.c
+++ b/drivers/mtd/nand/nand.c
@@ -9,6 +9,7 @@
#include <common.h>
#include <nand.h>
#include <errno.h>
+#include <linux/mtd/concat.h>
#ifndef CONFIG_SYS_NAND_BASE_LIST
#define CONFIG_SYS_NAND_BASE_LIST { CONFIG_SYS_NAND_BASE }
@@ -92,6 +93,44 @@ static void nand_init_chip(int i)
}
#endif
+#ifdef CONFIG_MTD_CONCAT
+static void create_mtd_concat(void)
+{
+ struct mtd_info *nand_info_list[CONFIG_SYS_MAX_NAND_DEVICE];
+ int nand_devices_found = 0;
+ int i;
+
+ for (i = 0; i < CONFIG_SYS_MAX_NAND_DEVICE; i++) {
+ if (nand_info[i] != NULL) {
+ nand_info_list[nand_devices_found] = nand_info[i];
+ nand_devices_found++;
+ }
+ }
+ if (nand_devices_found > 1) {
+ struct mtd_info *mtd;
+ char c_mtd_name[16];
+
+ /*
+ * We detected multiple devices. Concatenate them together.
+ */
+ sprintf(c_mtd_name, "nand%d", nand_devices_found);
+ mtd = mtd_concat_create(nand_info_list, nand_devices_found,
+ c_mtd_name);
+
+ if (mtd == NULL)
+ return;
+
+ nand_register(nand_devices_found, mtd);
+ }
+
+ return;
+}
+#else
+static void create_mtd_concat(void)
+{
+}
+#endif
+
void nand_init(void)
{
#ifdef CONFIG_SYS_NAND_SELF_INIT
@@ -112,4 +151,6 @@ void nand_init(void)
board_nand_select_device(mtd_to_nand(nand_info[nand_curr_device]),
nand_curr_device);
#endif
+
+ create_mtd_concat();
}