1 /* 2 * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <arch_helpers.h> 8 #include <assert.h> 9 #include <debug.h> 10 #include <k3_gicv3.h> 11 #include <psci.h> 12 #include <stdbool.h> 13 14 #define STUB() ERROR("stub %s called\n", __func__) 15 16 uintptr_t k3_sec_entrypoint; 17 18 static void k3_cpu_standby(plat_local_state_t cpu_state) 19 { 20 /* 21 * Enter standby state 22 * dsb is good practice before using wfi to enter low power states 23 */ 24 dsb(); 25 wfi(); 26 } 27 28 static int k3_pwr_domain_on(u_register_t mpidr) 29 { 30 sev(); 31 32 /* TODO: Indicate to System firmware about powering up */ 33 34 return PSCI_E_SUCCESS; 35 } 36 37 void k3_pwr_domain_off(const psci_power_state_t *target_state) 38 { 39 /* Prevent interrupts from spuriously waking up this cpu */ 40 k3_gic_cpuif_disable(); 41 42 /* TODO: Indicate to System firmware about powering down */ 43 } 44 45 void k3_pwr_domain_on_finish(const psci_power_state_t *target_state) 46 { 47 /* TODO: Indicate to System firmware about completion */ 48 49 k3_gic_pcpu_init(); 50 k3_gic_cpuif_enable(); 51 } 52 53 static void __dead2 k3_system_reset(void) 54 { 55 /* TODO: Indicate to System firmware about system reset */ 56 STUB(); 57 58 while (true) 59 wfi(); 60 } 61 62 static int k3_validate_power_state(unsigned int power_state, 63 psci_power_state_t *req_state) 64 { 65 /* TODO: perform the proper validation */ 66 67 return PSCI_E_SUCCESS; 68 } 69 70 static int k3_validate_ns_entrypoint(uintptr_t entrypoint) 71 { 72 /* TODO: perform the proper validation */ 73 74 return PSCI_E_SUCCESS; 75 } 76 77 static const plat_psci_ops_t k3_plat_psci_ops = { 78 .cpu_standby = k3_cpu_standby, 79 .pwr_domain_on = k3_pwr_domain_on, 80 .pwr_domain_off = k3_pwr_domain_off, 81 .pwr_domain_on_finish = k3_pwr_domain_on_finish, 82 .system_reset = k3_system_reset, 83 .validate_power_state = k3_validate_power_state, 84 .validate_ns_entrypoint = k3_validate_ns_entrypoint 85 }; 86 87 int plat_setup_psci_ops(uintptr_t sec_entrypoint, 88 const plat_psci_ops_t **psci_ops) 89 { 90 k3_sec_entrypoint = sec_entrypoint; 91 92 *psci_ops = &k3_plat_psci_ops; 93 94 return 0; 95 } 96