summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/Kconfig7
-rw-r--r--common/board_f.c2
-rw-r--r--common/board_r.c8
-rw-r--r--common/cyclic.c17
-rw-r--r--common/init/board_init.c7
-rw-r--r--common/menu.c44
-rw-r--r--common/spl/Kconfig19
-rw-r--r--common/spl/spl.c16
-rw-r--r--common/spl/spl_fat.c1
-rw-r--r--common/usb.c1
-rw-r--r--common/usb_onboard_hub.c12
11 files changed, 111 insertions, 23 deletions
diff --git a/common/Kconfig b/common/Kconfig
index be517b80eb5..17539079f90 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -727,6 +727,13 @@ config BOARD_EARLY_INIT_R
relocation. With this option, U-Boot calls board_early_init_r()
in the post-relocation init sequence.
+config BOARD_INIT
+ bool "Call board-specific init board_init() during init-calls"
+ default y if ARM || RISCV || SANDBOX
+ help
+ Some boards need an board_init() function called during the initcall
+ phase of startup.
+
config BOARD_POSTCLK_INIT
bool "Call board_postclk_init"
help
diff --git a/common/board_f.c b/common/board_f.c
index bff465d9cb2..c8a612d6070 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -1079,7 +1079,7 @@ void board_init_f(ulong boot_flags)
*/
static void initcall_run_f_r(void)
{
-#if CONFIG_IS_ENABLED(X86_64)
+#if !CONFIG_IS_ENABLED(X86_64)
INITCALL(init_cache_f_r);
#endif
}
diff --git a/common/board_r.c b/common/board_r.c
index b90a4d9ff69..46b5ded69d8 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -36,7 +36,6 @@
#include <env.h>
#include <env_internal.h>
#include <fdtdec.h>
-#include <ide.h>
#include <init.h>
#include <initcall.h>
#include <kgdb.h>
@@ -649,8 +648,7 @@ static void initcall_run_r(void)
#if CONFIG_IS_ENABLED(ADDR_MAP)
INITCALL(init_addr_map);
#endif
-#if CONFIG_IS_ENABLED(ARM) || CONFIG_IS_ENABLED(RISCV) || \
- CONFIG_IS_ENABLED(SANDBOX)
+#if CONFIG_IS_ENABLED(BOARD_INIT)
INITCALL(board_init); /* Setup chipselects */
#endif
/*
@@ -815,7 +813,9 @@ void board_init_r(gd_t *new_gd, ulong dest_addr)
if (CONFIG_IS_ENABLED(X86_64) && !IS_ENABLED(CONFIG_EFI_APP))
arch_setup_gd(new_gd);
-#if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
+#if defined(CONFIG_RISCV)
+ set_gd(new_gd);
+#elif !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64)
gd = new_gd;
#endif
gd->flags &= ~GD_FLG_LOG_READY;
diff --git a/common/cyclic.c b/common/cyclic.c
index b695f092f52..ec952a01ee1 100644
--- a/common/cyclic.c
+++ b/common/cyclic.c
@@ -28,9 +28,23 @@ struct hlist_head *cyclic_get_list(void)
return (struct hlist_head *)&gd->cyclic_list;
}
+static bool cyclic_is_registered(const struct cyclic_info *cyclic)
+{
+ const struct cyclic_info *c;
+
+ hlist_for_each_entry(c, cyclic_get_list(), list) {
+ if (c == cyclic)
+ return true;
+ }
+
+ return false;
+}
+
void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func,
uint64_t delay_us, const char *name)
{
+ cyclic_unregister(cyclic);
+
memset(cyclic, 0, sizeof(*cyclic));
/* Store values in struct */
@@ -43,6 +57,9 @@ void cyclic_register(struct cyclic_info *cyclic, cyclic_func_t func,
void cyclic_unregister(struct cyclic_info *cyclic)
{
+ if (!cyclic_is_registered(cyclic))
+ return;
+
hlist_del(&cyclic->list);
}
diff --git a/common/init/board_init.c b/common/init/board_init.c
index a06ec1caa2c..2a6f39f51ad 100644
--- a/common/init/board_init.c
+++ b/common/init/board_init.c
@@ -13,8 +13,11 @@
DECLARE_GLOBAL_DATA_PTR;
-/* Unfortunately x86 or ARM can't compile this code as gd cannot be assigned */
-#if !defined(CONFIG_X86) && !defined(CONFIG_ARM)
+/*
+ * Unfortunately x86, ARM and RISC-V can't compile this code as gd is defined
+ * as macro and cannot be assigned.
+ */
+#if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_RISCV)
__weak void arch_setup_gd(struct global_data *gd_ptr)
{
gd = gd_ptr;
diff --git a/common/menu.c b/common/menu.c
index 5a2126aa01a..ae5afa14766 100644
--- a/common/menu.c
+++ b/common/menu.c
@@ -8,6 +8,7 @@
#include <cli.h>
#include <malloc.h>
#include <errno.h>
+#include <linux/ctype.h>
#include <linux/delay.h>
#include <linux/list.h>
#include <watchdog.h>
@@ -436,6 +437,29 @@ int menu_destroy(struct menu *m)
return 1;
}
+static int bootmenu_conv_shortcut_key(struct bootmenu_data *menu, int ichar)
+{
+ int shortcut_key;
+
+ ichar = tolower(ichar);
+ switch (ichar) {
+ /* a-z for bootmenu entry > 9 */
+ case 'a' ... 'z':
+ shortcut_key = ichar - 'a' + 9;
+ break;
+ /* 1-9 for bootmenu entry <= 9 */
+ case '1' ... '9':
+ shortcut_key = ichar - '1';
+ break;
+ /* Reserve 0 for last option (aka Exit) */
+ case '0':
+ default:
+ return -1;
+ }
+
+ return shortcut_key;
+}
+
enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
struct cli_ch_state *cch)
{
@@ -443,12 +467,12 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
int i, c;
while (menu->delay > 0) {
+ int ichar;
+
if (ansi)
printf(ANSI_CURSOR_POSITION, menu->count + 5, 3);
printf("Hit any key to stop autoboot: %d ", menu->delay);
for (i = 0; i < 100; ++i) {
- int ichar;
-
if (!tstc()) {
schedule();
mdelay(10);
@@ -470,6 +494,11 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
case 0x3: /* ^C */
key = BKEY_QUIT;
break;
+ case 'A' ... 'Z':
+ case 'a' ... 'z':
+ case '0' ... '9':
+ key = BKEY_SHORTCUT;
+ break;
default:
key = BKEY_NONE;
break;
@@ -477,6 +506,9 @@ enum bootmenu_key bootmenu_autoboot_loop(struct bootmenu_data *menu,
break;
}
+ if (key == BKEY_SHORTCUT)
+ cch->shortcut_key = bootmenu_conv_shortcut_key(menu, ichar);
+
if (menu->delay < 0)
break;
@@ -524,6 +556,11 @@ enum bootmenu_key bootmenu_conv_key(int ichar)
case ' ':
key = BKEY_SPACE;
break;
+ case 'A' ... 'Z':
+ case 'a' ... 'z':
+ case '0' ... '9':
+ key = BKEY_SHORTCUT;
+ break;
default:
key = BKEY_NONE;
break;
@@ -554,5 +591,8 @@ enum bootmenu_key bootmenu_loop(struct bootmenu_data *menu,
key = bootmenu_conv_key(c);
+ if (key == BKEY_SHORTCUT)
+ cch->shortcut_key = bootmenu_conv_shortcut_key(menu, c);
+
return key;
}
diff --git a/common/spl/Kconfig b/common/spl/Kconfig
index 0bc96d0a781..880192043c4 100644
--- a/common/spl/Kconfig
+++ b/common/spl/Kconfig
@@ -96,6 +96,7 @@ config SPL_MAX_SIZE
config SPL_PAD_TO
hex "Offset to which the SPL should be padded before appending the SPL payload"
+ default 0x7f8000 if ARCH_ROCKCHIP
default 0x31000 if ARCH_MX6 && MX6_OCRAM_256KB
default 0x11000 if ARCH_MX7 || (ARCH_MX6 && !MX6_OCRAM_256KB)
default 0x10000 if ARCH_KEYSTONE
@@ -487,7 +488,7 @@ config SPL_CUSTOM_SYS_MALLOC_ADDR
config SPL_SYS_MALLOC_SIZE
hex "Size of the SPL malloc pool"
depends on SPL_SYS_MALLOC
- default 0x180000 if BIOSEMU && RISCV
+ default 0x800000 if RISCV
default 0x100000
config SPL_READ_ONLY
@@ -973,6 +974,21 @@ config SPL_NAND_SUPPORT
This enables the drivers in drivers/mtd/nand/raw as part of an SPL
build.
+config SPL_NAND_RAW_U_BOOT_USE_SECTOR
+ bool "NAND raw mode: by sector"
+ depends on SPL_NAND_SUPPORT
+ select SPL_LOAD_BLOCK
+ help
+ Use sector number for specifying U-Boot location on NAND in
+ raw mode.
+
+config SPL_NAND_RAW_U_BOOT_SECTOR
+ hex "Address on the NAND to load U-Boot from"
+ depends on SPL_NAND_RAW_U_BOOT_USE_SECTOR
+ help
+ Address on the NAND to load U-Boot from, when the NAND is being used
+ in raw mode. Units: NAND disk sectors (1 sector = 512 bytes).
+
config SPL_NAND_RAW_ONLY
bool "Support to boot only raw u-boot.bin images"
depends on SPL_NAND_SUPPORT
@@ -1122,6 +1138,7 @@ config SPL_DM_SPI_FLASH
config SPL_NET
bool "Support networking"
depends on !NET_LWIP
+ select SPL_USE_TINY_PRINTF_POINTER_SUPPORT if SPL_USE_TINY_PRINTF
help
Enable support for network devices (such as Ethernet) in SPL.
This permits SPL to load U-Boot over a network link rather than
diff --git a/common/spl/spl.c b/common/spl/spl.c
index 76fd56dfe4b..d8e26605d20 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -392,7 +392,7 @@ int spl_load(struct spl_image_info *spl_image,
}
#endif
-__weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image)
+__weak void __noreturn jump_to_image(struct spl_image_info *spl_image)
{
typedef void __noreturn (*image_entry_noargs_t)(void);
@@ -689,7 +689,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
BOOT_DEVICE_NONE,
BOOT_DEVICE_NONE,
};
- spl_jump_to_image_t jump_to_image = &jump_to_image_no_args;
+ spl_jump_to_image_t jumper = &jump_to_image;
struct spl_image_info spl_image;
int ret, os;
@@ -783,20 +783,20 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
} else if (CONFIG_IS_ENABLED(ATF) && os == IH_OS_ARM_TRUSTED_FIRMWARE) {
debug("Jumping to U-Boot via ARM Trusted Firmware\n");
spl_fixup_fdt(spl_image_fdt_addr(&spl_image));
- jump_to_image = &spl_invoke_atf;
+ jumper = &spl_invoke_atf;
} else if (CONFIG_IS_ENABLED(OPTEE_IMAGE) && os == IH_OS_TEE) {
debug("Jumping to U-Boot via OP-TEE\n");
spl_board_prepare_for_optee(spl_image_fdt_addr(&spl_image));
- jump_to_image = &jump_to_image_optee;
+ jumper = &jump_to_image_optee;
} else if (CONFIG_IS_ENABLED(OPENSBI) && os == IH_OS_OPENSBI) {
debug("Jumping to U-Boot via RISC-V OpenSBI\n");
- jump_to_image = &spl_invoke_opensbi;
+ jumper = &spl_invoke_opensbi;
} else if (CONFIG_IS_ENABLED(OS_BOOT) && os == IH_OS_LINUX) {
debug("Jumping to Linux\n");
if (IS_ENABLED(CONFIG_SPL_OS_BOOT))
spl_fixup_fdt((void *)SPL_PAYLOAD_ARGS_ADDR);
spl_board_prepare_for_linux();
- jump_to_image = &jump_to_image_linux;
+ jumper = &jump_to_image_linux;
} else {
debug("Unsupported OS image.. Jumping nevertheless..\n");
}
@@ -848,7 +848,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
if (CONFIG_IS_ENABLED(RELOC_LOADER)) {
int ret;
- ret = spl_reloc_jump(&spl_image, jump_to_image);
+ ret = spl_reloc_jump(&spl_image, jumper);
if (ret) {
if (xpl_phase() == PHASE_VPL)
printf("jump failed %d\n", ret);
@@ -856,7 +856,7 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
}
}
- jump_to_image(&spl_image);
+ jumper(&spl_image);
}
/*
diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c
index f426a068ff9..8b7cafa7291 100644
--- a/common/spl/spl_fat.c
+++ b/common/spl/spl_fat.c
@@ -16,6 +16,7 @@
#include <errno.h>
#include <image.h>
#include <linux/libfdt.h>
+#include <asm/cache.h>
static int fat_registered;
diff --git a/common/usb.c b/common/usb.c
index 7a8435296c6..6a4ad346f4b 100644
--- a/common/usb.c
+++ b/common/usb.c
@@ -28,6 +28,7 @@
#include <command.h>
#include <dm.h>
#include <dm/device_compat.h>
+#include <env.h>
#include <log.h>
#include <malloc.h>
#include <memalign.h>
diff --git a/common/usb_onboard_hub.c b/common/usb_onboard_hub.c
index 7fe62b043e6..d17c85dd622 100644
--- a/common/usb_onboard_hub.c
+++ b/common/usb_onboard_hub.c
@@ -146,7 +146,7 @@ static int usb_onboard_hub_probe(struct udevice *dev)
int ret;
ret = device_get_supply_regulator(dev, "vdd-supply", &hub->vdd);
- if (ret && ret != -ENOENT) {
+ if (ret && ret != -ENOENT && ret != -ENOSYS) {
dev_err(dev, "can't get vdd-supply: %d\n", ret);
return ret;
}
@@ -204,14 +204,16 @@ static int usb_onboard_hub_bind(struct udevice *dev)
static int usb_onboard_hub_remove(struct udevice *dev)
{
struct onboard_hub *hub = dev_get_priv(dev);
- int ret;
+ int ret = 0;
if (hub->reset_gpio)
dm_gpio_free(hub->reset_gpio->dev, hub->reset_gpio);
- ret = regulator_set_enable_if_allowed(hub->vdd, false);
- if (ret)
- dev_err(dev, "can't disable vdd-supply: %d\n", ret);
+ if (hub->vdd) {
+ ret = regulator_set_enable_if_allowed(hub->vdd, false);
+ if (ret)
+ dev_err(dev, "can't disable vdd-supply: %d\n", ret);
+ }
return ret;
}