plat_pm.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2023, Aspeed Technology Inc.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <arch.h>
  7. #include <common/debug.h>
  8. #include <drivers/arm/gicv3.h>
  9. #include <drivers/console.h>
  10. #include <lib/mmio.h>
  11. #include <lib/psci/psci.h>
  12. #include <plat/common/platform.h>
  13. static uintptr_t sec_ep;
  14. static int plat_pwr_domain_on(u_register_t mpidr)
  15. {
  16. unsigned int cpu = plat_core_pos_by_mpidr(mpidr);
  17. uintptr_t ep_reg;
  18. switch (cpu) {
  19. case 1U:
  20. ep_reg = SCU_CPU_SMP_EP1;
  21. break;
  22. case 2U:
  23. ep_reg = SCU_CPU_SMP_EP2;
  24. break;
  25. case 3U:
  26. ep_reg = SCU_CPU_SMP_EP3;
  27. break;
  28. default:
  29. return PSCI_E_INVALID_PARAMS;
  30. }
  31. mmio_write_64(ep_reg, sec_ep);
  32. dsbsy();
  33. sev();
  34. return PSCI_E_SUCCESS;
  35. }
  36. static void plat_pwr_domain_on_finish(const psci_power_state_t *target_state)
  37. {
  38. gicv3_rdistif_init(plat_my_core_pos());
  39. gicv3_cpuif_enable(plat_my_core_pos());
  40. }
  41. static const plat_psci_ops_t plat_psci_ops = {
  42. .pwr_domain_on = plat_pwr_domain_on,
  43. .pwr_domain_on_finish = plat_pwr_domain_on_finish,
  44. };
  45. int plat_setup_psci_ops(uintptr_t sec_entrypoint,
  46. const plat_psci_ops_t **psci_ops)
  47. {
  48. sec_ep = sec_entrypoint;
  49. *psci_ops = &plat_psci_ops;
  50. return 0;
  51. }