Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 1 | /* |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 2 | * Copyright 2008-2009 Freescale Semiconductor, Inc. |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 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 | |
| 26 | int |
| 27 | cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) |
| 28 | { |
Kumar Gala | deeac57 | 2008-03-26 08:34:25 -0500 | [diff] [blame] | 29 | unsigned long cpuid; |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 30 | |
| 31 | if (argc < 3) { |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 32 | cmd_usage(cmdtp); |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 33 | return 1; |
| 34 | } |
| 35 | |
| 36 | cpuid = simple_strtoul(argv[1], NULL, 10); |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 37 | if (cpuid >= cpu_numcores()) { |
Kumar Gala | 275f4c1 | 2008-07-14 14:03:02 -0500 | [diff] [blame] | 38 | printf ("Core num: %lu is out of range[0..%d]\n", |
Poonam Aggrwal | 4baef82 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 39 | cpuid, cpu_numcores() - 1); |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 40 | 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); |
Kumar Gala | 006e2c8 | 2010-01-12 11:42:43 -0600 | [diff] [blame] | 49 | } else if (strncmp(argv[2], "disable", 7) == 0) { |
| 50 | return cpu_disable(cpuid); |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 51 | } else { |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 52 | cmd_usage(cmdtp); |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 53 | return 1; |
| 54 | } |
| 55 | return 0; |
| 56 | } |
| 57 | |
| 58 | /* 4 or greater, make sure its release */ |
| 59 | if (strncmp(argv[2], "release", 7) != 0) { |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 60 | cmd_usage(cmdtp); |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 61 | return 1; |
| 62 | } |
| 63 | |
Kumar Gala | deeac57 | 2008-03-26 08:34:25 -0500 | [diff] [blame] | 64 | if (cpu_release(cpuid, argc - 3, argv + 3)) { |
Peter Tyser | ddb3af9 | 2009-01-27 18:03:10 -0600 | [diff] [blame] | 65 | cmd_usage(cmdtp); |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 66 | return 1; |
| 67 | } |
| 68 | |
| 69 | return 0; |
| 70 | } |
| 71 | |
| 72 | #ifdef CONFIG_PPC |
| 73 | #define CPU_ARCH_HELP \ |
Kumar Gala | deeac57 | 2008-03-26 08:34:25 -0500 | [diff] [blame] | 74 | " [args] : <pir> <r3> <r6>\n" \ |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 75 | " pir - processor id (if writeable)\n" \ |
| 76 | " r3 - value for gpr 3\n" \ |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 77 | " r6 - value for gpr 6\n" \ |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 78 | "\n" \ |
| 79 | " Use '-' for any arg if you want the default value.\n" \ |
Kumar Gala | deeac57 | 2008-03-26 08:34:25 -0500 | [diff] [blame] | 80 | " Default for r3 is <num> and r6 is 0\n" \ |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 81 | "\n" \ |
Kumar Gala | deeac57 | 2008-03-26 08:34:25 -0500 | [diff] [blame] | 82 | " When cpu <num> is released r4 and r5 = 0.\n" \ |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 83 | " r7 will contain the size of the initial mapped area" |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 84 | #endif |
| 85 | |
| 86 | U_BOOT_CMD( |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 87 | cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 88 | "Multiprocessor CPU boot manipulation and release", |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 89 | "<num> reset - Reset cpu <num>\n" |
| 90 | "cpu <num> status - Status of cpu <num>\n" |
Kumar Gala | 006e2c8 | 2010-01-12 11:42:43 -0600 | [diff] [blame] | 91 | "cpu <num> disable - Disable cpu <num>\n" |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 92 | "cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]" |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 93 | #ifdef CPU_ARCH_HELP |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 94 | "\n" |
Kumar Gala | 36d6b3f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 95 | CPU_ARCH_HELP |
| 96 | #endif |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 97 | ); |