Merge tag 'efi-2020-07-rc6' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
[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 <image.h>
9 #include <init.h>
10 #include <log.h>
11 #include <spl.h>
12 #include <generated/dt.h>
13
14 #include <asm/io.h>
15 #include <asm/spl.h>
16 #include <asm/arch/hardware.h>
17 #include <asm/arch/sys_proto.h>
18 #include <asm/arch/ps7_init_gpl.h>
19
20 void board_init_f(ulong dummy)
21 {
22         ps7_init();
23
24         arch_cpu_init();
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
31 }
32
33 #ifdef CONFIG_SPL_BOARD_INIT
34 void spl_board_init(void)
35 {
36         preloader_console_init();
37 #if defined(CONFIG_ARCH_EARLY_INIT_R) && defined(CONFIG_SPL_FPGA_SUPPORT)
38         arch_early_init_r();
39 #endif
40         board_init();
41 }
42 #endif
43
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:
51                 mode = BOOT_DEVICE_SPI;
52                 break;
53 #endif
54         case ZYNQ_BM_NAND:
55                 mode = BOOT_DEVICE_NAND;
56                 break;
57         case ZYNQ_BM_NOR:
58                 mode = BOOT_DEVICE_NOR;
59                 break;
60 #ifdef CONFIG_SPL_MMC_SUPPORT
61         case ZYNQ_BM_SD:
62                 mode = BOOT_DEVICE_MMC1;
63                 break;
64 #endif
65         case ZYNQ_BM_JTAG:
66                 mode = BOOT_DEVICE_RAM;
67                 break;
68         default:
69                 puts("Unsupported boot mode selected\n");
70                 hang();
71         }
72
73         return mode;
74 }
75
76 #ifdef CONFIG_SPL_OS_BOOT
77 int spl_start_uboot(void)
78 {
79         /* boot linux */
80         return 0;
81 }
82 #endif
83
84 void spl_board_prepare_for_boot(void)
85 {
86         ps7_post_config();
87         debug("SPL bye\n");
88 }
89
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 */
94         debug("%s: Check %s, default %s\n", __func__, name, DEVICE_TREE);
95
96         if (!strcmp(name, DEVICE_TREE))
97                 return 0;
98
99         return -1;
100 }
101 #endif