[PATCH 08/12] event: Convert misc_init_f() to use events
Simon Glass
sjg at chromium.org
Tue Dec 28 09:28:50 CET 2021
This hook can be implmented using events, for the three boards that
actually use it.
Add the event type and event handlers. Drop CONFIG_MISC_INIT_F since we
can just use CONFIG_EVENT to control this. Since sandbox always enables
CONFIG_EVENT, we can drop the defconfig lines there too.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
arch/sandbox/cpu/start.c | 4 +++-
board/google/chromebook_coral/coral.c | 6 ++++--
board/keymile/kmcent2/kmcent2.c | 5 ++++-
common/Kconfig | 6 ------
common/board_f.c | 7 +++++--
common/event.c | 3 +++
configs/chromebook_coral_defconfig | 1 +
configs/kmcent2_defconfig | 2 +-
configs/sandbox64_defconfig | 1 -
configs/sandbox_defconfig | 1 -
configs/sandbox_flattree_defconfig | 1 -
configs/sandbox_spl_defconfig | 1 -
configs/tools-only_defconfig | 1 -
include/event.h | 3 +++
include/init.h | 1 -
15 files changed, 24 insertions(+), 19 deletions(-)
diff --git a/arch/sandbox/cpu/start.c b/arch/sandbox/cpu/start.c
index 12aace9a202..684ef569cdc 100644
--- a/arch/sandbox/cpu/start.c
+++ b/arch/sandbox/cpu/start.c
@@ -8,6 +8,7 @@
#include <command.h>
#include <efi_loader.h>
#include <errno.h>
+#include <event.h>
#include <init.h>
#include <log.h>
#include <os.h>
@@ -119,10 +120,11 @@ int sandbox_early_getopt_check(void)
os_exit(0);
}
-int misc_init_f(void)
+int sandbox_misc_init_f(void *ctx, struct event *event)
{
return sandbox_early_getopt_check();
}
+EVENT_SPY(EVT_MISC_INIT_F, sandbox_misc_init_f);
static int sandbox_cmdline_cb_help(struct sandbox_state *state, const char *arg)
{
diff --git a/board/google/chromebook_coral/coral.c b/board/google/chromebook_coral/coral.c
index 53c5171d02b..34ec1803e47 100644
--- a/board/google/chromebook_coral/coral.c
+++ b/board/google/chromebook_coral/coral.c
@@ -10,6 +10,7 @@
#include <command.h>
#include <cros_ec.h>
#include <dm.h>
+#include <event.h>
#include <init.h>
#include <log.h>
#include <sysinfo.h>
@@ -32,9 +33,9 @@ struct cros_gpio_info {
int flags;
};
-int misc_init_f(void)
+static int coral_check_ll_boot(void *ctx, struct event *event)
{
- if (!ll_boot_init()) {
+ if (CONFIG_IS_ENABLED(COREBOOT_SYSINFO) && !ll_boot_init()) {
printf("Running as secondary loader");
if (gd->arch.coreboot_table) {
int ret;
@@ -55,6 +56,7 @@ int misc_init_f(void)
return 0;
}
+EVENT_SPY(EVT_MISC_INIT_F, coral_check_ll_boot);
int arch_misc_init(void)
{
diff --git a/board/keymile/kmcent2/kmcent2.c b/board/keymile/kmcent2/kmcent2.c
index 4f5164e63ca..768b2276ae2 100644
--- a/board/keymile/kmcent2/kmcent2.c
+++ b/board/keymile/kmcent2/kmcent2.c
@@ -6,6 +6,7 @@
* Copyright 2013 Freescale Semiconductor, Inc.
*/
+#include <event.h>
#include <asm/cache.h>
#include <asm/fsl_fdt.h>
#include <asm/fsl_law.h>
@@ -186,7 +187,7 @@ unsigned long get_board_sys_clk(unsigned long dummy)
return 66666666;
}
-int misc_init_f(void)
+static int kmcent2_misc_init_f(void *ctx, struct event *event)
{
/* configure QRIO pis for i2c deblocking */
i2c_deblock_gpio_cfg();
@@ -214,6 +215,8 @@ int misc_init_f(void)
return 0;
}
+EVENT_SPY(EVT_MISC_INIT_F, kmcent2_misc_init_f);
+
#define USED_SRDS_BANK 0
#define EXPECTED_SRDS_RFCK SRDS_PLLCR0_RFCK_SEL_100
diff --git a/common/Kconfig b/common/Kconfig
index 9ebfdb4626b..f989dc38bc7 100644
--- a/common/Kconfig
+++ b/common/Kconfig
@@ -574,12 +574,6 @@ config LAST_STAGE_INIT
U-Boot calls last_stage_init() before the command-line interpreter is
started.
-config MISC_INIT_F
- bool "Execute pre-relocation misc init"
- help
- Enabling this option calls the 'misc_init_f' function in the init
- sequence just before DRAM is inited.
-
config MISC_INIT_R
bool "Execute Misc Init"
default y if ARCH_KEYSTONE || ARCH_SUNXI || MPC85xx
diff --git a/common/board_f.c b/common/board_f.c
index ebb9b65c6be..7fa3cbe08e3 100644
--- a/common/board_f.c
+++ b/common/board_f.c
@@ -818,6 +818,11 @@ __weak int clear_bss(void)
return 0;
}
+static int misc_init_f(void)
+{
+ return event_notify_null(EVT_MISC_INIT_F);
+}
+
static const init_fnc_t init_sequence_f[] = {
setup_mon_len,
#ifdef CONFIG_OF_CONTROL
@@ -877,9 +882,7 @@ static const init_fnc_t init_sequence_f[] = {
show_board_info,
#endif
INIT_FUNC_WATCHDOG_INIT
-#if defined(CONFIG_MISC_INIT_F)
misc_init_f,
-#endif
INIT_FUNC_WATCHDOG_RESET
#if CONFIG_IS_ENABLED(SYS_I2C_LEGACY)
init_func_i2c,
diff --git a/common/event.c b/common/event.c
index 737d3ac9eaa..4270809d496 100644
--- a/common/event.c
+++ b/common/event.c
@@ -30,6 +30,9 @@ const char *const type_name[] = {
"dm_post_probe",
"dm_pre_remove",
"dm_post_remove",
+
+ /* init hooks */
+ "misc_init_f",
};
_Static_assert(ARRAY_SIZE(type_name) == EVT_COUNT, "event type_name size");
diff --git a/configs/chromebook_coral_defconfig b/configs/chromebook_coral_defconfig
index 2dd37f64c00..c74b2517645 100644
--- a/configs/chromebook_coral_defconfig
+++ b/configs/chromebook_coral_defconfig
@@ -35,6 +35,7 @@ CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="tpm init; tpm startup TPM2_SU_CLEAR; read mmc 0:2 100000 0 80; setexpr loader *001004f0; setexpr size *00100518; setexpr blocks $size / 200; read mmc 0:2 100000 80 $blocks; setexpr setup $loader - 1000; setexpr cmdline_ptr $loader - 2000; setexpr.s cmdline *$cmdline_ptr; setexpr cmdline gsub %U \\\\${uuid}; if part uuid mmc 0:2 uuid; then zboot start 100000 0 0 0 $setup cmdline; zboot load; zboot setup; zboot dump; zboot go;fi"
CONFIG_SYS_CONSOLE_INFO_QUIET=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
+CONFIG_EVENT=y
CONFIG_LAST_STAGE_INIT=y
CONFIG_BLOBLIST=y
# CONFIG_TPL_BLOBLIST is not set
diff --git a/configs/kmcent2_defconfig b/configs/kmcent2_defconfig
index 9361e81e803..d64aa020f4c 100644
--- a/configs/kmcent2_defconfig
+++ b/configs/kmcent2_defconfig
@@ -14,10 +14,10 @@ CONFIG_FIT=y
CONFIG_FIT_VERBOSE=y
CONFIG_OF_BOARD_SETUP=y
CONFIG_OF_STDOUT_VIA_ALIAS=y
+CONFIG_EVENT=y
CONFIG_BOARD_EARLY_INIT_F=y
CONFIG_BOARD_EARLY_INIT_R=y
CONFIG_LAST_STAGE_INIT=y
-CONFIG_MISC_INIT_F=y
CONFIG_HUSH_PARSER=y
CONFIG_CMD_DM=y
CONFIG_CMD_I2C=y
diff --git a/configs/sandbox64_defconfig b/configs/sandbox64_defconfig
index d849989cf61..d7d23ab5af8 100644
--- a/configs/sandbox64_defconfig
+++ b/configs/sandbox64_defconfig
@@ -23,7 +23,6 @@ CONFIG_CONSOLE_RECORD=y
CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
CONFIG_PRE_CONSOLE_BUFFER=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
-CONFIG_MISC_INIT_F=y
CONFIG_CMD_CPU=y
CONFIG_CMD_LICENSE=y
CONFIG_CMD_BOOTZ=y
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig
index c390afe9de5..b4abc065395 100644
--- a/configs/sandbox_defconfig
+++ b/configs/sandbox_defconfig
@@ -32,7 +32,6 @@ CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
CONFIG_PRE_CONSOLE_BUFFER=y
CONFIG_LOG=y
CONFIG_DISPLAY_BOARDINFO_LATE=y
-CONFIG_MISC_INIT_F=y
CONFIG_STACKPROTECTOR=y
CONFIG_ANDROID_AB=y
CONFIG_CMD_CPU=y
diff --git a/configs/sandbox_flattree_defconfig b/configs/sandbox_flattree_defconfig
index f184723a899..bfeb1651125 100644
--- a/configs/sandbox_flattree_defconfig
+++ b/configs/sandbox_flattree_defconfig
@@ -20,7 +20,6 @@ CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
CONFIG_CONSOLE_RECORD=y
CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
CONFIG_DISPLAY_BOARDINFO_LATE=y
-CONFIG_MISC_INIT_F=y
CONFIG_CMD_CPU=y
CONFIG_CMD_LICENSE=y
CONFIG_CMD_BOOTZ=y
diff --git a/configs/sandbox_spl_defconfig b/configs/sandbox_spl_defconfig
index f1a54ace9bc..4afa488b129 100644
--- a/configs/sandbox_spl_defconfig
+++ b/configs/sandbox_spl_defconfig
@@ -30,7 +30,6 @@ CONFIG_BOOTSTAGE_STASH_SIZE=0x4096
CONFIG_CONSOLE_RECORD=y
CONFIG_CONSOLE_RECORD_OUT_SIZE=0x1000
CONFIG_DISPLAY_BOARDINFO_LATE=y
-CONFIG_MISC_INIT_F=y
CONFIG_HANDOFF=y
CONFIG_SPL_BOARD_INIT=y
CONFIG_SPL_ENV_SUPPORT=y
diff --git a/configs/tools-only_defconfig b/configs/tools-only_defconfig
index 5ffc625b0dd..77cf2db6109 100644
--- a/configs/tools-only_defconfig
+++ b/configs/tools-only_defconfig
@@ -8,7 +8,6 @@ CONFIG_FIT=y
CONFIG_FIT_SIGNATURE=y
CONFIG_USE_BOOTCOMMAND=y
CONFIG_BOOTCOMMAND="run distro_bootcmd"
-CONFIG_MISC_INIT_F=y
# CONFIG_CMD_BOOTD is not set
# CONFIG_CMD_BOOTM is not set
# CONFIG_CMD_ELF is not set
diff --git a/include/event.h b/include/event.h
index 16a5c192802..f1333af7bd4 100644
--- a/include/event.h
+++ b/include/event.h
@@ -25,6 +25,9 @@ enum event_t {
EVT_DM_PRE_REMOVE,
EVT_DM_POST_REMOVE,
+ /* Init hooks */
+ EVT_MISC_INIT_F,
+
EVT_COUNT
};
diff --git a/include/init.h b/include/init.h
index f2cd46dead0..f1c3982319f 100644
--- a/include/init.h
+++ b/include/init.h
@@ -214,7 +214,6 @@ int init_cache_f_r(void);
int print_cpuinfo(void);
#endif
int timer_init(void);
-int misc_init_f(void);
#if defined(CONFIG_DTB_RESELECT)
int embedded_dtb_select(void);
--
2.34.1.448.ga2b2bfdf31-goog
More information about the U-Boot
mailing list