mp.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2014
  4. * Gabriel Huau <contact@huau-gabriel.fr>
  5. *
  6. * (C) Copyright 2009 Freescale Semiconductor, Inc.
  7. */
  8. #include <common.h>
  9. #include <asm/io.h>
  10. #include <linux/errno.h>
  11. #include <asm/arch/sys_proto.h>
  12. #include <asm/arch/imx-regs.h>
  13. #define MAX_CPUS 4
  14. static struct src *src = (struct src *)SRC_BASE_ADDR;
  15. static uint32_t cpu_reset_mask[MAX_CPUS] = {
  16. 0, /* We don't really want to modify the cpu0 */
  17. SRC_SCR_CORE_1_RESET_MASK,
  18. SRC_SCR_CORE_2_RESET_MASK,
  19. SRC_SCR_CORE_3_RESET_MASK
  20. };
  21. static uint32_t cpu_ctrl_mask[MAX_CPUS] = {
  22. 0, /* We don't really want to modify the cpu0 */
  23. SRC_SCR_CORE_1_ENABLE_MASK,
  24. SRC_SCR_CORE_2_ENABLE_MASK,
  25. SRC_SCR_CORE_3_ENABLE_MASK
  26. };
  27. int cpu_reset(u32 nr)
  28. {
  29. /* Software reset of the CPU N */
  30. src->scr |= cpu_reset_mask[nr];
  31. return 0;
  32. }
  33. int cpu_status(u32 nr)
  34. {
  35. printf("core %d => %d\n", nr, !!(src->scr & cpu_ctrl_mask[nr]));
  36. return 0;
  37. }
  38. int cpu_release(u32 nr, int argc, char *const argv[])
  39. {
  40. uint32_t boot_addr;
  41. boot_addr = simple_strtoul(argv[0], NULL, 16);
  42. switch (nr) {
  43. case 1:
  44. src->gpr3 = boot_addr;
  45. break;
  46. case 2:
  47. src->gpr5 = boot_addr;
  48. break;
  49. case 3:
  50. src->gpr7 = boot_addr;
  51. break;
  52. default:
  53. return 1;
  54. }
  55. /* CPU N is ready to start */
  56. src->scr |= cpu_ctrl_mask[nr];
  57. return 0;
  58. }
  59. int is_core_valid(unsigned int core)
  60. {
  61. uint32_t nr_cores = get_nr_cpus();
  62. if (core > nr_cores)
  63. return 0;
  64. return 1;
  65. }
  66. int cpu_disable(u32 nr)
  67. {
  68. /* Disable the CPU N */
  69. src->scr &= ~cpu_ctrl_mask[nr];
  70. return 0;
  71. }