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