1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Michal Simek <monstr@monstr.eu>
4 * Copyright (C) 2012 Xilinx, Inc. All rights reserved.
9 #include <asm/arch/clk.h>
10 #include <asm/arch/hardware.h>
11 #include <asm/arch/ps7_init_gpl.h>
12 #include <asm/arch/sys_proto.h>
14 #define ZYNQ_SILICON_VER_MASK 0xF0000000
15 #define ZYNQ_SILICON_VER_SHIFT 28
17 #if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
18 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
20 .family = xilinx_zynq,
22 .operations = &zynq_op,
28 #if defined(CONFIG_FPGA)
32 } zynq_fpga_descs[] = {
46 int arch_cpu_init(void)
49 #ifndef CONFIG_SPL_BUILD
50 /* Device config APB, unlock the PCAP */
51 writel(0x757BDF0D, &devcfg_base->unlock);
52 writel(0xFFFFFFFF, &devcfg_base->rom_shadow);
54 #if (CONFIG_SYS_SDRAM_BASE == 0)
55 /* remap DDR to zero, FILTERSTART */
56 writel(0, &scu_base->filter_start);
58 /* OCM_CFG, Mask out the ROM, map ram into upper addresses */
59 writel(0x1F, &slcr_base->ocm_cfg);
60 /* FPGA_RST_CTRL, clear resets on AXI fabric ports */
61 writel(0x0, &slcr_base->fpga_rst_ctrl);
62 /* Set urgent bits with register */
63 writel(0x0, &slcr_base->ddr_urgent_sel);
64 /* Urgent write, ports S2/S3 */
65 writel(0xC, &slcr_base->ddr_urgent);
73 unsigned int zynq_get_silicon_version(void)
75 return (readl(&devcfg_base->mctrl) & ZYNQ_SILICON_VER_MASK)
76 >> ZYNQ_SILICON_VER_SHIFT;
79 void reset_cpu(ulong addr)
81 zynq_slcr_cpu_reset();
86 #ifndef CONFIG_SYS_DCACHE_OFF
87 void enable_caches(void)
89 /* Enable D-cache. I-cache is already enabled in start.S */
94 static int __maybe_unused cpu_desc_id(void)
99 idcode = zynq_slcr_get_idcode();
100 for (i = 0; zynq_fpga_descs[i].idcode; i++) {
101 if (zynq_fpga_descs[i].idcode == idcode)
108 #if defined(CONFIG_ARCH_EARLY_INIT_R)
109 int arch_early_init_r(void)
111 #if (defined(CONFIG_FPGA) && !defined(CONFIG_SPL_BUILD)) || \
112 (defined(CONFIG_SPL_FPGA_SUPPORT) && defined(CONFIG_SPL_BUILD))
113 int cpu_id = cpu_desc_id();
118 fpga.size = zynq_fpga_descs[cpu_id].fpga_size;
119 fpga.name = zynq_fpga_descs[cpu_id].devicename;
121 fpga_add(fpga_xilinx, &fpga);