marvell_pm.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /*
  2. * Copyright (C) 2018 Marvell International Ltd.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. * https://spdx.org/licenses
  6. */
  7. #include <assert.h>
  8. #include <arch_helpers.h>
  9. #include <lib/psci/psci.h>
  10. #include <marvell_pm.h>
  11. /* Standard ARM platforms are expected to export plat_arm_psci_pm_ops */
  12. extern const plat_psci_ops_t plat_arm_psci_pm_ops;
  13. /*****************************************************************************
  14. * Private function to program the mailbox for a cpu before it is released
  15. * from reset. This function assumes that the mail box base is within
  16. * the MARVELL_SHARED_RAM region
  17. *****************************************************************************
  18. */
  19. void marvell_program_mailbox(uintptr_t address)
  20. {
  21. uintptr_t *mailbox = (void *)PLAT_MARVELL_MAILBOX_BASE;
  22. /*
  23. * Ensure that the PLAT_MARVELL_MAILBOX_BASE is within
  24. * MARVELL_SHARED_RAM region.
  25. */
  26. assert((PLAT_MARVELL_MAILBOX_BASE >= MARVELL_SHARED_RAM_BASE) &&
  27. ((PLAT_MARVELL_MAILBOX_BASE + sizeof(*mailbox)) <=
  28. (MARVELL_SHARED_RAM_BASE + MARVELL_SHARED_RAM_SIZE)));
  29. mailbox[MBOX_IDX_MAGIC] = MVEBU_MAILBOX_MAGIC_NUM;
  30. mailbox[MBOX_IDX_SEC_ADDR] = address;
  31. /* Flush data cache if the mail box shared RAM is cached */
  32. #if PLAT_MARVELL_SHARED_RAM_CACHED
  33. flush_dcache_range((uintptr_t)PLAT_MARVELL_MAILBOX_BASE +
  34. 8 * MBOX_IDX_MAGIC,
  35. 2 * sizeof(uint64_t));
  36. #endif
  37. }
  38. /*****************************************************************************
  39. * The ARM Standard platform definition of platform porting API
  40. * `plat_setup_psci_ops`.
  41. *****************************************************************************
  42. */
  43. int plat_setup_psci_ops(uintptr_t sec_entrypoint,
  44. const plat_psci_ops_t **psci_ops)
  45. {
  46. *psci_ops = &plat_arm_psci_pm_ops;
  47. /* Setup mailbox with entry point. */
  48. marvell_program_mailbox(sec_entrypoint);
  49. return 0;
  50. }