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