imx_bootaux.c 1.7 KB

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