]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
event: Convert misc_init_f() to use events
authorSimon Glass <sjg@chromium.org>
Fri, 4 Mar 2022 15:43:04 +0000 (08:43 -0700)
committerTom Rini <trini@konsulko.com>
Thu, 10 Mar 2022 13:28:36 +0000 (08:28 -0500)
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@chromium.org>
21 files changed:
arch/sandbox/cpu/start.c
board/google/chromebook_coral/coral.c
board/keymile/kmcent2/kmcent2.c
board/keymile/pg-wcom-ls102xa/pg-wcom-ls102xa.c
common/Kconfig
common/board_f.c
common/event.c
configs/chromebook_coral_defconfig
configs/kmcent2_defconfig
configs/pg_wcom_expu1_defconfig
configs/pg_wcom_expu1_update_defconfig
configs/pg_wcom_seli8_defconfig
configs/pg_wcom_seli8_update_defconfig
configs/sandbox64_defconfig
configs/sandbox_defconfig
configs/sandbox_flattree_defconfig
configs/sandbox_spl_defconfig
configs/tools-only_defconfig
include/configs/km/pg-wcom-ls102xa.h
include/event.h
include/init.h

index 12aace9a2026127e4949311e0a8c395aa6badef7..0f5a87309d2a2e42cfd60d40183bf6662dbaf172 100644 (file)
@@ -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)
+static 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)
 {
index 182cf7517a942c90e1a5336172cfbfb6f3c631c1..9e23f5cd31e756dc9bb89e4624a81d490627ba12 100644 (file)
@@ -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,11 +33,12 @@ 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()) {
                printf("Running as secondary loader");
-               if (gd->arch.coreboot_table) {
+               if (CONFIG_IS_ENABLED(COREBOOT_SYSINFO) &&
+                   gd->arch.coreboot_table) {
                        int ret;
 
                        printf(" (found coreboot table at %lx)",
@@ -55,6 +57,7 @@ int misc_init_f(void)
 
        return 0;
 }
+EVENT_SPY(EVT_MISC_INIT_F, coral_check_ll_boot);
 
 int arch_misc_init(void)
 {
index ca24b960c7624babb29ca700550f018158531c72..44865384f653dc4b499bff58a013fa0aae3da315 100644 (file)
@@ -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>
@@ -181,7 +182,7 @@ unsigned long get_serial_clock(unsigned long dummy)
        return (gd->bus_clk / 2);
 }
 
-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();
@@ -209,6 +210,7 @@ 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
index 467f1109517b45351381c2b50daba5ff8a1c8e2c..ed8142d868f9ba9e3fd5dfb92b7f78d86b455ff2 100644 (file)
@@ -4,6 +4,7 @@
  */
 
 #include <common.h>
+#include <event.h>
 #include <i2c.h>
 #include <asm/io.h>
 #include <asm/arch/immap_ls102xa.h>
@@ -109,12 +110,14 @@ int board_early_init_f(void)
        return 0;
 }
 
-int misc_init_f(void)
+static int pg_wcom_misc_init_f(void *ctx, struct event *event)
 {
        if (IS_ENABLED(CONFIG_PG_WCOM_UBOOT_UPDATE_SUPPORTED))
                check_for_uboot_update();
+
        return 0;
 }
+EVENT_SPY(EVT_MISC_INIT_F, pg_wcom_misc_init_f);
 
 int board_init(void)
 {
index cabc24fb9ce2054fc629522dac89aeaebecc65df..24c83f04e23415ca6f95e0606c6313778cbf437e 100644 (file)
@@ -589,12 +589,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
index e36bdbc988fa3bde621b18fe39f8a669b939e71c..0ef34c7575937c0a4a162984eb47f41002680f03 100644 (file)
@@ -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,
index 737d3ac9eaaab5aca907dce237cd8dacea406b50..4270809d49636bce17b317aae022505878adecbd 100644 (file)
@@ -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");
index 70d62c0f068d087aa48fdcc0b21447a017c7d246..29bf9b96fc028b564b26bd7c2dae3ff2789c3906 100644 (file)
@@ -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
index 40f471ec22cd5816d1ada251c54318dbced6c4e2..982cef668f744defe869bc914c4ca2657f3a2221 100644 (file)
@@ -16,10 +16,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
index 706aacfea008a3cfcc47bccd671ebcd5c8b02e5e..648cb2c84032bb60e23733d34e45b67d31732420 100644 (file)
@@ -35,6 +35,7 @@ CONFIG_AUTOBOOT_STOP_STR=" "
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0"
 CONFIG_SILENT_CONSOLE=y
+CONFIG_EVENT=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_MISC_INIT_R=y
 CONFIG_CMD_IMLS=y
index 9cd479877ec8b6d550165a02a2775908cc39140a..f4895553d2c541d6909ecb368fc1ef82dc4f6b8c 100644 (file)
@@ -33,6 +33,7 @@ CONFIG_AUTOBOOT_STOP_STR=" "
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0"
 CONFIG_SILENT_CONSOLE=y
+CONFIG_EVENT=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_MISC_INIT_R=y
 CONFIG_CMD_IMLS=y
index 8ca1a60e11160ae0a80c82e377d8bf9750d24c4f..bca016314e729dd1adf031463cd7f943127cbb5d 100644 (file)
@@ -35,6 +35,7 @@ CONFIG_AUTOBOOT_STOP_STR=" "
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0"
 CONFIG_SILENT_CONSOLE=y
+CONFIG_EVENT=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_MISC_INIT_R=y
 CONFIG_CMD_IMLS=y
index 5575ee8115fcb7adf85156abafc6f920dd06d1b1..af1812b67d77bd5ca63e381b729e7ae4f61afeae 100644 (file)
@@ -33,6 +33,7 @@ CONFIG_AUTOBOOT_STOP_STR=" "
 CONFIG_USE_BOOTARGS=y
 CONFIG_BOOTARGS="console=ttyS0,115200 root=/dev/ram0"
 CONFIG_SILENT_CONSOLE=y
+CONFIG_EVENT=y
 CONFIG_LAST_STAGE_INIT=y
 CONFIG_MISC_INIT_R=y
 CONFIG_CMD_IMLS=y
index 7c157a23d0fb44b95fd65ffcdec9ff2aa0f8e7d9..40d1422a37822f1589a98b929402746dffa9185f 100644 (file)
@@ -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
index 7ebeb89264cb7399ded76e51f98801a8544c8adf..eaaac6d3fd970bef751d3c42cc9cf1b3d1854e28 100644 (file)
@@ -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
index 217b0647bb586904f544ec29b4442f4987e507d2..7ccee70f42b6d333668126ddb31706e346ab5e6c 100644 (file)
@@ -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
index 1687ccf45304230e885369425904ae379b886a1c..31f5aa850211ee31571caa9ef384f08bcc2ed06b 100644 (file)
@@ -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
index 64eb766515356b180875f288aeed77d9f26904cd..211acc77740417d4e21513fee3dceb3388fdce1c 100644 (file)
@@ -9,7 +9,6 @@ CONFIG_TIMESTAMP=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
index 97f64530456696b6520e4435379c7b9dce1cae84..57d11d6e4f6672ad34b7a170424ff12c11c77b37 100644 (file)
 #define CONFIG_SYS_BOOTM_LEN   (64 << 20) /* Increase max gunzip size */
 #define CONFIG_SYS_BOOTMAPSZ   (256 << 20) /* Increase map for Linux */
 
-#define CONFIG_MISC_INIT_F
-
 #endif
index f4c12d768b4187fbde047e2c816bb90f03218415..6b347e92f0874b1ebc9e06dc5bbe6eb127bafb0e 100644 (file)
@@ -25,6 +25,9 @@ enum event_t {
        EVT_DM_PRE_REMOVE,
        EVT_DM_POST_REMOVE,
 
+       /* Init hooks */
+       EVT_MISC_INIT_F,
+
        EVT_COUNT
 };
 
index 20c3976af09a717496aace4b5d76238fc7f5ec87..c03b29bb0dbda1947c4b48c92e97fcb6e4c63859 100644 (file)
@@ -217,7 +217,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);