gpc.h 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /*
  2. * Copyright (c) 2018-2023, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef IMX8M_GPC_H
  7. #define IMX8M_GPC_H
  8. #include <gpc_reg.h>
  9. /* helper macro */
  10. #define A53_LPM_MASK U(0xF)
  11. #define A53_LPM_WAIT U(0x5)
  12. #define A53_LPM_STOP U(0xA)
  13. #define LPM_MODE(local_state) ((local_state) == PLAT_WAIT_RET_STATE ? A53_LPM_WAIT : A53_LPM_STOP)
  14. #define DSM_MODE_MASK BIT(31)
  15. #define CORE_WKUP_FROM_GIC (IRQ_SRC_C0 | IRQ_SRC_C1 | IRQ_SRC_C2 | IRQ_SRC_C3)
  16. #define A53_CORE_WUP_SRC(core_id) (1 << ((core_id) < 2 ? 28 + (core_id) : 22 + (core_id) - 2))
  17. #define COREx_PGC_PCR(core_id) (0x800 + (core_id) * 0x40)
  18. #define COREx_WFI_PDN(core_id) (1 << ((core_id) < 2 ? (core_id) * 2 : ((core_id) - 2) * 2 + 16))
  19. #define COREx_IRQ_WUP(core_id) ((core_id) < 2 ? (1 << ((core_id) * 2 + 8)) : (1 << ((core_id) * 2 + 20)))
  20. #define COREx_LPM_PUP(core_id) ((core_id) < 2 ? (1 << ((core_id) * 2 + 9)) : (1 << ((core_id) * 2 + 21)))
  21. #define SLTx_CFG(n) ((SLT0_CFG + ((n) * 4)))
  22. #define SLT_COREx_PUP(core_id) (0x2 << ((core_id) * 2))
  23. #define SLT_COREx_PUP_ACK(core_id) ((core_id) < 2 ? (1 << ((core_id) + 16)) : (1 << ((core_id) + 27)))
  24. #define IMR_MASK_ALL 0xffffffff
  25. #define IMX_PD_DOMAIN(name, on) \
  26. { \
  27. .pwr_req = name##_PWR_REQ, \
  28. .pgc_offset = name##_PGC, \
  29. .need_sync = false, \
  30. .always_on = (on), \
  31. }
  32. #define IMX_MIX_DOMAIN(name, on) \
  33. { \
  34. .pwr_req = name##_PWR_REQ, \
  35. .pgc_offset = name##_PGC, \
  36. .adb400_sync = name##_ADB400_SYNC, \
  37. .adb400_ack = name##_ADB400_ACK, \
  38. .need_sync = true, \
  39. .always_on = (on), \
  40. }
  41. struct imx_pwr_domain {
  42. uint32_t pwr_req;
  43. uint32_t adb400_sync;
  44. uint32_t adb400_ack;
  45. uint32_t pgc_offset;
  46. bool need_sync;
  47. bool always_on;
  48. };
  49. struct pll_override {
  50. uint32_t reg;
  51. uint32_t override_mask;
  52. };
  53. DECLARE_BAKERY_LOCK(gpc_lock);
  54. /* function declare */
  55. void imx_gpc_init(void);
  56. void imx_set_cpu_secure_entry(unsigned int core_index, uintptr_t sec_entrypoint);
  57. void imx_set_cpu_pwr_off(unsigned int core_index);
  58. void imx_set_cpu_pwr_on(unsigned int core_index);
  59. void imx_set_cpu_lpm(unsigned int core_index, bool pdn);
  60. void imx_set_cluster_standby(bool retention);
  61. void imx_set_cluster_powerdown(unsigned int last_core, uint8_t power_state);
  62. void imx_noc_slot_config(bool pdn);
  63. void imx_set_sys_wakeup(unsigned int last_core, bool pdn);
  64. void imx_set_sys_lpm(unsigned last_core, bool retention);
  65. void imx_set_rbc_count(void);
  66. void imx_clear_rbc_count(void);
  67. void imx_anamix_override(bool enter);
  68. void imx_gpc_pm_domain_enable(uint32_t domain_id, bool on);
  69. #if defined(PLAT_imx8mq)
  70. void imx_gpc_set_a53_core_awake(uint32_t core_id);
  71. void imx_gpc_core_wake(uint32_t cpumask);
  72. #endif
  73. #endif /*IMX8M_GPC_H */