cmd: bind: Fix driver binding on a device
[platform/kernel/u-boot.git] / board / congatec / cgtqmx8 / spl.c
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 <init.h>
10 #include <log.h>
11 #include <spl.h>
12 #include <dm/uclass.h>
13 #include <dm/device.h>
14 #include <dm/uclass-internal.h>
15 #include <dm/device-internal.h>
16 #include <dm/lists.h>
17
18 DECLARE_GLOBAL_DATA_PTR;
19
20 void spl_board_init(void)
21 {
22         struct udevice *dev;
23         int offset;
24
25         uclass_find_first_device(UCLASS_MISC, &dev);
26
27         for (; dev; uclass_find_next_device(&dev)) {
28                 if (device_probe(dev))
29                         continue;
30         }
31
32         offset = fdt_node_offset_by_compatible(gd->fdt_blob, -1, "nxp,imx8-pd");
33         while (offset != -FDT_ERR_NOTFOUND) {
34                 lists_bind_fdt(gd->dm_root, offset_to_ofnode(offset),
35                                NULL, NULL, true);
36                 offset = fdt_node_offset_by_compatible(gd->fdt_blob, offset,
37                                                        "nxp,imx8-pd");
38         }
39
40         uclass_find_first_device(UCLASS_POWER_DOMAIN, &dev);
41
42         for (; dev; uclass_find_next_device(&dev)) {
43                 if (device_probe(dev))
44                         continue;
45         }
46
47         arch_cpu_init();
48
49         board_early_init_f();
50
51         timer_init();
52
53         preloader_console_init();
54
55         puts("Normal Boot\n");
56 }
57
58 #if (IS_ENABLED(CONFIG_SPL_LOAD_FIT))
59 int board_fit_config_name_match(const char *name)
60 {
61         /* Just empty function now - can't decide what to choose */
62         debug("%s: %s\n", __func__, name);
63
64         return 0;
65 }
66 #endif
67
68 void board_init_f(ulong dummy)
69 {
70         /* Clear global data */
71         memset((void *)gd, 0, sizeof(gd_t));
72
73         /* Clear the BSS. */
74         memset(__bss_start, 0, __bss_end - __bss_start);
75
76         board_init_r(NULL, 0);
77 }