xref: /openbmc/u-boot/board/xilinx/zynqmp/zynqmp.c (revision 16247d28d5e50fca8b2e11b5e1804524bca83361)
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>
1084c7204bSMichal Simek #include <asm/arch/hardware.h>
1184c7204bSMichal Simek #include <asm/arch/sys_proto.h>
1284c7204bSMichal Simek #include <asm/io.h>
1384c7204bSMichal Simek 
1484c7204bSMichal Simek DECLARE_GLOBAL_DATA_PTR;
1584c7204bSMichal Simek 
1684c7204bSMichal Simek int board_init(void)
1784c7204bSMichal Simek {
1884c7204bSMichal Simek 	return 0;
1984c7204bSMichal Simek }
2084c7204bSMichal Simek 
2184c7204bSMichal Simek int board_early_init_r(void)
2284c7204bSMichal Simek {
2384c7204bSMichal Simek 	u32 val;
2484c7204bSMichal Simek 
2584c7204bSMichal Simek 	val = readl(&crlapb_base->timestamp_ref_ctrl);
2684c7204bSMichal Simek 	val |= ZYNQMP_CRL_APB_TIMESTAMP_REF_CTRL_CLKACT;
2784c7204bSMichal Simek 	writel(val, &crlapb_base->timestamp_ref_ctrl);
2884c7204bSMichal Simek 
2984c7204bSMichal Simek 	/* Program freq register in System counter and enable system counter */
3084c7204bSMichal Simek 	writel(gd->cpu_clk, &iou_scntr->base_frequency_id_register);
3184c7204bSMichal Simek 	writel(ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_HDBG |
3284c7204bSMichal Simek 	       ZYNQMP_IOU_SCNTR_COUNTER_CONTROL_REGISTER_EN,
3384c7204bSMichal Simek 	       &iou_scntr->counter_control_register);
3484c7204bSMichal Simek 
3584c7204bSMichal Simek 	return 0;
3684c7204bSMichal Simek }
3784c7204bSMichal Simek 
3884c7204bSMichal Simek int dram_init(void)
3984c7204bSMichal Simek {
4084c7204bSMichal Simek 	gd->ram_size = CONFIG_SYS_SDRAM_SIZE;
4184c7204bSMichal Simek 
4284c7204bSMichal Simek 	return 0;
4384c7204bSMichal Simek }
4484c7204bSMichal Simek 
4584c7204bSMichal Simek int timer_init(void)
4684c7204bSMichal Simek {
4784c7204bSMichal Simek 	return 0;
4884c7204bSMichal Simek }
4984c7204bSMichal Simek 
5084c7204bSMichal Simek void reset_cpu(ulong addr)
5184c7204bSMichal Simek {
5284c7204bSMichal Simek }
5384c7204bSMichal Simek 
5484c7204bSMichal Simek #ifdef CONFIG_CMD_MMC
5584c7204bSMichal Simek int board_mmc_init(bd_t *bd)
5684c7204bSMichal Simek {
5784c7204bSMichal Simek 	int ret = 0;
5884c7204bSMichal Simek 
59*16247d28SMichal Simek 	u32 ver = zynqmp_get_silicon_version();
60*16247d28SMichal Simek 
61*16247d28SMichal Simek 	if (ver != ZYNQMP_CSU_VERSION_VELOCE) {
6284c7204bSMichal Simek #if defined(CONFIG_ZYNQ_SDHCI)
6384c7204bSMichal Simek # if defined(CONFIG_ZYNQ_SDHCI0)
6484c7204bSMichal Simek 		ret = zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR0);
6584c7204bSMichal Simek # endif
6684c7204bSMichal Simek # if defined(CONFIG_ZYNQ_SDHCI1)
6784c7204bSMichal Simek 		ret |= zynq_sdhci_init(ZYNQ_SDHCI_BASEADDR1);
6884c7204bSMichal Simek # endif
6984c7204bSMichal Simek #endif
70*16247d28SMichal Simek 	}
7184c7204bSMichal Simek 
7284c7204bSMichal Simek 	return ret;
7384c7204bSMichal Simek }
7484c7204bSMichal Simek #endif
7584c7204bSMichal Simek 
7684c7204bSMichal Simek int board_late_init(void)
7784c7204bSMichal Simek {
7884c7204bSMichal Simek 	u32 reg = 0;
7984c7204bSMichal Simek 	u8 bootmode;
8084c7204bSMichal Simek 
8184c7204bSMichal Simek 	reg = readl(&crlapb_base->boot_mode);
8284c7204bSMichal Simek 	bootmode = reg & BOOT_MODES_MASK;
8384c7204bSMichal Simek 
8484c7204bSMichal Simek 	switch (bootmode) {
8584c7204bSMichal Simek 	case SD_MODE:
8684c7204bSMichal Simek 		setenv("modeboot", "sdboot");
8784c7204bSMichal Simek 		break;
8884c7204bSMichal Simek 	default:
8984c7204bSMichal Simek 		printf("Invalid Boot Mode:0x%x\n", bootmode);
9084c7204bSMichal Simek 		break;
9184c7204bSMichal Simek 	}
9284c7204bSMichal Simek 
9384c7204bSMichal Simek 	return 0;
9484c7204bSMichal Simek }
95