Skip to content

Commit 476fb4d

Browse files
Zhiqiang-Houfabioestevam
authored andcommitted
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 <[email protected]> Reviewed-by: Simon Glass <[email protected]>
1 parent 8a73b5b commit 476fb4d

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

cmd/cpu.c

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (c) 2015 Google, Inc
44
* Written by Simon Glass <[email protected]>
55
* Copyright (c) 2017 Álvaro Fernández Rojas <[email protected]>
6+
* Copyright 2024 NXP
67
*/
78

89
#include <command.h>
@@ -18,6 +19,19 @@ static const char *cpu_feature_name[CPU_FEAT_COUNT] = {
1819
"Device ID",
1920
};
2021

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+
}
34+
2135
static int print_cpu_list(bool detail)
2236
{
2337
struct udevice *dev;
@@ -82,10 +96,36 @@ static int do_cpu_detail(struct cmd_tbl *cmdtp, int flag, int argc,
8296
return 0;
8397
}
8498

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+
85122
U_BOOT_LONGHELP(cpu,
86123
"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");
88127

89128
U_BOOT_CMD_WITH_SUBCMDS(cpu, "display information about CPUs", cpu_help_text,
90129
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));

0 commit comments

Comments
 (0)