
Instead of a special function, send an event after driver model is inited and adjust the boards which use this function.
Signed-off-by: Simon Glass sjg@chromium.org ---
arch/Kconfig | 3 +++ arch/arm/Kconfig | 3 +++ arch/arm/include/asm/omap_common.h | 2 ++ arch/arm/mach-imx/imx8m/soc.c | 4 +++- arch/arm/mach-imx/imx8ulp/soc.c | 4 +++- arch/arm/mach-omap2/am33xx/board.c | 10 ++++++---- arch/arm/mach-omap2/hwinit-common.c | 5 ++++- arch/mips/Kconfig | 1 + arch/mips/mach-pic32/cpu.c | 4 +++- arch/nios2/cpu/cpu.c | 4 +++- arch/riscv/cpu/cpu.c | 5 ++++- arch/riscv/include/asm/system.h | 5 +++++ arch/riscv/lib/spl.c | 3 ++- arch/x86/cpu/baytrail/cpu.c | 4 +++- arch/x86/cpu/broadwell/cpu.c | 4 +++- arch/x86/cpu/ivybridge/cpu.c | 4 +++- arch/x86/cpu/quark/quark.c | 4 +++- arch/x86/include/asm/fsp2/fsp_api.h | 8 ++++++++ arch/x86/lib/fsp2/fsp_init.c | 4 +++- arch/x86/lib/spl.c | 12 ------------ arch/x86/lib/tpl.c | 10 ---------- common/board_f.c | 6 ------ common/event.c | 1 + configs/galileo_defconfig | 1 + drivers/core/root.c | 5 +++++ include/event.h | 1 + include/init.h | 11 ----------- 27 files changed, 73 insertions(+), 55 deletions(-)
diff --git a/arch/Kconfig b/arch/Kconfig index 39156067b2c..0734397d3d3 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -89,6 +89,7 @@ config NIOS2 bool "Nios II architecture" select CPU select DM + imply DM_EVENT select OF_CONTROL select SUPPORT_OF_CONTROL imply CMD_DM @@ -108,6 +109,7 @@ config RISCV select DM imply DM_SERIAL imply DM_ETH + imply DM_EVENT imply DM_MMC imply DM_SPI imply DM_SPI_FLASH @@ -230,6 +232,7 @@ config X86 imply CMD_SF_TEST imply CMD_ZBOOT imply DM_ETH + imply DM_EVENT imply DM_GPIO imply DM_KEYBOARD imply DM_MMC diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 85c964b7a18..1167bd488d2 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -766,6 +766,7 @@ config ARCH_OMAP2PLUS select SUPPORT_SPL imply TI_SYSC if DM && OF_CONTROL imply FIT + imply DM_EVENT
config ARCH_MESON bool "Amlogic Meson" @@ -823,6 +824,7 @@ config ARCH_IMX8M select DM select SUPPORT_SPL imply CMD_DM + imply DM_EVENT
config ARCH_IMX8ULP bool "NXP i.MX8ULP platform" @@ -833,6 +835,7 @@ config ARCH_IMX8ULP select SUPPORT_SPL select GPIO_EXTRA_HEADER imply CMD_DM + imply DM_EVENT
config ARCH_IMXRT bool "NXP i.MXRT platform" diff --git a/arch/arm/include/asm/omap_common.h b/arch/arm/include/asm/omap_common.h index de8fc99d047..0ebaf269e4c 100644 --- a/arch/arm/include/asm/omap_common.h +++ b/arch/arm/include/asm/omap_common.h @@ -833,6 +833,8 @@ static inline u8 is_dra76x_acd(void)
#ifndef __ASSEMBLY__ u32 omap_sys_boot_device(void); + +void early_system_init(void); #endif
#endif /* _OMAP_COMMON_H_ */ diff --git a/arch/arm/mach-imx/imx8m/soc.c b/arch/arm/mach-imx/imx8m/soc.c index 863508776dd..f270eecfe8b 100644 --- a/arch/arm/mach-imx/imx8m/soc.c +++ b/arch/arm/mach-imx/imx8m/soc.c @@ -7,6 +7,7 @@
#include <common.h> #include <cpu_func.h> +#include <event.h> #include <init.h> #include <log.h> #include <asm/arch/imx-regs.h> @@ -481,7 +482,7 @@ static void imx_set_wdog_powerdown(bool enable) writew(enable, &wdog3->wmcr); }
-int arch_cpu_init_dm(void) +static int imx8m_check_clock(void *ctx, struct event *event) { struct udevice *dev; int ret; @@ -498,6 +499,7 @@ int arch_cpu_init_dm(void)
return 0; } +EVENT_SPY(EVT_DM_POST_INIT, imx8m_check_clock);
int arch_cpu_init(void) { diff --git a/arch/arm/mach-imx/imx8ulp/soc.c b/arch/arm/mach-imx/imx8ulp/soc.c index bba6323f96f..fd3f8c29d8f 100644 --- a/arch/arm/mach-imx/imx8ulp/soc.c +++ b/arch/arm/mach-imx/imx8ulp/soc.c @@ -11,6 +11,7 @@ #include <asm/mach-imx/boot_mode.h> #include <asm/global_data.h> #include <efi_loader.h> +#include <event.h> #include <spl.h> #include <asm/arch/rdc.h> #include <asm/arch/s400_api.h> @@ -495,7 +496,7 @@ int arch_cpu_init(void) return 0; }
-int arch_cpu_init_dm(void) +static int imx8ulp_check_mu(void *ctx, struct event *event) { struct udevice *devp; int node, ret; @@ -510,6 +511,7 @@ int arch_cpu_init_dm(void)
return 0; } +EVENT_SPY(EVT_DM_POST_INIT, imx8ulp_check_mu);
#if defined(CONFIG_SPL_BUILD) __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) diff --git a/arch/arm/mach-omap2/am33xx/board.c b/arch/arm/mach-omap2/am33xx/board.c index c44667668e9..7a4818caa4c 100644 --- a/arch/arm/mach-omap2/am33xx/board.c +++ b/arch/arm/mach-omap2/am33xx/board.c @@ -11,6 +11,7 @@ #include <dm.h> #include <debug_uart.h> #include <errno.h> +#include <event.h> #include <init.h> #include <net.h> #include <ns16550.h> @@ -596,11 +597,12 @@ void board_init_f(ulong dummy)
#endif
-int arch_cpu_init_dm(void) +static int am33xx_dm_post_init(void *ctx, struct event *event) { hw_data_init(); -#if !CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT) - early_system_init(); -#endif + if (!CONFIG_IS_ENABLED(SKIP_LOWLEVEL_INIT)) + early_system_init(); + return 0; } +EVENT_SPY(EVT_DM_POST_INIT, am33xx_dm_post_init); diff --git a/arch/arm/mach-omap2/hwinit-common.c b/arch/arm/mach-omap2/hwinit-common.c index 3da50f974dc..5d4445d5bca 100644 --- a/arch/arm/mach-omap2/hwinit-common.c +++ b/arch/arm/mach-omap2/hwinit-common.c @@ -12,6 +12,7 @@ */ #include <common.h> #include <debug_uart.h> +#include <event.h> #include <fdtdec.h> #include <init.h> #include <spl.h> @@ -239,11 +240,13 @@ void board_init_f(ulong dummy) } #endif
-int arch_cpu_init_dm(void) +int omap2_system_init(void *ctx, struct event *event) { early_system_init(); + return 0; } +EVENT_SPY(EVT_DM_POST_INIT, omap2_system_init);
/* * Routine: wait_for_command_complete diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 28234aa0bb6..06cae68ee57 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig @@ -130,6 +130,7 @@ config MACH_PIC32 config TARGET_BOSTON bool "Support Boston" select DM + imply DM_EVENT select DM_SERIAL select MIPS_CM select SYS_CACHE_SHIFT_6 diff --git a/arch/mips/mach-pic32/cpu.c b/arch/mips/mach-pic32/cpu.c index eac2fe5f8c9..9de4ec0ed63 100644 --- a/arch/mips/mach-pic32/cpu.c +++ b/arch/mips/mach-pic32/cpu.c @@ -7,6 +7,7 @@ #include <common.h> #include <clk.h> #include <dm.h> +#include <event.h> #include <init.h> #include <malloc.h> #include <asm/global_data.h> @@ -95,12 +96,13 @@ static void prefetch_init(void) }
/* arch specific CPU init after DM */ -int arch_cpu_init_dm(void) +int pic32_flash_prefetch(void *ctx, struct event *event) { /* flash prefetch */ prefetch_init(); return 0; } +EVENT_SPY(EVT_DM_POST_INIT, pic32_flash_prefetch);
/* Un-gate DDR2 modules (gated by default) */ static void ddr2_pmd_ungate(void) diff --git a/arch/nios2/cpu/cpu.c b/arch/nios2/cpu/cpu.c index b55c8fbc584..4dd9c10faa5 100644 --- a/arch/nios2/cpu/cpu.c +++ b/arch/nios2/cpu/cpu.c @@ -10,6 +10,7 @@ #include <cpu_func.h> #include <dm.h> #include <errno.h> +#include <event.h> #include <init.h> #include <irq_func.h> #include <asm/cache.h> @@ -63,7 +64,7 @@ static void copy_exception_trampoline(void) } #endif
-int arch_cpu_init_dm(void) +static int nios_cpu_setup(void *ctx, struct event *event) { struct udevice *dev; int ret; @@ -79,6 +80,7 @@ int arch_cpu_init_dm(void)
return 0; } +EVENT_SPY(EVT_DM_POST_INIT, nios_cpu_setup);
static int altera_nios2_get_desc(const struct udevice *dev, char *buf, int size) diff --git a/arch/riscv/cpu/cpu.c b/arch/riscv/cpu/cpu.c index 8d90c5e6b8a..3ffcbbd23fa 100644 --- a/arch/riscv/cpu/cpu.c +++ b/arch/riscv/cpu/cpu.c @@ -7,9 +7,11 @@ #include <cpu.h> #include <dm.h> #include <dm/lists.h> +#include <event.h> #include <init.h> #include <log.h> #include <asm/encoding.h> +#include <asm/system.h> #include <dm/uclass-internal.h> #include <linux/bitops.h>
@@ -81,7 +83,7 @@ static void dummy_pending_ipi_clear(ulong hart, ulong arg0, ulong arg1) } #endif
-int arch_cpu_init_dm(void) +int riscv_cpu_setup(void *ctx, struct event *event) { int ret;
@@ -133,6 +135,7 @@ int arch_cpu_init_dm(void)
return 0; } +EVENT_SPY(EVT_DM_POST_INIT, riscv_cpu_setup);
int arch_early_init_r(void) { diff --git a/arch/riscv/include/asm/system.h b/arch/riscv/include/asm/system.h index a3404758235..9d8e43e3942 100644 --- a/arch/riscv/include/asm/system.h +++ b/arch/riscv/include/asm/system.h @@ -7,6 +7,8 @@ #ifndef __ASM_RISCV_SYSTEM_H #define __ASM_RISCV_SYSTEM_H
+struct event; + /* * Interrupt configuring macros. * @@ -14,4 +16,7 @@ * */
+/* Hook to set up the CPU (called from SPL too) */ +int riscv_cpu_setup(void *ctx, struct event *event); + #endif /* __ASM_RISCV_SYSTEM_H */ diff --git a/arch/riscv/lib/spl.c b/arch/riscv/lib/spl.c index 8baee07beac..f4d3b67e5dd 100644 --- a/arch/riscv/lib/spl.c +++ b/arch/riscv/lib/spl.c @@ -11,6 +11,7 @@ #include <spl.h> #include <asm/global_data.h> #include <asm/smp.h> +#include <asm/system.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -27,7 +28,7 @@ __weak void board_init_f(ulong dummy) if (ret) panic("spl_early_init() failed: %d\n", ret);
- arch_cpu_init_dm(); + riscv_cpu_setup(NULL, NULL);
preloader_console_init();
diff --git a/arch/x86/cpu/baytrail/cpu.c b/arch/x86/cpu/baytrail/cpu.c index 309a50a1161..68bf40ba8e8 100644 --- a/arch/x86/cpu/baytrail/cpu.c +++ b/arch/x86/cpu/baytrail/cpu.c @@ -8,6 +8,7 @@ #include <common.h> #include <cpu.h> #include <dm.h> +#include <event.h> #include <init.h> #include <log.h> #include <pci.h> @@ -44,7 +45,7 @@ static void hsuart_clock_set(void *base) * Configure the internal clock of both SIO HS-UARTs, if they are enabled * via FSP */ -int arch_cpu_init_dm(void) +static int baytrail_uart_init(void *ctx, struct event *event) { struct udevice *dev; void *base; @@ -63,6 +64,7 @@ int arch_cpu_init_dm(void)
return 0; } +EVENT_SPY(EVT_DM_POST_INIT, baytrail_uart_init);
static void set_max_freq(void) { diff --git a/arch/x86/cpu/broadwell/cpu.c b/arch/x86/cpu/broadwell/cpu.c index 3832a97f2c7..2adcf4b242c 100644 --- a/arch/x86/cpu/broadwell/cpu.c +++ b/arch/x86/cpu/broadwell/cpu.c @@ -8,6 +8,7 @@ #include <common.h> #include <dm.h> #include <cpu.h> +#include <event.h> #include <init.h> #include <log.h> #include <asm/cpu.h> @@ -24,7 +25,7 @@ #include <asm/arch/pch.h> #include <asm/arch/rcb.h>
-int arch_cpu_init_dm(void) +static int broadwell_init_cpu(void *ctx, struct event *event) { struct udevice *dev; int ret; @@ -41,6 +42,7 @@ int arch_cpu_init_dm(void)
return 0; } +EVENT_SPY(EVT_DM_POST_INIT, broadwell_init_cpu);
void set_max_freq(void) { diff --git a/arch/x86/cpu/ivybridge/cpu.c b/arch/x86/cpu/ivybridge/cpu.c index a02f4f9600e..cffc5d5b1d8 100644 --- a/arch/x86/cpu/ivybridge/cpu.c +++ b/arch/x86/cpu/ivybridge/cpu.c @@ -14,6 +14,7 @@ #include <cpu_func.h> #include <dm.h> #include <errno.h> +#include <event.h> #include <fdtdec.h> #include <init.h> #include <log.h> @@ -53,7 +54,7 @@ int arch_cpu_init(void) return x86_cpu_init_f(); }
-int arch_cpu_init_dm(void) +static int ivybridge_cpu_init(void *ctx, struct event *ev) { struct pci_controller *hose; struct udevice *bus, *dev; @@ -85,6 +86,7 @@ int arch_cpu_init_dm(void)
return 0; } +EVENT_SPY(EVT_DM_POST_INIT, ivybridge_cpu_init);
#define PCH_EHCI0_TEMP_BAR0 0xe8000000 #define PCH_EHCI1_TEMP_BAR0 0xe8000400 diff --git a/arch/x86/cpu/quark/quark.c b/arch/x86/cpu/quark/quark.c index 30b4711b9a5..2fd4ee3e69e 100644 --- a/arch/x86/cpu/quark/quark.c +++ b/arch/x86/cpu/quark/quark.c @@ -5,6 +5,7 @@
#include <common.h> #include <cpu_func.h> +#include <event.h> #include <init.h> #include <mmc.h> #include <asm/cache.h> @@ -247,7 +248,7 @@ int arch_cpu_init(void) return 0; }
-int arch_cpu_init_dm(void) +static int quark_init_dm(void *ctx, struct event *event) { /* * Initialize PCIe controller @@ -262,6 +263,7 @@ int arch_cpu_init_dm(void)
return 0; } +EVENT_SPY(EVT_DM_POST_INIT, quark_init_dm);
int checkcpu(void) { diff --git a/arch/x86/include/asm/fsp2/fsp_api.h b/arch/x86/include/asm/fsp2/fsp_api.h index af1e8857b97..07e50b271d5 100644 --- a/arch/x86/include/asm/fsp2/fsp_api.h +++ b/arch/x86/include/asm/fsp2/fsp_api.h @@ -60,4 +60,12 @@ int fsp_silicon_init(bool s3wake, bool use_spi_flash);
typedef asmlinkage int (*fsp_silicon_init_func)(struct fsps_upd *params);
+/** + * fsp_setup_pinctrl() - Set up the pinctrl for FSP + * + * @ctx: Event context (not used) + * @event: Event information (not used) + */ +int fsp_setup_pinctrl(void *ctx, struct event *event); + #endif diff --git a/arch/x86/lib/fsp2/fsp_init.c b/arch/x86/lib/fsp2/fsp_init.c index 5afdce1e0d4..b15926e8247 100644 --- a/arch/x86/lib/fsp2/fsp_init.c +++ b/arch/x86/lib/fsp2/fsp_init.c @@ -9,6 +9,7 @@ #include <bootstage.h> #include <cbfs.h> #include <dm.h> +#include <event.h> #include <init.h> #include <log.h> #include <spi.h> @@ -18,7 +19,7 @@ #include <dm/uclass-internal.h> #include <asm/fsp2/fsp_internal.h>
-int arch_cpu_init_dm(void) +int fsp_setup_pinctrl(void *ctx, struct event *event) { struct udevice *dev; ofnode node; @@ -41,6 +42,7 @@ int arch_cpu_init_dm(void)
return ret; } +EVENT_SPY(EVT_DM_POST_INIT, fsp_setup_pinctrl);
#if !defined(CONFIG_TPL_BUILD) binman_sym_declare(ulong, intel_fsp_m, image_pos); diff --git a/arch/x86/lib/spl.c b/arch/x86/lib/spl.c index b18c1cd6092..4260ccde14f 100644 --- a/arch/x86/lib/spl.c +++ b/arch/x86/lib/spl.c @@ -27,11 +27,6 @@
DECLARE_GLOBAL_DATA_PTR;
-__weak int arch_cpu_init_dm(void) -{ - return 0; -} - #ifdef CONFIG_TPL
static int set_max_freq(void) @@ -88,13 +83,6 @@ static int x86_spl_init(void) debug("%s: arch_cpu_init() failed\n", __func__); return ret; } -#ifndef CONFIG_TPL - ret = arch_cpu_init_dm(); - if (ret) { - debug("%s: arch_cpu_init_dm() failed\n", __func__); - return ret; - } -#endif preloader_console_init(); #if !defined(CONFIG_TPL) && !CONFIG_IS_ENABLED(CPU) ret = print_cpuinfo(); diff --git a/arch/x86/lib/tpl.c b/arch/x86/lib/tpl.c index 5b57e53c2dd..18b05b2f672 100644 --- a/arch/x86/lib/tpl.c +++ b/arch/x86/lib/tpl.c @@ -19,11 +19,6 @@
DECLARE_GLOBAL_DATA_PTR;
-__weak int arch_cpu_init_dm(void) -{ - return 0; -} - static int x86_tpl_init(void) { int ret; @@ -44,11 +39,6 @@ static int x86_tpl_init(void) debug("%s: arch_cpu_init() failed\n", __func__); return ret; } - ret = arch_cpu_init_dm(); - if (ret) { - debug("%s: arch_cpu_init_dm() failed\n", __func__); - return ret; - } preloader_console_init();
return 0; diff --git a/common/board_f.c b/common/board_f.c index 7fa3cbe08e3..bf51449bdcd 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -803,11 +803,6 @@ __weak int reserve_arch(void) return 0; }
-__weak int arch_cpu_init_dm(void) -{ - return 0; -} - __weak int checkcpu(void) { return 0; @@ -848,7 +843,6 @@ static const init_fnc_t init_sequence_f[] = { arch_cpu_init, /* basic arch cpu dependent setup */ mach_cpu_init, /* SoC/machine dependent CPU setup */ initf_dm, - arch_cpu_init_dm, #if defined(CONFIG_BOARD_EARLY_INIT_F) board_early_init_f, #endif diff --git a/common/event.c b/common/event.c index 4270809d496..9d67a060a02 100644 --- a/common/event.c +++ b/common/event.c @@ -26,6 +26,7 @@ const char *const type_name[] = { "test",
/* Events related to driver model */ + "dm_post_init", "dm_pre_probe", "dm_post_probe", "dm_pre_remove", diff --git a/configs/galileo_defconfig b/configs/galileo_defconfig index eaa90219b24..168898d994c 100644 --- a/configs/galileo_defconfig +++ b/configs/galileo_defconfig @@ -18,6 +18,7 @@ CONFIG_USE_BOOTCOMMAND=y CONFIG_BOOTCOMMAND="ext2load scsi 0:3 01000000 /boot/vmlinuz; zboot 01000000" CONFIG_SYS_CONSOLE_INFO_QUIET=y CONFIG_DISPLAY_BOARDINFO_LATE=y +CONFIG_EVENT=y CONFIG_LAST_STAGE_INIT=y CONFIG_HUSH_PARSER=y CONFIG_CMD_CPU=y diff --git a/drivers/core/root.c b/drivers/core/root.c index 815173f86eb..62f7f7b971a 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -404,6 +404,11 @@ int dm_init_and_scan(bool pre_reloc_only) return ret; } } + if (CONFIG_IS_ENABLED(DM_EVENT)) { + ret = event_notify_null(EVT_DM_POST_INIT); + if (ret) + return log_msg_ret("ev", ret); + }
return 0; } diff --git a/include/event.h b/include/event.h index f1333af7bd4..f2d3639c82a 100644 --- a/include/event.h +++ b/include/event.h @@ -20,6 +20,7 @@ enum event_t { EVT_TEST,
/* Events related to driver model */ + EVT_DM_POST_INIT, EVT_DM_PRE_PROBE, EVT_DM_POST_PROBE, EVT_DM_PRE_REMOVE, diff --git a/include/init.h b/include/init.h index f1c3982319f..52c5606b887 100644 --- a/include/init.h +++ b/include/init.h @@ -42,17 +42,6 @@ void board_init_f(ulong dummy); */ int arch_cpu_init(void);
-/** - * arch_cpu_init_dm() - init CPU after driver model is available - * - * This is called immediately after driver model is available before - * relocation. This is similar to arch_cpu_init() but is able to reference - * devices - * - * Return: 0 if OK, -ve on error - */ -int arch_cpu_init_dm(void); - /** * mach_cpu_init() - SoC/machine dependent CPU setup *