drivers: renesas: Move plat common sources

Move plat common sources to common directory, so that same
code can be re-used by both R-Car Gen3 and RZ/G2 platforms.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Change-Id: Id2b1822c97cc50e3febaffc2e5f42b4d53809a17
diff --git a/plat/renesas/rcar/platform.mk b/plat/renesas/rcar/platform.mk
index bdc29fe..8613f5e 100644
--- a/plat/renesas/rcar/platform.mk
+++ b/plat/renesas/rcar/platform.mk
@@ -300,9 +300,9 @@
 
 PLAT_INCLUDES	+=	-Idrivers/renesas/rcar/ddr		\
 			-Idrivers/renesas/rcar/qos		\
-			-Idrivers/renesas/rcar/iic_dvfs		\
 			-Idrivers/renesas/rcar/board		\
 			-Idrivers/renesas/rcar/cpld/		\
+			-Idrivers/renesas/common/iic_dvfs	\
 			-Idrivers/renesas/rcar/avs		\
 			-Idrivers/renesas/rcar/delay		\
 			-Idrivers/renesas/rcar/rom		\
@@ -311,9 +311,6 @@
 			-Idrivers/renesas/rcar/pwrc		\
 			-Idrivers/renesas/rcar/io
 
-PLAT_BL_COMMON_SOURCES	:=	drivers/renesas/rcar/iic_dvfs/iic_dvfs.c \
-				plat/renesas/rcar/rcar_common.c
-
 BL2_SOURCES	+=	plat/renesas/rcar/aarch64/platform_common.c	\
 			plat/renesas/rcar/aarch64/plat_helpers.S	\
 			plat/renesas/rcar/bl2_interrupt_error.c		\
@@ -358,10 +355,6 @@
 BL31_SOURCES		+=	drivers/renesas/rcar/cpld/ulcb_cpld.c
 endif
 
-include lib/xlat_tables_v2/xlat_tables.mk
-include drivers/auth/mbedtls/mbedtls_crypto.mk
-PLAT_BL_COMMON_SOURCES	+=	${XLAT_TABLES_LIB_SRCS}
-
 # build the layout images for the bootrom and the necessary srecords
 rcar: rcar_layout_tool rcar_srecord
 distclean realclean clean: clean_layout_tool clean_srecord
diff --git a/plat/renesas/rcar/rcar_common.c b/plat/renesas/rcar/rcar_common.c
deleted file mode 100644
index dec7229..0000000
--- a/plat/renesas/rcar/rcar_common.c
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2019, Renesas Electronics Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <assert.h>
-
-#include <arch_helpers.h>
-#include <drivers/console.h>
-#include <lib/xlat_tables/xlat_mmu_helpers.h>
-#include <plat/common/platform.h>
-
-#include <lib/mmio.h>
-
-#define CPG_BASE		0xE6150000
-#define CPG_MSTPSR3		0x0048
-#define MSTP318			(1 << 18)
-#define MSTP319			(1 << 19)
-#define PMSR			0x5c
-#define PMSR_L1FAEG		(1U << 31)
-#define PMSR_PMEL1RX		(1 << 23)
-#define PMCTLR			0x60
-#define PMSR_L1IATN		(1U << 31)
-
-static int rcar_pcie_fixup(unsigned int controller)
-{
-	uint32_t rcar_pcie_base[] = { 0xfe011000, 0xee811000 };
-	uint32_t addr = rcar_pcie_base[controller];
-	uint32_t cpg, pmsr;
-	int ret = 0;
-
-	/* Test if PCIECx is enabled */
-	cpg = mmio_read_32(CPG_BASE + CPG_MSTPSR3);
-	if (cpg & (MSTP318 << !controller))
-		return ret;
-
-	pmsr = mmio_read_32(addr + PMSR);
-
-	if ((pmsr & PMSR_PMEL1RX) && ((pmsr & 0x70000) != 0x30000)) {
-		/* Fix applicable */
-		mmio_write_32(addr + PMCTLR, PMSR_L1IATN);
-		while (!(mmio_read_32(addr + PMSR) & PMSR_L1FAEG))
-			;
-		mmio_write_32(addr + PMSR, PMSR_L1FAEG | PMSR_PMEL1RX);
-		ret = 1;
-	}
-
-	return ret;
-}
-
-/* RAS functions common to AArch64 ARM platforms */
-void plat_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *cookie,
-		void *handle, uint64_t flags)
-{
-	unsigned int fixed = 0;
-
-	fixed |= rcar_pcie_fixup(0);
-	fixed |= rcar_pcie_fixup(1);
-
-	if (fixed)
-		return;
-
-	ERROR("Unhandled External Abort received on 0x%lx at EL3!\n",
-			read_mpidr_el1());
-	ERROR(" exception reason=%u syndrome=0x%llx\n", ea_reason, syndrome);
-
-	panic();
-}
-
-#include <drivers/renesas/rcar/console/console.h>
-
-static console_t rcar_boot_console;
-static console_t rcar_runtime_console;
-
-void rcar_console_boot_init(void)
-{
-	int ret;
-
-	ret = console_rcar_register(0, 0, 0, &rcar_boot_console);
-	if (!ret)
-		panic();
-
-	console_set_scope(&rcar_boot_console, CONSOLE_FLAG_BOOT);
-}
-
-void rcar_console_boot_end(void)
-{
-}
-
-void rcar_console_runtime_init(void)
-{
-	int ret;
-
-	ret = console_rcar_register(1, 0, 0, &rcar_runtime_console);
-	if (!ret)
-		panic();
-
-	console_set_scope(&rcar_boot_console, CONSOLE_FLAG_RUNTIME);
-}
-
-void rcar_console_runtime_end(void)
-{
-}