627c84cebaeca9ed5b16f68d6313a05ce17176ca
[pandora-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 <spl.h>
10 #include <generated/dt.h>
11
12 #include <asm/io.h>
13 #include <asm/spl.h>
14 #include <asm/arch/hardware.h>
15 #include <asm/arch/sys_proto.h>
16 #include <asm/arch/ps7_init_gpl.h>
17
18 void board_init_f(ulong dummy)
19 {
20         ps7_init();
21
22         arch_cpu_init();
23
24 #ifdef CONFIG_DEBUG_UART
25         /* Uart debug for sure */
26         debug_uart_init();
27         puts("Debug uart enabled\n"); /* or printch() */
28 #endif
29 }
30
31 #ifdef CONFIG_SPL_BOARD_INIT
32 void spl_board_init(void)
33 {
34         preloader_console_init();
35 #if defined(CONFIG_ARCH_EARLY_INIT_R) && defined(CONFIG_SPL_FPGA_SUPPORT)
36         arch_early_init_r();
37 #endif
38         board_init();
39 }
40 #endif
41
42 u32 spl_boot_device(void)
43 {
44         u32 mode;
45
46         switch ((zynq_slcr_get_boot_mode()) & ZYNQ_BM_MASK) {
47 #ifdef CONFIG_SPL_SPI_SUPPORT
48         case ZYNQ_BM_QSPI:
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                 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: Check %s, default %s\n", __func__, name, DEVICE_TREE);
93
94         if (!strcmp(name, DEVICE_TREE))
95                 return 0;
96
97         return -1;
98 }
99 #endif