+// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2002
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*
* $Id: cmdlinepart.c,v 1.17 2004/11/26 11:18:47 lavinen Exp $
* Copyright 2002 SYSGO Real-Time Solutions GmbH
- *
- * SPDX-License-Identifier: GPL-2.0+
*/
/*
* mtdids=<idmap>[,<idmap>,...]
*
* <idmap> := <dev-id>=<mtd-id>
- * <dev-id> := 'nand'|'nor'|'onenand'<dev-num>
+ * <dev-id> := 'nand'|'nor'|'onenand'|'spi-nand'<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>...]
+ * 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)
*
* 1 NOR Flash, with 1 single writable partition:
* mtdids=nor0=edb7312-nor
- * mtdparts=mtdparts=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)
+ * mtdparts=[mtdparts=]edb7312-nor:256k(ARMboot)ro,-(root);edb7312-nand:-(home)
*
*/
#include <common.h>
#include <command.h>
+#include <env.h>
#include <malloc.h>
#include <jffs2/load_kernel.h>
#include <linux/list.h>
#include <linux/mtd/mtd.h>
#if defined(CONFIG_CMD_NAND)
-#include <linux/mtd/nand.h>
+#include <linux/mtd/rawnand.h>
#include <nand.h>
#endif
case 'G':
case 'g':
ret <<= 10;
+ /* Fallthrough */
case 'M':
case 'm':
ret <<= 10;
+ /* Fallthrough */
case 'K':
case 'k':
ret <<= 10;
(*retptr)++;
+ /* Fallthrough */
default:
break;
}
if (!mtd->numeraseregions) {
/*
- * Only one eraseregion (NAND, OneNAND or uniform NOR),
+ * Only one eraseregion (NAND, SPI-NAND, OneNAND or uniform NOR),
* checking for alignment is easy here
*/
offset = part->offset;
part->auto_name = 0;
} else {
/* auto generated name in form of size@offset */
- sprintf(part->name, "0x%08llx@0x%08llx", size, offset);
+ snprintf(part->name, name_len, "0x%08llx@0x%08llx", size, offset);
part->auto_name = 1;
}
return 1;
}
-#ifdef DEBUG
pend = strchr(p, ';');
-#endif
debug("dev type = %d (%s), dev num = %d, mtd-id = %s\n",
id->type, MTD_DEV_TYPE(id->type),
id->num, id->mtd_id);
debug("parsing partitions %.*s\n", (int)(pend ? pend - p : strlen(p)), p);
-
/* parse partitions */
num_parts = 0;
}
/**
- * Parse device id string <dev-id> := 'nand'|'nor'|'onenand'<dev-num>,
+ * Parse device id string <dev-id> := 'nand'|'nor'|'onenand'|'spi-nand'<dev-num>,
* return device type and number.
*
* @param id string describing device id
} else if (strncmp(p, "onenand", 7) == 0) {
*dev_type = MTD_DEV_TYPE_ONENAND;
p += 7;
+ } else if (strncmp(p, "spi-nand", 8) == 0) {
+ *dev_type = MTD_DEV_TYPE_SPINAND;
+ p += 8;
} else {
printf("incorrect device type in %s\n", id);
return 1;
return 0;
}
- strcpy(p, "mtdparts=");
- p += 9;
-
list_for_each(dentry, &devices) {
dev = list_entry(dentry, struct mtd_device, link);
if (!p)
p = mtdparts;
- if (strncmp(p, "mtdparts=", 9) != 0) {
- printf("mtdparts variable doesn't start with 'mtdparts='\n");
- return err;
- }
- p += 9;
+ /* Skip the useless prefix, if any */
+ if (strncmp(p, "mtdparts=", 9) == 0)
+ p += 9;
while (*p != '\0') {
err = 1;
while(p && (*p != '\0')) {
ret = 1;
- /* parse 'nor'|'nand'|'onenand'<dev-num> */
+ /* parse 'nor'|'nand'|'onenand'|'spi-nand'<dev-num> */
if (mtd_id_parse(p, &p, &type, &num) != 0)
break;
/* save it for later parsing, cannot rely on current partition pointer
* as 'partition' variable may be updated during init */
memset(tmp_parts, 0, sizeof(tmp_parts));
+ memset(tmp_ep, 0, sizeof(tmp_ep));
if (current_partition)
strncpy(tmp_ep, current_partition, PARTITION_MAXLEN);
"'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-id> := 'nand'|'nor'|'onenand'|'spi-nand'<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"