blob: 6893108fe324b1ba66ce7dd2ec651010ff74306e [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Rick Chen8bbb2902017-12-26 13:55:49 +08002/*
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>
Rick Chen8bbb2902017-12-26 13:55:49 +08007 */
8
9#include <common.h>
10#include <command.h>
11#include <image.h>
12#include <u-boot/zlib.h>
13#include <asm/byteorder.h>
Rick Chen8bbb2902017-12-26 13:55:49 +080014
15DECLARE_GLOBAL_DATA_PTR;
16
Alexander Grafb66babd2018-04-23 07:59:46 +020017__weak void board_quiesce_devices(void)
18{
19}
20
Rick Chen8bbb2902017-12-26 13:55:49 +080021int arch_fixup_fdt(void *blob)
22{
23 return 0;
24}
25
Rick Chen8bbb2902017-12-26 13:55:49 +080026int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
27{
Bin Meng4afeedf2018-09-26 06:55:08 -070028 void (*kernel)(ulong hart, void *dtb);
Rick Chen8bbb2902017-12-26 13:55:49 +080029
Rick Chen8bbb2902017-12-26 13:55:49 +080030 /*
31 * allow the PREP bootm subcommand, it is required for bootm to work
32 */
33 if (flag & BOOTM_STATE_OS_PREP)
34 return 0;
35
36 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
37 return 1;
38
Bin Meng4afeedf2018-09-26 06:55:08 -070039 kernel = (void (*)(ulong, void *))images->ep;
Rick Chen8bbb2902017-12-26 13:55:49 +080040
41 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
42
43 debug("## Transferring control to Linux (at address %08lx) ...\n",
Bin Meng4afeedf2018-09-26 06:55:08 -070044 (ulong)kernel);
Rick Chen8bbb2902017-12-26 13:55:49 +080045
46 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
47#ifdef CONFIG_OF_LIBFDT
48 debug("using: FDT\n");
49 if (image_setup_linux(images)) {
50 printf("FDT creation failed! hanging...");
51 hang();
52 }
53#endif
Rick Chen22b7e6f2018-03-13 14:59:41 +080054 }
Rick Chen8bbb2902017-12-26 13:55:49 +080055
56 /* we assume that the kernel is in place */
57 printf("\nStarting kernel ...\n\n");
58
Rick Chen8bbb2902017-12-26 13:55:49 +080059 cleanup_before_linux();
Bin Meng4afeedf2018-09-26 06:55:08 -070060 /* TODO: hardcode the hart id to zero for now */
Rick Chen8bbb2902017-12-26 13:55:49 +080061 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
Bin Meng4afeedf2018-09-26 06:55:08 -070062 kernel(0, images->ft_addr);
Rick Chen22b7e6f2018-03-13 14:59:41 +080063
Rick Chen8bbb2902017-12-26 13:55:49 +080064 /* does not return */
65
66 return 1;
67}