184c7204bSMichal Simek /* 284c7204bSMichal Simek * (C) Copyright 2014 - 2015 Xilinx, Inc. 384c7204bSMichal Simek * Michal Simek <michal.simek@xilinx.com> 484c7204bSMichal Simek * 584c7204bSMichal Simek * SPDX-License-Identifier: GPL-2.0+ 684c7204bSMichal Simek */ 784c7204bSMichal Simek 884c7204bSMichal Simek #include <common.h> 9679b994aSMichal Simek #include <sata.h> 106fe6f135SMichal Simek #include <ahci.h> 116fe6f135SMichal Simek #include <scsi.h> 12b72894f1SMichal Simek #include <malloc.h> 130785dfd8SMichal Simek #include <asm/arch/clk.h> 1484c7204bSMichal Simek #include <asm/arch/hardware.h> 1584c7204bSMichal Simek #include <asm/arch/sys_proto.h> 1684c7204bSMichal Simek #include <asm/io.h> 1716fa00a7SSiva Durga Prasad Paladugu #include <usb.h> 1816fa00a7SSiva Durga Prasad Paladugu #include <dwc3-uboot.h> 1947e60cbdSMichal Simek #include <zynqmppl.h> 206919b4bfSMichal Simek #include <i2c.h> 219feff385SMichal Simek #include <g_dnl.h> 2284c7204bSMichal Simek 2384c7204bSMichal Simek DECLARE_GLOBAL_DATA_PTR; 2484c7204bSMichal Simek 2547e60cbdSMichal Simek #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \ 2647e60cbdSMichal Simek !defined(CONFIG_SPL_BUILD) 2747e60cbdSMichal Simek static xilinx_desc zynqmppl = XILINX_ZYNQMP_DESC; 2847e60cbdSMichal Simek 2947e60cbdSMichal Simek static const struct { 308ebdf9efSMichal Simek u32 id; 31494fffe7SMichal Simek u32 ver; 3247e60cbdSMichal Simek char *name; 3347e60cbdSMichal Simek } zynqmp_devices[] = { 3447e60cbdSMichal Simek { 3547e60cbdSMichal Simek .id = 0x10, 3647e60cbdSMichal Simek .name = "3eg", 3747e60cbdSMichal Simek }, 3847e60cbdSMichal Simek { 39494fffe7SMichal Simek .id = 0x10, 40494fffe7SMichal Simek .ver = 0x2c, 41494fffe7SMichal Simek .name = "3cg", 42494fffe7SMichal Simek }, 43494fffe7SMichal Simek { 4447e60cbdSMichal Simek .id = 0x11, 4547e60cbdSMichal Simek .name = "2eg", 4647e60cbdSMichal Simek }, 4747e60cbdSMichal Simek { 48494fffe7SMichal Simek .id = 0x11, 49494fffe7SMichal Simek .ver = 0x2c, 50494fffe7SMichal Simek .name = "2cg", 51494fffe7SMichal Simek }, 52494fffe7SMichal Simek { 5347e60cbdSMichal Simek .id = 0x20, 5447e60cbdSMichal Simek .name = "5ev", 5547e60cbdSMichal Simek }, 5647e60cbdSMichal Simek { 57494fffe7SMichal Simek .id = 0x20, 58494fffe7SMichal Simek .ver = 0x100, 59494fffe7SMichal Simek .name = "5eg", 60494fffe7SMichal Simek }, 61494fffe7SMichal Simek { 62494fffe7SMichal Simek .id = 0x20, 63494fffe7SMichal Simek .ver = 0x12c, 64494fffe7SMichal Simek .name = "5cg", 65494fffe7SMichal Simek }, 66494fffe7SMichal Simek { 6747e60cbdSMichal Simek .id = 0x21, 6847e60cbdSMichal Simek .name = "4ev", 6947e60cbdSMichal Simek }, 7047e60cbdSMichal Simek { 71494fffe7SMichal Simek .id = 0x21, 72494fffe7SMichal Simek .ver = 0x100, 73494fffe7SMichal Simek .name = "4eg", 74494fffe7SMichal Simek }, 75494fffe7SMichal Simek { 76494fffe7SMichal Simek .id = 0x21, 77494fffe7SMichal Simek .ver = 0x12c, 78494fffe7SMichal Simek .name = "4cg", 79494fffe7SMichal Simek }, 80494fffe7SMichal Simek { 8147e60cbdSMichal Simek .id = 0x30, 8247e60cbdSMichal Simek .name = "7ev", 8347e60cbdSMichal Simek }, 8447e60cbdSMichal Simek { 85494fffe7SMichal Simek .id = 0x30, 86494fffe7SMichal Simek .ver = 0x100, 87494fffe7SMichal Simek .name = "7eg", 88494fffe7SMichal Simek }, 89494fffe7SMichal Simek { 90494fffe7SMichal Simek .id = 0x30, 91494fffe7SMichal Simek .ver = 0x12c, 92494fffe7SMichal Simek .name = "7cg", 93494fffe7SMichal Simek }, 94494fffe7SMichal Simek { 9547e60cbdSMichal Simek .id = 0x38, 9647e60cbdSMichal Simek .name = "9eg", 9747e60cbdSMichal Simek }, 9847e60cbdSMichal Simek { 99494fffe7SMichal Simek .id = 0x38, 100494fffe7SMichal Simek .ver = 0x2c, 101494fffe7SMichal Simek .name = "9cg", 102494fffe7SMichal Simek }, 103494fffe7SMichal Simek { 10447e60cbdSMichal Simek .id = 0x39, 10547e60cbdSMichal Simek .name = "6eg", 10647e60cbdSMichal Simek }, 10747e60cbdSMichal Simek { 108494fffe7SMichal Simek .id = 0x39, 109494fffe7SMichal Simek .ver = 0x2c, 110494fffe7SMichal Simek .name = "6cg", 111494fffe7SMichal Simek }, 112494fffe7SMichal Simek { 11347e60cbdSMichal Simek .id = 0x40, 11447e60cbdSMichal Simek .name = "11eg", 11547e60cbdSMichal Simek }, 116494fffe7SMichal Simek { /* For testing purpose only */ 117494fffe7SMichal Simek .id = 0x50, 118494fffe7SMichal Simek .ver = 0x2c, 119494fffe7SMichal Simek .name = "15cg", 120494fffe7SMichal Simek }, 12147e60cbdSMichal Simek { 12247e60cbdSMichal Simek .id = 0x50, 12347e60cbdSMichal Simek .name = "15eg", 12447e60cbdSMichal Simek }, 12547e60cbdSMichal Simek { 12647e60cbdSMichal Simek .id = 0x58, 12747e60cbdSMichal Simek .name = "19eg", 12847e60cbdSMichal Simek }, 12947e60cbdSMichal Simek { 13047e60cbdSMichal Simek .id = 0x59, 13147e60cbdSMichal Simek .name = "17eg", 13247e60cbdSMichal Simek }, 133b030fedfSMichal Simek { 134b030fedfSMichal Simek .id = 0x61, 135b030fedfSMichal Simek .name = "21dr", 136b030fedfSMichal Simek }, 137b030fedfSMichal Simek { 138b030fedfSMichal Simek .id = 0x63, 139b030fedfSMichal Simek .name = "23dr", 140b030fedfSMichal Simek }, 141b030fedfSMichal Simek { 142b030fedfSMichal Simek .id = 0x65, 143b030fedfSMichal Simek .name = "25dr", 144b030fedfSMichal Simek }, 145b030fedfSMichal Simek { 146b030fedfSMichal Simek .id = 0x64, 147b030fedfSMichal Simek .name = "27dr", 148b030fedfSMichal Simek }, 149b030fedfSMichal Simek { 150b030fedfSMichal Simek .id = 0x60, 151b030fedfSMichal Simek .name = "28dr", 152b030fedfSMichal Simek }, 153b030fedfSMichal Simek { 154b030fedfSMichal Simek .id = 0x62, 155b030fedfSMichal Simek .name = "29dr", 156b030fedfSMichal Simek }, 15747e60cbdSMichal Simek }; 15874ba69dbSSiva Durga Prasad Paladugu #endif 15947e60cbdSMichal Simek 160f52bf5a3SSiva Durga Prasad Paladugu int chip_id(unsigned char id) 16147e60cbdSMichal Simek { 16247e60cbdSMichal Simek struct pt_regs regs; 16374ba69dbSSiva Durga Prasad Paladugu int val = -EINVAL; 16474ba69dbSSiva Durga Prasad Paladugu 16574ba69dbSSiva Durga Prasad Paladugu if (current_el() != 3) { 16647e60cbdSMichal Simek regs.regs[0] = ZYNQMP_SIP_SVC_CSU_DMA_CHIPID; 16747e60cbdSMichal Simek regs.regs[1] = 0; 16847e60cbdSMichal Simek regs.regs[2] = 0; 16947e60cbdSMichal Simek regs.regs[3] = 0; 17047e60cbdSMichal Simek 17147e60cbdSMichal Simek smc_call(®s); 17247e60cbdSMichal Simek 1730cba6abbSSoren Brinkmann /* 1740cba6abbSSoren Brinkmann * SMC returns: 1750cba6abbSSoren Brinkmann * regs[0][31:0] = status of the operation 1760cba6abbSSoren Brinkmann * regs[0][63:32] = CSU.IDCODE register 1770cba6abbSSoren Brinkmann * regs[1][31:0] = CSU.version register 178494fffe7SMichal Simek * regs[1][63:32] = CSU.IDCODE2 register 1790cba6abbSSoren Brinkmann */ 180db3123b4SSiva Durga Prasad Paladugu switch (id) { 181db3123b4SSiva Durga Prasad Paladugu case IDCODE: 1820cba6abbSSoren Brinkmann regs.regs[0] = upper_32_bits(regs.regs[0]); 1830cba6abbSSoren Brinkmann regs.regs[0] &= ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK | 1840cba6abbSSoren Brinkmann ZYNQMP_CSU_IDCODE_SVD_MASK; 1850cba6abbSSoren Brinkmann regs.regs[0] >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT; 186db3123b4SSiva Durga Prasad Paladugu val = regs.regs[0]; 187db3123b4SSiva Durga Prasad Paladugu break; 188db3123b4SSiva Durga Prasad Paladugu case VERSION: 189db3123b4SSiva Durga Prasad Paladugu regs.regs[1] = lower_32_bits(regs.regs[1]); 190db3123b4SSiva Durga Prasad Paladugu regs.regs[1] &= ZYNQMP_CSU_SILICON_VER_MASK; 191db3123b4SSiva Durga Prasad Paladugu val = regs.regs[1]; 192db3123b4SSiva Durga Prasad Paladugu break; 193494fffe7SMichal Simek case IDCODE2: 194494fffe7SMichal Simek regs.regs[1] = lower_32_bits(regs.regs[1]); 195494fffe7SMichal Simek regs.regs[1] >>= ZYNQMP_CSU_VERSION_EMPTY_SHIFT; 196494fffe7SMichal Simek val = regs.regs[1]; 197494fffe7SMichal Simek break; 198db3123b4SSiva Durga Prasad Paladugu default: 199db3123b4SSiva Durga Prasad Paladugu printf("%s, Invalid Req:0x%x\n", __func__, id); 200db3123b4SSiva Durga Prasad Paladugu } 20174ba69dbSSiva Durga Prasad Paladugu } else { 20274ba69dbSSiva Durga Prasad Paladugu switch (id) { 20374ba69dbSSiva Durga Prasad Paladugu case IDCODE: 20474ba69dbSSiva Durga Prasad Paladugu val = readl(ZYNQMP_CSU_IDCODE_ADDR); 20574ba69dbSSiva Durga Prasad Paladugu val &= ZYNQMP_CSU_IDCODE_DEVICE_CODE_MASK | 20674ba69dbSSiva Durga Prasad Paladugu ZYNQMP_CSU_IDCODE_SVD_MASK; 20774ba69dbSSiva Durga Prasad Paladugu val >>= ZYNQMP_CSU_IDCODE_SVD_SHIFT; 20874ba69dbSSiva Durga Prasad Paladugu break; 20974ba69dbSSiva Durga Prasad Paladugu case VERSION: 21074ba69dbSSiva Durga Prasad Paladugu val = readl(ZYNQMP_CSU_VER_ADDR); 21174ba69dbSSiva Durga Prasad Paladugu val &= ZYNQMP_CSU_SILICON_VER_MASK; 21274ba69dbSSiva Durga Prasad Paladugu break; 21374ba69dbSSiva Durga Prasad Paladugu default: 21474ba69dbSSiva Durga Prasad Paladugu printf("%s, Invalid Req:0x%x\n", __func__, id); 21574ba69dbSSiva Durga Prasad Paladugu } 21674ba69dbSSiva Durga Prasad Paladugu } 2170cba6abbSSoren Brinkmann 218db3123b4SSiva Durga Prasad Paladugu return val; 21947e60cbdSMichal Simek } 22047e60cbdSMichal Simek 22174ba69dbSSiva Durga Prasad Paladugu #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \ 22274ba69dbSSiva Durga Prasad Paladugu !defined(CONFIG_SPL_BUILD) 22347e60cbdSMichal Simek static char *zynqmp_get_silicon_idcode_name(void) 22447e60cbdSMichal Simek { 225494fffe7SMichal Simek u32 i, id, ver; 22647e60cbdSMichal Simek 227db3123b4SSiva Durga Prasad Paladugu id = chip_id(IDCODE); 228494fffe7SMichal Simek ver = chip_id(IDCODE2); 229494fffe7SMichal Simek 23047e60cbdSMichal Simek for (i = 0; i < ARRAY_SIZE(zynqmp_devices); i++) { 231494fffe7SMichal Simek if (zynqmp_devices[i].id == id && zynqmp_devices[i].ver == ver) 23247e60cbdSMichal Simek return zynqmp_devices[i].name; 23347e60cbdSMichal Simek } 23447e60cbdSMichal Simek return "unknown"; 23547e60cbdSMichal Simek } 23647e60cbdSMichal Simek #endif 23747e60cbdSMichal Simek 238fb4000e8SMichal Simek int board_early_init_f(void) 239fb4000e8SMichal Simek { 240fb4000e8SMichal Simek #if !defined(CONFIG_SPL_BUILD) && defined(CONFIG_CLK_ZYNQMP) 241fb4000e8SMichal Simek zynqmp_pmufw_version(); 242fb4000e8SMichal Simek #endif 24355de0929SMichal Simek 244fd1b635cSMichal Simek #if defined(CONFIG_SPL_BUILD) || defined(CONFIG_ZYNQMP_PSU_INIT_ENABLED) 24555de0929SMichal Simek psu_init(); 24655de0929SMichal Simek #endif 24755de0929SMichal Simek 248fb4000e8SMichal Simek return 0; 249fb4000e8SMichal Simek } 250fb4000e8SMichal Simek 25147e60cbdSMichal Simek #define ZYNQMP_VERSION_SIZE 9 25247e60cbdSMichal Simek 25384c7204bSMichal Simek int board_init(void) 25484c7204bSMichal Simek { 255a0736efbSMichal Simek printf("EL Level:\tEL%d\n", current_el()); 256a0736efbSMichal Simek 25747e60cbdSMichal Simek #if defined(CONFIG_FPGA) && defined(CONFIG_FPGA_ZYNQMPPL) && \ 25847e60cbdSMichal Simek !defined(CONFIG_SPL_BUILD) || (defined(CONFIG_SPL_FPGA_SUPPORT) && \ 25947e60cbdSMichal Simek defined(CONFIG_SPL_BUILD)) 26047e60cbdSMichal Simek if (current_el() != 3) { 26147e60cbdSMichal Simek static char version[ZYNQMP_VERSION_SIZE]; 26247e60cbdSMichal Simek 2630fc9d848SMichal Simek strncat(version, "zu", 2); 26447e60cbdSMichal Simek zynqmppl.name = strncat(version, 26547e60cbdSMichal Simek zynqmp_get_silicon_idcode_name(), 2660fc9d848SMichal Simek ZYNQMP_VERSION_SIZE - 3); 26747e60cbdSMichal Simek printf("Chip ID:\t%s\n", zynqmppl.name); 26847e60cbdSMichal Simek fpga_init(); 26947e60cbdSMichal Simek fpga_add(fpga_xilinx, &zynqmppl); 27047e60cbdSMichal Simek } 27147e60cbdSMichal Simek #endif 27247e60cbdSMichal Simek 27384c7204bSMichal Simek return 0; 27484c7204bSMichal Simek } 27584c7204bSMichal Simek 27684c7204bSMichal Simek int board_early_init_r(void) 27784c7204bSMichal Simek { 27884c7204bSMichal Simek u32 val; 27984c7204bSMichal Simek 280ec60a279SSiva Durga Prasad Paladugu if (current_el() != 3) 281ec60a279SSiva Durga Prasad Paladugu return 0; 282ec60a279SSiva Durga Prasad Paladugu 28390a35db4SMichal Simek val = readl(&crlapb_base->timestamp_ref_ctrl); 28490a35db4SMichal Simek val &= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; 28590a35db4SMichal Simek 286ec60a279SSiva Durga Prasad Paladugu if (!val) { 28784c7204bSMichal Simek val = readl(&crlapb_base->timestamp_ref_ctrl); 28884c7204bSMichal Simek val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; 28984c7204bSMichal Simek writel(val, &crlapb_base->timestamp_ref_ctrl); 29084c7204bSMichal Simek 2910785dfd8SMichal Simek /* Program freq register in System counter */ 2920785dfd8SMichal Simek writel(zynqmp_get_system_timer_freq(), 2930785dfd8SMichal Simek &iou_scntr_secure->base_frequency_id_register); 2940785dfd8SMichal Simek /* And enable system counter */ 2950785dfd8SMichal Simek writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN, 2960785dfd8SMichal Simek &iou_scntr_secure->counter_control_register); 2970785dfd8SMichal Simek } 29884c7204bSMichal Simek return 0; 29984c7204bSMichal Simek } 30084c7204bSMichal Simek 3016919b4bfSMichal Simek int zynq_board_read_rom_ethaddr(unsigned char *ethaddr) 3026919b4bfSMichal Simek { 3036919b4bfSMichal Simek #if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \ 3046919b4bfSMichal Simek defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET) && \ 3056919b4bfSMichal Simek defined(CONFIG_ZYNQ_EEPROM_BUS) 3066919b4bfSMichal Simek i2c_set_bus_num(CONFIG_ZYNQ_EEPROM_BUS); 3076919b4bfSMichal Simek 3086919b4bfSMichal Simek if (eeprom_read(CONFIG_ZYNQ_GEM_EEPROM_ADDR, 3096919b4bfSMichal Simek CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET, 3106919b4bfSMichal Simek ethaddr, 6)) 3116919b4bfSMichal Simek printf("I2C EEPROM MAC address read failed\n"); 3126919b4bfSMichal Simek #endif 3136919b4bfSMichal Simek 3146919b4bfSMichal Simek return 0; 3156919b4bfSMichal Simek } 3166919b4bfSMichal Simek 3178d59d7f6SMichal Simek #if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE) 31876b00acaSSimon Glass int dram_init_banksize(void) 319361a8799STom Rini { 320da3f003bSMichal Simek return fdtdec_setup_memory_banksize(); 3218d59d7f6SMichal Simek } 3228d59d7f6SMichal Simek 3238d59d7f6SMichal Simek int dram_init(void) 3248d59d7f6SMichal Simek { 325950f86caSNathan Rossi if (fdtdec_setup_memory_size() != 0) 326950f86caSNathan Rossi return -EINVAL; 3278d59d7f6SMichal Simek 3288d59d7f6SMichal Simek return 0; 3298d59d7f6SMichal Simek } 3308d59d7f6SMichal Simek #else 33184c7204bSMichal Simek int dram_init(void) 33284c7204bSMichal Simek { 33384c7204bSMichal Simek gd->ram_size = CONFIG_SYS_SDRAM_SIZE; 33484c7204bSMichal Simek 33584c7204bSMichal Simek return 0; 33684c7204bSMichal Simek } 3378d59d7f6SMichal Simek #endif 33884c7204bSMichal Simek 33984c7204bSMichal Simek void reset_cpu(ulong addr) 34084c7204bSMichal Simek { 34184c7204bSMichal Simek } 34284c7204bSMichal Simek 34384c7204bSMichal Simek int board_late_init(void) 34484c7204bSMichal Simek { 34584c7204bSMichal Simek u32 reg = 0; 34684c7204bSMichal Simek u8 bootmode; 347b72894f1SMichal Simek const char *mode; 348b72894f1SMichal Simek char *new_targets; 349*01c42d3dSSiva Durga Prasad Paladugu char *env_targets; 350d1db89f4SSiva Durga Prasad Paladugu int ret; 351b72894f1SMichal Simek 352b72894f1SMichal Simek if (!(gd->flags & GD_FLG_ENV_DEFAULT)) { 353b72894f1SMichal Simek debug("Saved variables - Skipping\n"); 354b72894f1SMichal Simek return 0; 355b72894f1SMichal Simek } 35684c7204bSMichal Simek 357d1db89f4SSiva Durga Prasad Paladugu ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, ®); 358d1db89f4SSiva Durga Prasad Paladugu if (ret) 359d1db89f4SSiva Durga Prasad Paladugu return -EINVAL; 360d1db89f4SSiva Durga Prasad Paladugu 36147359a03SMichal Simek if (reg >> BOOT_MODE_ALT_SHIFT) 36247359a03SMichal Simek reg >>= BOOT_MODE_ALT_SHIFT; 36347359a03SMichal Simek 36484c7204bSMichal Simek bootmode = reg & BOOT_MODES_MASK; 36584c7204bSMichal Simek 366fb90917cSMichal Simek puts("Bootmode: "); 36784c7204bSMichal Simek switch (bootmode) { 368d58fc12eSMichal Simek case USB_MODE: 369d58fc12eSMichal Simek puts("USB_MODE\n"); 370d58fc12eSMichal Simek mode = "usb"; 37107656ba5SMichal Simek env_set("modeboot", "usb_dfu_spl"); 372d58fc12eSMichal Simek break; 3730a5bcc8cSSiva Durga Prasad Paladugu case JTAG_MODE: 374fb90917cSMichal Simek puts("JTAG_MODE\n"); 375b72894f1SMichal Simek mode = "pxe dhcp"; 37607656ba5SMichal Simek env_set("modeboot", "jtagboot"); 3770a5bcc8cSSiva Durga Prasad Paladugu break; 3780a5bcc8cSSiva Durga Prasad Paladugu case QSPI_MODE_24BIT: 3790a5bcc8cSSiva Durga Prasad Paladugu case QSPI_MODE_32BIT: 380b72894f1SMichal Simek mode = "qspi0"; 381fb90917cSMichal Simek puts("QSPI_MODE\n"); 38207656ba5SMichal Simek env_set("modeboot", "qspiboot"); 3830a5bcc8cSSiva Durga Prasad Paladugu break; 38439c56f55SMichal Simek case EMMC_MODE: 38578678feeSMichal Simek puts("EMMC_MODE\n"); 386b72894f1SMichal Simek mode = "mmc0"; 38707656ba5SMichal Simek env_set("modeboot", "emmcboot"); 38878678feeSMichal Simek break; 38978678feeSMichal Simek case SD_MODE: 390fb90917cSMichal Simek puts("SD_MODE\n"); 391b72894f1SMichal Simek mode = "mmc0"; 39207656ba5SMichal Simek env_set("modeboot", "sdboot"); 39384c7204bSMichal Simek break; 394e1992276SSiva Durga Prasad Paladugu case SD1_LSHFT_MODE: 395e1992276SSiva Durga Prasad Paladugu puts("LVL_SHFT_"); 396e1992276SSiva Durga Prasad Paladugu /* fall through */ 397af813acdSMichal Simek case SD_MODE1: 398fb90917cSMichal Simek puts("SD_MODE1\n"); 3992d9925bcSMichal Simek #if defined(CONFIG_ZYNQ_SDHCI0) && defined(CONFIG_ZYNQ_SDHCI1) 400b72894f1SMichal Simek mode = "mmc1"; 40107656ba5SMichal Simek env_set("sdbootdev", "1"); 402b72894f1SMichal Simek #else 403b72894f1SMichal Simek mode = "mmc0"; 4042d9925bcSMichal Simek #endif 40507656ba5SMichal Simek env_set("modeboot", "sdboot"); 406af813acdSMichal Simek break; 407af813acdSMichal Simek case NAND_MODE: 408fb90917cSMichal Simek puts("NAND_MODE\n"); 409b72894f1SMichal Simek mode = "nand0"; 41007656ba5SMichal Simek env_set("modeboot", "nandboot"); 411af813acdSMichal Simek break; 41284c7204bSMichal Simek default: 413b72894f1SMichal Simek mode = ""; 41484c7204bSMichal Simek printf("Invalid Boot Mode:0x%x\n", bootmode); 41584c7204bSMichal Simek break; 41684c7204bSMichal Simek } 41784c7204bSMichal Simek 418b72894f1SMichal Simek /* 419b72894f1SMichal Simek * One terminating char + one byte for space between mode 420b72894f1SMichal Simek * and default boot_targets 421b72894f1SMichal Simek */ 422*01c42d3dSSiva Durga Prasad Paladugu env_targets = env_get("boot_targets"); 423*01c42d3dSSiva Durga Prasad Paladugu if (env_targets) { 424b72894f1SMichal Simek new_targets = calloc(1, strlen(mode) + 425*01c42d3dSSiva Durga Prasad Paladugu strlen(env_targets) + 2); 426*01c42d3dSSiva Durga Prasad Paladugu sprintf(new_targets, "%s %s", mode, env_targets); 427*01c42d3dSSiva Durga Prasad Paladugu } else { 428*01c42d3dSSiva Durga Prasad Paladugu new_targets = calloc(1, strlen(mode) + 2); 429*01c42d3dSSiva Durga Prasad Paladugu sprintf(new_targets, "%s", mode); 430*01c42d3dSSiva Durga Prasad Paladugu } 431b72894f1SMichal Simek 432382bee57SSimon Glass env_set("boot_targets", new_targets); 433b72894f1SMichal Simek 43484c7204bSMichal Simek return 0; 43584c7204bSMichal Simek } 43684696ff5SSiva Durga Prasad Paladugu 43784696ff5SSiva Durga Prasad Paladugu int checkboard(void) 43884696ff5SSiva Durga Prasad Paladugu { 4395af08556SMichal Simek puts("Board: Xilinx ZynqMP\n"); 44084696ff5SSiva Durga Prasad Paladugu return 0; 44184696ff5SSiva Durga Prasad Paladugu } 44216fa00a7SSiva Durga Prasad Paladugu 44316fa00a7SSiva Durga Prasad Paladugu #ifdef CONFIG_USB_DWC3 444275bd6d1SMichal Simek static struct dwc3_device dwc3_device_data0 = { 44516fa00a7SSiva Durga Prasad Paladugu .maximum_speed = USB_SPEED_HIGH, 44616fa00a7SSiva Durga Prasad Paladugu .base = ZYNQMP_USB0_XHCI_BASEADDR, 44716fa00a7SSiva Durga Prasad Paladugu .dr_mode = USB_DR_MODE_PERIPHERAL, 44816fa00a7SSiva Durga Prasad Paladugu .index = 0, 44916fa00a7SSiva Durga Prasad Paladugu }; 45016fa00a7SSiva Durga Prasad Paladugu 451275bd6d1SMichal Simek static struct dwc3_device dwc3_device_data1 = { 452275bd6d1SMichal Simek .maximum_speed = USB_SPEED_HIGH, 453275bd6d1SMichal Simek .base = ZYNQMP_USB1_XHCI_BASEADDR, 454275bd6d1SMichal Simek .dr_mode = USB_DR_MODE_PERIPHERAL, 455275bd6d1SMichal Simek .index = 1, 456275bd6d1SMichal Simek }; 457275bd6d1SMichal Simek 4589feff385SMichal Simek int usb_gadget_handle_interrupts(int index) 45916fa00a7SSiva Durga Prasad Paladugu { 4609feff385SMichal Simek dwc3_uboot_handle_interrupt(index); 46116fa00a7SSiva Durga Prasad Paladugu return 0; 46216fa00a7SSiva Durga Prasad Paladugu } 46316fa00a7SSiva Durga Prasad Paladugu 46416fa00a7SSiva Durga Prasad Paladugu int board_usb_init(int index, enum usb_init_type init) 46516fa00a7SSiva Durga Prasad Paladugu { 466275bd6d1SMichal Simek debug("%s: index %x\n", __func__, index); 467275bd6d1SMichal Simek 4688ecd50c8SMichal Simek #if defined(CONFIG_USB_GADGET_DOWNLOAD) 4698ecd50c8SMichal Simek g_dnl_set_serialnumber(CONFIG_SYS_CONFIG_NAME); 4708ecd50c8SMichal Simek #endif 4718ecd50c8SMichal Simek 472275bd6d1SMichal Simek switch (index) { 473275bd6d1SMichal Simek case 0: 474275bd6d1SMichal Simek return dwc3_uboot_init(&dwc3_device_data0); 475275bd6d1SMichal Simek case 1: 476275bd6d1SMichal Simek return dwc3_uboot_init(&dwc3_device_data1); 477275bd6d1SMichal Simek }; 478275bd6d1SMichal Simek 479275bd6d1SMichal Simek return -1; 48016fa00a7SSiva Durga Prasad Paladugu } 48116fa00a7SSiva Durga Prasad Paladugu 48216fa00a7SSiva Durga Prasad Paladugu int board_usb_cleanup(int index, enum usb_init_type init) 48316fa00a7SSiva Durga Prasad Paladugu { 48416fa00a7SSiva Durga Prasad Paladugu dwc3_uboot_exit(index); 48516fa00a7SSiva Durga Prasad Paladugu return 0; 48616fa00a7SSiva Durga Prasad Paladugu } 48716fa00a7SSiva Durga Prasad Paladugu #endif 488