blob: 261bb8a07d43416e61846cce88494209551b558f [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Kumar Gala36d6b3f2008-01-17 16:48:33 -06002/*
Poonam Aggrwal4baef822009-07-31 12:08:14 +05303 * Copyright 2008-2009 Freescale Semiconductor, Inc.
Kumar Gala36d6b3f2008-01-17 16:48:33 -06004 */
5
Kumar Gala36d6b3f2008-01-17 16:48:33 -06006#include <command.h>
Simon Glass970b61e2019-11-14 12:57:09 -07007#include <cpu_func.h>
Tom Rinidec7ea02024-05-20 13:35:03 -06008#include <vsprintf.h>
Kumar Gala36d6b3f2008-01-17 16:48:33 -06009
Michal Simek47e98982015-06-22 10:46:40 +020010static int cpu_status_all(void)
11{
12 unsigned long cpuid;
13
14 for (cpuid = 0; ; cpuid++) {
15 if (!is_core_valid(cpuid)) {
16 if (cpuid == 0) {
17 printf("Core num: %lu is not valid\n", cpuid);
18 return 1;
19 }
20 break;
21 }
22 cpu_status(cpuid);
23 }
24
25 return 0;
26}
27
Kim Phillipsdc00a682012-10-29 13:34:31 +000028static int
Simon Glassed38aef2020-05-10 11:40:03 -060029cpu_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
Kumar Gala36d6b3f2008-01-17 16:48:33 -060030{
Kumar Galadeeac572008-03-26 08:34:25 -050031 unsigned long cpuid;
Kumar Gala36d6b3f2008-01-17 16:48:33 -060032
Michal Simek47e98982015-06-22 10:46:40 +020033 if (argc == 2 && strncmp(argv[1], "status", 6) == 0)
34 return cpu_status_all();
35
Wolfgang Denk3b683112010-07-17 01:06:04 +020036 if (argc < 3)
Simon Glassa06dfc72011-12-10 08:44:01 +000037 return CMD_RET_USAGE;
Kumar Gala36d6b3f2008-01-17 16:48:33 -060038
Simon Glassff9b9032021-07-24 09:03:30 -060039 cpuid = dectoul(argv[1], NULL);
Timur Tabi47289422011-08-05 16:15:24 -050040 if (!is_core_valid(cpuid)) {
41 printf ("Core num: %lu is not valid\n", cpuid);
Kumar Gala36d6b3f2008-01-17 16:48:33 -060042 return 1;
43 }
44
Kumar Gala36d6b3f2008-01-17 16:48:33 -060045 if (argc == 3) {
Wolfgang Denk3b683112010-07-17 01:06:04 +020046 if (strncmp(argv[2], "reset", 5) == 0)
Kumar Gala36d6b3f2008-01-17 16:48:33 -060047 cpu_reset(cpuid);
Wolfgang Denk3b683112010-07-17 01:06:04 +020048 else if (strncmp(argv[2], "status", 6) == 0)
Kumar Gala36d6b3f2008-01-17 16:48:33 -060049 cpu_status(cpuid);
Wolfgang Denk3b683112010-07-17 01:06:04 +020050 else if (strncmp(argv[2], "disable", 7) == 0)
Kumar Gala006e2c82010-01-12 11:42:43 -060051 return cpu_disable(cpuid);
Wolfgang Denk3b683112010-07-17 01:06:04 +020052 else
Simon Glassa06dfc72011-12-10 08:44:01 +000053 return CMD_RET_USAGE;
Wolfgang Denk3b683112010-07-17 01:06:04 +020054
Kumar Gala36d6b3f2008-01-17 16:48:33 -060055 return 0;
56 }
57
58 /* 4 or greater, make sure its release */
Wolfgang Denk3b683112010-07-17 01:06:04 +020059 if (strncmp(argv[2], "release", 7) != 0)
Simon Glassa06dfc72011-12-10 08:44:01 +000060 return CMD_RET_USAGE;
Kumar Gala36d6b3f2008-01-17 16:48:33 -060061
Wolfgang Denk3b683112010-07-17 01:06:04 +020062 if (cpu_release(cpuid, argc - 3, argv + 3))
Simon Glassa06dfc72011-12-10 08:44:01 +000063 return CMD_RET_USAGE;
Kumar Gala36d6b3f2008-01-17 16:48:33 -060064
65 return 0;
66}
67
Tom Rini03f146c2023-10-07 15:13:08 -040068U_BOOT_LONGHELP(cpu,
Kim Phillipsdc00a682012-10-29 13:34:31 +000069 "<num> reset - Reset cpu <num>\n"
Michal Simek47e98982015-06-22 10:46:40 +020070 "cpu status - Status of all cpus\n"
Kim Phillipsdc00a682012-10-29 13:34:31 +000071 "cpu <num> status - Status of cpu <num>\n"
72 "cpu <num> disable - Disable cpu <num>\n"
73 "cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
Kumar Gala36d6b3f2008-01-17 16:48:33 -060074#ifdef CONFIG_PPC
Kim Phillipsdc00a682012-10-29 13:34:31 +000075 "\n"
Kumar Galadeeac572008-03-26 08:34:25 -050076 " [args] : <pir> <r3> <r6>\n" \
Kumar Gala36d6b3f2008-01-17 16:48:33 -060077 " pir - processor id (if writeable)\n" \
78 " r3 - value for gpr 3\n" \
Kumar Gala36d6b3f2008-01-17 16:48:33 -060079 " r6 - value for gpr 6\n" \
Kumar Gala36d6b3f2008-01-17 16:48:33 -060080 "\n" \
81 " Use '-' for any arg if you want the default value.\n" \
Kumar Galadeeac572008-03-26 08:34:25 -050082 " Default for r3 is <num> and r6 is 0\n" \
Kumar Gala36d6b3f2008-01-17 16:48:33 -060083 "\n" \
Kumar Galadeeac572008-03-26 08:34:25 -050084 " When cpu <num> is released r4 and r5 = 0.\n" \
Wolfgang Denkc54781c2009-05-24 17:06:54 +020085 " r7 will contain the size of the initial mapped area"
Kumar Gala36d6b3f2008-01-17 16:48:33 -060086#endif
Tom Rini03f146c2023-10-07 15:13:08 -040087 );
Kumar Gala36d6b3f2008-01-17 16:48:33 -060088
89U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020090 cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
Kim Phillipsdc00a682012-10-29 13:34:31 +000091 "Multiprocessor CPU boot manipulation and release", cpu_help_text
Wolfgang Denkc54781c2009-05-24 17:06:54 +020092);