Simon Glass | 7cf5fe0 | 2019-05-02 10:52:12 -0600 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Copyright (c) 2018 Google, Inc |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
| 7 | #include <debug_uart.h> |
| 8 | #include <spl.h> |
| 9 | #include <asm/cpu.h> |
| 10 | #include <asm/mtrr.h> |
| 11 | #include <asm/processor.h> |
| 12 | #include <asm-generic/sections.h> |
| 13 | |
| 14 | DECLARE_GLOBAL_DATA_PTR; |
| 15 | |
| 16 | __weak int arch_cpu_init_dm(void) |
| 17 | { |
| 18 | return 0; |
| 19 | } |
| 20 | |
| 21 | static int x86_tpl_init(void) |
| 22 | { |
| 23 | int ret; |
| 24 | |
| 25 | debug("%s starting\n", __func__); |
| 26 | ret = spl_init(); |
| 27 | if (ret) { |
| 28 | debug("%s: spl_init() failed\n", __func__); |
| 29 | return ret; |
| 30 | } |
| 31 | ret = arch_cpu_init(); |
| 32 | if (ret) { |
| 33 | debug("%s: arch_cpu_init() failed\n", __func__); |
| 34 | return ret; |
| 35 | } |
| 36 | ret = arch_cpu_init_dm(); |
| 37 | if (ret) { |
| 38 | debug("%s: arch_cpu_init_dm() failed\n", __func__); |
| 39 | return ret; |
| 40 | } |
| 41 | preloader_console_init(); |
| 42 | ret = print_cpuinfo(); |
| 43 | if (ret) { |
| 44 | debug("%s: print_cpuinfo() failed\n", __func__); |
| 45 | return ret; |
| 46 | } |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | void board_init_f(ulong flags) |
| 52 | { |
| 53 | int ret; |
| 54 | |
| 55 | ret = x86_tpl_init(); |
| 56 | if (ret) { |
| 57 | debug("Error %d\n", ret); |
| 58 | hang(); |
| 59 | } |
| 60 | |
| 61 | /* Uninit CAR and jump to board_init_f_r() */ |
| 62 | board_init_r(gd, 0); |
| 63 | } |
| 64 | |
| 65 | void board_init_f_r(void) |
| 66 | { |
| 67 | /* Not used since we never call board_init_f_r_trampoline() */ |
| 68 | while (1); |
| 69 | } |
| 70 | |
| 71 | u32 spl_boot_device(void) |
| 72 | { |
| 73 | return IS_ENABLED(CONFIG_CHROMEOS) ? BOOT_DEVICE_CROS_VBOOT : |
| 74 | BOOT_DEVICE_BOARD; |
| 75 | } |
| 76 | |
| 77 | int spl_start_uboot(void) |
| 78 | { |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | void spl_board_announce_boot_device(void) |
| 83 | { |
| 84 | printf("SPI flash"); |
| 85 | } |
| 86 | |
| 87 | static int spl_board_load_image(struct spl_image_info *spl_image, |
| 88 | struct spl_boot_device *bootdev) |
| 89 | { |
| 90 | spl_image->size = CONFIG_SYS_MONITOR_LEN; /* We don't know SPL size */ |
| 91 | spl_image->entry_point = CONFIG_SPL_TEXT_BASE; |
| 92 | spl_image->load_addr = CONFIG_SPL_TEXT_BASE; |
| 93 | spl_image->os = IH_OS_U_BOOT; |
| 94 | spl_image->name = "U-Boot"; |
| 95 | |
| 96 | debug("Loading to %lx\n", spl_image->load_addr); |
| 97 | |
| 98 | return 0; |
| 99 | } |
| 100 | SPL_LOAD_IMAGE_METHOD("SPI", 0, BOOT_DEVICE_BOARD, spl_board_load_image); |
| 101 | |
| 102 | int spl_spi_load_image(void) |
| 103 | { |
| 104 | return -EPERM; |
| 105 | } |
| 106 | |
| 107 | void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) |
| 108 | { |
| 109 | printf("Jumping to U-Boot SPL at %lx\n", (ulong)spl_image->entry_point); |
| 110 | jump_to_spl(spl_image->entry_point); |
| 111 | while (1) |
| 112 | ; |
| 113 | } |
| 114 | |
| 115 | void spl_board_init(void) |
| 116 | { |
| 117 | preloader_console_init(); |
| 118 | } |