]> Git Repo - J-u-boot.git/blame - arch/arm/mach-zynq/cpu.c
Merge patch series "Add AM64x Support to PRUSS and PRU_RPROC driver"
[J-u-boot.git] / arch / arm / mach-zynq / cpu.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
38b343dd
MS
2/*
3 * Copyright (C) 2012 Michal Simek <[email protected]>
4 * Copyright (C) 2012 Xilinx, Inc. All rights reserved.
38b343dd 5 */
74bb55bc 6#include <config.h>
9edefc27 7#include <cpu_func.h>
691d719d 8#include <init.h>
4aba5fb8 9#include <zynqpl.h>
74bb55bc 10#include <linux/errno.h>
90526e9f 11#include <asm/cache.h>
00ed3458 12#include <asm/io.h>
6c3e61de 13#include <asm/arch/clk.h>
00ed3458 14#include <asm/arch/hardware.h>
4aba5fb8
MS
15#include <asm/arch/ps7_init_gpl.h>
16#include <asm/arch/sys_proto.h>
38b343dd 17
96a2859e
SDPP
18#define ZYNQ_SILICON_VER_MASK 0xF0000000
19#define ZYNQ_SILICON_VER_SHIFT 28
20
29bd8ada 21#if CONFIG_IS_ENABLED(FPGA)
4aba5fb8
MS
22xilinx_desc fpga = {
23 .family = xilinx_zynq,
24 .iface = devcfg,
25 .operations = &zynq_op,
d7fcbfc1 26 .flags = FPGA_LEGACY,
4aba5fb8
MS
27};
28#endif
29
30static const struct {
31 u8 idcode;
32#if defined(CONFIG_FPGA)
33 u32 fpga_size;
34#endif
35 char *devicename;
36} zynq_fpga_descs[] = {
37 ZYNQ_DESC(7Z007S),
38 ZYNQ_DESC(7Z010),
39 ZYNQ_DESC(7Z012S),
40 ZYNQ_DESC(7Z014S),
41 ZYNQ_DESC(7Z015),
42 ZYNQ_DESC(7Z020),
43 ZYNQ_DESC(7Z030),
44 ZYNQ_DESC(7Z035),
45 ZYNQ_DESC(7Z045),
46 ZYNQ_DESC(7Z100),
47 { /* Sentinel */ },
48};
49
262f08d6 50int arch_cpu_init(void)
00ed3458
MS
51{
52 zynq_slcr_unlock();
d7e269cf 53#ifndef CONFIG_SPL_BUILD
00ed3458
MS
54 /* Device config APB, unlock the PCAP */
55 writel(0x757BDF0D, &devcfg_base->unlock);
56 writel(0xFFFFFFFF, &devcfg_base->rom_shadow);
57
aa6e94de 58#if (CFG_SYS_SDRAM_BASE == 0)
c1824ea2
MS
59 /* remap DDR to zero, FILTERSTART */
60 writel(0, &scu_base->filter_start);
61
00ed3458
MS
62 /* OCM_CFG, Mask out the ROM, map ram into upper addresses */
63 writel(0x1F, &slcr_base->ocm_cfg);
64 /* FPGA_RST_CTRL, clear resets on AXI fabric ports */
65 writel(0x0, &slcr_base->fpga_rst_ctrl);
00ed3458
MS
66 /* Set urgent bits with register */
67 writel(0x0, &slcr_base->ddr_urgent_sel);
68 /* Urgent write, ports S2/S3 */
69 writel(0xC, &slcr_base->ddr_urgent);
c1824ea2 70#endif
d7e269cf 71#endif
00ed3458 72 zynq_slcr_lock();
262f08d6
MS
73
74 return 0;
00ed3458 75}
38b343dd 76
96a2859e
SDPP
77unsigned int zynq_get_silicon_version(void)
78{
63a7578e
MY
79 return (readl(&devcfg_base->mctrl) & ZYNQ_SILICON_VER_MASK)
80 >> ZYNQ_SILICON_VER_SHIFT;
96a2859e
SDPP
81}
82
35b65dd8 83void reset_cpu(void)
38b343dd 84{
59c651f4 85 zynq_slcr_cpu_reset();
38b343dd
MS
86 while (1)
87 ;
88}
673ba27a 89
10015025 90#if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
673ba27a
MS
91void enable_caches(void)
92{
93 /* Enable D-cache. I-cache is already enabled in start.S */
94 dcache_enable();
95}
96#endif
4aba5fb8
MS
97
98static int __maybe_unused cpu_desc_id(void)
99{
100 u32 idcode;
101 u8 i;
102
103 idcode = zynq_slcr_get_idcode();
104 for (i = 0; zynq_fpga_descs[i].idcode; i++) {
105 if (zynq_fpga_descs[i].idcode == idcode)
106 return i;
107 }
108
109 return -ENODEV;
110}
111
112#if defined(CONFIG_ARCH_EARLY_INIT_R)
113int arch_early_init_r(void)
114{
29bd8ada 115#if CONFIG_IS_ENABLED(FPGA)
4aba5fb8
MS
116 int cpu_id = cpu_desc_id();
117
118 if (cpu_id < 0)
119 return 0;
120
121 fpga.size = zynq_fpga_descs[cpu_id].fpga_size;
122 fpga.name = zynq_fpga_descs[cpu_id].devicename;
123 fpga_init();
124 fpga_add(fpga_xilinx, &fpga);
125#endif
126 return 0;
127}
128#endif
0b4b82ad
MS
129
130#ifdef CONFIG_DISPLAY_CPUINFO
131int print_cpuinfo(void)
132{
133 u32 version;
134 int cpu_id = cpu_desc_id();
135
136 if (cpu_id < 0)
137 return 0;
138
139 version = zynq_get_silicon_version() << 1;
140 if (version > (PCW_SILICON_VERSION_3 << 1))
141 version += 1;
142
143 printf("CPU: Zynq %s\n", zynq_fpga_descs[cpu_id].devicename);
144 printf("Silicon: v%d.%d\n", version >> 1, version & 1);
145 return 0;
146}
147#endif
This page took 0.48452 seconds and 4 git commands to generate.