1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright 2018 NXP
4 *
5 */
6
7#include <common.h>
8#include <dm.h>
9#include <fdt_support.h>
10#include <init.h>
11#include <log.h>
12#include <spl.h>
13#include <asm/sections.h>
14#include <dm/uclass.h>
15#include <dm/device.h>
16#include <dm/uclass-internal.h>
17#include <dm/device-internal.h>
18#include <dm/lists.h>
19
20DECLARE_GLOBAL_DATA_PTR;
21
22void spl_board_init(void)
23{
24	struct udevice *dev;
25	int offset;
26
27	uclass_find_first_device(UCLASS_MISC, &dev);
28
29	for (; dev; uclass_find_next_device(&dev)) {
30		if (device_probe(dev))
31			continue;
32	}
33
34	fdt_for_each_node_by_compatible(offset, gd->fdt_blob, -1,
35					"nxp,imx8-pd")
36		lists_bind_fdt(gd->dm_root, offset_to_ofnode(offset),
37			       NULL, NULL, true);
38
39	uclass_find_first_device(UCLASS_POWER_DOMAIN, &dev);
40
41	for (; dev; uclass_find_next_device(&dev)) {
42		if (device_probe(dev))
43			continue;
44	}
45
46	arch_cpu_init();
47
48	board_early_init_f();
49
50	timer_init();
51
52	preloader_console_init();
53
54	puts("Normal Boot\n");
55}
56
57#if (IS_ENABLED(CONFIG_SPL_LOAD_FIT))
58int board_fit_config_name_match(const char *name)
59{
60	/* Just empty function now - can't decide what to choose */
61	debug("%s: %s\n", __func__, name);
62
63	return 0;
64}
65#endif
66
67void board_init_f(ulong dummy)
68{
69	/* Clear global data */
70	memset((void *)gd, 0, sizeof(gd_t));
71
72	/* Clear the BSS. */
73	memset(__bss_start, 0, __bss_end - __bss_start);
74
75	board_init_r(NULL, 0);
76}
77