Debian Codegraph @

plat/arm/board/corstone1000/common/corstone1000_pm.c

raw
1 /*
2 * Copyright (c) 2021-2024, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <lib/psci/psci.h>
8 #include <plat/arm/common/plat_arm.h>
9 #include <platform_def.h>
10 #include <plat/common/platform.h>
11 #include <drivers/arm/gicv2.h>
12 /*******************************************************************************
13 * Export the platform handlers via plat_arm_psci_pm_ops. The ARM Standard
14 * platform layer will take care of registering the handlers with PSCI.
15 ******************************************************************************/
16
17 static void __dead2 corstone1000_system_reset(void)
18 {
19
20 uint32_t volatile * const watchdog_ctrl_reg = (uint32_t *) SECURE_WATCHDOG_ADDR_CTRL_REG;
21 uint32_t volatile * const watchdog_val_reg = (uint32_t *) SECURE_WATCHDOG_ADDR_VAL_REG;
22
23 /*
24 * Disable GIC CPU interface to prevent pending interrupt
25 * from waking up the AP from WFI.
26 */
27 gicv2_cpuif_disable();
28
29 /* Flush and invalidate data cache */
30 dcsw_op_all(DCCISW);
31
32 *(watchdog_val_reg) = SECURE_WATCHDOG_COUNTDOWN_VAL;
33 *watchdog_ctrl_reg = SECURE_WATCHDOG_MASK_ENABLE;
34 while (1) {
35 wfi();
36 }
37 }
38
39 #if defined(CORSTONE1000_FVP_MULTICORE)
40 int corstone1000_validate_ns_entrypoint(uintptr_t entrypoint)
41 {
42 /*
43 * Check if the non secure entrypoint lies within the non
44 * secure DRAM.
45 */
46 if ((entrypoint >= ARM_NS_DRAM1_BASE) && (entrypoint < (ARM_NS_DRAM1_BASE + ARM_NS_DRAM1_SIZE))) {
47 return PSCI_E_SUCCESS;
48 }
49 return PSCI_E_INVALID_ADDRESS;
50 }
51
52 int corstone1000_pwr_domain_on(u_register_t mpidr)
53 {
54 int core_index = plat_core_pos_by_mpidr(mpidr);
55 uint64_t *secondary_core_hold_base = (uint64_t *)CORSTONE1000_SECONDARY_CORE_HOLD_BASE;
56
57 /* Validate the core index */
58 if (core_index < 0 || core_index > PLATFORM_CORE_COUNT) {
59 return PSCI_E_INVALID_PARAMS;
60 }
61 secondary_core_hold_base[core_index] = CORSTONE1000_SECONDARY_CORE_STATE_GO;
62 dsbish();
63 sev();
64
65 return PSCI_E_SUCCESS;
66 }
67
68 void corstone1000_pwr_domain_on_finish(const psci_power_state_t *target_state)
69 {
70 (void)target_state;
71 plat_arm_gic_init();
72 }
73 #endif
74
75 plat_psci_ops_t plat_arm_psci_pm_ops = {
76 #if defined(CORSTONE1000_FVP_MULTICORE)
77 .pwr_domain_on = corstone1000_pwr_domain_on,
78 .pwr_domain_on_finish = corstone1000_pwr_domain_on_finish,
79 .validate_ns_entrypoint = corstone1000_validate_ns_entrypoint,
80 .system_reset = corstone1000_system_reset,
81 #else
82 .validate_ns_entrypoint = NULL,
83 .system_reset = corstone1000_system_reset,
84 #endif
85 };
86
87 const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops)
88 {
89 ops = &plat_arm_psci_pm_ops;
90 return ops;
91 }