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 263df1cd46fSHeinrich Schuchardt strncat(version, "xczu", 4); 26447e60cbdSMichal Simek zynqmppl.name = strncat(version, 26547e60cbdSMichal Simek zynqmp_get_silicon_idcode_name(), 266df1cd46fSHeinrich Schuchardt ZYNQMP_VERSION_SIZE - 5); 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 28090a35db4SMichal Simek val = readl(&crlapb_base->timestamp_ref_ctrl); 28190a35db4SMichal Simek val &= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; 28290a35db4SMichal Simek 28390a35db4SMichal Simek if (current_el() == 3 && !val) { 28484c7204bSMichal Simek val = readl(&crlapb_base->timestamp_ref_ctrl); 28584c7204bSMichal Simek val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; 28684c7204bSMichal Simek writel(val, &crlapb_base->timestamp_ref_ctrl); 28784c7204bSMichal Simek 2880785dfd8SMichal Simek /* Program freq register in System counter */ 2890785dfd8SMichal Simek writel(zynqmp_get_system_timer_freq(), 2900785dfd8SMichal Simek &iou_scntr_secure->base_frequency_id_register); 2910785dfd8SMichal Simek /* And enable system counter */ 2920785dfd8SMichal Simek writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN, 2930785dfd8SMichal Simek &iou_scntr_secure->counter_control_register); 2940785dfd8SMichal Simek } 29584c7204bSMichal Simek return 0; 29684c7204bSMichal Simek } 29784c7204bSMichal Simek 2986919b4bfSMichal Simek int zynq_board_read_rom_ethaddr(unsigned char *ethaddr) 2996919b4bfSMichal Simek { 3006919b4bfSMichal Simek #if defined(CONFIG_ZYNQ_GEM_EEPROM_ADDR) && \ 3016919b4bfSMichal Simek defined(CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET) && \ 3026919b4bfSMichal Simek defined(CONFIG_ZYNQ_EEPROM_BUS) 3036919b4bfSMichal Simek i2c_set_bus_num(CONFIG_ZYNQ_EEPROM_BUS); 3046919b4bfSMichal Simek 3056919b4bfSMichal Simek if (eeprom_read(CONFIG_ZYNQ_GEM_EEPROM_ADDR, 3066919b4bfSMichal Simek CONFIG_ZYNQ_GEM_I2C_MAC_OFFSET, 3076919b4bfSMichal Simek ethaddr, 6)) 3086919b4bfSMichal Simek printf("I2C EEPROM MAC address read failed\n"); 3096919b4bfSMichal Simek #endif 3106919b4bfSMichal Simek 3116919b4bfSMichal Simek return 0; 3126919b4bfSMichal Simek } 3136919b4bfSMichal Simek 3148d59d7f6SMichal Simek #if !defined(CONFIG_SYS_SDRAM_BASE) && !defined(CONFIG_SYS_SDRAM_SIZE) 31576b00acaSSimon Glass int dram_init_banksize(void) 316361a8799STom Rini { 317da3f003bSMichal Simek return fdtdec_setup_memory_banksize(); 3188d59d7f6SMichal Simek } 3198d59d7f6SMichal Simek 3208d59d7f6SMichal Simek int dram_init(void) 3218d59d7f6SMichal Simek { 322950f86caSNathan Rossi if (fdtdec_setup_memory_size() != 0) 323950f86caSNathan Rossi return -EINVAL; 3248d59d7f6SMichal Simek 3258d59d7f6SMichal Simek return 0; 3268d59d7f6SMichal Simek } 3278d59d7f6SMichal Simek #else 32884c7204bSMichal Simek int dram_init(void) 32984c7204bSMichal Simek { 33084c7204bSMichal Simek gd->ram_size = CONFIG_SYS_SDRAM_SIZE; 33184c7204bSMichal Simek 33284c7204bSMichal Simek return 0; 33384c7204bSMichal Simek } 3348d59d7f6SMichal Simek #endif 33584c7204bSMichal Simek 33684c7204bSMichal Simek void reset_cpu(ulong addr) 33784c7204bSMichal Simek { 33884c7204bSMichal Simek } 33984c7204bSMichal Simek 34084c7204bSMichal Simek int board_late_init(void) 34184c7204bSMichal Simek { 34284c7204bSMichal Simek u32 reg = 0; 34384c7204bSMichal Simek u8 bootmode; 344b72894f1SMichal Simek const char *mode; 345b72894f1SMichal Simek char *new_targets; 346*d1db89f4SSiva Durga Prasad Paladugu int ret; 347b72894f1SMichal Simek 348b72894f1SMichal Simek if (!(gd->flags & GD_FLG_ENV_DEFAULT)) { 349b72894f1SMichal Simek debug("Saved variables - Skipping\n"); 350b72894f1SMichal Simek return 0; 351b72894f1SMichal Simek } 35284c7204bSMichal Simek 353*d1db89f4SSiva Durga Prasad Paladugu ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, ®); 354*d1db89f4SSiva Durga Prasad Paladugu if (ret) 355*d1db89f4SSiva Durga Prasad Paladugu return -EINVAL; 356*d1db89f4SSiva Durga Prasad Paladugu 35747359a03SMichal Simek if (reg >> BOOT_MODE_ALT_SHIFT) 35847359a03SMichal Simek reg >>= BOOT_MODE_ALT_SHIFT; 35947359a03SMichal Simek 36084c7204bSMichal Simek bootmode = reg & BOOT_MODES_MASK; 36184c7204bSMichal Simek 362fb90917cSMichal Simek puts("Bootmode: "); 36384c7204bSMichal Simek switch (bootmode) { 364d58fc12eSMichal Simek case USB_MODE: 365d58fc12eSMichal Simek puts("USB_MODE\n"); 366d58fc12eSMichal Simek mode = "usb"; 367d58fc12eSMichal Simek break; 3680a5bcc8cSSiva Durga Prasad Paladugu case JTAG_MODE: 369fb90917cSMichal Simek puts("JTAG_MODE\n"); 370b72894f1SMichal Simek mode = "pxe dhcp"; 3710a5bcc8cSSiva Durga Prasad Paladugu break; 3720a5bcc8cSSiva Durga Prasad Paladugu case QSPI_MODE_24BIT: 3730a5bcc8cSSiva Durga Prasad Paladugu case QSPI_MODE_32BIT: 374b72894f1SMichal Simek mode = "qspi0"; 375fb90917cSMichal Simek puts("QSPI_MODE\n"); 3760a5bcc8cSSiva Durga Prasad Paladugu break; 37739c56f55SMichal Simek case EMMC_MODE: 37878678feeSMichal Simek puts("EMMC_MODE\n"); 379b72894f1SMichal Simek mode = "mmc0"; 38078678feeSMichal Simek break; 38178678feeSMichal Simek case SD_MODE: 382fb90917cSMichal Simek puts("SD_MODE\n"); 383b72894f1SMichal Simek mode = "mmc0"; 38484c7204bSMichal Simek break; 385e1992276SSiva Durga Prasad Paladugu case SD1_LSHFT_MODE: 386e1992276SSiva Durga Prasad Paladugu puts("LVL_SHFT_"); 387e1992276SSiva Durga Prasad Paladugu /* fall through */ 388af813acdSMichal Simek case SD_MODE1: 389fb90917cSMichal Simek puts("SD_MODE1\n"); 3902d9925bcSMichal Simek #if defined(CONFIG_ZYNQ_SDHCI0) && defined(CONFIG_ZYNQ_SDHCI1) 391b72894f1SMichal Simek mode = "mmc1"; 392b72894f1SMichal Simek #else 393b72894f1SMichal Simek mode = "mmc0"; 3942d9925bcSMichal Simek #endif 395af813acdSMichal Simek break; 396af813acdSMichal Simek case NAND_MODE: 397fb90917cSMichal Simek puts("NAND_MODE\n"); 398b72894f1SMichal Simek mode = "nand0"; 399af813acdSMichal Simek break; 40084c7204bSMichal Simek default: 401b72894f1SMichal Simek mode = ""; 40284c7204bSMichal Simek printf("Invalid Boot Mode:0x%x\n", bootmode); 40384c7204bSMichal Simek break; 40484c7204bSMichal Simek } 40584c7204bSMichal Simek 406b72894f1SMichal Simek /* 407b72894f1SMichal Simek * One terminating char + one byte for space between mode 408b72894f1SMichal Simek * and default boot_targets 409b72894f1SMichal Simek */ 410b72894f1SMichal Simek new_targets = calloc(1, strlen(mode) + 41100caae6dSSimon Glass strlen(env_get("boot_targets")) + 2); 412b72894f1SMichal Simek 41300caae6dSSimon Glass sprintf(new_targets, "%s %s", mode, env_get("boot_targets")); 414382bee57SSimon Glass env_set("boot_targets", new_targets); 415b72894f1SMichal Simek 41684c7204bSMichal Simek return 0; 41784c7204bSMichal Simek } 41884696ff5SSiva Durga Prasad Paladugu 41984696ff5SSiva Durga Prasad Paladugu int checkboard(void) 42084696ff5SSiva Durga Prasad Paladugu { 4215af08556SMichal Simek puts("Board: Xilinx ZynqMP\n"); 42284696ff5SSiva Durga Prasad Paladugu return 0; 42384696ff5SSiva Durga Prasad Paladugu } 42416fa00a7SSiva Durga Prasad Paladugu 42516fa00a7SSiva Durga Prasad Paladugu #ifdef CONFIG_USB_DWC3 426275bd6d1SMichal Simek static struct dwc3_device dwc3_device_data0 = { 42716fa00a7SSiva Durga Prasad Paladugu .maximum_speed = USB_SPEED_HIGH, 42816fa00a7SSiva Durga Prasad Paladugu .base = ZYNQMP_USB0_XHCI_BASEADDR, 42916fa00a7SSiva Durga Prasad Paladugu .dr_mode = USB_DR_MODE_PERIPHERAL, 43016fa00a7SSiva Durga Prasad Paladugu .index = 0, 43116fa00a7SSiva Durga Prasad Paladugu }; 43216fa00a7SSiva Durga Prasad Paladugu 433275bd6d1SMichal Simek static struct dwc3_device dwc3_device_data1 = { 434275bd6d1SMichal Simek .maximum_speed = USB_SPEED_HIGH, 435275bd6d1SMichal Simek .base = ZYNQMP_USB1_XHCI_BASEADDR, 436275bd6d1SMichal Simek .dr_mode = USB_DR_MODE_PERIPHERAL, 437275bd6d1SMichal Simek .index = 1, 438275bd6d1SMichal Simek }; 439275bd6d1SMichal Simek 4409feff385SMichal Simek int usb_gadget_handle_interrupts(int index) 44116fa00a7SSiva Durga Prasad Paladugu { 4429feff385SMichal Simek dwc3_uboot_handle_interrupt(index); 44316fa00a7SSiva Durga Prasad Paladugu return 0; 44416fa00a7SSiva Durga Prasad Paladugu } 44516fa00a7SSiva Durga Prasad Paladugu 44616fa00a7SSiva Durga Prasad Paladugu int board_usb_init(int index, enum usb_init_type init) 44716fa00a7SSiva Durga Prasad Paladugu { 448275bd6d1SMichal Simek debug("%s: index %x\n", __func__, index); 449275bd6d1SMichal Simek 4508ecd50c8SMichal Simek #if defined(CONFIG_USB_GADGET_DOWNLOAD) 4518ecd50c8SMichal Simek g_dnl_set_serialnumber(CONFIG_SYS_CONFIG_NAME); 4528ecd50c8SMichal Simek #endif 4538ecd50c8SMichal Simek 454275bd6d1SMichal Simek switch (index) { 455275bd6d1SMichal Simek case 0: 456275bd6d1SMichal Simek return dwc3_uboot_init(&dwc3_device_data0); 457275bd6d1SMichal Simek case 1: 458275bd6d1SMichal Simek return dwc3_uboot_init(&dwc3_device_data1); 459275bd6d1SMichal Simek }; 460275bd6d1SMichal Simek 461275bd6d1SMichal Simek return -1; 46216fa00a7SSiva Durga Prasad Paladugu } 46316fa00a7SSiva Durga Prasad Paladugu 46416fa00a7SSiva Durga Prasad Paladugu int board_usb_cleanup(int index, enum usb_init_type init) 46516fa00a7SSiva Durga Prasad Paladugu { 46616fa00a7SSiva Durga Prasad Paladugu dwc3_uboot_exit(index); 46716fa00a7SSiva Durga Prasad Paladugu return 0; 46816fa00a7SSiva Durga Prasad Paladugu } 46916fa00a7SSiva Durga Prasad Paladugu #endif 470