summaryrefslogtreecommitdiff
path: root/drivers/renesas/rcar/rpc/rpc_driver.c
blob: bea27521013f2e8cf381b3e290356f6b29a5edb0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */

#include <stdint.h>
#include <string.h>

#include <common/debug.h>
#include <lib/mmio.h>

#include "cpg_registers.h"
#include "rpc_registers.h"
#include "rcar_private.h"

#define MSTPSR9_RPC_BIT		(0x00020000U)
#define RPC_CMNCR_MD_BIT	(0x80000000U)

static void rpc_enable(void)
{
	/* Enable clock supply to RPC. */
	mstpcr_write(CPG_SMSTPCR9, CPG_MSTPSR9, MSTPSR9_RPC_BIT);
}

static void rpc_setup(void)
{
	if (mmio_read_32(RPC_CMNCR) & RPC_CMNCR_MD_BIT)
		mmio_clrbits_32(RPC_CMNCR, RPC_CMNCR_MD_BIT);
}

void rcar_rpc_init(void)
{
	rpc_enable();
	rpc_setup();
}