]> git.ipfire.org Git - people/ms/u-boot.git/blame - arch/arm/cpu/armv8/zynqmp/spl.c
ARM64: zynqmp: Add support for DFU from SPL
[people/ms/u-boot.git] / arch / arm / cpu / armv8 / zynqmp / spl.c
CommitLineData
e6a9ed04
MS
1/*
2 * Copyright 2015 - 2016 Xilinx, Inc.
3 *
4 * Michal Simek <michal.simek@xilinx.com>
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
9#include <common.h>
10#include <debug_uart.h>
11#include <spl.h>
12
13#include <asm/io.h>
14#include <asm/spl.h>
15#include <asm/arch/hardware.h>
16#include <asm/arch/sys_proto.h>
17
18void board_init_f(ulong dummy)
19{
20 psu_init();
21 board_early_init_r();
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 /* Delay is required for clocks to be propagated */
29 udelay(1000000);
30
31 /* Clear the BSS */
32 memset(__bss_start, 0, __bss_end - __bss_start);
33
34 /* No need to call timer init - it is empty for ZynqMP */
35 board_init_r(NULL, 0);
36}
37
38#ifdef CONFIG_SPL_BOARD_INIT
39void spl_board_init(void)
40{
41 preloader_console_init();
42 board_init();
43}
44#endif
45
46u32 spl_boot_device(void)
47{
48 u32 reg = 0;
49 u8 bootmode;
50
7f491d7b
MS
51#if defined(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED)
52 /* Change default boot mode at run-time */
53 writel(BOOT_MODE_USE_ALT |
54 CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT,
55 &crlapb_base->boot_mode);
56#endif
57
e6a9ed04
MS
58 reg = readl(&crlapb_base->boot_mode);
59 bootmode = reg & BOOT_MODES_MASK;
60
61 switch (bootmode) {
62 case JTAG_MODE:
63 return BOOT_DEVICE_RAM;
64#ifdef CONFIG_SPL_MMC_SUPPORT
65 case EMMC_MODE:
66 case SD_MODE:
67 case SD_MODE1:
68 return BOOT_DEVICE_MMC1;
d58fc12e
MS
69#endif
70#ifdef CONFIG_SPL_DFU_SUPPORT
71 case USB_MODE:
72 return BOOT_DEVICE_DFU;
e6a9ed04
MS
73#endif
74 default:
75 printf("Invalid Boot Mode:0x%x\n", bootmode);
76 break;
77 }
78
79 return 0;
80}
81
2b1cdafa 82u32 spl_boot_mode(const u32 boot_device)
e6a9ed04
MS
83{
84 switch (spl_boot_device()) {
85 case BOOT_DEVICE_RAM:
86 return 0;
87 case BOOT_DEVICE_MMC1:
88 return MMCSD_MODE_FS;
89 default:
90 puts("spl: error: unsupported device\n");
91 hang();
92 }
93}
94
95__weak void psu_init(void)
96{
97 /*
98 * This function is overridden by the one in
99 * board/xilinx/zynqmp/(platform)/psu_init_gpl.c, if it exists.
100 */
101}
102
103#ifdef CONFIG_SPL_OS_BOOT
104int spl_start_uboot(void)
105{
106 return 0;
107}
108#endif
109
110#ifdef CONFIG_SPL_LOAD_FIT
111int board_fit_config_name_match(const char *name)
112{
113 /* Just empty function now - can't decide what to choose */
114 debug("%s: %s\n", __func__, name);
115
116 return 0;
117}
118#endif