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