Sanitise includes across codebase

Enforce full include path for includes. Deprecate old paths.

The following folders inside include/lib have been left unchanged:

- include/lib/cpus/${ARCH}
- include/lib/el3_runtime/${ARCH}

The reason for this change is that having a global namespace for
includes isn't a good idea. It defeats one of the advantages of having
folders and it introduces problems that are sometimes subtle (because
you may not know the header you are actually including if there are two
of them).

For example, this patch had to be created because two headers were
called the same way: e0ea0928d5b7 ("Fix gpio includes of mt8173 platform
to avoid collision."). More recently, this patch has had similar
problems: 46f9b2c3a282 ("drivers: add tzc380 support").

This problem was introduced in commit 4ecca33988b9 ("Move include and
source files to logical locations"). At that time, there weren't too
many headers so it wasn't a real issue. However, time has shown that
this creates problems.

Platforms that want to preserve the way they include headers may add the
removed paths to PLAT_INCLUDES, but this is discouraged.

Change-Id: I39dc53ed98f9e297a5966e723d1936d6ccf2fc8f
Signed-off-by: Antonio Nino Diaz <antonio.ninodiaz@arm.com>
diff --git a/plat/mediatek/common/custom/oem_svc.c b/plat/mediatek/common/custom/oem_svc.c
index 18bda51..27ee6aa 100644
--- a/plat/mediatek/common/custom/oem_svc.c
+++ b/plat/mediatek/common/custom/oem_svc.c
@@ -3,15 +3,18 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
+#include <assert.h>
+#include <stdint.h>
+
 #include <arch.h>
 #include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <plat/common/platform.h>
+#include <tools_share/uuid.h>
+
 #include <oem_svc.h>
-#include <platform.h>
-#include <runtime_svc.h>
-#include <stdint.h>
-#include <uuid.h>
 
 /* OEM Service UUID */
 DEFINE_SVC_UUID2(oem_svc_uid,
diff --git a/plat/mediatek/common/mtk_plat_common.c b/plat/mediatek/common/mtk_plat_common.c
index bff83c7..a07a298 100644
--- a/plat/mediatek/common/mtk_plat_common.c
+++ b/plat/mediatek/common/mtk_plat_common.c
@@ -3,17 +3,19 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
 #include <arch_helpers.h>
-#include <bl_common.h>
-#include <cci.h>
-#include <console.h>
-#include <debug.h>
-#include <mmio.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
+
 #include <mtk_plat_common.h>
 #include <mtk_sip_svc.h>
 #include <plat_private.h>
-#include <platform.h>
-#include <xlat_tables.h>
 
 struct atf_arg_t gteearg;
 
diff --git a/plat/mediatek/common/mtk_plat_common.h b/plat/mediatek/common/mtk_plat_common.h
index ff8e8c0..55f4c51 100644
--- a/plat/mediatek/common/mtk_plat_common.h
+++ b/plat/mediatek/common/mtk_plat_common.h
@@ -6,10 +6,11 @@
 #ifndef MTK_PLAT_COMMON_H
 #define MTK_PLAT_COMMON_H
 
-#include <bl_common.h>
-#include <param_header.h>
 #include <stdint.h>
 
+#include <common/bl_common.h>
+#include <common/param_header.h>
+
 /*******************************************************************************
  * Function and variable prototypes
  ******************************************************************************/
diff --git a/plat/mediatek/common/mtk_sip_svc.c b/plat/mediatek/common/mtk_sip_svc.c
index 71eddca..dab0d45 100644
--- a/plat/mediatek/common/mtk_sip_svc.c
+++ b/plat/mediatek/common/mtk_sip_svc.c
@@ -3,15 +3,18 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
 #include <assert.h>
-#include <console.h>
-#include <debug.h>
-#include <mmio.h>
+
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <tools_share/uuid.h>
+
 #include <mtk_plat_common.h>
 #include <mtk_sip_svc.h>
 #include <plat_sip_calls.h>
-#include <runtime_svc.h>
-#include <uuid.h>
 
 /* Mediatek SiP Service UUID */
 DEFINE_SVC_UUID2(mtk_sip_svc_uid,
diff --git a/plat/mediatek/mt6795/bl31.ld.S b/plat/mediatek/mt6795/bl31.ld.S
index 8f391df..6ec7a1a 100644
--- a/plat/mediatek/mt6795/bl31.ld.S
+++ b/plat/mediatek/mt6795/bl31.ld.S
@@ -4,8 +4,8 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
+#include <lib/xlat_tables/xlat_tables_defs.h>
 #include <platform_def.h>
-#include <xlat_tables_defs.h>
 
 OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
 OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
diff --git a/plat/mediatek/mt6795/bl31_plat_setup.c b/plat/mediatek/mt6795/bl31_plat_setup.c
index 8df7dad..2051fe7 100644
--- a/plat/mediatek/mt6795/bl31_plat_setup.c
+++ b/plat/mediatek/mt6795/bl31_plat_setup.c
@@ -3,25 +3,28 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
-#include <arch_helpers.h>
+
 #include <assert.h>
-#include <bl_common.h>
-#include <cci.h>
-#include <common_def.h>
-#include <console.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <generic_delay_timer.h>
+#include <string.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/console.h>
+#include <drivers/generic_delay_timer.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/common_def.h>
+#include <plat/common/platform.h>
+
 #include <mcucfg.h>
-#include <mmio.h>
 #include <mt_cpuxgpt.h>
 #include <mtk_plat_common.h>
 #include <mtk_sip_svc.h>
 #include <plat_private.h>
-#include <platform.h>
-#include <string.h>
-#include <utils_def.h>
-#include <xlat_tables.h>
 
 /*******************************************************************************
  * Declarations of linker defined symbols which will help us find the layout
diff --git a/plat/mediatek/mt6795/drivers/timer/mt_cpuxgpt.c b/plat/mediatek/mt6795/drivers/timer/mt_cpuxgpt.c
index b357972..3696f8e 100644
--- a/plat/mediatek/mt6795/drivers/timer/mt_cpuxgpt.c
+++ b/plat/mediatek/mt6795/drivers/timer/mt_cpuxgpt.c
@@ -4,13 +4,15 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
+#include <stdint.h>
 
 #include <arch_helpers.h>
-#include <debug.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
 #include <mt_cpuxgpt.h>
-#include <platform.h>
-#include <stdint.h>
+
 #define CPUXGPT_BASE	0x10200000
 #define INDEX_BASE		(CPUXGPT_BASE+0x0674)
 #define CTL_BASE		(CPUXGPT_BASE+0x0670)
diff --git a/plat/mediatek/mt6795/include/mcucfg.h b/plat/mediatek/mt6795/include/mcucfg.h
index 7f6a786..21c5394 100644
--- a/plat/mediatek/mt6795/include/mcucfg.h
+++ b/plat/mediatek/mt6795/include/mcucfg.h
@@ -7,9 +7,10 @@
 #ifndef MCUCFG_H
 #define MCUCFG_H
 
-#include <platform_def.h>
 #include <stdint.h>
 
+#include <platform_def.h>
+
 struct mt6795_mcucfg_regs {
 	uint32_t mp0_ca7l_cache_config;
 	struct {
diff --git a/plat/mediatek/mt6795/include/plat_macros.S b/plat/mediatek/mt6795/include/plat_macros.S
index 7485647..d198fdc 100644
--- a/plat/mediatek/mt6795/include/plat_macros.S
+++ b/plat/mediatek/mt6795/include/plat_macros.S
@@ -4,7 +4,7 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <cci.h>
+#include <drivers/arm/cci.h>
 #include <platform_def.h>
 
 .section .rodata.gic_reg_name, "aS"
diff --git a/plat/mediatek/mt6795/include/plat_private.h b/plat/mediatek/mt6795/include/plat_private.h
index 10baa23..f7450ca 100644
--- a/plat/mediatek/mt6795/include/plat_private.h
+++ b/plat/mediatek/mt6795/include/plat_private.h
@@ -8,7 +8,8 @@
 #define PLAT_PRIVATE_H
 
 #include <stdint.h>
-#include <xlat_tables.h>
+
+#include <lib/xlat_tables/xlat_tables.h>
 
 void plat_configure_mmu_el3(unsigned long total_base,
 					unsigned long total_size,
diff --git a/plat/mediatek/mt6795/include/platform_def.h b/plat/mediatek/mt6795/include/platform_def.h
index 0110e19..301610d 100644
--- a/plat/mediatek/mt6795/include/platform_def.h
+++ b/plat/mediatek/mt6795/include/platform_def.h
@@ -7,7 +7,7 @@
 #ifndef PLATFORM_DEF_H
 #define PLATFORM_DEF_H
 
-#include <utils_def.h>
+#include <lib/utils_def.h>
 
 #define PLAT_PRIMARY_CPU  0x0
 
diff --git a/plat/mediatek/mt6795/plat_delay_timer.c b/plat/mediatek/mt6795/plat_delay_timer.c
index 9df2867..965b653 100644
--- a/plat/mediatek/mt6795/plat_delay_timer.c
+++ b/plat/mediatek/mt6795/plat_delay_timer.c
@@ -4,10 +4,11 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <arch_helpers.h>
-#include <delay_timer.h>
 #include <platform_def.h>
 
+#include <arch_helpers.h>
+#include <drivers/delay_timer.h>
+
 static uint32_t plat_get_timer_value(void)
 {
 	/*
diff --git a/plat/mediatek/mt6795/plat_mt_gic.c b/plat/mediatek/mt6795/plat_mt_gic.c
index 11282fc..20cb26d 100644
--- a/plat/mediatek/mt6795/plat_mt_gic.c
+++ b/plat/mediatek/mt6795/plat_mt_gic.c
@@ -4,11 +4,12 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <gicv2.h>
-#include <interrupt_props.h>
-#include <platform.h>
 #include <platform_def.h>
 
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv2.h>
+#include <plat/common/platform.h>
+
 static const interrupt_prop_t g0_interrupt_props[] = {
 	INTR_PROP_DESC(FIQ_SMP_CALL_SGI, GIC_HIGHEST_SEC_PRIORITY,
 		       GICV2_INTR_GROUP0, GIC_INTR_CFG_LEVEL),
diff --git a/plat/mediatek/mt6795/plat_pm.c b/plat/mediatek/mt6795/plat_pm.c
index d050664..0dfbd18 100644
--- a/plat/mediatek/mt6795/plat_pm.c
+++ b/plat/mediatek/mt6795/plat_pm.c
@@ -4,19 +4,22 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <arch_helpers.h>
 #include <assert.h>
-#include <bakery_lock.h>
-#include <cci.h>
-#include <console.h>
-#include <debug.h>
 #include <errno.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/console.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+
 #include <mcucfg.h>
-#include <mmio.h>
 #include <plat_private.h>
-#include <platform_def.h>
 #include <power_tracer.h>
-#include <psci.h>
 #include <scu.h>
 
 struct core_context {
diff --git a/plat/mediatek/mt6795/plat_topology.c b/plat/mediatek/mt6795/plat_topology.c
index 0a0cf8d..7425d26 100644
--- a/plat/mediatek/mt6795/plat_topology.c
+++ b/plat/mediatek/mt6795/plat_topology.c
@@ -4,9 +4,10 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <arch.h>
 #include <platform_def.h>
-#include <psci.h>
+
+#include <arch.h>
+#include <lib/psci/psci.h>
 
 unsigned int plat_get_aff_count(unsigned int aff_lvl, unsigned long mpidr)
 {
diff --git a/plat/mediatek/mt6795/power_tracer.c b/plat/mediatek/mt6795/power_tracer.c
index 56e2240..64d086d 100644
--- a/plat/mediatek/mt6795/power_tracer.c
+++ b/plat/mediatek/mt6795/power_tracer.c
@@ -5,7 +5,8 @@
  */
 
 #include <arch.h>
-#include <debug.h>
+#include <common/debug.h>
+
 #include <power_tracer.h>
 
 #define trace_log(...)  INFO("psci: " __VA_ARGS__)
diff --git a/plat/mediatek/mt6795/scu.c b/plat/mediatek/mt6795/scu.c
index 9add19e..3b74527 100644
--- a/plat/mediatek/mt6795/scu.c
+++ b/plat/mediatek/mt6795/scu.c
@@ -5,8 +5,9 @@
  */
 
 #include <arch.h>
+#include <lib/mmio.h>
+
 #include <mcucfg.h>
-#include <mmio.h>
 
 void disable_scu(unsigned long mpidr)
 {
diff --git a/plat/mediatek/mt8173/aarch64/platform_common.c b/plat/mediatek/mt8173/aarch64/platform_common.c
index a761992..a2dbe3e 100644
--- a/plat/mediatek/mt8173/aarch64/platform_common.c
+++ b/plat/mediatek/mt8173/aarch64/platform_common.c
@@ -3,14 +3,17 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
+#include <platform_def.h>
+
 #include <arch_helpers.h>
-#include <bl_common.h>
-#include <cci.h>
-#include <debug.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables.h>
+
 #include <mt8173_def.h>
-#include <platform_def.h>
-#include <utils.h>
-#include <xlat_tables.h>
 
 static const int cci_map[] = {
 	PLAT_MT_CCI_CLUSTER0_SL_IFACE_IX,
diff --git a/plat/mediatek/mt8173/bl31_plat_setup.c b/plat/mediatek/mt8173/bl31_plat_setup.c
index c27de82..bd384a1 100644
--- a/plat/mediatek/mt8173/bl31_plat_setup.c
+++ b/plat/mediatek/mt8173/bl31_plat_setup.c
@@ -3,19 +3,22 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
 #include <assert.h>
-#include <bl_common.h>
-#include <common_def.h>
-#include <console.h>
-#include <debug.h>
-#include <generic_delay_timer.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <drivers/generic_delay_timer.h>
+#include <lib/mmio.h>
+#include <plat/common/common_def.h>
+#include <plat/common/platform.h>
+
 #include <mcucfg.h>
-#include <mmio.h>
 #include <mtcmos.h>
 #include <mtk_plat_common.h>
 #include <plat_arm.h>
 #include <plat_private.h>
-#include <platform.h>
 #include <spm.h>
 
 static entry_point_info_t bl32_ep_info;
diff --git a/plat/mediatek/mt8173/drivers/crypt/crypt.c b/plat/mediatek/mt8173/drivers/crypt/crypt.c
index 74d7702..bfb3082 100644
--- a/plat/mediatek/mt8173/drivers/crypt/crypt.c
+++ b/plat/mediatek/mt8173/drivers/crypt/crypt.c
@@ -3,12 +3,15 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
+#include <assert.h>
+
 #include <arch.h>
 #include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
 #include <mt8173_def.h>
 #include <mtk_sip_svc.h>
 
diff --git a/plat/mediatek/mt8173/drivers/mtcmos/mtcmos.c b/plat/mediatek/mt8173/drivers/mtcmos/mtcmos.c
index 25f2509..452ac22 100644
--- a/plat/mediatek/mt8173/drivers/mtcmos/mtcmos.c
+++ b/plat/mediatek/mt8173/drivers/mtcmos/mtcmos.c
@@ -4,9 +4,10 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <debug.h>
-#include <delay_timer.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
 #include <mt8173_def.h>
 #include <mtcmos.h>
 #include <spm.h>
diff --git a/plat/mediatek/mt8173/drivers/pmic/pmic_wrap_init.c b/plat/mediatek/mt8173/drivers/pmic/pmic_wrap_init.c
index c64fdf7..8120d99 100644
--- a/plat/mediatek/mt8173/drivers/pmic/pmic_wrap_init.c
+++ b/plat/mediatek/mt8173/drivers/pmic/pmic_wrap_init.c
@@ -3,9 +3,11 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
-#include <debug.h>
-#include <delay_timer.h>
-#include <mmio.h>
+
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
 #include <mt8173_def.h>
 #include <pmic_wrap_init.h>
 
diff --git a/plat/mediatek/mt8173/drivers/rtc/rtc.c b/plat/mediatek/mt8173/drivers/rtc/rtc.c
index 22fed9e..2b9033e 100644
--- a/plat/mediatek/mt8173/drivers/rtc/rtc.c
+++ b/plat/mediatek/mt8173/drivers/rtc/rtc.c
@@ -3,9 +3,12 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
 #include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
+
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+
 #include <mt8173_def.h>
 #include <pmic_wrap_init.h>
 #include <rtc.h>
diff --git a/plat/mediatek/mt8173/drivers/spm/spm.c b/plat/mediatek/mt8173/drivers/spm/spm.c
index eb40072..1caab3b 100644
--- a/plat/mediatek/mt8173/drivers/spm/spm.c
+++ b/plat/mediatek/mt8173/drivers/spm/spm.c
@@ -3,9 +3,11 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
-#include <bakery_lock.h>
-#include <debug.h>
-#include <mmio.h>
+
+#include <common/debug.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+
 #include <mt8173_def.h>
 #include <spm.h>
 #include <spm_suspend.h>
diff --git a/plat/mediatek/mt8173/drivers/spm/spm_hotplug.c b/plat/mediatek/mt8173/drivers/spm/spm_hotplug.c
index 6d275d0..b2b9ada 100644
--- a/plat/mediatek/mt8173/drivers/spm/spm_hotplug.c
+++ b/plat/mediatek/mt8173/drivers/spm/spm_hotplug.c
@@ -3,10 +3,12 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
 #include <arch.h>
-#include <mmio.h>
+#include <lib/mmio.h>
 #include <mt8173_def.h>
-#include <platform.h>
+#include <plat/common/platform.h>
+
 #include <spm.h>
 #include <spm_hotplug.h>
 #include <spm_mcdi.h>
diff --git a/plat/mediatek/mt8173/drivers/spm/spm_mcdi.c b/plat/mediatek/mt8173/drivers/spm/spm_mcdi.c
index de8d73a..ea5f2bb 100644
--- a/plat/mediatek/mt8173/drivers/spm/spm_mcdi.c
+++ b/plat/mediatek/mt8173/drivers/spm/spm_mcdi.c
@@ -3,12 +3,15 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
+#include <platform_def.h>
+
 #include <arch.h>
-#include <debug.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
 #include <mt8173_def.h>
-#include <platform.h>
-#include <platform_def.h>
 #include <spm.h>
 #include <spm_hotplug.h>
 #include <spm_mcdi.h>
diff --git a/plat/mediatek/mt8173/drivers/spm/spm_suspend.c b/plat/mediatek/mt8173/drivers/spm/spm_suspend.c
index 8c79b3b..5021695 100644
--- a/plat/mediatek/mt8173/drivers/spm/spm_suspend.c
+++ b/plat/mediatek/mt8173/drivers/spm/spm_suspend.c
@@ -3,10 +3,12 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
-#include <bakery_lock.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <mmio.h>
+
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+
 #include <mt8173_def.h>
 #include <spm.h>
 #include <spm_suspend.h>
diff --git a/plat/mediatek/mt8173/drivers/timer/mt_cpuxgpt.c b/plat/mediatek/mt8173/drivers/timer/mt_cpuxgpt.c
index 8a30d8a..174a24d 100644
--- a/plat/mediatek/mt8173/drivers/timer/mt_cpuxgpt.c
+++ b/plat/mediatek/mt8173/drivers/timer/mt_cpuxgpt.c
@@ -3,9 +3,11 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
 #include <arch_helpers.h>
+#include <lib/mmio.h>
+
 #include <mcucfg.h>
-#include <mmio.h>
 #include <mt8173_def.h>
 #include <mt_cpuxgpt.h>
 
diff --git a/plat/mediatek/mt8173/include/mcucfg.h b/plat/mediatek/mt8173/include/mcucfg.h
index 49d7c3e..dedbc08 100644
--- a/plat/mediatek/mt8173/include/mcucfg.h
+++ b/plat/mediatek/mt8173/include/mcucfg.h
@@ -6,9 +6,10 @@
 #ifndef MCUCFG_H
 #define MCUCFG_H
 
-#include <mt8173_def.h>
 #include <stdint.h>
 
+#include <mt8173_def.h>
+
 struct mt8173_mcucfg_regs {
 	uint32_t mp0_ca7l_cache_config;
 	struct {
diff --git a/plat/mediatek/mt8173/include/plat_macros.S b/plat/mediatek/mt8173/include/plat_macros.S
index 5eb4913..ac9fb16 100644
--- a/plat/mediatek/mt8173/include/plat_macros.S
+++ b/plat/mediatek/mt8173/include/plat_macros.S
@@ -4,9 +4,9 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <cci.h>
-#include <gic_common.h>
-#include <gicv2.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
 #include <mt8173_def.h>
 
 .section .rodata.gic_reg_name, "aS"
diff --git a/plat/mediatek/mt8173/include/platform_def.h b/plat/mediatek/mt8173/include/platform_def.h
index 9bbed3c..205e263 100644
--- a/plat/mediatek/mt8173/include/platform_def.h
+++ b/plat/mediatek/mt8173/include/platform_def.h
@@ -7,9 +7,10 @@
 #ifndef PLATFORM_DEF_H
 #define PLATFORM_DEF_H
 
-#include <gic_common.h>
-#include <interrupt_props.h>
-#include <utils_def.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gic_common.h>
+#include <lib/utils_def.h>
+
 #include "mt8173_def.h"
 
 /*******************************************************************************
diff --git a/plat/mediatek/mt8173/plat_mt_gic.c b/plat/mediatek/mt8173/plat_mt_gic.c
index 16e36af..80b9010 100644
--- a/plat/mediatek/mt8173/plat_mt_gic.c
+++ b/plat/mediatek/mt8173/plat_mt_gic.c
@@ -4,9 +4,10 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <lib/utils.h>
+
 #include <mt8173_def.h>
-#include <utils.h>
 
 const unsigned int mt_irq_sec_array[] = {
 	MT_IRQ_SEC_SGI_0,
diff --git a/plat/mediatek/mt8173/plat_pm.c b/plat/mediatek/mt8173/plat_pm.c
index b19d3f3..9673d2c 100644
--- a/plat/mediatek/mt8173/plat_pm.c
+++ b/plat/mediatek/mt8173/plat_pm.c
@@ -4,22 +4,24 @@
  * SPDX-License-Identifier: BSD-3-Clause
  */
 
-#include <arch_helpers.h>
 #include <assert.h>
-#include <bakery_lock.h>
-#include <cci.h>
-#include <console.h>
-#include <debug.h>
 #include <errno.h>
-#include <gicv2.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/console.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+
 #include <mcucfg.h>
-#include <mmio.h>
 #include <mt8173_def.h>
 #include <mt_cpuxgpt.h> /* generic_timer_backup() */
 #include <plat_arm.h>
 #include <plat_private.h>
 #include <power_tracer.h>
-#include <psci.h>
 #include <rtc.h>
 #include <scu.h>
 #include <spm_hotplug.h>
diff --git a/plat/mediatek/mt8173/plat_sip_calls.c b/plat/mediatek/mt8173/plat_sip_calls.c
index 1d51cb5..102feb2 100644
--- a/plat/mediatek/mt8173/plat_sip_calls.c
+++ b/plat/mediatek/mt8173/plat_sip_calls.c
@@ -3,13 +3,15 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
+
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/mmio.h>
+
 #include <crypt.h>
-#include <debug.h>
-#include <mmio.h>
 #include <mtcmos.h>
 #include <mtk_sip_svc.h>
 #include <plat_sip_calls.h>
-#include <runtime_svc.h>
 
 /* Authorized secure register list */
 enum {
diff --git a/plat/mediatek/mt8173/plat_topology.c b/plat/mediatek/mt8173/plat_topology.c
index d70fea5..23e7d2d 100644
--- a/plat/mediatek/mt8173/plat_topology.c
+++ b/plat/mediatek/mt8173/plat_topology.c
@@ -3,10 +3,11 @@
  *
  * SPDX-License-Identifier: BSD-3-Clause
  */
-#include <arch.h>
+
 #include <platform_def.h>
-#include <psci.h>
 
+#include <arch.h>
+#include <lib/psci/psci.h>
 
 const unsigned char mtk_power_domain_tree_desc[] = {
 	/* No of root nodes */
diff --git a/plat/mediatek/mt8173/power_tracer.c b/plat/mediatek/mt8173/power_tracer.c
index 787dad1..d1fcf9f 100644
--- a/plat/mediatek/mt8173/power_tracer.c
+++ b/plat/mediatek/mt8173/power_tracer.c
@@ -5,7 +5,8 @@
  */
 
 #include <arch.h>
-#include <debug.h>
+#include <common/debug.h>
+
 #include <power_tracer.h>
 
 #define trace_log(...)  INFO("psci: " __VA_ARGS__)
diff --git a/plat/mediatek/mt8173/scu.c b/plat/mediatek/mt8173/scu.c
index 4daa9e5..2524d72 100644
--- a/plat/mediatek/mt8173/scu.c
+++ b/plat/mediatek/mt8173/scu.c
@@ -5,8 +5,9 @@
  */
 
 #include <arch.h>
+#include <lib/mmio.h>
+
 #include <mcucfg.h>
-#include <mmio.h>
 
 void disable_scu(unsigned long mpidr)
 {