nuvoton_pm.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * Copyright (c) 2015-2023, ARM Limited and Contributors. All rights reserved.
  3. *
  4. * Copyright (C) 2023 Nuvoton Ltd.
  5. *
  6. * SPDX-License-Identifier: BSD-3-Clause
  7. */
  8. #include <assert.h>
  9. #include <arch_helpers.h>
  10. #include <lib/psci/psci.h>
  11. #include <plat/arm/common/plat_arm.h>
  12. #include <plat/common/platform.h>
  13. #include <platform_def.h>
  14. /* Allow npcm845x to override these functions */
  15. #pragma weak plat_arm_program_trusted_mailbox
  16. #pragma weak plat_setup_psci_ops /* changed to weak */
  17. /*******************************************************************************
  18. * ARM standard platform handler called to check the validity of the non secure
  19. * entrypoint. Returns 0 if the entrypoint is valid, or -1 otherwise.
  20. ******************************************************************************/
  21. int arm_validate_ns_entrypoint(uintptr_t entrypoint)
  22. {
  23. /*
  24. * Check if the non secure entrypoint lies within the non
  25. * secure DRAM.
  26. */
  27. if ((entrypoint >= ARM_NS_DRAM1_BASE) &&
  28. (entrypoint < (ARM_NS_DRAM1_BASE + ARM_NS_DRAM1_SIZE))) {
  29. return 0;
  30. }
  31. #ifdef __aarch64__
  32. if ((entrypoint >= ARM_DRAM2_BASE) &&
  33. (entrypoint < (ARM_DRAM2_BASE + ARM_DRAM2_SIZE))) {
  34. return 0;
  35. }
  36. #endif
  37. return -1;
  38. }
  39. int arm_validate_psci_entrypoint(uintptr_t entrypoint)
  40. {
  41. return (arm_validate_ns_entrypoint(entrypoint) == 0) ? PSCI_E_SUCCESS :
  42. PSCI_E_INVALID_ADDRESS;
  43. }
  44. /******************************************************************************
  45. * Helper function to save the platform state before a system suspend. Save the
  46. * state of the system components which are not in the Always ON power domain.
  47. *****************************************************************************/
  48. void arm_system_pwr_domain_save(void)
  49. {
  50. /* Assert system power domain is available on the platform */
  51. assert(PLAT_MAX_PWR_LVL > ARM_PWR_LVL1);
  52. plat_arm_gic_save();
  53. /*
  54. * Unregister console now so that it is not registered for a second
  55. * time during resume.
  56. */
  57. arm_console_runtime_end();
  58. /*
  59. * All the other peripheral which are configured by TF-A are
  60. * re-initialized on resume from system suspend. Hence we
  61. * don't save their state here.
  62. */
  63. }