blob: 2143814d4fcedc5f9725599296da3f4e3d9a3a01 [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 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22
23#include <common.h>
24#include <command.h>
25
Kim Phillips088f1b12012-10-29 13:34:31 +000026static int
Wolfgang Denk54841ab2010-06-28 22:00:46 +020027cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
Kumar Galaec2b74f2008-01-17 16:48:33 -060028{
Kumar Gala79679d82008-03-26 08:34:25 -050029 unsigned long cpuid;
Kumar Galaec2b74f2008-01-17 16:48:33 -060030
Wolfgang Denk47e26b12010-07-17 01:06:04 +020031 if (argc < 3)
Simon Glass4c12eeb2011-12-10 08:44:01 +000032 return CMD_RET_USAGE;
Kumar Galaec2b74f2008-01-17 16:48:33 -060033
34 cpuid = simple_strtoul(argv[1], NULL, 10);
Timur Tabifbb9ecf2011-08-05 16:15:24 -050035 if (!is_core_valid(cpuid)) {
36 printf ("Core num: %lu is not valid\n", cpuid);
Kumar Galaec2b74f2008-01-17 16:48:33 -060037 return 1;
38 }
39
40
41 if (argc == 3) {
Wolfgang Denk47e26b12010-07-17 01:06:04 +020042 if (strncmp(argv[2], "reset", 5) == 0)
Kumar Galaec2b74f2008-01-17 16:48:33 -060043 cpu_reset(cpuid);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020044 else if (strncmp(argv[2], "status", 6) == 0)
Kumar Galaec2b74f2008-01-17 16:48:33 -060045 cpu_status(cpuid);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020046 else if (strncmp(argv[2], "disable", 7) == 0)
Kumar Gala4194b362010-01-12 11:42:43 -060047 return cpu_disable(cpuid);
Wolfgang Denk47e26b12010-07-17 01:06:04 +020048 else
Simon Glass4c12eeb2011-12-10 08:44:01 +000049 return CMD_RET_USAGE;
Wolfgang Denk47e26b12010-07-17 01:06:04 +020050
Kumar Galaec2b74f2008-01-17 16:48:33 -060051 return 0;
52 }
53
54 /* 4 or greater, make sure its release */
Wolfgang Denk47e26b12010-07-17 01:06:04 +020055 if (strncmp(argv[2], "release", 7) != 0)
Simon Glass4c12eeb2011-12-10 08:44:01 +000056 return CMD_RET_USAGE;
Kumar Galaec2b74f2008-01-17 16:48:33 -060057
Wolfgang Denk47e26b12010-07-17 01:06:04 +020058 if (cpu_release(cpuid, argc - 3, argv + 3))
Simon Glass4c12eeb2011-12-10 08:44:01 +000059 return CMD_RET_USAGE;
Kumar Galaec2b74f2008-01-17 16:48:33 -060060
61 return 0;
62}
63
Kim Phillips088f1b12012-10-29 13:34:31 +000064#ifdef CONFIG_SYS_LONGHELP
65static char cpu_help_text[] =
66 "<num> reset - Reset cpu <num>\n"
67 "cpu <num> status - Status of cpu <num>\n"
68 "cpu <num> disable - Disable cpu <num>\n"
69 "cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
Kumar Galaec2b74f2008-01-17 16:48:33 -060070#ifdef CONFIG_PPC
Kim Phillips088f1b12012-10-29 13:34:31 +000071 "\n"
Kumar Gala79679d82008-03-26 08:34:25 -050072 " [args] : <pir> <r3> <r6>\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060073 " pir - processor id (if writeable)\n" \
74 " r3 - value for gpr 3\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060075 " r6 - value for gpr 6\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060076 "\n" \
77 " Use '-' for any arg if you want the default value.\n" \
Kumar Gala79679d82008-03-26 08:34:25 -050078 " Default for r3 is <num> and r6 is 0\n" \
Kumar Galaec2b74f2008-01-17 16:48:33 -060079 "\n" \
Kumar Gala79679d82008-03-26 08:34:25 -050080 " When cpu <num> is released r4 and r5 = 0.\n" \
Wolfgang Denka89c33d2009-05-24 17:06:54 +020081 " r7 will contain the size of the initial mapped area"
Kumar Galaec2b74f2008-01-17 16:48:33 -060082#endif
Kim Phillips088f1b12012-10-29 13:34:31 +000083 "";
84#endif
Kumar Galaec2b74f2008-01-17 16:48:33 -060085
86U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020087 cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
Kim Phillips088f1b12012-10-29 13:34:31 +000088 "Multiprocessor CPU boot manipulation and release", cpu_help_text
Wolfgang Denka89c33d2009-05-24 17:06:54 +020089);