• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2018-2021, Renesas Electronics Corporation. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <lib/mmio.h>
8 
9 #include "cpg_registers.h"
10 #include "rcar_private.h"
11 
12 #if IMAGE_BL31
cpg_write(uintptr_t regadr,uint32_t regval)13 void __attribute__ ((section(".system_ram"))) cpg_write(uintptr_t regadr, uint32_t regval)
14 #else
15 void cpg_write(uintptr_t regadr, uint32_t regval)
16 #endif
17 {
18 	uint32_t value = regval;
19 
20 	mmio_write_32(CPG_CPGWPR, ~value);
21 	mmio_write_32(regadr, value);
22 }
23 
24 #if IMAGE_BL31
mstpcr_write(uint32_t mstpcr,uint32_t mstpsr,uint32_t target_bit)25 void __attribute__ ((section(".system_ram"))) mstpcr_write(uint32_t mstpcr, uint32_t mstpsr,
26 							   uint32_t target_bit)
27 #else
28 void mstpcr_write(uint32_t mstpcr, uint32_t mstpsr, uint32_t target_bit)
29 #endif
30 {
31 	uint32_t reg;
32 
33 	reg = mmio_read_32(mstpcr);
34 	reg &= ~target_bit;
35 	cpg_write(mstpcr, reg);
36 	while ((mmio_read_32(mstpsr) & target_bit) != 0U) {
37 	}
38 }
39