Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 2 | /* |
Michal Simek | 3e1b61d | 2018-01-17 07:37:47 +0100 | [diff] [blame] | 3 | * (C) Copyright 2014 - 2017 Xilinx, Inc. Michal Simek |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 4 | */ |
| 5 | #include <common.h> |
Simon Glass | c54c0a4 | 2015-10-17 19:41:22 -0600 | [diff] [blame] | 6 | #include <debug_uart.h> |
Simon Glass | db41d65 | 2019-12-28 10:45:07 -0700 | [diff] [blame] | 7 | #include <hang.h> |
Simon Glass | 4d72caa | 2020-05-10 11:40:01 -0600 | [diff] [blame] | 8 | #include <image.h> |
Simon Glass | 691d719 | 2020-05-10 11:40:02 -0600 | [diff] [blame] | 9 | #include <init.h> |
Simon Glass | f7ae49f | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 10 | #include <log.h> |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 11 | #include <spl.h> |
Michal Simek | dacec83 | 2020-02-18 15:03:13 +0100 | [diff] [blame] | 12 | #include <generated/dt.h> |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 13 | |
| 14 | #include <asm/io.h> |
Michal Simek | ae2ee77 | 2014-08-11 14:03:15 +0200 | [diff] [blame] | 15 | #include <asm/spl.h> |
Simon Glass | bd44758 | 2015-10-17 19:41:21 -0600 | [diff] [blame] | 16 | #include <asm/arch/hardware.h> |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 17 | #include <asm/arch/sys_proto.h> |
Michal Simek | f0b619e | 2017-11-08 16:14:47 +0100 | [diff] [blame] | 18 | #include <asm/arch/ps7_init_gpl.h> |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 19 | |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 20 | void board_init_f(ulong dummy) |
| 21 | { |
| 22 | ps7_init(); |
| 23 | |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 24 | arch_cpu_init(); |
Michal Simek | 57213c5 | 2018-04-19 12:36:48 +0200 | [diff] [blame] | 25 | |
| 26 | #ifdef CONFIG_DEBUG_UART |
| 27 | /* Uart debug for sure */ |
| 28 | debug_uart_init(); |
| 29 | puts("Debug uart enabled\n"); /* or printch() */ |
| 30 | #endif |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 31 | } |
| 32 | |
Michal Simek | 1540fb7 | 2014-04-25 12:15:40 +0200 | [diff] [blame] | 33 | #ifdef CONFIG_SPL_BOARD_INIT |
| 34 | void spl_board_init(void) |
| 35 | { |
Simon Glass | 5fa030b | 2015-10-19 06:50:02 -0600 | [diff] [blame] | 36 | preloader_console_init(); |
Luis Araneda | 577012d | 2018-07-19 03:10:18 -0400 | [diff] [blame] | 37 | #if defined(CONFIG_ARCH_EARLY_INIT_R) && defined(CONFIG_SPL_FPGA_SUPPORT) |
| 38 | arch_early_init_r(); |
| 39 | #endif |
Michal Simek | 1540fb7 | 2014-04-25 12:15:40 +0200 | [diff] [blame] | 40 | board_init(); |
| 41 | } |
| 42 | #endif |
| 43 | |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 44 | u32 spl_boot_device(void) |
| 45 | { |
| 46 | u32 mode; |
| 47 | |
| 48 | switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) { |
| 49 | #ifdef CONFIG_SPL_SPI_SUPPORT |
| 50 | case ZYNQ_BM_QSPI: |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 51 | mode = BOOT_DEVICE_SPI; |
| 52 | break; |
| 53 | #endif |
Michal Simek | 63e3cea | 2015-01-13 16:04:10 +0100 | [diff] [blame] | 54 | case ZYNQ_BM_NAND: |
| 55 | mode = BOOT_DEVICE_NAND; |
| 56 | break; |
| 57 | case ZYNQ_BM_NOR: |
| 58 | mode = BOOT_DEVICE_NOR; |
| 59 | break; |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 60 | #ifdef CONFIG_SPL_MMC_SUPPORT |
| 61 | case ZYNQ_BM_SD: |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 62 | mode = BOOT_DEVICE_MMC1; |
| 63 | break; |
| 64 | #endif |
Michal Simek | 63e3cea | 2015-01-13 16:04:10 +0100 | [diff] [blame] | 65 | case ZYNQ_BM_JTAG: |
| 66 | mode = BOOT_DEVICE_RAM; |
| 67 | break; |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 68 | default: |
| 69 | puts("Unsupported boot mode selected\n"); |
| 70 | hang(); |
| 71 | } |
| 72 | |
| 73 | return mode; |
| 74 | } |
| 75 | |
Michal Simek | d7e269c | 2014-01-14 14:21:52 +0100 | [diff] [blame] | 76 | #ifdef CONFIG_SPL_OS_BOOT |
| 77 | int spl_start_uboot(void) |
| 78 | { |
| 79 | /* boot linux */ |
| 80 | return 0; |
| 81 | } |
| 82 | #endif |
Masahiro Yamada | 66e6715 | 2014-05-12 12:18:30 +0900 | [diff] [blame] | 83 | |
Michal Simek | f44e603 | 2016-05-10 07:55:52 +0200 | [diff] [blame] | 84 | void spl_board_prepare_for_boot(void) |
| 85 | { |
| 86 | ps7_post_config(); |
| 87 | debug("SPL bye\n"); |
| 88 | } |
| 89 | |
Michal Simek | 9a23f45 | 2016-05-03 14:20:17 +0200 | [diff] [blame] | 90 | #ifdef CONFIG_SPL_LOAD_FIT |
| 91 | int board_fit_config_name_match(const char *name) |
| 92 | { |
| 93 | /* Just empty function now - can't decide what to choose */ |
Michal Simek | dacec83 | 2020-02-18 15:03:13 +0100 | [diff] [blame] | 94 | debug("%s: Check %s, default %s\n", __func__, name, DEVICE_TREE); |
Michal Simek | 9a23f45 | 2016-05-03 14:20:17 +0200 | [diff] [blame] | 95 | |
Michal Simek | dacec83 | 2020-02-18 15:03:13 +0100 | [diff] [blame] | 96 | if (!strcmp(name, DEVICE_TREE)) |
| 97 | return 0; |
| 98 | |
| 99 | return -1; |
Michal Simek | 9a23f45 | 2016-05-03 14:20:17 +0200 | [diff] [blame] | 100 | } |
| 101 | #endif |