diff options
Diffstat (limited to 'arch/arm/lib')
-rw-r--r-- | arch/arm/lib/Makefile | 10 | ||||
-rw-r--r-- | arch/arm/lib/bootm-fdt.c | 11 | ||||
-rw-r--r-- | arch/arm/lib/bootm.c | 49 | ||||
-rw-r--r-- | arch/arm/lib/cache.c | 22 | ||||
-rw-r--r-- | arch/arm/lib/crt0_64.S | 3 | ||||
-rw-r--r-- | arch/arm/lib/psci-dt.c | 117 | ||||
-rw-r--r-- | arch/arm/lib/sections.c | 2 | ||||
-rw-r--r-- | arch/arm/lib/spl.c | 26 | ||||
-rw-r--r-- | arch/arm/lib/zimage.c | 40 |
9 files changed, 221 insertions, 59 deletions
diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 0e05e87dea..caa62c6355 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -26,12 +26,15 @@ endif obj-$(CONFIG_CPU_V7M) += cmd_boot.o obj-$(CONFIG_OF_LIBFDT) += bootm-fdt.o +obj-$(CONFIG_CMD_BOOTI) += bootm.o obj-$(CONFIG_CMD_BOOTM) += bootm.o +obj-$(CONFIG_CMD_BOOTZ) += bootm.o zimage.o obj-$(CONFIG_SYS_L2_PL310) += cache-pl310.o obj-$(CONFIG_USE_ARCH_MEMSET) += memset.o obj-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o else obj-$(CONFIG_SPL_FRAMEWORK) += spl.o +obj-$(CONFIG_SPL_FRAMEWORK) += zimage.o endif obj-$(CONFIG_SEMIHOSTING) += semihosting.o @@ -55,6 +58,8 @@ ifndef CONFIG_ARM64 obj-y += cache-cp15.o endif +obj-y += psci-dt.o + obj-$(CONFIG_DEBUG_LL) += debug.o # For EABI conformant tool chains, provide eabi_compat() @@ -63,11 +68,6 @@ extra-y += eabi_compat.o endif asflags-y += -DCONFIG_ARM_ASM_UNIFIED -ifeq ($(CONFIG_SPL_BUILD)$(CONFIG_TEGRA),yy) -asflags-y += -D__LINUX_ARM_ARCH__=4 -else -asflags-y += -D__LINUX_ARM_ARCH__=$(CONFIG_SYS_ARM_ARCH) -endif # some files can only build in ARM or THUMB2, not THUMB1 diff --git a/arch/arm/lib/bootm-fdt.c b/arch/arm/lib/bootm-fdt.c index 76b75d8e46..a51755070b 100644 --- a/arch/arm/lib/bootm-fdt.c +++ b/arch/arm/lib/bootm-fdt.c @@ -21,9 +21,11 @@ #include <asm/armv7.h> #endif #include <asm/psci.h> +#include <asm/spin_table.h> DECLARE_GLOBAL_DATA_PTR; +#ifdef CONFIG_ARCH_FIXUP_FDT int arch_fixup_fdt(void *blob) { bd_t *bd = gd->bd; @@ -45,7 +47,13 @@ int arch_fixup_fdt(void *blob) if (ret) return ret; -#ifdef CONFIG_ARMV7_NONSEC +#ifdef CONFIG_ARMV8_SPIN_TABLE + ret = spin_table_update_dt(blob); + if (ret) + return ret; +#endif + +#if defined(CONFIG_ARMV7_NONSEC) || defined(CONFIG_ARMV8_PSCI) ret = psci_update_dt(blob); if (ret) return ret; @@ -53,3 +61,4 @@ int arch_fixup_fdt(void *blob) return 0; } +#endif diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c index 0838d89907..53c3141322 100644 --- a/arch/arm/lib/bootm.c +++ b/arch/arm/lib/bootm.c @@ -248,15 +248,20 @@ static void boot_prep_linux(bootm_headers_t *images) } } -#ifdef CONFIG_ARMV7_NONSEC -bool armv7_boot_nonsec(void) +__weak bool armv7_boot_nonsec_default(void) { - char *s = getenv("bootm_boot_mode"); #ifdef CONFIG_ARMV7_BOOT_SEC_DEFAULT - bool nonsec = false; + return false; #else - bool nonsec = true; + return true; #endif +} + +#ifdef CONFIG_ARMV7_NONSEC +bool armv7_boot_nonsec(void) +{ + char *s = getenv("bootm_boot_mode"); + bool nonsec = armv7_boot_nonsec_default(); if (s && !strcmp(s, "sec")) nonsec = false; @@ -358,38 +363,6 @@ int do_bootm_linux(int flag, int argc, char * const argv[], return 0; } -#ifdef CONFIG_CMD_BOOTZ - -struct zimage_header { - uint32_t code[9]; - uint32_t zi_magic; - uint32_t zi_start; - uint32_t zi_end; -}; - -#define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818 - -int bootz_setup(ulong image, ulong *start, ulong *end) -{ - struct zimage_header *zi; - - zi = (struct zimage_header *)map_sysmem(image, 0); - if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) { - puts("Bad Linux ARM zImage magic!\n"); - return 1; - } - - *start = zi->zi_start; - *end = zi->zi_end; - - printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n", image, *start, - *end); - - return 0; -} - -#endif /* CONFIG_CMD_BOOTZ */ - #if defined(CONFIG_BOOTM_VXWORKS) void boot_prep_vxworks(bootm_headers_t *images) { @@ -399,8 +372,10 @@ void boot_prep_vxworks(bootm_headers_t *images) if (images->ft_addr) { off = fdt_path_offset(images->ft_addr, "/memory"); if (off < 0) { +#ifdef CONFIG_ARCH_FIXUP_FDT if (arch_fixup_fdt(images->ft_addr)) puts("## WARNING: fixup memory failed!\n"); +#endif } } #endif diff --git a/arch/arm/lib/cache.c b/arch/arm/lib/cache.c index 3bd87105c5..d330b09434 100644 --- a/arch/arm/lib/cache.c +++ b/arch/arm/lib/cache.c @@ -10,6 +10,10 @@ #include <common.h> #include <malloc.h> +#ifndef CONFIG_SYS_CACHELINE_SIZE +#define CONFIG_SYS_CACHELINE_SIZE 32 +#endif + /* * Flush range from all levels of d-cache/unified-cache. * Affects the range [start, start + size - 1]. @@ -46,6 +50,24 @@ __weak void flush_dcache_range(unsigned long start, unsigned long stop) /* An empty stub, real implementation should be in platform code */ } +int check_cache_range(unsigned long start, unsigned long stop) +{ + int ok = 1; + + if (start & (CONFIG_SYS_CACHELINE_SIZE - 1)) + ok = 0; + + if (stop & (CONFIG_SYS_CACHELINE_SIZE - 1)) + ok = 0; + + if (!ok) { + warn_non_spl("CACHE: Misaligned operation at range [%08lx, %08lx]\n", + start, stop); + } + + return ok; +} + #ifdef CONFIG_SYS_NONCACHED_MEMORY /* * Reserve one MMU section worth of address space below the malloc() area that diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S index cad22c7b41..91b19e00da 100644 --- a/arch/arm/lib/crt0_64.S +++ b/arch/arm/lib/crt0_64.S @@ -108,6 +108,7 @@ relocation_return: * Set up final (full) environment */ bl c_runtime_cpu_setup /* still call old routine */ +#endif /* !CONFIG_SPL_BUILD */ /* TODO: For SPL, call spl_relocate_stack_gd() to alloc stack relocation */ @@ -130,6 +131,4 @@ clear_loop: /* NOTREACHED - board_init_r() does not return */ -#endif /* !CONFIG_SPL_BUILD */ - ENDPROC(_main) diff --git a/arch/arm/lib/psci-dt.c b/arch/arm/lib/psci-dt.c new file mode 100644 index 0000000000..baf6d7083f --- /dev/null +++ b/arch/arm/lib/psci-dt.c @@ -0,0 +1,117 @@ +/* + * Copyright 2016 NXP Semiconductor, Inc. + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <common.h> +#include <libfdt.h> +#include <fdt_support.h> +#include <linux/sizes.h> +#include <linux/kernel.h> +#include <asm/psci.h> +#ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT +#include <asm/armv8/sec_firmware.h> +#endif + +int fdt_psci(void *fdt) +{ +#if defined(CONFIG_ARMV8_PSCI) || defined(CONFIG_ARMV7_PSCI) + int nodeoff; + unsigned int psci_ver = 0; + int tmp; + + nodeoff = fdt_path_offset(fdt, "/cpus"); + if (nodeoff < 0) { + printf("couldn't find /cpus\n"); + return nodeoff; + } + + /* add 'enable-method = "psci"' to each cpu node */ + for (tmp = fdt_first_subnode(fdt, nodeoff); + tmp >= 0; + tmp = fdt_next_subnode(fdt, tmp)) { + const struct fdt_property *prop; + int len; + + prop = fdt_get_property(fdt, tmp, "device_type", &len); + if (!prop) + continue; + if (len < 4) + continue; + if (strcmp(prop->data, "cpu")) + continue; + + /* + * Not checking rv here, our approach is to skip over errors in + * individual cpu nodes, hopefully some of the nodes are + * processed correctly and those will boot + */ + fdt_setprop_string(fdt, tmp, "enable-method", "psci"); + } + + nodeoff = fdt_path_offset(fdt, "/psci"); + if (nodeoff >= 0) + goto init_psci_node; + + nodeoff = fdt_path_offset(fdt, "/"); + if (nodeoff < 0) + return nodeoff; + + nodeoff = fdt_add_subnode(fdt, nodeoff, "psci"); + if (nodeoff < 0) + return nodeoff; + +init_psci_node: +#ifdef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT + psci_ver = sec_firmware_support_psci_version(); +#elif defined(CONFIG_ARMV7_PSCI_1_0) + psci_ver = ARM_PSCI_VER_1_0; +#endif + switch (psci_ver) { + case ARM_PSCI_VER_1_0: + tmp = fdt_setprop_string(fdt, nodeoff, + "compatible", "arm,psci-1.0"); + if (tmp) + return tmp; + case ARM_PSCI_VER_0_2: + tmp = fdt_appendprop_string(fdt, nodeoff, + "compatible", "arm,psci-0.2"); + if (tmp) + return tmp; + default: + /* + * The Secure firmware framework isn't able to support PSCI version 0.1. + */ +#ifndef CONFIG_ARMV8_SEC_FIRMWARE_SUPPORT + tmp = fdt_appendprop_string(fdt, nodeoff, + "compatible", "arm,psci"); + if (tmp) + return tmp; + tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_suspend", + ARM_PSCI_FN_CPU_SUSPEND); + if (tmp) + return tmp; + tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_off", + ARM_PSCI_FN_CPU_OFF); + if (tmp) + return tmp; + tmp = fdt_setprop_u32(fdt, nodeoff, "cpu_on", + ARM_PSCI_FN_CPU_ON); + if (tmp) + return tmp; + tmp = fdt_setprop_u32(fdt, nodeoff, "migrate", + ARM_PSCI_FN_MIGRATE); + if (tmp) + return tmp; +#endif + break; + } + + tmp = fdt_setprop_string(fdt, nodeoff, "method", "smc"); + if (tmp) + return tmp; + +#endif + return 0; +} diff --git a/arch/arm/lib/sections.c b/arch/arm/lib/sections.c index 6a94522418..952e8ae49b 100644 --- a/arch/arm/lib/sections.c +++ b/arch/arm/lib/sections.c @@ -27,6 +27,8 @@ char __rel_dyn_start[0] __attribute__((section(".__rel_dyn_start"))); char __rel_dyn_end[0] __attribute__((section(".__rel_dyn_end"))); char __secure_start[0] __attribute__((section(".__secure_start"))); char __secure_end[0] __attribute__((section(".__secure_end"))); +char __secure_stack_start[0] __attribute__((section(".__secure_stack_start"))); +char __secure_stack_end[0] __attribute__((section(".__secure_stack_end"))); char __efi_runtime_start[0] __attribute__((section(".__efi_runtime_start"))); char __efi_runtime_stop[0] __attribute__((section(".__efi_runtime_stop"))); char __efi_runtime_rel_start[0] __attribute__((section(".__efi_runtime_rel_start"))); diff --git a/arch/arm/lib/spl.c b/arch/arm/lib/spl.c index e42886840e..3587ad6812 100644 --- a/arch/arm/lib/spl.c +++ b/arch/arm/lib/spl.c @@ -25,22 +25,20 @@ gd_t gdata __attribute__ ((section(".data"))); #endif /* - * In the context of SPL, board_init_f must ensure that any clocks/etc for - * DDR are enabled, ensure that the stack pointer is valid, clear the BSS - * and call board_init_r. We provide this version by default but mark it - * as __weak to allow for platforms to do this in their own way if needed. + * In the context of SPL, board_init_f() prepares the hardware for execution + * from system RAM (DRAM, DDR...). As system RAM may not be available yet, + * board_init_f() must use the current GD to store any data which must be + * passed on to later stages. These data include the relocation destination, + * the future stack, and the future GD location. BSS is cleared after this + * function (and therefore must be accessible). + * + * We provide this version by default but mark it as __weak to allow for + * platforms to do this in their own way if needed. Please see the top + * level U-Boot README "Board Initialization Flow" section for info on what + * to put in this function. */ void __weak board_init_f(ulong dummy) { - /* Clear the BSS. */ - memset(__bss_start, 0, __bss_end - __bss_start); - -#ifndef CONFIG_SPL_DM - /* TODO: Remove settings of the global data pointer here */ - gd = &gdata; -#endif - - board_init_r(NULL, 0); } /* @@ -60,7 +58,7 @@ void __noreturn jump_to_image_linux(void *arg) typedef void (*image_entry_arg_t)(int, int, void *) __attribute__ ((noreturn)); image_entry_arg_t image_entry = - (image_entry_arg_t) spl_image.entry_point; + (image_entry_arg_t)(uintptr_t) spl_image.entry_point; cleanup_before_linux(); image_entry(0, machid, arg); } diff --git a/arch/arm/lib/zimage.c b/arch/arm/lib/zimage.c new file mode 100644 index 0000000000..1e811a87dd --- /dev/null +++ b/arch/arm/lib/zimage.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2016 + * Ladislav Michl <ladis@linux-mips.org> + * + * bootz code: + * Copyright (C) 2012 Marek Vasut <marek.vasut@gmail.com> + * + * SPDX-License-Identifier: GPL-2.0+ + */ +#include <common.h> + +#define LINUX_ARM_ZIMAGE_MAGIC 0x016f2818 + +struct arm_z_header { + uint32_t code[9]; + uint32_t zi_magic; + uint32_t zi_start; + uint32_t zi_end; +} __attribute__ ((__packed__)); + +int bootz_setup(ulong image, ulong *start, ulong *end) +{ + struct arm_z_header *zi = (struct arm_z_header *)image; + + if (zi->zi_magic != LINUX_ARM_ZIMAGE_MAGIC) { +#ifndef CONFIG_SPL_FRAMEWORK + puts("Bad Linux ARM zImage magic!\n"); +#endif + return 1; + } + + *start = zi->zi_start; + *end = zi->zi_end; +#ifndef CONFIG_SPL_FRAMEWORK + printf("Kernel image @ %#08lx [ %#08lx - %#08lx ]\n", + image, *start, *end); +#endif + + return 0; +} |