Merge pull request #1724 from jbech-linaro/emmc_enumeration
mmc: increase delay when initializing mmc
diff --git a/.checkpatch.conf b/.checkpatch.conf
index 63bdf7b..50ab716 100644
--- a/.checkpatch.conf
+++ b/.checkpatch.conf
@@ -1,31 +1,7 @@
#
# Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved.
#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are met:
-#
-# Redistributions of source code must retain the above copyright notice, this
-# list of conditions and the following disclaimer.
-#
-# Redistributions in binary form must reproduce the above copyright notice,
-# this list of conditions and the following disclaimer in the documentation
-# and/or other materials provided with the distribution.
-#
-# Neither the name of ARM nor the names of its contributors may be used
-# to endorse or promote products derived from this software without specific
-# prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-# POSSIBILITY OF SUCH DAMAGE.
+# SPDX-License-Identifier: BSD-3-Clause
#
#
diff --git a/.gitignore b/.gitignore
index 562f812..341308c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,10 +21,12 @@
tools/cert_create/src/**/*.o
tools/cert_create/cert_create
tools/cert_create/cert_create.exe
-tools/doimage/doimage
+tools/marvell/doimage/doimage
tools/stm32image/*.o
tools/stm32image/stm32image
tools/stm32image/stm32image.exe
+tools/sptool/sptool
+tools/sptool/sptool.exe
# GNU GLOBAL files
GPATH
diff --git a/Makefile b/Makefile
index 2d01648..3de7b3f 100644
--- a/Makefile
+++ b/Makefile
@@ -26,10 +26,6 @@
# Default values for build configurations, and their dependencies
################################################################################
-ifdef ASM_ASSERTION
- $(warning ASM_ASSERTION is removed, use ENABLE_ASSERTIONS instead.)
-endif
-
include ${MAKE_HELPERS_DIRECTORY}defaults.mk
# Assertions enabled for DEBUG builds by default
@@ -154,7 +150,7 @@
march32-directive = -march=armv8-a
endif
-ifeq ($(notdir $(CC)),armclang)
+ifneq ($(findstring armclang,$(notdir $(CC))),)
TF_CFLAGS_aarch32 = -target arm-arm-none-eabi $(march32-directive)
TF_CFLAGS_aarch64 = -target aarch64-arm-none-eabi -march=armv8-a
LD = $(LINKER)
@@ -162,7 +158,7 @@
CPP = $(CC) -E $(TF_CFLAGS_$(ARCH))
PP = $(CC) -E $(TF_CFLAGS_$(ARCH))
else ifneq ($(findstring clang,$(notdir $(CC))),)
-TF_CFLAGS_aarch32 = $(target32-directive)
+TF_CFLAGS_aarch32 = $(target32-directive) $(march32-directive)
TF_CFLAGS_aarch64 = -target aarch64-elf
LD = $(LINKER)
AS = $(CC) -c -x assembler-with-cpp $(TF_CFLAGS_$(ARCH))
@@ -188,8 +184,50 @@
ASFLAGS_aarch32 = $(march32-directive)
ASFLAGS_aarch64 = -march=armv8-a
+WARNING1 := -Wextra
+WARNING1 += -Wunused -Wno-unused-parameter
+WARNING1 += -Wmissing-declarations
+WARNING1 += -Wmissing-format-attribute
+WARNING1 += -Wmissing-prototypes
+WARNING1 += -Wold-style-definition
+WARNING1 += -Wunused-but-set-variable
+WARNING1 += -Wunused-const-variable
+
+WARNING2 := -Waggregate-return
+WARNING2 += -Wcast-align
+WARNING2 += -Wdisabled-optimization
+WARNING2 += -Wnested-externs
+WARNING2 += -Wshadow
+WARNING2 += -Wlogical-op
+WARNING2 += -Wmissing-field-initializers
+WARNING2 += -Wsign-compare
+WARNING2 += -Wmaybe-uninitialized
+
+WARNING3 := -Wbad-function-cast
+WARNING3 += -Wcast-qual
+WARNING3 += -Wconversion
+WARNING3 += -Wpacked
+WARNING3 += -Wpadded
+WARNING3 += -Wpointer-arith
+WARNING3 += -Wredundant-decls
+WARNING3 += -Wswitch-default
+WARNING3 += -Wpacked-bitfield-compat
+WARNING3 += -Wvla
+
+ifeq (${W},1)
+WARNINGS := $(WARNING1)
+else ifeq (${W},2)
+WARNINGS := $(WARNING1) $(WARNING2)
+else ifeq (${W},3)
+WARNINGS := $(WARNING1) $(WARNING2) $(WARNING3)
+endif
+
+ifneq (${E},0)
+ERRORS := -Werror
+endif
+
CPPFLAGS = ${DEFINES} ${INCLUDES} ${MBEDTLS_INC} -nostdinc \
- -Wmissing-include-dirs -Werror
+ -Wmissing-include-dirs $(ERRORS) $(WARNINGS)
ASFLAGS += $(CPPFLAGS) $(ASFLAGS_$(ARCH)) \
-D__ASSEMBLY__ -ffreestanding \
-Wa,--fatal-warnings
@@ -228,32 +266,33 @@
endif
INCLUDES += -Iinclude \
- -Iinclude/bl1 \
+ -Iinclude/arch/${ARCH} \
+ -Iinclude/lib/cpus/${ARCH} \
+ -Iinclude/lib/el3_runtime/${ARCH} \
+ ${PLAT_INCLUDES} \
+ ${SPD_INCLUDES}
+
+ifeq (${ERROR_DEPRECATED},0)
+INCLUDES += -Iinclude/bl1 \
-Iinclude/bl2 \
-Iinclude/bl2u \
-Iinclude/bl31 \
- -Iinclude/common \
- -Iinclude/common/${ARCH} \
-Iinclude/drivers \
-Iinclude/drivers/arm \
-Iinclude/drivers/auth \
-Iinclude/drivers/io \
-Iinclude/drivers/ti/uart \
-Iinclude/lib \
- -Iinclude/lib/${ARCH} \
-Iinclude/lib/cpus \
- -Iinclude/lib/cpus/${ARCH} \
-Iinclude/lib/el3_runtime \
- -Iinclude/lib/el3_runtime/${ARCH} \
-Iinclude/lib/extensions \
-Iinclude/lib/pmf \
-Iinclude/lib/psci \
-Iinclude/lib/xlat_tables \
-Iinclude/plat/common \
-Iinclude/services \
- ${PLAT_INCLUDES} \
- ${SPD_INCLUDES} \
-Iinclude/tools_share
+endif
include common/backtrace/backtrace.mk
@@ -838,7 +877,7 @@
.PHONY: libraries
romlib.bin: libraries
- ${Q}${MAKE} BUILD_PLAT=${BUILD_PLAT} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all
+ ${Q}${MAKE} PLAT_DIR=${PLAT_DIR} BUILD_PLAT=${BUILD_PLAT} INCLUDES='${INCLUDES}' DEFINES='${DEFINES}' --no-print-directory -C ${ROMLIBPATH} all
cscope:
@echo " CSCOPE"
diff --git a/bl1/aarch32/bl1_context_mgmt.c b/bl1/aarch32/bl1_context_mgmt.c
index d1fd3ca..005d046 100644
--- a/bl1/aarch32/bl1_context_mgmt.c
+++ b/bl1/aarch32/bl1_context_mgmt.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
+
+#include <arch_helpers.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <platform.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <plat/common/platform.h>
#include <smccc_helpers.h>
+
#include "../bl1_private.h"
/*
diff --git a/bl1/aarch32/bl1_entrypoint.S b/bl1/aarch32/bl1_entrypoint.S
index 16b26b9..3f0cbaf 100644
--- a/bl1/aarch32/bl1_entrypoint.S
+++ b/bl1/aarch32/bl1_entrypoint.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <context.h>
#include <el3_common_macros.S>
#include <smccc_helpers.h>
diff --git a/bl1/aarch32/bl1_exceptions.S b/bl1/aarch32/bl1_exceptions.S
index 9b001a9..6728278 100644
--- a/bl1/aarch32/bl1_exceptions.S
+++ b/bl1/aarch32/bl1_exceptions.S
@@ -6,12 +6,12 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl1.h>
-#include <bl_common.h>
+#include <bl1/bl1.h>
+#include <common/bl_common.h>
#include <context.h>
+#include <lib/xlat_tables/xlat_tables.h>
#include <smccc_helpers.h>
#include <smccc_macros.S>
-#include <xlat_tables.h>
.globl bl1_aarch32_smc_handler
diff --git a/bl1/aarch64/bl1_context_mgmt.c b/bl1/aarch64/bl1_context_mgmt.c
index 9bfb309..0326319 100644
--- a/bl1/aarch64/bl1_context_mgmt.c
+++ b/bl1/aarch64/bl1_context_mgmt.c
@@ -4,12 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
+
+#include <arch_helpers.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <platform.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <plat/common/platform.h>
+
#include "../bl1_private.h"
/*
diff --git a/bl1/aarch64/bl1_exceptions.S b/bl1/aarch64/bl1_exceptions.S
index cf8a6a7..19a0ac2 100644
--- a/bl1/aarch64/bl1_exceptions.S
+++ b/bl1/aarch64/bl1_exceptions.S
@@ -6,8 +6,8 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl1.h>
-#include <bl_common.h>
+#include <bl1/bl1.h>
+#include <common/bl_common.h>
#include <context.h>
/* -----------------------------------------------------------------------------
diff --git a/bl1/bl1.ld.S b/bl1/bl1.ld.S
index fabe3ef..c4f6b99 100644
--- a/bl1/bl1.ld.S
+++ b/bl1/bl1.ld.S
@@ -5,7 +5,8 @@
*/
#include <platform_def.h>
-#include <xlat_tables_defs.h>
+
+#include <lib/xlat_tables/xlat_tables_defs.h>
OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
diff --git a/bl1/bl1_fwu.c b/bl1/bl1_fwu.c
index 0fbdf51..57a86ae 100644
--- a/bl1/bl1_fwu.c
+++ b/bl1/bl1_fwu.c
@@ -4,20 +4,23 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <auth_mod.h>
-#include <bl1.h>
-#include <bl_common.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
#include <errno.h>
-#include <platform.h>
-#include <platform_def.h>
-#include <smccc_helpers.h>
#include <string.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <bl1/bl1.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <context.h>
+#include <drivers/auth/auth_mod.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+#include <smccc_helpers.h>
+
#include "bl1_private.h"
/*
diff --git a/bl1/bl1_main.c b/bl1/bl1_main.c
index ca43695..d2c2b41 100644
--- a/bl1/bl1_main.c
+++ b/bl1/bl1_main.c
@@ -4,20 +4,23 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <auth_mod.h>
-#include <bl1.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <errata_report.h>
-#include <platform.h>
-#include <platform_def.h>
+#include <bl1/bl1.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/auth/auth_mod.h>
+#include <drivers/console.h>
+#include <lib/cpus/errata_report.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
#include <smccc_helpers.h>
-#include <utils.h>
-#include <uuid.h>
+#include <tools_share/uuid.h>
+
#include "bl1_private.h"
/* BL1 Service UUID */
diff --git a/bl1/bl1_private.h b/bl1/bl1_private.h
index ed81585..bdbf80f 100644
--- a/bl1/bl1_private.h
+++ b/bl1/bl1_private.h
@@ -8,7 +8,8 @@
#define BL1_PRIVATE_H
#include <stdint.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/*******************************************************************************
* Declarations of linker defined symbols which will tell us where BL1 lives
diff --git a/bl1/tbbr/tbbr_img_desc.c b/bl1/tbbr/tbbr_img_desc.c
index 2581d90..e8df73d 100644
--- a/bl1/tbbr/tbbr_img_desc.c
+++ b/bl1/tbbr/tbbr_img_desc.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl1.h>
-#include <bl_common.h>
#include <platform_def.h>
-#include <tbbr/tbbr_img_desc.h>
+
+#include <bl1/bl1.h>
+#include <bl1/tbbr/tbbr_img_desc.h>
+#include <common/bl_common.h>
image_desc_t bl1_tbbr_image_descs[] = {
{
diff --git a/bl2/aarch32/bl2_arch_setup.c b/bl2/aarch32/bl2_arch_setup.c
index db8a068..4fd8d07 100644
--- a/bl2/aarch32/bl2_arch_setup.c
+++ b/bl2/aarch32/bl2_arch_setup.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include "../bl2_private.h"
/*******************************************************************************
* Place holder function to perform any Secure SVC specific architectural
diff --git a/bl2/aarch32/bl2_el3_entrypoint.S b/bl2/aarch32/bl2_el3_entrypoint.S
index 0c7b064..cc846dd 100644
--- a/bl2/aarch32/bl2_el3_entrypoint.S
+++ b/bl2/aarch32/bl2_el3_entrypoint.S
@@ -6,10 +6,9 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <el3_common_macros.S>
-
.globl bl2_entrypoint
.globl bl2_run_next_image
diff --git a/bl2/aarch32/bl2_el3_exceptions.S b/bl2/aarch32/bl2_el3_exceptions.S
index 11ddf37..087b665 100644
--- a/bl2/aarch32/bl2_el3_exceptions.S
+++ b/bl2/aarch32/bl2_el3_exceptions.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
.globl bl2_vector_table
diff --git a/bl2/aarch32/bl2_entrypoint.S b/bl2/aarch32/bl2_entrypoint.S
index d215f48..e7b98af 100644
--- a/bl2/aarch32/bl2_entrypoint.S
+++ b/bl2/aarch32/bl2_entrypoint.S
@@ -6,8 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
-
+#include <common/bl_common.h>
.globl bl2_vector_table
.globl bl2_entrypoint
diff --git a/bl2/aarch64/bl2_el3_entrypoint.S b/bl2/aarch64/bl2_el3_entrypoint.S
index 2d3efd1..16b7c0d 100644
--- a/bl2/aarch64/bl2_el3_entrypoint.S
+++ b/bl2/aarch64/bl2_el3_entrypoint.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <el3_common_macros.S>
.globl bl2_entrypoint
diff --git a/bl2/aarch64/bl2_el3_exceptions.S b/bl2/aarch64/bl2_el3_exceptions.S
index 07d1040..3d58051 100644
--- a/bl2/aarch64/bl2_el3_exceptions.S
+++ b/bl2/aarch64/bl2_el3_exceptions.S
@@ -6,8 +6,8 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl1.h>
-#include <bl_common.h>
+#include <bl1/bl1.h>
+#include <common/bl_common.h>
#include <context.h>
/* -----------------------------------------------------------------------------
diff --git a/bl2/aarch64/bl2_entrypoint.S b/bl2/aarch64/bl2_entrypoint.S
index 30a5c59..d938947 100644
--- a/bl2/aarch64/bl2_entrypoint.S
+++ b/bl2/aarch64/bl2_entrypoint.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
.globl bl2_entrypoint
diff --git a/bl2/bl2.ld.S b/bl2/bl2.ld.S
index 6d26cdb..30cdf7d 100644
--- a/bl2/bl2.ld.S
+++ b/bl2/bl2.ld.S
@@ -5,7 +5,8 @@
*/
#include <platform_def.h>
-#include <xlat_tables_defs.h>
+
+#include <lib/xlat_tables/xlat_tables_defs.h>
OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
diff --git a/bl2/bl2_el3.ld.S b/bl2/bl2_el3.ld.S
index 82ab427..af93a0c 100644
--- a/bl2/bl2_el3.ld.S
+++ b/bl2/bl2_el3.ld.S
@@ -5,7 +5,8 @@
*/
#include <platform_def.h>
-#include <xlat_tables_defs.h>
+
+#include <lib/xlat_tables/xlat_tables_defs.h>
OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
diff --git a/bl2/bl2_image_load_v2.c b/bl2/bl2_image_load_v2.c
index 0f40785..dd53e1d 100644
--- a/bl2/bl2_image_load_v2.c
+++ b/bl2/bl2_image_load_v2.c
@@ -4,18 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <stdint.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <auth_mod.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <desc_image_load.h>
-#include <platform.h>
-#include <platform_def.h>
-#include <stdint.h>
-#include "bl2_private.h"
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <drivers/auth/auth_mod.h>
+#include <plat/common/platform.h>
+#include "bl2_private.h"
/*******************************************************************************
* This function loads SCP_BL2/BL3x images and returns the ep_info for
diff --git a/bl2/bl2_main.c b/bl2/bl2_main.c
index 101eb33..019088d 100644
--- a/bl2/bl2_main.c
+++ b/bl2/bl2_main.c
@@ -5,13 +5,14 @@
*/
#include <arch_helpers.h>
-#include <auth_mod.h>
-#include <bl1.h>
-#include <bl2.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <platform.h>
+#include <bl1/bl1.h>
+#include <bl2/bl2.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/auth/auth_mod.h>
+#include <drivers/console.h>
+#include <plat/common/platform.h>
+
#include "bl2_private.h"
#ifdef AARCH32
diff --git a/bl2/bl2_private.h b/bl2/bl2_private.h
index 7fd17bf..01f6c6b 100644
--- a/bl2/bl2_private.h
+++ b/bl2/bl2_private.h
@@ -8,6 +8,9 @@
#define BL2_PRIVATE_H
#if BL2_IN_XIP_MEM
+
+#include <stdint.h>
+
/*******************************************************************************
* Declarations of linker defined symbols which will tell us where BL2 lives
* in Trusted ROM and RAM
diff --git a/bl2u/aarch32/bl2u_entrypoint.S b/bl2u/aarch32/bl2u_entrypoint.S
index 7fb64f3..67566df 100644
--- a/bl2u/aarch32/bl2u_entrypoint.S
+++ b/bl2u/aarch32/bl2u_entrypoint.S
@@ -6,8 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
-
+#include <common/bl_common.h>
.globl bl2u_vector_table
.globl bl2u_entrypoint
diff --git a/bl2u/aarch64/bl2u_entrypoint.S b/bl2u/aarch64/bl2u_entrypoint.S
index 8b9c2a6..591f5f6 100644
--- a/bl2u/aarch64/bl2u_entrypoint.S
+++ b/bl2u/aarch64/bl2u_entrypoint.S
@@ -6,8 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
-
+#include <common/bl_common.h>
.globl bl2u_entrypoint
diff --git a/bl2u/bl2u.ld.S b/bl2u/bl2u.ld.S
index 3db5f89..8d4984f 100644
--- a/bl2u/bl2u.ld.S
+++ b/bl2u/bl2u.ld.S
@@ -5,7 +5,8 @@
*/
#include <platform_def.h>
-#include <xlat_tables_defs.h>
+
+#include <lib/xlat_tables/xlat_tables_defs.h>
OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
diff --git a/bl2u/bl2u_main.c b/bl2u/bl2u_main.c
index b29d57e..d3c83cc 100644
--- a/bl2u/bl2u_main.c
+++ b/bl2u/bl2u_main.c
@@ -4,19 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <auth_mod.h>
-#include <bl1.h>
-#include <bl2u.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <platform.h>
-#include <platform_def.h>
#include <stdint.h>
+#include <platform_def.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <bl1/bl1.h>
+#include <bl2u/bl2u.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/auth/auth_mod.h>
+#include <drivers/console.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* This function is responsible to:
diff --git a/bl31/aarch64/bl31_entrypoint.S b/bl31/aarch64/bl31_entrypoint.S
index 7c116a2..c41773b 100644
--- a/bl31/aarch64/bl31_entrypoint.S
+++ b/bl31/aarch64/bl31_entrypoint.S
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <bl_common.h>
-#include <el3_common_macros.S>
#include <platform_def.h>
-#include <pmf_asm_macros.S>
-#include <runtime_instr.h>
-#include <xlat_mmu_helpers.h>
+
+#include <arch.h>
+#include <common/bl_common.h>
+#include <el3_common_macros.S>
+#include <lib/pmf/pmf_asm_macros.S>
+#include <lib/runtime_instr.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
.globl bl31_entrypoint
.globl bl31_warm_entrypoint
diff --git a/bl31/aarch64/crash_reporting.S b/bl31/aarch64/crash_reporting.S
index 0986a0a..b3f5979 100644
--- a/bl31/aarch64/crash_reporting.S
+++ b/bl31/aarch64/crash_reporting.S
@@ -3,13 +3,15 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
+#include <plat_macros.S>
+#include <platform_def.h>
+
#include <arch.h>
#include <asm_macros.S>
#include <context.h>
-#include <cpu_data.h>
-#include <plat_macros.S>
-#include <platform_def.h>
-#include <utils_def.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/utils_def.h>
.globl report_unhandled_exception
.globl report_unhandled_interrupt
diff --git a/bl31/aarch64/ea_delegate.S b/bl31/aarch64/ea_delegate.S
index 9d7c5e8..0c8cfa8 100644
--- a/bl31/aarch64/ea_delegate.S
+++ b/bl31/aarch64/ea_delegate.S
@@ -8,9 +8,9 @@
#include <assert_macros.S>
#include <asm_macros.S>
#include <assert_macros.S>
+#include <bl31/ea_handle.h>
#include <context.h>
-#include <ea_handle.h>
-#include <ras_arch.h>
+#include <lib/extensions/ras_arch.h>
.globl handle_lower_el_ea_esb
diff --git a/bl31/aarch64/runtime_exceptions.S b/bl31/aarch64/runtime_exceptions.S
index ab61e8c..e7abd50 100644
--- a/bl31/aarch64/runtime_exceptions.S
+++ b/bl31/aarch64/runtime_exceptions.S
@@ -4,15 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <platform_def.h>
+
#include <arch.h>
#include <asm_macros.S>
+#include <bl31/ea_handle.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/runtime_svc.h>
#include <context.h>
-#include <cpu_data.h>
-#include <ea_handle.h>
-#include <interrupt_mgmt.h>
-#include <platform_def.h>
-#include <runtime_svc.h>
-#include <smccc.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/smccc.h>
.globl runtime_exceptions
diff --git a/bl31/bl31.ld.S b/bl31/bl31.ld.S
index 43d0ed4..5925e0c 100644
--- a/bl31/bl31.ld.S
+++ b/bl31/bl31.ld.S
@@ -5,7 +5,8 @@
*/
#include <platform_def.h>
-#include <xlat_tables_defs.h>
+
+#include <lib/xlat_tables/xlat_tables_defs.h>
OUTPUT_FORMAT(PLATFORM_LINKER_FORMAT)
OUTPUT_ARCH(PLATFORM_LINKER_ARCH)
@@ -66,18 +67,18 @@
__CPU_OPS_END__ = .;
/*
- * Keep the .got section in the RO section as the it is patched
+ * Keep the .got section in the RO section as it is patched
* prior to enabling the MMU and having the .got in RO is better for
- * security.
+ * security. GOT is a table of addresses so ensure 8-byte alignment.
*/
- . = ALIGN(16);
+ . = ALIGN(8);
__GOT_START__ = .;
*(.got)
__GOT_END__ = .;
/* Place pubsub sections for events */
. = ALIGN(8);
-#include <pubsub_events.h>
+#include <lib/el3_runtime/pubsub_events.h>
. = ALIGN(PAGE_SIZE);
__RODATA_END__ = .;
@@ -112,9 +113,19 @@
KEEP(*(cpu_ops))
__CPU_OPS_END__ = .;
+ /*
+ * Keep the .got section in the RO section as it is patched
+ * prior to enabling the MMU and having the .got in RO is better for
+ * security. GOT is a table of addresses so ensure 8-byte alignment.
+ */
+ . = ALIGN(8);
+ __GOT_START__ = .;
+ *(.got)
+ __GOT_END__ = .;
+
/* Place pubsub sections for events */
. = ALIGN(8);
-#include <pubsub_events.h>
+#include <lib/el3_runtime/pubsub_events.h>
*(.vectors)
__RO_END_UNALIGNED__ = .;
@@ -165,11 +176,12 @@
__DATA_END__ = .;
} >RAM
- . = ALIGN(16);
/*
* .rela.dyn needs to come after .data for the read-elf utility to parse
- * this section correctly.
+ * this section correctly. Ensure 8-byte alignment so that the fields of
+ * RELA data structure are aligned.
*/
+ . = ALIGN(8);
__RELA_START__ = .;
.rela.dyn . : {
} >RAM
diff --git a/bl31/bl31_context_mgmt.c b/bl31/bl31_context_mgmt.c
index f868372..d41979f 100644
--- a/bl31/bl31_context_mgmt.c
+++ b/bl31/bl31_context_mgmt.c
@@ -5,13 +5,13 @@
*/
#include <assert.h>
-#include <bl31.h>
-#include <bl_common.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <cpu_data.h>
-#include <platform.h>
+#include <bl31/bl31.h>
+#include <common/bl_common.h>
+#include <context.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* This function returns a pointer to the most recent 'cpu_context' structure
diff --git a/bl31/bl31_main.c b/bl31/bl31_main.c
index 77b59ed..927cda2 100644
--- a/bl31/bl31_main.c
+++ b/bl31/bl31_main.c
@@ -4,21 +4,22 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl31.h>
-#include <bl_common.h>
-#include <console.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <ehf.h>
-#include <platform.h>
-#include <pmf.h>
-#include <runtime_instr.h>
-#include <runtime_svc.h>
-#include <std_svc.h>
-#include <string.h>
+#include <bl31/bl31.h>
+#include <bl31/ehf.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <drivers/console.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/pmf/pmf.h>
+#include <lib/runtime_instr.h>
+#include <plat/common/platform.h>
+#include <services/std_svc.h>
#if ENABLE_RUNTIME_INSTRUMENTATION
PMF_REGISTER_SERVICE_SMC(rt_instr_svc, PMF_RT_INSTR_SVC_ID,
diff --git a/bl31/ehf.c b/bl31/ehf.c
index fa036cb..1bcebee 100644
--- a/bl31/ehf.c
+++ b/bl31/ehf.c
@@ -9,17 +9,18 @@
*/
#include <assert.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <cpu_data.h>
-#include <debug.h>
-#include <ehf.h>
-#include <gic_common.h>
-#include <interrupt_mgmt.h>
-#include <platform.h>
-#include <pubsub_events.h>
#include <stdbool.h>
+#include <bl31/ehf.h>
+#include <bl31/interrupt_mgmt.h>
+#include <context.h>
+#include <common/debug.h>
+#include <drivers/arm/gic_common.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/el3_runtime/pubsub_events.h>
+#include <plat/common/platform.h>
+
/* Output EHF logs as verbose */
#define EHF_LOG(...) VERBOSE("EHF: " __VA_ARGS__)
diff --git a/bl31/interrupt_mgmt.c b/bl31/interrupt_mgmt.c
index 0df50b6..e6efad3 100644
--- a/bl31/interrupt_mgmt.c
+++ b/bl31/interrupt_mgmt.c
@@ -5,11 +5,12 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
#include <errno.h>
-#include <interrupt_mgmt.h>
-#include <platform.h>
+
+#include <common/bl_common.h>
+#include <bl31/interrupt_mgmt.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* Local structure and corresponding array to keep track of the state of the
diff --git a/bl32/sp_min/aarch32/entrypoint.S b/bl32/sp_min/aarch32/entrypoint.S
index d6853cc..2ffef6a 100644
--- a/bl32/sp_min/aarch32/entrypoint.S
+++ b/bl32/sp_min/aarch32/entrypoint.S
@@ -6,13 +6,13 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <common/runtime_svc.h>
#include <context.h>
#include <el3_common_macros.S>
-#include <runtime_svc.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
#include <smccc_helpers.h>
#include <smccc_macros.S>
-#include <xlat_tables_defs.h>
.globl sp_min_vector_table
.globl sp_min_entrypoint
diff --git a/bl32/sp_min/sp_min.ld.S b/bl32/sp_min/sp_min.ld.S
index ce6c954..ba9d342 100644
--- a/bl32/sp_min/sp_min.ld.S
+++ b/bl32/sp_min/sp_min.ld.S
@@ -5,7 +5,8 @@
*/
#include <platform_def.h>
-#include <xlat_tables_defs.h>
+
+#include <lib/xlat_tables/xlat_tables_defs.h>
OUTPUT_FORMAT(elf32-littlearm)
OUTPUT_ARCH(arm)
@@ -62,7 +63,7 @@
/* Place pubsub sections for events */
. = ALIGN(8);
-#include <pubsub_events.h>
+#include <lib/el3_runtime/pubsub_events.h>
. = ALIGN(PAGE_SIZE);
__RODATA_END__ = .;
@@ -91,7 +92,7 @@
/* Place pubsub sections for events */
. = ALIGN(8);
-#include <pubsub_events.h>
+#include <lib/el3_runtime/pubsub_events.h>
*(.vectors)
__RO_END_UNALIGNED__ = .;
diff --git a/bl32/sp_min/sp_min_main.c b/bl32/sp_min/sp_min_main.c
index a12a83b..3cb1990 100644
--- a/bl32/sp_min/sp_min_main.c
+++ b/bl32/sp_min/sp_min_main.c
@@ -4,26 +4,28 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <platform.h>
-#include <platform_def.h>
-#include <platform_sp_min.h>
-#include <psci.h>
-#include <runtime_svc.h>
-#include <smccc_helpers.h>
#include <stddef.h>
#include <stdint.h>
-#include <std_svc.h>
-#include <stdint.h>
#include <string.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <context.h>
+#include <drivers/console.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/psci/psci.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+#include <platform_sp_min.h>
+#include <services/std_svc.h>
+#include <smccc_helpers.h>
+
#include "sp_min_private.h"
/* Pointers to per-core cpu contexts */
diff --git a/bl32/tsp/aarch64/tsp_entrypoint.S b/bl32/tsp/aarch64/tsp_entrypoint.S
index 5d9da85..48f6981 100644
--- a/bl32/tsp/aarch64/tsp_entrypoint.S
+++ b/bl32/tsp/aarch64/tsp_entrypoint.S
@@ -6,8 +6,9 @@
#include <arch.h>
#include <asm_macros.S>
-#include <tsp.h>
-#include <xlat_tables_defs.h>
+#include <bl32/tsp/tsp.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+
#include "../tsp_private.h"
diff --git a/bl32/tsp/aarch64/tsp_exceptions.S b/bl32/tsp/aarch64/tsp_exceptions.S
index 48e358a..ad4b648 100644
--- a/bl32/tsp/aarch64/tsp_exceptions.S
+++ b/bl32/tsp/aarch64/tsp_exceptions.S
@@ -6,9 +6,8 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
-#include <tsp.h>
-
+#include <bl32/tsp/tsp.h>
+#include <common/bl_common.h>
/* ----------------------------------------------------
* The caller-saved registers x0-x18 and LR are saved
diff --git a/bl32/tsp/aarch64/tsp_request.S b/bl32/tsp/aarch64/tsp_request.S
index 2261f87..5ad16da 100644
--- a/bl32/tsp/aarch64/tsp_request.S
+++ b/bl32/tsp/aarch64/tsp_request.S
@@ -5,7 +5,7 @@
*/
#include <asm_macros.S>
-#include <tsp.h>
+#include <bl32/tsp/tsp.h>
.globl tsp_get_magic
diff --git a/bl32/tsp/tsp.ld.S b/bl32/tsp/tsp.ld.S
index 97b12ce..e9a1df1 100644
--- a/bl32/tsp/tsp.ld.S
+++ b/bl32/tsp/tsp.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/bl32/tsp/tsp_interrupt.c b/bl32/tsp/tsp_interrupt.c
index f501338..4e500b3 100644
--- a/bl32/tsp/tsp_interrupt.c
+++ b/bl32/tsp/tsp_interrupt.c
@@ -4,12 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <tsp.h>
+
+#include <arch_helpers.h>
+#include <bl32/tsp/tsp.h>
+#include <common/debug.h>
+#include <plat/common/platform.h>
+
#include "tsp_private.h"
/*******************************************************************************
diff --git a/bl32/tsp/tsp_main.c b/bl32/tsp/tsp_main.c
index e41b51e..24efa61 100644
--- a/bl32/tsp/tsp_main.c
+++ b/bl32/tsp/tsp_main.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <platform.h>
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <bl32/tsp/tsp.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/spinlock.h>
+#include <plat/common/platform.h>
#include <platform_tsp.h>
-#include <spinlock.h>
-#include <tsp.h>
+
#include "tsp_private.h"
diff --git a/bl32/tsp/tsp_private.h b/bl32/tsp/tsp_private.h
index b697fa4..e39f291 100644
--- a/bl32/tsp/tsp_private.h
+++ b/bl32/tsp/tsp_private.h
@@ -22,12 +22,13 @@
#ifndef __ASSEMBLY__
-#include <cassert.h>
-#include <platform_def.h> /* For CACHE_WRITEBACK_GRANULE */
-#include <spinlock.h>
#include <stdint.h>
-#include <tsp.h>
+#include <platform_def.h> /* For CACHE_WRITEBACK_GRANULE */
+
+#include <bl32/tsp/tsp.h>
+#include <lib/cassert.h>
+#include <lib/spinlock.h>
typedef struct work_statistics {
/* Number of s-el1 interrupts on this cpu */
diff --git a/bl32/tsp/tsp_timer.c b/bl32/tsp/tsp_timer.c
index ebe7f0d..3592863 100644
--- a/bl32/tsp/tsp_timer.c
+++ b/bl32/tsp/tsp_timer.c
@@ -3,9 +3,12 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
+
#include <assert.h>
-#include <platform.h>
+
+#include <arch_helpers.h>
+#include <plat/common/platform.h>
+
#include "tsp_private.h"
/*******************************************************************************
diff --git a/common/aarch64/debug.S b/common/aarch64/debug.S
index 4478d0d..da740ef 100644
--- a/common/aarch64/debug.S
+++ b/common/aarch64/debug.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <debug.h>
+#include <common/debug.h>
.globl asm_print_str
.globl asm_print_hex
diff --git a/common/aarch64/early_exceptions.S b/common/aarch64/early_exceptions.S
index ba94f6c..36a8724 100644
--- a/common/aarch64/early_exceptions.S
+++ b/common/aarch64/early_exceptions.S
@@ -5,7 +5,7 @@
*/
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
/* -----------------------------------------------------------------------------
* Very simple stackless exception handlers used by BL2 and BL31 stages.
diff --git a/common/backtrace/backtrace.c b/common/backtrace/backtrace.c
index a91d065..bf60a08 100644
--- a/common/backtrace/backtrace.c
+++ b/common/backtrace/backtrace.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <console.h>
-#include <debug.h>
#include <stdbool.h>
#include <stdint.h>
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+
/* Maximum number of entries in the backtrace to display */
#define UNWIND_LIMIT 20U
diff --git a/common/bl_common.c b/common/bl_common.c
index d12a17c..b2d22c1 100644
--- a/common/bl_common.c
+++ b/common/bl_common.c
@@ -4,18 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <auth_mod.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <errno.h>
-#include <io_storage.h>
-#include <platform.h>
-#include <string.h>
-#include <utils.h>
-#include <xlat_tables_defs.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/auth/auth_mod.h>
+#include <drivers/io/io_storage.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <plat/common/platform.h>
#if TRUSTED_BOARD_BOOT
# ifdef DYN_DISABLE_AUTH
diff --git a/common/desc_image_load.c b/common/desc_image_load.c
index b07fba3..ada02f8 100644
--- a/common/desc_image_load.c
+++ b/common/desc_image_load.c
@@ -4,12 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <desc_image_load.h>
-
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
static bl_load_info_t bl_load_info;
static bl_params_t next_bl_params;
diff --git a/common/fdt_wrappers.c b/common/fdt_wrappers.c
index 31dafb2..e67fdb0 100644
--- a/common/fdt_wrappers.c
+++ b/common/fdt_wrappers.c
@@ -7,11 +7,13 @@
/* Helper functions to offer easier navigation of Device Tree Blob */
#include <assert.h>
-#include <debug.h>
-#include <fdt_wrappers.h>
-#include <libfdt.h>
#include <string.h>
+#include <libfdt.h>
+
+#include <common/debug.h>
+#include <common/fdt_wrappers.h>
+
/*
* Read cells from a given property of the given node. At most 2 cells of the
* property are read, and pointer is updated. Returns 0 on success, and -1 upon
diff --git a/common/image_decompress.c b/common/image_decompress.c
index 7bd02b1..a4586ae 100644
--- a/common/image_decompress.c
+++ b/common/image_decompress.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <image_decompress.h>
#include <stdint.h>
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/image_decompress.h>
+
static uintptr_t decompressor_buf_base;
static uint32_t decompressor_buf_size;
static decompressor_t *decompressor;
diff --git a/common/runtime_svc.c b/common/runtime_svc.c
index c30c0ec..09ce787 100644
--- a/common/runtime_svc.c
+++ b/common/runtime_svc.c
@@ -5,11 +5,12 @@
*/
#include <assert.h>
-#include <debug.h>
#include <errno.h>
-#include <runtime_svc.h>
#include <string.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+
/*******************************************************************************
* The 'rt_svc_descs' array holds the runtime service descriptors exported by
* services by placing them in the 'rt_svc_descs' linker section.
diff --git a/common/tf_log.c b/common/tf_log.c
index 0702185..3e174dd 100644
--- a/common/tf_log.c
+++ b/common/tf_log.c
@@ -4,9 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <stdarg.h>
#include <assert.h>
-#include <debug.h>
-#include <platform.h>
+#include <stdio.h>
+
+#include <common/debug.h>
+#include <plat/common/platform.h>
/* Set the default maximum log level to the `LOG_LEVEL` build flag */
static unsigned int max_log_level = LOG_LEVEL;
diff --git a/docs/exception-handling.rst b/docs/exception-handling.rst
index e7cb09c..dbcd4bc 100644
--- a/docs/exception-handling.rst
+++ b/docs/exception-handling.rst
@@ -308,9 +308,9 @@
.. code:: c
+ #include <common/interrupt_props.h>
+ #include <drivers/arm/gic_common.h>
#include <exception_mgmt.h>
- #include <gic_common.h>
- #include <interrupt_props.h>
...
diff --git a/docs/marvell/build.txt b/docs/marvell/build.txt
index 0682b77..7b75196 100644
--- a/docs/marvell/build.txt
+++ b/docs/marvell/build.txt
@@ -125,8 +125,8 @@
the image boot from SPI NOR flash partition 0, and the image is non trusted in WTP, the command
line is as following::
- > make DEBUG=1 USE_COHERENT_MEM=0 LOG_LEVEL=20 SECURE=0 CLOCKSPRESET=CPU_1000_DDR_800 \
- DDR_TOPOLOGY=3 BOOTDEV=SPINOR PARTNUM=0 PLAT=a3700 all fip
+ > make DEBUG=1 USE_COHERENT_MEM=0 LOG_LEVEL=20 CLOCKSPRESET=CPU_1000_DDR_800 \
+ MARVELL_SECURE_BOOT=0 DDR_TOPOLOGY=3 BOOTDEV=SPINOR PARTNUM=0 PLAT=a3700 all fip
Supported MARVELL_PLATFORM are:
- a3700 (for both A3720 DB and EspressoBin)
@@ -167,7 +167,7 @@
(1) ARM cross compiler capable of building images for the service CPU (CM3).
This component is usually included in the Linux host packages.
- On Debian/Uboot hosts the default GNU ARM tool chain can be installed
+ On Debian/Ubuntu hosts the default GNU ARM tool chain can be installed
using the following command::
> sudo apt-get install gcc-arm-linux-gnueabi
diff --git a/docs/user-guide.rst b/docs/user-guide.rst
index a8bd40c..103f1c7 100644
--- a/docs/user-guide.rst
+++ b/docs/user-guide.rst
@@ -1875,16 +1875,16 @@
-C cluster0.NUM_CORES=4 \
-C cluster1.NUM_CORES=4 \
-C cache_state_modelled=1 \
- -C cluster0.cpu0.RVBAR=0x04020000 \
- -C cluster0.cpu1.RVBAR=0x04020000 \
- -C cluster0.cpu2.RVBAR=0x04020000 \
- -C cluster0.cpu3.RVBAR=0x04020000 \
- -C cluster1.cpu0.RVBAR=0x04020000 \
- -C cluster1.cpu1.RVBAR=0x04020000 \
- -C cluster1.cpu2.RVBAR=0x04020000 \
- -C cluster1.cpu3.RVBAR=0x04020000 \
- --data cluster0.cpu0="<path-to>/<bl31-binary>"@0x04020000 \
- --data cluster0.cpu0="<path-to>/<bl32-binary>"@0x04001000 \
+ -C cluster0.cpu0.RVBAR=0x04010000 \
+ -C cluster0.cpu1.RVBAR=0x04010000 \
+ -C cluster0.cpu2.RVBAR=0x04010000 \
+ -C cluster0.cpu3.RVBAR=0x04010000 \
+ -C cluster1.cpu0.RVBAR=0x04010000 \
+ -C cluster1.cpu1.RVBAR=0x04010000 \
+ -C cluster1.cpu2.RVBAR=0x04010000 \
+ -C cluster1.cpu3.RVBAR=0x04010000 \
+ --data cluster0.cpu0="<path-to>/<bl31-binary>"@0x04010000 \
+ --data cluster0.cpu0="<path-to>/<bl32-binary>"@0xff000000 \
--data cluster0.cpu0="<path-to>/<bl33-binary>"@0x88000000 \
--data cluster0.cpu0="<path-to>/<fdt>"@0x82000000 \
--data cluster0.cpu0="<path-to>/<kernel-binary>"@0x80080000 \
@@ -1892,6 +1892,9 @@
Notes:
+- Since Position Independent Executable (PIE) support is enabled for BL31
+ in this config, it can be loaded at any valid address for execution.
+
- Since a FIP is not loaded when using BL31 as reset entrypoint, the
``--data="<path-to><bl31|bl32|bl33-binary>"@<base-address-of-binary>``
parameter is needed to load the individual bootloader images in memory.
@@ -1932,14 +1935,14 @@
-C cluster1.cpu1.CONFIG64=0 \
-C cluster1.cpu2.CONFIG64=0 \
-C cluster1.cpu3.CONFIG64=0 \
- -C cluster0.cpu0.RVBAR=0x04001000 \
- -C cluster0.cpu1.RVBAR=0x04001000 \
- -C cluster0.cpu2.RVBAR=0x04001000 \
- -C cluster0.cpu3.RVBAR=0x04001000 \
- -C cluster1.cpu0.RVBAR=0x04001000 \
- -C cluster1.cpu1.RVBAR=0x04001000 \
- -C cluster1.cpu2.RVBAR=0x04001000 \
- -C cluster1.cpu3.RVBAR=0x04001000 \
+ -C cluster0.cpu0.RVBAR=0x04002000 \
+ -C cluster0.cpu1.RVBAR=0x04002000 \
+ -C cluster0.cpu2.RVBAR=0x04002000 \
+ -C cluster0.cpu3.RVBAR=0x04002000 \
+ -C cluster1.cpu0.RVBAR=0x04002000 \
+ -C cluster1.cpu1.RVBAR=0x04002000 \
+ -C cluster1.cpu2.RVBAR=0x04002000 \
+ -C cluster1.cpu3.RVBAR=0x04002000 \
--data cluster0.cpu0="<path-to>/<bl32-binary>"@0x04002000 \
--data cluster0.cpu0="<path-to>/<bl33-binary>"@0x88000000 \
--data cluster0.cpu0="<path-to>/<fdt>"@0x82000000 \
@@ -1962,16 +1965,16 @@
-C bp.secure_memory=1 \
-C bp.tzc_400.diagnostics=1 \
-C cache_state_modelled=1 \
- -C cluster0.cpu0.RVBARADDR=0x04020000 \
- -C cluster0.cpu1.RVBARADDR=0x04020000 \
- -C cluster0.cpu2.RVBARADDR=0x04020000 \
- -C cluster0.cpu3.RVBARADDR=0x04020000 \
- -C cluster1.cpu0.RVBARADDR=0x04020000 \
- -C cluster1.cpu1.RVBARADDR=0x04020000 \
- -C cluster1.cpu2.RVBARADDR=0x04020000 \
- -C cluster1.cpu3.RVBARADDR=0x04020000 \
- --data cluster0.cpu0="<path-to>/<bl31-binary>"@0x04020000 \
- --data cluster0.cpu0="<path-to>/<bl32-binary>"@0x04002000 \
+ -C cluster0.cpu0.RVBARADDR=0x04010000 \
+ -C cluster0.cpu1.RVBARADDR=0x04010000 \
+ -C cluster0.cpu2.RVBARADDR=0x04010000 \
+ -C cluster0.cpu3.RVBARADDR=0x04010000 \
+ -C cluster1.cpu0.RVBARADDR=0x04010000 \
+ -C cluster1.cpu1.RVBARADDR=0x04010000 \
+ -C cluster1.cpu2.RVBARADDR=0x04010000 \
+ -C cluster1.cpu3.RVBARADDR=0x04010000 \
+ --data cluster0.cpu0="<path-to>/<bl31-binary>"@0x04010000 \
+ --data cluster0.cpu0="<path-to>/<bl32-binary>"@0xff000000 \
--data cluster0.cpu0="<path-to>/<bl33-binary>"@0x88000000 \
--data cluster0.cpu0="<path-to>/<fdt>"@0x82000000 \
--data cluster0.cpu0="<path-to>/<kernel-binary>"@0x80080000 \
@@ -1990,10 +1993,10 @@
-C bp.secure_memory=1 \
-C bp.tzc_400.diagnostics=1 \
-C cache_state_modelled=1 \
- -C cluster0.cpu0.RVBARADDR=0x04001000 \
- -C cluster0.cpu1.RVBARADDR=0x04001000 \
- -C cluster0.cpu2.RVBARADDR=0x04001000 \
- -C cluster0.cpu3.RVBARADDR=0x04001000 \
+ -C cluster0.cpu0.RVBARADDR=0x04002000 \
+ -C cluster0.cpu1.RVBARADDR=0x04002000 \
+ -C cluster0.cpu2.RVBARADDR=0x04002000 \
+ -C cluster0.cpu3.RVBARADDR=0x04002000 \
--data cluster0.cpu0="<path-to>/<bl32-binary>"@0x04002000 \
--data cluster0.cpu0="<path-to>/<bl33-binary>"@0x88000000 \
--data cluster0.cpu0="<path-to>/<fdt>"@0x82000000 \
diff --git a/drivers/allwinner/sunxi_rsb.c b/drivers/allwinner/sunxi_rsb.c
index 7075c67..67f5b7e 100644
--- a/drivers/allwinner/sunxi_rsb.c
+++ b/drivers/allwinner/sunxi_rsb.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <mmio.h>
+
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
#include <sunxi_mmap.h>
#define RSB_CTRL 0x00
diff --git a/drivers/arm/cci/cci.c b/drivers/arm/cci/cci.c
index 605971c..a139f6c 100644
--- a/drivers/arm/cci/cci.c
+++ b/drivers/arm/cci/cci.c
@@ -4,15 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <cci.h>
-#include <debug.h>
-#include <mmio.h>
#include <stdbool.h>
#include <stdint.h>
+#include <arch.h>
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <lib/mmio.h>
+
#define MAKE_CCI_PART_NUMBER(hi, lo) (((hi) << 8) | (lo))
#define CCI_PART_LO_MASK U(0xff)
#define CCI_PART_HI_MASK U(0xf)
diff --git a/drivers/arm/ccn/ccn.c b/drivers/arm/ccn/ccn.c
index 59a7576..64b1626 100644
--- a/drivers/arm/ccn/ccn.c
+++ b/drivers/arm/ccn/ccn.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
#include <assert.h>
-#include <bakery_lock.h>
-#include <ccn.h>
-#include <debug.h>
#include <errno.h>
-#include <mmio.h>
#include <stdbool.h>
+
+#include <arch.h>
+#include <common/debug.h>
+#include <drivers/arm/ccn.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+
#include "ccn_private.h"
static const ccn_desc_t *ccn_plat_desc;
@@ -553,7 +555,14 @@
return REGION_ID_LIMIT;
}
- region_id += node_pos_in_map;
+ /*
+ * According to section 3.1.1 in CCN specification, region offset for
+ * the RN-I components is calculated as (128 + NodeID of RN-I).
+ */
+ if (node_type == NODE_TYPE_RNI)
+ region_id += node_id;
+ else
+ region_id += node_pos_in_map;
return region_id;
}
diff --git a/drivers/arm/gic/common/gic_common.c b/drivers/arm/gic/common/gic_common.c
index 589de5d..38b2f67 100644
--- a/drivers/arm/gic/common/gic_common.c
+++ b/drivers/arm/gic/common/gic_common.c
@@ -5,8 +5,10 @@
*/
#include <assert.h>
-#include <gic_common.h>
-#include <mmio.h>
+
+#include <drivers/arm/gic_common.h>
+#include <lib/mmio.h>
+
#include "gic_common_private.h"
/*******************************************************************************
diff --git a/drivers/arm/gic/common/gic_common_private.h b/drivers/arm/gic/common/gic_common_private.h
index 9d9e8c7..1ab1bdb 100644
--- a/drivers/arm/gic/common/gic_common_private.h
+++ b/drivers/arm/gic/common/gic_common_private.h
@@ -7,10 +7,11 @@
#ifndef GIC_COMMON_PRIVATE_H
#define GIC_COMMON_PRIVATE_H
-#include <gic_common.h>
-#include <mmio.h>
#include <stdint.h>
+#include <drivers/arm/gic_common.h>
+#include <lib/mmio.h>
+
/*******************************************************************************
* GIC Distributor interface register accessors that are common to GICv3 & GICv2
******************************************************************************/
diff --git a/drivers/arm/gic/v2/gicv2_helpers.c b/drivers/arm/gic/v2/gicv2_helpers.c
index bc4c1d1..6739a78 100644
--- a/drivers/arm/gic/v2/gicv2_helpers.c
+++ b/drivers/arm/gic/v2/gicv2_helpers.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <gic_common.h>
-#include <gicv2.h>
-#include <interrupt_props.h>
+#include <common/debug.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+
#include "../common/gic_common_private.h"
#include "gicv2_private.h"
diff --git a/drivers/arm/gic/v2/gicv2_main.c b/drivers/arm/gic/v2/gicv2_main.c
index b872905..c5d4fe1 100644
--- a/drivers/arm/gic/v2/gicv2_main.c
+++ b/drivers/arm/gic/v2/gicv2_main.c
@@ -4,15 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <gic_common.h>
-#include <gicv2.h>
-#include <interrupt_props.h>
-#include <spinlock.h>
-#include <stdbool.h>
+#include <common/debug.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/spinlock.h>
#include "../common/gic_common_private.h"
#include "gicv2_private.h"
diff --git a/drivers/arm/gic/v2/gicv2_private.h b/drivers/arm/gic/v2/gicv2_private.h
index ccfad78..0fbdab0 100644
--- a/drivers/arm/gic/v2/gicv2_private.h
+++ b/drivers/arm/gic/v2/gicv2_private.h
@@ -7,10 +7,11 @@
#ifndef GICV2_PRIVATE_H
#define GICV2_PRIVATE_H
-#include <gicv2.h>
-#include <mmio.h>
#include <stdint.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/mmio.h>
+
/*******************************************************************************
* Private function prototypes
******************************************************************************/
diff --git a/drivers/arm/gic/v3/arm_gicv3_common.c b/drivers/arm/gic/v3/arm_gicv3_common.c
index c809732..4489892 100644
--- a/drivers/arm/gic/v3/arm_gicv3_common.c
+++ b/drivers/arm/gic/v3/arm_gicv3_common.c
@@ -10,12 +10,13 @@
* APIs that are different to those generic ones in GICv3 driver.
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <gicv3.h>
+
+#include <arch_helpers.h>
+#include <drivers/arm/arm_gicv3_common.h>
+#include <drivers/arm/gicv3.h>
#include "gicv3_private.h"
-#include "arm_gicv3_common.h"
/*
* Flush the internal GIC cache of the LPIs pending tables to memory before
diff --git a/drivers/arm/gic/v3/gic600.c b/drivers/arm/gic/v3/gic600.c
index eb4fc54..9cb2ab2 100644
--- a/drivers/arm/gic/v3/gic600.c
+++ b/drivers/arm/gic/v3/gic600.c
@@ -11,9 +11,10 @@
* GIC600 supports independently power-gating redistributor interface.
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <gicv3.h>
+
+#include <arch_helpers.h>
+#include <drivers/arm/gicv3.h>
#include "gicv3_private.h"
diff --git a/drivers/arm/gic/v3/gicv3_helpers.c b/drivers/arm/gic/v3/gicv3_helpers.c
index c12a4b6..39ea2a3 100644
--- a/drivers/arm/gic/v3/gicv3_helpers.c
+++ b/drivers/arm/gic/v3/gicv3_helpers.c
@@ -4,12 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <gic_common.h>
-#include <interrupt_props.h>
+#include <common/debug.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gic_common.h>
+
#include "../common/gic_common_private.h"
#include "gicv3_private.h"
diff --git a/drivers/arm/gic/v3/gicv3_main.c b/drivers/arm/gic/v3/gicv3_main.c
index 60f2e10..cf92f10 100644
--- a/drivers/arm/gic/v3/gicv3_main.c
+++ b/drivers/arm/gic/v3/gicv3_main.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <gicv3.h>
-#include <interrupt_props.h>
-#include <spinlock.h>
+#include <common/debug.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/spinlock.h>
+
#include "gicv3_private.h"
const gicv3_driver_data_t *gicv3_driver_data;
diff --git a/drivers/arm/gic/v3/gicv3_private.h b/drivers/arm/gic/v3/gicv3_private.h
index 188e711..92066e1 100644
--- a/drivers/arm/gic/v3/gicv3_private.h
+++ b/drivers/arm/gic/v3/gicv3_private.h
@@ -8,10 +8,12 @@
#define GICV3_PRIVATE_H
#include <assert.h>
-#include <gic_common.h>
-#include <gicv3.h>
-#include <mmio.h>
#include <stdint.h>
+
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/mmio.h>
+
#include "../common/gic_common_private.h"
/*******************************************************************************
diff --git a/drivers/arm/pl011/aarch32/pl011_console.S b/drivers/arm/pl011/aarch32/pl011_console.S
index 5d6b95f..ae613b1 100644
--- a/drivers/arm/pl011/aarch32/pl011_console.S
+++ b/drivers/arm/pl011/aarch32/pl011_console.S
@@ -8,7 +8,7 @@
#include <assert_macros.S>
#define USE_FINISH_CONSOLE_REG_2
#include <console_macros.S>
-#include <pl011.h>
+#include <drivers/arm/pl011.h>
#if !MULTI_CONSOLE_API
/*
diff --git a/drivers/arm/pl011/aarch64/pl011_console.S b/drivers/arm/pl011/aarch64/pl011_console.S
index 7fec090..aaa39c1 100644
--- a/drivers/arm/pl011/aarch64/pl011_console.S
+++ b/drivers/arm/pl011/aarch64/pl011_console.S
@@ -8,7 +8,7 @@
#include <assert_macros.S>
#define USE_FINISH_CONSOLE_REG_2
#include <console_macros.S>
-#include <pl011.h>
+#include <drivers/arm/pl011.h>
#if !MULTI_CONSOLE_API
/*
diff --git a/drivers/arm/pl061/pl061_gpio.c b/drivers/arm/pl061/pl061_gpio.c
index af980e5..97013e8 100644
--- a/drivers/arm/pl061/pl061_gpio.c
+++ b/drivers/arm/pl061/pl061_gpio.c
@@ -9,13 +9,14 @@
*/
#include <assert.h>
-#include <cassert.h>
-#include <debug.h>
#include <errno.h>
-#include <gpio.h>
-#include <mmio.h>
-#include <pl061_gpio.h>
-#include <utils.h>
+
+#include <common/debug.h>
+#include <drivers/arm/pl061_gpio.h>
+#include <drivers/gpio.h>
+#include <lib/cassert.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
#if !PLAT_PL061_MAX_GPIOS
# define PLAT_PL061_MAX_GPIOS 32
diff --git a/drivers/arm/smmu/smmu_v3.c b/drivers/arm/smmu/smmu_v3.c
index 78a9ffa..004e81e 100644
--- a/drivers/arm/smmu/smmu_v3.c
+++ b/drivers/arm/smmu/smmu_v3.c
@@ -5,10 +5,11 @@
*/
#include <cdefs.h>
-#include <mmio.h>
-#include <smmu_v3.h>
#include <stdbool.h>
+#include <drivers/arm/smmu_v3.h>
+#include <lib/mmio.h>
+
static inline uint32_t __init smmuv3_read_s_idr1(uintptr_t base)
{
return mmio_read_32(base + SMMU_S_IDR1);
diff --git a/drivers/arm/sp804/sp804_delay_timer.c b/drivers/arm/sp804/sp804_delay_timer.c
index 8f1c5c5..5313fbd 100644
--- a/drivers/arm/sp804/sp804_delay_timer.c
+++ b/drivers/arm/sp804/sp804_delay_timer.c
@@ -5,8 +5,9 @@
*/
#include <assert.h>
-#include <delay_timer.h>
-#include <mmio.h>
+
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
uintptr_t sp804_base_addr;
diff --git a/drivers/arm/sp805/sp805.c b/drivers/arm/sp805/sp805.c
index aee9016..ffca1ce 100644
--- a/drivers/arm/sp805/sp805.c
+++ b/drivers/arm/sp805/sp805.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
-#include <sp805.h>
#include <stdint.h>
+#include <drivers/arm/sp805.h>
+#include <lib/mmio.h>
+
/* Inline register access functions */
static inline void sp805_write_wdog_load(uintptr_t base, uint32_t value)
diff --git a/drivers/arm/tzc/tzc380.c b/drivers/arm/tzc/tzc380.c
index 082161f..676df8d 100644
--- a/drivers/arm/tzc/tzc380.c
+++ b/drivers/arm/tzc/tzc380.c
@@ -5,10 +5,11 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
#include <stddef.h>
-#include <tzc380.h>
+
+#include <common/debug.h>
+#include <drivers/arm/tzc380.h>
+#include <lib/mmio.h>
struct tzc380_instance {
uintptr_t base;
diff --git a/drivers/arm/tzc/tzc400.c b/drivers/arm/tzc/tzc400.c
index d27b010..50d6701 100644
--- a/drivers/arm/tzc/tzc400.c
+++ b/drivers/arm/tzc/tzc400.c
@@ -5,10 +5,12 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
#include <stddef.h>
-#include <tzc400.h>
+
+#include <common/debug.h>
+#include <drivers/arm/tzc400.h>
+#include <lib/mmio.h>
+
#include "tzc_common_private.h"
/*
diff --git a/drivers/arm/tzc/tzc_common_private.h b/drivers/arm/tzc/tzc_common_private.h
index efac850..c800536 100644
--- a/drivers/arm/tzc/tzc_common_private.h
+++ b/drivers/arm/tzc/tzc_common_private.h
@@ -9,8 +9,8 @@
#include <arch.h>
#include <arch_helpers.h>
-#include <mmio.h>
-#include <tzc_common.h>
+#include <drivers/arm/tzc_common.h>
+#include <lib/mmio.h>
#define DEFINE_TZC_COMMON_WRITE_ACTION(fn_name, macro_name) \
static inline void _tzc##fn_name##_write_action( \
diff --git a/drivers/arm/tzc/tzc_dmc500.c b/drivers/arm/tzc/tzc_dmc500.c
index f0aba9c..e45fbf8 100644
--- a/drivers/arm/tzc/tzc_dmc500.c
+++ b/drivers/arm/tzc/tzc_dmc500.c
@@ -5,10 +5,12 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
-#include <tzc_dmc500.h>
-#include "tzc_common.h"
+
+#include <common/debug.h>
+#include <drivers/arm/tzc_dmc500.h>
+#include <drivers/arm/tzc_common.h>
+#include <lib/mmio.h>
+
#include "tzc_common_private.h"
/*
diff --git a/drivers/arm/tzc/tzc_dmc620.c b/drivers/arm/tzc/tzc_dmc620.c
index 4abd080..64ec5ab 100644
--- a/drivers/arm/tzc/tzc_dmc620.c
+++ b/drivers/arm/tzc/tzc_dmc620.c
@@ -5,9 +5,10 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
-#include <tzc_dmc620.h>
+
+#include <common/debug.h>
+#include <drivers/arm/tzc_dmc620.h>
+#include <lib/mmio.h>
/* Mask to extract bit 31 to 16 */
#define MASK_31_16 UINT64_C(0x0000ffff0000)
diff --git a/drivers/auth/auth_mod.c b/drivers/auth/auth_mod.c
index eb537b6..1b8ff82 100644
--- a/drivers/auth/auth_mod.c
+++ b/drivers/auth/auth_mod.c
@@ -5,17 +5,19 @@
*/
#include <assert.h>
-#include <auth_common.h>
-#include <auth_mod.h>
-#include <cot_def.h>
-#include <crypto_mod.h>
-#include <debug.h>
-#include <img_parser_mod.h>
-#include <platform.h>
-#include <platform_def.h>
#include <stdint.h>
#include <string.h>
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <common/tbbr/cot_def.h>
+#include <drivers/auth/auth_common.h>
+#include <drivers/auth/auth_mod.h>
+#include <drivers/auth/crypto_mod.h>
+#include <drivers/auth/img_parser_mod.h>
+#include <plat/common/platform.h>
+
/* ASN.1 tags */
#define ASN1_INTEGER 0x02
diff --git a/drivers/auth/crypto_mod.c b/drivers/auth/crypto_mod.c
index 4cd0550..5e5ac2b 100644
--- a/drivers/auth/crypto_mod.c
+++ b/drivers/auth/crypto_mod.c
@@ -5,8 +5,9 @@
*/
#include <assert.h>
-#include <crypto_mod.h>
-#include <debug.h>
+
+#include <common/debug.h>
+#include <drivers/auth/crypto_mod.h>
/* Variable exported by the crypto library through REGISTER_CRYPTO_LIB() */
diff --git a/drivers/auth/cryptocell/cryptocell_crypto.c b/drivers/auth/cryptocell/cryptocell_crypto.c
index 80c1093..a507d0a 100644
--- a/drivers/auth/cryptocell/cryptocell_crypto.c
+++ b/drivers/auth/cryptocell/cryptocell_crypto.c
@@ -4,20 +4,22 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <crypto_driver.h>
-#include <crypto_mod.h>
-#include <debug.h>
-#include <mbedtls_common.h>
-#include <platform_def.h>
-#include <rsa.h>
-#include <sbrom_bsv_api.h>
-#include <secureboot_base_func.h>
-#include <secureboot_gen_defs.h>
#include <stddef.h>
#include <string.h>
-#include <util.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/cryptocell/crypto_driver.h>
+#include <drivers/arm/cryptocell/rsa.h>
+#include <drivers/arm/cryptocell/sbrom_bsv_api.h>
+#include <drivers/arm/cryptocell/secureboot_base_func.h>
+#include <drivers/arm/cryptocell/secureboot_gen_defs.h>
+#include <drivers/arm/cryptocell/util.h>
+#include <drivers/auth/crypto_mod.h>
+#include <drivers/auth/mbedtls/mbedtls_common.h>
+#include <lib/utils.h>
#include <mbedtls/oid.h>
diff --git a/drivers/auth/cryptocell/cryptocell_crypto.mk b/drivers/auth/cryptocell/cryptocell_crypto.mk
index a88dcfc..a631829 100644
--- a/drivers/auth/cryptocell/cryptocell_crypto.mk
+++ b/drivers/auth/cryptocell/cryptocell_crypto.mk
@@ -20,9 +20,7 @@
TF_LDFLAGS += -L$(CCSBROM_LIB_PATH)
LDLIBS += -lcc_712sbromx509
-INCLUDES += -Iinclude/drivers/arm/cryptocell
-
CRYPTOCELL_SOURCES := drivers/auth/cryptocell/cryptocell_crypto.c
BL1_SOURCES += ${CRYPTOCELL_SOURCES}
-BL2_SOURCES += ${CRYPTOCELL_SOURCES}
\ No newline at end of file
+BL2_SOURCES += ${CRYPTOCELL_SOURCES}
diff --git a/drivers/auth/img_parser_mod.c b/drivers/auth/img_parser_mod.c
index 6316014..c4688f8 100644
--- a/drivers/auth/img_parser_mod.c
+++ b/drivers/auth/img_parser_mod.c
@@ -5,14 +5,15 @@
*/
#include <assert.h>
-#include <auth_common.h>
-#include <debug.h>
#include <errno.h>
-#include <img_parser_mod.h>
#include <limits.h>
#include <stdint.h>
#include <string.h>
-#include <utils_def.h>
+
+#include <common/debug.h>
+#include <drivers/auth/auth_common.h>
+#include <drivers/auth/img_parser_mod.h>
+#include <lib/utils_def.h>
IMPORT_SYM(uintptr_t, __PARSER_LIB_DESCS_START__, PARSER_LIB_DESCS_START);
IMPORT_SYM(uintptr_t, __PARSER_LIB_DESCS_END__, PARSER_LIB_DESCS_END);
diff --git a/drivers/auth/mbedtls/mbedtls_common.c b/drivers/auth/mbedtls/mbedtls_common.c
index dbf45ba..b6d02fd 100644
--- a/drivers/auth/mbedtls/mbedtls_common.c
+++ b/drivers/auth/mbedtls/mbedtls_common.c
@@ -5,14 +5,16 @@
*/
#include <assert.h>
-#include <debug.h>
+#include <stddef.h>
+
/* mbed TLS headers */
#include <mbedtls/memory_buffer_alloc.h>
#include <mbedtls/platform.h>
-#include <mbedtls_common.h>
-#include <mbedtls_config.h>
-#include <platform.h>
-#include <stddef.h>
+
+#include <common/debug.h>
+#include <drivers/auth/mbedtls/mbedtls_common.h>
+#include <drivers/auth/mbedtls/mbedtls_config.h>
+#include <plat/common/platform.h>
static void cleanup(void)
{
diff --git a/drivers/auth/mbedtls/mbedtls_common.mk b/drivers/auth/mbedtls/mbedtls_common.mk
index cfbd86a..63e65bd 100644
--- a/drivers/auth/mbedtls/mbedtls_common.mk
+++ b/drivers/auth/mbedtls/mbedtls_common.mk
@@ -14,10 +14,9 @@
endif
MBEDTLS_INC = -I${MBEDTLS_DIR}/include
-INCLUDES += -Iinclude/drivers/auth/mbedtls
# Specify mbed TLS configuration file
-MBEDTLS_CONFIG_FILE := "<mbedtls_config.h>"
+MBEDTLS_CONFIG_FILE := "<drivers/auth/mbedtls/mbedtls_config.h>"
$(eval $(call add_define,MBEDTLS_CONFIG_FILE))
MBEDTLS_SOURCES += drivers/auth/mbedtls/mbedtls_common.c
diff --git a/drivers/auth/mbedtls/mbedtls_crypto.c b/drivers/auth/mbedtls/mbedtls_crypto.c
index bc9ed3a..33420fb 100644
--- a/drivers/auth/mbedtls/mbedtls_crypto.c
+++ b/drivers/auth/mbedtls/mbedtls_crypto.c
@@ -4,10 +4,6 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <crypto_mod.h>
-#include <debug.h>
-#include <mbedtls_common.h>
-#include <mbedtls_config.h>
#include <stddef.h>
#include <string.h>
@@ -17,6 +13,11 @@
#include <mbedtls/oid.h>
#include <mbedtls/platform.h>
+#include <common/debug.h>
+#include <drivers/auth/crypto_mod.h>
+#include <drivers/auth/mbedtls/mbedtls_common.h>
+#include <drivers/auth/mbedtls/mbedtls_config.h>
+
#define LIB_NAME "mbed TLS"
/*
diff --git a/drivers/auth/mbedtls/mbedtls_x509_parser.c b/drivers/auth/mbedtls/mbedtls_x509_parser.c
index bda1208..129566b 100644
--- a/drivers/auth/mbedtls/mbedtls_x509_parser.c
+++ b/drivers/auth/mbedtls/mbedtls_x509_parser.c
@@ -12,20 +12,21 @@
* extensions field, such as an image hash or a public key.
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <img_parser_mod.h>
-#include <mbedtls_common.h>
#include <stddef.h>
#include <stdint.h>
#include <string.h>
-#include <utils.h>
/* mbed TLS headers */
#include <mbedtls/asn1.h>
#include <mbedtls/oid.h>
#include <mbedtls/platform.h>
+#include <arch_helpers.h>
+#include <drivers/auth/img_parser_mod.h>
+#include <drivers/auth/mbedtls/mbedtls_common.h>
+#include <lib/utils.h>
+
/* Maximum OID string length ("a.b.c.d.e.f ...") */
#define MAX_OID_STR_LEN 64
diff --git a/drivers/auth/tbbr/tbbr_cot.c b/drivers/auth/tbbr/tbbr_cot.c
index a950a7a..ec14a18 100644
--- a/drivers/auth/tbbr/tbbr_cot.c
+++ b/drivers/auth/tbbr/tbbr_cot.c
@@ -4,12 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <auth_mod.h>
-#include <platform_def.h>
#include <stddef.h>
+#include <platform_def.h>
+
+#include <drivers/auth/auth_mod.h>
#if USE_TBBR_DEFS
-#include <tbbr_oid.h>
+#include <tools_share/tbbr_oid.h>
#else
#include <platform_oid.h>
#endif
diff --git a/drivers/cadence/uart/aarch64/cdns_console.S b/drivers/cadence/uart/aarch64/cdns_console.S
index 418810e..43d08f4 100644
--- a/drivers/cadence/uart/aarch64/cdns_console.S
+++ b/drivers/cadence/uart/aarch64/cdns_console.S
@@ -6,9 +6,9 @@
#include <arch.h>
#include <asm_macros.S>
#include <assert_macros.S>
-#include <cadence/cdns_uart.h>
#define USE_FINISH_CONSOLE_REG_2
#include <console_macros.S>
+#include <drivers/cadence/cdns_uart.h>
/*
* "core" functions are low-level implementations that don't require
diff --git a/drivers/cfi/v2m/v2m_flash.c b/drivers/cfi/v2m/v2m_flash.c
index 9b80e2f..aadafbc 100644
--- a/drivers/cfi/v2m/v2m_flash.c
+++ b/drivers/cfi/v2m/v2m_flash.c
@@ -5,8 +5,9 @@
*/
#include <errno.h>
-#include <mmio.h>
-#include <v2m_flash.h>
+
+#include <drivers/cfi/v2m_flash.h>
+#include <lib/mmio.h>
/*
* This file supplies a low level interface to the vexpress NOR flash
diff --git a/drivers/console/multi_console.c b/drivers/console/multi_console.c
index c678de0..e94de35 100644
--- a/drivers/console/multi_console.c
+++ b/drivers/console/multi_console.c
@@ -7,6 +7,7 @@
#if MULTI_CONSOLE_API
#include <assert.h>
+
#include <drivers/console.h>
console_t *console_list;
diff --git a/drivers/coreboot/cbmem_console/aarch64/cbmem_console.S b/drivers/coreboot/cbmem_console/aarch64/cbmem_console.S
index 89be349..4c14b69 100644
--- a/drivers/coreboot/cbmem_console/aarch64/cbmem_console.S
+++ b/drivers/coreboot/cbmem_console/aarch64/cbmem_console.S
@@ -5,9 +5,9 @@
*/
#include <asm_macros.S>
-#include <cbmem_console.h>
#define USE_FINISH_CONSOLE_REG_2
#include <console_macros.S>
+#include <drivers/coreboot/cbmem_console.h>
/*
* This driver implements access to coreboot's in-memory console
diff --git a/drivers/delay_timer/delay_timer.c b/drivers/delay_timer/delay_timer.c
index feac357..8c2996e 100644
--- a/drivers/delay_timer/delay_timer.c
+++ b/drivers/delay_timer/delay_timer.c
@@ -5,9 +5,11 @@
*/
#include <assert.h>
-#include <delay_timer.h>
+
#include <platform_def.h>
-#include <utils_def.h>
+
+#include <drivers/delay_timer.h>
+#include <lib/utils_def.h>
/***********************************************************
* The delay timer implementation
diff --git a/drivers/delay_timer/generic_delay_timer.c b/drivers/delay_timer/generic_delay_timer.c
index 03ca532..4b67ed0 100644
--- a/drivers/delay_timer/generic_delay_timer.c
+++ b/drivers/delay_timer/generic_delay_timer.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <generic_delay_timer.h>
-#include <platform.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/generic_delay_timer.h>
+#include <plat/common/platform.h>
/* Ticks elapsed in one second by a signal of 1 MHz */
#define MHZ_TICKS_PER_SEC 1000000
diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c
index 62f3dc2..76612b2 100644
--- a/drivers/gpio/gpio.c
+++ b/drivers/gpio/gpio.c
@@ -11,7 +11,8 @@
#include <assert.h>
#include <errno.h>
-#include <gpio.h>
+
+#include <drivers/gpio.h>
/*
* The gpio implementation
diff --git a/drivers/imx/timer/imx_gpt.c b/drivers/imx/timer/imx_gpt.c
index bd364eb..464efe9 100644
--- a/drivers/imx/timer/imx_gpt.c
+++ b/drivers/imx/timer/imx_gpt.c
@@ -5,8 +5,10 @@
*/
#include <assert.h>
-#include <delay_timer.h>
-#include <mmio.h>
+
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
#include <imx_gpt.h>
#define GPTCR_SWR BIT(15) /* Software reset */
diff --git a/drivers/imx/uart/imx_uart.c b/drivers/imx/uart/imx_uart.c
index 0250a41..68d31c8 100644
--- a/drivers/imx/uart/imx_uart.c
+++ b/drivers/imx/uart/imx_uart.c
@@ -3,10 +3,14 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
+
#include <stdint.h>
-#include <mmio.h>
+
#include <platform_def.h>
+
+#include <arch.h>
+#include <lib/mmio.h>
+
#include <imx_uart.h>
/* TX/RX FIFO threshold */
diff --git a/drivers/imx/usdhc/imx_usdhc.c b/drivers/imx/usdhc/imx_usdhc.c
index 1f9550e..07f55b7 100644
--- a/drivers/imx/usdhc/imx_usdhc.c
+++ b/drivers/imx/usdhc/imx_usdhc.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/mmc.h>
+#include <lib/mmio.h>
+
#include <imx_usdhc.h>
-#include <mmc.h>
-#include <errno.h>
-#include <mmio.h>
-#include <string.h>
static void imx_usdhc_initialize(void);
static int imx_usdhc_send_cmd(struct mmc_cmd *cmd);
diff --git a/drivers/imx/usdhc/imx_usdhc.h b/drivers/imx/usdhc/imx_usdhc.h
index 9ff3298..e063316 100644
--- a/drivers/imx/usdhc/imx_usdhc.h
+++ b/drivers/imx/usdhc/imx_usdhc.h
@@ -7,7 +7,7 @@
#ifndef IMX_USDHC_H
#define IMX_USDHC_H
-#include <mmc.h>
+#include <drivers/mmc.h>
typedef struct imx_usdhc_params {
uintptr_t reg_base;
diff --git a/drivers/io/io_block.c b/drivers/io/io_block.c
index 8226554..f190a43 100644
--- a/drivers/io/io_block.c
+++ b/drivers/io/io_block.c
@@ -5,14 +5,16 @@
*/
#include <assert.h>
-#include <debug.h>
#include <errno.h>
-#include <io_block.h>
-#include <io_driver.h>
-#include <io_storage.h>
-#include <platform_def.h>
#include <string.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <drivers/io/io_block.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_storage.h>
+#include <lib/utils.h>
typedef struct {
io_block_dev_spec_t *dev_spec;
@@ -67,8 +69,10 @@
static int find_first_block_state(const io_block_dev_spec_t *dev_spec,
unsigned int *index_out)
{
+ unsigned int index;
int result = -ENOENT;
- for (int index = 0; index < MAX_IO_BLOCK_DEVICES; ++index) {
+
+ for (index = 0U; index < MAX_IO_BLOCK_DEVICES; ++index) {
/* dev_spec is used as identifier since it's unique */
if (state_pool[index].dev_spec == dev_spec) {
result = 0;
diff --git a/drivers/io/io_dummy.c b/drivers/io/io_dummy.c
index d4020e3..4f0cda6 100644
--- a/drivers/io/io_dummy.c
+++ b/drivers/io/io_dummy.c
@@ -5,12 +5,13 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <io_driver.h>
-#include <io_dummy.h>
-#include <io_storage.h>
#include <string.h>
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_dummy.h>
+#include <drivers/io/io_storage.h>
+
struct file_state {
int in_use;
size_t size;
diff --git a/drivers/io/io_fip.c b/drivers/io/io_fip.c
index 9d6c763..d4771b5 100644
--- a/drivers/io/io_fip.c
+++ b/drivers/io/io_fip.c
@@ -5,19 +5,21 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
#include <errno.h>
-#include <firmware_image_package.h>
-#include <io_driver.h>
-#include <io_fip.h>
-#include <io_storage.h>
-#include <platform.h>
-#include <platform_def.h>
#include <stdint.h>
#include <string.h>
-#include <utils.h>
-#include <uuid.h>
+
+#include <platform_def.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_storage.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+#include <tools_share/firmware_image_package.h>
+#include <tools_share/uuid.h>
#ifndef MAX_FIP_DEVICES
#define MAX_FIP_DEVICES 1
diff --git a/drivers/io/io_memmap.c b/drivers/io/io_memmap.c
index 5595e60..96590b6 100644
--- a/drivers/io/io_memmap.c
+++ b/drivers/io/io_memmap.c
@@ -5,13 +5,15 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <io_driver.h>
-#include <io_memmap.h>
-#include <io_storage.h>
-#include <platform_def.h>
#include <string.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_memmap.h>
+#include <drivers/io/io_storage.h>
+#include <lib/utils.h>
/* As we need to be able to keep state for seek, only one file can be open
* at a time. Make this a structure and point to the entity->info. When we
diff --git a/drivers/io/io_semihosting.c b/drivers/io/io_semihosting.c
index 9ca0a9d..23d09c1 100644
--- a/drivers/io/io_semihosting.c
+++ b/drivers/io/io_semihosting.c
@@ -5,13 +5,13 @@
*/
#include <assert.h>
-#include <io_driver.h>
-#include <io_semihosting.h>
-#include <io_storage.h>
+
#include <platform_def.h>
-#include <semihosting.h>
-
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_semihosting.h>
+#include <drivers/io/io_storage.h>
+#include <lib/semihosting.h>
/* Identify the device type as semihosting */
static io_type_t device_type_sh(void)
diff --git a/drivers/io/io_storage.c b/drivers/io/io_storage.c
index 948f848..c9ff31b 100644
--- a/drivers/io/io_storage.c
+++ b/drivers/io/io_storage.c
@@ -5,11 +5,12 @@
*/
#include <assert.h>
-#include <io_driver.h>
-#include <io_storage.h>
-#include <platform_def.h>
#include <stddef.h>
+#include <platform_def.h>
+
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_storage.h>
/* Storage for a fixed maximum number of IO entities, definable by platform */
static io_entity_t entity_pool[MAX_IO_HANDLES];
diff --git a/drivers/marvell/amb_adec.c b/drivers/marvell/amb_adec.c
index 16fe772..1f67105 100644
--- a/drivers/marvell/amb_adec.c
+++ b/drivers/marvell/amb_adec.c
@@ -7,9 +7,10 @@
/* AXI to M-Bridge decoding unit driver for Marvell Armada 8K and 8K+ SoCs */
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include <armada_common.h>
-#include <debug.h>
-#include <mmio.h>
#include <mvebu.h>
#include <mvebu_def.h>
diff --git a/drivers/marvell/ap807_clocks_init.c b/drivers/marvell/ap807_clocks_init.c
index 841e6ae..04c256b 100644
--- a/drivers/marvell/ap807_clocks_init.c
+++ b/drivers/marvell/ap807_clocks_init.c
@@ -5,10 +5,11 @@
* https://spdx.org/licenses
*/
+#include <drivers/delay_timer.h>
+#include <drivers/marvell/aro.h>
+#include <lib/mmio.h>
+
#include <a8k_plat_def.h>
-#include <aro.h>
-#include <delay_timer.h>
-#include <mmio.h>
/* Notify bootloader on DRAM setup */
#define AP807_CPU_ARO_CTRL(cluster) \
diff --git a/drivers/marvell/cache_llc.c b/drivers/marvell/cache_llc.c
index e13e6ce..3df93a4 100644
--- a/drivers/marvell/cache_llc.c
+++ b/drivers/marvell/cache_llc.c
@@ -9,11 +9,13 @@
* for Marvell SoCs in AP806, AP807, and AP810
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <cache_llc.h>
-#include <ccu.h>
-#include <mmio.h>
+
+#include <arch_helpers.h>
+#include <drivers/marvell/cache_llc.h>
+#include <drivers/marvell/ccu.h>
+#include <lib/mmio.h>
+
#include <mvebu_def.h>
#define CCU_HTC_CR(ap_index) (MVEBU_CCU_BASE(ap_index) + 0x200)
diff --git a/drivers/marvell/ccu.c b/drivers/marvell/ccu.c
index acb1c00..1e4ab44 100644
--- a/drivers/marvell/ccu.c
+++ b/drivers/marvell/ccu.c
@@ -7,10 +7,11 @@
/* CCU unit device driver for Marvell AP807, AP807 and AP810 SoCs */
+#include <common/debug.h>
+#include <drivers/marvell/ccu.h>
+#include <lib/mmio.h>
+
#include <armada_common.h>
-#include <ccu.h>
-#include <debug.h>
-#include <mmio.h>
#include <mvebu.h>
#include <mvebu_def.h>
diff --git a/drivers/marvell/comphy/phy-comphy-3700.c b/drivers/marvell/comphy/phy-comphy-3700.c
index 53a59b0..2e8c412 100644
--- a/drivers/marvell/comphy/phy-comphy-3700.c
+++ b/drivers/marvell/comphy/phy-comphy-3700.c
@@ -5,13 +5,16 @@
* https://spdx.org/licenses
*/
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <mmio.h>
+
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/spinlock.h>
+
#include <mvebu.h>
#include <mvebu_def.h>
-#include <spinlock.h>
+
#include "phy-comphy-3700.h"
#include "phy-comphy-common.h"
diff --git a/drivers/marvell/comphy/phy-comphy-cp110.c b/drivers/marvell/comphy/phy-comphy-cp110.c
index 86e5f1c..384dd39 100644
--- a/drivers/marvell/comphy/phy-comphy-cp110.c
+++ b/drivers/marvell/comphy/phy-comphy-cp110.c
@@ -7,12 +7,14 @@
/* Marvell CP110 SoC COMPHY unit driver */
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <mmio.h>
+
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/spinlock.h>
+
#include <mvebu_def.h>
-#include <spinlock.h>
#include "mvebu.h"
#include "comphy-cp110.h"
#include "phy-comphy-cp110.h"
diff --git a/drivers/marvell/gwin.c b/drivers/marvell/gwin.c
index a4743eb..9d94308 100644
--- a/drivers/marvell/gwin.c
+++ b/drivers/marvell/gwin.c
@@ -7,10 +7,11 @@
/* GWIN unit device driver for Marvell AP810 SoC */
+#include <common/debug.h>
+#include <drivers/marvell/gwin.h>
+#include <lib/mmio.h>
+
#include <armada_common.h>
-#include <debug.h>
-#include <gwin.h>
-#include <mmio.h>
#include <mvebu.h>
#include <mvebu_def.h>
diff --git a/drivers/marvell/io_win.c b/drivers/marvell/io_win.c
index c0424e0..c4257fa 100644
--- a/drivers/marvell/io_win.c
+++ b/drivers/marvell/io_win.c
@@ -7,10 +7,11 @@
/* IO Window unit device driver for Marvell AP807, AP807 and AP810 SoCs */
+#include <common/debug.h>
+#include <drivers/marvell/io_win.h>
+#include <lib/mmio.h>
+
#include <armada_common.h>
-#include <debug.h>
-#include <io_win.h>
-#include <mmio.h>
#include <mvebu.h>
#include <mvebu_def.h>
diff --git a/drivers/marvell/iob.c b/drivers/marvell/iob.c
index e88bc16..87f147a 100644
--- a/drivers/marvell/iob.c
+++ b/drivers/marvell/iob.c
@@ -7,11 +7,12 @@
/* IOW unit device driver for Marvell CP110 and CP115 SoCs */
-#include <armada_common.h>
#include <arch_helpers.h>
-#include <debug.h>
-#include <iob.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/marvell/iob.h>
+#include <lib/mmio.h>
+
+#include <armada_common.h>
#include <mvebu.h>
#include <mvebu_def.h>
diff --git a/drivers/marvell/mc_trustzone/mc_trustzone.c b/drivers/marvell/mc_trustzone/mc_trustzone.c
index 0db3b8d..52b3006 100644
--- a/drivers/marvell/mc_trustzone/mc_trustzone.c
+++ b/drivers/marvell/mc_trustzone/mc_trustzone.c
@@ -5,10 +5,12 @@
* https://spdx.org/licenses
*/
-#include <addr_map.h>
-#include <debug.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/marvell/addr_map.h>
+#include <lib/mmio.h>
+
#include <mvebu_def.h>
+
#include "mc_trustzone.h"
#define TZ_SIZE(x) ((x) >> 13)
diff --git a/drivers/marvell/mc_trustzone/mc_trustzone.h b/drivers/marvell/mc_trustzone/mc_trustzone.h
index d36dcb5..296dce8 100644
--- a/drivers/marvell/mc_trustzone/mc_trustzone.h
+++ b/drivers/marvell/mc_trustzone/mc_trustzone.h
@@ -8,7 +8,7 @@
#ifndef MC_TRUSTZONE_H
#define MC_TRUSTZONE_H
-#include <addr_map.h>
+#include <drivers/marvell/addr_map.h>
#define MVEBU_TZ_MAX_WINS 16
diff --git a/drivers/marvell/mci.c b/drivers/marvell/mci.c
index 721504e..3a9859c 100644
--- a/drivers/marvell/mci.c
+++ b/drivers/marvell/mci.c
@@ -7,10 +7,11 @@
/* MCI bus driver for Marvell ARMADA 8K and 8K+ SoCs */
-#include <debug.h>
-#include <delay_timer.h>
-#include <mmio.h>
-#include <mci.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/marvell/mci.h>
+#include <lib/mmio.h>
+
#include <mvebu.h>
#include <mvebu_def.h>
#include <plat_marvell.h>
diff --git a/drivers/marvell/mochi/ap807_setup.c b/drivers/marvell/mochi/ap807_setup.c
index 075ca31..864c923 100644
--- a/drivers/marvell/mochi/ap807_setup.c
+++ b/drivers/marvell/mochi/ap807_setup.c
@@ -7,13 +7,14 @@
/* AP807 Marvell SoC driver */
-#include <ap_setup.h>
-#include <cache_llc.h>
-#include <ccu.h>
-#include <debug.h>
-#include <io_win.h>
-#include <mci.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/marvell/cache_llc.h>
+#include <drivers/marvell/ccu.h>
+#include <drivers/marvell/io_win.h>
+#include <drivers/marvell/mci.h>
+#include <drivers/marvell/mochi/ap_setup.h>
+#include <lib/mmio.h>
+
#include <mvebu_def.h>
#define SMMU_sACR (MVEBU_SMMU_BASE + 0x10)
diff --git a/drivers/marvell/mochi/apn806_setup.c b/drivers/marvell/mochi/apn806_setup.c
index 1d33be9..1e91c43 100644
--- a/drivers/marvell/mochi/apn806_setup.c
+++ b/drivers/marvell/mochi/apn806_setup.c
@@ -7,13 +7,14 @@
/* AP806 Marvell SoC driver */
-#include <ap_setup.h>
-#include <ccu.h>
-#include <cache_llc.h>
-#include <debug.h>
-#include <io_win.h>
-#include <mci.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/marvell/ccu.h>
+#include <drivers/marvell/cache_llc.h>
+#include <drivers/marvell/io_win.h>
+#include <drivers/marvell/mci.h>
+#include <drivers/marvell/mochi/ap_setup.h>
+#include <lib/mmio.h>
+
#include <mvebu_def.h>
#define SMMU_sACR (MVEBU_SMMU_BASE + 0x10)
diff --git a/drivers/marvell/mochi/cp110_setup.c b/drivers/marvell/mochi/cp110_setup.c
index 654bb62..d7d7373 100644
--- a/drivers/marvell/mochi/cp110_setup.c
+++ b/drivers/marvell/mochi/cp110_setup.c
@@ -7,11 +7,12 @@
/* CP110 Marvell SoC driver */
-#include <amb_adec.h>
-#include <cp110_setup.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <iob.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/marvell/amb_adec.h>
+#include <drivers/marvell/iob.h>
+#include <drivers/marvell/mochi/cp110_setup.h>
+
#include <plat_marvell.h>
/*
diff --git a/drivers/marvell/thermal.c b/drivers/marvell/thermal.c
index c7ceb92..a501ab4 100644
--- a/drivers/marvell/thermal.c
+++ b/drivers/marvell/thermal.c
@@ -7,8 +7,8 @@
/* Driver for thermal unit located in Marvell ARMADA 8K and compatible SoCs */
-#include <debug.h>
-#include <thermal.h>
+#include <common/debug.h>
+#include <drivers/marvell/thermal.h>
int marvell_thermal_init(struct tsen_config *tsen_cfg)
{
diff --git a/drivers/marvell/uart/a3700_console.S b/drivers/marvell/uart/a3700_console.S
index 25c21cf..cc3855d 100644
--- a/drivers/marvell/uart/a3700_console.S
+++ b/drivers/marvell/uart/a3700_console.S
@@ -7,9 +7,9 @@
#include <arch.h>
#include <asm_macros.S>
-#include <a3700_console.h>
#define USE_FINISH_CONSOLE_REG_2
#include <console_macros.S>
+#include <drivers/marvell/uart/a3700_console.h>
/*
* "core" functions are low-level implementations that don't require
diff --git a/drivers/mentor/i2c/mi2cv.c b/drivers/mentor/i2c/mi2cv.c
index 8ebd966..1cdcf74 100644
--- a/drivers/mentor/i2c/mi2cv.c
+++ b/drivers/mentor/i2c/mi2cv.c
@@ -11,12 +11,14 @@
* for Marvell and Allwinner SoCs in ATF.
*/
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <mentor/mi2cv.h>
+
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/mentor/mi2cv.h>
+#include <lib/mmio.h>
+
#include <mentor_i2c_plat.h>
-#include <mmio.h>
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
#define DEBUG_I2C
diff --git a/drivers/meson/console/aarch64/meson_console.S b/drivers/meson/console/aarch64/meson_console.S
index eaee10e..5cf9b88 100644
--- a/drivers/meson/console/aarch64/meson_console.S
+++ b/drivers/meson/console/aarch64/meson_console.S
@@ -8,7 +8,7 @@
#include <assert_macros.S>
#define USE_FINISH_CONSOLE_REG_2
#include <console_macros.S>
-#include <meson_console.h>
+#include <drivers/meson/meson_console.h>
.globl console_meson_register
.globl console_meson_init
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 6d5ba9d..450bd0b 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -6,15 +6,16 @@
/* Define a simple and generic interface to access eMMC and SD-card devices. */
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <mmc.h>
#include <stdbool.h>
#include <string.h>
-#include <utils.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/mmc.h>
+#include <lib/utils.h>
#define MMC_DEFAULT_MAX_RETRIES 5
#define SEND_OP_COND_MAX_RETRIES 100
diff --git a/drivers/partition/gpt.c b/drivers/partition/gpt.c
index 0c51e62..4577f06 100644
--- a/drivers/partition/gpt.c
+++ b/drivers/partition/gpt.c
@@ -5,11 +5,12 @@
*/
#include <assert.h>
-#include <debug.h>
#include <errno.h>
-#include <gpt.h>
#include <string.h>
-#include <utils.h>
+
+#include <common/debug.h>
+#include <drivers/partition/gpt.h>
+#include <lib/utils.h>
static int unicode_to_ascii(unsigned short *str_in, unsigned char *str_out)
{
diff --git a/drivers/partition/partition.c b/drivers/partition/partition.c
index 6085b86..07869ac 100644
--- a/drivers/partition/partition.c
+++ b/drivers/partition/partition.c
@@ -5,15 +5,16 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <gpt.h>
-#include <io_storage.h>
-#include <mbr.h>
-#include <partition.h>
-#include <platform.h>
#include <stdio.h>
#include <string.h>
+#include <common/debug.h>
+#include <drivers/io/io_storage.h>
+#include <drivers/partition/partition.h>
+#include <drivers/partition/gpt.h>
+#include <drivers/partition/mbr.h>
+#include <plat/common/platform.h>
+
static uint8_t mbr_sector[PARTITION_BLOCK_SIZE];
partition_entry_list_t list;
diff --git a/drivers/renesas/rcar/auth/auth_mod.c b/drivers/renesas/rcar/auth/auth_mod.c
index 04ed279..f7d8ec0 100644
--- a/drivers/renesas/rcar/auth/auth_mod.c
+++ b/drivers/renesas/rcar/auth/auth_mod.c
@@ -5,13 +5,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
#include <stddef.h>
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include "rom_api.h"
typedef int32_t(*secure_boot_api_f) (uint32_t a, uint32_t b, void *c);
@@ -111,7 +113,7 @@
}
#if RCAR_BL2_DCACHE == 1
/* clean and disable */
- write_sctlr_el1(read_sctlr_el1() & ~SCTLR_C_BIT);
+ write_sctlr_el3(read_sctlr_el3() & ~SCTLR_C_BIT);
dcsw_op_all(DCCISW);
#endif
ret = (mmio_read_32(RCAR_BOOT_KEY_CERT_NEW) == RCAR_CERT_MAGIC_NUM) ?
@@ -122,7 +124,7 @@
#if RCAR_BL2_DCACHE == 1
/* enable */
- write_sctlr_el1(read_sctlr_el1() | SCTLR_C_BIT);
+ write_sctlr_el3(read_sctlr_el3() | SCTLR_C_BIT);
#endif
#endif
diff --git a/drivers/renesas/rcar/avs/avs_driver.c b/drivers/renesas/rcar/avs/avs_driver.c
index 80a7c91..647869e 100644
--- a/drivers/renesas/rcar/avs/avs_driver.c
+++ b/drivers/renesas/rcar/avs/avs_driver.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
-#include <debug.h>
-#include <utils_def.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
+
#include "cpg_registers.h"
#include "avs_driver.h"
#include "rcar_def.h"
diff --git a/drivers/renesas/rcar/board/board.c b/drivers/renesas/rcar/board/board.c
index 147a0b0..f15e06b 100644
--- a/drivers/renesas/rcar/board/board.c
+++ b/drivers/renesas/rcar/board/board.c
@@ -6,9 +6,12 @@
*/
#include <stdint.h>
+
+#include <lib/utils_def.h>
+
#include <iic_dvfs.h>
+
#include "board.h"
-#include "utils_def.h"
#ifndef BOARD_DEFAULT
#if (RCAR_LSI == RCAR_E3)
diff --git a/drivers/renesas/rcar/common.c b/drivers/renesas/rcar/common.c
index e82e8b5..42bdce5 100644
--- a/drivers/renesas/rcar/common.c
+++ b/drivers/renesas/rcar/common.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include "rcar_private.h"
void
diff --git a/drivers/renesas/rcar/console/rcar_printf.c b/drivers/renesas/rcar/console/rcar_printf.c
index 9321b58..2a6e2c0 100644
--- a/drivers/renesas/rcar/console/rcar_printf.c
+++ b/drivers/renesas/rcar/console/rcar_printf.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
#include <stdarg.h>
#include <stdint.h>
-#include <arch_helpers.h>
-#include <platform_def.h>
-#include <bakery_lock.h>
-#include "rcar_def.h"
-#include "rcar_private.h"
-#include "rcar_printf.h"
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/bakery_lock.h>
+
+#include "rcar_def.h"
+#include "rcar_private.h"
+#include "rcar_printf.h"
#define INDEX_TIMER_COUNT (4U)
diff --git a/drivers/renesas/rcar/cpld/ulcb_cpld.c b/drivers/renesas/rcar/cpld/ulcb_cpld.c
index 92e438a..6b03614 100644
--- a/drivers/renesas/rcar/cpld/ulcb_cpld.c
+++ b/drivers/renesas/rcar/cpld/ulcb_cpld.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
+#include <lib/mmio.h>
+#include "ulcb_cpld.h"
#define SCLK 8 /* GP_6_8 */
#define SSTBZ 3 /* GP_2_3 */
diff --git a/drivers/renesas/rcar/cpld/ulcb_cpld.h b/drivers/renesas/rcar/cpld/ulcb_cpld.h
new file mode 100644
index 0000000..1616d71
--- /dev/null
+++ b/drivers/renesas/rcar/cpld/ulcb_cpld.h
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2018, Renesas Electronics Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef RCAR_ULCB_CPLD_H__
+#define RCAR_ULCB_CPLD_H__
+
+extern void rcar_cpld_reset_cpu(void);
+
+#endif /* RCAR_ULCB_CPLD_H__ */
diff --git a/drivers/renesas/rcar/delay/micro_delay.S b/drivers/renesas/rcar/delay/micro_delay.S
deleted file mode 100644
index 978973c..0000000
--- a/drivers/renesas/rcar/delay/micro_delay.S
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2015-2018, Renesas Electronics Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <arch.h>
-#include <asm_macros.S>
-#include "micro_delay.h"
-
-#define CPG_BASE (0xE6150000)
-#define CPG_SMSTPCR1 (0x0134)
-#define CPG_CPGWPR (0x0900)
-
-/* Module bit for TMU ch3-5 */
-#define MSTPCR1_TMU1 (1 << 24)
-
-#define TMU3_BASE (0xE6FC0000)
-#define TMU_TSTR (0x0004)
-#define TMU_TCOR (0x0008)
-#define TMU_TCNT (0x000C)
-#define TMU_TCR (0x0010)
-/* Start bit for TMU ch3 */
-#define TSTR1_TMU3 (1 << 0)
-
-#define MIDR_CA57 (0x0D07 << MIDR_PN_SHIFT)
-#define MIDR_CA53 (0x0D03 << MIDR_PN_SHIFT)
-
- .globl rcar_micro_delay
-#if (TMU3_MEASUREMENT == 1)
- .globl tmu3_init
- .globl tmu3_start
- .globl tmu3_stop
- .globl tcnt3_snapshot
-#endif
- /* Aligned with the cache line */
- .align 6
-
-func rcar_micro_delay
- cbz x0, micro_delay_e
- mrs x1, midr_el1
- and x1, x1, #MIDR_PN_MASK << MIDR_PN_SHIFT
- mov w2, #MIDR_CA53
- cmp w1, w2
- b.eq micro_delay_ca53
- b micro_delay_ca57
-micro_delay_e:
- ret
-endfunc rcar_micro_delay
-
-func micro_delay_ca57
-ca57_loop_1:
- mov x1, #185
-ca57_loop_2:
- subs x1, x1, #1
- b.ne ca57_loop_2
- subs x0, x0, #1
- b.ne ca57_loop_1
- ret
-endfunc micro_delay_ca57
-
-func micro_delay_ca53
-ca53_loop_1:
- mov x1, #134
-ca53_loop_2:
- subs x1, x1, #1
- b.ne ca53_loop_2
- subs x0, x0, #1
- b.ne ca53_loop_1
- ret
-endfunc micro_delay_ca53
-
-#if (TMU3_MEASUREMENT == 1)
-func tmu3_init
- ldr x2, =CPG_BASE
- ldr w0, [x2, #CPG_SMSTPCR1]
- ldr w1, [x2, #CPG_MSTPSR1]
- ldr w2, #MSTPCR1_TMU1
- bl mstpcr_write
- ret
-endfunc tmu3_init
-
-func tmu3_start
- ldr x0, =TMU3_BASE
- mov w1, #0xFFFFFFFF
- str w1, [x0, TMU_TCNT]
-
- ldr x0, =TMU3_BASE
- ldrb w1, [x0, TMU_TSTR]
- orr w1, w1, #TSTR1_TMU3
- strb w1, [x0, TMU_TSTR]
- ret
-endfunc tmu3_start
-
-func tcnt3_snapshot
- ldr x0, =TMU3_BASE
- ldr w0, [x0, TMU_TCNT]
- ret
-endfunc tcnt3_snapshot
-
-
-func tmu3_stop
- ldr x0, =TMU3_BASE
- ldrb w1, [x0, TMU_TSTR]
- and w1, w1, #~TSTR1_TMU3
- strb w1, [x0, TMU_TSTR]
- ret
-endfunc tmu3_stop
-#endif
diff --git a/drivers/renesas/rcar/delay/micro_delay.c b/drivers/renesas/rcar/delay/micro_delay.c
new file mode 100644
index 0000000..aced589
--- /dev/null
+++ b/drivers/renesas/rcar/delay/micro_delay.c
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2018, Renesas Electronics Corporation. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include "micro_delay.h"
+
+#define RCAR_CONV_MICROSEC 1000000U
+
+void
+#if IMAGE_BL31
+ __attribute__ ((section (".system_ram")))
+#endif
+ rcar_micro_delay(uint64_t micro_sec)
+{
+ uint64_t freq;
+ uint64_t base_count;
+ uint64_t get_count;
+ uint64_t wait_time = 0U;
+
+ freq = read_cntfrq_el0();
+ base_count = read_cntpct_el0();
+ while (micro_sec > wait_time) {
+ get_count = read_cntpct_el0();
+ wait_time = ((get_count - base_count) * RCAR_CONV_MICROSEC) / freq;
+ }
+}
diff --git a/drivers/renesas/rcar/delay/micro_delay.h b/drivers/renesas/rcar/delay/micro_delay.h
index 458959f..193daba 100644
--- a/drivers/renesas/rcar/delay/micro_delay.h
+++ b/drivers/renesas/rcar/delay/micro_delay.h
@@ -7,20 +7,9 @@
#ifndef MICRO_DELAY_H
#define MICRO_DELAY_H
-#define TMU3_MEASUREMENT (0)
-
#ifndef __ASSEMBLY__
-#include "stdint.h"
-void rcar_micro_delay(uint32_t count_us);
-
-#if (TMU3_MEASUREMENT == 1)
-void tmu3_start(void);
-void tmu3_init(void);
-void tmu3_stop(void);
-
-uint32_t tcnt3_snapshot(void);
-#endif
-
+#include <stdint.h>
+void rcar_micro_delay(uint64_t micro_sec);
#endif
#endif /* MICRO_DELAY_H */
diff --git a/drivers/renesas/rcar/dma/dma_driver.c b/drivers/renesas/rcar/dma/dma_driver.c
index d4fa65d..fef55c4 100644
--- a/drivers/renesas/rcar/dma/dma_driver.c
+++ b/drivers/renesas/rcar/dma/dma_driver.c
@@ -5,12 +5,14 @@
*/
#include <stdint.h>
-#include <arch_helpers.h>
#include <string.h>
-#include <mmio.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "rcar_def.h"
#include "cpg_registers.h"
-#include "debug.h"
#include "rcar_private.h"
/* DMA CHANNEL setting (0/16/32) */
diff --git a/drivers/renesas/rcar/emmc/emmc_cmd.c b/drivers/renesas/rcar/emmc/emmc_cmd.c
index 0f39349..a2e25e3 100644
--- a/drivers/renesas/rcar/emmc/emmc_cmd.c
+++ b/drivers/renesas/rcar/emmc/emmc_cmd.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
+#include <common/debug.h>
+
#include "emmc_config.h"
#include "emmc_hal.h"
#include "emmc_std.h"
diff --git a/drivers/renesas/rcar/emmc/emmc_init.c b/drivers/renesas/rcar/emmc/emmc_init.c
index 386fb1e..b27e165 100644
--- a/drivers/renesas/rcar/emmc/emmc_init.c
+++ b/drivers/renesas/rcar/emmc/emmc_init.c
@@ -5,7 +5,9 @@
*/
#include <stddef.h>
-#include <mmio.h>
+
+#include <lib/mmio.h>
+
#include "emmc_config.h"
#include "emmc_hal.h"
#include "emmc_std.h"
diff --git a/drivers/renesas/rcar/emmc/emmc_interrupt.c b/drivers/renesas/rcar/emmc/emmc_interrupt.c
index 3077db4..37a3cf9 100644
--- a/drivers/renesas/rcar/emmc/emmc_interrupt.c
+++ b/drivers/renesas/rcar/emmc/emmc_interrupt.c
@@ -5,6 +5,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <stddef.h>
+
+#include <lib/mmio.h>
#include "emmc_config.h"
#include "emmc_def.h"
@@ -13,9 +16,6 @@
#include "emmc_std.h"
#include "rcar_def.h"
-#include <mmio.h>
-#include <stddef.h>
-
static EMMC_ERROR_CODE emmc_trans_sector(uint32_t *buff_address_virtual);
uint32_t emmc_interrupt(void)
diff --git a/drivers/renesas/rcar/emmc/emmc_mount.c b/drivers/renesas/rcar/emmc/emmc_mount.c
index 9a7d2ca..dd57b0c 100644
--- a/drivers/renesas/rcar/emmc/emmc_mount.c
+++ b/drivers/renesas/rcar/emmc/emmc_mount.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "emmc_config.h"
#include "emmc_hal.h"
#include "emmc_std.h"
diff --git a/drivers/renesas/rcar/emmc/emmc_read.c b/drivers/renesas/rcar/emmc/emmc_read.c
index b11c2c4..390d0ca 100644
--- a/drivers/renesas/rcar/emmc/emmc_read.c
+++ b/drivers/renesas/rcar/emmc/emmc_read.c
@@ -3,7 +3,9 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <arch_helpers.h>
+
#include "emmc_config.h"
#include "emmc_hal.h"
#include "emmc_std.h"
diff --git a/drivers/renesas/rcar/emmc/emmc_utility.c b/drivers/renesas/rcar/emmc/emmc_utility.c
index e64947d..39d9ede 100644
--- a/drivers/renesas/rcar/emmc/emmc_utility.c
+++ b/drivers/renesas/rcar/emmc/emmc_utility.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
+#include <common/debug.h>
+
#include "emmc_config.h"
#include "emmc_hal.h"
#include "emmc_std.h"
diff --git a/drivers/renesas/rcar/iic_dvfs/iic_dvfs.c b/drivers/renesas/rcar/iic_dvfs/iic_dvfs.c
index 11d52bf..39b9bb4 100644
--- a/drivers/renesas/rcar/iic_dvfs/iic_dvfs.c
+++ b/drivers/renesas/rcar/iic_dvfs/iic_dvfs.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
-#include <debug.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "rcar_def.h"
#include "cpg_registers.h"
#include "iic_dvfs.h"
diff --git a/drivers/renesas/rcar/io/io_emmcdrv.c b/drivers/renesas/rcar/io/io_emmcdrv.c
index f74bd5f..4b464fb 100644
--- a/drivers/renesas/rcar/io/io_emmcdrv.c
+++ b/drivers/renesas/rcar/io/io_emmcdrv.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <io_driver.h>
-#include <io_storage.h>
#include <string.h>
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_storage.h>
+
#include "io_common.h"
#include "io_emmcdrv.h"
#include "io_private.h"
diff --git a/drivers/renesas/rcar/io/io_memdrv.c b/drivers/renesas/rcar/io/io_memdrv.c
index e55fd64..3f6b4c7 100644
--- a/drivers/renesas/rcar/io/io_memdrv.c
+++ b/drivers/renesas/rcar/io/io_memdrv.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <io_driver.h>
-#include <io_storage.h>
#include <string.h>
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_storage.h>
+
#include "io_common.h"
#include "io_private.h"
#include "io_memdrv.h"
diff --git a/drivers/renesas/rcar/io/io_rcar.c b/drivers/renesas/rcar/io/io_rcar.c
index 4293c51..650931b 100644
--- a/drivers/renesas/rcar/io/io_rcar.c
+++ b/drivers/renesas/rcar/io/io_rcar.c
@@ -4,23 +4,27 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <auth_mod.h>
-#include <bl_common.h>
-#include <debug.h>
#include <errno.h>
-#include <firmware_image_package.h>
-#include <io_driver.h>
-#include <io_storage.h>
-#include <platform.h>
-#include <platform_def.h>
#include <stdint.h>
#include <string.h>
-#include <uuid.h>
-#include <mmio.h>
+
+#include <platform_def.h>
+
#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/auth/auth_mod.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_storage.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+#include <tools_share/firmware_image_package.h>
+#include <tools_share/uuid.h>
+
#include "io_rcar.h"
#include "io_common.h"
#include "io_private.h"
+
extern int32_t plat_get_drv_source(uint32_t id, uintptr_t *dev,
uintptr_t *image_spec);
diff --git a/drivers/renesas/rcar/pwrc/pwrc.c b/drivers/renesas/rcar/pwrc/pwrc.c
index 6dfc0b6..b005caf 100644
--- a/drivers/renesas/rcar/pwrc/pwrc.c
+++ b/drivers/renesas/rcar/pwrc/pwrc.c
@@ -4,17 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bakery_lock.h>
-#include <debug.h>
-#include <mmio.h>
-#include <string.h>
-#include <xlat_tables_v2.h>
+#include <common/debug.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+
#include "iic_dvfs.h"
#include "rcar_def.h"
#include "rcar_private.h"
+#include "micro_delay.h"
#include "pwrc.h"
/*
@@ -120,7 +123,6 @@
#define RST_BASE (0xE6160000U)
#define RST_MODEMR (RST_BASE + 0x0060U)
#define RST_MODEMR_BIT0 (0x00000001U)
-#define RCAR_CONV_MICROSEC (1000000U)
#if PMIC_ROHM_BD9571
#define BIT_BKUP_CTRL_OUT ((uint8_t)(1U << 4))
@@ -141,23 +143,6 @@
IMPORT_SYM(unsigned long, __SRAM_COPY_START__, SRAM_COPY_START);
#endif
-#if RCAR_SYSTEM_SUSPEND
-static void __attribute__ ((section (".system_ram")))
- rcar_pwrc_micro_delay(uint64_t micro_sec)
-{
- uint64_t freq, base, val;
- uint64_t wait_time = 0;
-
- freq = read_cntfrq_el0();
- base = read_cntpct_el0();
-
- while (micro_sec > wait_time) {
- val = read_cntpct_el0() - base;
- wait_time = val * RCAR_CONV_MICROSEC / freq;
- }
-}
-#endif
-
uint32_t rcar_pwrc_status(uint64_t mpidr)
{
uint32_t ret = 0;
@@ -412,7 +397,7 @@
mmio_write_32(DBSC4_REG_DBACEN, 0);
if (product == RCAR_PRODUCT_H3 && cut < RCAR_CUT_VER20)
- rcar_pwrc_micro_delay(100);
+ rcar_micro_delay(100);
else if (product == RCAR_PRODUCT_H3) {
mmio_write_32(DBSC4_REG_DBCAM0CTRL0, 1);
DBCAM_FLUSH(0);
@@ -463,7 +448,7 @@
/* Set the auto-refresh enable register */
mmio_write_32(DBSC4_REG_DBRFEN, 0U);
- rcar_pwrc_micro_delay(1U);
+ rcar_micro_delay(1U);
if (product == RCAR_PRODUCT_M3)
return;
@@ -648,7 +633,6 @@
DEVICE_SRAM_STACK_SIZE);
uint32_t sctlr;
- rcar_pwrc_code_copy_to_system_ram();
rcar_pwrc_save_generic_timer(rcar_stack_generic_timer);
/* disable MMU */
@@ -663,10 +647,7 @@
{
#if PMIC_ROHM_BD9571
uint8_t mode;
-#endif
- rcar_pwrc_code_copy_to_system_ram();
-#if PMIC_ROHM_BD9571
if (rcar_iic_dvfs_receive(PMIC, PMIC_BKUP_MODE_CNT, &mode))
panic();
@@ -681,7 +662,6 @@
#if RCAR_SYSTEM_RESET_KEEPON_DDR
int32_t error;
- rcar_pwrc_code_copy_to_system_ram();
error = rcar_iic_dvfs_send(PMIC, REG_KEEP10, 0);
if (error) {
ERROR("Failed send KEEP10 init ret=%d \n", error);
diff --git a/drivers/renesas/rcar/rom/rom_api.c b/drivers/renesas/rcar/rom/rom_api.c
index c14de55..be38fbf 100644
--- a/drivers/renesas/rcar/rom/rom_api.c
+++ b/drivers/renesas/rcar/rom/rom_api.c
@@ -4,8 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
#include <stdint.h>
+
+#include <lib/mmio.h>
+
#include "rcar_def.h"
#include "rom_api.h"
diff --git a/drivers/renesas/rcar/rpc/rpc_driver.c b/drivers/renesas/rcar/rpc/rpc_driver.c
index bc7424a..bea2752 100644
--- a/drivers/renesas/rcar/rpc/rpc_driver.c
+++ b/drivers/renesas/rcar/rpc/rpc_driver.c
@@ -4,12 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
#include <stdint.h>
#include <string.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "cpg_registers.h"
#include "rpc_registers.h"
-#include "debug.h"
#include "rcar_private.h"
#define MSTPSR9_RPC_BIT (0x00020000U)
diff --git a/drivers/renesas/rcar/scif/scif.S b/drivers/renesas/rcar/scif/scif.S
index 1cc0d59..09dc90b 100644
--- a/drivers/renesas/rcar/scif/scif.S
+++ b/drivers/renesas/rcar/scif/scif.S
@@ -75,6 +75,8 @@
#if SCIF_CLK == SCIF_EXTARNAL_CLK
#define SCSCR_CKE_INT_CLK (SCSCR_CKE_BRG)
#else
+#define SCFSR_TEND_MASK (1 << 6)
+#define SCFSR_TEND_TRANS_END (0x0040)
#define SCSCR_CKE_INT_CLK (SCSCR_CKE_INT)
#endif
#define SCFSR_INIT_DATA (0x0000)
@@ -281,6 +283,11 @@
bcs 2b
strb w0, [x1, #SCIF_SCFTDR]
+ /* Clear TEND flag */
+ ldrh w2, [x1, #SCIF_SCFSR]
+ and w2, w2, #~SCFSR_TEND_MASK
+ strh w2, [x1, #SCIF_SCFSR]
+
ret
endfunc console_core_putc
@@ -309,16 +316,12 @@
func console_flush
ldr x0, =SCIF2_BASE
1:
- ldrh w1, [x0, #SCIF_SCFDR]
- ubfx w1, w1, #8, #5
- cmp w1, #0
+ /* Check TEND flag */
+ ldrh w1, [x0, #SCIF_SCFSR]
+ and w1, w1, #SCFSR_TEND_MASK
+ cmp w1, #SCFSR_TEND_TRANS_END
bne 1b
- mov x0, #100
- mov x3, x30
- bl rcar_micro_delay
- mov x30, x3
-
ldr x0, =SCIF2_BASE
ldrh w1, [x0, #SCIF_SCSCR]
and w1, w1, #~(SCSCR_TE_EN + SCSCR_RE_EN)
diff --git a/drivers/renesas/rcar/watchdog/swdt.c b/drivers/renesas/rcar/watchdog/swdt.c
index f9dbf86..7793ae5 100644
--- a/drivers/renesas/rcar/watchdog/swdt.c
+++ b/drivers/renesas/rcar/watchdog/swdt.c
@@ -5,9 +5,10 @@
*/
#include <arch_helpers.h>
-#include <debug.h>
-#include <gicv2.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/mmio.h>
+
#include "rcar_def.h"
extern void gicd_set_icenabler(uintptr_t base, unsigned int id);
@@ -132,7 +133,11 @@
(ARM_IRQ_SEC_WDT & ~ITARGET_MASK);
uint32_t i;
+ /* Disable FIQ interrupt */
write_daifset(DAIF_FIQ_BIT);
+ /* FIQ interrupts are not taken to EL3 */
+ write_scr_el3(read_scr_el3() & ~SCR_FIQ_BIT);
+
swdt_disable();
gicv2_cpuif_disable();
diff --git a/drivers/st/clk/stm32mp1_clk.c b/drivers/st/clk/stm32mp1_clk.c
index b8457cb..e4cc9b9 100644
--- a/drivers/st/clk/stm32mp1_clk.c
+++ b/drivers/st/clk/stm32mp1_clk.c
@@ -4,26 +4,28 @@
* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
*/
-#include <arch.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <dt-bindings/clock/stm32mp1-clks.h>
-#include <dt-bindings/clock/stm32mp1-clksrc.h>
#include <errno.h>
-#include <generic_delay_timer.h>
-#include <libfdt.h>
-#include <mmio.h>
-#include <platform.h>
#include <stdint.h>
#include <stdio.h>
-#include <stm32mp1_clk.h>
-#include <stm32mp1_clkfunc.h>
-#include <stm32mp1_dt.h>
-#include <stm32mp1_private.h>
-#include <stm32mp1_rcc.h>
-#include <utils_def.h>
+
+#include <libfdt.h>
+
+#include <platform_def.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/generic_delay_timer.h>
+#include <drivers/st/stm32mp1_clk.h>
+#include <drivers/st/stm32mp1_clkfunc.h>
+#include <drivers/st/stm32mp1_rcc.h>
+#include <dt-bindings/clock/stm32mp1-clks.h>
+#include <dt-bindings/clock/stm32mp1-clksrc.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
+#include <plat/common/platform.h>
#define MAX_HSI_HZ 64000000
diff --git a/drivers/st/clk/stm32mp1_clkfunc.c b/drivers/st/clk/stm32mp1_clkfunc.c
index 078d803..1d92271 100644
--- a/drivers/st/clk/stm32mp1_clkfunc.c
+++ b/drivers/st/clk/stm32mp1_clkfunc.c
@@ -4,12 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <dt-bindings/clock/stm32mp1-clksrc.h>
#include <errno.h>
+
#include <libfdt.h>
-#include <stm32mp1_clk.h>
-#include <stm32mp1_clkfunc.h>
-#include <stm32mp1_dt.h>
+
+#include <platform_def.h>
+
+#include <drivers/st/stm32mp1_clk.h>
+#include <drivers/st/stm32mp1_clkfunc.h>
+#include <dt-bindings/clock/stm32mp1-clksrc.h>
#define DT_RCC_NODE_NAME "rcc@50000000"
#define DT_RCC_CLK_COMPAT "st,stm32mp1-rcc"
diff --git a/drivers/st/ddr/stm32mp1_ddr.c b/drivers/st/ddr/stm32mp1_ddr.c
index eed1d76..aca0450 100644
--- a/drivers/st/ddr/stm32mp1_ddr.c
+++ b/drivers/st/ddr/stm32mp1_ddr.c
@@ -4,22 +4,24 @@
* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
*/
+#include <stddef.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <debug.h>
-#include <delay_timer.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/st/stm32mp1_clk.h>
+#include <drivers/st/stm32mp1_ddr.h>
+#include <drivers/st/stm32mp1_ddr_regs.h>
+#include <drivers/st/stm32mp1_pmic.h>
+#include <drivers/st/stm32mp1_pwr.h>
+#include <drivers/st/stm32mp1_ram.h>
+#include <drivers/st/stm32mp1_rcc.h>
#include <dt-bindings/clock/stm32mp1-clks.h>
-#include <mmio.h>
-#include <platform.h>
-#include <stddef.h>
-#include <stm32mp1_clk.h>
-#include <stm32mp1_ddr.h>
-#include <stm32mp1_ddr_regs.h>
-#include <stm32mp1_dt.h>
-#include <stm32mp1_pmic.h>
-#include <stm32mp1_pwr.h>
-#include <stm32mp1_ram.h>
-#include <stm32mp1_rcc.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
struct reg_desc {
const char *name;
diff --git a/drivers/st/ddr/stm32mp1_ddr_helpers.c b/drivers/st/ddr/stm32mp1_ddr_helpers.c
index 325c0b8..a8c1b77 100644
--- a/drivers/st/ddr/stm32mp1_ddr_helpers.c
+++ b/drivers/st/ddr/stm32mp1_ddr_helpers.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
#include <platform_def.h>
-#include <stm32mp1_ddr_helpers.h>
-#include <stm32mp1_rcc.h>
+
+#include <drivers/st/stm32mp1_ddr_helpers.h>
+#include <drivers/st/stm32mp1_rcc.h>
+#include <lib/mmio.h>
void ddr_enable_clock(void)
{
diff --git a/drivers/st/ddr/stm32mp1_ram.c b/drivers/st/ddr/stm32mp1_ram.c
index 6d515ec..127b6c7 100644
--- a/drivers/st/ddr/stm32mp1_ram.c
+++ b/drivers/st/ddr/stm32mp1_ram.c
@@ -4,21 +4,21 @@
* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <boot_api.h>
-#include <debug.h>
-#include <dt-bindings/clock/stm32mp1-clks.h>
#include <errno.h>
+
#include <libfdt.h>
-#include <mmio.h>
+
#include <platform_def.h>
-#include <stm32mp1_clk.h>
-#include <stm32mp1_ddr.h>
-#include <stm32mp1_ddr_helpers.h>
-#include <stm32mp1_dt.h>
-#include <stm32mp1_private.h>
-#include <stm32mp1_ram.h>
-#include <stm32mp1_rcc.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/st/stm32mp1_clk.h>
+#include <drivers/st/stm32mp1_ddr.h>
+#include <drivers/st/stm32mp1_ddr_helpers.h>
+#include <drivers/st/stm32mp1_ram.h>
+#include <drivers/st/stm32mp1_rcc.h>
+#include <dt-bindings/clock/stm32mp1-clks.h>
+#include <lib/mmio.h>
#define DDR_PATTERN 0xAAAAAAAAU
#define DDR_ANTIPATTERN 0x55555555U
diff --git a/drivers/st/gpio/stm32_gpio.c b/drivers/st/gpio/stm32_gpio.c
index 200b473..9591e37 100644
--- a/drivers/st/gpio/stm32_gpio.c
+++ b/drivers/st/gpio/stm32_gpio.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <debug.h>
-#include <mmio.h>
#include <stdbool.h>
-#include <stm32_gpio.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/st/stm32_gpio.h>
+#include <lib/mmio.h>
static bool check_gpio(uint32_t bank, uint32_t pin)
{
diff --git a/drivers/st/io/io_mmc.c b/drivers/st/io/io_mmc.c
index 1ed2620..a239b5f 100644
--- a/drivers/st/io/io_mmc.c
+++ b/drivers/st/io/io_mmc.c
@@ -5,15 +5,16 @@
*/
#include <assert.h>
-#include <debug.h>
#include <errno.h>
-#include <io_driver.h>
-#include <io_mmc.h>
-#include <io_storage.h>
-#include <mmc.h>
-#include <stm32_sdmmc2.h>
#include <string.h>
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_storage.h>
+#include <drivers/mmc.h>
+#include <drivers/st/io_mmc.h>
+#include <drivers/st/stm32_sdmmc2.h>
+
/* SDMMC device functions */
static int mmc_dev_open(const uintptr_t init_params, io_dev_info_t **dev_info);
static int mmc_block_open(io_dev_info_t *dev_info, const uintptr_t spec,
diff --git a/drivers/st/io/io_stm32image.c b/drivers/st/io/io_stm32image.c
index e6798e0..0164a2d 100644
--- a/drivers/st/io/io_stm32image.c
+++ b/drivers/st/io/io_stm32image.c
@@ -5,17 +5,18 @@
*/
#include <assert.h>
-#include <boot_api.h>
-#include <debug.h>
#include <errno.h>
-#include <io_driver.h>
-#include <io_stm32image.h>
-#include <io_storage.h>
-#include <platform.h>
-#include <platform_def.h>
#include <stdint.h>
#include <string.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_storage.h>
+#include <drivers/st/io_stm32image.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
static uintptr_t backend_dev_handle;
static uintptr_t backend_image_spec;
diff --git a/drivers/st/mmc/stm32_sdmmc2.c b/drivers/st/mmc/stm32_sdmmc2.c
index db51581..05f5ae1 100644
--- a/drivers/st/mmc/stm32_sdmmc2.c
+++ b/drivers/st/mmc/stm32_sdmmc2.c
@@ -4,25 +4,28 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
+#include <libfdt.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/mmc.h>
+#include <drivers/st/stm32_sdmmc2.h>
+#include <drivers/st/stm32mp1_clk.h>
+#include <drivers/st/stm32mp1_rcc.h>
+#include <drivers/st/stm32mp1_reset.h>
#include <dt-bindings/clock/stm32mp1-clks.h>
#include <dt-bindings/reset/stm32mp1-resets.h>
-#include <errno.h>
-#include <libfdt.h>
-#include <mmc.h>
-#include <mmio.h>
-#include <platform.h>
-#include <stm32_sdmmc2.h>
-#include <stm32mp1_clk.h>
-#include <stm32mp1_dt.h>
-#include <stm32mp1_rcc.h>
-#include <stm32mp1_reset.h>
-#include <string.h>
-#include <utils.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
/* Registers offsets */
#define SDMMC_POWER 0x00U
diff --git a/drivers/st/pmic/stm32_i2c.c b/drivers/st/pmic/stm32_i2c.c
index 0980139..f861ba2 100644
--- a/drivers/st/pmic/stm32_i2c.c
+++ b/drivers/st/pmic/stm32_i2c.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <mmio.h>
#include <stdbool.h>
#include <stdlib.h>
-#include <stm32_i2c.h>
+
+#include <arch_helpers.h>
+#include <drivers/delay_timer.h>
+#include <drivers/st/stm32_i2c.h>
+#include <lib/mmio.h>
/* STM32 I2C registers offsets */
#define I2C_CR1 0x00U
diff --git a/drivers/st/pmic/stm32mp1_pmic.c b/drivers/st/pmic/stm32mp1_pmic.c
index 958de08..c5bdfc0 100644
--- a/drivers/st/pmic/stm32mp1_pmic.c
+++ b/drivers/st/pmic/stm32mp1_pmic.c
@@ -4,20 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <libfdt.h>
-#include <mmio.h>
-#include <mmio.h>
-#include <platform_def.h>
#include <stdbool.h>
-#include <stm32_gpio.h>
-#include <stm32mp1_clk.h>
-#include <stm32mp1_dt.h>
-#include <stm32mp1_pmic.h>
-#include <stpmu1.h>
-#include <utils_def.h>
+
+#include <libfdt.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/st/stm32_gpio.h>
+#include <drivers/st/stm32mp1_clk.h>
+#include <drivers/st/stm32mp1_pmic.h>
+#include <drivers/st/stpmu1.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
/* I2C Timing hard-coded value, for I2C clock source is HSI at 64MHz */
#define I2C_TIMING 0x10D07DB5
diff --git a/drivers/st/pmic/stpmu1.c b/drivers/st/pmic/stpmu1.c
index 5951899..9c36bf6 100644
--- a/drivers/st/pmic/stpmu1.c
+++ b/drivers/st/pmic/stpmu1.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <platform.h>
-#include <stpmu1.h>
#include <string.h>
+#include <common/debug.h>
+#include <drivers/st/stpmu1.h>
+#include <plat/common/platform.h>
+
struct regul_struct {
const char *dt_node_name;
const uint16_t *voltage_table;
diff --git a/drivers/st/reset/stm32mp1_reset.c b/drivers/st/reset/stm32mp1_reset.c
index 106bbfe..f58e10b 100644
--- a/drivers/st/reset/stm32mp1_reset.c
+++ b/drivers/st/reset/stm32mp1_reset.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <debug.h>
#include <limits.h>
-#include <mmio.h>
+
#include <platform_def.h>
-#include <stm32mp1_rcc.h>
-#include <stm32mp1_reset.h>
-#include <utils_def.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/st/stm32mp1_rcc.h>
+#include <drivers/st/stm32mp1_reset.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
#define RST_CLR_OFFSET 4U
diff --git a/drivers/st/uart/aarch32/stm32_console.S b/drivers/st/uart/aarch32/stm32_console.S
index 303d6ba..4d00e68 100644
--- a/drivers/st/uart/aarch32/stm32_console.S
+++ b/drivers/st/uart/aarch32/stm32_console.S
@@ -7,8 +7,8 @@
#include <assert_macros.S>
#define USE_FINISH_CONSOLE_REG_2
#include <console_macros.S>
-#include <stm32_console.h>
-#include <stm32_uart_regs.h>
+#include <drivers/st/stm32_console.h>
+#include <drivers/st/stm32_uart_regs.h>
#define USART_TIMEOUT 0x1000
diff --git a/drivers/staging/renesas/rcar/ddr/ddr_a/ddr_init_e3.c b/drivers/staging/renesas/rcar/ddr/ddr_a/ddr_init_e3.c
index 716d15d..62997bc 100644
--- a/drivers/staging/renesas/rcar/ddr/ddr_a/ddr_init_e3.c
+++ b/drivers/staging/renesas/rcar/ddr/ddr_a/ddr_init_e3.c
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-
#include <stdint.h>
-#include <debug.h>
+
+#include <common/debug.h>
#include "boot_init_dram_regdef_e3.h"
#include "ddr_init_e3.h"
@@ -48,701 +48,787 @@
******************************************************************************/
uint32_t init_ddr(void)
{
-
uint32_t RegVal_R2, RegVal_R5, RegVal_R6, RegVal_R7, RegVal_R12, i;
uint32_t ddr_md;
/* rev.0.08 */
- uint32_t RegVal,j;
+ uint32_t RegVal, j;
uint32_t dqsgd_0c, bdlcount_0c, bdlcount_0c_div2, bdlcount_0c_div4, bdlcount_0c_div8, bdlcount_0c_div16;
uint32_t gatesl_0c, rdqsd_0c, rdqsnd_0c, rbd_0c[4];
- uint32_t pdqsr_ctl,lcdl_ctl,lcdl_judge1,lcdl_judge2;
+ uint32_t pdqsr_ctl, lcdl_ctl, lcdl_judge1, lcdl_judge2;
+/* rev.0.10 */
+ uint32_t pdr_ctl;
+/* rev.0.11 */
+ uint32_t byp_ctl;
/* rev.0.08 */
if ((ReadReg_32(0xFFF00044) & 0x000000FF) == 0x00000000) {
pdqsr_ctl = 1;
lcdl_ctl = 1;
- }else {
+ pdr_ctl = 1; /* rev.0.10 */
+ byp_ctl = 1; /* rev.0.11 */
+ } else {
pdqsr_ctl = 0;
lcdl_ctl = 0;
+ pdr_ctl = 0; /* rev.0.10 */
+ byp_ctl = 0; /* rev.0.11 */
}
/* Judge the DDR bit rate (ddr_md : 0 = 1584Mbps, 1 = 1856Mbps) */
- ddr_md = (ReadReg_32(RST_MODEMR)>>19)&BIT0;
+ ddr_md = (ReadReg_32(RST_MODEMR) >> 19) & BIT0;
/* 1584Mbps setting */
- if (ddr_md==0){
+ if (ddr_md == 0) {
/* CPG setting ===============================================*/
- WriteReg_32(CPG_CPGWPR,0x5A5AFFFF);
- WriteReg_32(CPG_CPGWPCR,0xA5A50000);
+ WriteReg_32(CPG_CPGWPR, 0x5A5AFFFF);
+ WriteReg_32(CPG_CPGWPCR, 0xA5A50000);
- WriteReg_32(CPG_SRCR4,0x20000000);
+ WriteReg_32(CPG_SRCR4, 0x20000000);
- WriteReg_32(0xE61500DC,0xe2200000); /* Change to 1584Mbps */
- while ( (BIT11 & ReadReg_32(CPG_PLLECR)) == 0 );
+ WriteReg_32(0xE61500DC, 0xe2200000); /* Change to 1584Mbps */
+ while ((BIT11 & ReadReg_32(CPG_PLLECR)) == 0);
- WriteReg_32(CPG_SRSTCLR4,0x20000000);
+ WriteReg_32(CPG_SRSTCLR4, 0x20000000);
- WriteReg_32(CPG_CPGWPCR,0xA5A50001);
+ WriteReg_32(CPG_CPGWPCR, 0xA5A50001);
/* CPG setting ===============================================*/
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBSYSCNT0,0x00001234);
- WriteReg_32(DBSC_E3_DBKIND,0x00000007);
-
+ WriteReg_32(DBSC_E3_DBSYSCNT0, 0x00001234);
+ WriteReg_32(DBSC_E3_DBKIND, 0x00000007);
#if RCAR_DRAM_DDR3L_MEMCONF == 0
- WriteReg_32(DBSC_E3_DBMEMCONF00,0x0f030a02); /* 1GB */
+ WriteReg_32(DBSC_E3_DBMEMCONF00, 0x0f030a02); /* 1GB */
#elif RCAR_DRAM_DDR3L_MEMCONF == 1
- WriteReg_32(DBSC_E3_DBMEMCONF00,0x10030a02); /* 2GB(default) */
+ WriteReg_32(DBSC_E3_DBMEMCONF00, 0x10030a02); /* 2GB(default) */
#elif RCAR_DRAM_DDR3L_MEMCONF == 2
- WriteReg_32(DBSC_E3_DBMEMCONF00,0x10030b02); /* 4GB */
+ WriteReg_32(DBSC_E3_DBMEMCONF00, 0x10030b02); /* 4GB */
#else
- WriteReg_32(DBSC_E3_DBMEMCONF00,0x10030a02); /* 2GB */
+ WriteReg_32(DBSC_E3_DBMEMCONF00, 0x10030a02); /* 2GB */
#endif
#if RCAR_DRAM_DDR3L_MEMDUAL == 1
- RegVal_R2 = (ReadReg_32(0xE6790614));
- WriteReg_32(0xE6790614,RegVal_R2 | 0x00000003); /* MCS1_N/MODT1 are activated. */
+ RegVal_R2 = (ReadReg_32(0xE6790614));
+ WriteReg_32(0xE6790614, RegVal_R2 | 0x00000003); /* MCS1_N/MODT1 are activated. */
#endif
-
- WriteReg_32(DBSC_E3_DBPHYCONF0,0x00000001);
+ WriteReg_32(DBSC_E3_DBPHYCONF0, 0x00000001);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBTR0,0x0000000B);
- WriteReg_32(DBSC_E3_DBTR1,0x00000008);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBTR0, 0x0000000B);
+ WriteReg_32(DBSC_E3_DBTR1, 0x00000008);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBTR0,0x0000000D);
- WriteReg_32(DBSC_E3_DBTR1,0x00000009);
+ WriteReg_32(DBSC_E3_DBTR0, 0x0000000D);
+ WriteReg_32(DBSC_E3_DBTR1, 0x00000009);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBTR2,0x00000000);
+ WriteReg_32(DBSC_E3_DBTR2, 0x00000000);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBTR3,0x0000000B);
- WriteReg_32(DBSC_E3_DBTR4,0x000B000B);
- WriteReg_32(DBSC_E3_DBTR5,0x00000027);
- WriteReg_32(DBSC_E3_DBTR6,0x0000001C);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBTR3, 0x0000000B);
+ WriteReg_32(DBSC_E3_DBTR4, 0x000B000B);
+ WriteReg_32(DBSC_E3_DBTR5, 0x00000027);
+ WriteReg_32(DBSC_E3_DBTR6, 0x0000001C);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBTR3,0x0000000D);
- WriteReg_32(DBSC_E3_DBTR4,0x000D000D);
- WriteReg_32(DBSC_E3_DBTR5,0x0000002D);
- WriteReg_32(DBSC_E3_DBTR6,0x00000020);
+ WriteReg_32(DBSC_E3_DBTR3, 0x0000000D);
+ WriteReg_32(DBSC_E3_DBTR4, 0x000D000D);
+ WriteReg_32(DBSC_E3_DBTR5, 0x0000002D);
+ WriteReg_32(DBSC_E3_DBTR6, 0x00000020);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBTR7,0x00060006);
+ WriteReg_32(DBSC_E3_DBTR7, 0x00060006);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBTR8,0x00000020);
- WriteReg_32(DBSC_E3_DBTR9,0x00000006);
- WriteReg_32(DBSC_E3_DBTR10,0x0000000C);
- WriteReg_32(DBSC_E3_DBTR11,0x0000000A);
- WriteReg_32(DBSC_E3_DBTR12,0x00120012);
- WriteReg_32(DBSC_E3_DBTR13,0x000000CE);
- WriteReg_32(DBSC_E3_DBTR14,0x00140005);
- WriteReg_32(DBSC_E3_DBTR15,0x00050004);
- WriteReg_32(DBSC_E3_DBTR16,0x071F0305);
- WriteReg_32(DBSC_E3_DBTR17,0x040C0000);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBTR8, 0x00000020);
+ WriteReg_32(DBSC_E3_DBTR9, 0x00000006);
+ WriteReg_32(DBSC_E3_DBTR10, 0x0000000C);
+ WriteReg_32(DBSC_E3_DBTR11, 0x0000000A);
+ WriteReg_32(DBSC_E3_DBTR12, 0x00120012);
+ WriteReg_32(DBSC_E3_DBTR13, 0x000000CE);
+ WriteReg_32(DBSC_E3_DBTR14, 0x00140005);
+ WriteReg_32(DBSC_E3_DBTR15, 0x00050004);
+ WriteReg_32(DBSC_E3_DBTR16, 0x071F0305);
+ WriteReg_32(DBSC_E3_DBTR17, 0x040C0000);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBTR8,0x00000021);
- WriteReg_32(DBSC_E3_DBTR9,0x00000007);
- WriteReg_32(DBSC_E3_DBTR10,0x0000000E);
- WriteReg_32(DBSC_E3_DBTR11,0x0000000C);
- WriteReg_32(DBSC_E3_DBTR12,0x00140014);
- WriteReg_32(DBSC_E3_DBTR13,0x000000F2);
- WriteReg_32(DBSC_E3_DBTR14,0x00170006);
- WriteReg_32(DBSC_E3_DBTR15,0x00060005);
- WriteReg_32(DBSC_E3_DBTR16,0x09210507);
- WriteReg_32(DBSC_E3_DBTR17,0x040E0000);
+ WriteReg_32(DBSC_E3_DBTR8, 0x00000021);
+ WriteReg_32(DBSC_E3_DBTR9, 0x00000007);
+ WriteReg_32(DBSC_E3_DBTR10, 0x0000000E);
+ WriteReg_32(DBSC_E3_DBTR11, 0x0000000C);
+ WriteReg_32(DBSC_E3_DBTR12, 0x00140014);
+ WriteReg_32(DBSC_E3_DBTR13, 0x000000F2);
+ WriteReg_32(DBSC_E3_DBTR14, 0x00170006);
+ WriteReg_32(DBSC_E3_DBTR15, 0x00060005);
+ WriteReg_32(DBSC_E3_DBTR16, 0x09210507);
+ WriteReg_32(DBSC_E3_DBTR17, 0x040E0000);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBTR18,0x00000200);
+ WriteReg_32(DBSC_E3_DBTR18, 0x00000200);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBTR19,0x01000040);
- WriteReg_32(DBSC_E3_DBTR20,0x020000D6);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBTR19, 0x01000040);
+ WriteReg_32(DBSC_E3_DBTR20, 0x020000D6);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBTR19,0x0129004B);
- WriteReg_32(DBSC_E3_DBTR20,0x020000FB);
+ WriteReg_32(DBSC_E3_DBTR19, 0x0129004B);
+ WriteReg_32(DBSC_E3_DBTR20, 0x020000FB);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBTR21,0x00040004);
- WriteReg_32(DBSC_E3_DBBL,0x00000000);
- WriteReg_32(DBSC_E3_DBODT0,0x00000001);
- WriteReg_32(DBSC_E3_DBADJ0,0x00000001);
- WriteReg_32(DBSC_E3_DBSYSCONF1,0x00000002);
- WriteReg_32(DBSC_E3_DBDFICNT0,0x00000010);
- WriteReg_32(DBSC_E3_DBBCAMDIS,0x00000001);
- WriteReg_32(DBSC_E3_DBSCHRW1,0x00000046);
+ WriteReg_32(DBSC_E3_DBTR21, 0x00040004);
+ WriteReg_32(DBSC_E3_DBBL, 0x00000000);
+ WriteReg_32(DBSC_E3_DBODT0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBADJ0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBSYSCONF1, 0x00000002);
+ WriteReg_32(DBSC_E3_DBDFICNT0, 0x00000010);
+ WriteReg_32(DBSC_E3_DBBCAMDIS, 0x00000001);
+ WriteReg_32(DBSC_E3_DBSCHRW1, 0x00000046);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_SCFCTST0,0x0D050B03);
- WriteReg_32(DBSC_E3_SCFCTST1,0x0306030C);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_SCFCTST0, 0x0D050B03);
+ WriteReg_32(DBSC_E3_SCFCTST1, 0x0306030C);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_SCFCTST0,0x0C050B03);
- WriteReg_32(DBSC_E3_SCFCTST1,0x0305030C);
+ WriteReg_32(DBSC_E3_SCFCTST0, 0x0C050B03);
+ WriteReg_32(DBSC_E3_SCFCTST1, 0x0305030C);
} /* ddr_md */
/* rev.0.03 add Comment */
/****************************************************************************
* Initial_Step0( INITBYP )
***************************************************************************/
- WriteReg_32(DBSC_E3_DBPDLK0,0x0000A55A);
- WriteReg_32(DBSC_E3_DBCMD,0x01840001);
- WriteReg_32(DBSC_E3_DBCMD,0x08840000);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x80010000);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDLK0, 0x0000A55A);
+ WriteReg_32(DBSC_E3_DBCMD, 0x01840001);
+ WriteReg_32(DBSC_E3_DBCMD, 0x08840000);
+ NOTICE("BL2: [COLD_BOOT]\n"); /* rev.0.11 */
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x80010000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
/* rev.0.03 add Comment */
/****************************************************************************
* Initial_Step1( ZCAL,PLLINIT,DCAL,PHYRST training )
***************************************************************************/
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000008);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000B8000);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000090);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000B8000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000090);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04058904);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04058904);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04058A04);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04058A04);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000091);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0007BB6B);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000095);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0007BBAD);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000099);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0007BB6B);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000090);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000091);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0007BB6B);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000095);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0007BBAD);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000099);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0007BB6B);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000090);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04058900);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04058900);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04058A00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04058A00);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000021);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0024641E);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00010073);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000021);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0024641E);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00010073);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
/* rev.0.03 add Comment */
/****************************************************************************
* Initial_Step2( DRAMRST/DRAMINT training )
***************************************************************************/
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000090);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000090);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0C058900);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0C058900);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0C058A00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0C058A00);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000090);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000090);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04058900);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04058900);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04058A00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04058A00);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000003);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0780C700);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000007);
- while ( (BIT30 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000003);
+ if (byp_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0780C720);
+ } else {
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0780C700);
+ }
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000007);
+ while ((BIT30 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000004);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000004);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,(uint32_t)(REFRESH_RATE*792/125)-400 + 0x08B00000);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, (uint32_t)(REFRESH_RATE * 792 / 125) - 400 + 0x08B00000);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,(uint32_t)(REFRESH_RATE*928/125)-400 + 0x0A300000);
+ WriteReg_32(DBSC_E3_DBPDRGD0, (uint32_t)(REFRESH_RATE * 928 / 125) - 400 + 0x0A300000);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000022);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x1000040B);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000023);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000022);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x1000040B);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000023);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x2D9C0B66);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x2D9C0B66);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x35A00D77);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x35A00D77);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000024);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000024);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x2A88B400);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x2A88B400);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x2A8A2C28);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x2A8A2C28);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000025);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000025);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x30005200);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x30005200);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x30005E00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x30005E00);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000026);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000026);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0014A9C9);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0014A9C9);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0014CB49);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0014CB49);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000027);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000027);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000D70);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000D70);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000F14);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000F14);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000028);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000046);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000029);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000028);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000046);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000029);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
+ if (ddr_md == 0) { /* 1584Mbps */
if (REFRESH_RATE > 3900) {
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000018); /* [7]SRT=0 */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000018); /* [7]SRT=0 */
} else {
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000098); /* [7]SRT=1 */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000098); /* [7]SRT=1 */
}
} else { /* 1856Mbps */
if (REFRESH_RATE > 3900) {
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000020); /* [7]SRT=0 */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000020); /* [7]SRT=0 */
} else {
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000000A0); /* [7]SRT=1 */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000000A0); /* [7]SRT=1 */
} /* REFRESH_RATE */
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x0000002C);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x81003047);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000020);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00181884);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x0000001A);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x33C03C10);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x0000002C);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x81003047);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000020);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00181884);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x0000001A);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x33C03C10);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A7);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A8);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A9);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C7);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C8);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C9);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E7);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E8);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E9);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000107);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000108);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000109);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A7);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A8);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A9);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C7);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C8);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C9);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E7);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E8);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E9);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000107);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000108);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000109);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00010181);
- WriteReg_32(DBSC_E3_DBCMD,0x08840001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00010181);
+ WriteReg_32(DBSC_E3_DBCMD, 0x08840001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
/* rev.0.03 add Comment */
/****************************************************************************
* Initial_Step3( WL/QSG training )
***************************************************************************/
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00010601);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00010601);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- /* rev.0.03 add Comment */
- /****************************************************************************
- * Initial_Step4( WLADJ training )
- ***************************************************************************/
- for ( i = 0; i<4; i++){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B1 + i*0x20);
+ for (i = 0; i < 4; i++) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B1 + i * 0x20);
RegVal_R5 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x0000FF00) >> 0x8;
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B4 + i*0x20);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B4 + i * 0x20);
RegVal_R6 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x000000FF);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B3 + i*0x20);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B3 + i * 0x20);
RegVal_R7 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x00000007);
- if ( RegVal_R6 > 0 ){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | ((RegVal_R7 + 0x1) & 0x00000007));
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | RegVal_R6);
+ if (RegVal_R6 > 0) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | ((RegVal_R7 + 0x1) & 0x00000007));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | RegVal_R6);
} else {
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | RegVal_R7);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | ((RegVal_R6 + ((RegVal_R5) << 1)) & 0x000000FF));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | RegVal_R7);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | ((RegVal_R6 + ((RegVal_R5) << 1)) & 0x000000FF));
} /* RegVal_R6 */
} /* for i */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000005);
- WriteReg_32(DBSC_E3_DBPDRGD0,0xC1AA00C0);
+ /* rev.0.10 move Comment */
+ /****************************************************************************
+ * Initial_Step4( WLADJ training )
+ ***************************************************************************/
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000005);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0xC1AA00C0);
/* rev.0.08 */
- if (pdqsr_ctl == 1){}else{
-
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
-
+ if (pdqsr_ctl == 1){} else {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00010801);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ /* PDR always off */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ }
- /* rev.0.03 add Comment */
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00010801);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
+
/****************************************************************************
- * Initial_Step5678( RdWrbitRdWreye )
+ * Initial_Step5(Read Data Bit Deskew)
***************************************************************************/
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000005);
- WriteReg_32(DBSC_E3_DBPDRGD0,0xC1AA00D8);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000005);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0xC1AA00D8);
/* rev.0.08 */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00011001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00011001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
-if (pdqsr_ctl == 1){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
+if (pdqsr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00012001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ /* PDR dynamic */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ }
-if (pdqsr_ctl == 1){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
+ /****************************************************************************
+ * Initial_Step6(Write Data Bit Deskew)
+ ***************************************************************************/
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00012001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
+
+ /****************************************************************************
+ * Initial_Step7(Read Data Eye Training)
+ ***************************************************************************/
+if (pdqsr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00014001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ /* PDR always off */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ }
-if (pdqsr_ctl == 1){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00014001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
+
+if (pdqsr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00018001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ /* PDR dynamic */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ }
+
+ /****************************************************************************
+ * Initial_Step8(Write Data Eye Training)
+ ***************************************************************************/
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00018001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
/* rev.0.03 add Comment */
/****************************************************************************
* Initial_Step3_2( DQS Gate Training )
***************************************************************************/
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x0000002C);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x81003087);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00010401);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x0000002C);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x81003087);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00010401);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- /* rev.0.03 add Comment */
- /****************************************************************************
- * Initial_Step5-2_7-2( Rd bit Rd eye )
- ***************************************************************************/
- for ( i = 0; i < 4; i++){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B1 + i*0x20);
+ for (i = 0; i < 4; i++) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B1 + i * 0x20);
RegVal_R5 = ((ReadReg_32(DBSC_E3_DBPDRGD0) & 0x0000FF00) >> 0x8);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B4 + i*0x20);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B4 + i * 0x20);
RegVal_R6 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x000000FF);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B3 + i*0x20);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B3 + i * 0x20);
RegVal_R7 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x00000007);
RegVal_R12 = (RegVal_R5 >> 0x2);
- if ( RegVal_R12 < RegVal_R6 ){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | ((RegVal_R7 + 0x1) & 0x00000007));
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | ((RegVal_R6 - (RegVal_R12)) & 0x000000FF));
+ if (RegVal_R12 < RegVal_R6) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | ((RegVal_R7 + 0x1) & 0x00000007));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | ((RegVal_R6 - (RegVal_R12)) & 0x000000FF));
} else {
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | (RegVal_R7 & 0x00000007));
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | ((RegVal_R6 + (RegVal_R5) + ((RegVal_R5) >> 1) + (RegVal_R12)) & 0x000000FF));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | (RegVal_R7 & 0x00000007));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | ((RegVal_R6 + (RegVal_R5) + ((RegVal_R5) >> 1) + (RegVal_R12)) & 0x000000FF));
} /* RegVal_R12 < RegVal_R6 */
} /* for i */
+ /* rev.0.10 move Comment */
+ /****************************************************************************
+ * Initial_Step5-2_7-2( Rd bit Rd eye )
+ ***************************************************************************/
/* rev.0.08 */
- if (pdqsr_ctl == 1){}else{
-
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
-
+ if (pdqsr_ctl == 1){} else {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00015001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ /* PDR always off */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ }
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00015001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
/* rev.0.08 */
- if (lcdl_ctl == 1){
- for (i=0; i< 4; i++) {
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- dqsgd_0c = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x000000FF);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B1 + i*0x20);
- bdlcount_0c = ((ReadReg_32(DBSC_E3_DBPDRGD0) & 0x0000FF00) >> 8);
- bdlcount_0c_div2 = (bdlcount_0c >> 1);
- bdlcount_0c_div4 = (bdlcount_0c >> 2);
- bdlcount_0c_div8 = (bdlcount_0c >> 3);
- bdlcount_0c_div16 = (bdlcount_0c >> 4);
+ if (lcdl_ctl == 1) {
+ for (i = 0; i < 4; i++) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ dqsgd_0c = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x000000FF);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B1 + i * 0x20);
+ bdlcount_0c = ((ReadReg_32(DBSC_E3_DBPDRGD0) & 0x0000FF00) >> 8);
+ bdlcount_0c_div2 = (bdlcount_0c >> 1);
+ bdlcount_0c_div4 = (bdlcount_0c >> 2);
+ bdlcount_0c_div8 = (bdlcount_0c >> 3);
+ bdlcount_0c_div16 = (bdlcount_0c >> 4);
- if (ddr_md==0){ /* 1584Mbps */
- lcdl_judge1 = bdlcount_0c_div2 + bdlcount_0c_div4 + bdlcount_0c_div8 ;
- lcdl_judge2 = bdlcount_0c + bdlcount_0c_div4 + bdlcount_0c_div16 ;
- } else { /* 1856Mbps */
- lcdl_judge1 = bdlcount_0c_div2 + bdlcount_0c_div4 ;
- lcdl_judge2 = bdlcount_0c + bdlcount_0c_div4 ;
- } /* ddr_md */
+ if (ddr_md == 0) { /* 1584Mbps */
+ lcdl_judge1 = bdlcount_0c_div2 + bdlcount_0c_div4 + bdlcount_0c_div8;
+ lcdl_judge2 = bdlcount_0c + bdlcount_0c_div4 + bdlcount_0c_div16;
+ } else { /* 1856Mbps */
+ lcdl_judge1 = bdlcount_0c_div2 + bdlcount_0c_div4;
+ lcdl_judge2 = bdlcount_0c + bdlcount_0c_div4;
+ } /* ddr_md */
- if (dqsgd_0c > lcdl_judge1) {
- if (dqsgd_0c <= lcdl_judge2) {
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGD0,((dqsgd_0c - bdlcount_0c_div8) | RegVal));
- } else {
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
- gatesl_0c = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x00000007);
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
- WriteReg_32(DBSC_E3_DBPDRGD0, (RegVal|(gatesl_0c + 1)));
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AF + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
- rdqsd_0c = (RegVal & 0x0000FF00) >> 8;
- rdqsnd_0c = (RegVal & 0x00FF0000) >> 16;
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AF + i * 0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0, ((RegVal & 0xFF0000FF)|((rdqsd_0c + bdlcount_0c_div4) << 8)|((rdqsnd_0c + bdlcount_0c_div4) << 16)));
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AA + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
- rbd_0c[0] = (RegVal ) & 0x0000001f;
- rbd_0c[1] = (RegVal >> 8) & 0x0000001f;
- rbd_0c[2] = (RegVal >> 16) & 0x0000001f;
- rbd_0c[3] = (RegVal >> 24) & 0x0000001f;
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AA + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xE0E0E0E0);
- for (j=0; j< 4; j++) {
- rbd_0c[j] = (rbd_0c[j] + bdlcount_0c_div4);
- if (rbd_0c[j] > 0x1F) rbd_0c[j] = 0x1F;
- RegVal = RegVal | (rbd_0c[j] <<8*j);
- }
- WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AB + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
- rbd_0c[0] = (RegVal ) & 0x0000001f;
- rbd_0c[1] = (RegVal >> 8) & 0x0000001f;
- rbd_0c[2] = (RegVal >> 16) & 0x0000001f;
- rbd_0c[3] = (RegVal >> 24) & 0x0000001f;
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AB + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xE0E0E0E0);
- for (j=0; j< 4; j++) {
- rbd_0c[j] = (rbd_0c[j] + bdlcount_0c_div4);
- if (rbd_0c[j] > 0x1F) rbd_0c[j] = 0x1F;
- RegVal = RegVal | (rbd_0c[j] <<8*j);
- }
- WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
- }
- }
+ if (dqsgd_0c > lcdl_judge1) {
+ if (dqsgd_0c <= lcdl_judge2) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, ((dqsgd_0c - bdlcount_0c_div8) | RegVal));
+ } else {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ gatesl_0c = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x00000007);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
+ WriteReg_32(DBSC_E3_DBPDRGD0, (RegVal | (gatesl_0c + 1)));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AF + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
+ rdqsd_0c = (RegVal & 0x0000FF00) >> 8;
+ rdqsnd_0c = (RegVal & 0x00FF0000) >> 16;
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AF + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, ((RegVal & 0xFF0000FF) | ((rdqsd_0c + bdlcount_0c_div4) << 8) | ((rdqsnd_0c + bdlcount_0c_div4) << 16)));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AA + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
+ rbd_0c[0] = (RegVal) &0x0000001f;
+ rbd_0c[1] = (RegVal >> 8) & 0x0000001f;
+ rbd_0c[2] = (RegVal >> 16) & 0x0000001f;
+ rbd_0c[3] = (RegVal >> 24) & 0x0000001f;
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AA + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xE0E0E0E0);
+ for (j = 0; j < 4; j++) {
+ rbd_0c[j] = (rbd_0c[j] + bdlcount_0c_div4);
+ if (rbd_0c[j] > 0x1F) rbd_0c[j] = 0x1F;
+ RegVal = RegVal | (rbd_0c[j] << 8 * j);
+ }
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AB + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
+ rbd_0c[0] = (RegVal) &0x0000001f;
+ rbd_0c[1] = (RegVal >> 8) & 0x0000001f;
+ rbd_0c[2] = (RegVal >> 16) & 0x0000001f;
+ rbd_0c[3] = (RegVal >> 24) & 0x0000001f;
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AB + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xE0E0E0E0);
+ for (j = 0; j < 4; j++) {
+ rbd_0c[j] = (rbd_0c[j] + bdlcount_0c_div4);
+ if (rbd_0c[j] > 0x1F) rbd_0c[j] = 0x1F;
+ RegVal = RegVal | (rbd_0c[j] << 8 * j);
+ }
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
+ }
+ }
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000002);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x07D81E37);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000002);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x07D81E37);
}
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000003);
+ if (byp_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0380C720);
+ } else {
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0380C700);
+ }
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000007);
+ while ((BIT30 & ReadReg_32(DBSC_E3_DBPDRGD0)) != 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000003);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0380C700);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000007);
- while ( (BIT30 & ReadReg_32(DBSC_E3_DBPDRGD0)) != 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000021);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0024643E);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000021);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0024643E);
-
- WriteReg_32(DBSC_E3_DBBUS0CNF1,0x00000010);
- WriteReg_32(DBSC_E3_DBCALCNF, (uint32_t)(64000000/REFRESH_RATE) + 0x01000000);
+ WriteReg_32(DBSC_E3_DBBUS0CNF1, 0x00000010);
+ WriteReg_32(DBSC_E3_DBCALCNF, (uint32_t)(64000000 / REFRESH_RATE) + 0x01000000);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBRFCNF1, (uint32_t)(REFRESH_RATE*99/125) + 0x00080000);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBRFCNF1, (uint32_t)(REFRESH_RATE * 99 / 125) + 0x00080000);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBRFCNF1, (uint32_t)(REFRESH_RATE*116/125) + 0x00080000);
+ WriteReg_32(DBSC_E3_DBRFCNF1, (uint32_t)(REFRESH_RATE * 116 / 125) + 0x00080000);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBRFCNF2,0x00010000);
- WriteReg_32(DBSC_E3_DBDFICUPDCNF,0x40100001);
- WriteReg_32(DBSC_E3_DBRFEN,0x00000001);
- WriteReg_32(DBSC_E3_DBACEN,0x00000001);
+ WriteReg_32(DBSC_E3_DBRFCNF2, 0x00010000);
+ WriteReg_32(DBSC_E3_DBDFICUPDCNF, 0x40100001);
+ WriteReg_32(DBSC_E3_DBRFEN, 0x00000001);
+ WriteReg_32(DBSC_E3_DBACEN, 0x00000001);
/* rev.0.08 */
- if (pdqsr_ctl == 1){
- WriteReg_32(0xE67F0018,0x00000001);
+ if (pdqsr_ctl == 1) {
+ WriteReg_32(0xE67F0018, 0x00000001);
RegVal = ReadReg_32(0x40000000);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000000);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
-
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
}
+ /* PDR dynamic */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ }
/* rev.0.03 add Comment */
/****************************************************************************
* Initial_Step9( Initial End )
***************************************************************************/
- WriteReg_32(DBSC_E3_DBPDLK0,0x00000000);
- WriteReg_32(DBSC_E3_DBSYSCNT0,0x00000000);
+ WriteReg_32(DBSC_E3_DBPDLK0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBSYSCNT0, 0x00000000);
#ifdef ddr_qos_init_setting /* only for non qos_init */
- WriteReg_32(DBSC_E3_DBSYSCNT0,0x00001234);
- WriteReg_32(DBSC_E3_DBCAM0CNF1,0x00043218);
- WriteReg_32(DBSC_E3_DBCAM0CNF2,0x000000F4);
- WriteReg_32(DBSC_E3_DBSCHCNT0,0x000f0037);
- WriteReg_32(DBSC_E3_DBSCHSZ0,0x00000001);
- WriteReg_32(DBSC_E3_DBSCHRW0,0x22421111);
- WriteReg_32(DBSC_E3_SCFCTST2,0x012F1123);
- WriteReg_32(DBSC_E3_DBSCHQOS00,0x00000F00);
- WriteReg_32(DBSC_E3_DBSCHQOS01,0x00000B00);
- WriteReg_32(DBSC_E3_DBSCHQOS02,0x00000000);
- WriteReg_32(DBSC_E3_DBSCHQOS03,0x00000000);
- WriteReg_32(DBSC_E3_DBSCHQOS40,0x00000300);
- WriteReg_32(DBSC_E3_DBSCHQOS41,0x000002F0);
- WriteReg_32(DBSC_E3_DBSCHQOS42,0x00000200);
- WriteReg_32(DBSC_E3_DBSCHQOS43,0x00000100);
- WriteReg_32(DBSC_E3_DBSCHQOS90,0x00000100);
- WriteReg_32(DBSC_E3_DBSCHQOS91,0x000000F0);
- WriteReg_32(DBSC_E3_DBSCHQOS92,0x000000A0);
- WriteReg_32(DBSC_E3_DBSCHQOS93,0x00000040);
- WriteReg_32(DBSC_E3_DBSCHQOS130,0x00000100);
- WriteReg_32(DBSC_E3_DBSCHQOS131,0x000000F0);
- WriteReg_32(DBSC_E3_DBSCHQOS132,0x000000A0);
- WriteReg_32(DBSC_E3_DBSCHQOS133,0x00000040);
- WriteReg_32(DBSC_E3_DBSCHQOS140,0x000000C0);
- WriteReg_32(DBSC_E3_DBSCHQOS141,0x000000B0);
- WriteReg_32(DBSC_E3_DBSCHQOS142,0x00000080);
- WriteReg_32(DBSC_E3_DBSCHQOS143,0x00000040);
- WriteReg_32(DBSC_E3_DBSCHQOS150,0x00000040);
- WriteReg_32(DBSC_E3_DBSCHQOS151,0x00000030);
- WriteReg_32(DBSC_E3_DBSCHQOS152,0x00000020);
- WriteReg_32(DBSC_E3_DBSCHQOS153,0x00000010);
+ WriteReg_32(DBSC_E3_DBSYSCNT0, 0x00001234);
+ WriteReg_32(DBSC_E3_DBCAM0CNF1, 0x00043218);
+ WriteReg_32(DBSC_E3_DBCAM0CNF2, 0x000000F4);
+ WriteReg_32(DBSC_E3_DBSCHCNT0, 0x000f0037);
+ WriteReg_32(DBSC_E3_DBSCHSZ0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBSCHRW0, 0x22421111);
+ WriteReg_32(DBSC_E3_SCFCTST2, 0x012F1123);
+ WriteReg_32(DBSC_E3_DBSCHQOS00, 0x00000F00);
+ WriteReg_32(DBSC_E3_DBSCHQOS01, 0x00000B00);
+ WriteReg_32(DBSC_E3_DBSCHQOS02, 0x00000000);
+ WriteReg_32(DBSC_E3_DBSCHQOS03, 0x00000000);
+ WriteReg_32(DBSC_E3_DBSCHQOS40, 0x00000300);
+ WriteReg_32(DBSC_E3_DBSCHQOS41, 0x000002F0);
+ WriteReg_32(DBSC_E3_DBSCHQOS42, 0x00000200);
+ WriteReg_32(DBSC_E3_DBSCHQOS43, 0x00000100);
+ WriteReg_32(DBSC_E3_DBSCHQOS90, 0x00000100);
+ WriteReg_32(DBSC_E3_DBSCHQOS91, 0x000000F0);
+ WriteReg_32(DBSC_E3_DBSCHQOS92, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBSCHQOS93, 0x00000040);
+ WriteReg_32(DBSC_E3_DBSCHQOS130, 0x00000100);
+ WriteReg_32(DBSC_E3_DBSCHQOS131, 0x000000F0);
+ WriteReg_32(DBSC_E3_DBSCHQOS132, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBSCHQOS133, 0x00000040);
+ WriteReg_32(DBSC_E3_DBSCHQOS140, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBSCHQOS141, 0x000000B0);
+ WriteReg_32(DBSC_E3_DBSCHQOS142, 0x00000080);
+ WriteReg_32(DBSC_E3_DBSCHQOS143, 0x00000040);
+ WriteReg_32(DBSC_E3_DBSCHQOS150, 0x00000040);
+ WriteReg_32(DBSC_E3_DBSCHQOS151, 0x00000030);
+ WriteReg_32(DBSC_E3_DBSCHQOS152, 0x00000020);
+ WriteReg_32(DBSC_E3_DBSCHQOS153, 0x00000010);
/* rev.0.08 */
- if (pdqsr_ctl == 1){}else{
- WriteReg_32(0xE67F0018,0x00000001);
+ if (pdqsr_ctl == 1){} else {
+ WriteReg_32(0xE67F0018, 0x00000001);
}
- WriteReg_32(DBSC_E3_DBSYSCNT0,0x00000000);
+ WriteReg_32(DBSC_E3_DBSYSCNT0, 0x00000000);
#endif
return 1; /* rev.0.04 Restore the return code */
@@ -752,7 +838,6 @@
/* rev.0.04 add function */
uint32_t recovery_from_backup_mode(void)
{
-
/****************************************************************************
* recovery_Step0(DBSC Setting 1) / same "init_ddr"
***************************************************************************/
@@ -760,733 +845,810 @@
uint32_t ddr_md;
uint32_t err;
-
/* rev.0.08 */
- uint32_t RegVal,j;
+ uint32_t RegVal, j;
uint32_t dqsgd_0c, bdlcount_0c, bdlcount_0c_div2, bdlcount_0c_div4, bdlcount_0c_div8, bdlcount_0c_div16;
uint32_t gatesl_0c, rdqsd_0c, rdqsnd_0c, rbd_0c[4];
- uint32_t pdqsr_ctl,lcdl_ctl,lcdl_judge1,lcdl_judge2;
+ uint32_t pdqsr_ctl, lcdl_ctl, lcdl_judge1, lcdl_judge2;
+ /* rev.0.10 */
+ uint32_t pdr_ctl;
+ /* rev.0.11 */
+ uint32_t byp_ctl;
/* rev.0.08 */
if ((ReadReg_32(0xFFF00044) & 0x000000FF) == 0x00000000) {
pdqsr_ctl = 1;
lcdl_ctl = 1;
- }else {
+ pdr_ctl = 1; /* rev.0.10 */
+ byp_ctl = 1; /* rev.0.11 */
+ } else {
pdqsr_ctl = 0;
lcdl_ctl = 0;
+ pdr_ctl = 0; /* rev.0.10 */
+ byp_ctl = 0; /* rev.0.11 */
}
-
/* Judge the DDR bit rate (ddr_md : 0 = 1584Mbps, 1 = 1856Mbps) */
- ddr_md = (ReadReg_32(RST_MODEMR)>>19)&BIT0;
+ ddr_md = (ReadReg_32(RST_MODEMR) >> 19) & BIT0;
/* 1584Mbps setting */
- if (ddr_md==0){
+ if (ddr_md == 0) {
/* CPG setting ===============================================*/
- WriteReg_32(CPG_CPGWPR,0x5A5AFFFF);
- WriteReg_32(CPG_CPGWPCR,0xA5A50000);
+ WriteReg_32(CPG_CPGWPR, 0x5A5AFFFF);
+ WriteReg_32(CPG_CPGWPCR, 0xA5A50000);
- WriteReg_32(CPG_SRCR4,0x20000000);
+ WriteReg_32(CPG_SRCR4, 0x20000000);
- WriteReg_32(0xE61500DC,0xe2200000); /* Change to 1584Mbps */
- while ( (BIT11 & ReadReg_32(CPG_PLLECR)) == 0 );
+ WriteReg_32(0xE61500DC, 0xe2200000); /* Change to 1584Mbps */
+ while ((BIT11 & ReadReg_32(CPG_PLLECR)) == 0);
- WriteReg_32(CPG_SRSTCLR4,0x20000000);
+ WriteReg_32(CPG_SRSTCLR4, 0x20000000);
- WriteReg_32(CPG_CPGWPCR,0xA5A50001);
+ WriteReg_32(CPG_CPGWPCR, 0xA5A50001);
/* CPG setting ===============================================*/
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBSYSCNT0,0x00001234);
- WriteReg_32(DBSC_E3_DBKIND,0x00000007);
+ WriteReg_32(DBSC_E3_DBSYSCNT0, 0x00001234);
+ WriteReg_32(DBSC_E3_DBKIND, 0x00000007);
#if RCAR_DRAM_DDR3L_MEMCONF == 0
- WriteReg_32(DBSC_E3_DBMEMCONF00,0x0f030a02);
+ WriteReg_32(DBSC_E3_DBMEMCONF00, 0x0f030a02);
#elif RCAR_DRAM_DDR3L_MEMCONF == 1
- WriteReg_32(DBSC_E3_DBMEMCONF00,0x10030a02);
+ WriteReg_32(DBSC_E3_DBMEMCONF00, 0x10030a02);
#elif RCAR_DRAM_DDR3L_MEMCONF == 2
- WriteReg_32(DBSC_E3_DBMEMCONF00,0x10030b02);
+ WriteReg_32(DBSC_E3_DBMEMCONF00, 0x10030b02);
#else
- WriteReg_32(DBSC_E3_DBMEMCONF00,0x10030a02);
+ WriteReg_32(DBSC_E3_DBMEMCONF00, 0x10030a02);
#endif
/* rev.0.08 */
#if RCAR_DRAM_DDR3L_MEMDUAL == 1
- RegVal_R2 = (ReadReg_32(0xE6790614));
- WriteReg_32(0xE6790614,RegVal_R2 | 0x00000003); /* MCS1_N/MODT1 are activated. */
+ RegVal_R2 = (ReadReg_32(0xE6790614));
+ WriteReg_32(0xE6790614, RegVal_R2 | 0x00000003); /* MCS1_N/MODT1 are activated. */
#endif
- WriteReg_32(DBSC_E3_DBPHYCONF0,0x00000001);
+ WriteReg_32(DBSC_E3_DBPHYCONF0, 0x00000001);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBTR0,0x0000000B);
- WriteReg_32(DBSC_E3_DBTR1,0x00000008);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBTR0, 0x0000000B);
+ WriteReg_32(DBSC_E3_DBTR1, 0x00000008);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBTR0,0x0000000D);
- WriteReg_32(DBSC_E3_DBTR1,0x00000009);
+ WriteReg_32(DBSC_E3_DBTR0, 0x0000000D);
+ WriteReg_32(DBSC_E3_DBTR1, 0x00000009);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBTR2,0x00000000);
+ WriteReg_32(DBSC_E3_DBTR2, 0x00000000);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBTR3,0x0000000B);
- WriteReg_32(DBSC_E3_DBTR4,0x000B000B);
- WriteReg_32(DBSC_E3_DBTR5,0x00000027);
- WriteReg_32(DBSC_E3_DBTR6,0x0000001C);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBTR3, 0x0000000B);
+ WriteReg_32(DBSC_E3_DBTR4, 0x000B000B);
+ WriteReg_32(DBSC_E3_DBTR5, 0x00000027);
+ WriteReg_32(DBSC_E3_DBTR6, 0x0000001C);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBTR3,0x0000000D);
- WriteReg_32(DBSC_E3_DBTR4,0x000D000D);
- WriteReg_32(DBSC_E3_DBTR5,0x0000002D);
- WriteReg_32(DBSC_E3_DBTR6,0x00000020);
+ WriteReg_32(DBSC_E3_DBTR3, 0x0000000D);
+ WriteReg_32(DBSC_E3_DBTR4, 0x000D000D);
+ WriteReg_32(DBSC_E3_DBTR5, 0x0000002D);
+ WriteReg_32(DBSC_E3_DBTR6, 0x00000020);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBTR7,0x00060006);
+ WriteReg_32(DBSC_E3_DBTR7, 0x00060006);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBTR8,0x00000020);
- WriteReg_32(DBSC_E3_DBTR9,0x00000006);
- WriteReg_32(DBSC_E3_DBTR10,0x0000000C);
- WriteReg_32(DBSC_E3_DBTR11,0x0000000A);
- WriteReg_32(DBSC_E3_DBTR12,0x00120012);
- WriteReg_32(DBSC_E3_DBTR13,0x000000CE);
- WriteReg_32(DBSC_E3_DBTR14,0x00140005);
- WriteReg_32(DBSC_E3_DBTR15,0x00050004);
- WriteReg_32(DBSC_E3_DBTR16,0x071F0305);
- WriteReg_32(DBSC_E3_DBTR17,0x040C0000);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBTR8, 0x00000020);
+ WriteReg_32(DBSC_E3_DBTR9, 0x00000006);
+ WriteReg_32(DBSC_E3_DBTR10, 0x0000000C);
+ WriteReg_32(DBSC_E3_DBTR11, 0x0000000A);
+ WriteReg_32(DBSC_E3_DBTR12, 0x00120012);
+ WriteReg_32(DBSC_E3_DBTR13, 0x000000CE);
+ WriteReg_32(DBSC_E3_DBTR14, 0x00140005);
+ WriteReg_32(DBSC_E3_DBTR15, 0x00050004);
+ WriteReg_32(DBSC_E3_DBTR16, 0x071F0305);
+ WriteReg_32(DBSC_E3_DBTR17, 0x040C0000);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBTR8,0x00000021);
- WriteReg_32(DBSC_E3_DBTR9,0x00000007);
- WriteReg_32(DBSC_E3_DBTR10,0x0000000E);
- WriteReg_32(DBSC_E3_DBTR11,0x0000000C);
- WriteReg_32(DBSC_E3_DBTR12,0x00140014);
- WriteReg_32(DBSC_E3_DBTR13,0x000000F2);
- WriteReg_32(DBSC_E3_DBTR14,0x00170006);
- WriteReg_32(DBSC_E3_DBTR15,0x00060005);
- WriteReg_32(DBSC_E3_DBTR16,0x09210507);
- WriteReg_32(DBSC_E3_DBTR17,0x040E0000);
+ WriteReg_32(DBSC_E3_DBTR8, 0x00000021);
+ WriteReg_32(DBSC_E3_DBTR9, 0x00000007);
+ WriteReg_32(DBSC_E3_DBTR10, 0x0000000E);
+ WriteReg_32(DBSC_E3_DBTR11, 0x0000000C);
+ WriteReg_32(DBSC_E3_DBTR12, 0x00140014);
+ WriteReg_32(DBSC_E3_DBTR13, 0x000000F2);
+ WriteReg_32(DBSC_E3_DBTR14, 0x00170006);
+ WriteReg_32(DBSC_E3_DBTR15, 0x00060005);
+ WriteReg_32(DBSC_E3_DBTR16, 0x09210507);
+ WriteReg_32(DBSC_E3_DBTR17, 0x040E0000);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBTR18,0x00000200);
+ WriteReg_32(DBSC_E3_DBTR18, 0x00000200);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBTR19,0x01000040);
- WriteReg_32(DBSC_E3_DBTR20,0x020000D6);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBTR19, 0x01000040);
+ WriteReg_32(DBSC_E3_DBTR20, 0x020000D6);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBTR19,0x0129004B);
- WriteReg_32(DBSC_E3_DBTR20,0x020000FB);
+ WriteReg_32(DBSC_E3_DBTR19, 0x0129004B);
+ WriteReg_32(DBSC_E3_DBTR20, 0x020000FB);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBTR21,0x00040004);
- WriteReg_32(DBSC_E3_DBBL,0x00000000);
- WriteReg_32(DBSC_E3_DBODT0,0x00000001);
- WriteReg_32(DBSC_E3_DBADJ0,0x00000001);
- WriteReg_32(DBSC_E3_DBSYSCONF1,0x00000002);
- WriteReg_32(DBSC_E3_DBDFICNT0,0x00000010);
- WriteReg_32(DBSC_E3_DBBCAMDIS,0x00000001);
- WriteReg_32(DBSC_E3_DBSCHRW1,0x00000046);
+ WriteReg_32(DBSC_E3_DBTR21, 0x00040004);
+ WriteReg_32(DBSC_E3_DBBL, 0x00000000);
+ WriteReg_32(DBSC_E3_DBODT0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBADJ0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBSYSCONF1, 0x00000002);
+ WriteReg_32(DBSC_E3_DBDFICNT0, 0x00000010);
+ WriteReg_32(DBSC_E3_DBBCAMDIS, 0x00000001);
+ WriteReg_32(DBSC_E3_DBSCHRW1, 0x00000046);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_SCFCTST0,0x0D050B03);
- WriteReg_32(DBSC_E3_SCFCTST1,0x0306030C);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_SCFCTST0, 0x0D050B03);
+ WriteReg_32(DBSC_E3_SCFCTST1, 0x0306030C);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_SCFCTST0,0x0C050B03);
- WriteReg_32(DBSC_E3_SCFCTST1,0x0305030C);
+ WriteReg_32(DBSC_E3_SCFCTST0, 0x0C050B03);
+ WriteReg_32(DBSC_E3_SCFCTST1, 0x0305030C);
} /* ddr_md */
/****************************************************************************
* recovery_Step1(PHY setting 1)
***************************************************************************/
- WriteReg_32(DBSC_E3_DBPDLK0,0x0000A55A);
- WriteReg_32(DBSC_E3_DBCMD,0x01840001);
- WriteReg_32(DBSC_E3_DBCMD,0x0A840000);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000008); /* DDR_PLLCR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000B8000);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000003); /* DDR_PGCR1 */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0780C700);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000020); /* DDR_DXCCR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00181884);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x0000001A); /* DDR_ACIOCR0 */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x33C03C10);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000007);
- while ( (BIT30 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDLK0, 0x0000A55A);
+ WriteReg_32(DBSC_E3_DBCMD, 0x01840001);
+ WriteReg_32(DBSC_E3_DBCMD, 0x0A840000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000008); /* DDR_PLLCR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000B8000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000003); /* DDR_PGCR1 */
+ if (byp_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0780C720);
+ } else {
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0780C700);
+ }
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000020); /* DDR_DXCCR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00181884);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x0000001A); /* DDR_ACIOCR0 */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x33C03C10);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000007);
+ while ((BIT30 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000004);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000004);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,(uint32_t)(REFRESH_RATE*792/125)-400 + 0x08B00000);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, (uint32_t)(REFRESH_RATE * 792 / 125) - 400 + 0x08B00000);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,(uint32_t)(REFRESH_RATE*928/125)-400 + 0x0A300000);
+ WriteReg_32(DBSC_E3_DBPDRGD0, (uint32_t)(REFRESH_RATE * 928 / 125) - 400 + 0x0A300000);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000022);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x1000040B);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000023);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000022);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x1000040B);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000023);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x2D9C0B66);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x2D9C0B66);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x35A00D77);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x35A00D77);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000024);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000024);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x2A88B400);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x2A88B400);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x2A8A2C28);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x2A8A2C28);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000025);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000025);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x30005200);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x30005200);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x30005E00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x30005E00);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000026);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000026);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0014A9C9);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0014A9C9);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0014CB49);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0014CB49);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000027);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000027);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000D70);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000D70);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000F14);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000F14);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000028);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000046);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000029);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000028);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000046);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000029);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
+ if (ddr_md == 0) { /* 1584Mbps */
if (REFRESH_RATE > 3900) {
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000018); /* [7]SRT=0 */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000018); /* [7]SRT=0 */
} else {
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000098); /* [7]SRT=1 */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000098); /* [7]SRT=1 */
}
} else { /* 1856Mbps */
if (REFRESH_RATE > 3900) {
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000020); /* [7]SRT=0 */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000020); /* [7]SRT=0 */
} else {
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000000A0); /* [7]SRT=1 */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000000A0); /* [7]SRT=1 */
} /* REFRESH_RATE */
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x0000002C);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x81003047);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000091);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0007BB6B);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000095);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0007BBAD);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000099);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0007BB6B);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000021); /* DDR_DSGCR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0024641E);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006); /* DDR_PGSR0 */
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x0000002C);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x81003047);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000091);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0007BB6B);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000095);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0007BBAD);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000099);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0007BB6B);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000021); /* DDR_DSGCR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0024641E);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006); /* DDR_PGSR0 */
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001); /* DDR_PIR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x40010000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001); /* DDR_PIR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x40010000);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006); /* DDR_PGSR0 */
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006); /* DDR_PGSR0 */
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000092); /* DDR_ZQ0DR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0xC2C59AB5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000096); /* DDR_ZQ1DR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0xC4285FBF);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x0000009A); /* DDR_ZQ2DR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0xC2C59AB5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000090); /* DDR_ZQCR */
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000092); /* DDR_ZQ0DR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0xC2C59AB5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000096); /* DDR_ZQ1DR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0xC4285FBF);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x0000009A); /* DDR_ZQ2DR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0xC2C59AB5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000090); /* DDR_ZQCR */
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0C058900);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0C058900);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0C058A00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0C058A00);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000090); /* DDR_ZQCR */
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000090); /* DDR_ZQCR */
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04058900);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04058900);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04058A00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04058A00);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001); /* DDR_PIR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00050001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001); /* DDR_PIR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00050001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006); /* DDR_PGSR0 */
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006); /* DDR_PGSR0 */
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
/* ddr backupmode end */
- if(ddrBackup) {
+ if (ddrBackup) {
NOTICE("[WARM_BOOT]");
} else {
NOTICE("[COLD_BOOT]");
} /* ddrBackup */
- err=rcar_dram_update_boot_status(ddrBackup);
- if(err){
+ err = rcar_dram_update_boot_status(ddrBackup);
+ if (err) {
NOTICE("[BOOT_STATUS_UPDATE_ERROR]");
return INITDRAM_ERR_I;
} /* err */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000092); /* DDR_ZQ0DR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x02C59AB5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000096); /* DDR_ZQ1DR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04285FBF);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x0000009A); /* DDR_ZQ2DR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x02C59AB5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000092); /* DDR_ZQ0DR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x02C59AB5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000096); /* DDR_ZQ1DR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04285FBF);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x0000009A); /* DDR_ZQ2DR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x02C59AB5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001); /* DDR_PIR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x08000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001); /* DDR_PIR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x08000000);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001); /* DDR_PIR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00000003);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001); /* DDR_PIR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000003);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006); /* DDR_PGSR0 */
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006); /* DDR_PGSR0 */
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001); /* DDR_PIR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x80010000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001); /* DDR_PIR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x80010000);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006); /* DDR_PGSR0 */
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006); /* DDR_PGSR0 */
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001); /* DDR_PIR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00010073);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001); /* DDR_PIR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00010073);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006); /* DDR_PGSR0 */
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006); /* DDR_PGSR0 */
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000090); /* DDR_ZQCR */
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000090); /* DDR_ZQCR */
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0C058900);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0C058900);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0C058A00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0C058A00);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000090); /* DDR_ZQCR */
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000090); /* DDR_ZQCR */
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04058900);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04058900);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x04058A00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x04058A00);
} /* ddr_md */
/* rev0.08 */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x0000000C);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x18000040);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x0000000C);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x18000040);
/****************************************************************************
* recovery_Step2(PHY setting 2)
***************************************************************************/
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A7);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A8);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A9);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C7);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C8);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C9);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E7);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E8);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E9);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000107);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000108);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0D0D0D0D);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000109);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x000D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A7);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A8);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A9);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C7);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C8);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C9);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E7);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E8);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E9);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000107);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000108);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0D0D0D0D);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000109);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x000D0D0D);
- WriteReg_32(DBSC_E3_DBCALCNF, (uint32_t)(64000000/REFRESH_RATE) + 0x01000000);
- WriteReg_32(DBSC_E3_DBBUS0CNF1,0x00000010);
+ WriteReg_32(DBSC_E3_DBCALCNF, (uint32_t)(64000000 / REFRESH_RATE) + 0x01000000);
+ WriteReg_32(DBSC_E3_DBBUS0CNF1, 0x00000010);
/* Select setting value in bps */
- if (ddr_md==0){ /* 1584Mbps */
- WriteReg_32(DBSC_E3_DBRFCNF1, (uint32_t)(REFRESH_RATE*99/125) + 0x00080000);
+ if (ddr_md == 0) { /* 1584Mbps */
+ WriteReg_32(DBSC_E3_DBRFCNF1, (uint32_t)(REFRESH_RATE * 99 / 125) + 0x00080000);
} else { /* 1856Mbps */
- WriteReg_32(DBSC_E3_DBRFCNF1, (uint32_t)(REFRESH_RATE*116/125) + 0x00080000);
+ WriteReg_32(DBSC_E3_DBRFCNF1, (uint32_t)(REFRESH_RATE * 116 / 125) + 0x00080000);
} /* ddr_md */
- WriteReg_32(DBSC_E3_DBRFCNF2,0x00010000);
- WriteReg_32(DBSC_E3_DBRFEN,0x00000001);
- WriteReg_32(DBSC_E3_DBCMD,0x0A840001);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBWAIT)) != 0 );
+ WriteReg_32(DBSC_E3_DBRFCNF2, 0x00010000);
+ WriteReg_32(DBSC_E3_DBRFEN, 0x00000001);
+ WriteReg_32(DBSC_E3_DBCMD, 0x0A840001);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBWAIT)) != 0);
- WriteReg_32(DBSC_E3_DBCMD,0x00000000);
+ WriteReg_32(DBSC_E3_DBCMD, 0x00000000);
- WriteReg_32(DBSC_E3_DBCMD,0x04840010);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBWAIT)) != 0 );
+ WriteReg_32(DBSC_E3_DBCMD, 0x04840010);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBWAIT)) != 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006); /* DDR_PGSR0 */
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006); /* DDR_PGSR0 */
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001); /* DDR_PIR */
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00010701);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001); /* DDR_PIR */
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00010701);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006); /* DDR_PGSR0 */
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006); /* DDR_PGSR0 */
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- for ( i = 0; i<4; i++)
+ for (i = 0; i < 4; i++)
{
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B1 + i*0x20);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B1 + i * 0x20);
RegVal_R5 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x0000FF00) >> 0x8;
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B4 + i*0x20);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B4 + i * 0x20);
RegVal_R6 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x000000FF);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B3 + i*0x20);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B3 + i * 0x20);
RegVal_R7 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x00000007);
- if ( RegVal_R6 > 0 ){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | ((RegVal_R7 + 0x1) & 0x00000007));
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | RegVal_R6);
+ if (RegVal_R6 > 0) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | ((RegVal_R7 + 0x1) & 0x00000007));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | RegVal_R6);
} else {
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | RegVal_R7);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | ((RegVal_R6 + ((RegVal_R5) << 1)) & 0x000000FF));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | RegVal_R7);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | ((RegVal_R6 + ((RegVal_R5) << 1)) & 0x000000FF));
} /* RegVal_R6 */
} /* for i */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000005);
- WriteReg_32(DBSC_E3_DBPDRGD0,0xC1AA00C0);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000005);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0xC1AA00C0);
/* rev.0.08 */
- if (pdqsr_ctl == 1){}else{
-
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
-
+ if (pdqsr_ctl == 1){} else {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00010801);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ /* PDR always off */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ }
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000005);
- WriteReg_32(DBSC_E3_DBPDRGD0,0xC1AA00D8);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00010801);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000005);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0xC1AA00D8);
/* rev.0.08 */
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00011001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00011001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
-if (pdqsr_ctl == 1){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
+if (pdqsr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00012001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ /* PDR dynamic */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ }
-if (pdqsr_ctl == 1){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00012001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
+
+if (pdqsr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00014001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ /* PDR always off */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ }
-if (pdqsr_ctl == 1){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00014001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
+
+if (pdqsr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00018001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ /* PDR dynamic */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ }
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C000285);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x0000002C);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x81003087);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00010401);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00018001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
- for ( i = 0; i < 4; i++){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B1 + i*0x20);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C000285);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x0000002C);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x81003087);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00010401);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
+
+ for (i = 0; i < 4; i++) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B1 + i * 0x20);
RegVal_R5 = ((ReadReg_32(DBSC_E3_DBPDRGD0) & 0x0000FF00) >> 0x8);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B4 + i*0x20);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B4 + i * 0x20);
RegVal_R6 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x000000FF);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B3 + i*0x20);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B3 + i * 0x20);
RegVal_R7 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x00000007);
RegVal_R12 = (RegVal_R5 >> 0x2);
- if ( RegVal_R12 < RegVal_R6 ){
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | ((RegVal_R7 + 0x1) & 0x00000007));
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | ((RegVal_R6 - (RegVal_R12)) & 0x000000FF));
+ if (RegVal_R12 < RegVal_R6) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | ((RegVal_R7 + 0x1) & 0x00000007));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | ((RegVal_R6 - (RegVal_R12)) & 0x000000FF));
} else {
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B2 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | (RegVal_R7 & 0x00000007));
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal_R2 | ((RegVal_R6 + (RegVal_R5) + ((RegVal_R5) >> 1) + (RegVal_R12)) & 0x000000FF));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | (RegVal_R7 & 0x00000007));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal_R2 = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal_R2 | ((RegVal_R6 + (RegVal_R5) + ((RegVal_R5) >> 1) + (RegVal_R12)) & 0x000000FF));
} /* RegVal_R12 < RegVal_R6 */
} /* for i */
/* rev.0.08 */
- if (pdqsr_ctl == 1){}else{
-
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
-
+ if (pdqsr_ctl == 1){} else {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000001);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x00015001);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000006);
- while ( (BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0 );
+ /* PDR always off */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000008);
+ }
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00015001);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000006);
+ while ((BIT0 & ReadReg_32(DBSC_E3_DBPDRGD0)) == 0);
/* rev.0.08 */
- if (lcdl_ctl == 1){
- for (i=0; i< 4; i++) {
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B0 + i*0x20);
- dqsgd_0c = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x000000FF);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000B1 + i*0x20);
- bdlcount_0c = ((ReadReg_32(DBSC_E3_DBPDRGD0) & 0x0000FF00) >> 8);
- bdlcount_0c_div2 = (bdlcount_0c >> 1);
- bdlcount_0c_div4 = (bdlcount_0c >> 2);
- bdlcount_0c_div8 = (bdlcount_0c >> 3);
- bdlcount_0c_div16 = (bdlcount_0c >> 4);
+ if (lcdl_ctl == 1) {
+ for (i = 0; i < 4; i++) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ dqsgd_0c = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x000000FF);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B1 + i * 0x20);
+ bdlcount_0c = ((ReadReg_32(DBSC_E3_DBPDRGD0) & 0x0000FF00) >> 8);
+ bdlcount_0c_div2 = (bdlcount_0c >> 1);
+ bdlcount_0c_div4 = (bdlcount_0c >> 2);
+ bdlcount_0c_div8 = (bdlcount_0c >> 3);
+ bdlcount_0c_div16 = (bdlcount_0c >> 4);
- if (ddr_md==0){ /* 1584Mbps */
- lcdl_judge1 = bdlcount_0c_div2 + bdlcount_0c_div4 + bdlcount_0c_div8 ;
- lcdl_judge2 = bdlcount_0c + bdlcount_0c_div4 + bdlcount_0c_div16 ;
- } else { /* 1856Mbps */
- lcdl_judge1 = bdlcount_0c_div2 + bdlcount_0c_div4 ;
- lcdl_judge2 = bdlcount_0c + bdlcount_0c_div4 ;
- } /* ddr_md */
+ if (ddr_md == 0) { /* 1584Mbps */
+ lcdl_judge1 = bdlcount_0c_div2 + bdlcount_0c_div4 + bdlcount_0c_div8;
+ lcdl_judge2 = bdlcount_0c + bdlcount_0c_div4 + bdlcount_0c_div16;
+ } else { /* 1856Mbps */
+ lcdl_judge1 = bdlcount_0c_div2 + bdlcount_0c_div4;
+ lcdl_judge2 = bdlcount_0c + bdlcount_0c_div4;
+ } /* ddr_md */
- if (dqsgd_0c > lcdl_judge1) {
- if (dqsgd_0c <= lcdl_judge2) {
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGD0,((dqsgd_0c - bdlcount_0c_div8) | RegVal));
- } else {
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
- WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
- gatesl_0c = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x00000007);
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
- WriteReg_32(DBSC_E3_DBPDRGD0, (RegVal|(gatesl_0c + 1)));
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AF + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
- rdqsd_0c = (RegVal & 0x0000FF00) >> 8;
- rdqsnd_0c = (RegVal & 0x00FF0000) >> 16;
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AF + i * 0x20);
- WriteReg_32(DBSC_E3_DBPDRGD0, ((RegVal & 0xFF0000FF)|((rdqsd_0c + bdlcount_0c_div4) << 8)|((rdqsnd_0c + bdlcount_0c_div4) << 16)));
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AA + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
- rbd_0c[0] = (RegVal ) & 0x0000001f;
- rbd_0c[1] = (RegVal >> 8) & 0x0000001f;
- rbd_0c[2] = (RegVal >> 16) & 0x0000001f;
- rbd_0c[3] = (RegVal >> 24) & 0x0000001f;
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AA + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xE0E0E0E0);
- for (j=0; j< 4; j++) {
- rbd_0c[j] = (rbd_0c[j] + bdlcount_0c_div4);
- if (rbd_0c[j] > 0x1F) rbd_0c[j] = 0x1F;
- RegVal = RegVal | (rbd_0c[j] <<8*j);
- }
- WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AB + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
- rbd_0c[0] = (RegVal ) & 0x0000001f;
- rbd_0c[1] = (RegVal >> 8) & 0x0000001f;
- rbd_0c[2] = (RegVal >> 16) & 0x0000001f;
- rbd_0c[3] = (RegVal >> 24) & 0x0000001f;
- WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AB + i * 0x20);
- RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xE0E0E0E0);
- for (j=0; j< 4; j++) {
- rbd_0c[j] = (rbd_0c[j] + bdlcount_0c_div4);
- if (rbd_0c[j] > 0x1F) rbd_0c[j] = 0x1F;
- RegVal = RegVal | (rbd_0c[j] <<8*j);
- }
- WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
- }
- }
+ if (dqsgd_0c > lcdl_judge1) {
+ if (dqsgd_0c <= lcdl_judge2) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, ((dqsgd_0c - bdlcount_0c_div8) | RegVal));
+ } else {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B0 + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFF00);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ gatesl_0c = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0x00000007);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000B2 + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xFFFFFFF8);
+ WriteReg_32(DBSC_E3_DBPDRGD0, (RegVal | (gatesl_0c + 1)));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AF + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
+ rdqsd_0c = (RegVal & 0x0000FF00) >> 8;
+ rdqsnd_0c = (RegVal & 0x00FF0000) >> 16;
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AF + i * 0x20);
+ WriteReg_32(DBSC_E3_DBPDRGD0, ((RegVal & 0xFF0000FF) | ((rdqsd_0c + bdlcount_0c_div4) << 8) | ((rdqsnd_0c + bdlcount_0c_div4) << 16)));
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AA + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
+ rbd_0c[0] = (RegVal) &0x0000001f;
+ rbd_0c[1] = (RegVal >> 8) & 0x0000001f;
+ rbd_0c[2] = (RegVal >> 16) & 0x0000001f;
+ rbd_0c[3] = (RegVal >> 24) & 0x0000001f;
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AA + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xE0E0E0E0);
+ for (j = 0; j < 4; j++) {
+ rbd_0c[j] = (rbd_0c[j] + bdlcount_0c_div4);
+ if (rbd_0c[j] > 0x1F) rbd_0c[j] = 0x1F;
+ RegVal = RegVal | (rbd_0c[j] << 8 * j);
+ }
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AB + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0));
+ rbd_0c[0] = (RegVal) &0x0000001f;
+ rbd_0c[1] = (RegVal >> 8) & 0x0000001f;
+ rbd_0c[2] = (RegVal >> 16) & 0x0000001f;
+ rbd_0c[3] = (RegVal >> 24) & 0x0000001f;
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000AB + i * 0x20);
+ RegVal = (ReadReg_32(DBSC_E3_DBPDRGD0) & 0xE0E0E0E0);
+ for (j = 0; j < 4; j++) {
+ rbd_0c[j] = (rbd_0c[j] + bdlcount_0c_div4);
+ if (rbd_0c[j] > 0x1F) rbd_0c[j] = 0x1F;
+ RegVal = RegVal | (rbd_0c[j] << 8 * j);
+ }
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
+ }
+ }
}
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000002);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x07D81E37);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000002);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x07D81E37);
}
-
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000003);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0380C700);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000007);
- while ( (BIT30 & ReadReg_32(DBSC_E3_DBPDRGD0)) != 0 );
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000021);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x0024643E);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000003);
+ if (byp_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0380C720);
+ } else {
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0380C700);
+ }
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000007);
+ while ((BIT30 & ReadReg_32(DBSC_E3_DBPDRGD0)) != 0);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000021);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x0024643E);
/****************************************************************************
* recovery_Step3(DBSC Setting 2)
***************************************************************************/
- WriteReg_32(DBSC_E3_DBDFICUPDCNF,0x40100001);
- WriteReg_32(DBSC_E3_DBACEN,0x00000001);
+ WriteReg_32(DBSC_E3_DBDFICUPDCNF, 0x40100001);
+ WriteReg_32(DBSC_E3_DBACEN, 0x00000001);
/* rev.0.08 */
- if (pdqsr_ctl == 1){
- WriteReg_32(0xE67F0018,0x00000001);
+ if (pdqsr_ctl == 1) {
+ WriteReg_32(0xE67F0018, 0x00000001);
RegVal = ReadReg_32(0x40000000);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000000);
- WriteReg_32(DBSC_E3_DBPDRGD0,RegVal);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000A0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000C0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x000000E0);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
- WriteReg_32(DBSC_E3_DBPDRGA0,0x00000100);
- WriteReg_32(DBSC_E3_DBPDRGD0,0x7C0002C5);
-
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGD0, RegVal);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E0);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000100);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x7C0002C5);
}
+ /* PDR dynamic */ /* rev.0.10 */
+ if (pdr_ctl == 1) {
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000A3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000C3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x000000E3);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBPDRGA0, 0x00000103);
+ WriteReg_32(DBSC_E3_DBPDRGD0, 0x00000000);
+ }
- WriteReg_32(DBSC_E3_DBPDLK0,0x00000000);
- WriteReg_32(DBSC_E3_DBSYSCNT0,0x00000000);
+ WriteReg_32(DBSC_E3_DBPDLK0, 0x00000000);
+ WriteReg_32(DBSC_E3_DBSYSCNT0, 0x00000000);
#ifdef ddr_qos_init_setting /* only for non qos_init */
- WriteReg_32(DBSC_E3_DBSYSCNT0,0x00001234);
- WriteReg_32(DBSC_E3_DBCAM0CNF1,0x00043218);
- WriteReg_32(DBSC_E3_DBCAM0CNF2,0x000000F4);
- WriteReg_32(DBSC_E3_DBSCHCNT0,0x000f0037);
- WriteReg_32(DBSC_E3_DBSCHSZ0,0x00000001);
- WriteReg_32(DBSC_E3_DBSCHRW0,0x22421111);
- WriteReg_32(DBSC_E3_SCFCTST2,0x012F1123);
- WriteReg_32(DBSC_E3_DBSCHQOS00,0x00000F00);
- WriteReg_32(DBSC_E3_DBSCHQOS01,0x00000B00);
- WriteReg_32(DBSC_E3_DBSCHQOS02,0x00000000);
- WriteReg_32(DBSC_E3_DBSCHQOS03,0x00000000);
- WriteReg_32(DBSC_E3_DBSCHQOS40,0x00000300);
- WriteReg_32(DBSC_E3_DBSCHQOS41,0x000002F0);
- WriteReg_32(DBSC_E3_DBSCHQOS42,0x00000200);
- WriteReg_32(DBSC_E3_DBSCHQOS43,0x00000100);
- WriteReg_32(DBSC_E3_DBSCHQOS90,0x00000100);
- WriteReg_32(DBSC_E3_DBSCHQOS91,0x000000F0);
- WriteReg_32(DBSC_E3_DBSCHQOS92,0x000000A0);
- WriteReg_32(DBSC_E3_DBSCHQOS93,0x00000040);
- WriteReg_32(DBSC_E3_DBSCHQOS130,0x00000100);
- WriteReg_32(DBSC_E3_DBSCHQOS131,0x000000F0);
- WriteReg_32(DBSC_E3_DBSCHQOS132,0x000000A0);
- WriteReg_32(DBSC_E3_DBSCHQOS133,0x00000040);
- WriteReg_32(DBSC_E3_DBSCHQOS140,0x000000C0);
- WriteReg_32(DBSC_E3_DBSCHQOS141,0x000000B0);
- WriteReg_32(DBSC_E3_DBSCHQOS142,0x00000080);
- WriteReg_32(DBSC_E3_DBSCHQOS143,0x00000040);
- WriteReg_32(DBSC_E3_DBSCHQOS150,0x00000040);
- WriteReg_32(DBSC_E3_DBSCHQOS151,0x00000030);
- WriteReg_32(DBSC_E3_DBSCHQOS152,0x00000020);
- WriteReg_32(DBSC_E3_DBSCHQOS153,0x00000010);
+ WriteReg_32(DBSC_E3_DBSYSCNT0, 0x00001234);
+ WriteReg_32(DBSC_E3_DBCAM0CNF1, 0x00043218);
+ WriteReg_32(DBSC_E3_DBCAM0CNF2, 0x000000F4);
+ WriteReg_32(DBSC_E3_DBSCHCNT0, 0x000f0037);
+ WriteReg_32(DBSC_E3_DBSCHSZ0, 0x00000001);
+ WriteReg_32(DBSC_E3_DBSCHRW0, 0x22421111);
+ WriteReg_32(DBSC_E3_SCFCTST2, 0x012F1123);
+ WriteReg_32(DBSC_E3_DBSCHQOS00, 0x00000F00);
+ WriteReg_32(DBSC_E3_DBSCHQOS01, 0x00000B00);
+ WriteReg_32(DBSC_E3_DBSCHQOS02, 0x00000000);
+ WriteReg_32(DBSC_E3_DBSCHQOS03, 0x00000000);
+ WriteReg_32(DBSC_E3_DBSCHQOS40, 0x00000300);
+ WriteReg_32(DBSC_E3_DBSCHQOS41, 0x000002F0);
+ WriteReg_32(DBSC_E3_DBSCHQOS42, 0x00000200);
+ WriteReg_32(DBSC_E3_DBSCHQOS43, 0x00000100);
+ WriteReg_32(DBSC_E3_DBSCHQOS90, 0x00000100);
+ WriteReg_32(DBSC_E3_DBSCHQOS91, 0x000000F0);
+ WriteReg_32(DBSC_E3_DBSCHQOS92, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBSCHQOS93, 0x00000040);
+ WriteReg_32(DBSC_E3_DBSCHQOS130, 0x00000100);
+ WriteReg_32(DBSC_E3_DBSCHQOS131, 0x000000F0);
+ WriteReg_32(DBSC_E3_DBSCHQOS132, 0x000000A0);
+ WriteReg_32(DBSC_E3_DBSCHQOS133, 0x00000040);
+ WriteReg_32(DBSC_E3_DBSCHQOS140, 0x000000C0);
+ WriteReg_32(DBSC_E3_DBSCHQOS141, 0x000000B0);
+ WriteReg_32(DBSC_E3_DBSCHQOS142, 0x00000080);
+ WriteReg_32(DBSC_E3_DBSCHQOS143, 0x00000040);
+ WriteReg_32(DBSC_E3_DBSCHQOS150, 0x00000040);
+ WriteReg_32(DBSC_E3_DBSCHQOS151, 0x00000030);
+ WriteReg_32(DBSC_E3_DBSCHQOS152, 0x00000020);
+ WriteReg_32(DBSC_E3_DBSCHQOS153, 0x00000010);
/* rev.0.08 */
- if (pdqsr_ctl == 1){}else{
- WriteReg_32(0xE67F0018,0x00000001);
+ if (pdqsr_ctl == 1){} else {
+ WriteReg_32(0xE67F0018, 0x00000001);
}
- WriteReg_32(DBSC_E3_DBSYSCNT0,0x00000000);
+ WriteReg_32(DBSC_E3_DBSYSCNT0, 0x00000000);
#endif
return 1;
@@ -1504,38 +1666,37 @@
{
uint32_t dataL;
uint32_t failcount;
- uint32_t md=0;
- uint32_t ddr=0;
+ uint32_t md = 0;
+ uint32_t ddr = 0;
md = *((volatile uint32_t*)RST_MODEMR);
ddr = (md & 0x00080000) >> 19;
- if(ddr == 0x0){
- NOTICE("BL2: DDR1584(%s)", RCAR_E3_DDR_VERSION);
- }
- else if(ddr == 0x1){
- NOTICE("BL2: DDR1856(%s)", RCAR_E3_DDR_VERSION);
+ if (ddr == 0x0) {
+ NOTICE("BL2: DDR1584(%s)", RCAR_E3_DDR_VERSION);
+ } else if(ddr == 0x1){
+ NOTICE("BL2: DDR1856(%s)", RCAR_E3_DDR_VERSION);
} /* ddr */
rcar_dram_get_boot_status(&ddrBackup);
- if(ddrBackup==DRAM_BOOT_STATUS_WARM){
- dataL=recovery_from_backup_mode(); /* WARM boot */
+ if (ddrBackup == DRAM_BOOT_STATUS_WARM) {
+ dataL = recovery_from_backup_mode(); /* WARM boot */
} else {
- dataL=init_ddr(); /* COLD boot */
+ dataL = init_ddr(); /* COLD boot */
} /* ddrBackup */
- if(dataL==1){
- failcount =0;
+ if (dataL == 1) {
+ failcount = 0;
} else {
- failcount =1;
+ failcount = 1;
} /* dataL */
- NOTICE("..%d\n",failcount); /* rev.0.05 */
+ NOTICE("..%d\n", failcount); /* rev.0.05 */
- if(failcount==0){
- return INITDRAM_OK;
+ if (failcount == 0) {
+ return INITDRAM_OK;
} else {
- return INITDRAM_NG;
+ return INITDRAM_NG;
} /* failcount */
} /* InitDram */
diff --git a/drivers/staging/renesas/rcar/ddr/ddr_a/ddr_init_e3.h b/drivers/staging/renesas/rcar/ddr/ddr_a/ddr_init_e3.h
index 47fe07b..2e9a5bf 100644
--- a/drivers/staging/renesas/rcar/ddr/ddr_a/ddr_init_e3.h
+++ b/drivers/staging/renesas/rcar/ddr/ddr_a/ddr_init_e3.h
@@ -9,7 +9,7 @@
#include <stdint.h>
-#define RCAR_E3_DDR_VERSION "rev.0.09"
+#define RCAR_E3_DDR_VERSION "rev.0.11"
#ifdef ddr_qos_init_setting
#define REFRESH_RATE 3900 /* Average periodic refresh interval[ns]. Support 3900,7800 */
diff --git a/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram.c b/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram.c
index d729131..78f0f11 100644
--- a/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram.c
+++ b/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram.c
@@ -7,8 +7,10 @@
#include <stdint.h>
#include <string.h>
#include <stdio.h>
-#include <mmio.h>
-#include <debug.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "ddr_regdef.h"
#include "init_dram_tbl_h3.h"
#include "init_dram_tbl_m3.h"
@@ -85,21 +87,11 @@
static uint32_t ddr_mbpsdiv;
static uint32_t ddr_tccd;
static struct _boardcnf *Boardcnf;
-uint32_t ddr_phyvalid;
-uint32_t ddr_density[DRAM_CH_CNT][CS_CNT];
+static uint32_t ddr_phyvalid;
+static uint32_t ddr_phycaslice;
+static volatile uint32_t ddr_density[DRAM_CH_CNT][CS_CNT];
static uint32_t ch_have_this_cs[CS_CNT];
static uint32_t rdqdm_dly[DRAM_CH_CNT][CS_CNT][SLICE_CNT * 2][9];
-static uint32_t rdqdm_le[DRAM_CH_CNT][CS_CNT][SLICE_CNT * 2][9];
-static uint32_t rdqdm_te[DRAM_CH_CNT][CS_CNT][SLICE_CNT * 2][9];
-static uint32_t rdqdm_nw[DRAM_CH_CNT][CS_CNT][SLICE_CNT * 2][9];
-static uint32_t rdqdm_win[DRAM_CH_CNT][CS_CNT][SLICE_CNT];
-static uint32_t rdqdm_st[DRAM_CH_CNT][CS_CNT][SLICE_CNT * 2];
-
-static uint32_t wdqdm_le[DRAM_CH_CNT][CS_CNT][SLICE_CNT][9];
-static uint32_t wdqdm_te[DRAM_CH_CNT][CS_CNT][SLICE_CNT][9];
-static uint32_t wdqdm_dly[DRAM_CH_CNT][CS_CNT][SLICE_CNT][9];
-static uint32_t wdqdm_st[DRAM_CH_CNT][CS_CNT][SLICE_CNT];
-static uint32_t wdqdm_win[DRAM_CH_CNT][CS_CNT][SLICE_CNT];
static uint32_t max_density;
static uint32_t ddr0800_mul;
static uint32_t ddr_mul;
@@ -258,9 +250,6 @@
static void ddr_setval_ach_as(uint32_t regdef, uint32_t val);
static uint32_t ddr_getval(uint32_t ch, uint32_t regdef);
static uint32_t ddr_getval_ach(uint32_t regdef, uint32_t * p);
-/* NOT USED
-static uint32_t ddr_getval_ach_s(uint32_t slice, uint32_t regdef, uint32_t *p);
-*/
static uint32_t ddr_getval_ach_as(uint32_t regdef, uint32_t * p);
static void _tblcopy(uint32_t * to, const uint32_t * from, uint32_t size);
static void ddrtbl_setval(uint32_t * tbl, uint32_t _regdef, uint32_t val);
@@ -282,7 +271,7 @@
static uint32_t dfi_init_start(void);
static void change_lpddr4_en(uint32_t mode);
static uint32_t set_term_code(void);
-static void ddr_register_set(uint32_t ch);
+static void ddr_register_set(void);
static inline uint32_t wait_freqchgreq(uint32_t assert);
static inline void set_freqchgack(uint32_t assert);
static inline void set_dfifrequency(uint32_t freq);
@@ -291,12 +280,8 @@
static uint32_t pi_training_go(void);
static uint32_t init_ddr(void);
static uint32_t swlvl1(uint32_t ddr_csn, uint32_t reg_cs, uint32_t reg_kick);
-static void wdqdm_clr1(uint32_t ch, uint32_t ddr_csn);
-static uint32_t wdqdm_ana1(uint32_t ch, uint32_t ddr_csn);
static uint32_t wdqdm_man1(void);
static uint32_t wdqdm_man(void);
-static void rdqdm_clr1(uint32_t ch, uint32_t ddr_csn);
-static uint32_t rdqdm_ana1(uint32_t ch, uint32_t ddr_csn);
static uint32_t rdqdm_man1(void);
static uint32_t rdqdm_man(void);
@@ -323,6 +308,24 @@
******************************************************************************/
#include "boot_init_dram_config.c"
+#ifndef DDR_FAST_INIT
+static uint32_t rdqdm_le[DRAM_CH_CNT][CS_CNT][SLICE_CNT * 2][9];
+static uint32_t rdqdm_te[DRAM_CH_CNT][CS_CNT][SLICE_CNT * 2][9];
+static uint32_t rdqdm_nw[DRAM_CH_CNT][CS_CNT][SLICE_CNT * 2][9];
+static uint32_t rdqdm_win[DRAM_CH_CNT][CS_CNT][SLICE_CNT];
+static uint32_t rdqdm_st[DRAM_CH_CNT][CS_CNT][SLICE_CNT * 2];
+static void rdqdm_clr1(uint32_t ch, uint32_t ddr_csn);
+static uint32_t rdqdm_ana1(uint32_t ch, uint32_t ddr_csn);
+
+static uint32_t wdqdm_le[DRAM_CH_CNT][CS_CNT][SLICE_CNT][9];
+static uint32_t wdqdm_te[DRAM_CH_CNT][CS_CNT][SLICE_CNT][9];
+static uint32_t wdqdm_dly[DRAM_CH_CNT][CS_CNT][SLICE_CNT][9];
+static uint32_t wdqdm_st[DRAM_CH_CNT][CS_CNT][SLICE_CNT];
+static uint32_t wdqdm_win[DRAM_CH_CNT][CS_CNT][SLICE_CNT];
+static void wdqdm_clr1(uint32_t ch, uint32_t ddr_csn);
+static uint32_t wdqdm_ana1(uint32_t ch, uint32_t ddr_csn);
+#endif/* DDR_FAST_INIT */
+
/*******************************************************************************
* macro for channel selection loop
******************************************************************************/
@@ -361,95 +364,121 @@
{
uint32_t dataL, dataDIV, dataMUL, tmpDIV;
- /* PLL3 disable */
- dataL = mmio_read_32(CPG_PLLECR);
- dataL &= ~CPG_PLLECR_PLL3E_BIT;
- cpg_write_32(CPG_PLLECR, dataL);
- dsb_sev();
- cpg_write_32(CPG_FRQCRD, 0x00030003); /* PLL3 DIV resetting */
- dsb_sev();
-
- /* PLL3 enable */
- dataL = CPG_ZB3CKCR_ZB3ST_BIT | mmio_read_32(CPG_ZB3CKCR);
- cpg_write_32(CPG_ZB3CKCR, dataL); /* zb3 clk stop */
- dsb_sev();
-
- /* PLL3 Restart */
- dataL = mmio_read_32(CPG_PLLECR);
- dataL |= CPG_PLLECR_PLL3E_BIT;
- cpg_write_32(CPG_PLLECR, dataL);
- dsb_sev();
-
- do {
- dataL = mmio_read_32(CPG_PLLECR);
- } while ((dataL & CPG_PLLECR_PLL3ST_BIT) == 0);
- dsb_sev();
-
if (high) {
- /* High frequency */
tmpDIV =
(1000 * ddr_mbpsdiv * brd_clkdiv * (brd_clkdiva + 1)) /
(ddr_mul * brd_clk * ddr_mbpsdiv + 1);
dataMUL =
- ((ddr_mul * (tmpDIV + 1) - 1) << 24) | (brd_clkdiva << 7);
- if (tmpDIV) {
- dataDIV = tmpDIV + 1;
- } else {
- dataDIV = 0;
- }
+ (ddr_mul * (tmpDIV + 1) - 1) << 24;
Pll3Mode = 1;
loop_max = 2;
} else {
- /* Low frequency */
tmpDIV =
(1000 * ddr_mbpsdiv * brd_clkdiv * (brd_clkdiva + 1)) /
(ddr0800_mul * brd_clk * ddr_mbpsdiv + 1);
dataMUL =
- ((ddr0800_mul * (tmpDIV + 1) -
- 1) << 24) | (brd_clkdiva << 7);
- if (tmpDIV) {
- dataDIV = tmpDIV + 1;
- } else {
- dataDIV = 0;
- }
+ (ddr0800_mul * (tmpDIV + 1) - 1) << 24;
Pll3Mode = 0;
loop_max = 8;
}
+ if (tmpDIV) {
+ dataDIV = tmpDIV + 1;
+ } else {
+ dataDIV = 0;
+ }
+ dataMUL = dataMUL | (brd_clkdiva << 7);
- dataL = (0xFF80FF80 & mmio_read_32(CPG_FRQCRD));
- cpg_write_32(CPG_FRQCRD, dataL); /* PLL3 DIV resetting */
+ /* PLL3 disable */
+ dataL = mmio_read_32(CPG_PLLECR) & ~CPG_PLLECR_PLL3E_BIT;
+ cpg_write_32(CPG_PLLECR, dataL);
dsb_sev();
- dataL = CPG_FRQCRB_KICK_BIT | mmio_read_32(CPG_FRQCRB);
- cpg_write_32(CPG_FRQCRB, dataL); /* DIV SET KICK */
- dsb_sev();
+ if ((Prr_Product == PRR_PRODUCT_M3) ||
+ ((Prr_Product == PRR_PRODUCT_H3) && (Prr_Cut <= PRR_PRODUCT_20))) {
+ /* PLL3 DIV resetting(Lowest value:3) */
+ dataL = 0x00030003 | (0xFF80FF80 & mmio_read_32(CPG_FRQCRD));
+ cpg_write_32(CPG_FRQCRD, dataL);
+ dsb_sev();
- /* PLL3 FREQ */
- cpg_write_32(CPG_PLL3CR, dataMUL); /* Set PLL3 freq */
- dsb_sev();
+ /* zb3 clk stop */
+ dataL = CPG_ZB3CKCR_ZB3ST_BIT | mmio_read_32(CPG_ZB3CKCR);
+ cpg_write_32(CPG_ZB3CKCR, dataL);
+ dsb_sev();
- do {
- dataL = mmio_read_32(CPG_PLLECR);
- } while ((dataL & CPG_PLLECR_PLL3ST_BIT) == 0);
- dsb_sev();
+ /* PLL3 enable */
+ dataL = CPG_PLLECR_PLL3E_BIT | mmio_read_32(CPG_PLLECR);
+ cpg_write_32(CPG_PLLECR, dataL);
+ dsb_sev();
- dataL =
- (dataDIV << 16) | dataDIV | (0xFF80FF80 & mmio_read_32(CPG_FRQCRD));
- cpg_write_32(CPG_FRQCRD, dataL); /* PLL3 DIV resetting */
- dsb_sev();
+ do {
+ dataL = mmio_read_32(CPG_PLLECR);
+ } while ((dataL & CPG_PLLECR_PLL3ST_BIT) == 0);
+ dsb_sev();
- dataL = CPG_FRQCRB_KICK_BIT | mmio_read_32(CPG_FRQCRB);
- cpg_write_32(CPG_FRQCRB, dataL); /* DIV SET KICK */
- dsb_sev();
+ /* PLL3 DIV resetting (Highest value:0) */
+ dataL = (0xFF80FF80 & mmio_read_32(CPG_FRQCRD));
+ cpg_write_32(CPG_FRQCRD, dataL);
+ dsb_sev();
- do {
- dataL = mmio_read_32(CPG_PLLECR);
- } while ((dataL & CPG_PLLECR_PLL3ST_BIT) == 0);
- dsb_sev();
+ /* DIV SET KICK */
+ dataL = CPG_FRQCRB_KICK_BIT | mmio_read_32(CPG_FRQCRB);
+ cpg_write_32(CPG_FRQCRB, dataL);
+ dsb_sev();
- dataL = (~CPG_ZB3CKCR_ZB3ST_BIT) & mmio_read_32(CPG_ZB3CKCR);
- cpg_write_32(CPG_ZB3CKCR, dataL); /* zb3 clk start */
- dsb_sev();
+ /* PLL3 multiplie set */
+ cpg_write_32(CPG_PLL3CR, dataMUL);
+ dsb_sev();
+
+ do {
+ dataL = mmio_read_32(CPG_PLLECR);
+ } while ((dataL & CPG_PLLECR_PLL3ST_BIT) == 0);
+ dsb_sev();
+
+ /* PLL3 DIV resetting(Target value) */
+ dataL = (dataDIV << 16) | dataDIV | (0xFF80FF80 & mmio_read_32(CPG_FRQCRD));
+ cpg_write_32(CPG_FRQCRD, dataL);
+ dsb_sev();
+
+ /* DIV SET KICK */
+ dataL = CPG_FRQCRB_KICK_BIT | mmio_read_32(CPG_FRQCRB);
+ cpg_write_32(CPG_FRQCRB, dataL);
+ dsb_sev();
+
+ do {
+ dataL = mmio_read_32(CPG_PLLECR);
+ } while ((dataL & CPG_PLLECR_PLL3ST_BIT) == 0);
+ dsb_sev();
+
+ /* zb3 clk start */
+ dataL = (~CPG_ZB3CKCR_ZB3ST_BIT) & mmio_read_32(CPG_ZB3CKCR);
+ cpg_write_32(CPG_ZB3CKCR, dataL);
+ dsb_sev();
+
+ } else { /* H3Ver.3.0/M3N/V3H */
+
+ /* PLL3 multiplie set */
+ cpg_write_32(CPG_PLL3CR, dataMUL);
+ dsb_sev();
+
+ /* PLL3 DIV set(Target value) */
+ dataL = (dataDIV << 16) | dataDIV | (0xFF80FF80 & mmio_read_32(CPG_FRQCRD));
+ cpg_write_32(CPG_FRQCRD, dataL);
+
+ /* DIV SET KICK */
+ dataL = CPG_FRQCRB_KICK_BIT | mmio_read_32(CPG_FRQCRB);
+ cpg_write_32(CPG_FRQCRB, dataL);
+ dsb_sev();
+
+ /* PLL3 enable */
+ dataL = CPG_PLLECR_PLL3E_BIT | mmio_read_32(CPG_PLLECR);
+ cpg_write_32(CPG_PLLECR, dataL);
+ dsb_sev();
+
+ do {
+ dataL = mmio_read_32(CPG_PLLECR);
+ } while ((dataL & CPG_PLLECR_PLL3ST_BIT) == 0);
+ dsb_sev();
+ }
return;
}
@@ -645,11 +674,6 @@
return DDR_REGDEF_LSB(pDDR_REGDEF_TBL[_regdef]);
}
-static inline uint32_t ddr_regdef_len(uint32_t _regdef)
-{
- return DDR_REGDEF_LEN(pDDR_REGDEF_TBL[_regdef]);
-}
-
static void ddr_setval_s(uint32_t ch, uint32_t slice, uint32_t _regdef,
uint32_t val)
{
@@ -738,17 +762,6 @@
return p[0];
}
-/* NOT_USED
-static uint32_t ddr_getval_ach_s(uint32_t slice, uint32_t regdef, uint32_t *p)
-{
- uint32_t ch;
-
- foreach_vch(ch)
- p[ch] = ddr_getval_s(ch, slice, regdef);
- return p[0];
-}
-*/
-
static uint32_t ddr_getval_ach_as(uint32_t regdef, uint32_t * p)
{
uint32_t ch, slice;
@@ -923,9 +936,8 @@
#define JS2_tRCpb (JS2_TBLCNT)
#define JS2_tRCab (JS2_TBLCNT+1)
-#define JS2_tRFCpb (JS2_TBLCNT+2)
-#define JS2_tRFCab (JS2_TBLCNT+3)
-#define JS2_CNT (JS2_TBLCNT+4)
+#define JS2_tRFCab (JS2_TBLCNT+2)
+#define JS2_CNT (JS2_TBLCNT+3)
#ifndef JS2_DERATE
#define JS2_DERATE 0
@@ -980,13 +992,9 @@
}
};
-/* pb, ab */
-const uint16_t jedec_spec2_tRFC_pb_ab[2][7] = {
+const uint16_t jedec_spec2_tRFC_ab[7] = {
/* 4Gb, 6Gb, 8Gb,12Gb, 16Gb, 24Gb(non), 32Gb(non) */
- {
- 60, 90, 90, 140, 140, 280, 280},
- {
- 130, 180, 180, 280, 280, 560, 560}
+ 130, 180, 180, 280, 280, 560, 560
};
static uint32_t js1_ind;
@@ -1407,46 +1415,26 @@
}
/***********************************************************************
- Adjust PI paramters
+ Adjust PI parameters
***********************************************************************/
#ifdef _def_LPDDR4_ODT
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR11_DATA_F0_0,
- _def_LPDDR4_ODT);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR11_DATA_F0_1,
- _def_LPDDR4_ODT);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR11_DATA_F0_2,
- _def_LPDDR4_ODT);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR11_DATA_F0_3,
- _def_LPDDR4_ODT);
-
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR11_DATA_F1_0,
- _def_LPDDR4_ODT);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR11_DATA_F1_1,
- _def_LPDDR4_ODT);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR11_DATA_F1_2,
- _def_LPDDR4_ODT);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR11_DATA_F1_3,
- _def_LPDDR4_ODT);
+ for (i = 0; i < 2; i++) {
+ for (csab = 0; csab < CSAB_CNT; csab++) {
+ ddrtbl_setval(_cnf_DDR_PI_REGSET,
+ _reg_PI_MR11_DATA_Fx_CSx[i][csab],
+ _def_LPDDR4_ODT);
+ }
+ }
#endif /* _def_LPDDR4_ODT */
#ifdef _def_LPDDR4_VREFCA
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR12_DATA_F0_0,
- _def_LPDDR4_VREFCA);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR12_DATA_F0_1,
- _def_LPDDR4_VREFCA);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR12_DATA_F0_2,
- _def_LPDDR4_VREFCA);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR12_DATA_F0_3,
- _def_LPDDR4_VREFCA);
-
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR12_DATA_F1_0,
- _def_LPDDR4_VREFCA);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR12_DATA_F1_1,
- _def_LPDDR4_VREFCA);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR12_DATA_F1_2,
- _def_LPDDR4_VREFCA);
- ddrtbl_setval(_cnf_DDR_PI_REGSET, _reg_PI_MR12_DATA_F1_3,
- _def_LPDDR4_VREFCA);
+ for (i = 0; i < 2; i++) {
+ for (csab = 0; csab < CSAB_CNT; csab++) {
+ ddrtbl_setval(_cnf_DDR_PI_REGSET,
+ _reg_PI_MR12_DATA_Fx_CSx[i][csab],
+ _def_LPDDR4_VREFCA);
+ }
+ }
#endif /* _def_LPDDR4_VREFCA */
if ((Prr_Product == PRR_PRODUCT_M3N)
|| (Prr_Product == PRR_PRODUCT_V3H)) {
@@ -1561,6 +1549,32 @@
reg_ddrphy_write_a(adr + i, _cnf_DDR_PHY_ADR_V_REGSET[i]);
}
+ if (((Prr_Product == PRR_PRODUCT_M3)
+ || (Prr_Product == PRR_PRODUCT_M3N)) &&
+ ((0x00ffffff & (uint32_t)((Boardcnf->ch[0].ca_swap) >> 40))
+ != 0x00)) {
+ adr = DDR_PHY_ADR_I_REGSET_OFS + DDR_PHY_ADR_I_REGSET_SIZE;
+ for (i = 0; i < DDR_PHY_ADR_V_REGSET_NUM; i++) {
+ reg_ddrphy_write_a(adr + i,
+ _cnf_DDR_PHY_ADR_V_REGSET[i]);
+ }
+ ddrtbl_setval(_cnf_DDR_PHY_ADR_G_REGSET, _reg_PHY_ADR_DISABLE, 0x02);
+ DDR_PHY_ADR_I_NUM -= 1;
+ ddr_phycaslice = 1;
+
+#ifndef _def_LPDDR4_ODT
+ for (i = 0; i < 2; i++) {
+ for (csab = 0; csab < CSAB_CNT; csab++) {
+ ddrtbl_setval(_cnf_DDR_PI_REGSET,
+ _reg_PI_MR11_DATA_Fx_CSx[i][csab],
+ 0x66);
+ }
+ }
+#endif/* _def_LPDDR4_ODT */
+ } else {
+ ddr_phycaslice = 0;
+ }
+
if (DDR_PHY_ADR_I_NUM > 0) {
for (slice = 0; slice < DDR_PHY_ADR_I_NUM; slice++) {
adr =
@@ -1629,7 +1643,9 @@
BOARD SETTINGS (CA,ADDR_SEL)
***********************************************************************/
const uint32_t _par_CALVL_DEVICE_MAP = 1;
- dataL = Boardcnf->ch[ch].ca_swap | 0x00888888;
+
+ dataL = (0x00ffffff & (uint32_t)(Boardcnf->ch[ch].ca_swap)) |
+ 0x00888888;
/* --- ADR_CALVL_SWIZZLE --- */
if (Prr_Product == PRR_PRODUCT_M3) {
@@ -1661,6 +1677,38 @@
}
}
ddr_setval(ch, _reg_PHY_ADR_ADDR_SEL, dataL);
+ if (ddr_phycaslice == 1) {
+ /* ----------- adr slice2 swap ----------- */
+ tmp = (uint32_t)((Boardcnf->ch[ch].ca_swap) >> 40);
+ dataL = (tmp & 0x00ffffff) | 0x00888888;
+
+ /* --- ADR_CALVL_SWIZZLE --- */
+ if (Prr_Product == PRR_PRODUCT_M3) {
+ ddr_setval_s(ch, 2, _reg_PHY_ADR_CALVL_SWIZZLE0_0, dataL);
+ ddr_setval_s(ch, 2, _reg_PHY_ADR_CALVL_SWIZZLE1_0,
+ 0x00000000);
+ ddr_setval_s(ch, 2, _reg_PHY_ADR_CALVL_SWIZZLE0_1, dataL);
+ ddr_setval_s(ch, 2, _reg_PHY_ADR_CALVL_SWIZZLE1_1,
+ 0x00000000);
+ ddr_setval_s(ch, 2, _reg_PHY_ADR_CALVL_DEVICE_MAP,
+ _par_CALVL_DEVICE_MAP);
+ } else {
+ ddr_setval_s(ch, 2, _reg_PHY_ADR_CALVL_SWIZZLE0, dataL);
+ ddr_setval_s(ch, 2, _reg_PHY_ADR_CALVL_SWIZZLE1,
+ 0x00000000);
+ ddr_setval_s(ch, 2, _reg_PHY_CALVL_DEVICE_MAP,
+ _par_CALVL_DEVICE_MAP);
+ }
+
+ /* --- ADR_ADDR_SEL --- */
+ dataL = 0;
+ for (i = 0; i < 6; i++) {
+ dataL |= ((tmp & 0x0f) << (i * 5));
+ tmp = tmp >> 4;
+ }
+
+ ddr_setval_s(ch, 2, _reg_PHY_ADR_ADDR_SEL, dataL);
+ }
/***********************************************************************
BOARD SETTINGS (BYTE_ORDER_SEL)
@@ -1708,7 +1756,7 @@
if (tgt == tmp)
break;
}
- tmp = Boardcnf->ch[ch].ca_swap;
+ tmp = 0x00FFFFFF & Boardcnf->ch[ch].ca_swap;
if (slice % 2)
tmp |= 0x00888888;
*p_swz = tmp;
@@ -1753,7 +1801,7 @@
/***********************************************************************
BOARD SETTINGS (CA,ADDR_SEL)
***********************************************************************/
- ca = Boardcnf->ch[ch].ca_swap;
+ ca = 0x00FFFFFF & Boardcnf->ch[ch].ca_swap;
ddr_setval(ch, _reg_PHY_ADR_ADDR_SEL, ca);
ddr_setval(ch, _reg_PHY_CALVL_CS_MAP, csmap);
@@ -1862,6 +1910,16 @@
ddr_setval(ch, _reg_PHY_CLK_CACS_SLAVE_DELAY_X[i],
dataL + adj);
}
+ if (ddr_phycaslice == 1) {
+ for (i = 0; i < 6; i++) {
+ adj =
+ _f_scale_adj(Boardcnf->ch[ch].cacs_adj[i +
+ _reg_PHY_CLK_CACS_SLAVE_DELAY_X_NUM]);
+ ddr_setval_s(ch, 2,
+ _reg_PHY_CLK_CACS_SLAVE_DELAY_X[i],
+ dataL + adj);
+ }
+ }
}
set_dfifrequency(0x00);
@@ -1972,20 +2030,13 @@
/* RFC */
if ((Prr_Product == PRR_PRODUCT_H3) && (Prr_Cut == PRR_PRODUCT_20)
&& (max_density == 0)) {
- js2[JS2_tRFCpb] =
- _f_scale(ddr_mbps, ddr_mbpsdiv,
- 1UL * jedec_spec2_tRFC_pb_ab[0][1] * 1000, 0);
js2[JS2_tRFCab] =
_f_scale(ddr_mbps, ddr_mbpsdiv,
- 1UL * jedec_spec2_tRFC_pb_ab[1][1] * 1000, 0);
+ 1UL * jedec_spec2_tRFC_ab[1] * 1000, 0);
} else {
- js2[JS2_tRFCpb] = _f_scale(ddr_mbps, ddr_mbpsdiv,
- 1UL *
- jedec_spec2_tRFC_pb_ab[0]
- [max_density] * 1000, 0);
js2[JS2_tRFCab] =
_f_scale(ddr_mbps, ddr_mbpsdiv,
- 1UL * jedec_spec2_tRFC_pb_ab[1][max_density] *
+ 1UL * jedec_spec2_tRFC_ab[max_density] *
1000, 0);
}
@@ -2030,7 +2081,7 @@
dataL = WL + 1 + (16 / 2) + js2[JS2_tWTR];
mmio_write_32(DBSC_DBTR(12), (dataL << 16) | dataL);
- /* DBTR13.TRFCPB,TRFCAB : tRFCpb, tRFCab */
+ /* DBTR13.TRFCAB : tRFCab */
mmio_write_32(DBSC_DBTR(13), (js2[JS2_tRFCab]));
/* DBTR14.TCKEHDLL,tCKEH : tCKEHCMD,tCKEHCMD */
@@ -2059,7 +2110,11 @@
/* WRCSGAP = 5 */
tmp[1] = 5;
/* RDCSLAT = RDLAT_ADJ +2 */
- tmp[2] = tmp[3] + 2;
+ if (Prr_Product == PRR_PRODUCT_M3) {
+ tmp[2] = tmp[3];
+ } else {
+ tmp[2] = tmp[3] + 2;
+ }
/* RDCSGAP = 6 */
if (Prr_Product == PRR_PRODUCT_M3) {
tmp[3] = 4;
@@ -2426,20 +2481,7 @@
uint32_t dataL;
const uint32_t RETRY_MAX = 0x10000;
- /***********************************************************************
- set IE=1 when init_start_disable==0
- ***********************************************************************/
- if (ddrtbl_getval(_cnf_DDR_PHY_ADR_G_REGSET, _reg_PHY_CAL_MODE_0) &
- 0x01) {
- ddr_setval_ach_as(_reg_PHY_IE_MODE, 0x00);
- } else {
- ddr_setval_ach_as(_reg_PHY_IE_MODE,
- ddrtbl_getval(_cnf_DDR_PHY_SLICE_REGSET,
- _reg_PHY_IE_MODE));
- }
-
if ((Prr_Product == PRR_PRODUCT_H3) && (Prr_Cut <= PRR_PRODUCT_11)) {
-
/***********************************************************************
PLL3 Disable
***********************************************************************/
@@ -2533,8 +2575,8 @@
_reg_PHY_PAD_CS_DRIVE
};
- for (i = 0; i < 3; i++) {
- foreach_vch(ch) {
+ foreach_vch(ch) {
+ for (i = 0; i < 3; i++) {
dataL = ddr_getval(ch, _reg_PHY_PAD_DRIVE_X[i]);
if (mode) {
dataL |= (1U << 14);
@@ -2589,9 +2631,6 @@
&& (Prr_Cut == PRR_PRODUCT_10)) {
/* non */
} else {
- ddr_setval_ach_as(_reg_PHY_IE_MODE,
- ddrtbl_getval(_cnf_DDR_PHY_SLICE_REGSET,
- _reg_PHY_IE_MODE));
ddr_setval_ach(_reg_PHY_PAD_TERM_X[0],
(ddrtbl_getval
(_cnf_DDR_PHY_ADR_G_REGSET,
@@ -2662,48 +2701,46 @@
/*******************************************************************************
* DDR mode register setting
******************************************************************************/
-static void ddr_register_set(uint32_t ch)
+static void ddr_register_set(void)
{
int32_t fspwp;
- uint32_t chind;
uint32_t tmp;
- chind = ch << 20;
for (fspwp = 1; fspwp >= 0; fspwp--) {
/*MR13,fspwp */
- send_dbcmd(0x0e040d08 | chind | (fspwp << 6));
+ send_dbcmd(0x0e840d08 | (fspwp << 6));
tmp =
ddrtbl_getval(_cnf_DDR_PI_REGSET,
_reg_PI_MR1_DATA_Fx_CSx[fspwp][0]);
- send_dbcmd(0x0e040100 | chind | tmp);
+ send_dbcmd(0x0e840100 | tmp);
tmp =
ddrtbl_getval(_cnf_DDR_PI_REGSET,
_reg_PI_MR2_DATA_Fx_CSx[fspwp][0]);
- send_dbcmd(0x0e040200 | chind | tmp);
+ send_dbcmd(0x0e840200 | tmp);
tmp =
ddrtbl_getval(_cnf_DDR_PI_REGSET,
_reg_PI_MR3_DATA_Fx_CSx[fspwp][0]);
- send_dbcmd(0x0e040300 | chind | tmp);
+ send_dbcmd(0x0e840300 | tmp);
tmp =
ddrtbl_getval(_cnf_DDR_PI_REGSET,
_reg_PI_MR11_DATA_Fx_CSx[fspwp][0]);
- send_dbcmd(0x0e040b00 | chind | tmp);
+ send_dbcmd(0x0e840b00 | tmp);
tmp =
ddrtbl_getval(_cnf_DDR_PI_REGSET,
_reg_PI_MR12_DATA_Fx_CSx[fspwp][0]);
- send_dbcmd(0x0e040c00 | chind | tmp);
+ send_dbcmd(0x0e840c00 | tmp);
tmp =
ddrtbl_getval(_cnf_DDR_PI_REGSET,
_reg_PI_MR14_DATA_Fx_CSx[fspwp][0]);
- send_dbcmd(0x0e040e00 | chind | tmp);
+ send_dbcmd(0x0e840e00 | tmp);
/* MR22 */
- send_dbcmd(0x0e041600 | chind | 0x16);
+ send_dbcmd(0x0e841616);
}
}
@@ -2902,7 +2939,7 @@
int32_t i;
uint32_t dataL;
uint32_t phytrainingok;
- uint32_t ch;
+ uint32_t ch, slice;
uint32_t err;
MSG_LF("init_ddr:0\n");
@@ -3009,12 +3046,8 @@
return (INITDRAM_ERR_O);
MSG_LF("init_ddr:5\n");
- /***********************************************************************
- set ie_mode=1
- ***********************************************************************/
- ddr_setval_ach_as(_reg_PHY_IE_MODE,
- ddrtbl_getval(_cnf_DDR_PHY_SLICE_REGSET,
- _reg_PHY_IE_MODE));
+ /* PDX */
+ send_dbcmd(0x08840001);
/***********************************************************************
check register i/f is alive
@@ -3035,38 +3068,22 @@
/* CMOS MODE */
change_lpddr4_en(0);
- ch = 0x08;
-
- /* PDE */
- send_dbcmd(0x08040000 | (0x00100000 * ch));
-
- /* PDX */
- send_dbcmd(0x08040001 | (0x00100000 * ch));
-
- /* MR22 (ODTCS & RQZ */
- send_dbcmd(0x0e041600 | (0x00100000 * ch) | 0x16);
+ /* MRS */
+ ddr_register_set();
/* ZQCAL start */
- send_dbcmd(0x0d04004F | (0x00100000 * ch));
- rcar_micro_delay(100);
+ send_dbcmd(0x0d84004F);
/* ZQLAT */
- send_dbcmd(0x0d040051 | (0x00100000 * ch));
+ send_dbcmd(0x0d840051);
/***********************************************************************
Thermal sensor setting
***********************************************************************/
- /* THCTR Bit6: PONM=0 , Bit0: THSST=1 */
- dataL =
- ((*((volatile uint32_t *)THS1_THCTR)) & 0xFFFFFFBF) | 0x00000001;
- *((volatile uint32_t *)THS1_THCTR) = dataL;
+ /* THCTR Bit6: PONM=0 , Bit0: THSST=1 */
+ dataL = (mmio_read_32(THS1_THCTR) & 0xFFFFFFBF) | 0x00000001;
+ mmio_write_32(THS1_THCTR, dataL);
- /***********************************************************************
- setup DDR mode registers
- ***********************************************************************/
- foreach_vch(ch) {
- ddr_register_set(ch);
- }
/* LPDDR4 MODE */
change_lpddr4_en(1);
@@ -3077,8 +3094,6 @@
***********************************************************************/
foreach_vch(ch) {
dataL = ddr_getval(ch, _reg_PI_CS_MAP);
- if (!(ch_have_this_cs[0] & (1U << ch)))
- dataL = dataL & 0x0a;
if (!(ch_have_this_cs[1] & (1U << ch)))
dataL = dataL & 0x05;
ddr_setval(ch, _reg_PI_CS_MAP, dataL);
@@ -3088,7 +3103,19 @@
exec pi_training
***********************************************************************/
ddr_setval_ach_as(_reg_PHY_PER_CS_TRAINING_MULTICAST_EN, 0x00);
+
+ if ((Prr_Product == PRR_PRODUCT_H3) && (Prr_Cut <= PRR_PRODUCT_11)) {
ddr_setval_ach_as(_reg_PHY_PER_CS_TRAINING_EN, 0x01);
+ } else {
+ foreach_vch(ch) {
+ for (slice = 0; slice < SLICE_CNT; slice++) {
+ ddr_setval_s(ch, slice,
+ _reg_PHY_PER_CS_TRAINING_EN,
+ ((ch_have_this_cs[1]) >> ch)
+ & 0x01);
+ }
+ }
+ }
phytrainingok = pi_training_go();
@@ -3109,7 +3136,17 @@
ddr_setval(ch, _reg_PHY_CLK_CACS_SLAVE_DELAY_X[i],
dataL + adj);
}
+
+ if (ddr_phycaslice == 1) {
+ for (i = 0; i < 6; i++) {
+ adj = _f_scale_adj(Boardcnf->ch[ch].cacs_adj[i + _reg_PHY_CLK_CACS_SLAVE_DELAY_X_NUM]);
+ ddr_setval_s(ch, 2, _reg_PHY_CLK_CACS_SLAVE_DELAY_X[i],
+ dataL + adj
+ );
+ }
+ }
}
+
update_dly();
MSG_LF("init_ddr:9\n");
@@ -3130,15 +3167,16 @@
/***********************************************************************
RDQLVL Training
***********************************************************************/
- if ((Prr_Product == PRR_PRODUCT_H3) || (Prr_Product == PRR_PRODUCT_M3)) {
+ if (ddrtbl_getval(_cnf_DDR_PHY_SLICE_REGSET, _reg_PHY_IE_MODE) == 0x00) {
ddr_setval_ach_as(_reg_PHY_IE_MODE, 0x01);
- } else {
- ddr_setval_ach_as(_reg_PHY_IE_MODE,
- ddrtbl_getval(_cnf_DDR_PHY_SLICE_REGSET,
- _reg_PHY_IE_MODE));
}
err = rdqdm_man();
+
+ if (ddrtbl_getval(_cnf_DDR_PHY_SLICE_REGSET, _reg_PHY_IE_MODE) == 0x00) {
+ ddr_setval_ach_as(_reg_PHY_IE_MODE, 0x00);
+ }
+
if (err) {
return (INITDRAM_ERR_T);
}
@@ -3227,6 +3265,7 @@
/*******************************************************************************
* WDQ TRAINING
******************************************************************************/
+#ifndef DDR_FAST_INIT
static void wdqdm_clr1(uint32_t ch, uint32_t ddr_csn)
{
int32_t i, k;
@@ -3282,7 +3321,6 @@
cs = ddr_csn % 2;
ddr_setval_s(ch, slice, _reg_PHY_PER_CS_TRAINING_INDEX, cs);
- ddr_getval_s(ch, slice, _reg_PHY_PER_CS_TRAINING_INDEX);
for (i = 0; i < 9; i++) {
dq = slice * 8 + i;
if (i == 8)
@@ -3323,10 +3361,16 @@
err = 2;
}
wdqdm_win[ch][cs][slice] = min_win;
+ if ((Prr_Product == PRR_PRODUCT_H3) && (Prr_Cut <= PRR_PRODUCT_11)) {
ddr_setval_s(ch, slice, _reg_PHY_PER_CS_TRAINING_EN, 0x01);
+ } else {
+ ddr_setval_s(ch, slice, _reg_PHY_PER_CS_TRAINING_EN,
+ ((ch_have_this_cs[1]) >> ch) & 0x01);
+ }
}
return err;
}
+#endif/* DDR_FAST_INIT */
static void wdqdm_cp(uint32_t ddr_csn, uint32_t restore)
{
@@ -3373,26 +3417,26 @@
uint32_t ddr_csn;
uint32_t dataL;
uint32_t err;
+ uint32_t high_dq[DRAM_CH_CNT];
+ uint32_t mr14_csab0_bak[DRAM_CH_CNT];
+#ifndef DDR_FAST_INIT
uint32_t err_flg;
+#endif/* DDR_FAST_INIT */
/***********************************************************************
manual execution of training
***********************************************************************/
- uint32_t high_dq[DRAM_CH_CNT];
- uint32_t mr14_csab0_bak[DRAM_CH_CNT];
-
- foreach_vch(ch) {
- high_dq[ch] = 0;
- for (slice = 0; slice < SLICE_CNT; slice++) {
- k = (Boardcnf->ch[ch].dqs_swap >> (4 * slice)) & 0x0f;
- if (k >= 2)
- high_dq[ch] |= (1U << slice);
+ if ((Prr_Product == PRR_PRODUCT_H3) && (Prr_Cut <= PRR_PRODUCT_11)) {
+ foreach_vch(ch) {
+ high_dq[ch] = 0;
+ for (slice = 0; slice < SLICE_CNT; slice++) {
+ k = (Boardcnf->ch[ch].dqs_swap >> (4 * slice)) & 0x0f;
+ if (k >= 2)
+ high_dq[ch] |= (1U << slice);
+ }
+ ddr_setval(ch, _reg_PI_16BIT_DRAM_CONNECT, 0x00);
}
}
-
- if ((Prr_Product == PRR_PRODUCT_H3) && (Prr_Cut <= PRR_PRODUCT_11))
- ddr_setval_ach(_reg_PI_16BIT_DRAM_CONNECT, 0x00);
-
err = 0;
/* CLEAR PREV RESULT */
for (cs = 0; cs < CS_CNT; cs++) {
@@ -3410,8 +3454,9 @@
}
ddrphy_regif_idle();
+#ifndef DDR_FAST_INIT
err_flg = 0;
-
+#endif/* DDR_FAST_INIT */
for (ddr_csn = 0; ddr_csn < CSAB_CNT; ddr_csn++) {
if ((Prr_Product == PRR_PRODUCT_H3)
&& (Prr_Cut <= PRR_PRODUCT_11)) {
@@ -3456,6 +3501,7 @@
ddr_setval(ch, _reg_PI_MR14_DATA_Fx_CSx[1][0],
mr14_csab0_bak[ch]);
}
+#ifndef DDR_FAST_INIT
foreach_vch(ch) {
if (!(ch_have_this_cs[ddr_csn % 2] & (1U << ch))) {
wdqdm_clr1(ch, ddr_csn);
@@ -3466,16 +3512,22 @@
err_flg |= (1U << (ddr_csn * 4 + ch));
ddrphy_regif_idle();
}
+#endif/* DDR_FAST_INIT */
}
err_exit:
- ddr_setval_ach(_reg_PI_16BIT_DRAM_CONNECT, 0x01);
- foreach_vch(ch) {
- dataL = mmio_read_32(DBSC_DBDFICNT(ch));
- dataL &= ~(0x00ffU << 16);
- mmio_write_32(DBSC_DBDFICNT(ch), dataL);
- ddr_setval(ch, _reg_PI_WDQLVL_RESP_MASK, 0x00);
+#ifndef DDR_FAST_INIT
+ err |= err_flg;
+#endif/* DDR_FAST_INIT */
+ if ((Prr_Product == PRR_PRODUCT_H3) && (Prr_Cut <= PRR_PRODUCT_11)) {
+ ddr_setval_ach(_reg_PI_16BIT_DRAM_CONNECT, 0x01);
+ foreach_vch(ch) {
+ dataL = mmio_read_32(DBSC_DBDFICNT(ch));
+ dataL &= ~(0x00ffU << 16);
+ mmio_write_32(DBSC_DBDFICNT(ch), dataL);
+ ddr_setval(ch, _reg_PI_WDQLVL_RESP_MASK, 0x00);
+ }
}
- return (err_flg | err);
+ return (err);
}
static uint32_t wdqdm_man(void)
@@ -3589,6 +3641,7 @@
/*******************************************************************************
* RDQ TRAINING
******************************************************************************/
+#ifndef DDR_FAST_INIT
static void rdqdm_clr1(uint32_t ch, uint32_t ddr_csn)
{
int32_t i, k;
@@ -3738,11 +3791,15 @@
}
return (err);
}
+#endif/* DDR_FAST_INIT */
static uint32_t rdqdm_man1(void)
{
uint32_t ch;
uint32_t ddr_csn;
+#ifdef DDR_FAST_INIT
+ uint32_t slice;
+#endif/* DDR_FAST_INIT */
uint32_t err;
/***********************************************************************
@@ -3750,12 +3807,12 @@
***********************************************************************/
err = 0;
- for (ddr_csn = 0; ddr_csn < CSAB_CNT; ddr_csn++) {
+ for (ddr_csn = 0; ddr_csn < CS_CNT; ddr_csn++) {
/* KICK RDQLVL */
err = swlvl1(ddr_csn, _reg_PI_RDLVL_CS, _reg_PI_RDLVL_REQ);
if (err)
goto err_exit;
-
+#ifndef DDR_FAST_INIT
foreach_vch(ch) {
if (!(ch_have_this_cs[ddr_csn % 2] & (1U << ch))) {
rdqdm_clr1(ch, ddr_csn);
@@ -3767,7 +3824,50 @@
if (err)
goto err_exit;
}
+#else/* DDR_FAST_INIT */
+ foreach_vch(ch) {
+ if (ch_have_this_cs[ddr_csn] & (1U << ch)) {
+ for (slice = 0; slice < SLICE_CNT; slice++) {
+ if (ddr_getval_s(ch, slice,
+ _reg_PHY_RDLVL_STATUS_OBS) !=
+ 0x0D00FFFF) {
+ err = (1U << ch) |
+ (0x10U << slice);
+ goto err_exit;
+ }
+ }
+ }
+ if (((Prr_Product == PRR_PRODUCT_H3)
+ && (Prr_Cut <= PRR_PRODUCT_11))
+ || ((Prr_Product == PRR_PRODUCT_M3)
+ && (Prr_Cut <= PRR_PRODUCT_10))) {
+ uint32_t i, adj, dataL;
+
+ for (slice = 0; slice < SLICE_CNT; slice++) {
+ for (i = 0; i <= 8; i++) {
+ if (i == 8)
+ adj = _f_scale_adj(Boardcnf->ch[ch].dm_adj_r[slice]);
+ else
+ adj = _f_scale_adj(Boardcnf->ch[ch].dq_adj_r[slice * 8 + i]);
+ ddr_setval_s(ch, slice, _reg_PHY_PER_CS_TRAINING_INDEX, ddr_csn);
+ dataL = ddr_getval_s(ch, slice, _reg_PHY_RDDQS_X_RISE_SLAVE_DELAY[i]) + adj;
+ ddr_setval_s(ch, slice, _reg_PHY_RDDQS_X_RISE_SLAVE_DELAY[i], dataL);
+ rdqdm_dly[ch][ddr_csn][slice][i] = dataL;
+ rdqdm_dly[ch][ddr_csn | 1][slice][i] = dataL;
+
+ dataL = ddr_getval_s(ch, slice, _reg_PHY_RDDQS_X_FALL_SLAVE_DELAY[i]) + adj;
+ ddr_setval_s(ch, slice, _reg_PHY_RDDQS_X_FALL_SLAVE_DELAY[i], dataL);
+ rdqdm_dly[ch][ddr_csn][slice + SLICE_CNT][i] = dataL;
+ rdqdm_dly[ch][ddr_csn | 1][slice + SLICE_CNT][i] = dataL;
+ }
+ }
+ }
+ }
+ ddrphy_regif_idle();
+
+#endif/* DDR_FAST_INIT */
}
+
err_exit:
return (err);
}
@@ -3865,7 +3965,6 @@
return tmp;
}
-/* #define RX_OFFSET_FAST */
static uint32_t rx_offset_cal(void)
{
uint32_t index;
@@ -3876,11 +3975,7 @@
uint32_t tmp;
uint32_t tmp_ach_as[DRAM_CH_CNT][SLICE_CNT];
uint64_t val[DRAM_CH_CNT][SLICE_CNT][_reg_PHY_RX_CAL_X_NUM];
-#ifdef RX_OFFSET_FAST
- uint32_t adr_st;
- adr_st = ddr_regdef_adr(_reg_PHY_RX_CAL_X[0]);
-#endif
- ddr_setval_ach_as(_reg_PHY_IE_MODE, 0x01);
+
ddr_setval_ach_as(_reg_PHY_RX_CAL_OVERRIDE, 0x01);
foreach_vch(ch) {
for (slice = 0; slice < SLICE_CNT; slice++) {
@@ -3892,19 +3987,9 @@
for (code = 0; code < CODE_MAX / CODE_STEP; code++) {
tmp = _rx_offset_cal_updn(code * CODE_STEP);
-#ifdef RX_OFFSET_FAST
- tmp = tmp | (tmp << 16);
- for (index = 0; index < (_reg_PHY_RX_CAL_X_NUM + 1) / 2;
- index++) {
- for (slice = 0; slice < 4; slice++)
- reg_ddrphy_write_a(adr_st + 0x80 * slice +
- index, tmp);
- }
-#else
for (index = 0; index < _reg_PHY_RX_CAL_X_NUM; index++) {
ddr_setval_ach_as(_reg_PHY_RX_CAL_X[index], tmp);
}
-#endif
dsb_sev();
ddr_getval_ach_as(_reg_PHY_RX_CAL_OBS, (uint32_t *) tmp_ach_as);
@@ -3943,9 +4028,6 @@
}
}
ddr_setval_ach_as(_reg_PHY_RX_CAL_OVERRIDE, 0x00);
- ddr_setval_ach_as(_reg_PHY_IE_MODE,
- ddrtbl_getval(_cnf_DDR_PHY_SLICE_REGSET,
- _reg_PHY_IE_MODE));
return 0;
}
@@ -3958,7 +4040,6 @@
uint32_t tmp;
uint32_t tmp_ach_as[DRAM_CH_CNT][SLICE_CNT];
- ddr_setval_ach_as(_reg_PHY_IE_MODE, 0x01);
ddr_setval_ach_as(_reg_PHY_RX_CAL_X[9], 0x00);
ddr_setval_ach_as(_reg_PHY_RX_CAL_OVERRIDE, 0x00);
ddr_setval_ach_as(_reg_PHY_RX_CAL_SAMPLE_WAIT, 0x0f);
@@ -3995,9 +4076,6 @@
retry++;
}
- ddr_setval_ach_as(_reg_PHY_IE_MODE,
- ddrtbl_getval(_cnf_DDR_PHY_SLICE_REGSET,
- _reg_PHY_IE_MODE));
return (complete == 0);
}
@@ -4093,17 +4171,16 @@
/***********************************************************************
Thermal sensor setting
***********************************************************************/
- dataL = *((volatile uint32_t *)CPG_MSTPSR5);
+ dataL = mmio_read_32(CPG_MSTPSR5);
if (dataL & BIT22) { /* case THS/TSC Standby */
dataL &= ~(BIT22);
- *((volatile uint32_t *)CPG_CPGWPR) = ~dataL;
- *((volatile uint32_t *)CPG_SMSTPCR5) = dataL;
- while ((BIT22) & *((volatile uint32_t *)CPG_MSTPSR5)) ; /* wait bit=0 */
+ cpg_write_32(CPG_SMSTPCR5, dataL);
+ while ((BIT22) & mmio_read_32(CPG_MSTPSR5)); /* wait bit=0 */
}
/* THCTR Bit6: PONM=0 , Bit0: THSST=0 */
- dataL = (*((volatile uint32_t *)THS1_THCTR)) & 0xFFFFFFBE;
- *((volatile uint32_t *)THS1_THCTR) = dataL;
+ dataL = mmio_read_32(THS1_THCTR) & 0xFFFFFFBE;
+ mmio_write_32(THS1_THCTR, dataL);
/***********************************************************************
Judge product and cut
@@ -4134,7 +4211,7 @@
|| (Prr_Product == PRR_PRODUCT_V3H)) {
pDDR_REGDEF_TBL = (uint32_t *) & DDR_REGDEF_TBL[3][0];
} else {
- FATAL_MSG("DDR:Unknown Product");
+ FATAL_MSG("BL2: DDR:Unknown Product\n");
return 0xff;
}
@@ -4150,7 +4227,7 @@
***********************************************************************/
_cnf_BOARDTYPE = boardcnf_get_brd_type();
if (_cnf_BOARDTYPE >= BOARDNUM) {
- FATAL_MSG("DDR:Unknown Board");
+ FATAL_MSG("BL2: DDR:Unknown Board\n");
return 0xff;
}
Boardcnf = (struct _boardcnf *)&boardcnfs[_cnf_BOARDTYPE];
@@ -4252,7 +4329,7 @@
else
ddr_tccd = tmp_tccd;
- NOTICE("BL2: DDR%d(%s)", ddr_mbps / ddr_mbpsdiv, RCAR_DDR_VERSION);
+ NOTICE("BL2: DDR%d(%s)\n", ddr_mbps / ddr_mbpsdiv, RCAR_DDR_VERSION);
MSG_LF("Start\n");
@@ -4271,8 +4348,6 @@
failcount = 1;
}
- NOTICE("..%d\n", failcount);
-
foreach_vch(ch)
mmio_write_32(DBSC_DBPDLK(ch), 0x00000000);
if (((Prr_Product == PRR_PRODUCT_H3) && (Prr_Cut <= PRR_PRODUCT_11))
@@ -4292,6 +4367,7 @@
void pvtcode_update(void)
{
uint32_t ch;
+ uint32_t dataL;
uint32_t pvtp[4], pvtn[4], pvtp_init, pvtn_init;
int32_t pvtp_tmp, pvtn_tmp;
@@ -4319,58 +4395,39 @@
}
if ((Prr_Product == PRR_PRODUCT_H3)
&& (Prr_Cut <= PRR_PRODUCT_11)) {
+ dataL = pvtp[ch] | (pvtn[ch] << 6) | (tcal.tcomp_cal[ch] & 0xfffff000);
reg_ddrphy_write(ch,
ddr_regdef_adr(_reg_PHY_PAD_FDBK_TERM),
- pvtp[ch] | (pvtn[ch] << 6) | (tcal.
- tcomp_cal
- [ch] &
- 0xfffff000));
+ dataL | 0x00020000);
reg_ddrphy_write(ch,
ddr_regdef_adr(_reg_PHY_PAD_DATA_TERM),
- pvtp[ch] | (pvtn[ch] << 6) | (tcal.
- tcomp_cal
- [ch] &
- 0xfffff000));
+ dataL);
reg_ddrphy_write(ch,
ddr_regdef_adr(_reg_PHY_PAD_DQS_TERM),
- pvtp[ch] | (pvtn[ch] << 6) | (tcal.
- tcomp_cal
- [ch] &
- 0xfffff000));
+ dataL);
reg_ddrphy_write(ch,
ddr_regdef_adr(_reg_PHY_PAD_ADDR_TERM),
- pvtp[ch] | (pvtn[ch] << 6) | (tcal.
- tcomp_cal
- [ch] &
- 0xfffff000));
+ dataL);
reg_ddrphy_write(ch,
ddr_regdef_adr(_reg_PHY_PAD_CS_TERM),
- pvtp[ch] | (pvtn[ch] << 6) | (tcal.
- tcomp_cal
- [ch] &
- 0xfffff000));
+ dataL);
} else {
+ dataL = pvtp[ch] | (pvtn[ch] << 6) | 0x00015000;
reg_ddrphy_write(ch,
ddr_regdef_adr(_reg_PHY_PAD_FDBK_TERM),
- pvtp[ch] | (pvtn[ch] << 6) |
- 0x00035000);
+ dataL | 0x00020000);
reg_ddrphy_write(ch,
ddr_regdef_adr(_reg_PHY_PAD_DATA_TERM),
- pvtp[ch] | (pvtn[ch] << 6) |
- 0x00015000);
+ dataL);
reg_ddrphy_write(ch,
ddr_regdef_adr(_reg_PHY_PAD_DQS_TERM),
- pvtp[ch] | (pvtn[ch] << 6) |
- 0x00015000);
-
+ dataL);
reg_ddrphy_write(ch,
ddr_regdef_adr(_reg_PHY_PAD_ADDR_TERM),
- pvtp[ch] | (pvtn[ch] << 6) |
- 0x00015000);
+ dataL);
reg_ddrphy_write(ch,
ddr_regdef_adr(_reg_PHY_PAD_CS_TERM),
- pvtp[ch] | (pvtn[ch] << 6) |
- 0x00015000);
+ dataL);
}
}
}
@@ -4410,7 +4467,7 @@
}
if (!override) {
- dataL = *((volatile uint32_t *)THS1_TEMP);
+ dataL = mmio_read_32(THS1_TEMP);
if (dataL < 2800) {
tcal.init_temp =
(143 * (int32_t) dataL - 359000) / 1000;
@@ -4457,7 +4514,6 @@
/* for QoS init */
uint8_t get_boardcnf_phyvalid(void)
{
-/* return Boardcnf->phyvalid; */
return ddr_phyvalid;
}
#endif /* ddr_qos_init_setting */
diff --git a/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram_config.c b/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram_config.c
index 3d94da5..8040d93 100644
--- a/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram_config.c
+++ b/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram_config.c
@@ -4,24 +4,33 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#define BOARDNUM 16
+#define BOARDNUM 18
#define BOARD_JUDGE_AUTO
+#ifdef BOARD_JUDGE_AUTO
static uint32_t _board_judge(void);
static uint32_t boardcnf_get_brd_type(void)
{
return _board_judge();
}
+#else
+static uint32_t boardcnf_get_brd_type(void)
+{
+ return (1);
+}
+#endif
+
+#define DDR_FAST_INIT
struct _boardcnf_ch {
uint8_t ddr_density[CS_CNT];
- uint32_t ca_swap;
+ uint64_t ca_swap;
uint16_t dqs_swap;
uint32_t dq_swap[SLICE_CNT];
uint8_t dm_swap[SLICE_CNT];
uint16_t wdqlvl_patt[16];
- int8_t cacs_adj[10];
+ int8_t cacs_adj[16];
int8_t dm_adj_w[SLICE_CNT];
int8_t dq_adj_w[SLICE_CNT * 8];
int8_t dm_adj_r[SLICE_CNT];
@@ -876,7 +885,11 @@
0x0a0,
{
{
+#if (RCAR_DRAM_LPDDR4_MEMCONF == 2)
+ {0x04, 0x04},
+#else
{0x02, 0x02},
+#endif
0x00342501,
0x3201,
{0x10672534, 0x43257106, 0x34527601, 0x71605243},
@@ -1227,7 +1240,89 @@
0, 0, 0, 0, 0, 0, 0, 0}
}
}
+ },
+/* boardcnf[16] RENESAS KRIEK-P2P board with M3-W/SoC */
+ {
+ 0x03,
+ 0x01,
+ 0x0320,
+ 0,
+ 0x0300,
+ 0x00a0,
+ {
+ {
+ {0x04, 0x04},
+ 0x520314FFFF523041,
+ 0x3201,
+ {0x01672543, 0x45361207, 0x45632107, 0x60715234},
+ {0x08, 0x08, 0x08, 0x08},
+ WDQLVL_PAT,
+ {0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0}
+ },
+ {
+ {0x04, 0x04},
+ 0x314250FFFF312405,
+ 0x2310,
+ {0x01672543, 0x45361207, 0x45632107, 0x60715234},
+ {0x08, 0x08, 0x08, 0x08},
+ WDQLVL_PAT,
+ {0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0}
+ }
+ }
+ },
+/* boardcnf[17] RENESAS KRIEK-P2P board with M3-N/SoC */
+ {
+ 0x01,
+ 0x01,
+ 0x0300,
+ 0,
+ 0x0300,
+ 0x00a0,
+ {
+ {
+ {0x04, 0x04},
+ 0x520314FFFF523041,
+ 0x3201,
+ {0x01672543, 0x45361207, 0x45632107, 0x60715234},
+ {0x08, 0x08, 0x08, 0x08},
+ WDQLVL_PAT,
+ {0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0},
+ {0, 0, 0, 0},
+ {0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0}
+ }
}
+ }
};
void boardcnf_get_brd_clk(uint32_t brd, uint32_t * clk, uint32_t * div)
@@ -1258,6 +1353,7 @@
break;
}
}
+ (void)brd;
}
void boardcnf_get_ddr_mbps(uint32_t brd, uint32_t * mbps, uint32_t * div)
@@ -1284,6 +1380,7 @@
*div = 1;
break;
}
+ (void)brd;
}
#define _def_REFPERIOD 1890
@@ -1393,10 +1490,10 @@
if (down == up) {
/* Same = Connect */
return 0;
+ } else {
+ /* Diff = Open */
+ return 1;
}
-
- /* Diff = Open */
- return 1;
}
#endif
@@ -1431,6 +1528,7 @@
usb2_ovc_open = opencheck_SSI_WS6();
/* RENESAS Eva-borad */
+ brd = 99;
if (Prr_Product == PRR_PRODUCT_V3H) {
/* RENESAS Condor board */
brd = 12;
@@ -1441,10 +1539,12 @@
} else if (Prr_Product == PRR_PRODUCT_M3) {
/* RENESAS Kriek board with M3-W */
brd = 1;
- } else if (Prr_Cut <= PRR_PRODUCT_11) {
+ } else if ((Prr_Product == PRR_PRODUCT_H3)
+ && (Prr_Cut<=PRR_PRODUCT_11)) {
/* RENESAS Kriek board with PM3 */
brd = 13;
- } else {
+ } else if ((Prr_Product == PRR_PRODUCT_H3)
+ && (Prr_Cut > PRR_PRODUCT_20)) {
/* RENESAS Kriek board with H3N */
brd = 15;
}
@@ -1467,12 +1567,13 @@
} else if (Prr_Product == PRR_PRODUCT_M3N) {
/* RENESAS SALVATOR-X (M3-N/SIP) */
brd = 11;
- } else {
+ } else if (Prr_Product == PRR_PRODUCT_M3) {
/* RENESAS SALVATOR-X (M3-W/SIP) */
brd = 0;
}
}
#endif
+
return brd;
}
#endif
diff --git a/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram_regdef.h b/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram_regdef.h
index 91562b0..d72959b 100644
--- a/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram_regdef.h
+++ b/drivers/staging/renesas/rcar/ddr/ddr_b/boot_init_dram_regdef.h
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#define RCAR_DDR_VERSION "rev.0.33"
+#define RCAR_DDR_VERSION "rev.0.34"
#define DRAM_CH_CNT (0x04)
#define SLICE_CNT (0x04)
#define CS_CNT (0x02)
diff --git a/drivers/staging/renesas/rcar/ddr/ddr_b/init_dram_tbl_m3n.h b/drivers/staging/renesas/rcar/ddr/ddr_b/init_dram_tbl_m3n.h
index f8ff0fd..a9569ee 100644
--- a/drivers/staging/renesas/rcar/ddr/ddr_b/init_dram_tbl_m3n.h
+++ b/drivers/staging/renesas/rcar/ddr/ddr_b/init_dram_tbl_m3n.h
@@ -267,7 +267,7 @@
/*0bb9*/ 0x00000000,
/*0bba*/ 0x00000000,
/*0bbb*/ 0x00000000,
-/*0bbc*/ 0x00000065,
+/*0bbc*/ 0x00000265,
/*0bbd*/ 0x00000000,
/*0bbe*/ 0x00040401,
/*0bbf*/ 0x00000000,
diff --git a/drivers/staging/renesas/rcar/ddr/dram_sub_func.c b/drivers/staging/renesas/rcar/ddr/dram_sub_func.c
index 4bf6942..6739b0d 100644
--- a/drivers/staging/renesas/rcar/ddr/dram_sub_func.c
+++ b/drivers/staging/renesas/rcar/ddr/dram_sub_func.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
-#include <debug.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "dram_sub_func.h"
#define PRR (0xFFF00044U)
@@ -18,10 +19,11 @@
#define PRR_PRODUCT_V3H (0x00005600U) /* R-Car V3H */
#if RCAR_SYSTEM_SUSPEND
-#include "iic_dvfs.h"
-
+/* Local defines */
#define DRAM_BACKUP_GPIO_USE (0)
+#include "iic_dvfs.h"
#if PMIC_ROHM_BD9571
+#define PMIC_SLAVE_ADDR (0x30U)
#define PMIC_BKUP_MODE_CNT (0x20U)
#define PMIC_QLLM_CNT (0x27U)
#define BIT_BKUP_CTRL_OUT ((uint8_t)(1U << 4U))
@@ -51,40 +53,53 @@
void rcar_dram_get_boot_status(uint32_t * status)
{
#if RCAR_SYSTEM_SUSPEND
- uint32_t shift = GPIO_BKUP_TRG_SHIFT_SALVATOR;
- uint32_t gpio = GPIO_INDT1;
- uint32_t reg, product;
+
+ uint32_t reg_data;
+ uint32_t product;
+ uint32_t shift;
+ uint32_t gpio;
product = mmio_read_32(PRR) & PRR_PRODUCT_MASK;
-
if (product == PRR_PRODUCT_V3H) {
shift = GPIO_BKUP_TRG_SHIFT_CONDOR;
gpio = GPIO_INDT3;
} else if (product == PRR_PRODUCT_E3) {
shift = GPIO_BKUP_TRG_SHIFT_EBISU;
gpio = GPIO_INDT6;
+ } else {
+ shift = GPIO_BKUP_TRG_SHIFT_SALVATOR;
+ gpio = GPIO_INDT1;
}
- reg = mmio_read_32(gpio) & (1U << shift);
- *status = reg ? DRAM_BOOT_STATUS_WARM : DRAM_BOOT_STATUS_COLD;
-#else
+ reg_data = mmio_read_32(gpio);
+ if (0U != (reg_data & ((uint32_t)1U << shift))) {
+ *status = DRAM_BOOT_STATUS_WARM;
+ } else {
+ *status = DRAM_BOOT_STATUS_COLD;
+ }
+#else /* RCAR_SYSTEM_SUSPEND */
*status = DRAM_BOOT_STATUS_COLD;
-#endif
+#endif /* RCAR_SYSTEM_SUSPEND */
}
int32_t rcar_dram_update_boot_status(uint32_t status)
{
int32_t ret = 0;
#if RCAR_SYSTEM_SUSPEND
+ uint32_t reg_data;
#if PMIC_ROHM_BD9571
#if DRAM_BACKUP_GPIO_USE == 0
- uint8_t mode = 0U;
+ uint8_t bkup_mode_cnt = 0U;
#else
uint32_t reqb, outd;
#endif
- uint8_t qllm = 0;
+ uint8_t qllm_cnt = 0U;
+ int32_t i2c_dvfs_ret = -1;
#endif
- uint32_t i, product, trg, gpio;
+ uint32_t loop_count;
+ uint32_t product;
+ uint32_t trg;
+ uint32_t gpio;
product = mmio_read_32(PRR) & PRR_PRODUCT_MASK;
if (product == PRR_PRODUCT_V3H) {
@@ -110,50 +125,58 @@
gpio = GPIO_INDT1;
}
- if (status != DRAM_BOOT_STATUS_WARM)
- goto cold;
-
+ if (status == DRAM_BOOT_STATUS_WARM) {
#if DRAM_BACKUP_GPIO_USE==1
mmio_setbits_32(outd, 1U << reqb);
#else
-
#if PMIC_ROHM_BD9571
- if (rcar_iic_dvfs_receive(PMIC, PMIC_BKUP_MODE_CNT, &mode)) {
- ERROR("BKUP mode cnt READ ERROR.\n");
- return DRAM_UPDATE_STATUS_ERR;
+ /* Set BKUP_CRTL_OUT=High (BKUP mode cnt register) */
+ i2c_dvfs_ret = rcar_iic_dvfs_receive(PMIC_SLAVE_ADDR,
+ PMIC_BKUP_MODE_CNT, &bkup_mode_cnt);
+ if (0 != i2c_dvfs_ret) {
+ ERROR("BKUP mode cnt READ ERROR.\n");
+ ret = DRAM_UPDATE_STATUS_ERR;
+ } else {
+ bkup_mode_cnt &= (uint8_t)~BIT_BKUP_CTRL_OUT;
+ i2c_dvfs_ret = rcar_iic_dvfs_send(PMIC_SLAVE_ADDR,
+ PMIC_BKUP_MODE_CNT, bkup_mode_cnt);
+ if (0 != i2c_dvfs_ret) {
+ ERROR("BKUP mode cnt WRITE ERROR. "
+ "value = %d\n", bkup_mode_cnt);
+ ret = DRAM_UPDATE_STATUS_ERR;
+ }
+ }
+#endif /* PMIC_ROHM_BD9571 */
+#endif /* DRAM_BACKUP_GPIO_USE==1 */
+ /* Wait BKUP_TRG=Low */
+ loop_count = DRAM_BKUP_TRG_LOOP_CNT;
+ while (0U < loop_count) {
+ reg_data = mmio_read_32(gpio);
+ if ((reg_data &
+ ((uint32_t)1U << trg)) == 0U) {
+ break;
+ }
+ loop_count--;
+ }
+ if (0U == loop_count) {
+ ERROR( "\nWarm booting...\n" \
+ " The potential of BKUP_TRG did not switch " \
+ "to Low.\n If you expect the operation of " \
+ "cold boot,\n check the board configuration" \
+ " (ex, Dip-SW) and/or the H/W failure.\n");
+ ret = DRAM_UPDATE_STATUS_ERR;
+ }
}
-
- mode &= ~BIT_BKUP_CTRL_OUT;
- if (rcar_iic_dvfs_send(PMIC, PMIC_BKUP_MODE_CNT, mode)) {
- ERROR("BKUP mode cnt WRITE ERROR. value = %d\n", mode);
- return DRAM_UPDATE_STATUS_ERR;
- }
-#endif
-#endif
- for (i = 0; i < DRAM_BKUP_TRG_LOOP_CNT; i++) {
- if (mmio_read_32(gpio) & (1U << trg))
- continue;
-
- goto cold;
- }
-
- ERROR("\nWarm booting Error...\n"
- " The potential of BKUP_TRG did not switch "
- "to Low.\n If you expect the operation of "
- "cold boot,\n check the board configuration"
- " (ex, Dip-SW) and/or the H/W failure.\n");
-
- return DRAM_UPDATE_STATUS_ERR;
-
-cold:
#if PMIC_ROHM_BD9571
- if (ret)
- return ret;
-
- qllm = (BIT_QLLM_DDR0_EN | BIT_QLLM_DDR1_EN);
- if (rcar_iic_dvfs_send(PMIC, PMIC_QLLM_CNT, qllm)) {
- ERROR("QLLM cnt WRITE ERROR. value = %d\n", qllm);
- ret = DRAM_UPDATE_STATUS_ERR;
+ if(0 == ret) {
+ qllm_cnt = (BIT_QLLM_DDR0_EN | BIT_QLLM_DDR1_EN);
+ i2c_dvfs_ret = rcar_iic_dvfs_send(PMIC_SLAVE_ADDR,
+ PMIC_QLLM_CNT, qllm_cnt);
+ if (0 != i2c_dvfs_ret) {
+ ERROR("QLLM cnt WRITE ERROR. "
+ "value = %d\n", qllm_cnt);
+ ret = DRAM_UPDATE_STATUS_ERR;
+ }
}
#endif
#endif
diff --git a/drivers/staging/renesas/rcar/pfc/E3/pfc_init_e3.c b/drivers/staging/renesas/rcar/pfc/E3/pfc_init_e3.c
index d75aa7c..1fc13de 100644
--- a/drivers/staging/renesas/rcar/pfc/E3/pfc_init_e3.c
+++ b/drivers/staging/renesas/rcar/pfc/E3/pfc_init_e3.c
@@ -5,7 +5,9 @@
*/
#include <stdint.h> /* for uint32_t */
-#include <mmio.h>
+
+#include <lib/mmio.h>
+
#include "pfc_init_e3.h"
#include "rcar_def.h"
@@ -488,7 +490,8 @@
| MOD_SEL0_REMOCON_A
| MOD_SEL0_SCIF_A
| MOD_SEL0_SCIF0_A
- | MOD_SEL0_SCIF2_A | MOD_SEL0_SPEED_PULSE_IF_A);
+ | MOD_SEL0_SCIF2_A
+ | MOD_SEL0_SPEED_PULSE_IF_A);
pfc_reg_write(PFC_MOD_SEL1, MOD_SEL1_SIMCARD_A
| MOD_SEL1_SSI2_A
| MOD_SEL1_TIMER_TMU_A
@@ -505,135 +508,137 @@
| MOD_SEL1_SCIF4_A
| MOD_SEL1_SCIF5_A
| MOD_SEL1_VIN4_A
- | MOD_SEL1_VIN5_A | MOD_SEL1_ADGC_A | MOD_SEL1_SSI9_A);
+ | MOD_SEL1_VIN5_A
+ | MOD_SEL1_ADGC_A
+ | MOD_SEL1_SSI9_A);
/* initialize peripheral function select */
pfc_reg_write(PFC_IPSR0, IPSR_28_FUNC(0) /* QSPI1_MISO/IO1 */
- |IPSR_24_FUNC(0) /* QSPI1_MOSI/IO0 */
- |IPSR_20_FUNC(0) /* QSPI1_SPCLK */
- |IPSR_16_FUNC(0) /* QSPI0_IO3 */
- |IPSR_12_FUNC(0) /* QSPI0_IO2 */
- |IPSR_8_FUNC(0) /* QSPI0_MISO/IO1 */
- |IPSR_4_FUNC(0) /* QSPI0_MOSI/IO0 */
- |IPSR_0_FUNC(0)); /* QSPI0_SPCLK */
+ | IPSR_24_FUNC(0) /* QSPI1_MOSI/IO0 */
+ | IPSR_20_FUNC(0) /* QSPI1_SPCLK */
+ | IPSR_16_FUNC(0) /* QSPI0_IO3 */
+ | IPSR_12_FUNC(0) /* QSPI0_IO2 */
+ | IPSR_8_FUNC(0) /* QSPI0_MISO/IO1 */
+ | IPSR_4_FUNC(0) /* QSPI0_MOSI/IO0 */
+ | IPSR_0_FUNC(0)); /* QSPI0_SPCLK */
pfc_reg_write(PFC_IPSR1, IPSR_28_FUNC(0) /* AVB_RD2 */
- |IPSR_24_FUNC(0) /* AVB_RD1 */
- |IPSR_20_FUNC(0) /* AVB_RD0 */
- |IPSR_16_FUNC(0) /* RPC_RESET# */
- |IPSR_12_FUNC(0) /* RPC_INT# */
- |IPSR_8_FUNC(0) /* QSPI1_SSL */
- |IPSR_4_FUNC(0) /* QSPI1_IO3 */
- |IPSR_0_FUNC(0)); /* QSPI1_IO2 */
+ | IPSR_24_FUNC(0) /* AVB_RD1 */
+ | IPSR_20_FUNC(0) /* AVB_RD0 */
+ | IPSR_16_FUNC(0) /* RPC_RESET# */
+ | IPSR_12_FUNC(0) /* RPC_INT# */
+ | IPSR_8_FUNC(0) /* QSPI1_SSL */
+ | IPSR_4_FUNC(0) /* QSPI1_IO3 */
+ | IPSR_0_FUNC(0)); /* QSPI1_IO2 */
pfc_reg_write(PFC_IPSR2, IPSR_28_FUNC(1) /* IRQ0 */
- |IPSR_24_FUNC(0)
+ | IPSR_24_FUNC(0)
| IPSR_20_FUNC(0)
| IPSR_16_FUNC(2) /* AVB_LINK */
- |IPSR_12_FUNC(0)
+ | IPSR_12_FUNC(0)
| IPSR_8_FUNC(0) /* AVB_MDC */
- |IPSR_4_FUNC(0) /* AVB_MDIO */
- |IPSR_0_FUNC(0)); /* AVB_TXCREFCLK */
+ | IPSR_4_FUNC(0) /* AVB_MDIO */
+ | IPSR_0_FUNC(0)); /* AVB_TXCREFCLK */
pfc_reg_write(PFC_IPSR3, IPSR_28_FUNC(5) /* DU_HSYNC */
- |IPSR_24_FUNC(0)
+ | IPSR_24_FUNC(0)
| IPSR_20_FUNC(0)
| IPSR_16_FUNC(0)
| IPSR_12_FUNC(5) /* DU_DG4 */
- |IPSR_8_FUNC(5) /* DU_DOTCLKOUT0 */
- |IPSR_4_FUNC(5) /* DU_DISP */
- |IPSR_0_FUNC(1)); /* IRQ1 */
+ | IPSR_8_FUNC(5) /* DU_DOTCLKOUT0 */
+ | IPSR_4_FUNC(5) /* DU_DISP */
+ | IPSR_0_FUNC(1)); /* IRQ1 */
pfc_reg_write(PFC_IPSR4, IPSR_28_FUNC(5) /* DU_DB5 */
- |IPSR_24_FUNC(5) /* DU_DB4 */
- |IPSR_20_FUNC(5) /* DU_DB3 */
- |IPSR_16_FUNC(5) /* DU_DB2 */
- |IPSR_12_FUNC(5) /* DU_DG6 */
- |IPSR_8_FUNC(5) /* DU_VSYNC */
- |IPSR_4_FUNC(5) /* DU_DG5 */
- |IPSR_0_FUNC(5)); /* DU_DG7 */
+ | IPSR_24_FUNC(5) /* DU_DB4 */
+ | IPSR_20_FUNC(5) /* DU_DB3 */
+ | IPSR_16_FUNC(5) /* DU_DB2 */
+ | IPSR_12_FUNC(5) /* DU_DG6 */
+ | IPSR_8_FUNC(5) /* DU_VSYNC */
+ | IPSR_4_FUNC(5) /* DU_DG5 */
+ | IPSR_0_FUNC(5)); /* DU_DG7 */
pfc_reg_write(PFC_IPSR5, IPSR_28_FUNC(5) /* DU_DR3 */
- |IPSR_24_FUNC(5) /* DU_DB7 */
- |IPSR_20_FUNC(5) /* DU_DR2 */
- |IPSR_16_FUNC(5) /* DU_DR1 */
- |IPSR_12_FUNC(5) /* DU_DR0 */
- |IPSR_8_FUNC(5) /* DU_DB1 */
- |IPSR_4_FUNC(5) /* DU_DB0 */
- |IPSR_0_FUNC(5)); /* DU_DB6 */
+ | IPSR_24_FUNC(5) /* DU_DB7 */
+ | IPSR_20_FUNC(5) /* DU_DR2 */
+ | IPSR_16_FUNC(5) /* DU_DR1 */
+ | IPSR_12_FUNC(5) /* DU_DR0 */
+ | IPSR_8_FUNC(5) /* DU_DB1 */
+ | IPSR_4_FUNC(5) /* DU_DB0 */
+ | IPSR_0_FUNC(5)); /* DU_DB6 */
pfc_reg_write(PFC_IPSR6, IPSR_28_FUNC(5) /* DU_DG1 */
- |IPSR_24_FUNC(5) /* DU_DG0 */
- |IPSR_20_FUNC(5) /* DU_DR7 */
- |IPSR_16_FUNC(2) /* IRQ5 */
- |IPSR_12_FUNC(5) /* DU_DR6 */
- |IPSR_8_FUNC(5) /* DU_DR5 */
- |IPSR_4_FUNC(0)
+ | IPSR_24_FUNC(5) /* DU_DG0 */
+ | IPSR_20_FUNC(5) /* DU_DR7 */
+ | IPSR_16_FUNC(2) /* IRQ5 */
+ | IPSR_12_FUNC(5) /* DU_DR6 */
+ | IPSR_8_FUNC(5) /* DU_DR5 */
+ | IPSR_4_FUNC(0)
| IPSR_0_FUNC(5)); /* DU_DR4 */
pfc_reg_write(PFC_IPSR7, IPSR_28_FUNC(0) /* SD0_CLK */
- |IPSR_24_FUNC(0)
+ | IPSR_24_FUNC(0)
| IPSR_20_FUNC(5) /* DU_DOTCLKIN0 */
- |IPSR_16_FUNC(5) /* DU_DG3 */
- |IPSR_12_FUNC(0)
+ | IPSR_16_FUNC(5) /* DU_DG3 */
+ | IPSR_12_FUNC(0)
| IPSR_8_FUNC(0)
| IPSR_4_FUNC(0)
| IPSR_0_FUNC(5)); /* DU_DG2 */
pfc_reg_write(PFC_IPSR8, IPSR_28_FUNC(0) /* SD1_DAT0 */
- |IPSR_24_FUNC(0) /* SD1_CMD */
- |IPSR_20_FUNC(0) /* SD1_CLK */
- |IPSR_16_FUNC(0) /* SD0_DAT3 */
- |IPSR_12_FUNC(0) /* SD0_DAT2 */
- |IPSR_8_FUNC(0) /* SD0_DAT1 */
- |IPSR_4_FUNC(0) /* SD0_DAT0 */
- |IPSR_0_FUNC(0)); /* SD0_CMD */
+ | IPSR_24_FUNC(0) /* SD1_CMD */
+ | IPSR_20_FUNC(0) /* SD1_CLK */
+ | IPSR_16_FUNC(0) /* SD0_DAT3 */
+ | IPSR_12_FUNC(0) /* SD0_DAT2 */
+ | IPSR_8_FUNC(0) /* SD0_DAT1 */
+ | IPSR_4_FUNC(0) /* SD0_DAT0 */
+ | IPSR_0_FUNC(0)); /* SD0_CMD */
pfc_reg_write(PFC_IPSR9, IPSR_28_FUNC(0) /* SD3_DAT2 */
- |IPSR_24_FUNC(0) /* SD3_DAT1 */
- |IPSR_20_FUNC(0) /* SD3_DAT0 */
- |IPSR_16_FUNC(0) /* SD3_CMD */
- |IPSR_12_FUNC(0) /* SD3_CLK */
- |IPSR_8_FUNC(0) /* SD1_DAT3 */
- |IPSR_4_FUNC(0) /* SD1_DAT2 */
- |IPSR_0_FUNC(0)); /* SD1_DAT1 */
+ | IPSR_24_FUNC(0) /* SD3_DAT1 */
+ | IPSR_20_FUNC(0) /* SD3_DAT0 */
+ | IPSR_16_FUNC(0) /* SD3_CMD */
+ | IPSR_12_FUNC(0) /* SD3_CLK */
+ | IPSR_8_FUNC(0) /* SD1_DAT3 */
+ | IPSR_4_FUNC(0) /* SD1_DAT2 */
+ | IPSR_0_FUNC(0)); /* SD1_DAT1 */
pfc_reg_write(PFC_IPSR10, IPSR_28_FUNC(0) /* SD0_WP */
- |IPSR_24_FUNC(0) /* SD0_CD */
- |IPSR_20_FUNC(0) /* SD3_DS */
- |IPSR_16_FUNC(0) /* SD3_DAT7 */
- |IPSR_12_FUNC(0) /* SD3_DAT6 */
- |IPSR_8_FUNC(0) /* SD3_DAT5 */
- |IPSR_4_FUNC(0) /* SD3_DAT4 */
- |IPSR_0_FUNC(0)); /* SD3_DAT3 */
+ | IPSR_24_FUNC(0) /* SD0_CD */
+ | IPSR_20_FUNC(0) /* SD3_DS */
+ | IPSR_16_FUNC(0) /* SD3_DAT7 */
+ | IPSR_12_FUNC(0) /* SD3_DAT6 */
+ | IPSR_8_FUNC(0) /* SD3_DAT5 */
+ | IPSR_4_FUNC(0) /* SD3_DAT4 */
+ | IPSR_0_FUNC(0)); /* SD3_DAT3 */
pfc_reg_write(PFC_IPSR11, IPSR_28_FUNC(0)
| IPSR_24_FUNC(0)
| IPSR_20_FUNC(2) /* AUDIO_CLKOUT1_A */
- |IPSR_16_FUNC(2) /* AUDIO_CLKOUT_A */
- |IPSR_12_FUNC(0)
+ | IPSR_16_FUNC(2) /* AUDIO_CLKOUT_A */
+ | IPSR_12_FUNC(0)
| IPSR_8_FUNC(0)
| IPSR_4_FUNC(0) /* SD1_WP */
- |IPSR_0_FUNC(0)); /* SD1_CD */
+ | IPSR_0_FUNC(0)); /* SD1_CD */
pfc_reg_write(PFC_IPSR12, IPSR_28_FUNC(0)
| IPSR_24_FUNC(0)
| IPSR_20_FUNC(0)
| IPSR_16_FUNC(0)
| IPSR_12_FUNC(0) /* RX2_A */
- |IPSR_8_FUNC(0) /* TX2_A */
- |IPSR_4_FUNC(2) /* AUDIO_CLKB_A */
- |IPSR_0_FUNC(0));
+ | IPSR_8_FUNC(0) /* TX2_A */
+ | IPSR_4_FUNC(2) /* AUDIO_CLKB_A */
+ | IPSR_0_FUNC(0));
pfc_reg_write(PFC_IPSR13, IPSR_28_FUNC(0)
| IPSR_24_FUNC(0)
| IPSR_20_FUNC(0)
| IPSR_16_FUNC(0)
| IPSR_12_FUNC(0)
| IPSR_8_FUNC(2) /* AUDIO_CLKC_A */
- |IPSR_4_FUNC(1) /* HTX2_A */
- |IPSR_0_FUNC(1)); /* HRX2_A */
+ | IPSR_4_FUNC(1) /* HTX2_A */
+ | IPSR_0_FUNC(1)); /* HRX2_A */
pfc_reg_write(PFC_IPSR14, IPSR_28_FUNC(3) /* USB0_PWEN_B */
- |IPSR_24_FUNC(0) /* SSI_SDATA4 */
- |IPSR_20_FUNC(0) /* SSI_SDATA3 */
- |IPSR_16_FUNC(0) /* SSI_WS349 */
- |IPSR_12_FUNC(0) /* SSI_SCK349 */
- |IPSR_8_FUNC(0)
+ | IPSR_24_FUNC(0) /* SSI_SDATA4 */
+ | IPSR_20_FUNC(0) /* SSI_SDATA3 */
+ | IPSR_16_FUNC(0) /* SSI_WS349 */
+ | IPSR_12_FUNC(0) /* SSI_SCK349 */
+ | IPSR_8_FUNC(0)
| IPSR_4_FUNC(0) /* SSI_SDATA1 */
- |IPSR_0_FUNC(0)); /* SSI_SDATA0 */
+ | IPSR_0_FUNC(0)); /* SSI_SDATA0 */
pfc_reg_write(PFC_IPSR15, IPSR_28_FUNC(0) /* USB30_OVC */
- |IPSR_24_FUNC(0) /* USB30_PWEN */
- |IPSR_20_FUNC(0) /* AUDIO_CLKA */
- |IPSR_16_FUNC(1) /* HRTS2#_A */
- |IPSR_12_FUNC(1) /* HCTS2#_A */
- |IPSR_8_FUNC(0)
+ | IPSR_24_FUNC(0) /* USB30_PWEN */
+ | IPSR_20_FUNC(0) /* AUDIO_CLKA */
+ | IPSR_16_FUNC(1) /* HRTS2#_A */
+ | IPSR_12_FUNC(1) /* HCTS2#_A */
+ | IPSR_8_FUNC(0)
| IPSR_4_FUNC(0)
| IPSR_0_FUNC(3)); /* USB0_OVC_B */
@@ -646,7 +651,11 @@
| GPSR0_D8
| GPSR0_D7
| GPSR0_D6
- | GPSR0_D5 | GPSR0_D3 | GPSR0_D2 | GPSR0_D1 | GPSR0_D0);
+ | GPSR0_D5
+ | GPSR0_D3
+ | GPSR0_D2
+ | GPSR0_D1
+ | GPSR0_D0);
pfc_reg_write(PFC_GPSR1, GPSR1_WE0
| GPSR1_CS0
| GPSR1_A19
@@ -661,7 +670,11 @@
| GPSR1_A10
| GPSR1_A9
| GPSR1_A8
- | GPSR1_A4 | GPSR1_A3 | GPSR1_A2 | GPSR1_A1 | GPSR1_A0);
+ | GPSR1_A4
+ | GPSR1_A3
+ | GPSR1_A2
+ | GPSR1_A1
+ | GPSR1_A0);
pfc_reg_write(PFC_GPSR2, GPSR2_BIT27_REVERCED
| GPSR2_BIT26_REVERCED
| GPSR2_RD
@@ -685,7 +698,8 @@
| GPSR2_QSPI0_IO3
| GPSR2_QSPI0_IO2
| GPSR2_QSPI0_MISO_IO1
- | GPSR2_QSPI0_MOSI_IO0 | GPSR2_QSPI0_SPCLK);
+ | GPSR2_QSPI0_MOSI_IO0
+ | GPSR2_QSPI0_SPCLK);
pfc_reg_write(PFC_GPSR3, GPSR3_SD1_WP
| GPSR3_SD1_CD
| GPSR3_SD0_WP
@@ -699,7 +713,9 @@
| GPSR3_SD0_DAT3
| GPSR3_SD0_DAT2
| GPSR3_SD0_DAT1
- | GPSR3_SD0_DAT0 | GPSR3_SD0_CMD | GPSR3_SD0_CLK);
+ | GPSR3_SD0_DAT0
+ | GPSR3_SD0_CMD
+ | GPSR3_SD0_CLK);
pfc_reg_write(PFC_GPSR4, GPSR4_SD3_DS
| GPSR4_SD3_DAT7
| GPSR4_SD3_DAT6
@@ -708,13 +724,17 @@
| GPSR4_SD3_DAT3
| GPSR4_SD3_DAT2
| GPSR4_SD3_DAT1
- | GPSR4_SD3_DAT0 | GPSR4_SD3_CMD | GPSR4_SD3_CLK);
+ | GPSR4_SD3_DAT0
+ | GPSR4_SD3_CMD
+ | GPSR4_SD3_CLK);
pfc_reg_write(PFC_GPSR5, GPSR5_SSI_SDATA9
| GPSR5_MSIOF0_SS2
| GPSR5_MSIOF0_SS1
| GPSR5_RX2_A
| GPSR5_TX2_A
- | GPSR5_SCK2_A | GPSR5_RTS0_TANS_A | GPSR5_CTS0_A);
+ | GPSR5_SCK2_A
+ | GPSR5_RTS0_TANS_A
+ | GPSR5_CTS0_A);
pfc_reg_write(PFC_GPSR6, GPSR6_USB30_PWEN
| GPSR6_SSI_SDATA6
| GPSR6_SSI_WS6
@@ -728,7 +748,8 @@
| GPSR6_SSI_SCK349
| GPSR6_SSI_SDATA1
| GPSR6_SSI_SDATA0
- | GPSR6_SSI_WS01239 | GPSR6_SSI_SCK01239);
+ | GPSR6_SSI_WS01239
+ | GPSR6_SSI_SCK01239);
/* initialize POC control */
reg = mmio_read_32(PFC_IOCTRL30);
@@ -741,7 +762,9 @@
| POC_SD0_DAT3_33V
| POC_SD0_DAT2_33V
| POC_SD0_DAT1_33V
- | POC_SD0_DAT0_33V | POC_SD0_CMD_33V | POC_SD0_CLK_33V);
+ | POC_SD0_DAT0_33V
+ | POC_SD0_CMD_33V
+ | POC_SD0_CLK_33V);
pfc_reg_write(PFC_IOCTRL30, reg);
reg = mmio_read_32(PFC_IOCTRL32);
reg = (reg & IOCTRL32_MASK);
diff --git a/drivers/staging/renesas/rcar/pfc/H3/pfc_init_h3_v1.c b/drivers/staging/renesas/rcar/pfc/H3/pfc_init_h3_v1.c
index 1c38f06..2f62bb2 100644
--- a/drivers/staging/renesas/rcar/pfc/H3/pfc_init_h3_v1.c
+++ b/drivers/staging/renesas/rcar/pfc/H3/pfc_init_h3_v1.c
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <stdint.h> /* for uint32_t */
-#include <mmio.h>
+#include <stdint.h>
+#include <lib/mmio.h>
/* GPIO base address */
#define GPIO_BASE (0xE6050000U)
@@ -802,7 +802,9 @@
| MOD_SEL0_DRIF2_A
| MOD_SEL0_DRIF1_A
| MOD_SEL0_DRIF0_A
- | MOD_SEL0_CANFD0_A | MOD_SEL0_ADG_A | MOD_SEL0_5LINE_A);
+ | MOD_SEL0_CANFD0_A
+ | MOD_SEL0_ADG_A
+ | MOD_SEL0_5LINE_A);
pfc_reg_write(PFC_MOD_SEL1, MOD_SEL1_TSIF1_A
| MOD_SEL1_TSIF0_A
| MOD_SEL1_TIMER_TMU_A
@@ -822,9 +824,13 @@
| MOD_SEL1_PWM6_A
| MOD_SEL1_PWM5_A
| MOD_SEL1_PWM4_A
- | MOD_SEL1_PWM3_A | MOD_SEL1_PWM2_A | MOD_SEL1_PWM1_A);
+ | MOD_SEL1_PWM3_A
+ | MOD_SEL1_PWM2_A
+ | MOD_SEL1_PWM1_A);
pfc_reg_write(PFC_MOD_SEL2, MOD_SEL2_I2C_5_A
- | MOD_SEL2_I2C_3_A | MOD_SEL2_I2C_0_A | MOD_SEL2_VIN4_A);
+ | MOD_SEL2_I2C_3_A
+ | MOD_SEL2_I2C_0_A
+ | MOD_SEL2_VIN4_A);
/* initialize peripheral function select */
pfc_reg_write(PFC_IPSR0, IPSR_28_FUNC(0)
@@ -971,7 +977,10 @@
| GPSR0_D14
| GPSR0_D13
| GPSR0_D12
- | GPSR0_D11 | GPSR0_D10 | GPSR0_D9 | GPSR0_D8);
+ | GPSR0_D11
+ | GPSR0_D10
+ | GPSR0_D9
+ | GPSR0_D8);
pfc_reg_write(PFC_GPSR1, GPSR1_EX_WAIT0_A
| GPSR1_A19
| GPSR1_A18
@@ -984,7 +993,11 @@
| GPSR1_A7
| GPSR1_A6
| GPSR1_A5
- | GPSR1_A4 | GPSR1_A3 | GPSR1_A2 | GPSR1_A1 | GPSR1_A0);
+ | GPSR1_A4
+ | GPSR1_A3
+ | GPSR1_A2
+ | GPSR1_A1
+ | GPSR1_A0);
pfc_reg_write(PFC_GPSR2, GPSR2_AVB_AVTP_CAPTURE_A
| GPSR2_AVB_AVTP_MATCH_A
| GPSR2_AVB_LINK
@@ -994,7 +1007,10 @@
| GPSR2_PWM1_A
| GPSR2_IRQ5
| GPSR2_IRQ4
- | GPSR2_IRQ3 | GPSR2_IRQ2 | GPSR2_IRQ1 | GPSR2_IRQ0);
+ | GPSR2_IRQ3
+ | GPSR2_IRQ2
+ | GPSR2_IRQ1
+ | GPSR2_IRQ0);
pfc_reg_write(PFC_GPSR3, GPSR3_SD0_WP
| GPSR3_SD0_CD
| GPSR3_SD1_DAT3
@@ -1004,7 +1020,9 @@
| GPSR3_SD0_DAT3
| GPSR3_SD0_DAT2
| GPSR3_SD0_DAT1
- | GPSR3_SD0_DAT0 | GPSR3_SD0_CMD | GPSR3_SD0_CLK);
+ | GPSR3_SD0_DAT0
+ | GPSR3_SD0_CMD
+ | GPSR3_SD0_CLK);
pfc_reg_write(PFC_GPSR4, GPSR4_SD3_DAT7
| GPSR4_SD3_DAT6
| GPSR4_SD3_DAT3
@@ -1017,7 +1035,9 @@
| GPSR4_SD2_DAT3
| GPSR4_SD2_DAT2
| GPSR4_SD2_DAT1
- | GPSR4_SD2_DAT0 | GPSR4_SD2_CMD | GPSR4_SD2_CLK);
+ | GPSR4_SD2_DAT0
+ | GPSR4_SD2_CMD
+ | GPSR4_SD2_CLK);
pfc_reg_write(PFC_GPSR5, GPSR5_MSIOF0_SS2
| GPSR5_MSIOF0_SS1
| GPSR5_MSIOF0_SYNC
@@ -1032,7 +1052,9 @@
| GPSR5_RTS1_TANS
| GPSR5_CTS1
| GPSR5_TX1_A
- | GPSR5_RX1_A | GPSR5_RTS0_TANS | GPSR5_SCK0);
+ | GPSR5_RX1_A
+ | GPSR5_RTS0_TANS
+ | GPSR5_SCK0);
pfc_reg_write(PFC_GPSR6, GPSR6_USB30_OVC
| GPSR6_USB30_PWEN
| GPSR6_USB1_OVC
@@ -1052,9 +1074,12 @@
| GPSR6_SSI_SCK4
| GPSR6_SSI_SDATA1_A
| GPSR6_SSI_SDATA0
- | GPSR6_SSI_WS0129 | GPSR6_SSI_SCK0129);
+ | GPSR6_SSI_WS0129
+ | GPSR6_SSI_SCK0129);
pfc_reg_write(PFC_GPSR7, GPSR7_HDMI1_CEC
- | GPSR7_HDMI0_CEC | GPSR7_AVS2 | GPSR7_AVS1);
+ | GPSR7_HDMI0_CEC
+ | GPSR7_AVS2
+ | GPSR7_AVS1);
/* initialize POC control register */
pfc_reg_write(PFC_POCCTRL0, POC_SD3_DS_33V
@@ -1071,7 +1096,9 @@
| POC_SD0_DAT3_33V
| POC_SD0_DAT2_33V
| POC_SD0_DAT1_33V
- | POC_SD0_DAT0_33V | POC_SD0_CMD_33V | POC_SD0_CLK_33V);
+ | POC_SD0_DAT0_33V
+ | POC_SD0_CMD_33V
+ | POC_SD0_CLK_33V);
/* initialize DRV control register */
reg = mmio_read_32(PFC_DRVCTRL0);
diff --git a/drivers/staging/renesas/rcar/pfc/H3/pfc_init_h3_v2.c b/drivers/staging/renesas/rcar/pfc/H3/pfc_init_h3_v2.c
index 3ed0cd3..116fd82 100644
--- a/drivers/staging/renesas/rcar/pfc/H3/pfc_init_h3_v2.c
+++ b/drivers/staging/renesas/rcar/pfc/H3/pfc_init_h3_v2.c
@@ -5,7 +5,9 @@
*/
#include <stdint.h> /* for uint32_t */
-#include <mmio.h>
+
+#include <lib/mmio.h>
+
#include "pfc_init_h3_v2.h"
#include "rcar_def.h"
@@ -831,7 +833,8 @@
| MOD_SEL0_DRIF2_A
| MOD_SEL0_DRIF1_A
| MOD_SEL0_DRIF0_A
- | MOD_SEL0_CANFD0_A | MOD_SEL0_ADG_A_A);
+ | MOD_SEL0_CANFD0_A
+ | MOD_SEL0_ADG_A_A);
pfc_reg_write(PFC_MOD_SEL1, MOD_SEL1_TSIF1_A
| MOD_SEL1_TSIF0_A
| MOD_SEL1_TIMER_TMU_A
@@ -851,7 +854,9 @@
| MOD_SEL1_PWM6_A
| MOD_SEL1_PWM5_A
| MOD_SEL1_PWM4_A
- | MOD_SEL1_PWM3_A | MOD_SEL1_PWM2_A | MOD_SEL1_PWM1_A);
+ | MOD_SEL1_PWM3_A
+ | MOD_SEL1_PWM2_A
+ | MOD_SEL1_PWM1_A);
pfc_reg_write(PFC_MOD_SEL2, MOD_SEL2_I2C_5_A
| MOD_SEL2_I2C_3_A
| MOD_SEL2_I2C_0_A
@@ -862,7 +867,9 @@
| MOD_SEL2_SSI2_A
| MOD_SEL2_SSI9_A
| MOD_SEL2_TIMER_TMU2_A
- | MOD_SEL2_ADG_B_A | MOD_SEL2_ADG_C_A | MOD_SEL2_VIN4_A);
+ | MOD_SEL2_ADG_B_A
+ | MOD_SEL2_ADG_C_A
+ | MOD_SEL2_VIN4_A);
/* initialize peripheral function select */
pfc_reg_write(PFC_IPSR0, IPSR_28_FUNC(0)
@@ -1017,7 +1024,10 @@
| GPSR0_D14
| GPSR0_D13
| GPSR0_D12
- | GPSR0_D11 | GPSR0_D10 | GPSR0_D9 | GPSR0_D8);
+ | GPSR0_D11
+ | GPSR0_D10
+ | GPSR0_D9
+ | GPSR0_D8);
pfc_reg_write(PFC_GPSR1, GPSR1_CLKOUT
| GPSR1_EX_WAIT0_A
| GPSR1_A19
@@ -1031,7 +1041,11 @@
| GPSR1_A7
| GPSR1_A6
| GPSR1_A5
- | GPSR1_A4 | GPSR1_A3 | GPSR1_A2 | GPSR1_A1 | GPSR1_A0);
+ | GPSR1_A4
+ | GPSR1_A3
+ | GPSR1_A2
+ | GPSR1_A1
+ | GPSR1_A0);
pfc_reg_write(PFC_GPSR2, GPSR2_AVB_AVTP_CAPTURE_A
| GPSR2_AVB_AVTP_MATCH_A
| GPSR2_AVB_LINK
@@ -1041,7 +1055,10 @@
| GPSR2_PWM1_A
| GPSR2_IRQ5
| GPSR2_IRQ4
- | GPSR2_IRQ3 | GPSR2_IRQ2 | GPSR2_IRQ1 | GPSR2_IRQ0);
+ | GPSR2_IRQ3
+ | GPSR2_IRQ2
+ | GPSR2_IRQ1
+ | GPSR2_IRQ0);
pfc_reg_write(PFC_GPSR3, GPSR3_SD0_WP
| GPSR3_SD0_CD
| GPSR3_SD1_DAT3
@@ -1051,7 +1068,9 @@
| GPSR3_SD0_DAT3
| GPSR3_SD0_DAT2
| GPSR3_SD0_DAT1
- | GPSR3_SD0_DAT0 | GPSR3_SD0_CMD | GPSR3_SD0_CLK);
+ | GPSR3_SD0_DAT0
+ | GPSR3_SD0_CMD
+ | GPSR3_SD0_CLK);
pfc_reg_write(PFC_GPSR4, GPSR4_SD3_DAT7
| GPSR4_SD3_DAT6
| GPSR4_SD3_DAT3
@@ -1064,7 +1083,9 @@
| GPSR4_SD2_DAT3
| GPSR4_SD2_DAT2
| GPSR4_SD2_DAT1
- | GPSR4_SD2_DAT0 | GPSR4_SD2_CMD | GPSR4_SD2_CLK);
+ | GPSR4_SD2_DAT0
+ | GPSR4_SD2_CMD
+ | GPSR4_SD2_CLK);
pfc_reg_write(PFC_GPSR5, GPSR5_MSIOF0_SS2
| GPSR5_MSIOF0_SS1
| GPSR5_MSIOF0_SYNC
@@ -1079,7 +1100,9 @@
| GPSR5_RTS1_TANS
| GPSR5_CTS1
| GPSR5_TX1_A
- | GPSR5_RX1_A | GPSR5_RTS0_TANS | GPSR5_SCK0);
+ | GPSR5_RX1_A
+ | GPSR5_RTS0_TANS
+ | GPSR5_SCK0);
pfc_reg_write(PFC_GPSR6, GPSR6_USB30_OVC
| GPSR6_USB30_PWEN
| GPSR6_USB1_OVC
@@ -1099,9 +1122,12 @@
| GPSR6_SSI_SCK4
| GPSR6_SSI_SDATA1_A
| GPSR6_SSI_SDATA0
- | GPSR6_SSI_WS0129 | GPSR6_SSI_SCK0129);
+ | GPSR6_SSI_WS0129
+ | GPSR6_SSI_SCK0129);
pfc_reg_write(PFC_GPSR7, GPSR7_HDMI1_CEC
- | GPSR7_HDMI0_CEC | GPSR7_AVS2 | GPSR7_AVS1);
+ | GPSR7_HDMI0_CEC
+ | GPSR7_AVS2
+ | GPSR7_AVS1);
/* initialize POC control register */
pfc_reg_write(PFC_POCCTRL0, POC_SD3_DS_33V
@@ -1118,7 +1144,9 @@
| POC_SD0_DAT3_33V
| POC_SD0_DAT2_33V
| POC_SD0_DAT1_33V
- | POC_SD0_DAT0_33V | POC_SD0_CMD_33V | POC_SD0_CLK_33V);
+ | POC_SD0_DAT0_33V
+ | POC_SD0_CMD_33V
+ | POC_SD0_CLK_33V);
/* initialize DRV control register */
reg = mmio_read_32(PFC_DRVCTRL0);
diff --git a/drivers/staging/renesas/rcar/pfc/M3/pfc_init_m3.c b/drivers/staging/renesas/rcar/pfc/M3/pfc_init_m3.c
index 911ee8c..fc12cd6 100644
--- a/drivers/staging/renesas/rcar/pfc/M3/pfc_init_m3.c
+++ b/drivers/staging/renesas/rcar/pfc/M3/pfc_init_m3.c
@@ -5,7 +5,9 @@
*/
#include <stdint.h> /* for uint32_t */
-#include <mmio.h>
+
+#include <lib/mmio.h>
+
#include "pfc_init_m3.h"
#include "rcar_def.h"
#include "rcar_private.h"
@@ -865,7 +867,9 @@
/* Set transfer parameter, Start transfer */
mmio_write_32(RTDMAC_RDMCHCR(RTDMAC_CH), RDMCHCR_DPM_INFINITE
| RDMCHCR_RPT_TCR
- | RDMCHCR_TS_2 | RDMCHCR_RS_AUTO | RDMCHCR_DE);
+ | RDMCHCR_TS_2
+ | RDMCHCR_RS_AUTO
+ | RDMCHCR_DE);
}
}
@@ -911,7 +915,8 @@
| MOD_SEL0_DRIF2_A
| MOD_SEL0_DRIF1_A
| MOD_SEL0_DRIF0_A
- | MOD_SEL0_CANFD0_A | MOD_SEL0_ADG_A_A);
+ | MOD_SEL0_CANFD0_A
+ | MOD_SEL0_ADG_A_A);
pfc_reg_write(PFC_MOD_SEL1, MOD_SEL1_TSIF1_A
| MOD_SEL1_TSIF0_A
| MOD_SEL1_TIMER_TMU_A
@@ -931,7 +936,9 @@
| MOD_SEL1_PWM6_A
| MOD_SEL1_PWM5_A
| MOD_SEL1_PWM4_A
- | MOD_SEL1_PWM3_A | MOD_SEL1_PWM2_A | MOD_SEL1_PWM1_A);
+ | MOD_SEL1_PWM3_A
+ | MOD_SEL1_PWM2_A
+ | MOD_SEL1_PWM1_A);
pfc_reg_write(PFC_MOD_SEL2, MOD_SEL2_I2C_5_A
| MOD_SEL2_I2C_3_A
| MOD_SEL2_I2C_0_A
@@ -942,7 +949,9 @@
| MOD_SEL2_SSI2_A
| MOD_SEL2_SSI9_A
| MOD_SEL2_TIMER_TMU2_A
- | MOD_SEL2_ADG_B_A | MOD_SEL2_ADG_C_A | MOD_SEL2_VIN4_A);
+ | MOD_SEL2_ADG_B_A
+ | MOD_SEL2_ADG_C_A
+ | MOD_SEL2_VIN4_A);
/* initialize peripheral function select */
pfc_reg_write(PFC_IPSR0, IPSR_28_FUNC(0)
@@ -1097,7 +1106,10 @@
| GPSR0_D14
| GPSR0_D13
| GPSR0_D12
- | GPSR0_D11 | GPSR0_D10 | GPSR0_D9 | GPSR0_D8);
+ | GPSR0_D11
+ | GPSR0_D10
+ | GPSR0_D9
+ | GPSR0_D8);
pfc_reg_write(PFC_GPSR1, GPSR1_CLKOUT
| GPSR1_EX_WAIT0_A
| GPSR1_A19
@@ -1111,7 +1123,11 @@
| GPSR1_A7
| GPSR1_A6
| GPSR1_A5
- | GPSR1_A4 | GPSR1_A3 | GPSR1_A2 | GPSR1_A1 | GPSR1_A0);
+ | GPSR1_A4
+ | GPSR1_A3
+ | GPSR1_A2
+ | GPSR1_A1
+ | GPSR1_A0);
pfc_reg_write(PFC_GPSR2, GPSR2_AVB_AVTP_CAPTURE_A
| GPSR2_AVB_AVTP_MATCH_A
| GPSR2_AVB_LINK
@@ -1121,7 +1137,10 @@
| GPSR2_PWM1_A
| GPSR2_IRQ5
| GPSR2_IRQ4
- | GPSR2_IRQ3 | GPSR2_IRQ2 | GPSR2_IRQ1 | GPSR2_IRQ0);
+ | GPSR2_IRQ3
+ | GPSR2_IRQ2
+ | GPSR2_IRQ1
+ | GPSR2_IRQ0);
pfc_reg_write(PFC_GPSR3, GPSR3_SD0_WP
| GPSR3_SD0_CD
| GPSR3_SD1_DAT3
@@ -1131,7 +1150,9 @@
| GPSR3_SD0_DAT3
| GPSR3_SD0_DAT2
| GPSR3_SD0_DAT1
- | GPSR3_SD0_DAT0 | GPSR3_SD0_CMD | GPSR3_SD0_CLK);
+ | GPSR3_SD0_DAT0
+ | GPSR3_SD0_CMD
+ | GPSR3_SD0_CLK);
pfc_reg_write(PFC_GPSR4, GPSR4_SD3_DAT7
| GPSR4_SD3_DAT6
| GPSR4_SD3_DAT3
@@ -1144,7 +1165,9 @@
| GPSR4_SD2_DAT3
| GPSR4_SD2_DAT2
| GPSR4_SD2_DAT1
- | GPSR4_SD2_DAT0 | GPSR4_SD2_CMD | GPSR4_SD2_CLK);
+ | GPSR4_SD2_DAT0
+ | GPSR4_SD2_CMD
+ | GPSR4_SD2_CLK);
pfc_reg_write(PFC_GPSR5, GPSR5_MSIOF0_SS2
| GPSR5_MSIOF0_SS1
| GPSR5_MSIOF0_SYNC
@@ -1159,7 +1182,9 @@
| GPSR5_RTS1_TANS
| GPSR5_CTS1
| GPSR5_TX1_A
- | GPSR5_RX1_A | GPSR5_RTS0_TANS | GPSR5_SCK0);
+ | GPSR5_RX1_A
+ | GPSR5_RTS0_TANS
+ | GPSR5_SCK0);
pfc_reg_write(PFC_GPSR6, GPSR6_USB30_OVC
| GPSR6_USB30_PWEN
| GPSR6_USB1_OVC
@@ -1179,9 +1204,12 @@
| GPSR6_SSI_SCK4
| GPSR6_SSI_SDATA1_A
| GPSR6_SSI_SDATA0
- | GPSR6_SSI_WS0129 | GPSR6_SSI_SCK0129);
+ | GPSR6_SSI_WS0129
+ | GPSR6_SSI_SCK0129);
pfc_reg_write(PFC_GPSR7, GPSR7_HDMI1_CEC
- | GPSR7_HDMI0_CEC | GPSR7_AVS2 | GPSR7_AVS1);
+ | GPSR7_HDMI0_CEC
+ | GPSR7_AVS2
+ | GPSR7_AVS1);
/* initialize POC control register */
pfc_reg_write(PFC_POCCTRL0, POC_SD3_DS_33V
@@ -1198,7 +1226,9 @@
| POC_SD0_DAT3_33V
| POC_SD0_DAT2_33V
| POC_SD0_DAT1_33V
- | POC_SD0_DAT0_33V | POC_SD0_CMD_33V | POC_SD0_CLK_33V);
+ | POC_SD0_DAT0_33V
+ | POC_SD0_CMD_33V
+ | POC_SD0_CLK_33V);
/* initialize DRV control register */
reg = mmio_read_32(PFC_DRVCTRL0);
diff --git a/drivers/staging/renesas/rcar/pfc/M3N/pfc_init_m3n.c b/drivers/staging/renesas/rcar/pfc/M3N/pfc_init_m3n.c
index a2b6b34..07f08fa 100644
--- a/drivers/staging/renesas/rcar/pfc/M3N/pfc_init_m3n.c
+++ b/drivers/staging/renesas/rcar/pfc/M3N/pfc_init_m3n.c
@@ -5,7 +5,9 @@
*/
#include <stdint.h> /* for uint32_t */
-#include <mmio.h>
+
+#include <lib/mmio.h>
+
#include "pfc_init_m3n.h"
#include "rcar_def.h"
@@ -819,7 +821,8 @@
| MOD_SEL0_DRIF2_A
| MOD_SEL0_DRIF1_A
| MOD_SEL0_DRIF0_A
- | MOD_SEL0_CANFD0_A | MOD_SEL0_ADG_A_A);
+ | MOD_SEL0_CANFD0_A
+ | MOD_SEL0_ADG_A_A);
pfc_reg_write(PFC_MOD_SEL1, MOD_SEL1_TSIF1_A
| MOD_SEL1_TSIF0_A
| MOD_SEL1_TIMER_TMU_A
@@ -839,7 +842,9 @@
| MOD_SEL1_PWM6_A
| MOD_SEL1_PWM5_A
| MOD_SEL1_PWM4_A
- | MOD_SEL1_PWM3_A | MOD_SEL1_PWM2_A | MOD_SEL1_PWM1_A);
+ | MOD_SEL1_PWM3_A
+ | MOD_SEL1_PWM2_A
+ | MOD_SEL1_PWM1_A);
pfc_reg_write(PFC_MOD_SEL2, MOD_SEL2_I2C_5_A
| MOD_SEL2_I2C_3_A
| MOD_SEL2_I2C_0_A
@@ -850,7 +855,9 @@
| MOD_SEL2_SSI2_A
| MOD_SEL2_SSI9_A
| MOD_SEL2_TIMER_TMU2_A
- | MOD_SEL2_ADG_B_A | MOD_SEL2_ADG_C_A | MOD_SEL2_VIN4_A);
+ | MOD_SEL2_ADG_B_A
+ | MOD_SEL2_ADG_C_A
+ | MOD_SEL2_VIN4_A);
/* initialize peripheral function select */
pfc_reg_write(PFC_IPSR0, IPSR_28_FUNC(0)
@@ -1005,7 +1012,10 @@
| GPSR0_D14
| GPSR0_D13
| GPSR0_D12
- | GPSR0_D11 | GPSR0_D10 | GPSR0_D9 | GPSR0_D8);
+ | GPSR0_D11
+ | GPSR0_D10
+ | GPSR0_D9
+ | GPSR0_D8);
pfc_reg_write(PFC_GPSR1, GPSR1_CLKOUT
| GPSR1_EX_WAIT0_A
| GPSR1_A19
@@ -1019,7 +1029,11 @@
| GPSR1_A7
| GPSR1_A6
| GPSR1_A5
- | GPSR1_A4 | GPSR1_A3 | GPSR1_A2 | GPSR1_A1 | GPSR1_A0);
+ | GPSR1_A4
+ | GPSR1_A3
+ | GPSR1_A2
+ | GPSR1_A1
+ | GPSR1_A0);
pfc_reg_write(PFC_GPSR2, GPSR2_AVB_AVTP_CAPTURE_A
| GPSR2_AVB_AVTP_MATCH_A
| GPSR2_AVB_LINK
@@ -1029,7 +1043,10 @@
| GPSR2_PWM1_A
| GPSR2_IRQ5
| GPSR2_IRQ4
- | GPSR2_IRQ3 | GPSR2_IRQ2 | GPSR2_IRQ1 | GPSR2_IRQ0);
+ | GPSR2_IRQ3
+ | GPSR2_IRQ2
+ | GPSR2_IRQ1
+ | GPSR2_IRQ0);
pfc_reg_write(PFC_GPSR3, GPSR3_SD0_WP
| GPSR3_SD0_CD
| GPSR3_SD1_DAT3
@@ -1039,7 +1056,9 @@
| GPSR3_SD0_DAT3
| GPSR3_SD0_DAT2
| GPSR3_SD0_DAT1
- | GPSR3_SD0_DAT0 | GPSR3_SD0_CMD | GPSR3_SD0_CLK);
+ | GPSR3_SD0_DAT0
+ | GPSR3_SD0_CMD
+ | GPSR3_SD0_CLK);
pfc_reg_write(PFC_GPSR4, GPSR4_SD3_DAT7
| GPSR4_SD3_DAT6
| GPSR4_SD3_DAT3
@@ -1052,7 +1071,9 @@
| GPSR4_SD2_DAT3
| GPSR4_SD2_DAT2
| GPSR4_SD2_DAT1
- | GPSR4_SD2_DAT0 | GPSR4_SD2_CMD | GPSR4_SD2_CLK);
+ | GPSR4_SD2_DAT0
+ | GPSR4_SD2_CMD
+ | GPSR4_SD2_CLK);
pfc_reg_write(PFC_GPSR5, GPSR5_MSIOF0_SS2
| GPSR5_MSIOF0_SS1
| GPSR5_MSIOF0_SYNC
@@ -1067,7 +1088,9 @@
| GPSR5_RTS1_TANS
| GPSR5_CTS1
| GPSR5_TX1_A
- | GPSR5_RX1_A | GPSR5_RTS0_TANS | GPSR5_SCK0);
+ | GPSR5_RX1_A
+ | GPSR5_RTS0_TANS
+ | GPSR5_SCK0);
pfc_reg_write(PFC_GPSR6, GPSR6_USB30_OVC
| GPSR6_USB30_PWEN
| GPSR6_USB1_OVC
@@ -1087,9 +1110,12 @@
| GPSR6_SSI_SCK4
| GPSR6_SSI_SDATA1_A
| GPSR6_SSI_SDATA0
- | GPSR6_SSI_WS0129 | GPSR6_SSI_SCK0129);
+ | GPSR6_SSI_WS0129
+ | GPSR6_SSI_SCK0129);
pfc_reg_write(PFC_GPSR7, GPSR7_HDMI1_CEC
- | GPSR7_HDMI0_CEC | GPSR7_AVS2 | GPSR7_AVS1);
+ | GPSR7_HDMI0_CEC
+ | GPSR7_AVS2
+ | GPSR7_AVS1);
/* initialize POC control register */
pfc_reg_write(PFC_POCCTRL0, POC_SD3_DS_33V
@@ -1106,7 +1132,9 @@
| POC_SD0_DAT3_33V
| POC_SD0_DAT2_33V
| POC_SD0_DAT1_33V
- | POC_SD0_DAT0_33V | POC_SD0_CMD_33V | POC_SD0_CLK_33V);
+ | POC_SD0_DAT0_33V
+ | POC_SD0_CMD_33V
+ | POC_SD0_CLK_33V);
/* initialize DRV control register */
reg = mmio_read_32(PFC_DRVCTRL0);
diff --git a/drivers/staging/renesas/rcar/pfc/pfc_init.c b/drivers/staging/renesas/rcar/pfc/pfc_init.c
index fceff3d..f20e8b0 100644
--- a/drivers/staging/renesas/rcar/pfc/pfc_init.c
+++ b/drivers/staging/renesas/rcar/pfc/pfc_init.c
@@ -5,8 +5,10 @@
*/
#include <stdint.h>
-#include <debug.h>
-#include <mmio.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "rcar_def.h"
#if RCAR_LSI == RCAR_AUTO
#include "H3/pfc_init_h3_v1.h"
diff --git a/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10.c b/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10.c
index efe0c75..db51912 100644
--- a/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10.c
+++ b/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10.c
@@ -5,12 +5,14 @@
*/
#include <stdint.h>
-#include <debug.h>
+
+#include <common/debug.h>
+
#include "../qos_common.h"
#include "../qos_reg.h"
#include "qos_init_e3_v10.h"
-#define RCAR_QOS_VERSION "rev.0.02"
+#define RCAR_QOS_VERSION "rev.0.05"
#define QOSCTRL_EARLYR (QOS_BASE1 + 0x0060U)
#define QOSCTRL_FSS (QOS_BASE1 + 0x0048U)
@@ -132,14 +134,6 @@
}
}
- /* 3DG bus Leaf setting */
- io_write_32(GPU_ACT_GRD, 0x00001234U);
- io_write_32(GPU_ACT0, 0x00000000U);
- io_write_32(GPU_ACT1, 0x00000000U);
- io_write_32(GPU_ACT2, 0x00000000U);
- io_write_32(GPU_ACT3, 0x00000000U);
- io_write_32(GPU_ACT_GRD, 0x00000000U);
-
/* RT bus Leaf setting */
io_write_32(RT_ACT0, 0x00000000U);
io_write_32(RT_ACT1, 0x00000000U);
diff --git a/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10_mstat390.h b/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10_mstat390.h
index cf376a2..d7f9d14 100644
--- a/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10_mstat390.h
+++ b/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10_mstat390.h
@@ -27,20 +27,20 @@
/* 0x0098, */ 0x0000000000000000UL,
/* 0x00a0, */ 0x000C08380000FFFFUL,
/* 0x00a8, */ 0x000C04110000FFFFUL,
- /* 0x00b0, */ 0x000C04110000FFFFUL,
+ /* 0x00b0, */ 0x000C04150000FFFFUL,
/* 0x00b8, */ 0x0000000000000000UL,
/* 0x00c0, */ 0x000C08380000FFFFUL,
/* 0x00c8, */ 0x000C04110000FFFFUL,
- /* 0x00d0, */ 0x000C04110000FFFFUL,
+ /* 0x00d0, */ 0x000C04150000FFFFUL,
/* 0x00d8, */ 0x0000000000000000UL,
/* 0x00e0, */ 0x0000000000000000UL,
/* 0x00e8, */ 0x0000000000000000UL,
/* 0x00f0, */ 0x001018580000FFFFUL,
- /* 0x00f8, */ 0x000C04400000FFFFUL,
+ /* 0x00f8, */ 0x000C084F0000FFFFUL,
/* 0x0100, */ 0x0000000000000000UL,
/* 0x0108, */ 0x0000000000000000UL,
/* 0x0110, */ 0x001008580000FFFFUL,
- /* 0x0118, */ 0x000C19660000FFFFUL,
+ /* 0x0118, */ 0x000C21E40000FFFFUL,
/* 0x0120, */ 0x0000000000000000UL,
/* 0x0128, */ 0x0000000000000000UL,
/* 0x0130, */ 0x0000000000000000UL,
diff --git a/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10_mstat780.h b/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10_mstat780.h
index 002a664..439cafe 100644
--- a/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10_mstat780.h
+++ b/drivers/staging/renesas/rcar/qos/E3/qos_init_e3_v10_mstat780.h
@@ -27,20 +27,20 @@
/* 0x0098, */ 0x0000000000000000UL,
/* 0x00a0, */ 0x000C10700000FFFFUL,
/* 0x00a8, */ 0x000C08210000FFFFUL,
- /* 0x00b0, */ 0x000C08210000FFFFUL,
+ /* 0x00b0, */ 0x000C082A0000FFFFUL,
/* 0x00b8, */ 0x0000000000000000UL,
/* 0x00c0, */ 0x000C10700000FFFFUL,
/* 0x00c8, */ 0x000C08210000FFFFUL,
- /* 0x00d0, */ 0x000C08210000FFFFUL,
+ /* 0x00d0, */ 0x000C082A0000FFFFUL,
/* 0x00d8, */ 0x0000000000000000UL,
/* 0x00e0, */ 0x0000000000000000UL,
/* 0x00e8, */ 0x0000000000000000UL,
/* 0x00f0, */ 0x00102CAF0000FFFFUL,
- /* 0x00f8, */ 0x000C087F0000FFFFUL,
+ /* 0x00f8, */ 0x000C0C9D0000FFFFUL,
/* 0x0100, */ 0x0000000000000000UL,
/* 0x0108, */ 0x0000000000000000UL,
/* 0x0110, */ 0x00100CAF0000FFFFUL,
- /* 0x0118, */ 0x000C32CC0000FFFFUL,
+ /* 0x0118, */ 0x000C43C80000FFFFUL,
/* 0x0120, */ 0x0000000000000000UL,
/* 0x0128, */ 0x0000000000000000UL,
/* 0x0130, */ 0x0000000000000000UL,
diff --git a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v10.c b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v10.c
index fd81187..21aa3df 100644
--- a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v10.c
+++ b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v10.c
@@ -5,7 +5,9 @@
*/
#include <stdint.h>
-#include <debug.h>
+
+#include <common/debug.h>
+
#include "../qos_common.h"
#include "qos_init_h3_v10.h"
diff --git a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v11.c b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v11.c
index 1f65600..5b7348c 100644
--- a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v11.c
+++ b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v11.c
@@ -5,8 +5,11 @@
*/
#include <stdint.h>
-#include <debug.h>
+
+#include <common/debug.h>
+
#include <rcar_def.h>
+
#include "../qos_common.h"
#include "qos_init_h3_v11.h"
diff --git a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v20.c b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v20.c
index 6922360..c4f8701 100644
--- a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v20.c
+++ b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v20.c
@@ -5,12 +5,15 @@
*/
#include <stdint.h>
-#include <debug.h>
+
+#include <common/debug.h>
+
#include "../qos_common.h"
#include "../qos_reg.h"
#include "qos_init_h3_v20.h"
-#define RCAR_QOS_VERSION "rev.0.19"
+
+#define RCAR_QOS_VERSION "rev.0.20"
#define QOSWT_TIME_BANK0 (20000000U) /* unit:ns */
diff --git a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30.c b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30.c
index 5986a39..95f4810 100644
--- a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30.c
+++ b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30.c
@@ -5,12 +5,15 @@
*/
#include <stdint.h>
-#include <debug.h>
+
+#include <common/debug.h>
+
#include "../qos_common.h"
#include "../qos_reg.h"
#include "qos_init_h3_v30.h"
-#define RCAR_QOS_VERSION "rev.0.07"
+
+#define RCAR_QOS_VERSION "rev.0.10"
#define QOSCTRL_FSS (QOS_BASE1 + 0x0048U)
@@ -224,8 +227,6 @@
io_write_32(AXI_TR3CR, 0x00010000U);
io_write_32(AXI_TR4CR, 0x00010000U);
- /* 3DG bus Leaf setting */
-
/* RT bus Leaf setting */
io_write_32(RT_ACT0, 0x00000000U);
io_write_32(RT_ACT1, 0x00000000U);
diff --git a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30_mstat195.h b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30_mstat195.h
index daa4076..28a240f 100644
--- a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30_mstat195.h
+++ b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30_mstat195.h
@@ -36,12 +36,12 @@
/* 0x00e0, */ 0x00100C090000FFFFUL,
/* 0x00e8, */ 0x0000000000000000UL,
/* 0x00f0, */ 0x001024090000FFFFUL,
- /* 0x00f8, */ 0x000C08080000FFFFUL,
+ /* 0x00f8, */ 0x000C100D0000FFFFUL,
/* 0x0100, */ 0x0000000000000000UL,
/* 0x0108, */ 0x0000000000000000UL,
/* 0x0110, */ 0x00100C090000FFFFUL,
- /* 0x0118, */ 0x000C18180000FFFFUL,
- /* 0x0120, */ 0x000C18180000FFFFUL,
+ /* 0x0118, */ 0x000C1C1B0000FFFFUL,
+ /* 0x0120, */ 0x000C1C1B0000FFFFUL,
/* 0x0128, */ 0x0000000000000000UL,
/* 0x0130, */ 0x0000000000000000UL,
/* 0x0138, */ 0x00100C0B0000FFFFUL,
diff --git a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30_mstat390.h b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30_mstat390.h
index f72165c..def6585 100644
--- a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30_mstat390.h
+++ b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3_v30_mstat390.h
@@ -36,12 +36,12 @@
/* 0x00e0, */ 0x001014110000FFFFUL,
/* 0x00e8, */ 0x0000000000000000UL,
/* 0x00f0, */ 0x001044110000FFFFUL,
- /* 0x00f8, */ 0x000C10100000FFFFUL,
+ /* 0x00f8, */ 0x000C1C1A0000FFFFUL,
/* 0x0100, */ 0x0000000000000000UL,
/* 0x0108, */ 0x0000000000000000UL,
/* 0x0110, */ 0x001014110000FFFFUL,
- /* 0x0118, */ 0x000C302F0000FFFFUL,
- /* 0x0120, */ 0x000C302F0000FFFFUL,
+ /* 0x0118, */ 0x000C38360000FFFFUL,
+ /* 0x0120, */ 0x000C38360000FFFFUL,
/* 0x0128, */ 0x0000000000000000UL,
/* 0x0130, */ 0x0000000000000000UL,
/* 0x0138, */ 0x001018150000FFFFUL,
diff --git a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30.c b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30.c
index 58c3716..71e0396 100644
--- a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30.c
+++ b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30.c
@@ -5,12 +5,15 @@
*/
#include <stdint.h>
-#include <debug.h>
+
+#include <common/debug.h>
+
#include "../qos_common.h"
#include "../qos_reg.h"
#include "qos_init_h3n_v30.h"
-#define RCAR_QOS_VERSION "rev.0.03"
+
+#define RCAR_QOS_VERSION "rev.0.06"
#define QOSCTRL_FSS (QOS_BASE1 + 0x0048U)
@@ -218,14 +221,6 @@
io_write_32(AXI_TR3CR, 0x00010000U);
io_write_32(AXI_TR4CR, 0x00010000U);
- /* 3DG bus Leaf setting */
- io_write_32(GPU_ACT_GRD, 0x00001234U);
- io_write_32(GPU_ACT0, 0x00000000U);
- io_write_32(GPU_ACT1, 0x00000000U);
- io_write_32(GPU_ACT2, 0x00000000U);
- io_write_32(GPU_ACT3, 0x00000000U);
- io_write_32(GPU_ACT_GRD, 0x00000000U);
-
/* RT bus Leaf setting */
io_write_32(RT_ACT0, 0x00000000U);
io_write_32(RT_ACT1, 0x00000000U);
diff --git a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30_mstat195.h b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30_mstat195.h
index b73e90b..6dbc88a 100644
--- a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30_mstat195.h
+++ b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30_mstat195.h
@@ -36,12 +36,12 @@
/* 0x00e0, */ 0x00100C090000FFFFUL,
/* 0x00e8, */ 0x0000000000000000UL,
/* 0x00f0, */ 0x001024090000FFFFUL,
- /* 0x00f8, */ 0x000C08080000FFFFUL,
+ /* 0x00f8, */ 0x000C100D0000FFFFUL,
/* 0x0100, */ 0x0000000000000000UL,
/* 0x0108, */ 0x0000000000000000UL,
/* 0x0110, */ 0x00100C090000FFFFUL,
- /* 0x0118, */ 0x000C18180000FFFFUL,
- /* 0x0120, */ 0x000C18180000FFFFUL,
+ /* 0x0118, */ 0x000C1C1B0000FFFFUL,
+ /* 0x0120, */ 0x000C1C1B0000FFFFUL,
/* 0x0128, */ 0x0000000000000000UL,
/* 0x0130, */ 0x0000000000000000UL,
/* 0x0138, */ 0x00100C0B0000FFFFUL,
diff --git a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30_mstat390.h b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30_mstat390.h
index 1b7c383..880211c 100644
--- a/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30_mstat390.h
+++ b/drivers/staging/renesas/rcar/qos/H3/qos_init_h3n_v30_mstat390.h
@@ -36,12 +36,12 @@
/* 0x00e0, */ 0x001014110000FFFFUL,
/* 0x00e8, */ 0x0000000000000000UL,
/* 0x00f0, */ 0x001044110000FFFFUL,
- /* 0x00f8, */ 0x000C10100000FFFFUL,
+ /* 0x00f8, */ 0x000C1C1A0000FFFFUL,
/* 0x0100, */ 0x0000000000000000UL,
/* 0x0108, */ 0x0000000000000000UL,
/* 0x0110, */ 0x001014110000FFFFUL,
- /* 0x0118, */ 0x000C302F0000FFFFUL,
- /* 0x0120, */ 0x000C302F0000FFFFUL,
+ /* 0x0118, */ 0x000C38360000FFFFUL,
+ /* 0x0120, */ 0x000C38360000FFFFUL,
/* 0x0128, */ 0x0000000000000000UL,
/* 0x0130, */ 0x0000000000000000UL,
/* 0x0138, */ 0x001018150000FFFFUL,
diff --git a/drivers/staging/renesas/rcar/qos/M3/qos_init_m3_v10.c b/drivers/staging/renesas/rcar/qos/M3/qos_init_m3_v10.c
index a0d1e14..c0846d2 100644
--- a/drivers/staging/renesas/rcar/qos/M3/qos_init_m3_v10.c
+++ b/drivers/staging/renesas/rcar/qos/M3/qos_init_m3_v10.c
@@ -5,7 +5,9 @@
*/
#include <stdint.h>
-#include <debug.h>
+
+#include <common/debug.h>
+
#include "../qos_common.h"
#include "qos_init_m3_v10.h"
diff --git a/drivers/staging/renesas/rcar/qos/M3/qos_init_m3_v11.c b/drivers/staging/renesas/rcar/qos/M3/qos_init_m3_v11.c
index fc0d2cc..10fa6b4 100644
--- a/drivers/staging/renesas/rcar/qos/M3/qos_init_m3_v11.c
+++ b/drivers/staging/renesas/rcar/qos/M3/qos_init_m3_v11.c
@@ -5,12 +5,15 @@
*/
#include <stdint.h>
-#include <debug.h>
+
+#include <common/debug.h>
+
#include "../qos_common.h"
#include "../qos_reg.h"
#include "qos_init_m3_v11.h"
-#define RCAR_QOS_VERSION "rev.0.17"
+#define RCAR_QOS_VERSION "rev.0.18"
+
#define QOSWT_TIME_BANK0 (20000000U) /* unit:ns */
diff --git a/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10.c b/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10.c
index e9d6676..52a3ca2 100644
--- a/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10.c
+++ b/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10.c
@@ -5,12 +5,14 @@
*/
#include <stdint.h>
-#include <debug.h>
+
+#include <common/debug.h>
+
#include "../qos_common.h"
#include "../qos_reg.h"
#include "qos_init_m3n_v10.h"
-#define RCAR_QOS_VERSION "rev.0.06"
+#define RCAR_QOS_VERSION "rev.0.08"
#define QOSCTRL_EARLYR (QOS_BASE1 + 0x0060U)
#define QOSCTRL_FSS (QOS_BASE1 + 0x0048U)
@@ -196,14 +198,6 @@
#endif /* RCAR_REWT_TRAINING != RCAR_REWT_TRAINING_DISABLE */
}
- /* 3DG bus Leaf setting */
- io_write_32(GPU_ACT_GRD, 0x00001234U);
- io_write_32(GPU_ACT0, 0x00000000U);
- io_write_32(GPU_ACT1, 0x00000000U);
- io_write_32(GPU_ACT2, 0x00000000U);
- io_write_32(GPU_ACT3, 0x00000000U);
- io_write_32(GPU_ACT_GRD, 0x00000000U);
-
/* RT bus Leaf setting */
io_write_32(RT_ACT0, 0x00000000U);
io_write_32(RT_ACT1, 0x00000000U);
diff --git a/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10_mstat195.h b/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10_mstat195.h
index d30e95f..9b8b9e9 100644
--- a/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10_mstat195.h
+++ b/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10_mstat195.h
@@ -27,11 +27,11 @@
/* 0x0098, */ 0x0000000000000000UL,
/* 0x00a0, */ 0x000C041D0000FFFFUL,
/* 0x00a8, */ 0x000C04090000FFFFUL,
- /* 0x00b0, */ 0x000C04090000FFFFUL,
+ /* 0x00b0, */ 0x000C040B0000FFFFUL,
/* 0x00b8, */ 0x0000000000000000UL,
/* 0x00c0, */ 0x000C041D0000FFFFUL,
/* 0x00c8, */ 0x000C04090000FFFFUL,
- /* 0x00d0, */ 0x000C04090000FFFFUL,
+ /* 0x00d0, */ 0x000C040B0000FFFFUL,
/* 0x00d8, */ 0x0000000000000000UL,
/* 0x00e0, */ 0x0000000000000000UL,
/* 0x00e8, */ 0x0000000000000000UL,
diff --git a/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10_mstat390.h b/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10_mstat390.h
index 0dc37ca..19143ed 100644
--- a/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10_mstat390.h
+++ b/drivers/staging/renesas/rcar/qos/M3N/qos_init_m3n_v10_mstat390.h
@@ -27,11 +27,11 @@
/* 0x0098, */ 0x0000000000000000UL,
/* 0x00a0, */ 0x000C08390000FFFFUL,
/* 0x00a8, */ 0x000C04110000FFFFUL,
- /* 0x00b0, */ 0x000C04110000FFFFUL,
+ /* 0x00b0, */ 0x000C04150000FFFFUL,
/* 0x00b8, */ 0x0000000000000000UL,
/* 0x00c0, */ 0x000C08390000FFFFUL,
/* 0x00c8, */ 0x000C04110000FFFFUL,
- /* 0x00d0, */ 0x000C04110000FFFFUL,
+ /* 0x00d0, */ 0x000C04150000FFFFUL,
/* 0x00d8, */ 0x0000000000000000UL,
/* 0x00e0, */ 0x0000000000000000UL,
/* 0x00e8, */ 0x0000000000000000UL,
diff --git a/drivers/staging/renesas/rcar/qos/qos_common.h b/drivers/staging/renesas/rcar/qos/qos_common.h
index 0174d5b..9bad424 100644
--- a/drivers/staging/renesas/rcar/qos/qos_common.h
+++ b/drivers/staging/renesas/rcar/qos/qos_common.h
@@ -9,6 +9,15 @@
#define RCAR_REF_DEFAULT (0U)
+/* define used for get_refperiod. */
+/* REFPERIOD_CYCLE need smaller than QOSWT_WTSET0_CYCLEs */
+/* refere to plat/renesas/rcar/ddr/ddr_a/ddr_init_e3.h for E3. */
+#if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF default */
+#define REFPERIOD_CYCLE ((126 * BASE_SUB_SLOT_NUM * 1000U)/400) /* unit:ns */
+#else /* REF option */
+#define REFPERIOD_CYCLE ((252 * BASE_SUB_SLOT_NUM * 1000U)/400) /* unit:ns */
+#endif
+
#if (RCAR_LSI == RCAR_E3)
/* define used for E3 */
#if (RCAR_REF_INT == RCAR_REF_DEFAULT) /* REF 3.9usec */
@@ -19,7 +28,7 @@
#define OPERATING_FREQ_E3 (266U) /* MHz */
#define SL_INIT_SSLOTCLK_E3 (SUB_SLOT_CYCLE_E3 -1U)
-#define QOSWT_WTSET0_CYCLE_E3 ((SUB_SLOT_CYCLE_E3 * BASE_SUB_SLOT_NUM * 1000U)/OPERATING_FREQ_E3) /* unit:ns */
+/* #define QOSWT_WTSET0_CYCLE_E3 ((SUB_SLOT_CYCLE_E3 * BASE_SUB_SLOT_NUM * 1000U)/OPERATING_FREQ_E3) */ /* unit:ns */
#endif
#if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_M3N)
diff --git a/drivers/staging/renesas/rcar/qos/qos_init.c b/drivers/staging/renesas/rcar/qos/qos_init.c
index 54c8803..be4487a 100644
--- a/drivers/staging/renesas/rcar/qos/qos_init.c
+++ b/drivers/staging/renesas/rcar/qos/qos_init.c
@@ -5,8 +5,10 @@
*/
#include <stdint.h>
-#include <debug.h>
-#include <mmio.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "qos_init.h"
#include "qos_common.h"
#if RCAR_LSI == RCAR_AUTO
@@ -236,6 +238,7 @@
#endif
}
+#if !(RCAR_LSI == RCAR_E3)
uint32_t get_refperiod(void)
{
uint32_t refperiod = QOSWT_WTSET0_CYCLE;
@@ -252,11 +255,9 @@
case PRR_PRODUCT_11:
break;
case PRR_PRODUCT_20:
- refperiod = QOSWT_WTSET0_CYCLE_H3_20;
- break;
case PRR_PRODUCT_30:
default:
- refperiod = QOSWT_WTSET0_CYCLE_H3_30;
+ refperiod = REFPERIOD_CYCLE;
break;
}
break;
@@ -265,7 +266,7 @@
switch (reg & PRR_CUT_MASK) {
case PRR_PRODUCT_30:
default:
- refperiod = QOSWT_WTSET0_CYCLE_H3N;
+ refperiod = REFPERIOD_CYCLE;
break;
}
break;
@@ -275,21 +276,16 @@
switch (reg & PRR_CUT_MASK) {
case PRR_PRODUCT_10:
break;
- case PRR_PRODUCT_20: /* M3 Cut 11 */
+ case PRR_PRODUCT_20: /* M3 Cut 11 */
default:
- refperiod = QOSWT_WTSET0_CYCLE_M3_11;
+ refperiod = REFPERIOD_CYCLE;
break;
}
break;
#endif
#if (RCAR_LSI == RCAR_AUTO) || (RCAR_LSI == RCAR_M3N)
case PRR_PRODUCT_M3N:
- refperiod = QOSWT_WTSET0_CYCLE_M3N;
- break;
-#endif
-#if (RCAR_LSI == RCAR_E3)
- case PRR_PRODUCT_E3:
- refperiod = QOSWT_WTSET0_CYCLE_E3;
+ refperiod = REFPERIOD_CYCLE;
break;
#endif
default:
@@ -300,28 +296,25 @@
/* H3 Cut 10 */
#elif RCAR_LSI_CUT == RCAR_CUT_11
/* H3 Cut 11 */
-#elif RCAR_LSI_CUT == RCAR_CUT_20
- /* H3 Cut 20 */
- refperiod = QOSWT_WTSET0_CYCLE_H3_20;
#else
+ /* H3 Cut 20 */
/* H3 Cut 30 or later */
- refperiod = QOSWT_WTSET0_CYCLE_H3_30;
+ refperiod = REFPERIOD_CYCLE;
#endif
#elif RCAR_LSI == RCAR_H3N
/* H3N Cut 30 or later */
- refperiod = QOSWT_WTSET0_CYCLE_H3N;
+ refperiod = REFPERIOD_CYCLE;
#elif RCAR_LSI == RCAR_M3
#if RCAR_LSI_CUT == RCAR_CUT_10
/* M3 Cut 10 */
#else
/* M3 Cut 11 or later */
- refperiod = QOSWT_WTSET0_CYCLE_M3_11;
+ refperiod = REFPERIOD_CYCLE;
#endif
#elif RCAR_LSI == RCAR_M3N /* for M3N */
- refperiod = QOSWT_WTSET0_CYCLE_M3N;
-#elif RCAR_LSI == RCAR_E3 /* for E3 */
- refperiod = QOSWT_WTSET0_CYCLE_E3;
+ refperiod = REFPERIOD_CYCLE;
#endif
return refperiod;
}
+#endif
diff --git a/drivers/synopsys/emmc/dw_mmc.c b/drivers/synopsys/emmc/dw_mmc.c
index eb42819..0c5c645 100644
--- a/drivers/synopsys/emmc/dw_mmc.c
+++ b/drivers/synopsys/emmc/dw_mmc.c
@@ -4,16 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <dw_mmc.h>
-#include <errno.h>
-#include <mmc.h>
-#include <mmio.h>
-#include <string.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/mmc.h>
+#include <drivers/synopsys/dw_mmc.h>
+#include <lib/mmio.h>
#define DWMMC_CTRL (0x00)
#define CTRL_IDMAC_EN (1 << 25)
diff --git a/drivers/synopsys/ufs/dw_ufs.c b/drivers/synopsys/ufs/dw_ufs.c
index b0ea3e7..c7c8fc2 100644
--- a/drivers/synopsys/ufs/dw_ufs.c
+++ b/drivers/synopsys/ufs/dw_ufs.c
@@ -5,12 +5,13 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <dw_ufs.h>
-#include <mmio.h>
#include <stdint.h>
#include <string.h>
-#include <ufs.h>
+
+#include <common/debug.h>
+#include <drivers/dw_ufs.h>
+#include <drivers/ufs.h>
+#include <lib/mmio.h>
static int dwufs_phy_init(ufs_params_t *params)
{
diff --git a/drivers/ti/uart/aarch64/16550_console.S b/drivers/ti/uart/aarch64/16550_console.S
index 785b640..3180593 100644
--- a/drivers/ti/uart/aarch64/16550_console.S
+++ b/drivers/ti/uart/aarch64/16550_console.S
@@ -9,7 +9,7 @@
#include <assert_macros.S>
#define USE_FINISH_CONSOLE_REG_2
#include <console_macros.S>
-#include <uart_16550.h>
+#include <drivers/ti/uart/uart_16550.h>
/*
* "core" functions are low-level implementations that don't require
diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c
index 515fc27..2351c9b 100644
--- a/drivers/ufs/ufs.c
+++ b/drivers/ufs/ufs.c
@@ -4,17 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <endian.h>
#include <errno.h>
-#include <mmio.h>
-#include <platform_def.h>
#include <stdint.h>
#include <string.h>
-#include <ufs.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/ufs.h>
+#include <lib/mmio.h>
#define CDB_ADDR_MASK 127
#define ALIGN_CDB(x) (((x) + CDB_ADDR_MASK) & ~CDB_ADDR_MASK)
diff --git a/include/lib/aarch32/arch.h b/include/arch/aarch32/arch.h
similarity index 98%
rename from include/lib/aarch32/arch.h
rename to include/arch/aarch32/arch.h
index fa6e5db..cbe272c 100644
--- a/include/lib/aarch32/arch.h
+++ b/include/arch/aarch32/arch.h
@@ -7,7 +7,7 @@
#ifndef ARCH_H
#define ARCH_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* MIDR bit definitions
@@ -94,11 +94,17 @@
/* CSSELR definitions */
#define LEVEL_SHIFT U(1)
-/* ID_PFR0 definitions */
+/* ID_PFR0 AMU definitions */
#define ID_PFR0_AMU_SHIFT U(20)
#define ID_PFR0_AMU_LENGTH U(4)
#define ID_PFR0_AMU_MASK U(0xf)
+/* ID_PFR0 DIT definitions */
+#define ID_PFR0_DIT_SHIFT U(24)
+#define ID_PFR0_DIT_LENGTH U(4)
+#define ID_PFR0_DIT_MASK U(0xf)
+#define ID_PFR0_DIT_SUPPORTED (U(1) << ID_PFR0_DIT_SHIFT)
+
/* ID_PFR1 definitions */
#define ID_PFR1_VIRTEXT_SHIFT U(12)
#define ID_PFR1_VIRTEXT_MASK U(0xf)
@@ -276,6 +282,7 @@
#define DISABLE_ALL_EXCEPTIONS \
(SPSR_FIQ_BIT | SPSR_IRQ_BIT | SPSR_ABT_BIT)
+#define CPSR_DIT_BIT (U(1) << 21)
/*
* TTBCR definitions
*/
diff --git a/include/lib/aarch32/arch_helpers.h b/include/arch/aarch32/arch_helpers.h
similarity index 87%
rename from include/lib/aarch32/arch_helpers.h
rename to include/arch/aarch32/arch_helpers.h
index 7d1944c..c2773c1 100644
--- a/include/lib/aarch32/arch_helpers.h
+++ b/include/arch/aarch32/arch_helpers.h
@@ -7,11 +7,12 @@
#ifndef ARCH_HELPERS_H
#define ARCH_HELPERS_H
-#include <arch.h>
#include <cdefs.h>
#include <stdint.h>
#include <string.h>
+#include <arch.h>
+
/**********************************************************************
* Macros which create inline functions to read or write CPU system
* registers
@@ -248,6 +249,19 @@
DEFINE_COPROCR_RW_FUNCS(cnthp_tval_el2, CNTHP_TVAL)
DEFINE_COPROCR_RW_FUNCS_64(cnthp_cval_el2, CNTHP_CVAL_64)
+#define get_cntp_ctl_enable(x) (((x) >> CNTP_CTL_ENABLE_SHIFT) & \
+ CNTP_CTL_ENABLE_MASK)
+#define get_cntp_ctl_imask(x) (((x) >> CNTP_CTL_IMASK_SHIFT) & \
+ CNTP_CTL_IMASK_MASK)
+#define get_cntp_ctl_istatus(x) (((x) >> CNTP_CTL_ISTATUS_SHIFT) & \
+ CNTP_CTL_ISTATUS_MASK)
+
+#define set_cntp_ctl_enable(x) ((x) |= U(1) << CNTP_CTL_ENABLE_SHIFT)
+#define set_cntp_ctl_imask(x) ((x) |= U(1) << CNTP_CTL_IMASK_SHIFT)
+
+#define clr_cntp_ctl_enable(x) ((x) &= ~(U(1) << CNTP_CTL_ENABLE_SHIFT))
+#define clr_cntp_ctl_imask(x) ((x) &= ~(U(1) << CNTP_CTL_IMASK_SHIFT))
+
DEFINE_COPROCR_RW_FUNCS(icc_sre_el1, ICC_SRE)
DEFINE_COPROCR_RW_FUNCS(icc_sre_el2, ICC_HSRE)
DEFINE_COPROCR_RW_FUNCS(icc_sre_el3, ICC_MSRE)
@@ -378,4 +392,59 @@
#define read_amcntenset0_el0() read_amcntenset0()
#define read_amcntenset1_el0() read_amcntenset1()
+/* Helper functions to manipulate CPSR */
+static inline void enable_irq(void)
+{
+ /*
+ * The compiler memory barrier will prevent the compiler from
+ * scheduling non-volatile memory access after the write to the
+ * register.
+ *
+ * This could happen if some initialization code issues non-volatile
+ * accesses to an area used by an interrupt handler, in the assumption
+ * that it is safe as the interrupts are disabled at the time it does
+ * that (according to program order). However, non-volatile accesses
+ * are not necessarily in program order relatively with volatile inline
+ * assembly statements (and volatile accesses).
+ */
+ COMPILER_BARRIER();
+ __asm__ volatile ("cpsie i");
+ isb();
+}
+
+static inline void enable_serror(void)
+{
+ COMPILER_BARRIER();
+ __asm__ volatile ("cpsie a");
+ isb();
+}
+
+static inline void enable_fiq(void)
+{
+ COMPILER_BARRIER();
+ __asm__ volatile ("cpsie f");
+ isb();
+}
+
+static inline void disable_irq(void)
+{
+ COMPILER_BARRIER();
+ __asm__ volatile ("cpsid i");
+ isb();
+}
+
+static inline void disable_serror(void)
+{
+ COMPILER_BARRIER();
+ __asm__ volatile ("cpsid a");
+ isb();
+}
+
+static inline void disable_fiq(void)
+{
+ COMPILER_BARRIER();
+ __asm__ volatile ("cpsid f");
+ isb();
+}
+
#endif /* ARCH_HELPERS_H */
diff --git a/include/common/aarch32/asm_macros.S b/include/arch/aarch32/asm_macros.S
similarity index 98%
rename from include/common/aarch32/asm_macros.S
rename to include/arch/aarch32/asm_macros.S
index c54f75c..8408804 100644
--- a/include/common/aarch32/asm_macros.S
+++ b/include/arch/aarch32/asm_macros.S
@@ -7,8 +7,8 @@
#define ASM_MACROS_S
#include <arch.h>
-#include <asm_macros_common.S>
-#include <spinlock.h>
+#include <common/asm_macros_common.S>
+#include <lib/spinlock.h>
/*
* TLBI instruction with type specifier that implements the workaround for
diff --git a/include/common/aarch32/assert_macros.S b/include/arch/aarch32/assert_macros.S
similarity index 100%
rename from include/common/aarch32/assert_macros.S
rename to include/arch/aarch32/assert_macros.S
diff --git a/include/common/aarch32/console_macros.S b/include/arch/aarch32/console_macros.S
similarity index 98%
rename from include/common/aarch32/console_macros.S
rename to include/arch/aarch32/console_macros.S
index ba6e7d0..ed5088d 100644
--- a/include/common/aarch32/console_macros.S
+++ b/include/arch/aarch32/console_macros.S
@@ -6,7 +6,7 @@
#ifndef CONSOLE_MACROS_S
#define CONSOLE_MACROS_S
-#include <console.h>
+#include <drivers/console.h>
/*
* This macro encapsulates the common setup that has to be done at the end of
diff --git a/include/common/aarch32/el3_common_macros.S b/include/arch/aarch32/el3_common_macros.S
similarity index 97%
rename from include/common/aarch32/el3_common_macros.S
rename to include/arch/aarch32/el3_common_macros.S
index 2438423..048f161 100644
--- a/include/common/aarch32/el3_common_macros.S
+++ b/include/arch/aarch32/el3_common_macros.S
@@ -110,6 +110,18 @@
stcopr r0, SDCR
#endif
+ /*
+ * If Data Independent Timing (DIT) functionality is implemented,
+ * always enable DIT in EL3
+ */
+ ldcopr r0, ID_PFR0
+ and r0, r0, #(ID_PFR0_DIT_MASK << ID_PFR0_DIT_SHIFT)
+ cmp r0, #ID_PFR0_DIT_SUPPORTED
+ bne 1f
+ mrs r0, cpsr
+ orr r0, r0, #CPSR_DIT_BIT
+ msr cpsr_cxsf, r0
+1:
.endm
/* -----------------------------------------------------------------------------
diff --git a/include/lib/aarch32/smccc_helpers.h b/include/arch/aarch32/smccc_helpers.h
similarity index 98%
rename from include/lib/aarch32/smccc_helpers.h
rename to include/arch/aarch32/smccc_helpers.h
index 67952ec..d3e5e59 100644
--- a/include/lib/aarch32/smccc_helpers.h
+++ b/include/arch/aarch32/smccc_helpers.h
@@ -7,7 +7,7 @@
#ifndef SMCCC_HELPERS_H
#define SMCCC_HELPERS_H
-#include <smccc.h>
+#include <lib/smccc.h>
/* These are offsets to registers in smc_ctx_t */
#define SMC_CTX_GPREG_R0 U(0x0)
@@ -25,9 +25,11 @@
#define SMC_CTX_SIZE U(0x90)
#ifndef __ASSEMBLY__
-#include <cassert.h>
+
#include <stdint.h>
+#include <lib/cassert.h>
+
/*
* The generic structure to save arguments and callee saved registers during
* an SMC. Also this structure is used to store the result return values after
diff --git a/include/lib/aarch32/smccc_macros.S b/include/arch/aarch32/smccc_macros.S
similarity index 100%
rename from include/lib/aarch32/smccc_macros.S
rename to include/arch/aarch32/smccc_macros.S
diff --git a/include/lib/aarch64/arch.h b/include/arch/aarch64/arch.h
similarity index 97%
rename from include/lib/aarch64/arch.h
rename to include/arch/aarch64/arch.h
index 97595e9..8a44d83 100644
--- a/include/lib/aarch64/arch.h
+++ b/include/arch/aarch64/arch.h
@@ -7,7 +7,7 @@
#ifndef ARCH_H
#define ARCH_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* MIDR bit definitions
@@ -135,6 +135,10 @@
#define ID_AA64PFR0_SVE_LENGTH U(4)
#define ID_AA64PFR0_MPAM_SHIFT U(40)
#define ID_AA64PFR0_MPAM_MASK ULL(0xf)
+#define ID_AA64PFR0_DIT_SHIFT U(48)
+#define ID_AA64PFR0_DIT_MASK ULL(0xf)
+#define ID_AA64PFR0_DIT_LENGTH U(4)
+#define ID_AA64PFR0_DIT_SUPPORTED U(1)
#define ID_AA64PFR0_CSV2_SHIFT U(56)
#define ID_AA64PFR0_CSV2_MASK ULL(0xf)
#define ID_AA64PFR0_CSV2_LENGTH U(4)
@@ -534,19 +538,6 @@
#define CNTP_CTL_IMASK_MASK U(1)
#define CNTP_CTL_ISTATUS_MASK U(1)
-#define get_cntp_ctl_enable(x) (((x) >> CNTP_CTL_ENABLE_SHIFT) & \
- CNTP_CTL_ENABLE_MASK)
-#define get_cntp_ctl_imask(x) (((x) >> CNTP_CTL_IMASK_SHIFT) & \
- CNTP_CTL_IMASK_MASK)
-#define get_cntp_ctl_istatus(x) (((x) >> CNTP_CTL_ISTATUS_SHIFT) & \
- CNTP_CTL_ISTATUS_MASK)
-
-#define set_cntp_ctl_enable(x) ((x) |= (U(1) << CNTP_CTL_ENABLE_SHIFT))
-#define set_cntp_ctl_imask(x) ((x) |= (U(1) << CNTP_CTL_IMASK_SHIFT))
-
-#define clr_cntp_ctl_enable(x) ((x) &= ~(U(1) << CNTP_CTL_ENABLE_SHIFT))
-#define clr_cntp_ctl_imask(x) ((x) &= ~(U(1) << CNTP_CTL_IMASK_SHIFT))
-
/* Exception Syndrome register bits and bobs */
#define ESR_EC_SHIFT U(26)
#define ESR_EC_MASK U(0x3f)
@@ -791,7 +782,7 @@
/*******************************************************************************
* RAS system registers
- *******************************************************************************/
+ ******************************************************************************/
#define DISR_EL1 S3_0_C12_C1_1
#define DISR_A_BIT U(31)
@@ -820,7 +811,13 @@
/*******************************************************************************
* Armv8.3 Pointer Authentication Registers
- *******************************************************************************/
+ ******************************************************************************/
#define APGAKeyLo_EL1 S3_0_C2_C3_0
+/*******************************************************************************
+ * Armv8.4 Data Independent Timing Registers
+ ******************************************************************************/
+#define DIT S3_3_C4_C2_5
+#define DIT_BIT BIT(24)
+
#endif /* ARCH_H */
diff --git a/include/lib/aarch64/arch_helpers.h b/include/arch/aarch64/arch_helpers.h
similarity index 86%
rename from include/lib/aarch64/arch_helpers.h
rename to include/arch/aarch64/arch_helpers.h
index 8b3d53a..b912b42 100644
--- a/include/lib/aarch64/arch_helpers.h
+++ b/include/arch/aarch64/arch_helpers.h
@@ -7,12 +7,13 @@
#ifndef ARCH_HELPERS_H
#define ARCH_HELPERS_H
-#include <arch.h>
#include <cdefs.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
+#include <arch.h>
+
/**********************************************************************
* Macros which create inline functions to read or write CPU system
* registers
@@ -215,11 +216,81 @@
DEFINE_SYSOP_TYPE_FUNC(dmb, ish)
DEFINE_SYSOP_FUNC(isb)
+static inline void enable_irq(void)
+{
+ /*
+ * The compiler memory barrier will prevent the compiler from
+ * scheduling non-volatile memory access after the write to the
+ * register.
+ *
+ * This could happen if some initialization code issues non-volatile
+ * accesses to an area used by an interrupt handler, in the assumption
+ * that it is safe as the interrupts are disabled at the time it does
+ * that (according to program order). However, non-volatile accesses
+ * are not necessarily in program order relatively with volatile inline
+ * assembly statements (and volatile accesses).
+ */
+ COMPILER_BARRIER();
+ write_daifclr(DAIF_IRQ_BIT);
+ isb();
+}
+
+static inline void enable_fiq(void)
+{
+ COMPILER_BARRIER();
+ write_daifclr(DAIF_FIQ_BIT);
+ isb();
+}
+
+static inline void enable_serror(void)
+{
+ COMPILER_BARRIER();
+ write_daifclr(DAIF_ABT_BIT);
+ isb();
+}
+
+static inline void enable_debug_exceptions(void)
+{
+ COMPILER_BARRIER();
+ write_daifclr(DAIF_DBG_BIT);
+ isb();
+}
+
+static inline void disable_irq(void)
+{
+ COMPILER_BARRIER();
+ write_daifset(DAIF_IRQ_BIT);
+ isb();
+}
+
+static inline void disable_fiq(void)
+{
+ COMPILER_BARRIER();
+ write_daifset(DAIF_FIQ_BIT);
+ isb();
+}
+
+static inline void disable_serror(void)
+{
+ COMPILER_BARRIER();
+ write_daifset(DAIF_ABT_BIT);
+ isb();
+}
+
+static inline void disable_debug_exceptions(void)
+{
+ COMPILER_BARRIER();
+ write_daifset(DAIF_DBG_BIT);
+ isb();
+}
+
+#if !ERROR_DEPRECATED
uint32_t get_afflvl_shift(uint32_t);
uint32_t mpidr_mask_lower_afflvls(uint64_t, uint32_t);
void __dead2 eret(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3,
uint64_t x4, uint64_t x5, uint64_t x6, uint64_t x7);
+#endif
void __dead2 smc(uint64_t x0, uint64_t x1, uint64_t x2, uint64_t x3,
uint64_t x4, uint64_t x5, uint64_t x6, uint64_t x7);
@@ -306,6 +377,19 @@
DEFINE_SYSREG_READ_FUNC(cntpct_el0)
DEFINE_SYSREG_RW_FUNCS(cnthctl_el2)
+#define get_cntp_ctl_enable(x) (((x) >> CNTP_CTL_ENABLE_SHIFT) & \
+ CNTP_CTL_ENABLE_MASK)
+#define get_cntp_ctl_imask(x) (((x) >> CNTP_CTL_IMASK_SHIFT) & \
+ CNTP_CTL_IMASK_MASK)
+#define get_cntp_ctl_istatus(x) (((x) >> CNTP_CTL_ISTATUS_SHIFT) & \
+ CNTP_CTL_ISTATUS_MASK)
+
+#define set_cntp_ctl_enable(x) ((x) |= (U(1) << CNTP_CTL_ENABLE_SHIFT))
+#define set_cntp_ctl_imask(x) ((x) |= (U(1) << CNTP_CTL_IMASK_SHIFT))
+
+#define clr_cntp_ctl_enable(x) ((x) &= ~(U(1) << CNTP_CTL_ENABLE_SHIFT))
+#define clr_cntp_ctl_imask(x) ((x) &= ~(U(1) << CNTP_CTL_IMASK_SHIFT))
+
DEFINE_SYSREG_RW_FUNCS(tpidr_el3)
DEFINE_SYSREG_RW_FUNCS(cntvoff_el2)
diff --git a/include/common/aarch64/asm_macros.S b/include/arch/aarch64/asm_macros.S
similarity index 98%
rename from include/common/aarch64/asm_macros.S
rename to include/arch/aarch64/asm_macros.S
index dea3021..387be4c 100644
--- a/include/common/aarch64/asm_macros.S
+++ b/include/arch/aarch64/asm_macros.S
@@ -7,8 +7,8 @@
#define ASM_MACROS_S
#include <arch.h>
-#include <asm_macros_common.S>
-#include <spinlock.h>
+#include <common/asm_macros_common.S>
+#include <lib/spinlock.h>
/*
* TLBI instruction with type specifier that implements the workaround for
diff --git a/include/common/aarch64/assert_macros.S b/include/arch/aarch64/assert_macros.S
similarity index 100%
rename from include/common/aarch64/assert_macros.S
rename to include/arch/aarch64/assert_macros.S
diff --git a/include/common/aarch64/console_macros.S b/include/arch/aarch64/console_macros.S
similarity index 98%
rename from include/common/aarch64/console_macros.S
rename to include/arch/aarch64/console_macros.S
index 5c88d4f..90ef420 100644
--- a/include/common/aarch64/console_macros.S
+++ b/include/arch/aarch64/console_macros.S
@@ -6,7 +6,7 @@
#ifndef CONSOLE_MACROS_S
#define CONSOLE_MACROS_S
-#include <console.h>
+#include <drivers/console.h>
/*
* This macro encapsulates the common setup that has to be done at the end of
diff --git a/include/common/aarch64/el3_common_macros.S b/include/arch/aarch64/el3_common_macros.S
similarity index 97%
rename from include/common/aarch64/el3_common_macros.S
rename to include/arch/aarch64/el3_common_macros.S
index 008daca..410aeab 100644
--- a/include/common/aarch64/el3_common_macros.S
+++ b/include/arch/aarch64/el3_common_macros.S
@@ -130,6 +130,18 @@
*/
mov_imm x0, (CPTR_EL3_RESET_VAL & ~(TCPAC_BIT | TTA_BIT | TFP_BIT))
msr cptr_el3, x0
+
+ /*
+ * If Data Independent Timing (DIT) functionality is implemented,
+ * always enable DIT in EL3
+ */
+ mrs x0, id_aa64pfr0_el1
+ ubfx x0, x0, #ID_AA64PFR0_DIT_SHIFT, #ID_AA64PFR0_DIT_LENGTH
+ cmp x0, #ID_AA64PFR0_DIT_SUPPORTED
+ bne 1f
+ mov x0, #DIT_BIT
+ msr DIT, x0
+1:
.endm
/* -----------------------------------------------------------------------------
diff --git a/include/lib/aarch64/setjmp.h b/include/arch/aarch64/setjmp.h
similarity index 100%
rename from include/lib/aarch64/setjmp.h
rename to include/arch/aarch64/setjmp.h
diff --git a/include/lib/aarch64/smccc_helpers.h b/include/arch/aarch64/smccc_helpers.h
similarity index 98%
rename from include/lib/aarch64/smccc_helpers.h
rename to include/arch/aarch64/smccc_helpers.h
index efab18b..e28697d 100644
--- a/include/lib/aarch64/smccc_helpers.h
+++ b/include/arch/aarch64/smccc_helpers.h
@@ -7,12 +7,14 @@
#ifndef SMCCC_HELPERS_H
#define SMCCC_HELPERS_H
-#include <smccc.h>
+#include <lib/smccc.h>
#ifndef __ASSEMBLY__
-#include <context.h>
+
#include <stdbool.h>
+#include <context.h>
+
/* Convenience macros to return from SMC handler */
#define SMC_RET0(_h) { \
return (uint64_t) (_h); \
diff --git a/include/bl1/bl1.h b/include/bl1/bl1.h
index 39b8d1e..7b5d875 100644
--- a/include/bl1/bl1.h
+++ b/include/bl1/bl1.h
@@ -7,7 +7,7 @@
#ifndef BL1_H
#define BL1_H
-#include <bl_common.h>
+#include <common/bl_common.h>
/*
* Defines for BL1 SMC function ids.
@@ -62,7 +62,8 @@
((_fid >= FWU_SMC_FID_START) && (_fid <= FWU_SMC_FID_END))
#ifndef __ASSEMBLY__
-#include <cassert.h>
+
+#include <lib/cassert.h>
struct entry_point_info;
diff --git a/include/bl1/tbbr/tbbr_img_desc.h b/include/bl1/tbbr/tbbr_img_desc.h
index bb36eb5..db15cdb 100644
--- a/include/bl1/tbbr/tbbr_img_desc.h
+++ b/include/bl1/tbbr/tbbr_img_desc.h
@@ -7,7 +7,7 @@
#ifndef TBBR_IMG_DESC_H
#define TBBR_IMG_DESC_H
-#include <bl_common.h>
+#include <common/bl_common.h>
extern image_desc_t bl1_tbbr_image_descs[];
diff --git a/include/bl31/ehf.h b/include/bl31/ehf.h
index f35d810..ee00d09 100644
--- a/include/bl31/ehf.h
+++ b/include/bl31/ehf.h
@@ -11,7 +11,8 @@
#include <cdefs.h>
#include <stdint.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/* Valid priorities set bit 0 of the priority handler. */
#define EHF_PRI_VALID_ BIT(0)
diff --git a/include/bl31/interrupt_mgmt.h b/include/bl31/interrupt_mgmt.h
index 6a49fb6..b1683cc 100644
--- a/include/bl31/interrupt_mgmt.h
+++ b/include/bl31/interrupt_mgmt.h
@@ -8,7 +8,7 @@
#define INTERRUPT_MGMT_H
#include <arch.h>
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* Constants for the types of interrupts recognised by the IM framework
diff --git a/include/bl32/payloads/tlk.h b/include/bl32/payloads/tlk.h
index 0234cbe..2c12633 100644
--- a/include/bl32/payloads/tlk.h
+++ b/include/bl32/payloads/tlk.h
@@ -7,7 +7,7 @@
#ifndef TLK_H
#define TLK_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*
* Generate function IDs for the Trusted OS/Apps
diff --git a/include/common/bl_common.h b/include/common/bl_common.h
index 56c89fc..c12b08b 100644
--- a/include/common/bl_common.h
+++ b/include/common/bl_common.h
@@ -7,9 +7,9 @@
#ifndef BL_COMMON_H
#define BL_COMMON_H
-#include <ep_info.h>
-#include <param_header.h>
-#include <utils_def.h>
+#include <common/ep_info.h>
+#include <common/param_header.h>
+#include <lib/utils_def.h>
#define UP U(1)
#define DOWN U(0)
@@ -58,11 +58,11 @@
#define SERROR_AARCH32 U(0xf)
#ifndef __ASSEMBLY__
-#include <cassert.h>
+
#include <stddef.h>
#include <stdint.h>
-#include <utils_def.h> /* To retain compatibility */
+#include <lib/cassert.h>
/*
* Declarations of linker defined symbols to help determine memory layout of
diff --git a/include/common/debug.h b/include/common/debug.h
index a14a66e..f8faf68 100644
--- a/include/common/debug.h
+++ b/include/common/debug.h
@@ -7,7 +7,7 @@
#ifndef DEBUG_H
#define DEBUG_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*
* The log output macros print output to the console. These macros produce
@@ -28,12 +28,14 @@
#define LOG_LEVEL_VERBOSE U(50)
#ifndef __ASSEMBLY__
+
#include <cdefs.h>
-#include <console.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
+#include <drivers/console.h>
+
/*
* Define Log Markers corresponding to each log level which will
* be embedded in the format string and is expected by tf_log() to determine
diff --git a/include/common/desc_image_load.h b/include/common/desc_image_load.h
index 6254895..f2f26ea 100644
--- a/include/common/desc_image_load.h
+++ b/include/common/desc_image_load.h
@@ -6,7 +6,7 @@
#ifndef DESC_IMAGE_LOAD_H
#define DESC_IMAGE_LOAD_H
-#include <bl_common.h>
+#include <common/bl_common.h>
/* Following structure is used to store BL ep/image info. */
typedef struct bl_mem_params_node {
diff --git a/include/common/ep_info.h b/include/common/ep_info.h
index 0f67687..a09d03b 100644
--- a/include/common/ep_info.h
+++ b/include/common/ep_info.h
@@ -7,8 +7,8 @@
#ifndef EP_INFO_H
#define EP_INFO_H
-#include <param_header.h>
-#include <utils_def.h>
+#include <common/param_header.h>
+#include <lib/utils_def.h>
#define SECURE U(0x0)
#define NON_SECURE U(0x1)
@@ -64,9 +64,10 @@
#ifndef __ASSEMBLY__
-#include <cassert.h>
#include <stdint.h>
+#include <lib/cassert.h>
+
typedef struct aapcs64_params {
u_register_t arg0;
u_register_t arg1;
diff --git a/include/common/param_header.h b/include/common/param_header.h
index e9717cb..0c1503f 100644
--- a/include/common/param_header.h
+++ b/include/common/param_header.h
@@ -8,7 +8,8 @@
#define PARAM_HEADER_H
#include <stdbool.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/* Param header types */
#define PARAM_EP U(0x01)
diff --git a/include/common/runtime_svc.h b/include/common/runtime_svc.h
index e32c287..59bf158 100644
--- a/include/common/runtime_svc.h
+++ b/include/common/runtime_svc.h
@@ -7,10 +7,10 @@
#ifndef RUNTIME_SVC_H
#define RUNTIME_SVC_H
-#include <bl_common.h> /* to include exception types */
-#include <cassert.h>
+#include <common/bl_common.h> /* to include exception types */
+#include <lib/cassert.h>
+#include <lib/utils_def.h>
#include <smccc_helpers.h> /* to include SMCCC definitions */
-#include <utils_def.h>
/*******************************************************************************
* Structure definition, typedefs & constants for the runtime service framework
diff --git a/include/common/tbbr/tbbr_img_def.h b/include/common/tbbr/tbbr_img_def.h
index bd8f5dc..672886d 100644
--- a/include/common/tbbr/tbbr_img_def.h
+++ b/include/common/tbbr/tbbr_img_def.h
@@ -7,7 +7,7 @@
#ifndef TBBR_IMG_DEF_H
#define TBBR_IMG_DEF_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* Firmware Image Package */
#define FIP_IMAGE_ID U(0)
diff --git a/include/drivers/arm/cci.h b/include/drivers/arm/cci.h
index 24b76da..c5ddcfd 100644
--- a/include/drivers/arm/cci.h
+++ b/include/drivers/arm/cci.h
@@ -7,7 +7,7 @@
#ifndef CCI_H
#define CCI_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* Slave interface offsets from PERIPHBASE */
#define SLAVE_IFACE6_OFFSET UL(0x7000)
diff --git a/include/drivers/arm/gic_common.h b/include/drivers/arm/gic_common.h
index 2f5334f..3ac1b43 100644
--- a/include/drivers/arm/gic_common.h
+++ b/include/drivers/arm/gic_common.h
@@ -7,7 +7,7 @@
#ifndef GIC_COMMON_H
#define GIC_COMMON_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* GIC Distributor interface general definitions
@@ -35,11 +35,9 @@
#define GIC_INTR_CFG_LEVEL (0 << 1)
#define GIC_INTR_CFG_EDGE (1 << 1)
-/* Constants to categorise priorities */
+/* Highest possible interrupt priorities */
#define GIC_HIGHEST_SEC_PRIORITY U(0x00)
-#define GIC_LOWEST_SEC_PRIORITY U(0x7f)
#define GIC_HIGHEST_NS_PRIORITY U(0x80)
-#define GIC_LOWEST_NS_PRIORITY U(0xfe) /* 0xff would disable all interrupts */
/*******************************************************************************
* GIC Distributor interface register offsets that are common to GICv3 & GICv2
diff --git a/include/drivers/arm/gicv2.h b/include/drivers/arm/gicv2.h
index 705077c..6bc5101 100644
--- a/include/drivers/arm/gicv2.h
+++ b/include/drivers/arm/gicv2.h
@@ -7,7 +7,7 @@
#ifndef GICV2_H
#define GICV2_H
-#include <gic_common.h>
+#include <drivers/arm/gic_common.h>
/*******************************************************************************
* GICv2 miscellaneous definitions
@@ -119,9 +119,10 @@
#ifndef __ASSEMBLY__
#include <cdefs.h>
-#include <interrupt_props.h>
#include <stdint.h>
+#include <common/interrupt_props.h>
+
/*******************************************************************************
* This structure describes some of the implementation defined attributes of
* the GICv2 IP. It is used by the platform port to specify these attributes
diff --git a/include/drivers/arm/gicv3.h b/include/drivers/arm/gicv3.h
index c26f297..2382697 100644
--- a/include/drivers/arm/gicv3.h
+++ b/include/drivers/arm/gicv3.h
@@ -209,12 +209,13 @@
#ifndef __ASSEMBLY__
-#include <arch_helpers.h>
-#include <gic_common.h>
-#include <interrupt_props.h>
#include <stdbool.h>
#include <stdint.h>
-#include <utils_def.h>
+
+#include <arch_helpers.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gic_common.h>
+#include <lib/utils_def.h>
static inline bool gicv3_is_intr_id_special_identifier(unsigned int id)
{
diff --git a/include/drivers/arm/pl011.h b/include/drivers/arm/pl011.h
index 6216a61..f201f00 100644
--- a/include/drivers/arm/pl011.h
+++ b/include/drivers/arm/pl011.h
@@ -7,7 +7,7 @@
#ifndef PL011_H
#define PL011_H
-#include <console.h>
+#include <drivers/console.h>
/* PL011 Registers */
#define UARTDR 0x000
diff --git a/include/drivers/arm/pl061_gpio.h b/include/drivers/arm/pl061_gpio.h
index 6c4a9f5..68238c9 100644
--- a/include/drivers/arm/pl061_gpio.h
+++ b/include/drivers/arm/pl061_gpio.h
@@ -7,7 +7,7 @@
#ifndef PL061_GPIO_H
#define PL061_GPIO_H
-#include <gpio.h>
+#include <drivers/gpio.h>
void pl061_gpio_register(uintptr_t base_addr, int gpio_dev);
void pl061_gpio_init(void);
diff --git a/include/drivers/arm/smmu_v3.h b/include/drivers/arm/smmu_v3.h
index 1b7ffb8..33f3d6f 100644
--- a/include/drivers/arm/smmu_v3.h
+++ b/include/drivers/arm/smmu_v3.h
@@ -8,7 +8,8 @@
#define SMMU_V3_H
#include <stdint.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/* SMMUv3 register offsets from device base */
#define SMMU_S_IDR1 U(0x8004)
diff --git a/include/drivers/arm/sp804_delay_timer.h b/include/drivers/arm/sp804_delay_timer.h
index 8eb8715..f8769e8 100644
--- a/include/drivers/arm/sp804_delay_timer.h
+++ b/include/drivers/arm/sp804_delay_timer.h
@@ -7,9 +7,9 @@
#ifndef SP804_DELAY_TIMER_H
#define SP804_DELAY_TIMER_H
-#include <delay_timer.h>
#include <stdint.h>
+#include <drivers/delay_timer.h>
uint32_t sp804_get_timer_value(void);
diff --git a/include/drivers/arm/sp805.h b/include/drivers/arm/sp805.h
index e7714a3..551bfe4 100644
--- a/include/drivers/arm/sp805.h
+++ b/include/drivers/arm/sp805.h
@@ -7,7 +7,7 @@
#ifndef SP805_H
#define SP805_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* SP805 register offset */
#define SP805_WDOG_LOAD_OFF UL(0x000)
diff --git a/include/drivers/arm/tzc380.h b/include/drivers/arm/tzc380.h
index 19cf988..03b9b05 100644
--- a/include/drivers/arm/tzc380.h
+++ b/include/drivers/arm/tzc380.h
@@ -7,8 +7,8 @@
#ifndef TZC380_H
#define TZC380_H
-#include <tzc_common.h>
-#include <utils_def.h>
+#include <drivers/arm/tzc_common.h>
+#include <lib/utils_def.h>
#define TZC380_CONFIGURATION_OFF U(0x000)
#define ACTION_OFF U(0x004)
diff --git a/include/drivers/arm/tzc400.h b/include/drivers/arm/tzc400.h
index a7bb3f6..98ef0ec 100644
--- a/include/drivers/arm/tzc400.h
+++ b/include/drivers/arm/tzc400.h
@@ -7,8 +7,8 @@
#ifndef TZC400_H
#define TZC400_H
-#include <tzc_common.h>
-#include <utils_def.h>
+#include <drivers/arm/tzc_common.h>
+#include <lib/utils_def.h>
#define BUILD_CONFIG_OFF U(0x000)
#define GATE_KEEPER_OFF U(0x008)
diff --git a/include/drivers/arm/tzc_common.h b/include/drivers/arm/tzc_common.h
index 4b81547..4820baa 100644
--- a/include/drivers/arm/tzc_common.h
+++ b/include/drivers/arm/tzc_common.h
@@ -7,7 +7,7 @@
#ifndef TZC_COMMON_H
#define TZC_COMMON_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*
* Offset of core registers from the start of the base of configuration
diff --git a/include/drivers/arm/tzc_dmc500.h b/include/drivers/arm/tzc_dmc500.h
index df6e7f9..24bfaeb 100644
--- a/include/drivers/arm/tzc_dmc500.h
+++ b/include/drivers/arm/tzc_dmc500.h
@@ -7,8 +7,8 @@
#ifndef TZC_DMC500_H
#define TZC_DMC500_H
-#include <tzc_common.h>
-#include <utils_def.h>
+#include <drivers/arm/tzc_common.h>
+#include <lib/utils_def.h>
#define SI_STATUS_OFFSET U(0x000)
#define SI_STATE_CTRL_OFFSET U(0x030)
diff --git a/include/drivers/arm/tzc_dmc620.h b/include/drivers/arm/tzc_dmc620.h
index 074bbc1..e0e6760 100644
--- a/include/drivers/arm/tzc_dmc620.h
+++ b/include/drivers/arm/tzc_dmc620.h
@@ -7,7 +7,7 @@
#ifndef TZC_DMC620_H
#define TZC_DMC620_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* DMC-620 memc register offsets */
#define DMC620_MEMC_STATUS U(0x0000)
diff --git a/include/drivers/auth/auth_mod.h b/include/drivers/auth/auth_mod.h
index 19bc2f1..9089953 100644
--- a/include/drivers/auth/auth_mod.h
+++ b/include/drivers/auth/auth_mod.h
@@ -9,10 +9,10 @@
#if TRUSTED_BOARD_BOOT
-#include <auth_common.h>
-#include <cot_def.h>
-#include <img_parser_mod.h>
-#include <tbbr_img_def.h>
+#include <common/tbbr/cot_def.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <drivers/auth/auth_common.h>
+#include <drivers/auth/img_parser_mod.h>
/*
* Image flags
diff --git a/include/drivers/auth/img_parser_mod.h b/include/drivers/auth/img_parser_mod.h
index 4379693..b2fb60e 100644
--- a/include/drivers/auth/img_parser_mod.h
+++ b/include/drivers/auth/img_parser_mod.h
@@ -7,7 +7,7 @@
#ifndef IMG_PARSER_MOD_H
#define IMG_PARSER_MOD_H
-#include <auth_common.h>
+#include <drivers/auth/auth_common.h>
/*
* Return values
diff --git a/include/drivers/cadence/cdns_uart.h b/include/drivers/cadence/cdns_uart.h
index 490be10..0a1cf77 100644
--- a/include/drivers/cadence/cdns_uart.h
+++ b/include/drivers/cadence/cdns_uart.h
@@ -7,7 +7,7 @@
#ifndef CDNS_UART_H
#define CDNS_UART_H
-#include <console.h>
+#include <drivers/console.h>
/* This is very minimalistic and will only work in QEMU. */
diff --git a/include/drivers/console.h b/include/drivers/console.h
index 02f2f8a..24887f9 100644
--- a/include/drivers/console.h
+++ b/include/drivers/console.h
@@ -7,7 +7,7 @@
#ifndef CONSOLE_H
#define CONSOLE_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
#define CONSOLE_T_NEXT (U(0) * REGSZ)
#define CONSOLE_T_FLAGS (U(1) * REGSZ)
@@ -44,7 +44,9 @@
int (*const flush)(struct console *console);
/* Additional private driver data may follow here. */
} console_t;
-#include <console_assertions.h> /* offset macro assertions for console_t */
+
+/* offset macro assertions for console_t */
+#include <drivers/console_assertions.h>
/*
* NOTE: There is no publicly accessible console_register() function. Consoles
diff --git a/include/drivers/console_assertions.h b/include/drivers/console_assertions.h
index 559bb50..00caa31 100644
--- a/include/drivers/console_assertions.h
+++ b/include/drivers/console_assertions.h
@@ -7,7 +7,7 @@
#ifndef CONSOLE_ASSERTIONS_H
#define CONSOLE_ASSERTIONS_H
-#include <cassert.h>
+#include <lib/cassert.h>
/*
* This file contains some separate assertions about console_t, moved here to
diff --git a/include/drivers/coreboot/cbmem_console.h b/include/drivers/coreboot/cbmem_console.h
index 7fe7a72..40c90e6 100644
--- a/include/drivers/coreboot/cbmem_console.h
+++ b/include/drivers/coreboot/cbmem_console.h
@@ -7,7 +7,7 @@
#ifndef CBMEM_CONSOLE_H
#define CBMEM_CONSOLE_H
-#include <console.h>
+#include <drivers/console.h>
#define CONSOLE_T_CBMC_BASE CONSOLE_T_DRVDATA
#define CONSOLE_T_CBMC_SIZE (CONSOLE_T_DRVDATA + REGSZ)
diff --git a/include/drivers/io/io_block.h b/include/drivers/io/io_block.h
index d6d32f9..c99e8c7 100644
--- a/include/drivers/io/io_block.h
+++ b/include/drivers/io/io_block.h
@@ -7,7 +7,7 @@
#ifndef IO_BLOCK_H
#define IO_BLOCK_H
-#include <io_storage.h>
+#include <drivers/io/io_storage.h>
/* block devices ops */
typedef struct io_block_ops {
diff --git a/include/drivers/io/io_driver.h b/include/drivers/io/io_driver.h
index 587f137..2b704f4 100644
--- a/include/drivers/io/io_driver.h
+++ b/include/drivers/io/io_driver.h
@@ -7,9 +7,9 @@
#ifndef IO_DRIVER_H
#define IO_DRIVER_H
-#include <io_storage.h>
#include <stdint.h>
+#include <drivers/io/io_storage.h>
/* Generic IO entity structure,representing an accessible IO construct on the
* device, such as a file */
diff --git a/include/drivers/io/io_storage.h b/include/drivers/io/io_storage.h
index c496d48..ec6db3f 100644
--- a/include/drivers/io/io_storage.h
+++ b/include/drivers/io/io_storage.h
@@ -10,8 +10,8 @@
#include <errno.h>
#include <stdint.h>
#include <stdio.h> /* For ssize_t */
-#include <uuid.h>
+#include <tools_share/uuid.h>
/* Device type which can be used to enable policy decisions about which device
* to access */
diff --git a/include/drivers/marvell/ccu.h b/include/drivers/marvell/ccu.h
index 2757765..546d9f1 100644
--- a/include/drivers/marvell/ccu.h
+++ b/include/drivers/marvell/ccu.h
@@ -11,7 +11,7 @@
#define CCU_H
#ifndef __ASSEMBLY__
-#include <addr_map.h>
+#include <drivers/marvell/addr_map.h>
#endif
/* CCU registers definitions */
diff --git a/include/drivers/marvell/gwin.h b/include/drivers/marvell/gwin.h
index 6b7f175..1b874a7 100644
--- a/include/drivers/marvell/gwin.h
+++ b/include/drivers/marvell/gwin.h
@@ -10,7 +10,7 @@
#ifndef GWIN_H
#define GWIN_H
-#include <addr_map.h>
+#include <drivers/marvell/addr_map.h>
int init_gwin(int ap_index);
void gwin_temp_win_insert(int ap_index, struct addr_map_win *win, int size);
diff --git a/include/drivers/marvell/io_win.h b/include/drivers/marvell/io_win.h
index 45e8666..7438d6b 100644
--- a/include/drivers/marvell/io_win.h
+++ b/include/drivers/marvell/io_win.h
@@ -10,7 +10,7 @@
#ifndef IO_WIN_H
#define IO_WIN_H
-#include <addr_map.h>
+#include <drivers/marvell/addr_map.h>
int init_io_win(int ap_index);
void iow_temp_win_insert(int ap_index, struct addr_map_win *win, int size);
diff --git a/include/drivers/marvell/iob.h b/include/drivers/marvell/iob.h
index ccbdf96..9b5e515 100644
--- a/include/drivers/marvell/iob.h
+++ b/include/drivers/marvell/iob.h
@@ -10,7 +10,7 @@
#ifndef IOB_H
#define IOB_H
-#include <addr_map.h>
+#include <drivers/marvell/addr_map.h>
enum target_ids_iob {
INTERNAL_TID = 0x0,
diff --git a/include/drivers/marvell/mochi/cp110_setup.h b/include/drivers/marvell/mochi/cp110_setup.h
index 18d9f18..3686257 100644
--- a/include/drivers/marvell/mochi/cp110_setup.h
+++ b/include/drivers/marvell/mochi/cp110_setup.h
@@ -10,7 +10,8 @@
#ifndef CP110_SETUP_H
#define CP110_SETUP_H
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include <mvebu_def.h>
#define MVEBU_DEVICE_ID_REG (MVEBU_CP_DFX_OFFSET + 0x40)
diff --git a/include/drivers/marvell/uart/a3700_console.h b/include/drivers/marvell/uart/a3700_console.h
index 01335a2..5511d96 100644
--- a/include/drivers/marvell/uart/a3700_console.h
+++ b/include/drivers/marvell/uart/a3700_console.h
@@ -8,7 +8,7 @@
#ifndef A3700_CONSOLE_H
#define A3700_CONSOLE_H
-#include <console.h>
+#include <drivers/console.h>
/* MVEBU UART Registers */
#define UART_RX_REG 0x00
diff --git a/include/drivers/meson/meson_console.h b/include/drivers/meson/meson_console.h
index 759571d..5da1e3f 100644
--- a/include/drivers/meson/meson_console.h
+++ b/include/drivers/meson/meson_console.h
@@ -7,7 +7,7 @@
#ifndef MESON_CONSOLE_H
#define MESON_CONSOLE_H
-#include <console.h>
+#include <drivers/console.h>
#define CONSOLE_T_MESON_BASE CONSOLE_T_DRVDATA
diff --git a/include/drivers/mmc.h b/include/drivers/mmc.h
index a62928b..2aaa28d 100644
--- a/include/drivers/mmc.h
+++ b/include/drivers/mmc.h
@@ -8,7 +8,8 @@
#define MMC_H
#include <stdint.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
#define MMC_BLOCK_SIZE U(512)
#define MMC_BLOCK_MASK (MMC_BLOCK_SIZE - U(1))
diff --git a/include/drivers/partition/gpt.h b/include/drivers/partition/gpt.h
index 7984e4d..3ae160f 100644
--- a/include/drivers/partition/gpt.h
+++ b/include/drivers/partition/gpt.h
@@ -7,7 +7,7 @@
#ifndef GPT_H
#define GPT_H
-#include <partition.h>
+#include <drivers/partition/partition.h>
#define PARTITION_TYPE_GPT 0xee
#define GPT_HEADER_OFFSET PARTITION_BLOCK_SIZE
diff --git a/include/drivers/partition/partition.h b/include/drivers/partition/partition.h
index 2aeaace..d94c782 100644
--- a/include/drivers/partition/partition.h
+++ b/include/drivers/partition/partition.h
@@ -7,9 +7,10 @@
#ifndef PARTITION_H
#define PARTITION_H
-#include <cassert.h>
#include <stdint.h>
+#include <lib/cassert.h>
+
#if !PLAT_PARTITION_MAX_ENTRIES
# define PLAT_PARTITION_MAX_ENTRIES 128
#endif /* PLAT_PARTITION_MAX_ENTRIES */
diff --git a/include/drivers/st/io_mmc.h b/include/drivers/st/io_mmc.h
index de71e7d..b35b4b5 100644
--- a/include/drivers/st/io_mmc.h
+++ b/include/drivers/st/io_mmc.h
@@ -7,7 +7,7 @@
#ifndef IO_MMC_H
#define IO_MMC_H
-#include <io_driver.h>
+#include <drivers/io/io_driver.h>
int register_io_dev_mmc(const io_dev_connector_t **dev_con);
diff --git a/include/drivers/st/io_stm32image.h b/include/drivers/st/io_stm32image.h
index b668219..6806055 100644
--- a/include/drivers/st/io_stm32image.h
+++ b/include/drivers/st/io_stm32image.h
@@ -7,8 +7,8 @@
#ifndef IO_STM32IMAGE_H
#define IO_STM32IMAGE_H
-#include <io_driver.h>
-#include <partition.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/partition/partition.h>
#define MAX_LBA_SIZE 512
#define MAX_PART_NAME_SIZE (EFI_NAMELEN + 1)
diff --git a/include/drivers/st/stm32_console.h b/include/drivers/st/stm32_console.h
index 57e6d74..b303768 100644
--- a/include/drivers/st/stm32_console.h
+++ b/include/drivers/st/stm32_console.h
@@ -7,7 +7,7 @@
#ifndef STM32_CONSOLE_H
#define STM32_CONSOLE_H
-#include <console.h>
+#include <drivers/console.h>
#define CONSOLE_T_STM32_BASE CONSOLE_T_DRVDATA
diff --git a/include/drivers/st/stm32_gpio.h b/include/drivers/st/stm32_gpio.h
index 938922b..acd95ec 100644
--- a/include/drivers/st/stm32_gpio.h
+++ b/include/drivers/st/stm32_gpio.h
@@ -7,7 +7,7 @@
#ifndef STM32_GPIO_H
#define STM32_GPIO_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
#define STM32_GPIOA_BANK U(0x50002000)
#define STM32_GPIOZ_BANK U(0x54004000)
diff --git a/include/drivers/st/stm32_i2c.h b/include/drivers/st/stm32_i2c.h
index 4760c00..de2ca59 100644
--- a/include/drivers/st/stm32_i2c.h
+++ b/include/drivers/st/stm32_i2c.h
@@ -8,7 +8,8 @@
#define STM32_I2C_H
#include <stdint.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/* Bit definition for I2C_CR1 register */
#define I2C_CR1_PE BIT(0)
diff --git a/include/drivers/st/stm32_sdmmc2.h b/include/drivers/st/stm32_sdmmc2.h
index b172659..aa9472c 100644
--- a/include/drivers/st/stm32_sdmmc2.h
+++ b/include/drivers/st/stm32_sdmmc2.h
@@ -7,9 +7,10 @@
#ifndef STM32_SDMMC2_H
#define STM32_SDMMC2_H
-#include <mmc.h>
#include <stdbool.h>
+#include <drivers/mmc.h>
+
struct stm32_sdmmc2_params {
uintptr_t reg_base;
unsigned int clk_rate;
diff --git a/include/drivers/st/stm32_uart_regs.h b/include/drivers/st/stm32_uart_regs.h
index e78d3d4..14b296c 100644
--- a/include/drivers/st/stm32_uart_regs.h
+++ b/include/drivers/st/stm32_uart_regs.h
@@ -7,7 +7,7 @@
#ifndef STM32_UART_REGS_H
#define STM32_UART_REGS_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
#define USART_CR1 U(0x00)
#define USART_CR2 U(0x04)
diff --git a/include/drivers/st/stm32mp1_clk.h b/include/drivers/st/stm32mp1_clk.h
index c895517..5594e23 100644
--- a/include/drivers/st/stm32mp1_clk.h
+++ b/include/drivers/st/stm32mp1_clk.h
@@ -7,9 +7,10 @@
#ifndef STM32MP1_CLK_H
#define STM32MP1_CLK_H
-#include <arch_helpers.h>
#include <stdbool.h>
+#include <arch_helpers.h>
+
int stm32mp1_clk_probe(void);
int stm32mp1_clk_init(void);
bool stm32mp1_clk_is_enabled(unsigned long id);
diff --git a/include/drivers/st/stm32mp1_clkfunc.h b/include/drivers/st/stm32mp1_clkfunc.h
index 2467af9..106dcae 100644
--- a/include/drivers/st/stm32mp1_clkfunc.h
+++ b/include/drivers/st/stm32mp1_clkfunc.h
@@ -7,9 +7,10 @@
#ifndef STM32MP1_CLKFUNC_H
#define STM32MP1_CLKFUNC_H
-#include <libfdt.h>
#include <stdbool.h>
+#include <libfdt.h>
+
enum stm32mp_osc_id {
_HSI,
_HSE,
diff --git a/include/drivers/st/stm32mp1_ddr_regs.h b/include/drivers/st/stm32mp1_ddr_regs.h
index 288e072..bfcd5e2 100644
--- a/include/drivers/st/stm32mp1_ddr_regs.h
+++ b/include/drivers/st/stm32mp1_ddr_regs.h
@@ -7,7 +7,7 @@
#ifndef STM32MP1_DDR_REGS_H
#define STM32MP1_DDR_REGS_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* DDR3/LPDDR2/LPDDR3 Controller (DDRCTRL) registers */
struct stm32mp1_ddrctl {
diff --git a/include/drivers/st/stm32mp1_pmic.h b/include/drivers/st/stm32mp1_pmic.h
index cc80b25..75f8e61 100644
--- a/include/drivers/st/stm32mp1_pmic.h
+++ b/include/drivers/st/stm32mp1_pmic.h
@@ -9,6 +9,8 @@
#include <stdbool.h>
+#include <platform_def.h>
+
bool dt_check_pmic(void);
int dt_pmic_enable_boot_on_regulators(void);
void initialize_pmic_i2c(void);
diff --git a/include/drivers/st/stm32mp1_pwr.h b/include/drivers/st/stm32mp1_pwr.h
index b34536e..e17df44 100644
--- a/include/drivers/st/stm32mp1_pwr.h
+++ b/include/drivers/st/stm32mp1_pwr.h
@@ -7,7 +7,7 @@
#ifndef STM32MP1_PWR_H
#define STM32MP1_PWR_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
#define PWR_CR1 U(0x00)
#define PWR_CR2 U(0x08)
diff --git a/include/drivers/st/stm32mp1_rcc.h b/include/drivers/st/stm32mp1_rcc.h
index 87f4d7f..fd406c5 100644
--- a/include/drivers/st/stm32mp1_rcc.h
+++ b/include/drivers/st/stm32mp1_rcc.h
@@ -7,7 +7,7 @@
#ifndef STM32MP1_RCC_H
#define STM32MP1_RCC_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
#define RCC_TZCR U(0x00)
#define RCC_OCENSETR U(0x0C)
diff --git a/include/drivers/st/stpmu1.h b/include/drivers/st/stpmu1.h
index 4bbcebb..e75d9a6 100644
--- a/include/drivers/st/stpmu1.h
+++ b/include/drivers/st/stpmu1.h
@@ -7,8 +7,8 @@
#ifndef STPMU1_H
#define STPMU1_H
-#include <stm32_i2c.h>
-#include <utils_def.h>
+#include <drivers/st/stm32_i2c.h>
+#include <lib/utils_def.h>
#define TURN_ON_REG 0x1U
#define TURN_OFF_REG 0x2U
diff --git a/include/drivers/synopsys/dw_mmc.h b/include/drivers/synopsys/dw_mmc.h
index 533a876..7031e0f 100644
--- a/include/drivers/synopsys/dw_mmc.h
+++ b/include/drivers/synopsys/dw_mmc.h
@@ -7,7 +7,7 @@
#ifndef DW_MMC_H
#define DW_MMC_H
-#include <mmc.h>
+#include <drivers/mmc.h>
typedef struct dw_mmc_params {
uintptr_t reg_base;
diff --git a/include/drivers/ti/uart/uart_16550.h b/include/drivers/ti/uart/uart_16550.h
index ad80c57..92b1ea8 100644
--- a/include/drivers/ti/uart/uart_16550.h
+++ b/include/drivers/ti/uart/uart_16550.h
@@ -7,7 +7,7 @@
#ifndef UART_16550_H
#define UART_16550_H
-#include <console.h>
+#include <drivers/console.h>
/* UART16550 Registers */
#define UARTTX 0x0
diff --git a/include/drivers/ufs.h b/include/drivers/ufs.h
index 414649b..a10cd80 100644
--- a/include/drivers/ufs.h
+++ b/include/drivers/ufs.h
@@ -7,7 +7,7 @@
#ifndef UFS_H
#define UFS_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* register map of UFSHCI */
/* Controller Capabilities */
diff --git a/include/lib/bakery_lock.h b/include/lib/bakery_lock.h
index 2d1612e..a2f540c 100644
--- a/include/lib/bakery_lock.h
+++ b/include/lib/bakery_lock.h
@@ -15,7 +15,8 @@
#include <cdefs.h>
#include <stdbool.h>
#include <stdint.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/*****************************************************************************
* Internal helpers used by the bakery lock implementation.
diff --git a/include/lib/cpus/aarch32/cortex_a57.h b/include/lib/cpus/aarch32/cortex_a57.h
index 6f60c11..2ac1e17 100644
--- a/include/lib/cpus/aarch32/cortex_a57.h
+++ b/include/lib/cpus/aarch32/cortex_a57.h
@@ -7,7 +7,7 @@
#ifndef CORTEX_A57_H
#define CORTEX_A57_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* Cortex-A57 midr for revision 0 */
#define CORTEX_A57_MIDR 0x410FD070
diff --git a/include/lib/cpus/aarch32/cortex_a72.h b/include/lib/cpus/aarch32/cortex_a72.h
index f45865a..95402d0 100644
--- a/include/lib/cpus/aarch32/cortex_a72.h
+++ b/include/lib/cpus/aarch32/cortex_a72.h
@@ -6,7 +6,8 @@
#ifndef CORTEX_A72_H
#define CORTEX_A72_H
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/* Cortex-A72 midr for revision 0 */
#define CORTEX_A72_MIDR 0x410FD080
diff --git a/include/lib/cpus/aarch32/cpu_macros.S b/include/lib/cpus/aarch32/cpu_macros.S
index 1c0da0f..a5ae6a4 100644
--- a/include/lib/cpus/aarch32/cpu_macros.S
+++ b/include/lib/cpus/aarch32/cpu_macros.S
@@ -7,7 +7,7 @@
#define CPU_MACROS_S
#include <arch.h>
-#include <errata_report.h>
+#include <lib/cpus/errata_report.h>
#if defined(IMAGE_BL1) || defined(IMAGE_BL32) || (defined(IMAGE_BL2) && BL2_AT_EL3)
#define IMAGE_AT_EL3
diff --git a/include/lib/cpus/aarch64/cortex_a57.h b/include/lib/cpus/aarch64/cortex_a57.h
index 71d07db..5b6c9dd 100644
--- a/include/lib/cpus/aarch64/cortex_a57.h
+++ b/include/lib/cpus/aarch64/cortex_a57.h
@@ -6,7 +6,8 @@
#ifndef CORTEX_A57_H
#define CORTEX_A57_H
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/* Cortex-A57 midr for revision 0 */
#define CORTEX_A57_MIDR U(0x410FD070)
diff --git a/include/lib/cpus/aarch64/cortex_a72.h b/include/lib/cpus/aarch64/cortex_a72.h
index 4eafc11..60b6c61 100644
--- a/include/lib/cpus/aarch64/cortex_a72.h
+++ b/include/lib/cpus/aarch64/cortex_a72.h
@@ -6,7 +6,8 @@
#ifndef CORTEX_A72_H
#define CORTEX_A72_H
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/* Cortex-A72 midr for revision 0 */
#define CORTEX_A72_MIDR 0x410FD080
diff --git a/include/lib/cpus/aarch64/cortex_a75.h b/include/lib/cpus/aarch64/cortex_a75.h
index f68f98f..fabc1af 100644
--- a/include/lib/cpus/aarch64/cortex_a75.h
+++ b/include/lib/cpus/aarch64/cortex_a75.h
@@ -7,7 +7,7 @@
#ifndef CORTEX_A75_H
#define CORTEX_A75_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* Cortex-A75 MIDR */
#define CORTEX_A75_MIDR U(0x410fd0a0)
diff --git a/include/lib/cpus/aarch64/cortex_ares.h b/include/lib/cpus/aarch64/cortex_ares.h
index 4f3e812..cfc36e4 100644
--- a/include/lib/cpus/aarch64/cortex_ares.h
+++ b/include/lib/cpus/aarch64/cortex_ares.h
@@ -7,7 +7,7 @@
#ifndef CORTEX_ARES_H
#define CORTEX_ARES_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* Cortex-ARES MIDR for revision 0 */
#define CORTEX_ARES_MIDR U(0x410fd0c0)
diff --git a/include/lib/cpus/aarch64/cpu_macros.S b/include/lib/cpus/aarch64/cpu_macros.S
index 2875700..b907668 100644
--- a/include/lib/cpus/aarch64/cpu_macros.S
+++ b/include/lib/cpus/aarch64/cpu_macros.S
@@ -7,7 +7,7 @@
#define CPU_MACROS_S
#include <arch.h>
-#include <errata_report.h>
+#include <lib/cpus/errata_report.h>
#define CPU_IMPL_PN_MASK (MIDR_IMPL_MASK << MIDR_IMPL_SHIFT) | \
(MIDR_PN_MASK << MIDR_PN_SHIFT)
diff --git a/include/lib/cpus/aarch64/dsu_def.h b/include/lib/cpus/aarch64/dsu_def.h
index 0e2d93a..aa8b1b1 100644
--- a/include/lib/cpus/aarch64/dsu_def.h
+++ b/include/lib/cpus/aarch64/dsu_def.h
@@ -7,7 +7,7 @@
#ifndef DSU_DEF_H
#define DSU_DEF_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/********************************************************************
* DSU control registers definitions *
diff --git a/include/lib/cpus/errata_report.h b/include/lib/cpus/errata_report.h
index c97d4c2..17b2c30 100644
--- a/include/lib/cpus/errata_report.h
+++ b/include/lib/cpus/errata_report.h
@@ -11,8 +11,8 @@
#include <arch.h>
#include <arch_helpers.h>
-#include <spinlock.h>
-#include <utils_def.h>
+#include <lib/spinlock.h>
+#include <lib/utils_def.h>
#if DEBUG
void print_errata_status(void);
diff --git a/include/lib/el3_runtime/aarch32/context.h b/include/lib/el3_runtime/aarch32/context.h
index 1ea19ca..86ff53a 100644
--- a/include/lib/el3_runtime/aarch32/context.h
+++ b/include/lib/el3_runtime/aarch32/context.h
@@ -7,7 +7,7 @@
#ifndef CONTEXT_H
#define CONTEXT_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* Constants that allow assembler code to access members of and the 'regs'
@@ -26,9 +26,10 @@
#ifndef __ASSEMBLY__
-#include <cassert.h>
#include <stdint.h>
+#include <lib/cassert.h>
+
/*
* Common constants to help define the 'cpu_context' structure and its
* members below.
diff --git a/include/lib/el3_runtime/aarch64/context.h b/include/lib/el3_runtime/aarch64/context.h
index 8c5f4c6..70c50aa 100644
--- a/include/lib/el3_runtime/aarch64/context.h
+++ b/include/lib/el3_runtime/aarch64/context.h
@@ -7,7 +7,7 @@
#ifndef CONTEXT_H
#define CONTEXT_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* Constants that allow assembler code to access members of and the 'gp_regs'
@@ -180,10 +180,12 @@
#ifndef __ASSEMBLY__
-#include <cassert.h>
-#include <platform_def.h> /* for CACHE_WRITEBACK_GRANULE */
#include <stdint.h>
+#include <platform_def.h> /* for CACHE_WRITEBACK_GRANULE */
+
+#include <lib/cassert.h>
+
/*
* Common constants to help define the 'cpu_context' structure and its
* members below.
diff --git a/include/lib/el3_runtime/context_mgmt.h b/include/lib/el3_runtime/context_mgmt.h
index 149ac3f..f23f9cd 100644
--- a/include/lib/el3_runtime/context_mgmt.h
+++ b/include/lib/el3_runtime/context_mgmt.h
@@ -7,11 +7,12 @@
#ifndef CONTEXT_MGMT_H
#define CONTEXT_MGMT_H
-#include <arch.h>
#include <assert.h>
#include <context.h>
#include <stdint.h>
+#include <arch.h>
+
/*******************************************************************************
* Forward declarations
******************************************************************************/
diff --git a/include/lib/el3_runtime/cpu_data.h b/include/lib/el3_runtime/cpu_data.h
index 561f8be..9e1d7f1 100644
--- a/include/lib/el3_runtime/cpu_data.h
+++ b/include/lib/el3_runtime/cpu_data.h
@@ -7,9 +7,10 @@
#ifndef CPU_DATA_H
#define CPU_DATA_H
-#include <ehf.h>
#include <platform_def.h> /* CACHE_WRITEBACK_GRANULE required */
+#include <bl31/ehf.h>
+
#ifdef AARCH32
#if CRASH_REPORTING
@@ -51,9 +52,9 @@
#ifndef __ASSEMBLY__
#include <arch_helpers.h>
-#include <cassert.h>
+#include <lib/cassert.h>
+#include <lib/psci/psci.h>
#include <platform_def.h>
-#include <psci.h>
#include <stdint.h>
/* Offsets for the cpu_data structure */
diff --git a/include/lib/el3_runtime/pubsub.h b/include/lib/el3_runtime/pubsub.h
index 930952f..eb91286 100644
--- a/include/lib/el3_runtime/pubsub.h
+++ b/include/lib/el3_runtime/pubsub.h
@@ -30,11 +30,12 @@
/* For the compiler ... */
-#include <arch_helpers.h>
#include <assert.h>
#include <cdefs.h>
#include <stddef.h>
+#include <arch_helpers.h>
+
#define __pubsub_section(event) __section("__pubsub_" #event)
/*
diff --git a/include/lib/el3_runtime/pubsub_events.h b/include/lib/el3_runtime/pubsub_events.h
index 64b3f63..8e4a87a 100644
--- a/include/lib/el3_runtime/pubsub_events.h
+++ b/include/lib/el3_runtime/pubsub_events.h
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <pubsub.h>
+#include <lib/el3_runtime/pubsub.h>
/*
* This file defines a list of pubsub events, declared using
diff --git a/include/lib/extensions/amu.h b/include/lib/extensions/amu.h
index 1836fe5..99ecfcc 100644
--- a/include/lib/extensions/amu.h
+++ b/include/lib/extensions/amu.h
@@ -7,11 +7,13 @@
#ifndef AMU_H
#define AMU_H
-#include <cassert.h>
-#include <platform_def.h>
#include <stdbool.h>
#include <stdint.h>
-#include <utils_def.h>
+
+#include <platform_def.h>
+
+#include <lib/cassert.h>
+#include <lib/utils_def.h>
/* All group 0 counters */
#define AMU_GROUP0_COUNTERS_MASK U(0xf)
diff --git a/include/lib/extensions/ras.h b/include/lib/extensions/ras.h
index 62fd63f..9f6b290 100644
--- a/include/lib/extensions/ras.h
+++ b/include/lib/extensions/ras.h
@@ -71,7 +71,8 @@
#ifndef __ASSEMBLY__
#include <assert.h>
-#include <ras_arch.h>
+
+#include <lib/extensions/ras_arch.h>
struct err_record_info;
diff --git a/include/lib/extensions/ras_arch.h b/include/lib/extensions/ras_arch.h
index e6cd736..e9375a3 100644
--- a/include/lib/extensions/ras_arch.h
+++ b/include/lib/extensions/ras_arch.h
@@ -184,7 +184,7 @@
#include <arch_helpers.h>
#include <assert.h>
#include <context.h>
-#include <mmio.h>
+#include <lib/mmio.h>
#include <stdint.h>
/*
diff --git a/include/lib/libc/assert.h b/include/lib/libc/assert.h
index 2cca6a0..d04f9dc 100644
--- a/include/lib/libc/assert.h
+++ b/include/lib/libc/assert.h
@@ -8,9 +8,11 @@
#define ASSERT_H
#include <cdefs.h>
-#include <debug.h>
+
#include <platform_def.h>
+#include <common/debug.h>
+
#ifndef PLAT_LOG_LEVEL_ASSERT
#define PLAT_LOG_LEVEL_ASSERT LOG_LEVEL
#endif
diff --git a/include/lib/object_pool.h b/include/lib/object_pool.h
index 7d40b41..0f85331 100644
--- a/include/lib/object_pool.h
+++ b/include/lib/object_pool.h
@@ -7,9 +7,10 @@
#ifndef OBJECT_POOL_H
#define OBJECT_POOL_H
-#include <debug.h>
#include <stdlib.h>
-#include <utils_def.h>
+
+#include <common/debug.h>
+#include <lib/utils_def.h>
/*
* Pool of statically allocated objects.
diff --git a/include/lib/optee_utils.h b/include/lib/optee_utils.h
index b13c450..6067caf 100644
--- a/include/lib/optee_utils.h
+++ b/include/lib/optee_utils.h
@@ -3,10 +3,11 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#ifndef OPTEE_UTILS_H
#define OPTEE_UTILS_H
-#include <bl_common.h>
+#include <common/bl_common.h>
int parse_optee_header(entry_point_info_t *header_ep,
image_info_t *pager_image_info,
diff --git a/include/lib/pmf/pmf.h b/include/lib/pmf/pmf.h
index 18ef0a5..df7c9ff 100644
--- a/include/lib/pmf/pmf.h
+++ b/include/lib/pmf/pmf.h
@@ -7,9 +7,9 @@
#ifndef PMF_H
#define PMF_H
-#include <cassert.h>
-#include <pmf_helpers.h>
-#include <utils_def.h>
+#include <lib/cassert.h>
+#include <lib/pmf/pmf_helpers.h>
+#include <lib/utils_def.h>
/*
* Constants used for/by PMF services.
diff --git a/include/lib/pmf/pmf_helpers.h b/include/lib/pmf/pmf_helpers.h
index c535b22..e6798a7 100644
--- a/include/lib/pmf/pmf_helpers.h
+++ b/include/lib/pmf/pmf_helpers.h
@@ -7,13 +7,14 @@
#ifndef PMF_HELPERS_H
#define PMF_HELPERS_H
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <platform.h>
#include <stddef.h>
#include <stdint.h>
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <plat/common/platform.h>
+
/*
* Prototype for PMF service functions.
*/
diff --git a/include/lib/psci/psci.h b/include/lib/psci/psci.h
index b7febc3..fe279d4 100644
--- a/include/lib/psci/psci.h
+++ b/include/lib/psci/psci.h
@@ -7,11 +7,12 @@
#ifndef PSCI_H
#define PSCI_H
-#include <bakery_lock.h>
-#include <bl_common.h>
#include <platform_def.h> /* for PLAT_NUM_PWR_DOMAINS */
-#include <psci_lib.h> /* To maintain compatibility for SPDs */
-#include <utils_def.h>
+
+#include <common/bl_common.h>
+#include <lib/bakery_lock.h>
+#include <lib/psci/psci_lib.h> /* To maintain compatibility for SPDs */
+#include <lib/utils_def.h>
/*******************************************************************************
* Number of power domains whose state this PSCI implementation can track
diff --git a/include/lib/psci/psci_lib.h b/include/lib/psci/psci_lib.h
index 134cad9..53d7711 100644
--- a/include/lib/psci/psci_lib.h
+++ b/include/lib/psci/psci_lib.h
@@ -7,9 +7,10 @@
#ifndef PSCI_LIB_H
#define PSCI_LIB_H
-#include <ep_info.h>
+#include <common/ep_info.h>
#ifndef __ASSEMBLY__
+
#include <cdefs.h>
#include <stdint.h>
diff --git a/include/lib/runtime_instr.h b/include/lib/runtime_instr.h
index cb64839..f5a3f13 100644
--- a/include/lib/runtime_instr.h
+++ b/include/lib/runtime_instr.h
@@ -7,7 +7,7 @@
#ifndef RUNTIME_INSTR_H
#define RUNTIME_INSTR_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
#define RT_INSTR_ENTER_PSCI U(0)
#define RT_INSTR_EXIT_PSCI U(1)
diff --git a/include/lib/smccc.h b/include/lib/smccc.h
index 6ee8aa0..b10c52c 100644
--- a/include/lib/smccc.h
+++ b/include/lib/smccc.h
@@ -7,7 +7,7 @@
#ifndef SMCCC_H
#define SMCCC_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
#define SMCCC_VERSION_MAJOR_SHIFT U(16)
#define SMCCC_VERSION_MAJOR_MASK U(0x7FFF)
@@ -21,10 +21,10 @@
#if SMCCC_MAJOR_VERSION == 1
# define SMCCC_MINOR_VERSION U(1)
-# include <smccc_v1.h>
+# include <lib/smccc_v1.h>
#elif SMCCC_MAJOR_VERSION == 2
# define SMCCC_MINOR_VERSION U(0)
-# include <smccc_v2.h>
+# include <lib/smccc_v2.h>
#else
# error "Unsupported version of SMCCC."
#endif
@@ -35,9 +35,10 @@
#ifndef __ASSEMBLY__
-#include <cassert.h>
#include <stdint.h>
+#include <lib/cassert.h>
+
#define is_caller_non_secure(_f) (((_f) & SMC_FROM_NON_SECURE) != U(0))
#define is_caller_secure(_f) (!is_caller_non_secure(_f))
diff --git a/include/lib/utils.h b/include/lib/utils.h
index b6ab26e..6748454 100644
--- a/include/lib/utils.h
+++ b/include/lib/utils.h
@@ -13,6 +13,7 @@
*/
#if !(defined(__LINKER__) || defined(__ASSEMBLY__))
+#include <stddef.h>
#include <stdint.h>
typedef struct mem_region {
diff --git a/include/lib/xlat_tables/aarch32/xlat_tables_aarch32.h b/include/lib/xlat_tables/aarch32/xlat_tables_aarch32.h
index 37f3b53..a333d1e 100644
--- a/include/lib/xlat_tables/aarch32/xlat_tables_aarch32.h
+++ b/include/lib/xlat_tables/aarch32/xlat_tables_aarch32.h
@@ -8,8 +8,8 @@
#define XLAT_TABLES_AARCH32_H
#include <arch.h>
-#include <utils_def.h>
-#include <xlat_tables_defs.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
#if !defined(PAGE_SIZE)
#error "PAGE_SIZE is not defined."
diff --git a/include/lib/xlat_tables/aarch64/xlat_tables_aarch64.h b/include/lib/xlat_tables/aarch64/xlat_tables_aarch64.h
index 91ca8e4..cc5624c 100644
--- a/include/lib/xlat_tables/aarch64/xlat_tables_aarch64.h
+++ b/include/lib/xlat_tables/aarch64/xlat_tables_aarch64.h
@@ -8,8 +8,8 @@
#define XLAT_TABLES_AARCH64_H
#include <arch.h>
-#include <utils_def.h>
-#include <xlat_tables_defs.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
#if !defined(PAGE_SIZE)
#error "PAGE_SIZE is not defined."
diff --git a/include/lib/xlat_tables/xlat_tables.h b/include/lib/xlat_tables/xlat_tables.h
index 050679d..9e2543f 100644
--- a/include/lib/xlat_tables/xlat_tables.h
+++ b/include/lib/xlat_tables/xlat_tables.h
@@ -7,12 +7,13 @@
#ifndef XLAT_TABLES_H
#define XLAT_TABLES_H
-#include <xlat_tables_defs.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
#ifndef __ASSEMBLY__
#include <stddef.h>
#include <stdint.h>
-#include <xlat_mmu_helpers.h>
+
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
/* Helper macro to define entries for mmap_region_t. It creates
* identity mappings for each region.
diff --git a/include/lib/xlat_tables/xlat_tables_compat.h b/include/lib/xlat_tables/xlat_tables_compat.h
index 4650a8c..90768db 100644
--- a/include/lib/xlat_tables/xlat_tables_compat.h
+++ b/include/lib/xlat_tables/xlat_tables_compat.h
@@ -5,7 +5,7 @@
*/
#if XLAT_TABLES_LIB_V2
-#include <xlat_tables_v2.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
#else
-#include <xlat_tables.h>
+#include <lib/xlat_tables/xlat_tables.h>
#endif
diff --git a/include/lib/xlat_tables/xlat_tables_defs.h b/include/lib/xlat_tables/xlat_tables_defs.h
index 09baae9..6d0fb78 100644
--- a/include/lib/xlat_tables/xlat_tables_defs.h
+++ b/include/lib/xlat_tables/xlat_tables_defs.h
@@ -8,8 +8,8 @@
#define XLAT_TABLES_DEFS_H
#include <arch.h>
-#include <utils_def.h>
-#include <xlat_mmu_helpers.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
/* Miscellaneous MMU related constants */
#define NUM_2MB_IN_GB (U(1) << 9)
diff --git a/include/lib/xlat_tables/xlat_tables_v2.h b/include/lib/xlat_tables/xlat_tables_v2.h
index 5c4edc3..5551426 100644
--- a/include/lib/xlat_tables/xlat_tables_v2.h
+++ b/include/lib/xlat_tables/xlat_tables_v2.h
@@ -7,13 +7,14 @@
#ifndef XLAT_TABLES_V2_H
#define XLAT_TABLES_V2_H
-#include <xlat_tables_defs.h>
-#include <xlat_tables_v2_helpers.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <lib/xlat_tables/xlat_tables_v2_helpers.h>
#ifndef __ASSEMBLY__
#include <stddef.h>
#include <stdint.h>
-#include <xlat_mmu_helpers.h>
+
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
/*
* Default granularity size for an mmap_region_t.
diff --git a/include/lib/xlat_tables/xlat_tables_v2_helpers.h b/include/lib/xlat_tables/xlat_tables_v2_helpers.h
index fa89958..ce5cf82 100644
--- a/include/lib/xlat_tables/xlat_tables_v2_helpers.h
+++ b/include/lib/xlat_tables/xlat_tables_v2_helpers.h
@@ -18,12 +18,14 @@
#ifndef __ASSEMBLY__
-#include <cassert.h>
-#include <platform_def.h>
#include <stdbool.h>
#include <stddef.h>
-#include <xlat_tables_arch.h>
-#include <xlat_tables_defs.h>
+
+#include <platform_def.h>
+
+#include <lib/cassert.h>
+#include <lib/xlat_tables/xlat_tables_arch.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
/* Forward declaration */
struct mmap_region;
diff --git a/include/plat/arm/board/common/board_css_def.h b/include/plat/arm/board/common/board_css_def.h
index 29211be..6cca389 100644
--- a/include/plat/arm/board/common/board_css_def.h
+++ b/include/plat/arm/board/common/board_css_def.h
@@ -7,9 +7,10 @@
#ifndef BOARD_CSS_DEF_H
#define BOARD_CSS_DEF_H
-#include <common_def.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
+
#include <soc_css_def.h>
-#include <utils_def.h>
#include <v2m_def.h>
/*
@@ -31,7 +32,7 @@
#ifndef __ASSEMBLY__
-#include <mmio.h>
+#include <lib/mmio.h>
#define BOARD_CSS_GET_PLAT_TYPE(addr) \
((mmio_read_32(addr) & BOARD_CSS_PLAT_ID_REG_ID_MASK) \
diff --git a/include/plat/arm/board/common/v2m_def.h b/include/plat/arm/board/common/v2m_def.h
index ed57fc9..c5de407 100644
--- a/include/plat/arm/board/common/v2m_def.h
+++ b/include/plat/arm/board/common/v2m_def.h
@@ -6,7 +6,7 @@
#ifndef V2M_DEF_H
#define V2M_DEF_H
-#include <xlat_tables_compat.h>
+#include <lib/xlat_tables/xlat_tables_compat.h>
/* V2M motherboard system registers & offsets */
#define V2M_SYSREGS_BASE UL(0x1c010000)
diff --git a/include/plat/arm/common/aarch64/arm_macros.S b/include/plat/arm/common/aarch64/arm_macros.S
index c2ba7db..0bd0daf 100644
--- a/include/plat/arm/common/aarch64/arm_macros.S
+++ b/include/plat/arm/common/aarch64/arm_macros.S
@@ -6,9 +6,9 @@
#ifndef ARM_MACROS_S
#define ARM_MACROS_S
-#include <gic_common.h>
-#include <gicv2.h>
-#include <gicv3.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/gicv3.h>
#include <platform_def.h>
.section .rodata.gic_reg_name, "aS"
diff --git a/include/plat/arm/common/aarch64/cci_macros.S b/include/plat/arm/common/aarch64/cci_macros.S
index 069dc85..07f7cd3 100644
--- a/include/plat/arm/common/aarch64/cci_macros.S
+++ b/include/plat/arm/common/aarch64/cci_macros.S
@@ -6,7 +6,7 @@
#ifndef CCI_MACROS_S
#define CCI_MACROS_S
-#include <cci.h>
+#include <drivers/arm/cci.h>
#include <platform_def.h>
.section .rodata.cci_reg_name, "aS"
diff --git a/include/plat/arm/common/arm_config.h b/include/plat/arm/common/arm_config.h
index 4dda350..c2b28df 100644
--- a/include/plat/arm/common/arm_config.h
+++ b/include/plat/arm/common/arm_config.h
@@ -7,7 +7,8 @@
#define ARM_CONFIG_H
#include <stdint.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/* Whether Base memory map is in use */
#define ARM_CONFIG_BASE_MMAP BIT(1)
diff --git a/include/plat/arm/common/arm_def.h b/include/plat/arm/common/arm_def.h
index cbac247..4e9c70a 100644
--- a/include/plat/arm/common/arm_def.h
+++ b/include/plat/arm/common/arm_def.h
@@ -6,15 +6,15 @@
#ifndef ARM_DEF_H
#define ARM_DEF_H
-#include <arch.h>
-#include <common_def.h>
-#include <gic_common.h>
-#include <interrupt_props.h>
#include <platform_def.h>
-#include <tbbr_img_def.h>
-#include <utils_def.h>
-#include <xlat_tables_defs.h>
+#include <arch.h>
+#include <common/interrupt_props.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <drivers/arm/gic_common.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <plat/common/common_def.h>
/******************************************************************************
* Definitions common to all ARM standard platforms
@@ -207,13 +207,11 @@
ARM_DRAM2_BASE, \
ARM_DRAM2_SIZE, \
MT_MEMORY | MT_RW | MT_NS)
-#ifdef SPD_tspd
#define ARM_MAP_TSP_SEC_MEM MAP_REGION_FLAT( \
TSP_SEC_MEM_BASE, \
TSP_SEC_MEM_SIZE, \
MT_MEMORY | MT_RW | MT_SECURE)
-#endif
#if ARM_BL31_IN_DRAM
#define ARM_MAP_BL31_SEC_DRAM MAP_REGION_FLAT( \
@@ -407,12 +405,21 @@
#define BL31_LIMIT (ARM_AP_TZC_DRAM1_BASE + \
PLAT_ARM_MAX_BL31_SIZE)
#elif (RESET_TO_BL31)
+
+# if ENABLE_PIE
/*
- * Put BL31_BASE in the middle of the Trusted SRAM.
+ * Since this is PIE, we can define BL31_BASE to 0x0 since this macro is solely
+ * used for building BL31 and not used for loading BL31.
*/
-#define BL31_BASE (ARM_TRUSTED_SRAM_BASE + \
- (PLAT_ARM_TRUSTED_SRAM_SIZE >> 1))
-#define BL31_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
+# define BL31_BASE 0x0
+# define BL31_LIMIT PLAT_ARM_MAX_BL31_SIZE
+# else
+/* Put BL31_BASE in the middle of the Trusted SRAM.*/
+# define BL31_BASE (ARM_TRUSTED_SRAM_BASE + \
+ (PLAT_ARM_TRUSTED_SRAM_SIZE >> 1))
+# define BL31_LIMIT (ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)
+# endif /* ENABLE_PIE */
+
#else
/* Put BL31 below BL2 in the Trusted SRAM.*/
#define BL31_BASE ((ARM_BL_RAM_BASE + ARM_BL_RAM_SIZE)\
diff --git a/include/plat/arm/common/arm_sip_svc.h b/include/plat/arm/common/arm_sip_svc.h
index 3e25cbc..16573ce 100644
--- a/include/plat/arm/common/arm_sip_svc.h
+++ b/include/plat/arm/common/arm_sip_svc.h
@@ -7,7 +7,7 @@
#ifndef ARM_SIP_SVC_H
#define ARM_SIP_SVC_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* SMC function IDs for SiP Service queries */
diff --git a/include/plat/arm/common/arm_spm_def.h b/include/plat/arm/common/arm_spm_def.h
index bf3cb8f..bdcbc96 100644
--- a/include/plat/arm/common/arm_spm_def.h
+++ b/include/plat/arm/common/arm_spm_def.h
@@ -6,9 +6,10 @@
#ifndef ARM_SPM_DEF_H
#define ARM_SPM_DEF_H
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+
#include <arm_def.h>
-#include <utils_def.h>
-#include <xlat_tables_defs.h>
/*
* Reserve 4 MiB for binaries of Secure Partitions and Resource Description
diff --git a/include/plat/arm/common/arm_tzc_dram.ld.S b/include/plat/arm/common/arm_tzc_dram.ld.S
index df951e1..6dcea0b 100644
--- a/include/plat/arm/common/arm_tzc_dram.ld.S
+++ b/include/plat/arm/common/arm_tzc_dram.ld.S
@@ -3,10 +3,10 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#ifndef ARM_TZC_DRAM_LD_S__
-#define ARM_TZC_DRAM_LD_S__
+#ifndef ARM_TZC_DRAM_LD_S
+#define ARM_TZC_DRAM_LD_S
-#include <xlat_tables_defs.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
MEMORY {
EL3_SEC_DRAM (rw): ORIGIN = ARM_EL3_TZC_DRAM1_BASE, LENGTH = ARM_EL3_TZC_DRAM1_SIZE
@@ -27,4 +27,4 @@
} >EL3_SEC_DRAM
}
-#endif /* ARM_TZC_DRAM_LD_S__ */
+#endif /* ARM_TZC_DRAM_LD_S */
diff --git a/include/plat/arm/common/plat_arm.h b/include/plat/arm/common/plat_arm.h
index 9b45984..6281608 100644
--- a/include/plat/arm/common/plat_arm.h
+++ b/include/plat/arm/common/plat_arm.h
@@ -6,14 +6,15 @@
#ifndef PLAT_ARM_H
#define PLAT_ARM_H
-#include <bakery_lock.h>
-#include <cassert.h>
-#include <cpu_data.h>
#include <stdint.h>
-#include <spinlock.h>
-#include <tzc_common.h>
-#include <utils_def.h>
-#include <xlat_tables_compat.h>
+
+#include <drivers/arm/tzc_common.h>
+#include <lib/bakery_lock.h>
+#include <lib/cassert.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/spinlock.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_compat.h>
/*******************************************************************************
* Forward declarations
diff --git a/include/plat/arm/css/common/css_def.h b/include/plat/arm/css/common/css_def.h
index 4a7d314..6b355a4 100644
--- a/include/plat/arm/css/common/css_def.h
+++ b/include/plat/arm/css/common/css_def.h
@@ -7,10 +7,11 @@
#ifndef CSS_DEF_H
#define CSS_DEF_H
+#include <common/interrupt_props.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/tzc400.h>
+
#include <arm_def.h>
-#include <gic_common.h>
-#include <interrupt_props.h>
-#include <tzc400.h>
/*************************************************************************
* Definitions common to all ARM Compute SubSystems (CSS)
diff --git a/include/plat/arm/css/common/css_pm.h b/include/plat/arm/css/common/css_pm.h
index ff75c69..b82ff47 100644
--- a/include/plat/arm/css/common/css_pm.h
+++ b/include/plat/arm/css/common/css_pm.h
@@ -8,9 +8,10 @@
#define CSS_PM_H
#include <cdefs.h>
-#include <psci.h>
#include <stdint.h>
+#include <lib/psci/psci.h>
+
/* Macros to read the CSS power domain state */
#define CSS_CORE_PWR_STATE(state) (state)->pwr_domain_state[ARM_PWR_LVL0]
#define CSS_CLUSTER_PWR_STATE(state) (state)->pwr_domain_state[ARM_PWR_LVL1]
diff --git a/include/plat/arm/soc/common/soc_css_def.h b/include/plat/arm/soc/common/soc_css_def.h
index 263313a..b4b6ba8 100644
--- a/include/plat/arm/soc/common/soc_css_def.h
+++ b/include/plat/arm/soc/common/soc_css_def.h
@@ -7,9 +7,8 @@
#ifndef SOC_CSS_DEF_H
#define SOC_CSS_DEF_H
-#include <common_def.h>
-#include <utils_def.h>
-
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
/*
* Definitions common to all ARM CSS SoCs
diff --git a/include/plat/common/common_def.h b/include/plat/common/common_def.h
index 66074ac..66c88ba 100644
--- a/include/plat/common/common_def.h
+++ b/include/plat/common/common_def.h
@@ -6,10 +6,11 @@
#ifndef COMMON_DEF_H
#define COMMON_DEF_H
-#include <bl_common.h>
#include <platform_def.h>
-#include <utils_def.h>
-#include <xlat_tables_defs.h>
+
+#include <common/bl_common.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
/******************************************************************************
* Required platform porting definitions that are expected to be common to
diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h
index 04272b1..13767ff 100644
--- a/include/plat/common/platform.h
+++ b/include/plat/common/platform.h
@@ -7,9 +7,10 @@
#ifndef PLATFORM_H
#define PLATFORM_H
-#include <psci.h>
#include <stdint.h>
+#include <lib/psci/psci.h>
+
/*******************************************************************************
* Forward declarations
******************************************************************************/
diff --git a/include/plat/marvell/a3700/common/armada_common.h b/include/plat/marvell/a3700/common/armada_common.h
index fdcc02a..c6953fb 100644
--- a/include/plat/marvell/a3700/common/armada_common.h
+++ b/include/plat/marvell/a3700/common/armada_common.h
@@ -8,9 +8,10 @@
#ifndef ARMADA_COMMON_H
#define ARMADA_COMMON_H
-#include <io_addr_dec.h>
#include <stdint.h>
+#include <io_addr_dec.h>
+
int marvell_get_io_dec_win_conf(struct dec_win_config **win, uint32_t *size);
#endif /* ARMADA_COMMON_H */
diff --git a/include/plat/marvell/a3700/common/marvell_def.h b/include/plat/marvell/a3700/common/marvell_def.h
index 3c105fc..229b8b0 100644
--- a/include/plat/marvell/a3700/common/marvell_def.h
+++ b/include/plat/marvell/a3700/common/marvell_def.h
@@ -8,12 +8,12 @@
#ifndef MARVELL_DEF_H
#define MARVELL_DEF_H
-#include <arch.h>
-#include <common_def.h>
#include <platform_def.h>
-#include <tbbr_img_def.h>
-#include <xlat_tables.h>
+#include <arch.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/common_def.h>
/****************************************************************************
* Definitions common to all MARVELL standard platforms
diff --git a/include/plat/marvell/a3700/common/plat_marvell.h b/include/plat/marvell/a3700/common/plat_marvell.h
index 01e42c5..8b8b53f 100644
--- a/include/plat/marvell/a3700/common/plat_marvell.h
+++ b/include/plat/marvell/a3700/common/plat_marvell.h
@@ -8,11 +8,12 @@
#ifndef PLAT_MARVELL_H
#define PLAT_MARVELL_H
-#include <bl_common.h>
-#include <cassert.h>
-#include <cpu_data.h>
#include <stdint.h>
-#include <xlat_tables.h>
+
+#include <common/bl_common.h>
+#include <lib/cassert.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/xlat_tables/xlat_tables.h>
/*
* Extern declarations common to Marvell standard platforms
diff --git a/include/plat/marvell/a8k/common/armada_common.h b/include/plat/marvell/a8k/common/armada_common.h
index 64d9adf..dd2a24a 100644
--- a/include/plat/marvell/a8k/common/armada_common.h
+++ b/include/plat/marvell/a8k/common/armada_common.h
@@ -8,10 +8,10 @@
#ifndef ARMADA_COMMON_H
#define ARMADA_COMMON_H
-#include <amb_adec.h>
-#include <io_win.h>
-#include <iob.h>
-#include <ccu.h>
+#include <drivers/marvell/amb_adec.h>
+#include <drivers/marvell/ccu.h>
+#include <drivers/marvell/io_win.h>
+#include <drivers/marvell/iob.h>
/*
* This struct supports skip image request
diff --git a/include/plat/marvell/a8k/common/marvell_def.h b/include/plat/marvell/a8k/common/marvell_def.h
index c67b3cd..5ba90f7 100644
--- a/include/plat/marvell/a8k/common/marvell_def.h
+++ b/include/plat/marvell/a8k/common/marvell_def.h
@@ -8,12 +8,12 @@
#ifndef MARVELL_DEF_H
#define MARVELL_DEF_H
-#include <arch.h>
-#include <common_def.h>
#include <platform_def.h>
-#include <tbbr_img_def.h>
-#include <xlat_tables.h>
+#include <arch.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/common_def.h>
/******************************************************************************
* Definitions common to all MARVELL standard platforms
diff --git a/include/plat/marvell/a8k/common/plat_marvell.h b/include/plat/marvell/a8k/common/plat_marvell.h
index 037548d..65d4de8 100644
--- a/include/plat/marvell/a8k/common/plat_marvell.h
+++ b/include/plat/marvell/a8k/common/plat_marvell.h
@@ -8,11 +8,12 @@
#ifndef PLAT_MARVELL_H
#define PLAT_MARVELL_H
-#include <cassert.h>
-#include <cpu_data.h>
#include <stdint.h>
-#include <utils.h>
-#include <xlat_tables.h>
+
+#include <lib/cassert.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables.h>
/*
* Extern declarations common to Marvell standard platforms
diff --git a/include/plat/marvell/common/aarch64/cci_macros.S b/include/plat/marvell/common/aarch64/cci_macros.S
index 96b364e..b0a909b 100644
--- a/include/plat/marvell/common/aarch64/cci_macros.S
+++ b/include/plat/marvell/common/aarch64/cci_macros.S
@@ -8,7 +8,7 @@
#ifndef CCI_MACROS_S
#define CCI_MACROS_S
-#include <cci.h>
+#include <drivers/arm/cci.h>
#include <platform_def.h>
.section .rodata.cci_reg_name, "aS"
diff --git a/include/plat/marvell/common/aarch64/marvell_macros.S b/include/plat/marvell/common/aarch64/marvell_macros.S
index c2a8bd0..bfe2d41 100644
--- a/include/plat/marvell/common/aarch64/marvell_macros.S
+++ b/include/plat/marvell/common/aarch64/marvell_macros.S
@@ -8,10 +8,10 @@
#ifndef MARVELL_MACROS_S
#define MARVELL_MACROS_S
-#include <cci.h>
-#include <gic_common.h>
-#include <gicv2.h>
-#include <gicv3.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/gicv3.h>
#include <platform_def.h>
/*
diff --git a/include/plat/marvell/common/marvell_plat_priv.h b/include/plat/marvell/common/marvell_plat_priv.h
index 6f0b588..78b5331 100644
--- a/include/plat/marvell/common/marvell_plat_priv.h
+++ b/include/plat/marvell/common/marvell_plat_priv.h
@@ -8,7 +8,7 @@
#ifndef MARVELL_PLAT_PRIV_H
#define MARVELL_PLAT_PRIV_H
-#include <utils.h>
+#include <lib/utils.h>
/*****************************************************************************
* Function and variable prototypes
diff --git a/include/services/mm_svc.h b/include/services/mm_svc.h
index e2ce90f..c81e904 100644
--- a/include/services/mm_svc.h
+++ b/include/services/mm_svc.h
@@ -9,7 +9,7 @@
#if SPM_DEPRECATED
-#include <utils_def.h>
+#include <lib/utils_def.h>
#define MM_VERSION_MAJOR U(1)
#define MM_VERSION_MAJOR_SHIFT 16
diff --git a/include/services/sdei.h b/include/services/sdei.h
index 4d0fd3f..ae8c7e4 100644
--- a/include/services/sdei.h
+++ b/include/services/sdei.h
@@ -7,8 +7,8 @@
#ifndef SDEI_H
#define SDEI_H
-#include <spinlock.h>
-#include <utils_def.h>
+#include <lib/spinlock.h>
+#include <lib/utils_def.h>
/* Range 0xC4000020 - 0xC400003F reserved for SDE 64bit smc calls */
#define SDEI_VERSION 0xC4000020U
diff --git a/include/services/secure_partition.h b/include/services/secure_partition.h
index 0ae6cf9..47f6368 100644
--- a/include/services/secure_partition.h
+++ b/include/services/secure_partition.h
@@ -10,7 +10,8 @@
#if SPM_DEPRECATED
#include <stdint.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/*
* Flags used by the secure_partition_mp_info structure to describe the
diff --git a/include/services/sp_res_desc.h b/include/services/sp_res_desc.h
index dc00221..b8be72e 100644
--- a/include/services/sp_res_desc.h
+++ b/include/services/sp_res_desc.h
@@ -8,7 +8,8 @@
#define SPM_RES_DESC_H
#include <stdint.h>
-#include <sp_res_desc_def.h>
+
+#include <services/sp_res_desc_def.h>
/*******************************************************************************
* Attribute Section
diff --git a/include/services/sp_res_desc_def.h b/include/services/sp_res_desc_def.h
index 68df297..5a3c50d 100644
--- a/include/services/sp_res_desc_def.h
+++ b/include/services/sp_res_desc_def.h
@@ -7,7 +7,7 @@
#ifndef SPM_RES_DESC_DEFS_H
#define SPM_RES_DESC_DEFS_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* Attribute Section
diff --git a/include/services/spci_svc.h b/include/services/spci_svc.h
index eae4fb7..b82cf1e 100644
--- a/include/services/spci_svc.h
+++ b/include/services/spci_svc.h
@@ -7,8 +7,8 @@
#ifndef SPCI_SVC_H
#define SPCI_SVC_H
-#include <smccc.h>
-#include <utils_def.h>
+#include <lib/smccc.h>
+#include <lib/utils_def.h>
/* SPCI_VERSION helpers */
diff --git a/include/services/spm_svc.h b/include/services/spm_svc.h
index 763b24e..fcb409b 100644
--- a/include/services/spm_svc.h
+++ b/include/services/spm_svc.h
@@ -9,7 +9,7 @@
#if SPM_DEPRECATED
-#include <utils_def.h>
+#include <lib/utils_def.h>
#define SPM_VERSION_MAJOR U(0)
#define SPM_VERSION_MAJOR_SHIFT 16
diff --git a/include/services/sprt_svc.h b/include/services/sprt_svc.h
index b6b51dd..bd695e5 100644
--- a/include/services/sprt_svc.h
+++ b/include/services/sprt_svc.h
@@ -7,8 +7,8 @@
#ifndef SPRT_SVC_H
#define SPRT_SVC_H
-#include <smccc.h>
-#include <utils_def.h>
+#include <lib/smccc.h>
+#include <lib/utils_def.h>
/* SPRT_VERSION helpers */
diff --git a/include/tools_share/firmware_image_package.h b/include/tools_share/firmware_image_package.h
index 9f586b0..598d5c2 100644
--- a/include/tools_share/firmware_image_package.h
+++ b/include/tools_share/firmware_image_package.h
@@ -8,7 +8,8 @@
#define FIRMWARE_IMAGE_PACKAGE_H
#include <stdint.h>
-#include <uuid.h>
+
+#include "uuid.h"
/* This is used as a signature to validate the blob header */
#define TOC_HEADER_NAME 0xAA640001
diff --git a/lib/aarch64/misc_helpers.S b/lib/aarch64/misc_helpers.S
index 002942e..9aac8cf 100644
--- a/lib/aarch64/misc_helpers.S
+++ b/lib/aarch64/misc_helpers.S
@@ -7,11 +7,13 @@
#include <arch.h>
#include <asm_macros.S>
#include <assert_macros.S>
-#include <xlat_tables_defs.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#if !ERROR_DEPRECATED
.globl get_afflvl_shift
.globl mpidr_mask_lower_afflvls
.globl eret
+#endif /* ERROR_DEPRECATED */
.globl smc
.globl zero_normalmem
@@ -30,6 +32,7 @@
.globl enable_vfp
#endif
+#if !ERROR_DEPRECATED
func get_afflvl_shift
cmp x0, #3
cinc x0, x0, eq
@@ -52,7 +55,7 @@
func eret
eret
endfunc eret
-
+#endif /* ERROR_DEPRECATED */
func smc
smc #0
diff --git a/lib/coreboot/coreboot.mk b/lib/coreboot/coreboot.mk
index bbaa332..4201823 100644
--- a/lib/coreboot/coreboot.mk
+++ b/lib/coreboot/coreboot.mk
@@ -19,6 +19,4 @@
BL31_SOURCES += drivers/coreboot/cbmem_console/${ARCH}/cbmem_console.S
-INCLUDES += -Iinclude/drivers/coreboot
-
endif # COREBOOT
diff --git a/lib/coreboot/coreboot_table.c b/lib/coreboot/coreboot_table.c
index 64f8879..63bdc63 100644
--- a/lib/coreboot/coreboot_table.c
+++ b/lib/coreboot/coreboot_table.c
@@ -5,12 +5,13 @@
*/
#include <assert.h>
-#include <cbmem_console.h>
-#include <coreboot.h>
-#include <debug.h>
-#include <mmio.h>
#include <string.h>
-#include <xlat_tables_v2.h>
+
+#include <drivers/coreboot/cbmem_console.h>
+#include <common/debug.h>
+#include <lib/coreboot.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
/*
* Structures describing coreboot's in-memory descriptor tables. See
diff --git a/lib/cpus/aarch32/cortex_a53.S b/lib/cpus/aarch32/cortex_a53.S
index 1647e16..4975ec6 100644
--- a/lib/cpus/aarch32/cortex_a53.S
+++ b/lib/cpus/aarch32/cortex_a53.S
@@ -3,12 +3,13 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <arch.h>
#include <asm_macros.S>
#include <assert_macros.S>
+#include <common/debug.h>
#include <cortex_a53.h>
#include <cpu_macros.S>
-#include <debug.h>
#if A53_DISABLE_NON_TEMPORAL_HINT
#undef ERRATA_A53_836870
diff --git a/lib/cpus/aarch32/cortex_a57.S b/lib/cpus/aarch32/cortex_a57.S
index dff86be..04942d3 100644
--- a/lib/cpus/aarch32/cortex_a57.S
+++ b/lib/cpus/aarch32/cortex_a57.S
@@ -6,9 +6,9 @@
#include <arch.h>
#include <asm_macros.S>
#include <assert_macros.S>
+#include <common/debug.h>
#include <cortex_a57.h>
#include <cpu_macros.S>
-#include <debug.h>
/* ---------------------------------------------
* Disable intra-cluster coherency
diff --git a/lib/cpus/aarch32/cortex_a72.S b/lib/cpus/aarch32/cortex_a72.S
index 3bc3388..ff2b0e6 100644
--- a/lib/cpus/aarch32/cortex_a72.S
+++ b/lib/cpus/aarch32/cortex_a72.S
@@ -6,9 +6,9 @@
#include <arch.h>
#include <asm_macros.S>
#include <assert_macros.S>
+#include <common/debug.h>
#include <cortex_a72.h>
#include <cpu_macros.S>
-#include <debug.h>
/* ---------------------------------------------
* Disable all types of L2 prefetches.
diff --git a/lib/cpus/aarch32/cpu_helpers.S b/lib/cpus/aarch32/cpu_helpers.S
index ddc0808..f84cd0d 100644
--- a/lib/cpus/aarch32/cpu_helpers.S
+++ b/lib/cpus/aarch32/cpu_helpers.S
@@ -7,8 +7,8 @@
#include <arch.h>
#include <asm_macros.S>
#include <assert_macros.S>
-#include <cpu_data.h>
#include <cpu_macros.S>
+#include <lib/el3_runtime/cpu_data.h>
#if defined(IMAGE_BL1) || defined(IMAGE_BL32) || (defined(IMAGE_BL2) && BL2_AT_EL3)
/*
diff --git a/lib/cpus/aarch64/cortex_a35.S b/lib/cpus/aarch64/cortex_a35.S
index 2e0d631..96e5dd3 100644
--- a/lib/cpus/aarch64/cortex_a35.S
+++ b/lib/cpus/aarch64/cortex_a35.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <cortex_a35.h>
#include <cpu_macros.S>
#include <plat_macros.S>
diff --git a/lib/cpus/aarch64/cortex_a53.S b/lib/cpus/aarch64/cortex_a53.S
index 108509f..332bad7 100644
--- a/lib/cpus/aarch64/cortex_a53.S
+++ b/lib/cpus/aarch64/cortex_a53.S
@@ -5,11 +5,11 @@
*/
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#include <cortex_a53.h>
#include <cpu_macros.S>
-#include <debug.h>
-#include <errata_report.h>
+#include <lib/cpus/errata_report.h>
#include <plat_macros.S>
#if A53_DISABLE_NON_TEMPORAL_HINT
diff --git a/lib/cpus/aarch64/cortex_a55.S b/lib/cpus/aarch64/cortex_a55.S
index 4e9bd9f..b347e29 100644
--- a/lib/cpus/aarch64/cortex_a55.S
+++ b/lib/cpus/aarch64/cortex_a55.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <cortex_a55.h>
#include <cpu_macros.S>
#include <plat_macros.S>
diff --git a/lib/cpus/aarch64/cortex_a57.S b/lib/cpus/aarch64/cortex_a57.S
index 8e60445..a862671 100644
--- a/lib/cpus/aarch64/cortex_a57.S
+++ b/lib/cpus/aarch64/cortex_a57.S
@@ -6,10 +6,10 @@
#include <arch.h>
#include <asm_macros.S>
#include <assert_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#include <cortex_a57.h>
#include <cpu_macros.S>
-#include <debug.h>
#include <plat_macros.S>
/* ---------------------------------------------
diff --git a/lib/cpus/aarch64/cortex_a73.S b/lib/cpus/aarch64/cortex_a73.S
index b796561..772b0be 100644
--- a/lib/cpus/aarch64/cortex_a73.S
+++ b/lib/cpus/aarch64/cortex_a73.S
@@ -5,7 +5,7 @@
*/
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <cortex_a73.h>
#include <cpu_macros.S>
#include <plat_macros.S>
diff --git a/lib/cpus/aarch64/cortex_a75_pubsub.c b/lib/cpus/aarch64/cortex_a75_pubsub.c
index f4ca486..bd2c697 100644
--- a/lib/cpus/aarch64/cortex_a75_pubsub.c
+++ b/lib/cpus/aarch64/cortex_a75_pubsub.c
@@ -6,7 +6,7 @@
#include <cortex_a75.h>
#include <cpuamu.h>
-#include <pubsub_events.h>
+#include <lib/el3_runtime/pubsub_events.h>
static void *cortex_a75_context_save(const void *arg)
{
diff --git a/lib/cpus/aarch64/cortex_a76.S b/lib/cpus/aarch64/cortex_a76.S
index 4def143..27db74e 100644
--- a/lib/cpus/aarch64/cortex_a76.S
+++ b/lib/cpus/aarch64/cortex_a76.S
@@ -5,13 +5,13 @@
*/
#include <arch.h>
-#include <arm_arch_svc.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <context.h>
#include <cortex_a76.h>
#include <cpu_macros.S>
#include <plat_macros.S>
+#include <services/arm_arch_svc.h>
#if !DYNAMIC_WORKAROUND_CVE_2018_3639
#error Cortex A76 requires DYNAMIC_WORKAROUND_CVE_2018_3639=1
diff --git a/lib/cpus/aarch64/cortex_ares_pubsub.c b/lib/cpus/aarch64/cortex_ares_pubsub.c
index 9566223..4a4f333 100644
--- a/lib/cpus/aarch64/cortex_ares_pubsub.c
+++ b/lib/cpus/aarch64/cortex_ares_pubsub.c
@@ -6,7 +6,7 @@
#include <cortex_ares.h>
#include <cpuamu.h>
-#include <pubsub_events.h>
+#include <lib/el3_runtime/pubsub_events.h>
static void *cortex_ares_context_save(const void *arg)
{
diff --git a/lib/cpus/aarch64/cortex_deimos.S b/lib/cpus/aarch64/cortex_deimos.S
index cad906f..0e72fba 100644
--- a/lib/cpus/aarch64/cortex_deimos.S
+++ b/lib/cpus/aarch64/cortex_deimos.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <cortex_deimos.h>
#include <cpu_macros.S>
#include <plat_macros.S>
diff --git a/lib/cpus/aarch64/cortex_helios.S b/lib/cpus/aarch64/cortex_helios.S
index 4812ac4..7d3d7e4 100644
--- a/lib/cpus/aarch64/cortex_helios.S
+++ b/lib/cpus/aarch64/cortex_helios.S
@@ -5,10 +5,10 @@
*/
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#include <cortex_helios.h>
#include <cpu_macros.S>
-#include <debug.h>
#include <plat_macros.S>
func cortex_helios_cpu_pwr_dwn
diff --git a/lib/cpus/aarch64/cpu_helpers.S b/lib/cpus/aarch64/cpu_helpers.S
index 69ece8f..74d7bb2 100644
--- a/lib/cpus/aarch64/cpu_helpers.S
+++ b/lib/cpus/aarch64/cpu_helpers.S
@@ -7,10 +7,10 @@
#include <arch.h>
#include <asm_macros.S>
#include <assert_macros.S>
-#include <cpu_data.h>
+#include <common/debug.h>
#include <cpu_macros.S>
-#include <debug.h>
-#include <errata_report.h>
+#include <lib/cpus/errata_report.h>
+#include <lib/el3_runtime/cpu_data.h>
/* Reset fn is needed in BL at reset vector */
#if defined(IMAGE_BL1) || defined(IMAGE_BL31) || (defined(IMAGE_BL2) && BL2_AT_EL3)
diff --git a/lib/cpus/aarch64/cpuamu.c b/lib/cpus/aarch64/cpuamu.c
index 5ad5bf8..3a2fa81 100644
--- a/lib/cpus/aarch64/cpuamu.c
+++ b/lib/cpus/aarch64/cpuamu.c
@@ -5,8 +5,8 @@
*/
#include <cpuamu.h>
-#include <platform.h>
-#include <pubsub_events.h>
+#include <lib/el3_runtime/pubsub_events.h>
+#include <plat/common/platform.h>
#define CPUAMU_NR_COUNTERS 5U
diff --git a/lib/cpus/aarch64/dsu_helpers.S b/lib/cpus/aarch64/dsu_helpers.S
index 152a3da..eb84daa 100644
--- a/lib/cpus/aarch64/dsu_helpers.S
+++ b/lib/cpus/aarch64/dsu_helpers.S
@@ -6,7 +6,7 @@
#include <asm_macros.S>
#include <dsu_def.h>
-#include <errata_report.h>
+#include <lib/cpus/errata_report.h>
/* -----------------------------------------------------------------------
* DSU erratum 936184 check function
diff --git a/lib/cpus/aarch64/wa_cve_2017_5715_bpiall.S b/lib/cpus/aarch64/wa_cve_2017_5715_bpiall.S
index c613ebd..c9a9544 100644
--- a/lib/cpus/aarch64/wa_cve_2017_5715_bpiall.S
+++ b/lib/cpus/aarch64/wa_cve_2017_5715_bpiall.S
@@ -5,9 +5,9 @@
*/
#include <arch.h>
-#include <arm_arch_svc.h>
#include <asm_macros.S>
#include <context.h>
+#include <services/arm_arch_svc.h>
.globl wa_cve_2017_5715_bpiall_vbar
diff --git a/lib/cpus/aarch64/wa_cve_2017_5715_mmu.S b/lib/cpus/aarch64/wa_cve_2017_5715_mmu.S
index d7b6e26..9277cc6 100644
--- a/lib/cpus/aarch64/wa_cve_2017_5715_mmu.S
+++ b/lib/cpus/aarch64/wa_cve_2017_5715_mmu.S
@@ -5,9 +5,9 @@
*/
#include <arch.h>
-#include <arm_arch_svc.h>
#include <asm_macros.S>
#include <context.h>
+#include <services/arm_arch_svc.h>
.globl wa_cve_2017_5715_mmu_vbar
diff --git a/lib/cpus/errata_report.c b/lib/cpus/errata_report.c
index 42603cb..aeb3560 100644
--- a/lib/cpus/errata_report.c
+++ b/lib/cpus/errata_report.c
@@ -6,14 +6,15 @@
/* Runtime firmware routines to report errata status for the current CPU. */
-#include <arch_helpers.h>
#include <assert.h>
-#include <cpu_data.h>
-#include <debug.h>
-#include <errata_report.h>
-#include <spinlock.h>
#include <stdbool.h>
-#include <utils.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/cpus/errata_report.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/spinlock.h>
+#include <lib/utils.h>
#ifdef IMAGE_BL1
# define BL_STRING "BL1"
diff --git a/lib/el3_runtime/aarch32/context_mgmt.c b/lib/el3_runtime/aarch32/context_mgmt.c
index ad0a120..a4702fc 100644
--- a/lib/el3_runtime/aarch32/context_mgmt.c
+++ b/lib/el3_runtime/aarch32/context_mgmt.c
@@ -4,19 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <amu.h>
-#include <arch.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <platform.h>
-#include <platform_def.h>
-#include <smccc_helpers.h>
#include <stdbool.h>
#include <string.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <context.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/extensions/amu.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+#include <smccc_helpers.h>
/*******************************************************************************
* Context management library initialisation routine. This library is used by
diff --git a/lib/el3_runtime/aarch32/cpu_data.S b/lib/el3_runtime/aarch32/cpu_data.S
index 68d6415..bdad2c1 100644
--- a/lib/el3_runtime/aarch32/cpu_data.S
+++ b/lib/el3_runtime/aarch32/cpu_data.S
@@ -5,7 +5,7 @@
*/
#include <asm_macros.S>
-#include <cpu_data.h>
+#include <lib/el3_runtime/cpu_data.h>
.globl _cpu_data
.globl _cpu_data_by_index
diff --git a/lib/el3_runtime/aarch64/context_mgmt.c b/lib/el3_runtime/aarch64/context_mgmt.c
index 39c27d0..8a5764c 100644
--- a/lib/el3_runtime/aarch64/context_mgmt.c
+++ b/lib/el3_runtime/aarch64/context_mgmt.c
@@ -4,24 +4,26 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <amu.h>
-#include <arch.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <interrupt_mgmt.h>
-#include <mpam.h>
-#include <platform.h>
-#include <platform_def.h>
-#include <pubsub_events.h>
-#include <smccc_helpers.h>
-#include <spe.h>
#include <stdbool.h>
#include <string.h>
-#include <sve.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/bl_common.h>
+#include <context.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/el3_runtime/pubsub_events.h>
+#include <lib/extensions/amu.h>
+#include <lib/extensions/mpam.h>
+#include <lib/extensions/spe.h>
+#include <lib/extensions/sve.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+#include <smccc_helpers.h>
/*******************************************************************************
diff --git a/lib/el3_runtime/aarch64/cpu_data.S b/lib/el3_runtime/aarch64/cpu_data.S
index 96be081..2edf225 100644
--- a/lib/el3_runtime/aarch64/cpu_data.S
+++ b/lib/el3_runtime/aarch64/cpu_data.S
@@ -5,7 +5,7 @@
*/
#include <asm_macros.S>
-#include <cpu_data.h>
+#include <lib/el3_runtime/cpu_data.h>
.globl init_cpu_data_ptr
.globl _cpu_data_by_index
diff --git a/lib/el3_runtime/cpu_data_array.c b/lib/el3_runtime/cpu_data_array.c
index 10b1a7c..13d464c 100644
--- a/lib/el3_runtime/cpu_data_array.c
+++ b/lib/el3_runtime/cpu_data_array.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <cassert.h>
-#include <cpu_data.h>
#include <platform_def.h>
+#include <lib/cassert.h>
+#include <lib/el3_runtime/cpu_data.h>
+
/* The per_cpu_ptr_cache_t space allocation */
cpu_data_t percpu_data[PLATFORM_CORE_COUNT];
diff --git a/lib/extensions/amu/aarch32/amu.c b/lib/extensions/amu/aarch32/amu.c
index 585d908..82d2e18 100644
--- a/lib/extensions/amu/aarch32/amu.c
+++ b/lib/extensions/amu/aarch32/amu.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <amu.h>
-#include <amu_private.h>
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <platform.h>
-#include <pubsub_events.h>
-#include <stdbool.h>
+#include <lib/el3_runtime/pubsub_events.h>
+#include <lib/extensions/amu.h>
+#include <lib/extensions/amu_private.h>
+#include <plat/common/platform.h>
#define AMU_GROUP0_NR_COUNTERS 4
diff --git a/lib/extensions/amu/aarch64/amu.c b/lib/extensions/amu/aarch64/amu.c
index 1564e84..85f7007 100644
--- a/lib/extensions/amu/aarch64/amu.c
+++ b/lib/extensions/amu/aarch64/amu.c
@@ -4,14 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <amu.h>
-#include <amu_private.h>
+#include <assert.h>
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <platform.h>
-#include <pubsub_events.h>
-#include <stdbool.h>
+#include <lib/el3_runtime/pubsub_events.h>
+#include <lib/extensions/amu.h>
+#include <lib/extensions/amu_private.h>
+#include <plat/common/platform.h>
#define AMU_GROUP0_NR_COUNTERS 4
diff --git a/lib/extensions/mpam/mpam.c b/lib/extensions/mpam/mpam.c
index d57bb47..0166707 100644
--- a/lib/extensions/mpam/mpam.c
+++ b/lib/extensions/mpam/mpam.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <mpam.h>
-#include <stdbool.h>
+#include <lib/extensions/mpam.h>
bool mpam_supported(void)
{
diff --git a/lib/extensions/ras/ras_common.c b/lib/extensions/ras/ras_common.c
index f39e5f5..be8bece 100644
--- a/lib/extensions/ras/ras_common.c
+++ b/lib/extensions/ras/ras_common.c
@@ -4,15 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
-#include <ea_handle.h>
-#include <ehf.h>
-#include <platform.h>
-#include <ras.h>
-#include <ras_arch.h>
#include <stdbool.h>
+#include <arch_helpers.h>
+#include <bl31/ea_handle.h>
+#include <bl31/ehf.h>
+#include <common/debug.h>
+#include <lib/extensions/ras.h>
+#include <lib/extensions/ras_arch.h>
+#include <plat/common/platform.h>
+
#ifndef PLAT_RAS_PRI
# error Platform must define RAS priority value
#endif
diff --git a/lib/extensions/ras/std_err_record.c b/lib/extensions/ras/std_err_record.c
index 9fdfd6b..c03fbbe 100644
--- a/lib/extensions/ras/std_err_record.c
+++ b/lib/extensions/ras/std_err_record.c
@@ -3,8 +3,9 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <ras_arch.h>
-#include <utils_def.h>
+
+#include <lib/extensions/ras_arch.h>
+#include <lib/utils_def.h>
/*
* Probe for error in memory-mapped registers containing error records
diff --git a/lib/extensions/spe/spe.c b/lib/extensions/spe/spe.c
index e5df015..78876c6 100644
--- a/lib/extensions/spe/spe.c
+++ b/lib/extensions/spe/spe.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <pubsub.h>
-#include <spe.h>
-#include <stdbool.h>
+#include <lib/el3_runtime/pubsub.h>
+#include <lib/extensions/spe.h>
static inline void psb_csync(void)
{
diff --git a/lib/extensions/sve/sve.c b/lib/extensions/sve/sve.c
index e031bf6..fa4ac77 100644
--- a/lib/extensions/sve/sve.c
+++ b/lib/extensions/sve/sve.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <pubsub.h>
-#include <stdbool.h>
-#include <sve.h>
+#include <lib/el3_runtime/pubsub.h>
+#include <lib/extensions/sve.h>
bool sve_supported(void)
{
diff --git a/lib/libc/abort.c b/lib/libc/abort.c
index c9d16cc..432b1d0 100644
--- a/lib/libc/abort.c
+++ b/lib/libc/abort.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
#include <stdlib.h>
+#include <common/debug.h>
+
void abort(void)
{
ERROR("ABORT\n");
diff --git a/lib/libc/assert.c b/lib/libc/assert.c
index 8fa8f72..60f1a86 100644
--- a/lib/libc/assert.c
+++ b/lib/libc/assert.c
@@ -6,11 +6,12 @@
#include <assert.h>
#include <cdefs.h>
-#include <console.h>
-#include <debug.h>
-#include <platform.h>
#include <stdio.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <plat/common/platform.h>
+
/*
* Only print the output if PLAT_LOG_LEVEL_ASSERT is higher or equal to
* LOG_LEVEL_INFO, which is the default value for builds with DEBUG=1.
diff --git a/lib/libc/printf.c b/lib/libc/printf.c
index d50876d..2715a72 100644
--- a/lib/libc/printf.c
+++ b/lib/libc/printf.c
@@ -3,12 +3,14 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <assert.h>
-#include <debug.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
+#include <common/debug.h>
+
#define get_num_va_args(_args, _lcount) \
(((_lcount) > 1) ? va_arg(_args, long long int) : \
(((_lcount) == 1) ? va_arg(_args, long int) : \
diff --git a/lib/libc/putchar.c b/lib/libc/putchar.c
index 0beb625..037e28a 100644
--- a/lib/libc/putchar.c
+++ b/lib/libc/putchar.c
@@ -5,7 +5,8 @@
*/
#include <stdio.h>
-#include <console.h>
+
+#include <drivers/console.h>
int putchar(int c)
{
diff --git a/lib/libc/snprintf.c b/lib/libc/snprintf.c
index 66a2fa2..38ad1c7 100644
--- a/lib/libc/snprintf.c
+++ b/lib/libc/snprintf.c
@@ -5,10 +5,11 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <platform.h>
#include <stdarg.h>
+#include <common/debug.h>
+#include <plat/common/platform.h>
+
static void string_print(char **s, size_t n, size_t *chars_printed,
const char *str)
{
diff --git a/lib/locks/bakery/bakery_lock_coherent.c b/lib/locks/bakery/bakery_lock_coherent.c
index 8e86790..1634e3a 100644
--- a/lib/locks/bakery/bakery_lock_coherent.c
+++ b/lib/locks/bakery/bakery_lock_coherent.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bakery_lock.h>
-#include <cpu_data.h>
-#include <platform.h>
#include <string.h>
+#include <arch_helpers.h>
+#include <lib/bakery_lock.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <plat/common/platform.h>
+
/*
* Functions in this file implement Bakery Algorithm for mutual exclusion with the
* bakery lock data structures in coherent memory.
diff --git a/lib/locks/bakery/bakery_lock_normal.c b/lib/locks/bakery/bakery_lock_normal.c
index beae63c..867da92 100644
--- a/lib/locks/bakery/bakery_lock_normal.c
+++ b/lib/locks/bakery/bakery_lock_normal.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bakery_lock.h>
-#include <cpu_data.h>
-#include <platform.h>
#include <string.h>
-#include <utils_def.h>
+
+#include <arch_helpers.h>
+#include <lib/bakery_lock.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/utils_def.h>
+#include <plat/common/platform.h>
/*
* Functions in this file implement Bakery Algorithm for mutual exclusion with the
diff --git a/lib/optee/optee_utils.c b/lib/optee/optee_utils.c
index 34d095b..f7392fd 100644
--- a/lib/optee/optee_utils.c
+++ b/lib/optee/optee_utils.c
@@ -4,12 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <desc_image_load.h>
#include <errno.h>
-#include <optee_utils.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <lib/optee_utils.h>
/*
* load_addr_hi and load_addr_lo: image load address.
diff --git a/lib/pmf/pmf_main.c b/lib/pmf/pmf_main.c
index fe7bb74..131a055 100644
--- a/lib/pmf/pmf_main.c
+++ b/lib/pmf/pmf_main.c
@@ -3,15 +3,17 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <errno.h>
-#include <platform.h>
-#include <pmf.h>
-#include <string.h>
-#include <utils_def.h>
+#include <common/debug.h>
+#include <lib/pmf/pmf.h>
+#include <lib/utils_def.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* The 'pmf_svc_descs' array holds the PMF service descriptors exported by
diff --git a/lib/pmf/pmf_smc.c b/lib/pmf/pmf_smc.c
index 4c5b14f..6d79502 100644
--- a/lib/pmf/pmf_smc.c
+++ b/lib/pmf/pmf_smc.c
@@ -3,10 +3,12 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <assert.h>
-#include <debug.h>
-#include <platform.h>
-#include <pmf.h>
+
+#include <common/debug.h>
+#include <lib/pmf/pmf.h>
+#include <plat/common/platform.h>
#include <smccc_helpers.h>
/*
diff --git a/lib/psci/aarch32/psci_helpers.S b/lib/psci/aarch32/psci_helpers.S
index 63d7e70..5cc192e 100644
--- a/lib/psci/aarch32/psci_helpers.S
+++ b/lib/psci/aarch32/psci_helpers.S
@@ -5,8 +5,8 @@
*/
#include <asm_macros.S>
+#include <lib/psci/psci.h>
#include <platform_def.h>
-#include <psci.h>
.globl psci_do_pwrdown_cache_maintenance
.globl psci_do_pwrup_cache_maintenance
diff --git a/lib/psci/aarch64/psci_helpers.S b/lib/psci/aarch64/psci_helpers.S
index 88db1c9..add968a 100644
--- a/lib/psci/aarch64/psci_helpers.S
+++ b/lib/psci/aarch64/psci_helpers.S
@@ -6,8 +6,8 @@
#include <asm_macros.S>
#include <assert_macros.S>
+#include <lib/psci/psci.h>
#include <platform_def.h>
-#include <psci.h>
.globl psci_do_pwrdown_cache_maintenance
.globl psci_do_pwrup_cache_maintenance
diff --git a/lib/psci/psci_common.c b/lib/psci/psci_common.c
index 97aeb83..2928c33 100644
--- a/lib/psci/psci_common.c
+++ b/lib/psci/psci_common.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <platform.h>
-#include <string.h>
-#include <utils.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+
#include "psci_private.h"
/*
diff --git a/lib/psci/psci_main.c b/lib/psci/psci_main.c
index b4a25fb..5c0e952 100644
--- a/lib/psci/psci_main.c
+++ b/lib/psci/psci_main.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <arm_arch_svc.h>
-#include <assert.h>
-#include <debug.h>
-#include <platform.h>
-#include <pmf.h>
-#include <runtime_instr.h>
-#include <smccc.h>
-#include <string.h>
+#include <common/debug.h>
+#include <lib/pmf/pmf.h>
+#include <lib/runtime_instr.h>
+#include <lib/smccc.h>
+#include <plat/common/platform.h>
+#include <services/arm_arch_svc.h>
+
#include "psci_private.h"
/*******************************************************************************
diff --git a/lib/psci/psci_mem_protect.c b/lib/psci/psci_mem_protect.c
index 857146b..481051f 100644
--- a/lib/psci/psci_mem_protect.c
+++ b/lib/psci/psci_mem_protect.c
@@ -6,7 +6,9 @@
#include <assert.h>
#include <limits.h>
-#include <utils.h>
+
+#include <lib/utils.h>
+
#include "psci_private.h"
u_register_t psci_mem_protect(unsigned int enable)
diff --git a/lib/psci/psci_off.c b/lib/psci/psci_off.c
index 944f8bf..ac03e05 100644
--- a/lib/psci/psci_off.c
+++ b/lib/psci/psci_off.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <platform.h>
-#include <pmf.h>
-#include <runtime_instr.h>
-#include <string.h>
+#include <common/debug.h>
+#include <lib/pmf/pmf.h>
+#include <lib/runtime_instr.h>
+#include <plat/common/platform.h>
+
#include "psci_private.h"
/******************************************************************************
diff --git a/lib/psci/psci_on.c b/lib/psci/psci_on.c
index f38900c..aa6b324 100644
--- a/lib/psci/psci_on.c
+++ b/lib/psci/psci_on.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <stddef.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <platform.h>
-#include <pubsub_events.h>
-#include <stddef.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/el3_runtime/pubsub_events.h>
+#include <plat/common/platform.h>
+
#include "psci_private.h"
/*
diff --git a/lib/psci/psci_private.h b/lib/psci/psci_private.h
index 82b951d..68ec7fb 100644
--- a/lib/psci/psci_private.h
+++ b/lib/psci/psci_private.h
@@ -7,14 +7,15 @@
#ifndef PSCI_PRIVATE_H
#define PSCI_PRIVATE_H
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <bakery_lock.h>
-#include <bl_common.h>
-#include <cpu_data.h>
-#include <psci.h>
-#include <spinlock.h>
-#include <stdbool.h>
+#include <common/bl_common.h>
+#include <lib/bakery_lock.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/psci/psci.h>
+#include <lib/spinlock.h>
/*
* The PSCI capability which are provided by the generic code but does not
diff --git a/lib/psci/psci_setup.c b/lib/psci/psci_setup.c
index 6b3081e..b9467d3 100644
--- a/lib/psci/psci_setup.c
+++ b/lib/psci/psci_setup.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <stddef.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <errata_report.h>
-#include <platform.h>
-#include <stddef.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/cpus/errata_report.h>
+#include <plat/common/platform.h>
+
#include "psci_private.h"
/*******************************************************************************
diff --git a/lib/psci/psci_stat.c b/lib/psci/psci_stat.c
index 6f6a7d4..772a184 100644
--- a/lib/psci/psci_stat.c
+++ b/lib/psci/psci_stat.c
@@ -5,9 +5,12 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <common/debug.h>
+#include <plat/common/platform.h>
+
#include "psci_private.h"
#ifndef PLAT_MAX_PWR_LVL_STATES
diff --git a/lib/psci/psci_suspend.c b/lib/psci/psci_suspend.c
index e00819d..8a752c1 100644
--- a/lib/psci/psci_suspend.c
+++ b/lib/psci/psci_suspend.c
@@ -4,19 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <stddef.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <cpu_data.h>
-#include <debug.h>
-#include <platform.h>
-#include <pmf.h>
-#include <pubsub_events.h>
-#include <runtime_instr.h>
-#include <stddef.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/el3_runtime/pubsub_events.h>
+#include <lib/pmf/pmf.h>
+#include <lib/runtime_instr.h>
+#include <plat/common/platform.h>
+
#include "psci_private.h"
/*******************************************************************************
diff --git a/lib/psci/psci_system_off.c b/lib/psci/psci_system_off.c
index 7cac4e9..141d69e 100644
--- a/lib/psci/psci_system_off.c
+++ b/lib/psci/psci_system_off.c
@@ -4,12 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <console.h>
-#include <debug.h>
-#include <platform.h>
#include <stddef.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <plat/common/platform.h>
+
#include "psci_private.h"
void __dead2 psci_system_off(void)
diff --git a/lib/romlib/Makefile b/lib/romlib/Makefile
index 00dde31..0e5d447 100644
--- a/lib/romlib/Makefile
+++ b/lib/romlib/Makefile
@@ -60,11 +60,16 @@
$(LIB_DIR)/libwrappers.a: jmptbl.i $(WRAPPER_DIR)/jmpvar.o
@echo " AR $@"
- $(Q)./genwrappers.sh -b $(WRAPPER_DIR) -o $@ jmptbl.i
+ $(Q)./genwrappers.sh -b $(WRAPPER_DIR) -o $@ $(BUILD_DIR)/jmptbl.i
$(BUILD_DIR)/jmptbl.s: jmptbl.i
@echo " TBL $@"
- $(Q)./gentbl.sh -o $@ jmptbl.i
+ if [ -e "../../$(PLAT_DIR)/jmptbl.i" ] ; \
+ then \
+ $(Q)./gentbl.sh -o $@ -b $(BUILD_DIR) ../../$(PLAT_DIR)/jmptbl.i; \
+ else \
+ @echo "USE_ROMLIB=1 requires jump table list file: jmptbl.i in platform directory"; \
+ fi
clean:
@rm -f $(BUILD_DIR)/*
diff --git a/lib/romlib/gentbl.sh b/lib/romlib/gentbl.sh
index 0695f6e..e64cfe2 100755
--- a/lib/romlib/gentbl.sh
+++ b/lib/romlib/gentbl.sh
@@ -6,6 +6,7 @@
set -e
output=jmptbl.s
+build=.
for i
do
@@ -14,27 +15,45 @@
output=$2
shift 2
;;
+ -b)
+ build=$2
+ shift 2
+ ;;
--)
shift
break
;;
-*)
- echo usage: gentbl.sh [-o output] file ... >&2
+ echo usage: gentbl.sh [-o output] [-b dir] file ... >&2
exit 1
;;
esac
done
tmp=`mktemp`
-trap "rm -f $tmp" EXIT INT QUIT
-
+trap "rm -f $$.tmp" EXIT INT QUIT
rm -f $output
+# Pre-process include files
+awk '!/^$/ && !/[:blank:]*#.*/{
+if (NF == 2 && $1 == "include") {
+ while ((getline line < $2) > 0)
+ if (line !~ /^$/ && line !~ /[:blank:]*#.*/)
+ print line
+ close($2)
+} else
+ print
+}' "$@" |
+awk -v OFS="\t" '
+BEGIN{print "#index\tlib\tfunction\t[patch]"}
+{print NR-1, $0}' | tee $build/jmptbl.i |
awk -v OFS="\n" '
BEGIN {print "\t.text",
"\t.globl\tjmptbl",
"jmptbl:"}
{sub(/[:blank:]*#.*/,"")}
-!/^$/ {print "\tb\t" $3}' "$@" > $tmp
-
-mv $tmp $output
+!/^$/ {if ($3 == "reserved")
+ print "\t.word\t0x0"
+ else
+ print "\tb\t" $3}' > $$.tmp &&
+mv $$.tmp $output
diff --git a/lib/romlib/genwrappers.sh b/lib/romlib/genwrappers.sh
index 48ee5a4..746e4ba 100755
--- a/lib/romlib/genwrappers.sh
+++ b/lib/romlib/genwrappers.sh
@@ -31,7 +31,7 @@
done
awk '{sub(/[:blank:]*#.*/,"")}
-!/^$/ && !/\\tpatch$/ {print $1*4, $2, $3}' "$@" |
+!/^$/ && !/\\tpatch$/ !/\\treserved$/ {print $1*4, $2, $3}' "$@" |
while read idx lib sym
do
file=$build/${lib}_$sym
diff --git a/lib/romlib/jmptbl.i b/lib/romlib/jmptbl.i
index 5eca5aa..a7280d0 100644
--- a/lib/romlib/jmptbl.i
+++ b/lib/romlib/jmptbl.i
@@ -4,37 +4,40 @@
# SPDX-License-Identifier: BSD-3-Clause
#
# Format:
-# index lib function [patch]
+# lib function [patch]
# Add "patch" at the end of the line to patch a function. For example:
-# 14 mbedtls mbedtls_memory_buffer_alloc_init patch
+# mbedtls mbedtls_memory_buffer_alloc_init patch
+# Holes can be introduced in the table by using a special keyword "reserved".
+# Example:
+# reserved reserved
+# The jump table will contain an invalid instruction instead of branch
-0 rom rom_lib_init
-1 fdt fdt_getprop_namelen
-2 fdt fdt_setprop_inplace
-3 fdt fdt_check_header
-4 fdt fdt_node_offset_by_compatible
-5 mbedtls mbedtls_asn1_get_alg
-6 mbedtls mbedtls_asn1_get_alg_null
-7 mbedtls mbedtls_asn1_get_bitstring_null
-8 mbedtls mbedtls_asn1_get_bool
-9 mbedtls mbedtls_asn1_get_int
-10 mbedtls mbedtls_asn1_get_tag
-11 mbedtls mbedtls_free
-12 mbedtls mbedtls_md
-13 mbedtls mbedtls_md_get_size
-14 mbedtls mbedtls_memory_buffer_alloc_init
-15 mbedtls mbedtls_oid_get_md_alg
-16 mbedtls mbedtls_oid_get_numeric_string
-17 mbedtls mbedtls_oid_get_pk_alg
-18 mbedtls mbedtls_oid_get_sig_alg
-19 mbedtls mbedtls_pk_free
-20 mbedtls mbedtls_pk_init
-21 mbedtls mbedtls_pk_parse_subpubkey
-22 mbedtls mbedtls_pk_verify_ext
-23 mbedtls mbedtls_platform_set_calloc_free
-24 mbedtls mbedtls_platform_set_snprintf
-25 mbedtls mbedtls_x509_get_rsassa_pss_params
-26 mbedtls mbedtls_x509_get_sig_alg
-27 mbedtls mbedtls_md_info_from_type
-28 c exit
-29 c atexit
\ No newline at end of file
+rom rom_lib_init
+fdt fdt_getprop_namelen
+fdt fdt_setprop_inplace
+fdt fdt_check_header
+fdt fdt_node_offset_by_compatible
+mbedtls mbedtls_asn1_get_alg
+mbedtls mbedtls_asn1_get_alg_null
+mbedtls mbedtls_asn1_get_bitstring_null
+mbedtls mbedtls_asn1_get_bool
+mbedtls mbedtls_asn1_get_int
+mbedtls mbedtls_asn1_get_tag
+mbedtls mbedtls_free
+mbedtls mbedtls_md
+mbedtls mbedtls_md_get_size
+mbedtls mbedtls_memory_buffer_alloc_init
+mbedtls mbedtls_oid_get_md_alg
+mbedtls mbedtls_oid_get_numeric_string
+mbedtls mbedtls_oid_get_pk_alg
+mbedtls mbedtls_oid_get_sig_alg
+mbedtls mbedtls_pk_free
+mbedtls mbedtls_pk_init
+mbedtls mbedtls_pk_parse_subpubkey
+mbedtls mbedtls_pk_verify_ext
+mbedtls mbedtls_platform_set_snprintf
+mbedtls mbedtls_x509_get_rsassa_pss_params
+mbedtls mbedtls_x509_get_sig_alg
+mbedtls mbedtls_md_info_from_type
+c exit
+c atexit
diff --git a/lib/romlib/romlib.ld.S b/lib/romlib/romlib.ld.S
index 8f0bc62..2aac4ad 100644
--- a/lib/romlib/romlib.ld.S
+++ b/lib/romlib/romlib.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>
MEMORY {
ROM (rx): ORIGIN = ROMLIB_RO_BASE, LENGTH = ROMLIB_RO_LIMIT - ROMLIB_RO_BASE
diff --git a/lib/semihosting/semihosting.c b/lib/semihosting/semihosting.c
index 2ba43f3..ee48dbc 100644
--- a/lib/semihosting/semihosting.c
+++ b/lib/semihosting/semihosting.c
@@ -6,9 +6,10 @@
#include <assert.h>
#include <errno.h>
-#include <semihosting.h>
#include <string.h>
+#include <lib/semihosting.h>
+
#ifndef SEMIHOSTING_SUPPORTED
#define SEMIHOSTING_SUPPORTED 1
#endif
diff --git a/lib/stack_protector/stack_protector.c b/lib/stack_protector/stack_protector.c
index fba5e1f..3ff74fc 100644
--- a/lib/stack_protector/stack_protector.c
+++ b/lib/stack_protector/stack_protector.c
@@ -3,10 +3,12 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <platform.h>
+
#include <stdint.h>
+#include <common/debug.h>
+#include <plat/common/platform.h>
+
/*
* Canary value used by the compiler runtime checks to detect stack corruption.
*
diff --git a/lib/utils/mem_region.c b/lib/utils/mem_region.c
index a5c3c61..662f6a0 100644
--- a/lib/utils/mem_region.c
+++ b/lib/utils/mem_region.c
@@ -5,7 +5,8 @@
*/
#include <assert.h>
-#include <utils.h>
+
+#include <lib/utils.h>
/*
* All the regions defined in mem_region_t must have the following properties
diff --git a/lib/xlat_tables/aarch32/xlat_tables.c b/lib/xlat_tables/aarch32/xlat_tables.c
index 5595703..468a9e7 100644
--- a/lib/xlat_tables/aarch32/xlat_tables.c
+++ b/lib/xlat_tables/aarch32/xlat_tables.c
@@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <platform_def.h>
-#include <utils.h>
-#include <xlat_tables_arch.h>
-#include <xlat_tables.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables_arch.h>
+#include <lib/xlat_tables/xlat_tables.h>
+
#include "../xlat_tables_private.h"
#if (ARM_ARCH_MAJOR == 7) && !defined(ARMV7_SUPPORTS_LARGE_PAGE_ADDRESSING)
diff --git a/lib/xlat_tables/aarch64/xlat_tables.c b/lib/xlat_tables/aarch64/xlat_tables.c
index 4afdeed..71f491a 100644
--- a/lib/xlat_tables/aarch64/xlat_tables.c
+++ b/lib/xlat_tables/aarch64/xlat_tables.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <stdint.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <common_def.h>
-#include <platform_def.h>
-#include <stdint.h>
-#include <utils.h>
-#include <xlat_tables.h>
-#include <xlat_tables_arch.h>
+#include <common/bl_common.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <lib/xlat_tables/xlat_tables_arch.h>
+#include <plat/common/common_def.h>
+
#include "../xlat_tables_private.h"
#define XLAT_TABLE_LEVEL_BASE \
diff --git a/lib/xlat_tables/xlat_tables_common.c b/lib/xlat_tables/xlat_tables_common.c
index 2ee77c7..23fe3f0 100644
--- a/lib/xlat_tables/xlat_tables_common.c
+++ b/lib/xlat_tables/xlat_tables_common.c
@@ -4,18 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <cassert.h>
-#include <common_def.h>
-#include <debug.h>
-#include <platform_def.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
-#include <utils.h>
-#include <xlat_tables.h>
+
+#include <platform_def.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/cassert.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/common_def.h>
+
#include "xlat_tables_private.h"
#if LOG_LEVEL >= LOG_LEVEL_VERBOSE
diff --git a/lib/xlat_tables/xlat_tables_private.h b/lib/xlat_tables/xlat_tables_private.h
index fad967e..4390f34 100644
--- a/lib/xlat_tables/xlat_tables_private.h
+++ b/lib/xlat_tables/xlat_tables_private.h
@@ -7,9 +7,10 @@
#ifndef XLAT_TABLES_PRIVATE_H
#define XLAT_TABLES_PRIVATE_H
-#include <cassert.h>
#include <platform_def.h>
-#include <xlat_tables_arch.h>
+
+#include <lib/cassert.h>
+#include <lib/xlat_tables/xlat_tables_arch.h>
#if HW_ASSISTED_COHERENCY
#error xlat tables v2 must be used with HW_ASSISTED_COHERENCY
diff --git a/lib/xlat_tables_v2/aarch32/enable_mmu.S b/lib/xlat_tables_v2/aarch32/enable_mmu.S
index 4a4ac30..f2fff36 100644
--- a/lib/xlat_tables_v2/aarch32/enable_mmu.S
+++ b/lib/xlat_tables_v2/aarch32/enable_mmu.S
@@ -6,7 +6,7 @@
#include <asm_macros.S>
#include <assert_macros.S>
-#include <xlat_tables_v2.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
.global enable_mmu_direct_svc_mon
.global enable_mmu_direct_hyp
diff --git a/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c b/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c
index 66938e5..349b6c4 100644
--- a/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c
+++ b/lib/xlat_tables_v2/aarch32/xlat_tables_arch.c
@@ -4,14 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <stdbool.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <cassert.h>
-#include <platform_def.h>
-#include <stdbool.h>
-#include <utils_def.h>
-#include <xlat_tables_v2.h>
+#include <lib/cassert.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+
#include "../xlat_tables_private.h"
#if (ARM_ARCH_MAJOR == 7) && !defined(ARMV7_SUPPORTS_LARGE_PAGE_ADDRESSING)
diff --git a/lib/xlat_tables_v2/aarch64/enable_mmu.S b/lib/xlat_tables_v2/aarch64/enable_mmu.S
index 504c03c..07e7be1 100644
--- a/lib/xlat_tables_v2/aarch64/enable_mmu.S
+++ b/lib/xlat_tables_v2/aarch64/enable_mmu.S
@@ -6,7 +6,7 @@
#include <asm_macros.S>
#include <assert_macros.S>
-#include <xlat_tables_v2.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
.global enable_mmu_direct_el1
.global enable_mmu_direct_el2
diff --git a/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c b/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c
index 269adc7..a803d83 100644
--- a/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c
+++ b/lib/xlat_tables_v2/aarch64/xlat_tables_arch.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <cassert.h>
#include <stdbool.h>
#include <stdint.h>
-#include <utils_def.h>
-#include <xlat_tables_v2.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <lib/cassert.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+
#include "../xlat_tables_private.h"
/*
diff --git a/lib/xlat_tables_v2/xlat_tables_context.c b/lib/xlat_tables_v2/xlat_tables_context.c
index b887427..bf3ae1e 100644
--- a/lib/xlat_tables_v2/xlat_tables_context.c
+++ b/lib/xlat_tables_v2/xlat_tables_context.c
@@ -5,10 +5,12 @@
*/
#include <assert.h>
-#include <debug.h>
+
#include <platform_def.h>
-#include <xlat_tables_defs.h>
-#include <xlat_tables_v2.h>
+
+#include <common/debug.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
#include "xlat_tables_private.h"
diff --git a/lib/xlat_tables_v2/xlat_tables_core.c b/lib/xlat_tables_v2/xlat_tables_core.c
index 53fc874..c49554f 100644
--- a/lib/xlat_tables_v2/xlat_tables_core.c
+++ b/lib/xlat_tables_v2/xlat_tables_core.c
@@ -4,17 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
#include <errno.h>
-#include <platform_def.h>
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
-#include <utils_def.h>
-#include <xlat_tables_defs.h>
-#include <xlat_tables_v2.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
#include "xlat_tables_private.h"
diff --git a/lib/xlat_tables_v2/xlat_tables_private.h b/lib/xlat_tables_v2/xlat_tables_private.h
index 528996a..fc70955 100644
--- a/lib/xlat_tables_v2/xlat_tables_private.h
+++ b/lib/xlat_tables_v2/xlat_tables_private.h
@@ -7,9 +7,11 @@
#ifndef XLAT_TABLES_PRIVATE_H
#define XLAT_TABLES_PRIVATE_H
-#include <platform_def.h>
#include <stdbool.h>
-#include <xlat_tables_defs.h>
+
+#include <platform_def.h>
+
+#include <lib/xlat_tables/xlat_tables_defs.h>
#if PLAT_XLAT_TABLES_DYNAMIC
/*
diff --git a/lib/xlat_tables_v2/xlat_tables_utils.c b/lib/xlat_tables_v2/xlat_tables_utils.c
index 41c01ae..f5848a2 100644
--- a/lib/xlat_tables_v2/xlat_tables_utils.c
+++ b/lib/xlat_tables_v2/xlat_tables_utils.c
@@ -4,17 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
#include <errno.h>
-#include <platform_def.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
-#include <utils_def.h>
-#include <xlat_tables_defs.h>
-#include <xlat_tables_v2.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
#include "xlat_tables_private.h"
diff --git a/lib/zlib/tf_gunzip.c b/lib/zlib/tf_gunzip.c
index 574d871..fd56dfc 100644
--- a/lib/zlib/tf_gunzip.c
+++ b/lib/zlib/tf_gunzip.c
@@ -5,11 +5,12 @@
*/
#include <assert.h>
-#include <debug.h>
#include <errno.h>
#include <string.h>
+
+#include <common/debug.h>
+#include <lib/utils.h>
#include <tf_gunzip.h>
-#include <utils.h>
#include "zutil.h"
diff --git a/maintainers.rst b/maintainers.rst
index e807f18..37766ed 100644
--- a/maintainers.rst
+++ b/maintainers.rst
@@ -103,7 +103,7 @@
--------------------------------------
:M: Konstantin Porotchkin <kostap@marvell.com>
:G: `kostapr`_
-:F: docs/plat/marvell/
+:F: docs/marvell/
:F: plat/marvell/
:F: drivers/marvell/
:F: tools/marvell/
diff --git a/plat/allwinner/common/include/platform_def.h b/plat/allwinner/common/include/platform_def.h
index 08eb5cf..ede3881 100644
--- a/plat/allwinner/common/include/platform_def.h
+++ b/plat/allwinner/common/include/platform_def.h
@@ -7,10 +7,11 @@
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
-#include <common_def.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
+
#include <sunxi_mmap.h>
-#include <tbbr/tbbr_img_def.h>
-#include <utils_def.h>
#define BL31_BASE SUNXI_SRAM_A2_BASE
#define BL31_LIMIT (SUNXI_SRAM_A2_BASE + SUNXI_SRAM_A2_SIZE)
diff --git a/plat/allwinner/common/sunxi_bl31_setup.c b/plat/allwinner/common/sunxi_bl31_setup.c
index 2c66329..7ffa658 100644
--- a/plat/allwinner/common/sunxi_bl31_setup.c
+++ b/plat/allwinner/common/sunxi_bl31_setup.c
@@ -4,20 +4,24 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
#include <assert.h>
-#include <console.h>
-#include <debug.h>
-#include <generic_delay_timer.h>
-#include <gicv2.h>
+
#include <libfdt.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <arch.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/console.h>
+#include <drivers/generic_delay_timer.h>
+#include <drivers/ti/uart/uart_16550.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include <sunxi_def.h>
#include <sunxi_mmap.h>
#include <sunxi_private.h>
-#include <uart_16550.h>
static entry_point_info_t bl32_image_ep_info;
diff --git a/plat/allwinner/common/sunxi_common.c b/plat/allwinner/common/sunxi_common.c
index 2eb26a9..6bb8968 100644
--- a/plat/allwinner/common/sunxi_common.c
+++ b/plat/allwinner/common/sunxi_common.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
#include <errno.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/platform.h>
+
#include <sunxi_def.h>
#include <sunxi_mmap.h>
#include <sunxi_private.h>
-#include <xlat_tables_v2.h>
static mmap_region_t sunxi_mmap[PLATFORM_MMAP_REGIONS + 1] = {
MAP_REGION_FLAT(SUNXI_SRAM_BASE, SUNXI_SRAM_SIZE,
diff --git a/plat/allwinner/common/sunxi_cpu_ops.c b/plat/allwinner/common/sunxi_cpu_ops.c
index 3b732b5..8c08603 100644
--- a/plat/allwinner/common/sunxi_cpu_ops.c
+++ b/plat/allwinner/common/sunxi_cpu_ops.c
@@ -4,18 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <core_off_arisc.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
+#include <plat/common/platform.h>
+
+#include <core_off_arisc.h>
#include <sunxi_cpucfg.h>
#include <sunxi_mmap.h>
#include <sunxi_private.h>
-#include <utils_def.h>
static void sunxi_cpu_disable_power(unsigned int cluster, unsigned int core)
{
diff --git a/plat/allwinner/common/sunxi_pm.c b/plat/allwinner/common/sunxi_pm.c
index 7d13cda..8cc715c 100644
--- a/plat/allwinner/common/sunxi_pm.c
+++ b/plat/allwinner/common/sunxi_pm.c
@@ -4,15 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <gicv2.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
#include <sunxi_cpucfg.h>
#include <sunxi_mmap.h>
#include <sunxi_private.h>
diff --git a/plat/allwinner/common/sunxi_security.c b/plat/allwinner/common/sunxi_security.c
index 9053728..1f16a0b 100644
--- a/plat/allwinner/common/sunxi_security.c
+++ b/plat/allwinner/common/sunxi_security.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include <sunxi_mmap.h>
#include <sunxi_private.h>
diff --git a/plat/allwinner/common/sunxi_topology.c b/plat/allwinner/common/sunxi_topology.c
index 98cf63c..7acc77a 100644
--- a/plat/allwinner/common/sunxi_topology.c
+++ b/plat/allwinner/common/sunxi_topology.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <platform.h>
#include <platform_def.h>
+#include <arch.h>
+#include <plat/common/platform.h>
+
static unsigned char plat_power_domain_tree_desc[PLAT_MAX_PWR_LVL + 1] = {
/* One root node for the SoC */
1,
diff --git a/plat/allwinner/sun50i_a64/sunxi_power.c b/plat/allwinner/sun50i_a64/sunxi_power.c
index 59feed7..706bfce 100644
--- a/plat/allwinner/sun50i_a64/sunxi_power.c
+++ b/plat/allwinner/sun50i_a64/sunxi_power.c
@@ -5,14 +5,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <allwinner/sunxi_rsb.h>
-#include <arch_helpers.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
+
#include <libfdt.h>
-#include <mmio.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/allwinner/sunxi_rsb.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
#include <sunxi_def.h>
#include <sunxi_mmap.h>
#include <sunxi_private.h>
diff --git a/plat/allwinner/sun50i_h6/sunxi_power.c b/plat/allwinner/sun50i_h6/sunxi_power.c
index 7bdac8a..5b5bad1 100644
--- a/plat/allwinner/sun50i_h6/sunxi_power.c
+++ b/plat/allwinner/sun50i_h6/sunxi_power.c
@@ -5,13 +5,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <mmio.h>
-#include <mentor/mi2cv.h>
#include <string.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/mentor/mi2cv.h>
+#include <lib/mmio.h>
+
#include <sunxi_def.h>
#include <sunxi_mmap.h>
#include <sunxi_private.h>
diff --git a/plat/arm/board/common/aarch32/board_arm_helpers.S b/plat/arm/board/common/aarch32/board_arm_helpers.S
index d64da29..320bfb3 100644
--- a/plat/arm/board/common/aarch32/board_arm_helpers.S
+++ b/plat/arm/board/common/aarch32/board_arm_helpers.S
@@ -3,8 +3,9 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <v2m_def.h>
.globl plat_report_exception
diff --git a/plat/arm/board/common/aarch64/board_arm_helpers.S b/plat/arm/board/common/aarch64/board_arm_helpers.S
index 4385e62..5a90524 100644
--- a/plat/arm/board/common/aarch64/board_arm_helpers.S
+++ b/plat/arm/board/common/aarch64/board_arm_helpers.S
@@ -3,8 +3,9 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <v2m_def.h>
.globl plat_report_exception
diff --git a/plat/arm/board/common/board_arm_trusted_boot.c b/plat/arm/board/common/board_arm_trusted_boot.c
index 6c03c91..64ca3c3 100644
--- a/plat/arm/board/common/board_arm_trusted_boot.c
+++ b/plat/arm/board/common/board_arm_trusted_boot.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_def.h>
#include <assert.h>
-#include <cassert.h>
-#include <platform.h>
#include <stdint.h>
#include <string.h>
-#include <tbbr_oid.h>
+
+#include <lib/cassert.h>
+#include <plat/common/platform.h>
+#include <tools_share/tbbr_oid.h>
+
+#include <arm_def.h>
/* SHA256 algorithm */
#define SHA256_BYTES 32
@@ -180,9 +182,9 @@
}
#else /* ARM_CRYPTOCELL_INTEG */
-#include <nvm.h>
-#include <nvm_otp.h>
-#include <sbrom_bsv_api.h>
+#include <drivers/arm/cryptocell/nvm.h>
+#include <drivers/arm/cryptocell/nvm_otp.h>
+#include <drivers/arm/cryptocell/sbrom_bsv_api.h>
CASSERT(HASH_RESULT_SIZE_IN_BYTES == SHA256_BYTES,
assert_mismatch_in_hash_result_size);
diff --git a/plat/arm/board/common/board_common.mk b/plat/arm/board/common/board_common.mk
index 2556fc0..487aad7 100644
--- a/plat/arm/board/common/board_common.mk
+++ b/plat/arm/board/common/board_common.mk
@@ -4,8 +4,7 @@
# SPDX-License-Identifier: BSD-3-Clause
#
-PLAT_INCLUDES += -Iinclude/drivers/cfi/ \
- -Iinclude/plat/arm/board/common/
+PLAT_INCLUDES += -Iinclude/plat/arm/board/common/
PLAT_BL_COMMON_SOURCES += drivers/arm/pl011/${ARCH}/pl011_console.S \
plat/arm/board/common/${ARCH}/board_arm_helpers.S
diff --git a/plat/arm/board/fvp/aarch64/fvp_helpers.S b/plat/arm/board/fvp/aarch64/fvp_helpers.S
index abc3ceb..0f90515 100644
--- a/plat/arm/board/fvp/aarch64/fvp_helpers.S
+++ b/plat/arm/board/fvp/aarch64/fvp_helpers.S
@@ -6,8 +6,8 @@
#include <arch.h>
#include <asm_macros.S>
-#include <gicv2.h>
-#include <gicv3.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/gicv3.h>
#include <platform_def.h>
#include <v2m_def.h>
#include "../drivers/pwrc/fvp_pwrc.h"
diff --git a/plat/arm/board/fvp/aarch64/fvp_ras.c b/plat/arm/board/fvp/aarch64/fvp_ras.c
index fb80a8a..759f6d0 100644
--- a/plat/arm/board/fvp/aarch64/fvp_ras.c
+++ b/plat/arm/board/fvp/aarch64/fvp_ras.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <ras.h>
+#include <lib/extensions/ras.h>
struct ras_interrupt fvp_ras_interrupts[] = {
};
diff --git a/plat/arm/board/fvp/drivers/pwrc/fvp_pwrc.c b/plat/arm/board/fvp/drivers/pwrc/fvp_pwrc.c
index b17446c..c48bb07 100644
--- a/plat/arm/board/fvp/drivers/pwrc/fvp_pwrc.c
+++ b/plat/arm/board/fvp/drivers/pwrc/fvp_pwrc.c
@@ -4,9 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bakery_lock.h>
-#include <mmio.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+
#include <plat_arm.h>
+
#include "../../fvp_def.h"
#include "../../fvp_private.h"
#include "fvp_pwrc.h"
diff --git a/plat/arm/board/fvp/fvp_bl1_setup.c b/plat/arm/board/fvp/fvp_bl1_setup.c
index 4b2a340..d6e82f5 100644
--- a/plat/arm/board/fvp/fvp_bl1_setup.c
+++ b/plat/arm/board/fvp/fvp_bl1_setup.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <plat_arm.h>
-#include <platform.h>
-#include <tbbr_img_def.h>
-#include "fvp_private.h"
+#include <common/tbbr/tbbr_img_def.h>
+#include <plat/common/platform.h>
+#include <plat_arm.h>
+
+#include "fvp_private.h"
/*******************************************************************************
* Perform any BL1 specific platform actions.
diff --git a/plat/arm/board/fvp/fvp_bl2_setup.c b/plat/arm/board/fvp/fvp_bl2_setup.c
index 0a3b67d..13e74fd 100644
--- a/plat/arm/board/fvp/fvp_bl2_setup.c
+++ b/plat/arm/board/fvp/fvp_bl2_setup.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <generic_delay_timer.h>
-#include <mmio.h>
+#include <drivers/arm/sp804_delay_timer.h>
+#include <drivers/generic_delay_timer.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include <plat_arm.h>
-#include <platform.h>
-#include <sp804_delay_timer.h>
#include <v2m_def.h>
#include "fvp_def.h"
#include "fvp_private.h"
diff --git a/plat/arm/board/fvp/fvp_bl2u_setup.c b/plat/arm/board/fvp/fvp_bl2u_setup.c
index b9ab3f3..c51e287 100644
--- a/plat/arm/board/fvp/fvp_bl2u_setup.c
+++ b/plat/arm/board/fvp/fvp_bl2u_setup.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <plat/common/platform.h>
+
#include <plat_arm.h>
-#include <platform.h>
#include "fvp_def.h"
#include "fvp_private.h"
diff --git a/plat/arm/board/fvp/fvp_bl31_setup.c b/plat/arm/board/fvp/fvp_bl31_setup.c
index 1c8804f..5f2121c 100644
--- a/plat/arm/board/fvp/fvp_bl31_setup.c
+++ b/plat/arm/board/fvp/fvp_bl31_setup.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <drivers/arm/smmu_v3.h>
+#include <plat/common/platform.h>
+
#include <arm_config.h>
#include <plat_arm.h>
-#include <platform.h>
-#include <smmu_v3.h>
#include "fvp_private.h"
void __init bl31_early_platform_setup2(u_register_t arg0,
diff --git a/plat/arm/board/fvp/fvp_common.c b/plat/arm/board/fvp/fvp_common.c
index f36b637..31a61de 100644
--- a/plat/arm/board/fvp/fvp_common.c
+++ b/plat/arm/board/fvp/fvp_common.c
@@ -4,20 +4,22 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/ccn.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_compat.h>
+#include <plat/common/platform.h>
+#include <services/secure_partition.h>
+
#include <arm_config.h>
#include <arm_def.h>
#include <arm_spm_def.h>
-#include <assert.h>
-#include <cci.h>
-#include <ccn.h>
-#include <debug.h>
-#include <gicv2.h>
-#include <mmio.h>
#include <plat_arm.h>
-#include <platform.h>
-#include <secure_partition.h>
#include <v2m_def.h>
-#include <xlat_tables_compat.h>
#include "../fvp_def.h"
#include "fvp_private.h"
diff --git a/plat/arm/board/fvp/fvp_def.h b/plat/arm/board/fvp/fvp_def.h
index a8ed9d3..1b9f84b 100644
--- a/plat/arm/board/fvp/fvp_def.h
+++ b/plat/arm/board/fvp/fvp_def.h
@@ -7,7 +7,7 @@
#ifndef FVP_DEF_H
#define FVP_DEF_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
#ifndef FVP_CLUSTER_COUNT
#define FVP_CLUSTER_COUNT 2
diff --git a/plat/arm/board/fvp/fvp_io_storage.c b/plat/arm/board/fvp/fvp_io_storage.c
index 11c7c3b..e186b30 100644
--- a/plat/arm/board/fvp/fvp_io_storage.c
+++ b/plat/arm/board/fvp/fvp_io_storage.c
@@ -5,13 +5,15 @@
*/
#include <assert.h>
-#include <common_def.h>
-#include <debug.h>
-#include <io_driver.h>
-#include <io_semihosting.h>
-#include <io_storage.h>
+
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_semihosting.h>
+#include <drivers/io/io_storage.h>
+#include <lib/semihosting.h>
+#include <plat/common/common_def.h>
+
#include <plat_arm.h>
-#include <semihosting.h> /* For FOPEN_MODE_... */
/* Semihosting filenames */
#define BL2_IMAGE_NAME "bl2.bin"
diff --git a/plat/arm/board/fvp/fvp_pm.c b/plat/arm/board/fvp/fvp_pm.c
index 78d3025..7da246b 100644
--- a/plat/arm/board/fvp/fvp_pm.c
+++ b/plat/arm/board/fvp/fvp_pm.c
@@ -4,18 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <arm_config.h>
#include <assert.h>
-#include <debug.h>
#include <errno.h>
-#include <gicv3.h>
-#include <mmio.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/extensions/spe.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
+#include <arm_config.h>
#include <plat_arm.h>
-#include <platform.h>
-#include <psci.h>
-#include <spe.h>
#include <v2m_def.h>
+
#include "../../../../drivers/arm/gic/v3/gicv3_private.h"
#include "drivers/pwrc/fvp_pwrc.h"
#include "fvp_def.h"
diff --git a/plat/arm/board/fvp/fvp_stack_protector.c b/plat/arm/board/fvp/fvp_stack_protector.c
index 1e8e301..e940a12 100644
--- a/plat/arm/board/fvp/fvp_stack_protector.c
+++ b/plat/arm/board/fvp/fvp_stack_protector.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <platform.h>
#include <stdint.h>
+#include <arch_helpers.h>
+#include <plat/common/platform.h>
+
#define RANDOM_CANARY_VALUE ((u_register_t) 3288484550995823360ULL)
u_register_t plat_get_stack_protector_canary(void)
diff --git a/plat/arm/board/fvp/fvp_topology.c b/plat/arm/board/fvp/fvp_topology.c
index e21b9d2..3384a2f 100644
--- a/plat/arm/board/fvp/fvp_topology.c
+++ b/plat/arm/board/fvp/fvp_topology.c
@@ -4,12 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <arm_config.h>
-#include <cassert.h>
-#include <plat_arm.h>
-#include <platform.h>
#include <platform_def.h>
+
+#include <arch.h>
+#include <lib/cassert.h>
+#include <plat/common/platform.h>
+
+#include <plat_arm.h>
+#include <arm_config.h>
#include "drivers/pwrc/fvp_pwrc.h"
/* The FVP power domain tree descriptor */
diff --git a/plat/arm/board/fvp/fvp_trusted_boot.c b/plat/arm/board/fvp/fvp_trusted_boot.c
index 39be4a6..c18bfb2 100644
--- a/plat/arm/board/fvp/fvp_trusted_boot.c
+++ b/plat/arm/board/fvp/fvp_trusted_boot.c
@@ -7,8 +7,9 @@
#include <assert.h>
#include <stdint.h>
#include <string.h>
-#include <platform.h>
-#include <tbbr_oid.h>
+
+#include <plat/common/platform.h>
+#include <tools_share/tbbr_oid.h>
#include "fvp_def.h"
diff --git a/plat/arm/board/fvp/include/platform_def.h b/plat/arm/board/fvp/include/platform_def.h
index 3097f90..ca4bd53 100644
--- a/plat/arm/board/fvp/include/platform_def.h
+++ b/plat/arm/board/fvp/include/platform_def.h
@@ -18,12 +18,14 @@
# endif
#endif /* AARCH32 */
+#include <drivers/arm/tzc400.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
+
#include <arm_def.h>
#include <arm_spm_def.h>
-#include <common_def.h>
-#include <tzc400.h>
-#include <utils_def.h>
#include <v2m_def.h>
+
#include "../fvp_def.h"
/* Required platform porting definitions */
diff --git a/plat/arm/board/fvp/jmptbl.i b/plat/arm/board/fvp/jmptbl.i
new file mode 100644
index 0000000..8d232d5
--- /dev/null
+++ b/plat/arm/board/fvp/jmptbl.i
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Platform specific romlib functions can be added or included here.
+# The index in the output file will be generated cumulatively in the same
+# order as it is given in this file.
+# Output file can be found at: $BUILD_DIR/jmptbl.i
+#
+# Format:
+# lib function [patch]
+# Example:
+# rom rom_lib_init
+# fdt fdt_getprop_namelen patch
+
+include ../../lib/romlib/jmptbl.i
diff --git a/plat/arm/board/fvp/platform.mk b/plat/arm/board/fvp/platform.mk
index 3d858c2..3b60daa 100644
--- a/plat/arm/board/fvp/platform.mk
+++ b/plat/arm/board/fvp/platform.mk
@@ -201,9 +201,15 @@
# Enable dynamic mitigation support by default
DYNAMIC_WORKAROUND_CVE_2018_3639 := 1
-# Enable reclaiming of BL31 initialisation code for secondary cores stacks for FVP
ifneq (${RESET_TO_BL31},1)
+# Enable reclaiming of BL31 initialisation code for secondary cores stacks for
+# FVP. We cannot enable PIE for this case because the overlayed init section
+# creates some dynamic relocations which cannot be handled by the fixup
+# logic currently.
RECLAIM_INIT_CODE := 1
+else
+# Enable PIE support when RESET_TO_BL31=1
+ENABLE_PIE := 1
endif
ifeq (${ENABLE_AMU},1)
diff --git a/plat/arm/board/juno/aarch32/juno_helpers.S b/plat/arm/board/juno/aarch32/juno_helpers.S
index 1bc4e30..080a8dd 100644
--- a/plat/arm/board/juno/aarch32/juno_helpers.S
+++ b/plat/arm/board/juno/aarch32/juno_helpers.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <cortex_a53.h>
#include <cortex_a57.h>
#include <cortex_a72.h>
diff --git a/plat/arm/board/juno/aarch64/juno_helpers.S b/plat/arm/board/juno/aarch64/juno_helpers.S
index edcfc74..373f2fc 100644
--- a/plat/arm/board/juno/aarch64/juno_helpers.S
+++ b/plat/arm/board/juno/aarch64/juno_helpers.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <cortex_a53.h>
#include <cortex_a57.h>
#include <cortex_a72.h>
diff --git a/plat/arm/board/juno/include/platform_def.h b/plat/arm/board/juno/include/platform_def.h
index 8098bc3..ed82879 100644
--- a/plat/arm/board/juno/include/platform_def.h
+++ b/plat/arm/board/juno/include/platform_def.h
@@ -19,15 +19,16 @@
#endif /* AARCH32 */
+#include <drivers/arm/tzc400.h>
+#if TRUSTED_BOARD_BOOT
+#include <drivers/auth/mbedtls/mbedtls_config.h>
+#endif
+#include <plat/common/common_def.h>
+
#include <arm_def.h>
#include <board_css_def.h>
-#include <common_def.h>
#include <css_def.h>
-#if TRUSTED_BOARD_BOOT
-#include <mbedtls_config.h>
-#endif
#include <soc_css_def.h>
-#include <tzc400.h>
#include <v2m_def.h>
#include "../juno_def.h"
diff --git a/plat/arm/board/juno/jmptbl.i b/plat/arm/board/juno/jmptbl.i
new file mode 100644
index 0000000..8d232d5
--- /dev/null
+++ b/plat/arm/board/juno/jmptbl.i
@@ -0,0 +1,17 @@
+#
+# Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+#
+# SPDX-License-Identifier: BSD-3-Clause
+#
+# Platform specific romlib functions can be added or included here.
+# The index in the output file will be generated cumulatively in the same
+# order as it is given in this file.
+# Output file can be found at: $BUILD_DIR/jmptbl.i
+#
+# Format:
+# lib function [patch]
+# Example:
+# rom rom_lib_init
+# fdt fdt_getprop_namelen patch
+
+include ../../lib/romlib/jmptbl.i
diff --git a/plat/arm/board/juno/juno_bl1_setup.c b/plat/arm/board/juno/juno_bl1_setup.c
index 3dd2a22..e751ab6 100644
--- a/plat/arm/board/juno/juno_bl1_setup.c
+++ b/plat/arm/board/juno/juno_bl1_setup.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <debug.h>
#include <errno.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <drivers/arm/sp805.h>
+#include <plat/common/platform.h>
+
#include <plat_arm.h>
-#include <platform.h>
#include <sds.h>
-#include <sp805.h>
-#include <tbbr_img_def.h>
#include <v2m_def.h>
void juno_reset_to_aarch32_state(void);
diff --git a/plat/arm/board/juno/juno_bl2_setup.c b/plat/arm/board/juno/juno_bl2_setup.c
index 1f483d6..56f05eb 100644
--- a/plat/arm/board/juno/juno_bl2_setup.c
+++ b/plat/arm/board/juno/juno_bl2_setup.c
@@ -5,8 +5,10 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <desc_image_load.h>
+
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+
#include <plat_arm.h>
#if JUNO_AARCH32_EL3_RUNTIME
diff --git a/plat/arm/board/juno/juno_def.h b/plat/arm/board/juno/juno_def.h
index 5301886..7a8bedf 100644
--- a/plat/arm/board/juno/juno_def.h
+++ b/plat/arm/board/juno/juno_def.h
@@ -7,7 +7,7 @@
#ifndef JUNO_DEF_H
#define JUNO_DEF_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* Juno memory map related constants
diff --git a/plat/arm/board/juno/juno_err.c b/plat/arm/board/juno/juno_err.c
index dd8e278..69daa1a 100644
--- a/plat/arm/board/juno/juno_err.c
+++ b/plat/arm/board/juno/juno_err.c
@@ -4,9 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <errno.h>
-#include <platform.h>
+
+#include <arch_helpers.h>
+#include <plat/common/platform.h>
+
#include <v2m_def.h>
/*
diff --git a/plat/arm/board/juno/juno_pm.c b/plat/arm/board/juno/juno_pm.c
index da2e92b..dbf7b6c 100644
--- a/plat/arm/board/juno/juno_pm.c
+++ b/plat/arm/board/juno/juno_pm.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@@ -9,5 +9,9 @@
const plat_psci_ops_t *plat_arm_psci_override_pm_ops(plat_psci_ops_t *ops)
{
+#if CSS_USE_SCMI_SDS_DRIVER
return css_scmi_override_pm_ops(ops);
+#else
+ return ops;
+#endif /* CSS_USE_SCMI_SDS_DRIVER */
}
diff --git a/plat/arm/board/juno/juno_security.c b/plat/arm/board/juno/juno_security.c
index b6cfe78..b0df837 100644
--- a/plat/arm/board/juno/juno_security.c
+++ b/plat/arm/board/juno/juno_security.c
@@ -4,12 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
-#include <nic_400.h>
+#include <common/debug.h>
+#include <drivers/arm/nic_400.h>
+#include <lib/mmio.h>
+
#include <plat_arm.h>
#include <soc_css.h>
-
#include "juno_def.h"
#include "juno_tzmp1_def.h"
diff --git a/plat/arm/board/juno/juno_stack_protector.c b/plat/arm/board/juno/juno_stack_protector.c
index ec0b1fb..ff05b5d 100644
--- a/plat/arm/board/juno/juno_stack_protector.c
+++ b/plat/arm/board/juno/juno_stack_protector.c
@@ -5,8 +5,9 @@
*/
#include <arch_helpers.h>
-#include <debug.h>
-#include <utils.h>
+#include <common/debug.h>
+#include <lib/utils.h>
+
#include "juno_decl.h"
#include "juno_def.h"
diff --git a/plat/arm/board/juno/juno_topology.c b/plat/arm/board/juno/juno_topology.c
index c8a7598..51b99ac 100644
--- a/plat/arm/board/juno/juno_topology.c
+++ b/plat/arm/board/juno/juno_topology.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <plat/common/platform.h>
+
#include <arm_def.h>
#include <css_pm.h>
#include <plat_arm.h>
-#include <platform.h>
#include "juno_def.h"
#include "../../css/drivers/scmi/scmi.h"
#include "../../css/drivers/mhu/css_mhu_doorbell.h"
diff --git a/plat/arm/board/juno/juno_trng.c b/plat/arm/board/juno/juno_trng.c
index d9ad1d4..505fb02 100644
--- a/plat/arm/board/juno/juno_trng.c
+++ b/plat/arm/board/juno/juno_trng.c
@@ -5,9 +5,11 @@
*/
#include <assert.h>
-#include <mmio.h>
#include <string.h>
-#include <utils_def.h>
+
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
+
#include "juno_decl.h"
#include "juno_def.h"
diff --git a/plat/arm/board/juno/platform.mk b/plat/arm/board/juno/platform.mk
index ad955f6..aec2b9b 100644
--- a/plat/arm/board/juno/platform.mk
+++ b/plat/arm/board/juno/platform.mk
@@ -94,7 +94,7 @@
endif
ifneq (${RESET_TO_BL31},0)
- $(error "Using BL31 as the reset vector is not supported on ${PLATFORM} platform. \
+ $(error "Using BL31 as the reset vector is not supported on ${PLAT} platform. \
Please set RESET_TO_BL31 to 0.")
endif
diff --git a/plat/arm/board/n1sdp/include/platform_def.h b/plat/arm/board/n1sdp/include/platform_def.h
index fa639ca..1556ac7 100644
--- a/plat/arm/board/n1sdp/include/platform_def.h
+++ b/plat/arm/board/n1sdp/include/platform_def.h
@@ -8,9 +8,23 @@
#define PLATFORM_DEF_H
#include <arm_def.h>
-#include <board_css_def.h>
#include <css_def.h>
+/* UART related constants */
+#define PLAT_ARM_BOOT_UART_BASE 0x2A400000
+#define PLAT_ARM_BOOT_UART_CLK_IN_HZ 50000000
+
+#define PLAT_ARM_BL31_RUN_UART_BASE 0x2A410000
+#define PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ 50000000
+
+#define PLAT_ARM_SP_MIN_RUN_UART_BASE 0x2A410000
+#define PLAT_ARM_SP_MIN_RUN_UART_CLK_IN_HZ 50000000
+
+#define PLAT_ARM_CRASH_UART_BASE PLAT_ARM_BL31_RUN_UART_BASE
+#define PLAT_ARM_CRASH_UART_CLK_IN_HZ PLAT_ARM_BL31_RUN_UART_CLK_IN_HZ
+
+#define PLAT_ARM_DRAM2_SIZE ULL(0x780000000)
+
#if CSS_USE_SCMI_SDS_DRIVER
#define N1SDP_SCMI_PAYLOAD_BASE 0x45400000
#else
@@ -57,7 +71,7 @@
#define N1SDP_DEVICE_BASE (0x20000000)
-#define N1SDP_DEVICE_SIZE (0x20000000)
+#define N1SDP_DEVICE_SIZE (0x30000000)
#define N1SDP_MAP_DEVICE MAP_REGION_FLAT( \
N1SDP_DEVICE_BASE, \
N1SDP_DEVICE_SIZE, \
diff --git a/plat/arm/board/n1sdp/n1sdp_bl31_setup.c b/plat/arm/board/n1sdp/n1sdp_bl31_setup.c
index cdd0b63..d044b7c 100644
--- a/plat/arm/board/n1sdp/n1sdp_bl31_setup.c
+++ b/plat/arm/board/n1sdp/n1sdp_bl31_setup.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <platform_def.h>
+
#include "../../css/drivers/scmi/scmi.h"
#include "../../css/drivers/mhu/css_mhu_doorbell.h"
#include <plat_arm.h>
-#include <platform_def.h>
static scmi_channel_plat_info_t n1sdp_scmi_plat_info = {
.scmi_mbx_mem = N1SDP_SCMI_PAYLOAD_BASE,
diff --git a/plat/arm/board/n1sdp/n1sdp_plat.c b/plat/arm/board/n1sdp/n1sdp_plat.c
index 8c057c5..3bf1fe6 100644
--- a/plat/arm/board/n1sdp/n1sdp_plat.c
+++ b/plat/arm/board/n1sdp/n1sdp_plat.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_def.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <plat_arm.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <plat/common/platform.h>
+
+#include <arm_def.h>
+#include <plat_arm.h>
+
/*
* Table of regions to map using the MMU.
* Replace or extend the below regions as required
@@ -19,7 +21,6 @@
const mmap_region_t plat_arm_mmap[] = {
ARM_MAP_SHARED_RAM,
N1SDP_MAP_DEVICE,
- SOC_CSS_MAP_DEVICE,
{0}
};
diff --git a/plat/arm/board/n1sdp/platform.mk b/plat/arm/board/n1sdp/platform.mk
index c9acb49..2b68f65 100644
--- a/plat/arm/board/n1sdp/platform.mk
+++ b/plat/arm/board/n1sdp/platform.mk
@@ -62,6 +62,5 @@
USE_COHERENT_MEM := 0
include plat/arm/common/arm_common.mk
include plat/arm/css/common/css_common.mk
-include plat/arm/soc/common/soc_css.mk
include plat/arm/board/common/board_common.mk
diff --git a/plat/arm/board/sgi575/include/platform_def.h b/plat/arm/board/sgi575/include/platform_def.h
index 16e2898..6aea522 100644
--- a/plat/arm/board/sgi575/include/platform_def.h
+++ b/plat/arm/board/sgi575/include/platform_def.h
@@ -7,8 +7,9 @@
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
+#include <lib/utils_def.h>
+
#include <sgi_base_platform_def.h>
-#include <utils_def.h>
#define PLAT_ARM_CLUSTER_COUNT 2
#define CSS_SGI_MAX_CPUS_PER_CLUSTER 4
diff --git a/plat/arm/board/sgi575/sgi575_plat.c b/plat/arm/board/sgi575/sgi575_plat.c
index a8ca916..d1a1fbf 100644
--- a/plat/arm/board/sgi575/sgi575_plat.c
+++ b/plat/arm/board/sgi575/sgi575_plat.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+#include <plat/common/platform.h>
unsigned int plat_arm_sgi_get_platform_id(void)
{
diff --git a/plat/arm/board/sgi575/sgi575_security.c b/plat/arm/board/sgi575/sgi575_security.c
index 7ccc59a..8417e10 100644
--- a/plat/arm/board/sgi575/sgi575_security.c
+++ b/plat/arm/board/sgi575/sgi575_security.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
#include <platform_def.h>
-#include <tzc_dmc620.h>
+
+#include <common/debug.h>
+#include <drivers/arm/tzc_dmc620.h>
uintptr_t sgi575_dmc_base[] = {
SGI575_DMC620_BASE0,
diff --git a/plat/arm/board/sgiclarka/include/platform_def.h b/plat/arm/board/sgiclarka/include/platform_def.h
index 39907e8..d2cdb49 100644
--- a/plat/arm/board/sgiclarka/include/platform_def.h
+++ b/plat/arm/board/sgiclarka/include/platform_def.h
@@ -7,8 +7,9 @@
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
+#include <lib/utils_def.h>
+
#include <sgi_base_platform_def.h>
-#include <utils_def.h>
#define PLAT_ARM_CLUSTER_COUNT 2
#define CSS_SGI_MAX_CPUS_PER_CLUSTER 4
diff --git a/plat/arm/board/sgiclarka/sgiclarka_plat.c b/plat/arm/board/sgiclarka/sgiclarka_plat.c
index 3df2da6..3b7e5ee 100644
--- a/plat/arm/board/sgiclarka/sgiclarka_plat.c
+++ b/plat/arm/board/sgiclarka/sgiclarka_plat.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+#include <plat/common/platform.h>
unsigned int plat_arm_sgi_get_platform_id(void)
{
diff --git a/plat/arm/board/sgiclarka/sgiclarka_security.c b/plat/arm/board/sgiclarka/sgiclarka_security.c
index 29cd754..c455111 100644
--- a/plat/arm/board/sgiclarka/sgiclarka_security.c
+++ b/plat/arm/board/sgiclarka/sgiclarka_security.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
#include <platform_def.h>
-#include <tzc_dmc620.h>
+
+#include <common/debug.h>
+#include <drivers/arm/tzc_dmc620.h>
uintptr_t sgiclarka_dmc_base[] = {
SGICLARKA_DMC620_BASE0,
diff --git a/plat/arm/board/sgiclarkh/include/platform_def.h b/plat/arm/board/sgiclarkh/include/platform_def.h
index 544ad90..fe8907b 100644
--- a/plat/arm/board/sgiclarkh/include/platform_def.h
+++ b/plat/arm/board/sgiclarkh/include/platform_def.h
@@ -7,8 +7,9 @@
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
+#include <lib/utils_def.h>
+
#include <sgi_base_platform_def.h>
-#include <utils_def.h>
#define PLAT_ARM_CLUSTER_COUNT 2
#define CSS_SGI_MAX_CPUS_PER_CLUSTER 8
diff --git a/plat/arm/board/sgiclarkh/sgiclarkh_plat.c b/plat/arm/board/sgiclarkh/sgiclarkh_plat.c
index 437592d..a1b8d62 100644
--- a/plat/arm/board/sgiclarkh/sgiclarkh_plat.c
+++ b/plat/arm/board/sgiclarkh/sgiclarkh_plat.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+#include <plat/common/platform.h>
unsigned int plat_arm_sgi_get_platform_id(void)
{
diff --git a/plat/arm/board/sgiclarkh/sgiclarkh_security.c b/plat/arm/board/sgiclarkh/sgiclarkh_security.c
index 5ae0b82..aaf9691 100644
--- a/plat/arm/board/sgiclarkh/sgiclarkh_security.c
+++ b/plat/arm/board/sgiclarkh/sgiclarkh_security.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
#include <platform_def.h>
-#include <tzc_dmc620.h>
+
+#include <common/debug.h>
+#include <drivers/arm/tzc_dmc620.h>
uintptr_t sgiclarkh_dmc_base[] = {
SGICLARKH_DMC620_BASE0,
diff --git a/plat/arm/common/aarch32/arm_bl2_mem_params_desc.c b/plat/arm/common/aarch32/arm_bl2_mem_params_desc.c
index 890f2c9..e23dd25 100644
--- a/plat/arm/common/aarch32/arm_bl2_mem_params_desc.c
+++ b/plat/arm/common/aarch32/arm_bl2_mem_params_desc.c
@@ -4,11 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* Following descriptor provides BL image/ep information that gets used
diff --git a/plat/arm/common/aarch64/arm_bl2_mem_params_desc.c b/plat/arm/common/aarch64/arm_bl2_mem_params_desc.c
index 8e6d00d..c0f42f3 100644
--- a/plat/arm/common/aarch64/arm_bl2_mem_params_desc.c
+++ b/plat/arm/common/aarch64/arm_bl2_mem_params_desc.c
@@ -4,11 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* Following descriptor provides BL image/ep information that gets used
diff --git a/plat/arm/common/aarch64/arm_ehf.c b/plat/arm/common/aarch64/arm_ehf.c
index f313851..4ae992c 100644
--- a/plat/arm/common/aarch64/arm_ehf.c
+++ b/plat/arm/common/aarch64/arm_ehf.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <ehf.h>
#include <platform_def.h>
+#include <bl31/ehf.h>
+
/*
* Enumeration of priority levels on ARM platforms.
*/
diff --git a/plat/arm/common/aarch64/arm_sdei.c b/plat/arm/common/aarch64/arm_sdei.c
index 687b21d..493134b 100644
--- a/plat/arm/common/aarch64/arm_sdei.c
+++ b/plat/arm/common/aarch64/arm_sdei.c
@@ -6,9 +6,10 @@
/* SDEI configuration for ARM platforms */
-#include <ehf.h>
#include <platform_def.h>
-#include <sdei.h>
+
+#include <bl31/ehf.h>
+#include <services/sdei.h>
/* Private event mappings */
static sdei_ev_map_t arm_sdei_private[] = {
diff --git a/plat/arm/common/arm_bl1_fwu.c b/plat/arm/common/arm_bl1_fwu.c
index f2be477..cd92aa8 100644
--- a/plat/arm/common/arm_bl1_fwu.c
+++ b/plat/arm/common/arm_bl1_fwu.c
@@ -5,14 +5,17 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
#include <errno.h>
-#include <plat_arm.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <tbbr_img_desc.h>
-#include <utils.h>
+
+#include <bl1/tbbr/tbbr_img_desc.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+
+#include <plat_arm.h>
/* Struct to keep track of usable memory */
typedef struct bl1_mem_info {
diff --git a/plat/arm/common/arm_bl1_setup.c b/plat/arm/common/arm_bl1_setup.c
index f760e18..e28211c 100644
--- a/plat/arm/common/arm_bl1_setup.c
+++ b/plat/arm/common/arm_bl1_setup.c
@@ -4,17 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <arm_def.h>
#include <assert.h>
-#include <bl1.h>
-#include <bl_common.h>
-#include <plat_arm.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <sp805.h>
-#include <utils.h>
-#include <xlat_tables_compat.h>
+
+#include <arch.h>
+#include <bl1/bl1.h>
+#include <common/bl_common.h>
+#include <drivers/arm/sp805.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables_compat.h>
+#include <plat/common/platform.h>
+
+#include <arm_def.h>
+#include <plat_arm.h>
#include "../../../bl1/bl1_private.h"
diff --git a/plat/arm/common/arm_bl2_el3_setup.c b/plat/arm/common/arm_bl2_el3_setup.c
index 4f5e6a9..0c1f63e 100644
--- a/plat/arm/common/arm_bl2_el3_setup.c
+++ b/plat/arm/common/arm_bl2_el3_setup.c
@@ -3,11 +3,14 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_def.h>
+
#include <assert.h>
-#include <generic_delay_timer.h>
+
+#include <drivers/generic_delay_timer.h>
+#include <plat/common/platform.h>
+
+#include <arm_def.h>
#include <plat_arm.h>
-#include <platform.h>
#pragma weak bl2_el3_early_platform_setup
#pragma weak bl2_el3_plat_arch_setup
diff --git a/plat/arm/common/arm_bl2_setup.c b/plat/arm/common/arm_bl2_setup.c
index 628a50d..9319004 100644
--- a/plat/arm/common/arm_bl2_setup.c
+++ b/plat/arm/common/arm_bl2_setup.c
@@ -4,21 +4,24 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <arm_def.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <desc_image_load.h>
-#include <generic_delay_timer.h>
-#ifdef SPD_opteed
-#include <optee_utils.h>
-#endif
-#include <plat_arm.h>
-#include <platform.h>
-#include <platform_def.h>
#include <string.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <drivers/generic_delay_timer.h>
+#ifdef SPD_opteed
+#include <lib/optee_utils.h>
+#endif
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+
+#include <arm_def.h>
+#include <plat_arm.h>
/* Data structure which holds the extents of the trusted SRAM for BL2 */
static meminfo_t bl2_tzram_layout __aligned(CACHE_WRITEBACK_GRANULE);
diff --git a/plat/arm/common/arm_bl2u_setup.c b/plat/arm/common/arm_bl2u_setup.c
index 3848aa0..0dc66e6 100644
--- a/plat/arm/common/arm_bl2u_setup.c
+++ b/plat/arm/common/arm_bl2u_setup.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <arm_def.h>
#include <assert.h>
-#include <bl_common.h>
-#include <generic_delay_timer.h>
-#include <plat_arm.h>
-#include <platform_def.h>
-#include <platform.h>
#include <string.h>
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <drivers/generic_delay_timer.h>
+#include <plat/common/platform.h>
+
+#include <arm_def.h>
+#include <plat_arm.h>
+
/* Weak definitions may be overridden in specific ARM standard platform */
#pragma weak bl2u_platform_setup
#pragma weak bl2u_early_platform_setup
diff --git a/plat/arm/common/arm_bl31_setup.c b/plat/arm/common/arm_bl31_setup.c
index 1b05f46..41151c2 100644
--- a/plat/arm/common/arm_bl31_setup.c
+++ b/plat/arm/common/arm_bl31_setup.c
@@ -4,19 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
#include <arch.h>
#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <lib/extensions/ras.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables_compat.h>
+#include <plat/common/platform.h>
+
#include <arm_def.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <mmio.h>
#include <plat_arm.h>
-#include <platform.h>
-#include <ras.h>
-#include <utils.h>
-#include <xlat_tables_compat.h>
/*
* Placeholder variables for copying the arguments that have been passed to
diff --git a/plat/arm/common/arm_cci.c b/plat/arm/common/arm_cci.c
index 6505b91..7ee997e 100644
--- a/plat/arm/common/arm_cci.c
+++ b/plat/arm/common/arm_cci.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <cci.h>
-#include <plat_arm.h>
#include <platform_def.h>
-#include <utils.h>
+
+#include <arch.h>
+#include <drivers/arm/cci.h>
+#include <lib/utils.h>
+
+#include <plat_arm.h>
static const int cci_map[] = {
PLAT_ARM_CCI_CLUSTER0_SL_IFACE_IX,
diff --git a/plat/arm/common/arm_ccn.c b/plat/arm/common/arm_ccn.c
index ddf3286..6aa56f2 100644
--- a/plat/arm/common/arm_ccn.c
+++ b/plat/arm/common/arm_ccn.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <ccn.h>
-#include <plat_arm.h>
#include <platform_def.h>
+#include <arch.h>
+#include <drivers/arm/ccn.h>
+
+#include <plat_arm.h>
+
static const unsigned char master_to_rn_id_map[] = {
PLAT_ARM_CLUSTER_TO_CCN_ID_MAP
};
diff --git a/plat/arm/common/arm_common.c b/plat/arm/common/arm_common.c
index 56ad8ae..4cd2ce3 100644
--- a/plat/arm/common/arm_common.c
+++ b/plat/arm/common/arm_common.c
@@ -3,17 +3,21 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
+#include <assert.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <common/romlib.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_compat.h>
+#include <plat/common/platform.h>
+#include <services/secure_partition.h>
+
#include <plat_arm.h>
-#include <platform.h>
-#include <platform_def.h>
-#include <romlib.h>
-#include <secure_partition.h>
-#include <xlat_tables_compat.h>
/* Weak definitions may be overridden in specific ARM standard platform */
#pragma weak plat_get_ns_image_entrypoint
diff --git a/plat/arm/common/arm_common.mk b/plat/arm/common/arm_common.mk
index 24b61e8..a8ac286 100644
--- a/plat/arm/common/arm_common.mk
+++ b/plat/arm/common/arm_common.mk
@@ -133,11 +133,6 @@
$(eval $(call assert_boolean,ARM_CRYPTOCELL_INTEG))
$(eval $(call add_define,ARM_CRYPTOCELL_INTEG))
-# Enable PIE support for RESET_TO_BL31 case
-ifeq (${RESET_TO_BL31},1)
- ENABLE_PIE := 1
-endif
-
# CryptoCell integration relies on coherent buffers for passing data from
# the AP CPU to the CryptoCell
ifeq (${ARM_CRYPTOCELL_INTEG},1)
@@ -290,12 +285,7 @@
endif
-# RECLAIM_INIT_CODE can only be set when LOAD_IMAGE_V2=2 and xlat tables v2
-# are used
ifeq (${RECLAIM_INIT_CODE}, 1)
- ifeq (${LOAD_IMAGE_V2}, 0)
- $(error "LOAD_IMAGE_V2 must be enabled to use RECLAIM_INIT_CODE")
- endif
ifeq (${ARM_XLAT_TABLES_LIB_V1}, 1)
$(error "To reclaim init code xlat tables v2 must be used")
endif
diff --git a/plat/arm/common/arm_console.c b/plat/arm/common/arm_console.c
index bd3dca1..29cb378 100644
--- a/plat/arm/common/arm_console.c
+++ b/plat/arm/common/arm_console.c
@@ -3,13 +3,17 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <assert.h>
-#include <console.h>
-#include <debug.h>
-#include <pl011.h>
-#include <plat_arm.h>
+
#include <platform_def.h>
+#include <common/debug.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/console.h>
+
+#include <plat_arm.h>
+
/*******************************************************************************
* Functions that set up the console
******************************************************************************/
diff --git a/plat/arm/common/arm_dyn_cfg.c b/plat/arm/common/arm_dyn_cfg.c
index c2a4bb1..6c6dc56 100644
--- a/plat/arm/common/arm_dyn_cfg.c
+++ b/plat/arm/common/arm_dyn_cfg.c
@@ -4,19 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_dyn_cfg_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <desc_image_load.h>
-#if TRUSTED_BOARD_BOOT
-#include <mbedtls_config.h>
-#endif
-#include <plat_arm.h>
-#include <platform.h>
-#include <platform_def.h>
#include <string.h>
-#include <tbbr_img_def.h>
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <common/tbbr/tbbr_img_def.h>
+#if TRUSTED_BOARD_BOOT
+#include <drivers/auth/mbedtls/mbedtls_config.h>
+#endif
+#include <plat/common/platform.h>
+
+#include <arm_dyn_cfg_helpers.h>
+#include <plat_arm.h>
/* Variable to store the address to TB_FW_CONFIG passed from BL1 */
static void *tb_fw_cfg_dtb;
diff --git a/plat/arm/common/arm_dyn_cfg_helpers.c b/plat/arm/common/arm_dyn_cfg_helpers.c
index d12d09c..bf2f156 100644
--- a/plat/arm/common/arm_dyn_cfg_helpers.c
+++ b/plat/arm/common/arm_dyn_cfg_helpers.c
@@ -4,11 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_dyn_cfg_helpers.h>
#include <assert.h>
-#include <desc_image_load.h>
-#include <fdt_wrappers.h>
+
#include <libfdt.h>
+
+#include <common/desc_image_load.h>
+#include <common/fdt_wrappers.h>
+
+#include <arm_dyn_cfg_helpers.h>
#include <plat_arm.h>
#define DTB_PROP_MBEDTLS_HEAP_ADDR "mbedtls_heap_addr"
diff --git a/plat/arm/common/arm_err.c b/plat/arm/common/arm_err.c
index aa65f4f..8650d48 100644
--- a/plat/arm/common/arm_err.c
+++ b/plat/arm/common/arm_err.c
@@ -4,15 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <console.h>
-#include <debug.h>
#include <errno.h>
-#include <plat_arm.h>
-#include <platform.h>
-#include <platform_def.h>
#include <stdint.h>
-#include <v2m_flash.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/cfi/v2m_flash.h>
+#include <drivers/console.h>
+#include <plat/common/platform.h>
+
+#include <plat_arm.h>
#pragma weak plat_arm_error_handler
diff --git a/plat/arm/common/arm_gicv2.c b/plat/arm/common/arm_gicv2.c
index 5644c60..fc848c1 100644
--- a/plat/arm/common/arm_gicv2.c
+++ b/plat/arm/common/arm_gicv2.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <gicv2.h>
-#include <plat_arm.h>
-#include <platform.h>
#include <platform_def.h>
+#include <drivers/arm/gicv2.h>
+#include <plat/common/platform.h>
+
+#include <plat_arm.h>
+
/******************************************************************************
* The following functions are defined as weak to allow a platform to override
* the way the GICv2 driver is initialised and used.
diff --git a/plat/arm/common/arm_gicv3.c b/plat/arm/common/arm_gicv3.c
index a43bff3..0f6690a 100644
--- a/plat/arm/common/arm_gicv3.c
+++ b/plat/arm/common/arm_gicv3.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_def.h>
-#include <gicv3.h>
-#include <interrupt_props.h>
-#include <plat_arm.h>
-#include <platform.h>
#include <platform_def.h>
-#include <utils.h>
+
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+
+#include <arm_def.h>
+#include <plat_arm.h>
/******************************************************************************
* The following functions are defined as weak to allow a platform to override
diff --git a/plat/arm/common/arm_image_load.c b/plat/arm/common/arm_image_load.c
index 4f86efd..791f05e 100644
--- a/plat/arm/common/arm_image_load.c
+++ b/plat/arm/common/arm_image_load.c
@@ -4,12 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_def.h>
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <plat_arm.h>
-#include <platform.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
+#include <arm_def.h>
+#include <plat_arm.h>
#pragma weak plat_flush_next_bl_params
#pragma weak plat_get_bl_image_load_info
diff --git a/plat/arm/common/arm_io_storage.c b/plat/arm/common/arm_io_storage.c
index cd58e45..d7c5cac 100644
--- a/plat/arm/common/arm_io_storage.c
+++ b/plat/arm/common/arm_io_storage.c
@@ -3,18 +3,22 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <assert.h>
-#include <debug.h>
-#include <firmware_image_package.h>
-#include <io_driver.h>
-#include <io_fip.h>
-#include <io_memmap.h>
-#include <io_storage.h>
-#include <plat_arm.h>
-#include <platform.h>
-#include <platform_def.h>
#include <string.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_memmap.h>
+#include <drivers/io/io_storage.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+#include <tools_share/firmware_image_package.h>
+
+#include <plat_arm.h>
/* IO devices */
static const io_dev_connector_t *fip_dev_con;
diff --git a/plat/arm/common/arm_nor_psci_mem_protect.c b/plat/arm/common/arm_nor_psci_mem_protect.c
index 2a46b95..4ae57e5 100644
--- a/plat/arm/common/arm_nor_psci_mem_protect.c
+++ b/plat/arm/common/arm_nor_psci_mem_protect.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
-#include <plat_arm.h>
#include <platform_def.h>
-#include <psci.h>
-#include <utils.h>
-#include <v2m_flash.h>
+
+#include <common/debug.h>
+#include <drivers/cfi/v2m_flash.h>
+#include <lib/psci/psci.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
+
+#include <plat_arm.h>
/*
* DRAM1 is used also to load the NS boot loader. For this reason we
diff --git a/plat/arm/common/arm_pm.c b/plat/arm/common/arm_pm.c
index 3be1b5d..acfd908 100644
--- a/plat/arm/common/arm_pm.c
+++ b/plat/arm/common/arm_pm.c
@@ -4,14 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <arm_def.h>
#include <assert.h>
#include <errno.h>
-#include <plat_arm.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch_helpers.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
+#include <arm_def.h>
+#include <plat_arm.h>
/* Allow ARM Standard platforms to override these functions */
#pragma weak plat_arm_program_trusted_mailbox
diff --git a/plat/arm/common/arm_sip_svc.c b/plat/arm/common/arm_sip_svc.c
index e482a89..6b0f7e7 100644
--- a/plat/arm/common/arm_sip_svc.c
+++ b/plat/arm/common/arm_sip_svc.c
@@ -4,14 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_sip_svc.h>
-#include <debug.h>
-#include <plat_arm.h>
-#include <pmf.h>
-#include <runtime_svc.h>
#include <stdint.h>
-#include <uuid.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/pmf/pmf.h>
+#include <tools_share/uuid.h>
+
+#include <arm_sip_svc.h>
+#include <plat_arm.h>
/* ARM SiP Service UUID */
DEFINE_SVC_UUID2(arm_sip_svc_uid,
diff --git a/plat/arm/common/arm_topology.c b/plat/arm/common/arm_topology.c
index b0ad4d1..6986e52 100644
--- a/plat/arm/common/arm_topology.c
+++ b/plat/arm/common/arm_topology.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <plat_arm.h>
#include <platform_def.h>
+#include <arch.h>
+
+#include <plat_arm.h>
+
/*******************************************************************************
* This function validates an MPIDR by checking whether it falls within the
* acceptable bounds. An error code (-1) is returned if an incorrect mpidr
diff --git a/plat/arm/common/arm_tzc400.c b/plat/arm/common/arm_tzc400.c
index 2ae084c..0346fa1 100644
--- a/plat/arm/common/arm_tzc400.c
+++ b/plat/arm/common/arm_tzc400.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <drivers/arm/tzc400.h>
+
#include <arm_def.h>
#include <arm_spm_def.h>
-#include <debug.h>
#include <plat_arm.h>
-#include <platform_def.h>
-#include <tzc400.h>
-
/* Weak definitions may be overridden in specific ARM standard platform */
#pragma weak plat_arm_security_setup
diff --git a/plat/arm/common/arm_tzc_dmc500.c b/plat/arm/common/arm_tzc_dmc500.c
index 6bd771b..bea3867 100644
--- a/plat/arm/common/arm_tzc_dmc500.c
+++ b/plat/arm/common/arm_tzc_dmc500.c
@@ -4,12 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_def.h>
#include <assert.h>
-#include <debug.h>
-#include <plat_arm.h>
+
#include <platform_def.h>
-#include <tzc_dmc500.h>
+
+#include <common/debug.h>
+#include <drivers/arm/tzc_dmc500.h>
+
+#include <arm_def.h>
+#include <plat_arm.h>
/*******************************************************************************
* Initialize the DMC500-TrustZone Controller for ARM standard platforms.
diff --git a/plat/arm/common/execution_state_switch.c b/plat/arm/common/execution_state_switch.c
index 8fa864d..e313410 100644
--- a/plat/arm/common/execution_state_switch.c
+++ b/plat/arm/common/execution_state_switch.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <arm_sip_svc.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <plat_arm.h>
-#include <psci.h>
-#include <smccc_helpers.h>
#include <stdbool.h>
#include <string.h>
-#include <utils.h>
+
+#include <arch_helpers.h>
+#include <context.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/psci/psci.h>
+#include <lib/utils.h>
+#include <smccc_helpers.h>
+
+#include <arm_sip_svc.h>
+#include <plat_arm.h>
/*
* Handle SMC from a lower exception level to switch its execution state
diff --git a/plat/arm/common/sp_min/arm_sp_min_setup.c b/plat/arm/common/sp_min/arm_sp_min_setup.c
index ca427d5..967b551 100644
--- a/plat/arm/common/sp_min/arm_sp_min_setup.c
+++ b/plat/arm/common/sp_min/arm_sp_min_setup.c
@@ -5,15 +5,18 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <mmio.h>
-#include <pl011.h>
-#include <plat_arm.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <platform_sp_min.h>
+
+#include <bl32/sp_min/platform_sp_min.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <plat_arm.h>
static entry_point_info_t bl33_image_ep_info;
diff --git a/plat/arm/common/tsp/arm_tsp_setup.c b/plat/arm/common/tsp/arm_tsp_setup.c
index 3cf8825..a3d2f71 100644
--- a/plat/arm/common/tsp/arm_tsp_setup.c
+++ b/plat/arm/common/tsp/arm_tsp_setup.c
@@ -4,15 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_def.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <pl011.h>
-#include <plat_arm.h>
+
#include <platform_def.h>
-#include <platform_tsp.h>
+
+#include <bl32/tsp/platform_tsp.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/console.h>
+
+#include <arm_def.h>
+#include <plat_arm.h>
#define BL32_END (unsigned long)(&__BL32_END__)
diff --git a/plat/arm/css/common/css_bl1_setup.c b/plat/arm/css/common/css_bl1_setup.c
index b1b275c..ae0f011 100644
--- a/plat/arm/css/common/css_bl1_setup.c
+++ b/plat/arm/css/common/css_bl1_setup.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <debug.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <plat/common/platform.h>
+
#include <plat_arm.h>
-#include <platform.h>
#include <soc_css.h>
void bl1_platform_setup(void)
diff --git a/plat/arm/css/common/css_bl2_setup.c b/plat/arm/css/common/css_bl2_setup.c
index e41b1ca..c1c7868 100644
--- a/plat/arm/css/common/css_bl2_setup.c
+++ b/plat/arm/css/common/css_bl2_setup.c
@@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <css_def.h>
-#include <debug.h>
-#include <mmio.h>
-#include <plat_arm.h>
#include <string.h>
-#include <utils.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
+
+#include <css_def.h>
+#include <plat_arm.h>
+
#include "../drivers/scp/css_scp.h"
/* Weak definition may be overridden in specific CSS based platform */
diff --git a/plat/arm/css/common/css_bl2u_setup.c b/plat/arm/css/common/css_bl2u_setup.c
index 4ceb5cd..564e98f 100644
--- a/plat/arm/css/common/css_bl2u_setup.c
+++ b/plat/arm/css/common/css_bl2u_setup.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <debug.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <plat/common/platform.h>
+
#include <plat_arm.h>
-#include <platform.h>
+
#include "../drivers/scp/css_scp.h"
/* Weak definition may be overridden in specific CSS based platform */
diff --git a/plat/arm/css/common/css_pm.c b/plat/arm/css/common/css_pm.c
index 4735a9d..8a156e6 100644
--- a/plat/arm/css/common/css_pm.c
+++ b/plat/arm/css/common/css_pm.c
@@ -4,15 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <cassert.h>
-#include <css_pm.h>
-#include <debug.h>
#include <errno.h>
-#include <plat_arm.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/cassert.h>
+#include <plat/common/platform.h>
+
+#include <css_pm.h>
+#include <plat_arm.h>
+
#include "../drivers/scp/css_scp.h"
/* Allow CSS platforms to override `plat_arm_psci_pm_ops` */
diff --git a/plat/arm/css/common/css_topology.c b/plat/arm/css/common/css_topology.c
index d1f1c98..8ac2232 100644
--- a/plat/arm/css/common/css_topology.c
+++ b/plat/arm/css/common/css_topology.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <plat_arm.h>
-#include <platform.h>
#include <assert.h>
+#include <plat/common/platform.h>
+
+#include <plat_arm.h>
+
#if ARM_PLAT_MT
#pragma weak plat_arm_get_cpu_pe_count
#endif
diff --git a/plat/arm/css/drivers/mhu/css_mhu.c b/plat/arm/css/drivers/mhu/css_mhu.c
index 7b33317..e13818f 100644
--- a/plat/arm/css/drivers/mhu/css_mhu.c
+++ b/plat/arm/css/drivers/mhu/css_mhu.c
@@ -4,13 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bakery_lock.h>
-#include <css_def.h>
-#include <mmio.h>
-#include <plat_arm.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+
+#include <css_def.h>
+#include <plat_arm.h>
+
#include "css_mhu.h"
/* SCP MHU secure channel registers */
diff --git a/plat/arm/css/drivers/mhu/css_mhu_doorbell.c b/plat/arm/css/drivers/mhu/css_mhu_doorbell.c
index 54f3e05..b3203c2 100644
--- a/plat/arm/css/drivers/mhu/css_mhu_doorbell.c
+++ b/plat/arm/css/drivers/mhu/css_mhu_doorbell.c
@@ -4,8 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <platform_def.h>
+
+#include <arch_helpers.h>
+
#include "css_mhu_doorbell.h"
#include "../scmi/scmi.h"
diff --git a/plat/arm/css/drivers/mhu/css_mhu_doorbell.h b/plat/arm/css/drivers/mhu/css_mhu_doorbell.h
index cb75ed0..ecee563 100644
--- a/plat/arm/css/drivers/mhu/css_mhu_doorbell.h
+++ b/plat/arm/css/drivers/mhu/css_mhu_doorbell.h
@@ -7,9 +7,10 @@
#ifndef CSS_MHU_DOORBELL_H
#define CSS_MHU_DOORBELL_H
-#include <mmio.h>
#include <stdint.h>
+#include <lib/mmio.h>
+
/* MHUv2 Base Address */
#define MHUV2_BASE_ADDR PLAT_CSS_MHU_BASE
diff --git a/plat/arm/css/drivers/scmi/scmi.h b/plat/arm/css/drivers/scmi/scmi.h
index 28dfc9a..df259f7 100644
--- a/plat/arm/css/drivers/scmi/scmi.h
+++ b/plat/arm/css/drivers/scmi/scmi.h
@@ -7,11 +7,12 @@
#ifndef SCMI_H
#define SCMI_H
-#include <bakery_lock.h>
-#include <psci.h>
#include <stddef.h>
#include <stdint.h>
-#include <spinlock.h>
+
+#include <lib/bakery_lock.h>
+#include <lib/psci/psci.h>
+#include <lib/spinlock.h>
/* Supported SCMI Protocol Versions */
#define SCMI_AP_CORE_PROTO_VER MAKE_SCMI_VERSION(1, 0)
diff --git a/plat/arm/css/drivers/scmi/scmi_ap_core_proto.c b/plat/arm/css/drivers/scmi/scmi_ap_core_proto.c
index 1438cba..e495dcc 100644
--- a/plat/arm/css/drivers/scmi/scmi_ap_core_proto.c
+++ b/plat/arm/css/drivers/scmi/scmi_ap_core_proto.c
@@ -4,9 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+
#include "scmi.h"
#include "scmi_private.h"
diff --git a/plat/arm/css/drivers/scmi/scmi_common.c b/plat/arm/css/drivers/scmi/scmi_common.c
index b34178e..1b4ecb2 100644
--- a/plat/arm/css/drivers/scmi/scmi_common.c
+++ b/plat/arm/css/drivers/scmi/scmi_common.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+
#include "scmi.h"
#include "scmi_private.h"
-
#if HW_ASSISTED_COHERENCY
#define scmi_lock_init(lock)
#define scmi_lock_get(lock) spin_lock(lock)
diff --git a/plat/arm/css/drivers/scmi/scmi_private.h b/plat/arm/css/drivers/scmi/scmi_private.h
index a4f4179..6530573 100644
--- a/plat/arm/css/drivers/scmi/scmi_private.h
+++ b/plat/arm/css/drivers/scmi/scmi_private.h
@@ -7,6 +7,8 @@
#ifndef SCMI_PRIVATE_H
#define SCMI_PRIVATE_H
+#include <lib/mmio.h>
+
/*
* SCMI power domain management protocol message and response lengths. It is
* calculated as sum of length in bytes of the message header (4) and payload
diff --git a/plat/arm/css/drivers/scmi/scmi_pwr_dmn_proto.c b/plat/arm/css/drivers/scmi/scmi_pwr_dmn_proto.c
index 90c5d6b..f315621 100644
--- a/plat/arm/css/drivers/scmi/scmi_pwr_dmn_proto.c
+++ b/plat/arm/css/drivers/scmi/scmi_pwr_dmn_proto.c
@@ -4,9 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+
#include "scmi.h"
#include "scmi_private.h"
diff --git a/plat/arm/css/drivers/scmi/scmi_sys_pwr_proto.c b/plat/arm/css/drivers/scmi/scmi_sys_pwr_proto.c
index f6da394..03c3c06 100644
--- a/plat/arm/css/drivers/scmi/scmi_sys_pwr_proto.c
+++ b/plat/arm/css/drivers/scmi/scmi_sys_pwr_proto.c
@@ -4,9 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+
#include "scmi.h"
#include "scmi_private.h"
diff --git a/plat/arm/css/drivers/scp/css_bom_bootloader.c b/plat/arm/css/drivers/scp/css_bom_bootloader.c
index 5268510..27c9e1d 100644
--- a/plat/arm/css/drivers/scp/css_bom_bootloader.c
+++ b/plat/arm/css/drivers/scp/css_bom_bootloader.c
@@ -4,12 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <css_def.h>
-#include <debug.h>
-#include <platform.h>
#include <stdint.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <plat/common/platform.h>
+
+#include <css_def.h>
+
#include "../mhu/css_mhu.h"
#include "../scpi/css_scpi.h"
#include "css_scp.h"
diff --git a/plat/arm/css/drivers/scp/css_pm_scmi.c b/plat/arm/css/drivers/scp/css_pm_scmi.c
index 1397fd8..bd6b595 100644
--- a/plat/arm/css/drivers/scp/css_pm_scmi.c
+++ b/plat/arm/css/drivers/scp/css_pm_scmi.c
@@ -4,14 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
+#include <string.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <plat/common/platform.h>
+
#include <css_def.h>
#include <css_pm.h>
-#include <debug.h>
#include <plat_arm.h>
-#include <platform.h>
-#include <string.h>
+
#include "../scmi/scmi.h"
#include "css_scp.h"
diff --git a/plat/arm/css/drivers/scp/css_pm_scpi.c b/plat/arm/css/drivers/scp/css_pm_scpi.c
index 123d54f..f53ac30 100644
--- a/plat/arm/css/drivers/scp/css_pm_scpi.c
+++ b/plat/arm/css/drivers/scp/css_pm_scpi.c
@@ -4,11 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+
#include <css_pm.h>
-#include <debug.h>
#include <plat_arm.h>
+
#include "../scpi/css_scpi.h"
#include "css_scp.h"
diff --git a/plat/arm/css/drivers/scp/css_scp.h b/plat/arm/css/drivers/scp/css_scp.h
index 84c1487..f3c08c5 100644
--- a/plat/arm/css/drivers/scp/css_scp.h
+++ b/plat/arm/css/drivers/scp/css_scp.h
@@ -7,10 +7,12 @@
#ifndef CSS_SCP_H
#define CSS_SCP_H
-#include <cassert.h>
-#include <platform_def.h>
#include <stdint.h>
+#include <platform_def.h>
+
+#include <lib/cassert.h>
+
/* Forward declarations */
struct psci_power_state;
diff --git a/plat/arm/css/drivers/scp/css_sds.c b/plat/arm/css/drivers/scp/css_sds.c
index 561e97b..c152abc 100644
--- a/plat/arm/css/drivers/scp/css_sds.c
+++ b/plat/arm/css/drivers/scp/css_sds.c
@@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <css_def.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <platform.h>
#include <stdint.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <plat/common/platform.h>
+
+#include <css_def.h>
+
#include "css_scp.h"
#include "../sds/sds.h"
diff --git a/plat/arm/css/drivers/scpi/css_scpi.c b/plat/arm/css/drivers/scpi/css_scpi.c
index 2ed5760..42bf3b8 100644
--- a/plat/arm/css/drivers/scpi/css_scpi.c
+++ b/plat/arm/css/drivers/scpi/css_scpi.c
@@ -4,13 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <css_def.h>
-#include <debug.h>
-#include <platform.h>
#include <string.h>
-#include <utils.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+
+#include <css_def.h>
+
#include "../mhu/css_mhu.h"
#include "css_scpi.h"
diff --git a/plat/arm/css/drivers/sds/sds.c b/plat/arm/css/drivers/sds/sds.c
index e2fac54..3eeb0dc 100644
--- a/plat/arm/css/drivers/sds/sds.c
+++ b/plat/arm/css/drivers/sds/sds.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <css_def.h>
#include <stdint.h>
#include <string.h>
+#include <arch_helpers.h>
+#include <common/debug.h>
+
+#include <css_def.h>
#include "sds.h"
#include "sds_private.h"
diff --git a/plat/arm/css/sgi/include/sgi_base_platform_def.h b/plat/arm/css/sgi/include/sgi_base_platform_def.h
index 8705d63..ad7ab81 100644
--- a/plat/arm/css/sgi/include/sgi_base_platform_def.h
+++ b/plat/arm/css/sgi/include/sgi_base_platform_def.h
@@ -7,15 +7,16 @@
#ifndef SGI_BASE_PLATFORM_DEF_H
#define SGI_BASE_PLATFORM_DEF_H
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <plat/common/common_def.h>
+
#include <arm_def.h>
#include <arm_spm_def.h>
#include <board_css_def.h>
-#include <common_def.h>
#include <css_def.h>
#include <soc_css_def.h>
-#include <utils_def.h>
#include <v2m_def.h>
-#include <xlat_tables_defs.h>
#define PLATFORM_CORE_COUNT (PLAT_ARM_CLUSTER_COUNT * \
CSS_SGI_MAX_CPUS_PER_CLUSTER * \
diff --git a/plat/arm/css/sgi/sgi-common.mk b/plat/arm/css/sgi/sgi-common.mk
index 46fa7c4..613d3d5 100644
--- a/plat/arm/css/sgi/sgi-common.mk
+++ b/plat/arm/css/sgi/sgi-common.mk
@@ -47,7 +47,7 @@
endif
ifneq (${RESET_TO_BL31},0)
- $(error "Using BL31 as the reset vector is not supported on ${PLATFORM} platform. \
+ $(error "Using BL31 as the reset vector is not supported on ${PLAT} platform. \
Please set RESET_TO_BL31 to 0.")
endif
diff --git a/plat/arm/css/sgi/sgi_bl31_setup.c b/plat/arm/css/sgi/sgi_bl31_setup.c
index b1aa089..617a62b 100644
--- a/plat/arm/css/sgi/sgi_bl31_setup.c
+++ b/plat/arm/css/sgi/sgi_bl31_setup.c
@@ -5,12 +5,16 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
+
#include <libfdt.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+
#include <plat_arm.h>
#include <sgi_ras.h>
#include <sgi_variant.h>
+
#include "../../css/drivers/scmi/scmi.h"
#include "../../css/drivers/mhu/css_mhu_doorbell.h"
diff --git a/plat/arm/css/sgi/sgi_image_load.c b/plat/arm/css/sgi/sgi_image_load.c
index e078bd2..1ed219d 100644
--- a/plat/arm/css/sgi/sgi_image_load.c
+++ b/plat/arm/css/sgi/sgi_image_load.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
-#include <desc_image_load.h>
#include <libfdt.h>
-#include <platform.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
+
#include <sgi_variant.h>
/*******************************************************************************
diff --git a/plat/arm/css/sgi/sgi_interconnect.c b/plat/arm/css/sgi/sgi_interconnect.c
index 074f8a2..e86c760 100644
--- a/plat/arm/css/sgi/sgi_interconnect.c
+++ b/plat/arm/css/sgi/sgi_interconnect.c
@@ -5,7 +5,7 @@
*/
#include <arch_helpers.h>
-#include <debug.h>
+#include <common/debug.h>
/*
* For SGI575 which support FCM (with automatic interconnect enter/exit),
diff --git a/plat/arm/css/sgi/sgi_plat.c b/plat/arm/css/sgi/sgi_plat.c
index 710430b..79f3e5b 100644
--- a/plat/arm/css/sgi/sgi_plat.c
+++ b/plat/arm/css/sgi/sgi_plat.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
+#include <platform_def.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/ccn.h>
+#include <plat/common/platform.h>
+#include <services/secure_partition.h>
+
#include <arm_def.h>
#include <arm_spm_def.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <ccn.h>
-#include <debug.h>
#include <plat_arm.h>
-#include <platform_def.h>
-#include <platform.h>
-#include <secure_partition.h>
#include "../../../../bl1/bl1_private.h"
#if USE_COHERENT_MEM
diff --git a/plat/arm/css/sgi/sgi_ras.c b/plat/arm/css/sgi/sgi_ras.c
index ac4610d..a6a32d1 100644
--- a/plat/arm/css/sgi/sgi_ras.c
+++ b/plat/arm/css/sgi/sgi_ras.c
@@ -4,18 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_spm_def.h>
#include <assert.h>
-#include <context_mgmt.h>
-#include <interrupt_mgmt.h>
-#include <mm_svc.h>
-#include <ras.h>
-#include <sgi_ras.h>
-#include <platform.h>
-#include <spm_svc.h>
-#include <sdei.h>
#include <string.h>
+#include <bl31/interrupt_mgmt.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/extensions/ras.h>
+#include <plat/common/platform.h>
+#include <services/mm_svc.h>
+#include <services/sdei.h>
+#include <services/spm_svc.h>
+
+#include <arm_spm_def.h>
+#include <sgi_ras.h>
+
static int sgi_ras_intr_handler(const struct err_record_info *err_rec,
int probe_data,
const struct err_handler_data *const data);
diff --git a/plat/arm/css/sgm/include/sgm_base_platform_def.h b/plat/arm/css/sgm/include/sgm_base_platform_def.h
index 2178f06..e3fa3f3 100644
--- a/plat/arm/css/sgm/include/sgm_base_platform_def.h
+++ b/plat/arm/css/sgm/include/sgm_base_platform_def.h
@@ -7,13 +7,14 @@
#ifndef SGM_BASE_PLATFORM_DEF_H
#define SGM_BASE_PLATFORM_DEF_H
+#include <drivers/arm/tzc400.h>
+#include <drivers/arm/tzc_common.h>
+#include <plat/common/common_def.h>
+
#include <arm_def.h>
#include <board_css_def.h>
-#include <common_def.h>
#include <css_def.h>
#include <soc_css_def.h>
-#include <tzc400.h>
-#include <tzc_common.h>
#include <v2m_def.h>
/* CPU topology */
diff --git a/plat/arm/css/sgm/include/sgm_plat_config.h b/plat/arm/css/sgm/include/sgm_plat_config.h
index 79e6b5c..29b98d4 100644
--- a/plat/arm/css/sgm/include/sgm_plat_config.h
+++ b/plat/arm/css/sgm/include/sgm_plat_config.h
@@ -7,8 +7,8 @@
#ifndef SGM_PLAT_CONFIG_H
#define SGM_PLAT_CONFIG_H
-#include <ccn.h>
-#include <gicv3.h>
+#include <drivers/arm/ccn.h>
+#include <drivers/arm/gicv3.h>
/* The type of interconnect */
typedef enum {
diff --git a/plat/arm/css/sgm/sgm-common.mk b/plat/arm/css/sgm/sgm-common.mk
index 3eb4840..ddeac68 100644
--- a/plat/arm/css/sgm/sgm-common.mk
+++ b/plat/arm/css/sgm/sgm-common.mk
@@ -46,7 +46,7 @@
${CSS_SGM_BASE}/sgm_plat_config.c
ifneq (${RESET_TO_BL31},0)
- $(error "Using BL31 as the reset vector is not supported on ${PLATFORM} platform. \
+ $(error "Using BL31 as the reset vector is not supported on ${PLAT} platform. \
Please set RESET_TO_BL31 to 0.")
endif
diff --git a/plat/arm/css/sgm/sgm_bl1_setup.c b/plat/arm/css/sgm/sgm_bl1_setup.c
index dc3d71d..8b7c5da 100644
--- a/plat/arm/css/sgm/sgm_bl1_setup.c
+++ b/plat/arm/css/sgm/sgm_bl1_setup.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <debug.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+
#include <plat_arm.h>
#include <sgm_plat_config.h>
#include <soc_css.h>
diff --git a/plat/arm/css/sgm/sgm_bl31_setup.c b/plat/arm/css/sgm/sgm_bl31_setup.c
index 952572e..7967cb5 100644
--- a/plat/arm/css/sgm/sgm_bl31_setup.c
+++ b/plat/arm/css/sgm/sgm_bl31_setup.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <debug.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+
#include <plat_arm.h>
#include <sgm_plat_config.h>
+
#include "../../css/drivers/scmi/scmi.h"
#include "../../css/drivers/mhu/css_mhu_doorbell.h"
diff --git a/plat/arm/css/sgm/sgm_mmap_config.c b/plat/arm/css/sgm/sgm_mmap_config.c
index 0f04109..a4df9ab 100644
--- a/plat/arm/css/sgm/sgm_mmap_config.c
+++ b/plat/arm/css/sgm/sgm_mmap_config.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_def.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <plat_arm.h>
#include <platform_def.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+
+#include <arm_def.h>
+#include <plat_arm.h>
#include <sgm_variant.h>
/*
@@ -39,7 +41,9 @@
CSS_MAP_GIC_DEVICE,
SOC_CSS_MAP_DEVICE,
ARM_MAP_NS_DRAM1,
+#ifdef SPD_tspd
ARM_MAP_TSP_SEC_MEM,
+#endif
#ifdef SPD_opteed
ARM_OPTEE_PAGEABLE_LOAD_MEM,
#endif
diff --git a/plat/arm/css/sgm/sgm_plat_config.c b/plat/arm/css/sgm/sgm_plat_config.c
index e977e61..2a43487 100644
--- a/plat/arm/css/sgm/sgm_plat_config.c
+++ b/plat/arm/css/sgm/sgm_plat_config.c
@@ -5,12 +5,15 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <plat_arm.h>
+#include <string.h>
+
#include <platform_def.h>
+
+#include <common/debug.h>
+
+#include <plat_arm.h>
#include <sgm_plat_config.h>
#include <sgm_variant.h>
-#include <string.h>
static css_plat_config_t *css_plat_info;
diff --git a/plat/arm/css/sgm/sgm_security.c b/plat/arm/css/sgm/sgm_security.c
index 7f98060..548ec7b 100644
--- a/plat/arm/css/sgm/sgm_security.c
+++ b/plat/arm/css/sgm/sgm_security.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
+#include <common/debug.h>
+#include <drivers/arm/tzc_dmc500.h>
+
#include <plat_arm.h>
#include <sgm_variant.h>
#include <soc_css.h>
-#include <tzc_dmc500.h>
/* Is populated with the DMC-500 controllers base addresses */
static tzc_dmc500_driver_data_t plat_driver_data;
diff --git a/plat/arm/soc/common/soc_css_security.c b/plat/arm/soc/common/soc_css_security.c
index f229679..bbc5dcd 100644
--- a/plat/arm/soc/common/soc_css_security.c
+++ b/plat/arm/soc/common/soc_css_security.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <board_css_def.h>
-#include <mmio.h>
-#include <nic_400.h>
#include <platform_def.h>
+
+#include <drivers/arm/nic_400.h>
+#include <lib/mmio.h>
+
+#include <board_css_def.h>
#include <soc_css.h>
#include <soc_css_def.h>
diff --git a/plat/common/aarch32/crash_console_helpers.S b/plat/common/aarch32/crash_console_helpers.S
index fc37c08..c9ad12c 100644
--- a/plat/common/aarch32/crash_console_helpers.S
+++ b/plat/common/aarch32/crash_console_helpers.S
@@ -10,7 +10,7 @@
*/
#include <asm_macros.S>
-#include <console.h>
+#include <drivers/console.h>
.globl plat_crash_console_init
.globl plat_crash_console_putc
diff --git a/plat/common/aarch32/plat_common.c b/plat/common/aarch32/plat_common.c
index 16c2b5c..2c1a8fa 100644
--- a/plat/common/aarch32/plat_common.c
+++ b/plat/common/aarch32/plat_common.c
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
-#include <xlat_mmu_helpers.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
+#include <plat/common/platform.h>
/*
* The following platform setup functions are weakly defined. They
diff --git a/plat/common/aarch32/plat_sp_min_common.c b/plat/common/aarch32/plat_sp_min_common.c
index f1b1e9c..3bc84b1 100644
--- a/plat/common/aarch32/plat_sp_min_common.c
+++ b/plat/common/aarch32/plat_sp_min_common.c
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <console.h>
-#include <platform.h>
+#include <drivers/console.h>
+#include <plat/common/platform.h>
#include <platform_sp_min.h>
/*
diff --git a/plat/common/aarch64/crash_console_helpers.S b/plat/common/aarch64/crash_console_helpers.S
index 8f8ca11..491a99d 100644
--- a/plat/common/aarch64/crash_console_helpers.S
+++ b/plat/common/aarch64/crash_console_helpers.S
@@ -10,7 +10,7 @@
*/
#include <asm_macros.S>
-#include <console.h>
+#include <drivers/console.h>
.globl plat_crash_console_init
.globl plat_crash_console_putc
diff --git a/plat/common/aarch64/plat_common.c b/plat/common/aarch64/plat_common.c
index e6f5f20..1424c78 100644
--- a/plat/common/aarch64/plat_common.c
+++ b/plat/common/aarch64/plat_common.c
@@ -4,14 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <console.h>
-#include <platform.h>
+
+#include <arch_helpers.h>
+#include <drivers/console.h>
#if RAS_EXTENSION
-#include <ras.h>
+#include <lib/extensions/ras.h>
#endif
-#include <xlat_mmu_helpers.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
+#include <plat/common/platform.h>
/*
* The following platform setup functions are weakly defined. They
diff --git a/plat/common/aarch64/platform_helpers.S b/plat/common/aarch64/platform_helpers.S
index 8952319..b5788fb 100644
--- a/plat/common/aarch64/platform_helpers.S
+++ b/plat/common/aarch64/platform_helpers.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <console.h>
+#include <drivers/console.h>
#include <platform_def.h>
.weak plat_report_exception
diff --git a/plat/common/plat_bl1_common.c b/plat/common/plat_bl1_common.c
index 824f9e5..5733781 100644
--- a/plat/common/plat_bl1_common.c
+++ b/plat/common/plat_bl1_common.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <bl1.h>
-#include <debug.h>
#include <errno.h>
-#include <platform.h>
+
#include <platform_def.h>
+#include <arch_helpers.h>
+#include <bl1/bl1.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <plat/common/platform.h>
+
/*
* The following platform functions are weakly defined. They
* are default implementations that allow BL1 to compile in
diff --git a/plat/common/plat_bl_common.c b/plat/common/plat_bl_common.c
index 4cf1cc5..2357edf 100644
--- a/plat/common/plat_bl_common.c
+++ b/plat/common/plat_bl_common.c
@@ -4,16 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
#include <errno.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#if TRUSTED_BOARD_BOOT
-#include <mbedtls_config.h>
+#include <drivers/auth/mbedtls/mbedtls_config.h>
#endif
-#include <platform.h>
-#include <xlat_tables_compat.h>
+#include <lib/xlat_tables/xlat_tables_compat.h>
+#include <plat/common/platform.h>
/*
* The following platform functions are weakly defined. The Platforms
diff --git a/plat/common/plat_gicv2.c b/plat/common/plat_gicv2.c
index 4b66873..4c76f1b 100644
--- a/plat/common/plat_gicv2.c
+++ b/plat/common/plat_gicv2.c
@@ -3,13 +3,15 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <assert.h>
-#include <gic_common.h>
-#include <gicv2.h>
-#include <interrupt_mgmt.h>
-#include <platform.h>
#include <stdbool.h>
+#include <bl31/interrupt_mgmt.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <plat/common/platform.h>
+
/*
* The following platform GIC functions are weakly defined. They
* provide typical implementations that may be re-used by multiple
diff --git a/plat/common/plat_gicv3.c b/plat/common/plat_gicv3.c
index f8277fe..f5ed6fc 100644
--- a/plat/common/plat_gicv3.c
+++ b/plat/common/plat_gicv3.c
@@ -3,16 +3,18 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
+
#include <assert.h>
-#include <bl_common.h>
-#include <cassert.h>
-#include <gic_common.h>
-#include <gicv3.h>
-#include <interrupt_mgmt.h>
-#include <platform.h>
#include <stdbool.h>
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <bl31/interrupt_mgmt.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/cassert.h>
+#include <plat/common/platform.h>
+
#ifdef IMAGE_BL31
/*
diff --git a/plat/common/plat_log_common.c b/plat/common/plat_log_common.c
index 49e1c15..66b9758 100644
--- a/plat/common/plat_log_common.c
+++ b/plat/common/plat_log_common.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
+#include <common/debug.h>
+#include <plat/common/platform.h>
/* Allow platforms to override the log prefix string */
#pragma weak plat_log_get_prefix
diff --git a/plat/common/plat_psci_common.c b/plat/common/plat_psci_common.c
index fab3c77..1a29d9c 100644
--- a/plat/common/plat_psci_common.c
+++ b/plat/common/plat_psci_common.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
#include <assert.h>
-#include <platform.h>
-#include <pmf.h>
-#include <psci.h>
+
+#include <arch.h>
+#include <lib/pmf/pmf.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
#if ENABLE_PSCI_STAT && ENABLE_PMF
#pragma weak plat_psci_stat_accounting_start
diff --git a/plat/common/plat_spm_rd.c b/plat/common/plat_spm_rd.c
index 69b9a23..0c72cb7 100644
--- a/plat/common/plat_spm_rd.c
+++ b/plat/common/plat_spm_rd.c
@@ -5,13 +5,16 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <fdt_wrappers.h>
-#include <libfdt.h>
-#include <platform_def.h>
-#include <sp_res_desc.h>
#include <string.h>
-#include <object_pool.h>
+
+#include <libfdt.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <common/fdt_wrappers.h>
+#include <lib/object_pool.h>
+#include <services/sp_res_desc.h>
/*******************************************************************************
* Resource pool
diff --git a/plat/common/plat_spm_sp.c b/plat/common/plat_spm_sp.c
index 7b7fbd9..ce48279 100644
--- a/plat/common/plat_spm_sp.c
+++ b/plat/common/plat_spm_sp.c
@@ -5,9 +5,11 @@
*/
#include <assert.h>
-#include <debug.h>
+
#include <platform_def.h>
-#include <sptool.h>
+
+#include <common/debug.h>
+#include <tools_share/sptool.h>
static unsigned int sp_next;
diff --git a/plat/common/tbbr/plat_tbbr.c b/plat/common/tbbr/plat_tbbr.c
index f5a4f31..12ab0a9 100644
--- a/plat/common/tbbr/plat_tbbr.c
+++ b/plat/common/tbbr/plat_tbbr.c
@@ -5,14 +5,15 @@
*/
#include <assert.h>
-#include <auth/auth_mod.h>
-#include <platform.h>
+#include <string.h>
+
+#include <drivers/auth/auth_mod.h>
+#include <plat/common/platform.h>
#if USE_TBBR_DEFS
-#include <tbbr_oid.h>
+#include <tools_share/tbbr_oid.h>
#else
#include <platform_oid.h>
#endif
-#include <string.h>
/*
* Store a new non-volatile counter value. This implementation
diff --git a/plat/hisilicon/hikey/aarch64/hikey_common.c b/plat/hisilicon/hikey/aarch64/hikey_common.c
index 60e4d86..702fc2d 100644
--- a/plat/hisilicon/hikey/aarch64/hikey_common.c
+++ b/plat/hisilicon/hikey/aarch64/hikey_common.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
+
#include <hikey_def.h>
#include <hikey_layout.h>
-#include <mmio.h>
-#include <platform.h>
-#include <xlat_tables.h>
#define MAP_DDR MAP_REGION_FLAT(DDR_BASE, \
DDR_SIZE - DDR_SEC_SIZE, \
diff --git a/plat/hisilicon/hikey/hikey_bl1_setup.c b/plat/hisilicon/hikey/hikey_bl1_setup.c
index 6fcb597..a08bdfa 100644
--- a/plat/hisilicon/hikey/hikey_bl1_setup.c
+++ b/plat/hisilicon/hikey/hikey_bl1_setup.c
@@ -4,23 +4,25 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <dw_mmc.h>
#include <errno.h>
+#include <string.h>
+
+#include <arch_helpers.h>
+#include <bl1/tbbr/tbbr_img_desc.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/mmc.h>
+#include <drivers/synopsys/dw_mmc.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include <hi6220.h>
#include <hikey_def.h>
#include <hikey_layout.h>
-#include <mmc.h>
-#include <mmio.h>
-#include <pl011.h>
-#include <platform.h>
-#include <string.h>
-#include <tbbr/tbbr_img_desc.h>
-#include "../../bl1/bl1_private.h"
+#include "../../../bl1/bl1_private.h"
#include "hikey_private.h"
/* Data structure which holds the extents of the trusted RAM for BL1 */
diff --git a/plat/hisilicon/hikey/hikey_bl2_mem_params_desc.c b/plat/hisilicon/hikey/hikey_bl2_mem_params_desc.c
index 23c16ed..4e013a0 100644
--- a/plat/hisilicon/hikey/hikey_bl2_mem_params_desc.c
+++ b/plat/hisilicon/hikey/hikey_bl2_mem_params_desc.c
@@ -4,11 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h> /* also includes hikey_def.h and hikey_layout.h*/
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* Following descriptor provides BL image/ep information that gets used
diff --git a/plat/hisilicon/hikey/hikey_bl2_setup.c b/plat/hisilicon/hikey/hikey_bl2_setup.c
index 125d665..b872373 100644
--- a/plat/hisilicon/hikey/hikey_bl2_setup.c
+++ b/plat/hisilicon/hikey/hikey_bl2_setup.c
@@ -4,27 +4,29 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <desc_image_load.h>
-#include <dw_mmc.h>
#include <errno.h>
+#include <string.h>
+
+#include <platform_def.h> /* also includes hikey_def.h and hikey_layout.h*/
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/delay_timer.h>
+#include <drivers/mmc.h>
+#include <drivers/synopsys/dw_mmc.h>
+#include <lib/mmio.h>
+#ifdef SPD_opteed
+#include <lib/optee_utils.h>
+#endif
+#include <plat/common/platform.h>
+
#include <hi6220.h>
#include <hisi_mcu.h>
#include <hisi_sram_map.h>
-#include <mmc.h>
-#include <mmio.h>
-#ifdef SPD_opteed
-#include <optee_utils.h>
-#endif
-#include <pl011.h>
-#include <platform.h>
-#include <platform_def.h> /* also includes hikey_def.h and hikey_layout.h*/
-#include <string.h>
-
#include "hikey_private.h"
/*
diff --git a/plat/hisilicon/hikey/hikey_bl31_setup.c b/plat/hisilicon/hikey/hikey_bl31_setup.c
index 0e061e9..b2dcb61 100644
--- a/plat/hisilicon/hikey/hikey_bl31_setup.c
+++ b/plat/hisilicon/hikey/hikey_bl31_setup.c
@@ -4,21 +4,24 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <cci.h>
-#include <debug.h>
#include <errno.h>
-#include <gicv2.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/pl011.h>
+#include <lib/mmio.h>
+
#include <hi6220.h>
#include <hikey_def.h>
#include <hisi_ipc.h>
#include <hisi_pwrc.h>
-#include <interrupt_props.h>
-#include <mmio.h>
-#include <pl011.h>
-#include <platform_def.h>
#include "hikey_private.h"
diff --git a/plat/hisilicon/hikey/hikey_bl_common.c b/plat/hisilicon/hikey/hikey_bl_common.c
index b254a90..d062de4 100644
--- a/plat/hisilicon/hikey/hikey_bl_common.c
+++ b/plat/hisilicon/hikey/hikey_bl_common.c
@@ -5,13 +5,13 @@
*/
#include <arch_helpers.h>
-#include <gpio.h>
+#include <drivers/arm/pl061_gpio.h>
+#include <drivers/arm/sp804_delay_timer.h>
+#include <drivers/gpio.h>
+#include <lib/mmio.h>
+
#include <hi6220.h>
#include <hi6553.h>
-#include <mmio.h>
-#include <pl061_gpio.h>
-#include <sp804_delay_timer.h>
-
#include "hikey_private.h"
void hikey_sp804_init(void)
diff --git a/plat/hisilicon/hikey/hikey_ddr.c b/plat/hisilicon/hikey/hikey_ddr.c
index 43cece0..e688c15 100644
--- a/plat/hisilicon/hikey/hikey_ddr.c
+++ b/plat/hisilicon/hikey/hikey_ddr.c
@@ -4,16 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
#include <errno.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/sp804_delay_timer.h>
+#include <lib/mmio.h>
+
#include <hi6220.h>
#include <hi6553.h>
#include <hisi_sram_map.h>
-#include <mmio.h>
-#include <sp804_delay_timer.h>
-
#include "hikey_private.h"
static void init_pll(void)
diff --git a/plat/hisilicon/hikey/hikey_image_load.c b/plat/hisilicon/hikey/hikey_image_load.c
index 32ca36d..0ab1ca4 100644
--- a/plat/hisilicon/hikey/hikey_image_load.c
+++ b/plat/hisilicon/hikey/hikey_image_load.c
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* This function flushes the data structures so that they are visible
diff --git a/plat/hisilicon/hikey/hikey_io_storage.c b/plat/hisilicon/hikey/hikey_io_storage.c
index 3efbefe..11dd973 100644
--- a/plat/hisilicon/hikey/hikey_io_storage.c
+++ b/plat/hisilicon/hikey/hikey_io_storage.c
@@ -4,21 +4,24 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
#include <errno.h>
-#include <firmware_image_package.h>
-#include <io_block.h>
-#include <io_driver.h>
-#include <io_fip.h>
-#include <io_memmap.h>
-#include <io_storage.h>
-#include <mmc.h>
-#include <mmio.h>
-#include <platform_def.h>
-#include <semihosting.h> /* For FOPEN_MODE_... */
#include <string.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/io/io_block.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_memmap.h>
+#include <drivers/io/io_storage.h>
+#include <drivers/mmc.h>
+#include <lib/mmio.h>
+#include <lib/semihosting.h>
+#include <tools_share/firmware_image_package.h>
+
#include "hikey_private.h"
#define EMMC_BLOCK_SHIFT 9
diff --git a/plat/hisilicon/hikey/hikey_pm.c b/plat/hisilicon/hikey/hikey_pm.c
index 3128a3d..05c1e7f 100644
--- a/plat/hisilicon/hikey/hikey_pm.c
+++ b/plat/hisilicon/hikey/hikey_pm.c
@@ -4,19 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <cci.h>
-#include <debug.h>
-#include <gicv2.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/sp804_delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+
#include <hi6220.h>
#include <hikey_def.h>
#include <hisi_ipc.h>
#include <hisi_pwrc.h>
#include <hisi_sram_map.h>
-#include <mmio.h>
-#include <psci.h>
-#include <sp804_delay_timer.h>
#define CORE_PWR_STATE(state) \
((state)->pwr_domain_state[MPIDR_AFFLVL0])
diff --git a/plat/hisilicon/hikey/hikey_private.h b/plat/hisilicon/hikey/hikey_private.h
index ca1baa3..d82a079 100644
--- a/plat/hisilicon/hikey/hikey_private.h
+++ b/plat/hisilicon/hikey/hikey_private.h
@@ -7,7 +7,7 @@
#ifndef HIKEY_PRIVATE_H
#define HIKEY_PRIVATE_H
-#include <bl_common.h>
+#include <common/bl_common.h>
#define RANDOM_MAX 0x7fffffffffffffff
#define RANDOM_MAGIC 0x9a4dbeaf
diff --git a/plat/hisilicon/hikey/hikey_security.c b/plat/hisilicon/hikey/hikey_security.c
index 43d7b7a..4b95939 100644
--- a/plat/hisilicon/hikey/hikey_security.c
+++ b/plat/hisilicon/hikey/hikey_security.c
@@ -5,11 +5,14 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <platform_def.h>
#include <stdint.h>
#include <string.h>
-#include <utils_def.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <lib/utils_def.h>
+
#include "hikey_private.h"
#define PORTNUM_MAX 5
diff --git a/plat/hisilicon/hikey/hikey_tbbr.c b/plat/hisilicon/hikey/hikey_tbbr.c
index 20eda36..1f05d18 100644
--- a/plat/hisilicon/hikey/hikey_tbbr.c
+++ b/plat/hisilicon/hikey/hikey_tbbr.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+#include <plat/common/platform.h>
extern char hikey_rotpk_hash[], hikey_rotpk_hash_end[];
diff --git a/plat/hisilicon/hikey/hikey_topology.c b/plat/hisilicon/hikey/hikey_topology.c
index 95948b8..7890eb7 100644
--- a/plat/hisilicon/hikey/hikey_topology.c
+++ b/plat/hisilicon/hikey/hikey_topology.c
@@ -3,9 +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>
/*
* The HiKey power domain tree descriptor. The cluster power domains
diff --git a/plat/hisilicon/hikey/hisi_dvfs.c b/plat/hisilicon/hikey/hisi_dvfs.c
index 0d4f893..22a67fd 100644
--- a/plat/hisilicon/hikey/hisi_dvfs.c
+++ b/plat/hisilicon/hikey/hisi_dvfs.c
@@ -4,18 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
+#include <string.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include <hi6220.h>
#include <hi6553.h>
#include <hisi_sram_map.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
-#include <string.h>
#define ACPU_FREQ_MAX_NUM 5
#define ACPU_OPP_NUM 7
diff --git a/plat/hisilicon/hikey/hisi_ipc.c b/plat/hisilicon/hikey/hisi_ipc.c
index 7e02f3a..43ee0b2 100644
--- a/plat/hisilicon/hikey/hisi_ipc.c
+++ b/plat/hisilicon/hikey/hisi_ipc.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
-#include <hisi_ipc.h>
-#include <hisi_sram_map.h>
-#include <mmio.h>
-#include <platform_def.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
+#include <hisi_ipc.h>
+#include <hisi_sram_map.h>
+
static int ipc_init;
static unsigned int cpu_ipc_num[PLATFORM_CLUSTER_COUNT][PLATFORM_CORE_COUNT_PER_CLUSTER] = {
diff --git a/plat/hisilicon/hikey/hisi_mcu.c b/plat/hisilicon/hikey/hisi_mcu.c
index 359b94d..ac83bd8 100644
--- a/plat/hisilicon/hikey/hisi_mcu.c
+++ b/plat/hisilicon/hikey/hisi_mcu.c
@@ -4,17 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <hi6220.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
#include <string.h>
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <hi6220.h>
+
#define MCU_SECTION_MAX 30
enum MCU_IMAGE_SEC_TYPE_ENUM {
diff --git a/plat/hisilicon/hikey/hisi_pwrc.c b/plat/hisilicon/hikey/hisi_pwrc.c
index b635fb1..e2e3db7 100644
--- a/plat/hisilicon/hikey/hisi_pwrc.c
+++ b/plat/hisilicon/hikey/hisi_pwrc.c
@@ -4,8 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
+#include <stdarg.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
#include <hi6220_regs_acpu.h>
#include <hi6220_regs_ao.h>
@@ -13,11 +19,6 @@
#include <hisi_pwrc.h>
#include <hisi_sram_map.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#include <platform_def.h>
-
#define CLUSTER_CORE_COUNT (4)
#define CLUSTER_CORE_MASK ((1 << CLUSTER_CORE_COUNT) - 1)
diff --git a/plat/hisilicon/hikey/hisi_sip_svc.c b/plat/hisilicon/hikey/hisi_sip_svc.c
index ffa4903..3cd1bd0 100644
--- a/plat/hisilicon/hikey/hisi_sip_svc.c
+++ b/plat/hisilicon/hikey/hisi_sip_svc.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <hisi_sip_svc.h>
-#include <pmf.h>
-#include <runtime_svc.h>
#include <stdint.h>
-#include <uuid.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/pmf/pmf.h>
+#include <tools_share/uuid.h>
+
+#include <hisi_sip_svc.h>
/* Hisi SiP Service UUID */
DEFINE_SVC_UUID2(hisi_sip_svc_uid,
diff --git a/plat/hisilicon/hikey/include/hi6553.h b/plat/hisilicon/hikey/include/hi6553.h
index 55ce91c..fc991f8 100644
--- a/plat/hisilicon/hikey/include/hi6553.h
+++ b/plat/hisilicon/hikey/include/hi6553.h
@@ -7,8 +7,9 @@
#ifndef HI6553_H
#define HI6553_H
+#include <lib/mmio.h>
+
#include <hi6220.h>
-#include <mmio.h>
#define HI6553_DISABLE6_XO_CLK (PMUSSI_BASE + (0x036 << 2))
diff --git a/plat/hisilicon/hikey/include/plat_macros.S b/plat/hisilicon/hikey/include/plat_macros.S
index de38bd5..9cd276a 100644
--- a/plat/hisilicon/hikey/include/plat_macros.S
+++ b/plat/hisilicon/hikey/include/plat_macros.S
@@ -7,8 +7,8 @@
#ifndef PLAT_MACROS_S
#define PLAT_MACROS_S
-#include <cci.h>
-#include <gicv2.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gicv2.h>
#include <hi6220.h>
#include <platform_def.h>
diff --git a/plat/hisilicon/hikey/include/platform_def.h b/plat/hisilicon/hikey/include/platform_def.h
index f2d358a..2537ac6 100644
--- a/plat/hisilicon/hikey/include/platform_def.h
+++ b/plat/hisilicon/hikey/include/platform_def.h
@@ -8,11 +8,12 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <common_def.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
+
#include <hikey_def.h>
#include <hikey_layout.h> /* BL memory region sizes, etc */
-#include <tbbr_img_def.h>
-#include <utils_def.h>
/* Special value used to verify platform parameters from BL2 to BL3-1 */
#define HIKEY_BL31_PLAT_PARAM_VAL 0x0f1e2d3c4b5a6978ULL
@@ -41,7 +42,7 @@
#define MAX_IO_DEVICES 3
#define MAX_IO_HANDLES 4
/* eMMC RPMB and eMMC User Data */
-#define MAX_IO_BLOCK_DEVICES 2
+#define MAX_IO_BLOCK_DEVICES U(2)
/* GIC related constants (no GICR in GIC-400) */
#define PLAT_ARM_GICD_BASE 0xF6801000
diff --git a/plat/hisilicon/hikey/platform.mk b/plat/hisilicon/hikey/platform.mk
index 398b224..6d077f7 100644
--- a/plat/hisilicon/hikey/platform.mk
+++ b/plat/hisilicon/hikey/platform.mk
@@ -46,7 +46,6 @@
USE_COHERENT_MEM := 1
PLAT_INCLUDES := -Iinclude/common/tbbr \
- -Iinclude/drivers/synopsys \
-Iplat/hisilicon/hikey/include
PLAT_BL_COMMON_SOURCES := drivers/arm/pl011/aarch64/pl011_console.S \
diff --git a/plat/hisilicon/hikey960/aarch64/hikey960_common.c b/plat/hisilicon/hikey960/aarch64/hikey960_common.c
index 1ed3eaa..612a7f2 100644
--- a/plat/hisilicon/hikey960/aarch64/hikey960_common.c
+++ b/plat/hisilicon/hikey960/aarch64/hikey960_common.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <xlat_tables.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
#include "../hikey960_def.h"
#include "../hikey960_private.h"
diff --git a/plat/hisilicon/hikey960/drivers/ipc/hisi_ipc.c b/plat/hisilicon/hikey960/drivers/ipc/hisi_ipc.c
index 4c664d1..a6a4949 100644
--- a/plat/hisilicon/hikey960/drivers/ipc/hisi_ipc.c
+++ b/plat/hisilicon/hikey960/drivers/ipc/hisi_ipc.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <hi3660.h>
-#include <hisi_ipc.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <hi3660.h>
+#include <hisi_ipc.h>
#include "../../hikey960_private.h"
#define IPC_MBX_SOURCE_REG(m) (IPC_BASE + ((m) << 6))
diff --git a/plat/hisilicon/hikey960/drivers/pwrc/hisi_pwrc.c b/plat/hisilicon/hikey960/drivers/pwrc/hisi_pwrc.c
index 45fcd42..659a1c4 100644
--- a/plat/hisilicon/hikey960/drivers/pwrc/hisi_pwrc.c
+++ b/plat/hisilicon/hikey960/drivers/pwrc/hisi_pwrc.c
@@ -4,15 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <../hikey960_def.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <hisi_ipc.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
+#include <arch_helpers.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+#include <../hikey960_def.h>
+#include <hisi_ipc.h>
#include "hisi_pwrc.h"
diff --git a/plat/hisilicon/hikey960/hikey960_bl1_setup.c b/plat/hisilicon/hikey960/hikey960_bl1_setup.c
index ff2c77a..38bdbe4 100644
--- a/plat/hisilicon/hikey960/hikey960_bl1_setup.c
+++ b/plat/hisilicon/hikey960/hikey960_bl1_setup.c
@@ -4,26 +4,28 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <dw_ufs.h>
#include <errno.h>
-#include <generic_delay_timer.h>
-#include <gicv2.h>
-#include <hi3660.h>
-#include <interrupt_props.h>
-#include <mmio.h>
-#include <pl011.h>
-#include <platform.h>
-#include <platform_def.h>
#include <string.h>
-#include <tbbr/tbbr_img_desc.h>
-#include <ufs.h>
-#include "../../bl1/bl1_private.h"
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <bl1/tbbr/tbbr_img_desc.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/delay_timer.h>
+#include <drivers/dw_ufs.h>
+#include <drivers/generic_delay_timer.h>
+#include <drivers/ufs.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <hi3660.h>
+#include "../../../bl1/bl1_private.h"
#include "hikey960_def.h"
#include "hikey960_private.h"
diff --git a/plat/hisilicon/hikey960/hikey960_bl2_mem_params_desc.c b/plat/hisilicon/hikey960/hikey960_bl2_mem_params_desc.c
index 2944b1f..ba236d2 100644
--- a/plat/hisilicon/hikey960/hikey960_bl2_mem_params_desc.c
+++ b/plat/hisilicon/hikey960/hikey960_bl2_mem_params_desc.c
@@ -4,11 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* Following descriptor provides BL image/ep information that gets used
diff --git a/plat/hisilicon/hikey960/hikey960_bl2_setup.c b/plat/hisilicon/hikey960/hikey960_bl2_setup.c
index 552356f..788392d 100644
--- a/plat/hisilicon/hikey960/hikey960_bl2_setup.c
+++ b/plat/hisilicon/hikey960/hikey960_bl2_setup.c
@@ -4,25 +4,27 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <desc_image_load.h>
-#include <dw_ufs.h>
#include <errno.h>
-#include <generic_delay_timer.h>
-#include <hi3660.h>
-#include <mmio.h>
-#ifdef SPD_opteed
-#include <optee_utils.h>
-#endif
-#include <pl011.h>
-#include <platform_def.h>
#include <string.h>
-#include <ufs.h>
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/delay_timer.h>
+#include <drivers/dw_ufs.h>
+#include <drivers/generic_delay_timer.h>
+#include <drivers/ufs.h>
+#include <lib/mmio.h>
+#ifdef SPD_opteed
+#include <lib/optee_utils.h>
+#endif
+
+#include <hi3660.h>
#include "hikey960_def.h"
#include "hikey960_private.h"
diff --git a/plat/hisilicon/hikey960/hikey960_bl31_setup.c b/plat/hisilicon/hikey960/hikey960_bl31_setup.c
index 2261470..67b06f4 100644
--- a/plat/hisilicon/hikey960/hikey960_bl31_setup.c
+++ b/plat/hisilicon/hikey960/hikey960_bl31_setup.c
@@ -4,24 +4,26 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <cci.h>
-#include <console.h>
-#include <debug.h>
#include <errno.h>
-#include <generic_delay_timer.h>
-#include <gicv2.h>
-#include <hi3660.h>
-#include <mmio.h>
-#include <hisi_ipc.h>
-#include <interrupt_mgmt.h>
-#include <interrupt_props.h>
-#include <pl011.h>
-#include <platform.h>
+
#include <platform_def.h>
+#include <arch_helpers.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/console.h>
+#include <drivers/generic_delay_timer.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <hi3660.h>
+#include <hisi_ipc.h>
#include "hikey960_def.h"
#include "hikey960_private.h"
diff --git a/plat/hisilicon/hikey960/hikey960_bl_common.c b/plat/hisilicon/hikey960/hikey960_bl_common.c
index 0cee69f..89adccb 100644
--- a/plat/hisilicon/hikey960/hikey960_bl_common.c
+++ b/plat/hisilicon/hikey960/hikey960_bl_common.c
@@ -4,12 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <delay_timer.h>
-#include <hi3660.h>
-#include <mmio.h>
-#include <pl061_gpio.h>
+#include <common/debug.h>
+#include <drivers/arm/pl061_gpio.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <hi3660.h>
#include "hikey960_private.h"
void hikey960_clk_init(void)
diff --git a/plat/hisilicon/hikey960/hikey960_boardid.c b/plat/hisilicon/hikey960/hikey960_boardid.c
index f39c153..1e1126f 100644
--- a/plat/hisilicon/hikey960/hikey960_boardid.c
+++ b/plat/hisilicon/hikey960/hikey960_boardid.c
@@ -5,12 +5,13 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <hi3660.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
+#include <hi3660.h>
#include "hikey960_private.h"
#define ADC_ADCIN0 0
diff --git a/plat/hisilicon/hikey960/hikey960_def.h b/plat/hisilicon/hikey960/hikey960_def.h
index 91d0af3..d977c79 100644
--- a/plat/hisilicon/hikey960/hikey960_def.h
+++ b/plat/hisilicon/hikey960/hikey960_def.h
@@ -7,8 +7,8 @@
#ifndef HIKEY960_DEF_H
#define HIKEY960_DEF_H
-#include <common_def.h>
-#include <tbbr_img_def.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <plat/common/common_def.h>
#define DDR_BASE 0x0
#define DDR_SIZE 0xC0000000
diff --git a/plat/hisilicon/hikey960/hikey960_image_load.c b/plat/hisilicon/hikey960/hikey960_image_load.c
index ad7be50..57cb1b2 100644
--- a/plat/hisilicon/hikey960/hikey960_image_load.c
+++ b/plat/hisilicon/hikey960/hikey960_image_load.c
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* This function flushes the data structures so that they are visible
diff --git a/plat/hisilicon/hikey960/hikey960_io_storage.c b/plat/hisilicon/hikey960/hikey960_io_storage.c
index cff3b0d..a4e8389 100644
--- a/plat/hisilicon/hikey960/hikey960_io_storage.c
+++ b/plat/hisilicon/hikey960/hikey960_io_storage.c
@@ -4,21 +4,23 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
#include <errno.h>
-#include <firmware_image_package.h>
-#include <io_block.h>
-#include <io_driver.h>
-#include <io_fip.h>
-#include <io_memmap.h>
-#include <io_storage.h>
-#include <mmio.h>
-#include <platform_def.h>
-#include <semihosting.h> /* For FOPEN_MODE_... */
#include <string.h>
-#include <ufs.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/ufs.h>
+#include <drivers/io/io_block.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_memmap.h>
+#include <drivers/io/io_storage.h>
+#include <lib/mmio.h>
+#include <lib/semihosting.h>
+#include <tools_share/firmware_image_package.h>
struct plat_io_policy {
uintptr_t *dev_handle;
diff --git a/plat/hisilicon/hikey960/hikey960_mcu_load.c b/plat/hisilicon/hikey960/hikey960_mcu_load.c
index 7bf9a3d..b9ae313 100644
--- a/plat/hisilicon/hikey960/hikey960_mcu_load.c
+++ b/plat/hisilicon/hikey960/hikey960_mcu_load.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <hi3660.h>
-#include <mmio.h>
#include <string.h>
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
+#include <hi3660.h>
+
#define ADDR_CONVERT(addr) ((addr) < 0x40000 ? \
(addr) + 0xFFF30000 : \
(addr) + 0x40000000)
diff --git a/plat/hisilicon/hikey960/hikey960_pm.c b/plat/hisilicon/hikey960/hikey960_pm.c
index f1873ee..676cfa3 100644
--- a/plat/hisilicon/hikey960/hikey960_pm.c
+++ b/plat/hisilicon/hikey960/hikey960_pm.c
@@ -4,19 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <cci.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <gicv2.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+
#include <hi3660.h>
#include <hi3660_crg.h>
-#include <mmio.h>
-#include <pl011.h>
-#include <psci.h>
-#include "drivers/pwrc/hisi_pwrc.h"
+#include "drivers/pwrc/hisi_pwrc.h"
#include "hikey960_def.h"
#include "hikey960_private.h"
diff --git a/plat/hisilicon/hikey960/hikey960_private.h b/plat/hisilicon/hikey960/hikey960_private.h
index 31d3a4a..9a18dd6 100644
--- a/plat/hisilicon/hikey960/hikey960_private.h
+++ b/plat/hisilicon/hikey960/hikey960_private.h
@@ -7,7 +7,7 @@
#ifndef HIKEY960_PRIVATE_H
#define HIKEY960_PRIVATE_H
-#include <bl_common.h>
+#include <common/bl_common.h>
/*
* Function and variable prototypes
diff --git a/plat/hisilicon/hikey960/hikey960_tbbr.c b/plat/hisilicon/hikey960/hikey960_tbbr.c
index e9f28b3..e435ec2 100644
--- a/plat/hisilicon/hikey960/hikey960_tbbr.c
+++ b/plat/hisilicon/hikey960/hikey960_tbbr.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+#include <plat/common/platform.h>
extern char hikey960_rotpk_hash[], hikey960_rotpk_hash_end[];
diff --git a/plat/hisilicon/hikey960/hikey960_topology.c b/plat/hisilicon/hikey960/hikey960_topology.c
index 3363724..a242bb1 100644
--- a/plat/hisilicon/hikey960/hikey960_topology.c
+++ b/plat/hisilicon/hikey960/hikey960_topology.c
@@ -3,9 +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>
/*
* The HiKey power domain tree descriptor. The cluster power domains
diff --git a/plat/hisilicon/hikey960/include/plat_macros.S b/plat/hisilicon/hikey960/include/plat_macros.S
index 3b126f6..8765562 100644
--- a/plat/hisilicon/hikey960/include/plat_macros.S
+++ b/plat/hisilicon/hikey960/include/plat_macros.S
@@ -7,8 +7,8 @@
#ifndef PLAT_MACROS_S
#define PLAT_MACROS_S
-#include <cci.h>
-#include <gicv2.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gicv2.h>
#include <hi3660.h>
#include <platform_def.h>
diff --git a/plat/hisilicon/hikey960/include/platform_def.h b/plat/hisilicon/hikey960/include/platform_def.h
index 3717ff8..3e2d79d 100644
--- a/plat/hisilicon/hikey960/include/platform_def.h
+++ b/plat/hisilicon/hikey960/include/platform_def.h
@@ -8,7 +8,8 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <utils_def.h>
+#include <lib/utils_def.h>
+
#include "../hikey960_def.h"
/* Special value used to verify platform parameters from BL2 to BL3-1 */
@@ -38,7 +39,7 @@
#define MAX_IO_DEVICES 3
#define MAX_IO_HANDLES 4
/* UFS RPMB and UFS User Data */
-#define MAX_IO_BLOCK_DEVICES 2
+#define MAX_IO_BLOCK_DEVICES U(2)
/*
diff --git a/plat/hisilicon/poplar/aarch64/platform_common.c b/plat/hisilicon/poplar/aarch64/platform_common.c
index d408209..fcd0a8b 100644
--- a/plat/hisilicon/poplar/aarch64/platform_common.c
+++ b/plat/hisilicon/poplar/aarch64/platform_common.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <mmio.h>
-#include <platform.h>
-#include <xlat_tables.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
+
#include "hi3798cv200.h"
#include "platform_def.h"
diff --git a/plat/hisilicon/poplar/bl1_plat_setup.c b/plat/hisilicon/poplar/bl1_plat_setup.c
index d0b12ad..eb8ffe4 100644
--- a/plat/hisilicon/poplar/bl1_plat_setup.c
+++ b/plat/hisilicon/poplar/bl1_plat_setup.c
@@ -4,22 +4,25 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <dw_mmc.h>
#include <errno.h>
-#include <generic_delay_timer.h>
-#include <mmc.h>
-#include <mmio.h>
-#include <pl011.h>
-#include <pl061_gpio.h>
-#include <platform.h>
-#include <platform_def.h>
#include <string.h>
-#include <tbbr_img_def.h>
-#include "../../bl1/bl1_private.h"
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/arm/pl061_gpio.h>
+#include <drivers/generic_delay_timer.h>
+#include <drivers/mmc.h>
+#include <drivers/synopsys/dw_mmc.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include "../../../bl1/bl1_private.h"
#include "hi3798cv200.h"
#include "plat_private.h"
diff --git a/plat/hisilicon/poplar/bl2_plat_mem_params_desc.c b/plat/hisilicon/poplar/bl2_plat_mem_params_desc.c
index c73ead8..f683d75 100644
--- a/plat/hisilicon/poplar/bl2_plat_mem_params_desc.c
+++ b/plat/hisilicon/poplar/bl2_plat_mem_params_desc.c
@@ -4,11 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* Following descriptor provides BL image/ep information that gets used
diff --git a/plat/hisilicon/poplar/bl2_plat_setup.c b/plat/hisilicon/poplar/bl2_plat_setup.c
index 3a3ed6a..ff8e107 100644
--- a/plat/hisilicon/poplar/bl2_plat_setup.c
+++ b/plat/hisilicon/poplar/bl2_plat_setup.c
@@ -4,21 +4,23 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <desc_image_load.h>
-#include <dw_mmc.h>
#include <errno.h>
-#include <generic_delay_timer.h>
-#include <mmc.h>
-#include <mmio.h>
-#include <optee_utils.h>
-#include <partition/partition.h>
-#include <pl011.h>
-#include <platform.h>
#include <string.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/generic_delay_timer.h>
+#include <drivers/partition/partition.h>
+#include <drivers/synopsys/dw_mmc.h>
+#include <drivers/mmc.h>
+#include <lib/mmio.h>
+#include <lib/optee_utils.h>
+#include <plat/common/platform.h>
+
#include "hi3798cv200.h"
#include "plat_private.h"
diff --git a/plat/hisilicon/poplar/bl31_plat_setup.c b/plat/hisilicon/poplar/bl31_plat_setup.c
index e2079f9..69911e8 100644
--- a/plat/hisilicon/poplar/bl31_plat_setup.c
+++ b/plat/hisilicon/poplar/bl31_plat_setup.c
@@ -4,21 +4,24 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl31.h>
-#include <bl_common.h>
-#include <cortex_a53.h>
-#include <debug.h>
#include <errno.h>
-#include <generic_delay_timer.h>
-#include <mmio.h>
-#include <pl011.h>
-#include <platform.h>
-#include <platform_def.h>
#include <stddef.h>
#include <string.h>
+
+#include <platform_def.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <bl31/bl31.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <cortex_a53.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/generic_delay_timer.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include "hi3798cv200.h"
#include "plat_private.h"
diff --git a/plat/hisilicon/poplar/include/hi3798cv200.h b/plat/hisilicon/poplar/include/hi3798cv200.h
index ddb4396..e31f4b3 100644
--- a/plat/hisilicon/poplar/include/hi3798cv200.h
+++ b/plat/hisilicon/poplar/include/hi3798cv200.h
@@ -7,7 +7,7 @@
#ifndef HI3798CV200_H
#define HI3798CV200_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* PL011 */
#define PL011_UART0_BASE (0xF8B00000)
diff --git a/plat/hisilicon/poplar/include/plat_private.h b/plat/hisilicon/poplar/include/plat_private.h
index 3aeccc4..a34f138 100644
--- a/plat/hisilicon/poplar/include/plat_private.h
+++ b/plat/hisilicon/poplar/include/plat_private.h
@@ -7,7 +7,8 @@
#ifndef PLAT_PRIVATE_H
#define PLAT_PRIVATE_H
-#include <bl_common.h>
+#include <common/bl_common.h>
+
#include "hi3798cv200.h"
void plat_configure_mmu_el3(unsigned long total_base,
diff --git a/plat/hisilicon/poplar/include/platform_def.h b/plat/hisilicon/poplar/include/platform_def.h
index 6287a76..8f7a155 100644
--- a/plat/hisilicon/poplar/include/platform_def.h
+++ b/plat/hisilicon/poplar/include/platform_def.h
@@ -8,11 +8,12 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <common_def.h>
-#include <gic_common.h>
-#include <interrupt_props.h>
-#include <tbbr/tbbr_img_def.h>
-#include <utils_def.h>
+#include <common/interrupt_props.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <drivers/arm/gic_common.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
+
#include "hi3798cv200.h"
#include "poplar_layout.h" /* BL memory region sizes, etc */
@@ -40,7 +41,7 @@
/* IO framework user */
#define MAX_IO_DEVICES (4)
#define MAX_IO_HANDLES (4)
-#define MAX_IO_BLOCK_DEVICES (2)
+#define MAX_IO_BLOCK_DEVICES U(2)
/* Memory size options */
#define POPLAR_DRAM_SIZE_1G 0
diff --git a/plat/hisilicon/poplar/plat_pm.c b/plat/hisilicon/poplar/plat_pm.c
index eccb0b0..67ebca1 100644
--- a/plat/hisilicon/poplar/plat_pm.c
+++ b/plat/hisilicon/poplar/plat_pm.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <context.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
#include "hi3798cv200.h"
#include "plat_private.h"
diff --git a/plat/hisilicon/poplar/plat_storage.c b/plat/hisilicon/poplar/plat_storage.c
index 925274c..a17e0f1 100644
--- a/plat/hisilicon/poplar/plat_storage.c
+++ b/plat/hisilicon/poplar/plat_storage.c
@@ -4,23 +4,25 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <firmware_image_package.h>
-#include <io_block.h>
-#include <io_driver.h>
-#include <io_fip.h>
-#include <io_memmap.h>
-#include <io_storage.h>
-#include <mmc.h>
-#include <mmio.h>
-#include <partition/partition.h>
-#include <semihosting.h>
#include <string.h>
-#include <tbbr_img_def.h>
-#include <utils.h>
-#include "platform_def.h"
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <drivers/io/io_block.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_memmap.h>
+#include <drivers/io/io_storage.h>
+#include <drivers/mmc.h>
+#include <drivers/partition/partition.h>
+#include <lib/mmio.h>
+#include <lib/semihosting.h>
+#include <lib/utils.h>
+#include <tools_share/firmware_image_package.h>
#if !POPLAR_RECOVERY
static const io_dev_connector_t *emmc_dev_con;
diff --git a/plat/hisilicon/poplar/plat_topology.c b/plat/hisilicon/poplar/plat_topology.c
index bb53c6b..764008e 100644
--- a/plat/hisilicon/poplar/plat_topology.c
+++ b/plat/hisilicon/poplar/plat_topology.c
@@ -4,9 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <platform_def.h>
+
#include <arch.h>
-#include <psci.h>
-#include "platform_def.h"
+#include <lib/psci/psci.h>
+
#include "plat_private.h"
const unsigned char hisi_power_domain_tree_desc[] = {
diff --git a/plat/hisilicon/poplar/platform.mk b/plat/hisilicon/poplar/platform.mk
index 0aaa707..eca1412 100644
--- a/plat/hisilicon/poplar/platform.mk
+++ b/plat/hisilicon/poplar/platform.mk
@@ -54,9 +54,7 @@
PLAT_INCLUDES := -Iplat/hisilicon/poplar/include \
-Iplat/hisilicon/poplar \
- -Iinclude/common/tbbr \
- -Iinclude/drivers/synopsys \
- -Iinclude/drivers/io
+ -Iinclude/common/tbbr
PLAT_BL_COMMON_SOURCES := \
lib/xlat_tables/aarch64/xlat_tables.c \
diff --git a/plat/hisilicon/poplar/poplar_gicv2.c b/plat/hisilicon/poplar/poplar_gicv2.c
index 1c1be47..59f7b76 100644
--- a/plat/hisilicon/poplar/poplar_gicv2.c
+++ b/plat/hisilicon/poplar/poplar_gicv2.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <gicv2.h>
-#include <platform.h>
#include <platform_def.h>
+#include <drivers/arm/gicv2.h>
+#include <plat/common/platform.h>
+
/******************************************************************************
* On a GICv2 system, the Group 1 secure interrupts are treated as Group 0
* interrupts.
diff --git a/plat/hisilicon/poplar/poplar_image_load.c b/plat/hisilicon/poplar/poplar_image_load.c
index 32ca36d..0ab1ca4 100644
--- a/plat/hisilicon/poplar/poplar_image_load.c
+++ b/plat/hisilicon/poplar/poplar_image_load.c
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* This function flushes the data structures so that they are visible
diff --git a/plat/imx/common/imx8_psci.c b/plat/imx/common/imx8_psci.c
index 22a531b..588d8b4 100644
--- a/plat/imx/common/imx8_psci.c
+++ b/plat/imx/common/imx8_psci.c
@@ -4,12 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <debug.h>
+#include <common/debug.h>
+
#include <plat_imx8.h>
#include <sci/sci.h>
-#include <stdbool.h>
void __dead2 imx_system_off(void)
{
diff --git a/plat/imx/common/imx8_topology.c b/plat/imx/common/imx8_topology.c
index 64145c4..5e14d17 100644
--- a/plat/imx/common/imx8_topology.c
+++ b/plat/imx/common/imx8_topology.c
@@ -6,7 +6,7 @@
#include <arch.h>
#include <arch_helpers.h>
-#include <platform.h>
+#include <plat/common/platform.h>
const unsigned char imx_power_domain_tree_desc[] = {
PWR_DOMAIN_AT_MAX_LVL,
diff --git a/plat/imx/common/imx_aips.c b/plat/imx/common/imx_aips.c
index 991c262..532d9c0 100644
--- a/plat/imx/common/imx_aips.c
+++ b/plat/imx/common/imx_aips.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
-#include <utils_def.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
+
#include <imx_aips.h>
#include <imx_regs.h>
diff --git a/plat/imx/common/imx_caam.c b/plat/imx/common/imx_caam.c
index 335e1ed..d9c141f 100644
--- a/plat/imx/common/imx_caam.c
+++ b/plat/imx/common/imx_caam.c
@@ -3,8 +3,11 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <stdint.h>
-#include <mmio.h>
+
+#include <lib/mmio.h>
+
#include <imx_caam.h>
void imx_caam_init(void)
diff --git a/plat/imx/common/imx_clock.c b/plat/imx/common/imx_clock.c
index ccf2aeb..743de55 100644
--- a/plat/imx/common/imx_clock.c
+++ b/plat/imx/common/imx_clock.c
@@ -3,10 +3,13 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <mmio.h>
+
#include <stdint.h>
#include <stdbool.h>
+
+#include <arch.h>
+#include <lib/mmio.h>
+
#include <imx_regs.h>
#include <imx_clock.h>
diff --git a/plat/imx/common/imx_csu.c b/plat/imx/common/imx_csu.c
index 7c6a63e..7e165d9 100644
--- a/plat/imx/common/imx_csu.c
+++ b/plat/imx/common/imx_csu.c
@@ -3,7 +3,9 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
+
+#include <lib/mmio.h>
+
#include <imx_csu.h>
#include <imx_regs.h>
diff --git a/plat/imx/common/imx_io_mux.c b/plat/imx/common/imx_io_mux.c
index 7230647..75de5d1 100644
--- a/plat/imx/common/imx_io_mux.c
+++ b/plat/imx/common/imx_io_mux.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include <imx_regs.h>
#include <imx_io_mux.h>
diff --git a/plat/imx/common/imx_snvs.c b/plat/imx/common/imx_snvs.c
index 4a2a7d7..9b3a737 100644
--- a/plat/imx/common/imx_snvs.c
+++ b/plat/imx/common/imx_snvs.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include <imx_regs.h>
#include <imx_snvs.h>
diff --git a/plat/imx/common/imx_wdog.c b/plat/imx/common/imx_wdog.c
index 86813dd..af6d767 100644
--- a/plat/imx/common/imx_wdog.c
+++ b/plat/imx/common/imx_wdog.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include <imx_regs.h>
#include <imx_wdog.h>
diff --git a/plat/imx/common/include/imx8_lpuart.h b/plat/imx/common/include/imx8_lpuart.h
index 8e1184f..63449e7 100644
--- a/plat/imx/common/include/imx8_lpuart.h
+++ b/plat/imx/common/include/imx8_lpuart.h
@@ -7,7 +7,7 @@
#ifndef IMX8_LPUART_H
#define IMX8_LPUART_H
-#include <console.h>
+#include <drivers/console.h>
#define VERID 0x0
#define PARAM 0x4
diff --git a/plat/imx/common/include/imx_snvs.h b/plat/imx/common/include/imx_snvs.h
index 0aed1e1..0b3d108 100644
--- a/plat/imx/common/include/imx_snvs.h
+++ b/plat/imx/common/include/imx_snvs.h
@@ -7,6 +7,7 @@
#define IMX_SNVS_H
#include <stdint.h>
+
#include <arch.h>
struct snvs {
diff --git a/plat/imx/common/include/imx_uart.h b/plat/imx/common/include/imx_uart.h
index d2c3968..a251024 100644
--- a/plat/imx/common/include/imx_uart.h
+++ b/plat/imx/common/include/imx_uart.h
@@ -7,7 +7,7 @@
#ifndef IMX_UART_H
#define IMX_UART_H
-#include <console.h>
+#include <drivers/console.h>
#ifndef __ASSEMBLY__
diff --git a/plat/imx/common/include/imx_wdog.h b/plat/imx/common/include/imx_wdog.h
index 7b3037d..75a729a 100644
--- a/plat/imx/common/include/imx_wdog.h
+++ b/plat/imx/common/include/imx_wdog.h
@@ -7,9 +7,10 @@
#ifndef IMX_WDOG_H
#define IMX_WDOG_H
-#include <arch.h>
#include <stdint.h>
+#include <arch.h>
+
struct wdog_regs {
uint16_t wcr;
uint16_t wsr;
diff --git a/plat/imx/common/include/plat_imx8.h b/plat/imx/common/include/plat_imx8.h
index 03799c4..8d83173 100644
--- a/plat/imx/common/include/plat_imx8.h
+++ b/plat/imx/common/include/plat_imx8.h
@@ -7,8 +7,8 @@
#ifndef PLAT_IMX8_H
#define PLAT_IMX8_H
-#include <gicv3.h>
-#include <psci.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/psci/psci.h>
unsigned int plat_calc_core_pos(uint64_t mpidr);
void imx_mailbox_init(uintptr_t base_addr);
diff --git a/plat/imx/common/include/sci/sci_rpc.h b/plat/imx/common/include/sci/sci_rpc.h
index 1771bae..60dbc27 100644
--- a/plat/imx/common/include/sci/sci_rpc.h
+++ b/plat/imx/common/include/sci/sci_rpc.h
@@ -13,9 +13,10 @@
/* Includes */
+#include <stdbool.h>
+
#include <sci/sci_types.h>
#include <sci/sci_ipc.h>
-#include <stdbool.h>
/* Defines */
diff --git a/plat/imx/common/plat_imx8_gic.c b/plat/imx/common/plat_imx8_gic.c
index 2da9cc0..aec0b6c 100644
--- a/plat/imx/common/plat_imx8_gic.c
+++ b/plat/imx/common/plat_imx8_gic.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <gicv3.h>
-#include <interrupt_props.h>
-#include <plat_imx8.h>
-#include <platform.h>
#include <platform_def.h>
-#include <utils.h>
+
+#include <common/bl_common.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+
+#include <plat_imx8.h>
/* the GICv3 driver only needs to be initialized in EL3 */
uintptr_t rdistif_base_addrs[PLATFORM_CORE_COUNT];
diff --git a/plat/imx/common/sci/imx8_mu.c b/plat/imx/common/sci/imx8_mu.c
index 8028c76..26d9bdf 100644
--- a/plat/imx/common/sci/imx8_mu.c
+++ b/plat/imx/common/sci/imx8_mu.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include "imx8_mu.h"
void MU_EnableRxFullInt(uint32_t base, uint32_t index)
diff --git a/plat/imx/common/sci/ipc.c b/plat/imx/common/sci/ipc.c
index 2af2567..6491ca5 100644
--- a/plat/imx/common/sci/ipc.c
+++ b/plat/imx/common/sci/ipc.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bakery_lock.h>
+#include <stdlib.h>
+
+#include <lib/bakery_lock.h>
+
#include <sci/sci_scfw.h>
#include <sci/sci_ipc.h>
#include <sci/sci_rpc.h>
-#include <stdlib.h>
#include "imx8_mu.h"
DEFINE_BAKERY_LOCK(sc_ipc_bakery_lock);
diff --git a/plat/imx/common/sci/svc/pad/pad_rpc_clnt.c b/plat/imx/common/sci/svc/pad/pad_rpc_clnt.c
index 555e704..319d469 100644
--- a/plat/imx/common/sci/svc/pad/pad_rpc_clnt.c
+++ b/plat/imx/common/sci/svc/pad/pad_rpc_clnt.c
@@ -14,11 +14,12 @@
/* Includes */
+#include <stdlib.h>
+
#include <sci/sci_types.h>
#include <sci/svc/rm/sci_rm_api.h>
#include <sci/svc/pad/sci_pad_api.h>
#include <sci/sci_rpc.h>
-#include <stdlib.h>
#include "sci_pad_rpc.h"
/* Local Defines */
diff --git a/plat/imx/common/sci/svc/pm/pm_rpc_clnt.c b/plat/imx/common/sci/svc/pm/pm_rpc_clnt.c
index b108c49..66a57a1 100644
--- a/plat/imx/common/sci/svc/pm/pm_rpc_clnt.c
+++ b/plat/imx/common/sci/svc/pm/pm_rpc_clnt.c
@@ -14,11 +14,13 @@
/* Includes */
+#include <stdlib.h>
+
#include <sci/sci_types.h>
#include <sci/svc/rm/sci_rm_api.h>
#include <sci/svc/pm/sci_pm_api.h>
#include <sci/sci_rpc.h>
-#include <stdlib.h>
+
#include "sci_pm_rpc.h"
/* Local Defines */
diff --git a/plat/imx/common/sci/svc/rm/rm_rpc_clnt.c b/plat/imx/common/sci/svc/rm/rm_rpc_clnt.c
index 230956c..16771a5 100644
--- a/plat/imx/common/sci/svc/rm/rm_rpc_clnt.c
+++ b/plat/imx/common/sci/svc/rm/rm_rpc_clnt.c
@@ -14,10 +14,12 @@
/* Includes */
+#include <stdlib.h>
+
#include <sci/sci_types.h>
#include <sci/svc/rm/sci_rm_api.h>
#include <sci/sci_rpc.h>
-#include <stdlib.h>
+
#include "sci_rm_rpc.h"
/* Local Defines */
diff --git a/plat/imx/imx7/warp7/include/platform_def.h b/plat/imx/imx7/warp7/include/platform_def.h
index d0148f4..a931c80 100644
--- a/plat/imx/imx7/warp7/include/platform_def.h
+++ b/plat/imx/imx7/warp7/include/platform_def.h
@@ -8,8 +8,8 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <common_def.h>
-#include <tbbr_img_def.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <plat/common/common_def.h>
#define PLATFORM_STACK_SIZE 0x1000
@@ -169,7 +169,7 @@
#define MAX_XLAT_TABLES 6
#define MAX_IO_DEVICES 2
#define MAX_IO_HANDLES 3
-#define MAX_IO_BLOCK_DEVICES 1
+#define MAX_IO_BLOCK_DEVICES 1U
/* UART defines */
#if PLAT_WARP7_UART == 1
diff --git a/plat/imx/imx7/warp7/warp7_bl2_el3_setup.c b/plat/imx/imx7/warp7/warp7_bl2_el3_setup.c
index 10c4160..032ed7b 100644
--- a/plat/imx/imx7/warp7/warp7_bl2_el3_setup.c
+++ b/plat/imx/imx7/warp7/warp7_bl2_el3_setup.c
@@ -4,19 +4,22 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <desc_image_load.h>
-#include <mmc.h>
-#include <mmio.h>
-#include <optee_utils.h>
+
#include <platform_def.h>
-#include <utils.h>
-#include <xlat_mmu_helpers.h>
-#include <xlat_tables_defs.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <drivers/console.h>
+#include <drivers/mmc.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <lib/mmio.h>
+#include <lib/optee_utils.h>
+#include <lib/utils.h>
+
#include <imx_aips.h>
#include <imx_caam.h>
#include <imx_clock.h>
@@ -27,6 +30,7 @@
#include <imx_snvs.h>
#include <imx_usdhc.h>
#include <imx_wdog.h>
+
#include "warp7_private.h"
#define UART1_CLK_SELECT (CCM_TARGET_ROOT_ENABLE |\
diff --git a/plat/imx/imx7/warp7/warp7_bl2_mem_params_desc.c b/plat/imx/imx7/warp7/warp7_bl2_mem_params_desc.c
index 12254d4..a29e141 100644
--- a/plat/imx/imx7/warp7/warp7_bl2_mem_params_desc.c
+++ b/plat/imx/imx7/warp7/warp7_bl2_mem_params_desc.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
+
static bl_mem_params_node_t bl2_mem_params_descs[] = {
{
.image_id = BL32_IMAGE_ID,
diff --git a/plat/imx/imx7/warp7/warp7_image_load.c b/plat/imx/imx7/warp7/warp7_image_load.c
index 1e3a2b0..c3e47b9 100644
--- a/plat/imx/imx7/warp7/warp7_image_load.c
+++ b/plat/imx/imx7/warp7/warp7_image_load.c
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
void plat_flush_next_bl_params(void)
{
diff --git a/plat/imx/imx7/warp7/warp7_io_storage.c b/plat/imx/imx7/warp7/warp7_io_storage.c
index 8354766..b9cace0 100644
--- a/plat/imx/imx7/warp7/warp7_io_storage.c
+++ b/plat/imx/imx7/warp7/warp7_io_storage.c
@@ -3,16 +3,19 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <assert.h>
-#include <debug.h>
-#include <mmc.h>
-#include <firmware_image_package.h>
-#include <io_block.h>
-#include <io_driver.h>
-#include <io_fip.h>
-#include <io_memmap.h>
+
#include <platform_def.h>
+#include <common/debug.h>
+#include <drivers/io/io_block.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_memmap.h>
+#include <drivers/mmc.h>
+#include <tools_share/firmware_image_package.h>
+
static const io_dev_connector_t *fip_dev_con;
static uintptr_t fip_dev_handle;
diff --git a/plat/imx/imx8m/imx8mq/gpc.c b/plat/imx/imx8m/imx8mq/gpc.c
index 187a4ad..7fa5a3d 100644
--- a/plat/imx/imx8m/imx8mq/gpc.c
+++ b/plat/imx/imx8m/imx8mq/gpc.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <gpc.h>
-#include <mmio.h>
-#include <platform_def.h>
-#include <psci.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
-#include <std_svc.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <platform_def.h>
+#include <services/std_svc.h>
+
+#include <gpc.h>
void imx_set_cpu_secure_entry(unsigned int core_id, uintptr_t sec_entrypoint)
{
diff --git a/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c b/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c
index 45d2a40..f4e6ee7 100644
--- a/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c
+++ b/plat/imx/imx8m/imx8mq/imx8mq_bl31_setup.c
@@ -4,22 +4,25 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
+#include <stdbool.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
+#include <drivers/arm/tzc380.h>
+#include <drivers/console.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
+
#include <gpc.h>
#include <imx_uart.h>
-#include <stdbool.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
#include <plat_imx8.h>
-#include <xlat_tables.h>
-#include <tzc380.h>
IMPORT_SYM(uintptr_t, __COHERENT_RAM_START__, BL31_COHERENT_RAM_START);
IMPORT_SYM(uintptr_t, __COHERENT_RAM_END__, BL31_COHERENT_RAM_END);
diff --git a/plat/imx/imx8m/imx8mq/imx8mq_psci.c b/plat/imx/imx8m/imx8mq/imx8mq_psci.c
index 7afe52d..ee58865 100644
--- a/plat/imx/imx8m/imx8mq/imx8mq_psci.c
+++ b/plat/imx/imx8m/imx8mq/imx8mq_psci.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <debug.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+
#include <gpc.h>
-#include <stdbool.h>
#include <plat_imx8.h>
-#include <psci.h>
-#include <mmio.h>
#define CORE_PWR_STATE(state) ((state)->pwr_domain_state[MPIDR_AFFLVL0])
#define CLUSTER_PWR_STATE(state) ((state)->pwr_domain_state[MPIDR_AFFLVL1])
diff --git a/plat/imx/imx8qm/imx8qm_bl31_setup.c b/plat/imx/imx8qm/imx8qm_bl31_setup.c
index 7410ac1..a00695c 100644
--- a/plat/imx/imx8qm/imx8qm_bl31_setup.c
+++ b/plat/imx/imx8qm/imx8qm_bl31_setup.c
@@ -4,25 +4,28 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <cci.h>
-#include <console.h>
+#include <stdbool.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/console.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
+
#include <imx8qm_pads.h>
#include <imx8_iomux.h>
#include <imx8_lpuart.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
#include <plat_imx8.h>
#include <sci/sci.h>
#include <sec_rsrc.h>
-#include <stdbool.h>
-#include <xlat_tables.h>
IMPORT_SYM(unsigned long, __COHERENT_RAM_START__, BL31_COHERENT_RAM_START);
IMPORT_SYM(unsigned long, __COHERENT_RAM_END__, BL31_COHERENT_RAM_END);
diff --git a/plat/imx/imx8qm/imx8qm_psci.c b/plat/imx/imx8qm/imx8qm_psci.c
index 8166546..833048d 100644
--- a/plat/imx/imx8qm/imx8qm_psci.c
+++ b/plat/imx/imx8qm/imx8qm_psci.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <cci.h>
-#include <debug.h>
-#include <gicv3.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+
#include <plat_imx8.h>
-#include <psci.h>
#include <sci/sci.h>
-#include <stdbool.h>
#define CORE_PWR_STATE(state) \
((state)->pwr_domain_state[MPIDR_AFFLVL0])
diff --git a/plat/imx/imx8qm/include/platform_def.h b/plat/imx/imx8qm/include/platform_def.h
index 1cf7511..1d0bdf9 100644
--- a/plat/imx/imx8qm/include/platform_def.h
+++ b/plat/imx/imx8qm/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 PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
#define PLATFORM_LINKER_ARCH aarch64
diff --git a/plat/imx/imx8qx/imx8qx_bl31_setup.c b/plat/imx/imx8qx/imx8qx_bl31_setup.c
index 6384a85..c90794a 100644
--- a/plat/imx/imx8qx/imx8qx_bl31_setup.c
+++ b/plat/imx/imx8qx/imx8qx_bl31_setup.c
@@ -4,25 +4,28 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <cci.h>
-#include <console.h>
+#include <stdbool.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/console.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
+
#include <imx8qx_pads.h>
#include <imx8_iomux.h>
#include <imx8_lpuart.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
#include <plat_imx8.h>
#include <sci/sci.h>
#include <sec_rsrc.h>
-#include <stdbool.h>
-#include <xlat_tables.h>
IMPORT_SYM(unsigned long, __COHERENT_RAM_START__, BL31_COHERENT_RAM_START);
IMPORT_SYM(unsigned long, __COHERENT_RAM_END__, BL31_COHERENT_RAM_END);
diff --git a/plat/imx/imx8qx/imx8qx_psci.c b/plat/imx/imx8qx/imx8qx_psci.c
index 46ea724..94c2e2b 100644
--- a/plat/imx/imx8qx/imx8qx_psci.c
+++ b/plat/imx/imx8qx/imx8qx_psci.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <stdbool.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <debug.h>
-#include <gicv3.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+
#include <plat_imx8.h>
-#include <psci.h>
#include <sci/sci.h>
-#include <stdbool.h>
const static int ap_core_index[PLATFORM_CORE_COUNT] = {
SC_R_A35_0, SC_R_A35_1, SC_R_A35_2, SC_R_A35_3
diff --git a/plat/imx/imx8qx/include/platform_def.h b/plat/imx/imx8qx/include/platform_def.h
index b9fd96c..1239340 100644
--- a/plat/imx/imx8qx/include/platform_def.h
+++ b/plat/imx/imx8qx/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 PLATFORM_LINKER_FORMAT "elf64-littleaarch64"
#define PLATFORM_LINKER_ARCH aarch64
diff --git a/plat/layerscape/board/ls1043/include/ls_def.h b/plat/layerscape/board/ls1043/include/ls_def.h
index 9c83720..d8c66e3 100644
--- a/plat/layerscape/board/ls1043/include/ls_def.h
+++ b/plat/layerscape/board/ls1043/include/ls_def.h
@@ -7,13 +7,13 @@
#ifndef LS_DEF_H
#define LS_DEF_H
-#include <arch.h>
-#include <common_def.h>
#include <platform_def.h>
-#include <tbbr_img_def.h>
-#include <utils_def.h>
-#include <xlat_tables_defs.h>
+#include <arch.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
/******************************************************************************
* Definitions common to all ARM standard platforms
diff --git a/plat/layerscape/board/ls1043/include/platform_def.h b/plat/layerscape/board/ls1043/include/platform_def.h
index 46b2031..b613000 100644
--- a/plat/layerscape/board/ls1043/include/platform_def.h
+++ b/plat/layerscape/board/ls1043/include/platform_def.h
@@ -7,9 +7,10 @@
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
-#include <common_def.h>
-#include <tzc400.h>
-#include <utils.h>
+#include <drivers/arm/tzc400.h>
+#include <lib/utils.h>
+#include <plat/common/common_def.h>
+
#include "ls_def.h"
#define FIRMWARE_WELCOME_STR_LS1043 "Welcome to LS1043 BL1 Phase\n"
diff --git a/plat/layerscape/board/ls1043/ls1043_bl1_setup.c b/plat/layerscape/board/ls1043/ls1043_bl1_setup.c
index e82a1fb..dfa4725 100644
--- a/plat/layerscape/board/ls1043/ls1043_bl1_setup.c
+++ b/plat/layerscape/board/ls1043/ls1043_bl1_setup.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <cci.h>
-#include <debug.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <lib/mmio.h>
+
#include "plat_ls.h"
static const int cci_map[] = {
diff --git a/plat/layerscape/board/ls1043/ls1043_bl2_setup.c b/plat/layerscape/board/ls1043/ls1043_bl2_setup.c
index b529aa5..c9db814 100644
--- a/plat/layerscape/board/ls1043/ls1043_bl2_setup.c
+++ b/plat/layerscape/board/ls1043/ls1043_bl2_setup.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
-#include <debug.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "plat_ls.h"
void bl2_early_platform_setup2(u_register_t arg0, u_register_t arg1,
diff --git a/plat/layerscape/board/ls1043/ls1043_bl31_setup.c b/plat/layerscape/board/ls1043/ls1043_bl31_setup.c
index 3473d98..6d15c11 100644
--- a/plat/layerscape/board/ls1043/ls1043_bl31_setup.c
+++ b/plat/layerscape/board/ls1043/ls1043_bl31_setup.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <cci.h>
-#include <debug.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+
#include "plat_ls.h"
#include "fsl_csu.h"
diff --git a/plat/layerscape/board/ls1043/ls1043_err.c b/plat/layerscape/board/ls1043/ls1043_err.c
index e4a2cae..37077d4 100644
--- a/plat/layerscape/board/ls1043/ls1043_err.c
+++ b/plat/layerscape/board/ls1043/ls1043_err.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
#include <errno.h>
#include <stdint.h>
+#include <arch_helpers.h>
+#include <common/debug.h>
+
/*
* Error handler
*/
diff --git a/plat/layerscape/board/ls1043/ls1043_psci.c b/plat/layerscape/board/ls1043/ls1043_psci.c
index b402e7f..d6429c3 100644
--- a/plat/layerscape/board/ls1043/ls1043_psci.c
+++ b/plat/layerscape/board/ls1043/ls1043_psci.c
@@ -4,17 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <endian.h>
#include <errno.h>
-#include <gicv2.h>
-#include <mmio.h>
-#include <platform.h>
-#include <psci.h>
-#include "platform_def.h"
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
#define LS_SCFG_BASE 0x01570000
/* register to store warm boot entry, big endian, higher 32bit */
diff --git a/plat/layerscape/board/ls1043/ls1043_stack_protector.c b/plat/layerscape/board/ls1043/ls1043_stack_protector.c
index 50f463b..8a1a4e5 100644
--- a/plat/layerscape/board/ls1043/ls1043_stack_protector.c
+++ b/plat/layerscape/board/ls1043/ls1043_stack_protector.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <stdint.h>
+#include <arch_helpers.h>
+
#define RANDOM_CANARY_VALUE ((u_register_t) 3288484550995823360ULL)
u_register_t plat_get_stack_protector_canary(void)
diff --git a/plat/layerscape/board/ls1043/ls1043_topology.c b/plat/layerscape/board/ls1043/ls1043_topology.c
index 12d2830..c9c6a9c 100644
--- a/plat/layerscape/board/ls1043/ls1043_topology.c
+++ b/plat/layerscape/board/ls1043/ls1043_topology.c
@@ -5,7 +5,9 @@
*/
#include <arch.h>
-#include <cassert.h>
+
+#include <lib/cassert.h>
+
#include "plat_ls.h"
#include "platform_def.h"
diff --git a/plat/layerscape/board/ls1043/ls_gic.c b/plat/layerscape/board/ls1043/ls_gic.c
index 3986153..3d8b262 100644
--- a/plat/layerscape/board/ls1043/ls_gic.c
+++ b/plat/layerscape/board/ls1043/ls_gic.c
@@ -4,10 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
-#include <debug.h>
#include <endian.h>
-#include "platform_def.h"
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "soc.h"
/*
diff --git a/plat/layerscape/board/ls1043/platform.mk b/plat/layerscape/board/ls1043/platform.mk
index 795d924..91a14a4 100644
--- a/plat/layerscape/board/ls1043/platform.mk
+++ b/plat/layerscape/board/ls1043/platform.mk
@@ -23,9 +23,7 @@
PLAT_INCLUDES := -Iplat/layerscape/board/ls1043/include \
-Iplat/layerscape/common/include \
- -Iinclude/drivers/arm \
- -Iinclude/lib \
- -Iinclude/drivers/io
+ -Iinclude/lib
PLAT_BL_COMMON_SOURCES := plat/layerscape/common/aarch64/ls_console.S
diff --git a/plat/layerscape/common/aarch64/ls_bl2_mem_params_desc.c b/plat/layerscape/common/aarch64/ls_bl2_mem_params_desc.c
index a96e390..9410740 100644
--- a/plat/layerscape/common/aarch64/ls_bl2_mem_params_desc.c
+++ b/plat/layerscape/common/aarch64/ls_bl2_mem_params_desc.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
-#include <debug.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
+
#include <ls_def.h>
/*******************************************************************************
diff --git a/plat/layerscape/common/aarch64/ls_helpers.S b/plat/layerscape/common/aarch64/ls_helpers.S
index 7d71f48..bbddd0b 100644
--- a/plat/layerscape/common/aarch64/ls_helpers.S
+++ b/plat/layerscape/common/aarch64/ls_helpers.S
@@ -5,7 +5,7 @@
*/
#include <asm_macros.S>
-#include <console.h>
+#include <drivers/console.h>
#include <platform_def.h>
.weak plat_my_core_pos
diff --git a/plat/layerscape/common/include/ls_16550.h b/plat/layerscape/common/include/ls_16550.h
index 94694ee..b0b1856 100644
--- a/plat/layerscape/common/include/ls_16550.h
+++ b/plat/layerscape/common/include/ls_16550.h
@@ -7,7 +7,7 @@
#ifndef LS_16550_H
#define LS_16550_H
-#include <console.h>
+#include <drivers/console.h>
/* UART16550 Registers */
#define UARTTX 0x0
diff --git a/plat/layerscape/common/include/plat_ls.h b/plat/layerscape/common/include/plat_ls.h
index 49526ca..e56670b 100644
--- a/plat/layerscape/common/include/plat_ls.h
+++ b/plat/layerscape/common/include/plat_ls.h
@@ -7,9 +7,10 @@
#ifndef PLAT_LS_H
#define PLAT_LS_H
-#include <cpu_data.h>
#include <stdint.h>
+#include <lib/el3_runtime/cpu_data.h>
+
/* BL1 utility functions */
void ls_bl1_platform_setup(void);
void ls_bl1_early_platform_setup(void);
diff --git a/plat/layerscape/common/ls_bl1_setup.c b/plat/layerscape/common/ls_bl1_setup.c
index 0642b5e..fb929fe 100644
--- a/plat/layerscape/common/ls_bl1_setup.c
+++ b/plat/layerscape/common/ls_bl1_setup.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
+#include <common/debug.h>
+
#include "ls_16550.h"
#include "plat_ls.h"
#include "../../../bl1/bl1_private.h"
diff --git a/plat/layerscape/common/ls_bl2_setup.c b/plat/layerscape/common/ls_bl2_setup.c
index 4b2dc72..192eaec 100644
--- a/plat/layerscape/common/ls_bl2_setup.c
+++ b/plat/layerscape/common/ls_bl2_setup.c
@@ -5,8 +5,10 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <desc_image_load.h>
+
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+
#include "ls_16550.h"
#include "plat_ls.h"
#include "ls_def.h"
diff --git a/plat/layerscape/common/ls_bl31_setup.c b/plat/layerscape/common/ls_bl31_setup.c
index 2067b90..03e5807 100644
--- a/plat/layerscape/common/ls_bl31_setup.c
+++ b/plat/layerscape/common/ls_bl31_setup.c
@@ -5,11 +5,12 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <gicv2.h>
-#include <interrupt_props.h>
-#include <mmio.h>
+
+#include <common/bl_common.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
#include "ls_16550.h"
#include "plat_ls.h"
diff --git a/plat/layerscape/common/ls_common.c b/plat/layerscape/common/ls_common.c
index afd5927..3b42909 100644
--- a/plat/layerscape/common/ls_common.c
+++ b/plat/layerscape/common/ls_common.c
@@ -3,13 +3,16 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
+#include <assert.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <xlat_tables_v2.h>
-#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
-#include "platform_def.h"
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
const mmap_region_t *plat_ls_get_mmap(void);
diff --git a/plat/layerscape/common/ls_image_load.c b/plat/layerscape/common/ls_image_load.c
index 909bec2..70c01f2 100644
--- a/plat/layerscape/common/ls_image_load.c
+++ b/plat/layerscape/common/ls_image_load.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <desc_image_load.h>
+#include <common/desc_image_load.h>
+
#include "ls_def.h"
/*******************************************************************************
diff --git a/plat/layerscape/common/ls_io_storage.c b/plat/layerscape/common/ls_io_storage.c
index 7402366..71c2f45 100644
--- a/plat/layerscape/common/ls_io_storage.c
+++ b/plat/layerscape/common/ls_io_storage.c
@@ -3,14 +3,17 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <assert.h>
-#include <debug.h>
-#include <firmware_image_package.h>
-#include <io_driver.h>
-#include <io_fip.h>
-#include <io_memmap.h>
-#include <io_storage.h>
-#include "platform_def.h"
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_memmap.h>
+#include <drivers/io/io_storage.h>
+#include <tools_share/firmware_image_package.h>
/* IO devices */
static const io_dev_connector_t *fip_dev_con;
diff --git a/plat/layerscape/common/ls_timer.c b/plat/layerscape/common/ls_timer.c
index 25b5e63..021890b 100644
--- a/plat/layerscape/common/ls_timer.c
+++ b/plat/layerscape/common/ls_timer.c
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
-#include <delay_timer.h>
#include <arch_helpers.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
#define TIMER_BASE_ADDR 0x02B00000
diff --git a/plat/layerscape/common/ls_tzc380.c b/plat/layerscape/common/ls_tzc380.c
index b9f32ac..44f3fcd 100644
--- a/plat/layerscape/common/ls_tzc380.c
+++ b/plat/layerscape/common/ls_tzc380.c
@@ -4,10 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
#include <endian.h>
-#include "platform_def.h"
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "soc_tzasc.h"
int tzc380_set_region(unsigned int tzasc_base, unsigned int region_id,
diff --git a/plat/layerscape/common/ns_access.c b/plat/layerscape/common/ns_access.c
index e1daaed..b84fdbd 100644
--- a/plat/layerscape/common/ns_access.c
+++ b/plat/layerscape/common/ns_access.c
@@ -4,11 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
#include <endian.h>
-#include <debug.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "ns_access.h"
-#include "platform_def.h"
static void enable_devices_ns_access(struct csu_ns_dev *ns_dev, uint32_t num)
{
diff --git a/plat/layerscape/common/tsp/ls_tsp_setup.c b/plat/layerscape/common/tsp/ls_tsp_setup.c
index a046e2f..c607361 100644
--- a/plat/layerscape/common/tsp/ls_tsp_setup.c
+++ b/plat/layerscape/common/tsp/ls_tsp_setup.c
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <gicv2.h>
-#include <interrupt_props.h>
+#include <common/debug.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv2.h>
#include "ls_16550.h"
#include "plat_ls.h"
diff --git a/plat/marvell/a3700/a3700/board/pm_src.c b/plat/marvell/a3700/a3700/board/pm_src.c
index bc48ce8..d6eca5d 100644
--- a/plat/marvell/a3700/a3700/board/pm_src.c
+++ b/plat/marvell/a3700/a3700/board/pm_src.c
@@ -4,6 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
* https://spdx.org/licenses
*/
+
#include <a3700_pm.h>
#include <plat_marvell.h>
diff --git a/plat/marvell/a3700/a3700/plat_bl31_setup.c b/plat/marvell/a3700/a3700/plat_bl31_setup.c
index 83db06f..6862a86 100644
--- a/plat/marvell/a3700/a3700/plat_bl31_setup.c
+++ b/plat/marvell/a3700/a3700/plat_bl31_setup.c
@@ -5,10 +5,11 @@
* https://spdx.org/licenses
*/
+#include <lib/mmio.h>
+
#include <armada_common.h>
#include <dram_win.h>
#include <io_addr_dec.h>
-#include <mmio.h>
#include <marvell_plat_priv.h>
#include <plat_marvell.h>
diff --git a/plat/marvell/a3700/common/a3700_common.mk b/plat/marvell/a3700/common/a3700_common.mk
index e2ac97f..a4727d2 100644
--- a/plat/marvell/a3700/common/a3700_common.mk
+++ b/plat/marvell/a3700/common/a3700_common.mk
@@ -84,14 +84,12 @@
plat/common/plat_gicv3.c \
drivers/arm/gic/v3/gic500.c
-ATF_INCLUDES := -Iinclude/common/tbbr \
- -Iinclude/drivers
+ATF_INCLUDES := -Iinclude/common/tbbr
PLAT_INCLUDES := -I$(PLAT_FAMILY_BASE)/$(PLAT) \
-I$(PLAT_COMMON_BASE)/include \
-I$(PLAT_INCLUDE_BASE)/common \
-I$(MARVELL_DRV_BASE) \
- -Iinclude/drivers/marvell/uart \
-I$/drivers/arm/gic/common/ \
$(ATF_INCLUDES)
diff --git a/plat/marvell/a3700/common/a3700_sip_svc.c b/plat/marvell/a3700/common/a3700_sip_svc.c
index 88d1fc2..e8ac5fc 100644
--- a/plat/marvell/a3700/common/a3700_sip_svc.c
+++ b/plat/marvell/a3700/common/a3700_sip_svc.c
@@ -5,11 +5,13 @@
* https://spdx.org/licenses
*/
-#include <debug.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/smccc.h>
+
#include <marvell_plat_priv.h>
#include <plat_marvell.h>
-#include <runtime_svc.h>
-#include <smccc.h>
+
#include "comphy/phy-comphy-3700.h"
/* Comphy related FID's */
diff --git a/plat/marvell/a3700/common/dram_win.c b/plat/marvell/a3700/common/dram_win.c
index fb236d8..694f6d4 100644
--- a/plat/marvell/a3700/common/dram_win.c
+++ b/plat/marvell/a3700/common/dram_win.c
@@ -5,12 +5,14 @@
* https://spdx.org/licenses
*/
+#include <string.h>
+
+#include <lib/mmio.h>
+
#include <dram_win.h>
#include <marvell_plat_priv.h>
-#include <mmio.h>
#include <mvebu.h>
#include <plat_marvell.h>
-#include <string.h>
/* Armada 3700 has 5 configurable windows */
#define MV_CPU_WIN_NUM 5
diff --git a/plat/marvell/a3700/common/include/dram_win.h b/plat/marvell/a3700/common/include/dram_win.h
index 6f345f9..26a0137 100644
--- a/plat/marvell/a3700/common/include/dram_win.h
+++ b/plat/marvell/a3700/common/include/dram_win.h
@@ -8,7 +8,8 @@
#ifndef DRAM_WIN_H
#define DRAM_WIN_H
-#include <bl_common.h>
+#include <common/bl_common.h>
+
#include <io_addr_dec.h>
void dram_win_map_build(struct dram_win_map *win_map);
diff --git a/plat/marvell/a3700/common/include/platform_def.h b/plat/marvell/a3700/common/include/platform_def.h
index ca2553c..16865c4 100644
--- a/plat/marvell/a3700/common/include/platform_def.h
+++ b/plat/marvell/a3700/common/include/platform_def.h
@@ -8,12 +8,13 @@
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
-#include <board_marvell_def.h>
-#include <mvebu_def.h>
#ifndef __ASSEMBLY__
#include <stdio.h>
#endif /* __ASSEMBLY__ */
+#include <board_marvell_def.h>
+#include <mvebu_def.h>
+
/*
* Most platform porting definitions provided by included headers
*/
diff --git a/plat/marvell/a3700/common/io_addr_dec.c b/plat/marvell/a3700/common/io_addr_dec.c
index f009594..b27633c 100644
--- a/plat/marvell/a3700/common/io_addr_dec.c
+++ b/plat/marvell/a3700/common/io_addr_dec.c
@@ -4,9 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
* https://spdx.org/licenses
*/
-#include <debug.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include <io_addr_dec.h>
-#include <mmio.h>
#include <plat_marvell.h>
#define MVEBU_DEC_WIN_CTRL_REG(base, win, off) (MVEBU_REGS_BASE + (base) + \
diff --git a/plat/marvell/a3700/common/marvell_plat_config.c b/plat/marvell/a3700/common/marvell_plat_config.c
index 85a4201..3bf3d96 100644
--- a/plat/marvell/a3700/common/marvell_plat_config.c
+++ b/plat/marvell/a3700/common/marvell_plat_config.c
@@ -5,7 +5,8 @@
* https://spdx.org/licenses
*/
-#include <bl_common.h>
+#include <common/bl_common.h>
+
#include <io_addr_dec.h>
#include <mvebu_def.h>
diff --git a/plat/marvell/a3700/common/plat_pm.c b/plat/marvell/a3700/common/plat_pm.c
index dce4841..f8ce6fe 100644
--- a/plat/marvell/a3700/common/plat_pm.c
+++ b/plat/marvell/a3700/common/plat_pm.c
@@ -5,22 +5,23 @@
* https://spdx.org/licenses
*/
+#include <common/debug.h>
+#ifdef USE_CCI
+#include <drivers/arm/cci.h>
+#endif
+#include <lib/psci/psci.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include <a3700_pm.h>
#include <arch_helpers.h>
#include <armada_common.h>
-#include <debug.h>
#include <dram_win.h>
#include <io_addr_dec.h>
-#include <mmio.h>
#include <mvebu.h>
#include <mvebu_def.h>
#include <marvell_plat_priv.h>
-#include <platform.h>
#include <plat_marvell.h>
-#include <psci.h>
-#ifdef USE_CCI
-#include <cci.h>
-#endif
/* Warm reset register */
#define MVEBU_WARM_RESET_REG (MVEBU_NB_REGS_BASE + 0x840)
diff --git a/plat/marvell/a8k/a70x0/board/dram_port.c b/plat/marvell/a8k/a70x0/board/dram_port.c
index c670258..4fca7e3 100644
--- a/plat/marvell/a8k/a70x0/board/dram_port.c
+++ b/plat/marvell/a8k/a70x0/board/dram_port.c
@@ -6,7 +6,8 @@
*/
#include <arch_helpers.h>
-#include <debug.h>
+#include <common/debug.h>
+
#include <mv_ddr_if.h>
#include <plat_marvell.h>
diff --git a/plat/marvell/a8k/a70x0_amc/board/dram_port.c b/plat/marvell/a8k/a70x0_amc/board/dram_port.c
index ab1df46..aecf6c5 100644
--- a/plat/marvell/a8k/a70x0_amc/board/dram_port.c
+++ b/plat/marvell/a8k/a70x0_amc/board/dram_port.c
@@ -6,7 +6,8 @@
*/
#include <arch_helpers.h>
-#include <debug.h>
+#include <common/debug.h>
+
#include <mv_ddr_if.h>
#include <plat_marvell.h>
diff --git a/plat/marvell/a8k/a80x0/board/dram_port.c b/plat/marvell/a8k/a80x0/board/dram_port.c
index a99bf7c..02f4ffb 100644
--- a/plat/marvell/a8k/a80x0/board/dram_port.c
+++ b/plat/marvell/a8k/a80x0/board/dram_port.c
@@ -6,9 +6,10 @@
*/
#include <arch_helpers.h>
-#include <debug.h>
-#include <mentor/mi2cv.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/mentor/mi2cv.h>
+#include <lib/mmio.h>
+
#include <mv_ddr_if.h>
#include <mvebu_def.h>
#include <plat_marvell.h>
diff --git a/plat/marvell/a8k/a80x0_mcbin/board/dram_port.c b/plat/marvell/a8k/a80x0_mcbin/board/dram_port.c
index fa222ee..2580852 100644
--- a/plat/marvell/a8k/a80x0_mcbin/board/dram_port.c
+++ b/plat/marvell/a8k/a80x0_mcbin/board/dram_port.c
@@ -6,9 +6,10 @@
*/
#include <arch_helpers.h>
-#include <debug.h>
-#include <mentor/mi2cv.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/mentor/mi2cv.h>
+#include <lib/mmio.h>
+
#include <mv_ddr_if.h>
#include <mvebu_def.h>
#include <plat_marvell.h>
diff --git a/plat/marvell/a8k/a80x0_mcbin/board/marvell_plat_config.c b/plat/marvell/a8k/a80x0_mcbin/board/marvell_plat_config.c
index 384d0f5..fa4e144 100644
--- a/plat/marvell/a8k/a80x0_mcbin/board/marvell_plat_config.c
+++ b/plat/marvell/a8k/a80x0_mcbin/board/marvell_plat_config.c
@@ -5,9 +5,10 @@
* https://spdx.org/licenses
*/
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
#include <armada_common.h>
-#include <delay_timer.h>
-#include <mmio.h>
/*
* If bootrom is currently at BLE there's no need to include the memory
diff --git a/plat/marvell/a8k/common/a8k_common.mk b/plat/marvell/a8k/common/a8k_common.mk
index e350d6a..efb05b8 100644
--- a/plat/marvell/a8k/common/a8k_common.mk
+++ b/plat/marvell/a8k/common/a8k_common.mk
@@ -50,8 +50,6 @@
PLAT_INCLUDES := -I$(PLAT_FAMILY_BASE)/$(PLAT) \
-I$(PLAT_COMMON_BASE)/include \
-I$(PLAT_INCLUDE_BASE)/common \
- -Iinclude/drivers/marvell \
- -Iinclude/drivers/marvell/mochi \
$(ATF_INCLUDES)
PLAT_BL_COMMON_SOURCES := $(PLAT_COMMON_BASE)/aarch64/a8k_common.c \
diff --git a/plat/marvell/a8k/common/aarch64/plat_arch_config.c b/plat/marvell/a8k/common/aarch64/plat_arch_config.c
index 8667331..06dc841 100644
--- a/plat/marvell/a8k/common/aarch64/plat_arch_config.c
+++ b/plat/marvell/a8k/common/aarch64/plat_arch_config.c
@@ -5,12 +5,11 @@
* https://spdx.org/licenses
*/
-#include <platform.h>
#include <arch_helpers.h>
-#include <mmio.h>
-#include <debug.h>
-#include <cache_llc.h>
-
+#include <common/debug.h>
+#include <drivers/marvell/cache_llc.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
#define CCU_HTC_ASET (MVEBU_CCU_BASE(MVEBU_AP0) + 0x264)
#define MVEBU_IO_AFFINITY (0xF00)
diff --git a/plat/marvell/a8k/common/ble/ble.mk b/plat/marvell/a8k/common/ble/ble.mk
index 5f24ced..ed4ff3a 100644
--- a/plat/marvell/a8k/common/ble/ble.mk
+++ b/plat/marvell/a8k/common/ble/ble.mk
@@ -13,12 +13,12 @@
BLE_SOURCES += $(BLE_PATH)/ble_main.c \
$(BLE_PATH)/ble_mem.S \
drivers/delay_timer/delay_timer.c \
+ $(PLAT_MARVELL)/common/aarch64/marvell_helpers.S \
$(PLAT_MARVELL)/common/plat_delay_timer.c \
$(PLAT_MARVELL)/common/marvell_console.c
PLAT_INCLUDES += -I$(MV_DDR_PATH) \
-I$(CURDIR)/include/ \
- -I$(CURDIR)/include/drivers \
-I$(CURDIR)/include/lib \
-I$(CURDIR)/include/lib/libc \
-I$(CURDIR)/include/lib/libc/aarch64 \
diff --git a/plat/marvell/a8k/common/ble/ble_main.c b/plat/marvell/a8k/common/ble/ble_main.c
index b04e8b7..5b3acec 100644
--- a/plat/marvell/a8k/common/ble/ble_main.c
+++ b/plat/marvell/a8k/common/ble/ble_main.c
@@ -5,14 +5,17 @@
* https://spdx.org/licenses
*/
+#include <string.h>
+
+#include <platform_def.h>
+
#include <arch_helpers.h>
-#include <debug.h>
-#include <console.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+
#include <marvell_plat_priv.h>
#include <marvell_pm.h>
-#include <platform_def.h>
#include <plat_marvell.h>
-#include <string.h>
#define BR_FLAG_SILENT 0x1
#define SKIP_IMAGE_CODE 0xDEADB002
diff --git a/plat/marvell/a8k/common/include/platform_def.h b/plat/marvell/a8k/common/include/platform_def.h
index 4c3e7a9..3f6154e 100644
--- a/plat/marvell/a8k/common/include/platform_def.h
+++ b/plat/marvell/a8k/common/include/platform_def.h
@@ -8,14 +8,16 @@
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
-#include <board_marvell_def.h>
-#include <gic_common.h>
-#include <interrupt_props.h>
-#include <mvebu_def.h>
#ifndef __ASSEMBLY__
#include <stdio.h>
#endif /* __ASSEMBLY__ */
+#include <common/interrupt_props.h>
+#include <drivers/arm/gic_common.h>
+
+#include <board_marvell_def.h>
+#include <mvebu_def.h>
+
/*
* Most platform porting definitions provided by included headers
*/
diff --git a/plat/marvell/a8k/common/mss/mss_bl2_setup.c b/plat/marvell/a8k/common/mss/mss_bl2_setup.c
index 973c56d..728ee54 100644
--- a/plat/marvell/a8k/common/mss/mss_bl2_setup.c
+++ b/plat/marvell/a8k/common/mss/mss_bl2_setup.c
@@ -5,15 +5,17 @@
* https://spdx.org/licenses
*/
-#include <armada_common.h>
-#include <bl_common.h>
-#include <ccu.h>
-#include <cp110_setup.h>
-#include <debug.h>
-#include <marvell_plat_priv.h> /* timer functionality */
-#include <mmio.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/marvell/ccu.h>
+#include <drivers/marvell/mochi/cp110_setup.h>
+#include <lib/mmio.h>
+
+#include <armada_common.h>
+#include <marvell_plat_priv.h> /* timer functionality */
+
#include "mss_scp_bootloader.h"
/* IO windows configuration */
diff --git a/plat/marvell/a8k/common/mss/mss_pm_ipc.c b/plat/marvell/a8k/common/mss/mss_pm_ipc.c
index d1297b0..a070583 100644
--- a/plat/marvell/a8k/common/mss/mss_pm_ipc.c
+++ b/plat/marvell/a8k/common/mss/mss_pm_ipc.c
@@ -5,11 +5,12 @@
* https://spdx.org/licenses
*/
-#include <debug.h>
-#include <mmio.h>
-#include <psci.h>
#include <string.h>
+#include <common/debug.h>
+#include <lib/psci/psci.h>
+#include <lib/mmio.h>
+
#include <mss_pm_ipc.h>
/*
diff --git a/plat/marvell/a8k/common/plat_bl1_setup.c b/plat/marvell/a8k/common/plat_bl1_setup.c
index 5d85102..f9521c8 100644
--- a/plat/marvell/a8k/common/plat_bl1_setup.c
+++ b/plat/marvell/a8k/common/plat_bl1_setup.c
@@ -5,7 +5,8 @@
* https://spdx.org/licenses
*/
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include <plat_marvell.h>
void marvell_bl1_setup_mpps(void)
diff --git a/plat/marvell/a8k/common/plat_bl31_setup.c b/plat/marvell/a8k/common/plat_bl31_setup.c
index 6dfbcbb..98b3966 100644
--- a/plat/marvell/a8k/common/plat_bl31_setup.c
+++ b/plat/marvell/a8k/common/plat_bl31_setup.c
@@ -5,17 +5,17 @@
* https://spdx.org/licenses
*/
+#include <common/debug.h>
+#include <drivers/marvell/mci.h>
+#include <drivers/marvell/mochi/ap_setup.h>
+#include <drivers/marvell/mochi/cp110_setup.h>
+#include <lib/mmio.h>
+
#include <armada_common.h>
-#include <ap_setup.h>
-#include <cp110_setup.h>
-#include <debug.h>
#include <marvell_plat_priv.h>
#include <marvell_pm.h>
#include <mc_trustzone/mc_trustzone.h>
-#include <mmio.h>
-#include <mci.h>
#include <plat_marvell.h>
-
#include <mss_ipc_drv.h>
#include <mss_mem.h>
diff --git a/plat/marvell/a8k/common/plat_ble_setup.c b/plat/marvell/a8k/common/plat_ble_setup.c
index dbadeb7..0590cc0 100644
--- a/plat/marvell/a8k/common/plat_ble_setup.c
+++ b/plat/marvell/a8k/common/plat_ble_setup.c
@@ -5,17 +5,18 @@
* https://spdx.org/licenses
*/
-#include <ap_setup.h>
+#include <common/debug.h>
+#include <drivers/marvell/ap807_clocks_init.h>
+#include <drivers/marvell/aro.h>
+#include <drivers/marvell/ccu.h>
+#include <drivers/marvell/io_win.h>
+#include <drivers/marvell/mochi/ap_setup.h>
+#include <drivers/marvell/mochi/cp110_setup.h>
+
#include <armada_common.h>
-#include <aro.h>
-#include <ccu.h>
-#include <cp110_setup.h>
-#include <debug.h>
-#include <io_win.h>
#include <mv_ddr_if.h>
#include <mvebu_def.h>
#include <plat_marvell.h>
-#include "ap807_clocks_init.h"
/* Register for skip image use */
#define SCRATCH_PAD_REG2 0xF06F00A8
diff --git a/plat/marvell/a8k/common/plat_pm.c b/plat/marvell/a8k/common/plat_pm.c
index 2854416..e2575b1 100644
--- a/plat/marvell/a8k/common/plat_pm.c
+++ b/plat/marvell/a8k/common/plat_pm.c
@@ -5,19 +5,21 @@
* https://spdx.org/licenses
*/
-#include <armada_common.h>
#include <assert.h>
-#include <bakery_lock.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <cache_llc.h>
-#include <console.h>
-#include <gicv2.h>
+
+#include <common/debug.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/console.h>
+#include <drivers/delay_timer.h>
+#include <drivers/marvell/cache_llc.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <armada_common.h>
#include <marvell_pm.h>
-#include <mmio.h>
#include <mss_pm_ipc.h>
#include <plat_marvell.h>
-#include <platform.h>
#include <plat_pm_trace.h>
#define MVEBU_PRIVATE_UID_REG 0x30
diff --git a/plat/marvell/a8k/common/plat_pm_trace.c b/plat/marvell/a8k/common/plat_pm_trace.c
index 683e56f..f589ff3 100644
--- a/plat/marvell/a8k/common/plat_pm_trace.c
+++ b/plat/marvell/a8k/common/plat_pm_trace.c
@@ -5,9 +5,10 @@
* https://spdx.org/licenses
*/
-#include <mmio.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include <mss_mem.h>
-#include <platform.h>
#include <plat_pm_trace.h>
#ifdef PM_TRACE_ENABLE
diff --git a/plat/marvell/a8k/common/plat_thermal.c b/plat/marvell/a8k/common/plat_thermal.c
index 02fe820..a2fc0d0 100644
--- a/plat/marvell/a8k/common/plat_thermal.c
+++ b/plat/marvell/a8k/common/plat_thermal.c
@@ -5,11 +5,12 @@
* https://spdx.org/licenses
*/
-#include <debug.h>
-#include <delay_timer.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/marvell/thermal.h>
+#include <lib/mmio.h>
+
#include <mvebu_def.h>
-#include <thermal.h>
#define THERMAL_TIMEOUT 1200
diff --git a/plat/marvell/common/aarch64/marvell_bl2_mem_params_desc.c b/plat/marvell/common/aarch64/marvell_bl2_mem_params_desc.c
index 17f8771..6a8e11c 100644
--- a/plat/marvell/common/aarch64/marvell_bl2_mem_params_desc.c
+++ b/plat/marvell/common/aarch64/marvell_bl2_mem_params_desc.c
@@ -4,12 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <marvell_def.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <marvell_def.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* Following descriptor provides BL image/ep information that gets used
diff --git a/plat/marvell/common/aarch64/marvell_common.c b/plat/marvell/common/aarch64/marvell_common.c
index abc501a..ea0902c 100644
--- a/plat/marvell/common/aarch64/marvell_common.c
+++ b/plat/marvell/common/aarch64/marvell_common.c
@@ -5,15 +5,17 @@
* https://spdx.org/licenses
*/
+#include <assert.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
-#include <plat_marvell.h>
-#include <platform_def.h>
-#include <xlat_tables.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat_marvell.h>
/* Weak definitions may be overridden in specific ARM standard platform */
#pragma weak plat_get_ns_image_entrypoint
diff --git a/plat/marvell/common/aarch64/marvell_helpers.S b/plat/marvell/common/aarch64/marvell_helpers.S
index fbd19cb..6f625b9 100644
--- a/plat/marvell/common/aarch64/marvell_helpers.S
+++ b/plat/marvell/common/aarch64/marvell_helpers.S
@@ -7,12 +7,12 @@
#include <asm_macros.S>
#include <cortex_a72.h>
+#ifndef PLAT_a3700
+#include <drivers/marvell/ccu.h>
+#include <drivers/marvell/cache_llc.h>
+#endif
#include <marvell_def.h>
#include <platform_def.h>
-#ifndef PLAT_a3700
-#include <ccu.h>
-#include <cache_llc.h>
-#endif
.weak plat_marvell_calc_core_pos
.weak plat_my_core_pos
diff --git a/plat/marvell/common/marvell_bl1_setup.c b/plat/marvell/common/marvell_bl1_setup.c
index c96f006..8f72210 100644
--- a/plat/marvell/common/marvell_bl1_setup.c
+++ b/plat/marvell/common/marvell_bl1_setup.c
@@ -5,15 +5,17 @@
* https://spdx.org/licenses
*/
-#include <bl1.h>
-#include <bl1/bl1_private.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <platform.h>
#include <platform_def.h>
+
+#include <bl1/bl1.h>
+#include <bl1/bl1_private.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/sp805.h>
+#include <drivers/console.h>
+#include <plat/common/platform.h>
+
#include <plat_marvell.h>
-#include <sp805.h>
/* Weak definitions may be overridden in specific Marvell standard platform */
#pragma weak bl1_early_platform_setup
diff --git a/plat/marvell/common/marvell_bl2_setup.c b/plat/marvell/common/marvell_bl2_setup.c
index 883336f..3c1c391 100644
--- a/plat/marvell/common/marvell_bl2_setup.c
+++ b/plat/marvell/common/marvell_bl2_setup.c
@@ -5,17 +5,20 @@
* https://spdx.org/licenses
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <desc_image_load.h>
-#include <marvell_def.h>
-#include <platform_def.h>
-#include <plat_marvell.h>
#include <string.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <drivers/console.h>
+#include <lib/utils.h>
+
+#include <marvell_def.h>
+#include <plat_marvell.h>
/* Data structure which holds the extents of the trusted SRAM for BL2 */
static meminfo_t bl2_tzram_layout __aligned(CACHE_WRITEBACK_GRANULE);
diff --git a/plat/marvell/common/marvell_bl31_setup.c b/plat/marvell/common/marvell_bl31_setup.c
index 3b1a6f1..802c013 100644
--- a/plat/marvell/common/marvell_bl31_setup.c
+++ b/plat/marvell/common/marvell_bl31_setup.c
@@ -5,18 +5,19 @@
* https://spdx.org/licenses
*/
-#include <arch.h>
#include <assert.h>
-#include <console.h>
-#include <debug.h>
+
+#include <arch.h>
+#include <common/debug.h>
+#ifdef USE_CCI
+#include <drivers/arm/cci.h>
+#endif
+#include <drivers/console.h>
+#include <plat/common/platform.h>
+
#include <marvell_def.h>
#include <marvell_plat_priv.h>
#include <plat_marvell.h>
-#include <platform.h>
-
-#ifdef USE_CCI
-#include <cci.h>
-#endif
/*
* The next 3 constants identify the extents of the code, RO data region and the
diff --git a/plat/marvell/common/marvell_cci.c b/plat/marvell/common/marvell_cci.c
index 2df4802..80351ae 100644
--- a/plat/marvell/common/marvell_cci.c
+++ b/plat/marvell/common/marvell_cci.c
@@ -5,7 +5,8 @@
* https://spdx.org/licenses
*/
-#include <cci.h>
+#include <drivers/arm/cci.h>
+
#include <plat_marvell.h>
static const int cci_map[] = {
diff --git a/plat/marvell/common/marvell_console.c b/plat/marvell/common/marvell_console.c
index eba106d..22c5eb3 100644
--- a/plat/marvell/common/marvell_console.c
+++ b/plat/marvell/common/marvell_console.c
@@ -4,18 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <assert.h>
-#include <console.h>
-#include <debug.h>
-#include <plat_marvell.h>
+
#include <platform_def.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+
+#include <plat_marvell.h>
+
#ifdef PLAT_a3700
-#include <a3700_console.h>
+#include <drivers/marvell/uart/a3700_console.h>
static console_a3700_t marvell_boot_console;
static console_a3700_t marvell_runtime_console;
#else
-#include <uart_16550.h>
+#include <drivers/ti/uart/uart_16550.h>
static console_16550_t marvell_boot_console;
static console_16550_t marvell_runtime_console;
diff --git a/plat/marvell/common/marvell_ddr_info.c b/plat/marvell/common/marvell_ddr_info.c
index 68bff99..7340996 100644
--- a/plat/marvell/common/marvell_ddr_info.c
+++ b/plat/marvell/common/marvell_ddr_info.c
@@ -5,10 +5,12 @@
* https://spdx.org/licenses
*/
-#include <debug.h>
#include <platform_def.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include <ddr_info.h>
-#include <mmio.h>
#define DRAM_CH0_MMAP_LOW_REG(iface, cs, base) \
(base + DRAM_CH0_MMAP_LOW_OFFSET + (iface) * 0x10000 + (cs) * 0x8)
diff --git a/plat/marvell/common/marvell_gicv2.c b/plat/marvell/common/marvell_gicv2.c
index 19e1ec0..2505c9f 100644
--- a/plat/marvell/common/marvell_gicv2.c
+++ b/plat/marvell/common/marvell_gicv2.c
@@ -5,15 +5,17 @@
* https://spdx.org/licenses
*/
-#include <bakery_lock.h>
-#include <debug.h>
-#include <gicv2.h>
-#include <interrupt_mgmt.h>
-#include <mmio.h>
-#include <plat_marvell.h>
-#include <platform.h>
#include <platform_def.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <plat_marvell.h>
+
/*
* The following functions are defined as weak to allow a platform to override
* the way the GICv2 driver is initialised and used.
diff --git a/plat/marvell/common/marvell_gicv3.c b/plat/marvell/common/marvell_gicv3.c
index 7cfefaf..0bd5545 100644
--- a/plat/marvell/common/marvell_gicv3.c
+++ b/plat/marvell/common/marvell_gicv3.c
@@ -5,13 +5,15 @@
* https://spdx.org/licenses
*/
-#include <debug.h>
-#include <gicv3.h>
-#include <interrupt_props.h>
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv3.h>
+#include <plat/common/platform.h>
+
#include <marvell_def.h>
#include <plat_marvell.h>
-#include <platform.h>
-#include <platform_def.h>
/******************************************************************************
* The following functions are defined as weak to allow a platform to override
diff --git a/plat/marvell/common/marvell_image_load.c b/plat/marvell/common/marvell_image_load.c
index d69b1b1..be16b08 100644
--- a/plat/marvell/common/marvell_image_load.c
+++ b/plat/marvell/common/marvell_image_load.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
+
/*******************************************************************************
* This function flushes the data structures so that they are visible
* in memory for the next BL image.
diff --git a/plat/marvell/common/marvell_io_storage.c b/plat/marvell/common/marvell_io_storage.c
index cb9ece2..065f956 100644
--- a/plat/marvell/common/marvell_io_storage.c
+++ b/plat/marvell/common/marvell_io_storage.c
@@ -6,16 +6,18 @@
*/
#include <assert.h>
-#include <bl_common.h> /* For ARRAY_SIZE */
-#include <debug.h>
-#include <firmware_image_package.h>
-#include <io_driver.h>
-#include <io_fip.h>
-#include <io_memmap.h>
-#include <io_storage.h>
-#include <platform_def.h>
#include <string.h>
+#include <platform_def.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_memmap.h>
+#include <drivers/io/io_storage.h>
+#include <tools_share/firmware_image_package.h>
+
/* IO devices */
static const io_dev_connector_t *fip_dev_con;
static uintptr_t fip_dev_handle;
diff --git a/plat/marvell/common/marvell_pm.c b/plat/marvell/common/marvell_pm.c
index 2a75790..3c675b2 100644
--- a/plat/marvell/common/marvell_pm.c
+++ b/plat/marvell/common/marvell_pm.c
@@ -5,9 +5,11 @@
* https://spdx.org/licenses
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <psci.h>
+
+#include <arch_helpers.h>
+#include <lib/psci/psci.h>
+
#include <marvell_pm.h>
/* Standard ARM platforms are expected to export plat_arm_psci_pm_ops */
diff --git a/plat/marvell/common/mrvl_sip_svc.c b/plat/marvell/common/mrvl_sip_svc.c
index bc4b621..df21105 100644
--- a/plat/marvell/common/mrvl_sip_svc.c
+++ b/plat/marvell/common/mrvl_sip_svc.c
@@ -5,13 +5,15 @@
* https://spdx.org/licenses
*/
-#include <ap_setup.h>
-#include <cache_llc.h>
-#include <debug.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <drivers/marvell/cache_llc.h>
+#include <drivers/marvell/mochi/ap_setup.h>
+#include <lib/smccc.h>
+
#include <marvell_plat_priv.h>
#include <plat_marvell.h>
-#include <runtime_svc.h>
-#include <smccc.h>
+
#include "comphy/phy-comphy-cp110.h"
/* #define DEBUG_COMPHY */
diff --git a/plat/marvell/common/mss/mss_ipc_drv.c b/plat/marvell/common/mss/mss_ipc_drv.c
index 731c315..70ccfa5 100644
--- a/plat/marvell/common/mss/mss_ipc_drv.c
+++ b/plat/marvell/common/mss/mss_ipc_drv.c
@@ -5,11 +5,13 @@
* https://spdx.org/licenses
*/
-#include <plat_marvell.h>
-#include <debug.h>
#include <string.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
+#include <plat_marvell.h>
#include <mss_ipc_drv.h>
-#include <mmio.h>
#define IPC_MSG_BASE_MASK MVEBU_REGS_BASE_MASK
diff --git a/plat/marvell/common/mss/mss_ipc_drv.h b/plat/marvell/common/mss/mss_ipc_drv.h
index 7bb15d3..bcb4b2d 100644
--- a/plat/marvell/common/mss/mss_ipc_drv.h
+++ b/plat/marvell/common/mss/mss_ipc_drv.h
@@ -8,7 +8,7 @@
#ifndef MSS_IPC_DRV_H
#define MSS_IPC_DRV_H
-#include <psci.h>
+#include <lib/psci/psci.h>
#define MV_PM_FW_IPC_VERSION_MAGIC (0xCA530000) /* Do NOT change */
/* Increament for each version */
diff --git a/plat/marvell/common/mss/mss_scp_bootloader.c b/plat/marvell/common/mss/mss_scp_bootloader.c
index 334fcfc..7e442c6 100644
--- a/plat/marvell/common/mss/mss_scp_bootloader.c
+++ b/plat/marvell/common/mss/mss_scp_bootloader.c
@@ -6,11 +6,13 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
-#include <arch_helpers.h> /* for cache maintanance operations */
+
#include <platform_def.h>
-#include <delay_timer.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
#include <plat_pm_trace.h>
#include <mss_scp_bootloader.h>
diff --git a/plat/marvell/common/plat_delay_timer.c b/plat/marvell/common/plat_delay_timer.c
index dfc77c7..2539752 100644
--- a/plat/marvell/common/plat_delay_timer.c
+++ b/plat/marvell/common/plat_delay_timer.c
@@ -6,7 +6,8 @@
*/
#include <arch_helpers.h>
-#include <delay_timer.h>
+#include <drivers/delay_timer.h>
+
#include <mvebu_def.h>
#define SYS_COUNTER_FREQ_IN_MHZ (COUNTER_FREQUENCY/1000000)
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 <mcucfg.h>
-#include <mmio.h>
-#include <plat_private.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 <plat_private.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 <arch_helpers.h>
-#include <bl_common.h>
-#include <cci.h>
-#include <debug.h>
-#include <mt8173_def.h>
+
#include <platform_def.h>
-#include <utils.h>
-#include <xlat_tables.h>
+
+#include <arch_helpers.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>
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 <arch.h>
-#include <debug.h>
-#include <mmio.h>
-#include <mt8173_def.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <arch.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <mt8173_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 <platform_def.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)
{
diff --git a/plat/meson/gxbb/gxbb_bl31_setup.c b/plat/meson/gxbb/gxbb_bl31_setup.c
index 3e176f9..b867a58 100644
--- a/plat/meson/gxbb/gxbb_bl31_setup.c
+++ b/plat/meson/gxbb/gxbb_bl31_setup.c
@@ -5,12 +5,14 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <gicv2.h>
-#include <interrupt_props.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <xlat_mmu_helpers.h>
+
+#include <common/bl_common.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
+#include <plat/common/platform.h>
#include "gxbb_private.h"
diff --git a/plat/meson/gxbb/gxbb_common.c b/plat/meson/gxbb/gxbb_common.c
index 349d02f..0ca15e8 100644
--- a/plat/meson/gxbb/gxbb_common.c
+++ b/plat/meson/gxbb/gxbb_common.c
@@ -5,15 +5,17 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <ep_info.h>
-#include <interrupt_mgmt.h>
-#include <meson_console.h>
-#include <mmio.h>
-#include <platform_def.h>
#include <stdint.h>
-#include <xlat_tables_v2.h>
+
+#include <platform_def.h>
+
+#include <bl31/interrupt_mgmt.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/ep_info.h>
+#include <drivers/meson/meson_console.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
/*******************************************************************************
* Platform memory map regions
diff --git a/plat/meson/gxbb/gxbb_def.h b/plat/meson/gxbb/gxbb_def.h
index 0c73ac0..3e27097 100644
--- a/plat/meson/gxbb/gxbb_def.h
+++ b/plat/meson/gxbb/gxbb_def.h
@@ -7,7 +7,7 @@
#ifndef GXBB_DEF_H
#define GXBB_DEF_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* System oscillator
diff --git a/plat/meson/gxbb/gxbb_mhu.c b/plat/meson/gxbb/gxbb_mhu.c
index 78b895c..903ef41 100644
--- a/plat/meson/gxbb/gxbb_mhu.c
+++ b/plat/meson/gxbb/gxbb_mhu.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bakery_lock.h>
-#include <mmio.h>
#include <platform_def.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+
static DEFINE_BAKERY_LOCK(mhu_lock);
void mhu_secure_message_start(void)
diff --git a/plat/meson/gxbb/gxbb_pm.c b/plat/meson/gxbb/gxbb_pm.c
index 930b5e1..59b9436 100644
--- a/plat/meson/gxbb/gxbb_pm.c
+++ b/plat/meson/gxbb/gxbb_pm.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <console.h>
-#include <debug.h>
#include <errno.h>
-#include <gicv2.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
#include "gxbb_private.h"
diff --git a/plat/meson/gxbb/gxbb_scpi.c b/plat/meson/gxbb/gxbb_scpi.c
index 2390bca..83eeda2 100644
--- a/plat/meson/gxbb/gxbb_scpi.c
+++ b/plat/meson/gxbb/gxbb_scpi.c
@@ -5,11 +5,13 @@
*/
#include <assert.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
#include <string.h>
+#include <platform_def.h>
+
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include "gxbb_private.h"
#define SIZE_SHIFT 20
diff --git a/plat/meson/gxbb/gxbb_sip_svc.c b/plat/meson/gxbb/gxbb_sip_svc.c
index 82ed449..63c7dba 100644
--- a/plat/meson/gxbb/gxbb_sip_svc.c
+++ b/plat/meson/gxbb/gxbb_sip_svc.c
@@ -4,12 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
-#include <platform_def.h>
-#include <runtime_svc.h>
#include <stdint.h>
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/mmio.h>
+
#include "gxbb_private.h"
/*******************************************************************************
diff --git a/plat/meson/gxbb/gxbb_topology.c b/plat/meson/gxbb/gxbb_topology.c
index 49bb2dc..eec2d34 100644
--- a/plat/meson/gxbb/gxbb_topology.c
+++ b/plat/meson/gxbb/gxbb_topology.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <platform_def.h>
#include <stdint.h>
+#include <platform_def.h>
+
+#include <arch.h>
+
#include "gxbb_private.h"
/* The power domain tree descriptor */
diff --git a/plat/meson/gxbb/include/plat_macros.S b/plat/meson/gxbb/include/plat_macros.S
index 948b5f9..c721c21 100644
--- a/plat/meson/gxbb/include/plat_macros.S
+++ b/plat/meson/gxbb/include/plat_macros.S
@@ -7,7 +7,7 @@
#ifndef PLAT_MACROS_S
#define PLAT_MACROS_S
-#include <gicv2.h>
+#include <drivers/arm/gicv2.h>
#include <platform_def.h>
.section .rodata.gic_reg_name, "aS"
diff --git a/plat/meson/gxbb/include/platform_def.h b/plat/meson/gxbb/include/platform_def.h
index a85637f..da4aedd 100644
--- a/plat/meson/gxbb/include/platform_def.h
+++ b/plat/meson/gxbb/include/platform_def.h
@@ -8,7 +8,7 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <utils_def.h>
+#include <lib/utils_def.h>
#include "../gxbb_def.h"
diff --git a/plat/meson/gxbb/platform.mk b/plat/meson/gxbb/platform.mk
index 68ff400..9669bf9 100644
--- a/plat/meson/gxbb/platform.mk
+++ b/plat/meson/gxbb/platform.mk
@@ -6,8 +6,7 @@
include lib/xlat_tables_v2/xlat_tables.mk
-PLAT_INCLUDES := -Iinclude/drivers/meson/ \
- -Iplat/meson/gxbb/include
+PLAT_INCLUDES := -Iplat/meson/gxbb/include
GXBB_GIC_SOURCES := drivers/arm/gic/common/gic_common.c \
drivers/arm/gic/v2/gicv2_main.c \
diff --git a/plat/nvidia/tegra/common/drivers/flowctrl/flowctrl.c b/plat/nvidia/tegra/common/drivers/flowctrl/flowctrl.c
index 2d827da..775ad30 100644
--- a/plat/nvidia/tegra/common/drivers/flowctrl/flowctrl.c
+++ b/plat/nvidia/tegra/common/drivers/flowctrl/flowctrl.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
+
+#include <arch_helpers.h>
#include <cortex_a53.h>
-#include <debug.h>
-#include <delay_timer.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
#include <flowctrl.h>
-#include <mmio.h>
#include <pmc.h>
#include <tegra_def.h>
diff --git a/plat/nvidia/tegra/common/drivers/memctrl/memctrl_v1.c b/plat/nvidia/tegra/common/drivers/memctrl/memctrl_v1.c
index 9944e72..58f49d0 100644
--- a/plat/nvidia/tegra/common/drivers/memctrl/memctrl_v1.c
+++ b/plat/nvidia/tegra/common/drivers/memctrl/memctrl_v1.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
+#include <string.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+
#include <memctrl.h>
#include <memctrl_v1.h>
-#include <mmio.h>
-#include <string.h>
#include <tegra_def.h>
-#include <utils.h>
-#include <xlat_tables_v2.h>
/* Video Memory base and size (live values) */
static uint64_t video_mem_base;
diff --git a/plat/nvidia/tegra/common/drivers/memctrl/memctrl_v2.c b/plat/nvidia/tegra/common/drivers/memctrl/memctrl_v2.c
index 92fdadc..55b9152 100644
--- a/plat/nvidia/tegra/common/drivers/memctrl/memctrl_v2.c
+++ b/plat/nvidia/tegra/common/drivers/memctrl/memctrl_v2.c
@@ -4,20 +4,22 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
+#include <string.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+
#include <mce.h>
#include <memctrl.h>
#include <memctrl_v2.h>
-#include <mmio.h>
#include <smmu.h>
-#include <string.h>
#include <tegra_def.h>
#include <tegra_platform.h>
-#include <utils.h>
-#include <xlat_tables_v2.h>
/* Video Memory base and size (live values) */
static uint64_t video_mem_base;
diff --git a/plat/nvidia/tegra/common/drivers/pmc/pmc.c b/plat/nvidia/tegra/common/drivers/pmc/pmc.c
index d8827e1..b9ff511 100644
--- a/plat/nvidia/tegra/common/drivers/pmc/pmc.c
+++ b/plat/nvidia/tegra/common/drivers/pmc/pmc.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include <pmc.h>
#include <tegra_def.h>
diff --git a/plat/nvidia/tegra/common/drivers/smmu/smmu.c b/plat/nvidia/tegra/common/drivers/smmu/smmu.c
index 4b9edb6..610f32f 100644
--- a/plat/nvidia/tegra/common/drivers/smmu/smmu.c
+++ b/plat/nvidia/tegra/common/drivers/smmu/smmu.c
@@ -5,11 +5,14 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <platform_def.h>
-#include <smmu.h>
#include <string.h>
+
+#include <platform_def.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+
+#include <smmu.h>
#include <tegra_private.h>
extern void memcpy16(void *dest, const void *src, unsigned int length);
diff --git a/plat/nvidia/tegra/common/tegra_bl31_setup.c b/plat/nvidia/tegra/common/tegra_bl31_setup.c
index 9410d44..b496650 100644
--- a/plat/nvidia/tegra/common/tegra_bl31_setup.c
+++ b/plat/nvidia/tegra/common/tegra_bl31_setup.c
@@ -4,27 +4,30 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl31.h>
-#include <bl_common.h>
-#include <console.h>
-#include <cortex_a53.h>
-#include <cortex_a57.h>
-#include <debug.h>
-#include <denver.h>
#include <errno.h>
-#include <memctrl.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
#include <stddef.h>
#include <string.h>
+
+#include <platform_def.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <bl31/bl31.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <cortex_a53.h>
+#include <cortex_a57.h>
+#include <denver.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
+#include <lib/utils_def.h>
+#include <plat/common/platform.h>
+
+#include <memctrl.h>
#include <tegra_def.h>
#include <tegra_private.h>
-#include <utils.h>
-#include <utils_def.h>
/* length of Trusty's input parameters (in bytes) */
#define TRUSTY_PARAMS_LEN_BYTES (4096*2)
diff --git a/plat/nvidia/tegra/common/tegra_common.mk b/plat/nvidia/tegra/common/tegra_common.mk
index abb9bb8..6a0854e 100644
--- a/plat/nvidia/tegra/common/tegra_common.mk
+++ b/plat/nvidia/tegra/common/tegra_common.mk
@@ -13,15 +13,21 @@
COMMON_DIR := plat/nvidia/tegra/common
-BL31_SOURCES += drivers/console/aarch64/console.S \
+TEGRA_GICv2_SOURCES := drivers/arm/gic/common/gic_common.c \
+ drivers/arm/gic/v2/gicv2_main.c \
+ drivers/arm/gic/v2/gicv2_helpers.c \
+ plat/common/plat_gicv2.c \
+ ${COMMON_DIR}/tegra_gicv2.c
+
+BL31_SOURCES += drivers/console/aarch64/console.S \
drivers/delay_timer/delay_timer.c \
drivers/ti/uart/aarch64/16550_console.S \
+ ${TEGRA_GICv2_SOURCES} \
${COMMON_DIR}/aarch64/tegra_helpers.S \
${COMMON_DIR}/drivers/pmc/pmc.c \
${COMMON_DIR}/tegra_bl31_setup.c \
${COMMON_DIR}/tegra_delay_timer.c \
${COMMON_DIR}/tegra_fiq_glue.c \
- ${COMMON_DIR}/tegra_gic.c \
${COMMON_DIR}/tegra_platform.c \
${COMMON_DIR}/tegra_pm.c \
${COMMON_DIR}/tegra_sip_calls.c \
diff --git a/plat/nvidia/tegra/common/tegra_delay_timer.c b/plat/nvidia/tegra/common/tegra_delay_timer.c
index 3bd2b0e..63dcf41 100644
--- a/plat/nvidia/tegra/common/tegra_delay_timer.c
+++ b/plat/nvidia/tegra/common/tegra_delay_timer.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <delay_timer.h>
-#include <mmio.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
#include <tegra_def.h>
#include <tegra_private.h>
diff --git a/plat/nvidia/tegra/common/tegra_fiq_glue.c b/plat/nvidia/tegra/common/tegra_fiq_glue.c
index bc6d305..0b663ce 100644
--- a/plat/nvidia/tegra/common/tegra_fiq_glue.c
+++ b/plat/nvidia/tegra/common/tegra_fiq_glue.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bakery_lock.h>
-#include <bl_common.h>
+
+#include <arch_helpers.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
#include <denver.h>
-#include <interrupt_mgmt.h>
-#include <platform.h>
+#include <lib/bakery_lock.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <plat/common/platform.h>
+
#include <tegra_def.h>
#include <tegra_private.h>
diff --git a/plat/nvidia/tegra/common/tegra_gic.c b/plat/nvidia/tegra/common/tegra_gic.c
deleted file mode 100644
index c3dc5f6..0000000
--- a/plat/nvidia/tegra/common/tegra_gic.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- */
-
-#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <interrupt_mgmt.h>
-#include <platform.h>
-#include <stdint.h>
-#include <tegra_def.h>
-#include <tegra_private.h>
-
-/* Value used to initialize Non-Secure IRQ priorities four at a time */
-#define GICD_IPRIORITYR_DEF_VAL \
- (GIC_HIGHEST_NS_PRIORITY | \
- (GIC_HIGHEST_NS_PRIORITY << 8) | \
- (GIC_HIGHEST_NS_PRIORITY << 16) | \
- (GIC_HIGHEST_NS_PRIORITY << 24))
-
-static const irq_sec_cfg_t *g_irq_sec_ptr;
-static uint32_t g_num_irqs;
-
-/*******************************************************************************
- * Place the cpu interface in a state where it can never make a cpu exit wfi as
- * as result of an asserted interrupt. This is critical for powering down a cpu
- ******************************************************************************/
-void tegra_gic_cpuif_deactivate(void)
-{
- uint32_t val;
-
- /* Disable secure, non-secure interrupts and disable their bypass */
- val = gicc_read_ctlr(TEGRA_GICC_BASE);
- val &= ~(ENABLE_GRP0 | ENABLE_GRP1);
- val |= FIQ_BYP_DIS_GRP1 | FIQ_BYP_DIS_GRP0;
- val |= IRQ_BYP_DIS_GRP0 | IRQ_BYP_DIS_GRP1;
- gicc_write_ctlr(TEGRA_GICC_BASE, val);
-}
-
-/*******************************************************************************
- * Enable secure interrupts and set the priority mask register to allow all
- * interrupts to trickle in.
- ******************************************************************************/
-static void tegra_gic_cpuif_setup(uint32_t gicc_base)
-{
- uint32_t val;
-
- val = ENABLE_GRP0 | ENABLE_GRP1 | FIQ_EN | FIQ_BYP_DIS_GRP0;
- val |= IRQ_BYP_DIS_GRP0 | FIQ_BYP_DIS_GRP1 | IRQ_BYP_DIS_GRP1;
-
- gicc_write_ctlr(gicc_base, val);
- gicc_write_pmr(gicc_base, GIC_PRI_MASK);
-}
-
-/*******************************************************************************
- * Per cpu gic distributor setup which will be done by all cpus after a cold
- * boot/hotplug. This marks out the secure interrupts & enables them.
- ******************************************************************************/
-static void tegra_gic_pcpu_distif_setup(uint32_t gicd_base)
-{
- uint32_t index, sec_ppi_sgi_mask = 0;
-
- assert(gicd_base != 0U);
-
- /* Setup PPI priorities doing four at a time */
- for (index = 0U; index < 32U; index += 4U) {
- gicd_write_ipriorityr(gicd_base, index,
- GICD_IPRIORITYR_DEF_VAL);
- }
-
- /*
- * Invert the bitmask to create a mask for non-secure PPIs and
- * SGIs. Program the GICD_IGROUPR0 with this bit mask. This write will
- * update the GICR_IGROUPR0 as well in case we are running on a GICv3
- * system. This is critical if GICD_CTLR.ARE_NS=1.
- */
- gicd_write_igroupr(gicd_base, 0, ~sec_ppi_sgi_mask);
-}
-
-/*******************************************************************************
- * Global gic distributor setup which will be done by the primary cpu after a
- * cold boot. It marks out the non secure SPIs, PPIs & SGIs and enables them.
- * It then enables the secure GIC distributor interface.
- ******************************************************************************/
-static void tegra_gic_distif_setup(uint32_t gicd_base)
-{
- uint32_t index, num_ints, irq_num;
- uint8_t target_cpus;
- uint32_t val;
-
- /*
- * Mark out non-secure interrupts. Calculate number of
- * IGROUPR registers to consider. Will be equal to the
- * number of IT_LINES
- */
- num_ints = gicd_read_typer(gicd_base) & IT_LINES_NO_MASK;
- num_ints = (num_ints + 1U) << 5;
- for (index = MIN_SPI_ID; index < num_ints; index += 32U) {
- gicd_write_igroupr(gicd_base, index, 0xFFFFFFFFU);
- }
-
- /* Setup SPI priorities doing four at a time */
- for (index = MIN_SPI_ID; index < num_ints; index += 4U) {
- gicd_write_ipriorityr(gicd_base, index,
- GICD_IPRIORITYR_DEF_VAL);
- }
-
- /* Configure SPI secure interrupts now */
- if (g_irq_sec_ptr != NULL) {
-
- for (index = 0U; index < g_num_irqs; index++) {
- irq_num = g_irq_sec_ptr[index].irq;
- target_cpus = (uint8_t)g_irq_sec_ptr[index].target_cpus;
-
- if (irq_num >= MIN_SPI_ID) {
-
- /* Configure as a secure interrupt */
- gicd_clr_igroupr(gicd_base, irq_num);
-
- /* Configure SPI priority */
- mmio_write_8((uint64_t)gicd_base +
- (uint64_t)GICD_IPRIORITYR +
- (uint64_t)irq_num,
- GIC_HIGHEST_SEC_PRIORITY &
- GIC_PRI_MASK);
-
- /* Configure as level triggered */
- val = gicd_read_icfgr(gicd_base, irq_num);
- val |= (3U << ((irq_num & 0xFU) << 1U));
- gicd_write_icfgr(gicd_base, irq_num, val);
-
- /* Route SPI to the target CPUs */
- gicd_set_itargetsr(gicd_base, irq_num,
- target_cpus);
-
- /* Enable this interrupt */
- gicd_set_isenabler(gicd_base, irq_num);
- }
- }
- }
-
- /*
- * Configure the SGI and PPI. This is done in a separated function
- * because each CPU is responsible for initializing its own private
- * interrupts.
- */
- tegra_gic_pcpu_distif_setup(gicd_base);
-
- /* enable distributor */
- gicd_write_ctlr(gicd_base, ENABLE_GRP0 | ENABLE_GRP1);
-}
-
-void tegra_gic_setup(const irq_sec_cfg_t *irq_sec_ptr, uint32_t num_irqs)
-{
- g_irq_sec_ptr = irq_sec_ptr;
- g_num_irqs = num_irqs;
-
- tegra_gic_cpuif_setup(TEGRA_GICC_BASE);
- tegra_gic_distif_setup(TEGRA_GICD_BASE);
-}
-
-/*******************************************************************************
- * An ARM processor signals interrupt exceptions through the IRQ and FIQ pins.
- * The interrupt controller knows which pin/line it uses to signal a type of
- * interrupt. This function provides a common implementation of
- * plat_interrupt_type_to_line() in an ARM GIC environment for optional re-use
- * across platforms. It lets the interrupt management framework determine
- * for a type of interrupt and security state, which line should be used in the
- * SCR_EL3 to control its routing to EL3. The interrupt line is represented as
- * the bit position of the IRQ or FIQ bit in the SCR_EL3.
- ******************************************************************************/
-static uint32_t tegra_gic_interrupt_type_to_line(uint32_t type,
- uint32_t security_state)
-{
- assert((type == INTR_TYPE_S_EL1) ||
- (type == INTR_TYPE_EL3) ||
- (type == INTR_TYPE_NS));
-
- assert(sec_state_is_valid(security_state));
-
- /*
- * We ignore the security state parameter under the assumption that
- * both normal and secure worlds are using ARM GICv2. This parameter
- * will be used when the secure world starts using GICv3.
- */
- return gicv2_interrupt_type_to_line(TEGRA_GICC_BASE, type);
-}
-
-/*******************************************************************************
- * This function returns the type of the highest priority pending interrupt at
- * the GIC cpu interface. INTR_TYPE_INVAL is returned when there is no
- * interrupt pending.
- ******************************************************************************/
-static uint32_t tegra_gic_get_pending_interrupt_type(void)
-{
- uint32_t id;
- uint32_t index;
- uint32_t ret = INTR_TYPE_NS;
-
- id = gicc_read_hppir(TEGRA_GICC_BASE) & INT_ID_MASK;
-
- /* get the interrupt type */
- if (id < 1022U) {
- for (index = 0U; index < g_num_irqs; index++) {
- if (id == g_irq_sec_ptr[index].irq) {
- ret = g_irq_sec_ptr[index].type;
- break;
- }
- }
- } else {
- if (id == GIC_SPURIOUS_INTERRUPT) {
- ret = INTR_TYPE_INVAL;
- }
- }
-
- return ret;
-}
-
-/*******************************************************************************
- * This function returns the id of the highest priority pending interrupt at
- * the GIC cpu interface. INTR_ID_UNAVAILABLE is returned when there is no
- * interrupt pending.
- ******************************************************************************/
-static uint32_t tegra_gic_get_pending_interrupt_id(void)
-{
- uint32_t id, ret;
-
- id = gicc_read_hppir(TEGRA_GICC_BASE) & INT_ID_MASK;
-
- if (id < 1022U) {
- ret = id;
- } else if (id == 1023U) {
- ret = 0xFFFFFFFFU; /* INTR_ID_UNAVAILABLE */
- } else {
- /*
- * Find out which non-secure interrupt it is under the assumption that
- * the GICC_CTLR.AckCtl bit is 0.
- */
- ret = gicc_read_ahppir(TEGRA_GICC_BASE) & INT_ID_MASK;
- }
-
- return ret;
-}
-
-/*******************************************************************************
- * This functions reads the GIC cpu interface Interrupt Acknowledge register
- * to start handling the pending interrupt. It returns the contents of the IAR.
- ******************************************************************************/
-static uint32_t tegra_gic_acknowledge_interrupt(void)
-{
- return gicc_read_IAR(TEGRA_GICC_BASE);
-}
-
-/*******************************************************************************
- * This functions writes the GIC cpu interface End Of Interrupt register with
- * the passed value to finish handling the active interrupt
- ******************************************************************************/
-static void tegra_gic_end_of_interrupt(uint32_t id)
-{
- gicc_write_EOIR(TEGRA_GICC_BASE, id);
-}
-
-/*******************************************************************************
- * This function returns the type of the interrupt id depending upon the group
- * this interrupt has been configured under by the interrupt controller i.e.
- * group0 or group1.
- ******************************************************************************/
-static uint32_t tegra_gic_get_interrupt_type(uint32_t id)
-{
- uint32_t group;
- uint32_t index;
- uint32_t ret = INTR_TYPE_NS;
-
- group = gicd_get_igroupr(TEGRA_GICD_BASE, id);
-
- /* get the interrupt type */
- if (group == GRP0) {
- for (index = 0U; index < g_num_irqs; index++) {
- if (id == g_irq_sec_ptr[index].irq) {
- ret = g_irq_sec_ptr[index].type;
- break;
- }
- }
- }
-
- return ret;
-}
-
-uint32_t plat_ic_get_pending_interrupt_id(void)
-{
- return tegra_gic_get_pending_interrupt_id();
-}
-
-uint32_t plat_ic_get_pending_interrupt_type(void)
-{
- return tegra_gic_get_pending_interrupt_type();
-}
-
-uint32_t plat_ic_acknowledge_interrupt(void)
-{
- return tegra_gic_acknowledge_interrupt();
-}
-
-uint32_t plat_ic_get_interrupt_type(uint32_t id)
-{
- return tegra_gic_get_interrupt_type(id);
-}
-
-void plat_ic_end_of_interrupt(uint32_t id)
-{
- tegra_gic_end_of_interrupt(id);
-}
-
-uint32_t plat_interrupt_type_to_line(uint32_t type,
- uint32_t security_state)
-{
- return tegra_gic_interrupt_type_to_line(type, security_state);
-}
diff --git a/plat/nvidia/tegra/common/tegra_gicv2.c b/plat/nvidia/tegra/common/tegra_gicv2.c
new file mode 100644
index 0000000..293df8d
--- /dev/null
+++ b/plat/nvidia/tegra/common/tegra_gicv2.c
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#include <assert.h>
+
+#include <platform_def.h>
+
+#include <common/bl_common.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/utils.h>
+
+#include <tegra_private.h>
+#include <tegra_def.h>
+
+/******************************************************************************
+ * Tegra common helper to setup the GICv2 driver data.
+ *****************************************************************************/
+void tegra_gic_setup(const interrupt_prop_t *interrupt_props,
+ unsigned int interrupt_props_num)
+{
+ /*
+ * Tegra GIC configuration settings
+ */
+ static gicv2_driver_data_t tegra_gic_data;
+
+ /*
+ * Register Tegra GICv2 driver
+ */
+ tegra_gic_data.gicd_base = TEGRA_GICD_BASE;
+ tegra_gic_data.gicc_base = TEGRA_GICC_BASE;
+ tegra_gic_data.interrupt_props = interrupt_props;
+ tegra_gic_data.interrupt_props_num = interrupt_props_num;
+ gicv2_driver_init(&tegra_gic_data);
+}
+
+/******************************************************************************
+ * Tegra common helper to initialize the GICv2 only driver.
+ *****************************************************************************/
+void tegra_gic_init(void)
+{
+ gicv2_distif_init();
+ gicv2_pcpu_distif_init();
+ gicv2_cpuif_enable();
+}
+
+/******************************************************************************
+ * Tegra common helper to disable the GICv2 CPU interface
+ *****************************************************************************/
+void tegra_gic_cpuif_deactivate(void)
+{
+ gicv2_cpuif_disable();
+}
+
+/******************************************************************************
+ * Tegra common helper to initialize the per cpu distributor interface
+ * in GICv2
+ *****************************************************************************/
+void tegra_gic_pcpu_init(void)
+{
+ gicv2_pcpu_distif_init();
+ gicv2_cpuif_enable();
+}
diff --git a/plat/nvidia/tegra/common/tegra_platform.c b/plat/nvidia/tegra/common/tegra_platform.c
index 6a906ae..10edf92 100644
--- a/plat/nvidia/tegra/common/tegra_platform.c
+++ b/plat/nvidia/tegra/common/tegra_platform.c
@@ -5,7 +5,8 @@
*/
#include <arch_helpers.h>
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include <tegra_def.h>
#include <tegra_platform.h>
#include <tegra_private.h>
diff --git a/plat/nvidia/tegra/common/tegra_pm.c b/plat/nvidia/tegra/common/tegra_pm.c
index 86021ba..8361ddd 100644
--- a/plat/nvidia/tegra/common/tegra_pm.c
+++ b/plat/nvidia/tegra/common/tegra_pm.c
@@ -4,19 +4,22 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <memctrl.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <context.h>
+#include <drivers/console.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
+#include <memctrl.h>
#include <pmc.h>
-#include <psci.h>
#include <tegra_def.h>
#include <tegra_private.h>
diff --git a/plat/nvidia/tegra/common/tegra_sip_calls.c b/plat/nvidia/tegra/common/tegra_sip_calls.c
index a818453..e50d12f 100644
--- a/plat/nvidia/tegra/common/tegra_sip_calls.c
+++ b/plat/nvidia/tegra/common/tegra_sip_calls.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <errno.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <errno.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/mmio.h>
+
#include <memctrl.h>
-#include <mmio.h>
-#include <runtime_svc.h>
#include <tegra_platform.h>
#include <tegra_private.h>
diff --git a/plat/nvidia/tegra/common/tegra_topology.c b/plat/nvidia/tegra/common/tegra_topology.c
index 0593053..893f28f 100644
--- a/plat/nvidia/tegra/common/tegra_topology.c
+++ b/plat/nvidia/tegra/common/tegra_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>
extern const unsigned char tegra_power_domain_tree_desc[];
#pragma weak plat_core_pos_by_mpidr
diff --git a/plat/nvidia/tegra/include/drivers/flowctrl.h b/plat/nvidia/tegra/include/drivers/flowctrl.h
index d604c97..3122181 100644
--- a/plat/nvidia/tegra/include/drivers/flowctrl.h
+++ b/plat/nvidia/tegra/include/drivers/flowctrl.h
@@ -7,7 +7,8 @@
#ifndef FLOWCTRL_H
#define FLOWCTRL_H
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include <tegra_def.h>
#define FLOWCTRL_HALT_CPU0_EVENTS 0x0U
diff --git a/plat/nvidia/tegra/include/drivers/mce.h b/plat/nvidia/tegra/include/drivers/mce.h
index 8140870..4470b6b 100644
--- a/plat/nvidia/tegra/include/drivers/mce.h
+++ b/plat/nvidia/tegra/include/drivers/mce.h
@@ -7,7 +7,8 @@
#ifndef MCE_H
#define MCE_H
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include <tegra_def.h>
/*******************************************************************************
diff --git a/plat/nvidia/tegra/include/drivers/memctrl_v1.h b/plat/nvidia/tegra/include/drivers/memctrl_v1.h
index 2553a1f..8e9f198 100644
--- a/plat/nvidia/tegra/include/drivers/memctrl_v1.h
+++ b/plat/nvidia/tegra/include/drivers/memctrl_v1.h
@@ -7,7 +7,8 @@
#ifndef MEMCTRL_V1_H
#define MEMCTRL_V1_H
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include <tegra_def.h>
/* SMMU registers */
diff --git a/plat/nvidia/tegra/include/drivers/memctrl_v2.h b/plat/nvidia/tegra/include/drivers/memctrl_v2.h
index 9ae4302..957ff54 100644
--- a/plat/nvidia/tegra/include/drivers/memctrl_v2.h
+++ b/plat/nvidia/tegra/include/drivers/memctrl_v2.h
@@ -407,7 +407,7 @@
#ifndef __ASSEMBLY__
-#include <mmio.h>
+#include <lib/mmio.h>
static inline uint32_t tegra_mc_read_32(uint32_t off)
{
diff --git a/plat/nvidia/tegra/include/drivers/pmc.h b/plat/nvidia/tegra/include/drivers/pmc.h
index 14c9225..a01a4b6 100644
--- a/plat/nvidia/tegra/include/drivers/pmc.h
+++ b/plat/nvidia/tegra/include/drivers/pmc.h
@@ -7,9 +7,10 @@
#ifndef PMC_H
#define PMC_H
-#include <mmio.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
+
#include <tegra_def.h>
-#include <utils_def.h>
#define PMC_CONFIG U(0x0)
#define PMC_PWRGATE_STATUS U(0x38)
diff --git a/plat/nvidia/tegra/include/drivers/smmu.h b/plat/nvidia/tegra/include/drivers/smmu.h
index 974aa35..9582a67 100644
--- a/plat/nvidia/tegra/include/drivers/smmu.h
+++ b/plat/nvidia/tegra/include/drivers/smmu.h
@@ -7,8 +7,9 @@
#ifndef SMMU_H
#define SMMU_H
+#include <lib/mmio.h>
+
#include <memctrl_v2.h>
-#include <mmio.h>
#include <tegra_def.h>
/*******************************************************************************
diff --git a/plat/nvidia/tegra/include/drivers/tegra_gic.h b/plat/nvidia/tegra/include/drivers/tegra_gic.h
new file mode 100644
index 0000000..6106b40
--- /dev/null
+++ b/plat/nvidia/tegra/include/drivers/tegra_gic.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef __TEGRA_GIC_H__
+#define __TEGRA_GIC_H__
+
+#include <common/interrupt_props.h>
+
+/*******************************************************************************
+ * Per-CPU struct describing FIQ state to be stored
+ ******************************************************************************/
+typedef struct pcpu_fiq_state {
+ uint64_t elr_el3;
+ uint64_t spsr_el3;
+} pcpu_fiq_state_t;
+
+/*******************************************************************************
+ * Fucntion declarations
+ ******************************************************************************/
+void tegra_gic_cpuif_deactivate(void);
+void tegra_gic_init(void);
+void tegra_gic_pcpu_init(void);
+void tegra_gic_setup(const interrupt_prop_t *interrupt_props,
+ unsigned int interrupt_props_num);
+
+#endif /* __TEGRA_GIC_H__ */
diff --git a/plat/nvidia/tegra/include/plat_macros.S b/plat/nvidia/tegra/include/plat_macros.S
index 14e7d8a..01ae821 100644
--- a/plat/nvidia/tegra/include/plat_macros.S
+++ b/plat/nvidia/tegra/include/plat_macros.S
@@ -7,6 +7,7 @@
#ifndef PLAT_MACROS_S
#define PLAT_MACROS_S
+#include <gicv2.h>
#include <tegra_def.h>
.section .rodata.gic_reg_name, "aS"
diff --git a/plat/nvidia/tegra/include/platform_def.h b/plat/nvidia/tegra/include/platform_def.h
index 6a507d4..d10dc26 100644
--- a/plat/nvidia/tegra/include/platform_def.h
+++ b/plat/nvidia/tegra/include/platform_def.h
@@ -8,9 +8,10 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <common_def.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
+
#include <tegra_def.h>
-#include <utils_def.h>
/*******************************************************************************
* Generic platform constants
diff --git a/plat/nvidia/tegra/include/t132/tegra_def.h b/plat/nvidia/tegra/include/t132/tegra_def.h
index 277f91b..1f58caa 100644
--- a/plat/nvidia/tegra/include/t132/tegra_def.h
+++ b/plat/nvidia/tegra/include/t132/tegra_def.h
@@ -7,7 +7,7 @@
#ifndef TEGRA_DEF_H
#define TEGRA_DEF_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* This value is used by the PSCI implementation during the `SYSTEM_SUSPEND`
diff --git a/plat/nvidia/tegra/include/t186/tegra_def.h b/plat/nvidia/tegra/include/t186/tegra_def.h
index 79aff59..3abba55 100644
--- a/plat/nvidia/tegra/include/t186/tegra_def.h
+++ b/plat/nvidia/tegra/include/t186/tegra_def.h
@@ -7,7 +7,7 @@
#ifndef TEGRA_DEF_H
#define TEGRA_DEF_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* MCE apertures used by the ARI interface
diff --git a/plat/nvidia/tegra/include/t210/tegra_def.h b/plat/nvidia/tegra/include/t210/tegra_def.h
index 5d86224..14cdfd5 100644
--- a/plat/nvidia/tegra/include/t210/tegra_def.h
+++ b/plat/nvidia/tegra/include/t210/tegra_def.h
@@ -7,7 +7,7 @@
#ifndef TEGRA_DEF_H
#define TEGRA_DEF_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*******************************************************************************
* Power down state IDs
diff --git a/plat/nvidia/tegra/include/tegra_private.h b/plat/nvidia/tegra/include/tegra_private.h
index c4c277e..93223cc 100644
--- a/plat/nvidia/tegra/include/tegra_private.h
+++ b/plat/nvidia/tegra/include/tegra_private.h
@@ -7,10 +7,14 @@
#ifndef TEGRA_PRIVATE_H
#define TEGRA_PRIVATE_H
-#include <arch.h>
#include <platform_def.h>
-#include <psci.h>
-#include <xlat_tables_v2.h>
+
+#include <arch.h>
+#include <arch_helpers.h>
+#include <lib/psci/psci.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+
+#include <tegra_gic.h>
/*******************************************************************************
* Tegra DRAM memory base address
@@ -31,26 +35,6 @@
} plat_params_from_bl2_t;
/*******************************************************************************
- * Per-CPU struct describing FIQ state to be stored
- ******************************************************************************/
-typedef struct pcpu_fiq_state {
- uint64_t elr_el3;
- uint64_t spsr_el3;
-} pcpu_fiq_state_t;
-
-/*******************************************************************************
- * Struct describing per-FIQ configuration settings
- ******************************************************************************/
-typedef struct irq_sec_cfg {
- /* IRQ number */
- unsigned int irq;
- /* Target CPUs servicing this interrupt */
- unsigned int target_cpus;
- /* type = INTR_TYPE_S_EL1 or INTR_TYPE_EL3 */
- uint32_t type;
-} irq_sec_cfg_t;
-
-/*******************************************************************************
* Struct describing parameters passed to bl31
******************************************************************************/
struct tegra_bl31_params {
@@ -82,10 +66,6 @@
int tegra_fiq_get_intr_context(void);
void tegra_fiq_set_ns_entrypoint(uint64_t entrypoint);
-/* Declarations for tegra_gic.c */
-void tegra_gic_cpuif_deactivate(void);
-void tegra_gic_setup(const irq_sec_cfg_t *irq_sec_ptr, uint32_t num_irqs);
-
/* Declarations for tegra_security.c */
void tegra_security_setup(void);
void tegra_security_setup_videomem(uintptr_t base, uint64_t size);
diff --git a/plat/nvidia/tegra/soc/t132/plat_psci_handlers.c b/plat/nvidia/tegra/soc/t132/plat_psci_handlers.c
index 1cffb74..7226120 100644
--- a/plat/nvidia/tegra/soc/t132/plat_psci_handlers.c
+++ b/plat/nvidia/tegra/soc/t132/plat_psci_handlers.c
@@ -4,17 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
#include <denver.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+
#include <flowctrl.h>
-#include <mmio.h>
-#include <platform_def.h>
#include <pmc.h>
-#include <psci.h>
#include <tegra_def.h>
#include <tegra_private.h>
diff --git a/plat/nvidia/tegra/soc/t132/plat_secondary.c b/plat/nvidia/tegra/soc/t132/plat_secondary.c
index d5ca30c..f46ad3b 100644
--- a/plat/nvidia/tegra/soc/t132/plat_secondary.c
+++ b/plat/nvidia/tegra/soc/t132/plat_secondary.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
#include <denver.h>
-#include <mmio.h>
-#include <platform.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
#include <pmc.h>
-#include <psci.h>
#include <tegra_def.h>
#define SB_CSR 0x0
diff --git a/plat/nvidia/tegra/soc/t132/plat_setup.c b/plat/nvidia/tegra/soc/t132/plat_setup.c
index 4cbb3cc..f72b73e 100644
--- a/plat/nvidia/tegra/soc/t132/plat_setup.c
+++ b/plat/nvidia/tegra/soc/t132/plat_setup.c
@@ -5,10 +5,11 @@
*/
#include <arch_helpers.h>
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+
#include <tegra_def.h>
#include <tegra_private.h>
-#include <xlat_tables_v2.h>
/*******************************************************************************
* The Tegra power domain tree has a single system level power domain i.e. a
diff --git a/plat/nvidia/tegra/soc/t132/plat_sip_calls.c b/plat/nvidia/tegra/soc/t132/plat_sip_calls.c
index adc1c71..02dd1cd 100644
--- a/plat/nvidia/tegra/soc/t132/plat_sip_calls.c
+++ b/plat/nvidia/tegra/soc/t132/plat_sip_calls.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <errno.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <errno.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+
#include <tegra_private.h>
#define NS_SWITCH_AARCH32 1
diff --git a/plat/nvidia/tegra/soc/t132/platform_t132.mk b/plat/nvidia/tegra/soc/t132/platform_t132.mk
index 8b3d238..f15ee74 100644
--- a/plat/nvidia/tegra/soc/t132/platform_t132.mk
+++ b/plat/nvidia/tegra/soc/t132/platform_t132.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
diff --git a/plat/nvidia/tegra/soc/t186/drivers/include/mce_private.h b/plat/nvidia/tegra/soc/t186/drivers/include/mce_private.h
index 27baab6..96a5525 100644
--- a/plat/nvidia/tegra/soc/t186/drivers/include/mce_private.h
+++ b/plat/nvidia/tegra/soc/t186/drivers/include/mce_private.h
@@ -7,7 +7,8 @@
#ifndef MCE_PRIVATE_H
#define MCE_PRIVATE_H
-#include <mmio.h>
+#include <lib/mmio.h>
+
#include <tegra_def.h>
/*******************************************************************************
diff --git a/plat/nvidia/tegra/soc/t186/drivers/mce/ari.c b/plat/nvidia/tegra/soc/t186/drivers/mce/ari.c
index 7126c3b..1429a61 100644
--- a/plat/nvidia/tegra/soc/t186/drivers/mce/ari.c
+++ b/plat/nvidia/tegra/soc/t186/drivers/mce/ari.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <errno.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
#include <denver.h>
-#include <errno.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include <mce_private.h>
-#include <mmio.h>
-#include <platform.h>
#include <t18x_ari.h>
/*******************************************************************************
diff --git a/plat/nvidia/tegra/soc/t186/drivers/mce/mce.c b/plat/nvidia/tegra/soc/t186/drivers/mce/mce.c
index 712519f..828ad3c 100644
--- a/plat/nvidia/tegra/soc/t186/drivers/mce/mce.c
+++ b/plat/nvidia/tegra/soc/t186/drivers/mce/mce.c
@@ -4,19 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <errno.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
#include <denver.h>
-#include <errno.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/mmio.h>
+
#include <mce.h>
#include <mce_private.h>
-#include <mmio.h>
-#include <string.h>
#include <t18x_ari.h>
#include <tegra_def.h>
#include <tegra_platform.h>
diff --git a/plat/nvidia/tegra/soc/t186/drivers/mce/nvg.c b/plat/nvidia/tegra/soc/t186/drivers/mce/nvg.c
index 857cfbb..1ac3710 100644
--- a/plat/nvidia/tegra/soc/t186/drivers/mce/nvg.c
+++ b/plat/nvidia/tegra/soc/t186/drivers/mce/nvg.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <errno.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <debug.h>
+#include <common/debug.h>
#include <denver.h>
-#include <errno.h>
+#include <lib/mmio.h>
+
#include <mce_private.h>
-#include <mmio.h>
#include <t18x_ari.h>
int32_t nvg_enter_cstate(uint32_t ari_base, uint32_t state, uint32_t wake_time)
diff --git a/plat/nvidia/tegra/soc/t186/plat_memctrl.c b/plat/nvidia/tegra/soc/t186/plat_memctrl.c
index 957ecf1..38dffb2 100644
--- a/plat/nvidia/tegra/soc/t186/plat_memctrl.c
+++ b/plat/nvidia/tegra/soc/t186/plat_memctrl.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
+#include <common/bl_common.h>
+
#include <memctrl_v2.h>
/*******************************************************************************
diff --git a/plat/nvidia/tegra/soc/t186/plat_psci_handlers.c b/plat/nvidia/tegra/soc/t186/plat_psci_handlers.c
index 6eb18fa..fb94bce 100644
--- a/plat/nvidia/tegra/soc/t186/plat_psci_handlers.c
+++ b/plat/nvidia/tegra/soc/t186/plat_psci_handlers.c
@@ -4,19 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
#include <denver.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
#include <mce.h>
-#include <platform.h>
-#include <psci.h>
#include <smmu.h>
-#include <string.h>
#include <t18x_ari.h>
#include <tegra_private.h>
diff --git a/plat/nvidia/tegra/soc/t186/plat_secondary.c b/plat/nvidia/tegra/soc/t186/plat_secondary.c
index ebc2b46..4485e27 100644
--- a/plat/nvidia/tegra/soc/t186/plat_secondary.c
+++ b/plat/nvidia/tegra/soc/t186/plat_secondary.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
-#include <mce.h>
-#include <mmio.h>
#include <string.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
+#include <mce.h>
#include <tegra_def.h>
#include <tegra_private.h>
diff --git a/plat/nvidia/tegra/soc/t186/plat_setup.c b/plat/nvidia/tegra/soc/t186/plat_setup.c
index 233644b..15dbd16 100644
--- a/plat/nvidia/tegra/soc/t186/plat_setup.c
+++ b/plat/nvidia/tegra/soc/t186/plat_setup.c
@@ -1,26 +1,31 @@
/*
- * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved.
+ * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl31.h>
-#include <bl_common.h>
-#include <console.h>
+
+#include <arch_helpers.h>
+#include <bl31/bl31.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/interrupt_props.h>
#include <context.h>
-#include <context_mgmt.h>
#include <cortex_a57.h>
-#include <debug.h>
#include <denver.h>
-#include <interrupt_mgmt.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/console.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/platform.h>
+
#include <mce.h>
-#include <platform.h>
#include <tegra_def.h>
#include <tegra_platform.h>
#include <tegra_private.h>
-#include <xlat_tables_v2.h>
DEFINE_RENAME_SYSREG_RW_FUNCS(l2ctlr_el1, CORTEX_A57_L2CTLR_EL1)
extern uint64_t tegra_enable_l2_ecc_parity_prot;
@@ -185,17 +190,11 @@
}
/* Secure IRQs for Tegra186 */
-static const irq_sec_cfg_t tegra186_sec_irqs[] = {
- {
- TEGRA186_TOP_WDT_IRQ,
- TEGRA186_SEC_IRQ_TARGET_MASK,
- INTR_TYPE_EL3,
- },
- {
- TEGRA186_AON_WDT_IRQ,
- TEGRA186_SEC_IRQ_TARGET_MASK,
- INTR_TYPE_EL3,
- },
+static const interrupt_prop_t tegra186_interrupt_props[] = {
+ INTR_PROP_DESC(TEGRA186_TOP_WDT_IRQ, GIC_HIGHEST_SEC_PRIORITY,
+ GICV2_INTR_GROUP0, GIC_INTR_CFG_EDGE),
+ INTR_PROP_DESC(TEGRA186_AON_WDT_IRQ, GIC_HIGHEST_SEC_PRIORITY,
+ GICV2_INTR_GROUP0, GIC_INTR_CFG_EDGE)
};
/*******************************************************************************
@@ -203,14 +202,13 @@
******************************************************************************/
void plat_gic_setup(void)
{
- tegra_gic_setup(tegra186_sec_irqs,
- sizeof(tegra186_sec_irqs) / sizeof(tegra186_sec_irqs[0]));
+ tegra_gic_setup(tegra186_interrupt_props, ARRAY_SIZE(tegra186_interrupt_props));
/*
* Initialize the FIQ handler only if the platform supports any
* FIQ interrupt sources.
*/
- if (sizeof(tegra186_sec_irqs) > 0)
+ if (sizeof(tegra186_interrupt_props) > 0)
tegra_fiq_handler_setup();
}
diff --git a/plat/nvidia/tegra/soc/t186/plat_sip_calls.c b/plat/nvidia/tegra/soc/t186/plat_sip_calls.c
index dfe1c7d..bf98fcf 100644
--- a/plat/nvidia/tegra/soc/t186/plat_sip_calls.c
+++ b/plat/nvidia/tegra/soc/t186/plat_sip_calls.c
@@ -4,17 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <errno.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
#include <denver.h>
-#include <errno.h>
+#include <lib/el3_runtime/context_mgmt.h>
+
#include <mce.h>
#include <memctrl.h>
-#include <runtime_svc.h>
#include <t18x_ari.h>
#include <tegra_private.h>
diff --git a/plat/nvidia/tegra/soc/t186/plat_smmu.c b/plat/nvidia/tegra/soc/t186/plat_smmu.c
index ead4c22..19e065c 100644
--- a/plat/nvidia/tegra/soc/t186/plat_smmu.c
+++ b/plat/nvidia/tegra/soc/t186/plat_smmu.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
+#include <common/bl_common.h>
+
#include <smmu.h>
#include <tegra_def.h>
diff --git a/plat/nvidia/tegra/soc/t186/plat_trampoline.S b/plat/nvidia/tegra/soc/t186/plat_trampoline.S
index 6a17c33..69ca798 100644
--- a/plat/nvidia/tegra/soc/t186/plat_trampoline.S
+++ b/plat/nvidia/tegra/soc/t186/plat_trampoline.S
@@ -6,8 +6,8 @@
#include <arch.h>
#include <asm_macros.S>
-#include <common_def.h>
#include <memctrl_v2.h>
+#include <plat/common/common_def.h>
#include <tegra_def.h>
#define TEGRA186_SMMU_CTX_SIZE 0x420
diff --git a/plat/nvidia/tegra/soc/t210/plat_psci_handlers.c b/plat/nvidia/tegra/soc/t210/plat_psci_handlers.c
index f77746c..27786d3 100644
--- a/plat/nvidia/tegra/soc/t210/plat_psci_handlers.c
+++ b/plat/nvidia/tegra/soc/t210/plat_psci_handlers.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <flowctrl.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
+#include <flowctrl.h>
#include <pmc.h>
-#include <psci.h>
#include <tegra_def.h>
#include <tegra_private.h>
diff --git a/plat/nvidia/tegra/soc/t210/plat_secondary.c b/plat/nvidia/tegra/soc/t210/plat_secondary.c
index ecb258b..e0242cf 100644
--- a/plat/nvidia/tegra/soc/t210/plat_secondary.c
+++ b/plat/nvidia/tegra/soc/t210/plat_secondary.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include <pmc.h>
#include <tegra_def.h>
diff --git a/plat/nvidia/tegra/soc/t210/plat_setup.c b/plat/nvidia/tegra/soc/t210/plat_setup.c
index c3fc7b4..c7f7165 100644
--- a/plat/nvidia/tegra/soc/t210/plat_setup.c
+++ b/plat/nvidia/tegra/soc/t210/plat_setup.c
@@ -5,11 +5,12 @@
*/
#include <arch_helpers.h>
-#include <bl_common.h>
-#include <console.h>
+#include <common/bl_common.h>
+#include <drivers/console.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+
#include <tegra_def.h>
#include <tegra_private.h>
-#include <xlat_tables_v2.h>
/*******************************************************************************
* The Tegra power domain tree has a single system level power domain i.e. a
diff --git a/plat/nvidia/tegra/soc/t210/platform_t210.mk b/plat/nvidia/tegra/soc/t210/platform_t210.mk
index 97ca3f1..b0a474c 100644
--- a/plat/nvidia/tegra/soc/t210/platform_t210.mk
+++ b/plat/nvidia/tegra/soc/t210/platform_t210.mk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
+# Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -22,12 +22,12 @@
MAX_MMAP_REGIONS := 8
$(eval $(call add_define,MAX_MMAP_REGIONS))
-BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
- lib/cpus/aarch64/cortex_a57.S \
+BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \
+ lib/cpus/aarch64/cortex_a57.S \
${COMMON_DIR}/drivers/flowctrl/flowctrl.c \
${COMMON_DIR}/drivers/memctrl/memctrl_v1.c \
- ${SOC_DIR}/plat_psci_handlers.c \
- ${SOC_DIR}/plat_setup.c \
+ ${SOC_DIR}/plat_psci_handlers.c \
+ ${SOC_DIR}/plat_setup.c \
${SOC_DIR}/plat_secondary.c
# Enable workarounds for selected Cortex-A57 erratas.
diff --git a/plat/qemu/dt.c b/plat/qemu/dt.c
index c544d9f..b1cd368 100644
--- a/plat/qemu/dt.c
+++ b/plat/qemu/dt.c
@@ -3,11 +3,15 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <console.h>
-#include <debug.h>
-#include <libfdt.h>
-#include <psci.h>
+
#include <string.h>
+
+#include <libfdt.h>
+
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <lib/psci/psci.h>
+
#include "qemu_private.h"
static int append_psci_compatible(void *fdt, int offs, const char *str)
diff --git a/plat/qemu/include/platform_def.h b/plat/qemu/include/platform_def.h
index c2289bc..2dd10ad 100644
--- a/plat/qemu/include/platform_def.h
+++ b/plat/qemu/include/platform_def.h
@@ -8,9 +8,9 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <common_def.h>
-#include <tbbr_img_def.h>
-#include <utils_def.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
/* Special value used to verify platform parameters from BL2 to BL3-1 */
#define QEMU_BL31_PLAT_PARAM_VAL 0x0f1e2d3c4b5a6978ULL
diff --git a/plat/qemu/qemu_bl1_setup.c b/plat/qemu/qemu_bl1_setup.c
index fd53495..b582151 100644
--- a/plat/qemu/qemu_bl1_setup.c
+++ b/plat/qemu/qemu_bl1_setup.c
@@ -4,11 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <platform_def.h>
+#include <common/bl_common.h>
+
#include "qemu_private.h"
/* Data structure which holds the extents of the trusted SRAM for BL1*/
diff --git a/plat/qemu/qemu_bl2_mem_params_desc.c b/plat/qemu/qemu_bl2_mem_params_desc.c
index 9965cfd..ba6a4db 100644
--- a/plat/qemu/qemu_bl2_mem_params_desc.c
+++ b/plat/qemu/qemu_bl2_mem_params_desc.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
+
/*******************************************************************************
* Following descriptor provides BL image/ep information that gets used
* by BL2 to load the images and also subset of this information is
diff --git a/plat/qemu/qemu_bl2_setup.c b/plat/qemu/qemu_bl2_setup.c
index b3c3960..b8ca895 100644
--- a/plat/qemu/qemu_bl2_setup.c
+++ b/plat/qemu/qemu_bl2_setup.c
@@ -3,17 +3,22 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
+
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <desc_image_load.h>
-#include <optee_utils.h>
-#include <libfdt.h>
-#include <platform.h>
-#include <platform_def.h>
#include <string.h>
-#include <utils.h>
+
+#include <libfdt.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <lib/optee_utils.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+
#include "qemu_private.h"
diff --git a/plat/qemu/qemu_bl31_setup.c b/plat/qemu/qemu_bl31_setup.c
index 7542674..9746811 100644
--- a/plat/qemu/qemu_bl31_setup.c
+++ b/plat/qemu/qemu_bl31_setup.c
@@ -5,11 +5,14 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <gic_common.h>
-#include <gicv2.h>
+
#include <platform_def.h>
-#include <platform.h>
+
+#include <common/bl_common.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <plat/common/platform.h>
+
#include "qemu_private.h"
/*
diff --git a/plat/qemu/qemu_common.c b/plat/qemu/qemu_common.c
index 43a3f70..aee8321 100644
--- a/plat/qemu/qemu_common.c
+++ b/plat/qemu/qemu_common.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <bl_common.h>
#include <platform_def.h>
-#include <xlat_tables_v2.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
#include "qemu_private.h"
diff --git a/plat/qemu/qemu_console.c b/plat/qemu/qemu_console.c
index a90c9a1..759f997 100644
--- a/plat/qemu/qemu_console.c
+++ b/plat/qemu/qemu_console.c
@@ -3,10 +3,12 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <console.h>
-#include <pl011.h>
+
#include <platform_def.h>
+#include <drivers/console.h>
+#include <drivers/arm/pl011.h>
+
#if MULTI_CONSOLE_API
static console_pl011_t console;
#endif /* MULTI_CONSOLE_API */
diff --git a/plat/qemu/qemu_image_load.c b/plat/qemu/qemu_image_load.c
index 8e24647..9970d1d 100644
--- a/plat/qemu/qemu_image_load.c
+++ b/plat/qemu/qemu_image_load.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <desc_image_load.h>
+#include <common/desc_image_load.h>
/*******************************************************************************
* This function is a wrapper of a common function which flushes the data
diff --git a/plat/qemu/qemu_io_storage.c b/plat/qemu/qemu_io_storage.c
index 1918f21..0e81cd1 100644
--- a/plat/qemu/qemu_io_storage.c
+++ b/plat/qemu/qemu_io_storage.c
@@ -5,18 +5,20 @@
*/
#include <assert.h>
-#include <bl_common.h> /* For ARRAY_SIZE */
-#include <debug.h>
-#include <firmware_image_package.h>
-#include <io_driver.h>
-#include <io_fip.h>
-#include <io_memmap.h>
-#include <io_semihosting.h>
-#include <io_storage.h>
-#include <platform_def.h>
-#include <semihosting.h>
#include <string.h>
+#include <platform_def.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_memmap.h>
+#include <drivers/io/io_semihosting.h>
+#include <drivers/io/io_storage.h>
+#include <lib/semihosting.h>
+#include <tools_share/firmware_image_package.h>
+
/* Semihosting filenames */
#define BL2_IMAGE_NAME "bl2.bin"
#define BL31_IMAGE_NAME "bl31.bin"
diff --git a/plat/qemu/qemu_pm.c b/plat/qemu/qemu_pm.c
index c184f1c..3249d6e 100644
--- a/plat/qemu/qemu_pm.c
+++ b/plat/qemu/qemu_pm.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <gicv2.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
/*
* The secure entry point to be used on warm reset.
diff --git a/plat/qemu/qemu_stack_protector.c b/plat/qemu/qemu_stack_protector.c
index 5b19828..c226158 100644
--- a/plat/qemu/qemu_stack_protector.c
+++ b/plat/qemu/qemu_stack_protector.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <platform.h>
#include <stdint.h>
+#include <arch_helpers.h>
+#include <plat/common/platform.h>
+
#define RANDOM_CANARY_VALUE ((u_register_t) 3288484550995823360ULL)
u_register_t plat_get_stack_protector_canary(void)
diff --git a/plat/qemu/qemu_trusted_boot.c b/plat/qemu/qemu_trusted_boot.c
index 7d8fed2..17666b9 100644
--- a/plat/qemu/qemu_trusted_boot.c
+++ b/plat/qemu/qemu_trusted_boot.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+#include <plat/common/platform.h>
extern char qemu_rotpk_hash[], qemu_rotpk_hash_end[];
diff --git a/plat/qemu/sp_min/sp_min_setup.c b/plat/qemu/sp_min/sp_min_setup.c
index 5b98079..88decdf 100644
--- a/plat/qemu/sp_min/sp_min_setup.c
+++ b/plat/qemu/sp_min/sp_min_setup.c
@@ -4,18 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <gic_common.h>
-#include <gicv2.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
#include <string.h>
-#include <xlat_tables.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
+
#include "../qemu_private.h"
#if RESET_TO_SP_MIN
diff --git a/plat/qemu/topology.c b/plat/qemu/topology.c
index 569d15f..6352706 100644
--- a/plat/qemu/topology.c
+++ b/plat/qemu/topology.c
@@ -4,9 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <platform_def.h>
#include <stdint.h>
+
+#include <platform_def.h>
+
+#include <arch.h>
+
#include "qemu_private.h"
/* The power domain tree descriptor */
diff --git a/plat/renesas/rcar/aarch64/plat_helpers.S b/plat/renesas/rcar/aarch64/plat_helpers.S
index 7e1ff8d..ae0d675 100644
--- a/plat/renesas/rcar/aarch64/plat_helpers.S
+++ b/plat/renesas/rcar/aarch64/plat_helpers.S
@@ -7,10 +7,11 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
+#include <common/runtime_svc.h>
#include <cortex_a57.h>
#include <platform_def.h>
-#include <runtime_svc.h>
+
#include "rcar_def.h"
.globl plat_get_my_entrypoint
@@ -216,6 +217,8 @@
* ---------------------------------------------
*/
func plat_report_exception
+ /* Switch to SP_EL0 */
+ msr spsel, #0
#if IMAGE_BL2
mov w1, #FIQ_SP_EL0
cmp w0, w1
@@ -325,11 +328,11 @@
ubfx w0, w0, 8, 8
/* H3? */
cmp w0, #0x4F
- b.eq H3
+ b.eq RCARH3
/* set R-Car M3/M3N */
mov x2, #1
b CHK_A5x
-H3:
+RCARH3:
/* set R-Car H3 */
mov x2, #0
/* --------------------------------------------------------------------
diff --git a/plat/renesas/rcar/aarch64/platform_common.c b/plat/renesas/rcar/aarch64/platform_common.c
index f344b37..b0a88cb 100644
--- a/plat/renesas/rcar/aarch64/platform_common.c
+++ b/plat/renesas/rcar/aarch64/platform_common.c
@@ -5,17 +5,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <gicv2.h>
-#include <gic_common.h>
-#include <interrupt_props.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
-#include <xlat_tables_v2.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/gic_common.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/platform.h>
+
#include "rcar_def.h"
#include "rcar_private.h"
#include "rcar_version.h"
@@ -100,7 +102,7 @@
#endif
#if IMAGE_BL2
-const mmap_region_t rcar_mmap[] = {
+static const mmap_region_t rcar_mmap[] = {
MAP_FLASH0, /* 0x08000000 - 0x0BFFFFFF RPC area */
MAP_DRAM0, /* 0x40000000 - 0xBFFFFFFF DRAM area(Legacy) */
MAP_REG0, /* 0xE6000000 - 0xE62FFFFF SoC register area */
@@ -114,7 +116,7 @@
#endif
#if IMAGE_BL31
-const mmap_region_t rcar_mmap[] = {
+static const mmap_region_t rcar_mmap[] = {
MAP_SHARED_RAM,
MAP_ATFW_CRASH,
MAP_ATFW_LOG,
@@ -127,7 +129,7 @@
#endif
#if IMAGE_BL32
-const mmap_region_t rcar_mmap[] = {
+static const mmap_region_t rcar_mmap[] = {
MAP_DEVICE0,
MAP_DEVICE1,
{0}
diff --git a/plat/renesas/rcar/bl2_cpg_init.c b/plat/renesas/rcar/bl2_cpg_init.c
index 880ad36..883fc9a 100644
--- a/plat/renesas/rcar/bl2_cpg_init.c
+++ b/plat/renesas/rcar/bl2_cpg_init.c
@@ -4,8 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "rcar_def.h"
#include "cpg_registers.h"
#include "rcar_private.h"
diff --git a/plat/renesas/rcar/bl2_interrupt_error.c b/plat/renesas/rcar/bl2_interrupt_error.c
index c50c603..d9a4b8e 100644
--- a/plat/renesas/rcar/bl2_interrupt_error.c
+++ b/plat/renesas/rcar/bl2_interrupt_error.c
@@ -5,11 +5,12 @@
*/
#include <arch_helpers.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <gicv2.h>
-#include <mmio.h>
-#include <runtime_svc.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/mmio.h>
+
#include "rcar_def.h"
#define SWDT_ERROR_ID (1024U)
@@ -23,7 +24,7 @@
ERROR("\n");
if (int_id >= SWDT_ERROR_ID) {
ERROR("Unhandled exception occurred.\n");
- ERROR(" Exception type = FIQ_SP_ELX\n");
+ ERROR(" Exception type = FIQ_SP_EL0\n");
panic();
}
@@ -31,11 +32,11 @@
gicv2_end_of_interrupt((uint32_t) int_id);
rcar_swdt_release();
ERROR("Unhandled exception occurred.\n");
- ERROR(" Exception type = FIQ_SP_ELX\n");
- ERROR(" SPSR_EL1 = 0x%x\n", (uint32_t) read_spsr_el1());
- ERROR(" ELR_EL1 = 0x%x\n", (uint32_t) read_elr_el1());
- ERROR(" ESR_EL1 = 0x%x\n", (uint32_t) read_esr_el1());
- ERROR(" FAR_EL1 = 0x%x\n", (uint32_t) read_far_el1());
+ ERROR(" Exception type = FIQ_SP_EL0\n");
+ ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
+ ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
+ ERROR(" ESR_EL3 = 0x%x\n", (uint32_t) read_esr_el3());
+ ERROR(" FAR_EL3 = 0x%x\n", (uint32_t) read_far_el3());
ERROR("\n");
panic();
}
@@ -77,27 +78,27 @@
&interrupt_ex[ex_type][0]);
ERROR("%s", msg);
switch (ex_type) {
- case SYNC_EXCEPTION_SP_ELX:
- ERROR(" SPSR_EL1 = 0x%x\n", (uint32_t) read_spsr_el1());
- ERROR(" ELR_EL1 = 0x%x\n", (uint32_t) read_elr_el1());
- ERROR(" ESR_EL1 = 0x%x\n", (uint32_t) read_esr_el1());
- ERROR(" FAR_EL1 = 0x%x\n", (uint32_t) read_far_el1());
+ case SYNC_EXCEPTION_SP_EL0:
+ ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
+ ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
+ ERROR(" ESR_EL3 = 0x%x\n", (uint32_t) read_esr_el3());
+ ERROR(" FAR_EL3 = 0x%x\n", (uint32_t) read_far_el3());
break;
- case IRQ_SP_ELX:
- ERROR(" SPSR_EL1 = 0x%x\n", (uint32_t) read_spsr_el1());
- ERROR(" ELR_EL1 = 0x%x\n", (uint32_t) read_elr_el1());
- ERROR(" IAR_EL1 = 0x%x\n", gicv2_acknowledge_interrupt());
+ case IRQ_SP_EL0:
+ ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
+ ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
+ ERROR(" IAR_EL3 = 0x%x\n", gicv2_acknowledge_interrupt());
break;
- case FIQ_SP_ELX:
- ERROR(" SPSR_EL1 = 0x%x\n", (uint32_t) read_spsr_el1());
- ERROR(" ELR_EL1 = 0x%x\n", (uint32_t) read_elr_el1());
- ERROR(" IAR_EL1 = 0x%x\n", gicv2_acknowledge_interrupt());
+ case FIQ_SP_EL0:
+ ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
+ ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
+ ERROR(" IAR_EL3 = 0x%x\n", gicv2_acknowledge_interrupt());
break;
- case SERROR_SP_ELX:
- ERROR(" SPSR_EL1 = 0x%x\n", (uint32_t) read_spsr_el1());
- ERROR(" ELR_EL1 = 0x%x\n", (uint32_t) read_elr_el1());
- ERROR(" ESR_EL1 = 0x%x\n", (uint32_t) read_esr_el1());
- ERROR(" FAR_EL1 = 0x%x\n", (uint32_t) read_far_el1());
+ case SERROR_SP_EL0:
+ ERROR(" SPSR_EL3 = 0x%x\n", (uint32_t) read_spsr_el3());
+ ERROR(" ELR_EL3 = 0x%x\n", (uint32_t) read_elr_el3());
+ ERROR(" ESR_EL3 = 0x%x\n", (uint32_t) read_esr_el3());
+ ERROR(" FAR_EL3 = 0x%x\n", (uint32_t) read_far_el3());
break;
default:
break;
diff --git a/plat/renesas/rcar/bl2_plat_mem_params_desc.c b/plat/renesas/rcar/bl2_plat_mem_params_desc.c
index 728eac6..3b124c7 100644
--- a/plat/renesas/rcar/bl2_plat_mem_params_desc.c
+++ b/plat/renesas/rcar/bl2_plat_mem_params_desc.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
-#include <xlat_tables_defs.h>
+
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <plat/common/platform.h>
#if (RCAR_BL33_EXECUTION_EL != 0) && (RCAR_BL33_EXECUTION_EL != 1)
#error
@@ -72,7 +73,7 @@
#ifdef RCAR_BL33_ARG0
.ep_info.args.arg0 = RCAR_BL33_ARG0,
#endif
- .ep_info.args.arg3 = (uintptr_t)fdt_blob,
+ .ep_info.args.arg1 = (uintptr_t)fdt_blob,
SET_STATIC_PARAM_HEAD(image_info, PARAM_EP, VERSION_2,
image_info_t, 0),
.image_info.image_max_size =
diff --git a/plat/renesas/rcar/bl2_plat_setup.c b/plat/renesas/rcar/bl2_plat_setup.c
index 7567813..2debbf9 100644
--- a/plat/renesas/rcar/bl2_plat_setup.c
+++ b/plat/renesas/rcar/bl2_plat_setup.c
@@ -4,18 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <desc_image_load.h>
-#include <arch_helpers.h>
-#include <bl_common.h>
-#include <bl1.h>
-#include <console.h>
-#include <debug.h>
-#include <libfdt.h>
-#include <mmio.h>
-#include <platform.h>
-#include <platform_def.h>
#include <string.h>
-#include <xlat_tables_defs.h>
+
+#include <libfdt.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <bl1/bl1.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <plat/common/platform.h>
#include "avs_driver.h"
#include "boot_init_dram.h"
@@ -58,6 +61,8 @@
extern void rcar_pfc_init(void);
extern void rcar_dma_init(void);
+static void bl2_init_generic_timer(void);
+
/* R-Car Gen3 product check */
#if (RCAR_LSI == RCAR_H3) || (RCAR_LSI == RCAR_H3N)
#define TARGET_PRODUCT RCAR_PRODUCT_H3
@@ -71,6 +76,8 @@
#elif RCAR_LSI == RCAR_E3
#define TARGET_PRODUCT RCAR_PRODUCT_E3
#define TARGET_NAME "R-Car E3"
+#elif RCAR_LSI == RCAR_AUTO
+#define TARGET_NAME "R-Car H3/M3/M3N"
#endif
#if (RCAR_LSI == RCAR_E3)
@@ -256,8 +263,10 @@
product_cut == (RCAR_PRODUCT_M3N | RCAR_CUT_VER11)) {
mmio_write_32(IPMMUVI0_IMSCTLR, IMSCTLR_DISCACHE);
mmio_write_32(IPMMUPV0_IMSCTLR, IMSCTLR_DISCACHE);
- } else if (product_cut == (RCAR_PRODUCT_E3 | RCAR_CUT_VER10)) {
+ } else if ((product_cut == (RCAR_PRODUCT_E3 | RCAR_CUT_VER10)) ||
+ (product_cut == (RCAR_PRODUCT_E3 | RCAR_CUT_VER11))) {
mmio_write_32(IPMMUVI0_IMSCTLR, IMSCTLR_DISCACHE);
+ mmio_write_32(IPMMUVP0_IMSCTLR, IMSCTLR_DISCACHE);
mmio_write_32(IPMMUPV0_IMSCTLR, IMSCTLR_DISCACHE);
}
@@ -385,7 +394,7 @@
return 0;
}
-meminfo_t *bl2_plat_sec_mem_layout(void)
+struct meminfo *bl2_plat_sec_mem_layout(void)
{
return &bl2_tzram_layout;
}
@@ -621,6 +630,8 @@
int fcnlnode;
#endif
+ bl2_init_generic_timer();
+
reg = mmio_read_32(RCAR_MODEMR);
boot_dev = reg & MODEMR_BOOT_DEV_MASK;
boot_cpu = reg & MODEMR_BOOT_CPU_MASK;
@@ -896,7 +907,7 @@
#if RCAR_BL2_DCACHE == 1
NOTICE("BL2: D-Cache enable\n");
rcar_configure_mmu_el3(BL2_BASE,
- RCAR_SYSRAM_LIMIT - BL2_BASE,
+ BL2_END - BL2_BASE,
BL2_RO_BASE, BL2_RO_LIMIT
#if USE_COHERENT_MEM
, BL2_COHERENT_RAM_BASE, BL2_COHERENT_RAM_LIMIT
@@ -909,3 +920,52 @@
{
}
+
+static void bl2_init_generic_timer(void)
+{
+#if RCAR_LSI == RCAR_E3
+ uint32_t reg_cntfid = EXTAL_EBISU;
+#else /* RCAR_LSI == RCAR_E3 */
+ uint32_t reg;
+ uint32_t reg_cntfid;
+ uint32_t modemr;
+ uint32_t modemr_pll;
+ uint32_t board_type;
+ uint32_t board_rev;
+ uint32_t pll_table[] = {
+ EXTAL_MD14_MD13_TYPE_0, /* MD14/MD13 : 0b00 */
+ EXTAL_MD14_MD13_TYPE_1, /* MD14/MD13 : 0b01 */
+ EXTAL_MD14_MD13_TYPE_2, /* MD14/MD13 : 0b10 */
+ EXTAL_MD14_MD13_TYPE_3 /* MD14/MD13 : 0b11 */
+ };
+
+ modemr = mmio_read_32(RCAR_MODEMR);
+ modemr_pll = (modemr & MODEMR_BOOT_PLL_MASK);
+
+ /* Set frequency data in CNTFID0 */
+ reg_cntfid = pll_table[modemr_pll >> MODEMR_BOOT_PLL_SHIFT];
+ reg = mmio_read_32(RCAR_PRR) & (RCAR_PRODUCT_MASK | RCAR_CUT_MASK);
+ switch (modemr_pll) {
+ case MD14_MD13_TYPE_0:
+ rcar_get_board_type(&board_type, &board_rev);
+ if (BOARD_SALVATOR_XS == board_type) {
+ reg_cntfid = EXTAL_SALVATOR_XS;
+ }
+ break;
+ case MD14_MD13_TYPE_3:
+ if (RCAR_PRODUCT_H3_CUT10 == reg) {
+ reg_cntfid = reg_cntfid >> 1U;
+ }
+ break;
+ default:
+ /* none */
+ break;
+ }
+#endif /* RCAR_LSI == RCAR_E3 */
+ /* Update memory mapped and register based freqency */
+ write_cntfrq_el0((u_register_t )reg_cntfid);
+ mmio_write_32(ARM_SYS_CNTCTL_BASE + (uintptr_t)CNTFID_OFF, reg_cntfid);
+ /* Enable counter */
+ mmio_setbits_32(RCAR_CNTC_BASE + (uintptr_t)CNTCR_OFF,
+ (uint32_t)CNTCR_EN);
+}
diff --git a/plat/renesas/rcar/bl2_secure_setting.c b/plat/renesas/rcar/bl2_secure_setting.c
index c0d49de..cbda1eb 100644
--- a/plat/renesas/rcar/bl2_secure_setting.c
+++ b/plat/renesas/rcar/bl2_secure_setting.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
+
#include "axi_registers.h"
#include "lifec_registers.h"
#include "micro_delay.h"
-#include "mmio.h"
-#include "utils_def.h"
static void lifec_security_setting(void);
static void axi_security_setting(void);
diff --git a/plat/renesas/rcar/bl31_plat_setup.c b/plat/renesas/rcar/bl31_plat_setup.c
index 00f6d10..4e08b5a 100644
--- a/plat/renesas/rcar/bl31_plat_setup.c
+++ b/plat/renesas/rcar/bl31_plat_setup.c
@@ -5,16 +5,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <stddef.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <bl_common.h>
-#include <bl31.h>
-#include <cci.h>
-#include <console.h>
-#include <mmio.h>
-#include <platform.h>
-#include <stddef.h>
-#include <debug.h>
+#include <bl31/bl31.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include "pwrc.h"
#include "rcar_def.h"
#include "rcar_private.h"
@@ -62,7 +64,7 @@
cci_disable_snoop_dvm_reqs(MPIDR_AFFLVL1_VAL(read_mpidr()));
}
-entry_point_info_t *bl31_plat_get_next_image_ep_info(uint32_t type)
+struct entry_point_info *bl31_plat_get_next_image_ep_info(uint32_t type)
{
bl2_to_bl31_params_mem_t *from_bl2 = (bl2_to_bl31_params_mem_t *)
PARAMS_BASE;
@@ -98,6 +100,7 @@
, BL31_COHERENT_RAM_BASE, BL31_COHERENT_RAM_LIMIT
#endif
);
+ rcar_pwrc_code_copy_to_system_ram();
}
void bl31_platform_setup(void)
diff --git a/plat/renesas/rcar/include/plat.ld.S b/plat/renesas/rcar/include/plat.ld.S
index 0461141..7aef324 100644
--- a/plat/renesas/rcar/include/plat.ld.S
+++ b/plat/renesas/rcar/include/plat.ld.S
@@ -6,8 +6,8 @@
#ifndef RCAR_PLAT_LD_S
#define RCAR_PLAT_LD_S
+#include <lib/xlat_tables/xlat_tables_defs.h>
#include <platform_def.h>
-#include <xlat_tables_defs.h>
MEMORY {
SRAM (rwx): ORIGIN = BL31_SRAM_BASE, LENGTH = DEVICE_SRAM_SIZE
diff --git a/plat/renesas/rcar/include/plat_macros.S b/plat/renesas/rcar/include/plat_macros.S
index eb10928..927cd39 100644
--- a/plat/renesas/rcar/include/plat_macros.S
+++ b/plat/renesas/rcar/include/plat_macros.S
@@ -4,9 +4,10 @@
* 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 "rcar_def.h"
.section .rodata.gic_reg_name, "aS"
diff --git a/plat/renesas/rcar/include/platform_def.h b/plat/renesas/rcar/include/platform_def.h
index fa6e474..934b2dc 100644
--- a/plat/renesas/rcar/include/platform_def.h
+++ b/plat/renesas/rcar/include/platform_def.h
@@ -7,10 +7,12 @@
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
-#include <arch.h>
#ifndef __ASSEMBLY__
#include <stdlib.h>
#endif
+
+#include <arch.h>
+
#include "rcar_def.h"
/*******************************************************************************
@@ -77,7 +79,7 @@
* Cortex-A53
* L1:I/32KB(16KBx2way) D/32KB(8KBx4way) L2:512KB(32KBx16way)
*/
-#define PLATFORM_CACHE_LINE_SIZE 128
+#define PLATFORM_CACHE_LINE_SIZE 64
#define PLATFORM_CLUSTER_COUNT U(2)
#define PLATFORM_CLUSTER0_CORE_COUNT U(4)
#define PLATFORM_CLUSTER1_CORE_COUNT U(4)
@@ -102,16 +104,16 @@
* size plus a little space for growth. */
#define RCAR_SYSRAM_BASE U(0xE6300000)
#if RCAR_LSI == RCAR_E3
-#define RCAR_SYSRAM_LIMIT U(0xE6320000)
+#define BL2_LIMIT U(0xE6320000)
#else
-#define RCAR_SYSRAM_LIMIT U(0xE6360000)
+#define BL2_LIMIT U(0xE6360000)
#endif
#define BL2_BASE U(0xE6304000)
#if RCAR_LSI == RCAR_E3
-#define BL2_LIMIT U(0xE6318000)
+#define BL2_IMAGE_LIMIT U(0xE6318000)
#else
-#define BL2_LIMIT U(0xE632E800)
+#define BL2_IMAGE_LIMIT U(0xE632E800)
#endif
#define RCAR_SYSRAM_SIZE (BL2_BASE - RCAR_SYSRAM_BASE)
diff --git a/plat/renesas/rcar/include/rcar_def.h b/plat/renesas/rcar/include/rcar_def.h
index 61b95a4..1829e59 100644
--- a/plat/renesas/rcar/include/rcar_def.h
+++ b/plat/renesas/rcar/include/rcar_def.h
@@ -7,8 +7,8 @@
#ifndef RCAR_DEF_H
#define RCAR_DEF_H
-#include <tbbr_img_def.h>
-#include <utils_def.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <lib/utils_def.h>
#define RCAR_PRIMARY_CPU 0x0
#define RCAR_TRUSTED_SRAM_BASE 0x44000000
@@ -24,7 +24,7 @@
#define DEVICE_RCAR_SIZE U(0x00300000)
#define DEVICE_RCAR_BASE2 U(0xE6360000)
#define DEVICE_RCAR_SIZE2 U(0x19CA0000)
-#define DEVICE_SRAM_BASE U(0xE6310000)
+#define DEVICE_SRAM_BASE U(0xE6300000)
#define DEVICE_SRAM_SIZE U(0x00002000)
#define DEVICE_SRAM_STACK_BASE (DEVICE_SRAM_BASE + DEVICE_SRAM_SIZE)
#define DEVICE_SRAM_STACK_SIZE U(0x00001000)
@@ -231,6 +231,8 @@
#define IPMMUMM_IMSCTLR_ENABLE (0xC0000000U)
#define IPMMUMM_IMAUXCTLR_NMERGE40_BIT (0x01000000U)
#define IMSCTLR_DISCACHE (0xE0000000U)
+#define IPMMU_VP0_BASE (0xFE990000U)
+#define IPMMUVP0_IMSCTLR (IPMMU_VP0_BASE + 0x0500U)
#define IPMMU_VI0_BASE (0xFEBD0000U)
#define IPMMUVI0_IMSCTLR (IPMMU_VI0_BASE + 0x0500U)
#define IPMMU_VI1_BASE (0xFEBE0000U)
diff --git a/plat/renesas/rcar/include/rcar_private.h b/plat/renesas/rcar/include/rcar_private.h
index e90fa08..def3276 100644
--- a/plat/renesas/rcar/include/rcar_private.h
+++ b/plat/renesas/rcar/include/rcar_private.h
@@ -7,11 +7,12 @@
#ifndef RCAR_PRIVATE_H
#define RCAR_PRIVATE_H
-#include <bakery_lock.h>
-#include <bl_common.h>
-#include <cpu_data.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <lib/bakery_lock.h>
+#include <lib/el3_runtime/cpu_data.h>
+
typedef volatile struct mailbox {
unsigned long value __aligned(CACHE_WRITEBACK_GRANULE);
} mailbox_t;
diff --git a/plat/renesas/rcar/include/rcar_version.h b/plat/renesas/rcar/include/rcar_version.h
index 5ab8efc..5c8805c 100644
--- a/plat/renesas/rcar/include/rcar_version.h
+++ b/plat/renesas/rcar/include/rcar_version.h
@@ -9,7 +9,7 @@
#include <arch_helpers.h>
-#define VERSION_OF_RENESAS "1.0.22"
+#define VERSION_OF_RENESAS "2.0.0"
#define VERSION_OF_RENESAS_MAXLEN (128)
extern const uint8_t version_of_renesas[VERSION_OF_RENESAS_MAXLEN];
diff --git a/plat/renesas/rcar/plat_image_load.c b/plat/renesas/rcar/plat_image_load.c
index 469ac29..9d814a6 100644
--- a/plat/renesas/rcar/plat_image_load.c
+++ b/plat/renesas/rcar/plat_image_load.c
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
extern void bl2_plat_flush_bl31_params(void);
diff --git a/plat/renesas/rcar/plat_pm.c b/plat/renesas/rcar/plat_pm.c
index 84cc47e..245a45a 100644
--- a/plat/renesas/rcar/plat_pm.c
+++ b/plat/renesas/rcar/plat_pm.c
@@ -4,22 +4,25 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <bakery_lock.h>
-#include <bl_common.h>
-#include <cci.h>
-#include <debug.h>
#include <errno.h>
-#include <gicv2.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
#include "iic_dvfs.h"
#include "pwrc.h"
#include "rcar_def.h"
#include "rcar_private.h"
+#include "ulcb_cpld.h"
#define DVFS_SET_VID_0V (0x00)
#define P_ALL_OFF (0x80)
@@ -39,10 +42,6 @@
extern void plat_rcar_gic_init(void);
extern u_register_t rcar_boot_mpidr;
-#if (RCAR_GEN3_ULCB == 1)
-extern void rcar_cpld_reset_cpu(void);
-#endif
-
static uintptr_t rcar_sec_entrypoint;
static void rcar_program_mailbox(uint64_t mpidr, uint64_t address)
@@ -153,6 +152,7 @@
write_cntfrq_el0(plat_get_syscnt_freq2());
mmio_write_32(RCAR_CNTC_BASE + CNTCR_OFF, CNTCR_FCREQ(U(0)) | CNTCR_EN);
rcar_pwrc_setup();
+ rcar_pwrc_code_copy_to_system_ram();
#if RCAR_SYSTEM_SUSPEND
rcar_pwrc_init_suspend_to_ram();
@@ -165,11 +165,9 @@
{
#if PMIC_ROHM_BD9571
#if PMIC_LEVEL_MODE
- rcar_pwrc_code_copy_to_system_ram();
if (rcar_iic_dvfs_send(PMIC, DVFS_SET_VID, DVFS_SET_VID_0V))
ERROR("BL3-1:Failed the SYSTEM-OFF.\n");
#else
- rcar_pwrc_code_copy_to_system_ram();
if (rcar_iic_dvfs_send(PMIC, BKUP_MODE_CNT, P_ALL_OFF))
ERROR("BL3-1:Failed the SYSTEM-RESET.\n");
#endif
@@ -202,7 +200,6 @@
uint8_t mode;
int32_t error;
- rcar_pwrc_code_copy_to_system_ram();
error = rcar_iic_dvfs_send(PMIC, REG_KEEP10, KEEP10_MAGIC);
if (error) {
ERROR("Failed send KEEP10 magic ret=%d \n", error);
@@ -225,7 +222,6 @@
rcar_pwrc_set_suspend_to_ram();
done:
#else
- rcar_pwrc_code_copy_to_system_ram();
if (rcar_iic_dvfs_send(PMIC, BKUP_MODE_CNT, P_ALL_OFF))
ERROR("BL3-1:Failed the SYSTEM-RESET.\n");
#endif
diff --git a/plat/renesas/rcar/plat_storage.c b/plat/renesas/rcar/plat_storage.c
index 3b5d620..05e3d9f 100644
--- a/plat/renesas/rcar/plat_storage.c
+++ b/plat/renesas/rcar/plat_storage.c
@@ -4,12 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <io_driver.h>
-#include <io_storage.h>
-#include <io_semihosting.h>
-#include <platform_def.h>
#include <string.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_storage.h>
+#include <drivers/io/io_semihosting.h>
+
#include "io_common.h"
#include "io_rcar.h"
#include "io_memdrv.h"
diff --git a/plat/renesas/rcar/plat_topology.c b/plat/renesas/rcar/plat_topology.c
index 3582c2b..0d5880d 100644
--- a/plat/renesas/rcar/plat_topology.c
+++ b/plat/renesas/rcar/plat_topology.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
#include <platform_def.h>
-#include <psci.h>
+
+#include <common/debug.h>
+#include <lib/psci/psci.h>
static const unsigned char rcar_power_domain_tree_desc[] = {
1,
diff --git a/plat/renesas/rcar/platform.mk b/plat/renesas/rcar/platform.mk
index 0cc746d..b9c0802 100644
--- a/plat/renesas/rcar/platform.mk
+++ b/plat/renesas/rcar/platform.mk
@@ -4,13 +4,14 @@
# SPDX-License-Identifier: BSD-3-Clause
#
-PROGRAMMABLE_RESET_ADDRESS := 0
+PROGRAMMABLE_RESET_ADDRESS := 1
COLD_BOOT_SINGLE_CPU := 1
ARM_CCI_PRODUCT_ID := 500
TRUSTED_BOARD_BOOT := 1
RESET_TO_BL31 := 1
GENERATE_COT := 1
BL2_AT_EL3 := 1
+ENABLE_SVE_FOR_NS := 0
$(eval $(call add_define,PLAT_EXTRA_LD_SCRIPT))
@@ -310,6 +311,7 @@
-Idrivers/staging/renesas/rcar/qos \
-Idrivers/renesas/rcar/iic_dvfs \
-Idrivers/renesas/rcar/board \
+ -Idrivers/renesas/rcar/cpld/ \
-Idrivers/renesas/rcar/avs \
-Idrivers/renesas/rcar/delay \
-Idrivers/renesas/rcar/rom \
@@ -353,7 +355,7 @@
drivers/renesas/rcar/rpc/rpc_driver.c \
drivers/renesas/rcar/dma/dma_driver.c \
drivers/renesas/rcar/avs/avs_driver.c \
- drivers/renesas/rcar/delay/micro_delay.S \
+ drivers/renesas/rcar/delay/micro_delay.c \
drivers/renesas/rcar/emmc/emmc_interrupt.c \
drivers/renesas/rcar/emmc/emmc_utility.c \
drivers/renesas/rcar/emmc/emmc_mount.c \
@@ -376,6 +378,7 @@
plat/renesas/rcar/plat_pm.c \
drivers/renesas/rcar/console/rcar_console.S \
drivers/renesas/rcar/console/rcar_printf.c \
+ drivers/renesas/rcar/delay/micro_delay.c \
drivers/renesas/rcar/pwrc/call_sram.S \
drivers/renesas/rcar/pwrc/pwrc.c \
drivers/renesas/rcar/common.c \
@@ -415,7 +418,7 @@
rm -f ${SREC_PATH}/bl2.srec ${SREC_PATH}/bl31.srec
.PHONY: rcar_srecord
-rcar_srecord:
+rcar_srecord: $(BL2_ELF_SRC) $(BL31_ELF_SRC)
@echo "generating srec: ${SREC_PATH}/bl2.srec"
$(Q)$(OC) -O srec --srec-forceS3 ${BL2_ELF_SRC} ${SREC_PATH}/bl2.srec
@echo "generating srec: ${SREC_PATH}/bl31.srec"
diff --git a/plat/rockchip/common/aarch64/plat_helpers.S b/plat/rockchip/common/aarch64/plat_helpers.S
index f0136b0..4af052b 100644
--- a/plat/rockchip/common/aarch64/plat_helpers.S
+++ b/plat/rockchip/common/aarch64/plat_helpers.S
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <platform_def.h>
+
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <cortex_a53.h>
#include <cortex_a72.h>
#include <plat_private.h>
-#include <platform_def.h>
#include <plat_pmu_macros.S>
.globl cpuson_entry_point
diff --git a/plat/rockchip/common/aarch64/platform_common.c b/plat/rockchip/common/aarch64/platform_common.c
index 9a74314..81e8520 100644
--- a/plat/rockchip/common/aarch64/platform_common.c
+++ b/plat/rockchip/common/aarch64/platform_common.c
@@ -4,15 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <bl_common.h>
-#include <cci.h>
-#include <debug.h>
-#include <plat_private.h>
-#include <platform_def.h>
#include <string.h>
-#include <utils.h>
-#include <xlat_tables.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.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 <plat_private.h>
#ifdef PLAT_RK_CCI_BASE
static const int cci_map[] = {
diff --git a/plat/rockchip/common/bl31_plat_setup.c b/plat/rockchip/common/bl31_plat_setup.c
index 7a9f7a9..2c970eb 100644
--- a/plat/rockchip/common/bl31_plat_setup.c
+++ b/plat/rockchip/common/bl31_plat_setup.c
@@ -5,16 +5,18 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <coreboot.h>
-#include <debug.h>
-#include <generic_delay_timer.h>
-#include <mmio.h>
-#include <plat_private.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <uart_16550.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <drivers/generic_delay_timer.h>
+#include <drivers/ti/uart/uart_16550.h>
+#include <lib/coreboot.h>
+#include <lib/mmio.h>
+#include <plat_private.h>
+#include <plat/common/platform.h>
/*
* The next 2 constants identify the extents of the code & RO data region.
diff --git a/plat/rockchip/common/drivers/parameter/ddr_parameter.c b/plat/rockchip/common/drivers/parameter/ddr_parameter.c
index ea77757..e89fe1e 100644
--- a/plat/rockchip/common/drivers/parameter/ddr_parameter.c
+++ b/plat/rockchip/common/drivers/parameter/ddr_parameter.c
@@ -4,15 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <console.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <mmio.h>
-#include <plat_private.h>
-#include <platform_def.h>
-#include <soc.h>
#include <string.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
+#include <plat_private.h>
+#include <soc.h>
+
#include "ddr_parameter.h"
/*
diff --git a/plat/rockchip/common/drivers/parameter/ddr_parameter.h b/plat/rockchip/common/drivers/parameter/ddr_parameter.h
index 69c4e18..61349c4 100644
--- a/plat/rockchip/common/drivers/parameter/ddr_parameter.h
+++ b/plat/rockchip/common/drivers/parameter/ddr_parameter.h
@@ -7,16 +7,19 @@
#ifndef DDR_PARAMETER_H
#define DDR_PARAMETER_H
-#include <arch_helpers.h>
-#include <console.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <mmio.h>
-#include <plat_private.h>
-#include <platform_def.h>
-#include <soc.h>
#include <string.h>
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
+#include <plat_private.h>
+#include <soc.h>
+
#define DDR_REGION_NR_MAX 10
#define REGION_NR_OFFSET 0
#define REGION_ADDR_OFFSET 8
diff --git a/plat/rockchip/common/include/plat_macros.S b/plat/rockchip/common/include/plat_macros.S
index 9ee4e83..691beeb 100644
--- a/plat/rockchip/common/include/plat_macros.S
+++ b/plat/rockchip/common/include/plat_macros.S
@@ -6,10 +6,10 @@
#ifndef ROCKCHIP_PLAT_MACROS_S
#define ROCKCHIP_PLAT_MACROS_S
-#include <cci.h>
-#include <gic_common.h>
-#include <gicv2.h>
-#include <gicv3.h>
+#include <drivers/arm/cci.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/gicv3.h>
#include <platform_def.h>
.section .rodata.gic_reg_name, "aS"
diff --git a/plat/rockchip/common/include/plat_private.h b/plat/rockchip/common/include/plat_private.h
index 955ca64..e8750a5 100644
--- a/plat/rockchip/common/include/plat_private.h
+++ b/plat/rockchip/common/include/plat_private.h
@@ -8,10 +8,12 @@
#define PLAT_PRIVATE_H
#ifndef __ASSEMBLY__
-#include <mmio.h>
-#include <psci.h>
+
#include <stdint.h>
-#include <xlat_tables.h>
+
+#include <lib/psci/psci.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <lib/mmio.h>
#define __sramdata __attribute__((section(".sram.data")))
#define __sramconst __attribute__((section(".sram.rodata")))
diff --git a/plat/rockchip/common/params_setup.c b/plat/rockchip/common/params_setup.c
index a7ba83e..3d1b40b 100644
--- a/plat/rockchip/common/params_setup.c
+++ b/plat/rockchip/common/params_setup.c
@@ -5,16 +5,18 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <coreboot.h>
-#include <debug.h>
-#include <gpio.h>
-#include <mmio.h>
+#include <string.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <drivers/gpio.h>
+#include <lib/coreboot.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include <plat_params.h>
#include <plat_private.h>
-#include <platform.h>
-#include <string.h>
static struct gpio_info param_reset;
static struct gpio_info param_poweroff;
diff --git a/plat/rockchip/common/plat_pm.c b/plat/rockchip/common/plat_pm.c
index 352dbc8..c9563c9 100644
--- a/plat/rockchip/common/plat_pm.c
+++ b/plat/rockchip/common/plat_pm.c
@@ -4,15 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <console.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <plat_private.h>
+
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <drivers/delay_timer.h>
+#include <lib/psci/psci.h>
+
+#include <plat_private.h>
/* Macros to read the rk power domain state */
#define RK_CORE_PWR_STATE(state) \
diff --git a/plat/rockchip/common/plat_topology.c b/plat/rockchip/common/plat_topology.c
index 49d063c..a31e410 100644
--- a/plat/rockchip/common/plat_topology.c
+++ b/plat/rockchip/common/plat_topology.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <plat_private.h>
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch.h>
+#include <lib/psci/psci.h>
+
+#include <plat_private.h>
/*******************************************************************************
* This function returns the RockChip default topology tree information.
diff --git a/plat/rockchip/common/rockchip_gicv2.c b/plat/rockchip/common/rockchip_gicv2.c
index 4705042..222a882 100644
--- a/plat/rockchip/common/rockchip_gicv2.c
+++ b/plat/rockchip/common/rockchip_gicv2.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <gicv2.h>
-#include <interrupt_props.h>
#include <platform_def.h>
-#include <utils.h>
+
+#include <common/bl_common.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/utils.h>
/******************************************************************************
* The following functions are defined as weak to allow a platform to override
diff --git a/plat/rockchip/common/rockchip_gicv3.c b/plat/rockchip/common/rockchip_gicv3.c
index efbf1d1..edae2ef 100644
--- a/plat/rockchip/common/rockchip_gicv3.c
+++ b/plat/rockchip/common/rockchip_gicv3.c
@@ -4,12 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <gicv3.h>
-#include <interrupt_props.h>
-#include <platform.h>
#include <platform_def.h>
-#include <utils.h>
+
+#include <common/bl_common.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
/******************************************************************************
* The following functions are defined as weak to allow a platform to override
diff --git a/plat/rockchip/common/rockchip_sip_svc.c b/plat/rockchip/common/rockchip_sip_svc.c
index d690e92..27ef042 100644
--- a/plat/rockchip/common/rockchip_sip_svc.c
+++ b/plat/rockchip/common/rockchip_sip_svc.c
@@ -5,12 +5,14 @@
*/
#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
+
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/mmio.h>
+#include <tools_share/uuid.h>
+
#include <plat_sip_calls.h>
#include <rockchip_sip_svc.h>
-#include <runtime_svc.h>
-#include <uuid.h>
/* Rockchip SiP Service UUID */
DEFINE_SVC_UUID2(rk_sip_svc_uid,
diff --git a/plat/rockchip/rk3328/drivers/pmu/pmu.c b/plat/rockchip/rk3328/drivers/pmu/pmu.c
index 835c3a6..c215ee2 100644
--- a/plat/rockchip/rk3328/drivers/pmu/pmu.c
+++ b/plat/rockchip/rk3328/drivers/pmu/pmu.c
@@ -4,18 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bakery_lock.h>
-#include <bl31.h>
-#include <console.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <mmio.h>
-#include <plat_private.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <bl31/bl31.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <drivers/delay_timer.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <plat_private.h>
#include <pmu.h>
#include <pmu_com.h>
#include <rk3328_def.h>
diff --git a/plat/rockchip/rk3328/drivers/soc/soc.c b/plat/rockchip/rk3328/drivers/soc/soc.c
index ce344d6..d216020 100644
--- a/plat/rockchip/rk3328/drivers/soc/soc.c
+++ b/plat/rockchip/rk3328/drivers/soc/soc.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <console.h>
-#include <ddr_parameter.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <mmio.h>
-#include <plat_private.h>
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
+#include <ddr_parameter.h>
+#include <plat_private.h>
#include <rk3328_def.h>
#include <soc.h>
diff --git a/plat/rockchip/rk3328/include/platform_def.h b/plat/rockchip/rk3328/include/platform_def.h
index 9b20b41..b62c868 100644
--- a/plat/rockchip/rk3328/include/platform_def.h
+++ b/plat/rockchip/rk3328/include/platform_def.h
@@ -8,7 +8,8 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <common_def.h>
+#include <plat/common/common_def.h>
+
#include <rk3328_def.h>
/*******************************************************************************
diff --git a/plat/rockchip/rk3368/drivers/ddr/ddr_rk3368.c b/plat/rockchip/rk3368/drivers/ddr/ddr_rk3368.c
index 1c33763..84d2654 100644
--- a/plat/rockchip/rk3368/drivers/ddr/ddr_rk3368.c
+++ b/plat/rockchip/rk3368/drivers/ddr/ddr_rk3368.c
@@ -4,15 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
-#include <ddr_rk3368.h>
-#include <debug.h>
+#include <stdint.h>
+#include <string.h>
+
#include <platform_def.h>
+
+#include <common/debug.h>
+#include <lib/mmio.h>
+
+#include <ddr_rk3368.h>
#include <pmu.h>
#include <rk3368_def.h>
#include <soc.h>
-#include <stdint.h>
-#include <string.h>
/* GRF_SOC_STATUS0 */
#define DPLL_LOCK (0x1 << 2)
diff --git a/plat/rockchip/rk3368/drivers/pmu/pmu.c b/plat/rockchip/rk3368/drivers/pmu/pmu.c
index cb323e6..e277a18 100644
--- a/plat/rockchip/rk3368/drivers/pmu/pmu.c
+++ b/plat/rockchip/rk3368/drivers/pmu/pmu.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <ddr_rk3368.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <mmio.h>
-#include <plat_private.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <ddr_rk3368.h>
+#include <plat_private.h>
#include <pmu.h>
#include <pmu_com.h>
#include <rk3368_def.h>
diff --git a/plat/rockchip/rk3368/drivers/soc/soc.c b/plat/rockchip/rk3368/drivers/soc/soc.c
index d6979a8..0c34554 100644
--- a/plat/rockchip/rk3368/drivers/soc/soc.c
+++ b/plat/rockchip/rk3368/drivers/soc/soc.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
-#include <mmio.h>
-#include <plat_private.h>
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
+#include <plat_private.h>
#include <rk3368_def.h>
#include <soc.h>
diff --git a/plat/rockchip/rk3368/include/platform_def.h b/plat/rockchip/rk3368/include/platform_def.h
index 4083938..815650f 100644
--- a/plat/rockchip/rk3368/include/platform_def.h
+++ b/plat/rockchip/rk3368/include/platform_def.h
@@ -8,9 +8,10 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <common_def.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
+
#include <rk3368_def.h>
-#include <utils_def.h>
/*******************************************************************************
* Platform binary types for linking
diff --git a/plat/rockchip/rk3368/plat_sip_calls.c b/plat/rockchip/rk3368/plat_sip_calls.c
index c0f43db..5918d58 100644
--- a/plat/rockchip/rk3368/plat_sip_calls.c
+++ b/plat/rockchip/rk3368/plat_sip_calls.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/mmio.h>
+
#include <plat_sip_calls.h>
#include <rockchip_sip_svc.h>
-#include <runtime_svc.h>
uintptr_t rockchip_plat_sip_handler(uint32_t smc_fid,
u_register_t x1,
diff --git a/plat/rockchip/rk3399/drivers/dp/cdn_dp.c b/plat/rockchip/rk3399/drivers/dp/cdn_dp.c
index 73a75bb..aa71fde 100644
--- a/plat/rockchip/rk3399/drivers/dp/cdn_dp.c
+++ b/plat/rockchip/rk3399/drivers/dp/cdn_dp.c
@@ -6,11 +6,13 @@
#include <assert.h>
#include <cdefs.h>
-#include <cdn_dp.h>
-#include <smccc.h>
#include <stdlib.h>
#include <string.h>
+#include <lib/smccc.h>
+
+#include <cdn_dp.h>
+
__asm__(
".pushsection .text.hdcp_handler, \"ax\", %progbits\n"
".global hdcp_handler\n"
diff --git a/plat/rockchip/rk3399/drivers/dram/dfs.c b/plat/rockchip/rk3399/drivers/dram/dfs.c
index e6d39a1..45fd924 100644
--- a/plat/rockchip/rk3399/drivers/dram/dfs.c
+++ b/plat/rockchip/rk3399/drivers/dram/dfs.c
@@ -5,10 +5,11 @@
*/
#include <arch_helpers.h>
-#include <debug.h>
-#include <delay_timer.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
#include <m0_ctl.h>
-#include <mmio.h>
#include <plat_private.h>
#include "dfs.h"
#include "dram.h"
diff --git a/plat/rockchip/rk3399/drivers/dram/dram.h b/plat/rockchip/rk3399/drivers/dram/dram.h
index ded511e..0eb12cf 100644
--- a/plat/rockchip/rk3399/drivers/dram/dram.h
+++ b/plat/rockchip/rk3399/drivers/dram/dram.h
@@ -7,9 +7,10 @@
#ifndef DRAM_H
#define DRAM_H
+#include <stdint.h>
+
#include <dram_regs.h>
#include <plat_private.h>
-#include <stdint.h>
enum {
DDR3 = 3,
diff --git a/plat/rockchip/rk3399/drivers/dram/dram_spec_timing.c b/plat/rockchip/rk3399/drivers/dram/dram_spec_timing.c
index 3527f0e..3cdb7a2 100644
--- a/plat/rockchip/rk3399/drivers/dram/dram_spec_timing.c
+++ b/plat/rockchip/rk3399/drivers/dram/dram_spec_timing.c
@@ -4,10 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <dram.h>
#include <stdint.h>
#include <string.h>
-#include <utils.h>
+
+#include <lib/utils.h>
+
+#include <dram.h>
+
#include "dram_spec_timing.h"
static const uint8_t ddr3_cl_cwl[][7] = {
diff --git a/plat/rockchip/rk3399/drivers/dram/suspend.c b/plat/rockchip/rk3399/drivers/dram/suspend.c
index dd97581..8bc66e1 100644
--- a/plat/rockchip/rk3399/drivers/dram/suspend.c
+++ b/plat/rockchip/rk3399/drivers/dram/suspend.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <platform_def.h>
+
#include <arch_helpers.h>
-#include <debug.h>
+#include <common/debug.h>
+
#include <dram.h>
#include <plat_private.h>
-#include <platform_def.h>
#include <pmu.h>
#include <pmu_bits.h>
#include <pmu_regs.h>
diff --git a/plat/rockchip/rk3399/drivers/gpio/rk3399_gpio.c b/plat/rockchip/rk3399/drivers/gpio/rk3399_gpio.c
index e74c4d9..b8cba6d 100644
--- a/plat/rockchip/rk3399/drivers/gpio/rk3399_gpio.c
+++ b/plat/rockchip/rk3399/drivers/gpio/rk3399_gpio.c
@@ -3,15 +3,19 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
+
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <gpio.h>
-#include <mmio.h>
-#include <plat_private.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/gpio.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <plat_private.h>
#include <soc.h>
uint32_t gpio_port[] = {
diff --git a/plat/rockchip/rk3399/drivers/pmu/m0_ctl.c b/plat/rockchip/rk3399/drivers/pmu/m0_ctl.c
index 3f258b7..d919fa1 100644
--- a/plat/rockchip/rk3399/drivers/pmu/m0_ctl.c
+++ b/plat/rockchip/rk3399/drivers/pmu/m0_ctl.c
@@ -4,12 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
#include <m0_ctl.h>
-#include <mmio.h>
#include <plat_private.h>
#include <rk3399_def.h>
#include <secure.h>
diff --git a/plat/rockchip/rk3399/drivers/pmu/pmu.c b/plat/rockchip/rk3399/drivers/pmu/pmu.c
index 04446d6..42589b9 100644
--- a/plat/rockchip/rk3399/drivers/pmu/pmu.c
+++ b/plat/rockchip/rk3399/drivers/pmu/pmu.c
@@ -4,29 +4,32 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bakery_lock.h>
-#include <bl31.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <dfs.h>
#include <errno.h>
-#include <gicv3.h>
-#include <gpio.h>
+#include <string.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <bl31/bl31.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv3.h>
+#include <drivers/delay_timer.h>
+#include <drivers/gpio.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
+#include <dfs.h>
#include <m0_ctl.h>
-#include <mmio.h>
#include <plat_params.h>
#include <plat_private.h>
-#include <platform.h>
-#include <platform_def.h>
#include <pmu.h>
#include <pmu_com.h>
#include <pwm.h>
#include <rk3399_def.h>
#include <secure.h>
#include <soc.h>
-#include <string.h>
#include <suspend.h>
DEFINE_BAKERY_LOCK(rockchip_pd_lock);
diff --git a/plat/rockchip/rk3399/drivers/secure/secure.c b/plat/rockchip/rk3399/drivers/secure/secure.c
index 1937b13..8286f17 100644
--- a/plat/rockchip/rk3399/drivers/secure/secure.c
+++ b/plat/rockchip/rk3399/drivers/secure/secure.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+
#include <plat_private.h>
#include <secure.h>
#include <soc.h>
diff --git a/plat/rockchip/rk3399/drivers/soc/soc.c b/plat/rockchip/rk3399/drivers/soc/soc.c
index 741adde..c877dbd 100644
--- a/plat/rockchip/rk3399/drivers/soc/soc.c
+++ b/plat/rockchip/rk3399/drivers/soc/soc.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <delay_timer.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+
#include <dfs.h>
#include <dram.h>
#include <m0_ctl.h>
-#include <mmio.h>
#include <plat_private.h>
-#include <platform_def.h>
#include <rk3399_def.h>
#include <secure.h>
#include <soc.h>
diff --git a/plat/rockchip/rk3399/drivers/soc/soc.h b/plat/rockchip/rk3399/drivers/soc/soc.h
index 1f7ec07..8539337 100644
--- a/plat/rockchip/rk3399/drivers/soc/soc.h
+++ b/plat/rockchip/rk3399/drivers/soc/soc.h
@@ -7,7 +7,7 @@
#ifndef SOC_H
#define SOC_H
-#include <utils.h>
+#include <lib/utils.h>
#define GLB_SRST_FST_CFG_VAL 0xfdb9
#define GLB_SRST_SND_CFG_VAL 0xeca8
diff --git a/plat/rockchip/rk3399/include/plat.ld.S b/plat/rockchip/rk3399/include/plat.ld.S
index 5045ba8..cfa912f 100644
--- a/plat/rockchip/rk3399/include/plat.ld.S
+++ b/plat/rockchip/rk3399/include/plat.ld.S
@@ -6,7 +6,7 @@
#ifndef ROCKCHIP_PLAT_LD_S
#define ROCKCHIP_PLAT_LD_S
-#include <xlat_tables_defs.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
MEMORY {
SRAM (rwx): ORIGIN = SRAM_BASE, LENGTH = SRAM_SIZE
diff --git a/plat/rockchip/rk3399/include/platform_def.h b/plat/rockchip/rk3399/include/platform_def.h
index cb798fb..2861a7d 100644
--- a/plat/rockchip/rk3399/include/platform_def.h
+++ b/plat/rockchip/rk3399/include/platform_def.h
@@ -8,10 +8,11 @@
#define PLATFORM_DEF_H
#include <arch.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
+
#include <bl31_param.h>
-#include <common_def.h>
#include <rk3399_def.h>
-#include <utils_def.h>
/*******************************************************************************
* Platform binary types for linking
diff --git a/plat/rockchip/rk3399/plat_sip_calls.c b/plat/rockchip/rk3399/plat_sip_calls.c
index 3f0f619..c2cc5b1 100644
--- a/plat/rockchip/rk3399/plat_sip_calls.c
+++ b/plat/rockchip/rk3399/plat_sip_calls.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/mmio.h>
+
#include <cdn_dp.h>
-#include <debug.h>
#include <dfs.h>
-#include <mmio.h>
#include <plat_sip_calls.h>
#include <rockchip_sip_svc.h>
-#include <runtime_svc.h>
#define RK_SIP_DDR_CFG 0x82000008
#define DRAM_INIT 0x00
diff --git a/plat/rpi3/aarch64/rpi3_bl2_mem_params_desc.c b/plat/rpi3/aarch64/rpi3_bl2_mem_params_desc.c
index 6a3c1d6..715aec4 100644
--- a/plat/rpi3/aarch64/rpi3_bl2_mem_params_desc.c
+++ b/plat/rpi3/aarch64/rpi3_bl2_mem_params_desc.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
+
/*******************************************************************************
* Following descriptor provides BL image/ep information that gets used
* by BL2 to load the images and also subset of this information is
diff --git a/plat/rpi3/include/platform_def.h b/plat/rpi3/include/platform_def.h
index 3b12c30..69ebdb3 100644
--- a/plat/rpi3/include/platform_def.h
+++ b/plat/rpi3/include/platform_def.h
@@ -8,9 +8,9 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <common_def.h>
-#include <tbbr_img_def.h>
-#include <utils_def.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
#include "../rpi3_hw.h"
diff --git a/plat/rpi3/platform.mk b/plat/rpi3/platform.mk
index 46c139e..559f316 100644
--- a/plat/rpi3/platform.mk
+++ b/plat/rpi3/platform.mk
@@ -7,8 +7,7 @@
include lib/libfdt/libfdt.mk
include lib/xlat_tables_v2/xlat_tables.mk
-PLAT_INCLUDES := -Iinclude/common/tbbr \
- -Iplat/rpi3/include
+PLAT_INCLUDES := -Iplat/rpi3/include
PLAT_BL_COMMON_SOURCES := drivers/ti/uart/aarch64/16550_console.S \
plat/rpi3/rpi3_common.c \
@@ -185,8 +184,6 @@
drivers/auth/img_parser_mod.c \
drivers/auth/tbbr/tbbr_cot.c
- PLAT_INCLUDES += -Iinclude/bl1/tbbr
-
BL1_SOURCES += ${AUTH_SOURCES} \
bl1/tbbr/tbbr_img_desc.c \
plat/common/tbbr/plat_tbbr.c \
diff --git a/plat/rpi3/rpi3_bl1_setup.c b/plat/rpi3/rpi3_bl1_setup.c
index 39bb332..ea4215d 100644
--- a/plat/rpi3/rpi3_bl1_setup.c
+++ b/plat/rpi3/rpi3_bl1_setup.c
@@ -4,13 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <platform_def.h>
-#include <xlat_mmu_helpers.h>
-#include <xlat_tables_defs.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
#include "../../bl1/bl1_private.h"
#include "rpi3_private.h"
diff --git a/plat/rpi3/rpi3_bl2_setup.c b/plat/rpi3/rpi3_bl2_setup.c
index c78024e..53a2c72 100644
--- a/plat/rpi3/rpi3_bl2_setup.c
+++ b/plat/rpi3/rpi3_bl2_setup.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <desc_image_load.h>
-#include <optee_utils.h>
+
#include <platform_def.h>
-#include <xlat_mmu_helpers.h>
-#include <xlat_tables_defs.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <lib/optee_utils.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
#include "rpi3_private.h"
diff --git a/plat/rpi3/rpi3_bl31_setup.c b/plat/rpi3/rpi3_bl31_setup.c
index 483d150..af7f806 100644
--- a/plat/rpi3/rpi3_bl31_setup.c
+++ b/plat/rpi3/rpi3_bl31_setup.c
@@ -5,12 +5,15 @@
*/
#include <assert.h>
-#include <bl_common.h>
+
#include <libfdt.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <xlat_mmu_helpers.h>
-#include <xlat_tables_defs.h>
+
+#include <common/bl_common.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+#include <plat/common/platform.h>
#include "rpi3_private.h"
diff --git a/plat/rpi3/rpi3_common.c b/plat/rpi3/rpi3_common.c
index c7e8b3a..9b10974 100644
--- a/plat/rpi3/rpi3_common.c
+++ b/plat/rpi3/rpi3_common.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
-#include <interrupt_mgmt.h>
+
#include <platform_def.h>
-#include <uart_16550.h>
-#include <xlat_tables_v2.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <bl31/interrupt_mgmt.h>
+#include <drivers/console.h>
+#include <drivers/ti/uart/uart_16550.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
#include "rpi3_hw.h"
#include "rpi3_private.h"
diff --git a/plat/rpi3/rpi3_hw.h b/plat/rpi3/rpi3_hw.h
index 822644c..9d86eb8 100644
--- a/plat/rpi3/rpi3_hw.h
+++ b/plat/rpi3/rpi3_hw.h
@@ -7,7 +7,7 @@
#ifndef RPI3_HW_H
#define RPI3_HW_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/*
* Peripherals
diff --git a/plat/rpi3/rpi3_image_load.c b/plat/rpi3/rpi3_image_load.c
index fad9e4f..5394c6f 100644
--- a/plat/rpi3/rpi3_image_load.c
+++ b/plat/rpi3/rpi3_image_load.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
+
/*******************************************************************************
* This function flushes the data structures so that they are visible
* in memory for the next BL image.
diff --git a/plat/rpi3/rpi3_io_storage.c b/plat/rpi3/rpi3_io_storage.c
index cafcf6d..7e66deb 100644
--- a/plat/rpi3/rpi3_io_storage.c
+++ b/plat/rpi3/rpi3_io_storage.c
@@ -5,15 +5,17 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <firmware_image_package.h>
-#include <io_driver.h>
-#include <io_fip.h>
-#include <io_memmap.h>
-#include <platform_def.h>
#include <string.h>
+#include <platform_def.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_memmap.h>
+#include <tools_share/firmware_image_package.h>
+
/* Semihosting filenames */
#define BL2_IMAGE_NAME "bl2.bin"
#define BL31_IMAGE_NAME "bl31.bin"
diff --git a/plat/rpi3/rpi3_mbox.c b/plat/rpi3/rpi3_mbox.c
index 77e17af..2db605e 100644
--- a/plat/rpi3/rpi3_mbox.c
+++ b/plat/rpi3/rpi3_mbox.c
@@ -5,11 +5,13 @@
*/
#include <assert.h>
-#include <arch_helpers.h>
-#include <debug.h>
-#include <mmio.h>
+
#include <platform_def.h>
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "rpi3_hw.h"
/* This struct must be aligned to 16 bytes */
diff --git a/plat/rpi3/rpi3_pm.c b/plat/rpi3/rpi3_pm.c
index b6adc8a..3a077d3 100644
--- a/plat/rpi3/rpi3_pm.c
+++ b/plat/rpi3/rpi3_pm.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <console.h>
-#include <debug.h>
-#include <mmio.h>
+
#include <platform_def.h>
-#include <platform.h>
-#include <psci.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
#include "rpi3_hw.h"
diff --git a/plat/rpi3/rpi3_rng.c b/plat/rpi3/rpi3_rng.c
index 111b3b6..fd69adb 100644
--- a/plat/rpi3/rpi3_rng.c
+++ b/plat/rpi3/rpi3_rng.c
@@ -5,9 +5,10 @@
*/
#include <assert.h>
-#include <mmio.h>
#include <string.h>
+#include <lib/mmio.h>
+
#include "rpi3_hw.h"
/* Initial amount of values to discard */
diff --git a/plat/rpi3/rpi3_stack_protector.c b/plat/rpi3/rpi3_stack_protector.c
index 812f6ed..815f731 100644
--- a/plat/rpi3/rpi3_stack_protector.c
+++ b/plat/rpi3/rpi3_stack_protector.c
@@ -5,7 +5,8 @@
*/
#include <stdint.h>
-#include <utils.h>
+
+#include <lib/utils.h>
#include "rpi3_private.h"
diff --git a/plat/rpi3/rpi3_topology.c b/plat/rpi3/rpi3_topology.c
index 31a22a4..200d41d 100644
--- a/plat/rpi3/rpi3_topology.c
+++ b/plat/rpi3/rpi3_topology.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <platform_def.h>
#include <stdint.h>
+#include <platform_def.h>
+
+#include <arch.h>
+
#include "rpi3_private.h"
/* The power domain tree descriptor */
diff --git a/plat/rpi3/rpi3_trusted_boot.c b/plat/rpi3/rpi3_trusted_boot.c
index 2f528fc..b306c45 100644
--- a/plat/rpi3/rpi3_trusted_boot.c
+++ b/plat/rpi3/rpi3_trusted_boot.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+#include <plat/common/platform.h>
extern char rpi3_rotpk_hash[], rpi3_rotpk_hash_end[];
diff --git a/plat/socionext/synquacer/drivers/mhu/sq_mhu.c b/plat/socionext/synquacer/drivers/mhu/sq_mhu.c
index 5c2a635..925ed97 100644
--- a/plat/socionext/synquacer/drivers/mhu/sq_mhu.c
+++ b/plat/socionext/synquacer/drivers/mhu/sq_mhu.c
@@ -4,11 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bakery_lock.h>
-#include <mmio.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+
#include <sq_common.h>
#include "sq_mhu.h"
diff --git a/plat/socionext/synquacer/drivers/scpi/sq_scpi.c b/plat/socionext/synquacer/drivers/scpi/sq_scpi.c
index 170b7e1..0cb75a0 100644
--- a/plat/socionext/synquacer/drivers/scpi/sq_scpi.c
+++ b/plat/socionext/synquacer/drivers/scpi/sq_scpi.c
@@ -4,12 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <platform_def.h>
-#include <sq_common.h>
-#include <debug.h>
#include <string.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <sq_common.h>
+
#include "sq_mhu.h"
#include "sq_scpi.h"
diff --git a/plat/socionext/synquacer/include/platform_def.h b/plat/socionext/synquacer/include/platform_def.h
index bde7348..de6be7d 100644
--- a/plat/socionext/synquacer/include/platform_def.h
+++ b/plat/socionext/synquacer/include/platform_def.h
@@ -7,8 +7,8 @@
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
-#include <common_def.h>
-#include <utils_def.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
/* CPU topology */
#define PLAT_MAX_CORES_PER_CLUSTER 2
diff --git a/plat/socionext/synquacer/include/sq_common.h b/plat/socionext/synquacer/include/sq_common.h
index c395640..abd9090 100644
--- a/plat/socionext/synquacer/include/sq_common.h
+++ b/plat/socionext/synquacer/include/sq_common.h
@@ -8,7 +8,8 @@
#define SQ_COMMON_H
#include <stdint.h>
-#include <xlat_tables_v2.h>
+
+#include <lib/xlat_tables/xlat_tables_v2.h>
struct draminfo {
uint32_t num_regions;
diff --git a/plat/socionext/synquacer/sq_bl31_setup.c b/plat/socionext/synquacer/sq_bl31_setup.c
index 07c1f89..f8d2526 100644
--- a/plat/socionext/synquacer/sq_bl31_setup.c
+++ b/plat/socionext/synquacer/sq_bl31_setup.c
@@ -4,14 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <platform_def.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <pl011.h>
-#include <debug.h>
-#include <mmio.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/pl011.h>
+#include <lib/mmio.h>
+
#include <sq_common.h>
static console_pl011_t console;
diff --git a/plat/socionext/synquacer/sq_ccn.c b/plat/socionext/synquacer/sq_ccn.c
index bb70d5d..fa6ea87 100644
--- a/plat/socionext/synquacer/sq_ccn.c
+++ b/plat/socionext/synquacer/sq_ccn.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <ccn.h>
-#include <platform_def.h>
+#include <drivers/arm/ccn.h>
static const unsigned char master_to_rn_id_map[] = {
PLAT_SQ_CLUSTER_TO_CCN_ID_MAP
diff --git a/plat/socionext/synquacer/sq_gicv3.c b/plat/socionext/synquacer/sq_gicv3.c
index 94e5a66..05318e3 100644
--- a/plat/socionext/synquacer/sq_gicv3.c
+++ b/plat/socionext/synquacer/sq_gicv3.c
@@ -5,11 +5,13 @@
*/
#include <assert.h>
-#include <gicv3.h>
-#include <interrupt_props.h>
-#include <platform.h>
+
#include <platform_def.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv3.h>
+#include <plat/common/platform.h>
+
#include "sq_common.h"
static uintptr_t sq_rdistif_base_addrs[PLATFORM_CORE_COUNT];
diff --git a/plat/socionext/synquacer/sq_psci.c b/plat/socionext/synquacer/sq_psci.c
index c327f1d..134224d 100644
--- a/plat/socionext/synquacer/sq_psci.c
+++ b/plat/socionext/synquacer/sq_psci.c
@@ -4,17 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <cassert.h>
-#include <debug.h>
-#include <delay_timer.h>
#include <errno.h>
-#include <generic_delay_timer.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/delay_timer.h>
+#include <drivers/generic_delay_timer.h>
+#include <lib/cassert.h>
+#include <lib/psci/psci.h>
+
#include <sq_common.h>
#include "sq_scpi.h"
-#include <psci.h>
/* Macros to read the SQ power domain state */
#define SQ_PWR_LVL0 MPIDR_AFFLVL0
diff --git a/plat/socionext/synquacer/sq_topology.c b/plat/socionext/synquacer/sq_topology.c
index aa20355..359997a 100644
--- a/plat/socionext/synquacer/sq_topology.c
+++ b/plat/socionext/synquacer/sq_topology.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
-#include <sq_common.h>
#include <platform_def.h>
+#include <arch.h>
+
+#include <sq_common.h>
+
unsigned char sq_pd_tree_desc[PLAT_CLUSTER_COUNT + 1];
int plat_core_pos_by_mpidr(u_register_t mpidr)
diff --git a/plat/socionext/synquacer/sq_xlat_setup.c b/plat/socionext/synquacer/sq_xlat_setup.c
index ae14700..5d1669d 100644
--- a/plat/socionext/synquacer/sq_xlat_setup.c
+++ b/plat/socionext/synquacer/sq_xlat_setup.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
#include <platform_def.h>
-#include <xlat_tables_v2.h>
+
+#include <common/debug.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
#define SQ_REG_REGION_BASE 0x20000000ULL
#define SQ_REG_REGION_SIZE 0x60000000ULL
diff --git a/plat/socionext/uniphier/include/platform_def.h b/plat/socionext/uniphier/include/platform_def.h
index 3d71db2..d4db3f5 100644
--- a/plat/socionext/uniphier/include/platform_def.h
+++ b/plat/socionext/uniphier/include/platform_def.h
@@ -7,9 +7,9 @@
#ifndef PLATFORM_DEF_H
#define PLATFORM_DEF_H
-#include <common_def.h>
-#include <tbbr/tbbr_img_def.h>
-#include <utils_def.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
#define PLATFORM_STACK_SIZE 0x1000
@@ -53,7 +53,7 @@
#define MAX_IO_HANDLES 2
#define MAX_IO_DEVICES 2
-#define MAX_IO_BLOCK_DEVICES 1
+#define MAX_IO_BLOCK_DEVICES U(1)
#define TSP_SEC_MEM_BASE (BL32_BASE)
#define TSP_SEC_MEM_SIZE ((BL32_LIMIT) - (BL32_BASE))
diff --git a/plat/socionext/uniphier/tsp/uniphier_tsp_setup.c b/plat/socionext/uniphier/tsp/uniphier_tsp_setup.c
index 7df17d3..e7dcc65 100644
--- a/plat/socionext/uniphier/tsp/uniphier_tsp_setup.c
+++ b/plat/socionext/uniphier/tsp/uniphier_tsp_setup.c
@@ -5,7 +5,8 @@
*/
#include <platform_def.h>
-#include <xlat_mmu_helpers.h>
+
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
#include "../uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_bl2_setup.c b/plat/socionext/uniphier/uniphier_bl2_setup.c
index fb7997c..7109d21 100644
--- a/plat/socionext/uniphier/uniphier_bl2_setup.c
+++ b/plat/socionext/uniphier/uniphier_bl2_setup.c
@@ -4,18 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <debug.h>
-#include <desc_image_load.h>
#include <errno.h>
-#include <io/io_storage.h>
-#include <image_decompress.h>
-#include <platform.h>
+
#include <platform_def.h>
+
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <common/image_decompress.h>
+#include <drivers/io/io_storage.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/platform.h>
#ifdef UNIPHIER_DECOMPRESS_GZIP
#include <tf_gunzip.h>
#endif
-#include <xlat_tables_v2.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_bl31_setup.c b/plat/socionext/uniphier/uniphier_bl31_setup.c
index c5acdbd..ce32d89 100644
--- a/plat/socionext/uniphier/uniphier_bl31_setup.c
+++ b/plat/socionext/uniphier/uniphier_bl31_setup.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
#include <assert.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
#include <errno.h>
-#include <mmio.h>
-#include <platform.h>
+
#include <platform_def.h>
-#include <xlat_mmu_helpers.h>
+
+#include <arch.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_mmu_helpers.h>
+#include <plat/common/platform.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_boot_device.c b/plat/socionext/uniphier/uniphier_boot_device.c
index 78ca8ef..462c085 100644
--- a/plat/socionext/uniphier/uniphier_boot_device.c
+++ b/plat/socionext/uniphier/uniphier_boot_device.c
@@ -5,10 +5,11 @@
*/
#include <assert.h>
-#include <mmio.h>
#include <stdbool.h>
#include <stddef.h>
-#include <utils_def.h>
+
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_cci.c b/plat/socionext/uniphier/uniphier_cci.c
index 9e00c56..3ca1768 100644
--- a/plat/socionext/uniphier/uniphier_cci.c
+++ b/plat/socionext/uniphier/uniphier_cci.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <cci.h>
#include <stddef.h>
-#include <utils_def.h>
+
+#include <arch_helpers.h>
+#include <drivers/arm/cci.h>
+#include <lib/utils_def.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_emmc.c b/plat/socionext/uniphier/uniphier_emmc.c
index db87637..4ac1f51 100644
--- a/plat/socionext/uniphier/uniphier_emmc.c
+++ b/plat/socionext/uniphier/uniphier_emmc.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <io/io_block.h>
-#include <mmio.h>
-#include <platform_def.h>
#include <stdint.h>
-#include <utils_def.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <drivers/io/io_block.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_gicv3.c b/plat/socionext/uniphier/uniphier_gicv3.c
index 93bc73a..5148e8f 100644
--- a/plat/socionext/uniphier/uniphier_gicv3.c
+++ b/plat/socionext/uniphier/uniphier_gicv3.c
@@ -5,11 +5,13 @@
*/
#include <assert.h>
-#include <gicv3.h>
-#include <interrupt_props.h>
-#include <platform.h>
+
#include <platform_def.h>
+#include <drivers/arm/gicv3.h>
+#include <common/interrupt_props.h>
+#include <plat/common/platform.h>
+
#include "uniphier.h"
static uintptr_t uniphier_rdistif_base_addrs[PLATFORM_CORE_COUNT];
diff --git a/plat/socionext/uniphier/uniphier_image_desc.c b/plat/socionext/uniphier/uniphier_image_desc.c
index f4651db..9e171e0 100644
--- a/plat/socionext/uniphier/uniphier_image_desc.c
+++ b/plat/socionext/uniphier/uniphier_image_desc.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch.h>
#include <assert.h>
-#include <desc_image_load.h>
+
#include <platform_def.h>
+#include <arch.h>
+#include <common/desc_image_load.h>
+
#include "uniphier.h"
static struct bl_mem_params_node uniphier_image_descs[] = {
diff --git a/plat/socionext/uniphier/uniphier_io_storage.c b/plat/socionext/uniphier/uniphier_io_storage.c
index 5d841ac..451e84f 100644
--- a/plat/socionext/uniphier/uniphier_io_storage.c
+++ b/plat/socionext/uniphier/uniphier_io_storage.c
@@ -6,15 +6,17 @@
#include <assert.h>
#include <errno.h>
-#include <firmware_image_package.h>
-#include <io/io_block.h>
-#include <io/io_driver.h>
-#include <io/io_fip.h>
-#include <io/io_memmap.h>
-#include <platform_def.h>
#include <stdint.h>
-#include <utils_def.h>
-#include <xlat_tables_v2.h>
+
+#include <platform_def.h>
+
+#include <drivers/io/io_block.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_fip.h>
+#include <drivers/io/io_memmap.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <tools_share/firmware_image_package.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_nand.c b/plat/socionext/uniphier/uniphier_nand.c
index c8e825d..271aa0f 100644
--- a/plat/socionext/uniphier/uniphier_nand.c
+++ b/plat/socionext/uniphier/uniphier_nand.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
-#include <io/io_block.h>
-#include <mmio.h>
-#include <platform_def.h>
#include <stdint.h>
-#include <utils_def.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/io/io_block.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_psci.c b/plat/socionext/uniphier/uniphier_psci.c
index 82081a0..ce11aa7 100644
--- a/plat/socionext/uniphier/uniphier_psci.c
+++ b/plat/socionext/uniphier/uniphier_psci.c
@@ -5,9 +5,9 @@
*/
#include <arch_helpers.h>
-#include <debug.h>
-#include <mmio.h>
-#include <psci.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_scp.c b/plat/socionext/uniphier/uniphier_scp.c
index 58eb72e..c608a25 100644
--- a/plat/socionext/uniphier/uniphier_scp.c
+++ b/plat/socionext/uniphier/uniphier_scp.c
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
-#include <utils_def.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_soc_info.c b/plat/socionext/uniphier/uniphier_soc_info.c
index 55688f3..377532d 100644
--- a/plat/socionext/uniphier/uniphier_soc_info.c
+++ b/plat/socionext/uniphier/uniphier_soc_info.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <mmio.h>
+#include <lib/mmio.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_syscnt.c b/plat/socionext/uniphier/uniphier_syscnt.c
index d7bcaf8..1937843 100644
--- a/plat/socionext/uniphier/uniphier_syscnt.c
+++ b/plat/socionext/uniphier/uniphier_syscnt.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+#include <plat/common/platform.h>
unsigned int plat_get_syscnt_freq2(void)
{
diff --git a/plat/socionext/uniphier/uniphier_tbbr.c b/plat/socionext/uniphier/uniphier_tbbr.c
index 1c83411..962a8d2 100644
--- a/plat/socionext/uniphier/uniphier_tbbr.c
+++ b/plat/socionext/uniphier/uniphier_tbbr.c
@@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+#include <plat/common/platform.h>
extern char uniphier_rotpk_hash[], uniphier_rotpk_hash_end[];
diff --git a/plat/socionext/uniphier/uniphier_topology.c b/plat/socionext/uniphier/uniphier_topology.c
index 1f96f58..c106c98 100644
--- a/plat/socionext/uniphier/uniphier_topology.c
+++ b/plat/socionext/uniphier/uniphier_topology.c
@@ -5,7 +5,7 @@
*/
#include <arch.h>
-#include <platform.h>
+#include <plat/common/platform.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_usb.c b/plat/socionext/uniphier/uniphier_usb.c
index b51b601..ef7079a 100644
--- a/plat/socionext/uniphier/uniphier_usb.c
+++ b/plat/socionext/uniphier/uniphier_usb.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <io/io_block.h>
-#include <mmio.h>
-#include <platform_def.h>
#include <stdint.h>
-#include <utils_def.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <drivers/io/io_block.h>
+#include <lib/mmio.h>
+#include <lib/utils_def.h>
#include "uniphier.h"
diff --git a/plat/socionext/uniphier/uniphier_xlat_setup.c b/plat/socionext/uniphier/uniphier_xlat_setup.c
index 3112ecd..0faebc9 100644
--- a/plat/socionext/uniphier/uniphier_xlat_setup.c
+++ b/plat/socionext/uniphier/uniphier_xlat_setup.c
@@ -4,9 +4,10 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
#include <platform_def.h>
-#include <xlat_tables_v2.h>
+
+#include <common/debug.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
#define UNIPHIER_REG_REGION_BASE 0x50000000ULL
#define UNIPHIER_REG_REGION_SIZE 0x20000000ULL
diff --git a/plat/st/stm32mp1/bl2_io_storage.c b/plat/st/stm32mp1/bl2_io_storage.c
index b1125d1..45a352e 100644
--- a/plat/st/stm32mp1/bl2_io_storage.c
+++ b/plat/st/stm32mp1/bl2_io_storage.c
@@ -4,26 +4,29 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <boot_api.h>
-#include <debug.h>
-#include <io_block.h>
-#include <io_driver.h>
-#include <io_dummy.h>
-#include <io_mmc.h>
-#include <io_stm32image.h>
-#include <io_storage.h>
-#include <mmc.h>
-#include <mmio.h>
-#include <partition.h>
-#include <platform.h>
-#include <platform_def.h>
-#include <stm32_sdmmc2.h>
-#include <stm32mp1_private.h>
-#include <stm32mp1_rcc.h>
#include <string.h>
-#include <utils.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/io/io_block.h>
+#include <drivers/io/io_driver.h>
+#include <drivers/io/io_dummy.h>
+#include <drivers/io/io_storage.h>
+#include <drivers/mmc.h>
+#include <drivers/partition/partition.h>
+#include <drivers/st/io_mmc.h>
+#include <drivers/st/io_stm32image.h>
+#include <drivers/st/stm32_sdmmc2.h>
+#include <drivers/st/stm32mp1_rcc.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+
+#include <boot_api.h>
+#include <stm32mp1_private.h>
/* IO devices */
static const io_dev_connector_t *dummy_dev_con;
diff --git a/plat/st/stm32mp1/bl2_plat_setup.c b/plat/st/stm32mp1/bl2_plat_setup.c
index d85ae96..6af65fd 100644
--- a/plat/st/stm32mp1/bl2_plat_setup.c
+++ b/plat/st/stm32mp1/bl2_plat_setup.c
@@ -4,29 +4,32 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <boot_api.h>
-#include <debug.h>
-#include <delay_timer.h>
-#include <desc_image_load.h>
-#include <generic_delay_timer.h>
-#include <mmio.h>
-#include <platform.h>
+#include <string.h>
+
#include <platform_def.h>
-#include <stm32_console.h>
-#include <stm32mp1_clk.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/desc_image_load.h>
+#include <drivers/delay_timer.h>
+#include <drivers/generic_delay_timer.h>
+#include <drivers/st/stm32_console.h>
+#include <drivers/st/stm32mp1_clk.h>
+#include <drivers/st/stm32mp1_pmic.h>
+#include <drivers/st/stm32mp1_pwr.h>
+#include <drivers/st/stm32mp1_ram.h>
+#include <drivers/st/stm32mp1_rcc.h>
+#include <drivers/st/stm32mp1_reset.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/platform.h>
+
+#include <boot_api.h>
#include <stm32mp1_context.h>
#include <stm32mp1_dt.h>
-#include <stm32mp1_pmic.h>
#include <stm32mp1_private.h>
-#include <stm32mp1_pwr.h>
-#include <stm32mp1_ram.h>
-#include <stm32mp1_rcc.h>
-#include <stm32mp1_reset.h>
-#include <string.h>
-#include <xlat_tables_v2.h>
static struct console_stm32 console;
diff --git a/plat/st/stm32mp1/include/platform_def.h b/plat/st/stm32mp1/include/platform_def.h
index 2ba6cc6..1b4df16 100644
--- a/plat/st/stm32mp1/include/platform_def.h
+++ b/plat/st/stm32mp1/include/platform_def.h
@@ -8,9 +8,10 @@
#define PLATFORM_DEF_H
#include <arch.h>
-#include <common_def.h>
-#include <gic_common.h>
-#include <utils_def.h>
+#include <drivers/arm/gic_common.h>
+#include <lib/utils_def.h>
+#include <plat/common/common_def.h>
+
#include "../stm32mp1_def.h"
/*******************************************************************************
diff --git a/plat/st/stm32mp1/plat_bl2_mem_params_desc.c b/plat/st/stm32mp1/plat_bl2_mem_params_desc.c
index 6f5bc4c..6214194 100644
--- a/plat/st/stm32mp1/plat_bl2_mem_params_desc.c
+++ b/plat/st/stm32mp1/plat_bl2_mem_params_desc.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <desc_image_load.h>
-#include <platform.h>
#include <platform_def.h>
+#include <common/bl_common.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
+
/*******************************************************************************
* Following descriptor provides BL image/ep information that gets used
* by BL2 to load the images and also subset of this information is
diff --git a/plat/st/stm32mp1/plat_image_load.c b/plat/st/stm32mp1/plat_image_load.c
index d5b328e..a52db6c 100644
--- a/plat/st/stm32mp1/plat_image_load.c
+++ b/plat/st/stm32mp1/plat_image_load.c
@@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <desc_image_load.h>
-#include <platform.h>
+#include <common/desc_image_load.h>
+#include <plat/common/platform.h>
/*******************************************************************************
* This function flushes the data structures so that they are visible
diff --git a/plat/st/stm32mp1/platform.mk b/plat/st/stm32mp1/platform.mk
index 545b140..60852c6 100644
--- a/plat/st/stm32mp1/platform.mk
+++ b/plat/st/stm32mp1/platform.mk
@@ -22,9 +22,6 @@
$(eval $(call add_define,PLAT_PARTITION_MAX_ENTRIES))
PLAT_INCLUDES := -Iplat/st/stm32mp1/include/
-PLAT_INCLUDES += -Iinclude/common/tbbr
-PLAT_INCLUDES += -Iinclude/drivers/partition
-PLAT_INCLUDES += -Iinclude/drivers/st
# Device tree
STM32_DTB_FILE_NAME ?= stm32mp157c-ev1.dtb
@@ -83,10 +80,6 @@
plat/st/stm32mp1/plat_bl2_mem_params_desc.c \
plat/st/stm32mp1/plat_image_load.c
-# For memory footprint optimization, build with thumb and interwork support
-ASFLAGS += -mthumb -mthumb-interwork
-TF_CFLAGS += -mthumb -mthumb-interwork
-
# Macros and rules to build TF binary
STM32_TF_ELF_LDFLAGS := --hash-style=gnu --as-needed
STM32_DT_BASENAME := $(STM32_DTB_FILE_NAME:.dtb=)
diff --git a/plat/st/stm32mp1/sp_min/sp_min_setup.c b/plat/st/stm32mp1/sp_min/sp_min_setup.c
index bd4f2ec..f541379 100644
--- a/plat/st/stm32mp1/sp_min/sp_min_setup.c
+++ b/plat/st/stm32mp1/sp_min/sp_min_setup.c
@@ -4,25 +4,28 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <dt-bindings/clock/stm32mp1-clks.h>
-#include <generic_delay_timer.h>
-#include <mmio.h>
-#include <platform.h>
+#include <string.h>
+
#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <context.h>
+#include <drivers/arm/tzc400.h>
+#include <drivers/generic_delay_timer.h>
+#include <drivers/st/stm32_console.h>
+#include <drivers/st/stm32mp1_clk.h>
+#include <dt-bindings/clock/stm32mp1-clks.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/platform.h>
+
#include <platform_sp_min.h>
-#include <stm32_console.h>
-#include <stm32mp1_clk.h>
#include <stm32mp1_dt.h>
#include <stm32mp1_private.h>
-#include <string.h>
-#include <tzc400.h>
-#include <xlat_tables_v2.h>
/******************************************************************************
* Placeholder variables for copying the arguments that have been passed to
diff --git a/plat/st/stm32mp1/stm32mp1.ld.S b/plat/st/stm32mp1/stm32mp1.ld.S
index 50c926f..a8e8220 100644
--- a/plat/st/stm32mp1/stm32mp1.ld.S
+++ b/plat/st/stm32mp1/stm32mp1.ld.S
@@ -7,8 +7,8 @@
#ifndef STM32MP1_LD_S
#define STM32MP1_LD_S
+#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/st/stm32mp1/stm32mp1_common.c b/plat/st/stm32mp1/stm32mp1_common.c
index 7d84da1..b54f313 100644
--- a/plat/st/stm32mp1/stm32mp1_common.c
+++ b/plat/st/stm32mp1/stm32mp1_common.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
-#include <gicv2.h>
-#include <mmio.h>
+
#include <platform_def.h>
-#include <platform.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/platform.h>
+
#include <stm32mp1_private.h>
-#include <xlat_tables_v2.h>
#define MAP_SRAM MAP_REGION_FLAT(STM32MP1_SRAM_BASE, \
STM32MP1_SRAM_SIZE, \
diff --git a/plat/st/stm32mp1/stm32mp1_context.c b/plat/st/stm32mp1/stm32mp1_context.c
index 245fd17..a8f9bf4 100644
--- a/plat/st/stm32mp1/stm32mp1_context.c
+++ b/plat/st/stm32mp1/stm32mp1_context.c
@@ -4,11 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <dt-bindings/clock/stm32mp1-clks.h>
#include <errno.h>
-#include <mmio.h>
+
#include <platform_def.h>
-#include <stm32mp1_clk.h>
+
+#include <drivers/st/stm32mp1_clk.h>
+#include <dt-bindings/clock/stm32mp1-clks.h>
+#include <lib/mmio.h>
+
#include <stm32mp1_context.h>
#define TAMP_BOOT_ITF_BACKUP_REG_ID U(20)
diff --git a/plat/st/stm32mp1/stm32mp1_def.h b/plat/st/stm32mp1/stm32mp1_def.h
index 2224498..15f0432 100644
--- a/plat/st/stm32mp1/stm32mp1_def.h
+++ b/plat/st/stm32mp1/stm32mp1_def.h
@@ -7,9 +7,15 @@
#ifndef STM32MP1_DEF_H
#define STM32MP1_DEF_H
-#include <tbbr_img_def.h>
-#include <utils_def.h>
-#include <xlat_tables_defs.h>
+#include <common/tbbr/tbbr_img_def.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_defs.h>
+
+#ifndef __ASSEMBLY__
+#include <boot_api.h>
+#include <stm32mp1_dt.h>
+#include <stm32mp1_private.h>
+#endif
/*******************************************************************************
* STM32MP1 memory map related constants
diff --git a/plat/st/stm32mp1/stm32mp1_dt.c b/plat/st/stm32mp1/stm32mp1_dt.c
index bde968a..29e936a 100644
--- a/plat/st/stm32mp1/stm32mp1_dt.c
+++ b/plat/st/stm32mp1/stm32mp1_dt.c
@@ -5,15 +5,19 @@
*/
#include <assert.h>
-#include <debug.h>
+
#include <libfdt.h>
+
#include <platform_def.h>
-#include <stm32_gpio.h>
-#include <stm32mp1_clk.h>
-#include <stm32mp1_clkfunc.h>
-#include <stm32mp1_ddr.h>
+
+#include <common/debug.h>
+#include <drivers/st/stm32_gpio.h>
+#include <drivers/st/stm32mp1_clk.h>
+#include <drivers/st/stm32mp1_clkfunc.h>
+#include <drivers/st/stm32mp1_ddr.h>
+#include <drivers/st/stm32mp1_ram.h>
+
#include <stm32mp1_dt.h>
-#include <stm32mp1_ram.h>
#define DT_GPIO_BANK_SHIFT 12
#define DT_GPIO_BANK_MASK 0x1F000U
diff --git a/plat/st/stm32mp1/stm32mp1_gic.c b/plat/st/stm32mp1/stm32mp1_gic.c
index 11eb0a3..fabed37 100644
--- a/plat/st/stm32mp1/stm32mp1_gic.c
+++ b/plat/st/stm32mp1/stm32mp1_gic.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <gicv2.h>
-#include <platform.h>
#include <platform_def.h>
-#include <utils.h>
+
+#include <common/bl_common.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
#include <stm32mp1_private.h>
diff --git a/plat/st/stm32mp1/stm32mp1_helper.S b/plat/st/stm32mp1/stm32mp1_helper.S
index 673706e..61c587f 100644
--- a/plat/st/stm32mp1/stm32mp1_helper.S
+++ b/plat/st/stm32mp1/stm32mp1_helper.S
@@ -4,12 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <platform_def.h>
+
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
-#include <platform_def.h>
-#include <stm32_gpio.h>
-#include <stm32mp1_rcc.h>
+#include <common/bl_common.h>
+#include <drivers/st/stm32_gpio.h>
+#include <drivers/st/stm32mp1_rcc.h>
#define GPIO_BANK_G_ADDRESS 0x50008000
#define GPIO_TX_PORT 11
diff --git a/plat/st/stm32mp1/stm32mp1_pm.c b/plat/st/stm32mp1/stm32mp1_pm.c
index e24af0e..85189ff 100644
--- a/plat/st/stm32mp1/stm32mp1_pm.c
+++ b/plat/st/stm32mp1/stm32mp1_pm.c
@@ -4,21 +4,24 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <boot_api.h>
-#include <debug.h>
-#include <dt-bindings/clock/stm32mp1-clks.h>
#include <errno.h>
-#include <gic_common.h>
-#include <gicv2.h>
-#include <mmio.h>
+
#include <platform_def.h>
-#include <platform.h>
-#include <psci.h>
-#include <stm32mp1_clk.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/st/stm32mp1_clk.h>
+#include <drivers/st/stm32mp1_rcc.h>
+#include <dt-bindings/clock/stm32mp1-clks.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
+#include <boot_api.h>
#include <stm32mp1_private.h>
-#include <stm32mp1_rcc.h>
static uint32_t stm32_sec_entrypoint;
static uint32_t cntfrq_core0;
diff --git a/plat/st/stm32mp1/stm32mp1_security.c b/plat/st/stm32mp1/stm32mp1_security.c
index e783c14..3992704 100644
--- a/plat/st/stm32mp1/stm32mp1_security.c
+++ b/plat/st/stm32mp1/stm32mp1_security.c
@@ -4,16 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <dt-bindings/clock/stm32mp1-clks.h>
-#include <mmio.h>
#include <stdint.h>
-#include <stm32mp1_clk.h>
+
+#include <platform_def.h>
+
+#include <common/debug.h>
+#include <drivers/arm/tzc400.h>
+#include <drivers/st/stm32mp1_clk.h>
+#include <drivers/st/stm32mp1_rcc.h>
+#include <dt-bindings/clock/stm32mp1-clks.h>
+#include <lib/mmio.h>
+
#include <stm32mp1_dt.h>
#include <stm32mp1_private.h>
-#include <stm32mp1_rcc.h>
-#include <tzc400.h>
-#include "platform_def.h"
/*******************************************************************************
* Initialize the TrustZone Controller. Configure Region 0 with Secure RW access
diff --git a/plat/st/stm32mp1/stm32mp1_stack_protector.c b/plat/st/stm32mp1/stm32mp1_stack_protector.c
index c681300..14e8e16 100644
--- a/plat/st/stm32mp1/stm32mp1_stack_protector.c
+++ b/plat/st/stm32mp1/stm32mp1_stack_protector.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <platform.h>
#include <stdint.h>
+#include <arch_helpers.h>
+#include <plat/common/platform.h>
+
#define RANDOM_CANARY_VALUE 2144346116U
u_register_t plat_get_stack_protector_canary(void)
diff --git a/plat/st/stm32mp1/stm32mp1_topology.c b/plat/st/stm32mp1/stm32mp1_topology.c
index 405aa33..59a0c17 100644
--- a/plat/st/stm32mp1/stm32mp1_topology.c
+++ b/plat/st/stm32mp1/stm32mp1_topology.c
@@ -5,8 +5,9 @@
*/
#include <platform_def.h>
-#include <platform.h>
-#include <psci.h>
+
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
/* 1 cluster, all cores into */
static const unsigned char stm32mp1_power_domain_tree_desc[] = {
diff --git a/plat/ti/k3/board/generic/include/board_def.h b/plat/ti/k3/board/generic/include/board_def.h
index 1bf58ed..4c8f882 100644
--- a/plat/ti/k3/board/generic/include/board_def.h
+++ b/plat/ti/k3/board/generic/include/board_def.h
@@ -7,7 +7,7 @@
#ifndef BOARD_DEF_H
#define BOARD_DEF_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
/* The ports must be in order and contiguous */
#define K3_CLUSTER0_CORE_COUNT 2
diff --git a/plat/ti/k3/common/drivers/sec_proxy/sec_proxy.c b/plat/ti/k3/common/drivers/sec_proxy/sec_proxy.c
index 92414b9..5dd54d4 100644
--- a/plat/ti/k3/common/drivers/sec_proxy/sec_proxy.c
+++ b/plat/ti/k3/common/drivers/sec_proxy/sec_proxy.c
@@ -7,14 +7,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <debug.h>
#include <errno.h>
-#include <mmio.h>
-#include <platform_def.h>
#include <stdlib.h>
-#include <utils.h>
-#include <utils_def.h>
+
+#include <platform_def.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
+#include <lib/utils_def.h>
#include "sec_proxy.h"
diff --git a/plat/ti/k3/common/drivers/ti_sci/ti_sci.c b/plat/ti/k3/common/drivers/ti_sci/ti_sci.c
index 7ba0267..b211bdf 100644
--- a/plat/ti/k3/common/drivers/ti_sci/ti_sci.c
+++ b/plat/ti/k3/common/drivers/ti_sci/ti_sci.c
@@ -7,13 +7,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
#include <errno.h>
-#include <platform_def.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
+#include <platform_def.h>
+
+#include <common/debug.h>
#include <sec_proxy.h>
#include "ti_sci_protocol.h"
diff --git a/plat/ti/k3/common/k3_bl31_setup.c b/plat/ti/k3/common/k3_bl31_setup.c
index c0cf5e2..3fa11b2 100644
--- a/plat/ti/k3/common/k3_bl31_setup.c
+++ b/plat/ti/k3/common/k3_bl31_setup.c
@@ -4,17 +4,20 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <string.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <bl_common.h>
-#include <debug.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+
#include <k3_console.h>
#include <k3_gicv3.h>
-#include <platform_def.h>
-#include <string.h>
#include <ti_sci.h>
-#include <xlat_tables_v2.h>
/* Table of regions to map using the MMU */
const mmap_region_t plat_k3_mmap[] = {
diff --git a/plat/ti/k3/common/k3_console.c b/plat/ti/k3/common/k3_console.c
index ff3ca61..31c9632 100644
--- a/plat/ti/k3/common/k3_console.c
+++ b/plat/ti/k3/common/k3_console.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <console.h>
-#include <k3_console.h>
#include <platform_def.h>
-#include <uart_16550.h>
+
+#include <drivers/console.h>
+#include <drivers/ti/uart/uart_16550.h>
+
+#include <k3_console.h>
void bl31_console_setup(void)
{
diff --git a/plat/ti/k3/common/k3_gicv3.c b/plat/ti/k3/common/k3_gicv3.c
index 3253130..b7c7880 100644
--- a/plat/ti/k3/common/k3_gicv3.c
+++ b/plat/ti/k3/common/k3_gicv3.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <gicv3.h>
-#include <interrupt_props.h>
-#include <k3_gicv3.h>
-#include <platform.h>
#include <platform_def.h>
-#include <utils.h>
+
+#include <common/bl_common.h>
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+
+#include <k3_gicv3.h>
/* The GICv3 driver only needs to be initialized in EL3 */
uintptr_t rdistif_base_addrs[PLATFORM_CORE_COUNT];
diff --git a/plat/ti/k3/common/k3_psci.c b/plat/ti/k3/common/k3_psci.c
index 787cc82..cb75bf6 100644
--- a/plat/ti/k3/common/k3_psci.c
+++ b/plat/ti/k3/common/k3_psci.c
@@ -4,19 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <cpu_data.h>
-#include <debug.h>
-#include <k3_gicv3.h>
-#include <psci.h>
-/* Need to flush psci internal locks before shutdown or their values are lost */
-#include <../../lib/psci/psci_private.h>
-#include <platform.h>
#include <stdbool.h>
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
+#include <k3_gicv3.h>
#include <ti_sci.h>
+/* Need to flush psci internal locks before shutdown or their values are lost */
+#include "../../../../lib/psci/psci_private.h"
+
#define STUB() ERROR("stub %s called\n", __func__)
uintptr_t k3_sec_entrypoint;
diff --git a/plat/ti/k3/common/k3_topology.c b/plat/ti/k3/common/k3_topology.c
index d7ac0a5..2b98acb 100644
--- a/plat/ti/k3/common/k3_topology.c
+++ b/plat/ti/k3/common/k3_topology.c
@@ -5,7 +5,8 @@
*/
#include <platform_def.h>
-#include <psci.h>
+
+#include <lib/psci/psci.h>
/* The power domain tree descriptor */
static unsigned char power_domain_tree_desc[] = {
diff --git a/plat/ti/k3/include/platform_def.h b/plat/ti/k3/include/platform_def.h
index 7d1df0a..5d563b6 100644
--- a/plat/ti/k3/include/platform_def.h
+++ b/plat/ti/k3/include/platform_def.h
@@ -8,8 +8,9 @@
#define PLATFORM_DEF_H
#include <arch.h>
+#include <plat/common/common_def.h>
+
#include <board_def.h>
-#include <common_def.h>
/*******************************************************************************
* Generic platform constants
diff --git a/plat/xilinx/versal/aarch64/versal_common.c b/plat/xilinx/versal/aarch64/versal_common.c
index c13b1b5..587b797 100644
--- a/plat/xilinx/versal/aarch64/versal_common.c
+++ b/plat/xilinx/versal/aarch64/versal_common.c
@@ -4,11 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <generic_delay_timer.h>
-#include <mmio.h>
-#include <platform.h>
-#include <xlat_tables.h>
+#include <common/debug.h>
+#include <drivers/generic_delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
+
#include "../versal_def.h"
#include "../versal_private.h"
diff --git a/plat/xilinx/versal/aarch64/versal_helpers.S b/plat/xilinx/versal/aarch64/versal_helpers.S
index 1b7f955..26eb052 100644
--- a/plat/xilinx/versal/aarch64/versal_helpers.S
+++ b/plat/xilinx/versal/aarch64/versal_helpers.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <gicv3.h>
+#include <drivers/arm/gicv3.h>
#include <platform_def.h>
.globl plat_secondary_cold_boot_setup
diff --git a/plat/xilinx/versal/bl31_versal_setup.c b/plat/xilinx/versal/bl31_versal_setup.c
index 9f71a1c..d7e07e0 100644
--- a/plat/xilinx/versal/bl31_versal_setup.c
+++ b/plat/xilinx/versal/bl31_versal_setup.c
@@ -5,14 +5,16 @@
*/
#include <assert.h>
-#include <bl_common.h>
-#include <bl31.h>
-#include <console.h>
-#include <debug.h>
#include <errno.h>
-#include <platform.h>
-#include <pl011.h>
-#include <xlat_tables.h>
+
+#include <bl31/bl31.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/arm/pl011.h>
+#include <drivers/console.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
+
#include "versal_private.h"
static entry_point_info_t bl32_image_ep_info;
diff --git a/plat/xilinx/versal/include/plat_macros.S b/plat/xilinx/versal/include/plat_macros.S
index 4fc1315..3a52212 100644
--- a/plat/xilinx/versal/include/plat_macros.S
+++ b/plat/xilinx/versal/include/plat_macros.S
@@ -7,10 +7,11 @@
#ifndef PLAT_MACROS_S
#define PLAT_MACROS_S
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <drivers/arm/gicv3.h>
+
#include "../include/platform_def.h"
-#include <gic_common.h>
-#include <gicv2.h>
-#include <gicv3.h>
.section .rodata.gic_reg_name, "aS"
/* Applicable only to GICv2 and GICv3 with SRE disabled (legacy mode) */
diff --git a/plat/xilinx/versal/include/platform_def.h b/plat/xilinx/versal/include/platform_def.h
index 45aaa84..0c4b954 100644
--- a/plat/xilinx/versal/include/platform_def.h
+++ b/plat/xilinx/versal/include/platform_def.h
@@ -8,6 +8,7 @@
#define PLATFORM_DEF_H
#include <arch.h>
+
#include "../versal_def.h"
/*******************************************************************************
diff --git a/plat/xilinx/versal/plat_psci.c b/plat/xilinx/versal/plat_psci.c
index 37d00f6..4a44369 100644
--- a/plat/xilinx/versal/plat_psci.c
+++ b/plat/xilinx/versal/plat_psci.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <mmio.h>
-#include <platform.h>
-#include <psci.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
#include "versal_private.h"
static uintptr_t versal_sec_entry;
diff --git a/plat/xilinx/versal/plat_versal.c b/plat/xilinx/versal/plat_versal.c
index 152cb36..642867d 100644
--- a/plat/xilinx/versal/plat_versal.c
+++ b/plat/xilinx/versal/plat_versal.c
@@ -3,7 +3,9 @@
*
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+
+#include <plat/common/platform.h>
+
#include "versal_private.h"
int plat_core_pos_by_mpidr(u_register_t mpidr)
diff --git a/plat/xilinx/versal/sip_svc_setup.c b/plat/xilinx/versal/sip_svc_setup.c
index 4007d5c..8f2180b 100644
--- a/plat/xilinx/versal/sip_svc_setup.c
+++ b/plat/xilinx/versal/sip_svc_setup.c
@@ -6,9 +6,9 @@
/* Top level SMC handler for SiP calls. Dispatch PM calls to PM SMC handler. */
-#include <debug.h>
-#include <runtime_svc.h>
-#include <uuid.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <tools_share/uuid.h>
/* SMC function IDs for SiP Service queries */
#define VERSAL_SIP_SVC_CALL_COUNT 0x8200ff00
diff --git a/plat/xilinx/versal/versal_def.h b/plat/xilinx/versal/versal_def.h
index 5e42bd7..41c65b9 100644
--- a/plat/xilinx/versal/versal_def.h
+++ b/plat/xilinx/versal/versal_def.h
@@ -7,7 +7,7 @@
#ifndef VERSAL_DEF_H
#define VERSAL_DEF_H
-#include <common_def.h>
+#include <plat/common/common_def.h>
/* List all consoles */
#define VERSAL_CONSOLE_ID_pl011 1
diff --git a/plat/xilinx/versal/versal_gicv3.c b/plat/xilinx/versal/versal_gicv3.c
index 72374b5..dcf23b4 100644
--- a/plat/xilinx/versal/versal_gicv3.c
+++ b/plat/xilinx/versal/versal_gicv3.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <gicv3.h>
-#include <interrupt_props.h>
-#include <platform.h>
#include <platform_def.h>
-#include <utils.h>
+
+#include <common/interrupt_props.h>
+#include <drivers/arm/gicv3.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+
#include "versal_private.h"
/******************************************************************************
diff --git a/plat/xilinx/versal/versal_private.h b/plat/xilinx/versal/versal_private.h
index 1e30ebc..5d98d08 100644
--- a/plat/xilinx/versal/versal_private.h
+++ b/plat/xilinx/versal/versal_private.h
@@ -7,7 +7,7 @@
#ifndef VERSAL_PRIVATE_H
#define VERSAL_PRIVATE_H
-#include <xlat_tables.h>
+#include <lib/xlat_tables/xlat_tables.h>
void versal_config_setup(void);
diff --git a/plat/xilinx/zynqmp/aarch64/zynqmp_common.c b/plat/xilinx/zynqmp/aarch64/zynqmp_common.c
index 2f4228f..23c02e0 100644
--- a/plat/xilinx/zynqmp/aarch64/zynqmp_common.c
+++ b/plat/xilinx/zynqmp/aarch64/zynqmp_common.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <generic_delay_timer.h>
-#include <mmio.h>
-#include <platform.h>
#include <stdbool.h>
#include <string.h>
-#include <xlat_tables.h>
+
+#include <common/debug.h>
+#include <drivers/generic_delay_timer.h>
+#include <lib/mmio.h>
+#include <lib/xlat_tables/xlat_tables.h>
+#include <plat/common/platform.h>
+
#include "../zynqmp_private.h"
#include "pm_api_sys.h"
diff --git a/plat/xilinx/zynqmp/aarch64/zynqmp_helpers.S b/plat/xilinx/zynqmp/aarch64/zynqmp_helpers.S
index 969d8fa..8d81665 100644
--- a/plat/xilinx/zynqmp/aarch64/zynqmp_helpers.S
+++ b/plat/xilinx/zynqmp/aarch64/zynqmp_helpers.S
@@ -5,7 +5,7 @@
*/
#include <asm_macros.S>
-#include <gicv2.h>
+#include <drivers/arm/gicv2.h>
#include <platform_def.h>
.globl plat_secondary_cold_boot_setup
diff --git a/plat/xilinx/zynqmp/bl31_zynqmp_setup.c b/plat/xilinx/zynqmp/bl31_zynqmp_setup.c
index 0163450..01cd781 100644
--- a/plat/xilinx/zynqmp/bl31_zynqmp_setup.c
+++ b/plat/xilinx/zynqmp/bl31_zynqmp_setup.c
@@ -5,13 +5,15 @@
*/
#include <assert.h>
-#include <bl31.h>
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
#include <errno.h>
+
+#include <bl31/bl31.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/console.h>
#include <plat_arm.h>
-#include <platform.h>
+#include <plat/common/platform.h>
+
#include "zynqmp_private.h"
#define BL31_END (unsigned long)(&__BL31_END__)
diff --git a/plat/xilinx/zynqmp/include/platform_def.h b/plat/xilinx/zynqmp/include/platform_def.h
index d721778..e3c9fcc 100644
--- a/plat/xilinx/zynqmp/include/platform_def.h
+++ b/plat/xilinx/zynqmp/include/platform_def.h
@@ -8,9 +8,10 @@
#define PLATFORM_DEF_H
#include <arch.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 "../zynqmp_def.h"
/*******************************************************************************
diff --git a/plat/xilinx/zynqmp/ipi_mailbox_service/ipi_mailbox_svc.c b/plat/xilinx/zynqmp/ipi_mailbox_service/ipi_mailbox_svc.c
index bfc19d3..11f382a 100644
--- a/plat/xilinx/zynqmp/ipi_mailbox_service/ipi_mailbox_svc.c
+++ b/plat/xilinx/zynqmp/ipi_mailbox_service/ipi_mailbox_svc.c
@@ -8,12 +8,14 @@
* Top-level SMC handler for ZynqMP IPI Mailbox doorbell functions.
*/
-#include <bakery_lock.h>
-#include <debug.h>
#include <errno.h>
-#include <mmio.h>
-#include <runtime_svc.h>
#include <string.h>
+
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+
#include "ipi_mailbox_svc.h"
#include "../zynqmp_ipi.h"
#include "../zynqmp_private.h"
diff --git a/plat/xilinx/zynqmp/plat_psci.c b/plat/xilinx/zynqmp/plat_psci.c
index a82f696..4183979 100644
--- a/plat/xilinx/zynqmp/plat_psci.c
+++ b/plat/xilinx/zynqmp/plat_psci.c
@@ -4,15 +4,17 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
#include <errno.h>
-#include <gicv2.h>
-#include <mmio.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/mmio.h>
+#include <lib/psci/psci.h>
+#include <plat/common/platform.h>
+
#include <plat_arm.h>
-#include <platform.h>
-#include <psci.h>
#include "pm_api_sys.h"
#include "pm_client.h"
#include "zynqmp_private.h"
diff --git a/plat/xilinx/zynqmp/plat_startup.c b/plat/xilinx/zynqmp/plat_startup.c
index d3e182c..03f0e3d 100644
--- a/plat/xilinx/zynqmp/plat_startup.c
+++ b/plat/xilinx/zynqmp/plat_startup.c
@@ -4,10 +4,12 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <debug.h>
-#include <mmio.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/mmio.h>
+
#include "zynqmp_def.h"
#include "zynqmp_private.h"
diff --git a/plat/xilinx/zynqmp/plat_zynqmp.c b/plat/xilinx/zynqmp/plat_zynqmp.c
index 2441630..ad18aaf 100644
--- a/plat/xilinx/zynqmp/plat_zynqmp.c
+++ b/plat/xilinx/zynqmp/plat_zynqmp.c
@@ -4,7 +4,8 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <platform.h>
+#include <plat/common/platform.h>
+
#include "zynqmp_private.h"
int plat_core_pos_by_mpidr(u_register_t mpidr)
diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_clock.c b/plat/xilinx/zynqmp/pm_service/pm_api_clock.c
index b175b78..85cffcb 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_api_clock.c
+++ b/plat/xilinx/zynqmp/pm_service/pm_api_clock.c
@@ -8,11 +8,13 @@
* ZynqMP system level PM-API functions for clock control.
*/
-#include <arch_helpers.h>
-#include <mmio.h>
-#include <platform.h>
#include <stdbool.h>
#include <string.h>
+
+#include <arch_helpers.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include "pm_api_clock.h"
#include "pm_api_sys.h"
#include "pm_client.h"
@@ -330,18 +332,6 @@
.mult = NA_MULT,
.div = NA_DIV,
},
- {
- .type = TYPE_GATE,
- .offset = PERIPH_GATE_SHIFT,
- .width = PERIPH_GATE_WIDTH,
- .clkflags = CLK_SET_RATE_PARENT |
- CLK_IGNORE_UNUSED |
- CLK_IS_BASIC |
- CLK_IS_CRITICAL,
- .typeflags = NA_TYPE_FLAGS,
- .mult = NA_MULT,
- .div = NA_DIV,
- },
};
static struct pm_clock_node generic_mux_div_nodes[] = {
@@ -476,6 +466,20 @@
},
};
+static struct pm_clock_node acpu_full_nodes[] = {
+ {
+ .type = TYPE_GATE,
+ .offset = 24,
+ .width = PERIPH_GATE_WIDTH,
+ .clkflags = CLK_IGNORE_UNUSED |
+ CLK_SET_RATE_PARENT |
+ CLK_IS_BASIC,
+ .typeflags = NA_TYPE_FLAGS,
+ .mult = NA_MULT,
+ .div = NA_DIV,
+ },
+};
+
static struct pm_clock_node wdt_nodes[] = {
{
.type = TYPE_MUX,
@@ -1205,6 +1209,17 @@
.nodes = &acpu_nodes,
.num_nodes = ARRAY_SIZE(acpu_nodes),
},
+ [CLK_ACPU_FULL] = {
+ .name = "acpu_full",
+ .control_reg = CRF_APB_ACPU_CTRL,
+ .status_reg = 0,
+ .parents = &((int32_t []) {
+ CLK_ACPU | PARENT_CLK_NODE2 << CLK_PARENTS_ID_LEN,
+ CLK_NA_PARENT
+ }),
+ .nodes = &acpu_full_nodes,
+ .num_nodes = ARRAY_SIZE(acpu_full_nodes),
+ },
[CLK_DBG_TRACE] = {
.name = "dbg_trace",
.control_reg = CRF_APB_DBG_TRACE_CTRL,
@@ -2240,7 +2255,29 @@
};
/* Array of clock which are invalid for this variant */
-static uint32_t pm_clk_invalid_list[] = {CLK_USB0, CLK_USB1, CLK_CSU_SPB};
+static uint32_t pm_clk_invalid_list[] = {CLK_USB0, CLK_USB1, CLK_CSU_SPB,
+ CLK_ACPU_FULL,
+ CLK_ACPU_HALF,
+ CLK_APLL_TO_LPD,
+ CLK_DBG_FPD,
+ CLK_DBG_LPD,
+ CLK_DBG_TRACE,
+ CLK_DBG_TSTMP,
+ CLK_DDR_REF,
+ CLK_TOPSW_MAIN,
+ CLK_TOPSW_LSBUS,
+ CLK_GTGREF0_REF,
+ CLK_LPD_SWITCH,
+ CLK_LPD_LSBUS,
+ CLK_CPU_R5,
+ CLK_CPU_R5_CORE,
+ CLK_CSU_SPB,
+ CLK_CSU_PLL,
+ CLK_PCAP,
+ CLK_IOU_SWITCH,
+ CLK_DLL_REF,
+ CLK_TIMESTAMP_REF,
+};
/**
* pm_clock_valid - Check if clock is valid or not
@@ -2489,716 +2526,343 @@
}
/**
- * pll_get_lockbit() - Returns lockbit index for pll id
- * @pll_id: Id of the pll
- *
- * This function return the PLL_LOCKED bit index in
- * pll status register accosiated with given pll id.
- *
- * Return: Returns bit index
+ * struct pm_pll - PLL related data required to map IOCTL-based PLL control
+ * implemented by linux to system-level EEMI APIs
+ * @nid: PLL node ID
+ * @cid: PLL clock ID
+ * @pre_src: Pre-source PLL clock ID
+ * @post_src: Post-source PLL clock ID
+ * @div2: DIV2 PLL clock ID
+ * @bypass: PLL output clock ID that maps to bypass select output
+ * @mode: PLL mode currently set via IOCTL (PLL_FRAC_MODE/PLL_INT_MODE)
*/
-static int pll_get_lockbit(unsigned int pll_id)
+struct pm_pll {
+ const enum pm_node_id nid;
+ const enum clock_id cid;
+ const enum clock_id pre_src;
+ const enum clock_id post_src;
+ const enum clock_id div2;
+ const enum clock_id bypass;
+ uint8_t mode;
+};
+
+static struct pm_pll pm_plls[] = {
+ {
+ .nid = NODE_IOPLL,
+ .cid = CLK_IOPLL_INT,
+ .pre_src = CLK_IOPLL_PRE_SRC,
+ .post_src = CLK_IOPLL_POST_SRC,
+ .div2 = CLK_IOPLL_INT_MUX,
+ .bypass = CLK_IOPLL,
+ }, {
+ .nid = NODE_RPLL,
+ .cid = CLK_RPLL_INT,
+ .pre_src = CLK_RPLL_PRE_SRC,
+ .post_src = CLK_RPLL_POST_SRC,
+ .div2 = CLK_RPLL_INT_MUX,
+ .bypass = CLK_RPLL,
+ }, {
+ .nid = NODE_APLL,
+ .cid = CLK_APLL_INT,
+ .pre_src = CLK_APLL_PRE_SRC,
+ .post_src = CLK_APLL_POST_SRC,
+ .div2 = CLK_APLL_INT_MUX,
+ .bypass = CLK_APLL,
+ }, {
+ .nid = NODE_VPLL,
+ .cid = CLK_VPLL_INT,
+ .pre_src = CLK_VPLL_PRE_SRC,
+ .post_src = CLK_VPLL_POST_SRC,
+ .div2 = CLK_VPLL_INT_MUX,
+ .bypass = CLK_VPLL,
+ }, {
+ .nid = NODE_DPLL,
+ .cid = CLK_DPLL_INT,
+ .pre_src = CLK_DPLL_PRE_SRC,
+ .post_src = CLK_DPLL_POST_SRC,
+ .div2 = CLK_DPLL_INT_MUX,
+ .bypass = CLK_DPLL,
+ },
+};
+
+/**
+ * pm_clock_get_pll() - Get PLL structure by PLL clock ID
+ * @clock_id Clock ID of the target PLL
+ *
+ * @return Pointer to PLL structure if found, NULL otherwise
+ */
+struct pm_pll *pm_clock_get_pll(enum clock_id clock_id)
{
- switch (pll_id) {
- case CLK_APLL_INT:
- case CLK_IOPLL_INT:
- return 0;
- case CLK_DPLL_INT:
- case CLK_RPLL_INT:
- return 1;
- case CLK_VPLL_INT:
- return 2;
- default:
- return -1;
+ uint32_t i;
+
+ for (i = 0; i < ARRAY_SIZE(pm_plls); i++) {
+ if (pm_plls[i].cid == clock_id)
+ return &pm_plls[i];
}
+
+ return NULL;
}
/**
- * pm_api_pll_bypass_and_reset() - Bypass and reset PLL
- * @clock_id: Id of the PLL
+ * pm_clock_get_pll_node_id() - Get PLL node ID by PLL clock ID
+ * @clock_id Clock ID of the target PLL
+ * @node_id Location to store node ID of the target PLL
*
- * This function is to bypass and reset PLL.
+ * @return PM_RET_SUCCESS if node ID is found, PM_RET_ERROR_ARGS otherwise
*/
-static inline enum pm_ret_status
-pm_api_pll_bypass_and_reset(unsigned int clock_id, unsigned int flag)
+enum pm_ret_status pm_clock_get_pll_node_id(enum clock_id clock_id,
+ enum pm_node_id *node_id)
{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- unsigned int reg, val;
- int lockbit;
+ struct pm_pll *pll = pm_clock_get_pll(clock_id);
- reg = clocks[clock_id].control_reg;
-
- if (flag & CLK_PLL_RESET_ASSERT) {
- ret = pm_mmio_write(reg, PLLCTRL_BP_MASK, PLLCTRL_BP_MASK);
- if (ret != PM_RET_SUCCESS)
- return ret;
- ret = pm_mmio_write(reg, PLLCTRL_RESET_MASK,
- PLLCTRL_RESET_MASK);
- if (ret != PM_RET_SUCCESS)
- return ret;
- }
- if (flag & CLK_PLL_RESET_RELEASE) {
- ret = pm_mmio_write(reg, PLLCTRL_RESET_MASK,
- ~PLLCTRL_RESET_MASK);
- if (ret != PM_RET_SUCCESS)
- return ret;
-
- lockbit = pll_get_lockbit(clock_id);
- do {
- ret = pm_mmio_read(clocks[clock_id].status_reg, &val);
- if (ret != PM_RET_SUCCESS)
- return ret;
- } while ((lockbit >= 0) && !(val & (1 << lockbit)));
-
- ret = pm_mmio_write(reg, PLLCTRL_BP_MASK,
- ~(unsigned int)PLLCTRL_BP_MASK);
- }
- return ret;
-}
-
-/**
- * pm_api_clk_enable_disable() - Enable/Disable the clock for given id
- * @clock_id: Id of the clock to be enabled
- * @enable: Enable(1)/Disable(0)
- *
- * This function is to enable/disable the clock which is not PLL.
- *
- * Return: Returns status, either success or error+reason.
- */
-static enum pm_ret_status pm_api_clk_enable_disable(unsigned int clock_id,
- unsigned int enable)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- struct pm_clock_node *nodes = *clocks[clock_id].nodes;
- uint8_t num_nodes = clocks[clock_id].num_nodes;
- unsigned int reg, val;
- uint8_t i = 0;
- uint8_t offset = NA_SHIFT, width = NA_WIDTH;
-
- if (clock_id == CLK_GEM0_TX || clock_id == CLK_GEM1_TX ||
- clock_id == CLK_GEM2_TX || clock_id == CLK_GEM3_TX)
- reg = clocks[clock_id].status_reg;
- else
- reg = clocks[clock_id].control_reg;
-
- for (i = 0; i < num_nodes; i++) {
- if (nodes->type == TYPE_GATE) {
- offset = nodes->offset;
- width = nodes->width;
- break;
- }
- nodes++;
- }
- if (width == NA_WIDTH)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- ret = pm_mmio_read(reg, &val);
- if (ret != PM_RET_SUCCESS)
- return ret;
- if ((val & BIT_MASK(offset, width)) == enable)
+ if (pll) {
+ *node_id = pll->nid;
return PM_RET_SUCCESS;
-
- if (enable == 0)
- val &= ~(BIT_MASK(offset, width));
- else
- val |= BIT_MASK(offset, width);
-
- ret = pm_mmio_write(reg, BIT_MASK(offset, width), val);
-
- return ret;
-}
-
-/**
- * pm_api_clock_enable() - Enable the clock for given id
- * @clock_id: Id of the clock to be enabled
- *
- * This function is used by master to enable the clock
- * including peripherals and PLL clocks.
- *
- * Return: Returns status, either success or error+reason.
- */
-enum pm_ret_status pm_api_clock_enable(unsigned int clock_id)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
-
- if (!pm_clock_valid(clock_id))
- return PM_RET_ERROR_ARGS;
-
- if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- /*
- * PLL type clock should not enable explicitly.
- * It is done by FSBL on boot-up and by PMUFW whenever required.
- */
- if (!ISPLL(clock_id))
- ret = pm_api_clk_enable_disable(clock_id, 1);
-
- return ret;
-}
-
-/**
- * pm_api_clock_disable - Disable the clock for given id
- * @clock_id Id of the clock to be disable
- *
- * This function is used by master to disable the clock
- * including peripherals and PLL clocks.
- *
- * Return: Returns status, either success or error+reason.
- */
-
-enum pm_ret_status pm_api_clock_disable(unsigned int clock_id)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
-
- if (!pm_clock_valid(clock_id))
- return PM_RET_ERROR_ARGS;
-
- if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- /*
- * PLL type clock should not be disabled explicitly.
- * It is done by PMUFW if required.
- */
- if (!ISPLL(clock_id))
- ret = pm_api_clk_enable_disable(clock_id, 0);
-
- return ret;
-}
-
-/**
- * pm_api_get_pll_state() - Get state of PLL
- * @clock_id Id of the PLL
- * @state State of PLL(1: Enable, 0: Reset)
- *
- * This function is to check state of PLL.
- */
-static inline enum pm_ret_status pm_api_get_pll_state(unsigned int clock_id,
- unsigned int *state)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- unsigned int reg, val;
-
- reg = clocks[clock_id].control_reg;
-
- ret = pm_mmio_read(reg, &val);
-
- /* state:
- * 1 - PLL is enabled
- * 0 - PLL is in reset state
- */
- *state = !(val & PLLCTRL_RESET_MASK);
- return ret;
-}
-
-/**
- * pm_api_get_clk_state() - Get the state of clock for given id
- * @clock_id: Id of the clock to be enabled
- * @state: Enable(1)/Disable(0)
- *
- * This function is to get state of the clock which is not PLL.
- *
- * Return: Returns status, either success or error+reason.
- */
-static enum pm_ret_status pm_api_get_clk_state(unsigned int clock_id,
- unsigned int *state)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- struct pm_clock_node *nodes = *clocks[clock_id].nodes;
- uint8_t num_nodes = clocks[clock_id].num_nodes;
- unsigned int reg, val;
- uint8_t i = 0;
- uint8_t offset = NA_SHIFT, width = NA_WIDTH;
-
- reg = clocks[clock_id].control_reg;
-
- for (i = 0; i < num_nodes; i++) {
- if (nodes->type == TYPE_GATE) {
- offset = nodes->offset;
- width = nodes->width;
- }
- nodes++;
}
- if (width == NA_WIDTH)
- return PM_RET_ERROR_NOTSUPPORTED;
- ret = pm_mmio_read(reg, &val);
- *state = (val & BIT_MASK(offset, width)) >> offset;
-
- return ret;
+ return PM_RET_ERROR_ARGS;
}
/**
- * pm_api_clock_getstate - Get the clock state for given id
- * @clock_id Id of the clock to be queried
- * @state 1/0 (Enabled/Disabled)
+ * pm_clock_get_pll_by_related_clk() - Get PLL structure by PLL-related clock ID
+ * @clock_id Clock ID
*
- * This function is used by master to get the state of clock
- * including peripherals and PLL clocks.
+ * @return Pointer to PLL structure if found, NULL otherwise
+ */
+struct pm_pll *pm_clock_get_pll_by_related_clk(enum clock_id clock_id)
+{
+ uint32_t i;
+
+ for (i = 0; i < ARRAY_SIZE(pm_plls); i++) {
+ if (pm_plls[i].pre_src == clock_id ||
+ pm_plls[i].post_src == clock_id ||
+ pm_plls[i].div2 == clock_id ||
+ pm_plls[i].bypass == clock_id) {
+ return &pm_plls[i];
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * pm_clock_pll_enable() - "Enable" the PLL clock (lock the PLL)
+ * @pll: PLL to be locked
+ *
+ * This function is used to map IOCTL/linux-based PLL handling to system-level
+ * EEMI APIs
+ *
+ * Return: Error if the argument is not valid or status as returned by PMU
+ */
+enum pm_ret_status pm_clock_pll_enable(struct pm_pll *pll)
+{
+ if (!pll)
+ return PM_RET_ERROR_ARGS;
+
+ /* Set the PLL mode according to the buffered mode value */
+ if (pll->mode == PLL_FRAC_MODE)
+ return pm_pll_set_mode(pll->nid, PM_PLL_MODE_FRACTIONAL);
+
+ return pm_pll_set_mode(pll->nid, PM_PLL_MODE_INTEGER);
+}
+
+/**
+ * pm_clock_pll_disable - "Disable" the PLL clock (bypass/reset the PLL)
+ * @pll PLL to be bypassed/reset
+ *
+ * This function is used to map IOCTL/linux-based PLL handling to system-level
+ * EEMI APIs
+ *
+ * Return: Error if the argument is not valid or status as returned by PMU
+ */
+enum pm_ret_status pm_clock_pll_disable(struct pm_pll *pll)
+{
+ if (!pll)
+ return PM_RET_ERROR_ARGS;
+
+ return pm_pll_set_mode(pll->nid, PM_PLL_MODE_RESET);
+}
+
+/**
+ * pm_clock_pll_get_state - Get state of the PLL
+ * @pll Pointer to the target PLL structure
+ * @state Location to store the state: 1/0 ("Enabled"/"Disabled")
+ *
+ * "Enable" actually means that the PLL is locked and its bypass is deasserted,
+ * "Disable" means that it is bypassed.
+ *
+ * Return: PM_RET_ERROR_ARGS error if the argument is not valid, success if
+ * returned state value is valid or an error if returned by PMU
+ */
+enum pm_ret_status pm_clock_pll_get_state(struct pm_pll *pll,
+ unsigned int *state)
+{
+ enum pm_ret_status status;
+ enum pm_pll_mode mode;
+
+ if (!pll || !state)
+ return PM_RET_ERROR_ARGS;
+
+ status = pm_pll_get_mode(pll->nid, &mode);
+ if (status != PM_RET_SUCCESS)
+ return status;
+
+ if (mode == PM_PLL_MODE_RESET)
+ *state = 0;
+ else
+ *state = 1;
+
+ return PM_RET_SUCCESS;
+}
+
+/**
+ * pm_clock_pll_set_parent - Set the clock parent for PLL-related clock id
+ * @pll Target PLL structure
+ * @clock_id Id of the clock
+ * @parent_index parent index (=mux select value)
+ *
+ * The whole clock-tree implementation relies on the fact that parent indexes
+ * match to the multiplexer select values. This function has to rely on that
+ * assumption as well => parent_index is actually the mux select value.
*
* Return: Returns status, either success or error+reason.
*/
-enum pm_ret_status pm_api_clock_getstate(unsigned int clock_id,
- unsigned int *state)
+enum pm_ret_status pm_clock_pll_set_parent(struct pm_pll *pll,
+ enum clock_id clock_id,
+ unsigned int parent_index)
{
- enum pm_ret_status ret = PM_RET_SUCCESS;
+ if (!pll)
+ return PM_RET_ERROR_ARGS;
+ if (pll->pre_src == clock_id)
+ return pm_pll_set_parameter(pll->nid, PM_PLL_PARAM_PRE_SRC,
+ parent_index);
+ if (pll->post_src == clock_id)
+ return pm_pll_set_parameter(pll->nid, PM_PLL_PARAM_POST_SRC,
+ parent_index);
+ if (pll->div2 == clock_id)
+ return pm_pll_set_parameter(pll->nid, PM_PLL_PARAM_DIV2,
+ parent_index);
+ return PM_RET_ERROR_ARGS;
+}
+
+/**
+ * pm_clock_pll_get_parent - Get mux select value of PLL-related clock parent
+ * @pll Target PLL structure
+ * @clock_id Id of the clock
+ * @parent_index parent index (=mux select value)
+ *
+ * This function is used by master to get parent index for PLL-related clock.
+ *
+ * Return: Returns status, either success or error+reason.
+ */
+enum pm_ret_status pm_clock_pll_get_parent(struct pm_pll *pll,
+ enum clock_id clock_id,
+ unsigned int *parent_index)
+{
+ if (!pll)
+ return PM_RET_ERROR_ARGS;
+ if (pll->pre_src == clock_id)
+ return pm_pll_get_parameter(pll->nid, PM_PLL_PARAM_PRE_SRC,
+ parent_index);
+ if (pll->post_src == clock_id)
+ return pm_pll_get_parameter(pll->nid, PM_PLL_PARAM_POST_SRC,
+ parent_index);
+ if (pll->div2 == clock_id)
+ return pm_pll_get_parameter(pll->nid, PM_PLL_PARAM_DIV2,
+ parent_index);
+ if (pll->bypass == clock_id) {
+ *parent_index = 0;
+ return PM_RET_SUCCESS;
+ }
+
+ return PM_RET_ERROR_ARGS;
+}
+
+/**
+ * pm_clock_set_pll_mode() - Set PLL mode
+ * @clock_id PLL clock id
+ * @mode Mode fractional/integer
+ *
+ * This function buffers/saves the PLL mode that is set.
+ *
+ * @return Success if mode is buffered or error if an argument is invalid
+ */
+enum pm_ret_status pm_clock_set_pll_mode(enum clock_id clock_id,
+ unsigned int mode)
+{
+ struct pm_pll *pll = pm_clock_get_pll(clock_id);
+
+ if (!pll || (mode != PLL_FRAC_MODE && mode != PLL_INT_MODE))
+ return PM_RET_ERROR_ARGS;
+ pll->mode = mode;
+
+ return PM_RET_SUCCESS;
+}
+
+/**
+ * pm_clock_get_pll_mode() - Get PLL mode
+ * @clock_id PLL clock id
+ * @mode Location to store the mode (fractional/integer)
+ *
+ * This function returns buffered PLL mode.
+ *
+ * @return Success if mode is stored or error if an argument is invalid
+ */
+enum pm_ret_status pm_clock_get_pll_mode(enum clock_id clock_id,
+ unsigned int *mode)
+{
+ struct pm_pll *pll = pm_clock_get_pll(clock_id);
+
+ if (!pll || !mode)
+ return PM_RET_ERROR_ARGS;
+ *mode = pll->mode;
+
+ return PM_RET_SUCCESS;
+}
+
+/**
+ * pm_clock_id_is_valid() - Check if given clock ID is valid
+ * @clock_id ID of the clock to be checked
+ *
+ * @return Returns success if clock_id is valid, otherwise an error
+ */
+enum pm_ret_status pm_clock_id_is_valid(unsigned int clock_id)
+{
if (!pm_clock_valid(clock_id))
return PM_RET_ERROR_ARGS;
if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
return PM_RET_ERROR_NOTSUPPORTED;
- if (ISPLL(clock_id))
- ret = pm_api_get_pll_state(clock_id, state);
- else
- ret = pm_api_get_clk_state(clock_id, state);
-
- return ret;
+ return PM_RET_SUCCESS;
}
-static enum pm_ret_status pm_api_clk_set_divider(unsigned int clock_id,
- uint32_t divider)
+/**
+ * pm_clock_has_div() - Check if the clock has divider with given ID
+ * @clock_id Clock ID
+ * @div_id Divider ID
+ *
+ * @return True(1)=clock has the divider, false(0)=otherwise
+ */
+uint8_t pm_clock_has_div(unsigned int clock_id, enum pm_clock_div_id div_id)
{
- enum pm_ret_status ret = PM_RET_SUCCESS;
+ uint32_t i;
struct pm_clock_node *nodes;
- uint8_t num_nodes;
- uint16_t div1, div2;
- unsigned int reg, mask = 0, val = 0, i;
- uint8_t div1_width = NA_WIDTH, div1_offset = NA_SHIFT;
- uint8_t div2_width = NA_WIDTH, div2_offset = NA_SHIFT;
- div1 = (uint16_t)(divider & 0xFFFFU);
- div2 = (uint16_t)((divider >> 16) & 0xFFFFU);
-
- reg = clocks[clock_id].control_reg;
+ if (clock_id >= CLK_MAX_OUTPUT_CLK)
+ return 0;
nodes = *clocks[clock_id].nodes;
- num_nodes = clocks[clock_id].num_nodes;
- for (i = 0; i < num_nodes; i++) {
- if (nodes->type == TYPE_DIV1) {
- div1_offset = nodes->offset;
- div1_width = nodes->width;
+ for (i = 0; i < clocks[clock_id].num_nodes; i++) {
+ if (nodes[i].type == TYPE_DIV1) {
+ if (div_id == PM_CLOCK_DIV0_ID)
+ return 1;
+ } else if (nodes[i].type == TYPE_DIV2) {
+ if (div_id == PM_CLOCK_DIV1_ID)
+ return 1;
}
- if (nodes->type == TYPE_DIV2) {
- div2_offset = nodes->offset;
- div2_width = nodes->width;
- }
- nodes++;
}
- if (div1 != (uint16_t)-1) {
- if (div1_width == NA_WIDTH)
- return PM_RET_ERROR_NOTSUPPORTED;
- val |= div1 << div1_offset;
- mask |= BIT_MASK(div1_offset, div1_width);
- }
- if (div2 != (uint16_t)-1) {
- if (div2_width == NA_WIDTH)
- return PM_RET_ERROR_NOTSUPPORTED;
- val |= div2 << div2_offset;
- mask |= BIT_MASK(div2_offset, div2_width);
- }
- ret = pm_mmio_write(reg, mask, val);
-
- return ret;
-}
-
-static enum pm_ret_status pm_api_pll_set_divider(unsigned int clock_id,
- unsigned int divider)
-{
- unsigned int reg = clocks[clock_id].control_reg;
- enum pm_ret_status ret;
-
- pm_api_pll_bypass_and_reset(clock_id, CLK_PLL_RESET_ASSERT);
- ret = pm_mmio_write(reg, PLL_FBDIV_MASK, divider << PLL_FBDIV_SHIFT);
- pm_api_pll_bypass_and_reset(clock_id, CLK_PLL_RESET_RELEASE);
-
- return ret;
-}
-
-/**
- * pm_api_clock_setdivider - Set the clock divider for given id
- * @clock_id Id of the clock
- * @divider Divider value
- *
- * This function is used by master to set divider for any clock
- * to achieve desired rate.
- *
- * Return: Returns status, either success or error+reason.
- */
-enum pm_ret_status pm_api_clock_setdivider(unsigned int clock_id,
- unsigned int divider)
-{
- enum pm_ret_status ret;
-
- if (!pm_clock_valid(clock_id))
- return PM_RET_ERROR_ARGS;
-
- if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- if (ISPLL(clock_id))
- ret = pm_api_pll_set_divider(clock_id, divider);
- else
- ret = pm_api_clk_set_divider(clock_id, divider);
-
- return ret;
-}
-
-static enum pm_ret_status pm_api_clk_get_divider(unsigned int clock_id,
- uint32_t *divider)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- struct pm_clock_node *nodes;
- uint8_t num_nodes;
- unsigned int reg, val, i, div1 = 0, div2 = 0;
- uint8_t div1_width = NA_WIDTH, div1_offset = NA_SHIFT;
- uint8_t div2_width = NA_WIDTH, div2_offset = NA_SHIFT;
-
- reg = clocks[clock_id].control_reg;
-
- nodes = *clocks[clock_id].nodes;
- num_nodes = clocks[clock_id].num_nodes;
- for (i = 0; i < num_nodes; i++) {
- if (nodes->type == TYPE_DIV1) {
- div1_offset = nodes->offset;
- div1_width = nodes->width;
- }
- if (nodes->type == TYPE_DIV2) {
- div2_offset = nodes->offset;
- div2_width = nodes->width;
- }
- nodes++;
- }
-
- ret = pm_mmio_read(reg, &val);
-
- if (div1_width == NA_WIDTH)
- return PM_RET_ERROR_ARGS;
-
- div1 = (val & BIT_MASK(div1_offset, div1_width)) >> div1_offset;
-
- if (div2_width != NA_WIDTH)
- div2 = (val & BIT_MASK(div2_offset, div2_width)) >> div2_offset;
-
- *divider = div1 | (div2 << 16);
-
- return ret;
-}
-
-static enum pm_ret_status pm_api_pll_get_divider(unsigned int clock_id,
- unsigned int *divider)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- unsigned int reg, val;
-
- reg = clocks[clock_id].control_reg;
-
- ret = pm_mmio_read(reg, &val);
- *divider = (val & PLL_FBDIV_MASK) >> PLL_FBDIV_SHIFT;
-
- return ret;
-}
-
-/**
- * pm_api_clock_getdivider - Get the clock divider for given id
- * @clock_id Id of the clock
- * @divider Divider value
- *
- * This function is used by master to get divider values
- * for any clock.
- *
- * Return: Returns status, either success or error+reason.
- */
-enum pm_ret_status pm_api_clock_getdivider(unsigned int clock_id,
- unsigned int *divider)
-{
- enum pm_ret_status ret;
-
- if (!pm_clock_valid(clock_id))
- return PM_RET_ERROR_ARGS;
-
- if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- if (ISPLL(clock_id))
- ret = pm_api_pll_get_divider(clock_id, divider);
- else
- ret = pm_api_clk_get_divider(clock_id, divider);
-
- return ret;
-}
-
-/**
- * pm_api_clock_setrate - Set the clock rate for given id
- * @clock_id Id of the clock
- * @rate Rate value in hz
- *
- * This function is used by master to set rate for any clock.
- *
- * Return: Returns status, either success or error+reason.
- */
-enum pm_ret_status pm_api_clock_setrate(unsigned int clock_id,
- uint64_t rate)
-{
- return PM_RET_ERROR_NOTSUPPORTED;
-}
-
-/**
- * pm_api_clock_getrate - Get the clock rate for given id
- * @clock_id Id of the clock
- * @rate rate value in hz
- *
- * This function is used by master to get rate
- * for any clock.
- *
- * Return: Returns status, either success or error+reason.
- */
-enum pm_ret_status pm_api_clock_getrate(unsigned int clock_id,
- uint64_t *rate)
-{
- return PM_RET_ERROR_NOTSUPPORTED;
-}
-
-/**
- * pm_api_clock_setparent - Set the clock parent for given id
- * @clock_id Id of the clock
- * @parent_idx parent index
- *
- * This function is used by master to set parent for any clock.
- *
- * Return: Returns status, either success or error+reason.
- */
-enum pm_ret_status pm_api_clock_setparent(unsigned int clock_id,
- unsigned int parent_idx)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- struct pm_clock_node *nodes;
- uint8_t num_nodes;
- unsigned int reg, val;
- int32_t *clk_parents;
- unsigned int i = 0;
- uint8_t offset = NA_SHIFT, width = NA_WIDTH;
-
- if (!pm_clock_valid(clock_id))
- return PM_RET_ERROR_ARGS;
-
- if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- clk_parents = *clocks[clock_id].parents;
-
- for (i = 0; i <= parent_idx; i++)
- if (clk_parents[i] == CLK_NA_PARENT)
- return PM_RET_ERROR_ARGS;
-
- nodes = *clocks[clock_id].nodes;
- num_nodes = clocks[clock_id].num_nodes;
- for (i = 0; i < num_nodes; i++) {
- if (nodes->type == TYPE_MUX) {
- offset = nodes->offset;
- width = nodes->width;
- }
- nodes++;
- }
- if (width == NA_WIDTH)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- reg = clocks[clock_id].control_reg;
- val = parent_idx << offset;
- ret = pm_mmio_write(reg, BIT_MASK(offset, width), val);
-
- return ret;
-}
-
-/**
- * pm_api_clock_getparent - Get the clock parent for given id
- * @clock_id Id of the clock
- * @parent_idx parent index
- *
- * This function is used by master to get parent index
- * for any clock.
- *
- * Return: Returns status, either success or error+reason.
- */
-enum pm_ret_status pm_api_clock_getparent(unsigned int clock_id,
- unsigned int *parent_idx)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- struct pm_clock_node *nodes;
- uint8_t num_nodes;
- unsigned int reg, val;
- uint8_t i = 0, offset = NA_SHIFT, width = NA_WIDTH;
-
- if (!pm_clock_valid(clock_id))
- return PM_RET_ERROR_ARGS;
-
- if (pm_clock_type(clock_id) != CLK_TYPE_OUTPUT)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- nodes = *clocks[clock_id].nodes;
- num_nodes = clocks[clock_id].num_nodes;
-
- for (i = 0; i < num_nodes; i++) {
- if (nodes->type == TYPE_MUX) {
- offset = nodes->offset;
- width = nodes->width;
- }
- nodes++;
- }
- if (width == NA_WIDTH)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- reg = clocks[clock_id].control_reg;
- ret = pm_mmio_read(reg, &val);
- val >>= offset;
- val &= ((1U << width) - 1);
-
- *parent_idx = val;
-
- return ret;
-}
-
-/**
- * pm_api_clk_set_pll_mode() - Set PLL mode
- * @pll PLL id
- * @mode Mode fraction/integar
- *
- * This function sets PLL mode.
- *
- * @return Returns status, either success or error+reason
- */
-enum pm_ret_status pm_api_clk_set_pll_mode(unsigned int pll,
- unsigned int mode)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- unsigned int reg;
-
- if (!pm_clock_valid(pll))
- return PM_RET_ERROR_ARGS;
-
- if (pm_clock_type(pll) != CLK_TYPE_OUTPUT)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- if (!ISPLL(pll))
- return PM_RET_ERROR_NOTSUPPORTED;
-
- if (mode != PLL_FRAC_MODE && mode != PLL_INT_MODE)
- return PM_RET_ERROR_ARGS;
-
- reg = clocks[pll].control_reg + PLL_FRAC_OFFSET;
-
- ret = pm_mmio_write(reg, PLL_FRAC_MODE_MASK,
- mode << PLL_FRAC_MODE_SHIFT);
-
- return ret;
-}
-
-/**
- * pm_ioctl_get_pll_mode() - Get PLL mode
- * @pll PLL id
- * @mode Mode fraction/integar
- *
- * This function returns current PLL mode.
- *
- * @return Returns status, either success or error+reason
- */
-enum pm_ret_status pm_api_clk_get_pll_mode(unsigned int pll,
- unsigned int *mode)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- unsigned int val, reg;
-
- if (!pm_clock_valid(pll))
- return PM_RET_ERROR_ARGS;
-
- if (pm_clock_type(pll) != CLK_TYPE_OUTPUT)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- if (!ISPLL(pll))
- return PM_RET_ERROR_NOTSUPPORTED;
-
- reg = clocks[pll].control_reg + PLL_FRAC_OFFSET;
-
- ret = pm_mmio_read(reg, &val);
- val = val & PLL_FRAC_MODE_MASK;
- if (val == 0)
- *mode = PLL_INT_MODE;
- else
- *mode = PLL_FRAC_MODE;
-
- return ret;
-}
-
-/**
- * pm_api_clk_set_pll_frac_data() - Set PLL fraction data
- * @pll PLL id
- * @data fraction data
- *
- * This function sets fraction data. It is valid for fraction
- * mode only.
- *
- * @return Returns status, either success or error+reason
- */
-enum pm_ret_status pm_api_clk_set_pll_frac_data(unsigned int pll,
- unsigned int data)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- unsigned int val, reg, mode = 0;
-
- if (!pm_clock_valid(pll))
- return PM_RET_ERROR_ARGS;
-
- if (pm_clock_type(pll) != CLK_TYPE_OUTPUT)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- if (!ISPLL(pll))
- return PM_RET_ERROR_NOTSUPPORTED;
-
- ret = pm_api_clk_get_pll_mode(pll, &mode);
- if (ret != PM_RET_SUCCESS)
- return ret;
- if (mode == PLL_FRAC_MODE) {
- reg = clocks[pll].control_reg + PLL_FRAC_OFFSET;
- val = data << PLL_FRAC_DATA_SHIFT;
- ret = pm_mmio_write(reg, PLL_FRAC_DATA_MASK, val);
- } else {
- return PM_RET_ERROR_ARGS;
- }
-
- return ret;
-}
-
-/**
- * pm_api_clk_get_pll_frac_data() - Get PLL fraction data
- * @pll PLL id
- * @data fraction data
- *
- * This function returns fraction data value.
- *
- * @return Returns status, either success or error+reason
- */
-enum pm_ret_status pm_api_clk_get_pll_frac_data(unsigned int pll,
- unsigned int *data)
-{
- enum pm_ret_status ret = PM_RET_SUCCESS;
- unsigned int val, reg;
-
- if (!pm_clock_valid(pll))
- return PM_RET_ERROR_ARGS;
-
- if (pm_clock_type(pll) != CLK_TYPE_OUTPUT)
- return PM_RET_ERROR_NOTSUPPORTED;
-
- if (!ISPLL(pll))
- return PM_RET_ERROR_NOTSUPPORTED;
-
- reg = clocks[pll].control_reg + PLL_FRAC_OFFSET;
-
- ret = pm_mmio_read(reg, &val);
- *data = (val & PLL_FRAC_DATA_MASK);
-
- return ret;
+ return 0;
}
diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_clock.h b/plat/xilinx/zynqmp/pm_service/pm_api_clock.h
index f7cbdba..9717ca8 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_api_clock.h
+++ b/plat/xilinx/zynqmp/pm_service/pm_api_clock.h
@@ -11,7 +11,8 @@
#ifndef PM_API_CLOCK_H
#define PM_API_CLOCK_H
-#include <utils_def.h>
+#include <lib/utils_def.h>
+
#include "pm_common.h"
#define CLK_NAME_LEN U(15)
@@ -55,7 +56,7 @@
#define END_OF_CLK "END_OF_CLK"
//CLock Ids
-enum {
+enum clock_id {
CLK_IOPLL,
CLK_RPLL,
CLK_APLL,
@@ -159,6 +160,7 @@
CLK_VPLL_POST_SRC,
CLK_CAN0_MIO,
CLK_CAN1_MIO,
+ CLK_ACPU_FULL,
END_OF_OUTPUT_CLKS,
};
@@ -274,6 +276,10 @@
#define TYPE_DIV2 5U
#define TYPE_GATE 6U
+struct pm_pll;
+struct pm_pll *pm_clock_get_pll(enum clock_id clock_id);
+struct pm_pll *pm_clock_get_pll_by_related_clk(enum clock_id clock_id);
+uint8_t pm_clock_has_div(unsigned int clock_id, enum pm_clock_div_id div_id);
enum pm_ret_status pm_api_clock_get_name(unsigned int clock_id, char *name);
enum pm_ret_status pm_api_clock_get_num_clocks(unsigned int *nclocks);
@@ -288,29 +294,24 @@
uint32_t *parents);
enum pm_ret_status pm_api_clock_get_attributes(unsigned int clock_id,
uint32_t *attr);
-enum pm_ret_status pm_api_clock_enable(unsigned int clock_id);
-enum pm_ret_status pm_api_clock_disable(unsigned int clock_id);
-enum pm_ret_status pm_api_clock_getstate(unsigned int clock_id,
- unsigned int *state);
-enum pm_ret_status pm_api_clock_setdivider(unsigned int clock_id,
- unsigned int divider);
-enum pm_ret_status pm_api_clock_getdivider(unsigned int clock_id,
- unsigned int *divider);
-enum pm_ret_status pm_api_clock_setrate(unsigned int clock_id,
- uint64_t rate);
-enum pm_ret_status pm_api_clock_getrate(unsigned int clock_id,
- uint64_t *rate);
-enum pm_ret_status pm_api_clock_setparent(unsigned int clock_id,
- unsigned int parent_idx);
-enum pm_ret_status pm_api_clock_getparent(unsigned int clock_id,
- unsigned int *parent_idx);
-enum pm_ret_status pm_api_clk_set_pll_mode(unsigned int pll,
- unsigned int mode);
-enum pm_ret_status pm_api_clk_get_pll_mode(unsigned int pll,
- unsigned int *mode);
-enum pm_ret_status pm_api_clk_set_pll_frac_data(unsigned int pll,
- unsigned int data);
-enum pm_ret_status pm_api_clk_get_pll_frac_data(unsigned int pll,
- unsigned int *data);
+
+enum pm_ret_status pm_clock_get_pll_node_id(enum clock_id clock_id,
+ enum pm_node_id *node_id);
+enum pm_ret_status pm_clock_id_is_valid(unsigned int clock_id);
+
+enum pm_ret_status pm_clock_pll_enable(struct pm_pll *pll);
+enum pm_ret_status pm_clock_pll_disable(struct pm_pll *pll);
+enum pm_ret_status pm_clock_pll_get_state(struct pm_pll *pll,
+ unsigned int *state);
+enum pm_ret_status pm_clock_pll_set_parent(struct pm_pll *pll,
+ enum clock_id clock_id,
+ unsigned int parent_index);
+enum pm_ret_status pm_clock_pll_get_parent(struct pm_pll *pll,
+ enum clock_id clock_id,
+ unsigned int *parent_index);
+enum pm_ret_status pm_clock_set_pll_mode(enum clock_id clock_id,
+ unsigned int mode);
+enum pm_ret_status pm_clock_get_pll_mode(enum clock_id clock_id,
+ unsigned int *mode);
#endif /* PM_API_CLOCK_H */
diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c b/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c
index 16c08ae..d3f1fbf 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c
+++ b/plat/xilinx/zynqmp/pm_service/pm_api_ioctl.c
@@ -9,9 +9,10 @@
*/
#include <arch_helpers.h>
-#include <delay_timer.h>
-#include <mmio.h>
-#include <platform.h>
+#include <drivers/delay_timer.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include "pm_api_clock.h"
#include "pm_api_ioctl.h"
#include "pm_api_sys.h"
@@ -332,7 +333,7 @@
/**
* pm_ioctl_set_pll_frac_mode() - Ioctl function for
* setting pll mode
- * @pll PLL id
+ * @pll PLL clock id
* @mode Mode fraction/integar
*
* This function sets PLL mode
@@ -342,13 +343,13 @@
static enum pm_ret_status pm_ioctl_set_pll_frac_mode
(unsigned int pll, unsigned int mode)
{
- return pm_api_clk_set_pll_mode(pll, mode);
+ return pm_clock_set_pll_mode(pll, mode);
}
/**
* pm_ioctl_get_pll_frac_mode() - Ioctl function for
* getting pll mode
- * @pll PLL id
+ * @pll PLL clock id
* @mode Mode fraction/integar
*
* This function return current PLL mode
@@ -358,13 +359,13 @@
static enum pm_ret_status pm_ioctl_get_pll_frac_mode
(unsigned int pll, unsigned int *mode)
{
- return pm_api_clk_get_pll_mode(pll, mode);
+ return pm_clock_get_pll_mode(pll, mode);
}
/**
* pm_ioctl_set_pll_frac_data() - Ioctl function for
* setting pll fraction data
- * @pll PLL id
+ * @pll PLL clock id
* @data fraction data
*
* This function sets fraction data.
@@ -375,13 +376,21 @@
static enum pm_ret_status pm_ioctl_set_pll_frac_data
(unsigned int pll, unsigned int data)
{
- return pm_api_clk_set_pll_frac_data(pll, data);
+ enum pm_node_id pll_nid;
+ enum pm_ret_status status;
+
+ /* Get PLL node ID using PLL clock ID */
+ status = pm_clock_get_pll_node_id(pll, &pll_nid);
+ if (status != PM_RET_SUCCESS)
+ return status;
+
+ return pm_pll_set_parameter(pll_nid, PM_PLL_PARAM_DATA, data);
}
/**
* pm_ioctl_get_pll_frac_data() - Ioctl function for
* getting pll fraction data
- * @pll PLL id
+ * @pll PLL clock id
* @data fraction data
*
* This function returns fraction data value.
@@ -391,7 +400,15 @@
static enum pm_ret_status pm_ioctl_get_pll_frac_data
(unsigned int pll, unsigned int *data)
{
- return pm_api_clk_get_pll_frac_data(pll, data);
+ enum pm_node_id pll_nid;
+ enum pm_ret_status status;
+
+ /* Get PLL node ID using PLL clock ID */
+ status = pm_clock_get_pll_node_id(pll, &pll_nid);
+ if (status != PM_RET_SUCCESS)
+ return status;
+
+ return pm_pll_get_parameter(pll_nid, PM_PLL_PARAM_DATA, data);
}
/**
diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_pinctrl.c b/plat/xilinx/zynqmp/pm_service/pm_api_pinctrl.c
index 12b9c2d..a900057 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_api_pinctrl.c
+++ b/plat/xilinx/zynqmp/pm_service/pm_api_pinctrl.c
@@ -8,9 +8,11 @@
* ZynqMP system level PM-API functions for pin control.
*/
-#include <arch_helpers.h>
-#include <platform.h>
#include <string.h>
+
+#include <arch_helpers.h>
+#include <plat/common/platform.h>
+
#include "pm_api_pinctrl.h"
#include "pm_api_sys.h"
#include "pm_client.h"
diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_sys.c b/plat/xilinx/zynqmp/pm_service/pm_api_sys.c
index e85b2ce..f651880 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_api_sys.c
+++ b/plat/xilinx/zynqmp/pm_service/pm_api_sys.c
@@ -10,7 +10,8 @@
*/
#include <arch_helpers.h>
-#include <platform.h>
+#include <plat/common/platform.h>
+
#include "pm_api_clock.h"
#include "pm_api_ioctl.h"
#include "pm_api_pinctrl.h"
@@ -844,18 +845,56 @@
}
/**
+ * pm_clock_gate() - Configure clock gate
+ * @clock_id Id of the clock to be configured
+ * @enable Flag 0=disable (gate the clock), !0=enable (activate the clock)
+ *
+ * @return Error if an argument is not valid or status as returned by the
+ * PM controller (PMU)
+ */
+static enum pm_ret_status pm_clock_gate(unsigned int clock_id,
+ unsigned char enable)
+{
+ uint32_t payload[PAYLOAD_ARG_CNT];
+ enum pm_ret_status status;
+ enum pm_api_id api_id;
+
+ /* Check if clock ID is valid and return an error if it is not */
+ status = pm_clock_id_is_valid(clock_id);
+ if (status != PM_RET_SUCCESS)
+ return status;
+
+ if (enable)
+ api_id = PM_CLOCK_ENABLE;
+ else
+ api_id = PM_CLOCK_DISABLE;
+
+ /* Send request to the PMU */
+ PM_PACK_PAYLOAD2(payload, api_id, clock_id);
+ return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
+}
+
+/**
* pm_clock_enable() - Enable the clock for given id
* @clock_id: Id of the clock to be enabled
*
* This function is used by master to enable the clock
* including peripherals and PLL clocks.
*
- * Return: Returns status, either success or error+reason.
+ * @return: Error if an argument is not valid or status as returned by the
+ * pm_clock_gate
*/
-
enum pm_ret_status pm_clock_enable(unsigned int clock_id)
{
- return pm_api_clock_enable(clock_id);
+ struct pm_pll *pll;
+
+ /* First try to handle it as a PLL */
+ pll = pm_clock_get_pll(clock_id);
+ if (pll)
+ return pm_clock_pll_enable(pll);
+
+ /* It's an on-chip clock, PMU should configure clock's gate */
+ return pm_clock_gate(clock_id, 1);
}
/**
@@ -865,12 +904,20 @@
* This function is used by master to disable the clock
* including peripherals and PLL clocks.
*
- * Return: Returns status, either success or error+reason.
+ * @return: Error if an argument is not valid or status as returned by the
+ * pm_clock_gate
*/
-
enum pm_ret_status pm_clock_disable(unsigned int clock_id)
{
- return pm_api_clock_disable(clock_id);
+ struct pm_pll *pll;
+
+ /* First try to handle it as a PLL */
+ pll = pm_clock_get_pll(clock_id);
+ if (pll)
+ return pm_clock_pll_disable(pll);
+
+ /* It's an on-chip clock, PMU should configure clock's gate */
+ return pm_clock_gate(clock_id, 0);
}
/**
@@ -886,7 +933,23 @@
enum pm_ret_status pm_clock_getstate(unsigned int clock_id,
unsigned int *state)
{
- return pm_api_clock_getstate(clock_id, state);
+ struct pm_pll *pll;
+ uint32_t payload[PAYLOAD_ARG_CNT];
+ enum pm_ret_status status;
+
+ /* First try to handle it as a PLL */
+ pll = pm_clock_get_pll(clock_id);
+ if (pll)
+ return pm_clock_pll_get_state(pll, state);
+
+ /* Check if clock ID is a valid on-chip clock */
+ status = pm_clock_id_is_valid(clock_id);
+ if (status != PM_RET_SUCCESS)
+ return status;
+
+ /* Send request to the PMU */
+ PM_PACK_PAYLOAD2(payload, PM_CLOCK_GETSTATE, clock_id);
+ return pm_ipi_send_sync(primary_proc, payload, state, 1);
}
/**
@@ -902,7 +965,37 @@
enum pm_ret_status pm_clock_setdivider(unsigned int clock_id,
unsigned int divider)
{
- return pm_api_clock_setdivider(clock_id, divider);
+ enum pm_ret_status status;
+ enum pm_node_id nid;
+ enum pm_clock_div_id div_id;
+ uint32_t payload[PAYLOAD_ARG_CNT];
+ const uint32_t div0 = 0xFFFF0000;
+ const uint32_t div1 = 0x0000FFFF;
+ uint32_t val;
+
+ /* Get PLL node ID using PLL clock ID */
+ status = pm_clock_get_pll_node_id(clock_id, &nid);
+ if (status == PM_RET_SUCCESS)
+ return pm_pll_set_parameter(nid, PM_PLL_PARAM_FBDIV, divider);
+
+ /* Check if clock ID is a valid on-chip clock */
+ status = pm_clock_id_is_valid(clock_id);
+ if (status != PM_RET_SUCCESS)
+ return status;
+
+ if (div0 == (divider & div0)) {
+ div_id = PM_CLOCK_DIV0_ID;
+ val = divider & ~div0;
+ } else if (div1 == (divider & div1)) {
+ div_id = PM_CLOCK_DIV1_ID;
+ val = (divider & ~div1) >> 16;
+ } else {
+ return PM_RET_ERROR_ARGS;
+ }
+
+ /* Send request to the PMU */
+ PM_PACK_PAYLOAD4(payload, PM_CLOCK_SETDIVIDER, clock_id, div_id, val);
+ return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
}
/**
@@ -918,7 +1011,42 @@
enum pm_ret_status pm_clock_getdivider(unsigned int clock_id,
unsigned int *divider)
{
- return pm_api_clock_getdivider(clock_id, divider);
+ enum pm_ret_status status;
+ enum pm_node_id nid;
+ uint32_t payload[PAYLOAD_ARG_CNT];
+ uint32_t val;
+
+ /* Get PLL node ID using PLL clock ID */
+ status = pm_clock_get_pll_node_id(clock_id, &nid);
+ if (status == PM_RET_SUCCESS)
+ return pm_pll_get_parameter(nid, PM_PLL_PARAM_FBDIV, divider);
+
+ /* Check if clock ID is a valid on-chip clock */
+ status = pm_clock_id_is_valid(clock_id);
+ if (status != PM_RET_SUCCESS)
+ return status;
+
+ if (pm_clock_has_div(clock_id, PM_CLOCK_DIV0_ID)) {
+ /* Send request to the PMU to get div0 */
+ PM_PACK_PAYLOAD3(payload, PM_CLOCK_GETDIVIDER, clock_id,
+ PM_CLOCK_DIV0_ID);
+ status = pm_ipi_send_sync(primary_proc, payload, &val, 1);
+ if (status != PM_RET_SUCCESS)
+ return status;
+ *divider = val;
+ }
+
+ if (pm_clock_has_div(clock_id, PM_CLOCK_DIV1_ID)) {
+ /* Send request to the PMU to get div1 */
+ PM_PACK_PAYLOAD3(payload, PM_CLOCK_GETDIVIDER, clock_id,
+ PM_CLOCK_DIV1_ID);
+ status = pm_ipi_send_sync(primary_proc, payload, &val, 1);
+ if (status != PM_RET_SUCCESS)
+ return status;
+ *divider |= val << 16;
+ }
+
+ return status;
}
/**
@@ -933,7 +1061,7 @@
enum pm_ret_status pm_clock_setrate(unsigned int clock_id,
uint64_t rate)
{
- return pm_api_clock_setrate(clock_id, rate);
+ return PM_RET_ERROR_NOTSUPPORTED;
}
/**
@@ -949,28 +1077,44 @@
enum pm_ret_status pm_clock_getrate(unsigned int clock_id,
uint64_t *rate)
{
- return pm_api_clock_getrate(clock_id, rate);
+ return PM_RET_ERROR_NOTSUPPORTED;
}
/**
* pm_clock_setparent - Set the clock parent for given id
* @clock_id: Id of the clock
- * @parent_id: parent id
+ * @parent_index: Index of the parent clock into clock's parents array
*
* This function is used by master to set parent for any clock.
*
* Return: Returns status, either success or error+reason.
*/
enum pm_ret_status pm_clock_setparent(unsigned int clock_id,
- unsigned int parent_id)
+ unsigned int parent_index)
{
- return pm_api_clock_setparent(clock_id, parent_id);
+ struct pm_pll *pll;
+ uint32_t payload[PAYLOAD_ARG_CNT];
+ enum pm_ret_status status;
+
+ /* First try to handle it as a PLL */
+ pll = pm_clock_get_pll_by_related_clk(clock_id);
+ if (pll)
+ return pm_clock_pll_set_parent(pll, clock_id, parent_index);
+
+ /* Check if clock ID is a valid on-chip clock */
+ status = pm_clock_id_is_valid(clock_id);
+ if (status != PM_RET_SUCCESS)
+ return status;
+
+ /* Send request to the PMU */
+ PM_PACK_PAYLOAD3(payload, PM_CLOCK_SETPARENT, clock_id, parent_index);
+ return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
}
/**
* pm_clock_getparent - Get the clock parent for given id
* @clock_id: Id of the clock
- * @parent_id: parent id
+ * @parent_index: parent index
*
* This function is used by master to get parent index
* for any clock.
@@ -978,9 +1122,25 @@
* Return: Returns status, either success or error+reason.
*/
enum pm_ret_status pm_clock_getparent(unsigned int clock_id,
- unsigned int *parent_id)
+ unsigned int *parent_index)
{
- return pm_api_clock_getparent(clock_id, parent_id);
+ struct pm_pll *pll;
+ uint32_t payload[PAYLOAD_ARG_CNT];
+ enum pm_ret_status status;
+
+ /* First try to handle it as a PLL */
+ pll = pm_clock_get_pll_by_related_clk(clock_id);
+ if (pll)
+ return pm_clock_pll_get_parent(pll, clock_id, parent_index);
+
+ /* Check if clock ID is a valid on-chip clock */
+ status = pm_clock_id_is_valid(clock_id);
+ if (status != PM_RET_SUCCESS)
+ return status;
+
+ /* Send request to the PMU */
+ PM_PACK_PAYLOAD2(payload, PM_CLOCK_GETPARENT, clock_id);
+ return pm_ipi_send_sync(primary_proc, payload, parent_index, 1);
}
/**
@@ -1237,3 +1397,113 @@
address_high, readback_type);
return pm_ipi_send_sync(primary_proc, payload, value, 1);
}
+
+/*
+ * pm_pll_set_parameter() - Set the PLL parameter value
+ * @nid Node id of the target PLL
+ * @param_id ID of the PLL parameter
+ * @value Parameter value to be set
+ *
+ * Setting the parameter will have physical effect once the PLL mode is set to
+ * integer or fractional.
+ *
+ * @return Error if an argument is not valid or status as returned by the
+ * PM controller (PMU)
+ */
+enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid,
+ enum pm_pll_param param_id,
+ unsigned int value)
+{
+ uint32_t payload[PAYLOAD_ARG_CNT];
+
+ /* Check if given node ID is a PLL node */
+ if (nid < NODE_APLL || nid > NODE_IOPLL)
+ return PM_RET_ERROR_ARGS;
+
+ /* Check if parameter ID is valid and return an error if it's not */
+ if (param_id >= PM_PLL_PARAM_MAX)
+ return PM_RET_ERROR_ARGS;
+
+ /* Send request to the PMU */
+ PM_PACK_PAYLOAD4(payload, PM_PLL_SET_PARAMETER, nid, param_id, value);
+ return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
+}
+
+/**
+ * pm_pll_get_parameter() - Get the PLL parameter value
+ * @nid Node id of the target PLL
+ * @param_id ID of the PLL parameter
+ * @value Location to store the parameter value
+ *
+ * @return Error if an argument is not valid or status as returned by the
+ * PM controller (PMU)
+ */
+enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid,
+ enum pm_pll_param param_id,
+ unsigned int *value)
+{
+ uint32_t payload[PAYLOAD_ARG_CNT];
+
+ /* Check if given node ID is a PLL node */
+ if (nid < NODE_APLL || nid > NODE_IOPLL)
+ return PM_RET_ERROR_ARGS;
+
+ /* Check if parameter ID is valid and return an error if it's not */
+ if (param_id >= PM_PLL_PARAM_MAX)
+ return PM_RET_ERROR_ARGS;
+
+ /* Send request to the PMU */
+ PM_PACK_PAYLOAD3(payload, PM_PLL_GET_PARAMETER, nid, param_id);
+ return pm_ipi_send_sync(primary_proc, payload, value, 1);
+}
+
+/**
+ * pm_pll_set_mode() - Set the PLL mode
+ * @nid Node id of the target PLL
+ * @mode PLL mode to be set
+ *
+ * If reset mode is set the PM controller will first bypass the PLL and then
+ * assert the reset. If integer or fractional mode is set the PM controller will
+ * ensure that the complete PLL programming sequence is satisfied. After this
+ * function returns success the PLL is locked and its bypass is deasserted.
+ *
+ * @return Error if an argument is not valid or status as returned by the
+ * PM controller (PMU)
+ */
+enum pm_ret_status pm_pll_set_mode(enum pm_node_id nid, enum pm_pll_mode mode)
+{
+ uint32_t payload[PAYLOAD_ARG_CNT];
+
+ /* Check if given node ID is a PLL node */
+ if (nid < NODE_APLL || nid > NODE_IOPLL)
+ return PM_RET_ERROR_ARGS;
+
+ /* Check if PLL mode is valid */
+ if (mode >= PM_PLL_MODE_MAX)
+ return PM_RET_ERROR_ARGS;
+
+ /* Send request to the PMU */
+ PM_PACK_PAYLOAD3(payload, PM_PLL_SET_MODE, nid, mode);
+ return pm_ipi_send_sync(primary_proc, payload, NULL, 0);
+}
+
+/**
+ * pm_pll_get_mode() - Get the PLL mode
+ * @nid Node id of the target PLL
+ * @mode Location to store the mode of the PLL
+ *
+ * @return Error if an argument is not valid or status as returned by the
+ * PM controller (PMU)
+ */
+enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode)
+{
+ uint32_t payload[PAYLOAD_ARG_CNT];
+
+ /* Check if given node ID is a PLL node */
+ if (nid < NODE_APLL || nid > NODE_IOPLL)
+ return PM_RET_ERROR_ARGS;
+
+ /* Send request to the PMU */
+ PM_PACK_PAYLOAD2(payload, PM_PLL_GET_MODE, nid);
+ return pm_ipi_send_sync(primary_proc, payload, mode, 1);
+}
diff --git a/plat/xilinx/zynqmp/pm_service/pm_api_sys.h b/plat/xilinx/zynqmp/pm_service/pm_api_sys.h
index fee91cd..282ca3d 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_api_sys.h
+++ b/plat/xilinx/zynqmp/pm_service/pm_api_sys.h
@@ -8,6 +8,7 @@
#define PM_API_SYS_H
#include <stdint.h>
+
#include "pm_defs.h"
enum pm_query_id {
@@ -176,4 +177,15 @@
uint32_t address_low,
uint32_t *value);
+enum pm_ret_status pm_pll_set_parameter(enum pm_node_id nid,
+ enum pm_pll_param param_id,
+ unsigned int value);
+
+enum pm_ret_status pm_pll_get_parameter(enum pm_node_id nid,
+ enum pm_pll_param param_id,
+ unsigned int *value);
+
+enum pm_ret_status pm_pll_set_mode(enum pm_node_id nid, enum pm_pll_mode mode);
+enum pm_ret_status pm_pll_get_mode(enum pm_node_id nid, enum pm_pll_mode *mode);
+
#endif /* PM_API_SYS_H */
diff --git a/plat/xilinx/zynqmp/pm_service/pm_client.c b/plat/xilinx/zynqmp/pm_service/pm_client.c
index 874b8a9..bebb74c 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_client.c
+++ b/plat/xilinx/zynqmp/pm_service/pm_client.c
@@ -10,13 +10,15 @@
*/
#include <assert.h>
-#include <bakery_lock.h>
-#include <bl_common.h>
-#include <gic_common.h>
-#include <gicv2.h>
-#include <mmio.h>
#include <string.h>
-#include <utils.h>
+
+#include <common/bl_common.h>
+#include <drivers/arm/gic_common.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+#include <lib/utils.h>
+
#include "../zynqmp_def.h"
#include "pm_api_sys.h"
#include "pm_client.h"
diff --git a/plat/xilinx/zynqmp/pm_service/pm_common.h b/plat/xilinx/zynqmp/pm_service/pm_common.h
index 5474627..94e0568 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_common.h
+++ b/plat/xilinx/zynqmp/pm_service/pm_common.h
@@ -12,8 +12,10 @@
#ifndef PM_COMMON_H
#define PM_COMMON_H
-#include <debug.h>
#include <stdint.h>
+
+#include <common/debug.h>
+
#include "pm_defs.h"
#define PAYLOAD_ARG_CNT 6U
diff --git a/plat/xilinx/zynqmp/pm_service/pm_defs.h b/plat/xilinx/zynqmp/pm_service/pm_defs.h
index 7a0d978..cae36c9 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_defs.h
+++ b/plat/xilinx/zynqmp/pm_service/pm_defs.h
@@ -92,6 +92,11 @@
/* FPGA PL Readback */
PM_FPGA_READ,
PM_SECURE_AES,
+ /* PLL control API functions */
+ PM_PLL_SET_PARAMETER,
+ PM_PLL_GET_PARAMETER,
+ PM_PLL_SET_MODE,
+ PM_PLL_GET_MODE,
PM_API_MAX
};
@@ -265,4 +270,51 @@
PMF_SHUTDOWN_SUBTYPE_SYSTEM,
};
+/**
+ * @PM_PLL_PARAM_DIV2: Enable for divide by 2 function inside the PLL
+ * @PM_PLL_PARAM_FBDIV: Feedback divisor integer portion for the PLL
+ * @PM_PLL_PARAM_DATA: Feedback divisor fractional portion for the PLL
+ * @PM_PLL_PARAM_PRE_SRC: Clock source for PLL input
+ * @PM_PLL_PARAM_POST_SRC: Clock source for PLL Bypass mode
+ * @PM_PLL_PARAM_LOCK_DLY: Lock circuit config settings for lock windowsize
+ * @PM_PLL_PARAM_LOCK_CNT: Lock circuit counter setting
+ * @PM_PLL_PARAM_LFHF: PLL loop filter high frequency capacitor control
+ * @PM_PLL_PARAM_CP: PLL charge pump control
+ * @PM_PLL_PARAM_RES: PLL loop filter resistor control
+ */
+enum pm_pll_param {
+ PM_PLL_PARAM_DIV2,
+ PM_PLL_PARAM_FBDIV,
+ PM_PLL_PARAM_DATA,
+ PM_PLL_PARAM_PRE_SRC,
+ PM_PLL_PARAM_POST_SRC,
+ PM_PLL_PARAM_LOCK_DLY,
+ PM_PLL_PARAM_LOCK_CNT,
+ PM_PLL_PARAM_LFHF,
+ PM_PLL_PARAM_CP,
+ PM_PLL_PARAM_RES,
+ PM_PLL_PARAM_MAX,
+};
+
+/**
+ * @PM_PLL_MODE_RESET: PLL is in reset (not locked)
+ * @PM_PLL_MODE_INTEGER: PLL is locked in integer mode
+ * @PM_PLL_MODE_FRACTIONAL: PLL is locked in fractional mode
+ */
+enum pm_pll_mode {
+ PM_PLL_MODE_RESET,
+ PM_PLL_MODE_INTEGER,
+ PM_PLL_MODE_FRACTIONAL,
+ PM_PLL_MODE_MAX,
+};
+
+/**
+ * @PM_CLOCK_DIV0_ID: Clock divider 0
+ * @PM_CLOCK_DIV1_ID: Clock divider 1
+ */
+enum pm_clock_div_id {
+ PM_CLOCK_DIV0_ID,
+ PM_CLOCK_DIV1_ID,
+};
+
#endif /* PM_DEFS_H */
diff --git a/plat/xilinx/zynqmp/pm_service/pm_ipi.c b/plat/xilinx/zynqmp/pm_service/pm_ipi.c
index dc1ea4d..b3d833d 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_ipi.c
+++ b/plat/xilinx/zynqmp/pm_service/pm_ipi.c
@@ -5,9 +5,10 @@
*/
#include <arch_helpers.h>
-#include <bakery_lock.h>
-#include <mmio.h>
-#include <platform.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+#include <plat/common/platform.h>
+
#include "../zynqmp_ipi.h"
#include "../zynqmp_private.h"
#include "pm_ipi.h"
diff --git a/plat/xilinx/zynqmp/pm_service/pm_svc_main.c b/plat/xilinx/zynqmp/pm_service/pm_svc_main.c
index 7790c97..0b8fc23 100644
--- a/plat/xilinx/zynqmp/pm_service/pm_svc_main.c
+++ b/plat/xilinx/zynqmp/pm_service/pm_svc_main.c
@@ -10,18 +10,20 @@
*/
#include <errno.h>
-#include <runtime_svc.h>
+
+#include <common/runtime_svc.h>
+#if ZYNQMP_WDT_RESTART
+#include <arch_helpers.h>
+#include <drivers/arm/gicv2.h>
+#include <lib/mmio.h>
+#include <lib/spinlock.h>
+#include <plat/common/platform.h>
+#endif
+
#include "../zynqmp_private.h"
#include "pm_api_sys.h"
#include "pm_client.h"
#include "pm_ipi.h"
-#if ZYNQMP_WDT_RESTART
-#include <arch_helpers.h>
-#include <gicv2.h>
-#include <mmio.h>
-#include <platform.h>
-#include <spinlock.h>
-#endif
#define PM_SET_SUSPEND_MODE 0xa02
#define PM_GET_TRUSTZONE_VERSION 0xa03
@@ -563,6 +565,30 @@
SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value) << 32);
}
+ case PM_PLL_SET_PARAMETER:
+ ret = pm_pll_set_parameter(pm_arg[0], pm_arg[1], pm_arg[2]);
+ SMC_RET1(handle, (uint64_t)ret);
+
+ case PM_PLL_GET_PARAMETER:
+ {
+ uint32_t value;
+
+ ret = pm_pll_get_parameter(pm_arg[0], pm_arg[1], &value);
+ SMC_RET1(handle, (uint64_t)ret | ((uint64_t)value << 32));
+ }
+
+ case PM_PLL_SET_MODE:
+ ret = pm_pll_set_mode(pm_arg[0], pm_arg[1]);
+ SMC_RET1(handle, (uint64_t)ret);
+
+ case PM_PLL_GET_MODE:
+ {
+ uint32_t mode;
+
+ ret = pm_pll_get_mode(pm_arg[0], &mode);
+ SMC_RET1(handle, (uint64_t)ret | ((uint64_t)mode << 32));
+ }
+
default:
WARN("Unimplemented PM Service Call: 0x%x\n", smc_fid);
SMC_RET1(handle, SMC_UNK);
diff --git a/plat/xilinx/zynqmp/sip_svc_setup.c b/plat/xilinx/zynqmp/sip_svc_setup.c
index 9fe709d..8d23a01 100644
--- a/plat/xilinx/zynqmp/sip_svc_setup.c
+++ b/plat/xilinx/zynqmp/sip_svc_setup.c
@@ -6,8 +6,9 @@
/* Top level SMC handler for SiP calls. Dispatch PM calls to PM SMC handler. */
-#include <runtime_svc.h>
-#include <uuid.h>
+#include <common/runtime_svc.h>
+#include <tools_share/uuid.h>
+
#include "ipi_mailbox_svc.h"
#include "pm_svc_main.h"
#include "zynqmp_ipi.h"
diff --git a/plat/xilinx/zynqmp/tsp/tsp_plat_setup.c b/plat/xilinx/zynqmp/tsp/tsp_plat_setup.c
index a27f34b..25359f9 100644
--- a/plat/xilinx/zynqmp/tsp/tsp_plat_setup.c
+++ b/plat/xilinx/zynqmp/tsp/tsp_plat_setup.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <bl_common.h>
-#include <console.h>
-#include <debug.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <drivers/console.h>
+
#include <plat_arm.h>
#include <platform_tsp.h>
+
#include "../zynqmp_private.h"
#define BL32_END (unsigned long)(&__BL32_END__)
diff --git a/plat/xilinx/zynqmp/zynqmp_def.h b/plat/xilinx/zynqmp/zynqmp_def.h
index ba382dd..f75530e 100644
--- a/plat/xilinx/zynqmp/zynqmp_def.h
+++ b/plat/xilinx/zynqmp/zynqmp_def.h
@@ -7,7 +7,7 @@
#ifndef ZYNQMP_DEF_H
#define ZYNQMP_DEF_H
-#include <common_def.h>
+#include <plat/common/common_def.h>
#define ZYNQMP_CONSOLE_ID_cadence 1
#define ZYNQMP_CONSOLE_ID_cadence0 1
diff --git a/plat/xilinx/zynqmp/zynqmp_ipi.c b/plat/xilinx/zynqmp/zynqmp_ipi.c
index 5038f84..54b1838 100644
--- a/plat/xilinx/zynqmp/zynqmp_ipi.c
+++ b/plat/xilinx/zynqmp/zynqmp_ipi.c
@@ -8,12 +8,14 @@
* Zynq UltraScale+ MPSoC IPI agent registers access management
*/
-#include <bakery_lock.h>
-#include <debug.h>
#include <errno.h>
-#include <mmio.h>
-#include <runtime_svc.h>
#include <string.h>
+
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/bakery_lock.h>
+#include <lib/mmio.h>
+
#include "zynqmp_ipi.h"
#include "../zynqmp_private.h"
diff --git a/plat/xilinx/zynqmp/zynqmp_private.h b/plat/xilinx/zynqmp/zynqmp_private.h
index 8a8d38a..a8ebceb 100644
--- a/plat/xilinx/zynqmp/zynqmp_private.h
+++ b/plat/xilinx/zynqmp/zynqmp_private.h
@@ -7,10 +7,11 @@
#ifndef ZYNQMP_PRIVATE_H
#define ZYNQMP_PRIVATE_H
-#include <bl_common.h>
-#include <interrupt_mgmt.h>
#include <stdint.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/bl_common.h>
+
void zynqmp_config_setup(void);
unsigned int zynqmp_calc_core_pos(u_register_t mpidr);
diff --git a/services/arm_arch_svc/arm_arch_svc_setup.c b/services/arm_arch_svc/arm_arch_svc_setup.c
index 3a5299f..dfbe02c 100644
--- a/services/arm_arch_svc/arm_arch_svc_setup.c
+++ b/services/arm_arch_svc/arm_arch_svc_setup.c
@@ -4,14 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arm_arch_svc.h>
-#include <debug.h>
-#include <errata_report.h>
-#include <runtime_svc.h>
-#include <smccc.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/cpus/errata_report.h>
+#include <lib/cpus/wa_cve_2017_5715.h>
+#include <lib/cpus/wa_cve_2018_3639.h>
+#include <lib/smccc.h>
+#include <services/arm_arch_svc.h>
#include <smccc_helpers.h>
-#include <wa_cve_2017_5715.h>
-#include <wa_cve_2018_3639.h>
static int32_t smccc_version(void)
{
diff --git a/services/spd/opteed/opteed_common.c b/services/spd/opteed/opteed_common.c
index e5e2be7..9aa19c5 100644
--- a/services/spd/opteed/opteed_common.c
+++ b/services/spd/opteed/opteed_common.c
@@ -4,12 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
#include <string.h>
-#include <utils.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/utils.h>
+
#include "opteed_private.h"
/*******************************************************************************
diff --git a/services/spd/opteed/opteed_main.c b/services/spd/opteed/opteed_main.c
index 59d6ed2..160a693 100644
--- a/services/spd/opteed/opteed_main.c
+++ b/services/spd/opteed/opteed_main.c
@@ -14,22 +14,23 @@
* handle the request locally or delegate it to the Secure Payload. It is also
* responsible for initialising and maintaining communication with the SP.
******************************************************************************/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl31.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
#include <errno.h>
-#include <platform.h>
-#include <runtime_svc.h>
#include <stddef.h>
-#include <uuid.h>
+
+#include <arch_helpers.h>
+#include <bl31/bl31.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <plat/common/platform.h>
+#include <tools_share/uuid.h>
+
#include "opteed_private.h"
#include "teesmc_opteed.h"
#include "teesmc_opteed_macros.h"
-
/*******************************************************************************
* Address of the entrypoint vector table in OPTEE. It is
* initialised once on the primary core after a cold boot.
diff --git a/services/spd/opteed/opteed_pm.c b/services/spd/opteed/opteed_pm.c
index b133651..719eeb7 100644
--- a/services/spd/opteed/opteed_pm.c
+++ b/services/spd/opteed/opteed_pm.c
@@ -4,12 +4,14 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <platform.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <plat/common/platform.h>
+
#include "opteed_private.h"
/*******************************************************************************
diff --git a/services/spd/opteed/opteed_private.h b/services/spd/opteed/opteed_private.h
index 1a67fce..847b9c5 100644
--- a/services/spd/opteed/opteed_private.h
+++ b/services/spd/opteed/opteed_private.h
@@ -7,11 +7,12 @@
#ifndef OPTEED_PRIVATE_H
#define OPTEED_PRIVATE_H
-#include <arch.h>
-#include <context.h>
-#include <interrupt_mgmt.h>
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch.h>
+#include <bl31/interrupt_mgmt.h>
+#include <context.h>
+#include <lib/psci/psci.h>
/*******************************************************************************
* OPTEE PM state information e.g. OPTEE is suspended, uninitialised etc
@@ -80,9 +81,10 @@
#ifndef __ASSEMBLY__
-#include <cassert.h>
#include <stdint.h>
+#include <lib/cassert.h>
+
typedef uint32_t optee_vector_isn_t;
typedef struct optee_vectors {
diff --git a/services/spd/opteed/teesmc_opteed_macros.h b/services/spd/opteed/teesmc_opteed_macros.h
index 0068dc7..9d8a169 100644
--- a/services/spd/opteed/teesmc_opteed_macros.h
+++ b/services/spd/opteed/teesmc_opteed_macros.h
@@ -6,7 +6,7 @@
#ifndef TEESMC_OPTEED_MACROS_H
#define TEESMC_OPTEED_MACROS_H
-#include <runtime_svc.h>
+#include <common/runtime_svc.h>
#define TEESMC_OPTEED_RV(func_num) \
((SMC_TYPE_FAST << FUNCID_TYPE_SHIFT) | \
diff --git a/services/spd/tlkd/tlkd_common.c b/services/spd/tlkd/tlkd_common.c
index 6fec91b..2f0194e 100644
--- a/services/spd/tlkd/tlkd_common.c
+++ b/services/spd/tlkd/tlkd_common.c
@@ -4,11 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
#include <string.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <lib/el3_runtime/context_mgmt.h>
+
#include "tlkd_private.h"
#define AT_MASK 3
diff --git a/services/spd/tlkd/tlkd_main.c b/services/spd/tlkd/tlkd_main.c
index cee7ef8..ffe3319 100644
--- a/services/spd/tlkd/tlkd_main.c
+++ b/services/spd/tlkd/tlkd_main.c
@@ -15,16 +15,18 @@
******************************************************************************/
#include <arch_helpers.h>
#include <assert.h>
-#include <bl31.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
#include <errno.h>
-#include <platform.h>
-#include <runtime_svc.h>
#include <stddef.h>
+
+#include <bl31/bl31.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <plat/common/platform.h>
+#include <tools_share/uuid.h>
+
#include <tlk.h>
-#include <uuid.h>
#include "tlkd_private.h"
extern const spd_pm_ops_t tlkd_pm_ops;
diff --git a/services/spd/tlkd/tlkd_pm.c b/services/spd/tlkd/tlkd_pm.c
index 2cd2fbb..de34bf6 100644
--- a/services/spd/tlkd/tlkd_pm.c
+++ b/services/spd/tlkd/tlkd_pm.c
@@ -4,12 +4,13 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <psci.h>
+
+#include <arch_helpers.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/psci/psci.h>
#include <tlk.h>
#include "tlkd_private.h"
diff --git a/services/spd/tlkd/tlkd_private.h b/services/spd/tlkd/tlkd_private.h
index 525cc3a..53f9e20 100644
--- a/services/spd/tlkd/tlkd_private.h
+++ b/services/spd/tlkd/tlkd_private.h
@@ -7,11 +7,12 @@
#ifndef TLKD_PRIVATE_H
#define TLKD_PRIVATE_H
-#include <arch.h>
-#include <context.h>
-#include <interrupt_mgmt.h>
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch.h>
+#include <bl31/interrupt_mgmt.h>
+#include <context.h>
+#include <lib/psci/psci.h>
/*
* This flag is used by the TLKD to determine if the SP is servicing a yielding
@@ -72,9 +73,10 @@
#ifndef __ASSEMBLY__
-#include <cassert.h>
#include <stdint.h>
+#include <lib/cassert.h>
+
/* AArch64 callee saved general purpose register context structure. */
DEFINE_REG_STRUCT(c_rt_regs, TLKD_C_RT_CTX_ENTRIES);
diff --git a/services/spd/trusty/generic-arm64-smcall.c b/services/spd/trusty/generic-arm64-smcall.c
index 6f766c4..771e2cf 100644
--- a/services/spd/trusty/generic-arm64-smcall.c
+++ b/services/spd/trusty/generic-arm64-smcall.c
@@ -4,10 +4,11 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <debug.h>
-#include <runtime_svc.h>
#include <stdio.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+
#include "generic-arm64-smcall.h"
int trusty_disable_serial_debug;
diff --git a/services/spd/trusty/trusty.c b/services/spd/trusty/trusty.c
index 3335836..b6ebeeb 100644
--- a/services/spd/trusty/trusty.c
+++ b/services/spd/trusty/trusty.c
@@ -4,18 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
-#include <assert.h> /* for context_mgmt.h */
-#include <bl31.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <interrupt_mgmt.h>
-#include <platform.h>
-#include <runtime_svc.h>
+#include <assert.h>
#include <stdbool.h>
#include <string.h>
+#include <arch_helpers.h>
+#include <bl31/bl31.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <plat/common/platform.h>
+
#include "sm_err.h"
#include "smcall.h"
diff --git a/services/spd/tspd/tspd_common.c b/services/spd/tspd/tspd_common.c
index de54dbe..063fd01 100644
--- a/services/spd/tspd/tspd_common.c
+++ b/services/spd/tspd/tspd_common.c
@@ -4,14 +4,16 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
#include <string.h>
-#include <tsp.h>
-#include <utils.h>
+
+#include <arch_helpers.h>
+#include <bl32/tsp/tsp.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/utils.h>
+
#include "tspd_private.h"
/*******************************************************************************
diff --git a/services/spd/tspd/tspd_main.c b/services/spd/tspd/tspd_main.c
index d2acda8..d2bd43f 100644
--- a/services/spd/tspd/tspd_main.c
+++ b/services/spd/tspd/tspd_main.c
@@ -14,20 +14,22 @@
* handle the request locally or delegate it to the Secure Payload. It is also
* responsible for initialising and maintaining communication with the SP.
******************************************************************************/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl31.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <ehf.h>
#include <errno.h>
-#include <platform.h>
-#include <runtime_svc.h>
#include <stddef.h>
#include <string.h>
-#include <tsp.h>
-#include <uuid.h>
+
+#include <arch_helpers.h>
+#include <bl31/bl31.h>
+#include <bl31/ehf.h>
+#include <bl32/tsp/tsp.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <plat/common/platform.h>
+#include <tools_share/uuid.h>
+
#include "tspd_private.h"
/*******************************************************************************
diff --git a/services/spd/tspd/tspd_pm.c b/services/spd/tspd/tspd_pm.c
index 9414c15..b95ee8f 100644
--- a/services/spd/tspd/tspd_pm.c
+++ b/services/spd/tspd/tspd_pm.c
@@ -4,13 +4,15 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <platform.h>
-#include <tsp.h>
+
+#include <arch_helpers.h>
+#include <bl32/tsp/tsp.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <plat/common/platform.h>
+
#include "tspd_private.h"
/*******************************************************************************
diff --git a/services/spd/tspd/tspd_private.h b/services/spd/tspd/tspd_private.h
index e2e333d..50f3b87 100644
--- a/services/spd/tspd/tspd_private.h
+++ b/services/spd/tspd/tspd_private.h
@@ -7,11 +7,12 @@
#ifndef TSPD_PRIVATE_H
#define TSPD_PRIVATE_H
-#include <arch.h>
-#include <context.h>
-#include <interrupt_mgmt.h>
#include <platform_def.h>
-#include <psci.h>
+
+#include <arch.h>
+#include <bl31/interrupt_mgmt.h>
+#include <context.h>
+#include <lib/psci/psci.h>
/*******************************************************************************
* Secure Payload PM state information e.g. SP is suspended, uninitialised etc
@@ -127,9 +128,10 @@
#ifndef __ASSEMBLY__
-#include <cassert.h>
#include <stdint.h>
+#include <lib/cassert.h>
+
/*
* The number of arguments to save during a SMC call for TSP.
* Currently only x1 and x2 are used by TSP.
diff --git a/services/std_svc/sdei/sdei_event.c b/services/std_svc/sdei/sdei_event.c
index ec69b9d..0b608e1 100644
--- a/services/std_svc/sdei/sdei_event.c
+++ b/services/std_svc/sdei/sdei_event.c
@@ -5,7 +5,9 @@
*/
#include <assert.h>
-#include <utils.h>
+
+#include <lib/utils.h>
+
#include "sdei_private.h"
#define MAP_OFF(_map, _mapping) ((_map) - (_mapping)->map)
diff --git a/services/std_svc/sdei/sdei_intr_mgmt.c b/services/std_svc/sdei/sdei_intr_mgmt.c
index fa778c0..b8799cd 100644
--- a/services/std_svc/sdei/sdei_intr_mgmt.c
+++ b/services/std_svc/sdei/sdei_intr_mgmt.c
@@ -4,16 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl_common.h>
-#include <cassert.h>
-#include <debug.h>
-#include <ehf.h>
-#include <interrupt_mgmt.h>
-#include <runtime_svc.h>
-#include <sdei.h>
#include <string.h>
+
+#include <arch_helpers.h>
+#include <bl31/ehf.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/cassert.h>
+#include <services/sdei.h>
+
#include "sdei_private.h"
/* x0-x17 GPREGS context */
diff --git a/services/std_svc/sdei/sdei_main.c b/services/std_svc/sdei/sdei_main.c
index 990d028..0424177 100644
--- a/services/std_svc/sdei/sdei_main.c
+++ b/services/std_svc/sdei/sdei_main.c
@@ -6,20 +6,22 @@
#include <arch_helpers.h>
#include <assert.h>
-#include <bl31.h>
-#include <bl_common.h>
-#include <cassert.h>
-#include <context.h>
-#include <debug.h>
-#include <ehf.h>
-#include <interrupt_mgmt.h>
-#include <platform.h>
-#include <pubsub.h>
-#include <runtime_svc.h>
-#include <sdei.h>
#include <stddef.h>
#include <string.h>
-#include <utils.h>
+
+#include <bl31/bl31.h>
+#include <bl31/ehf.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/bl_common.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <context.h>
+#include <lib/cassert.h>
+#include <lib/el3_runtime/pubsub.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+#include <services/sdei.h>
+
#include "sdei_private.h"
#define MAJOR_VERSION 1ULL
diff --git a/services/std_svc/sdei/sdei_private.h b/services/std_svc/sdei/sdei_private.h
index 8212667..b945394 100644
--- a/services/std_svc/sdei/sdei_private.h
+++ b/services/std_svc/sdei/sdei_private.h
@@ -7,19 +7,20 @@
#ifndef SDEI_PRIVATE_H
#define SDEI_PRIVATE_H
-#include <arch_helpers.h>
-#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
#include <errno.h>
-#include <interrupt_mgmt.h>
-#include <platform.h>
-#include <sdei.h>
-#include <setjmp.h>
-#include <spinlock.h>
#include <stdbool.h>
#include <stdint.h>
-#include <utils_def.h>
+
+#include <arch_helpers.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/debug.h>
+#include <context.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/spinlock.h>
+#include <lib/utils_def.h>
+#include <plat/common/platform.h>
+#include <services/sdei.h>
+#include <setjmp.h>
#ifdef AARCH32
# error SDEI is implemented only for AArch64 systems
diff --git a/services/std_svc/sdei/sdei_state.c b/services/std_svc/sdei/sdei_state.c
index 6665786..1b448e6 100644
--- a/services/std_svc/sdei/sdei_state.c
+++ b/services/std_svc/sdei/sdei_state.c
@@ -5,8 +5,10 @@
*/
#include <assert.h>
-#include <cassert.h>
#include <stdbool.h>
+
+#include <lib/cassert.h>
+
#include "sdei_private.h"
/* Aliases for SDEI handler states: 'R'unning, 'E'nabled, and re'G'istered */
diff --git a/services/std_svc/spm/aarch64/spm_shim_exceptions.S b/services/std_svc/spm/aarch64/spm_shim_exceptions.S
index 9c218df..dab6150 100644
--- a/services/std_svc/spm/aarch64/spm_shim_exceptions.S
+++ b/services/std_svc/spm/aarch64/spm_shim_exceptions.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <context.h>
/* -----------------------------------------------------------------------------
diff --git a/services/std_svc/spm/spci.c b/services/std_svc/spm/spci.c
index 5e4ff91..44a0acd 100644
--- a/services/std_svc/spm/spci.c
+++ b/services/std_svc/spm/spci.c
@@ -5,17 +5,18 @@
*/
#include <assert.h>
-#include <context_mgmt.h>
-#include <debug.h>
#include <errno.h>
-#include <smccc.h>
-#include <smccc_helpers.h>
-#include <spci_svc.h>
-#include <spinlock.h>
-#include <sprt_host.h>
-#include <sprt_svc.h>
#include <string.h>
-#include <utils.h>
+
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/smccc.h>
+#include <lib/spinlock.h>
+#include <lib/utils.h>
+#include <services/spci_svc.h>
+#include <services/sprt_svc.h>
+#include <smccc_helpers.h>
+#include <sprt_host.h>
#include "spm_private.h"
diff --git a/services/std_svc/spm/spm_buffers.c b/services/std_svc/spm/spm_buffers.c
index 747337a..0c26a74 100644
--- a/services/std_svc/spm/spm_buffers.c
+++ b/services/std_svc/spm/spm_buffers.c
@@ -5,9 +5,9 @@
*/
#include <arch_helpers.h>
+#include <lib/spinlock.h>
+#include <lib/utils_def.h>
#include <platform_def.h>
-#include <spinlock.h>
-#include <utils_def.h>
/*******************************************************************************
* Secure Service response global array. All the responses to the requests done
diff --git a/services/std_svc/spm/spm_main.c b/services/std_svc/spm/spm_main.c
index 460d1fb..adfffd5 100644
--- a/services/std_svc/spm/spm_main.c
+++ b/services/std_svc/spm/spm_main.c
@@ -4,23 +4,24 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <bl31.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <ehf.h>
#include <errno.h>
-#include <interrupt_mgmt.h>
-#include <platform.h>
-#include <runtime_svc.h>
-#include <smccc.h>
-#include <smccc_helpers.h>
-#include <spinlock.h>
#include <string.h>
-#include <sprt_svc.h>
-#include <utils.h>
-#include <xlat_tables_v2.h>
+
+#include <arch_helpers.h>
+#include <bl31/bl31.h>
+#include <bl31/ehf.h>
+#include <bl31/interrupt_mgmt.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/smccc.h>
+#include <lib/spinlock.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/platform.h>
+#include <services/sprt_svc.h>
+#include <smccc_helpers.h>
#include "spm_private.h"
diff --git a/services/std_svc/spm/spm_private.h b/services/std_svc/spm/spm_private.h
index c1aad93..1d5a88e 100644
--- a/services/std_svc/spm/spm_private.h
+++ b/services/std_svc/spm/spm_private.h
@@ -34,10 +34,11 @@
#ifndef __ASSEMBLY__
-#include <spinlock.h>
-#include <sp_res_desc.h>
#include <stdint.h>
-#include <xlat_tables_v2.h>
+
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <lib/spinlock.h>
+#include <services/sp_res_desc.h>
typedef enum sp_state {
SP_STATE_RESET = 0,
diff --git a/services/std_svc/spm/spm_setup.c b/services/std_svc/spm/spm_setup.c
index aca779f..3aabc20 100644
--- a/services/std_svc/spm/spm_setup.c
+++ b/services/std_svc/spm/spm_setup.c
@@ -4,19 +4,21 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <string.h>
+
+#include <platform_def.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <common_def.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <platform_def.h>
-#include <platform.h>
-#include <sp_res_desc.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/common_def.h>
+#include <plat/common/platform.h>
+#include <services/sp_res_desc.h>
#include <sprt_host.h>
-#include <string.h>
-#include <xlat_tables_v2.h>
#include "spm_private.h"
#include "spm_shim_private.h"
diff --git a/services/std_svc/spm/spm_shim_private.h b/services/std_svc/spm/spm_shim_private.h
index f2a7e05..7fe9692 100644
--- a/services/std_svc/spm/spm_shim_private.h
+++ b/services/std_svc/spm/spm_shim_private.h
@@ -8,7 +8,8 @@
#define SPM_SHIM_PRIVATE_H
#include <stdint.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/* Assembly source */
IMPORT_SYM(uintptr_t, spm_shim_exceptions_ptr, SPM_SHIM_EXCEPTIONS_PTR);
diff --git a/services/std_svc/spm/spm_xlat.c b/services/std_svc/spm/spm_xlat.c
index bbe392d..57ad742 100644
--- a/services/std_svc/spm/spm_xlat.c
+++ b/services/std_svc/spm/spm_xlat.c
@@ -8,14 +8,16 @@
#include <arch_helpers.h>
#include <assert.h>
#include <errno.h>
-#include <object_pool.h>
-#include <platform_def.h>
-#include <platform.h>
-#include <sp_res_desc.h>
#include <string.h>
-#include <utils.h>
-#include <utils_def.h>
-#include <xlat_tables_v2.h>
+
+#include <platform_def.h>
+
+#include <lib/object_pool.h>
+#include <lib/utils.h>
+#include <lib/utils_def.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/platform.h>
+#include <services/sp_res_desc.h>
#include "spm_private.h"
#include "spm_shim_private.h"
diff --git a/services/std_svc/spm/sprt.c b/services/std_svc/spm/sprt.c
index 034dced..f6af49f 100644
--- a/services/std_svc/spm/sprt.c
+++ b/services/std_svc/spm/sprt.c
@@ -4,17 +4,18 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
-#include <arch_helpers.h>
#include <assert.h>
-#include <context_mgmt.h>
-#include <debug.h>
#include <errno.h>
#include <limits.h>
-#include <platform.h>
-#include <smccc.h>
+
+#include <arch_helpers.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/smccc.h>
+#include <lib/utils.h>
+#include <plat/common/platform.h>
+#include <services/sprt_svc.h>
#include <smccc_helpers.h>
-#include <sprt_svc.h>
-#include <utils.h>
#include "spm_private.h"
diff --git a/services/std_svc/spm_deprecated/aarch64/spm_shim_exceptions.S b/services/std_svc/spm_deprecated/aarch64/spm_shim_exceptions.S
index 9c218df..dab6150 100644
--- a/services/std_svc/spm_deprecated/aarch64/spm_shim_exceptions.S
+++ b/services/std_svc/spm_deprecated/aarch64/spm_shim_exceptions.S
@@ -6,7 +6,7 @@
#include <arch.h>
#include <asm_macros.S>
-#include <bl_common.h>
+#include <common/bl_common.h>
#include <context.h>
/* -----------------------------------------------------------------------------
diff --git a/services/std_svc/spm_deprecated/spm_main.c b/services/std_svc/spm_deprecated/spm_main.c
index 880e86e..540f257 100644
--- a/services/std_svc/spm_deprecated/spm_main.c
+++ b/services/std_svc/spm_deprecated/spm_main.c
@@ -6,21 +6,22 @@
#include <arch_helpers.h>
#include <assert.h>
-#include <bl31.h>
-#include <context_mgmt.h>
-#include <debug.h>
-#include <ehf.h>
#include <errno.h>
-#include <mm_svc.h>
-#include <platform.h>
-#include <runtime_svc.h>
-#include <secure_partition.h>
-#include <smccc.h>
+
+#include <bl31/bl31.h>
+#include <bl31/ehf.h>
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/smccc.h>
+#include <lib/spinlock.h>
+#include <lib/utils.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
+#include <plat/common/platform.h>
+#include <services/mm_svc.h>
+#include <services/secure_partition.h>
+#include <services/spm_svc.h>
#include <smccc_helpers.h>
-#include <spinlock.h>
-#include <spm_svc.h>
-#include <utils.h>
-#include <xlat_tables_v2.h>
#include "spm_private.h"
diff --git a/services/std_svc/spm_deprecated/spm_private.h b/services/std_svc/spm_deprecated/spm_private.h
index ec3f48e..8e94a28 100644
--- a/services/std_svc/spm_deprecated/spm_private.h
+++ b/services/std_svc/spm_deprecated/spm_private.h
@@ -31,9 +31,10 @@
#ifndef __ASSEMBLY__
-#include <spinlock.h>
#include <stdint.h>
-#include <xlat_tables_v2.h>
+
+#include <lib/spinlock.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
typedef enum sp_state {
SP_STATE_RESET = 0,
diff --git a/services/std_svc/spm_deprecated/spm_setup.c b/services/std_svc/spm_deprecated/spm_setup.c
index 0d61306..d458f4a 100644
--- a/services/std_svc/spm_deprecated/spm_setup.c
+++ b/services/std_svc/spm_deprecated/spm_setup.c
@@ -4,18 +4,19 @@
* SPDX-License-Identifier: BSD-3-Clause
*/
+#include <assert.h>
+#include <string.h>
+
#include <arch.h>
#include <arch_helpers.h>
-#include <assert.h>
-#include <common_def.h>
#include <context.h>
-#include <context_mgmt.h>
-#include <debug.h>
+#include <common/debug.h>
+#include <lib/el3_runtime/context_mgmt.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
#include <platform_def.h>
-#include <platform.h>
-#include <secure_partition.h>
-#include <string.h>
-#include <xlat_tables_v2.h>
+#include <plat/common/common_def.h>
+#include <plat/common/platform.h>
+#include <services/secure_partition.h>
#include "spm_private.h"
#include "spm_shim_private.h"
diff --git a/services/std_svc/spm_deprecated/spm_shim_private.h b/services/std_svc/spm_deprecated/spm_shim_private.h
index f2a7e05..7fe9692 100644
--- a/services/std_svc/spm_deprecated/spm_shim_private.h
+++ b/services/std_svc/spm_deprecated/spm_shim_private.h
@@ -8,7 +8,8 @@
#define SPM_SHIM_PRIVATE_H
#include <stdint.h>
-#include <utils_def.h>
+
+#include <lib/utils_def.h>
/* Assembly source */
IMPORT_SYM(uintptr_t, spm_shim_exceptions_ptr, SPM_SHIM_EXCEPTIONS_PTR);
diff --git a/services/std_svc/spm_deprecated/spm_xlat.c b/services/std_svc/spm_deprecated/spm_xlat.c
index 3527138..f54168e 100644
--- a/services/std_svc/spm_deprecated/spm_xlat.c
+++ b/services/std_svc/spm_deprecated/spm_xlat.c
@@ -8,11 +8,11 @@
#include <arch_helpers.h>
#include <assert.h>
#include <errno.h>
+#include <lib/xlat_tables/xlat_tables_v2.h>
#include <platform_def.h>
-#include <platform.h>
-#include <secure_partition.h>
-#include <spm_svc.h>
-#include <xlat_tables_v2.h>
+#include <plat/common/platform.h>
+#include <services/secure_partition.h>
+#include <services/spm_svc.h>
#include "spm_private.h"
#include "spm_shim_private.h"
diff --git a/services/std_svc/std_svc_setup.c b/services/std_svc/std_svc_setup.c
index 86ecdf7..7a34655 100644
--- a/services/std_svc/std_svc_setup.c
+++ b/services/std_svc/std_svc_setup.c
@@ -5,18 +5,19 @@
*/
#include <assert.h>
-#include <cpu_data.h>
-#include <debug.h>
-#include <pmf.h>
-#include <psci.h>
-#include <runtime_instr.h>
-#include <runtime_svc.h>
-#include <sdei.h>
-#include <smccc_helpers.h>
-#include <spm_svc.h>
-#include <std_svc.h>
#include <stdint.h>
-#include <uuid.h>
+
+#include <common/debug.h>
+#include <common/runtime_svc.h>
+#include <lib/el3_runtime/cpu_data.h>
+#include <lib/pmf/pmf.h>
+#include <lib/psci/psci.h>
+#include <lib/runtime_instr.h>
+#include <services/sdei.h>
+#include <services/spm_svc.h>
+#include <services/std_svc.h>
+#include <smccc_helpers.h>
+#include <tools_share/uuid.h>
/* Standard Service UUID */
static uuid_t arm_svc_uid = {