]>
Commit | Line | Data |
---|---|---|
7c03caf6 SG |
1 | // SPDX-License-Identifier: GPL-2.0 |
2 | /* | |
3 | * Copyright (c) 2018 Google, Inc | |
4 | */ | |
5 | ||
6 | #include <common.h> | |
7 | #include <debug_uart.h> | |
0ced70a0 | 8 | #include <dm.h> |
db41d65a | 9 | #include <hang.h> |
4d72caa5 | 10 | #include <image.h> |
7c03caf6 SG |
11 | #include <spl.h> |
12 | #include <asm/cpu.h> | |
13 | #include <asm/mtrr.h> | |
14 | #include <asm/processor.h> | |
15 | #include <asm-generic/sections.h> | |
16 | ||
17 | DECLARE_GLOBAL_DATA_PTR; | |
18 | ||
19 | __weak int arch_cpu_init_dm(void) | |
20 | { | |
21 | return 0; | |
22 | } | |
23 | ||
24 | static int x86_tpl_init(void) | |
25 | { | |
26 | int ret; | |
27 | ||
28 | debug("%s starting\n", __func__); | |
0e72ac71 SG |
29 | ret = x86_cpu_init_tpl(); |
30 | if (ret) { | |
31 | debug("%s: x86_cpu_init_tpl() failed\n", __func__); | |
32 | return ret; | |
33 | } | |
7c03caf6 SG |
34 | ret = spl_init(); |
35 | if (ret) { | |
36 | debug("%s: spl_init() failed\n", __func__); | |
37 | return ret; | |
38 | } | |
39 | ret = arch_cpu_init(); | |
40 | if (ret) { | |
41 | debug("%s: arch_cpu_init() failed\n", __func__); | |
42 | return ret; | |
43 | } | |
44 | ret = arch_cpu_init_dm(); | |
45 | if (ret) { | |
46 | debug("%s: arch_cpu_init_dm() failed\n", __func__); | |
47 | return ret; | |
48 | } | |
49 | preloader_console_init(); | |
7c03caf6 SG |
50 | |
51 | return 0; | |
52 | } | |
53 | ||
54 | void board_init_f(ulong flags) | |
55 | { | |
56 | int ret; | |
57 | ||
58 | ret = x86_tpl_init(); | |
59 | if (ret) { | |
60 | debug("Error %d\n", ret); | |
3d95688c | 61 | panic("x86_tpl_init fail"); |
7c03caf6 SG |
62 | } |
63 | ||
64 | /* Uninit CAR and jump to board_init_f_r() */ | |
65 | board_init_r(gd, 0); | |
66 | } | |
67 | ||
68 | void board_init_f_r(void) | |
69 | { | |
70 | /* Not used since we never call board_init_f_r_trampoline() */ | |
71 | while (1); | |
72 | } | |
73 | ||
74 | u32 spl_boot_device(void) | |
75 | { | |
76 | return IS_ENABLED(CONFIG_CHROMEOS) ? BOOT_DEVICE_CROS_VBOOT : | |
daade119 | 77 | BOOT_DEVICE_SPI_MMAP; |
7c03caf6 SG |
78 | } |
79 | ||
80 | int spl_start_uboot(void) | |
81 | { | |
82 | return 0; | |
83 | } | |
84 | ||
85 | void spl_board_announce_boot_device(void) | |
86 | { | |
87 | printf("SPI flash"); | |
88 | } | |
89 | ||
90 | static int spl_board_load_image(struct spl_image_info *spl_image, | |
91 | struct spl_boot_device *bootdev) | |
92 | { | |
93 | spl_image->size = CONFIG_SYS_MONITOR_LEN; /* We don't know SPL size */ | |
94 | spl_image->entry_point = CONFIG_SPL_TEXT_BASE; | |
95 | spl_image->load_addr = CONFIG_SPL_TEXT_BASE; | |
96 | spl_image->os = IH_OS_U_BOOT; | |
97 | spl_image->name = "U-Boot"; | |
98 | ||
99 | debug("Loading to %lx\n", spl_image->load_addr); | |
100 | ||
101 | return 0; | |
102 | } | |
daade119 | 103 | SPL_LOAD_IMAGE_METHOD("SPI", 5, BOOT_DEVICE_SPI_MMAP, spl_board_load_image); |
7c03caf6 SG |
104 | |
105 | int spl_spi_load_image(void) | |
106 | { | |
107 | return -EPERM; | |
108 | } | |
109 | ||
110 | void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) | |
111 | { | |
73c6cd6c | 112 | debug("Jumping to U-Boot SPL at %lx\n", (ulong)spl_image->entry_point); |
7c03caf6 | 113 | jump_to_spl(spl_image->entry_point); |
14dd93be | 114 | hang(); |
7c03caf6 SG |
115 | } |
116 | ||
117 | void spl_board_init(void) | |
118 | { | |
119 | preloader_console_init(); | |
120 | } | |
0ced70a0 SG |
121 | |
122 | #if !CONFIG_IS_ENABLED(PCI) | |
123 | /* | |
124 | * This is a fake PCI bus for TPL when it doesn't have proper PCI. It is enough | |
125 | * to bind the devices on the PCI bus, some of which have early-regs properties | |
126 | * providing fixed BARs. Individual drivers program these BARs themselves so | |
127 | * that they can access the devices. The BARs are allocated statically in the | |
128 | * device tree. | |
129 | * | |
130 | * Once SPL is running it enables PCI properly, but does not auto-assign BARs | |
131 | * for devices, so the TPL BARs continue to be used. Once U-Boot starts it does | |
132 | * the auto allocation (after relocation). | |
133 | */ | |
134 | static const struct udevice_id tpl_fake_pci_ids[] = { | |
135 | { .compatible = "pci-x86" }, | |
136 | { } | |
137 | }; | |
138 | ||
139 | U_BOOT_DRIVER(pci_x86) = { | |
140 | .name = "pci_x86", | |
141 | .id = UCLASS_SIMPLE_BUS, | |
142 | .of_match = tpl_fake_pci_ids, | |
143 | }; | |
144 | #endif |