Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Rick Chen | 6eedd92 | 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 | 6eedd92 | 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> |
Bin Meng | 8294bb5 | 2018-09-26 06:55:16 -0700 | [diff] [blame] | 14 | #include <asm/csr.h> |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
| 17 | |
Alexander Graf | 7ea64b0 | 2018-04-23 07:59:46 +0200 | [diff] [blame] | 18 | __weak void board_quiesce_devices(void) |
| 19 | { |
| 20 | } |
| 21 | |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 22 | int arch_fixup_fdt(void *blob) |
| 23 | { |
| 24 | return 0; |
| 25 | } |
| 26 | |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 27 | int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images) |
| 28 | { |
Bin Meng | aca590b | 2018-09-26 06:55:08 -0700 | [diff] [blame] | 29 | void (*kernel)(ulong hart, void *dtb); |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 30 | |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 31 | /* |
| 32 | * allow the PREP bootm subcommand, it is required for bootm to work |
| 33 | */ |
| 34 | if (flag & BOOTM_STATE_OS_PREP) |
| 35 | return 0; |
| 36 | |
| 37 | if ((flag != 0) && (flag != BOOTM_STATE_OS_GO)) |
| 38 | return 1; |
| 39 | |
Bin Meng | aca590b | 2018-09-26 06:55:08 -0700 | [diff] [blame] | 40 | kernel = (void (*)(ulong, void *))images->ep; |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 41 | |
| 42 | bootstage_mark(BOOTSTAGE_ID_RUN_OS); |
| 43 | |
| 44 | debug("## Transferring control to Linux (at address %08lx) ...\n", |
Bin Meng | aca590b | 2018-09-26 06:55:08 -0700 | [diff] [blame] | 45 | (ulong)kernel); |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 46 | |
| 47 | if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) { |
| 48 | #ifdef CONFIG_OF_LIBFDT |
| 49 | debug("using: FDT\n"); |
| 50 | if (image_setup_linux(images)) { |
| 51 | printf("FDT creation failed! hanging..."); |
| 52 | hang(); |
| 53 | } |
| 54 | #endif |
Rick Chen | 53b47b8 | 2018-03-13 14:59:41 +0800 | [diff] [blame] | 55 | } |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 56 | |
| 57 | /* we assume that the kernel is in place */ |
| 58 | printf("\nStarting kernel ...\n\n"); |
| 59 | |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 60 | cleanup_before_linux(); |
Bin Meng | 8294bb5 | 2018-09-26 06:55:16 -0700 | [diff] [blame] | 61 | |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 62 | if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) |
Bin Meng | 8294bb5 | 2018-09-26 06:55:16 -0700 | [diff] [blame] | 63 | kernel(csr_read(mhartid), images->ft_addr); |
Rick Chen | 53b47b8 | 2018-03-13 14:59:41 +0800 | [diff] [blame] | 64 | |
Rick Chen | 6eedd92 | 2017-12-26 13:55:49 +0800 | [diff] [blame] | 65 | /* does not return */ |
| 66 | |
| 67 | return 1; |
| 68 | } |