From aa7877c4bf68fa6ad6813323f659b82355acaab5 Mon Sep 17 00:00:00 2001 From: Antonio Nino Diaz Date: Wed, 10 Oct 2018 11:14:44 +0100 Subject: [PATCH] plat/arm: Move norflash driver to drivers/ folder This way it can be reused by other platforms if needed. Note that this driver is designed to work with the Versatile Express NOR flash of Juno and FVP. In said platforms, the memory is organized as an interleaved memory of two chips with a 16 bit word. Any platform that wishes to reuse it with a different configuration will need to modify the driver so that it is more generic. Change-Id: Ic721758425864e0cf42b7b9b04bf0d9513b6022e Signed-off-by: Antonio Nino Diaz --- .../norflash.c => drivers/cfi/v2m/v2m_flash.c | 17 ++++++++--------- .../norflash.h => drivers/cfi/v2m_flash.h} | 0 plat/arm/board/common/board_common.mk | 10 +++++----- plat/arm/board/fvp/platform.mk | 2 +- plat/arm/board/fvp/sp_min/sp_min-fvp.mk | 6 +++--- plat/arm/board/juno/platform.mk | 4 ++-- plat/arm/board/juno/sp_min/sp_min-juno.mk | 6 +++--- plat/arm/board/sgi575/platform.mk | 4 ++-- plat/arm/board/sgm775/platform.mk | 4 ++-- plat/arm/common/arm_err.c | 2 +- plat/arm/common/arm_nor_psci_mem_protect.c | 3 +-- 11 files changed, 28 insertions(+), 30 deletions(-) rename plat/arm/board/common/drivers/norflash/norflash.c => drivers/cfi/v2m/v2m_flash.c (98%) rename include/{plat/arm/board/common/drivers/norflash.h => drivers/cfi/v2m_flash.h} (100%) diff --git a/plat/arm/board/common/drivers/norflash/norflash.c b/drivers/cfi/v2m/v2m_flash.c similarity index 98% rename from plat/arm/board/common/drivers/norflash/norflash.c rename to drivers/cfi/v2m/v2m_flash.c index 722cf33ee..9b80e2f2a 100644 --- a/plat/arm/board/common/drivers/norflash/norflash.c +++ b/drivers/cfi/v2m/v2m_flash.c @@ -6,8 +6,15 @@ #include #include -#include +#include +/* + * This file supplies a low level interface to the vexpress NOR flash + * memory of juno and fvp. This memory is organized as an interleaved + * memory of two chips with a 16 bit word. It means that every 32 bit + * access is going to access to two different chips. This is very + * important when we send commands or read status of the chips. + */ /* * DWS ready poll retries. The number of retries in this driver have been @@ -21,14 +28,6 @@ /* Helper macro to detect end of command */ #define NOR_CMD_END (NOR_DWS | NOR_DWS << 16l) -/* - * This file supplies a low level interface to the vexpress NOR flash - * memory of juno and fvp. This memory is organized as an interleaved - * memory of two chips with a 16 bit word. It means that every 32 bit - * access is going to access to two different chips. This is very - * important when we send commands or read status of the chips - */ - /* Helper macros to access two flash banks in parallel */ #define NOR_2X16(d) ((d << 16) | (d & 0xffff)) diff --git a/include/plat/arm/board/common/drivers/norflash.h b/include/drivers/cfi/v2m_flash.h similarity index 100% rename from include/plat/arm/board/common/drivers/norflash.h rename to include/drivers/cfi/v2m_flash.h diff --git a/plat/arm/board/common/board_common.mk b/plat/arm/board/common/board_common.mk index 8b46c4bee..2556fc04a 100644 --- a/plat/arm/board/common/board_common.mk +++ b/plat/arm/board/common/board_common.mk @@ -4,15 +4,15 @@ # SPDX-License-Identifier: BSD-3-Clause # -PLAT_INCLUDES += -Iinclude/plat/arm/board/common/ \ - -Iinclude/plat/arm/board/common/drivers +PLAT_INCLUDES += -Iinclude/drivers/cfi/ \ + -Iinclude/plat/arm/board/common/ -PLAT_BL_COMMON_SOURCES += drivers/arm/pl011/${ARCH}/pl011_console.S \ +PLAT_BL_COMMON_SOURCES += drivers/arm/pl011/${ARCH}/pl011_console.S \ plat/arm/board/common/${ARCH}/board_arm_helpers.S -BL1_SOURCES += plat/arm/board/common/drivers/norflash/norflash.c +BL1_SOURCES += drivers/cfi/v2m/v2m_flash.c -BL2_SOURCES += plat/arm/board/common/drivers/norflash/norflash.c +BL2_SOURCES += drivers/cfi/v2m/v2m_flash.c ifneq (${TRUSTED_BOARD_BOOT},0) ifneq (${ARM_CRYPTOCELL_INTEG}, 1) diff --git a/plat/arm/board/fvp/platform.mk b/plat/arm/board/fvp/platform.mk index 9bd3bde65..332df4d44 100644 --- a/plat/arm/board/fvp/platform.mk +++ b/plat/arm/board/fvp/platform.mk @@ -147,13 +147,13 @@ BL2U_SOURCES += plat/arm/board/fvp/fvp_bl2u_setup.c \ ${FVP_SECURITY_SOURCES} BL31_SOURCES += drivers/arm/smmu/smmu_v3.c \ + drivers/cfi/v2m/v2m_flash.c \ lib/utils/mem_region.c \ plat/arm/board/fvp/fvp_bl31_setup.c \ plat/arm/board/fvp/fvp_pm.c \ plat/arm/board/fvp/fvp_topology.c \ plat/arm/board/fvp/aarch64/fvp_helpers.S \ plat/arm/board/fvp/drivers/pwrc/fvp_pwrc.c \ - plat/arm/board/common/drivers/norflash/norflash.c \ plat/arm/common/arm_nor_psci_mem_protect.c \ ${FVP_CPU_LIBS} \ ${FVP_GIC_SOURCES} \ diff --git a/plat/arm/board/fvp/sp_min/sp_min-fvp.mk b/plat/arm/board/fvp/sp_min/sp_min-fvp.mk index b370fd55a..8b17c9b73 100644 --- a/plat/arm/board/fvp/sp_min/sp_min-fvp.mk +++ b/plat/arm/board/fvp/sp_min/sp_min-fvp.mk @@ -1,17 +1,17 @@ # -# Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # # SP_MIN source files specific to FVP platform -BL32_SOURCES += lib/utils/mem_region.c \ +BL32_SOURCES += drivers/cfi/v2m/v2m_flash.c \ + lib/utils/mem_region.c \ plat/arm/board/fvp/aarch32/fvp_helpers.S \ plat/arm/board/fvp/drivers/pwrc/fvp_pwrc.c \ plat/arm/board/fvp/fvp_pm.c \ plat/arm/board/fvp/fvp_topology.c \ plat/arm/board/fvp/sp_min/fvp_sp_min_setup.c \ - plat/arm/board/common/drivers/norflash/norflash.c \ plat/arm/common/arm_nor_psci_mem_protect.c \ ${FVP_CPU_LIBS} \ ${FVP_GIC_SOURCES} \ diff --git a/plat/arm/board/juno/platform.mk b/plat/arm/board/juno/platform.mk index 90fa938a3..6e137a765 100644 --- a/plat/arm/board/juno/platform.mk +++ b/plat/arm/board/juno/platform.mk @@ -73,12 +73,12 @@ BL2_SOURCES += lib/utils/mem_region.c \ BL2U_SOURCES += ${JUNO_SECURITY_SOURCES} -BL31_SOURCES += lib/cpus/aarch64/cortex_a53.S \ +BL31_SOURCES += drivers/cfi/v2m/v2m_flash.c \ + lib/cpus/aarch64/cortex_a53.S \ lib/cpus/aarch64/cortex_a57.S \ lib/cpus/aarch64/cortex_a72.S \ lib/utils/mem_region.c \ plat/arm/board/juno/juno_topology.c \ - plat/arm/board/common/drivers/norflash/norflash.c \ plat/arm/common/arm_nor_psci_mem_protect.c \ ${JUNO_GIC_SOURCES} \ ${JUNO_INTERCONNECT_SOURCES} \ diff --git a/plat/arm/board/juno/sp_min/sp_min-juno.mk b/plat/arm/board/juno/sp_min/sp_min-juno.mk index cd1f4976c..52781093f 100644 --- a/plat/arm/board/juno/sp_min/sp_min-juno.mk +++ b/plat/arm/board/juno/sp_min/sp_min-juno.mk @@ -1,15 +1,15 @@ # -# Copyright (c) 2016, ARM Limited and Contributors. All rights reserved. +# Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. # # SPDX-License-Identifier: BSD-3-Clause # # SP_MIN source files specific to JUNO platform -BL32_SOURCES += lib/cpus/aarch32/cortex_a53.S \ +BL32_SOURCES += drivers/cfi/v2m/v2m_flash.c \ + lib/cpus/aarch32/cortex_a53.S \ lib/cpus/aarch32/cortex_a57.S \ lib/cpus/aarch32/cortex_a72.S \ lib/utils/mem_region.c \ - plat/arm/board/common/drivers/norflash/norflash.c \ plat/arm/board/juno/juno_topology.c \ plat/arm/common/arm_nor_psci_mem_protect.c \ plat/arm/soc/common/soc_css_security.c \ diff --git a/plat/arm/board/sgi575/platform.mk b/plat/arm/board/sgi575/platform.mk index 284bae8aa..078f393c9 100644 --- a/plat/arm/board/sgi575/platform.mk +++ b/plat/arm/board/sgi575/platform.mk @@ -9,6 +9,6 @@ include plat/arm/css/sgi/sgi-common.mk BL2_SOURCES += lib/utils/mem_region.c \ plat/arm/common/arm_nor_psci_mem_protect.c -BL31_SOURCES += lib/utils/mem_region.c \ - plat/arm/board/common/drivers/norflash/norflash.c \ +BL31_SOURCES += drivers/cfi/v2m/v2m_flash.c \ + lib/utils/mem_region.c \ plat/arm/common/arm_nor_psci_mem_protect.c diff --git a/plat/arm/board/sgm775/platform.mk b/plat/arm/board/sgm775/platform.mk index 633cee664..c8337554a 100644 --- a/plat/arm/board/sgm775/platform.mk +++ b/plat/arm/board/sgm775/platform.mk @@ -15,6 +15,6 @@ PLAT_INCLUDES +=-I${SGM775_BASE}/include/ BL2_SOURCES += lib/utils/mem_region.c \ plat/arm/common/arm_nor_psci_mem_protect.c -BL31_SOURCES += lib/utils/mem_region.c \ - plat/arm/board/common/drivers/norflash/norflash.c \ +BL31_SOURCES += drivers/cfi/v2m/v2m_flash.c \ + lib/utils/mem_region.c \ plat/arm/common/arm_nor_psci_mem_protect.c diff --git a/plat/arm/common/arm_err.c b/plat/arm/common/arm_err.c index e13e51f78..519d44d7d 100644 --- a/plat/arm/common/arm_err.c +++ b/plat/arm/common/arm_err.c @@ -8,10 +8,10 @@ #include #include #include -#include #include #include #include +#include #pragma weak plat_arm_error_handler diff --git a/plat/arm/common/arm_nor_psci_mem_protect.c b/plat/arm/common/arm_nor_psci_mem_protect.c index 1b0b1da66..07766a0fd 100644 --- a/plat/arm/common/arm_nor_psci_mem_protect.c +++ b/plat/arm/common/arm_nor_psci_mem_protect.c @@ -6,12 +6,11 @@ #include #include -#include #include #include #include #include - +#include /* * DRAM1 is used also to load the NS boot loader. For this reason we