blob: 2610a57bbff32e6d9f9c0d63840177c43973bfeb [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Rick Chen6eedd922017-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 Chen6eedd922017-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>
14#include <asm/bootm.h>
15
16DECLARE_GLOBAL_DATA_PTR;
17
Alexander Graf7ea64b02018-04-23 07:59:46 +020018__weak void board_quiesce_devices(void)
19{
20}
21
Rick Chen6eedd922017-12-26 13:55:49 +080022int arch_fixup_fdt(void *blob)
23{
24 return 0;
25}
26
Rick Chen6eedd922017-12-26 13:55:49 +080027int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
28{
29 bd_t *bd = gd->bd;
30 char *s;
31 int machid = bd->bi_arch_number;
Rick Chen632a5692018-03-13 14:48:33 +080032 void (*theKernel)(int arch, uint params);
Rick Chen6eedd922017-12-26 13:55:49 +080033
Rick Chen6eedd922017-12-26 13:55:49 +080034 /*
35 * allow the PREP bootm subcommand, it is required for bootm to work
36 */
37 if (flag & BOOTM_STATE_OS_PREP)
38 return 0;
39
40 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
41 return 1;
42
Rick Chen632a5692018-03-13 14:48:33 +080043 theKernel = (void (*)(int, uint))images->ep;
Rick Chen6eedd922017-12-26 13:55:49 +080044
45 s = env_get("machid");
46 if (s) {
47 machid = simple_strtoul(s, NULL, 16);
48 printf("Using machid 0x%x from environment\n", machid);
49 }
50
51 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
52
53 debug("## Transferring control to Linux (at address %08lx) ...\n",
54 (ulong)theKernel);
55
56 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
57#ifdef CONFIG_OF_LIBFDT
58 debug("using: FDT\n");
59 if (image_setup_linux(images)) {
60 printf("FDT creation failed! hanging...");
61 hang();
62 }
63#endif
Rick Chen53b47b82018-03-13 14:59:41 +080064 }
Rick Chen6eedd922017-12-26 13:55:49 +080065
66 /* we assume that the kernel is in place */
67 printf("\nStarting kernel ...\n\n");
68
Rick Chen6eedd922017-12-26 13:55:49 +080069 cleanup_before_linux();
70 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len)
Rick Chen632a5692018-03-13 14:48:33 +080071 theKernel(machid, (unsigned long)images->ft_addr);
Rick Chen53b47b82018-03-13 14:59:41 +080072
Rick Chen6eedd922017-12-26 13:55:49 +080073 /* does not return */
74
75 return 1;
76}