Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2015 - 2016 Xilinx, Inc. |
| 4 | * |
| 5 | * Michal Simek <michal.simek@xilinx.com> |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 6 | */ |
| 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 | |
| 17 | void board_init_f(ulong dummy) |
| 18 | { |
Michal Simek | 55de092 | 2017-07-12 13:08:41 +0200 | [diff] [blame] | 19 | board_early_init_f(); |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 20 | 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 | |
| 30 | /* Clear the BSS */ |
| 31 | memset(__bss_start, 0, __bss_end - __bss_start); |
| 32 | |
| 33 | /* No need to call timer init - it is empty for ZynqMP */ |
| 34 | board_init_r(NULL, 0); |
| 35 | } |
| 36 | |
Michal Simek | 48255f5 | 2016-08-15 09:41:36 +0200 | [diff] [blame] | 37 | static void ps_mode_reset(ulong mode) |
| 38 | { |
Michal Simek | 48255f5 | 2016-08-15 09:41:36 +0200 | [diff] [blame] | 39 | writel(mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_EN_SHIFT, |
| 40 | &crlapb_base->boot_pin_ctrl); |
| 41 | udelay(5); |
| 42 | writel(mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_VAL_SHIFT | |
| 43 | mode << ZYNQMP_CRL_APB_BOOT_PIN_CTRL_OUT_EN_SHIFT, |
| 44 | &crlapb_base->boot_pin_ctrl); |
| 45 | } |
| 46 | |
| 47 | /* |
| 48 | * Set default PS_MODE1 which is used for USB ULPI phy reset |
| 49 | * Also other resets can be connected to this certain pin |
| 50 | */ |
| 51 | #ifndef MODE_RESET |
| 52 | # define MODE_RESET PS_MODE1 |
| 53 | #endif |
| 54 | |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 55 | #ifdef CONFIG_SPL_BOARD_INIT |
| 56 | void spl_board_init(void) |
| 57 | { |
| 58 | preloader_console_init(); |
Michal Simek | 48255f5 | 2016-08-15 09:41:36 +0200 | [diff] [blame] | 59 | ps_mode_reset(MODE_RESET); |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 60 | board_init(); |
| 61 | } |
| 62 | #endif |
| 63 | |
| 64 | u32 spl_boot_device(void) |
| 65 | { |
| 66 | u32 reg = 0; |
| 67 | u8 bootmode; |
| 68 | |
Michal Simek | 7f491d7 | 2016-08-30 16:17:27 +0200 | [diff] [blame] | 69 | #if defined(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE_ENABLED) |
| 70 | /* Change default boot mode at run-time */ |
Michal Simek | 47359a0 | 2016-10-25 11:43:02 +0200 | [diff] [blame] | 71 | writel(CONFIG_SPL_ZYNQMP_ALT_BOOTMODE << BOOT_MODE_ALT_SHIFT, |
Michal Simek | 7f491d7 | 2016-08-30 16:17:27 +0200 | [diff] [blame] | 72 | &crlapb_base->boot_mode); |
| 73 | #endif |
| 74 | |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 75 | reg = readl(&crlapb_base->boot_mode); |
Michal Simek | 47359a0 | 2016-10-25 11:43:02 +0200 | [diff] [blame] | 76 | if (reg >> BOOT_MODE_ALT_SHIFT) |
| 77 | reg >>= BOOT_MODE_ALT_SHIFT; |
| 78 | |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 79 | bootmode = reg & BOOT_MODES_MASK; |
| 80 | |
| 81 | switch (bootmode) { |
| 82 | case JTAG_MODE: |
| 83 | return BOOT_DEVICE_RAM; |
| 84 | #ifdef CONFIG_SPL_MMC_SUPPORT |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 85 | case SD_MODE1: |
Michal Simek | b0259c8 | 2017-03-02 11:02:55 +0100 | [diff] [blame] | 86 | case SD1_LSHFT_MODE: /* not working on silicon v1 */ |
Jean-Francois Dagenais | e3fdf5d | 2017-04-02 21:44:34 -0400 | [diff] [blame] | 87 | /* if both controllers enabled, then these two are the second controller */ |
Michal Simek | 35e2b92 | 2019-02-13 13:46:41 +0100 | [diff] [blame] | 88 | #if defined(SPL_ZYNQMP_TWO_SDHCI) |
Jean-Francois Dagenais | e3fdf5d | 2017-04-02 21:44:34 -0400 | [diff] [blame] | 89 | return BOOT_DEVICE_MMC2; |
| 90 | /* else, fall through, the one SDHCI controller that is enabled is number 1 */ |
| 91 | #endif |
| 92 | case SD_MODE: |
| 93 | case EMMC_MODE: |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 94 | return BOOT_DEVICE_MMC1; |
| 95 | #endif |
Andrew F. Davis | 6536ca4 | 2019-01-17 13:43:02 -0600 | [diff] [blame] | 96 | #ifdef CONFIG_SPL_DFU |
Michal Simek | d58fc12 | 2016-08-19 14:14:52 +0200 | [diff] [blame] | 97 | case USB_MODE: |
| 98 | return BOOT_DEVICE_DFU; |
| 99 | #endif |
Michal Simek | 2661081 | 2016-10-26 09:24:32 +0200 | [diff] [blame] | 100 | #ifdef CONFIG_SPL_SATA_SUPPORT |
| 101 | case SW_SATA_MODE: |
| 102 | return BOOT_DEVICE_SATA; |
| 103 | #endif |
Michal Simek | 40d1f8a | 2017-11-02 09:15:05 +0100 | [diff] [blame] | 104 | #ifdef CONFIG_SPL_SPI_SUPPORT |
| 105 | case QSPI_MODE_24BIT: |
| 106 | case QSPI_MODE_32BIT: |
| 107 | return BOOT_DEVICE_SPI; |
| 108 | #endif |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 109 | default: |
| 110 | printf("Invalid Boot Mode:0x%x\n", bootmode); |
| 111 | break; |
| 112 | } |
| 113 | |
| 114 | return 0; |
| 115 | } |
| 116 | |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 117 | #ifdef CONFIG_SPL_OS_BOOT |
| 118 | int spl_start_uboot(void) |
| 119 | { |
Michal Simek | 509d4b9 | 2017-01-09 10:05:16 +0100 | [diff] [blame] | 120 | handoff_setup(); |
| 121 | |
Michal Simek | e6a9ed0 | 2015-11-20 13:17:22 +0100 | [diff] [blame] | 122 | return 0; |
| 123 | } |
| 124 | #endif |
| 125 | |
| 126 | #ifdef CONFIG_SPL_LOAD_FIT |
| 127 | int board_fit_config_name_match(const char *name) |
| 128 | { |
| 129 | /* Just empty function now - can't decide what to choose */ |
| 130 | debug("%s: %s\n", __func__, name); |
| 131 | |
| 132 | return 0; |
| 133 | } |
| 134 | #endif |