imx8_psci.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <stdbool.h>
  7. #include <arch.h>
  8. #include <arch_helpers.h>
  9. #include <common/debug.h>
  10. #include <plat_imx8.h>
  11. #include <sci/sci.h>
  12. void __dead2 imx_system_off(void)
  13. {
  14. sc_pm_set_sys_power_mode(ipc_handle, SC_PM_PW_MODE_OFF);
  15. wfi();
  16. ERROR("power off failed.\n");
  17. panic();
  18. }
  19. void __dead2 imx_system_reset(void)
  20. {
  21. sc_pm_reset(ipc_handle, SC_PM_RESET_TYPE_BOARD);
  22. wfi();
  23. ERROR("system reset failed.\n");
  24. panic();
  25. }
  26. int imx_validate_power_state(unsigned int power_state,
  27. psci_power_state_t *req_state)
  28. {
  29. int pwr_lvl = psci_get_pstate_pwrlvl(power_state);
  30. int pwr_type = psci_get_pstate_type(power_state);
  31. int state_id = psci_get_pstate_id(power_state);
  32. if (pwr_lvl > PLAT_MAX_PWR_LVL)
  33. return PSCI_E_INVALID_PARAMS;
  34. if (pwr_type == PSTATE_TYPE_POWERDOWN) {
  35. req_state->pwr_domain_state[MPIDR_AFFLVL0] = PLAT_MAX_OFF_STATE;
  36. if (!state_id)
  37. req_state->pwr_domain_state[MPIDR_AFFLVL1] = PLAT_MAX_RET_STATE;
  38. else
  39. req_state->pwr_domain_state[MPIDR_AFFLVL1] = PLAT_MAX_OFF_STATE;
  40. }
  41. return PSCI_E_SUCCESS;
  42. }
  43. void imx_get_sys_suspend_power_state(psci_power_state_t *req_state)
  44. {
  45. unsigned int i;
  46. /* CPU & cluster off, system in retention */
  47. for (i = MPIDR_AFFLVL0; i < PLAT_MAX_PWR_LVL; i++)
  48. req_state->pwr_domain_state[i] = PLAT_MAX_OFF_STATE;
  49. req_state->pwr_domain_state[PLAT_MAX_PWR_LVL] = PLAT_MAX_RET_STATE;
  50. }