Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2014 - 2015 Xilinx, Inc. |
| 4 | * Michal Simek <michal.simek@xilinx.com> |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 970b61e | 2019-11-14 12:57:09 -0700 | [diff] [blame] | 8 | #include <cpu_func.h> |
Simon Glass | 0f2af88 | 2020-05-10 11:40:05 -0600 | [diff] [blame] | 9 | #include <log.h> |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 10 | #include <asm/arch/hardware.h> |
| 11 | #include <asm/arch/sys_proto.h> |
| 12 | #include <asm/io.h> |
Simon Glass | dbd7954 | 2020-05-10 11:40:11 -0600 | [diff] [blame] | 13 | #include <linux/delay.h> |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 14 | |
| 15 | #define LOCK 0 |
| 16 | #define SPLIT 1 |
| 17 | |
| 18 | #define HALT 0 |
| 19 | #define RELEASE 1 |
| 20 | |
| 21 | #define ZYNQMP_BOOTADDR_HIGH_MASK 0xFFFFFFFF |
| 22 | #define ZYNQMP_R5_HIVEC_ADDR 0xFFFF0000 |
| 23 | #define ZYNQMP_R5_LOVEC_ADDR 0x0 |
| 24 | #define ZYNQMP_RPU_CFG_CPU_HALT_MASK 0x01 |
| 25 | #define ZYNQMP_RPU_CFG_HIVEC_MASK 0x04 |
| 26 | #define ZYNQMP_RPU_GLBL_CTRL_SPLIT_LOCK_MASK 0x08 |
| 27 | #define ZYNQMP_RPU_GLBL_CTRL_TCM_COMB_MASK 0x40 |
| 28 | #define ZYNQMP_RPU_GLBL_CTRL_SLCLAMP_MASK 0x10 |
| 29 | |
| 30 | #define ZYNQMP_CRLAPB_RST_LPD_AMBA_RST_MASK 0x04 |
| 31 | #define ZYNQMP_CRLAPB_RST_LPD_R50_RST_MASK 0x01 |
| 32 | #define ZYNQMP_CRLAPB_RST_LPD_R51_RST_MASK 0x02 |
| 33 | #define ZYNQMP_CRLAPB_CPU_R5_CTRL_CLKACT_MASK 0x1000000 |
| 34 | |
Ashok Reddy Soma | b43d3cf | 2023-04-05 15:06:45 +0200 | [diff] [blame] | 35 | #define ZYNQMP_R5_0_TCM_START_ADDR 0xFFE00000 |
| 36 | #define ZYNQMP_R5_1_TCM_START_ADDR 0xFFE90000 |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 37 | #define ZYNQMP_TCM_BOTH_SIZE 0x40000 |
| 38 | |
| 39 | #define ZYNQMP_CORE_APU0 0 |
| 40 | #define ZYNQMP_CORE_APU3 3 |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 41 | #define ZYNQMP_CORE_RPU0 4 |
| 42 | #define ZYNQMP_CORE_RPU1 5 |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 43 | |
| 44 | #define ZYNQMP_MAX_CORES 6 |
| 45 | |
Lukas Funke | c6f9058 | 2022-10-28 14:15:47 +0200 | [diff] [blame] | 46 | #define ZYNQMP_RPU0_USE_MASK BIT(1) |
| 47 | #define ZYNQMP_RPU1_USE_MASK BIT(2) |
| 48 | |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 49 | int is_core_valid(unsigned int core) |
| 50 | { |
| 51 | if (core < ZYNQMP_MAX_CORES) |
| 52 | return 1; |
| 53 | |
| 54 | return 0; |
| 55 | } |
| 56 | |
Michal Simek | 1669e18 | 2018-06-13 08:56:31 +0200 | [diff] [blame] | 57 | int cpu_reset(u32 nr) |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 58 | { |
| 59 | puts("Feature is not implemented.\n"); |
| 60 | return 0; |
| 61 | } |
| 62 | |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 63 | static void set_r5_halt_mode(u32 nr, u8 halt, u8 mode) |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 64 | { |
| 65 | u32 tmp; |
| 66 | |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 67 | if (mode == LOCK || nr == ZYNQMP_CORE_RPU0) { |
| 68 | tmp = readl(&rpu_base->rpu0_cfg); |
| 69 | if (halt == HALT) |
| 70 | tmp &= ~ZYNQMP_RPU_CFG_CPU_HALT_MASK; |
| 71 | else |
| 72 | tmp |= ZYNQMP_RPU_CFG_CPU_HALT_MASK; |
| 73 | writel(tmp, &rpu_base->rpu0_cfg); |
| 74 | } |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 75 | |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 76 | if (mode == LOCK || nr == ZYNQMP_CORE_RPU1) { |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 77 | tmp = readl(&rpu_base->rpu1_cfg); |
| 78 | if (halt == HALT) |
| 79 | tmp &= ~ZYNQMP_RPU_CFG_CPU_HALT_MASK; |
| 80 | else |
| 81 | tmp |= ZYNQMP_RPU_CFG_CPU_HALT_MASK; |
| 82 | writel(tmp, &rpu_base->rpu1_cfg); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | static void set_r5_tcm_mode(u8 mode) |
| 87 | { |
| 88 | u32 tmp; |
| 89 | |
| 90 | tmp = readl(&rpu_base->rpu_glbl_ctrl); |
| 91 | if (mode == LOCK) { |
| 92 | tmp &= ~ZYNQMP_RPU_GLBL_CTRL_SPLIT_LOCK_MASK; |
| 93 | tmp |= ZYNQMP_RPU_GLBL_CTRL_TCM_COMB_MASK | |
| 94 | ZYNQMP_RPU_GLBL_CTRL_SLCLAMP_MASK; |
| 95 | } else { |
| 96 | tmp |= ZYNQMP_RPU_GLBL_CTRL_SPLIT_LOCK_MASK; |
| 97 | tmp &= ~(ZYNQMP_RPU_GLBL_CTRL_TCM_COMB_MASK | |
| 98 | ZYNQMP_RPU_GLBL_CTRL_SLCLAMP_MASK); |
| 99 | } |
| 100 | |
| 101 | writel(tmp, &rpu_base->rpu_glbl_ctrl); |
| 102 | } |
| 103 | |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 104 | static void set_r5_reset(u32 nr, u8 mode) |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 105 | { |
| 106 | u32 tmp; |
| 107 | |
| 108 | tmp = readl(&crlapb_base->rst_lpd_top); |
Neal Frager | d929bbf | 2022-05-04 09:12:26 +0200 | [diff] [blame] | 109 | if (mode == LOCK) { |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 110 | tmp |= (ZYNQMP_CRLAPB_RST_LPD_AMBA_RST_MASK | |
Neal Frager | d929bbf | 2022-05-04 09:12:26 +0200 | [diff] [blame] | 111 | ZYNQMP_CRLAPB_RST_LPD_R50_RST_MASK | |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 112 | ZYNQMP_CRLAPB_RST_LPD_R51_RST_MASK); |
Neal Frager | d929bbf | 2022-05-04 09:12:26 +0200 | [diff] [blame] | 113 | } else { |
| 114 | if (nr == ZYNQMP_CORE_RPU0) { |
| 115 | tmp |= ZYNQMP_CRLAPB_RST_LPD_R50_RST_MASK; |
| 116 | if (tmp & ZYNQMP_CRLAPB_RST_LPD_R51_RST_MASK) |
| 117 | tmp |= ZYNQMP_CRLAPB_RST_LPD_AMBA_RST_MASK; |
| 118 | } else { |
| 119 | tmp |= ZYNQMP_CRLAPB_RST_LPD_R51_RST_MASK; |
| 120 | if (tmp & ZYNQMP_CRLAPB_RST_LPD_R50_RST_MASK) |
| 121 | tmp |= ZYNQMP_CRLAPB_RST_LPD_AMBA_RST_MASK; |
| 122 | } |
| 123 | } |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 124 | |
| 125 | writel(tmp, &crlapb_base->rst_lpd_top); |
| 126 | } |
| 127 | |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 128 | static void release_r5_reset(u32 nr, u8 mode) |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 129 | { |
| 130 | u32 tmp; |
| 131 | |
| 132 | tmp = readl(&crlapb_base->rst_lpd_top); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 133 | if (mode == LOCK || nr == ZYNQMP_CORE_RPU0) |
| 134 | tmp &= ~(ZYNQMP_CRLAPB_RST_LPD_AMBA_RST_MASK | |
| 135 | ZYNQMP_CRLAPB_RST_LPD_R50_RST_MASK); |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 136 | |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 137 | if (mode == LOCK || nr == ZYNQMP_CORE_RPU1) |
| 138 | tmp &= ~(ZYNQMP_CRLAPB_RST_LPD_AMBA_RST_MASK | |
| 139 | ZYNQMP_CRLAPB_RST_LPD_R51_RST_MASK); |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 140 | |
| 141 | writel(tmp, &crlapb_base->rst_lpd_top); |
| 142 | } |
| 143 | |
| 144 | static void enable_clock_r5(void) |
| 145 | { |
| 146 | u32 tmp; |
| 147 | |
| 148 | tmp = readl(&crlapb_base->cpu_r5_ctrl); |
| 149 | tmp |= ZYNQMP_CRLAPB_CPU_R5_CTRL_CLKACT_MASK; |
| 150 | writel(tmp, &crlapb_base->cpu_r5_ctrl); |
| 151 | |
| 152 | /* Give some delay for clock |
Robert P. J. Day | 8d56db9 | 2016-07-15 13:44:45 -0400 | [diff] [blame] | 153 | * to propagate */ |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 154 | udelay(0x500); |
| 155 | } |
| 156 | |
Neal Frager | d929bbf | 2022-05-04 09:12:26 +0200 | [diff] [blame] | 157 | static int check_r5_mode(void) |
| 158 | { |
| 159 | u32 tmp; |
| 160 | |
| 161 | tmp = readl(&rpu_base->rpu_glbl_ctrl); |
| 162 | if (tmp & ZYNQMP_RPU_GLBL_CTRL_SPLIT_LOCK_MASK) |
| 163 | return SPLIT; |
| 164 | |
| 165 | return LOCK; |
| 166 | } |
| 167 | |
Michal Simek | 1669e18 | 2018-06-13 08:56:31 +0200 | [diff] [blame] | 168 | int cpu_disable(u32 nr) |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 169 | { |
Venkatesh Yadav Abbarapu | ae8bc3d | 2022-10-04 11:04:54 +0530 | [diff] [blame] | 170 | if (nr <= ZYNQMP_CORE_APU3) { |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 171 | u32 val = readl(&crfapb_base->rst_fpd_apu); |
| 172 | val |= 1 << nr; |
| 173 | writel(val, &crfapb_base->rst_fpd_apu); |
| 174 | } else { |
Neal Frager | d929bbf | 2022-05-04 09:12:26 +0200 | [diff] [blame] | 175 | set_r5_reset(nr, check_r5_mode()); |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | return 0; |
| 179 | } |
| 180 | |
Michal Simek | 1669e18 | 2018-06-13 08:56:31 +0200 | [diff] [blame] | 181 | int cpu_status(u32 nr) |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 182 | { |
Venkatesh Yadav Abbarapu | ae8bc3d | 2022-10-04 11:04:54 +0530 | [diff] [blame] | 183 | if (nr <= ZYNQMP_CORE_APU3) { |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 184 | u32 addr_low = readl(((u8 *)&apu_base->rvbar_addr0_l) + nr * 8); |
| 185 | u32 addr_high = readl(((u8 *)&apu_base->rvbar_addr0_h) + |
| 186 | nr * 8); |
| 187 | u32 val = readl(&crfapb_base->rst_fpd_apu); |
| 188 | val &= 1 << nr; |
| 189 | printf("APU CPU%d %s - starting address HI: %x, LOW: %x\n", |
| 190 | nr, val ? "OFF" : "ON" , addr_high, addr_low); |
| 191 | } else { |
| 192 | u32 val = readl(&crlapb_base->rst_lpd_top); |
| 193 | val &= 1 << (nr - 4); |
| 194 | printf("RPU CPU%d %s\n", nr - 4, val ? "OFF" : "ON"); |
| 195 | } |
| 196 | |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | static void set_r5_start(u8 high) |
| 201 | { |
| 202 | u32 tmp; |
| 203 | |
| 204 | tmp = readl(&rpu_base->rpu0_cfg); |
| 205 | if (high) |
| 206 | tmp |= ZYNQMP_RPU_CFG_HIVEC_MASK; |
| 207 | else |
| 208 | tmp &= ~ZYNQMP_RPU_CFG_HIVEC_MASK; |
| 209 | writel(tmp, &rpu_base->rpu0_cfg); |
| 210 | |
| 211 | tmp = readl(&rpu_base->rpu1_cfg); |
| 212 | if (high) |
| 213 | tmp |= ZYNQMP_RPU_CFG_HIVEC_MASK; |
| 214 | else |
| 215 | tmp &= ~ZYNQMP_RPU_CFG_HIVEC_MASK; |
| 216 | writel(tmp, &rpu_base->rpu1_cfg); |
| 217 | } |
| 218 | |
Ashok Reddy Soma | b43d3cf | 2023-04-05 15:06:45 +0200 | [diff] [blame] | 219 | static void write_tcm_boot_trampoline(u32 nr, u32 boot_addr) |
Michal Simek | f5005ce | 2015-05-22 13:28:23 +0200 | [diff] [blame] | 220 | { |
| 221 | if (boot_addr) { |
Ashok Reddy Soma | b43d3cf | 2023-04-05 15:06:45 +0200 | [diff] [blame] | 222 | u64 tcm_start_addr = ZYNQMP_R5_0_TCM_START_ADDR; |
| 223 | |
| 224 | if (nr == ZYNQMP_CORE_RPU1) |
| 225 | tcm_start_addr = ZYNQMP_R5_1_TCM_START_ADDR; |
| 226 | |
Michal Simek | f5005ce | 2015-05-22 13:28:23 +0200 | [diff] [blame] | 227 | /* |
| 228 | * Boot trampoline is simple ASM code below. |
| 229 | * |
| 230 | * b over; |
| 231 | * label: |
| 232 | * .word 0 |
| 233 | * over: ldr r0, =label |
| 234 | * ldr r1, [r0] |
| 235 | * bx r1 |
| 236 | */ |
| 237 | debug("Write boot trampoline for %x\n", boot_addr); |
Ashok Reddy Soma | b43d3cf | 2023-04-05 15:06:45 +0200 | [diff] [blame] | 238 | writel(0xea000000, tcm_start_addr); |
| 239 | writel(boot_addr, tcm_start_addr + 0x4); |
| 240 | writel(0xe59f0004, tcm_start_addr + 0x8); |
| 241 | writel(0xe5901000, tcm_start_addr + 0xc); |
| 242 | writel(0xe12fff11, tcm_start_addr + 0x10); |
| 243 | writel(0x00000004, tcm_start_addr + 0x14); |
Michal Simek | f5005ce | 2015-05-22 13:28:23 +0200 | [diff] [blame] | 244 | } |
| 245 | } |
| 246 | |
Siva Durga Prasad Paladugu | 5e2a907 | 2017-07-13 19:01:09 +0530 | [diff] [blame] | 247 | void initialize_tcm(bool mode) |
| 248 | { |
| 249 | if (!mode) { |
| 250 | set_r5_tcm_mode(LOCK); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 251 | set_r5_halt_mode(ZYNQMP_CORE_RPU0, HALT, LOCK); |
Siva Durga Prasad Paladugu | 5e2a907 | 2017-07-13 19:01:09 +0530 | [diff] [blame] | 252 | enable_clock_r5(); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 253 | release_r5_reset(ZYNQMP_CORE_RPU0, LOCK); |
Siva Durga Prasad Paladugu | 5e2a907 | 2017-07-13 19:01:09 +0530 | [diff] [blame] | 254 | } else { |
| 255 | set_r5_tcm_mode(SPLIT); |
Neal Frager | 7aba255 | 2023-03-23 08:25:06 +0000 | [diff] [blame] | 256 | set_r5_halt_mode(ZYNQMP_CORE_RPU0, HALT, SPLIT); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 257 | set_r5_halt_mode(ZYNQMP_CORE_RPU1, HALT, SPLIT); |
Siva Durga Prasad Paladugu | 5e2a907 | 2017-07-13 19:01:09 +0530 | [diff] [blame] | 258 | enable_clock_r5(); |
Neal Frager | 7aba255 | 2023-03-23 08:25:06 +0000 | [diff] [blame] | 259 | release_r5_reset(ZYNQMP_CORE_RPU0, SPLIT); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 260 | release_r5_reset(ZYNQMP_CORE_RPU1, SPLIT); |
Siva Durga Prasad Paladugu | 5e2a907 | 2017-07-13 19:01:09 +0530 | [diff] [blame] | 261 | } |
Lukas Funke | c6f9058 | 2022-10-28 14:15:47 +0200 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | static void mark_r5_used(u32 nr, u8 mode) |
| 265 | { |
| 266 | u32 mask = 0; |
| 267 | |
| 268 | if (mode == LOCK) { |
| 269 | mask = ZYNQMP_RPU0_USE_MASK | ZYNQMP_RPU1_USE_MASK; |
| 270 | } else { |
| 271 | switch (nr) { |
| 272 | case ZYNQMP_CORE_RPU0: |
| 273 | mask = ZYNQMP_RPU0_USE_MASK; |
| 274 | break; |
| 275 | case ZYNQMP_CORE_RPU1: |
| 276 | mask = ZYNQMP_RPU1_USE_MASK; |
| 277 | break; |
| 278 | default: |
| 279 | return; |
| 280 | } |
| 281 | } |
| 282 | zynqmp_mmio_write((ulong)&pmu_base->gen_storage4, mask, mask); |
Siva Durga Prasad Paladugu | 5e2a907 | 2017-07-13 19:01:09 +0530 | [diff] [blame] | 283 | } |
| 284 | |
Simon Glass | ed38aef | 2020-05-10 11:40:03 -0600 | [diff] [blame] | 285 | int cpu_release(u32 nr, int argc, char *const argv[]) |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 286 | { |
Venkatesh Yadav Abbarapu | ae8bc3d | 2022-10-04 11:04:54 +0530 | [diff] [blame] | 287 | if (nr <= ZYNQMP_CORE_APU3) { |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 288 | u64 boot_addr = simple_strtoull(argv[0], NULL, 16); |
| 289 | /* HIGH */ |
| 290 | writel((u32)(boot_addr >> 32), |
| 291 | ((u8 *)&apu_base->rvbar_addr0_h) + nr * 8); |
| 292 | /* LOW */ |
| 293 | writel((u32)(boot_addr & ZYNQMP_BOOTADDR_HIGH_MASK), |
| 294 | ((u8 *)&apu_base->rvbar_addr0_l) + nr * 8); |
| 295 | |
| 296 | u32 val = readl(&crfapb_base->rst_fpd_apu); |
| 297 | val &= ~(1 << nr); |
| 298 | writel(val, &crfapb_base->rst_fpd_apu); |
| 299 | } else { |
| 300 | if (argc != 2) { |
| 301 | printf("Invalid number of arguments to release.\n"); |
| 302 | printf("<addr> <mode>-Start addr lockstep or split\n"); |
| 303 | return 1; |
| 304 | } |
| 305 | |
Simon Glass | 3ff49ec | 2021-07-24 09:03:29 -0600 | [diff] [blame] | 306 | u32 boot_addr = hextoul(argv[0], NULL); |
Michal Simek | f5005ce | 2015-05-22 13:28:23 +0200 | [diff] [blame] | 307 | u32 boot_addr_uniq = 0; |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 308 | if (!(boot_addr == ZYNQMP_R5_LOVEC_ADDR || |
| 309 | boot_addr == ZYNQMP_R5_HIVEC_ADDR)) { |
Michal Simek | f5005ce | 2015-05-22 13:28:23 +0200 | [diff] [blame] | 310 | printf("Using TCM jump trampoline for address 0x%x\n", |
| 311 | boot_addr); |
| 312 | /* Save boot address for later usage */ |
| 313 | boot_addr_uniq = boot_addr; |
| 314 | /* |
| 315 | * R5 needs to start from LOVEC at TCM |
| 316 | * OCM will be probably occupied by ATF |
| 317 | */ |
| 318 | boot_addr = ZYNQMP_R5_LOVEC_ADDR; |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 319 | } |
| 320 | |
Siva Durga Prasad Paladugu | e0a1f1e | 2017-08-01 16:24:52 +0530 | [diff] [blame] | 321 | /* |
| 322 | * Since we don't know where the user may have loaded the image |
| 323 | * for an R5 we have to flush all the data cache to ensure |
| 324 | * the R5 sees it. |
| 325 | */ |
| 326 | flush_dcache_all(); |
| 327 | |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 328 | if (!strncmp(argv[1], "lockstep", 8)) { |
Venkatesh Yadav Abbarapu | 5824c17 | 2023-06-08 08:51:52 +0530 | [diff] [blame] | 329 | if (nr != ZYNQMP_CORE_RPU0) { |
| 330 | printf("Lockstep mode should run on ZYNQMP_CORE_RPU0\n"); |
| 331 | return 1; |
| 332 | } |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 333 | printf("R5 lockstep mode\n"); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 334 | set_r5_reset(nr, LOCK); |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 335 | set_r5_tcm_mode(LOCK); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 336 | set_r5_halt_mode(nr, HALT, LOCK); |
Michal Simek | 08adc90 | 2015-05-22 13:26:33 +0200 | [diff] [blame] | 337 | set_r5_start(boot_addr); |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 338 | enable_clock_r5(); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 339 | release_r5_reset(nr, LOCK); |
Siva Durga Prasad Paladugu | e0a1f1e | 2017-08-01 16:24:52 +0530 | [diff] [blame] | 340 | dcache_disable(); |
Ashok Reddy Soma | b43d3cf | 2023-04-05 15:06:45 +0200 | [diff] [blame] | 341 | write_tcm_boot_trampoline(nr, boot_addr_uniq); |
Siva Durga Prasad Paladugu | e0a1f1e | 2017-08-01 16:24:52 +0530 | [diff] [blame] | 342 | dcache_enable(); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 343 | set_r5_halt_mode(nr, RELEASE, LOCK); |
Lukas Funke | c6f9058 | 2022-10-28 14:15:47 +0200 | [diff] [blame] | 344 | mark_r5_used(nr, LOCK); |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 345 | } else if (!strncmp(argv[1], "split", 5)) { |
| 346 | printf("R5 split mode\n"); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 347 | set_r5_reset(nr, SPLIT); |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 348 | set_r5_tcm_mode(SPLIT); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 349 | set_r5_halt_mode(nr, HALT, SPLIT); |
Siva Durga Prasad Paladugu | e0a1f1e | 2017-08-01 16:24:52 +0530 | [diff] [blame] | 350 | set_r5_start(boot_addr); |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 351 | enable_clock_r5(); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 352 | release_r5_reset(nr, SPLIT); |
Siva Durga Prasad Paladugu | e0a1f1e | 2017-08-01 16:24:52 +0530 | [diff] [blame] | 353 | dcache_disable(); |
Ashok Reddy Soma | b43d3cf | 2023-04-05 15:06:45 +0200 | [diff] [blame] | 354 | write_tcm_boot_trampoline(nr, boot_addr_uniq); |
Siva Durga Prasad Paladugu | e0a1f1e | 2017-08-01 16:24:52 +0530 | [diff] [blame] | 355 | dcache_enable(); |
Ashok Reddy Soma | 86d212e | 2021-04-15 05:12:15 -0600 | [diff] [blame] | 356 | set_r5_halt_mode(nr, RELEASE, SPLIT); |
Lukas Funke | c6f9058 | 2022-10-28 14:15:47 +0200 | [diff] [blame] | 357 | mark_r5_used(nr, SPLIT); |
Michal Simek | 58f865f | 2015-04-15 13:36:40 +0200 | [diff] [blame] | 358 | } else { |
| 359 | printf("Unsupported mode\n"); |
| 360 | return 1; |
| 361 | } |
| 362 | } |
| 363 | |
| 364 | return 0; |
| 365 | } |