blob: 01d30c1ccb74762c2701fcd8aa31f2e7e6c1658c [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kumar Galaec2b74f2008-01-17 16:48:33 -06002/*
Poonam Aggrwal0e870982009-07-31 12:08:14 +05303 * Copyright 2008-2009 Freescale Semiconductor, Inc.
Kumar Galaec2b74f2008-01-17 16:48:33 -06004 */
5
6#include <common.h>
7#include <command.h>
8
Michal Simek711e5e22015-06-22 10:46:40 +02009static 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
Kim Phillips088f1b12012-10-29 13:34:31 +000027static int
Wolfgang Denk54841ab2010-06-28 22:00:46 +020028cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Kumar Galaec2b74f2008-01-17 16:48:33 -060029{
Kumar Gala79679d82008-03-26 08:34:25 -050030 unsigned long cpuid;
Kumar Galaec2b74f2008-01-17 16:48:33 -060031
Michal Simek711e5e22015-06-22 10:46:40 +020032 if (argc == 2 && strncmp(argv[1], "status", 6) == 0)
33 return cpu_status_all();
34
Wolfgang Denk47e26b12010-07-17 01:06:04 +020035 if (argc < 3)
Simon Glass4c12eeb2011-12-10 08:44:01 +000036 return CMD_RET_USAGE;
Kumar Galaec2b74f2008-01-17 16:48:33 -060037
38 cpuid = simple_strtoul(argv[1], NULL, 10);
Timur Tabifbb9ecf2011-08-05 16:15:24 -050039 if (!is_core_valid(cpuid)) {
40 printf ("Core num: %lu is not valid\n", cpuid);
Kumar Galaec2b74f2008-01-17 16:48:33 -060041 return 1;
42 }
43
44
45 if (argc == 3) {
Wolfgang Denk47e26b12010-07-17 01:06:04 +020046 if (strncmp(argv[2], "reset", 5) == 0)
Kumar Galaec2b74f2008-01-17 16:48:33 -060047 cpu_reset(cpuid);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020048 else if (strncmp(argv[2], "status", 6) == 0)
Kumar Galaec2b74f2008-01-17 16:48:33 -060049 cpu_status(cpuid);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020050 else if (strncmp(argv[2], "disable", 7) == 0)
Kumar Gala4194b362010-01-12 11:42:43 -060051 return cpu_disable(cpuid);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020052 else
Simon Glass4c12eeb2011-12-10 08:44:01 +000053 return CMD_RET_USAGE;
Wolfgang Denk47e26b12010-07-17 01:06:04 +020054
Kumar Galaec2b74f2008-01-17 16:48:33 -060055 return 0;
56 }
57
58 /* 4 or greater, make sure its release */
Wolfgang Denk47e26b12010-07-17 01:06:04 +020059 if (strncmp(argv[2], "release", 7) != 0)
Simon Glass4c12eeb2011-12-10 08:44:01 +000060 return CMD_RET_USAGE;
Kumar Galaec2b74f2008-01-17 16:48:33 -060061
Wolfgang Denk47e26b12010-07-17 01:06:04 +020062 if (cpu_release(cpuid, argc - 3, argv + 3))
Simon Glass4c12eeb2011-12-10 08:44:01 +000063 return CMD_RET_USAGE;
Kumar Galaec2b74f2008-01-17 16:48:33 -060064
65 return 0;
66}
67
Kim Phillips088f1b12012-10-29 13:34:31 +000068#ifdef CONFIG_SYS_LONGHELP
69static char cpu_help_text[] =
70 "<num> reset - Reset cpu <num>\n"
Michal Simek711e5e22015-06-22 10:46:40 +020071 "cpu status - Status of all cpus\n"
Kim Phillips088f1b12012-10-29 13:34:31 +000072 "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]"
Kumar Galaec2b74f2008-01-17 16:48:33 -060075#ifdef CONFIG_PPC
Kim Phillips088f1b12012-10-29 13:34:31 +000076 "\n"
Kumar Gala79679d82008-03-26 08:34:25 -050077 " [args] : <pir> <r3> <r6>\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060078 " pir - processor id (if writeable)\n" \
79 " r3 - value for gpr 3\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060080 " r6 - value for gpr 6\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060081 "\n" \
82 " Use '-' for any arg if you want the default value.\n" \
Kumar Gala79679d82008-03-26 08:34:25 -050083 " Default for r3 is <num> and r6 is 0\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060084 "\n" \
Kumar Gala79679d82008-03-26 08:34:25 -050085 " When cpu <num> is released r4 and r5 = 0.\n" \
Wolfgang Denka89c33d2009-05-24 17:06:54 +020086 " r7 will contain the size of the initial mapped area"
Kumar Galaec2b74f2008-01-17 16:48:33 -060087#endif
Kim Phillips088f1b12012-10-29 13:34:31 +000088 "";
89#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -060090
91U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020092 cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
Kim Phillips088f1b12012-10-29 13:34:31 +000093 "Multiprocessor CPU boot manipulation and release", cpu_help_text
Wolfgang Denka89c33d2009-05-24 17:06:54 +020094);