blob: a0839c2fbb43f78d538dcebc92b6d3165093ccd5 [file] [log] [blame]
Kumar Galaec2b74f2008-01-17 16:48:33 -06001/*
2 * Copyright 2008 Freescale Semiconductor, Inc.
3 *
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
26int
27cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
28{
Kumar Gala79679d82008-03-26 08:34:25 -050029 unsigned long cpuid;
Kumar Galaec2b74f2008-01-17 16:48:33 -060030
31 if (argc < 3) {
Peter Tyser62c3ae72009-01-27 18:03:10 -060032 cmd_usage(cmdtp);
Kumar Galaec2b74f2008-01-17 16:48:33 -060033 return 1;
34 }
35
36 cpuid = simple_strtoul(argv[1], NULL, 10);
Kumar Gala902ca092008-08-11 11:29:28 -050037 if (cpuid >= CONFIG_NUM_CPUS) {
Kumar Gala348753d2008-07-14 14:03:02 -050038 printf ("Core num: %lu is out of range[0..%d]\n",
Kumar Gala902ca092008-08-11 11:29:28 -050039 cpuid, CONFIG_NUM_CPUS - 1);
Kumar Galaec2b74f2008-01-17 16:48:33 -060040 return 1;
41 }
42
43
44 if (argc == 3) {
45 if (strncmp(argv[2], "reset", 5) == 0) {
46 cpu_reset(cpuid);
47 } else if (strncmp(argv[2], "status", 6) == 0) {
48 cpu_status(cpuid);
49 } else {
Peter Tyser62c3ae72009-01-27 18:03:10 -060050 cmd_usage(cmdtp);
Kumar Galaec2b74f2008-01-17 16:48:33 -060051 return 1;
52 }
53 return 0;
54 }
55
56 /* 4 or greater, make sure its release */
57 if (strncmp(argv[2], "release", 7) != 0) {
Peter Tyser62c3ae72009-01-27 18:03:10 -060058 cmd_usage(cmdtp);
Kumar Galaec2b74f2008-01-17 16:48:33 -060059 return 1;
60 }
61
Kumar Gala79679d82008-03-26 08:34:25 -050062 if (cpu_release(cpuid, argc - 3, argv + 3)) {
Peter Tyser62c3ae72009-01-27 18:03:10 -060063 cmd_usage(cmdtp);
Kumar Galaec2b74f2008-01-17 16:48:33 -060064 return 1;
65 }
66
67 return 0;
68}
69
70#ifdef CONFIG_PPC
71#define CPU_ARCH_HELP \
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" \
81 " r7 will contain the size of the initial mapped area\n"
Kumar Galaec2b74f2008-01-17 16:48:33 -060082#endif
83
84U_BOOT_CMD(
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020085 cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
Peter Tyser2fb26042009-01-27 18:03:12 -060086 "Multiprocessor CPU boot manipulation and release",
Kumar Galaec2b74f2008-01-17 16:48:33 -060087 "<num> reset - Reset cpu <num>\n"
88 "cpu <num> status - Status of cpu <num>\n"
89 "cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]\n"
90#ifdef CPU_ARCH_HELP
91 CPU_ARCH_HELP
92#endif
93 );