2018-09-23 08:41:39 +01:00
|
|
|
/*
|
2019-05-20 03:23:48 +01:00
|
|
|
* Copyright (c) 2015-2019, Renesas Electronics Corporation. All rights reserved.
|
2018-09-23 08:41:39 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
2018-12-14 00:18:21 +00:00
|
|
|
|
|
|
|
#include <common/debug.h>
|
|
|
|
#include <lib/mmio.h>
|
|
|
|
|
2018-09-23 08:41:39 +01:00
|
|
|
#include "cpg_registers.h"
|
2019-05-20 03:23:48 +01:00
|
|
|
#include "rcar_def.h"
|
2018-09-23 08:41:39 +01:00
|
|
|
#include "rcar_private.h"
|
2019-05-20 03:23:48 +01:00
|
|
|
#include "rpc_registers.h"
|
2018-09-23 08:41:39 +01:00
|
|
|
|
|
|
|
#define MSTPSR9_RPC_BIT (0x00020000U)
|
|
|
|
#define RPC_CMNCR_MD_BIT (0x80000000U)
|
2019-05-20 03:23:48 +01:00
|
|
|
#define RPC_PHYCNT_CAL BIT(31)
|
|
|
|
#define RPC_PHYCNT_STRTIM_M3V1 (0x6 << 15UL)
|
|
|
|
#define RPC_PHYCNT_STRTIM (0x7 << 15UL)
|
2018-09-23 08:41:39 +01:00
|
|
|
|
|
|
|
static void rpc_enable(void)
|
|
|
|
{
|
|
|
|
/* Enable clock supply to RPC. */
|
|
|
|
mstpcr_write(CPG_SMSTPCR9, CPG_MSTPSR9, MSTPSR9_RPC_BIT);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void rpc_setup(void)
|
|
|
|
{
|
2019-05-20 03:23:48 +01:00
|
|
|
uint32_t product, cut, reg, phy_strtim;
|
|
|
|
|
2018-09-23 08:41:39 +01:00
|
|
|
if (mmio_read_32(RPC_CMNCR) & RPC_CMNCR_MD_BIT)
|
|
|
|
mmio_clrbits_32(RPC_CMNCR, RPC_CMNCR_MD_BIT);
|
2019-05-20 03:23:48 +01:00
|
|
|
|
2019-08-06 18:13:22 +01:00
|
|
|
product = mmio_read_32(RCAR_PRR) & PRR_PRODUCT_MASK;
|
|
|
|
cut = mmio_read_32(RCAR_PRR) & PRR_CUT_MASK;
|
2019-05-20 03:23:48 +01:00
|
|
|
|
2019-08-06 18:13:22 +01:00
|
|
|
if ((product == PRR_PRODUCT_M3) && (cut < PRR_PRODUCT_30))
|
2019-05-20 03:23:48 +01:00
|
|
|
phy_strtim = RPC_PHYCNT_STRTIM_M3V1;
|
|
|
|
else
|
|
|
|
phy_strtim = RPC_PHYCNT_STRTIM;
|
|
|
|
|
|
|
|
reg = mmio_read_32(RPC_PHYCNT);
|
|
|
|
reg &= ~RPC_PHYCNT_STRTIM;
|
|
|
|
reg |= phy_strtim;
|
|
|
|
mmio_write_32(RPC_PHYCNT, reg);
|
|
|
|
reg |= RPC_PHYCNT_CAL;
|
|
|
|
mmio_write_32(RPC_PHYCNT, reg);
|
2018-09-23 08:41:39 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void rcar_rpc_init(void)
|
|
|
|
{
|
|
|
|
rpc_enable();
|
|
|
|
rpc_setup();
|
|
|
|
}
|