"Das U-Boot" Source Tree
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cmd: cpu: add release subcommand

Add a new subcommand 'release' to bring up a core to run baremetal
and RTOS applications.

For example on i.MX8M Plus EVK, release the LAST core to run a RTOS
application, passing the sequence number of the CPU core to release,
here it is 3:
u-boot=> cpu list
0: cpu@0 NXP i.MX8MP Rev1.1 A53 at 1200 MHz at 31C
1: cpu@1 NXP i.MX8MP Rev1.1 A53 at 1200 MHz at 30C
2: cpu@2 NXP i.MX8MP Rev1.1 A53 at 1200 MHz at 31C
3: cpu@3 NXP i.MX8MP Rev1.1 A53 at 1200 MHz at 31C

u-boot=> load mmc 1:2 c0000000 /hello_world.bin
66008 bytes read in 5 ms (12.6 MiB/s)
u-boot=> dcache flush; icache flush
u-boot=> cpu release 3 c0000000
Released CPU core (mpidr: 0x3) to address 0xc0000000

Signed-off-by: Hou Zhiqiang <Zhiqiang.Hou@nxp.com>
Reviewed-by: Simon Glass <sjg@chromium.org>

authored by

Hou Zhiqiang and committed by
Fabio Estevam
476fb4d8 8a73b5b6

+42 -2
+42 -2
cmd/cpu.c
··· 3 3 * Copyright (c) 2015 Google, Inc 4 4 * Written by Simon Glass <sjg@chromium.org> 5 5 * Copyright (c) 2017 Álvaro Fernández Rojas <noltari@gmail.com> 6 + * Copyright 2024 NXP 6 7 */ 7 8 8 9 #include <command.h> ··· 17 18 "Microcode", 18 19 "Device ID", 19 20 }; 21 + 22 + static struct udevice *cpu_find_device(unsigned long cpu_id) 23 + { 24 + struct udevice *dev; 25 + 26 + for (uclass_first_device(UCLASS_CPU, &dev); dev; 27 + uclass_next_device(&dev)) { 28 + if (cpu_id == dev_seq(dev)) 29 + return dev; 30 + } 31 + 32 + return NULL; 33 + } 20 34 21 35 static int print_cpu_list(bool detail) 22 36 { ··· 82 96 return 0; 83 97 } 84 98 99 + static int do_cpu_release(struct cmd_tbl *cmdtp, int flag, int argc, 100 + char *const argv[]) 101 + { 102 + struct udevice *dev; 103 + unsigned long cpu_id; 104 + unsigned long long boot_addr; 105 + 106 + if (argc != 3) 107 + return CMD_RET_USAGE; 108 + 109 + cpu_id = dectoul(argv[1], NULL); 110 + dev = cpu_find_device(cpu_id); 111 + if (!dev) 112 + return CMD_RET_FAILURE; 113 + 114 + boot_addr = simple_strtoull(argv[2], NULL, 16); 115 + 116 + if (cpu_release_core(dev, boot_addr)) 117 + return CMD_RET_FAILURE; 118 + 119 + return 0; 120 + } 121 + 85 122 U_BOOT_LONGHELP(cpu, 86 123 "list - list available CPUs\n" 87 - "cpu detail - show CPU detail"); 124 + "cpu detail - show CPU detail\n" 125 + "cpu release <core ID> <addr> - Release CPU <core ID> at <addr>\n" 126 + " <core ID>: the sequence number in list subcommand outputs"); 88 127 89 128 U_BOOT_CMD_WITH_SUBCMDS(cpu, "display information about CPUs", cpu_help_text, 90 129 U_BOOT_SUBCMD_MKENT(list, 1, 1, do_cpu_list), 91 - U_BOOT_SUBCMD_MKENT(detail, 1, 0, do_cpu_detail)); 130 + U_BOOT_SUBCMD_MKENT(detail, 1, 0, do_cpu_detail), 131 + U_BOOT_SUBCMD_MKENT(release, 3, 0, do_cpu_release));