aboutsummaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2023-10-02 10:55:44 -0400
committerTom Rini <trini@konsulko.com>2023-10-02 10:55:44 -0400
commitac897385bbfa30cfdfb62ccf24acfcd4b274b2ff (patch)
treeae567980737beb24ca24e2ee8cfeaf6eb9e26e3f /cmd
parent4459ed60cb1e0562bc5b40405e2b4b9bbf766d57 (diff)
parente29b932aa07fa0226d325b35d96cd4eea0370129 (diff)
downloadu-boot-ac897385bbfa30cfdfb62ccf24acfcd4b274b2ff.zip
u-boot-ac897385bbfa30cfdfb62ccf24acfcd4b274b2ff.tar.gz
u-boot-ac897385bbfa30cfdfb62ccf24acfcd4b274b2ff.tar.bz2
Merge branch 'next'
Signed-off-by: Tom Rini <trini@konsulko.com>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/Kconfig20
-rw-r--r--cmd/adc.c1
-rw-r--r--cmd/blkcache.c13
-rw-r--r--cmd/bootflow.c49
-rw-r--r--cmd/bootm.c14
-rw-r--r--cmd/cedit.c209
-rw-r--r--cmd/date.c8
-rw-r--r--cmd/dm.c48
-rw-r--r--cmd/fastboot.c8
-rw-r--r--cmd/gpt.c208
-rw-r--r--cmd/i2c.c14
-rw-r--r--cmd/mux.c2
-rw-r--r--cmd/nvedit.c12
-rw-r--r--cmd/nvedit_efi.c2
-rw-r--r--cmd/onenand.c7
-rw-r--r--cmd/pxe.c17
-rw-r--r--cmd/regulator.c1
-rw-r--r--cmd/rockusb.c7
-rw-r--r--cmd/setexpr.c4
-rw-r--r--cmd/sf.c2
-rw-r--r--cmd/thordown.c25
-rw-r--r--cmd/tpm_test.c5
-rw-r--r--cmd/usb_gadget_sdp.c16
-rw-r--r--cmd/usb_mass_storage.c11
24 files changed, 531 insertions, 172 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig
index 43ca10f..6470b13 100644
--- a/cmd/Kconfig
+++ b/cmd/Kconfig
@@ -500,11 +500,6 @@ config CMD_XIMG
help
Extract a part of a multi-image.
-config CMD_XXD
- bool "xxd"
- help
- Print file as hexdump to standard output
-
config CMD_SPL
bool "spl export - Export boot information for Falcon boot"
depends on SPL
@@ -517,7 +512,7 @@ config CMD_SPL
config CMD_SPL_NAND_OFS
hex "Offset of OS args or dtb for Falcon-mode NAND boot"
depends on CMD_SPL && (TPL_NAND_SUPPORT || SPL_NAND_SUPPORT)
- default 0
+ default 0x0
help
This provides the offset of the command line arguments for Linux
when booting from NAND in Falcon mode. See doc/README.falcon
@@ -527,7 +522,7 @@ config CMD_SPL_NAND_OFS
config CMD_SPL_NOR_OFS
hex "Offset of OS args or dtb for Falcon-mode NOR boot"
depends on CMD_SPL && SPL_NOR_SUPPORT
- default 0
+ default 0x0
help
This provides the offset of the command line arguments or dtb for
Linux when booting from NOR in Falcon mode.
@@ -544,6 +539,8 @@ config CMD_SPL_WRITE_SIZE
config CMD_THOR_DOWNLOAD
bool "thor - TIZEN 'thor' download"
select DFU
+ select USB_FUNCTION_THOR
+ depends on USB_GADGET_DOWNLOAD
help
Implements the 'thor' download protocol. This is a way of
downloading a software update over USB from an attached host.
@@ -1524,7 +1521,7 @@ config DEFAULT_SPI_BUS
config DEFAULT_SPI_MODE
hex "default spi mode used by sspi command (see include/spi.h)"
depends on CMD_SPI
- default 0
+ default 0x0
config CMD_TEMPERATURE
bool "temperature - display the temperature from thermal sensors"
@@ -1666,6 +1663,11 @@ config CMD_SETEXPR_FMT
Evaluate format string expression and store result in an environment
variable.
+config CMD_XXD
+ bool "xxd"
+ help
+ Print file as hexdump to standard output
+
endmenu
menu "Android support commands"
@@ -1815,7 +1817,7 @@ config BOOTP_PXE_CLIENTARCH
depends on BOOTP_PXE
default 0x16 if ARM64
default 0x15 if ARM
- default 0 if X86
+ default 0x0 if X86
config BOOTP_VCI_STRING
string
diff --git a/cmd/adc.c b/cmd/adc.c
index a739d9e..4cb18b6 100644
--- a/cmd/adc.c
+++ b/cmd/adc.c
@@ -7,6 +7,7 @@
#include <command.h>
#include <dm.h>
#include <adc.h>
+#include <linux/printk.h>
static int do_adc_list(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
diff --git a/cmd/blkcache.c b/cmd/blkcache.c
index 47ea1ec..1456654 100644
--- a/cmd/blkcache.c
+++ b/cmd/blkcache.c
@@ -46,24 +46,11 @@ static struct cmd_tbl cmd_blkc_sub[] = {
U_BOOT_CMD_MKENT(configure, 3, 0, blkc_configure, "", ""),
};
-static __maybe_unused void blkc_reloc(void)
-{
- static int relocated;
-
- if (!relocated) {
- fixup_cmdtable(cmd_blkc_sub, ARRAY_SIZE(cmd_blkc_sub));
- relocated = 1;
- };
-}
-
static int do_blkcache(struct cmd_tbl *cmdtp, int flag,
int argc, char *const argv[])
{
struct cmd_tbl *c;
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
- blkc_reloc();
-#endif
if (argc < 2)
return CMD_RET_USAGE;
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index c0aa4f8..300ad3a 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -9,6 +9,7 @@
#include <common.h>
#include <bootdev.h>
#include <bootflow.h>
+#include <bootm.h>
#include <bootstd.h>
#include <command.h>
#include <console.h>
@@ -70,7 +71,7 @@ static void show_bootflow(int index, struct bootflow *bflow, bool errors)
printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index,
bflow->method->name, bootflow_state_get_name(bflow->state),
bflow->dev ? dev_get_uclass_name(dev_get_parent(bflow->dev)) :
- "(none)", bflow->part, bflow->name, bflow->fname);
+ "(none)", bflow->part, bflow->name, bflow->fname ?: "");
if (errors)
report_bootflow_err(bflow, bflow->err);
}
@@ -303,11 +304,14 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,
{
struct bootstd_priv *std;
struct bootflow *bflow;
+ bool x86_setup = false;
bool dump = false;
int ret;
- if (argc > 1 && *argv[1] == '-')
+ if (argc > 1 && *argv[1] == '-') {
dump = strchr(argv[1], 'd');
+ x86_setup = strchr(argv[1], 's');
+ }
ret = bootstd_get_priv(&std);
if (ret)
@@ -319,6 +323,12 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,
}
bflow = std->cur_bootflow;
+ if (IS_ENABLED(CONFIG_X86) && x86_setup) {
+ zimage_dump(bflow->x86_setup, false);
+
+ return 0;
+ }
+
printf("Name: %s\n", bflow->name);
printf("Device: %s\n", bflow->dev->name);
printf("Block dev: %s\n", bflow->blk ? bflow->blk->name : "(none)");
@@ -369,6 +379,35 @@ static int do_bootflow_info(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
+static int do_bootflow_read(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct bootstd_priv *std;
+ struct bootflow *bflow;
+ int ret;
+
+ ret = bootstd_get_priv(&std);
+ if (ret)
+ return CMD_RET_FAILURE;
+
+ /*
+ * Require a current bootflow. Users can use 'bootflow scan -b' to
+ * automatically scan and boot, if needed.
+ */
+ if (!std->cur_bootflow) {
+ printf("No bootflow selected\n");
+ return CMD_RET_FAILURE;
+ }
+ bflow = std->cur_bootflow;
+ ret = bootflow_read_all(bflow);
+ if (ret) {
+ printf("Failed: err=%dE\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ return 0;
+}
+
static int do_bootflow_boot(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -508,8 +547,9 @@ static char bootflow_help_text[] =
"scan [-abeGl] [bdev] - scan for valid bootflows (-l list, -a all, -e errors, -b boot, -G no global)\n"
"bootflow list [-e] - list scanned bootflows (-e errors)\n"
"bootflow select [<num>|<name>] - select a bootflow\n"
- "bootflow info [-d] - show info on current bootflow (-d dump bootflow)\n"
- "bootflow boot - boot current bootflow (or first available if none selected)\n"
+ "bootflow info [-ds] - show info on current bootflow (-d dump bootflow)\n"
+ "bootflow read - read all current-bootflow files\n"
+ "bootflow boot - boot current bootflow\n"
"bootflow menu [-t] - show a menu of available bootflows\n"
"bootflow cmdline [set|get|clear|delete|auto] <param> [<value>] - update cmdline";
#else
@@ -523,6 +563,7 @@ U_BOOT_CMD_WITH_SUBCMDS(bootflow, "Boot flows", bootflow_help_text,
U_BOOT_SUBCMD_MKENT(list, 2, 1, do_bootflow_list),
U_BOOT_SUBCMD_MKENT(select, 2, 1, do_bootflow_select),
U_BOOT_SUBCMD_MKENT(info, 2, 1, do_bootflow_info),
+ U_BOOT_SUBCMD_MKENT(read, 1, 1, do_bootflow_read),
U_BOOT_SUBCMD_MKENT(boot, 1, 1, do_bootflow_boot),
U_BOOT_SUBCMD_MKENT(menu, 2, 1, do_bootflow_menu),
U_BOOT_SUBCMD_MKENT(cmdline, 4, 1, do_bootflow_cmdline),
diff --git a/cmd/bootm.c b/cmd/bootm.c
index 37c2af9..7968415 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -123,20 +123,6 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
int states;
int ret;
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
- static int relocated = 0;
-
- if (!relocated) {
- int i;
-
- /* relocate names of sub-command table */
- for (i = 0; i < ARRAY_SIZE(cmd_bootm_sub); i++)
- cmd_bootm_sub[i].name += gd->reloc_off;
-
- relocated = 1;
- }
-#endif
-
/* determine if we have a sub command */
argc--; argv++;
if (argc > 0) {
diff --git a/cmd/cedit.c b/cmd/cedit.c
index 0cae304..2ff284f 100644
--- a/cmd/cedit.c
+++ b/cmd/cedit.c
@@ -7,14 +7,29 @@
*/
#include <common.h>
+#include <abuf.h>
+#include <cedit.h>
#include <command.h>
+#include <dm.h>
#include <expo.h>
#include <fs.h>
+#include <malloc.h>
+#include <mapmem.h>
#include <dm/ofnode.h>
#include <linux/sizes.h>
struct expo *cur_exp;
+static int check_cur_expo(void)
+{
+ if (!cur_exp) {
+ printf("No expo loaded\n");
+ return -ENOENT;
+ }
+
+ return 0;
+}
+
static int do_cedit_load(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
@@ -53,18 +68,192 @@ static int do_cedit_load(struct cmd_tbl *cmdtp, int flag, int argc,
return 0;
}
+static int do_cedit_write_fdt(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ const char *fname;
+ struct abuf buf;
+ loff_t bytes;
+ int ret;
+
+ if (argc < 4)
+ return CMD_RET_USAGE;
+ fname = argv[3];
+
+ if (check_cur_expo())
+ return CMD_RET_FAILURE;
+
+ ret = cedit_write_settings(cur_exp, &buf);
+ if (ret) {
+ printf("Failed to write settings: %dE\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ if (fs_set_blk_dev(argv[1], argv[2], FS_TYPE_ANY))
+ return CMD_RET_FAILURE;
+
+ ret = fs_write(fname, map_to_sysmem(abuf_data(&buf)), 0,
+ abuf_size(&buf), &bytes);
+ if (ret)
+ return CMD_RET_FAILURE;
+
+ return 0;
+}
+
+static int do_cedit_read_fdt(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ const char *fname;
+ void *buf;
+ oftree tree;
+ ulong size;
+ int ret;
+
+ if (argc < 4)
+ return CMD_RET_USAGE;
+ fname = argv[3];
+
+ ret = fs_load_alloc(argv[1], argv[2], argv[3], SZ_1M, 0, &buf, &size);
+ if (ret) {
+ printf("File not found\n");
+ return CMD_RET_FAILURE;
+ }
+
+ tree = oftree_from_fdt(buf);
+ if (!oftree_valid(tree)) {
+ free(buf);
+ printf("Cannot create oftree\n");
+ return CMD_RET_FAILURE;
+ }
+
+ ret = cedit_read_settings(cur_exp, tree);
+ oftree_dispose(tree);
+ free(buf);
+ if (ret) {
+ printf("Failed to read settings: %dE\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ return 0;
+}
+
+static int do_cedit_write_env(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ bool verbose;
+ int ret;
+
+ if (check_cur_expo())
+ return CMD_RET_FAILURE;
+
+ verbose = argc > 1 && !strcmp(argv[1], "-v");
+
+ ret = cedit_write_settings_env(cur_exp, verbose);
+ if (ret) {
+ printf("Failed to write settings to environment: %dE\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ return 0;
+}
+
+static int do_cedit_read_env(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ bool verbose;
+ int ret;
+
+ if (check_cur_expo())
+ return CMD_RET_FAILURE;
+
+ verbose = argc > 1 && !strcmp(argv[1], "-v");
+
+ ret = cedit_read_settings_env(cur_exp, verbose);
+ if (ret) {
+ printf("Failed to read settings from environment: %dE\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ return 0;
+}
+
+static int do_cedit_write_cmos(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct udevice *dev;
+ bool verbose = false;
+ int ret;
+
+ if (check_cur_expo())
+ return CMD_RET_FAILURE;
+
+ if (argc > 1 && !strcmp(argv[1], "-v")) {
+ verbose = true;
+ argc--;
+ argv++;
+ }
+
+ if (argc > 1)
+ ret = uclass_get_device_by_name(UCLASS_RTC, argv[1], &dev);
+ else
+ ret = uclass_first_device_err(UCLASS_RTC, &dev);
+ if (ret) {
+ printf("Failed to get RTC device: %dE\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ if (cedit_write_settings_cmos(cur_exp, dev, verbose)) {
+ printf("Failed to write settings to CMOS\n");
+ return CMD_RET_FAILURE;
+ }
+
+ return 0;
+}
+
+static int do_cedit_read_cmos(struct cmd_tbl *cmdtp, int flag, int argc,
+ char *const argv[])
+{
+ struct udevice *dev;
+ bool verbose = false;
+ int ret;
+
+ if (check_cur_expo())
+ return CMD_RET_FAILURE;
+
+ if (argc > 1 && !strcmp(argv[1], "-v")) {
+ verbose = true;
+ argc--;
+ argv++;
+ }
+
+ if (argc > 1)
+ ret = uclass_get_device_by_name(UCLASS_RTC, argv[1], &dev);
+ else
+ ret = uclass_first_device_err(UCLASS_RTC, &dev);
+ if (ret) {
+ printf("Failed to get RTC device: %dE\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ ret = cedit_read_settings_cmos(cur_exp, dev, verbose);
+ if (ret) {
+ printf("Failed to read settings from CMOS: %dE\n", ret);
+ return CMD_RET_FAILURE;
+ }
+
+ return 0;
+}
+
static int do_cedit_run(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
ofnode node;
int ret;
- if (!cur_exp) {
- printf("No expo loaded\n");
+ if (check_cur_expo())
return CMD_RET_FAILURE;
- }
- node = ofnode_path("/cedit-theme");
+ node = ofnode_path("/bootstd/cedit-theme");
if (ofnode_valid(node)) {
ret = expo_apply_theme(cur_exp, node);
if (ret)
@@ -84,10 +273,22 @@ static int do_cedit_run(struct cmd_tbl *cmdtp, int flag, int argc,
#ifdef CONFIG_SYS_LONGHELP
static char cedit_help_text[] =
"load <interface> <dev[:part]> <filename> - load config editor\n"
+ "cedit read_fdt <i/f> <dev[:part]> <filename> - read settings\n"
+ "cedit write_fdt <i/f> <dev[:part]> <filename> - write settings\n"
+ "cedit read_env [-v] - read settings from env vars\n"
+ "cedit write_env [-v] - write settings to env vars\n"
+ "cedit read_cmos [-v] [dev] - read settings from CMOS RAM\n"
+ "cedit write_cmos [-v] [dev] - write settings to CMOS RAM\n"
"cedit run - run config editor";
#endif /* CONFIG_SYS_LONGHELP */
U_BOOT_CMD_WITH_SUBCMDS(cedit, "Configuration editor", cedit_help_text,
U_BOOT_SUBCMD_MKENT(load, 5, 1, do_cedit_load),
+ U_BOOT_SUBCMD_MKENT(read_fdt, 5, 1, do_cedit_read_fdt),
+ U_BOOT_SUBCMD_MKENT(write_fdt, 5, 1, do_cedit_write_fdt),
+ U_BOOT_SUBCMD_MKENT(read_env, 2, 1, do_cedit_read_env),
+ U_BOOT_SUBCMD_MKENT(write_env, 2, 1, do_cedit_write_env),
+ U_BOOT_SUBCMD_MKENT(read_cmos, 2, 1, do_cedit_read_cmos),
+ U_BOOT_SUBCMD_MKENT(write_cmos, 2, 1, do_cedit_write_cmos),
U_BOOT_SUBCMD_MKENT(run, 1, 1, do_cedit_run),
);
diff --git a/cmd/date.c b/cmd/date.c
index fe9c8c6..4f98b47 100644
--- a/cmd/date.c
+++ b/cmd/date.c
@@ -20,12 +20,6 @@ static const char * const weekdays[] = {
"Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur",
};
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-#define RELOC(a) ((typeof(a))((unsigned long)(a) + gd->reloc_off))
-#else
-#define RELOC(a) a
-#endif
-
int mk_date (const char *, struct rtc_time *);
static struct rtc_time default_tm = { 0, 0, 0, 1, 1, 2000, 6, 0, 0 };
@@ -113,7 +107,7 @@ static int do_date(struct cmd_tbl *cmdtp, int flag, int argc,
printf ("Date: %4d-%02d-%02d (%sday) Time: %2d:%02d:%02d\n",
tm.tm_year, tm.tm_mon, tm.tm_mday,
(tm.tm_wday<0 || tm.tm_wday>6) ?
- "unknown " : RELOC(weekdays[tm.tm_wday]),
+ "unknown " : weekdays[tm.tm_wday],
tm.tm_hour, tm.tm_min, tm.tm_sec);
break;
diff --git a/cmd/dm.c b/cmd/dm.c
index 3263547..1aa86aa 100644
--- a/cmd/dm.c
+++ b/cmd/dm.c
@@ -59,11 +59,26 @@ static int do_dm_dump_static_driver_info(struct cmd_tbl *cmdtp, int flag,
static int do_dm_dump_tree(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- bool sort;
-
- sort = argc > 1 && !strcmp(argv[1], "-s");
-
- dm_dump_tree(sort);
+ bool extended = false, sort = false;
+ char *device = NULL;
+
+ for (; argc > 1; argc--, argv++) {
+ if (argv[1][0] != '-')
+ break;
+
+ if (!strcmp(argv[1], "-e")) {
+ extended = true;
+ } else if (!strcmp(argv[1], "-s")) {
+ sort = true;
+ } else {
+ printf("Unknown parameter: %s\n", argv[1]);
+ return 0;
+ }
+ }
+ if (argc > 1)
+ device = argv[1];
+
+ dm_dump_tree(device, extended, sort);
return 0;
}
@@ -71,7 +86,20 @@ static int do_dm_dump_tree(struct cmd_tbl *cmdtp, int flag, int argc,
static int do_dm_dump_uclass(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- dm_dump_uclass();
+ bool extended = false;
+ char *uclass = NULL;
+
+ if (argc > 1) {
+ if (!strcmp(argv[1], "-e")) {
+ extended = true;
+ argc--;
+ argv++;
+ }
+ if (argc > 1)
+ uclass = argv[1];
+ }
+
+ dm_dump_uclass(uclass, extended);
return 0;
}
@@ -91,8 +119,8 @@ static char dm_help_text[] =
"dm drivers Dump list of drivers with uclass and instances\n"
DM_MEM_HELP
"dm static Dump list of drivers with static platform data\n"
- "dm tree [-s] Dump tree of driver model devices (-s=sort)\n"
- "dm uclass Dump list of instances for each uclass"
+ "dm tree [-s][-e][name] Dump tree of driver model devices (-s=sort)\n"
+ "dm uclass [-e][name] Dump list of instances for each uclass"
;
#endif
@@ -102,5 +130,5 @@ U_BOOT_CMD_WITH_SUBCMDS(dm, "Driver model low level access", dm_help_text,
U_BOOT_SUBCMD_MKENT(drivers, 1, 1, do_dm_dump_drivers),
DM_MEM
U_BOOT_SUBCMD_MKENT(static, 1, 1, do_dm_dump_static_driver_info),
- U_BOOT_SUBCMD_MKENT(tree, 2, 1, do_dm_dump_tree),
- U_BOOT_SUBCMD_MKENT(uclass, 1, 1, do_dm_dump_uclass));
+ U_BOOT_SUBCMD_MKENT(tree, 4, 1, do_dm_dump_tree),
+ U_BOOT_SUBCMD_MKENT(uclass, 3, 1, do_dm_dump_uclass));
diff --git a/cmd/fastboot.c b/cmd/fastboot.c
index 3d5ff95..c3c1923 100644
--- a/cmd/fastboot.c
+++ b/cmd/fastboot.c
@@ -14,6 +14,7 @@
#include <net.h>
#include <usb.h>
#include <watchdog.h>
+#include <linux/printk.h>
#include <linux/stringify.h>
static int do_fastboot_udp(int argc, char *const argv[],
@@ -61,6 +62,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
{
int controller_index;
char *usb_controller;
+ struct udevice *udc;
char *endp;
int ret;
@@ -79,7 +81,7 @@ static int do_fastboot_usb(int argc, char *const argv[],
return CMD_RET_FAILURE;
}
- ret = usb_gadget_initialize(controller_index);
+ ret = udc_device_get_by_index(controller_index, &udc);
if (ret) {
pr_err("USB init failed: %d\n", ret);
return CMD_RET_FAILURE;
@@ -103,13 +105,13 @@ static int do_fastboot_usb(int argc, char *const argv[],
if (ctrlc())
break;
schedule();
- usb_gadget_handle_interrupts(controller_index);
+ dm_usb_gadget_handle_interrupts(udc);
}
ret = CMD_RET_SUCCESS;
exit:
- usb_gadget_release(controller_index);
+ udc_device_put(udc);
g_dnl_unregister();
g_dnl_clear_detach();
diff --git a/cmd/gpt.c b/cmd/gpt.c
index fe9e066..d7e9652 100644
--- a/cmd/gpt.c
+++ b/cmd/gpt.c
@@ -162,22 +162,31 @@ static bool found_key(const char *str, const char *key)
return result;
}
+/**
+ * calc_parts_list_len() - get size of partition table description
+ *
+ * @numparts: number of partitions
+ * Return: string size including terminating NUL
+ */
static int calc_parts_list_len(int numparts)
{
- int partlistlen = UUID_STR_LEN + 1 + strlen("uuid_disk=");
- /* for the comma */
- partlistlen++;
-
- /* per-partition additions; numparts starts at 1, so this should be correct */
- partlistlen += numparts * (strlen("name=,") + PART_NAME_LEN + 1);
+ /* number of hexadecimal digits of the lbaint_t representation */
+ const int lbaint_size = 2 * sizeof(lbaint_t);
+ int partlistlen;
+
+ /* media description including terminating NUL */
+ partlistlen = strlen("uuid_disk=;") + UUID_STR_LEN + 1;
+ /* per-partition descriptions; numparts */
+ partlistlen += numparts * (strlen("name=,") + PART_NAME_LEN);
/* see part.h for definition of struct disk_partition */
- partlistlen += numparts * (strlen("start=MiB,") + sizeof(lbaint_t) + 1);
- partlistlen += numparts * (strlen("size=MiB,") + sizeof(lbaint_t) + 1);
- partlistlen += numparts * (strlen("uuid=;") + UUID_STR_LEN + 1);
- /* for the terminating null */
- partlistlen++;
- debug("Length of partitions_list is %d for %d partitions\n", partlistlen,
- numparts);
+ partlistlen += numparts * (strlen("start=0x,") + lbaint_size);
+ partlistlen += numparts * (strlen("size=0x,") + lbaint_size);
+ if (IS_ENABLED(CONFIG_PARTITION_UUIDS))
+ partlistlen += numparts * (strlen("uuid=,") + UUID_STR_LEN);
+ if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))
+ partlistlen += numparts * (strlen("type=;") + UUID_STR_LEN);
+ debug("Length of partitions_list is %d for %d partitions\n",
+ partlistlen, numparts);
return partlistlen;
}
@@ -211,12 +220,12 @@ static struct disk_part *allocate_disk_part(struct disk_partition *info,
PART_TYPE_LEN);
newpart->gpt_part_info.type[PART_TYPE_LEN - 1] = '\0';
newpart->gpt_part_info.bootable = info->bootable;
-#ifdef CONFIG_PARTITION_UUIDS
- strncpy(newpart->gpt_part_info.uuid, (const char *)info->uuid,
- UUID_STR_LEN);
- /* UUID_STR_LEN is correct, as uuid[]'s length is UUID_STR_LEN+1 chars */
- newpart->gpt_part_info.uuid[UUID_STR_LEN] = '\0';
-#endif
+ if (IS_ENABLED(CONFIG_PARTITION_UUIDS))
+ disk_partition_set_uuid(&newpart->gpt_part_info,
+ disk_partition_uuid(info));
+ if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))
+ disk_partition_set_type_guid(&newpart->gpt_part_info,
+ disk_partition_type_guid(info));
newpart->partnum = partnum;
return newpart;
@@ -252,9 +261,12 @@ static void print_gpt_info(void)
curr->gpt_part_info.name);
printf("Type %s, bootable %d\n", curr->gpt_part_info.type,
curr->gpt_part_info.bootable & PART_BOOTABLE);
-#ifdef CONFIG_PARTITION_UUIDS
- printf("UUID %s\n", curr->gpt_part_info.uuid);
-#endif
+ if (CONFIG_IS_ENABLED(PARTITION_UUIDS))
+ printf("UUID %s\n",
+ disk_partition_uuid(&curr->gpt_part_info));
+ if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID))
+ printf("Type GUID %s\n",
+ disk_partition_type_guid(&curr->gpt_part_info));
printf("\n");
}
}
@@ -299,9 +311,20 @@ static int create_gpt_partitions_list(int numparts, const char *guid,
curr->gpt_part_info.blksz);
strncat(partitions_list, partstr, PART_NAME_LEN + 1);
- strcat(partitions_list, ",uuid=");
- strncat(partitions_list, curr->gpt_part_info.uuid,
- UUID_STR_LEN + 1);
+ if (IS_ENABLED(CONFIG_PARTITION_TYPE_GUID)) {
+ strcat(partitions_list, ",type=");
+ strncat(partitions_list,
+ disk_partition_type_guid(&curr->gpt_part_info),
+ UUID_STR_LEN + 1);
+ }
+ if (CONFIG_IS_ENABLED(PARTITION_UUIDS)) {
+ strcat(partitions_list, ",uuid=");
+ strncat(partitions_list,
+ disk_partition_uuid(&curr->gpt_part_info),
+ UUID_STR_LEN + 1);
+ }
+ if (curr->gpt_part_info.bootable & PART_BOOTABLE)
+ strcat(partitions_list, ",bootable");
strcat(partitions_list, ";");
}
return 0;
@@ -725,7 +748,7 @@ static int gpt_enumerate(struct blk_desc *desc)
* gpt_setenv_part_variables() - setup partition environmental variables
*
* Setup the gpt_partition_name, gpt_partition_entry, gpt_partition_addr
- * and gpt_partition_size environment variables.
+ * and gpt_partition_size, gpt_partition_bootable environment variables.
*
* @pinfo: pointer to disk partition
* @i: partition entry
@@ -752,6 +775,10 @@ static int gpt_setenv_part_variables(struct disk_partition *pinfo, int i)
if (ret)
goto fail;
+ ret = env_set_ulong("gpt_partition_bootable", !!(pinfo->bootable & PART_BOOTABLE));
+ if (ret)
+ goto fail;
+
return 0;
fail:
@@ -835,8 +862,9 @@ static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm,
u8 part_count = 0;
int partlistlen, ret, numparts = 0, partnum, i = 1, ctr1 = 0, ctr2 = 0;
- if ((subcomm == NULL) || (name1 == NULL) || (name2 == NULL) ||
- (strcmp(subcomm, "swap") && (strcmp(subcomm, "rename"))))
+ if (!subcomm || !name1 || !name2 ||
+ (strcmp(subcomm, "swap") && strcmp(subcomm, "rename") &&
+ strcmp(subcomm, "transpose")))
return -EINVAL;
ret = get_disk_guid(dev_desc, disk_guid);
@@ -897,6 +925,41 @@ static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm,
ret = -EINVAL;
goto out;
}
+ } else if (!strcmp(subcomm, "transpose")) {
+ int idx1, idx2;
+ struct disk_partition* first = NULL;
+ struct disk_partition* second= NULL;
+ struct disk_partition tmp_part;
+
+ idx1 = simple_strtoul(name1, NULL, 10);
+ idx2 = simple_strtoul(name2, NULL, 10);
+ if (idx1 == idx2) {
+ printf("Cannot swap partition with itself\n");
+ ret = -EINVAL;
+ goto out;
+ }
+
+ list_for_each(pos, &disk_partitions) {
+ curr = list_entry(pos, struct disk_part, list);
+ if (curr->partnum == idx1)
+ first = &curr->gpt_part_info;
+ else if (curr->partnum == idx2)
+ second = &curr->gpt_part_info;
+ }
+ if (!first) {
+ printf("Illegal partition number %s\n", name1);
+ ret = -EINVAL;
+ goto out;
+ }
+ if (!second) {
+ printf("Illegal partition number %s\n", name2);
+ ret = -EINVAL;
+ goto out;
+ }
+
+ tmp_part = *first;
+ *first = *second;
+ *second = tmp_part;
} else { /* rename */
if (strlen(name2) > PART_NAME_LEN) {
printf("Names longer than %d characters are truncated.\n", PART_NAME_LEN);
@@ -968,6 +1031,81 @@ static int do_rename_gpt_parts(struct blk_desc *dev_desc, char *subcomm,
free(partitions_list);
return ret;
}
+
+/**
+ * gpt_set_bootable() - Set bootable flags for partitions
+ *
+ * Sets the bootable flag for any partition names in the comma separated list of
+ * partition names. Any partitions not in the list have their bootable flag
+ * cleared
+ *
+ * @desc: block device descriptor
+ * @name: Comma separated list of partition names
+ *
+ * @Return: '0' on success and -ve error on failure
+ */
+static int gpt_set_bootable(struct blk_desc *blk_dev_desc, char *const part_list)
+{
+ char *name;
+ char disk_guid[UUID_STR_LEN + 1];
+ struct list_head *pos;
+ struct disk_part *curr;
+ struct disk_partition *partitions = NULL;
+ int part_count = 0;
+ int ret = get_disk_guid(blk_dev_desc, disk_guid);
+
+ if (ret < 0)
+ return ret;
+
+ ret = get_gpt_info(blk_dev_desc);
+ if (ret <= 0)
+ goto out;
+
+ part_count = ret;
+ partitions = malloc(sizeof(*partitions) * part_count);
+ if (!partitions) {
+ ret = -ENOMEM;
+ goto out;
+ }
+
+ /* Copy partitions and clear bootable flag */
+ part_count = 0;
+ list_for_each(pos, &disk_partitions) {
+ curr = list_entry(pos, struct disk_part, list);
+ partitions[part_count] = curr->gpt_part_info;
+ partitions[part_count].bootable &= ~PART_BOOTABLE;
+ part_count++;
+ }
+
+ name = strtok(part_list, ",");
+ while (name) {
+ bool found = false;
+
+ for (int i = 0; i < part_count; i++) {
+ if (strcmp((char *)partitions[i].name, name) == 0) {
+ partitions[i].bootable |= PART_BOOTABLE;
+ found = true;
+ }
+ }
+
+ if (!found) {
+ printf("Warning: No partition matching '%s' found\n",
+ name);
+ }
+
+ name = strtok(NULL, ",");
+ }
+
+ ret = gpt_restore(blk_dev_desc, disk_guid, partitions, part_count);
+
+out:
+ del_gpt_info();
+
+ if (partitions)
+ free(partitions);
+
+ return ret;
+}
#endif
/**
@@ -1025,8 +1163,11 @@ static int do_gpt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
} else if (strcmp(argv[1], "read") == 0) {
ret = do_get_gpt_info(blk_dev_desc, (argc == 5) ? argv[4] : NULL);
} else if ((strcmp(argv[1], "swap") == 0) ||
- (strcmp(argv[1], "rename") == 0)) {
+ (strcmp(argv[1], "rename") == 0) ||
+ (strcmp(argv[1], "transpose") == 0)) {
ret = do_rename_gpt_parts(blk_dev_desc, argv[1], argv[4], argv[5]);
+ } else if ((strcmp(argv[1], "set-bootable") == 0)) {
+ ret = gpt_set_bootable(blk_dev_desc, argv[4]);
#endif
} else {
return CMD_RET_USAGE;
@@ -1057,7 +1198,8 @@ U_BOOT_CMD(gpt, CONFIG_SYS_MAXARGS, 1, do_gpt,
" gpt setenv mmc 0 $name\n"
" - setup environment variables for partition $name:\n"
" gpt_partition_addr, gpt_partition_size,\n"
- " gpt_partition_name, gpt_partition_entry\n"
+ " gpt_partition_name, gpt_partition_entry,\n"
+ " gpt_partition_bootable\n"
" gpt enumerate mmc 0\n"
" - store list of partitions to gpt_partition_list environment variable\n"
" gpt guid <interface> <dev>\n"
@@ -1075,10 +1217,16 @@ U_BOOT_CMD(gpt, CONFIG_SYS_MAXARGS, 1, do_gpt,
" gpt swap <interface> <dev> <name1> <name2>\n"
" - change all partitions named name1 to name2\n"
" and vice-versa\n"
+ " gpt transpose <interface> <dev> <part1> <part2>\n"
+ " - Swap the order of the entries for part1 and part2 in the partition table\n"
" gpt rename <interface> <dev> <part> <name>\n"
" - rename the specified partition\n"
+ " gpt set-bootable <interface> <dev> <list>\n"
+ " - make partition names in list bootable\n"
" Example usage:\n"
" gpt swap mmc 0 foo bar\n"
" gpt rename mmc 0 3 foo\n"
+ " gpt set-bootable mmc 0 boot_a,boot_b\n"
+ " gpt transpose mmc 0 1 2\n"
#endif
);
diff --git a/cmd/i2c.c b/cmd/i2c.c
index dd803ee..f0a5fa2 100644
--- a/cmd/i2c.c
+++ b/cmd/i2c.c
@@ -1939,16 +1939,6 @@ static struct cmd_tbl cmd_i2c_sub[] = {
U_BOOT_CMD_MKENT(speed, 1, 1, do_i2c_bus_speed, "", ""),
};
-static __maybe_unused void i2c_reloc(void)
-{
- static int relocated;
-
- if (!relocated) {
- fixup_cmdtable(cmd_i2c_sub, ARRAY_SIZE(cmd_i2c_sub));
- relocated = 1;
- };
-}
-
/**
* do_i2c() - Handle the "i2c" command-line command
* @cmdtp: Command data struct pointer
@@ -1963,10 +1953,6 @@ static int do_i2c(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct cmd_tbl *c;
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
- i2c_reloc();
-#endif
-
if (argc < 2)
return CMD_RET_USAGE;
diff --git a/cmd/mux.c b/cmd/mux.c
index 833266f..c75907a 100644
--- a/cmd/mux.c
+++ b/cmd/mux.c
@@ -49,7 +49,7 @@ static struct mux_control *cmd_mux_find(char *const argv[])
chip = dev_get_uclass_priv(dev);
if (!chip)
- return ERR_PTR(ret);
+ return ERR_PTR(-EINVAL);
if (id >= chip->controllers)
return ERR_PTR(-EINVAL);
diff --git a/cmd/nvedit.c b/cmd/nvedit.c
index 9e4ee4b..eaa000b 100644
--- a/cmd/nvedit.c
+++ b/cmd/nvedit.c
@@ -36,6 +36,7 @@
#include <mapmem.h>
#include <asm/global_data.h>
#include <linux/bitops.h>
+#include <linux/printk.h>
#include <u-boot/crc.h>
#include <linux/stddef.h>
#include <asm/byteorder.h>
@@ -407,11 +408,7 @@ static int print_active_callback(struct env_entry *entry)
for (i = 0, clbkp = ll_entry_start(struct env_clbk_tbl, env_clbk);
i < num_callbacks;
i++, clbkp++) {
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
- if (entry->callback == clbkp->callback + gd->reloc_off)
-#else
if (entry->callback == clbkp->callback)
-#endif
break;
}
@@ -1222,13 +1219,6 @@ static struct cmd_tbl cmd_env_sub[] = {
#endif
};
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
-void env_reloc(void)
-{
- fixup_cmdtable(cmd_env_sub, ARRAY_SIZE(cmd_env_sub));
-}
-#endif
-
static int do_env(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct cmd_tbl *cp;
diff --git a/cmd/nvedit_efi.c b/cmd/nvedit_efi.c
index 24944ab..7a30b5c 100644
--- a/cmd/nvedit_efi.c
+++ b/cmd/nvedit_efi.c
@@ -262,7 +262,7 @@ static int append_value(char **bufp, size_t *sizep, char *data)
char *tmp_buf = NULL, *new_buf = NULL, *value;
unsigned long len = 0;
- if (!strncmp(data, "=0x", 2)) { /* hexadecimal number */
+ if (!strncmp(data, "=0x", 3)) { /* hexadecimal number */
union {
u8 u8;
u16 u16;
diff --git a/cmd/onenand.c b/cmd/onenand.c
index d633f19..fad7815 100644
--- a/cmd/onenand.c
+++ b/cmd/onenand.c
@@ -12,6 +12,7 @@
#include <common.h>
#include <command.h>
#include <malloc.h>
+#include <linux/printk.h>
#include <linux/compat.h>
#include <linux/mtd/mtd.h>
@@ -560,12 +561,6 @@ static struct cmd_tbl cmd_onenand_sub[] = {
U_BOOT_CMD_MKENT(markbad, CONFIG_SYS_MAXARGS, 0, do_onenand_markbad, "", ""),
};
-#ifdef CONFIG_NEEDS_MANUAL_RELOC
-void onenand_reloc(void) {
- fixup_cmdtable(cmd_onenand_sub, ARRAY_SIZE(cmd_onenand_sub));
-}
-#endif
-
static int do_onenand(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
diff --git a/cmd/pxe.c b/cmd/pxe.c
index 6771425..7045897 100644
--- a/cmd/pxe.c
+++ b/cmd/pxe.c
@@ -299,24 +299,10 @@ static struct cmd_tbl cmd_pxe_sub[] = {
U_BOOT_CMD_MKENT(boot, 3, 1, do_pxe_boot, "", "")
};
-static void __maybe_unused pxe_reloc(void)
-{
- static int relocated_pxe;
-
- if (!relocated_pxe) {
- fixup_cmdtable(cmd_pxe_sub, ARRAY_SIZE(cmd_pxe_sub));
- relocated_pxe = 1;
- }
-}
-
static int do_pxe(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct cmd_tbl *cp;
-#if defined(CONFIG_NEEDS_MANUAL_RELOC)
- pxe_reloc();
-#endif
-
if (argc < 2)
return CMD_RET_USAGE;
@@ -333,8 +319,7 @@ static int do_pxe(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}
U_BOOT_CMD(pxe, 4, 1, do_pxe,
- "commands to get and boot from pxe files\n"
- "To use IPv6 add -ipv6 parameter",
+ "get and boot from pxe files",
"get [" USE_IP6_CMD_PARAM "] - try to retrieve a pxe file using tftp\n"
"pxe boot [pxefile_addr_r] [-ipv6] - boot from the pxe file at pxefile_addr_r\n"
);
diff --git a/cmd/regulator.c b/cmd/regulator.c
index 8988c90..635a9ad 100644
--- a/cmd/regulator.c
+++ b/cmd/regulator.c
@@ -8,6 +8,7 @@
#include <errno.h>
#include <dm.h>
#include <dm/uclass-internal.h>
+#include <linux/printk.h>
#include <power/regulator.h>
#define LIMIT_DEVNAME 20
diff --git a/cmd/rockusb.c b/cmd/rockusb.c
index f181ec6..0708856 100644
--- a/cmd/rockusb.c
+++ b/cmd/rockusb.c
@@ -15,6 +15,7 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, int argc,
{
int controller_index, dev_index;
char *usb_controller;
+ struct udevice *udc;
char *devtype;
char *devnum;
int ret;
@@ -34,7 +35,7 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, int argc,
dev_index = simple_strtoul(devnum, NULL, 0);
rockusb_dev_init(devtype, dev_index);
- ret = usb_gadget_initialize(controller_index);
+ ret = udc_device_get_by_index(controller_index, &udc);
if (ret) {
printf("USB init failed: %d\n", ret);
return CMD_RET_FAILURE;
@@ -56,14 +57,14 @@ static int do_rockusb(struct cmd_tbl *cmdtp, int flag, int argc,
break;
if (ctrlc())
break;
- usb_gadget_handle_interrupts(controller_index);
+ dm_usb_gadget_handle_interrupts(udc);
}
ret = CMD_RET_SUCCESS;
exit:
g_dnl_unregister();
g_dnl_clear_detach();
- usb_gadget_release(controller_index);
+ udc_device_put(udc);
return ret;
}
diff --git a/cmd/setexpr.c b/cmd/setexpr.c
index 4d671e7..233471f 100644
--- a/cmd/setexpr.c
+++ b/cmd/setexpr.c
@@ -215,7 +215,7 @@ int setexpr_regex_sub(char *data, uint data_size, char *nbuf, uint nbuf_size,
if (res == 0) {
if (loop == 0) {
- printf("%s: No match\n", data);
+ debug("%s: No match\n", data);
return 1;
} else {
break;
@@ -359,7 +359,7 @@ static int regex_sub_var(const char *name, const char *r, const char *s,
if (ret)
return 1;
- printf("%s=%s\n", name, data);
+ debug("%s=%s\n", name, data);
return env_set(name, data);
}
diff --git a/cmd/sf.c b/cmd/sf.c
index 55bef2f..977ffcb 100644
--- a/cmd/sf.c
+++ b/cmd/sf.c
@@ -366,7 +366,7 @@ static int do_spi_flash_erase(int argc, char *const argv[])
}
if (flash->flash_is_unlocked &&
- !flash->flash_is_unlocked(flash, offset, len)) {
+ !flash->flash_is_unlocked(flash, offset, size)) {
printf("ERROR: flash area is locked\n");
return CMD_RET_FAILURE;
}
diff --git a/cmd/thordown.c b/cmd/thordown.c
index 838764c..48e22b3 100644
--- a/cmd/thordown.c
+++ b/cmd/thordown.c
@@ -12,26 +12,29 @@
#include <dfu.h>
#include <g_dnl.h>
#include <usb.h>
+#include <linux/printk.h>
int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
+ char *interface, *devstring;
+ int controller_index;
+ struct udevice *udc;
+ int ret;
+
if (argc < 4)
return CMD_RET_USAGE;
- char *usb_controller = argv[1];
- char *interface = argv[2];
- char *devstring = argv[3];
-
- int ret;
-
puts("TIZEN \"THOR\" Downloader\n");
+ interface = argv[2];
+ devstring = argv[3];
+
ret = dfu_init_env_entities(interface, devstring);
if (ret)
goto done;
- int controller_index = simple_strtoul(usb_controller, NULL, 0);
- ret = usb_gadget_initialize(controller_index);
+ controller_index = simple_strtoul(argv[1], NULL, 0);
+ ret = udc_device_get_by_index(controller_index, &udc);
if (ret) {
pr_err("USB init failed: %d\n", ret);
ret = CMD_RET_FAILURE;
@@ -45,7 +48,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
goto exit;
}
- ret = thor_init();
+ ret = thor_init(udc);
if (ret) {
pr_err("THOR DOWNLOAD failed: %d\n", ret);
ret = CMD_RET_FAILURE;
@@ -53,7 +56,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
}
do {
- ret = thor_handle();
+ ret = thor_handle(udc);
if (ret == THOR_DFU_REINIT_NEEDED) {
dfu_free_entities();
ret = dfu_init_env_entities(interface, devstring);
@@ -66,7 +69,7 @@ int do_thor_down(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
} while (ret == 0);
exit:
g_dnl_unregister();
- usb_gadget_release(controller_index);
+ udc_device_put(udc);
done:
dfu_free_entities();
diff --git a/cmd/tpm_test.c b/cmd/tpm_test.c
index c4ed8e5..c7fa6e7 100644
--- a/cmd/tpm_test.c
+++ b/cmd/tpm_test.c
@@ -8,6 +8,7 @@
#include <cpu_func.h>
#include <log.h>
#include <tpm-v1.h>
+#include <linux/printk.h>
#include "tpm-user-utils.h"
#include <tpm_api.h>
@@ -294,8 +295,8 @@ static int test_readonly(struct udevice *dev)
*/
index_0 += 1;
if (tpm_nv_write_value(dev, INDEX0, (uint8_t *)&index_0,
- sizeof(index_0) !=
- TPM_SUCCESS)) {
+ sizeof(index_0)) !=
+ TPM_SUCCESS) {
pr_err("\tcould not write index 0\n");
}
tpm_nv_write_value_lock(dev, INDEX0);
diff --git a/cmd/usb_gadget_sdp.c b/cmd/usb_gadget_sdp.c
index 1af82e1..cbdda73 100644
--- a/cmd/usb_gadget_sdp.c
+++ b/cmd/usb_gadget_sdp.c
@@ -11,17 +11,21 @@
#include <g_dnl.h>
#include <sdp.h>
#include <usb.h>
+#include <linux/printk.h>
static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
+ int controller_index;
+ struct udevice *udc;
int ret;
if (argc < 2)
return CMD_RET_USAGE;
- char *usb_controller = argv[1];
- int controller_index = simple_strtoul(usb_controller, NULL, 0);
- usb_gadget_initialize(controller_index);
+ controller_index = simple_strtoul(argv[1], NULL, 0);
+ ret = udc_device_get_by_index(controller_index, &udc);
+ if (ret)
+ return ret;
g_dnl_clear_detach();
ret = g_dnl_register("usb_dnl_sdp");
@@ -30,20 +34,20 @@ static int do_sdp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
goto exit_register;
}
- ret = sdp_init(controller_index);
+ ret = sdp_init(udc);
if (ret) {
pr_err("SDP init failed: %d\n", ret);
goto exit;
}
/* This command typically does not return but jumps to an image */
- sdp_handle(controller_index);
+ sdp_handle(udc);
pr_err("SDP ended\n");
exit:
g_dnl_unregister();
exit_register:
- usb_gadget_release(controller_index);
+ udc_device_put(udc);
return CMD_RET_FAILURE;
}
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c
index c3cc197..a8ddeb4 100644
--- a/cmd/usb_mass_storage.c
+++ b/cmd/usb_mass_storage.c
@@ -18,6 +18,7 @@
#include <usb_mass_storage.h>
#include <watchdog.h>
#include <linux/delay.h>
+#include <linux/printk.h>
static int ums_read_sector(struct ums *ums_dev,
ulong start, lbaint_t blkcnt, void *buf)
@@ -143,6 +144,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
const char *devtype;
const char *devnum;
unsigned int controller_index;
+ struct udevice *udc;
int rc;
int cable_ready_timeout __maybe_unused;
@@ -164,13 +166,14 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
controller_index = (unsigned int)(simple_strtoul(
usb_controller, NULL, 0));
- if (usb_gadget_initialize(controller_index)) {
+ rc = udc_device_get_by_index(controller_index, &udc);
+ if (rc) {
pr_err("Couldn't init USB controller.\n");
rc = CMD_RET_FAILURE;
goto cleanup_ums_init;
}
- rc = fsg_init(ums, ums_count, controller_index);
+ rc = fsg_init(ums, ums_count, udc);
if (rc) {
pr_err("fsg_init failed\n");
rc = CMD_RET_FAILURE;
@@ -215,7 +218,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
}
while (1) {
- usb_gadget_handle_interrupts(controller_index);
+ dm_usb_gadget_handle_interrupts(udc);
rc = fsg_main_thread(NULL);
if (rc) {
@@ -247,7 +250,7 @@ static int do_usb_mass_storage(struct cmd_tbl *cmdtp, int flag,
cleanup_register:
g_dnl_unregister();
cleanup_board:
- usb_gadget_release(controller_index);
+ udc_device_put(udc);
cleanup_ums_init:
ums_fini();