Merge tag '2020-01-20-ti-2020.04' of https://gitlab.denx.de/u-boot/custodians/u-boot-ti
[oweals/u-boot.git] / arch / arm / mach-zynq / spl.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2014 - 2017 Xilinx, Inc. Michal Simek
4  */
5 #include <common.h>
6 #include <debug_uart.h>
7 #include <hang.h>
8 #include <spl.h>
9
10 #include <asm/io.h>
11 #include <asm/spl.h>
12 #include <asm/arch/hardware.h>
13 #include <asm/arch/sys_proto.h>
14 #include <asm/arch/ps7_init_gpl.h>
15
16 void board_init_f(ulong dummy)
17 {
18         ps7_init();
19
20         arch_cpu_init();
21
22 #ifdef CONFIG_DEBUG_UART
23         /* Uart debug for sure */
24         debug_uart_init();
25         puts("Debug uart enabled\n"); /* or printch() */
26 #endif
27 }
28
29 #ifdef CONFIG_SPL_BOARD_INIT
30 void spl_board_init(void)
31 {
32         preloader_console_init();
33 #if defined(CONFIG_ARCH_EARLY_INIT_R) && defined(CONFIG_SPL_FPGA_SUPPORT)
34         arch_early_init_r();
35 #endif
36         board_init();
37 }
38 #endif
39
40 u32 spl_boot_device(void)
41 {
42         u32 mode;
43
44         switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
45 #ifdef CONFIG_SPL_SPI_SUPPORT
46         case ZYNQ_BM_QSPI:
47                 puts("qspi boot\n");
48                 mode = BOOT_DEVICE_SPI;
49                 break;
50 #endif
51         case ZYNQ_BM_NAND:
52                 mode = BOOT_DEVICE_NAND;
53                 break;
54         case ZYNQ_BM_NOR:
55                 mode = BOOT_DEVICE_NOR;
56                 break;
57 #ifdef CONFIG_SPL_MMC_SUPPORT
58         case ZYNQ_BM_SD:
59                 puts("mmc boot\n");
60                 mode = BOOT_DEVICE_MMC1;
61                 break;
62 #endif
63         case ZYNQ_BM_JTAG:
64                 mode = BOOT_DEVICE_RAM;
65                 break;
66         default:
67                 puts("Unsupported boot mode selected\n");
68                 hang();
69         }
70
71         return mode;
72 }
73
74 #ifdef CONFIG_SPL_OS_BOOT
75 int spl_start_uboot(void)
76 {
77         /* boot linux */
78         return 0;
79 }
80 #endif
81
82 void spl_board_prepare_for_boot(void)
83 {
84         ps7_post_config();
85         debug("SPL bye\n");
86 }
87
88 #ifdef CONFIG_SPL_LOAD_FIT
89 int board_fit_config_name_match(const char *name)
90 {
91         /* Just empty function now - can't decide what to choose */
92         debug("%s: %s\n", __func__, name);
93
94         return 0;
95 }
96 #endif