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