stm32mp2_pm.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Copyright (c) 2024, STMicroelectronics - All Rights Reserved
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <errno.h>
  8. #include <arch_helpers.h>
  9. #include <common/debug.h>
  10. #include <drivers/arm/gic_common.h>
  11. #include <drivers/arm/gicv2.h>
  12. #include <drivers/st/stm32mp_reset.h>
  13. #include <lib/mmio.h>
  14. #include <lib/psci/psci.h>
  15. #include <plat/common/platform.h>
  16. #include <platform_def.h>
  17. static uintptr_t stm32_sec_entrypoint;
  18. static void stm32_cpu_standby(plat_local_state_t cpu_state)
  19. {
  20. }
  21. static int stm32_pwr_domain_on(u_register_t mpidr)
  22. {
  23. return PSCI_E_INTERN_FAIL;
  24. }
  25. static void stm32_pwr_domain_off(const psci_power_state_t *target_state)
  26. {
  27. /* Nothing to do */
  28. }
  29. static void stm32_pwr_domain_suspend(const psci_power_state_t *target_state)
  30. {
  31. /* Nothing to do, power domain is not disabled */
  32. }
  33. static void stm32_pwr_domain_on_finish(const psci_power_state_t *target_state)
  34. {
  35. }
  36. /*******************************************************************************
  37. * STM32MP2 handler called when a power domain has just been powered on after
  38. * having been suspended earlier. The target_state encodes the low power state
  39. * that each level has woken up from.
  40. ******************************************************************************/
  41. static void stm32_pwr_domain_suspend_finish(const psci_power_state_t
  42. *target_state)
  43. {
  44. /* Nothing to do, power domain is not disabled */
  45. }
  46. static void __dead2 stm32_pwr_domain_pwr_down_wfi(const psci_power_state_t
  47. *target_state)
  48. {
  49. ERROR("stm32mp2 Power Down WFI: operation not handled.\n");
  50. panic();
  51. }
  52. static void __dead2 stm32_system_off(void)
  53. {
  54. ERROR("stm32mp2 System Off: operation not handled.\n");
  55. panic();
  56. }
  57. static void __dead2 stm32_system_reset(void)
  58. {
  59. stm32mp_system_reset();
  60. }
  61. static int stm32_validate_power_state(unsigned int power_state,
  62. psci_power_state_t *req_state)
  63. {
  64. return PSCI_E_INVALID_PARAMS;
  65. }
  66. static int stm32_validate_ns_entrypoint(uintptr_t entrypoint)
  67. {
  68. /* The non-secure entry point must be in DDR */
  69. if (entrypoint < STM32MP_DDR_BASE) {
  70. return PSCI_E_INVALID_ADDRESS;
  71. }
  72. return PSCI_E_SUCCESS;
  73. }
  74. static void stm32_get_sys_suspend_power_state(psci_power_state_t *req_state)
  75. {
  76. }
  77. /*******************************************************************************
  78. * Export the platform handlers. The ARM Standard platform layer will take care
  79. * of registering the handlers with PSCI.
  80. ******************************************************************************/
  81. static const plat_psci_ops_t stm32_psci_ops = {
  82. .cpu_standby = stm32_cpu_standby,
  83. .pwr_domain_on = stm32_pwr_domain_on,
  84. .pwr_domain_off = stm32_pwr_domain_off,
  85. .pwr_domain_suspend = stm32_pwr_domain_suspend,
  86. .pwr_domain_on_finish = stm32_pwr_domain_on_finish,
  87. .pwr_domain_suspend_finish = stm32_pwr_domain_suspend_finish,
  88. .pwr_domain_pwr_down_wfi = stm32_pwr_domain_pwr_down_wfi,
  89. .system_off = stm32_system_off,
  90. .system_reset = stm32_system_reset,
  91. .validate_power_state = stm32_validate_power_state,
  92. .validate_ns_entrypoint = stm32_validate_ns_entrypoint,
  93. .get_sys_suspend_power_state = stm32_get_sys_suspend_power_state,
  94. };
  95. /*******************************************************************************
  96. * Export the platform specific power ops.
  97. ******************************************************************************/
  98. int plat_setup_psci_ops(uintptr_t sec_entrypoint,
  99. const plat_psci_ops_t **psci_ops)
  100. {
  101. stm32_sec_entrypoint = sec_entrypoint;
  102. *psci_ops = &stm32_psci_ops;
  103. return 0;
  104. }