1 /* 2 * Copyright (c) 2013-2017, ARM Limited and Contributors. All rights reserved. 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 */ 6 7 #include <bakery_lock.h> 8 #include <mmio.h> 9 #include <plat_arm.h> 10 #include "../../fvp_def.h" 11 #include "../../fvp_private.h" 12 #include "fvp_pwrc.h" 13 14 /* 15 * TODO: Someday there will be a generic power controller api. At the moment 16 * each platform has its own pwrc so just exporting functions is fine. 17 */ 18 ARM_INSTANTIATE_LOCK; 19 fvp_pwrc_get_cpu_wkr(u_register_t mpidr)20unsigned int fvp_pwrc_get_cpu_wkr(u_register_t mpidr) 21 { 22 return PSYSR_WK(fvp_pwrc_read_psysr(mpidr)); 23 } 24 fvp_pwrc_read_psysr(u_register_t mpidr)25unsigned int fvp_pwrc_read_psysr(u_register_t mpidr) 26 { 27 unsigned int rc; 28 arm_lock_get(); 29 mmio_write_32(PWRC_BASE + PSYSR_OFF, (unsigned int) mpidr); 30 rc = mmio_read_32(PWRC_BASE + PSYSR_OFF); 31 arm_lock_release(); 32 return rc; 33 } 34 fvp_pwrc_write_pponr(u_register_t mpidr)35void fvp_pwrc_write_pponr(u_register_t mpidr) 36 { 37 arm_lock_get(); 38 mmio_write_32(PWRC_BASE + PPONR_OFF, (unsigned int) mpidr); 39 arm_lock_release(); 40 } 41 fvp_pwrc_write_ppoffr(u_register_t mpidr)42void fvp_pwrc_write_ppoffr(u_register_t mpidr) 43 { 44 arm_lock_get(); 45 mmio_write_32(PWRC_BASE + PPOFFR_OFF, (unsigned int) mpidr); 46 arm_lock_release(); 47 } 48 fvp_pwrc_set_wen(u_register_t mpidr)49void fvp_pwrc_set_wen(u_register_t mpidr) 50 { 51 arm_lock_get(); 52 mmio_write_32(PWRC_BASE + PWKUPR_OFF, 53 (unsigned int) (PWKUPR_WEN | mpidr)); 54 arm_lock_release(); 55 } 56 fvp_pwrc_clr_wen(u_register_t mpidr)57void fvp_pwrc_clr_wen(u_register_t mpidr) 58 { 59 arm_lock_get(); 60 mmio_write_32(PWRC_BASE + PWKUPR_OFF, 61 (unsigned int) mpidr); 62 arm_lock_release(); 63 } 64 fvp_pwrc_write_pcoffr(u_register_t mpidr)65void fvp_pwrc_write_pcoffr(u_register_t mpidr) 66 { 67 arm_lock_get(); 68 mmio_write_32(PWRC_BASE + PCOFFR_OFF, (unsigned int) mpidr); 69 arm_lock_release(); 70 } 71 72 /* Nothing else to do here apart from initializing the lock */ plat_arm_pwrc_setup(void)73void plat_arm_pwrc_setup(void) 74 { 75 arm_lock_init(); 76 } 77 78 79 80