cmd_mon.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * K2HK: secure kernel command file
  3. *
  4. * (C) Copyright 2012-2014
  5. * Texas Instruments Incorporated, <www.ti.com>
  6. *
  7. * SPDX-License-Identifier: GPL-2.0+
  8. */
  9. #include <common.h>
  10. #include <command.h>
  11. #include <mach/mon.h>
  12. asm(".arch_extension sec\n\t");
  13. static int do_mon_install(cmd_tbl_t *cmdtp, int flag, int argc,
  14. char * const argv[])
  15. {
  16. u32 addr, dpsc_base = 0x1E80000, freq;
  17. int rcode = 0;
  18. if (argc < 2)
  19. return CMD_RET_USAGE;
  20. freq = CONFIG_SYS_HZ_CLOCK;
  21. addr = simple_strtoul(argv[1], NULL, 16);
  22. rcode = mon_install(addr, dpsc_base, freq);
  23. printf("## installed monitor, freq [%d], status %d\n",
  24. freq, rcode);
  25. return 0;
  26. }
  27. U_BOOT_CMD(mon_install, 2, 0, do_mon_install,
  28. "Install boot kernel at 'addr'",
  29. ""
  30. );
  31. static void core_spin(void)
  32. {
  33. while (1) {
  34. asm volatile (
  35. "dsb\n"
  36. "isb\n"
  37. "wfi\n"
  38. );
  39. }
  40. }
  41. int do_mon_power(cmd_tbl_t *cmdtp, int flag, int argc,
  42. char * const argv[])
  43. {
  44. int rcode = 0, core_id, on;
  45. void (*fn)(void);
  46. fn = core_spin;
  47. if (argc < 3)
  48. return CMD_RET_USAGE;
  49. core_id = simple_strtoul(argv[1], NULL, 16);
  50. on = simple_strtoul(argv[2], NULL, 16);
  51. if (on)
  52. rcode = mon_power_on(core_id, fn);
  53. else
  54. rcode = mon_power_off(core_id);
  55. if (on) {
  56. if (!rcode)
  57. printf("core %d powered on successfully\n", core_id);
  58. else
  59. printf("core %d power on failure\n", core_id);
  60. } else {
  61. printf("core %d powered off successfully\n", core_id);
  62. }
  63. return 0;
  64. }
  65. U_BOOT_CMD(mon_power, 3, 0, do_mon_power,
  66. "Power On/Off secondary core",
  67. "mon_power <coreid> <oper>\n"
  68. "- coreid (1-3) and oper (1 - ON, 0 - OFF)\n"
  69. ""
  70. );