1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2011 Andes Technology Corporation
4 * Shawn Lin, Andes Technology Corporation <nobuhiro@andestech.com>
5 * Macpaul Lin, Andes Technology Corporation <macpaul@andestech.com>
6 * Rick Chen, Andes Technology Corporation <rick@andestech.com>
12 #include <asm/byteorder.h>
14 #include <dm/device.h>
16 #include <u-boot/zlib.h>
18 DECLARE_GLOBAL_DATA_PTR;
20 __weak void board_quiesce_devices(void)
24 int arch_fixup_fdt(void *blob)
29 int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
31 void (*kernel)(ulong hart, void *dtb);
34 * allow the PREP bootm subcommand, it is required for bootm to work
36 if (flag & BOOTM_STATE_OS_PREP)
39 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
42 kernel = (void (*)(ulong, void *))images->ep;
44 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
46 debug("## Transferring control to Linux (at address %08lx) ...\n",
49 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
50 #ifdef CONFIG_OF_LIBFDT
51 debug("using: FDT\n");
52 if (image_setup_linux(images)) {
53 printf("FDT creation failed! hanging...");
59 /* we assume that the kernel is in place */
60 printf("\nStarting kernel ...\n\n");
63 * Call remove function of all devices with a removal flag set.
64 * This may be useful for last-stage operations, like cancelling
65 * of DMA operation or releasing device internal buffers.
67 dm_remove_devices_flags(DM_REMOVE_ACTIVE_ALL);
69 cleanup_before_linux();
71 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
72 kernel(csr_read(mhartid), images->ft_addr);