]> git.sur5r.net Git - u-boot/commitdiff
Separate mtdparts command from jffs2
authorStefan Roese <sr@denx.de>
Thu, 19 Mar 2009 12:30:36 +0000 (13:30 +0100)
committerWolfgang Denk <wd@denx.de>
Fri, 20 Mar 2009 21:39:14 +0000 (22:39 +0100)
Currently the mtdparts commands are included in the jffs2 command support.
This doesn't make sense anymore since other commands (e.g. UBI) use this
infrastructure as well now. This patch separates the mtdparts commands from
the jffs2 commands making it possible to only select mtdparts when no JFFS2
support is needed.

Signed-off-by: Stefan Roese <sr@denx.de>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
81 files changed:
README
board/fads/fads.h
common/Makefile
common/cmd_flash.c
common/cmd_jffs2.c
common/cmd_mtdparts.c [new file with mode: 0644]
common/cmd_nand.c
include/config_cmd_all.h
include/configs/ADNPESC1.h
include/configs/Alaska8220.h
include/configs/BAB7xx.h
include/configs/BC3450.h
include/configs/CATcenter.h
include/configs/DB64360.h
include/configs/DB64460.h
include/configs/DK1C20.h
include/configs/DK1S10.h
include/configs/ELPPC.h
include/configs/FPS850L.h
include/configs/FPS860L.h
include/configs/LANTEC.h
include/configs/MHPC.h
include/configs/MIP405.h
include/configs/ML2.h
include/configs/MPC8266ADS.h
include/configs/NC650.h
include/configs/NETTA.h
include/configs/PPChameleonEVB.h
include/configs/R360MPI.h
include/configs/RBC823.h
include/configs/Rattler.h
include/configs/SIMPC8313.h
include/configs/SXNI855T.h
include/configs/TB5200.h
include/configs/TQM5200.h
include/configs/TQM823L.h
include/configs/TQM823M.h
include/configs/TQM834x.h
include/configs/TQM850L.h
include/configs/TQM850M.h
include/configs/TQM855L.h
include/configs/TQM855M.h
include/configs/TQM85xx.h
include/configs/TQM860L.h
include/configs/TQM860M.h
include/configs/TQM862L.h
include/configs/TQM862M.h
include/configs/TQM866M.h
include/configs/ZUMA.h
include/configs/apollon.h
include/configs/cm5200.h
include/configs/debris.h
include/configs/ep7312.h
include/configs/ep8260.h
include/configs/fx12mm.h
include/configs/hymod.h
include/configs/idmr.h
include/configs/impa7.h
include/configs/imx31_litekit.h
include/configs/imx31_phycore.h
include/configs/incaip.h
include/configs/innokom.h
include/configs/microblaze-generic.h
include/configs/modnet50.h
include/configs/motionpro.h
include/configs/mx1fs2.h
include/configs/mx31ads.h
include/configs/netstar.h
include/configs/omap2420h4.h
include/configs/qong.h
include/configs/sc3.h
include/configs/sc520_cdp.h
include/configs/sc520_spunk.h
include/configs/smmaco4.h
include/configs/trab.h
include/configs/v37.h
include/configs/vct.h
include/configs/virtlab2.h
include/configs/voiceblue.h
include/configs/xilinx-ppc.h
include/configs/xsengine.h

diff --git a/README b/README
index 46181a4bcd24f22fcb95d0b1dfd50218750833c1..32d9acdd216a8a972d79852948a1542d000fd591 100644 (file)
--- a/README
+++ b/README
@@ -636,6 +636,7 @@ The following options need to be configured:
                CONFIG_CMD_MISC           Misc functions like sleep etc
                CONFIG_CMD_MMC          * MMC memory mapped support
                CONFIG_CMD_MII          * MII utility commands
+               CONFIG_CMD_MTDPARTS     * MTD partition support
                CONFIG_CMD_NAND         * NAND support
                CONFIG_CMD_NET            bootp, tftpboot, rarpboot
                CONFIG_CMD_PCA953X      * PCA953x I2C gpio commands
index 24e43eab3f582767d3e7aa53a32fda7e4db3b319..4ab4b2615af2afa17e7d5211c5fd518ff696feef 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=fads0,nor1=fads-1,nor2=fads-2,nor3=fads-3"
 #define MTDPARTS_DEFAULT       "mtdparts=fads-0:-@1m(user1),fads-1:-(user2),fads-2:-(user3),fads-3:-(user4)"
 */
index f13cd11b9a5b67b8492bfed3b6c261ec4c0d8f05..7237ff4795180666e4c0efe2b5f0e687530a8909 100644 (file)
@@ -110,6 +110,7 @@ COBJS-$(CONFIG_CMD_MII) += cmd_mii.o
 COBJS-$(CONFIG_CMD_MISC) += cmd_misc.o
 COBJS-$(CONFIG_CMD_MMC) += cmd_mmc.o
 COBJS-$(CONFIG_MP) += cmd_mp.o
+COBJS-$(CONFIG_CMD_MTDPARTS) += cmd_mtdparts.o
 COBJS-y += cmd_nand.o
 COBJS-$(CONFIG_CMD_NET) += cmd_net.o
 COBJS-$(CONFIG_CMD_ONENAND) += cmd_onenand.o
index 510654e1aeba7edee84daa07354b9234593a48cb..f1f3517b12fd0f6fbc5cf25672783c9f9f66c5f0 100644 (file)
 #include <dataflash.h>
 #endif
 
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
 #include <jffs2/jffs2.h>
 
 /* parition handling routines */
 int mtdparts_init(void);
-int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num);
+int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num);
 int find_dev_and_part(const char *id, struct mtd_device **dev,
                u8 *part_num, struct part_info **part);
 #endif
@@ -325,7 +325,7 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        flash_info_t *info;
        ulong bank, addr_first, addr_last;
        int n, sect_first, sect_last;
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
        struct mtd_device *dev;
        struct part_info *part;
        u8 dev_type, dev_num, pnum;
@@ -357,9 +357,9 @@ int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                return rcode;
        }
 
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
        /* erase <part-id> - erase partition */
-       if ((argc == 2) && (id_parse(argv[1], NULL, &dev_type, &dev_num) == 0)) {
+       if ((argc == 2) && (mtd_id_parse(argv[1], NULL, &dev_type, &dev_num) == 0)) {
                mtdparts_init();
                if (find_dev_and_part(argv[1], &dev, &pnum, &part) == 0) {
                        if (dev->id->type == MTD_DEV_TYPE_NOR) {
@@ -470,7 +470,7 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
 #endif /* CONFIG_SYS_NO_FLASH */
        ulong addr_first, addr_last;
        int p;
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
        struct mtd_device *dev;
        struct part_info *part;
        u8 dev_type, dev_num, pnum;
@@ -563,9 +563,9 @@ int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
                return rcode;
        }
 
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
        /* protect on/off <part-id> */
-       if ((argc == 3) && (id_parse(argv[2], NULL, &dev_type, &dev_num) == 0)) {
+       if ((argc == 3) && (mtd_id_parse(argv[2], NULL, &dev_type, &dev_num) == 0)) {
                mtdparts_init();
                if (find_dev_and_part(argv[2], &dev, &pnum, &part) == 0) {
                        if (dev->id->type == MTD_DEV_TYPE_NOR) {
@@ -698,7 +698,7 @@ int flash_sect_protect (int p, ulong addr_first, ulong addr_last)
 
 
 /**************************************************/
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
 # define TMP_ERASE     "erase <part-id>\n    - erase partition\n"
 # define TMP_PROT_ON   "protect on <part-id>\n    - protect partition\n"
 # define TMP_PROT_OFF  "protect off <part-id>\n    - make partition writable\n"
index d0a7ceaa58b34636bc455f1a560b75268cffee6e..860d1d97e3aedc4fabfe6bd63db49ef238a0e94d 100644 (file)
  * field for read-only partitions */
 #define MTD_WRITEABLE_CMD              1
 
-#ifdef CONFIG_JFFS2_CMDLINE
-/* default values for mtdids and mtdparts variables */
-#if defined(MTDIDS_DEFAULT)
-static const char *const mtdids_default = MTDIDS_DEFAULT;
-#else
-#warning "MTDIDS_DEFAULT not defined!"
-static const char *const mtdids_default = NULL;
-#endif
-
-#if defined(MTDPARTS_DEFAULT)
-static const char *const mtdparts_default = MTDPARTS_DEFAULT;
-#else
-#warning "MTDPARTS_DEFAULT not defined!"
-static const char *const mtdparts_default = NULL;
-#endif
-
-/* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */
-#define MTDIDS_MAXLEN          128
-#define MTDPARTS_MAXLEN                512
-#define PARTITION_MAXLEN       16
-static char last_ids[MTDIDS_MAXLEN];
-static char last_parts[MTDPARTS_MAXLEN];
-static char last_partition[PARTITION_MAXLEN];
-
-/* low level jffs2 cache cleaning routine */
-extern void jffs2_free_cache(struct part_info *part);
-
-/* mtdids mapping list, filled by parse_ids() */
-struct list_head mtdids;
-
-/* device/partition list, parse_cmdline() parses into here */
-struct list_head devices;
-#endif /* #ifdef CONFIG_JFFS2_CMDLINE */
-
-/* current active device and partition number */
-static struct mtd_device *current_dev = NULL;
-static u8 current_partnum = 0;
-
-#if defined(CONFIG_CMD_CRAMFS)
-extern int cramfs_check (struct part_info *info);
-extern int cramfs_load (char *loadoffset, struct part_info *info, char *filename);
-extern int cramfs_ls (struct part_info *info, char *filename);
-extern int cramfs_info (struct part_info *info);
-#else
-/* defining empty macros for function names is ugly but avoids ifdef clutter
- * all over the code */
-#define cramfs_check(x)                (0)
-#define cramfs_load(x,y,z)     (-1)
-#define cramfs_ls(x,y)         (0)
-#define cramfs_info(x)         (0)
-#endif
-
-static struct part_info* jffs2_part_info(struct mtd_device *dev, unsigned int part_num);
-
-/* command line only routines */
-#ifdef CONFIG_JFFS2_CMDLINE
-
-static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_len);
-static int device_del(struct mtd_device *dev);
-
-/**
- * Parses a string into a number.  The number stored at ptr is
- * potentially suffixed with K (for kilobytes, or 1024 bytes),
- * M (for megabytes, or 1048576 bytes), or G (for gigabytes, or
- * 1073741824).  If the number is suffixed with K, M, or G, then
- * the return value is the number multiplied by one kilobyte, one
- * megabyte, or one gigabyte, respectively.
- *
- * @param ptr where parse begins
- * @param retptr output pointer to next char after parse completes (output)
- * @return resulting unsigned int
- */
-static unsigned long memsize_parse (const char *const ptr, const char **retptr)
-{
-       unsigned long ret = simple_strtoul(ptr, (char **)retptr, 0);
-
-       switch (**retptr) {
-               case 'G':
-               case 'g':
-                       ret <<= 10;
-               case 'M':
-               case 'm':
-                       ret <<= 10;
-               case 'K':
-               case 'k':
-                       ret <<= 10;
-                       (*retptr)++;
-               default:
-                       break;
-       }
-
-       return ret;
-}
-
-/**
- * Format string describing supplied size. This routine does the opposite job
- * to memsize_parse(). Size in bytes is converted to string and if possible
- * shortened by using k (kilobytes), m (megabytes) or g (gigabytes) suffix.
- *
- * Note, that this routine does not check for buffer overflow, it's the caller
- * who must assure enough space.
- *
- * @param buf output buffer
- * @param size size to be converted to string
- */
-static void memsize_format(char *buf, u32 size)
-{
-#define SIZE_GB ((u32)1024*1024*1024)
-#define SIZE_MB ((u32)1024*1024)
-#define SIZE_KB ((u32)1024)
-
-       if ((size % SIZE_GB) == 0)
-               sprintf(buf, "%ug", size/SIZE_GB);
-       else if ((size % SIZE_MB) == 0)
-               sprintf(buf, "%um", size/SIZE_MB);
-       else if (size % SIZE_KB == 0)
-               sprintf(buf, "%uk", size/SIZE_KB);
-       else
-               sprintf(buf, "%u", size);
-}
-
-/**
- * This routine does global indexing of all partitions. Resulting index for
- * current partition is saved in 'mtddevnum'. Current partition name in
- * 'mtddevname'.
- */
-static void index_partitions(void)
-{
-       char buf[16];
-       u16 mtddevnum;
-       struct part_info *part;
-       struct list_head *dentry;
-       struct mtd_device *dev;
-
-       DEBUGF("--- index partitions ---\n");
-
-       if (current_dev) {
-               mtddevnum = 0;
-               list_for_each(dentry, &devices) {
-                       dev = list_entry(dentry, struct mtd_device, link);
-                       if (dev == current_dev) {
-                               mtddevnum += current_partnum;
-                               sprintf(buf, "%d", mtddevnum);
-                               setenv("mtddevnum", buf);
-                               break;
-                       }
-                       mtddevnum += dev->num_parts;
-               }
-
-               part = jffs2_part_info(current_dev, current_partnum);
-               setenv("mtddevname", part->name);
-
-               DEBUGF("=> mtddevnum %d,\n=> mtddevname %s\n", mtddevnum, part->name);
-       } else {
-               setenv("mtddevnum", NULL);
-               setenv("mtddevname", NULL);
-
-               DEBUGF("=> mtddevnum NULL\n=> mtddevname NULL\n");
-       }
-}
-
-/**
- * Save current device and partition in environment variable 'partition'.
- */
-static void current_save(void)
-{
-       char buf[16];
-
-       DEBUGF("--- current_save ---\n");
-
-       if (current_dev) {
-               sprintf(buf, "%s%d,%d", MTD_DEV_TYPE(current_dev->id->type),
-                                       current_dev->id->num, current_partnum);
-
-               setenv("partition", buf);
-               strncpy(last_partition, buf, 16);
-
-               DEBUGF("=> partition %s\n", buf);
-       } else {
-               setenv("partition", NULL);
-               last_partition[0] = '\0';
-
-               DEBUGF("=> partition NULL\n");
-       }
-       index_partitions();
-}
-
-/**
- * Performs sanity check for supplied NOR flash partition. Table of existing
- * NOR flash devices is searched and partition device is located. Alignment
- * with the granularity of NOR flash sectors is verified.
- *
- * @param id of the parent device
- * @param part partition to validate
- * @return 0 if partition is valid, 1 otherwise
- */
-static int part_validate_nor(struct mtdids *id, struct part_info *part)
-{
-#if defined(CONFIG_CMD_FLASH)
-       /* info for FLASH chips */
-       extern flash_info_t flash_info[];
-       flash_info_t *flash;
-       int offset_aligned;
-       u32 end_offset, sector_size = 0;
-       int i;
-
-       flash = &flash_info[id->num];
-
-       /* size of last sector */
-       part->sector_size = flash->size -
-               (flash->start[flash->sector_count-1] - flash->start[0]);
-
-       offset_aligned = 0;
-       for (i = 0; i < flash->sector_count; i++) {
-               if ((flash->start[i] - flash->start[0]) == part->offset) {
-                       offset_aligned = 1;
-                       break;
-               }
-       }
-       if (offset_aligned == 0) {
-               printf("%s%d: partition (%s) start offset alignment incorrect\n",
-                               MTD_DEV_TYPE(id->type), id->num, part->name);
-               return 1;
-       }
-
-       end_offset = part->offset + part->size;
-       offset_aligned = 0;
-       for (i = 0; i < flash->sector_count; i++) {
-               if (i) {
-                       sector_size = flash->start[i] - flash->start[i-1];
-                       if (part->sector_size < sector_size)
-                               part->sector_size = sector_size;
-               }
-               if ((flash->start[i] - flash->start[0]) == end_offset)
-                       offset_aligned = 1;
-       }
-
-       if (offset_aligned || flash->size == end_offset)
-               return 0;
-
-       printf("%s%d: partition (%s) size alignment incorrect\n",
-                       MTD_DEV_TYPE(id->type), id->num, part->name);
-#endif
-       return 1;
-}
-
-/**
- * Performs sanity check for supplied NAND flash partition. Table of existing
- * NAND flash devices is searched and partition device is located. Alignment
- * with the granularity of nand erasesize is verified.
- *
- * @param id of the parent device
- * @param part partition to validate
- * @return 0 if partition is valid, 1 otherwise
- */
-static int part_validate_nand(struct mtdids *id, struct part_info *part)
-{
-#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
-       /* info for NAND chips */
-       nand_info_t *nand;
-
-       nand = &nand_info[id->num];
-
-       part->sector_size = nand->erasesize;
-
-       if ((unsigned long)(part->offset) % nand->erasesize) {
-               printf("%s%d: partition (%s) start offset alignment incorrect\n",
-                               MTD_DEV_TYPE(id->type), id->num, part->name);
-               return 1;
-       }
-
-       if (part->size % nand->erasesize) {
-               printf("%s%d: partition (%s) size alignment incorrect\n",
-                               MTD_DEV_TYPE(id->type), id->num, part->name);
-               return 1;
-       }
-
-       return 0;
-#else
-       return 1;
-#endif
-}
-
-/**
- * Performs sanity check for supplied OneNAND flash partition.
- * Table of existing OneNAND flash devices is searched and partition device
- * is located. Alignment with the granularity of nand erasesize is verified.
- *
- * @param id of the parent device
- * @param part partition to validate
- * @return 0 if partition is valid, 1 otherwise
- */
-static int part_validate_onenand(struct mtdids *id, struct part_info *part)
-{
-#if defined(CONFIG_CMD_ONENAND)
-       /* info for OneNAND chips */
-       struct mtd_info *mtd;
-
-       mtd = &onenand_mtd;
-
-       part->sector_size = mtd->erasesize;
-
-       if ((unsigned long)(part->offset) % mtd->erasesize) {
-               printf("%s%d: partition (%s) start offset"
-                       "alignment incorrect\n",
-                               MTD_DEV_TYPE(id->type), id->num, part->name);
-               return 1;
-       }
-
-       if (part->size % mtd->erasesize) {
-               printf("%s%d: partition (%s) size alignment incorrect\n",
-                               MTD_DEV_TYPE(id->type), id->num, part->name);
-               return 1;
-       }
-
-       return 0;
-#else
-       return 1;
-#endif
-}
-
-
-/**
- * Performs sanity check for supplied partition. Offset and size are verified
- * to be within valid range. Partition type is checked and either
- * parts_validate_nor() or parts_validate_nand() is called with the argument
- * of part.
- *
- * @param id of the parent device
- * @param part partition to validate
- * @return 0 if partition is valid, 1 otherwise
- */
-static int part_validate(struct mtdids *id, struct part_info *part)
-{
-       if (part->size == SIZE_REMAINING)
-               part->size = id->size - part->offset;
-
-       if (part->offset > id->size) {
-               printf("%s: offset %08x beyond flash size %08x\n",
-                               id->mtd_id, part->offset, id->size);
-               return 1;
-       }
-
-       if ((part->offset + part->size) <= part->offset) {
-               printf("%s%d: partition (%s) size too big\n",
-                               MTD_DEV_TYPE(id->type), id->num, part->name);
-               return 1;
-       }
-
-       if (part->offset + part->size > id->size) {
-               printf("%s: partitioning exceeds flash size\n", id->mtd_id);
-               return 1;
-       }
-
-       if (id->type == MTD_DEV_TYPE_NAND)
-               return part_validate_nand(id, part);
-       else if (id->type == MTD_DEV_TYPE_NOR)
-               return part_validate_nor(id, part);
-       else if (id->type == MTD_DEV_TYPE_ONENAND)
-               return part_validate_onenand(id, part);
-       else
-               DEBUGF("part_validate: invalid dev type\n");
-
-       return 1;
-}
-
-/**
- * Delete selected partition from the partion list of the specified device.
- *
- * @param dev device to delete partition from
- * @param part partition to delete
- * @return 0 on success, 1 otherwise
- */
-static int part_del(struct mtd_device *dev, struct part_info *part)
-{
-       u8 current_save_needed = 0;
-
-       /* if there is only one partition, remove whole device */
-       if (dev->num_parts == 1)
-               return device_del(dev);
-
-       /* otherwise just delete this partition */
-
-       if (dev == current_dev) {
-               /* we are modyfing partitions for the current device,
-                * update current */
-               struct part_info *curr_pi;
-               curr_pi = jffs2_part_info(current_dev, current_partnum);
-
-               if (curr_pi) {
-                       if (curr_pi == part) {
-                               printf("current partition deleted, resetting current to 0\n");
-                               current_partnum = 0;
-                       } else if (part->offset <= curr_pi->offset) {
-                               current_partnum--;
-                       }
-                       current_save_needed = 1;
-               }
-       }
-
-#ifdef CONFIG_NAND_LEGACY
-       jffs2_free_cache(part);
-#endif
-       list_del(&part->link);
-       free(part);
-       dev->num_parts--;
-
-       if (current_save_needed > 0)
-               current_save();
-       else
-               index_partitions();
-
-       return 0;
-}
-
-/**
- * Delete all partitions from parts head list, free memory.
- *
- * @param head list of partitions to delete
- */
-static void part_delall(struct list_head *head)
-{
-       struct list_head *entry, *n;
-       struct part_info *part_tmp;
-
-       /* clean tmp_list and free allocated memory */
-       list_for_each_safe(entry, n, head) {
-               part_tmp = list_entry(entry, struct part_info, link);
-
-#ifdef CONFIG_NAND_LEGACY
-               jffs2_free_cache(part_tmp);
-#endif
-               list_del(entry);
-               free(part_tmp);
-       }
-}
-
-/**
- * Add new partition to the supplied partition list. Make sure partitions are
- * sorted by offset in ascending order.
- *
- * @param head list this partition is to be added to
- * @param new partition to be added
- */
-static int part_sort_add(struct mtd_device *dev, struct part_info *part)
-{
-       struct list_head *entry;
-       struct part_info *new_pi, *curr_pi;
-
-       /* link partition to parrent dev */
-       part->dev = dev;
-
-       if (list_empty(&dev->parts)) {
-               DEBUGF("part_sort_add: list empty\n");
-               list_add(&part->link, &dev->parts);
-               dev->num_parts++;
-               index_partitions();
-               return 0;
-       }
-
-       new_pi = list_entry(&part->link, struct part_info, link);
-
-       /* get current partition info if we are updating current device */
-       curr_pi = NULL;
-       if (dev == current_dev)
-               curr_pi = jffs2_part_info(current_dev, current_partnum);
-
-       list_for_each(entry, &dev->parts) {
-               struct part_info *pi;
-
-               pi = list_entry(entry, struct part_info, link);
-
-               /* be compliant with kernel cmdline, allow only one partition at offset zero */
-               if ((new_pi->offset == pi->offset) && (pi->offset == 0)) {
-                       printf("cannot add second partition at offset 0\n");
-                       return 1;
-               }
-
-               if (new_pi->offset <= pi->offset) {
-                       list_add_tail(&part->link, entry);
-                       dev->num_parts++;
-
-                       if (curr_pi && (pi->offset <= curr_pi->offset)) {
-                               /* we are modyfing partitions for the current
-                                * device, update current */
-                               current_partnum++;
-                               current_save();
-                       } else {
-                               index_partitions();
-                       }
-                       return 0;
-               }
-       }
-
-       list_add_tail(&part->link, &dev->parts);
-       dev->num_parts++;
-       index_partitions();
-       return 0;
-}
-
-/**
- * Add provided partition to the partition list of a given device.
- *
- * @param dev device to which partition is added
- * @param part partition to be added
- * @return 0 on success, 1 otherwise
- */
-static int part_add(struct mtd_device *dev, struct part_info *part)
-{
-       /* verify alignment and size */
-       if (part_validate(dev->id, part) != 0)
-               return 1;
-
-       /* partition is ok, add it to the list */
-       if (part_sort_add(dev, part) != 0)
-               return 1;
-
-       return 0;
-}
-
-/**
- * Parse one partition definition, allocate memory and return pointer to this
- * location in retpart.
- *
- * @param partdef pointer to the partition definition string i.e. <part-def>
- * @param ret output pointer to next char after parse completes (output)
- * @param retpart pointer to the allocated partition (output)
- * @return 0 on success, 1 otherwise
- */
-static int part_parse(const char *const partdef, const char **ret, struct part_info **retpart)
-{
-       struct part_info *part;
-       unsigned long size;
-       unsigned long offset;
-       const char *name;
-       int name_len;
-       unsigned int mask_flags;
-       const char *p;
-
-       p = partdef;
-       *retpart = NULL;
-       *ret = NULL;
-
-       /* fetch the partition size */
-       if (*p == '-') {
-               /* assign all remaining space to this partition */
-               DEBUGF("'-': remaining size assigned\n");
-               size = SIZE_REMAINING;
-               p++;
-       } else {
-               size = memsize_parse(p, &p);
-               if (size < MIN_PART_SIZE) {
-                       printf("partition size too small (%lx)\n", size);
-                       return 1;
-               }
-       }
-
-       /* check for offset */
-       offset = OFFSET_NOT_SPECIFIED;
-       if (*p == '@') {
-               p++;
-               offset = memsize_parse(p, &p);
-       }
-
-       /* now look for the name */
-       if (*p == '(') {
-               name = ++p;
-               if ((p = strchr(name, ')')) == NULL) {
-                       printf("no closing ) found in partition name\n");
-                       return 1;
-               }
-               name_len = p - name + 1;
-               if ((name_len - 1) == 0) {
-                       printf("empty partition name\n");
-                       return 1;
-               }
-               p++;
-       } else {
-               /* 0x00000000@0x00000000 */
-               name_len = 22;
-               name = NULL;
-       }
-
-       /* test for options */
-       mask_flags = 0;
-       if (strncmp(p, "ro", 2) == 0) {
-               mask_flags |= MTD_WRITEABLE_CMD;
-               p += 2;
-       }
-
-       /* check for next partition definition */
-       if (*p == ',') {
-               if (size == SIZE_REMAINING) {
-                       *ret = NULL;
-                       printf("no partitions allowed after a fill-up partition\n");
-                       return 1;
-               }
-               *ret = ++p;
-       } else if ((*p == ';') || (*p == '\0')) {
-               *ret = p;
-       } else {
-               printf("unexpected character '%c' at the end of partition\n", *p);
-               *ret = NULL;
-               return 1;
-       }
-
-       /*  allocate memory */
-       part = (struct part_info *)malloc(sizeof(struct part_info) + name_len);
-       if (!part) {
-               printf("out of memory\n");
-               return 1;
-       }
-       memset(part, 0, sizeof(struct part_info) + name_len);
-       part->size = size;
-       part->offset = offset;
-       part->mask_flags = mask_flags;
-       part->name = (char *)(part + 1);
-
-       if (name) {
-               /* copy user provided name */
-               strncpy(part->name, name, name_len - 1);
-               part->auto_name = 0;
-       } else {
-               /* auto generated name in form of size@offset */
-               sprintf(part->name, "0x%08lx@0x%08lx", size, offset);
-               part->auto_name = 1;
-       }
-
-       part->name[name_len - 1] = '\0';
-       INIT_LIST_HEAD(&part->link);
-
-       DEBUGF("+ partition: name %-22s size 0x%08x offset 0x%08x mask flags %d\n",
-                       part->name, part->size,
-                       part->offset, part->mask_flags);
-
-       *retpart = part;
-       return 0;
-}
-#endif/* #ifdef CONFIG_JFFS2_CMDLINE */
-
-/**
- * Check device number to be within valid range for given device type.
- *
- * @param dev device to validate
- * @return 0 if device is valid, 1 otherwise
- */
-static int device_validate(u8 type, u8 num, u32 *size)
-{
-       if (type == MTD_DEV_TYPE_NOR) {
-#if defined(CONFIG_CMD_FLASH)
-               if (num < CONFIG_SYS_MAX_FLASH_BANKS) {
-                       extern flash_info_t flash_info[];
-                       *size = flash_info[num].size;
-
-                       return 0;
-               }
-
-               printf("no such FLASH device: %s%d (valid range 0 ... %d\n",
-                               MTD_DEV_TYPE(type), num, CONFIG_SYS_MAX_FLASH_BANKS - 1);
-#else
-               printf("support for FLASH devices not present\n");
-#endif
-       } else if (type == MTD_DEV_TYPE_NAND) {
-#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
-               if (num < CONFIG_SYS_MAX_NAND_DEVICE) {
-#ifndef CONFIG_NAND_LEGACY
-                       *size = nand_info[num].size;
-#else
-                       extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
-                       *size = nand_dev_desc[num].totlen;
-#endif
-                       return 0;
-               }
-
-               printf("no such NAND device: %s%d (valid range 0 ... %d)\n",
-                               MTD_DEV_TYPE(type), num, CONFIG_SYS_MAX_NAND_DEVICE - 1);
-#else
-               printf("support for NAND devices not present\n");
-#endif
-       } else if (type == MTD_DEV_TYPE_ONENAND) {
-#if defined(CONFIG_CMD_ONENAND)
-               *size = onenand_mtd.size;
-               return 0;
-#else
-               printf("support for OneNAND devices not present\n");
-#endif
-       } else
-               printf("Unknown defice type %d\n", type);
-
-       return 1;
-}
-
-#ifdef CONFIG_JFFS2_CMDLINE
-/**
- * Delete all mtd devices from a supplied devices list, free memory allocated for
- * each device and delete all device partitions.
- *
- * @return 0 on success, 1 otherwise
- */
-static int device_delall(struct list_head *head)
-{
-       struct list_head *entry, *n;
-       struct mtd_device *dev_tmp;
-
-       /* clean devices list */
-       list_for_each_safe(entry, n, head) {
-               dev_tmp = list_entry(entry, struct mtd_device, link);
-               list_del(entry);
-               part_delall(&dev_tmp->parts);
-               free(dev_tmp);
-       }
-       INIT_LIST_HEAD(&devices);
-
-       return 0;
-}
-
-/**
- * If provided device exists it's partitions are deleted, device is removed
- * from device list and device memory is freed.
- *
- * @param dev device to be deleted
- * @return 0 on success, 1 otherwise
- */
-static int device_del(struct mtd_device *dev)
-{
-       part_delall(&dev->parts);
-       list_del(&dev->link);
-       free(dev);
-
-       if (dev == current_dev) {
-               /* we just deleted current device */
-               if (list_empty(&devices)) {
-                       current_dev = NULL;
-               } else {
-                       /* reset first partition from first dev from the
-                        * devices list as current */
-                       current_dev = list_entry(devices.next, struct mtd_device, link);
-                       current_partnum = 0;
-               }
-               current_save();
-               return 0;
-       }
-
-       index_partitions();
-       return 0;
-}
-
-/**
- * Search global device list and return pointer to the device of type and num
- * specified.
- *
- * @param type device type
- * @param num device number
- * @return NULL if requested device does not exist
- */
-static struct mtd_device* device_find(u8 type, u8 num)
-{
-       struct list_head *entry;
-       struct mtd_device *dev_tmp;
-
-       list_for_each(entry, &devices) {
-               dev_tmp = list_entry(entry, struct mtd_device, link);
-
-               if ((dev_tmp->id->type == type) && (dev_tmp->id->num == num))
-                       return dev_tmp;
-       }
-
-       return NULL;
-}
-
-/**
- * Add specified device to the global device list.
- *
- * @param dev device to be added
- */
-static void device_add(struct mtd_device *dev)
-{
-       u8 current_save_needed = 0;
-
-       if (list_empty(&devices)) {
-               current_dev = dev;
-               current_partnum = 0;
-               current_save_needed = 1;
-       }
-
-       list_add_tail(&dev->link, &devices);
-
-       if (current_save_needed > 0)
-               current_save();
-       else
-               index_partitions();
-}
-
-/**
- * Parse device type, name and mtd-id. If syntax is ok allocate memory and
- * return pointer to the device structure.
- *
- * @param mtd_dev pointer to the device definition string i.e. <mtd-dev>
- * @param ret output pointer to next char after parse completes (output)
- * @param retdev pointer to the allocated device (output)
- * @return 0 on success, 1 otherwise
- */
-static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_device **retdev)
-{
-       struct mtd_device *dev;
-       struct part_info *part;
-       struct mtdids *id;
-       const char *mtd_id;
-       unsigned int mtd_id_len;
-       const char *p, *pend;
-       LIST_HEAD(tmp_list);
-       struct list_head *entry, *n;
-       u16 num_parts;
-       u32 offset;
-       int err = 1;
-
-       p = mtd_dev;
-       *retdev = NULL;
-       *ret = NULL;
-
-       DEBUGF("===device_parse===\n");
-
-       /* fetch <mtd-id> */
-       mtd_id = p;
-       if (!(p = strchr(mtd_id, ':'))) {
-               printf("no <mtd-id> identifier\n");
-               return 1;
-       }
-       mtd_id_len = p - mtd_id + 1;
-       p++;
-
-       /* verify if we have a valid device specified */
-       if ((id = id_find_by_mtd_id(mtd_id, mtd_id_len - 1)) == NULL) {
-               printf("invalid mtd device '%.*s'\n", mtd_id_len - 1, mtd_id);
-               return 1;
-       }
-
-       DEBUGF("dev type = %d (%s), dev num = %d, mtd-id = %s\n",
-                       id->type, MTD_DEV_TYPE(id->type),
-                       id->num, id->mtd_id);
-       pend = strchr(p, ';');
-       DEBUGF("parsing partitions %.*s\n", (pend ? pend - p : strlen(p)), p);
-
-
-       /* parse partitions */
-       num_parts = 0;
-
-       offset = 0;
-       if ((dev = device_find(id->type, id->num)) != NULL) {
-               /* if device already exists start at the end of the last partition */
-               part = list_entry(dev->parts.prev, struct part_info, link);
-               offset = part->offset + part->size;
-       }
-
-       while (p && (*p != '\0') && (*p != ';')) {
-               err = 1;
-               if ((part_parse(p, &p, &part) != 0) || (!part))
-                       break;
-
-               /* calculate offset when not specified */
-               if (part->offset == OFFSET_NOT_SPECIFIED)
-                       part->offset = offset;
-               else
-                       offset = part->offset;
-
-               /* verify alignment and size */
-               if (part_validate(id, part) != 0)
-                       break;
-
-               offset += part->size;
-
-               /* partition is ok, add it to the list */
-               list_add_tail(&part->link, &tmp_list);
-               num_parts++;
-               err = 0;
-       }
-       if (err == 1) {
-               part_delall(&tmp_list);
-               return 1;
-       }
-
-       if (num_parts == 0) {
-               printf("no partitions for device %s%d (%s)\n",
-                               MTD_DEV_TYPE(id->type), id->num, id->mtd_id);
-               return 1;
-       }
-
-       DEBUGF("\ntotal partitions: %d\n", num_parts);
-
-       /* check for next device presence */
-       if (p) {
-               if (*p == ';') {
-                       *ret = ++p;
-               } else if (*p == '\0') {
-                       *ret = p;
-               } else {
-                       printf("unexpected character '%c' at the end of device\n", *p);
-                       *ret = NULL;
-                       return 1;
-               }
-       }
-
-       /* allocate memory for mtd_device structure */
-       if ((dev = (struct mtd_device *)malloc(sizeof(struct mtd_device))) == NULL) {
-               printf("out of memory\n");
-               return 1;
-       }
-       memset(dev, 0, sizeof(struct mtd_device));
-       dev->id = id;
-       dev->num_parts = 0; /* part_sort_add increments num_parts */
-       INIT_LIST_HEAD(&dev->parts);
-       INIT_LIST_HEAD(&dev->link);
-
-       /* move partitions from tmp_list to dev->parts */
-       list_for_each_safe(entry, n, &tmp_list) {
-               part = list_entry(entry, struct part_info, link);
-               list_del(entry);
-               if (part_sort_add(dev, part) != 0) {
-                       device_del(dev);
-                       return 1;
-               }
-       }
-
-       *retdev = dev;
-
-       DEBUGF("===\n\n");
-       return 0;
-}
-
-/**
- * Initialize global device list.
- *
- * @return 0 on success, 1 otherwise
- */
-static int jffs2_devices_init(void)
-{
-       last_parts[0] = '\0';
-       current_dev = NULL;
-       current_save();
-
-       return device_delall(&devices);
-}
-
-/*
- * Search global mtdids list and find id of requested type and number.
- *
- * @return pointer to the id if it exists, NULL otherwise
- */
-static struct mtdids* id_find(u8 type, u8 num)
-{
-       struct list_head *entry;
-       struct mtdids *id;
-
-       list_for_each(entry, &mtdids) {
-               id = list_entry(entry, struct mtdids, link);
-
-               if ((id->type == type) && (id->num == num))
-                       return id;
-       }
-
-       return NULL;
-}
-
-/**
- * Search global mtdids list and find id of a requested mtd_id.
- *
- * Note: first argument is not null terminated.
- *
- * @param mtd_id string containing requested mtd_id
- * @param mtd_id_len length of supplied mtd_id
- * @return pointer to the id if it exists, NULL otherwise
- */
-static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_len)
-{
-       struct list_head *entry;
-       struct mtdids *id;
-
-       DEBUGF("--- id_find_by_mtd_id: '%.*s' (len = %d)\n",
-                       mtd_id_len, mtd_id, mtd_id_len);
-
-       list_for_each(entry, &mtdids) {
-               id = list_entry(entry, struct mtdids, link);
-
-               DEBUGF("entry: '%s' (len = %d)\n",
-                               id->mtd_id, strlen(id->mtd_id));
-
-               if (mtd_id_len != strlen(id->mtd_id))
-                       continue;
-               if (strncmp(id->mtd_id, mtd_id, mtd_id_len) == 0)
-                       return id;
-       }
-
-       return NULL;
-}
-#endif /* #ifdef CONFIG_JFFS2_CMDLINE */
-
-/**
- * Parse device id string <dev-id> := 'nand'|'nor'|'onenand'<dev-num>,
- * return device type and number.
- *
- * @param id string describing device id
- * @param ret_id output pointer to next char after parse completes (output)
- * @param dev_type parsed device type (output)
- * @param dev_num parsed device number (output)
- * @return 0 on success, 1 otherwise
- */
-int id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num)
-{
-       const char *p = id;
-
-       *dev_type = 0;
-       if (strncmp(p, "nand", 4) == 0) {
-               *dev_type = MTD_DEV_TYPE_NAND;
-               p += 4;
-       } else if (strncmp(p, "nor", 3) == 0) {
-               *dev_type = MTD_DEV_TYPE_NOR;
-               p += 3;
-       } else if (strncmp(p, "onenand", 7) == 0) {
-               *dev_type = MTD_DEV_TYPE_ONENAND;
-               p += 7;
-       } else {
-               printf("incorrect device type in %s\n", id);
-               return 1;
-       }
-
-       if (!isdigit(*p)) {
-               printf("incorrect device number in %s\n", id);
-               return 1;
-       }
-
-       *dev_num = simple_strtoul(p, (char **)&p, 0);
-       if (ret_id)
-               *ret_id = p;
-       return 0;
-}
-
-#ifdef CONFIG_JFFS2_CMDLINE
-/**
- * Process all devices and generate corresponding mtdparts string describing
- * all partitions on all devices.
- *
- * @param buf output buffer holding generated mtdparts string (output)
- * @param buflen buffer size
- * @return 0 on success, 1 otherwise
- */
-static int generate_mtdparts(char *buf, u32 buflen)
-{
-       struct list_head *pentry, *dentry;
-       struct mtd_device *dev;
-       struct part_info *part, *prev_part;
-       char *p = buf;
-       char tmpbuf[32];
-       u32 size, offset, len, part_cnt;
-       u32 maxlen = buflen - 1;
-
-       DEBUGF("--- generate_mtdparts ---\n");
-
-       if (list_empty(&devices)) {
-               buf[0] = '\0';
-               return 0;
-       }
-
-       sprintf(p, "mtdparts=");
-       p += 9;
-
-       list_for_each(dentry, &devices) {
-               dev = list_entry(dentry, struct mtd_device, link);
-
-               /* copy mtd_id */
-               len = strlen(dev->id->mtd_id) + 1;
-               if (len > maxlen)
-                       goto cleanup;
-               memcpy(p, dev->id->mtd_id, len - 1);
-               p += len - 1;
-               *(p++) = ':';
-               maxlen -= len;
-
-               /* format partitions */
-               prev_part = NULL;
-               part_cnt = 0;
-               list_for_each(pentry, &dev->parts) {
-                       part = list_entry(pentry, struct part_info, link);
-                       size = part->size;
-                       offset = part->offset;
-                       part_cnt++;
-
-                       /* partition size */
-                       memsize_format(tmpbuf, size);
-                       len = strlen(tmpbuf);
-                       if (len > maxlen)
-                               goto cleanup;
-                       memcpy(p, tmpbuf, len);
-                       p += len;
-                       maxlen -= len;
-
-
-                       /* add offset only when there is a gap between
-                        * partitions */
-                       if ((!prev_part && (offset != 0)) ||
-                                       (prev_part && ((prev_part->offset + prev_part->size) != part->offset))) {
-
-                               memsize_format(tmpbuf, offset);
-                               len = strlen(tmpbuf) + 1;
-                               if (len > maxlen)
-                                       goto cleanup;
-                               *(p++) = '@';
-                               memcpy(p, tmpbuf, len - 1);
-                               p += len - 1;
-                               maxlen -= len;
-                       }
-
-                       /* copy name only if user supplied */
-                       if(!part->auto_name) {
-                               len = strlen(part->name) + 2;
-                               if (len > maxlen)
-                                       goto cleanup;
-
-                               *(p++) = '(';
-                               memcpy(p, part->name, len - 2);
-                               p += len - 2;
-                               *(p++) = ')';
-                               maxlen -= len;
-                       }
-
-                       /* ro mask flag */
-                       if (part->mask_flags && MTD_WRITEABLE_CMD) {
-                               len = 2;
-                               if (len > maxlen)
-                                       goto cleanup;
-                               *(p++) = 'r';
-                               *(p++) = 'o';
-                               maxlen -= 2;
-                       }
-
-                       /* print ',' separator if there are other partitions
-                        * following */
-                       if (dev->num_parts > part_cnt) {
-                               if (1 > maxlen)
-                                       goto cleanup;
-                               *(p++) = ',';
-                               maxlen--;
-                       }
-                       prev_part = part;
-               }
-               /* print ';' separator if there are other devices following */
-               if (dentry->next != &devices) {
-                       if (1 > maxlen)
-                               goto cleanup;
-                       *(p++) = ';';
-                       maxlen--;
-               }
-       }
-
-       /* we still have at least one char left, as we decremented maxlen at
-        * the begining */
-       *p = '\0';
-
-       return 0;
-
-cleanup:
-       last_parts[0] = '\0';
-       return 1;
-}
-
-/**
- * Call generate_mtdparts to process all devices and generate corresponding
- * mtdparts string, save it in mtdparts environment variable.
- *
- * @param buf output buffer holding generated mtdparts string (output)
- * @param buflen buffer size
- * @return 0 on success, 1 otherwise
- */
-static int generate_mtdparts_save(char *buf, u32 buflen)
-{
-       int ret;
-
-       ret = generate_mtdparts(buf, buflen);
-
-       if ((buf[0] != '\0') && (ret == 0))
-               setenv("mtdparts", buf);
-       else
-               setenv("mtdparts", NULL);
-
-       return ret;
-}
-
-/**
- * Format and print out a partition list for each device from global device
- * list.
- */
-static void list_partitions(void)
-{
-       struct list_head *dentry, *pentry;
-       struct part_info *part;
-       struct mtd_device *dev;
-       int part_num;
-
-       DEBUGF("\n---list_partitions---\n");
-       list_for_each(dentry, &devices) {
-               dev = list_entry(dentry, struct mtd_device, link);
-               printf("\ndevice %s%d <%s>, # parts = %d\n",
-                               MTD_DEV_TYPE(dev->id->type), dev->id->num,
-                               dev->id->mtd_id, dev->num_parts);
-               printf(" #: name\t\t\tsize\t\toffset\t\tmask_flags\n");
-
-               /* list partitions for given device */
-               part_num = 0;
-               list_for_each(pentry, &dev->parts) {
-                       part = list_entry(pentry, struct part_info, link);
-                       printf("%2d: %-20s0x%08x\t0x%08x\t%d\n",
-                                       part_num, part->name, part->size,
-                                       part->offset, part->mask_flags);
-
-                       part_num++;
-               }
-       }
-       if (list_empty(&devices))
-               printf("no partitions defined\n");
-
-       /* current_dev is not NULL only when we have non empty device list */
-       if (current_dev) {
-               part = jffs2_part_info(current_dev, current_partnum);
-               if (part) {
-                       printf("\nactive partition: %s%d,%d - (%s) 0x%08x @ 0x%08x\n",
-                                       MTD_DEV_TYPE(current_dev->id->type),
-                                       current_dev->id->num, current_partnum,
-                                       part->name, part->size, part->offset);
-               } else {
-                       printf("could not get current partition info\n\n");
-               }
-       }
-
-       printf("\ndefaults:\n");
-       printf("mtdids  : %s\n", mtdids_default);
-       printf("mtdparts: %s\n", mtdparts_default);
-}
-
-/**
- * Given partition identifier in form of <dev_type><dev_num>,<part_num> find
- * corresponding device and verify partition number.
- *
- * @param id string describing device and partition or partition name
- * @param dev pointer to the requested device (output)
- * @param part_num verified partition number (output)
- * @param part pointer to requested partition (output)
- * @return 0 on success, 1 otherwise
- */
-int find_dev_and_part(const char *id, struct mtd_device **dev,
-               u8 *part_num, struct part_info **part)
-{
-       struct list_head *dentry, *pentry;
-       u8 type, dnum, pnum;
-       const char *p;
-
-       DEBUGF("--- find_dev_and_part ---\nid = %s\n", id);
-
-       list_for_each(dentry, &devices) {
-               *part_num = 0;
-               *dev = list_entry(dentry, struct mtd_device, link);
-               list_for_each(pentry, &(*dev)->parts) {
-                       *part = list_entry(pentry, struct part_info, link);
-                       if (strcmp((*part)->name, id) == 0)
-                               return 0;
-                       (*part_num)++;
-               }
-       }
-
-       p = id;
-       *dev = NULL;
-       *part = NULL;
-       *part_num = 0;
-
-       if (id_parse(p, &p, &type, &dnum) != 0)
-               return 1;
-
-       if ((*p++ != ',') || (*p == '\0')) {
-               printf("no partition number specified\n");
-               return 1;
-       }
-       pnum = simple_strtoul(p, (char **)&p, 0);
-       if (*p != '\0') {
-               printf("unexpected trailing character '%c'\n", *p);
-               return 1;
-       }
-
-       if ((*dev = device_find(type, dnum)) == NULL) {
-               printf("no such device %s%d\n", MTD_DEV_TYPE(type), dnum);
-               return 1;
-       }
-
-       if ((*part = jffs2_part_info(*dev, pnum)) == NULL) {
-               printf("no such partition\n");
-               *dev = NULL;
-               return 1;
-       }
-
-       *part_num = pnum;
-
-       return 0;
-}
-
-/**
- * Find and delete partition. For partition id format see find_dev_and_part().
- *
- * @param id string describing device and partition
- * @return 0 on success, 1 otherwise
- */
-static int delete_partition(const char *id)
-{
-       u8 pnum;
-       struct mtd_device *dev;
-       struct part_info *part;
-
-       if (find_dev_and_part(id, &dev, &pnum, &part) == 0) {
-
-               DEBUGF("delete_partition: device = %s%d, partition %d = (%s) 0x%08lx@0x%08lx\n",
-                               MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum,
-                               part->name, part->size, part->offset);
-
-               if (part_del(dev, part) != 0)
-                       return 1;
-
-               if (generate_mtdparts_save(last_parts, MTDPARTS_MAXLEN) != 0) {
-                       printf("generated mtdparts too long, reseting to null\n");
-                       return 1;
-               }
-               return 0;
-       }
-
-       printf("partition %s not found\n", id);
-       return 1;
-}
-
-/**
- * Accept character string describing mtd partitions and call device_parse()
- * for each entry. Add created devices to the global devices list.
- *
- * @param mtdparts string specifing mtd partitions
- * @return 0 on success, 1 otherwise
- */
-static int parse_mtdparts(const char *const mtdparts)
-{
-       const char *p = mtdparts;
-       struct mtd_device *dev;
-       int err = 1;
-
-       DEBUGF("\n---parse_mtdparts---\nmtdparts = %s\n\n", p);
-
-       /* delete all devices and partitions */
-       if (jffs2_devices_init() != 0) {
-               printf("could not initialise device list\n");
-               return err;
-       }
-
-       /* re-read 'mtdparts' variable, jffs2_devices_init may be updating env */
-       p = getenv("mtdparts");
-
-       if (strncmp(p, "mtdparts=", 9) != 0) {
-               printf("mtdparts variable doesn't start with 'mtdparts='\n");
-               return err;
-       }
-       p += 9;
-
-       while (p && (*p != '\0')) {
-               err = 1;
-               if ((device_parse(p, &p, &dev) != 0) || (!dev))
-                       break;
-
-               DEBUGF("+ device: %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type),
-                               dev->id->num, dev->id->mtd_id);
-
-               /* check if parsed device is already on the list */
-               if (device_find(dev->id->type, dev->id->num) != NULL) {
-                       printf("device %s%d redefined, please correct mtdparts variable\n",
-                                       MTD_DEV_TYPE(dev->id->type), dev->id->num);
-                       break;
-               }
-
-               list_add_tail(&dev->link, &devices);
-               err = 0;
-       }
-       if (err == 1) {
-               device_delall(&devices);
-               return 1;
-       }
+/* current active device and partition number */
+static struct mtd_device *current_dev = NULL;
+static u8 current_partnum = 0;
 
-       return 0;
-}
+#if defined(CONFIG_CMD_CRAMFS)
+extern int cramfs_check (struct part_info *info);
+extern int cramfs_load (char *loadoffset, struct part_info *info, char *filename);
+extern int cramfs_ls (struct part_info *info, char *filename);
+extern int cramfs_info (struct part_info *info);
+#else
+/* defining empty macros for function names is ugly but avoids ifdef clutter
+ * all over the code */
+#define cramfs_check(x)                (0)
+#define cramfs_load(x,y,z)     (-1)
+#define cramfs_ls(x,y)         (0)
+#define cramfs_info(x)         (0)
+#endif
 
+#ifndef CONFIG_CMD_MTDPARTS
 /**
- * Parse provided string describing mtdids mapping (see file header for mtdids
- * variable format). Allocate memory for each entry and add all found entries
- * to the global mtdids list.
+ * Check device number to be within valid range for given device type.
  *
- * @param ids mapping string
- * @return 0 on success, 1 otherwise
+ * @param dev device to validate
+ * @return 0 if device is valid, 1 otherwise
  */
-static int parse_mtdids(const char *const ids)
+static int mtd_device_validate(u8 type, u8 num, u32 *size)
 {
-       const char *p = ids;
-       const char *mtd_id;
-       int mtd_id_len;
-       struct mtdids *id;
-       struct list_head *entry, *n;
-       struct mtdids *id_tmp;
-       u8 type, num;
-       u32 size;
-       int ret = 1;
-
-       DEBUGF("\n---parse_mtdids---\nmtdids = %s\n\n", ids);
-
-       /* clean global mtdids list */
-       list_for_each_safe(entry, n, &mtdids) {
-               id_tmp = list_entry(entry, struct mtdids, link);
-               DEBUGF("mtdids del: %d %d\n", id_tmp->type, id_tmp->num);
-               list_del(entry);
-               free(id_tmp);
-       }
-       last_ids[0] = '\0';
-       INIT_LIST_HEAD(&mtdids);
-
-       while(p && (*p != '\0')) {
-
-               ret = 1;
-               /* parse 'nor'|'nand'|'onenand'<dev-num> */
-               if (id_parse(p, &p, &type, &num) != 0)
-                       break;
-
-               if (*p != '=') {
-                       printf("mtdids: incorrect <dev-num>\n");
-                       break;
-               }
-               p++;
-
-               /* check if requested device exists */
-               if (device_validate(type, num, &size) != 0)
-                       return 1;
-
-               /* locate <mtd-id> */
-               mtd_id = p;
-               if ((p = strchr(mtd_id, ',')) != NULL) {
-                       mtd_id_len = p - mtd_id + 1;
-                       p++;
-               } else {
-                       mtd_id_len = strlen(mtd_id) + 1;
-               }
-               if (mtd_id_len == 0) {
-                       printf("mtdids: no <mtd-id> identifier\n");
-                       break;
-               }
+       if (type == MTD_DEV_TYPE_NOR) {
+#if defined(CONFIG_CMD_FLASH)
+               if (num < CONFIG_SYS_MAX_FLASH_BANKS) {
+                       extern flash_info_t flash_info[];
+                       *size = flash_info[num].size;
 
-               /* check if this id is already on the list */
-               int double_entry = 0;
-               list_for_each(entry, &mtdids) {
-                       id_tmp = list_entry(entry, struct mtdids, link);
-                       if ((id_tmp->type == type) && (id_tmp->num == num)) {
-                               double_entry = 1;
-                               break;
-                       }
-               }
-               if (double_entry) {
-                       printf("device id %s%d redefined, please correct mtdids variable\n",
-                                       MTD_DEV_TYPE(type), num);
-                       break;
+                       return 0;
                }
 
-               /* allocate mtdids structure */
-               if (!(id = (struct mtdids *)malloc(sizeof(struct mtdids) + mtd_id_len))) {
-                       printf("out of memory\n");
-                       break;
+               printf("no such FLASH device: %s%d (valid range 0 ... %d\n",
+                               MTD_DEV_TYPE(type), num, CONFIG_SYS_MAX_FLASH_BANKS - 1);
+#else
+               printf("support for FLASH devices not present\n");
+#endif
+       } else if (type == MTD_DEV_TYPE_NAND) {
+#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
+               if (num < CONFIG_SYS_MAX_NAND_DEVICE) {
+#ifndef CONFIG_NAND_LEGACY
+                       *size = nand_info[num].size;
+#else
+                       extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
+                       *size = nand_dev_desc[num].totlen;
+#endif
+                       return 0;
                }
-               memset(id, 0, sizeof(struct mtdids) + mtd_id_len);
-               id->num = num;
-               id->type = type;
-               id->size = size;
-               id->mtd_id = (char *)(id + 1);
-               strncpy(id->mtd_id, mtd_id, mtd_id_len - 1);
-               id->mtd_id[mtd_id_len - 1] = '\0';
-               INIT_LIST_HEAD(&id->link);
-
-               DEBUGF("+ id %s%d\t%16d bytes\t%s\n",
-                               MTD_DEV_TYPE(id->type), id->num,
-                               id->size, id->mtd_id);
 
-               list_add_tail(&id->link, &mtdids);
-               ret = 0;
-       }
-       if (ret == 1) {
-               /* clean mtdids list and free allocated memory */
-               list_for_each_safe(entry, n, &mtdids) {
-                       id_tmp = list_entry(entry, struct mtdids, link);
-                       list_del(entry);
-                       free(id_tmp);
-               }
-               return 1;
-       }
+               printf("no such NAND device: %s%d (valid range 0 ... %d)\n",
+                               MTD_DEV_TYPE(type), num, CONFIG_SYS_MAX_NAND_DEVICE - 1);
+#else
+               printf("support for NAND devices not present\n");
+#endif
+       } else if (type == MTD_DEV_TYPE_ONENAND) {
+#if defined(CONFIG_CMD_ONENAND)
+               *size = onenand_mtd.size;
+               return 0;
+#else
+               printf("support for OneNAND devices not present\n");
+#endif
+       } else
+               printf("Unknown defice type %d\n", type);
 
-       return 0;
+       return 1;
 }
 
 /**
- * Parse and initialize global mtdids mapping and create global
- * device/partition list.
+ * Parse device id string <dev-id> := 'nand'|'nor'|'onenand'<dev-num>,
+ * return device type and number.
  *
+ * @param id string describing device id
+ * @param ret_id output pointer to next char after parse completes (output)
+ * @param dev_type parsed device type (output)
+ * @param dev_num parsed device number (output)
  * @return 0 on success, 1 otherwise
  */
-int mtdparts_init(void)
+static int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num)
 {
-       static int initialized = 0;
-       const char *ids, *parts;
-       const char *current_partition;
-       int ids_changed;
-       char tmp_ep[PARTITION_MAXLEN];
-
-       DEBUGF("\n---mtdparts_init---\n");
-       if (!initialized) {
-               INIT_LIST_HEAD(&mtdids);
-               INIT_LIST_HEAD(&devices);
-               memset(last_ids, 0, MTDIDS_MAXLEN);
-               memset(last_parts, 0, MTDPARTS_MAXLEN);
-               memset(last_partition, 0, PARTITION_MAXLEN);
-               initialized = 1;
-       }
+       const char *p = id;
 
-       /* get variables */
-       ids = getenv("mtdids");
-       parts = getenv("mtdparts");
-       current_partition = getenv("partition");
-
-       /* save it for later parsing, cannot rely on current partition pointer
-        * as 'partition' variable may be updated during init */
-       tmp_ep[0] = '\0';
-       if (current_partition)
-               strncpy(tmp_ep, current_partition, PARTITION_MAXLEN);
-
-       DEBUGF("last_ids  : %s\n", last_ids);
-       DEBUGF("env_ids   : %s\n", ids);
-       DEBUGF("last_parts: %s\n", last_parts);
-       DEBUGF("env_parts : %s\n\n", parts);
-
-       DEBUGF("last_partition : %s\n", last_partition);
-       DEBUGF("env_partition  : %s\n", current_partition);
-
-       /* if mtdids varible is empty try to use defaults */
-       if (!ids) {
-               if (mtdids_default) {
-                       DEBUGF("mtdids variable not defined, using default\n");
-                       ids = mtdids_default;
-                       setenv("mtdids", (char *)ids);
-               } else {
-                       printf("mtdids not defined, no default present\n");
-                       return 1;
-               }
-       }
-       if (strlen(ids) > MTDIDS_MAXLEN - 1) {
-               printf("mtdids too long (> %d)\n", MTDIDS_MAXLEN);
+       *dev_type = 0;
+       if (strncmp(p, "nand", 4) == 0) {
+               *dev_type = MTD_DEV_TYPE_NAND;
+               p += 4;
+       } else if (strncmp(p, "nor", 3) == 0) {
+               *dev_type = MTD_DEV_TYPE_NOR;
+               p += 3;
+       } else if (strncmp(p, "onenand", 7) == 0) {
+               *dev_type = MTD_DEV_TYPE_ONENAND;
+               p += 7;
+       } else {
+               printf("incorrect device type in %s\n", id);
                return 1;
        }
 
-       /* do no try to use defaults when mtdparts variable is not defined,
-        * just check the length */
-       if (!parts)
-               printf("mtdparts variable not set, see 'help mtdparts'\n");
-
-       if (parts && (strlen(parts) > MTDPARTS_MAXLEN - 1)) {
-               printf("mtdparts too long (> %d)\n", MTDPARTS_MAXLEN);
+       if (!isdigit(*p)) {
+               printf("incorrect device number in %s\n", id);
                return 1;
        }
 
-       /* check if we have already parsed those mtdids */
-       if ((last_ids[0] != '\0') && (strcmp(last_ids, ids) == 0)) {
-               ids_changed = 0;
-       } else {
-               ids_changed = 1;
-
-               if (parse_mtdids(ids) != 0) {
-                       jffs2_devices_init();
-                       return 1;
-               }
-
-               /* ok it's good, save new ids */
-               strncpy(last_ids, ids, MTDIDS_MAXLEN);
-       }
-
-       /* parse partitions if either mtdparts or mtdids were updated */
-       if (parts && ((last_parts[0] == '\0') || ((strcmp(last_parts, parts) != 0)) || ids_changed)) {
-               if (parse_mtdparts(parts) != 0)
-                       return 1;
-
-               if (list_empty(&devices)) {
-                       printf("mtdparts_init: no valid partitions\n");
-                       return 1;
-               }
-
-               /* ok it's good, save new parts */
-               strncpy(last_parts, parts, MTDPARTS_MAXLEN);
-
-               /* reset first partition from first dev from the list as current */
-               current_dev = list_entry(devices.next, struct mtd_device, link);
-               current_partnum = 0;
-               current_save();
-
-               DEBUGF("mtdparts_init: current_dev  = %s%d, current_partnum = %d\n",
-                               MTD_DEV_TYPE(current_dev->id->type),
-                               current_dev->id->num, current_partnum);
-       }
-
-       /* mtdparts variable was reset to NULL, delete all devices/partitions */
-       if (!parts && (last_parts[0] != '\0'))
-               return jffs2_devices_init();
-
-       /* do not process current partition if mtdparts variable is null */
-       if (!parts)
-               return 0;
-
-       /* is current partition set in environment? if so, use it */
-       if ((tmp_ep[0] != '\0') && (strcmp(tmp_ep, last_partition) != 0)) {
-               struct part_info *p;
-               struct mtd_device *cdev;
-               u8 pnum;
-
-               DEBUGF("--- getting current partition: %s\n", tmp_ep);
-
-               if (find_dev_and_part(tmp_ep, &cdev, &pnum, &p) == 0) {
-                       current_dev = cdev;
-                       current_partnum = pnum;
-                       current_save();
-               }
-       } else if (getenv("partition") == NULL) {
-               DEBUGF("no partition variable set, setting...\n");
-               current_save();
-       }
-
+       *dev_num = simple_strtoul(p, (char **)&p, 0);
+       if (ret_id)
+               *ret_id = p;
        return 0;
 }
-#else /* #ifdef CONFIG_JFFS2_CMDLINE */
+
 /*
  * 'Static' version of command line mtdparts_init() routine. Single partition on
  * a single device configuration.
@@ -1908,8 +383,8 @@ int mtdparts_init(void)
                dev_name = "nor0";
 #endif
 
-               if ((id_parse(dev_name, NULL, &id->type, &id->num) != 0) ||
-                               (device_validate(id->type, id->num, &size) != 0)) {
+               if ((mtd_id_parse(dev_name, NULL, &id->type, &id->num) != 0) ||
+                               (mtd_device_validate(id->type, id->num, &size) != 0)) {
                        printf("incorrect device: %s%d\n", MTD_DEV_TYPE(id->type), id->num);
                        free(current_dev);
                        return 1;
@@ -1958,7 +433,7 @@ int mtdparts_init(void)
 
        return 0;
 }
-#endif /* #ifdef CONFIG_JFFS2_CMDLINE */
+#endif /* #ifndef CONFIG_CMD_MTDPARTS */
 
 /**
  * Return pointer to the partition of a requested number from a requested
@@ -2145,155 +620,6 @@ int do_jffs2_fsinfo(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
        return 1;
 }
 
-/* command line only */
-#ifdef CONFIG_JFFS2_CMDLINE
-/**
- * Routine implementing u-boot chpart command. Sets new current partition based
- * on the user supplied partition id. For partition id format see find_dev_and_part().
- *
- * @param cmdtp command internal data
- * @param flag command flag
- * @param argc number of arguments supplied to the command
- * @param argv arguments list
- * @return 0 on success, 1 otherwise
- */
-int do_jffs2_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
-/* command line only */
-       struct mtd_device *dev;
-       struct part_info *part;
-       u8 pnum;
-
-       if (mtdparts_init() !=0)
-               return 1;
-
-       if (argc < 2) {
-               printf("no partition id specified\n");
-               return 1;
-       }
-
-       if (find_dev_and_part(argv[1], &dev, &pnum, &part) != 0)
-               return 1;
-
-       current_dev = dev;
-       current_partnum = pnum;
-       current_save();
-
-       printf("partition changed to %s%d,%d\n",
-                       MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum);
-
-       return 0;
-}
-
-/**
- * Routine implementing u-boot mtdparts command. Initialize/update default global
- * partition list and process user partition request (list, add, del).
- *
- * @param cmdtp command internal data
- * @param flag command flag
- * @param argc number of arguments supplied to the command
- * @param argv arguments list
- * @return 0 on success, 1 otherwise
- */
-int do_jffs2_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
-{
-       if (argc == 2) {
-               if (strcmp(argv[1], "default") == 0) {
-                       setenv("mtdids", (char *)mtdids_default);
-                       setenv("mtdparts", (char *)mtdparts_default);
-                       setenv("partition", NULL);
-
-                       mtdparts_init();
-                       return 0;
-               } else if (strcmp(argv[1], "delall") == 0) {
-                       /* this may be the first run, initialize lists if needed */
-                       mtdparts_init();
-
-                       setenv("mtdparts", NULL);
-
-                       /* jffs2_devices_init() calls current_save() */
-                       return jffs2_devices_init();
-               }
-       }
-
-       /* make sure we are in sync with env variables */
-       if (mtdparts_init() != 0)
-               return 1;
-
-       if (argc == 1) {
-               list_partitions();
-               return 0;
-       }
-
-       /* mtdparts add <mtd-dev> <size>[@<offset>] <name> [ro] */
-       if (((argc == 5) || (argc == 6)) && (strcmp(argv[1], "add") == 0)) {
-#define PART_ADD_DESC_MAXLEN 64
-               char tmpbuf[PART_ADD_DESC_MAXLEN];
-               u8 type, num, len;
-               struct mtd_device *dev;
-               struct mtd_device *dev_tmp;
-               struct mtdids *id;
-               struct part_info *p;
-
-               if (id_parse(argv[2], NULL, &type, &num) != 0)
-                       return 1;
-
-               if ((id = id_find(type, num)) == NULL) {
-                       printf("no such device %s defined in mtdids variable\n", argv[2]);
-                       return 1;
-               }
-
-               len = strlen(id->mtd_id) + 1;   /* 'mtd_id:' */
-               len += strlen(argv[3]);         /* size@offset */
-               len += strlen(argv[4]) + 2;     /* '(' name ')' */
-               if (argv[5] && (strlen(argv[5]) == 2))
-                       len += 2;               /* 'ro' */
-
-               if (len >= PART_ADD_DESC_MAXLEN) {
-                       printf("too long partition description\n");
-                       return 1;
-               }
-               sprintf(tmpbuf, "%s:%s(%s)%s",
-                               id->mtd_id, argv[3], argv[4], argv[5] ? argv[5] : "");
-               DEBUGF("add tmpbuf: %s\n", tmpbuf);
-
-               if ((device_parse(tmpbuf, NULL, &dev) != 0) || (!dev))
-                       return 1;
-
-               DEBUGF("+ %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type),
-                               dev->id->num, dev->id->mtd_id);
-
-               if ((dev_tmp = device_find(dev->id->type, dev->id->num)) == NULL) {
-                       device_add(dev);
-               } else {
-                       /* merge new partition with existing ones*/
-                       p = list_entry(dev->parts.next, struct part_info, link);
-                       if (part_add(dev_tmp, p) != 0) {
-                               device_del(dev);
-                               return 1;
-                       }
-               }
-
-               if (generate_mtdparts_save(last_parts, MTDPARTS_MAXLEN) != 0) {
-                       printf("generated mtdparts too long, reseting to null\n");
-                       return 1;
-               }
-
-               return 0;
-       }
-
-       /* mtdparts del part-id */
-       if ((argc == 3) && (strcmp(argv[1], "del") == 0)) {
-               DEBUGF("del: part-id = %s\n", argv[2]);
-
-               return delete_partition(argv[2]);
-       }
-
-       cmd_usage(cmdtp);
-       return 1;
-}
-#endif /* #ifdef CONFIG_JFFS2_CMDLINE */
-
 /***************************************************/
 U_BOOT_CMD(
        fsload, 3,      0,      do_jffs2_fsload,
@@ -2314,49 +640,4 @@ U_BOOT_CMD(
        "print information about filesystems",
        "    - print information about filesystems\n"
 );
-
-#ifdef CONFIG_JFFS2_CMDLINE
-U_BOOT_CMD(
-       chpart, 2,      0,      do_jffs2_chpart,
-       "change active partition",
-       "part-id\n"
-       "    - change active partition (e.g. part-id = nand0,1)\n"
-);
-
-U_BOOT_CMD(
-       mtdparts,       6,      0,      do_jffs2_mtdparts,
-       "define flash/nand partitions",
-       "\n"
-       "    - list partition table\n"
-       "mtdparts delall\n"
-       "    - delete all partitions\n"
-       "mtdparts del part-id\n"
-       "    - delete partition (e.g. part-id = nand0,1)\n"
-       "mtdparts add <mtd-dev> <size>[@<offset>] [<name>] [ro]\n"
-       "    - add partition\n"
-       "mtdparts default\n"
-       "    - reset partition table to defaults\n\n"
-       "-----\n\n"
-       "this command uses three environment variables:\n\n"
-       "'partition' - keeps current partition identifier\n\n"
-       "partition  := <part-id>\n"
-       "<part-id>  := <dev-id>,part_num\n\n"
-       "'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n"
-       "mtdids=<idmap>[,<idmap>,...]\n\n"
-       "<idmap>    := <dev-id>=<mtd-id>\n"
-       "<dev-id>   := 'nand'|'nor'|'onenand'<dev-num>\n"
-       "<dev-num>  := mtd device number, 0...\n"
-       "<mtd-id>   := unique device tag used by linux kernel to find mtd device (mtd->name)\n\n"
-       "'mtdparts' - partition list\n\n"
-       "mtdparts=mtdparts=<mtd-def>[;<mtd-def>...]\n\n"
-       "<mtd-def>  := <mtd-id>:<part-def>[,<part-def>...]\n"
-       "<mtd-id>   := unique device tag used by linux kernel to find mtd device (mtd->name)\n"
-       "<part-def> := <size>[@<offset>][<name>][<ro-flag>]\n"
-       "<size>     := standard linux memsize OR '-' to denote all remaining space\n"
-       "<offset>   := partition start offset within the device\n"
-       "<name>     := '(' NAME ')'\n"
-       "<ro-flag>  := when set to 'ro' makes partition read-only (not used, passed to kernel)\n"
-);
-#endif /* #ifdef CONFIG_JFFS2_CMDLINE */
-
 /***************************************************/
diff --git a/common/cmd_mtdparts.c b/common/cmd_mtdparts.c
new file mode 100644 (file)
index 0000000..c8bf2c6
--- /dev/null
@@ -0,0 +1,1986 @@
+/*
+ * (C) Copyright 2002
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * (C) Copyright 2002
+ * Robert Schwebel, Pengutronix, <r.schwebel@pengutronix.de>
+ *
+ * (C) Copyright 2003
+ * Kai-Uwe Bloem, Auerswald GmbH & Co KG, <linux-development@auerswald.de>
+ *
+ * (C) Copyright 2005
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ *   Added support for reading flash partition table from environment.
+ *   Parsing routines are based on driver/mtd/cmdline.c from the linux 2.4
+ *   kernel tree.
+ *
+ *   $Id: cmdlinepart.c,v 1.17 2004/11/26 11:18:47 lavinen Exp $
+ *   Copyright 2002 SYSGO Real-Time Solutions GmbH
+ *
+ * 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
+ */
+
+/*
+ * Three environment variables are used by the parsing routines:
+ *
+ * 'partition' - keeps current partition identifier
+ *
+ * partition  := <part-id>
+ * <part-id>  := <dev-id>,part_num
+ *
+ *
+ * 'mtdids' - linux kernel mtd device id <-> u-boot device id mapping
+ *
+ * mtdids=<idmap>[,<idmap>,...]
+ *
+ * <idmap>    := <dev-id>=<mtd-id>
+ * <dev-id>   := 'nand'|'nor'|'onenand'<dev-num>
+ * <dev-num>  := mtd device number, 0...
+ * <mtd-id>   := unique device tag used by linux kernel to find mtd device (mtd->name)
+ *
+ *
+ * 'mtdparts' - partition list
+ *
+ * mtdparts=mtdparts=<mtd-def>[;<mtd-def>...]
+ *
+ * <mtd-def>  := <mtd-id>:<part-def>[,<part-def>...]
+ * <mtd-id>   := unique device tag used by linux kernel to find mtd device (mtd->name)
+ * <part-def> := <size>[@<offset>][<name>][<ro-flag>]
+ * <size>     := standard linux memsize OR '-' to denote all remaining space
+ * <offset>   := partition start offset within the device
+ * <name>     := '(' NAME ')'
+ * <ro-flag>  := when set to 'ro' makes partition read-only (not used, passed to kernel)
+ *
+ * Notes:
+ * - each <mtd-id> used in mtdparts must albo exist in 'mtddis' mapping
+ * - if the above variables are not set defaults for a given target are used
+ *
+ * Examples:
+ *
+ * 1 NOR Flash, with 1 single writable partition:
+ * mtdids=nor0=edb7312-nor
+ * mtdparts=mtdparts=edb7312-nor:-
+ *
+ * 1 NOR Flash with 2 partitions, 1 NAND with one
+ * mtdids=nor0=edb7312-nor,nand0=edb7312-nand
+ * mtdparts=mtdparts=edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
+ *
+ */
+
+/*
+ * JFFS2/CRAMFS support
+ */
+#include <common.h>
+#include <command.h>
+#include <malloc.h>
+#include <jffs2/jffs2.h>
+#include <linux/list.h>
+#include <linux/ctype.h>
+#include <cramfs/cramfs_fs.h>
+
+#if defined(CONFIG_CMD_NAND)
+#ifdef CONFIG_NAND_LEGACY
+#include <linux/mtd/nand_legacy.h>
+#else /* !CONFIG_NAND_LEGACY */
+#include <linux/mtd/nand.h>
+#include <nand.h>
+#endif /* !CONFIG_NAND_LEGACY */
+#endif
+
+#if defined(CONFIG_CMD_ONENAND)
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/onenand.h>
+#include <onenand_uboot.h>
+#endif
+
+/* enable/disable debugging messages */
+#define        DEBUG_MTDPARTS
+#undef DEBUG_MTDPARTS
+
+#ifdef  DEBUG_MTDPARTS
+# define DEBUGF(fmt, args...)  printf(fmt ,##args)
+#else
+# define DEBUGF(fmt, args...)
+#endif
+
+/* special size referring to all the remaining space in a partition */
+#define SIZE_REMAINING         0xFFFFFFFF
+
+/* special offset value, it is used when not provided by user
+ *
+ * this value is used temporarily during parsing, later such offests
+ * are recalculated */
+#define OFFSET_NOT_SPECIFIED   0xFFFFFFFF
+
+/* minimum partition size */
+#define MIN_PART_SIZE          4096
+
+/* this flag needs to be set in part_info struct mask_flags
+ * field for read-only partitions */
+#define MTD_WRITEABLE_CMD              1
+
+/* default values for mtdids and mtdparts variables */
+#if defined(MTDIDS_DEFAULT)
+static const char *const mtdids_default = MTDIDS_DEFAULT;
+#else
+#warning "MTDIDS_DEFAULT not defined!"
+static const char *const mtdids_default = NULL;
+#endif
+
+#if defined(MTDPARTS_DEFAULT)
+static const char *const mtdparts_default = MTDPARTS_DEFAULT;
+#else
+#warning "MTDPARTS_DEFAULT not defined!"
+static const char *const mtdparts_default = NULL;
+#endif
+
+/* copies of last seen 'mtdids', 'mtdparts' and 'partition' env variables */
+#define MTDIDS_MAXLEN          128
+#define MTDPARTS_MAXLEN                512
+#define PARTITION_MAXLEN       16
+static char last_ids[MTDIDS_MAXLEN];
+static char last_parts[MTDPARTS_MAXLEN];
+static char last_partition[PARTITION_MAXLEN];
+
+/* low level jffs2 cache cleaning routine */
+extern void jffs2_free_cache(struct part_info *part);
+
+/* mtdids mapping list, filled by parse_ids() */
+struct list_head mtdids;
+
+/* device/partition list, parse_cmdline() parses into here */
+struct list_head devices;
+
+/* current active device and partition number */
+static struct mtd_device *current_dev = NULL;
+static u8 current_partnum = 0;
+
+static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part_num);
+
+/* command line only routines */
+static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_len);
+static int device_del(struct mtd_device *dev);
+
+/**
+ * Parses a string into a number.  The number stored at ptr is
+ * potentially suffixed with K (for kilobytes, or 1024 bytes),
+ * M (for megabytes, or 1048576 bytes), or G (for gigabytes, or
+ * 1073741824).  If the number is suffixed with K, M, or G, then
+ * the return value is the number multiplied by one kilobyte, one
+ * megabyte, or one gigabyte, respectively.
+ *
+ * @param ptr where parse begins
+ * @param retptr output pointer to next char after parse completes (output)
+ * @return resulting unsigned int
+ */
+static unsigned long memsize_parse (const char *const ptr, const char **retptr)
+{
+       unsigned long ret = simple_strtoul(ptr, (char **)retptr, 0);
+
+       switch (**retptr) {
+               case 'G':
+               case 'g':
+                       ret <<= 10;
+               case 'M':
+               case 'm':
+                       ret <<= 10;
+               case 'K':
+               case 'k':
+                       ret <<= 10;
+                       (*retptr)++;
+               default:
+                       break;
+       }
+
+       return ret;
+}
+
+/**
+ * Format string describing supplied size. This routine does the opposite job
+ * to memsize_parse(). Size in bytes is converted to string and if possible
+ * shortened by using k (kilobytes), m (megabytes) or g (gigabytes) suffix.
+ *
+ * Note, that this routine does not check for buffer overflow, it's the caller
+ * who must assure enough space.
+ *
+ * @param buf output buffer
+ * @param size size to be converted to string
+ */
+static void memsize_format(char *buf, u32 size)
+{
+#define SIZE_GB ((u32)1024*1024*1024)
+#define SIZE_MB ((u32)1024*1024)
+#define SIZE_KB ((u32)1024)
+
+       if ((size % SIZE_GB) == 0)
+               sprintf(buf, "%ug", size/SIZE_GB);
+       else if ((size % SIZE_MB) == 0)
+               sprintf(buf, "%um", size/SIZE_MB);
+       else if (size % SIZE_KB == 0)
+               sprintf(buf, "%uk", size/SIZE_KB);
+       else
+               sprintf(buf, "%u", size);
+}
+
+/**
+ * This routine does global indexing of all partitions. Resulting index for
+ * current partition is saved in 'mtddevnum'. Current partition name in
+ * 'mtddevname'.
+ */
+static void index_partitions(void)
+{
+       char buf[16];
+       u16 mtddevnum;
+       struct part_info *part;
+       struct list_head *dentry;
+       struct mtd_device *dev;
+
+       DEBUGF("--- index partitions ---\n");
+
+       if (current_dev) {
+               mtddevnum = 0;
+               list_for_each(dentry, &devices) {
+                       dev = list_entry(dentry, struct mtd_device, link);
+                       if (dev == current_dev) {
+                               mtddevnum += current_partnum;
+                               sprintf(buf, "%d", mtddevnum);
+                               setenv("mtddevnum", buf);
+                               break;
+                       }
+                       mtddevnum += dev->num_parts;
+               }
+
+               part = mtd_part_info(current_dev, current_partnum);
+               setenv("mtddevname", part->name);
+
+               DEBUGF("=> mtddevnum %d,\n=> mtddevname %s\n", mtddevnum, part->name);
+       } else {
+               setenv("mtddevnum", NULL);
+               setenv("mtddevname", NULL);
+
+               DEBUGF("=> mtddevnum NULL\n=> mtddevname NULL\n");
+       }
+}
+
+/**
+ * Save current device and partition in environment variable 'partition'.
+ */
+static void current_save(void)
+{
+       char buf[16];
+
+       DEBUGF("--- current_save ---\n");
+
+       if (current_dev) {
+               sprintf(buf, "%s%d,%d", MTD_DEV_TYPE(current_dev->id->type),
+                                       current_dev->id->num, current_partnum);
+
+               setenv("partition", buf);
+               strncpy(last_partition, buf, 16);
+
+               DEBUGF("=> partition %s\n", buf);
+       } else {
+               setenv("partition", NULL);
+               last_partition[0] = '\0';
+
+               DEBUGF("=> partition NULL\n");
+       }
+       index_partitions();
+}
+
+/**
+ * Performs sanity check for supplied NOR flash partition. Table of existing
+ * NOR flash devices is searched and partition device is located. Alignment
+ * with the granularity of NOR flash sectors is verified.
+ *
+ * @param id of the parent device
+ * @param part partition to validate
+ * @return 0 if partition is valid, 1 otherwise
+ */
+static int part_validate_nor(struct mtdids *id, struct part_info *part)
+{
+#if defined(CONFIG_CMD_FLASH)
+       /* info for FLASH chips */
+       extern flash_info_t flash_info[];
+       flash_info_t *flash;
+       int offset_aligned;
+       u32 end_offset, sector_size = 0;
+       int i;
+
+       flash = &flash_info[id->num];
+
+       /* size of last sector */
+       part->sector_size = flash->size -
+               (flash->start[flash->sector_count-1] - flash->start[0]);
+
+       offset_aligned = 0;
+       for (i = 0; i < flash->sector_count; i++) {
+               if ((flash->start[i] - flash->start[0]) == part->offset) {
+                       offset_aligned = 1;
+                       break;
+               }
+       }
+       if (offset_aligned == 0) {
+               printf("%s%d: partition (%s) start offset alignment incorrect\n",
+                               MTD_DEV_TYPE(id->type), id->num, part->name);
+               return 1;
+       }
+
+       end_offset = part->offset + part->size;
+       offset_aligned = 0;
+       for (i = 0; i < flash->sector_count; i++) {
+               if (i) {
+                       sector_size = flash->start[i] - flash->start[i-1];
+                       if (part->sector_size < sector_size)
+                               part->sector_size = sector_size;
+               }
+               if ((flash->start[i] - flash->start[0]) == end_offset)
+                       offset_aligned = 1;
+       }
+
+       if (offset_aligned || flash->size == end_offset)
+               return 0;
+
+       printf("%s%d: partition (%s) size alignment incorrect\n",
+                       MTD_DEV_TYPE(id->type), id->num, part->name);
+#endif
+       return 1;
+}
+
+/**
+ * Performs sanity check for supplied NAND flash partition. Table of existing
+ * NAND flash devices is searched and partition device is located. Alignment
+ * with the granularity of nand erasesize is verified.
+ *
+ * @param id of the parent device
+ * @param part partition to validate
+ * @return 0 if partition is valid, 1 otherwise
+ */
+static int part_validate_nand(struct mtdids *id, struct part_info *part)
+{
+#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
+       /* info for NAND chips */
+       nand_info_t *nand;
+
+       nand = &nand_info[id->num];
+
+       part->sector_size = nand->erasesize;
+
+       if ((unsigned long)(part->offset) % nand->erasesize) {
+               printf("%s%d: partition (%s) start offset alignment incorrect\n",
+                               MTD_DEV_TYPE(id->type), id->num, part->name);
+               return 1;
+       }
+
+       if (part->size % nand->erasesize) {
+               printf("%s%d: partition (%s) size alignment incorrect\n",
+                               MTD_DEV_TYPE(id->type), id->num, part->name);
+               return 1;
+       }
+
+       return 0;
+#else
+       return 1;
+#endif
+}
+
+/**
+ * Performs sanity check for supplied OneNAND flash partition.
+ * Table of existing OneNAND flash devices is searched and partition device
+ * is located. Alignment with the granularity of nand erasesize is verified.
+ *
+ * @param id of the parent device
+ * @param part partition to validate
+ * @return 0 if partition is valid, 1 otherwise
+ */
+static int part_validate_onenand(struct mtdids *id, struct part_info *part)
+{
+#if defined(CONFIG_CMD_ONENAND)
+       /* info for OneNAND chips */
+       struct mtd_info *mtd;
+
+       mtd = &onenand_mtd;
+
+       part->sector_size = mtd->erasesize;
+
+       if ((unsigned long)(part->offset) % mtd->erasesize) {
+               printf("%s%d: partition (%s) start offset"
+                       "alignment incorrect\n",
+                               MTD_DEV_TYPE(id->type), id->num, part->name);
+               return 1;
+       }
+
+       if (part->size % mtd->erasesize) {
+               printf("%s%d: partition (%s) size alignment incorrect\n",
+                               MTD_DEV_TYPE(id->type), id->num, part->name);
+               return 1;
+       }
+
+       return 0;
+#else
+       return 1;
+#endif
+}
+
+
+/**
+ * Performs sanity check for supplied partition. Offset and size are verified
+ * to be within valid range. Partition type is checked and either
+ * parts_validate_nor() or parts_validate_nand() is called with the argument
+ * of part.
+ *
+ * @param id of the parent device
+ * @param part partition to validate
+ * @return 0 if partition is valid, 1 otherwise
+ */
+static int part_validate(struct mtdids *id, struct part_info *part)
+{
+       if (part->size == SIZE_REMAINING)
+               part->size = id->size - part->offset;
+
+       if (part->offset > id->size) {
+               printf("%s: offset %08x beyond flash size %08x\n",
+                               id->mtd_id, part->offset, id->size);
+               return 1;
+       }
+
+       if ((part->offset + part->size) <= part->offset) {
+               printf("%s%d: partition (%s) size too big\n",
+                               MTD_DEV_TYPE(id->type), id->num, part->name);
+               return 1;
+       }
+
+       if (part->offset + part->size > id->size) {
+               printf("%s: partitioning exceeds flash size\n", id->mtd_id);
+               return 1;
+       }
+
+       if (id->type == MTD_DEV_TYPE_NAND)
+               return part_validate_nand(id, part);
+       else if (id->type == MTD_DEV_TYPE_NOR)
+               return part_validate_nor(id, part);
+       else if (id->type == MTD_DEV_TYPE_ONENAND)
+               return part_validate_onenand(id, part);
+       else
+               DEBUGF("part_validate: invalid dev type\n");
+
+       return 1;
+}
+
+/**
+ * Delete selected partition from the partion list of the specified device.
+ *
+ * @param dev device to delete partition from
+ * @param part partition to delete
+ * @return 0 on success, 1 otherwise
+ */
+static int part_del(struct mtd_device *dev, struct part_info *part)
+{
+       u8 current_save_needed = 0;
+
+       /* if there is only one partition, remove whole device */
+       if (dev->num_parts == 1)
+               return device_del(dev);
+
+       /* otherwise just delete this partition */
+
+       if (dev == current_dev) {
+               /* we are modyfing partitions for the current device,
+                * update current */
+               struct part_info *curr_pi;
+               curr_pi = mtd_part_info(current_dev, current_partnum);
+
+               if (curr_pi) {
+                       if (curr_pi == part) {
+                               printf("current partition deleted, resetting current to 0\n");
+                               current_partnum = 0;
+                       } else if (part->offset <= curr_pi->offset) {
+                               current_partnum--;
+                       }
+                       current_save_needed = 1;
+               }
+       }
+
+#ifdef CONFIG_NAND_LEGACY
+       jffs2_free_cache(part);
+#endif
+       list_del(&part->link);
+       free(part);
+       dev->num_parts--;
+
+       if (current_save_needed > 0)
+               current_save();
+       else
+               index_partitions();
+
+       return 0;
+}
+
+/**
+ * Delete all partitions from parts head list, free memory.
+ *
+ * @param head list of partitions to delete
+ */
+static void part_delall(struct list_head *head)
+{
+       struct list_head *entry, *n;
+       struct part_info *part_tmp;
+
+       /* clean tmp_list and free allocated memory */
+       list_for_each_safe(entry, n, head) {
+               part_tmp = list_entry(entry, struct part_info, link);
+
+#ifdef CONFIG_NAND_LEGACY
+               jffs2_free_cache(part_tmp);
+#endif
+               list_del(entry);
+               free(part_tmp);
+       }
+}
+
+/**
+ * Add new partition to the supplied partition list. Make sure partitions are
+ * sorted by offset in ascending order.
+ *
+ * @param head list this partition is to be added to
+ * @param new partition to be added
+ */
+static int part_sort_add(struct mtd_device *dev, struct part_info *part)
+{
+       struct list_head *entry;
+       struct part_info *new_pi, *curr_pi;
+
+       /* link partition to parrent dev */
+       part->dev = dev;
+
+       if (list_empty(&dev->parts)) {
+               DEBUGF("part_sort_add: list empty\n");
+               list_add(&part->link, &dev->parts);
+               dev->num_parts++;
+               index_partitions();
+               return 0;
+       }
+
+       new_pi = list_entry(&part->link, struct part_info, link);
+
+       /* get current partition info if we are updating current device */
+       curr_pi = NULL;
+       if (dev == current_dev)
+               curr_pi = mtd_part_info(current_dev, current_partnum);
+
+       list_for_each(entry, &dev->parts) {
+               struct part_info *pi;
+
+               pi = list_entry(entry, struct part_info, link);
+
+               /* be compliant with kernel cmdline, allow only one partition at offset zero */
+               if ((new_pi->offset == pi->offset) && (pi->offset == 0)) {
+                       printf("cannot add second partition at offset 0\n");
+                       return 1;
+               }
+
+               if (new_pi->offset <= pi->offset) {
+                       list_add_tail(&part->link, entry);
+                       dev->num_parts++;
+
+                       if (curr_pi && (pi->offset <= curr_pi->offset)) {
+                               /* we are modyfing partitions for the current
+                                * device, update current */
+                               current_partnum++;
+                               current_save();
+                       } else {
+                               index_partitions();
+                       }
+                       return 0;
+               }
+       }
+
+       list_add_tail(&part->link, &dev->parts);
+       dev->num_parts++;
+       index_partitions();
+       return 0;
+}
+
+/**
+ * Add provided partition to the partition list of a given device.
+ *
+ * @param dev device to which partition is added
+ * @param part partition to be added
+ * @return 0 on success, 1 otherwise
+ */
+static int part_add(struct mtd_device *dev, struct part_info *part)
+{
+       /* verify alignment and size */
+       if (part_validate(dev->id, part) != 0)
+               return 1;
+
+       /* partition is ok, add it to the list */
+       if (part_sort_add(dev, part) != 0)
+               return 1;
+
+       return 0;
+}
+
+/**
+ * Parse one partition definition, allocate memory and return pointer to this
+ * location in retpart.
+ *
+ * @param partdef pointer to the partition definition string i.e. <part-def>
+ * @param ret output pointer to next char after parse completes (output)
+ * @param retpart pointer to the allocated partition (output)
+ * @return 0 on success, 1 otherwise
+ */
+static int part_parse(const char *const partdef, const char **ret, struct part_info **retpart)
+{
+       struct part_info *part;
+       unsigned long size;
+       unsigned long offset;
+       const char *name;
+       int name_len;
+       unsigned int mask_flags;
+       const char *p;
+
+       p = partdef;
+       *retpart = NULL;
+       *ret = NULL;
+
+       /* fetch the partition size */
+       if (*p == '-') {
+               /* assign all remaining space to this partition */
+               DEBUGF("'-': remaining size assigned\n");
+               size = SIZE_REMAINING;
+               p++;
+       } else {
+               size = memsize_parse(p, &p);
+               if (size < MIN_PART_SIZE) {
+                       printf("partition size too small (%lx)\n", size);
+                       return 1;
+               }
+       }
+
+       /* check for offset */
+       offset = OFFSET_NOT_SPECIFIED;
+       if (*p == '@') {
+               p++;
+               offset = memsize_parse(p, &p);
+       }
+
+       /* now look for the name */
+       if (*p == '(') {
+               name = ++p;
+               if ((p = strchr(name, ')')) == NULL) {
+                       printf("no closing ) found in partition name\n");
+                       return 1;
+               }
+               name_len = p - name + 1;
+               if ((name_len - 1) == 0) {
+                       printf("empty partition name\n");
+                       return 1;
+               }
+               p++;
+       } else {
+               /* 0x00000000@0x00000000 */
+               name_len = 22;
+               name = NULL;
+       }
+
+       /* test for options */
+       mask_flags = 0;
+       if (strncmp(p, "ro", 2) == 0) {
+               mask_flags |= MTD_WRITEABLE_CMD;
+               p += 2;
+       }
+
+       /* check for next partition definition */
+       if (*p == ',') {
+               if (size == SIZE_REMAINING) {
+                       *ret = NULL;
+                       printf("no partitions allowed after a fill-up partition\n");
+                       return 1;
+               }
+               *ret = ++p;
+       } else if ((*p == ';') || (*p == '\0')) {
+               *ret = p;
+       } else {
+               printf("unexpected character '%c' at the end of partition\n", *p);
+               *ret = NULL;
+               return 1;
+       }
+
+       /*  allocate memory */
+       part = (struct part_info *)malloc(sizeof(struct part_info) + name_len);
+       if (!part) {
+               printf("out of memory\n");
+               return 1;
+       }
+       memset(part, 0, sizeof(struct part_info) + name_len);
+       part->size = size;
+       part->offset = offset;
+       part->mask_flags = mask_flags;
+       part->name = (char *)(part + 1);
+
+       if (name) {
+               /* copy user provided name */
+               strncpy(part->name, name, name_len - 1);
+               part->auto_name = 0;
+       } else {
+               /* auto generated name in form of size@offset */
+               sprintf(part->name, "0x%08lx@0x%08lx", size, offset);
+               part->auto_name = 1;
+       }
+
+       part->name[name_len - 1] = '\0';
+       INIT_LIST_HEAD(&part->link);
+
+       DEBUGF("+ partition: name %-22s size 0x%08x offset 0x%08x mask flags %d\n",
+                       part->name, part->size,
+                       part->offset, part->mask_flags);
+
+       *retpart = part;
+       return 0;
+}
+
+/**
+ * Check device number to be within valid range for given device type.
+ *
+ * @param dev device to validate
+ * @return 0 if device is valid, 1 otherwise
+ */
+int mtd_device_validate(u8 type, u8 num, u32 *size)
+{
+       if (type == MTD_DEV_TYPE_NOR) {
+#if defined(CONFIG_CMD_FLASH)
+               if (num < CONFIG_SYS_MAX_FLASH_BANKS) {
+                       extern flash_info_t flash_info[];
+                       *size = flash_info[num].size;
+
+                       return 0;
+               }
+
+               printf("no such FLASH device: %s%d (valid range 0 ... %d\n",
+                               MTD_DEV_TYPE(type), num, CONFIG_SYS_MAX_FLASH_BANKS - 1);
+#else
+               printf("support for FLASH devices not present\n");
+#endif
+       } else if (type == MTD_DEV_TYPE_NAND) {
+#if defined(CONFIG_JFFS2_NAND) && defined(CONFIG_CMD_NAND)
+               if (num < CONFIG_SYS_MAX_NAND_DEVICE) {
+#ifndef CONFIG_NAND_LEGACY
+                       *size = nand_info[num].size;
+#else
+                       extern struct nand_chip nand_dev_desc[CONFIG_SYS_MAX_NAND_DEVICE];
+                       *size = nand_dev_desc[num].totlen;
+#endif
+                       return 0;
+               }
+
+               printf("no such NAND device: %s%d (valid range 0 ... %d)\n",
+                               MTD_DEV_TYPE(type), num, CONFIG_SYS_MAX_NAND_DEVICE - 1);
+#else
+               printf("support for NAND devices not present\n");
+#endif
+       } else if (type == MTD_DEV_TYPE_ONENAND) {
+#if defined(CONFIG_CMD_ONENAND)
+               *size = onenand_mtd.size;
+               return 0;
+#else
+               printf("support for OneNAND devices not present\n");
+#endif
+       } else
+               printf("Unknown defice type %d\n", type);
+
+       return 1;
+}
+
+/**
+ * Delete all mtd devices from a supplied devices list, free memory allocated for
+ * each device and delete all device partitions.
+ *
+ * @return 0 on success, 1 otherwise
+ */
+static int device_delall(struct list_head *head)
+{
+       struct list_head *entry, *n;
+       struct mtd_device *dev_tmp;
+
+       /* clean devices list */
+       list_for_each_safe(entry, n, head) {
+               dev_tmp = list_entry(entry, struct mtd_device, link);
+               list_del(entry);
+               part_delall(&dev_tmp->parts);
+               free(dev_tmp);
+       }
+       INIT_LIST_HEAD(&devices);
+
+       return 0;
+}
+
+/**
+ * If provided device exists it's partitions are deleted, device is removed
+ * from device list and device memory is freed.
+ *
+ * @param dev device to be deleted
+ * @return 0 on success, 1 otherwise
+ */
+static int device_del(struct mtd_device *dev)
+{
+       part_delall(&dev->parts);
+       list_del(&dev->link);
+       free(dev);
+
+       if (dev == current_dev) {
+               /* we just deleted current device */
+               if (list_empty(&devices)) {
+                       current_dev = NULL;
+               } else {
+                       /* reset first partition from first dev from the
+                        * devices list as current */
+                       current_dev = list_entry(devices.next, struct mtd_device, link);
+                       current_partnum = 0;
+               }
+               current_save();
+               return 0;
+       }
+
+       index_partitions();
+       return 0;
+}
+
+/**
+ * Search global device list and return pointer to the device of type and num
+ * specified.
+ *
+ * @param type device type
+ * @param num device number
+ * @return NULL if requested device does not exist
+ */
+static struct mtd_device* device_find(u8 type, u8 num)
+{
+       struct list_head *entry;
+       struct mtd_device *dev_tmp;
+
+       list_for_each(entry, &devices) {
+               dev_tmp = list_entry(entry, struct mtd_device, link);
+
+               if ((dev_tmp->id->type == type) && (dev_tmp->id->num == num))
+                       return dev_tmp;
+       }
+
+       return NULL;
+}
+
+/**
+ * Add specified device to the global device list.
+ *
+ * @param dev device to be added
+ */
+static void device_add(struct mtd_device *dev)
+{
+       u8 current_save_needed = 0;
+
+       if (list_empty(&devices)) {
+               current_dev = dev;
+               current_partnum = 0;
+               current_save_needed = 1;
+       }
+
+       list_add_tail(&dev->link, &devices);
+
+       if (current_save_needed > 0)
+               current_save();
+       else
+               index_partitions();
+}
+
+/**
+ * Parse device type, name and mtd-id. If syntax is ok allocate memory and
+ * return pointer to the device structure.
+ *
+ * @param mtd_dev pointer to the device definition string i.e. <mtd-dev>
+ * @param ret output pointer to next char after parse completes (output)
+ * @param retdev pointer to the allocated device (output)
+ * @return 0 on success, 1 otherwise
+ */
+static int device_parse(const char *const mtd_dev, const char **ret, struct mtd_device **retdev)
+{
+       struct mtd_device *dev;
+       struct part_info *part;
+       struct mtdids *id;
+       const char *mtd_id;
+       unsigned int mtd_id_len;
+       const char *p, *pend;
+       LIST_HEAD(tmp_list);
+       struct list_head *entry, *n;
+       u16 num_parts;
+       u32 offset;
+       int err = 1;
+
+       p = mtd_dev;
+       *retdev = NULL;
+       *ret = NULL;
+
+       DEBUGF("===device_parse===\n");
+
+       /* fetch <mtd-id> */
+       mtd_id = p;
+       if (!(p = strchr(mtd_id, ':'))) {
+               printf("no <mtd-id> identifier\n");
+               return 1;
+       }
+       mtd_id_len = p - mtd_id + 1;
+       p++;
+
+       /* verify if we have a valid device specified */
+       if ((id = id_find_by_mtd_id(mtd_id, mtd_id_len - 1)) == NULL) {
+               printf("invalid mtd device '%.*s'\n", mtd_id_len - 1, mtd_id);
+               return 1;
+       }
+
+       DEBUGF("dev type = %d (%s), dev num = %d, mtd-id = %s\n",
+                       id->type, MTD_DEV_TYPE(id->type),
+                       id->num, id->mtd_id);
+       pend = strchr(p, ';');
+       DEBUGF("parsing partitions %.*s\n", (pend ? pend - p : strlen(p)), p);
+
+
+       /* parse partitions */
+       num_parts = 0;
+
+       offset = 0;
+       if ((dev = device_find(id->type, id->num)) != NULL) {
+               /* if device already exists start at the end of the last partition */
+               part = list_entry(dev->parts.prev, struct part_info, link);
+               offset = part->offset + part->size;
+       }
+
+       while (p && (*p != '\0') && (*p != ';')) {
+               err = 1;
+               if ((part_parse(p, &p, &part) != 0) || (!part))
+                       break;
+
+               /* calculate offset when not specified */
+               if (part->offset == OFFSET_NOT_SPECIFIED)
+                       part->offset = offset;
+               else
+                       offset = part->offset;
+
+               /* verify alignment and size */
+               if (part_validate(id, part) != 0)
+                       break;
+
+               offset += part->size;
+
+               /* partition is ok, add it to the list */
+               list_add_tail(&part->link, &tmp_list);
+               num_parts++;
+               err = 0;
+       }
+       if (err == 1) {
+               part_delall(&tmp_list);
+               return 1;
+       }
+
+       if (num_parts == 0) {
+               printf("no partitions for device %s%d (%s)\n",
+                               MTD_DEV_TYPE(id->type), id->num, id->mtd_id);
+               return 1;
+       }
+
+       DEBUGF("\ntotal partitions: %d\n", num_parts);
+
+       /* check for next device presence */
+       if (p) {
+               if (*p == ';') {
+                       *ret = ++p;
+               } else if (*p == '\0') {
+                       *ret = p;
+               } else {
+                       printf("unexpected character '%c' at the end of device\n", *p);
+                       *ret = NULL;
+                       return 1;
+               }
+       }
+
+       /* allocate memory for mtd_device structure */
+       if ((dev = (struct mtd_device *)malloc(sizeof(struct mtd_device))) == NULL) {
+               printf("out of memory\n");
+               return 1;
+       }
+       memset(dev, 0, sizeof(struct mtd_device));
+       dev->id = id;
+       dev->num_parts = 0; /* part_sort_add increments num_parts */
+       INIT_LIST_HEAD(&dev->parts);
+       INIT_LIST_HEAD(&dev->link);
+
+       /* move partitions from tmp_list to dev->parts */
+       list_for_each_safe(entry, n, &tmp_list) {
+               part = list_entry(entry, struct part_info, link);
+               list_del(entry);
+               if (part_sort_add(dev, part) != 0) {
+                       device_del(dev);
+                       return 1;
+               }
+       }
+
+       *retdev = dev;
+
+       DEBUGF("===\n\n");
+       return 0;
+}
+
+/**
+ * Initialize global device list.
+ *
+ * @return 0 on success, 1 otherwise
+ */
+static int mtd_devices_init(void)
+{
+       last_parts[0] = '\0';
+       current_dev = NULL;
+       current_save();
+
+       return device_delall(&devices);
+}
+
+/*
+ * Search global mtdids list and find id of requested type and number.
+ *
+ * @return pointer to the id if it exists, NULL otherwise
+ */
+static struct mtdids* id_find(u8 type, u8 num)
+{
+       struct list_head *entry;
+       struct mtdids *id;
+
+       list_for_each(entry, &mtdids) {
+               id = list_entry(entry, struct mtdids, link);
+
+               if ((id->type == type) && (id->num == num))
+                       return id;
+       }
+
+       return NULL;
+}
+
+/**
+ * Search global mtdids list and find id of a requested mtd_id.
+ *
+ * Note: first argument is not null terminated.
+ *
+ * @param mtd_id string containing requested mtd_id
+ * @param mtd_id_len length of supplied mtd_id
+ * @return pointer to the id if it exists, NULL otherwise
+ */
+static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_len)
+{
+       struct list_head *entry;
+       struct mtdids *id;
+
+       DEBUGF("--- id_find_by_mtd_id: '%.*s' (len = %d)\n",
+                       mtd_id_len, mtd_id, mtd_id_len);
+
+       list_for_each(entry, &mtdids) {
+               id = list_entry(entry, struct mtdids, link);
+
+               DEBUGF("entry: '%s' (len = %d)\n",
+                               id->mtd_id, strlen(id->mtd_id));
+
+               if (mtd_id_len != strlen(id->mtd_id))
+                       continue;
+               if (strncmp(id->mtd_id, mtd_id, mtd_id_len) == 0)
+                       return id;
+       }
+
+       return NULL;
+}
+
+/**
+ * Parse device id string <dev-id> := 'nand'|'nor'|'onenand'<dev-num>,
+ * return device type and number.
+ *
+ * @param id string describing device id
+ * @param ret_id output pointer to next char after parse completes (output)
+ * @param dev_type parsed device type (output)
+ * @param dev_num parsed device number (output)
+ * @return 0 on success, 1 otherwise
+ */
+int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num)
+{
+       const char *p = id;
+
+       *dev_type = 0;
+       if (strncmp(p, "nand", 4) == 0) {
+               *dev_type = MTD_DEV_TYPE_NAND;
+               p += 4;
+       } else if (strncmp(p, "nor", 3) == 0) {
+               *dev_type = MTD_DEV_TYPE_NOR;
+               p += 3;
+       } else if (strncmp(p, "onenand", 7) == 0) {
+               *dev_type = MTD_DEV_TYPE_ONENAND;
+               p += 7;
+       } else {
+               printf("incorrect device type in %s\n", id);
+               return 1;
+       }
+
+       if (!isdigit(*p)) {
+               printf("incorrect device number in %s\n", id);
+               return 1;
+       }
+
+       *dev_num = simple_strtoul(p, (char **)&p, 0);
+       if (ret_id)
+               *ret_id = p;
+       return 0;
+}
+
+/**
+ * Process all devices and generate corresponding mtdparts string describing
+ * all partitions on all devices.
+ *
+ * @param buf output buffer holding generated mtdparts string (output)
+ * @param buflen buffer size
+ * @return 0 on success, 1 otherwise
+ */
+static int generate_mtdparts(char *buf, u32 buflen)
+{
+       struct list_head *pentry, *dentry;
+       struct mtd_device *dev;
+       struct part_info *part, *prev_part;
+       char *p = buf;
+       char tmpbuf[32];
+       u32 size, offset, len, part_cnt;
+       u32 maxlen = buflen - 1;
+
+       DEBUGF("--- generate_mtdparts ---\n");
+
+       if (list_empty(&devices)) {
+               buf[0] = '\0';
+               return 0;
+       }
+
+       sprintf(p, "mtdparts=");
+       p += 9;
+
+       list_for_each(dentry, &devices) {
+               dev = list_entry(dentry, struct mtd_device, link);
+
+               /* copy mtd_id */
+               len = strlen(dev->id->mtd_id) + 1;
+               if (len > maxlen)
+                       goto cleanup;
+               memcpy(p, dev->id->mtd_id, len - 1);
+               p += len - 1;
+               *(p++) = ':';
+               maxlen -= len;
+
+               /* format partitions */
+               prev_part = NULL;
+               part_cnt = 0;
+               list_for_each(pentry, &dev->parts) {
+                       part = list_entry(pentry, struct part_info, link);
+                       size = part->size;
+                       offset = part->offset;
+                       part_cnt++;
+
+                       /* partition size */
+                       memsize_format(tmpbuf, size);
+                       len = strlen(tmpbuf);
+                       if (len > maxlen)
+                               goto cleanup;
+                       memcpy(p, tmpbuf, len);
+                       p += len;
+                       maxlen -= len;
+
+
+                       /* add offset only when there is a gap between
+                        * partitions */
+                       if ((!prev_part && (offset != 0)) ||
+                                       (prev_part && ((prev_part->offset + prev_part->size) != part->offset))) {
+
+                               memsize_format(tmpbuf, offset);
+                               len = strlen(tmpbuf) + 1;
+                               if (len > maxlen)
+                                       goto cleanup;
+                               *(p++) = '@';
+                               memcpy(p, tmpbuf, len - 1);
+                               p += len - 1;
+                               maxlen -= len;
+                       }
+
+                       /* copy name only if user supplied */
+                       if(!part->auto_name) {
+                               len = strlen(part->name) + 2;
+                               if (len > maxlen)
+                                       goto cleanup;
+
+                               *(p++) = '(';
+                               memcpy(p, part->name, len - 2);
+                               p += len - 2;
+                               *(p++) = ')';
+                               maxlen -= len;
+                       }
+
+                       /* ro mask flag */
+                       if (part->mask_flags && MTD_WRITEABLE_CMD) {
+                               len = 2;
+                               if (len > maxlen)
+                                       goto cleanup;
+                               *(p++) = 'r';
+                               *(p++) = 'o';
+                               maxlen -= 2;
+                       }
+
+                       /* print ',' separator if there are other partitions
+                        * following */
+                       if (dev->num_parts > part_cnt) {
+                               if (1 > maxlen)
+                                       goto cleanup;
+                               *(p++) = ',';
+                               maxlen--;
+                       }
+                       prev_part = part;
+               }
+               /* print ';' separator if there are other devices following */
+               if (dentry->next != &devices) {
+                       if (1 > maxlen)
+                               goto cleanup;
+                       *(p++) = ';';
+                       maxlen--;
+               }
+       }
+
+       /* we still have at least one char left, as we decremented maxlen at
+        * the begining */
+       *p = '\0';
+
+       return 0;
+
+cleanup:
+       last_parts[0] = '\0';
+       return 1;
+}
+
+/**
+ * Call generate_mtdparts to process all devices and generate corresponding
+ * mtdparts string, save it in mtdparts environment variable.
+ *
+ * @param buf output buffer holding generated mtdparts string (output)
+ * @param buflen buffer size
+ * @return 0 on success, 1 otherwise
+ */
+static int generate_mtdparts_save(char *buf, u32 buflen)
+{
+       int ret;
+
+       ret = generate_mtdparts(buf, buflen);
+
+       if ((buf[0] != '\0') && (ret == 0))
+               setenv("mtdparts", buf);
+       else
+               setenv("mtdparts", NULL);
+
+       return ret;
+}
+
+/**
+ * Format and print out a partition list for each device from global device
+ * list.
+ */
+static void list_partitions(void)
+{
+       struct list_head *dentry, *pentry;
+       struct part_info *part;
+       struct mtd_device *dev;
+       int part_num;
+
+       DEBUGF("\n---list_partitions---\n");
+       list_for_each(dentry, &devices) {
+               dev = list_entry(dentry, struct mtd_device, link);
+               printf("\ndevice %s%d <%s>, # parts = %d\n",
+                               MTD_DEV_TYPE(dev->id->type), dev->id->num,
+                               dev->id->mtd_id, dev->num_parts);
+               printf(" #: name\t\t\tsize\t\toffset\t\tmask_flags\n");
+
+               /* list partitions for given device */
+               part_num = 0;
+               list_for_each(pentry, &dev->parts) {
+                       part = list_entry(pentry, struct part_info, link);
+                       printf("%2d: %-20s0x%08x\t0x%08x\t%d\n",
+                                       part_num, part->name, part->size,
+                                       part->offset, part->mask_flags);
+
+                       part_num++;
+               }
+       }
+       if (list_empty(&devices))
+               printf("no partitions defined\n");
+
+       /* current_dev is not NULL only when we have non empty device list */
+       if (current_dev) {
+               part = mtd_part_info(current_dev, current_partnum);
+               if (part) {
+                       printf("\nactive partition: %s%d,%d - (%s) 0x%08x @ 0x%08x\n",
+                                       MTD_DEV_TYPE(current_dev->id->type),
+                                       current_dev->id->num, current_partnum,
+                                       part->name, part->size, part->offset);
+               } else {
+                       printf("could not get current partition info\n\n");
+               }
+       }
+
+       printf("\ndefaults:\n");
+       printf("mtdids  : %s\n", mtdids_default);
+       printf("mtdparts: %s\n", mtdparts_default);
+}
+
+/**
+ * Given partition identifier in form of <dev_type><dev_num>,<part_num> find
+ * corresponding device and verify partition number.
+ *
+ * @param id string describing device and partition or partition name
+ * @param dev pointer to the requested device (output)
+ * @param part_num verified partition number (output)
+ * @param part pointer to requested partition (output)
+ * @return 0 on success, 1 otherwise
+ */
+int find_dev_and_part(const char *id, struct mtd_device **dev,
+               u8 *part_num, struct part_info **part)
+{
+       struct list_head *dentry, *pentry;
+       u8 type, dnum, pnum;
+       const char *p;
+
+       DEBUGF("--- find_dev_and_part ---\nid = %s\n", id);
+
+       list_for_each(dentry, &devices) {
+               *part_num = 0;
+               *dev = list_entry(dentry, struct mtd_device, link);
+               list_for_each(pentry, &(*dev)->parts) {
+                       *part = list_entry(pentry, struct part_info, link);
+                       if (strcmp((*part)->name, id) == 0)
+                               return 0;
+                       (*part_num)++;
+               }
+       }
+
+       p = id;
+       *dev = NULL;
+       *part = NULL;
+       *part_num = 0;
+
+       if (mtd_id_parse(p, &p, &type, &dnum) != 0)
+               return 1;
+
+       if ((*p++ != ',') || (*p == '\0')) {
+               printf("no partition number specified\n");
+               return 1;
+       }
+       pnum = simple_strtoul(p, (char **)&p, 0);
+       if (*p != '\0') {
+               printf("unexpected trailing character '%c'\n", *p);
+               return 1;
+       }
+
+       if ((*dev = device_find(type, dnum)) == NULL) {
+               printf("no such device %s%d\n", MTD_DEV_TYPE(type), dnum);
+               return 1;
+       }
+
+       if ((*part = mtd_part_info(*dev, pnum)) == NULL) {
+               printf("no such partition\n");
+               *dev = NULL;
+               return 1;
+       }
+
+       *part_num = pnum;
+
+       return 0;
+}
+
+/**
+ * Find and delete partition. For partition id format see find_dev_and_part().
+ *
+ * @param id string describing device and partition
+ * @return 0 on success, 1 otherwise
+ */
+static int delete_partition(const char *id)
+{
+       u8 pnum;
+       struct mtd_device *dev;
+       struct part_info *part;
+
+       if (find_dev_and_part(id, &dev, &pnum, &part) == 0) {
+
+               DEBUGF("delete_partition: device = %s%d, partition %d = (%s) 0x%08lx@0x%08lx\n",
+                               MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum,
+                               part->name, part->size, part->offset);
+
+               if (part_del(dev, part) != 0)
+                       return 1;
+
+               if (generate_mtdparts_save(last_parts, MTDPARTS_MAXLEN) != 0) {
+                       printf("generated mtdparts too long, reseting to null\n");
+                       return 1;
+               }
+               return 0;
+       }
+
+       printf("partition %s not found\n", id);
+       return 1;
+}
+
+/**
+ * Accept character string describing mtd partitions and call device_parse()
+ * for each entry. Add created devices to the global devices list.
+ *
+ * @param mtdparts string specifing mtd partitions
+ * @return 0 on success, 1 otherwise
+ */
+static int parse_mtdparts(const char *const mtdparts)
+{
+       const char *p = mtdparts;
+       struct mtd_device *dev;
+       int err = 1;
+
+       DEBUGF("\n---parse_mtdparts---\nmtdparts = %s\n\n", p);
+
+       /* delete all devices and partitions */
+       if (mtd_devices_init() != 0) {
+               printf("could not initialise device list\n");
+               return err;
+       }
+
+       /* re-read 'mtdparts' variable, mtd_devices_init may be updating env */
+       p = getenv("mtdparts");
+
+       if (strncmp(p, "mtdparts=", 9) != 0) {
+               printf("mtdparts variable doesn't start with 'mtdparts='\n");
+               return err;
+       }
+       p += 9;
+
+       while (p && (*p != '\0')) {
+               err = 1;
+               if ((device_parse(p, &p, &dev) != 0) || (!dev))
+                       break;
+
+               DEBUGF("+ device: %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type),
+                               dev->id->num, dev->id->mtd_id);
+
+               /* check if parsed device is already on the list */
+               if (device_find(dev->id->type, dev->id->num) != NULL) {
+                       printf("device %s%d redefined, please correct mtdparts variable\n",
+                                       MTD_DEV_TYPE(dev->id->type), dev->id->num);
+                       break;
+               }
+
+               list_add_tail(&dev->link, &devices);
+               err = 0;
+       }
+       if (err == 1) {
+               device_delall(&devices);
+               return 1;
+       }
+
+       return 0;
+}
+
+/**
+ * Parse provided string describing mtdids mapping (see file header for mtdids
+ * variable format). Allocate memory for each entry and add all found entries
+ * to the global mtdids list.
+ *
+ * @param ids mapping string
+ * @return 0 on success, 1 otherwise
+ */
+static int parse_mtdids(const char *const ids)
+{
+       const char *p = ids;
+       const char *mtd_id;
+       int mtd_id_len;
+       struct mtdids *id;
+       struct list_head *entry, *n;
+       struct mtdids *id_tmp;
+       u8 type, num;
+       u32 size;
+       int ret = 1;
+
+       DEBUGF("\n---parse_mtdids---\nmtdids = %s\n\n", ids);
+
+       /* clean global mtdids list */
+       list_for_each_safe(entry, n, &mtdids) {
+               id_tmp = list_entry(entry, struct mtdids, link);
+               DEBUGF("mtdids del: %d %d\n", id_tmp->type, id_tmp->num);
+               list_del(entry);
+               free(id_tmp);
+       }
+       last_ids[0] = '\0';
+       INIT_LIST_HEAD(&mtdids);
+
+       while(p && (*p != '\0')) {
+
+               ret = 1;
+               /* parse 'nor'|'nand'|'onenand'<dev-num> */
+               if (mtd_id_parse(p, &p, &type, &num) != 0)
+                       break;
+
+               if (*p != '=') {
+                       printf("mtdids: incorrect <dev-num>\n");
+                       break;
+               }
+               p++;
+
+               /* check if requested device exists */
+               if (mtd_device_validate(type, num, &size) != 0)
+                       return 1;
+
+               /* locate <mtd-id> */
+               mtd_id = p;
+               if ((p = strchr(mtd_id, ',')) != NULL) {
+                       mtd_id_len = p - mtd_id + 1;
+                       p++;
+               } else {
+                       mtd_id_len = strlen(mtd_id) + 1;
+               }
+               if (mtd_id_len == 0) {
+                       printf("mtdids: no <mtd-id> identifier\n");
+                       break;
+               }
+
+               /* check if this id is already on the list */
+               int double_entry = 0;
+               list_for_each(entry, &mtdids) {
+                       id_tmp = list_entry(entry, struct mtdids, link);
+                       if ((id_tmp->type == type) && (id_tmp->num == num)) {
+                               double_entry = 1;
+                               break;
+                       }
+               }
+               if (double_entry) {
+                       printf("device id %s%d redefined, please correct mtdids variable\n",
+                                       MTD_DEV_TYPE(type), num);
+                       break;
+               }
+
+               /* allocate mtdids structure */
+               if (!(id = (struct mtdids *)malloc(sizeof(struct mtdids) + mtd_id_len))) {
+                       printf("out of memory\n");
+                       break;
+               }
+               memset(id, 0, sizeof(struct mtdids) + mtd_id_len);
+               id->num = num;
+               id->type = type;
+               id->size = size;
+               id->mtd_id = (char *)(id + 1);
+               strncpy(id->mtd_id, mtd_id, mtd_id_len - 1);
+               id->mtd_id[mtd_id_len - 1] = '\0';
+               INIT_LIST_HEAD(&id->link);
+
+               DEBUGF("+ id %s%d\t%16d bytes\t%s\n",
+                               MTD_DEV_TYPE(id->type), id->num,
+                               id->size, id->mtd_id);
+
+               list_add_tail(&id->link, &mtdids);
+               ret = 0;
+       }
+       if (ret == 1) {
+               /* clean mtdids list and free allocated memory */
+               list_for_each_safe(entry, n, &mtdids) {
+                       id_tmp = list_entry(entry, struct mtdids, link);
+                       list_del(entry);
+                       free(id_tmp);
+               }
+               return 1;
+       }
+
+       return 0;
+}
+
+/**
+ * Parse and initialize global mtdids mapping and create global
+ * device/partition list.
+ *
+ * @return 0 on success, 1 otherwise
+ */
+int mtdparts_init(void)
+{
+       static int initialized = 0;
+       const char *ids, *parts;
+       const char *current_partition;
+       int ids_changed;
+       char tmp_ep[PARTITION_MAXLEN];
+
+       DEBUGF("\n---mtdparts_init---\n");
+       if (!initialized) {
+               INIT_LIST_HEAD(&mtdids);
+               INIT_LIST_HEAD(&devices);
+               memset(last_ids, 0, MTDIDS_MAXLEN);
+               memset(last_parts, 0, MTDPARTS_MAXLEN);
+               memset(last_partition, 0, PARTITION_MAXLEN);
+               initialized = 1;
+       }
+
+       /* get variables */
+       ids = getenv("mtdids");
+       parts = getenv("mtdparts");
+       current_partition = getenv("partition");
+
+       /* save it for later parsing, cannot rely on current partition pointer
+        * as 'partition' variable may be updated during init */
+       tmp_ep[0] = '\0';
+       if (current_partition)
+               strncpy(tmp_ep, current_partition, PARTITION_MAXLEN);
+
+       DEBUGF("last_ids  : %s\n", last_ids);
+       DEBUGF("env_ids   : %s\n", ids);
+       DEBUGF("last_parts: %s\n", last_parts);
+       DEBUGF("env_parts : %s\n\n", parts);
+
+       DEBUGF("last_partition : %s\n", last_partition);
+       DEBUGF("env_partition  : %s\n", current_partition);
+
+       /* if mtdids varible is empty try to use defaults */
+       if (!ids) {
+               if (mtdids_default) {
+                       DEBUGF("mtdids variable not defined, using default\n");
+                       ids = mtdids_default;
+                       setenv("mtdids", (char *)ids);
+               } else {
+                       printf("mtdids not defined, no default present\n");
+                       return 1;
+               }
+       }
+       if (strlen(ids) > MTDIDS_MAXLEN - 1) {
+               printf("mtdids too long (> %d)\n", MTDIDS_MAXLEN);
+               return 1;
+       }
+
+       /* do no try to use defaults when mtdparts variable is not defined,
+        * just check the length */
+       if (!parts)
+               printf("mtdparts variable not set, see 'help mtdparts'\n");
+
+       if (parts && (strlen(parts) > MTDPARTS_MAXLEN - 1)) {
+               printf("mtdparts too long (> %d)\n", MTDPARTS_MAXLEN);
+               return 1;
+       }
+
+       /* check if we have already parsed those mtdids */
+       if ((last_ids[0] != '\0') && (strcmp(last_ids, ids) == 0)) {
+               ids_changed = 0;
+       } else {
+               ids_changed = 1;
+
+               if (parse_mtdids(ids) != 0) {
+                       mtd_devices_init();
+                       return 1;
+               }
+
+               /* ok it's good, save new ids */
+               strncpy(last_ids, ids, MTDIDS_MAXLEN);
+       }
+
+       /* parse partitions if either mtdparts or mtdids were updated */
+       if (parts && ((last_parts[0] == '\0') || ((strcmp(last_parts, parts) != 0)) || ids_changed)) {
+               if (parse_mtdparts(parts) != 0)
+                       return 1;
+
+               if (list_empty(&devices)) {
+                       printf("mtdparts_init: no valid partitions\n");
+                       return 1;
+               }
+
+               /* ok it's good, save new parts */
+               strncpy(last_parts, parts, MTDPARTS_MAXLEN);
+
+               /* reset first partition from first dev from the list as current */
+               current_dev = list_entry(devices.next, struct mtd_device, link);
+               current_partnum = 0;
+               current_save();
+
+               DEBUGF("mtdparts_init: current_dev  = %s%d, current_partnum = %d\n",
+                               MTD_DEV_TYPE(current_dev->id->type),
+                               current_dev->id->num, current_partnum);
+       }
+
+       /* mtdparts variable was reset to NULL, delete all devices/partitions */
+       if (!parts && (last_parts[0] != '\0'))
+               return mtd_devices_init();
+
+       /* do not process current partition if mtdparts variable is null */
+       if (!parts)
+               return 0;
+
+       /* is current partition set in environment? if so, use it */
+       if ((tmp_ep[0] != '\0') && (strcmp(tmp_ep, last_partition) != 0)) {
+               struct part_info *p;
+               struct mtd_device *cdev;
+               u8 pnum;
+
+               DEBUGF("--- getting current partition: %s\n", tmp_ep);
+
+               if (find_dev_and_part(tmp_ep, &cdev, &pnum, &p) == 0) {
+                       current_dev = cdev;
+                       current_partnum = pnum;
+                       current_save();
+               }
+       } else if (getenv("partition") == NULL) {
+               DEBUGF("no partition variable set, setting...\n");
+               current_save();
+       }
+
+       return 0;
+}
+
+/**
+ * Return pointer to the partition of a requested number from a requested
+ * device.
+ *
+ * @param dev device that is to be searched for a partition
+ * @param part_num requested partition number
+ * @return pointer to the part_info, NULL otherwise
+ */
+static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part_num)
+{
+       struct list_head *entry;
+       struct part_info *part;
+       int num;
+
+       if (!dev)
+               return NULL;
+
+       DEBUGF("\n--- mtd_part_info: partition number %d for device %s%d (%s)\n",
+                       part_num, MTD_DEV_TYPE(dev->id->type),
+                       dev->id->num, dev->id->mtd_id);
+
+       if (part_num >= dev->num_parts) {
+               printf("invalid partition number %d for device %s%d (%s)\n",
+                               part_num, MTD_DEV_TYPE(dev->id->type),
+                               dev->id->num, dev->id->mtd_id);
+               return NULL;
+       }
+
+       /* locate partition number, return it */
+       num = 0;
+       list_for_each(entry, &dev->parts) {
+               part = list_entry(entry, struct part_info, link);
+
+               if (part_num == num++) {
+                       return part;
+               }
+       }
+
+       return NULL;
+}
+
+/***************************************************/
+/* U-boot commands                                */
+/***************************************************/
+/* command line only */
+/**
+ * Routine implementing u-boot chpart command. Sets new current partition based
+ * on the user supplied partition id. For partition id format see find_dev_and_part().
+ *
+ * @param cmdtp command internal data
+ * @param flag command flag
+ * @param argc number of arguments supplied to the command
+ * @param argv arguments list
+ * @return 0 on success, 1 otherwise
+ */
+int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+/* command line only */
+       struct mtd_device *dev;
+       struct part_info *part;
+       u8 pnum;
+
+       if (mtdparts_init() !=0)
+               return 1;
+
+       if (argc < 2) {
+               printf("no partition id specified\n");
+               return 1;
+       }
+
+       if (find_dev_and_part(argv[1], &dev, &pnum, &part) != 0)
+               return 1;
+
+       current_dev = dev;
+       current_partnum = pnum;
+       current_save();
+
+       printf("partition changed to %s%d,%d\n",
+                       MTD_DEV_TYPE(dev->id->type), dev->id->num, pnum);
+
+       return 0;
+}
+
+/**
+ * Routine implementing u-boot mtdparts command. Initialize/update default global
+ * partition list and process user partition request (list, add, del).
+ *
+ * @param cmdtp command internal data
+ * @param flag command flag
+ * @param argc number of arguments supplied to the command
+ * @param argv arguments list
+ * @return 0 on success, 1 otherwise
+ */
+int do_mtdparts(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
+{
+       if (argc == 2) {
+               if (strcmp(argv[1], "default") == 0) {
+                       setenv("mtdids", (char *)mtdids_default);
+                       setenv("mtdparts", (char *)mtdparts_default);
+                       setenv("partition", NULL);
+
+                       mtdparts_init();
+                       return 0;
+               } else if (strcmp(argv[1], "delall") == 0) {
+                       /* this may be the first run, initialize lists if needed */
+                       mtdparts_init();
+
+                       setenv("mtdparts", NULL);
+
+                       /* mtd_devices_init() calls current_save() */
+                       return mtd_devices_init();
+               }
+       }
+
+       /* make sure we are in sync with env variables */
+       if (mtdparts_init() != 0)
+               return 1;
+
+       if (argc == 1) {
+               list_partitions();
+               return 0;
+       }
+
+       /* mtdparts add <mtd-dev> <size>[@<offset>] <name> [ro] */
+       if (((argc == 5) || (argc == 6)) && (strcmp(argv[1], "add") == 0)) {
+#define PART_ADD_DESC_MAXLEN 64
+               char tmpbuf[PART_ADD_DESC_MAXLEN];
+               u8 type, num, len;
+               struct mtd_device *dev;
+               struct mtd_device *dev_tmp;
+               struct mtdids *id;
+               struct part_info *p;
+
+               if (mtd_id_parse(argv[2], NULL, &type, &num) != 0)
+                       return 1;
+
+               if ((id = id_find(type, num)) == NULL) {
+                       printf("no such device %s defined in mtdids variable\n", argv[2]);
+                       return 1;
+               }
+
+               len = strlen(id->mtd_id) + 1;   /* 'mtd_id:' */
+               len += strlen(argv[3]);         /* size@offset */
+               len += strlen(argv[4]) + 2;     /* '(' name ')' */
+               if (argv[5] && (strlen(argv[5]) == 2))
+                       len += 2;               /* 'ro' */
+
+               if (len >= PART_ADD_DESC_MAXLEN) {
+                       printf("too long partition description\n");
+                       return 1;
+               }
+               sprintf(tmpbuf, "%s:%s(%s)%s",
+                               id->mtd_id, argv[3], argv[4], argv[5] ? argv[5] : "");
+               DEBUGF("add tmpbuf: %s\n", tmpbuf);
+
+               if ((device_parse(tmpbuf, NULL, &dev) != 0) || (!dev))
+                       return 1;
+
+               DEBUGF("+ %s\t%d\t%s\n", MTD_DEV_TYPE(dev->id->type),
+                               dev->id->num, dev->id->mtd_id);
+
+               if ((dev_tmp = device_find(dev->id->type, dev->id->num)) == NULL) {
+                       device_add(dev);
+               } else {
+                       /* merge new partition with existing ones*/
+                       p = list_entry(dev->parts.next, struct part_info, link);
+                       if (part_add(dev_tmp, p) != 0) {
+                               device_del(dev);
+                               return 1;
+                       }
+               }
+
+               if (generate_mtdparts_save(last_parts, MTDPARTS_MAXLEN) != 0) {
+                       printf("generated mtdparts too long, reseting to null\n");
+                       return 1;
+               }
+
+               return 0;
+       }
+
+       /* mtdparts del part-id */
+       if ((argc == 3) && (strcmp(argv[1], "del") == 0)) {
+               DEBUGF("del: part-id = %s\n", argv[2]);
+
+               return delete_partition(argv[2]);
+       }
+
+       cmd_usage(cmdtp);
+       return 1;
+}
+
+/***************************************************/
+U_BOOT_CMD(
+       chpart, 2,      0,      do_chpart,
+       "change active partition",
+       "part-id\n"
+       "    - change active partition (e.g. part-id = nand0,1)\n"
+);
+
+U_BOOT_CMD(
+       mtdparts,       6,      0,      do_mtdparts,
+       "define flash/nand partitions",
+       "\n"
+       "    - list partition table\n"
+       "mtdparts delall\n"
+       "    - delete all partitions\n"
+       "mtdparts del part-id\n"
+       "    - delete partition (e.g. part-id = nand0,1)\n"
+       "mtdparts add <mtd-dev> <size>[@<offset>] [<name>] [ro]\n"
+       "    - add partition\n"
+       "mtdparts default\n"
+       "    - reset partition table to defaults\n\n"
+       "-----\n\n"
+       "this command uses three environment variables:\n\n"
+       "'partition' - keeps current partition identifier\n\n"
+       "partition  := <part-id>\n"
+       "<part-id>  := <dev-id>,part_num\n\n"
+       "'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n"
+       "mtdids=<idmap>[,<idmap>,...]\n\n"
+       "<idmap>    := <dev-id>=<mtd-id>\n"
+       "<dev-id>   := 'nand'|'nor'|'onenand'<dev-num>\n"
+       "<dev-num>  := mtd device number, 0...\n"
+       "<mtd-id>   := unique device tag used by linux kernel to find mtd device (mtd->name)\n\n"
+       "'mtdparts' - partition list\n\n"
+       "mtdparts=mtdparts=<mtd-def>[;<mtd-def>...]\n\n"
+       "<mtd-def>  := <mtd-id>:<part-def>[,<part-def>...]\n"
+       "<mtd-id>   := unique device tag used by linux kernel to find mtd device (mtd->name)\n"
+       "<part-def> := <size>[@<offset>][<name>][<ro-flag>]\n"
+       "<size>     := standard linux memsize OR '-' to denote all remaining space\n"
+       "<offset>   := partition start offset within the device\n"
+       "<name>     := '(' NAME ')'\n"
+       "<ro-flag>  := when set to 'ro' makes partition read-only (not used, passed to kernel)\n"
+);
+/***************************************************/
index e6623caf176d84035c47c9a150a3d5f53a3524e5..04b3200e57dd4790f4af1c27981af00aae3cf8fe 100644 (file)
@@ -29,7 +29,7 @@
 #include <jffs2/jffs2.h>
 #include <nand.h>
 
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
 
 /* parition handling routines */
 int mtdparts_init(void);
@@ -105,7 +105,7 @@ static int
 arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, size_t *size)
 {
        int idx = nand_curr_device;
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
        struct mtd_device *dev;
        struct part_info *part;
        u8 pnum;
@@ -153,7 +153,7 @@ arg_off_size(int argc, char *argv[], nand_info_t *nand, ulong *off, size_t *size
                *size = nand->size - *off;
        }
 
-#if  defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if  defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
 out:
 #endif
        printf("device %d ", idx);
@@ -589,7 +589,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
        char *boot_device = NULL;
        int idx;
        ulong addr, offset = 0;
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
        struct mtd_device *dev;
        struct part_info *part;
        u8 pnum;
@@ -634,7 +634,7 @@ int do_nandboot(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
                offset = simple_strtoul(argv[3], NULL, 16);
                break;
        default:
-#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
+#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_CMD_MTDPARTS)
 usage:
 #endif
                cmd_usage(cmdtp);
index 205dd1f6594049ae01145b88751f4a79c9fc6371..db1f55c84a071fe5c17919959dc5bdbd1560dec8 100644 (file)
@@ -58,6 +58,7 @@
 #define CONFIG_CMD_MII         /* MII support                  */
 #define CONFIG_CMD_MISC                /* Misc functions like sleep etc*/
 #define CONFIG_CMD_MMC         /* MMC support                  */
+#define CONFIG_CMD_MTDPARTS    /* mtd parts support            */
 #define CONFIG_CMD_NAND                /* NAND support                 */
 #define CONFIG_CMD_NET         /* bootp, tftpboot, rarpboot    */
 #define CONFIG_CMD_NFS         /* NFS support                  */
index e61a3e1095f1c78eac39e485d886f15e26345e4d..0977bee35d859a6fae0e5860a006bd91f5d0a481 100644 (file)
  *
  */
 /* No command line, one static partition */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         ""
 #define MTDPARTS_DEFAULT       ""
 */
index 2581fdfefd8c6d2deaf03af63db1b36603eb1709..576aa740625fab9c8ae55dbcfd076a51c21899b4 100644 (file)
 
 /* No command line, one static partition */
 /*
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0x00400000
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=alaska-0"
 #define MTDPARTS_DEFAULT       "mtdparts=alaska-0:4m(user)"
 */
index 1910b34639e5def5f245d232f3a0f86fce3fcbbc..40a1c40cc4a1d45eab83ebe385500757c5352490 100644 (file)
  *
  */
 /* No command line, one static partition */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
  * Note: fake mtd_id used, no linux mtd map file
  */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=bab7xx-0"
 #define MTDPARTS_DEFAULT       "mtdparts=bab7xx-0:-(jffs2)"
 */
index bced118e38576d81cee6f301531c8c68f956da04..9934f29b7faaf62d346f94c433bb0486c92dc8da 100644 (file)
 #define CONFIG_SYS_FLASH_WRITE_TOUT    500     /* Flash Write Timeout (in ms)  */
 
 /* Dynamic MTD partition support */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM5200-0"
 #define MTDPARTS_DEFAULT       "mtdparts=TQM5200-0:640k(firmware),"    \
                                                "1408k(kernel),"        \
index fa9fc23823d7ee97ece27a13d5bcd95642f13350..39f41e6a2dc197fcb2ae69cb96a2566e4152064c 100644 (file)
  *
  */
 /* No command line, one static partition */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nand"
 #define CONFIG_JFFS2_PART_SIZE         0x00200000
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
  * Note: fake mtd_id used, no linux mtd map file
  */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nand0=catcenter"
 #define MTDPARTS_DEFAULT       "mtdparts=catcenter:2m(nand)"
 */
index daed9342b377f9c4999660cd1e441eafb1611960..160871b24e2e3449bd33398ca57d9c8a69553c4a 100644 (file)
@@ -230,7 +230,7 @@ ip=${ipaddr}:${serverip}${bootargs_end}; bootm 0x400000;\0"
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor1"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
@@ -242,7 +242,7 @@ ip=${ipaddr}:${serverip}${bootargs_end}; bootm 0x400000;\0"
  * Note: fake mtd_id's used, no linux mtd map file.
  */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor1=db64360-1"
 #define MTDPARTS_DEFAULT       "mtdparts=db64360-1:-(jffs2)"
 */
index 604fd45af7d9957351297cbff1a5a99a9258ea7f..06fd157ad22adb451bf92b5b6c1dfc66f2ccc06f 100644 (file)
@@ -168,7 +168,7 @@ ip=${ipaddr}:${serverip}${bootargs_end}; bootm 0x400000;\0"
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor1"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
@@ -180,7 +180,7 @@ ip=${ipaddr}:${serverip}${bootargs_end}; bootm 0x400000;\0"
  * Note: fake mtd_id's used, no linux mtd map file.
  */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor1=db64460-1"
 #define MTDPARTS_DEFAULT       "mtdparts=db64460-1:-(jffs2)"
 */
index 6fdc56600238bd0b67e2e562d64cc3e4c91286ea..db9c17df91372849c32d6ee81cd221cfc0d376fc 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         ""
 #define MTDPARTS_DEFAULT       ""
 */
index 1d031f1cde7308a9cdc6f92ee9fc0b29b72a179b..3bd270cdf2871ec3c8fe90c3e5a67ca931c42cd7 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         ""
 #define MTDPARTS_DEFAULT       ""
 */
index 79392668e07fba8af3f409ea320dfde0128e2401..d2aa8b92e47c59dfa5b7a264ff7edafdd0ab754c 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=elppc-0,nor1=elppc-1"
 #define MTDPARTS_DEFAULT       "mtdparts=elppc-0:-(jffs2),elppc-1:-(user)"
 */
index 08408e2c3128190ec733613265d0d83fb3c3823c..f152230da72eb2fa4f3894197fcc223fdfc201b0 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxL-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxL-0:256k(u-boot),"      \
index e5f3b606edf1b3a082aa95c046f79a9a265fb1d3..5eaed842bf73aea990ee61b012f6e155eb647cfa 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxL-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxL-0:256k(u-boot),"      \
index f14d9455d72ca62724dd2588d10a74157fddbc56..6e8a4b808543aa24d586922871bbfcc1e8a2d2c5 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         ""
 #define MTDPARTS_DEFAULT       ""
 */
index 8e7f9cdc140291ae09860709869893006e795e64..19a288c582045e42ceaddf822371d0f4b27ac347 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=mhpc-0"
 #define MTDPARTS_DEFAULT       "mtdparts=mhpc-0:-(jffs2)"
 */
index c58ce053fd1453ccb1e1c03c6ea470794baa1a95..a3869c8747bcb54bcc478b5ae56a23e136b941cd 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=mip405-0"
 #define MTDPARTS_DEFAULT       "mtdparts=mip405-0:-(jffs2)"
 */
index 190239732531335f3a19dfcc5806ff7b011624a8..5fcc1733bc38c35fad6a488dd1d701236a726f63 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00080000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=ml2-0"
 #define MTDPARTS_DEFAULT       "mtdparts=ml2-0:-@512k(jffs2)"
 */
index fe1cc17960aad7851734c8458919e7430b5dc41f..4fd86d3923f4a2350bca9b4a4fef0b09de830a93 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         ""
 #define MTDPARTS_DEFAULT       ""
 */
index 0b97f0ce666b188b417ff456e3cd562f785eaf2a..6343cfed1f265931572c52e6eae6f98e5ceb406f 100644 (file)
  */
 
 /* No command line, one static partition */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nand0"
 #define CONFIG_JFFS2_PART_SIZE         0x00400000
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=nc650-0,nand0=nc650-nand"
 
 #define MTDPARTS_DEFAULT       "mtdparts=nc650-0:1m(kernel1),1m(kernel2)," \
index 34fdba59c0ac1d909e2ece51928999c7a7e4cae7..724e8073981d4aee46a7bc86f4987433850245ba 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nand0"
 #define CONFIG_JFFS2_PART_SIZE         0x00100000
 #define CONFIG_JFFS2_PART_OFFSET       0x00200000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nand0=netta-nand"
 #define MTDPARTS_DEFAULT       "mtdparts=netta-nand:1m@2m(jffs2)"
 */
index d2eae1d7fad72fcbcf6a4e7af0ace755dde5accb..16baf8c9be79184c9b4271c939f393ce31c7260f 100644 (file)
  */
 
 /* No command line, one static partition */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nand0"
 #define CONFIG_JFFS2_PART_SIZE         0x00400000
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=PPChameleon-0,nand0=ppchameleonevb-nand"
 */
 
index bab44606da642b3217418372c66d61b960bc03de..830f4bc59b47ba55323f92fd1cd3f1288458a3c2 100644 (file)
  */
 /* No command line, one static partition
  * use all the space starting at offset 3MB*/
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00300000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=r360-0"
 #define MTDPARTS_DEFAULT       "mtdparts=r360-0:-@3m(user)"
 */
index 280175af1a464cc8076d87ce411edf1512263107..f36244d12c8b71a76f8a4539677d049a1ac62a79 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         ""
 #define MTDPARTS_DEFAULT       ""
 */
index 01d0d5fc3bdbb97129d1a337db1dcfa9e312030f..5b6f27186bf700312388cedf305abac340f2fa35 100644 (file)
  *
  */
 /* No command line, one static partition */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00100000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=rattler-0"
 #define MTDPARTS_DEFAULT       "mtdparts=rattler-0:-@1m(jffs2)"
 */
index b939cfa79f5d09d3a0a20adf9a4605bc9cc9df0e..e20527e4f9111eaa0a935bb8780d4ef3dccce003 100644 (file)
 #define CONFIG_JFFS2_DEV       "nand0"
 
 /* mtdparts command line support */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nand0=nand0"
 #define MTDPARTS_DEFAULT       "mtdparts=nand0:2M(u-boot),6M(kernel),-(jffs2)"
 
index 9857bf605ce8a7036b272d34b1fc26a451ef222f..cac04b4017a9beb6cc516e490d61424c29d23f93 100644 (file)
  *
  */
 /* No command line, one static partition */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 
 /*
 #define CONFIG_JFFS2_DEV               "nor0"
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=sixnet-0,nand0=sixnet-nand"
 #define MTDPARTS_DEFAULT       "mtdparts=sixnet-0:7680k@512k();sixnet-nand:2m(jffs2-nand)"
 */
index b42d3d944d9bbf2680ace213e5b464068c726175..92b4fa503efedda4ca4a79ad84ce84ee524092be 100644 (file)
                                           (= chip selects) */
 
 /* Dynamic MTD partition support */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM5200-0"
 #if defined(CONFIG_TQM5200_B)
 #define MTDPARTS_DEFAULT       "mtdparts=TQM5200-0:768k(firmware),"    \
index 6850eba15dd14f0a4875631d137830e46a444d1f..d374981abc468defb058433a53ca37fb18b7ab58 100644 (file)
 #endif
 
 /* Dynamic MTD partition support */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM5200-0"
 
 #ifdef CONFIG_STK52XX
index 8934d51bfad2493b21ed306294e335c1a3f6299a..87e5a650d223a4df5c146d1ce846a7b5733498a4 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxL-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxL-0:256k(u-boot),"      \
index fd4157343c0eba35c3b54d3f54c42fd85f31756c..f6664437d36e420a4d23498bdf5d41e3256e06cf 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxM-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxM-0:512k(u-boot),"      \
index e126dc38cb1ffb3e87ce4ead2507688bbd342d91..b74b4046a51a94d1c83d2a9d6002efebe77644cf 100644 (file)
@@ -537,7 +537,7 @@ extern int tqm834x_num_flash_banks;
  * JFFS2 partitions
  */
 /* mtdparts command line support */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM834x-0"
 
 /* default mtd partition table */
index 77eb5a96dccbf94ecd0e66cf52e74c0cf6a7084a..dc80b4746d4636fb960f9754061e9a7fc6ca1175 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxL-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxL-0:256k(u-boot),"      \
index bb8825b9e96f219a6c2150cbe0eb71e13914d6bb..22894432cbd278b36fd22c4a69ad9d1cb7ca5de7 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxM-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxM-0:512k(u-boot),"      \
index 2ccbaf8952a6c509851a0854eedb45140ae14597..999bdaadcb674a842502475c9445c9f9ed05b19b 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxL-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxL-0:256k(u-boot),"      \
index 8a651835839685a90030460f033cb935a30888fc..b54967dae781d169bd0e9bc1d54295325132a4fe 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxM-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxM-0:512k(u-boot),"      \
index 3b2272c231eaac5f9f4450faa879fb1a58482f31..72db26c7b13c3dce27901bc99f6c206869af2412 100644 (file)
 
 #define        CONFIG_JFFS2_NAND       1
 
-#ifdef CONFIG_JFFS2_CMDLINE
+#ifdef CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nand0=TQM85xx-nand"
 #define MTDPARTS_DEFAULT       "mtdparts=TQM85xx-nand:-"
 #else
 #define CONFIG_JFFS2_DEV       "nand0" /* NAND device jffs2 lives on   */
 #define CONFIG_JFFS2_PART_OFFSET 0     /* start of jffs2 partition     */
 #define CONFIG_JFFS2_PART_SIZE 0x200000 /* size of jffs2 partition     */
-#endif /* CONFIG_JFFS2_CMDLINE */
+#endif /* CONFIG_CMD_MTDPARTS */
 
 #endif /* CONFIG_NAND */
 
index 8bd1fe062a16066df7c89f14bed0ef0b2a49db1a..2e2a165b8a5f64187951c34c8b467f361ae3e582 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxL-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxL-0:256k(u-boot),"      \
index ad2c71ce03d9585c1c44b70b9235b5b4ae2c8ea1..1148f2e4efbcf5de5595a8beb89ff1334e3793f6 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxM-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxM-0:512k(u-boot),"      \
index 0a5180e4f36cac034cca2fb4261e17346ecbac98..577f982c5a312e614c32b6702935ef99f70fc175 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxL-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxL-0:256k(u-boot),"      \
index ee6980c81d06af4f10bba531eea3323e21474882..69070e64597fb2d1f562e2149065c77e56f136c0 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxM-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxM-0:512k(u-boot),"      \
index 421a2d86891b93bc38061379988091af5e8de79f..bb6861470ff849cfef939b2538573688c32dcce0 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxM-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxM-0:512k(u-boot),"      \
index 08c4ced1c9879ff0094397943988eb84a3d7434b..b73aaa817b4526724d36ccbda927301d3fcba38b 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor1=zuma-1,nor2=zuma-2"
 #define MTDPARTS_DEFAULT       "mtdparts=zuma-1:-(jffs2),zuma-2:-(user)"
 */
index dff47fc6a6cff12e1f76dec1a823ba2a02bea7d8..f83dd9c2434e04a671f907f20066efe1cffcfc32 100644 (file)
 #define CONFIG_ENV_ADDR                0x00020000
 
 #ifdef CONFIG_SYS_USE_UBI
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "onenand0=onenand"
 #define MTDPARTS_DEFAULT       "mtdparts=onenand:128k(bootloader),"    \
                                        "128k(params),"                 \
index ddcc6aad4657f16941b919c771dd6abacb852a21..54cf40d67fc52a9611ffedd15f55b169f5b08401 100644 (file)
 /*
  * MTD configuration
  */
-#define CONFIG_JFFS2_CMDLINE   1
+#define CONFIG_CMD_MTDPARTS    1
 #define MTDIDS_DEFAULT         "nor0=cm5200-0"
 #define MTDPARTS_DEFAULT       "mtdparts=cm5200-0:"                    \
                                        "384k(uboot),128k(env),"        \
index 4d65f6a44beb763edfde0191c31d436dc2d627f2..dc59df9c4421eea1706cd95e64851f8542c87692 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
  * Note: fake mtd_id's used, no linux mtd map file.
  */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=debris-0"
 #define MTDPARTS_DEFAULT       "mtdparts=debris-0:-(jffs2)"
 */
index 0581842ec22b74bd4ff0c1bc01e5ad33b96ec221..322a3ca41ac478a25079b97715273dc9cc0ba7b6 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=ep7312-0"
 #define MTDPARTS_DEFAULT       "mtdparts=ep7312-0:-(jffs2)"
 */
index d49d02f2872311ed05b9dfa532a717208292645a..3f4425abc8081caeb1ef10fb70fc58a92fa9fdbb 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         ""
 #define MTDPARTS_DEFAULT       ""
 */
index 58445674c355b2cbb1cd162d6bf53298c903f8b3..27c6e7d4a7ddecc14e557fa062aec15d3b155b0d 100644 (file)
@@ -37,7 +37,7 @@
 
 /* cmd config */
 #define CONFIG_CMD_JFFS2
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #undef CONFIG_CMD_NET
 
 /* sdram */
index 0fdcda230177282f76f037aff1e38e681ac11758..2dacfb6e074b0a7d615b7ee12ed56a4519d61fe3 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         ""
 #define MTDPARTS_DEFAULT       ""
 */
index 1dd89f90c7bd64aa328bee2368710c788f7048ed..944d06fbfc08a590b0639cd4a51e5d4d0c6dc115 100644 (file)
 
 
 /* Dynamic MTD partition support */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=idmr-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=idmr-0:128k(u-boot)," \
index bb3c02e72a2c32a2445a0ca01bc9cc97ae7d826d..a3d023f630f41fe4eb2eb1e2c831b1523eba6382 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00020000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=impA7 NOR Flash Bank #0,nor1=impA7 NOR Flash Bank #1"
 #define MTDPARTS_DEFAULT       "mtdparts=impA7 NOR Flash Bank #0:-(FileSystem1);impA7 NOR Flash Bank #1:-(FileSystem2)"
 */
index 6c150aed3995228d0089e9befe372a48af3b8b53..9ac6eec3b4519b8fe43a7e7c9c3ba1c9ec00c2f9 100644 (file)
 /*
  * JFFS2 partitions
  */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV       "nor0"
 
 #endif /* __CONFIG_H */
index 2dd9e92f8782116545f6d26b3f03c59e785dca8d..cbc0b9259a4c93cced3ba2ca2ba9e93d4aeb0cc5 100644 (file)
 /*
  * JFFS2 partitions
  */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV       "nor0"
 
 /* EET platform additions */
index a18ba801925fa4f0ec8395d9e89a5914485b1cf1..2129dfd804c90418140f17cb9dc2c640240b33c0 100644 (file)
  * JFFS2 partitions
  */
 /* No command line, one static partition, use all space on the device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor1"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=INCA-IP Bank 0"
 #define MTDPARTS_DEFAULT       "mtdparts=INCA-IP Bank 0:192k(uboot)," \
                                                        "64k(env)," \
index d9b155548a7a9772fdccb243521fc071b6d0fa5d..043ae2f364a270f49e91cff3a880856f8aca08b2 100644 (file)
 */
 
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=innokom-0"
 */
 
index ac18c8776dd68695bad2c93fc01f55a0f19dca95..aa117c8f7136c2cabdfe3eb27a8c88c99cbb7077 100644 (file)
 
 #if defined(CONFIG_CMD_JFFS2)
 /* JFFS2 partitions */
-#define CONFIG_JFFS2_CMDLINE   /* mtdparts command line support */
+#define CONFIG_CMD_MTDPARTS    /* mtdparts command line support */
 #define MTDIDS_DEFAULT         "nor0=ml401-0"
 
 /* default mtd partition table */
index c4f52868804aa855496ef9569f56497c929ffd79..27213a8d8dbeb26dd57ea6174196aa5f022eb91e 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00080000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=modnet50-0"
 #define MTDPARTS_DEFAULT       "mtdparts=modnet50-0:-@512k(jffs2)"
 */
index e6e3729a20dba92077005ed7e17076ab12784bcb..99a02cc2234f7d61bde3b563a6b16aa03d09e002 100644 (file)
 /*
  * MTD configuration
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=motionpro-0"
 #define MTDPARTS_DEFAULT       "mtdparts=motionpro-0:"                   \
                                        "13m(fs),2m(kernel),256k(uboot)," \
index aaa4e985220d68ab1ac3599293b0811f9334fefb..a19eb78409e4d7daf11672aaf321a97b6bfadea8 100644 (file)
  */
 /* No command line, one static partition, whole device */
 /*
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00050000
 
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=mx1fs2-0"
 
 #ifdef BUS32BIT_VERSION
index 1649f1fa85d01a52cf79484dac24e6238b3c99e8..c31c06acc42242a76fc4b623426b80939fe491f5 100644 (file)
 /*
  * JFFS2 partitions
  */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV       "nor0"
 
 #endif /* __CONFIG_H */
index 3b22e48d8dba474505525b98e630449d39fec7a7..0b38549dff0d8892a6e47ecd27ca6ee2c84a73e0 100644 (file)
 /*
  * partitions (mtdparts command line support)
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=omapflash.0,nand0=omapnand.0"
 #define MTDPARTS_DEFAULT       "mtdparts=" \
        "omapflash.0:8k@16k(env),8k(r_env),448k@576k(u-boot);" \
index 92df0b4fdc8c93ff81cec8af5ffd8ae064ccf6c2..983b5f25172a61a682c765655a8eafccfeca9ee4 100644 (file)
  * JFFS2 partitions
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor1"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor1=omap2420-1"
 #define MTDPARTS_DEFAULT       "mtdparts=omap2420-1:-(jffs2)"
 */
index ccc2625135f33a01b3a6dd74d9cd67f1b5696321..a67006aa2d663057566ddb9566fab90d17b32f36 100644 (file)
 /*
  * JFFS2 partitions
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=physmap-flash.0"
 #define MTDPARTS_DEFAULT       \
        "mtdparts=physmap-flash.0:256k(U-Boot),128k(env1),"     \
index 515b09789e73ca297113a6a9dc8ef4bafbefd336..5b68ef9875bfb742605652a859c0dbaeebe274de 100644 (file)
@@ -430,7 +430,7 @@ extern unsigned long offsetOfEnvironment;
 #define CONFIG_JFFS2_NAND 1                    /* jffs2 on nand support */
 
 /* No command line, one static partition */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nand0"
 #define CONFIG_JFFS2_PART_SIZE         0x01000000
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
index 82faca81003b2ce0f1c3ffbd6d2addfda9531739..960350c6c60b7c019377b76bee0083700681d694 100644 (file)
  * JFFS2 partitions
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 
 /* mtdparts command line support */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=SC520CDP Flash Bank #0"
 #define MTDPARTS_DEFAULT       "mtdparts=SC520CDP Flash Bank #0:-(jffs2)"
 */
index 36441696ad596856c6d7b852c7f2b55fcdba8d41..2445a341689628dfb51e64406a606ed93dae6f51 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=sc520_spunk-0"
 #define MTDPARTS_DEFAULT       "mtdparts=sc520_spunk-0:-(jffs2)"
 */
index a3f26773870c2f58f1c4be000f043228b7a98736..35f3e3a022317f93879647ca71877d615a28c920 100644 (file)
 #define CONFIG_SYS_FLASH_WRITE_TOUT    500     /* Flash Write Timeout (in ms)  */
 
 /* Dynamic MTD partition support */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM5200-0"
 #define MTDPARTS_DEFAULT       "mtdparts=TQM5200-0:640k(firmware),"    \
                                                "1408k(kernel),"        \
index 0a7a73d30c471acd44d4571fc8a3d10219d70e8c..8f13c35614caba7d0b3f7a9054cd3b1a7abf4c7c 100644 (file)
 #define        CONFIG_SYS_MONITOR_LEN          (256 << 10)
 
 /* Dynamic MTD partition support */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=0"
 
 /* production flash layout */
index a6b0f0daf06ba27c202ac89611822bd3a8299b2a..7f1670eafe7bcb58040842011e111dad0ef36663 100644 (file)
  *
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor1"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor1=v37-1"
 #define MTDPARTS_DEFAULT       "mtdparts=v37-1:-(jffs2)"
 */
index 391535ed2ce3399c4c3595dcfac7aaef4ed2c595..5371e2d7f619263d7e730c63eb0f8dfe30881e52 100644 (file)
@@ -286,7 +286,7 @@ int vct_gpio_get(int pin);
 #define        CONFIG_CMD_UBI
 #define        CONFIG_RBTREE
 #define CONFIG_MTD_PARTITIONS
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 
 #define MTDIDS_DEFAULT         "onenand0=onenand"
 #define MTDPARTS_DEFAULT       "mtdparts=onenand:128k(u-boot),"        \
index 7b61c82af3d3edd6d8f75f560f6ec6104bbd1091..021012d0f952aa615e74ce5d28b3f60fa421296d 100644 (file)
 /*-----------------------------------------------------------------------
  * Dynamic MTD partition support
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=TQM8xxL-0"
 
 #define MTDPARTS_DEFAULT       "mtdparts=TQM8xxL-0:256k(u-boot),"      \
index f4606102a99d881853bc480e6bf900611e69ac9e..cadd90633da5d3830020a7392e5dedb29598a078 100644 (file)
 /*
  * JFFS2 partitions (mtdparts command line support)
  */
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=omapflash.0"
 #define MTDPARTS_DEFAULT       "mtdparts=omapflash.0:256k(u-boot),64k(env),64k(r_env),16192k(data0),-(data1)"
 
index e7daa0771ecf4b6ad0292f2958f4773b0d303333..e3ea84b31592d7489c72ac7370cad9167c9b0c14 100644 (file)
@@ -41,7 +41,7 @@
 #define CONFIG_CMD_IRQ
 #define CONFIG_CMD_REGINFO
 #undef CONFIG_CMD_JFFS2
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #undef CONFIG_CMD_SPI
 #undef CONFIG_CMD_I2C
 #undef CONFIG_CMD_DTT
 #define        CONFIG_SYS_MAX_FLASH_BANKS      1
 #define        CONFIG_SYS_FLASH_PROTECTION
 #define CONFIG_CMD_JFFS2
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #else
 #define CONFIG_ENV_IS_NOWHERE
 #define CONFIG_SYS_NO_FLASH
index 6761438656eb2b69aeb3d0c91707dfe61b1c968c..5d13f9682e71b0498b05890cefdeec14513b4ffd 100644 (file)
@@ -62,7 +62,7 @@
  * JFFS2 partitions
  */
 /* No command line, one static partition, whole device */
-#undef CONFIG_JFFS2_CMDLINE
+#undef CONFIG_CMD_MTDPARTS
 #define CONFIG_JFFS2_DEV               "nor0"
 #define CONFIG_JFFS2_PART_SIZE         0xFFFFFFFF
 #define CONFIG_JFFS2_PART_OFFSET       0x00000000
@@ -70,7 +70,7 @@
 /* mtdparts command line support */
 /* Note: fake mtd_id used, no linux mtd map file */
 /*
-#define CONFIG_JFFS2_CMDLINE
+#define CONFIG_CMD_MTDPARTS
 #define MTDIDS_DEFAULT         "nor0=xsengine-0"
 #define MTDPARTS_DEFAULT       "mtdparts=xsengine-0:256k(uboot),1m(kernel1),8m(kernel2)"
 */