imx_bootaux.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * Copyright (C) 2016 Freescale Semiconductor, Inc.
  3. *
  4. * SPDX-License-Identifier: GPL-2.0+
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. /* Allow for arch specific config before we boot */
  9. static int __arch_auxiliary_core_up(u32 core_id, u32 boot_private_data)
  10. {
  11. /* please define platform specific arch_auxiliary_core_up() */
  12. return CMD_RET_FAILURE;
  13. }
  14. int arch_auxiliary_core_up(u32 core_id, u32 boot_private_data)
  15. __attribute__((weak, alias("__arch_auxiliary_core_up")));
  16. /* Allow for arch specific config before we boot */
  17. static int __arch_auxiliary_core_check_up(u32 core_id)
  18. {
  19. /* please define platform specific arch_auxiliary_core_check_up() */
  20. return 0;
  21. }
  22. int arch_auxiliary_core_check_up(u32 core_id)
  23. __attribute__((weak, alias("__arch_auxiliary_core_check_up")));
  24. /*
  25. * To i.MX6SX and i.MX7D, the image supported by bootaux needs
  26. * the reset vector at the head for the image, with SP and PC
  27. * as the first two words.
  28. *
  29. * Per the cortex-M reference manual, the reset vector of M4 needs
  30. * to exist at 0x0 (TCMUL). The PC and SP are the first two addresses
  31. * of that vector. So to boot M4, the A core must build the M4's reset
  32. * vector with getting the PC and SP from image and filling them to
  33. * TCMUL. When M4 is kicked, it will load the PC and SP by itself.
  34. * The TCMUL is mapped to (M4_BOOTROM_BASE_ADDR) at A core side for
  35. * accessing the M4 TCMUL.
  36. */
  37. int do_bootaux(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  38. {
  39. ulong addr;
  40. int ret, up;
  41. if (argc < 2)
  42. return CMD_RET_USAGE;
  43. up = arch_auxiliary_core_check_up(0);
  44. if (up) {
  45. printf("## Auxiliary core is already up\n");
  46. return CMD_RET_SUCCESS;
  47. }
  48. addr = simple_strtoul(argv[1], NULL, 16);
  49. printf("## Starting auxiliary core at 0x%08lX ...\n", addr);
  50. ret = arch_auxiliary_core_up(0, addr);
  51. if (ret)
  52. return CMD_RET_FAILURE;
  53. return CMD_RET_SUCCESS;
  54. }
  55. U_BOOT_CMD(
  56. bootaux, CONFIG_SYS_MAXARGS, 1, do_bootaux,
  57. "Start auxiliary core",
  58. ""
  59. );