pwr_ctrl.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2023 NXP
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdbool.h>
  7. #include <platform_def.h>
  8. #include <pwr_ctrl.h>
  9. /*Do the necessary GPC, SRC, BLK_CTRL_S init */
  10. void pwr_sys_init(void)
  11. {
  12. unsigned int cpu;
  13. /*
  14. * Assigned A55 cluster to 3, m33 to 2, A55 CORE0 & CORE1 to 0/1.
  15. * domain0/1 only used for trigger LPM of themselves. A55 cluster & M33's
  16. * domain assignment should be align with the TRDC DID.
  17. */
  18. gpc_assign_domains(0x3102);
  19. /* CA55 core0/1 config */
  20. for (cpu = CPU_A55C0; cpu <= CPU_A55_PLAT; cpu++) {
  21. /* clear the cpu sleep hold */
  22. gpc_clear_cpu_sleep_hold(cpu);
  23. /* use gic wakeup source by default */
  24. gpc_select_wakeup_gic(cpu);
  25. /*
  26. * Ignore A55 core0/1's LPM trigger for system sleep.
  27. * normally, for A55 side, only the A55 cluster(plat)
  28. * domain will be used to trigger the system wide low
  29. * power mode transition.
  30. */
  31. if (cpu != CPU_A55_PLAT) {
  32. gpc_force_cpu_suspend(cpu);
  33. }
  34. }
  35. /* boot core(A55C0) */
  36. src_mem_lpm_en(SRC_A55P0_MEM, MEM_OFF);
  37. /* For A55 core, only need to be on in RUN mode */
  38. src_mix_set_lpm(SRC_A55C0, 0x0, CM_MODE_WAIT);
  39. /* whitelist: 0x1 for domain 0 only */
  40. src_authen_config(SRC_A55C0, 0x1, 0x1);
  41. /* A55 cluster */
  42. gpc_select_wakeup_gic(CPU_A55_PLAT);
  43. gpc_clear_cpu_sleep_hold(CPU_A55_PLAT);
  44. /* SCU MEM must be OFF when A55 PLAT OFF */
  45. src_mem_lpm_en(SRC_A55_SCU_MEM, MEM_OFF);
  46. /* L3 memory in retention by default */
  47. src_mem_lpm_en(SRC_A55_L3_MEM, MEM_RETN);
  48. src_mix_set_lpm(SRC_A55P, 0x3, 0x1);
  49. /* whitelist: 0x8 for domain 3 only */
  50. src_authen_config(SRC_A55P, 0x8, 0x1);
  51. /* enable the HW LP handshake between S401 & A55 cluster */
  52. mmio_setbits_32(BLK_CTRL_S_BASE + HW_LP_HANDHSK, BIT(5));
  53. }