Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2014 - 2015 Xilinx, Inc. |
| 3 | * Michal Simek <michal.simek@xilinx.com> |
| 4 | * |
| 5 | * SPDX-License-Identifier: GPL-2.0+ |
| 6 | */ |
| 7 | |
| 8 | #include <common.h> |
Michal Simek | 679b994 | 2015-09-30 17:26:55 +0200 | [diff] [blame] | 9 | #include <sata.h> |
Michal Simek | 6fe6f13 | 2015-07-23 13:27:40 +0200 | [diff] [blame] | 10 | #include <ahci.h> |
| 11 | #include <scsi.h> |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 12 | #include <malloc.h> |
Michal Simek | 0785dfd | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 13 | #include <asm/arch/clk.h> |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 14 | #include <asm/arch/hardware.h> |
| 15 | #include <asm/arch/sys_proto.h> |
| 16 | #include <asm/io.h> |
Siva Durga Prasad Paladugu | 16fa00a | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 17 | #include <usb.h> |
| 18 | #include <dwc3-uboot.h> |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 19 | #include <zynqmppl.h> |
Michal Simek | 6919b4b | 2016-04-22 11:48:49 +0200 | [diff] [blame] | 20 | #include <i2c.h> |
Michal Simek | 9feff38 | 2016-09-01 11:16:40 +0200 | [diff] [blame] | 21 | #include <g_dnl.h> |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 22 | |
| 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 25 | #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \ |
| 26 | !defined(CONFIG_SPL_BUILD) |
| 27 | static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC; |
| 28 | |
| 29 | static const struct { |
Michal Simek | 8ebdf9e | 2017-11-06 12:55:59 +0100 | [diff] [blame] | 30 | u32 id; |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 31 | u32 ver; |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 32 | char *name; |
| 33 | } zynqmp_devices[] = { |
| 34 | { |
| 35 | .id = 0x10, |
| 36 | .name = "3eg", |
| 37 | }, |
| 38 | { |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 39 | .id = 0x10, |
| 40 | .ver = 0x2c, |
| 41 | .name = "3cg", |
| 42 | }, |
| 43 | { |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 44 | .id = 0x11, |
| 45 | .name = "2eg", |
| 46 | }, |
| 47 | { |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 48 | .id = 0x11, |
| 49 | .ver = 0x2c, |
| 50 | .name = "2cg", |
| 51 | }, |
| 52 | { |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 53 | .id = 0x20, |
| 54 | .name = "5ev", |
| 55 | }, |
| 56 | { |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 57 | .id = 0x20, |
| 58 | .ver = 0x100, |
| 59 | .name = "5eg", |
| 60 | }, |
| 61 | { |
| 62 | .id = 0x20, |
| 63 | .ver = 0x12c, |
| 64 | .name = "5cg", |
| 65 | }, |
| 66 | { |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 67 | .id = 0x21, |
| 68 | .name = "4ev", |
| 69 | }, |
| 70 | { |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 71 | .id = 0x21, |
| 72 | .ver = 0x100, |
| 73 | .name = "4eg", |
| 74 | }, |
| 75 | { |
| 76 | .id = 0x21, |
| 77 | .ver = 0x12c, |
| 78 | .name = "4cg", |
| 79 | }, |
| 80 | { |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 81 | .id = 0x30, |
| 82 | .name = "7ev", |
| 83 | }, |
| 84 | { |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 85 | .id = 0x30, |
| 86 | .ver = 0x100, |
| 87 | .name = "7eg", |
| 88 | }, |
| 89 | { |
| 90 | .id = 0x30, |
| 91 | .ver = 0x12c, |
| 92 | .name = "7cg", |
| 93 | }, |
| 94 | { |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 95 | .id = 0x38, |
| 96 | .name = "9eg", |
| 97 | }, |
| 98 | { |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 99 | .id = 0x38, |
| 100 | .ver = 0x2c, |
| 101 | .name = "9cg", |
| 102 | }, |
| 103 | { |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 104 | .id = 0x39, |
| 105 | .name = "6eg", |
| 106 | }, |
| 107 | { |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 108 | .id = 0x39, |
| 109 | .ver = 0x2c, |
| 110 | .name = "6cg", |
| 111 | }, |
| 112 | { |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 113 | .id = 0x40, |
| 114 | .name = "11eg", |
| 115 | }, |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 116 | { /* For testing purpose only */ |
| 117 | .id = 0x50, |
| 118 | .ver = 0x2c, |
| 119 | .name = "15cg", |
| 120 | }, |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 121 | { |
| 122 | .id = 0x50, |
| 123 | .name = "15eg", |
| 124 | }, |
| 125 | { |
| 126 | .id = 0x58, |
| 127 | .name = "19eg", |
| 128 | }, |
| 129 | { |
| 130 | .id = 0x59, |
| 131 | .name = "17eg", |
| 132 | }, |
Michal Simek | b030fed | 2017-06-02 08:08:59 +0200 | [diff] [blame^] | 133 | { |
| 134 | .id = 0x61, |
| 135 | .name = "21dr", |
| 136 | }, |
| 137 | { |
| 138 | .id = 0x63, |
| 139 | .name = "23dr", |
| 140 | }, |
| 141 | { |
| 142 | .id = 0x65, |
| 143 | .name = "25dr", |
| 144 | }, |
| 145 | { |
| 146 | .id = 0x64, |
| 147 | .name = "27dr", |
| 148 | }, |
| 149 | { |
| 150 | .id = 0x60, |
| 151 | .name = "28dr", |
| 152 | }, |
| 153 | { |
| 154 | .id = 0x62, |
| 155 | .name = "29dr", |
| 156 | }, |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 157 | }; |
Siva Durga Prasad Paladugu | 74ba69d | 2017-07-25 11:51:37 +0530 | [diff] [blame] | 158 | #endif |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 159 | |
Siva Durga Prasad Paladugu | f52bf5a | 2017-07-25 11:51:38 +0530 | [diff] [blame] | 160 | int chip_id(unsigned char id) |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 161 | { |
| 162 | struct pt_regs regs; |
Siva Durga Prasad Paladugu | db3123b | 2017-07-25 11:51:36 +0530 | [diff] [blame] | 163 | int val = -EINVAL; |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 164 | |
Siva Durga Prasad Paladugu | 74ba69d | 2017-07-25 11:51:37 +0530 | [diff] [blame] | 165 | if (current_el() != 3) { |
| 166 | regs.regs[0] = ZYNQMP_SIP_SVC_CSU_DMA_CHIPID; |
| 167 | regs.regs[1] = 0; |
| 168 | regs.regs[2] = 0; |
| 169 | regs.regs[3] = 0; |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 170 | |
Siva Durga Prasad Paladugu | 74ba69d | 2017-07-25 11:51:37 +0530 | [diff] [blame] | 171 | smc_call(®s); |
| 172 | |
| 173 | /* |
| 174 | * SMC returns: |
| 175 | * regs[0][31:0] = status of the operation |
| 176 | * regs[0][63:32] = CSU.IDCODE register |
| 177 | * regs[1][31:0] = CSU.version register |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 178 | * regs[1][63:32] = CSU.IDCODE2 register |
Siva Durga Prasad Paladugu | 74ba69d | 2017-07-25 11:51:37 +0530 | [diff] [blame] | 179 | */ |
| 180 | switch (id) { |
| 181 | case IDCODE: |
| 182 | regs.regs[0] = upper_32_bits(regs.regs[0]); |
| 183 | regs.regs[0] &= ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK | |
| 184 | ZYNQMP_CSU_IDCODE_SVD_MASK; |
| 185 | regs.regs[0] >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT; |
| 186 | val = regs.regs[0]; |
| 187 | break; |
| 188 | case VERSION: |
| 189 | regs.regs[1] = lower_32_bits(regs.regs[1]); |
| 190 | regs.regs[1] &= ZYNQMP_CSU_SILICON_VER_MASK; |
| 191 | val = regs.regs[1]; |
| 192 | break; |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 193 | case IDCODE2: |
| 194 | regs.regs[1] = lower_32_bits(regs.regs[1]); |
| 195 | regs.regs[1] >>= ZYNQMP_CSU_VERSION_EMPTY_SHIFT; |
| 196 | val = regs.regs[1]; |
| 197 | break; |
Siva Durga Prasad Paladugu | 74ba69d | 2017-07-25 11:51:37 +0530 | [diff] [blame] | 198 | default: |
| 199 | printf("%s, Invalid Req:0x%x\n", __func__, id); |
| 200 | } |
| 201 | } else { |
| 202 | switch (id) { |
| 203 | case IDCODE: |
| 204 | val = readl(ZYNQMP_CSU_IDCODE_ADDR); |
| 205 | val &= ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK | |
| 206 | ZYNQMP_CSU_IDCODE_SVD_MASK; |
| 207 | val >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT; |
| 208 | break; |
| 209 | case VERSION: |
| 210 | val = readl(ZYNQMP_CSU_VER_ADDR); |
| 211 | val &= ZYNQMP_CSU_SILICON_VER_MASK; |
| 212 | break; |
| 213 | default: |
| 214 | printf("%s, Invalid Req:0x%x\n", __func__, id); |
| 215 | } |
Siva Durga Prasad Paladugu | db3123b | 2017-07-25 11:51:36 +0530 | [diff] [blame] | 216 | } |
Soren Brinkmann | 0cba6ab | 2016-09-29 11:44:41 -0700 | [diff] [blame] | 217 | |
Siva Durga Prasad Paladugu | db3123b | 2017-07-25 11:51:36 +0530 | [diff] [blame] | 218 | return val; |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 219 | } |
| 220 | |
Siva Durga Prasad Paladugu | 74ba69d | 2017-07-25 11:51:37 +0530 | [diff] [blame] | 221 | #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \ |
| 222 | !defined(CONFIG_SPL_BUILD) |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 223 | static char *zynqmp_get_silicon_idcode_name(void) |
| 224 | { |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 225 | u32 i, id, ver; |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 226 | |
Siva Durga Prasad Paladugu | db3123b | 2017-07-25 11:51:36 +0530 | [diff] [blame] | 227 | id = chip_id(IDCODE); |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 228 | ver = chip_id(IDCODE2); |
| 229 | |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 230 | for (i = 0; i < ARRAY_SIZE(zynqmp_devices); i++) { |
Michal Simek | 494fffe | 2017-08-22 14:58:53 +0200 | [diff] [blame] | 231 | if (zynqmp_devices[i].id == id && zynqmp_devices[i].ver == ver) |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 232 | return zynqmp_devices[i].name; |
| 233 | } |
| 234 | return "unknown"; |
| 235 | } |
| 236 | #endif |
| 237 | |
Michal Simek | fb4000e | 2017-02-07 14:32:26 +0100 | [diff] [blame] | 238 | int board_early_init_f(void) |
| 239 | { |
| 240 | #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_CLK_ZYNQMP) |
| 241 | zynqmp_pmufw_version(); |
| 242 | #endif |
Michal Simek | 55de092 | 2017-07-12 13:08:41 +0200 | [diff] [blame] | 243 | |
Michal Simek | fd1b635 | 2017-07-12 13:21:27 +0200 | [diff] [blame] | 244 | #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED) |
Michal Simek | 55de092 | 2017-07-12 13:08:41 +0200 | [diff] [blame] | 245 | psu_init(); |
| 246 | #endif |
| 247 | |
Michal Simek | fb4000e | 2017-02-07 14:32:26 +0100 | [diff] [blame] | 248 | return 0; |
| 249 | } |
| 250 | |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 251 | #define ZYNQMP_VERSION_SIZE 9 |
| 252 | |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 253 | int board_init(void) |
| 254 | { |
Michal Simek | a0736ef | 2015-06-22 14:31:06 +0200 | [diff] [blame] | 255 | printf("EL Level:\tEL%d\n", current_el()); |
| 256 | |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 257 | #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \ |
| 258 | !defined(CONFIG_SPL_BUILD) || (defined(CONFIG_SPL_FPGA_SUPPORT) && \ |
| 259 | defined(CONFIG_SPL_BUILD)) |
| 260 | if (current_el() != 3) { |
| 261 | static char version[ZYNQMP_VERSION_SIZE]; |
| 262 | |
Heinrich Schuchardt | df1cd46 | 2017-07-30 22:18:18 +0200 | [diff] [blame] | 263 | strncat(version, "xczu", 4); |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 264 | zynqmppl.name = strncat(version, |
| 265 | zynqmp_get_silicon_idcode_name(), |
Heinrich Schuchardt | df1cd46 | 2017-07-30 22:18:18 +0200 | [diff] [blame] | 266 | ZYNQMP_VERSION_SIZE - 5); |
Michal Simek | 47e60cb | 2016-02-01 15:05:58 +0100 | [diff] [blame] | 267 | printf("Chip ID:\t%s\n", zynqmppl.name); |
| 268 | fpga_init(); |
| 269 | fpga_add(fpga_xilinx, &zynqmppl); |
| 270 | } |
| 271 | #endif |
| 272 | |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 273 | return 0; |
| 274 | } |
| 275 | |
| 276 | int board_early_init_r(void) |
| 277 | { |
| 278 | u32 val; |
| 279 | |
Michal Simek | 90a35db | 2017-07-12 10:32:18 +0200 | [diff] [blame] | 280 | val = readl(&crlapb_base->timestamp_ref_ctrl); |
| 281 | val &= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; |
| 282 | |
| 283 | if (current_el() == 3 && !val) { |
Michal Simek | 0785dfd | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 284 | val = readl(&crlapb_base->timestamp_ref_ctrl); |
| 285 | val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; |
| 286 | writel(val, &crlapb_base->timestamp_ref_ctrl); |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 287 | |
Michal Simek | 0785dfd | 2015-11-05 08:34:35 +0100 | [diff] [blame] | 288 | /* Program freq register in System counter */ |
| 289 | writel(zynqmp_get_system_timer_freq(), |
| 290 | &iou_scntr_secure->base_frequency_id_register); |
| 291 | /* And enable system counter */ |
| 292 | writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN, |
| 293 | &iou_scntr_secure->counter_control_register); |
| 294 | } |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 295 | return 0; |
| 296 | } |
| 297 | |
Michal Simek | 6919b4b | 2016-04-22 11:48:49 +0200 | [diff] [blame] | 298 | int zynq_board_read_rom_ethaddr(unsigned char *ethaddr) |
| 299 | { |
| 300 | #if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \ |
| 301 | defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET) && \ |
| 302 | defined(CONFIG_ZYNQ_EEPROM_BUS) |
| 303 | i2c_set_bus_num(CONFIG_ZYNQ_EEPROM_BUS); |
| 304 | |
| 305 | if (eeprom_read(CONFIG_ZYNQ_GEM_EEPROM_ADDR, |
| 306 | CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET, |
| 307 | ethaddr, 6)) |
| 308 | printf("I2C EEPROM MAC address read failed\n"); |
| 309 | #endif |
| 310 | |
| 311 | return 0; |
| 312 | } |
| 313 | |
Michal Simek | 8d59d7f | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 314 | #if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE) |
Simon Glass | 76b00ac | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 315 | int dram_init_banksize(void) |
Tom Rini | 361a879 | 2016-12-09 07:56:54 -0500 | [diff] [blame] | 316 | { |
Michal Simek | da3f003 | 2017-11-03 15:25:51 +0100 | [diff] [blame] | 317 | return fdtdec_setup_memory_banksize(); |
Michal Simek | 8d59d7f | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | int dram_init(void) |
| 321 | { |
Nathan Rossi | 950f86c | 2016-12-19 00:03:34 +1000 | [diff] [blame] | 322 | if (fdtdec_setup_memory_size() != 0) |
| 323 | return -EINVAL; |
Michal Simek | 8d59d7f | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 324 | |
| 325 | return 0; |
| 326 | } |
| 327 | #else |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 328 | int dram_init(void) |
| 329 | { |
| 330 | gd->ram_size = CONFIG_SYS_SDRAM_SIZE; |
| 331 | |
| 332 | return 0; |
| 333 | } |
Michal Simek | 8d59d7f | 2016-02-08 09:34:53 +0100 | [diff] [blame] | 334 | #endif |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 335 | |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 336 | void reset_cpu(ulong addr) |
| 337 | { |
| 338 | } |
| 339 | |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 340 | int board_late_init(void) |
| 341 | { |
| 342 | u32 reg = 0; |
| 343 | u8 bootmode; |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 344 | const char *mode; |
| 345 | char *new_targets; |
| 346 | |
| 347 | if (!(gd->flags & GD_FLG_ENV_DEFAULT)) { |
| 348 | debug("Saved variables - Skipping\n"); |
| 349 | return 0; |
| 350 | } |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 351 | |
| 352 | reg = readl(&crlapb_base->boot_mode); |
Michal Simek | 47359a0 | 2016-10-25 11:43:02 +0200 | [diff] [blame] | 353 | if (reg >> BOOT_MODE_ALT_SHIFT) |
| 354 | reg >>= BOOT_MODE_ALT_SHIFT; |
| 355 | |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 356 | bootmode = reg & BOOT_MODES_MASK; |
| 357 | |
Michal Simek | fb90917 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 358 | puts("Bootmode: "); |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 359 | switch (bootmode) { |
Michal Simek | d58fc12 | 2016-08-19 14:14:52 +0200 | [diff] [blame] | 360 | case USB_MODE: |
| 361 | puts("USB_MODE\n"); |
| 362 | mode = "usb"; |
| 363 | break; |
Siva Durga Prasad Paladugu | 0a5bcc8 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 364 | case JTAG_MODE: |
Michal Simek | fb90917 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 365 | puts("JTAG_MODE\n"); |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 366 | mode = "pxe dhcp"; |
Siva Durga Prasad Paladugu | 0a5bcc8 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 367 | break; |
| 368 | case QSPI_MODE_24BIT: |
| 369 | case QSPI_MODE_32BIT: |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 370 | mode = "qspi0"; |
Michal Simek | fb90917 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 371 | puts("QSPI_MODE\n"); |
Siva Durga Prasad Paladugu | 0a5bcc8 | 2015-03-13 11:10:26 +0530 | [diff] [blame] | 372 | break; |
Michal Simek | 39c56f5 | 2015-04-15 15:02:28 +0200 | [diff] [blame] | 373 | case EMMC_MODE: |
Michal Simek | 78678fe | 2015-10-05 15:59:38 +0200 | [diff] [blame] | 374 | puts("EMMC_MODE\n"); |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 375 | mode = "mmc0"; |
Michal Simek | 78678fe | 2015-10-05 15:59:38 +0200 | [diff] [blame] | 376 | break; |
| 377 | case SD_MODE: |
Michal Simek | fb90917 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 378 | puts("SD_MODE\n"); |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 379 | mode = "mmc0"; |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 380 | break; |
Siva Durga Prasad Paladugu | e199227 | 2016-09-21 11:45:05 +0530 | [diff] [blame] | 381 | case SD1_LSHFT_MODE: |
| 382 | puts("LVL_SHFT_"); |
| 383 | /* fall through */ |
Michal Simek | af813ac | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 384 | case SD_MODE1: |
Michal Simek | fb90917 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 385 | puts("SD_MODE1\n"); |
Michal Simek | 2d9925b | 2015-11-06 10:22:37 +0100 | [diff] [blame] | 386 | #if defined(CONFIG_ZYNQ_SDHCI0) && defined(CONFIG_ZYNQ_SDHCI1) |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 387 | mode = "mmc1"; |
| 388 | #else |
| 389 | mode = "mmc0"; |
Michal Simek | 2d9925b | 2015-11-06 10:22:37 +0100 | [diff] [blame] | 390 | #endif |
Michal Simek | af813ac | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 391 | break; |
| 392 | case NAND_MODE: |
Michal Simek | fb90917 | 2015-09-20 17:20:42 +0200 | [diff] [blame] | 393 | puts("NAND_MODE\n"); |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 394 | mode = "nand0"; |
Michal Simek | af813ac | 2015-10-05 10:51:12 +0200 | [diff] [blame] | 395 | break; |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 396 | default: |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 397 | mode = ""; |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 398 | printf("Invalid Boot Mode:0x%x\n", bootmode); |
| 399 | break; |
| 400 | } |
| 401 | |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 402 | /* |
| 403 | * One terminating char + one byte for space between mode |
| 404 | * and default boot_targets |
| 405 | */ |
| 406 | new_targets = calloc(1, strlen(mode) + |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 407 | strlen(env_get("boot_targets")) + 2); |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 408 | |
Simon Glass | 00caae6 | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 409 | sprintf(new_targets, "%s %s", mode, env_get("boot_targets")); |
Simon Glass | 382bee5 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 410 | env_set("boot_targets", new_targets); |
Michal Simek | b72894f | 2016-04-22 14:28:54 +0200 | [diff] [blame] | 411 | |
Michal Simek | 84c7204 | 2015-01-15 10:01:51 +0100 | [diff] [blame] | 412 | return 0; |
| 413 | } |
Siva Durga Prasad Paladugu | 84696ff | 2015-08-04 13:01:05 +0530 | [diff] [blame] | 414 | |
| 415 | int checkboard(void) |
| 416 | { |
Michal Simek | 5af0855 | 2016-01-25 11:04:21 +0100 | [diff] [blame] | 417 | puts("Board: Xilinx ZynqMP\n"); |
Siva Durga Prasad Paladugu | 84696ff | 2015-08-04 13:01:05 +0530 | [diff] [blame] | 418 | return 0; |
| 419 | } |
Siva Durga Prasad Paladugu | 16fa00a | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 420 | |
| 421 | #ifdef CONFIG_USB_DWC3 |
Michal Simek | 275bd6d | 2016-08-08 10:11:26 +0200 | [diff] [blame] | 422 | static struct dwc3_device dwc3_device_data0 = { |
Siva Durga Prasad Paladugu | 16fa00a | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 423 | .maximum_speed = USB_SPEED_HIGH, |
| 424 | .base = ZYNQMP_USB0_XHCI_BASEADDR, |
| 425 | .dr_mode = USB_DR_MODE_PERIPHERAL, |
| 426 | .index = 0, |
| 427 | }; |
| 428 | |
Michal Simek | 275bd6d | 2016-08-08 10:11:26 +0200 | [diff] [blame] | 429 | static struct dwc3_device dwc3_device_data1 = { |
| 430 | .maximum_speed = USB_SPEED_HIGH, |
| 431 | .base = ZYNQMP_USB1_XHCI_BASEADDR, |
| 432 | .dr_mode = USB_DR_MODE_PERIPHERAL, |
| 433 | .index = 1, |
| 434 | }; |
| 435 | |
Michal Simek | 9feff38 | 2016-09-01 11:16:40 +0200 | [diff] [blame] | 436 | int usb_gadget_handle_interrupts(int index) |
Siva Durga Prasad Paladugu | 16fa00a | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 437 | { |
Michal Simek | 9feff38 | 2016-09-01 11:16:40 +0200 | [diff] [blame] | 438 | dwc3_uboot_handle_interrupt(index); |
Siva Durga Prasad Paladugu | 16fa00a | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 439 | return 0; |
| 440 | } |
| 441 | |
| 442 | int board_usb_init(int index, enum usb_init_type init) |
| 443 | { |
Michal Simek | 275bd6d | 2016-08-08 10:11:26 +0200 | [diff] [blame] | 444 | debug("%s: index %x\n", __func__, index); |
| 445 | |
Michal Simek | 8ecd50c | 2016-09-01 11:27:32 +0200 | [diff] [blame] | 446 | #if defined(CONFIG_USB_GADGET_DOWNLOAD) |
| 447 | g_dnl_set_serialnumber(CONFIG_SYS_CONFIG_NAME); |
| 448 | #endif |
| 449 | |
Michal Simek | 275bd6d | 2016-08-08 10:11:26 +0200 | [diff] [blame] | 450 | switch (index) { |
| 451 | case 0: |
| 452 | return dwc3_uboot_init(&dwc3_device_data0); |
| 453 | case 1: |
| 454 | return dwc3_uboot_init(&dwc3_device_data1); |
| 455 | }; |
| 456 | |
| 457 | return -1; |
Siva Durga Prasad Paladugu | 16fa00a | 2015-08-04 13:03:26 +0530 | [diff] [blame] | 458 | } |
| 459 | |
| 460 | int board_usb_cleanup(int index, enum usb_init_type init) |
| 461 | { |
| 462 | dwc3_uboot_exit(index); |
| 463 | return 0; |
| 464 | } |
| 465 | #endif |