common.c 841 Bytes
Newer Older
1
/*
2
 * Copyright (c) 2018-2020, Renesas Electronics Corporation. All rights reserved.
3
4
5
6
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

7
8
#include <lib/mmio.h>

9
10
11
#include "rcar_private.h"

#if IMAGE_BL31
12
13
14
void __attribute__ ((section(".system_ram"))) cpg_write(uintptr_t regadr, uint32_t regval)
#else
void cpg_write(uintptr_t regadr, uint32_t regval)
15
16
#endif
{
17
18
	uint32_t value = regval;

19
20
21
22
23
	mmio_write_32((uintptr_t) RCAR_CPGWPR, ~value);
	mmio_write_32(regadr, value);
}

#if IMAGE_BL31
24
25
26
27
void __attribute__ ((section(".system_ram"))) mstpcr_write(uint32_t mstpcr, uint32_t mstpsr,
							   uint32_t target_bit)
#else
void mstpcr_write(uint32_t mstpcr, uint32_t mstpsr, uint32_t target_bit)
28
29
30
#endif
{
	uint32_t reg;
31

32
33
34
35
36
37
	reg = mmio_read_32(mstpcr);
	reg &= ~target_bit;
	cpg_write(mstpcr, reg);
	while ((mmio_read_32(mstpsr) & target_bit) != 0U) {
	}
}