rutigl@gmail.com | defbeed | 2023-03-19 09:19:05 +0200 | [diff] [blame] | 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 | |
| 9 | #include <assert.h> |
| 10 | |
| 11 | #include <arch_helpers.h> |
| 12 | #include <lib/psci/psci.h> |
| 13 | #include <plat/arm/common/plat_arm.h> |
| 14 | #include <plat/common/platform.h> |
| 15 | #include <platform_def.h> |
| 16 | |
| 17 | |
| 18 | /* Allow npcm845x to override these functions */ |
| 19 | #pragma weak plat_arm_program_trusted_mailbox |
| 20 | #pragma weak plat_setup_psci_ops /* changed to weak */ |
| 21 | |
| 22 | |
| 23 | /******************************************************************************* |
| 24 | * ARM standard platform handler called to check the validity of the non secure |
| 25 | * entrypoint. Returns 0 if the entrypoint is valid, or -1 otherwise. |
| 26 | ******************************************************************************/ |
| 27 | int arm_validate_ns_entrypoint(uintptr_t entrypoint) |
| 28 | { |
| 29 | /* |
| 30 | * Check if the non secure entrypoint lies within the non |
| 31 | * secure DRAM. |
| 32 | */ |
| 33 | if ((entrypoint >= ARM_NS_DRAM1_BASE) && |
| 34 | (entrypoint < (ARM_NS_DRAM1_BASE + ARM_NS_DRAM1_SIZE))) { |
| 35 | return 0; |
| 36 | } |
| 37 | #ifdef __aarch64__ |
| 38 | if ((entrypoint >= ARM_DRAM2_BASE) && |
| 39 | (entrypoint < (ARM_DRAM2_BASE + ARM_DRAM2_SIZE))) { |
| 40 | return 0; |
| 41 | } |
| 42 | #endif |
| 43 | |
| 44 | return -1; |
| 45 | } |
| 46 | |
| 47 | int arm_validate_psci_entrypoint(uintptr_t entrypoint) |
| 48 | { |
| 49 | return (arm_validate_ns_entrypoint(entrypoint) == 0) ? PSCI_E_SUCCESS : |
| 50 | PSCI_E_INVALID_ADDRESS; |
| 51 | } |
| 52 | |
| 53 | /****************************************************************************** |
| 54 | * Helper function to save the platform state before a system suspend. Save the |
| 55 | * state of the system components which are not in the Always ON power domain. |
| 56 | *****************************************************************************/ |
| 57 | void arm_system_pwr_domain_save(void) |
| 58 | { |
| 59 | /* Assert system power domain is available on the platform */ |
| 60 | assert(PLAT_MAX_PWR_LVL > ARM_PWR_LVL1); |
| 61 | |
| 62 | plat_arm_gic_save(); |
| 63 | |
| 64 | /* |
| 65 | * Unregister console now so that it is not registered for a second |
| 66 | * time during resume. |
| 67 | */ |
| 68 | arm_console_runtime_end(); |
| 69 | |
| 70 | /* |
| 71 | * All the other peripheral which are configured by TF-A are |
| 72 | * re-initialized on resume from system suspend. Hence we |
| 73 | * don't save their state here. |
| 74 | */ |
| 75 | } |