e89e46c1038ddd37421c85f3f7c80894ed34be45
[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 #include <generated/dt.h>
10
11 #include <asm/io.h>
12 #include <asm/spl.h>
13 #include <asm/arch/hardware.h>
14 #include <asm/arch/sys_proto.h>
15 #include <asm/arch/ps7_init_gpl.h>
16
17 void board_init_f(ulong dummy)
18 {
19         ps7_init();
20
21         arch_cpu_init();
22
23 #ifdef CONFIG_DEBUG_UART
24         /* Uart debug for sure */
25         debug_uart_init();
26         puts("Debug uart enabled\n"); /* or printch() */
27 #endif
28 }
29
30 #ifdef CONFIG_SPL_BOARD_INIT
31 void spl_board_init(void)
32 {
33         preloader_console_init();
34 #if defined(CONFIG_ARCH_EARLY_INIT_R) && defined(CONFIG_SPL_FPGA_SUPPORT)
35         arch_early_init_r();
36 #endif
37         board_init();
38 }
39 #endif
40
41 u32 spl_boot_device(void)
42 {
43         u32 mode;
44
45         switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
46 #ifdef CONFIG_SPL_SPI_SUPPORT
47         case ZYNQ_BM_QSPI:
48                 puts("qspi boot\n");
49                 mode = BOOT_DEVICE_SPI;
50                 break;
51 #endif
52         case ZYNQ_BM_NAND:
53                 mode = BOOT_DEVICE_NAND;
54                 break;
55         case ZYNQ_BM_NOR:
56                 mode = BOOT_DEVICE_NOR;
57                 break;
58 #ifdef CONFIG_SPL_MMC_SUPPORT
59         case ZYNQ_BM_SD:
60                 puts("mmc boot\n");
61                 mode = BOOT_DEVICE_MMC1;
62                 break;
63 #endif
64         case ZYNQ_BM_JTAG:
65                 mode = BOOT_DEVICE_RAM;
66                 break;
67         default:
68                 puts("Unsupported boot mode selected\n");
69                 hang();
70         }
71
72         return mode;
73 }
74
75 #ifdef CONFIG_SPL_OS_BOOT
76 int spl_start_uboot(void)
77 {
78         /* boot linux */
79         return 0;
80 }
81 #endif
82
83 void spl_board_prepare_for_boot(void)
84 {
85         ps7_post_config();
86         debug("SPL bye\n");
87 }
88
89 #ifdef CONFIG_SPL_LOAD_FIT
90 int board_fit_config_name_match(const char *name)
91 {
92         /* Just empty function now - can't decide what to choose */
93         debug("%s: Check %s, default %s\n", __func__, name, DEVICE_TREE);
94
95         if (!strcmp(name, DEVICE_TREE))
96                 return 0;
97
98         return -1;
99 }
100 #endif