blob: 328b338068b812f613bbe3c8998ef221e8e90897 [file] [log] [blame]
Kumar Galaec2b74f2008-01-17 16:48:33 -06001/*
Poonam Aggrwal0e870982009-07-31 12:08:14 +05302 * Copyright 2008-2009 Freescale Semiconductor, Inc.
Kumar Galaec2b74f2008-01-17 16:48:33 -06003 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Kumar Galaec2b74f2008-01-17 16:48:33 -06005 */
6
7#include <common.h>
8#include <command.h>
9
Kim Phillips088f1b12012-10-29 13:34:31 +000010static int
Wolfgang Denk54841ab2010-06-28 22:00:46 +020011cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Kumar Galaec2b74f2008-01-17 16:48:33 -060012{
Kumar Gala79679d82008-03-26 08:34:25 -050013 unsigned long cpuid;
Kumar Galaec2b74f2008-01-17 16:48:33 -060014
Wolfgang Denk47e26b12010-07-17 01:06:04 +020015 if (argc < 3)
Simon Glass4c12eeb2011-12-10 08:44:01 +000016 return CMD_RET_USAGE;
Kumar Galaec2b74f2008-01-17 16:48:33 -060017
18 cpuid = simple_strtoul(argv[1], NULL, 10);
Timur Tabifbb9ecf2011-08-05 16:15:24 -050019 if (!is_core_valid(cpuid)) {
20 printf ("Core num: %lu is not valid\n", cpuid);
Kumar Galaec2b74f2008-01-17 16:48:33 -060021 return 1;
22 }
23
24
25 if (argc == 3) {
Wolfgang Denk47e26b12010-07-17 01:06:04 +020026 if (strncmp(argv[2], "reset", 5) == 0)
Kumar Galaec2b74f2008-01-17 16:48:33 -060027 cpu_reset(cpuid);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020028 else if (strncmp(argv[2], "status", 6) == 0)
Kumar Galaec2b74f2008-01-17 16:48:33 -060029 cpu_status(cpuid);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020030 else if (strncmp(argv[2], "disable", 7) == 0)
Kumar Gala4194b362010-01-12 11:42:43 -060031 return cpu_disable(cpuid);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020032 else
Simon Glass4c12eeb2011-12-10 08:44:01 +000033 return CMD_RET_USAGE;
Wolfgang Denk47e26b12010-07-17 01:06:04 +020034
Kumar Galaec2b74f2008-01-17 16:48:33 -060035 return 0;
36 }
37
38 /* 4 or greater, make sure its release */
Wolfgang Denk47e26b12010-07-17 01:06:04 +020039 if (strncmp(argv[2], "release", 7) != 0)
Simon Glass4c12eeb2011-12-10 08:44:01 +000040 return CMD_RET_USAGE;
Kumar Galaec2b74f2008-01-17 16:48:33 -060041
Wolfgang Denk47e26b12010-07-17 01:06:04 +020042 if (cpu_release(cpuid, argc - 3, argv + 3))
Simon Glass4c12eeb2011-12-10 08:44:01 +000043 return CMD_RET_USAGE;
Kumar Galaec2b74f2008-01-17 16:48:33 -060044
45 return 0;
46}
47
Kim Phillips088f1b12012-10-29 13:34:31 +000048#ifdef CONFIG_SYS_LONGHELP
49static char cpu_help_text[] =
50 "<num> reset - Reset cpu <num>\n"
51 "cpu <num> status - Status of cpu <num>\n"
52 "cpu <num> disable - Disable cpu <num>\n"
53 "cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
Kumar Galaec2b74f2008-01-17 16:48:33 -060054#ifdef CONFIG_PPC
Kim Phillips088f1b12012-10-29 13:34:31 +000055 "\n"
Kumar Gala79679d82008-03-26 08:34:25 -050056 " [args] : <pir> <r3> <r6>\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060057 " pir - processor id (if writeable)\n" \
58 " r3 - value for gpr 3\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060059 " r6 - value for gpr 6\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060060 "\n" \
61 " Use '-' for any arg if you want the default value.\n" \
Kumar Gala79679d82008-03-26 08:34:25 -050062 " Default for r3 is <num> and r6 is 0\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060063 "\n" \
Kumar Gala79679d82008-03-26 08:34:25 -050064 " When cpu <num> is released r4 and r5 = 0.\n" \
Wolfgang Denka89c33d2009-05-24 17:06:54 +020065 " r7 will contain the size of the initial mapped area"
Kumar Galaec2b74f2008-01-17 16:48:33 -060066#endif
Kim Phillips088f1b12012-10-29 13:34:31 +000067 "";
68#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -060069
70U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020071 cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
Kim Phillips088f1b12012-10-29 13:34:31 +000072 "Multiprocessor CPU boot manipulation and release", cpu_help_text
Wolfgang Denka89c33d2009-05-24 17:06:54 +020073);