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