cmd_mp.c 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright 2008-2009 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. #include <common.h>
  23. #include <command.h>
  24. static int
  25. cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  26. {
  27. unsigned long cpuid;
  28. if (argc < 3)
  29. return CMD_RET_USAGE;
  30. cpuid = simple_strtoul(argv[1], NULL, 10);
  31. if (!is_core_valid(cpuid)) {
  32. printf ("Core num: %lu is not valid\n", cpuid);
  33. return 1;
  34. }
  35. if (argc == 3) {
  36. if (strncmp(argv[2], "reset", 5) == 0)
  37. cpu_reset(cpuid);
  38. else if (strncmp(argv[2], "status", 6) == 0)
  39. cpu_status(cpuid);
  40. else if (strncmp(argv[2], "disable", 7) == 0)
  41. return cpu_disable(cpuid);
  42. else
  43. return CMD_RET_USAGE;
  44. return 0;
  45. }
  46. /* 4 or greater, make sure its release */
  47. if (strncmp(argv[2], "release", 7) != 0)
  48. return CMD_RET_USAGE;
  49. if (cpu_release(cpuid, argc - 3, argv + 3))
  50. return CMD_RET_USAGE;
  51. return 0;
  52. }
  53. #ifdef CONFIG_SYS_LONGHELP
  54. static char cpu_help_text[] =
  55. "<num> reset - Reset cpu <num>\n"
  56. "cpu <num> status - Status of cpu <num>\n"
  57. "cpu <num> disable - Disable cpu <num>\n"
  58. "cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
  59. #ifdef CONFIG_PPC
  60. "\n"
  61. " [args] : <pir> <r3> <r6>\n" \
  62. " pir - processor id (if writeable)\n" \
  63. " r3 - value for gpr 3\n" \
  64. " r6 - value for gpr 6\n" \
  65. "\n" \
  66. " Use '-' for any arg if you want the default value.\n" \
  67. " Default for r3 is <num> and r6 is 0\n" \
  68. "\n" \
  69. " When cpu <num> is released r4 and r5 = 0.\n" \
  70. " r7 will contain the size of the initial mapped area"
  71. #endif
  72. "";
  73. #endif
  74. U_BOOT_CMD(
  75. cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
  76. "Multiprocessor CPU boot manipulation and release", cpu_help_text
  77. );