blob: bea27521013f2e8cf381b3e290356f6b29a5edb0 [file] [log] [blame]
Jorge Ramirez-Ortizd26a7222018-09-23 09:41:39 +02001/*
2 * Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
Jorge Ramirez-Ortizd26a7222018-09-23 09:41:39 +02007#include <stdint.h>
8#include <string.h>
Antonio Nino Diaze0f90632018-12-14 00:18:21 +00009
10#include <common/debug.h>
11#include <lib/mmio.h>
12
Jorge Ramirez-Ortizd26a7222018-09-23 09:41:39 +020013#include "cpg_registers.h"
14#include "rpc_registers.h"
Jorge Ramirez-Ortizd26a7222018-09-23 09:41:39 +020015#include "rcar_private.h"
16
17#define MSTPSR9_RPC_BIT (0x00020000U)
18#define RPC_CMNCR_MD_BIT (0x80000000U)
19
20static void rpc_enable(void)
21{
22 /* Enable clock supply to RPC. */
23 mstpcr_write(CPG_SMSTPCR9, CPG_MSTPSR9, MSTPSR9_RPC_BIT);
24}
25
26static void rpc_setup(void)
27{
28 if (mmio_read_32(RPC_CMNCR) & RPC_CMNCR_MD_BIT)
29 mmio_clrbits_32(RPC_CMNCR, RPC_CMNCR_MD_BIT);
30}
31
32void rcar_rpc_init(void)
33{
34 rpc_enable();
35 rpc_setup();
36}