projects
/
oweals
/
u-boot.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rockchip: rk3328: add rock-pi-e dts file
[oweals/u-boot.git]
/
cmd
/
mtdparts.c
diff --git
a/cmd/mtdparts.c
b/cmd/mtdparts.c
index 9bc977450cf8910aae84c2b6c225c27f2e651402..5220142b9ab25d704229832d84fe46e1241ff391 100644
(file)
--- a/
cmd/mtdparts.c
+++ b/
cmd/mtdparts.c
@@
-1,3
+1,4
@@
+// SPDX-License-Identifier: GPL-2.0+
/*
* (C) Copyright 2002
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
/*
* (C) Copyright 2002
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
@@
-20,8
+21,6
@@
*
* $Id: cmdlinepart.c,v 1.17 2004/11/26 11:18:47 lavinen Exp $
* Copyright 2002 SYSGO Real-Time Solutions GmbH
*
* $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+
*/
/*
*/
/*
@@
-38,14
+37,14
@@
* mtdids=<idmap>[,<idmap>,...]
*
* <idmap> := <dev-id>=<mtd-id>
* 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
*
* <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)
*
* <mtd-def> := <mtd-id>:<part-def>[,<part-def>...]
* <mtd-id> := unique device tag used by linux kernel to find mtd device (mtd->name)
@@
-63,16
+62,18
@@
*
* 1 NOR Flash, with 1 single writable partition:
* mtdids=nor0=edb7312-nor
*
* 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
*
* 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 <common.h>
#include <command.h>
+#include <env.h>
+#include <log.h>
#include <malloc.h>
#include <jffs2/load_kernel.h>
#include <linux/list.h>
#include <malloc.h>
#include <jffs2/load_kernel.h>
#include <linux/list.h>
@@
-178,13
+179,16
@@
static u64 memsize_parse (const char *const ptr, const char **retptr)
case 'G':
case 'g':
ret <<= 10;
case 'G':
case 'g':
ret <<= 10;
+ /* Fallthrough */
case 'M':
case 'm':
ret <<= 10;
case 'M':
case 'm':
ret <<= 10;
+ /* Fallthrough */
case 'K':
case 'k':
ret <<= 10;
(*retptr)++;
case 'K':
case 'k':
ret <<= 10;
(*retptr)++;
+ /* Fallthrough */
default:
break;
}
default:
break;
}
@@
-337,7
+341,7
@@
static int part_validate_eraseblock(struct mtdids *id, struct part_info *part)
if (!mtd->numeraseregions) {
/*
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;
* checking for alignment is easy here
*/
offset = part->offset;
@@
-691,7
+695,7
@@
static int part_parse(const char *const partdef, const char **ret, struct part_i
part->auto_name = 0;
} else {
/* auto generated name in form of size@offset */
part->auto_name = 0;
} else {
/* auto generated name in form of size@offset */
- s
printf(part->name
, "0x%08llx@0x%08llx", size, offset);
+ s
nprintf(part->name, name_len
, "0x%08llx@0x%08llx", size, offset);
part->auto_name = 1;
}
part->auto_name = 1;
}
@@
-1028,7
+1032,7
@@
static struct mtdids* id_find_by_mtd_id(const char *mtd_id, unsigned int mtd_id_
}
/**
}
/**
- * 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
* return device type and number.
*
* @param id string describing device id
@@
-1052,6
+1056,9
@@
int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type,
} else if (strncmp(p, "onenand", 7) == 0) {
*dev_type = MTD_DEV_TYPE_ONENAND;
p += 7;
} 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;
} else {
printf("incorrect device type in %s\n", id);
return 1;
@@
-1094,9
+1101,6
@@
static int generate_mtdparts(char *buf, u32 buflen)
return 0;
}
return 0;
}
- strcpy(p, "mtdparts=");
- p += 9;
-
list_for_each(dentry, &devices) {
dev = list_entry(dentry, struct mtd_device, link);
list_for_each(dentry, &devices) {
dev = list_entry(dentry, struct mtd_device, link);
@@
-1230,11
+1234,11
@@
static uint64_t net_part_size(struct mtd_info *mtd, struct part_info *part)
{
uint64_t i, net_size = 0;
{
uint64_t i, net_size = 0;
- if (!mtd->block_isbad)
+ if (!mtd->
_
block_isbad)
return part->size;
for (i = 0; i < part->size; i += mtd->erasesize) {
return part->size;
for (i = 0; i < part->size; i += mtd->erasesize) {
- if (!mtd->block_isbad(mtd, part->offset + i))
+ if (!mtd->
_
block_isbad(mtd, part->offset + i))
net_size += mtd->erasesize;
}
net_size += mtd->erasesize;
}
@@
-1271,7
+1275,7
@@
static void print_partition_table(void)
part = list_entry(pentry, struct part_info, link);
net_size = net_part_size(mtd, part);
size_note = part->size == net_size ? " " : " (!)";
part = list_entry(pentry, struct part_info, link);
net_size = net_part_size(mtd, part);
size_note = part->size == net_size ? " " : " (!)";
- printf("%2d: %-20s0x%08
x\t0x%08x%s\t0x%08
x\t%d\n",
+ printf("%2d: %-20s0x%08
llx\t0x%08x%s\t0x%08ll
x\t%d\n",
part_num, part->name, part->size,
net_size, size_note, part->offset,
part->mask_flags);
part_num, part->name, part->size,
net_size, size_note, part->offset,
part->mask_flags);
@@
-1567,11
+1571,9
@@
static int parse_mtdparts(const char *const mtdparts)
if (!p)
p = mtdparts;
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 != '\0') {
err = 1;
@@
-1634,7
+1636,7
@@
static int parse_mtdids(const char *const ids)
while(p && (*p != '\0')) {
ret = 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;
if (mtd_id_parse(p, &p, &type, &num) != 0)
break;
@@
-1914,7
+1916,8
@@
static struct part_info* mtd_part_info(struct mtd_device *dev, unsigned int part
* @param argv arguments list
* @return 0 on success, 1 otherwise
*/
* @param argv arguments list
* @return 0 on success, 1 otherwise
*/
-static int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+static int do_chpart(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
{
/* command line only */
struct mtd_device *dev;
{
/* command line only */
struct mtd_device *dev;
@@
-1952,8
+1955,8
@@
static int do_chpart(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
* @param argv arguments list
* @return 0 on success, 1 otherwise
*/
* @param argv arguments list
* @return 0 on success, 1 otherwise
*/
-static int do_mtdparts(
cmd_tbl_t
*cmdtp, int flag, int argc,
- char *
const argv[])
+static int do_mtdparts(
struct cmd_tbl
*cmdtp, int flag, int argc,
+ char *const argv[])
{
if (argc == 2) {
if (strcmp(argv[1], "default") == 0) {
{
if (argc == 2) {
if (strcmp(argv[1], "default") == 0) {
@@
-2110,7
+2113,7
@@
static char mtdparts_help_text[] =
"'mtdids' - linux kernel mtd device id <-> u-boot device id mapping\n\n"
"mtdids=<idmap>[,<idmap>,...]\n\n"
"<idmap> := <dev-id>=<mtd-id>\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-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"
"<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"