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.
10 #include <asm/cache.h>
12 #include <asm/arch/clk.h>
13 #include <asm/arch/hardware.h>
14 #include <asm/arch/ps7_init_gpl.h>
15 #include <asm/arch/sys_proto.h>
17 #define ZYNQ_SILICON_VER_MASK 0xF0000000
18 #define ZYNQ_SILICON_VER_SHIFT 28
20 #if CONFIG_IS_ENABLED(FPGA)
22 .family = xilinx_zynq,
24 .operations = &zynq_op,
31 #if defined(CONFIG_FPGA)
35 } zynq_fpga_descs[] = {
49 int arch_cpu_init(void)
52 #ifndef CONFIG_SPL_BUILD
53 /* Device config APB, unlock the PCAP */
54 writel(0x757BDF0D, &devcfg_base->unlock);
55 writel(0xFFFFFFFF, &devcfg_base->rom_shadow);
57 #if (CFG_SYS_SDRAM_BASE == 0)
58 /* remap DDR to zero, FILTERSTART */
59 writel(0, &scu_base->filter_start);
61 /* OCM_CFG, Mask out the ROM, map ram into upper addresses */
62 writel(0x1F, &slcr_base->ocm_cfg);
63 /* FPGA_RST_CTRL, clear resets on AXI fabric ports */
64 writel(0x0, &slcr_base->fpga_rst_ctrl);
65 /* Set urgent bits with register */
66 writel(0x0, &slcr_base->ddr_urgent_sel);
67 /* Urgent write, ports S2/S3 */
68 writel(0xC, &slcr_base->ddr_urgent);
76 unsigned int zynq_get_silicon_version(void)
78 return (readl(&devcfg_base->mctrl) & ZYNQ_SILICON_VER_MASK)
79 >> ZYNQ_SILICON_VER_SHIFT;
84 zynq_slcr_cpu_reset();
89 #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
90 void enable_caches(void)
92 /* Enable D-cache. I-cache is already enabled in start.S */
97 static int __maybe_unused cpu_desc_id(void)
102 idcode = zynq_slcr_get_idcode();
103 for (i = 0; zynq_fpga_descs[i].idcode; i++) {
104 if (zynq_fpga_descs[i].idcode == idcode)
111 #if defined(CONFIG_ARCH_EARLY_INIT_R)
112 int arch_early_init_r(void)
114 #if CONFIG_IS_ENABLED(FPGA)
115 int cpu_id = cpu_desc_id();
120 fpga.size = zynq_fpga_descs[cpu_id].fpga_size;
121 fpga.name = zynq_fpga_descs[cpu_id].devicename;
123 fpga_add(fpga_xilinx, &fpga);
129 #ifdef CONFIG_DISPLAY_CPUINFO
130 int print_cpuinfo(void)
133 int cpu_id = cpu_desc_id();
138 version = zynq_get_silicon_version() << 1;
139 if (version > (PCW_SILICON_VERSION_3 << 1))
142 printf("CPU: Zynq %s\n", zynq_fpga_descs[cpu_id].devicename);
143 printf("Silicon: v%d.%d\n", version >> 1, version & 1);