Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 2 | /* |
| 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 Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 7 | */ |
| 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 Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 14 | |
| 15 | DECLARE_GLOBAL_DATA_PTR; |
| 16 | |
Alexander Graf | b66babd | 2018-04-23 07:59:46 +0200 | [diff] [blame] | 17 | __weak void board_quiesce_devices(void) |
| 18 | { |
| 19 | } |
| 20 | |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 21 | int arch_fixup_fdt(void *blob) |
| 22 | { |
| 23 | return 0; |
| 24 | } |
| 25 | |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 26 | int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) |
| 27 | { |
Bin Meng | 4afeedf | 2018-09-26 06:55:08 -0700 | [diff] [blame^] | 28 | void (*kernel)(ulong hart, void *dtb); |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 29 | |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 30 | /* |
| 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 Meng | 4afeedf | 2018-09-26 06:55:08 -0700 | [diff] [blame^] | 39 | kernel = (void (*)(ulong, void *))images->ep; |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 40 | |
| 41 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); |
| 42 | |
| 43 | debug("## Transferring control to Linux (at address %08lx) ...\n", |
Bin Meng | 4afeedf | 2018-09-26 06:55:08 -0700 | [diff] [blame^] | 44 | (ulong)kernel); |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 45 | |
| 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 Chen | 22b7e6f | 2018-03-13 14:59:41 +0800 | [diff] [blame] | 54 | } |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 55 | |
| 56 | /* we assume that the kernel is in place */ |
| 57 | printf("\nStarting kernel ...\n\n"); |
| 58 | |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 59 | cleanup_before_linux(); |
Bin Meng | 4afeedf | 2018-09-26 06:55:08 -0700 | [diff] [blame^] | 60 | /* TODO: hardcode the hart id to zero for now */ |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 61 | if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) |
Bin Meng | 4afeedf | 2018-09-26 06:55:08 -0700 | [diff] [blame^] | 62 | kernel(0, images->ft_addr); |
Rick Chen | 22b7e6f | 2018-03-13 14:59:41 +0800 | [diff] [blame] | 63 | |
Rick Chen | 8bbb290 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 64 | /* does not return */ |
| 65 | |
| 66 | return 1; |
| 67 | } |