Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 1 | /* |
Poonam Aggrwal | 0e87098 | 2009-07-31 12:08:14 +0530 | [diff] [blame] | 2 | * Copyright 2008-2009 Freescale Semiconductor, Inc. |
Kumar Gala | ec2b74f | 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 | |
Kim Phillips | 088f1b1 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 26 | static int |
Wolfgang Denk | 54841ab | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 27 | cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 28 | { |
Kumar Gala | 79679d8 | 2008-03-26 08:34:25 -0500 | [diff] [blame] | 29 | unsigned long cpuid; |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 30 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 31 | if (argc < 3) |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 32 | return CMD_RET_USAGE; |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 33 | |
| 34 | cpuid = simple_strtoul(argv[1], NULL, 10); |
Timur Tabi | fbb9ecf | 2011-08-05 16:15:24 -0500 | [diff] [blame] | 35 | if (!is_core_valid(cpuid)) { |
| 36 | printf ("Core num: %lu is not valid\n", cpuid); |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 37 | return 1; |
| 38 | } |
| 39 | |
| 40 | |
| 41 | if (argc == 3) { |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 42 | if (strncmp(argv[2], "reset", 5) == 0) |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 43 | cpu_reset(cpuid); |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 44 | else if (strncmp(argv[2], "status", 6) == 0) |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 45 | cpu_status(cpuid); |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 46 | else if (strncmp(argv[2], "disable", 7) == 0) |
Kumar Gala | 4194b36 | 2010-01-12 11:42:43 -0600 | [diff] [blame] | 47 | return cpu_disable(cpuid); |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 48 | else |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 49 | return CMD_RET_USAGE; |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 50 | |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 51 | return 0; |
| 52 | } |
| 53 | |
| 54 | /* 4 or greater, make sure its release */ |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 55 | if (strncmp(argv[2], "release", 7) != 0) |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 56 | return CMD_RET_USAGE; |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 57 | |
Wolfgang Denk | 47e26b1 | 2010-07-17 01:06:04 +0200 | [diff] [blame] | 58 | if (cpu_release(cpuid, argc - 3, argv + 3)) |
Simon Glass | 4c12eeb | 2011-12-10 08:44:01 +0000 | [diff] [blame] | 59 | return CMD_RET_USAGE; |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 60 | |
| 61 | return 0; |
| 62 | } |
| 63 | |
Kim Phillips | 088f1b1 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 64 | #ifdef CONFIG_SYS_LONGHELP |
| 65 | static 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 Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 70 | #ifdef CONFIG_PPC |
Kim Phillips | 088f1b1 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 71 | "\n" |
Kumar Gala | 79679d8 | 2008-03-26 08:34:25 -0500 | [diff] [blame] | 72 | " [args] : <pir> <r3> <r6>\n" \ |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 73 | " pir - processor id (if writeable)\n" \ |
| 74 | " r3 - value for gpr 3\n" \ |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 75 | " r6 - value for gpr 6\n" \ |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 76 | "\n" \ |
| 77 | " Use '-' for any arg if you want the default value.\n" \ |
Kumar Gala | 79679d8 | 2008-03-26 08:34:25 -0500 | [diff] [blame] | 78 | " Default for r3 is <num> and r6 is 0\n" \ |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 79 | "\n" \ |
Kumar Gala | 79679d8 | 2008-03-26 08:34:25 -0500 | [diff] [blame] | 80 | " When cpu <num> is released r4 and r5 = 0.\n" \ |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 81 | " r7 will contain the size of the initial mapped area" |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 82 | #endif |
Kim Phillips | 088f1b1 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 83 | ""; |
| 84 | #endif |
Kumar Gala | ec2b74f | 2008-01-17 16:48:33 -0600 | [diff] [blame] | 85 | |
| 86 | U_BOOT_CMD( |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 87 | cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd, |
Kim Phillips | 088f1b1 | 2012-10-29 13:34:31 +0000 | [diff] [blame] | 88 | "Multiprocessor CPU boot manipulation and release", cpu_help_text |
Wolfgang Denk | a89c33d | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 89 | ); |