diff options
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/Kconfig | 22 | ||||
-rw-r--r-- | cmd/Makefile | 6 | ||||
-rw-r--r-- | cmd/bootcount.c | 4 | ||||
-rw-r--r-- | cmd/bootflow.c | 21 | ||||
-rw-r--r-- | cmd/bootmenu.c | 6 | ||||
-rw-r--r-- | cmd/cls.c | 2 | ||||
-rw-r--r-- | cmd/console.c | 14 | ||||
-rw-r--r-- | cmd/cpu.c | 2 | ||||
-rw-r--r-- | cmd/dataflash_mmc_mux.c | 48 | ||||
-rw-r--r-- | cmd/dm.c | 2 | ||||
-rw-r--r-- | cmd/eficonfig.c | 12 | ||||
-rw-r--r-- | cmd/fastboot.c | 4 | ||||
-rw-r--r-- | cmd/meson/Makefile | 5 | ||||
-rw-r--r-- | cmd/meson/sm.c | 191 | ||||
-rw-r--r-- | cmd/mfsl.c | 387 | ||||
-rw-r--r-- | cmd/mmc.c | 49 | ||||
-rw-r--r-- | cmd/net.c | 6 | ||||
-rw-r--r-- | cmd/nvedit.c | 3 | ||||
-rw-r--r-- | cmd/qfw.c | 89 | ||||
-rw-r--r-- | cmd/seama.c | 158 | ||||
-rw-r--r-- | cmd/ti/pd.c | 2 |
21 files changed, 474 insertions, 559 deletions
diff --git a/cmd/Kconfig b/cmd/Kconfig index 4fe2c75de25..2caa4af71cb 100644 --- a/cmd/Kconfig +++ b/cmd/Kconfig @@ -337,6 +337,12 @@ config BOOTM_RTEMS help Support booting RTEMS images via the bootm command. +config CMD_SEAMA + bool "Support read SEAMA NAND images" + depends on MTD_RAW_NAND + help + Support reading NAND Seattle Image (SEAMA) images. + config CMD_VBE bool "vbe - Verified Boot for Embedded" depends on BOOTMETH_VBE @@ -1994,7 +2000,9 @@ config CMD_EFIDEBUG config CMD_EFICONFIG bool "eficonfig - provide menu-driven uefi variables maintenance interface" + default y if !HAS_BOARD_SIZE_LIMIT depends on CMD_BOOTEFI_BOOTMGR + select MENU help Enable the 'eficonfig' command which provides the menu-driven UEFI variable maintenance interface. @@ -2015,6 +2023,13 @@ config CMD_LED with led on/off/togle/blink. Any LED drivers can be controlled with this command, e.g. led_gpio. +config CMD_INI + bool "ini" + help + Enable the 'ini' command which allows a .ini file to be parsed and + placed into environment variables. Please check the source code for + this as there is no documentation. + config CMD_DATE bool "date" default y if DM_RTC @@ -2733,4 +2748,11 @@ config MMC_SPEED_MODE_SET and is indicated using the index from enum bus_mode in include/mmc.h. A speed mode can be set only if it has already been enabled in the device tree. + +config CMD_MESON + bool "Amlogic Meson commands" + depends on ARCH_MESON + default y + help + Enable useful commands for the Meson Soc family developed by Amlogic Inc. endmenu diff --git a/cmd/Makefile b/cmd/Makefile index 0b6a96c1d91..36d2daf22a1 100644 --- a/cmd/Makefile +++ b/cmd/Makefile @@ -47,7 +47,6 @@ obj-$(CONFIG_CMD_CONFIG) += config.o obj-$(CONFIG_CMD_CONITRACE) += conitrace.o obj-$(CONFIG_CMD_CONSOLE) += console.o obj-$(CONFIG_CMD_CPU) += cpu.o -obj-$(CONFIG_DATAFLASH_MMC_SELECT) += dataflash_mmc_mux.o obj-$(CONFIG_CMD_DATE) += date.o obj-$(CONFIG_CMD_DEMO) += demo.o obj-$(CONFIG_CMD_DM) += dm.o @@ -108,7 +107,6 @@ obj-$(CONFIG_ID_EEPROM) += mac.o obj-$(CONFIG_CMD_MD5SUM) += md5sum.o obj-$(CONFIG_CMD_MEMORY) += mem.o obj-$(CONFIG_CMD_IO) += io.o -obj-$(CONFIG_CMD_MFSL) += mfsl.o obj-$(CONFIG_CMD_MII) += mii.o obj-$(CONFIG_CMD_MISC) += misc.o obj-$(CONFIG_CMD_MDIO) += mdio.o @@ -156,6 +154,7 @@ obj-$(CONFIG_SANDBOX) += sb.o obj-$(CONFIG_CMD_SF) += sf.o obj-$(CONFIG_CMD_SCSI) += scsi.o disk.o obj-$(CONFIG_CMD_SHA1SUM) += sha1sum.o +obj-$(CONFIG_CMD_SEAMA) += seama.o obj-$(CONFIG_CMD_SETEXPR) += setexpr.o obj-$(CONFIG_CMD_SETEXPR_FMT) += printf.o obj-$(CONFIG_CMD_SPI) += spi.o @@ -226,6 +225,9 @@ obj-$(CONFIG_RISCV) += riscv/ obj-$(CONFIG_SANDBOX) += sandbox/ obj-$(CONFIG_X86) += x86/ +# Meson +obj-$(CONFIG_CMD_MESON) += meson/ + obj-$(CONFIG_ARCH_MVEBU) += mvebu/ endif # !CONFIG_SPL_BUILD diff --git a/cmd/bootcount.c b/cmd/bootcount.c index 654bbb805c1..3898d2543d2 100644 --- a/cmd/bootcount.c +++ b/cmd/bootcount.c @@ -46,7 +46,7 @@ static int do_bootcount(struct cmd_tbl *cmdtp, int flag, int argc, return CMD_RET_USAGE; } -#if CONFIG_IS_ENABLED(SYS_LONGHELP) +#if IS_ENABLED(CONFIG_SYS_LONGHELP) static char bootcount_help_text[] = "print - print current bootcounter\n" "reset - reset the bootcounter" @@ -55,7 +55,7 @@ static char bootcount_help_text[] = U_BOOT_CMD(bootcount, 2, 1, do_bootcount, "bootcount", -#if CONFIG_IS_ENABLED(SYS_LONGHELP) +#if IS_ENABLED(CONFIG_SYS_LONGHELP) bootcount_help_text #endif ); diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 692bc6d117f..3548bbb6830 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -394,15 +394,20 @@ static int do_bootflow_menu(struct cmd_tbl *cmdtp, int flag, int argc, if (ret) return CMD_RET_FAILURE; - ret = bootflow_menu_run(std, text_mode, &bflow); - if (ret) { - if (ret == -EAGAIN) - printf("Nothing chosen\n"); - else - printf("Menu failed (err=%d)\n", ret); - - return CMD_RET_FAILURE; + if (IS_ENABLED(CONFIG_EXPO)) { + ret = bootflow_menu_run(std, text_mode, &bflow); + if (ret) { + if (ret == -EAGAIN) + printf("Nothing chosen\n"); + else + printf("Menu failed (err=%d)\n", ret); + } + } else { + printf("Menu not supported\n"); + ret = -ENOSYS; } + if (ret) + return CMD_RET_FAILURE; printf("Selected: %s\n", bflow->os_name ? bflow->os_name : bflow->name); std->cur_bootflow = bflow; diff --git a/cmd/bootmenu.c b/cmd/bootmenu.c index 3236ca5d799..6baeedc69f9 100644 --- a/cmd/bootmenu.c +++ b/cmd/bootmenu.c @@ -223,7 +223,7 @@ static int prepare_bootmenu_entry(struct bootmenu_data *menu, return 1; } -#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR)) && (CONFIG_IS_ENABLED(CMD_EFICONFIG)) +#if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) && (IS_ENABLED(CONFIG_CMD_EFICONFIG)) /** * prepare_uefi_bootorder_entry() - generate the uefi bootmenu entries * @@ -343,7 +343,7 @@ static struct bootmenu_data *bootmenu_create(int delay) if (ret < 0) goto cleanup; -#if (CONFIG_IS_ENABLED(CMD_BOOTEFI_BOOTMGR)) && (CONFIG_IS_ENABLED(CMD_EFICONFIG)) +#if (IS_ENABLED(CONFIG_CMD_BOOTEFI_BOOTMGR)) && (IS_ENABLED(CONFIG_CMD_EFICONFIG)) if (i < MAX_COUNT - 1) { efi_status_t efi_ret; @@ -437,7 +437,7 @@ static void menu_display_statusline(struct menu *m) printf(ANSI_CURSOR_POSITION, menu->count + 5, 1); puts(ANSI_CLEAR_LINE); printf(ANSI_CURSOR_POSITION, menu->count + 6, 3); - puts("Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit"); + puts("Press UP/DOWN to move, ENTER to select, ESC to quit"); puts(ANSI_CLEAR_LINE_TO_END); printf(ANSI_CURSOR_POSITION, menu->count + 7, 1); puts(ANSI_CLEAR_LINE); diff --git a/cmd/cls.c b/cmd/cls.c index 18643ec0243..40a32eeab63 100644 --- a/cmd/cls.c +++ b/cmd/cls.c @@ -19,7 +19,7 @@ static int do_video_clear(struct cmd_tbl *cmdtp, int flag, int argc, /* Send clear screen and home */ printf(CSI "2J" CSI "1;1H"); - if (CONFIG_IS_ENABLED(VIDEO) && !CONFIG_IS_ENABLED(VIDEO_ANSI)) { + if (IS_ENABLED(CONFIG_VIDEO) && !IS_ENABLED(CONFIG_VIDEO_ANSI)) { if (uclass_first_device_err(UCLASS_VIDEO, &dev)) return CMD_RET_FAILURE; if (video_clear(dev)) diff --git a/cmd/console.c b/cmd/console.c index 9a1db83c7c3..620a961cdef 100644 --- a/cmd/console.c +++ b/cmd/console.c @@ -22,23 +22,21 @@ static int do_coninfo(struct cmd_tbl *cmd, int flag, int argc, /* Scan for valid output and input devices */ - puts ("List of available devices:\n"); + puts("List of available devices\n"); list_for_each(pos, list) { dev = list_entry(pos, struct stdio_dev, list); - printf ("%-8s %08x %c%c ", - dev->name, - dev->flags, - (dev->flags & DEV_FLAGS_INPUT) ? 'I' : '.', - (dev->flags & DEV_FLAGS_OUTPUT) ? 'O' : '.'); + printf("|-- %s (%s%s)\n", + dev->name, + (dev->flags & DEV_FLAGS_INPUT) ? "I" : "", + (dev->flags & DEV_FLAGS_OUTPUT) ? "O" : ""); for (l = 0; l < MAX_FILES; l++) { if (stdio_devices[l] == dev) { - printf ("%s ", stdio_names[l]); + printf("| |-- %s\n", stdio_names[l]); } } - putc ('\n'); } return 0; } diff --git a/cmd/cpu.c b/cmd/cpu.c index a09736e1bb9..314852440f1 100644 --- a/cmd/cpu.c +++ b/cmd/cpu.c @@ -83,7 +83,7 @@ static int do_cpu_detail(struct cmd_tbl *cmdtp, int flag, int argc, return 0; } -#if CONFIG_IS_ENABLED(SYS_LONGHELP) +#if IS_ENABLED(CONFIG_SYS_LONGHELP) static char cpu_help_text[] = "list - list available CPUs\n" "cpu detail - show CPU detail" diff --git a/cmd/dataflash_mmc_mux.c b/cmd/dataflash_mmc_mux.c deleted file mode 100644 index 73876e9464a..00000000000 --- a/cmd/dataflash_mmc_mux.c +++ /dev/null @@ -1,48 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2000 - * Wolfgang Denk, DENX Software Engineering, wd@denx.de. - */ - -#include <common.h> -#include <command.h> - -static int mmc_nspi (const char *); - -int do_dataflash_mmc_mux(struct cmd_tbl *cmdtp, int flag, int argc, - char *const argv[]) -{ - switch (argc) { - case 2: /* on / off */ - switch (mmc_nspi (argv[1])) { - case 0: AT91F_SelectSPI (); - break; - case 1: AT91F_SelectMMC (); - break; - } - case 1: /* get status */ - printf ("Mux is configured to be %s\n", - AT91F_GetMuxStatus () ? "MMC" : "SPI"); - return 0; - default: - return CMD_RET_USAGE; - } - return 0; -} - -static int mmc_nspi (const char *s) -{ - if (strcmp (s, "mmc") == 0) { - return 1; - } else if (strcmp (s, "spi") == 0) { - return 0; - } - return -1; -} - -U_BOOT_CMD( - dataflash_mmc_mux, 2, 1, do_dataflash_mmc_mux, - "enable or disable MMC or SPI\n", - "[mmc, spi]\n" - " - enable or disable MMC or SPI" -); @@ -84,7 +84,7 @@ static int do_dm_dump_uclass(struct cmd_tbl *cmdtp, int flag, int argc, #define DM_MEM #endif -#if CONFIG_IS_ENABLED(SYS_LONGHELP) +#if IS_ENABLED(CONFIG_SYS_LONGHELP) static char dm_help_text[] = "compat Dump list of drivers with compatibility strings\n" "dm devres Dump list of device resources for each device\n" diff --git a/cmd/eficonfig.c b/cmd/eficonfig.c index 47c04cf5363..720f52b48b8 100644 --- a/cmd/eficonfig.c +++ b/cmd/eficonfig.c @@ -23,12 +23,12 @@ static struct efi_simple_text_input_protocol *cin; const char *eficonfig_menu_desc = - " Press UP/DOWN to move, ENTER to select, ESC/CTRL+C to quit"; + " Press UP/DOWN to move, ENTER to select, ESC to quit"; static const char *eficonfig_change_boot_order_desc = " Press UP/DOWN to move, +/- to change orde\n" " Press SPACE to activate or deactivate the entry\n" - " Select [Save] to complete, ESC/CTRL+C to quit"; + " CTRL+S to save, ESC to quit"; static struct efi_simple_text_output_protocol *cout; static int avail_row; @@ -927,7 +927,7 @@ static efi_status_t handle_user_input(u16 *buf, int buf_size, ANSI_CURSOR_POSITION "%s" ANSI_CURSOR_POSITION - " Press ENTER to complete, ESC/CTRL+C to quit", + " Press ENTER to complete, ESC to quit", 0, 1, msg, 8, 1); /* tmp is used to accept user cancel */ @@ -1983,6 +1983,10 @@ char *eficonfig_choice_change_boot_order(void *data) eficonfig_menu_down(efi_menu); return NULL; + case BKEY_SAVE: + /* force to select "Save" entry */ + efi_menu->active = efi_menu->count - 2; + fallthrough; case BKEY_SELECT: /* "Save" */ if (efi_menu->active == efi_menu->count - 2) { @@ -2670,7 +2674,7 @@ static const struct eficonfig_item maintenance_menu_items[] = { {"Edit Boot Option", eficonfig_process_edit_boot_option}, {"Change Boot Order", eficonfig_process_change_boot_order}, {"Delete Boot Option", eficonfig_process_delete_boot_option}, -#if (CONFIG_IS_ENABLED(EFI_SECURE_BOOT) && CONFIG_IS_ENABLED(EFI_MM_COMM_TEE)) +#if (IS_ENABLED(CONFIG_EFI_SECURE_BOOT) && IS_ENABLED(CONFIG_EFI_MM_COMM_TEE)) {"Secure Boot Configuration", eficonfig_process_secure_boot_config}, #endif {"Quit", eficonfig_process_quit}, diff --git a/cmd/fastboot.c b/cmd/fastboot.c index b94dbd54884..97dc02ce748 100644 --- a/cmd/fastboot.c +++ b/cmd/fastboot.c @@ -21,7 +21,7 @@ static int do_fastboot_udp(int argc, char *const argv[], { int err; - if (!CONFIG_IS_ENABLED(UDP_FUNCTION_FASTBOOT)) { + if (!IS_ENABLED(CONFIG_UDP_FUNCTION_FASTBOOT)) { pr_err("Fastboot UDP not enabled\n"); return CMD_RET_FAILURE; } @@ -44,7 +44,7 @@ static int do_fastboot_usb(int argc, char *const argv[], char *endp; int ret; - if (!CONFIG_IS_ENABLED(USB_FUNCTION_FASTBOOT)) { + if (!IS_ENABLED(CONFIG_USB_FUNCTION_FASTBOOT)) { pr_err("Fastboot USB not enabled\n"); return CMD_RET_FAILURE; } diff --git a/cmd/meson/Makefile b/cmd/meson/Makefile new file mode 100644 index 00000000000..ee26c175cfe --- /dev/null +++ b/cmd/meson/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0+ +# +# Copyright (c) 2022, SberDevices. All rights reserved. + +obj-y += sm.o diff --git a/cmd/meson/sm.c b/cmd/meson/sm.c new file mode 100644 index 00000000000..de9a242e17f --- /dev/null +++ b/cmd/meson/sm.c @@ -0,0 +1,191 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright (c) 2016 Beniamino Galvani + * + * Author: Beniamino Galvani <b.galvani@gmail.com> + * Author: Vyacheslav Bocharov <adeep@lexina.in> + * Author: Neil Armstrong <narmstrong@baylibre.com> + * Author: Alexey Romanov <avromanov@sberdevices.ru> + */ + +#include <command.h> +#include <common.h> +#include <env.h> +#include <asm/arch/sm.h> +#include <stdlib.h> +#include <display_options.h> + +static int do_sm_serial(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + ulong address; + int ret; + + if (argc < 2) + return CMD_RET_USAGE; + + address = simple_strtoul(argv[1], NULL, 0); + + ret = meson_sm_get_serial((void *)address, SM_SERIAL_SIZE); + if (ret) + return CMD_RET_FAILURE; + + return CMD_RET_SUCCESS; +} + +#define MAX_REBOOT_REASONS 14 + +static const char *reboot_reasons[MAX_REBOOT_REASONS] = { + [REBOOT_REASON_COLD] = "cold_boot", + [REBOOT_REASON_NORMAL] = "normal", + [REBOOT_REASON_RECOVERY] = "recovery", + [REBOOT_REASON_UPDATE] = "update", + [REBOOT_REASON_FASTBOOT] = "fastboot", + [REBOOT_REASON_SUSPEND_OFF] = "suspend_off", + [REBOOT_REASON_HIBERNATE] = "hibernate", + [REBOOT_REASON_BOOTLOADER] = "bootloader", + [REBOOT_REASON_SHUTDOWN_REBOOT] = "shutdown_reboot", + [REBOOT_REASON_RPMBP] = "rpmbp", + [REBOOT_REASON_CRASH_DUMP] = "crash_dump", + [REBOOT_REASON_KERNEL_PANIC] = "kernel_panic", + [REBOOT_REASON_WATCHDOG_REBOOT] = "watchdog_reboot", +}; + +static int do_sm_reboot_reason(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + const char *reason_str; + char *destarg = NULL; + int reason; + + if (argc > 1) + destarg = argv[1]; + + reason = meson_sm_get_reboot_reason(); + if (reason < 0) + return CMD_RET_FAILURE; + + if (reason >= MAX_REBOOT_REASONS || + !reboot_reasons[reason]) + reason_str = "unknown"; + else + reason_str = reboot_reasons[reason]; + + if (destarg) + env_set(destarg, reason_str); + else + printf("reboot reason: %s (%x)\n", reason_str, reason); + + return CMD_RET_SUCCESS; +} + +static int do_efuse_read(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + ulong address, offset, size; + int ret; + + if (argc < 4) + return CMD_RET_USAGE; + + offset = simple_strtoul(argv[1], NULL, 0); + size = simple_strtoul(argv[2], NULL, 0); + + address = simple_strtoul(argv[3], NULL, 0); + + ret = meson_sm_read_efuse(offset, (void *)address, size); + if (ret != size) + return CMD_RET_FAILURE; + + return CMD_RET_SUCCESS; +} + +static int do_efuse_write(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + ulong address, offset, size; + int ret; + + if (argc < 4) + return CMD_RET_USAGE; + + offset = simple_strtoul(argv[1], NULL, 0); + size = simple_strtoul(argv[2], NULL, 0); + + address = simple_strtoul(argv[3], NULL, 0); + + ret = meson_sm_write_efuse(offset, (void *)address, size); + if (ret != size) + return CMD_RET_FAILURE; + + return CMD_RET_SUCCESS; +} + +static int do_efuse_dump(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + ulong offset, size; + u8 *buffer; + int ret; + + if (argc != 3) + return CMD_RET_USAGE; + + offset = simple_strtoul(argv[1], NULL, 0); + size = simple_strtoul(argv[2], NULL, 0); + buffer = malloc(size); + if (!buffer) { + pr_err("Failed to allocate %lu bytes\n", size); + return CMD_RET_FAILURE; + } + + ret = meson_sm_read_efuse(offset, (void *)buffer, size); + if (ret != size) { + ret = CMD_RET_FAILURE; + goto free_buffer; + } + + print_buffer(0, buffer, 1, size, 0); + +free_buffer: + free(buffer); + return ret; +} + +static struct cmd_tbl cmd_sm_sub[] = { + U_BOOT_CMD_MKENT(serial, 2, 1, do_sm_serial, "", ""), + U_BOOT_CMD_MKENT(reboot_reason, 1, 1, do_sm_reboot_reason, "", ""), + U_BOOT_CMD_MKENT(efuseread, 4, 1, do_efuse_read, "", ""), + U_BOOT_CMD_MKENT(efusewrite, 4, 0, do_efuse_write, "", ""), + U_BOOT_CMD_MKENT(efusedump, 3, 1, do_efuse_dump, "", ""), +}; + +static int do_sm(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct cmd_tbl *c; + + if (argc < 2) + return CMD_RET_USAGE; + + /* Strip off leading 'sm' command argument */ + argc--; + argv++; + + c = find_cmd_tbl(argv[0], &cmd_sm_sub[0], ARRAY_SIZE(cmd_sm_sub)); + + if (c) + return c->cmd(cmdtp, flag, argc, argv); + else + return CMD_RET_USAGE; +} + +U_BOOT_CMD( + sm, 5, 0, do_sm, + "Secure Monitor Control", + "serial <address> - read chip unique id to memory address\n" + "sm reboot_reason [name] - get reboot reason and store to environment\n" + "sm efuseread <offset> <size> <address> - read efuse to memory address\n" + "sm efusewrite <offset> <size> <address> - write into efuse from memory address\n" + "sm efusedump <offset> <size> - dump efuse data range to console" +); diff --git a/cmd/mfsl.c b/cmd/mfsl.c deleted file mode 100644 index 0c78720ec46..00000000000 --- a/cmd/mfsl.c +++ /dev/null @@ -1,387 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0+ -/* - * (C) Copyright 2007 Michal Simek - * - * Michal SIMEK <monstr@monstr.eu> - */ - -/* - * Microblaze FSL support - */ - -#include <common.h> -#include <config.h> -#include <command.h> -#include <asm/asm.h> - -int do_frd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - unsigned int fslnum; - unsigned int num; - unsigned int blocking; - - if (argc < 2) - return CMD_RET_USAGE; - - fslnum = (unsigned int)hextoul(argv[1], NULL); - blocking = (unsigned int)hextoul(argv[2], NULL); - if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) { - puts ("Bad number of FSL\n"); - return CMD_RET_USAGE; - } - - switch (fslnum) { -#if (XILINX_FSL_NUMBER > 0) - case 0: - switch (blocking) { - case 0: NGET (num, 0); - break; - case 1: NCGET (num, 0); - break; - case 2: GET (num, 0); - break; - case 3: CGET (num, 0); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 1) - case 1: - switch (blocking) { - case 0: NGET (num, 1); - break; - case 1: NCGET (num, 1); - break; - case 2: GET (num, 1); - break; - case 3: CGET (num, 1); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 2) - case 2: - switch (blocking) { - case 0: NGET (num, 2); - break; - case 1: NCGET (num, 2); - break; - case 2: GET (num, 2); - break; - case 3: CGET (num, 2); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 3) - case 3: - switch (blocking) { - case 0: NGET (num, 3); - break; - case 1: NCGET (num, 3); - break; - case 2: GET (num, 3); - break; - case 3: CGET (num, 3); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 4) - case 4: - switch (blocking) { - case 0: NGET (num, 4); - break; - case 1: NCGET (num, 4); - break; - case 2: GET (num, 4); - break; - case 3: CGET (num, 4); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 5) - case 5: - switch (blocking) { - case 0: NGET (num, 5); - break; - case 1: NCGET (num, 5); - break; - case 2: GET (num, 5); - break; - case 3: CGET (num, 5); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 6) - case 6: - switch (blocking) { - case 0: NGET (num, 6); - break; - case 1: NCGET (num, 6); - break; - case 2: GET (num, 6); - break; - case 3: CGET (num, 6); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 7) - case 7: - switch (blocking) { - case 0: NGET (num, 7); - break; - case 1: NCGET (num, 7); - break; - case 2: GET (num, 7); - break; - case 3: CGET (num, 7); - break; - default: - return 2; - } - break; -#endif - default: - return 1; - } - - printf ("%01x: 0x%08x - %s %s read\n", fslnum, num, - blocking < 2 ? "non blocking" : "blocking", - ((blocking == 1) || (blocking == 3)) ? "control" : "data" ); - return 0; -} - -int do_fwr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - unsigned int fslnum; - unsigned int num; - unsigned int blocking; - - if (argc < 3) - return CMD_RET_USAGE; - - fslnum = (unsigned int)hextoul(argv[1], NULL); - num = (unsigned int)hextoul(argv[2], NULL); - blocking = (unsigned int)hextoul(argv[3], NULL); - if (fslnum < 0 || fslnum >= XILINX_FSL_NUMBER) - return CMD_RET_USAGE; - - switch (fslnum) { -#if (XILINX_FSL_NUMBER > 0) - case 0: - switch (blocking) { - case 0: NPUT (num, 0); - break; - case 1: NCPUT (num, 0); - break; - case 2: PUT (num, 0); - break; - case 3: CPUT (num, 0); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 1) - case 1: - switch (blocking) { - case 0: NPUT (num, 1); - break; - case 1: NCPUT (num, 1); - break; - case 2: PUT (num, 1); - break; - case 3: CPUT (num, 1); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 2) - case 2: - switch (blocking) { - case 0: NPUT (num, 2); - break; - case 1: NCPUT (num, 2); - break; - case 2: PUT (num, 2); - break; - case 3: CPUT (num, 2); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 3) - case 3: - switch (blocking) { - case 0: NPUT (num, 3); - break; - case 1: NCPUT (num, 3); - break; - case 2: PUT (num, 3); - break; - case 3: CPUT (num, 3); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 4) - case 4: - switch (blocking) { - case 0: NPUT (num, 4); - break; - case 1: NCPUT (num, 4); - break; - case 2: PUT (num, 4); - break; - case 3: CPUT (num, 4); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 5) - case 5: - switch (blocking) { - case 0: NPUT (num, 5); - break; - case 1: NCPUT (num, 5); - break; - case 2: PUT (num, 5); - break; - case 3: CPUT (num, 5); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 6) - case 6: - switch (blocking) { - case 0: NPUT (num, 6); - break; - case 1: NCPUT (num, 6); - break; - case 2: PUT (num, 6); - break; - case 3: CPUT (num, 6); - break; - default: - return 2; - } - break; -#endif -#if (XILINX_FSL_NUMBER > 7) - case 7: - switch (blocking) { - case 0: NPUT (num, 7); - break; - case 1: NCPUT (num, 7); - break; - case 2: PUT (num, 7); - break; - case 3: CPUT (num, 7); - break; - default: - return 2; - } - break; -#endif - default: - return 1; - } - - printf ("%01x: 0x%08x - %s %s write\n", fslnum, num, - blocking < 2 ? "non blocking" : "blocking", - ((blocking == 1) || (blocking == 3)) ? "control" : "data" ); - return 0; - -} - -int do_rspr(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) -{ - unsigned int reg = 0; - unsigned int val = 0; - - if (argc < 2) - return CMD_RET_USAGE; - - reg = (unsigned int)hextoul(argv[1], NULL); - val = (unsigned int)hextoul(argv[2], NULL); - switch (reg) { - case 0x1: - if (argc > 2) { - MTS (val, rmsr); - NOP; - MFS (val, rmsr); - } else { - MFS (val, rmsr); - } - puts ("MSR"); - break; - case 0x3: - MFS (val, rear); - puts ("EAR"); - break; - case 0x5: - MFS (val, resr); - puts ("ESR"); - break; - default: - puts ("Unsupported register\n"); - return 1; - } - printf (": 0x%08x\n", val); - return 0; -} - -/***************************************************/ - -U_BOOT_CMD (frd, 3, 1, do_frd, - "read data from FSL", - "- [fslnum [0|1|2|3]]\n" - " 0 - non blocking data read\n" - " 1 - non blocking control read\n" - " 2 - blocking data read\n" - " 3 - blocking control read"); - -U_BOOT_CMD (fwr, 4, 1, do_fwr, - "write data to FSL", - "- [fslnum [0|1|2|3]]\n" - " 0 - non blocking data write\n" - " 1 - non blocking control write\n" - " 2 - blocking data write\n" - " 3 - blocking control write"); - -U_BOOT_CMD (rspr, 3, 1, do_rspr, - "read/write special purpose register", - "- reg_num [write value] read/write special purpose register\n" - " 1 - MSR - Machine status register\n" - " 3 - EAR - Exception address register\n" - " 5 - ESR - Exception status register"); diff --git a/cmd/mmc.c b/cmd/mmc.c index c79d9407986..94deb9a1686 100644 --- a/cmd/mmc.c +++ b/cmd/mmc.c @@ -1020,16 +1020,12 @@ static int do_mmc_setdsr(struct cmd_tbl *cmdtp, int flag, } #ifdef CONFIG_CMD_BKOPS_ENABLE -static int do_mmc_bkops_enable(struct cmd_tbl *cmdtp, int flag, - int argc, char *const argv[]) +static int mmc_bkops_common(char *device, bool autobkops, bool enable) { - int dev; struct mmc *mmc; + int dev; - if (argc != 2) - return CMD_RET_USAGE; - - dev = dectoul(argv[1], NULL); + dev = dectoul(device, NULL); mmc = init_mmc_device(dev, false); if (!mmc) @@ -1040,7 +1036,41 @@ static int do_mmc_bkops_enable(struct cmd_tbl *cmdtp, int flag, return CMD_RET_FAILURE; } - return mmc_set_bkops_enable(mmc); + return mmc_set_bkops_enable(mmc, autobkops, enable); +} + +static int do_mmc_bkops(struct cmd_tbl *cmdtp, int flag, + int argc, char * const argv[]) +{ + bool autobkops, enable; + + if (argc != 4) + return CMD_RET_USAGE; + + if (!strcmp(argv[2], "manual")) + autobkops = false; + else if (!strcmp(argv[2], "auto")) + autobkops = true; + else + return CMD_RET_FAILURE; + + if (!strcmp(argv[3], "disable")) + enable = false; + else if (!strcmp(argv[3], "enable")) + enable = true; + else + return CMD_RET_FAILURE; + + return mmc_bkops_common(argv[1], autobkops, enable); +} + +static int do_mmc_bkops_enable(struct cmd_tbl *cmdtp, int flag, + int argc, char * const argv[]) +{ + if (argc != 2) + return CMD_RET_USAGE; + + return mmc_bkops_common(argv[1], false, true); } #endif @@ -1102,6 +1132,7 @@ static struct cmd_tbl cmd_mmc[] = { U_BOOT_CMD_MKENT(setdsr, 2, 0, do_mmc_setdsr, "", ""), #ifdef CONFIG_CMD_BKOPS_ENABLE U_BOOT_CMD_MKENT(bkops-enable, 2, 0, do_mmc_bkops_enable, "", ""), + U_BOOT_CMD_MKENT(bkops, 4, 0, do_mmc_bkops, "", ""), #endif }; @@ -1188,6 +1219,8 @@ U_BOOT_CMD( #ifdef CONFIG_CMD_BKOPS_ENABLE "mmc bkops-enable <dev> - enable background operations handshake on device\n" " WARNING: This is a write-once setting.\n" + "mmc bkops <dev> [auto|manual] [enable|disable]\n" + " - configure background operations handshake on device\n" #endif ); diff --git a/cmd/net.c b/cmd/net.c index 4227321871c..d5e20843dda 100644 --- a/cmd/net.c +++ b/cmd/net.c @@ -280,7 +280,7 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[]) switch (argc) { case 1: - if (CONFIG_IS_ENABLED(CMD_TFTPPUT) && proto == TFTPPUT) + if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) return 1; /* refresh bootfile name from env */ @@ -289,7 +289,7 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[]) break; case 2: - if (CONFIG_IS_ENABLED(CMD_TFTPPUT) && proto == TFTPPUT) + if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) return 1; /* * Only one arg - accept two forms: @@ -311,7 +311,7 @@ static int parse_args(enum proto_t proto, int argc, char *const argv[]) break; case 3: - if (CONFIG_IS_ENABLED(CMD_TFTPPUT) && proto == TFTPPUT) { + if (IS_ENABLED(CONFIG_CMD_TFTPPUT) && proto == TFTPPUT) { if (parse_addr_size(argv)) return 1; } else { diff --git a/cmd/nvedit.c b/cmd/nvedit.c index 53e6b57b60e..7cbc3fd573a 100644 --- a/cmd/nvedit.c +++ b/cmd/nvedit.c @@ -51,7 +51,6 @@ DECLARE_GLOBAL_DATA_PTR; defined(CONFIG_ENV_IS_IN_NAND) || \ defined(CONFIG_ENV_IS_IN_NVRAM) || \ defined(CONFIG_ENV_IS_IN_ONENAND) || \ - defined(CONFIG_ENV_IS_IN_SATA) || \ defined(CONFIG_ENV_IS_IN_SPI_FLASH) || \ defined(CONFIG_ENV_IS_IN_REMOTE) || \ defined(CONFIG_ENV_IS_IN_UBI) @@ -232,7 +231,7 @@ static int _do_env_set(int flag, int argc, char *const argv[], int env_flag) debug("Initial value for argc=%d\n", argc); -#if CONFIG_IS_ENABLED(CMD_NVEDIT_EFI) +#if !IS_ENABLED(CONFIG_SPL_BUILD) && IS_ENABLED(CONFIG_CMD_NVEDIT_EFI) if (argc > 1 && argv[1][0] == '-' && argv[1][1] == 'e') return do_env_set_efi(NULL, flag, --argc, ++argv); #endif diff --git a/cmd/qfw.c b/cmd/qfw.c index 0c49c6074e1..ae3c6a7a84e 100644 --- a/cmd/qfw.c +++ b/cmd/qfw.c @@ -12,73 +12,6 @@ static struct udevice *qfw_dev; -/* - * This function prepares kernel for zboot. It loads kernel data - * to 'load_addr', initrd to 'initrd_addr' and kernel command - * line using qemu fw_cfg interface. - */ -static int qemu_fwcfg_cmd_setup_kernel(void *load_addr, void *initrd_addr) -{ - char *data_addr; - uint32_t setup_size, kernel_size, cmdline_size, initrd_size; - - qfw_read_entry(qfw_dev, FW_CFG_SETUP_SIZE, 4, &setup_size); - qfw_read_entry(qfw_dev, FW_CFG_KERNEL_SIZE, 4, &kernel_size); - - if (kernel_size == 0) { - printf("fatal: no kernel available\n"); - return CMD_RET_FAILURE; - } - - data_addr = load_addr; - if (setup_size != 0) { - qfw_read_entry(qfw_dev, FW_CFG_SETUP_DATA, - le32_to_cpu(setup_size), data_addr); - data_addr += le32_to_cpu(setup_size); - } - - qfw_read_entry(qfw_dev, FW_CFG_KERNEL_DATA, - le32_to_cpu(kernel_size), data_addr); - data_addr += le32_to_cpu(kernel_size); - env_set_hex("filesize", le32_to_cpu(kernel_size)); - - data_addr = initrd_addr; - qfw_read_entry(qfw_dev, FW_CFG_INITRD_SIZE, 4, &initrd_size); - if (initrd_size == 0) { - printf("warning: no initrd available\n"); - } else { - qfw_read_entry(qfw_dev, FW_CFG_INITRD_DATA, - le32_to_cpu(initrd_size), data_addr); - data_addr += le32_to_cpu(initrd_size); - env_set_hex("filesize", le32_to_cpu(initrd_size)); - } - - qfw_read_entry(qfw_dev, FW_CFG_CMDLINE_SIZE, 4, &cmdline_size); - if (cmdline_size) { - qfw_read_entry(qfw_dev, FW_CFG_CMDLINE_DATA, - le32_to_cpu(cmdline_size), data_addr); - /* - * if kernel cmdline only contains '\0', (e.g. no -append - * when invoking qemu), do not update bootargs - */ - if (*data_addr != '\0') { - if (env_set("bootargs", data_addr) < 0) - printf("warning: unable to change bootargs\n"); - } - } - - printf("loading kernel to address %p size %x", load_addr, - le32_to_cpu(kernel_size)); - if (initrd_size) - printf(" initrd %p size %x\n", - initrd_addr, - le32_to_cpu(initrd_size)); - else - printf("\n"); - - return 0; -} - static int qemu_fwcfg_cmd_list_firmware(void) { int ret; @@ -119,28 +52,28 @@ static int qemu_fwcfg_do_load(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) { char *env; - void *load_addr; - void *initrd_addr; + ulong load_addr; + ulong initrd_addr; env = env_get("loadaddr"); load_addr = env ? - (void *)hextoul(env, NULL) : - (void *)CONFIG_SYS_LOAD_ADDR; + hextoul(env, NULL) : + CONFIG_SYS_LOAD_ADDR; env = env_get("ramdiskaddr"); initrd_addr = env ? - (void *)hextoul(env, NULL) : + hextoul(env, NULL) : #ifdef CFG_RAMDISK_ADDR - (void *)CFG_RAMDISK_ADDR; + CFG_RAMDISK_ADDR; #else - NULL; + 0; #endif if (argc == 2) { - load_addr = (void *)hextoul(argv[0], NULL); - initrd_addr = (void *)hextoul(argv[1], NULL); + load_addr = hextoul(argv[0], NULL); + initrd_addr = hextoul(argv[1], NULL); } else if (argc == 1) { - load_addr = (void *)hextoul(argv[0], NULL); + load_addr = hextoul(argv[0], NULL); } if (!load_addr || !initrd_addr) { @@ -148,7 +81,7 @@ static int qemu_fwcfg_do_load(struct cmd_tbl *cmdtp, int flag, return CMD_RET_FAILURE; } - return qemu_fwcfg_cmd_setup_kernel(load_addr, initrd_addr); + return qemu_fwcfg_setup_kernel(qfw_dev, load_addr, initrd_addr); } static struct cmd_tbl fwcfg_commands[] = { diff --git a/cmd/seama.c b/cmd/seama.c new file mode 100644 index 00000000000..3aafb43c48a --- /dev/null +++ b/cmd/seama.c @@ -0,0 +1,158 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2023 Linus Walleij <linus.walleij@linaro.org> + * Support for the "SEAttle iMAge" SEAMA NAND image format + */ + +#include <common.h> +#include <command.h> +#include <nand.h> + +/* + * All SEAMA data is stored in the flash in "network endianness" + * i.e. big endian, which means that it needs to be byte-swapped + * on all little endian platforms. + * + * structure for a SEAMA entity in NAND flash: + * + * 32 bit SEAMA magic 0x5EA3A417 + * 16 bit reserved + * 16 bit metadata size (following the header) + * 32 bit image size + * 16 bytes MD5 digest of the image + * meta data + * ... image data ... + * + * Then if a new SEAMA magic follows, that is the next image. + */ + +#define SEAMA_MAGIC 0x5EA3A417 +#define SEAMA_HDR_NO_META_SZ 28 +#define SEAMA_MAX_META_SZ (1024 - SEAMA_HDR_NO_META_SZ) + +struct seama_header { + u32 magic; + u32 meta_size; + u32 image_size; + u8 md5[16]; + u8 metadata[SEAMA_MAX_META_SZ]; +}; + +static struct seama_header shdr; + +static int env_set_val(const char *varname, ulong val) +{ + int ret; + + ret = env_set_hex(varname, val); + if (ret) + printf("Failed to %s env var\n", varname); + + return ret; +} + +static int do_seama_load_image(struct cmd_tbl *cmdtp, int flag, int argc, + char *const argv[]) +{ + struct mtd_info *mtd; + uintptr_t load_addr; + unsigned long image_index; + u32 len; + size_t readsz; + int ret; + u32 *start; + u32 *offset; + u32 *end; + u32 tmp; + + if (argc < 2 || argc > 3) + return CMD_RET_USAGE; + + load_addr = hextoul(argv[1], NULL); + if (!load_addr) { + printf("Invalid load address\n"); + return CMD_RET_USAGE; + } + + /* Can be 0 for first image */ + image_index = hextoul(argv[2], NULL); + + /* We only support one NAND, the first one */ + nand_curr_device = 0; + mtd = get_nand_dev_by_index(0); + if (!mtd) { + printf("NAND Device 0 not available\n"); + return CMD_RET_FAILURE; + } + +#ifdef CONFIG_SYS_NAND_SELECT_DEVICE + board_nand_select_device(mtd_to_nand(mtd), 0); +#endif + + printf("Loading SEAMA image %lu from %s\n", image_index, mtd->name); + + readsz = sizeof(shdr); + offset = 0; + ret = nand_read_skip_bad(mtd, 0, &readsz, NULL, mtd->size, + (u_char *)&shdr); + if (ret) { + printf("Read error reading SEAMA header\n"); + return CMD_RET_FAILURE; + } + + if (shdr.magic != SEAMA_MAGIC) { + printf("Invalid SEAMA image magic: 0x%08x\n", shdr.magic); + return CMD_RET_FAILURE; + } + + /* Only the lower 16 bits are valid */ + shdr.meta_size &= 0xFFFF; + + if (env_set_val("seama_image_size", 0)) + return CMD_RET_FAILURE; + + printf("SEMA IMAGE:\n"); + printf(" metadata size %d\n", shdr.meta_size); + printf(" image size %d\n", shdr.image_size); + printf(" checksum %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n", + shdr.md5[0], shdr.md5[1], shdr.md5[2], shdr.md5[3], + shdr.md5[4], shdr.md5[5], shdr.md5[6], shdr.md5[7], + shdr.md5[8], shdr.md5[9], shdr.md5[10], shdr.md5[11], + shdr.md5[12], shdr.md5[13], shdr.md5[14], shdr.md5[15]); + + /* TODO: handle metadata if needed */ + + len = shdr.image_size; + if (env_set_val("seama_image_size", len)) + return CMD_RET_FAILURE; + + /* We need to include the header (read full pages) */ + readsz = shdr.image_size + SEAMA_HDR_NO_META_SZ + shdr.meta_size; + ret = nand_read_skip_bad(mtd, 0, &readsz, NULL, mtd->size, + (u_char *)load_addr); + if (ret) { + printf("Read error reading SEAMA main image\n"); + return CMD_RET_FAILURE; + } + + /* We use a temporary variable tmp to avoid to hairy casts */ + start = (u32 *)load_addr; + tmp = (u32)start; + tmp += SEAMA_HDR_NO_META_SZ + shdr.meta_size; + offset = (u32 *)tmp; + tmp += shdr.image_size; + end = (u32 *)tmp; + + printf("Decoding SEAMA image 0x%08x..0x%08x to 0x%08x\n", + (u32)offset, (u32)end, (u32)start); + for (; start < end; start++, offset++) + *start = be32_to_cpu(*offset); + + return CMD_RET_SUCCESS; +} + +U_BOOT_CMD + (seama, 3, 1, do_seama_load_image, + "Load the SEAMA image and sets envs", + "seama <addr> <imageindex>\n" +); diff --git a/cmd/ti/pd.c b/cmd/ti/pd.c index 008668fd903..a9a182fc386 100644 --- a/cmd/ti/pd.c +++ b/cmd/ti/pd.c @@ -177,7 +177,7 @@ static int ti_do_pd(struct cmd_tbl *cmdtp, int flag, int argc, char * const argv U_BOOT_CMD(pd, 4, 1, ti_do_pd, "TI power domain control", -#if CONFIG_IS_ENABLED(SYS_LONGHELP) +#if IS_ENABLED(CONFIG_SYS_LONGHELP) "dump - show power domain status\n" "enable [psc] [lpsc] - enable power domain\n" "disable [psc] [lpsc] - disable power domain\n" |