blob: 42bdce5797d17f88faad2a025026bb435229c8aa [file] [log] [blame]
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02001/*
2 * Copyright (c) 2018, Renesas Electronics Corporation. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00007#include <lib/mmio.h>
8
Jorge Ramirez-Ortizbf084dc2018-09-23 09:36:13 +02009#include "rcar_private.h"
10
11void
12#if IMAGE_BL31
13 __attribute__ ((section(".system_ram")))
14#endif
15 cpg_write(uintptr_t regadr, uint32_t regval)
16{
17 uint32_t value = (regval);
18 mmio_write_32((uintptr_t) RCAR_CPGWPR, ~value);
19 mmio_write_32(regadr, value);
20}
21
22void
23#if IMAGE_BL31
24 __attribute__ ((section(".system_ram")))
25#endif
26 mstpcr_write(uint32_t mstpcr, uint32_t mstpsr, uint32_t target_bit)
27{
28 uint32_t reg;
29 reg = mmio_read_32(mstpcr);
30 reg &= ~target_bit;
31 cpg_write(mstpcr, reg);
32 while ((mmio_read_32(mstpsr) & target_bit) != 0U) {
33 }
34}