mp.c 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright 2008-2009 Freescale Semiconductor, Inc.
  4. */
  5. #include <common.h>
  6. #include <command.h>
  7. static int cpu_status_all(void)
  8. {
  9. unsigned long cpuid;
  10. for (cpuid = 0; ; cpuid++) {
  11. if (!is_core_valid(cpuid)) {
  12. if (cpuid == 0) {
  13. printf("Core num: %lu is not valid\n", cpuid);
  14. return 1;
  15. }
  16. break;
  17. }
  18. cpu_status(cpuid);
  19. }
  20. return 0;
  21. }
  22. static int
  23. cpu_cmd(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  24. {
  25. unsigned long cpuid;
  26. if (argc == 2 && strncmp(argv[1], "status", 6) == 0)
  27. return cpu_status_all();
  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 status - Status of all cpus\n"
  57. "cpu <num> status - Status of cpu <num>\n"
  58. "cpu <num> disable - Disable cpu <num>\n"
  59. "cpu <num> release <addr> [args] - Release cpu <num> at <addr> with [args]"
  60. #ifdef CONFIG_PPC
  61. "\n"
  62. " [args] : <pir> <r3> <r6>\n" \
  63. " pir - processor id (if writeable)\n" \
  64. " r3 - value for gpr 3\n" \
  65. " r6 - value for gpr 6\n" \
  66. "\n" \
  67. " Use '-' for any arg if you want the default value.\n" \
  68. " Default for r3 is <num> and r6 is 0\n" \
  69. "\n" \
  70. " When cpu <num> is released r4 and r5 = 0.\n" \
  71. " r7 will contain the size of the initial mapped area"
  72. #endif
  73. "";
  74. #endif
  75. U_BOOT_CMD(
  76. cpu, CONFIG_SYS_MAXARGS, 1, cpu_cmd,
  77. "Multiprocessor CPU boot manipulation and release", cpu_help_text
  78. );