]>
Commit | Line | Data |
---|---|---|
83d290c5 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
ec2b74ff | 2 | /* |
0e870980 | 3 | * Copyright 2008-2009 Freescale Semiconductor, Inc. |
ec2b74ff KG |
4 | */ |
5 | ||
6 | #include <common.h> | |
7 | #include <command.h> | |
8 | ||
711e5e26 MS |
9 | static int cpu_status_all(void) |
10 | { | |
11 | unsigned long cpuid; | |
12 | ||
13 | for (cpuid = 0; ; cpuid++) { | |
14 | if (!is_core_valid(cpuid)) { | |
15 | if (cpuid == 0) { | |
16 | printf("Core num: %lu is not valid\n", cpuid); | |
17 | return 1; | |
18 | } | |
19 | break; | |
20 | } | |
21 | cpu_status(cpuid); | |
22 | } | |
23 | ||
24 | return 0; | |
25 | } | |
26 | ||
088f1b19 | 27 | static int |
54841ab5 | 28 | cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
ec2b74ff | 29 | { |
79679d80 | 30 | unsigned long cpuid; |
ec2b74ff | 31 | |
711e5e26 MS |
32 | if (argc == 2 && strncmp(argv[1], "status", 6) == 0) |
33 | return cpu_status_all(); | |
34 | ||
47e26b1b | 35 | if (argc < 3) |
4c12eeb8 | 36 | return CMD_RET_USAGE; |
ec2b74ff KG |
37 | |
38 | cpuid = simple_strtoul(argv[1], NULL, 10); | |
fbb9ecf7 TT |
39 | if (!is_core_valid(cpuid)) { |
40 | printf ("Core num: %lu is not valid\n", cpuid); | |
ec2b74ff KG |
41 | return 1; |
42 | } | |
43 | ||
44 | ||
45 | if (argc == 3) { | |
47e26b1b | 46 | if (strncmp(argv[2], "reset", 5) == 0) |
ec2b74ff | 47 | cpu_reset(cpuid); |
47e26b1b | 48 | else if (strncmp(argv[2], "status", 6) == 0) |
ec2b74ff | 49 | cpu_status(cpuid); |
47e26b1b | 50 | else if (strncmp(argv[2], "disable", 7) == 0) |
4194b366 | 51 | return cpu_disable(cpuid); |
47e26b1b | 52 | else |
4c12eeb8 | 53 | return CMD_RET_USAGE; |
47e26b1b | 54 | |
ec2b74ff KG |
55 | return 0; |
56 | } | |
57 | ||
58 | /* 4 or greater, make sure its release */ | |
47e26b1b | 59 | if (strncmp(argv[2], "release", 7) != 0) |
4c12eeb8 | 60 | return CMD_RET_USAGE; |
ec2b74ff | 61 | |
47e26b1b | 62 | if (cpu_release(cpuid, argc - 3, argv + 3)) |
4c12eeb8 | 63 | return CMD_RET_USAGE; |
ec2b74ff KG |
64 | |
65 | return 0; | |
66 | } | |
67 | ||
088f1b19 KP |
68 | #ifdef CONFIG_SYS_LONGHELP |
69 | static char cpu_help_text[] = | |
70 | "<num> reset - Reset cpu <num>\n" | |
711e5e26 | 71 | "cpu status - Status of all cpus\n" |
088f1b19 KP |
72 | "cpu <num> status - Status of cpu <num>\n" |
73 | "cpu <num> disable - Disable cpu <num>\n" | |
74 | "cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]" | |
ec2b74ff | 75 | #ifdef CONFIG_PPC |
088f1b19 | 76 | "\n" |
79679d80 | 77 | " [args] : <pir> <r3> <r6>\n" \ |
ec2b74ff KG |
78 | " pir - processor id (if writeable)\n" \ |
79 | " r3 - value for gpr 3\n" \ | |
ec2b74ff | 80 | " r6 - value for gpr 6\n" \ |
ec2b74ff KG |
81 | "\n" \ |
82 | " Use '-' for any arg if you want the default value.\n" \ | |
79679d80 | 83 | " Default for r3 is <num> and r6 is 0\n" \ |
ec2b74ff | 84 | "\n" \ |
79679d80 | 85 | " When cpu <num> is released r4 and r5 = 0.\n" \ |
a89c33db | 86 | " r7 will contain the size of the initial mapped area" |
ec2b74ff | 87 | #endif |
088f1b19 KP |
88 | ""; |
89 | #endif | |
ec2b74ff KG |
90 | |
91 | U_BOOT_CMD( | |
6d0f6bcf | 92 | cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd, |
088f1b19 | 93 | "Multiprocessor CPU boot manipulation and release", cpu_help_text |
a89c33db | 94 | ); |