hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
u-boot/drivers/cpu/rockchip_amp.c
....@@ -134,7 +134,7 @@
134134 flush_dcache_all();
135135
136136 /* fixup: ramdisk/fdt/entry depend on U-Boot */
137
- *entry = env_get_ulong("kernel_addr_r", 16, 0);
137
+ *entry = (u32)images.ep;
138138
139139 return 0;
140140 }
....@@ -206,6 +206,31 @@
206206 return 0;
207207 }
208208
209
+__weak int fit_standalone_release(char *id, uintptr_t entry_point)
210
+{
211
+ return 0;
212
+}
213
+
214
+static int standalone_handler(const char *id, u32 entry_point, int data_size)
215
+{
216
+ int ret;
217
+
218
+ if (!sysmem_alloc_base_by_name(id,
219
+ (phys_addr_t)entry_point, data_size))
220
+ return -ENXIO;
221
+
222
+ printf("Handle standalone: '%s' at 0x%08x ...", id, entry_point);
223
+
224
+ ret = fit_standalone_release((char *)id, entry_point);
225
+ if (ret) {
226
+ printf("failed, ret=%d\n", ret);
227
+ return ret;
228
+ }
229
+ printf("OK\n");
230
+
231
+ return 0;
232
+}
233
+
209234 static int brought_up_amp(void *fit, int noffset,
210235 boot_cpu_t *bootcpu, int is_linux)
211236 {
....@@ -217,27 +242,38 @@
217242 int boot_on;
218243 int data_size;
219244 int i, ret;
220
- u8 arch = -ENODATA;
245
+ u8 type = -ENODATA;
246
+ u8 arch = -ENODATA;
221247
222248 desc = fdt_getprop(fit, noffset, "description", NULL);
223249 cpu = fit_get_u32_default(fit, noffset, "cpu", -ENODATA);
224250 hyp = fit_get_u32_default(fit, noffset, "hyp", 0);
225251 thumb = fit_get_u32_default(fit, noffset, "thumb", 0);
226
- load = fit_get_u32_default(fit, noffset, "load", -ENODATA);
252
+ entry = load = fit_get_u32_default(fit, noffset, "load", -ENODATA);
227253 us = fit_get_u32_default(fit, noffset, "udelay", 0);
228254 boot_on = fit_get_u32_default(fit, noffset, "boot-on", 1);
229255 fit_image_get_arch(fit, noffset, &arch);
256
+ fit_image_get_type(fit, noffset, &type);
230257 fit_image_get_data_size(fit, noffset, &data_size);
231258 memset(&args, 0, sizeof(args));
232259
233
- if (!desc || cpu == -ENODATA || arch == -ENODATA ||
260
+ /* standalone is simple, just handle it and then exit. Allow failure */
261
+ if (type == IH_TYPE_STANDALONE) {
262
+ if (!desc || load == -ENODATA) {
263
+ AMP_E("standalone: \"desc\" or \"load\" property missing!\n");
264
+ goto exit;
265
+ }
266
+ standalone_handler(desc, load, data_size);
267
+ goto exit;
268
+ }
269
+
270
+ if (!desc || cpu == -ENODATA || arch == -ENODATA || type == -ENODATA ||
234271 (load == -ENODATA && !is_linux)) {
235272 AMP_E("Property missing!\n");
236273 return -EINVAL;
237274 }
238275 aarch64 = (arch == IH_ARCH_ARM) ? 0 : 1;
239276 pe_state = PE_STATE(aarch64, hyp, thumb, 0);
240
- entry = load;
241277
242278 #ifdef DEBUG
243279 AMP_I(" desc: %s\n", desc);
....@@ -245,7 +281,7 @@
245281 AMP_I(" aarch64: %d\n", aarch64);
246282 AMP_I(" hyp: %d\n", hyp);
247283 AMP_I(" thumb: %d\n", thumb);
248
- AMP_I(" entry: 0x%08x\n", entry);
284
+ AMP_I(" load: 0x%08x\n", load);
249285 AMP_I(" pe_state: 0x%08x\n", pe_state);
250286 AMP_I(" linux-os: %d\n\n", is_linux);
251287 #endif
....@@ -294,7 +330,7 @@
294330 ret = smc_cpu_on(cpu, pe_state, entry, &args, is_linux);
295331 if (ret)
296332 return ret;
297
-
333
+exit:
298334 if (us)
299335 udelay(us);
300336
....@@ -336,7 +372,7 @@
336372
337373 /* === only boot cpu can reach here === */
338374
339
- if (!g_bootcpu.linux_os) {
375
+ if (!g_bootcpu.linux_os && g_bootcpu.entry) {
340376 flush_dcache_all();
341377 AMP_I("Brought up cpu[%x, self] with state 0x%x, entry 0x%08x ...",
342378 (u32)read_mpidr() & 0x0fff, g_bootcpu.state, g_bootcpu.entry);