mp.c 2.2 KB

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