blob: b52ac1785352bfc4b39c9113d1397c25061e70b0 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Michal Simeke6a9ed02015-11-20 13:17:22 +01002/*
3 * Copyright 2015 - 2016 Xilinx, Inc.
4 *
5 * Michal Simek <michal.simek@xilinx.com>
Michal Simeke6a9ed02015-11-20 13:17:22 +01006 */
7
8#include <common.h>
9#include <debug_uart.h>
10#include <spl.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
17void board_init_f(ulong dummy)
18{
Michal Simek55de0922017-07-12 13:08:41 +020019 board_early_init_f();
Michal Simeke6a9ed02015-11-20 13:17:22 +010020 board_early_init_r();
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 /* Delay is required for clocks to be propagated */
28 udelay(1000000);
29
Michal Simekba4f52b2019-02-21 10:42:40 +010030 debug("Clearing BSS 0x%p - 0x%p\n", __bss_start, __bss_end);
Michal Simeke6a9ed02015-11-20 13:17:22 +010031 /* 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
Michal Simek48255f52016-08-15 09:41:36 +020038static void ps_mode_reset(ulong mode)
39{
Michal Simek48255f52016-08-15 09:41:36 +020040 writel(mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_EN_SHIFT,
41 &crlapb_base->boot_pin_ctrl);
42 udelay(5);
43 writel(mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_VAL_SHIFT |
44 mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_EN_SHIFT,
45 &crlapb_base->boot_pin_ctrl);
46}
47
48/*
49 * Set default PS_MODE1 which is used for USB ULPI phy reset
50 * Also other resets can be connected to this certain pin
51 */
52#ifndef MODE_RESET
53# define MODE_RESET PS_MODE1
54#endif
55
Michal Simeke6a9ed02015-11-20 13:17:22 +010056#ifdef CONFIG_SPL_BOARD_INIT
57void spl_board_init(void)
58{
59 preloader_console_init();
Michal Simek48255f52016-08-15 09:41:36 +020060 ps_mode_reset(MODE_RESET);
Michal Simeke6a9ed02015-11-20 13:17:22 +010061 board_init();
62}
63#endif
64
65u32 spl_boot_device(void)
66{
67 u32 reg = 0;
68 u8 bootmode;
69
Michal Simek7f491d72016-08-30 16:17:27 +020070#if defined(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED)
71 /* Change default boot mode at run-time */
Michal Simek47359a02016-10-25 11:43:02 +020072 writel(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT,
Michal Simek7f491d72016-08-30 16:17:27 +020073 &crlapb_base->boot_mode);
74#endif
75
Michal Simeke6a9ed02015-11-20 13:17:22 +010076 reg = readl(&crlapb_base->boot_mode);
Michal Simek47359a02016-10-25 11:43:02 +020077 if (reg >> BOOT_MODE_ALT_SHIFT)
78 reg >>= BOOT_MODE_ALT_SHIFT;
79
Michal Simeke6a9ed02015-11-20 13:17:22 +010080 bootmode = reg & BOOT_MODES_MASK;
81
82 switch (bootmode) {
83 case JTAG_MODE:
84 return BOOT_DEVICE_RAM;
85#ifdef CONFIG_SPL_MMC_SUPPORT
Michal Simeke6a9ed02015-11-20 13:17:22 +010086 case SD_MODE1:
Michal Simekb0259c82017-03-02 11:02:55 +010087 case SD1_LSHFT_MODE: /* not working on silicon v1 */
Jean-Francois Dagenaise3fdf5d2017-04-02 21:44:34 -040088/* if both controllers enabled, then these two are the second controller */
Luca Ceresoli350cfe72019-04-15 16:18:18 +020089#ifdef CONFIG_SPL_ZYNQMP_TWO_SDHCI
Jean-Francois Dagenaise3fdf5d2017-04-02 21:44:34 -040090 return BOOT_DEVICE_MMC2;
91/* else, fall through, the one SDHCI controller that is enabled is number 1 */
92#endif
93 case SD_MODE:
94 case EMMC_MODE:
Michal Simeke6a9ed02015-11-20 13:17:22 +010095 return BOOT_DEVICE_MMC1;
96#endif
Andrew F. Davis6536ca42019-01-17 13:43:02 -060097#ifdef CONFIG_SPL_DFU
Michal Simekd58fc122016-08-19 14:14:52 +020098 case USB_MODE:
99 return BOOT_DEVICE_DFU;
100#endif
Michal Simek26610812016-10-26 09:24:32 +0200101#ifdef CONFIG_SPL_SATA_SUPPORT
102 case SW_SATA_MODE:
103 return BOOT_DEVICE_SATA;
104#endif
Michal Simek40d1f8a2017-11-02 09:15:05 +0100105#ifdef CONFIG_SPL_SPI_SUPPORT
106 case QSPI_MODE_24BIT:
107 case QSPI_MODE_32BIT:
108 return BOOT_DEVICE_SPI;
109#endif
Michal Simeke6a9ed02015-11-20 13:17:22 +0100110 default:
111 printf("Invalid Boot Mode:0x%x\n", bootmode);
112 break;
113 }
114
115 return 0;
116}
117
Michal Simeke6a9ed02015-11-20 13:17:22 +0100118#ifdef CONFIG_SPL_OS_BOOT
119int spl_start_uboot(void)
120{
Michal Simek509d4b92017-01-09 10:05:16 +0100121 handoff_setup();
122
Michal Simeke6a9ed02015-11-20 13:17:22 +0100123 return 0;
124}
125#endif
126
127#ifdef CONFIG_SPL_LOAD_FIT
128int board_fit_config_name_match(const char *name)
129{
130 /* Just empty function now - can't decide what to choose */
131 debug("%s: %s\n", __func__, name);
132
133 return 0;
134}
135#endif