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> 984c7204bSMichal Simek #include <netdev.h> 10*6fe6f135SMichal Simek #include <ahci.h> 11*6fe6f135SMichal Simek #include <scsi.h> 1284c7204bSMichal Simek #include <asm/arch/hardware.h> 1384c7204bSMichal Simek #include <asm/arch/sys_proto.h> 1484c7204bSMichal Simek #include <asm/io.h> 1584c7204bSMichal Simek 1684c7204bSMichal Simek DECLARE_GLOBAL_DATA_PTR; 1784c7204bSMichal Simek 1884c7204bSMichal Simek int board_init(void) 1984c7204bSMichal Simek { 2084c7204bSMichal Simek return 0; 2184c7204bSMichal Simek } 2284c7204bSMichal Simek 2384c7204bSMichal Simek int board_early_init_r(void) 2484c7204bSMichal Simek { 2584c7204bSMichal Simek u32 val; 2684c7204bSMichal Simek 2784c7204bSMichal Simek val = readl(&crlapb_base->timestamp_ref_ctrl); 2884c7204bSMichal Simek val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT; 2984c7204bSMichal Simek writel(val, &crlapb_base->timestamp_ref_ctrl); 3084c7204bSMichal Simek 3184c7204bSMichal Simek /* Program freq register in System counter and enable system counter */ 3284c7204bSMichal Simek writel(gd->cpu_clk, &iou_scntr->base_frequency_id_register); 3384c7204bSMichal Simek writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_HDBG | 3484c7204bSMichal Simek ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN, 3584c7204bSMichal Simek &iou_scntr->counter_control_register); 3684c7204bSMichal Simek 3784c7204bSMichal Simek return 0; 3884c7204bSMichal Simek } 3984c7204bSMichal Simek 4084c7204bSMichal Simek int dram_init(void) 4184c7204bSMichal Simek { 4284c7204bSMichal Simek gd->ram_size = CONFIG_SYS_SDRAM_SIZE; 4384c7204bSMichal Simek 4484c7204bSMichal Simek return 0; 4584c7204bSMichal Simek } 4684c7204bSMichal Simek 4784c7204bSMichal Simek int timer_init(void) 4884c7204bSMichal Simek { 4984c7204bSMichal Simek return 0; 5084c7204bSMichal Simek } 5184c7204bSMichal Simek 5284c7204bSMichal Simek void reset_cpu(ulong addr) 5384c7204bSMichal Simek { 5484c7204bSMichal Simek } 5584c7204bSMichal Simek 56*6fe6f135SMichal Simek #ifdef CONFIG_SCSI_AHCI_PLAT 57*6fe6f135SMichal Simek void scsi_init(void) 58*6fe6f135SMichal Simek { 59*6fe6f135SMichal Simek ahci_init((void __iomem *)ZYNQMP_SATA_BASEADDR); 60*6fe6f135SMichal Simek scsi_scan(1); 61*6fe6f135SMichal Simek } 62*6fe6f135SMichal Simek #endif 63*6fe6f135SMichal Simek 64cb7ea820SMichal Simek int board_eth_init(bd_t *bis) 65cb7ea820SMichal Simek { 66cb7ea820SMichal Simek u32 ret = 0; 67cb7ea820SMichal Simek 68cb7ea820SMichal Simek #if defined(CONFIG_ZYNQ_GEM) 69cb7ea820SMichal Simek # if defined(CONFIG_ZYNQ_GEM0) 70cb7ea820SMichal Simek ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR0, 71cb7ea820SMichal Simek CONFIG_ZYNQ_GEM_PHY_ADDR0, 0); 72cb7ea820SMichal Simek # endif 73cb7ea820SMichal Simek # if defined(CONFIG_ZYNQ_GEM1) 74cb7ea820SMichal Simek ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR1, 75cb7ea820SMichal Simek CONFIG_ZYNQ_GEM_PHY_ADDR1, 0); 76cb7ea820SMichal Simek # endif 77cb7ea820SMichal Simek # if defined(CONFIG_ZYNQ_GEM2) 78cb7ea820SMichal Simek ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR2, 79cb7ea820SMichal Simek CONFIG_ZYNQ_GEM_PHY_ADDR2, 0); 80cb7ea820SMichal Simek # endif 81cb7ea820SMichal Simek # if defined(CONFIG_ZYNQ_GEM3) 82cb7ea820SMichal Simek ret |= zynq_gem_initialize(bis, ZYNQ_GEM_BASEADDR3, 83cb7ea820SMichal Simek CONFIG_ZYNQ_GEM_PHY_ADDR3, 0); 84cb7ea820SMichal Simek # endif 85cb7ea820SMichal Simek #endif 86cb7ea820SMichal Simek return ret; 87cb7ea820SMichal Simek } 88cb7ea820SMichal Simek 8984c7204bSMichal Simek #ifdef CONFIG_CMD_MMC 9084c7204bSMichal Simek int board_mmc_init(bd_t *bd) 9184c7204bSMichal Simek { 9284c7204bSMichal Simek int ret = 0; 9384c7204bSMichal Simek 9416247d28SMichal Simek u32 ver = zynqmp_get_silicon_version(); 9516247d28SMichal Simek 9616247d28SMichal Simek if (ver != ZYNQMP_CSU_VERSION_VELOCE) { 9784c7204bSMichal Simek #if defined(CONFIG_ZYNQ_SDHCI) 9884c7204bSMichal Simek # if defined(CONFIG_ZYNQ_SDHCI0) 9984c7204bSMichal Simek ret = zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR0); 10084c7204bSMichal Simek # endif 10184c7204bSMichal Simek # if defined(CONFIG_ZYNQ_SDHCI1) 10284c7204bSMichal Simek ret |= zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR1); 10384c7204bSMichal Simek # endif 10484c7204bSMichal Simek #endif 10516247d28SMichal Simek } 10684c7204bSMichal Simek 10784c7204bSMichal Simek return ret; 10884c7204bSMichal Simek } 10984c7204bSMichal Simek #endif 11084c7204bSMichal Simek 11184c7204bSMichal Simek int board_late_init(void) 11284c7204bSMichal Simek { 11384c7204bSMichal Simek u32 reg = 0; 11484c7204bSMichal Simek u8 bootmode; 11584c7204bSMichal Simek 11684c7204bSMichal Simek reg = readl(&crlapb_base->boot_mode); 11784c7204bSMichal Simek bootmode = reg & BOOT_MODES_MASK; 11884c7204bSMichal Simek 11984c7204bSMichal Simek switch (bootmode) { 12084c7204bSMichal Simek case SD_MODE: 12139c56f55SMichal Simek case EMMC_MODE: 12284c7204bSMichal Simek setenv("modeboot", "sdboot"); 12384c7204bSMichal Simek break; 12484c7204bSMichal Simek default: 12584c7204bSMichal Simek printf("Invalid Boot Mode:0x%x\n", bootmode); 12684c7204bSMichal Simek break; 12784c7204bSMichal Simek } 12884c7204bSMichal Simek 12984c7204bSMichal Simek return 0; 13084c7204bSMichal Simek } 131