Merge branch 'master' of git://git.denx.de/u-boot-spi
authorTom Rini <trini@konsulko.com>
Fri, 16 Dec 2016 23:32:43 +0000 (18:32 -0500)
committerTom Rini <trini@konsulko.com>
Fri, 16 Dec 2016 23:32:43 +0000 (18:32 -0500)
56 files changed:
.travis.yml
arch/arm/Kconfig
arch/arm/config.mk
arch/arm/cpu/armv8/Kconfig
arch/arm/cpu/armv8/Makefile
arch/arm/cpu/armv8/cpu-dt.c
arch/arm/cpu/armv8/cpu.c
arch/arm/cpu/armv8/fsl-layerscape/Kconfig
arch/arm/cpu/armv8/fsl-layerscape/Makefile
arch/arm/cpu/armv8/fsl-layerscape/cpu.c
arch/arm/cpu/armv8/fsl-layerscape/fdt.c
arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S [new file with mode: 0644]
arch/arm/cpu/armv8/psci.S [new file with mode: 0644]
arch/arm/cpu/armv8/sec_firmware.c
arch/arm/cpu/armv8/sec_firmware_asm.S
arch/arm/cpu/armv8/u-boot.lds
arch/arm/dts/fsl-ls1043a-qds.dtsi
arch/arm/dts/fsl-ls1043a-rdb.dts
arch/arm/include/asm/armv8/sec_firmware.h
arch/arm/include/asm/macro.h
arch/arm/include/asm/psci.h
arch/arm/include/asm/secure.h
arch/arm/include/asm/system.h
arch/arm/lib/bootm-fdt.c
arch/arm/lib/bootm.c
arch/arm/lib/psci-dt.c
arch/powerpc/include/asm/config_mpc85xx.h
board/freescale/b4860qds/ddr.c
board/freescale/ls1043aqds/ddr.c
board/freescale/ls1043ardb/Kconfig
board/freescale/ls1043ardb/ddr.c
board/freescale/ls1046aqds/ddr.c
board/freescale/ls1046ardb/ddr.c
board/freescale/ls2080ardb/ddr.c
board/freescale/t102xqds/ddr.c
board/freescale/t102xrdb/ddr.c
board/freescale/t1040qds/ddr.c
board/freescale/t104xrdb/ddr.c
board/freescale/t208xqds/ddr.c
board/freescale/t208xrdb/ddr.c
board/freescale/t4qds/ddr.c
board/freescale/t4rdb/ddr.c
drivers/net/fsl-mc/dpio/qbman_portal.c
drivers/net/fsl-mc/dpio/qbman_portal.h
drivers/net/fsl-mc/dpio/qbman_private.h
drivers/net/fsl-mc/dpio/qbman_sys.h
include/configs/armadillo-800eva.h
include/configs/blanche.h
include/configs/colibri_imx7.h
include/configs/colibri_vf.h
include/configs/exynos-common.h
include/configs/ls1043ardb.h
include/configs/pcm052.h
include/configs/tegra-common.h
include/configs/uniphier.h
include/configs/vf610twr.h

index 51f14c85b283c336ce1e49a77f5305bd11aec99e..6c4ea59c3c7f6f518994b5874769e241582cbc96 100644 (file)
@@ -306,5 +306,11 @@ matrix:
           BUILDMAN="^qemu-x86$"
           TOOLCHAIN="x86_64"
           BUILD_ROM="yes"
+    - env:
+        - TEST_PY_BD="zynq_zc702"
+          TEST_PY_TEST_SPEC="not sleep"
+          QEMU_TARGET="arm-softmmu"
+          TEST_PY_ID="--id qemu"
+          BUILDMAN="^zynq_zc702$"
 
 # TODO make it perfect ;-r
index 714dd8b51493d21990e593cbd2dcee370dd490df..587f28892583e706185c9932903b2f1fb0416975 100644 (file)
@@ -126,6 +126,24 @@ config ENABLE_ARM_SOC_BOOT0_HOOK
          ARM_SOC_BOOT0_HOOK which contains the required assembler
          preprocessor code.
 
+config USE_ARCH_MEMCPY
+       bool "Use an assembly optimized implementation of memcpy"
+       default y if CPU_V7
+       depends on !ARM64 && !SPL
+       help
+         Enable the generation of an optimized version of memcpy.
+         Such implementation may be faster under some conditions
+         but may increase the binary size.
+
+config USE_ARCH_MEMSET
+       bool "Use an assembly optimized implementation of memset"
+       default y if CPU_V7
+       depends on !ARM64 && !SPL
+       help
+         Enable the generation of an optimized version of memset.
+         Such implementation may be faster under some conditions
+         but may increase the binary size.
+
 config ARCH_OMAP2
        bool
        select CPU_V7
index 008da39a6c02d11b5b8aa02a34363d9cc3b187e0..3a81f131e2c7c3f5ac7faf9e257c0af96e09af35 100644 (file)
@@ -121,7 +121,8 @@ endif
 
 # limit ourselves to the sections we want in the .bin.
 ifdef CONFIG_ARM64
-OBJCOPYFLAGS += -j .text -j .rodata -j .data -j .u_boot_list -j .rela.dyn
+OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .data \
+               -j .u_boot_list -j .rela.dyn
 else
 OBJCOPYFLAGS += -j .text -j .secure_text -j .secure_data -j .rodata -j .hash \
                -j .data -j .got -j .got.plt -j .u_boot_list -j .rel.dyn
index 965a8d129c1d0055a1decde4f38d898c1905452e..22dce8807650013f2fb7e0788f8adec2fd1f03d0 100644 (file)
@@ -40,4 +40,45 @@ config PSCI_RESET
 
          Select Y here to make use of PSCI calls for system reset
 
+config ARMV8_PSCI
+       bool "Enable PSCI support" if EXPERT
+       default n
+       help
+         PSCI is Power State Coordination Interface defined by ARM.
+         The PSCI in U-boot provides a general framework and each platform
+         can implement their own specific PSCI functions.
+         Say Y here to enable PSCI support on ARMv8 platform.
+
+config ARMV8_PSCI_NR_CPUS
+       int "Maximum supported CPUs for PSCI"
+       depends on ARMV8_PSCI
+       default 4
+       help
+         The maximum number of CPUs supported in the PSCI firmware.
+         It is no problem to set a larger value than the number of CPUs in
+         the actual hardware implementation.
+
+config ARMV8_PSCI_CPUS_PER_CLUSTER
+       int "Number of CPUs per cluster"
+       depends on ARMV8_PSCI
+       default 0
+       help
+         The number of CPUs per cluster, suppose each cluster has same number
+         of CPU cores, platforms with asymmetric clusters don't apply here.
+         A value 0 or no definition of it works for single cluster system.
+         System with multi-cluster should difine their own exact value.
+
+if SYS_HAS_ARMV8_SECURE_BASE
+
+config ARMV8_SECURE_BASE
+       hex "Secure address for PSCI image"
+       depends on ARMV8_PSCI
+       help
+         Address for placing the PSCI text, data and stack sections.
+         If not defined, the PSCI sections are placed together with the u-boot
+         but platform can choose to place PSCI code image separately in other
+         places such as some secure RAM built-in SOC etc.
+
+endif
+
 endif
index dea14657d9aef4ff3ef974cbceb75dd061536107..28ba7862072a2cc165c87bea0877e9422a76c520 100644 (file)
@@ -25,3 +25,4 @@ obj-$(CONFIG_FSL_LAYERSCAPE) += fsl-layerscape/
 obj-$(CONFIG_S32V234) += s32v234/
 obj-$(CONFIG_ARCH_ZYNQMP) += zynqmp/
 obj-$(CONFIG_TARGET_HIKEY) += hisilicon/
+obj-$(CONFIG_ARMV8_PSCI) += psci.o
index 9ffb49c37cd6f0ebbd173b32c76aa4aa397f8e35..3a5afe89be18adeba33bb4c0be116a4a0dbe9068 100644 (file)
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <asm/psci.h>
+#include <asm/system.h>
 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 #include <asm/armv8/sec_firmware.h>
 #endif
@@ -13,7 +14,8 @@
 int psci_update_dt(void *fdt)
 {
 #ifdef CONFIG_MP
-#if defined(CONFIG_ARMV8_PSCI)
+#if defined(CONFIG_ARMV8_PSCI) || defined(CONFIG_FSL_PPA_ARMV8_PSCI)
+
 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
        /*
         * If the PSCI in SEC Firmware didn't work, avoid to update the
@@ -25,6 +27,13 @@ int psci_update_dt(void *fdt)
                return 0;
 #endif
        fdt_psci(fdt);
+
+#if defined(CONFIG_ARMV8_PSCI) && !defined(CONFIG_ARMV8_SECURE_BASE)
+       /* secure code lives in RAM, keep it alive */
+       fdt_add_mem_rsv(fdt, (unsigned long)__secure_start,
+                       __secure_end - __secure_start);
+#endif
+
 #endif
 #endif
        return 0;
index e06c3cc04de47cae7374ca725d33120933cfbbd4..5dcb5e290b12e5fbd594ed1b3f5ea55cde8ca64c 100644 (file)
@@ -14,6 +14,7 @@
 #include <common.h>
 #include <command.h>
 #include <asm/system.h>
+#include <asm/secure.h>
 #include <linux/compiler.h>
 
 int cleanup_before_linux(void)
@@ -41,3 +42,24 @@ int cleanup_before_linux(void)
 
        return 0;
 }
+
+#ifdef CONFIG_ARMV8_PSCI
+static void relocate_secure_section(void)
+{
+#ifdef CONFIG_ARMV8_SECURE_BASE
+       size_t sz = __secure_end - __secure_start;
+
+       memcpy((void *)CONFIG_ARMV8_SECURE_BASE, __secure_start, sz);
+       flush_dcache_range(CONFIG_ARMV8_SECURE_BASE,
+                          CONFIG_ARMV8_SECURE_BASE + sz + 1);
+       invalidate_icache_all();
+#endif
+}
+
+void armv8_setup_psci(void)
+{
+       relocate_secure_section();
+       secure_ram_addr(psci_setup_vectors)();
+       secure_ram_addr(psci_arch_init)();
+}
+#endif
index 6772584a60422c8c14ee47033e43264d59659e05..cc0dc889ae9ffb1d8197211bf829979dcde19f9d 100644 (file)
@@ -44,6 +44,27 @@ config FSL_LSCH3
 menu "Layerscape architecture"
        depends on FSL_LSCH2 || FSL_LSCH3
 
+menu "Layerscape PPA"
+config FSL_LS_PPA
+       bool "FSL Layerscape PPA firmware support"
+       depends on !ARMV8_PSCI
+       depends on ARCH_LS1043A || ARCH_LS1046A
+       select FSL_PPA_ARMV8_PSCI
+       help
+         The FSL Primary Protected Application (PPA) is a software component
+         which is loaded during boot stage, and then remains resident in RAM
+         and runs in the TrustZone after boot.
+         Say y to enable it.
+
+config FSL_PPA_ARMV8_PSCI
+       bool "PSCI implementation in PPA firmware"
+       depends on FSL_LS_PPA
+       help
+         This config enables the ARMv8 PSCI implementation in PPA firmware.
+         This is a private PSCI implementation and different from those
+         implemented under the common ARMv8 PSCI framework.
+endmenu
+
 config SYS_FSL_MMDC
        bool
 
index 51c1ceeb838e9e8bc7cd334fe0fd6b231078b508..423b4b39a8a6a36140172d00845076f10c6321f3 100644 (file)
@@ -28,6 +28,7 @@ endif
 
 ifneq ($(CONFIG_LS1043A),)
 obj-$(CONFIG_SYS_HAS_SERDES) += ls1043a_serdes.o
+obj-$(CONFIG_ARMV8_PSCI) += ls1043a_psci.o
 endif
 
 ifneq ($(CONFIG_ARCH_LS1012A),)
index ffbbd729d461da29f4395cfd25d144d3cf8248b8..467d9af9200ab6dc26fd5a7eaddb9976c7ab2421 100644 (file)
@@ -410,7 +410,8 @@ int arch_early_init_r(void)
        erratum_a009942_check_cpo();
 #endif
 #ifdef CONFIG_MP
-#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && defined(CONFIG_ARMV8_PSCI)
+#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \
+       defined(CONFIG_FSL_PPA_ARMV8_PSCI)
        /* Check the psci version to determine if the psci is supported */
        psci_ver = sec_firmware_support_psci_version();
 #endif
index 0dae5faad81038e6d587a6f386cf65df381bdd8c..c10ccf9063a6cae4977fe5da7fbacf1f152f54c3 100644 (file)
@@ -42,7 +42,8 @@ void ft_fixup_cpu(void *blob)
        int addr_cells;
        u64 val, core_id;
        size_t *boot_code_size = &(__secondary_boot_code_size);
-#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && defined(CONFIG_ARMV8_PSCI)
+#if defined(CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT) && \
+       defined(CONFIG_FSL_PPA_ARMV8_PSCI)
        int node;
        u32 psci_ver;
 
diff --git a/arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S b/arch/arm/cpu/armv8/fsl-layerscape/ls1043a_psci.S
new file mode 100644 (file)
index 0000000..86045ac
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 Freescale Semiconductor, Inc.
+ * Author: Hongbo Zhang <hongbo.zhang@nxp.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ * This file implements LS102X platform PSCI SYSTEM-SUSPEND function
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+#include <asm/psci.h>
+
+       .pushsection ._secure.text, "ax"
+
+.globl psci_version
+psci_version:
+       ldr     w0, =0x00010000         /* PSCI v1.0 */
+       ret
+
+       .popsection
diff --git a/arch/arm/cpu/armv8/psci.S b/arch/arm/cpu/armv8/psci.S
new file mode 100644 (file)
index 0000000..43d5d6b
--- /dev/null
@@ -0,0 +1,286 @@
+/*
+ * Copyright 2016 Freescale Semiconductor, Inc.
+ * Author: Hongbo Zhang <hongbo.zhang@nxp.com>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ * This file implements LS102X platform PSCI SYSTEM-SUSPEND function
+ */
+
+#include <config.h>
+#include <linux/linkage.h>
+#include <asm/psci.h>
+
+/* Default PSCI function, return -1, Not Implemented */
+#define PSCI_DEFAULT(__fn) \
+       ENTRY(__fn); \
+       mov     w0, #ARM_PSCI_RET_NI; \
+       ret; \
+       ENDPROC(__fn); \
+       .weak __fn
+
+/* PSCI function and ID table definition*/
+#define PSCI_TABLE(__id, __fn) \
+       .word __id; \
+       .word __fn
+
+.pushsection ._secure.text, "ax"
+
+/* 32 bits PSCI default functions */
+PSCI_DEFAULT(psci_version)
+PSCI_DEFAULT(psci_cpu_suspend)
+PSCI_DEFAULT(psci_cpu_off)
+PSCI_DEFAULT(psci_cpu_on)
+PSCI_DEFAULT(psci_affinity_info)
+PSCI_DEFAULT(psci_migrate)
+PSCI_DEFAULT(psci_migrate_info_type)
+PSCI_DEFAULT(psci_migrate_info_up_cpu)
+PSCI_DEFAULT(psci_system_off)
+PSCI_DEFAULT(psci_system_reset)
+PSCI_DEFAULT(psci_features)
+PSCI_DEFAULT(psci_cpu_freeze)
+PSCI_DEFAULT(psci_cpu_default_suspend)
+PSCI_DEFAULT(psci_node_hw_state)
+PSCI_DEFAULT(psci_system_suspend)
+PSCI_DEFAULT(psci_set_suspend_mode)
+PSCI_DEFAULT(psi_stat_residency)
+PSCI_DEFAULT(psci_stat_count)
+
+.align 3
+_psci_32_table:
+PSCI_TABLE(ARM_PSCI_FN_CPU_SUSPEND, psci_cpu_suspend)
+PSCI_TABLE(ARM_PSCI_FN_CPU_OFF, psci_cpu_off)
+PSCI_TABLE(ARM_PSCI_FN_CPU_ON, psci_cpu_on)
+PSCI_TABLE(ARM_PSCI_FN_MIGRATE, psci_migrate)
+PSCI_TABLE(ARM_PSCI_0_2_FN_PSCI_VERSION, psci_version)
+PSCI_TABLE(ARM_PSCI_0_2_FN_CPU_SUSPEND, psci_cpu_suspend)
+PSCI_TABLE(ARM_PSCI_0_2_FN_CPU_OFF, psci_cpu_off)
+PSCI_TABLE(ARM_PSCI_0_2_FN_CPU_ON, psci_cpu_on)
+PSCI_TABLE(ARM_PSCI_0_2_FN_AFFINITY_INFO, psci_affinity_info)
+PSCI_TABLE(ARM_PSCI_0_2_FN_MIGRATE, psci_migrate)
+PSCI_TABLE(ARM_PSCI_0_2_FN_MIGRATE_INFO_TYPE, psci_migrate_info_type)
+PSCI_TABLE(ARM_PSCI_0_2_FN_MIGRATE_INFO_UP_CPU, psci_migrate_info_up_cpu)
+PSCI_TABLE(ARM_PSCI_0_2_FN_SYSTEM_OFF, psci_system_off)
+PSCI_TABLE(ARM_PSCI_0_2_FN_SYSTEM_RESET, psci_system_reset)
+PSCI_TABLE(ARM_PSCI_1_0_FN_PSCI_FEATURES, psci_features)
+PSCI_TABLE(ARM_PSCI_1_0_FN_CPU_FREEZE, psci_cpu_freeze)
+PSCI_TABLE(ARM_PSCI_1_0_FN_CPU_DEFAULT_SUSPEND, psci_cpu_default_suspend)
+PSCI_TABLE(ARM_PSCI_1_0_FN_NODE_HW_STATE, psci_node_hw_state)
+PSCI_TABLE(ARM_PSCI_1_0_FN_SYSTEM_SUSPEND, psci_system_suspend)
+PSCI_TABLE(ARM_PSCI_1_0_FN_SET_SUSPEND_MODE, psci_set_suspend_mode)
+PSCI_TABLE(ARM_PSCI_1_0_FN_STAT_RESIDENCY, psi_stat_residency)
+PSCI_TABLE(ARM_PSCI_1_0_FN_STAT_COUNT, psci_stat_count)
+PSCI_TABLE(0, 0)
+
+/* 64 bits PSCI default functions */
+PSCI_DEFAULT(psci_cpu_suspend_64)
+PSCI_DEFAULT(psci_cpu_on_64)
+PSCI_DEFAULT(psci_affinity_info_64)
+PSCI_DEFAULT(psci_migrate_64)
+PSCI_DEFAULT(psci_migrate_info_up_cpu_64)
+PSCI_DEFAULT(psci_cpu_default_suspend_64)
+PSCI_DEFAULT(psci_node_hw_state_64)
+PSCI_DEFAULT(psci_system_suspend_64)
+PSCI_DEFAULT(psci_stat_residency_64)
+PSCI_DEFAULT(psci_stat_count_64)
+
+.align 3
+_psci_64_table:
+PSCI_TABLE(ARM_PSCI_0_2_FN64_CPU_SUSPEND, psci_cpu_suspend_64)
+PSCI_TABLE(ARM_PSCI_0_2_FN64_CPU_ON, psci_cpu_on_64)
+PSCI_TABLE(ARM_PSCI_0_2_FN64_AFFINITY_INFO, psci_affinity_info_64)
+PSCI_TABLE(ARM_PSCI_0_2_FN64_MIGRATE, psci_migrate_64)
+PSCI_TABLE(ARM_PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU, psci_migrate_info_up_cpu_64)
+PSCI_TABLE(ARM_PSCI_1_0_FN64_CPU_DEFAULT_SUSPEND, psci_cpu_default_suspend_64)
+PSCI_TABLE(ARM_PSCI_1_0_FN64_NODE_HW_STATE, psci_node_hw_state_64)
+PSCI_TABLE(ARM_PSCI_1_0_FN64_SYSTEM_SUSPEND, psci_system_suspend_64)
+PSCI_TABLE(ARM_PSCI_1_0_FN64_STAT_RESIDENCY, psci_stat_residency_64)
+PSCI_TABLE(ARM_PSCI_1_0_FN64_STAT_COUNT, psci_stat_count_64)
+PSCI_TABLE(0, 0)
+
+.macro psci_enter
+       /* PSCI call is Fast Call(atomic), so mask DAIF */
+       mrs     x15, DAIF
+       stp     x15, xzr, [sp, #-16]!
+       ldr     x15, =0x3C0
+       msr     DAIF, x15
+       /* SMC convention, x18 ~ x30 should be saved by callee */
+       stp     x29, x30, [sp, #-16]!
+       stp     x27, x28, [sp, #-16]!
+       stp     x25, x26, [sp, #-16]!
+       stp     x23, x24, [sp, #-16]!
+       stp     x21, x22, [sp, #-16]!
+       stp     x19, x20, [sp, #-16]!
+       mrs     x15, elr_el3
+       stp     x18, x15, [sp, #-16]!
+.endm
+
+.macro psci_return
+       /* restore registers */
+       ldp     x18, x15, [sp], #16
+       msr     elr_el3, x15
+       ldp     x19, x20, [sp], #16
+       ldp     x21, x22, [sp], #16
+       ldp     x23, x24, [sp], #16
+       ldp     x25, x26, [sp], #16
+       ldp     x27, x28, [sp], #16
+       ldp     x29, x30, [sp], #16
+       /* restore DAIF */
+       ldp     x15, xzr, [sp], #16
+       msr     DAIF, x15
+       eret
+.endm
+
+/* Caller must put PSCI function-ID table base in x9 */
+handle_psci:
+       psci_enter
+1:     ldr x10, [x9]                   /* Load PSCI function table */
+       ubfx x11, x10, #32, #32
+       ubfx x10, x10, #0, #32
+       cbz     x10, 3f                 /* If reach the end, bail out */
+       cmp     x10, x0
+       b.eq    2f                      /* PSCI function found */
+       add x9, x9, #8                  /* If not match, try next entry */
+       b       1b
+
+2:     blr     x11                     /* Call PSCI function */
+       psci_return
+
+3:     mov     x0, #ARM_PSCI_RET_NI
+       psci_return
+
+unknown_smc_id:
+       ldr     x0, =0xFFFFFFFF
+       eret
+
+handle_smc32:
+       /* SMC function ID  0x84000000-0x8400001F: 32 bits PSCI */
+       ldr     w9, =0x8400001F
+       cmp     w0, w9
+       b.gt    unknown_smc_id
+       ldr     w9, =0x84000000
+       cmp     w0, w9
+       b.lt    unknown_smc_id
+
+       adr     x9, _psci_32_table
+       b       handle_psci
+
+handle_smc64:
+       /* check SMC32 or SMC64 calls */
+       ubfx    x9, x0, #30, #1
+       cbz     x9, handle_smc32
+
+       /* SMC function ID 0xC4000000-0xC400001F: 64 bits PSCI */
+       ldr     x9, =0xC400001F
+       cmp     x0, x9
+       b.gt    unknown_smc_id
+       ldr     x9, =0xC4000000
+       cmp     x0, x9
+       b.lt    unknown_smc_id
+
+       adr     x9, _psci_64_table
+       b       handle_psci
+
+/*
+ * Get CPU ID from MPIDR, suppose every cluster has same number of CPU cores,
+ * Platform with asymmetric clusters should implement their own interface.
+ * In case this function being called by other platform's C code, the ARM
+ * Architecture Procedure Call Standard is considered, e.g. register X0 is
+ * used for the return value, while in this PSCI environment, X0 usually holds
+ * the SMC function identifier, so X0 should be saved by caller function.
+ */
+ENTRY(psci_get_cpu_id)
+#ifdef CONFIG_ARMV8_PSCI_CPUS_PER_CLUSTER
+       mrs     x9, MPIDR_EL1
+       ubfx    x9, x9, #8, #8
+       ldr     x10, =CONFIG_ARMV8_PSCI_CPUS_PER_CLUSTER
+       mul     x9, x10, x9
+#else
+       mov     x9, xzr
+#endif
+       mrs     x10, MPIDR_EL1
+       ubfx    x10, x10, #0, #8
+       add     x0, x10, x9
+       ret
+ENDPROC(psci_get_cpu_id)
+.weak psci_get_cpu_id
+
+/* CPU ID input in x0, stack top output in x0*/
+LENTRY(psci_get_cpu_stack_top)
+       adr     x9, __secure_stack_end
+       lsl     x0, x0, #ARM_PSCI_STACK_SHIFT
+       sub     x0, x9, x0
+       ret
+ENDPROC(psci_get_cpu_stack_top)
+
+unhandled_exception:
+       b       unhandled_exception     /* simply dead loop */
+
+handle_sync:
+       mov     x15, x30
+       mov     x14, x0
+
+       bl      psci_get_cpu_id
+       bl      psci_get_cpu_stack_top
+       mov     x9, #1
+       msr     spsel, x9
+       mov     sp, x0
+
+       mov     x0, x14
+       mov     x30, x15
+
+       mrs     x9, esr_el3
+       ubfx    x9, x9, #26, #6
+       cmp     x9, #0x13
+       b.eq    handle_smc32
+       cmp     x9, #0x17
+       b.eq    handle_smc64
+
+       b       unhandled_exception
+
+       .align  11
+       .globl  el3_exception_vectors
+el3_exception_vectors:
+       b       unhandled_exception     /* Sync, Current EL using SP0 */
+       .align  7
+       b       unhandled_exception     /* IRQ, Current EL using SP0 */
+       .align  7
+       b       unhandled_exception     /* FIQ, Current EL using SP0 */
+       .align  7
+       b       unhandled_exception     /* SError, Current EL using SP0 */
+       .align  7
+       b       unhandled_exception     /* Sync, Current EL using SPx */
+       .align  7
+       b       unhandled_exception     /* IRQ, Current EL using SPx */
+       .align  7
+       b       unhandled_exception     /* FIQ, Current EL using SPx */
+       .align  7
+       b       unhandled_exception     /* SError, Current EL using SPx */
+       .align  7
+       b       handle_sync             /* Sync, Lower EL using AArch64 */
+       .align  7
+       b       unhandled_exception     /* IRQ, Lower EL using AArch64 */
+       .align  7
+       b       unhandled_exception     /* FIQ, Lower EL using AArch64 */
+       .align  7
+       b       unhandled_exception     /* SError, Lower EL using AArch64 */
+       .align  7
+       b       unhandled_exception     /* Sync, Lower EL using AArch32 */
+       .align  7
+       b       unhandled_exception     /* IRQ, Lower EL using AArch32 */
+       .align  7
+       b       unhandled_exception     /* FIQ, Lower EL using AArch32 */
+       .align  7
+       b       unhandled_exception     /* SError, Lower EL using AArch32 */
+
+ENTRY(psci_setup_vectors)
+       adr     x0, el3_exception_vectors
+       msr     vbar_el3, x0
+       ret
+ENDPROC(psci_setup_vectors)
+
+ENTRY(psci_arch_init)
+       ret
+ENDPROC(psci_arch_init)
+.weak psci_arch_init
+
+.popsection
index 2ddd67ef6cf9cb9511ef187ee6c295cd402e2f61..0b973f02f6a5496d11e766caa1f81f9c89289a19 100644 (file)
@@ -209,7 +209,7 @@ __weak bool sec_firmware_is_valid(const void *sec_firmware_img)
        return true;
 }
 
-#ifdef CONFIG_ARMV8_PSCI
+#ifdef CONFIG_FSL_PPA_ARMV8_PSCI
 /*
  * The PSCI_VERSION function is added from PSCI v0.2. When the PSCI
  * v0.1 received this function, the NOT_SUPPORTED (0xffff_ffff) error
index 1b39f1d3227a4cb754660bd48fb92283d3793a6c..903195dbce3f9599fa6c01db9c1773dbbade92c9 100644 (file)
@@ -41,7 +41,7 @@ WEAK(_sec_firmware_entry)
         ret
 ENDPROC(_sec_firmware_entry)
 
-#ifdef CONFIG_ARMV8_PSCI
+#ifdef CONFIG_FSL_PPA_ARMV8_PSCI
 ENTRY(_sec_firmware_support_psci_version)
        mov     x0, 0x84000000
        mov     x1, 0x0
index fd15ad59637dabe86f3a1334570c76b951a0426f..22195b8834b52c063f3f94406dffba221c3a04d7 100644 (file)
@@ -8,11 +8,17 @@
  * SPDX-License-Identifier:    GPL-2.0+
  */
 
+#include <config.h>
+#include <asm/psci.h>
+
 OUTPUT_FORMAT("elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64")
 OUTPUT_ARCH(aarch64)
 ENTRY(_start)
 SECTIONS
 {
+#ifdef CONFIG_ARMV8_SECURE_BASE
+       /DISCARD/ : { *(.rela._secure*) }
+#endif
        . = 0x00000000;
 
        . = ALIGN(8);
@@ -23,6 +29,57 @@ SECTIONS
                *(.text*)
        }
 
+#ifdef CONFIG_ARMV8_PSCI
+       .__secure_start :
+#ifndef CONFIG_ARMV8_SECURE_BASE
+               ALIGN(CONSTANT(COMMONPAGESIZE))
+#endif
+       {
+               KEEP(*(.__secure_start))
+       }
+
+#ifndef CONFIG_ARMV8_SECURE_BASE
+#define CONFIG_ARMV8_SECURE_BASE
+#define __ARMV8_PSCI_STACK_IN_RAM
+#endif
+       .secure_text CONFIG_ARMV8_SECURE_BASE :
+               AT(ADDR(.__secure_start) + SIZEOF(.__secure_start))
+       {
+               *(._secure.text)
+       }
+
+       .secure_data : AT(LOADADDR(.secure_text) + SIZEOF(.secure_text))
+       {
+               *(._secure.data)
+       }
+
+       .secure_stack ALIGN(ADDR(.secure_data) + SIZEOF(.secure_data),
+                           CONSTANT(COMMONPAGESIZE)) (NOLOAD) :
+#ifdef __ARMV8_PSCI_STACK_IN_RAM
+               AT(ADDR(.secure_stack))
+#else
+               AT(LOADADDR(.secure_data) + SIZEOF(.secure_data))
+#endif
+       {
+               KEEP(*(.__secure_stack_start))
+
+               . = . + CONFIG_ARMV8_PSCI_NR_CPUS * ARM_PSCI_STACK_SIZE;
+
+               . = ALIGN(CONSTANT(COMMONPAGESIZE));
+
+               KEEP(*(.__secure_stack_end))
+       }
+
+#ifndef __ARMV8_PSCI_STACK_IN_RAM
+       . = LOADADDR(.secure_stack);
+#endif
+
+       .__secure_end : AT(ADDR(.__secure_end)) {
+               KEEP(*(.__secure_end))
+               LONG(0x1d1071c);        /* Must output something to reset LMA */
+       }
+#endif
+
        . = ALIGN(8);
        .rodata : { *(SORT_BY_ALIGNMENT(SORT_BY_NAME(.rodata*))) }
 
index 2e9f1f917c5f74bd8eb5af3fc0871025942936ad..21011720dd7d0ba7640f5440b70c89c44209fb99 100644 (file)
        #size-cells = <1>;
        /* NOR, NAND Flashes and FPGA on board */
        ranges = <0x0 0x0 0x0 0x60000000 0x08000000
-                 0x2 0x0 0x0 0x7e800000 0x00010000
-                 0x3 0x0 0x0 0x7fb00000 0x00000100>;
+                 0x1 0x0 0x0 0x7e800000 0x00010000
+                 0x2 0x0 0x0 0x7fb00000 0x00000100>;
        status = "okay";
 
        nor@0,0 {
                device-width = <1>;
        };
 
-       nand@2,0 {
+       nand@1,0 {
                compatible = "fsl,ifc-nand";
                #address-cells = <1>;
                #size-cells = <1>;
                reg = <0x1 0x0 0x10000>;
        };
 
-       fpga: board-control@3,0 {
+       fpga: board-control@2,0 {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "simple-bus";
-               reg = <0x3 0x0 0x0000100>;
+               reg = <0x2 0x0 0x0000100>;
                bank-width = <1>;
                device-width = <1>;
-               ranges = <0 3 0 0x100>;
+               ranges = <0 2 0 0x100>;
        };
 };
 
index 16c5c89d7c799c1c2d94c6e62e058e1151e993e5..f271e714b18e4be8504f1d5bcddc25c56f0dcfd0 100644 (file)
                compatible = "adi,adt7461a";
                reg = <0x4c>;
        };
-       eeprom@56 {
+       eeprom@52 {
                compatible = "at24,24c512";
                reg = <0x52>;
        };
 
-       eeprom@57 {
+       eeprom@53 {
                compatible = "at24,24c512";
                reg = <0x53>;
        };
@@ -69,8 +69,8 @@
        #size-cells = <1>;
        /* NOR, NAND Flashes and FPGA on board */
        ranges = <0x0 0x0 0x0 0x60000000 0x08000000
-                 0x2 0x0 0x0 0x7e800000 0x00010000
-                 0x3 0x0 0x0 0x7fb00000 0x00000100>;
+                 0x1 0x0 0x0 0x7e800000 0x00010000
+                 0x2 0x0 0x0 0x7fb00000 0x00000100>;
 
                nor@0,0 {
                        compatible = "cfi-flash";
index eb68185feda082c03ad0d1dddfda2eaa3470773d..a4e144b171da9b83c359c906fc5f08fa830e9d35 100644 (file)
@@ -14,7 +14,7 @@
 int sec_firmware_init(const void *, u32 *, u32 *);
 int _sec_firmware_entry(const void *, u32 *, u32 *);
 bool sec_firmware_is_valid(const void *);
-#ifdef CONFIG_ARMV8_PSCI
+#ifdef CONFIG_FSL_PPA_ARMV8_PSCI
 unsigned int sec_firmware_support_psci_version(void);
 unsigned int _sec_firmware_support_psci_version(void);
 #endif
index 2553e3e349c5da1a4572fe735e0cbb5ec4ea5f04..e1916f7705d1c4a8ef830520b084356b83bd08ec 100644 (file)
@@ -182,11 +182,17 @@ lr        .req    x30
 
        /*
         * The next lower exception level is AArch64, 64bit EL2 | HCE |
-        * SMD | RES1 (Bits[5:4]) | Non-secure EL0/EL1.
+        * RES1 (Bits[5:4]) | Non-secure EL0/EL1.
+        * and the SMD depends on requirements.
         */
+#ifdef CONFIG_ARMV8_PSCI
+       ldr     \tmp, =(SCR_EL3_RW_AARCH64 | SCR_EL3_HCE_EN |\
+                       SCR_EL3_RES1 | SCR_EL3_NS_EN)
+#else
        ldr     \tmp, =(SCR_EL3_RW_AARCH64 | SCR_EL3_HCE_EN |\
                        SCR_EL3_SMD_DIS | SCR_EL3_RES1 |\
                        SCR_EL3_NS_EN)
+#endif
        msr     scr_el3, \tmp
 
        /* Return to the EL2_SP2 mode from EL3 */
index 9f1f779868381b91f14606b1f56c51f8d8348e96..ac8b00d6fc10971ca2662d5fc74c57b79cfbf169 100644 (file)
@@ -45,6 +45,9 @@
 #define ARM_PSCI_0_2_FN_BASE                   0x84000000
 #define ARM_PSCI_0_2_FN(n)                     (ARM_PSCI_0_2_FN_BASE + (n))
 
+#define ARM_PSCI_0_2_FN64_BASE                 0xC4000000
+#define ARM_PSCI_0_2_FN64(n)                   (ARM_PSCI_0_2_FN64_BASE + (n))
+
 #define ARM_PSCI_0_2_FN_PSCI_VERSION           ARM_PSCI_0_2_FN(0)
 #define ARM_PSCI_0_2_FN_CPU_SUSPEND            ARM_PSCI_0_2_FN(1)
 #define ARM_PSCI_0_2_FN_CPU_OFF                        ARM_PSCI_0_2_FN(2)
 #define ARM_PSCI_0_2_FN_SYSTEM_OFF             ARM_PSCI_0_2_FN(8)
 #define ARM_PSCI_0_2_FN_SYSTEM_RESET           ARM_PSCI_0_2_FN(9)
 
+#define ARM_PSCI_0_2_FN64_CPU_SUSPEND          ARM_PSCI_0_2_FN64(1)
+#define ARM_PSCI_0_2_FN64_CPU_ON               ARM_PSCI_0_2_FN64(3)
+#define ARM_PSCI_0_2_FN64_AFFINITY_INFO                ARM_PSCI_0_2_FN64(4)
+#define ARM_PSCI_0_2_FN64_MIGRATE              ARM_PSCI_0_2_FN64(5)
+#define ARM_PSCI_0_2_FN64_MIGRATE_INFO_UP_CPU  ARM_PSCI_0_2_FN64(7)
+
 /* PSCI 1.0 interface */
 #define ARM_PSCI_1_0_FN_PSCI_FEATURES          ARM_PSCI_0_2_FN(10)
 #define ARM_PSCI_1_0_FN_CPU_FREEZE             ARM_PSCI_0_2_FN(11)
 #define ARM_PSCI_1_0_FN_STAT_RESIDENCY         ARM_PSCI_0_2_FN(16)
 #define ARM_PSCI_1_0_FN_STAT_COUNT             ARM_PSCI_0_2_FN(17)
 
+#define ARM_PSCI_1_0_FN64_CPU_DEFAULT_SUSPEND  ARM_PSCI_0_2_FN64(12)
+#define ARM_PSCI_1_0_FN64_NODE_HW_STATE                ARM_PSCI_0_2_FN64(13)
+#define ARM_PSCI_1_0_FN64_SYSTEM_SUSPEND       ARM_PSCI_0_2_FN64(14)
+#define ARM_PSCI_1_0_FN64_STAT_RESIDENCY       ARM_PSCI_0_2_FN64(16)
+#define ARM_PSCI_1_0_FN64_STAT_COUNT           ARM_PSCI_0_2_FN64(17)
+
 /* 1KB stack per core */
 #define ARM_PSCI_STACK_SHIFT   10
 #define ARM_PSCI_STACK_SIZE    (1 << ARM_PSCI_STACK_SHIFT)
index 5a403bc0f153593163f3883692233ac1386ff81d..d23044a1c368a1d7fd5435db1ba84280f18be5d5 100644 (file)
@@ -6,7 +6,7 @@
 #define __secure __attribute__ ((section ("._secure.text")))
 #define __secure_data __attribute__ ((section ("._secure.data")))
 
-#ifdef CONFIG_ARMV7_SECURE_BASE
+#if defined(CONFIG_ARMV7_SECURE_BASE) || defined(CONFIG_ARMV8_SECURE_BASE)
 /*
  * Warning, horror ahead.
  *
index 01efc43657f3257b6b3c7c4a4dced0dbc34b1fcb..dc4c9914d7b77cbcce1d44b5b235425d88624920 100644 (file)
@@ -237,6 +237,17 @@ void smc_call(struct pt_regs *args);
 void __noreturn psci_system_reset(void);
 void __noreturn psci_system_off(void);
 
+#ifdef CONFIG_ARMV8_PSCI
+extern char __secure_start[];
+extern char __secure_end[];
+extern char __secure_stack_start[];
+extern char __secure_stack_end[];
+
+void armv8_setup_psci(void);
+void psci_setup_vectors(void);
+void psci_arch_init(void);
+#endif
+
 #endif /* __ASSEMBLY__ */
 
 #else /* CONFIG_ARM64 */
index 4481f9e2fa9ceb26f2f54f21e67f6b825c016601..e261d4febf6f63e1d69dfafbd8f31893304c1b75 100644 (file)
@@ -52,7 +52,8 @@ int arch_fixup_fdt(void *blob)
                return ret;
 #endif
 
-#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI)
+#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) || \
+       defined(CONFIG_FSL_PPA_ARMV8_PSCI)
        ret = psci_update_dt(blob);
        if (ret)
                return ret;
index 4eee13a59c4be22269751a2bc0e4278379f451d1..43cc83ec95b6f845ca76d7bcd422f4e5e297de41 100644 (file)
@@ -316,6 +316,9 @@ static void boot_jump_linux(bootm_headers_t *images, int flag)
        announce_and_cleanup(fake);
 
        if (!fake) {
+#ifdef CONFIG_ARMV8_PSCI
+               armv8_setup_psci();
+#endif
                do_nonsec_virt_switch();
 
                update_os_arch_secondary_cores(images->os.arch);
index baf6d7083f07652bf564f86cc8c89dfed80627e8..45af037f0a4833cd161cfd82ffdd1f7c78f1252c 100644 (file)
@@ -16,7 +16,8 @@
 
 int fdt_psci(void *fdt)
 {
-#if defined(CONFIG_ARMV8_PSCI) || defined(CONFIG_ARMV7_PSCI)
+#if defined(CONFIG_ARMV7_PSCI) || defined(CONFIG_ARMV8_PSCI) || \
+       defined(CONFIG_FSL_PPA_ARMV8_PSCI)
        int nodeoff;
        unsigned int psci_ver = 0;
        int tmp;
@@ -65,7 +66,7 @@ int fdt_psci(void *fdt)
 init_psci_node:
 #ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
        psci_ver = sec_firmware_support_psci_version();
-#elif defined(CONFIG_ARMV7_PSCI_1_0)
+#elif defined(CONFIG_ARMV7_PSCI_1_0) || defined(CONFIG_ARMV8_PSCI)
        psci_ver = ARM_PSCI_VER_1_0;
 #endif
        switch (psci_ver) {
index 603d6aeadc315db7428f8361529efaf3c92e0c6e..8cfc6127a7f304d43f16c23870977a028ead1ed6 100644 (file)
 #define CONFIG_SYS_FSL_ERRATUM_A007186
 #define CONFIG_SYS_FSL_ERRATUM_A006593
 #define CONFIG_SYS_FSL_ERRATUM_A007798
+#define CONFIG_SYS_FSL_ERRATUM_A009942
 #define CONFIG_SYS_FSL_SFP_VER_3_0
 #define CONFIG_SYS_FSL_PCI_VER_3_X
 
 #define CONFIG_SYS_FSL_ERRATUM_A006384
 #define CONFIG_SYS_FSL_ERRATUM_A007212
 #define CONFIG_SYS_FSL_ERRATUM_A004477
+#define CONFIG_SYS_FSL_ERRATUM_A009942
 #define CONFIG_SYS_FSL_SFP_VER_3_0
 
 #ifdef CONFIG_ARCH_B4860
@@ -626,6 +628,7 @@ defined(CONFIG_PPC_T1020) || defined(CONFIG_PPC_T1022)
 #define CONFIG_SYS_FSL_SFP_VER_3_0
 #define CONFIG_SYS_FSL_ERRATUM_A008378
 #define CONFIG_SYS_FSL_ERRATUM_A009663
+#define CONFIG_SYS_FSL_ERRATUM_A009942
 
 #elif defined(CONFIG_ARCH_T1024) || defined(CONFIG_ARCH_T1023) ||\
 defined(CONFIG_PPC_T1014) || defined(CONFIG_PPC_T1013)
@@ -668,6 +671,7 @@ defined(CONFIG_PPC_T1014) || defined(CONFIG_PPC_T1013)
 #define CONFIG_SYS_FSL_SFP_VER_3_0
 #define CONFIG_SYS_FSL_ERRATUM_A008378
 #define CONFIG_SYS_FSL_ERRATUM_A009663
+#define CONFIG_SYS_FSL_ERRATUM_A009942
 
 #elif defined(CONFIG_ARCH_T2080) || defined(CONFIG_ARCH_T2081)
 #define CONFIG_E6500
@@ -717,6 +721,7 @@ defined(CONFIG_PPC_T1014) || defined(CONFIG_PPC_T1013)
 #define CONFIG_SYS_FSL_ERRATUM_A006593
 #define CONFIG_SYS_FSL_ERRATUM_A007186
 #define CONFIG_SYS_FSL_ERRATUM_A006379
+#define CONFIG_SYS_FSL_ERRATUM_A009942
 #define ESDHCI_QUIRK_BROKEN_TIMEOUT_VALUE
 #define CONFIG_SYS_FSL_SFP_VER_3_0
 
index 31b186ea8ce9c51aaf35ed26dfc32d0a763ee764..3885acc170cb9b898cb0e6d54b841f477c51a113 100644 (file)
@@ -171,6 +171,9 @@ found:
        /* DHC_EN =1, ODT = 75 Ohm */
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_75ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_75ohm);
+
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x3e;
 }
 
 phys_size_t initdram(int board_type)
index d4540d0a9a0e4b2be5bed3e97e70a170f4f22fc3..7882a9a9a1d27761b456f08d85fe85b81c70d4f3 100644 (file)
@@ -96,6 +96,9 @@ found:
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_80ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_80ohm) |
                          DDR_CDR2_VREF_OVRD(70);       /* Vref = 70% */
+
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x59;
 #else
        popts->cswl_override = DDR_CSWL_CS0;
 
index 51818ec5801673ac140608f7f5541a073e363abf..80203a4f3b334dfd5856ab72468d77d35ac70faa 100644 (file)
@@ -13,4 +13,13 @@ config SYS_SOC
 config SYS_CONFIG_NAME
        default "ls1043ardb"
 
+config SYS_HAS_ARMV8_SECURE_BASE
+       bool "Enable secure address for PSCI image"
+       depends on ARMV8_PSCI
+       default n
+       help
+         PSCI image can be re-located to secure RAM.
+         If enabled, please also define the value for ARMV8_SECURE_BASE,
+         for LS1043ARDB, it could be some address in OCRAM.
+
 endif
index 61b1cc4f30e178561b5d8859d6e5bc36544c08d0..849f1d1b66d99041f5ebd016706f8fce5039926e 100644 (file)
@@ -91,6 +91,9 @@ found:
        /* Enable ZQ calibration */
        popts->zq_en = 1;
 
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x46;
+
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_80ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_80ohm) |
                          DDR_CDR2_VREF_OVRD(70);       /* Vref = 70% */
index d8139653add209d70a57b2c077959f0478fc9d63..4ea8b236bf7e785ea3ec2b85b067521c015c1a9d 100644 (file)
@@ -87,6 +87,9 @@ found:
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_80ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_80ohm) |
                          DDR_CDR2_VREF_TRAIN_EN | DDR_CDR2_VREF_RANGE_2;
+
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x70;
 }
 
 phys_size_t initdram(int board_type)
index a9b7dbdf90acb62f29907ee6f536e5003cce6675..dd3b5d0e6b2e92cd507d8fd5d55ff78d34b63a44 100644 (file)
@@ -91,6 +91,9 @@ found:
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_80ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_80ohm) |
                          DDR_CDR2_VREF_TRAIN_EN | DDR_CDR2_VREF_RANGE_2;
+
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x70;
 }
 
 phys_size_t initdram(int board_type)
index ecd1e71ad8fb81034a225e82f036aebac18dcb88..959dfeb02b6ac9e01325bbc915a8472d2b64d78a 100644 (file)
@@ -134,6 +134,9 @@ found:
        /* Enable ZQ calibration */
        popts->zq_en = 1;
 
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x6e;
+
        if (ddr_freq < 2350) {
                if (pdimm[0].n_ranks == 2 && pdimm[1].n_ranks == 2) {
                        /* four chip-selects */
index c26f3503b99192bf009010fe0df981c9a5f9c005..b6b11919906fd4543c2cceba0cad5dab25669f45 100644 (file)
@@ -139,6 +139,9 @@ found:
 #else
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_75ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_75ohm);
+
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x5f;
 #endif
 
        /* T1023 supports max DDR bus 32bit width, T1024 supports DDR 64bit,
index edfbdbf3a814e65b1fe3fd246b51f2fa38c9f5fd..9e1b16bfcdfc2011fb3b9f5fd2321b5afb3384b8 100644 (file)
@@ -139,6 +139,10 @@ found:
 #ifdef CONFIG_T1023RDB
        popts->wrlvl_ctl_2 = 0x07070606;
        popts->half_strength_driver_enable = 1;
+       popts->cpo_sample = 0x43;
+#elif defined(CONFIG_T1024RDB)
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x52;
 #endif
 }
 
index 82402408a74b7090326854bd7872704f2cb7b8db..cb58d1e5245b8bb5f4445e2006cbfd9211557a5c 100644 (file)
@@ -95,6 +95,9 @@ found:
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_80ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_80ohm) |
                          DDR_CDR2_VREF_OVRD(70);       /* Vref = 70% */
+
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x69;
 #else
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_75ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_75ohm);
index 22d6a5f617693c71bca2050627aa46788a4b66a3..302f19be698597115024c4c3e2c984aafd358b9d 100644 (file)
@@ -77,6 +77,8 @@ found:
         */
 #ifdef CONFIG_SYS_FSL_DDR4
        popts->half_strength_driver_enable = 1;
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x59;
 #else
        popts->half_strength_driver_enable = 0;
 #endif
index f96470f0206b551d2351369e784cca665040fc2b..d6e4554a807ad051309033f0de792d7faf872781 100644 (file)
@@ -99,6 +99,9 @@ found:
        /* DHC_EN =1, ODT = 75 Ohm */
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_75ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_75ohm);
+
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x64;
 }
 
 phys_size_t initdram(int board_type)
index f6c8ca30ac44388f35d2579e37cb2fb8c3c91098..3487261b9d8d0de44af54579ad523fd2e2ed697a 100644 (file)
@@ -92,6 +92,9 @@ found:
        /* DHC_EN =1, ODT = 75 Ohm */
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_75ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_75ohm);
+
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x54;
 }
 
 phys_size_t initdram(int board_type)
index d533924a0dd38ac76860870ba388e99d5b6383a2..842073b6c6b9240912099d2be7fdf387b1ec9da0 100644 (file)
@@ -107,6 +107,9 @@ found:
        /* DHC_EN =1, ODT = 75 Ohm */
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_75ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_75ohm);
+
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x63;
 }
 
 phys_size_t initdram(int board_type)
index 230f031a3bf8d9319869f6d22f8bc8709a2f3504..7b05821cf792a84c8ff9f8decd69ba6132f109f3 100644 (file)
@@ -100,6 +100,9 @@ found:
        /* DHC_EN =1, ODT = 75 Ohm */
        popts->ddr_cdr1 = DDR_CDR1_DHC_EN | DDR_CDR1_ODT(DDR_CDR_ODT_75ohm);
        popts->ddr_cdr2 = DDR_CDR2_ODT(DDR_CDR_ODT_75ohm);
+
+       /* optimize cpo for erratum A-009942 */
+       popts->cpo_sample = 0x64;
 }
 
 phys_size_t initdram(int board_type)
index 4b64c8ae73f3e69f7d84f7ff2ca5dcf1216e0261..86dc13d70d242c6ee6f71e59cda750dcbc1b0a04 100644 (file)
@@ -25,7 +25,7 @@
 #define QBMAN_CENA_SWP_VDQCR   0x780
 
 /* Reverse mapping of QBMAN_CENA_SWP_DQRR() */
-#define QBMAN_IDX_FROM_DQRR(p) (((unsigned long)p & 0xff) >> 6)
+#define QBMAN_IDX_FROM_DQRR(p) (((unsigned long)p & 0x1ff) >> 6)
 
 /*******************************/
 /* Pre-defined attribute codes */
@@ -65,6 +65,7 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 {
        int ret;
        struct qbman_swp *p = malloc(sizeof(struct qbman_swp));
+       u32 major = 0, minor = 0;
 
        if (!p)
                return NULL;
@@ -80,8 +81,20 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
        atomic_set(&p->vdq.busy, 1);
        p->vdq.valid_bit = QB_VALID_BIT;
        p->dqrr.next_idx = 0;
+
+       qbman_version(&major, &minor);
+       if (!major) {
+               printf("invalid qbman version\n");
+               return NULL;
+       }
+
+       if (major >= 4 && minor >= 1)
+               p->dqrr.dqrr_size = QBMAN_VER_4_1_DQRR_SIZE;
+       else
+               p->dqrr.dqrr_size = QBMAN_VER_4_0_DQRR_SIZE;
+
        p->dqrr.valid_bit = QB_VALID_BIT;
-       ret = qbman_swp_sys_init(&p->sys, d);
+       ret = qbman_swp_sys_init(&p->sys, d, p->dqrr.dqrr_size);
        if (ret) {
                free(p);
                printf("qbman_swp_sys_init() failed %d\n", ret);
@@ -380,7 +393,7 @@ const struct ldpaa_dq *qbman_swp_dqrr_next(struct qbman_swp *s)
        /* There's something there. Move "next_idx" attention to the next ring
         * entry (and prefetch it) before returning what we found. */
        s->dqrr.next_idx++;
-       s->dqrr.next_idx &= QBMAN_DQRR_SIZE - 1; /* Wrap around at 4 */
+       s->dqrr.next_idx &= s->dqrr.dqrr_size - 1;/* Wrap around at dqrr_size */
        /* TODO: it's possible to do all this without conditionals, optimise it
         * later. */
        if (!s->dqrr.next_idx)
index 86e2c3aac4c4e413add694517fd8531beb9df83a..97a47aa94e1d5d2f434d4cd665d0ca8927f816c1 100644 (file)
@@ -14,8 +14,8 @@
 /* Management command result codes */
 #define QBMAN_MC_RSLT_OK      0xf0
 
-/* TBD: as of QBMan 4.1, DQRR will be 8 rather than 4! */
-#define QBMAN_DQRR_SIZE 4
+#define QBMAN_VER_4_0_DQRR_SIZE 4
+#define QBMAN_VER_4_1_DQRR_SIZE 8
 
 
 /* --------------------- */
@@ -71,6 +71,7 @@ struct qbman_swp {
        struct {
                uint32_t next_idx;
                uint32_t valid_bit;
+               uint8_t dqrr_size;
        } dqrr;
 };
 
index f1f16b828bf8f498cba956bbb282886317a83729..73bbae373efe71db16f20ffd941f691dd0690310 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/types.h>
 #include <asm/atomic.h>
 #include <malloc.h>
+#include <asm/arch/soc.h>
 #include <fsl-mc/fsl_qbman_base.h>
 
 #define QBMAN_CHECKING
@@ -166,4 +167,22 @@ static inline void dcbz(void *ptr)
 
 #define lwsync()
 
+void qbman_version(u32 *major, u32 *minor)
+{
+       u32 svr_dev_id;
+
+       /*
+        * LS2080A SoC and its personalities has qbman cotroller version 4.0
+        * New SoCs like LS2088A, LS1088A has qbman conroller version 4.1
+        */
+       svr_dev_id = get_svr() >> 16;
+       if (svr_dev_id == SVR_DEV_LS2080A) {
+               *major = 4;
+               *minor = 0;
+       } else {
+               *major = 4;
+               *minor = 1;
+       }
+}
+
 #include "qbman_sys.h"
index 7a537fb82de1742cc9f9177197c53e5d0af7d773..72d74c5c5ac75b6f7d1152cf93df66dbcbc78617 100644 (file)
@@ -239,16 +239,18 @@ static inline uint32_t qbman_set_swp_cfg(uint8_t max_fill, uint8_t wn,
 {
        uint32_t reg;
 
-       reg = e32_uint8_t(20, 3, max_fill) | e32_uint8_t(16, 3, est) |
-               e32_uint8_t(12, 2, rpm) | e32_uint8_t(10, 2, dcm) |
-               e32_uint8_t(8, 2, epm) | e32_int(5, 1, sd) |
-               e32_int(4, 1, sp) | e32_int(3, 1, se) | e32_int(2, 1, dp) |
-               e32_int(1, 1, de) | e32_int(0, 1, ep) | e32_uint8_t(14, 1, wn);
+       reg = e32_uint8_t(20, (uint32_t)(3 + (max_fill >> 3)), max_fill) |
+               e32_uint8_t(16, 3, est) | e32_uint8_t(12, 2, rpm) |
+               e32_uint8_t(10, 2, dcm) | e32_uint8_t(8, 2, epm) |
+               e32_int(5, 1, sd) | e32_int(4, 1, sp) | e32_int(3, 1, se) |
+               e32_int(2, 1, dp) | e32_int(1, 1, de) | e32_int(0, 1, ep) |
+               e32_uint8_t(14, 1, wn);
        return reg;
 }
 
 static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
-                                    const struct qbman_swp_desc *d)
+                                    const struct qbman_swp_desc *d,
+                                    uint8_t dqrr_size)
 {
        uint32_t reg;
 
@@ -270,9 +272,9 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
        BUG_ON(reg);
 #endif
 #ifdef QBMAN_CINH_ONLY
-       reg = qbman_set_swp_cfg(4, 1, 0, 3, 2, 3, 0, 1, 0, 1, 0, 0);
+       reg = qbman_set_swp_cfg(dqrr_size, 1, 0, 3, 2, 3, 0, 1, 0, 1, 0, 0);
 #else
-       reg = qbman_set_swp_cfg(4, 0, 0, 3, 2, 3, 0, 1, 0, 1, 0, 0);
+       reg = qbman_set_swp_cfg(dqrr_size, 0, 0, 3, 2, 3, 0, 1, 0, 1, 0, 0);
 #endif
        qbman_cinh_write(s, QBMAN_CINH_SWP_CFG, reg);
        reg = qbman_cinh_read(s, QBMAN_CINH_SWP_CFG);
index 2d24253468cd10cdd7fc6a1f091e1c2fa41c1e4d..3775a496a4c14b999efc238be0a049db825a9f51 100644 (file)
@@ -28,8 +28,6 @@
 
 #define CONFIG_ARCH_CPU_INIT
 #define CONFIG_BOARD_EARLY_INIT_F
-#define CONFIG_USE_ARCH_MEMSET
-#define CONFIG_USE_ARCH_MEMCPY
 #define CONFIG_TMU_TIMER
 #define CONFIG_SYS_DCACHE_OFF
 
index f094bbead61e4c39e762c81afde0b0ab8b4e68bf..0deb350e3fc8bacc286fac782c6aeba4cd3a5cd6 100755 (executable)
@@ -16,9 +16,6 @@
 
 #include "rcar-gen2-common.h"
 
-#define CONFIG_USE_ARCH_MEMSET
-#define CONFIG_USE_ARCH_MEMCPY
-
 /* STACK */
 #define CONFIG_SYS_INIT_SP_ADDR                0xE817FFFC
 #define STACK_AREA_SIZE                        0xC000
index 5ce0a34a5d178a34c430390771d328810f4f4aea..bc3b53bfd38049b2aaa9c91c457bcda83e9aa938 100644 (file)
@@ -15,8 +15,6 @@
 #include "mx7_common.h"
 
 #define CONFIG_SYS_THUMB_BUILD
-#define CONFIG_USE_ARCH_MEMCPY
-#define CONFIG_USE_ARCH_MEMSET
 
 /*#define CONFIG_DBG_MONITOR*/
 #define PHYS_SDRAM_SIZE                        SZ_512M
index d58145e59d5e7ac1a8cdc1283d47054291f6cd7d..47dea625ed5889d76ecce079c9c5f0f665a07918 100644 (file)
@@ -16,8 +16,6 @@
 
 #define CONFIG_VF610
 #define CONFIG_SYS_THUMB_BUILD
-#define CONFIG_USE_ARCH_MEMCPY
-#define CONFIG_USE_ARCH_MEMSET
 #define CONFIG_SYS_FSL_CLK
 
 #define CONFIG_ARCH_MISC_INIT
index 3b61a4104d72b39c1da23d891f166b71ab8750b4..566f2464cee798a48281a7c8140664c3723cba70 100644 (file)
@@ -20,9 +20,6 @@
 #define CONFIG_SKIP_LOWLEVEL_INIT
 #define CONFIG_BOARD_EARLY_INIT_F
 
-#define CONFIG_USE_ARCH_MEMCPY
-#define CONFIG_USE_ARCH_MEMSET
-
 /* Keep L2 Cache Disabled */
 
 /* input clock of PLL: 24MHz input clock */
index 849a6cb364eb66a52fc719d4e30c1fab8fdddd7b..71c26bdcdab5c62de8a0336cb4ce1951afa6ff59 100644 (file)
@@ -12,7 +12,6 @@
 #if defined(CONFIG_FSL_LS_PPA)
 #define CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT
 #define SEC_FIRMWARE_ERET_ADDR_REVERT
-#define CONFIG_ARMV8_PSCI
 
 #define CONFIG_SYS_LS_PPA_FW_IN_XIP
 #ifdef CONFIG_SYS_LS_PPA_FW_IN_XIP
index eb1944aa290983c428a4a03e1bc2db1b2eeb15e6..e70c3f01d2d680aadd537ec91c082cf47b18d4c7 100644 (file)
@@ -35,7 +35,6 @@
 #define CONFIG_SYS_NAND_ONFI_DETECTION
 
 #ifdef CONFIG_CMD_NAND
-#define CONFIG_USE_ARCH_MEMCPY
 #define CONFIG_SYS_MAX_NAND_DEVICE     1
 #define CONFIG_SYS_NAND_BASE           NFC_BASE_ADDR
 
index 63b711be0f683b700ebf51bd9e1769c72e314705..23a0e782e0fc738c2e5c14314128261ed3214ea9 100644 (file)
 #define CONFIG_SYS_MEMTEST_START       (NV_PA_SDRC_CS0 + 0x600000)
 #define CONFIG_SYS_MEMTEST_END         (CONFIG_SYS_MEMTEST_START + 0x100000)
 
-#ifndef CONFIG_ARM64
-#ifndef CONFIG_SPL_BUILD
-#define CONFIG_USE_ARCH_MEMCPY
-#endif
-#endif
-
 /*-----------------------------------------------------------------------
  * Physical Memory Map
  */
index f9c9f821bfaae27069e19f9eb6f20f629085bb4b..74f13732628a992550a8a0c74e27fc9290949db2 100644 (file)
 /* serial console configuration */
 #define CONFIG_BAUDRATE                        115200
 
-#if !defined(CONFIG_SPL_BUILD) && !defined(CONFIG_ARM64)
-#define CONFIG_USE_ARCH_MEMSET
-#define CONFIG_USE_ARCH_MEMCPY
-#endif
-
 #define CONFIG_SYS_LONGHELP            /* undef to save memory */
 
 #define CONFIG_CMDLINE_EDITING         /* add command line history     */
index af5ba61ec9eb75f3549257813c4ceec775eb0700..6aeb0782616db3b8a32a368371d7490c7cb523ad 100644 (file)
@@ -42,7 +42,6 @@
 #define CONFIG_SYS_NAND_ONFI_DETECTION
 
 #ifdef CONFIG_CMD_NAND
-#define CONFIG_USE_ARCH_MEMCPY
 #define CONFIG_SYS_MAX_NAND_DEVICE     1
 #define CONFIG_SYS_NAND_BASE           NFC_BASE_ADDR