2018-05-07 05:58:06 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2008-01-18 06:48:33 +08:00
|
|
|
/*
|
2009-07-31 14:38:14 +08:00
|
|
|
* Copyright 2008-2009 Freescale Semiconductor, Inc.
|
2008-01-18 06:48:33 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <command.h>
|
2019-11-15 03:57:09 +08:00
|
|
|
#include <cpu_func.h>
|
2008-01-18 06:48:33 +08:00
|
|
|
|
2015-06-22 16:46:40 +08:00
|
|
|
static int cpu_status_all(void)
|
|
|
|
{
|
|
|
|
unsigned long cpuid;
|
|
|
|
|
|
|
|
for (cpuid = 0; ; cpuid++) {
|
|
|
|
if (!is_core_valid(cpuid)) {
|
|
|
|
if (cpuid == 0) {
|
|
|
|
printf("Core num: %lu is not valid\n", cpuid);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
cpu_status(cpuid);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-29 21:34:31 +08:00
|
|
|
static int
|
2020-05-11 01:40:03 +08:00
|
|
|
cpu_cmd(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
|
2008-01-18 06:48:33 +08:00
|
|
|
{
|
2008-03-26 21:34:25 +08:00
|
|
|
unsigned long cpuid;
|
2008-01-18 06:48:33 +08:00
|
|
|
|
2015-06-22 16:46:40 +08:00
|
|
|
if (argc == 2 && strncmp(argv[1], "status", 6) == 0)
|
|
|
|
return cpu_status_all();
|
|
|
|
|
2010-07-17 07:06:04 +08:00
|
|
|
if (argc < 3)
|
2011-12-10 16:44:01 +08:00
|
|
|
return CMD_RET_USAGE;
|
2008-01-18 06:48:33 +08:00
|
|
|
|
2021-07-24 23:03:30 +08:00
|
|
|
cpuid = dectoul(argv[1], NULL);
|
2011-08-06 05:15:24 +08:00
|
|
|
if (!is_core_valid(cpuid)) {
|
|
|
|
printf ("Core num: %lu is not valid\n", cpuid);
|
2008-01-18 06:48:33 +08:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (argc == 3) {
|
2010-07-17 07:06:04 +08:00
|
|
|
if (strncmp(argv[2], "reset", 5) == 0)
|
2008-01-18 06:48:33 +08:00
|
|
|
cpu_reset(cpuid);
|
2010-07-17 07:06:04 +08:00
|
|
|
else if (strncmp(argv[2], "status", 6) == 0)
|
2008-01-18 06:48:33 +08:00
|
|
|
cpu_status(cpuid);
|
2010-07-17 07:06:04 +08:00
|
|
|
else if (strncmp(argv[2], "disable", 7) == 0)
|
2010-01-13 01:42:43 +08:00
|
|
|
return cpu_disable(cpuid);
|
2010-07-17 07:06:04 +08:00
|
|
|
else
|
2011-12-10 16:44:01 +08:00
|
|
|
return CMD_RET_USAGE;
|
2010-07-17 07:06:04 +08:00
|
|
|
|
2008-01-18 06:48:33 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* 4 or greater, make sure its release */
|
2010-07-17 07:06:04 +08:00
|
|
|
if (strncmp(argv[2], "release", 7) != 0)
|
2011-12-10 16:44:01 +08:00
|
|
|
return CMD_RET_USAGE;
|
2008-01-18 06:48:33 +08:00
|
|
|
|
2010-07-17 07:06:04 +08:00
|
|
|
if (cpu_release(cpuid, argc - 3, argv + 3))
|
2011-12-10 16:44:01 +08:00
|
|
|
return CMD_RET_USAGE;
|
2008-01-18 06:48:33 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-10-29 21:34:31 +08:00
|
|
|
#ifdef CONFIG_SYS_LONGHELP
|
|
|
|
static char cpu_help_text[] =
|
|
|
|
"<num> reset - Reset cpu <num>\n"
|
2015-06-22 16:46:40 +08:00
|
|
|
"cpu status - Status of all cpus\n"
|
2012-10-29 21:34:31 +08:00
|
|
|
"cpu <num> status - Status of cpu <num>\n"
|
|
|
|
"cpu <num> disable - Disable cpu <num>\n"
|
|
|
|
"cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
|
2008-01-18 06:48:33 +08:00
|
|
|
#ifdef CONFIG_PPC
|
2012-10-29 21:34:31 +08:00
|
|
|
"\n"
|
2008-03-26 21:34:25 +08:00
|
|
|
" [args] : <pir> <r3> <r6>\n" \
|
2008-01-18 06:48:33 +08:00
|
|
|
" pir - processor id (if writeable)\n" \
|
|
|
|
" r3 - value for gpr 3\n" \
|
|
|
|
" r6 - value for gpr 6\n" \
|
|
|
|
"\n" \
|
|
|
|
" Use '-' for any arg if you want the default value.\n" \
|
2008-03-26 21:34:25 +08:00
|
|
|
" Default for r3 is <num> and r6 is 0\n" \
|
2008-01-18 06:48:33 +08:00
|
|
|
"\n" \
|
2008-03-26 21:34:25 +08:00
|
|
|
" When cpu <num> is released r4 and r5 = 0.\n" \
|
2009-05-24 23:06:54 +08:00
|
|
|
" r7 will contain the size of the initial mapped area"
|
2008-01-18 06:48:33 +08:00
|
|
|
#endif
|
2012-10-29 21:34:31 +08:00
|
|
|
"";
|
|
|
|
#endif
|
2008-01-18 06:48:33 +08:00
|
|
|
|
|
|
|
U_BOOT_CMD(
|
2008-10-16 21:01:15 +08:00
|
|
|
cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
|
2012-10-29 21:34:31 +08:00
|
|
|
"Multiprocessor CPU boot manipulation and release", cpu_help_text
|
2009-05-24 23:06:54 +08:00
|
|
|
);
|