summaryrefslogtreecommitdiffstats
path: root/arch/arm/include/asm
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/include/asm')
-rw-r--r--arch/arm/include/asm/arch-check.h9
-rw-r--r--arch/arm/include/asm/armlinux.h2
-rw-r--r--arch/arm/include/asm/asm-offsets.h4
-rw-r--r--arch/arm/include/asm/assembler.h239
-rw-r--r--arch/arm/include/asm/assembler64.h4
-rw-r--r--arch/arm/include/asm/atf_common.h203
-rw-r--r--arch/arm/include/asm/atomic.h108
-rw-r--r--arch/arm/include/asm/barebox-arm-head.h19
-rw-r--r--arch/arm/include/asm/barebox-arm.h223
-rw-r--r--arch/arm/include/asm/barebox.lds.h30
-rw-r--r--arch/arm/include/asm/bitops.h2
-rw-r--r--arch/arm/include/asm/bitsperlong.h2
-rw-r--r--arch/arm/include/asm/byteorder.h2
-rw-r--r--arch/arm/include/asm/cache-l2x0.h19
-rw-r--r--arch/arm/include/asm/cache.h7
-rw-r--r--arch/arm/include/asm/common.h19
-rw-r--r--arch/arm/include/asm/cputype.h24
-rw-r--r--arch/arm/include/asm/debug_ll.h71
-rw-r--r--arch/arm/include/asm/dma.h43
-rw-r--r--arch/arm/include/asm/elf.h10
-rw-r--r--arch/arm/include/asm/errata.h15
-rw-r--r--arch/arm/include/asm/esr.h20
-rw-r--r--arch/arm/include/asm/fncpy.h70
-rw-r--r--arch/arm/include/asm/gic.h2
-rw-r--r--arch/arm/include/asm/hardware/arm_timer.h2
-rw-r--r--arch/arm/include/asm/hardware/sp810.h6
-rw-r--r--arch/arm/include/asm/image.h59
-rw-r--r--arch/arm/include/asm/io.h73
-rw-r--r--arch/arm/include/asm/linkage.h2
-rw-r--r--arch/arm/include/asm/mach-types.h868
-rw-r--r--arch/arm/include/asm/memory.h33
-rw-r--r--arch/arm/include/asm/mmu.h15
-rw-r--r--arch/arm/include/asm/mmuinfo.h9
-rw-r--r--arch/arm/include/asm/module.h35
-rw-r--r--arch/arm/include/asm/neon.h8
-rw-r--r--arch/arm/include/asm/opcodes-sec.h17
-rw-r--r--arch/arm/include/asm/opcodes-virt.h23
-rw-r--r--arch/arm/include/asm/opcodes.h10
-rw-r--r--arch/arm/include/asm/optee.h18
-rw-r--r--arch/arm/include/asm/pci.h9
-rw-r--r--arch/arm/include/asm/pgtable.h14
-rw-r--r--arch/arm/include/asm/pgtable64.h26
-rw-r--r--arch/arm/include/asm/posix_types.h2
-rw-r--r--arch/arm/include/asm/proc-armv/system.h14
-rw-r--r--arch/arm/include/asm/processor.h131
-rw-r--r--arch/arm/include/asm/psci.h25
-rw-r--r--arch/arm/include/asm/ptrace.h14
-rw-r--r--arch/arm/include/asm/reloc.h42
-rw-r--r--arch/arm/include/asm/sections.h2
-rw-r--r--arch/arm/include/asm/secure.h2
-rw-r--r--arch/arm/include/asm/semihosting.h2
-rw-r--r--arch/arm/include/asm/setjmp.h31
-rw-r--r--arch/arm/include/asm/setup.h9
-rw-r--r--arch/arm/include/asm/stacktrace.h2
-rw-r--r--arch/arm/include/asm/string.h5
-rw-r--r--arch/arm/include/asm/swab.h2
-rw-r--r--arch/arm/include/asm/syscounter.h4
-rw-r--r--arch/arm/include/asm/sysreg.h76
-rw-r--r--arch/arm/include/asm/system.h8
-rw-r--r--arch/arm/include/asm/system_info.h13
-rw-r--r--arch/arm/include/asm/types.h50
-rw-r--r--arch/arm/include/asm/unaligned.h2
-rw-r--r--arch/arm/include/asm/unified.h19
-rw-r--r--arch/arm/include/asm/unwind.h26
-rw-r--r--arch/arm/include/asm/word-at-a-time.h60
65 files changed, 2200 insertions, 715 deletions
diff --git a/arch/arm/include/asm/arch-check.h b/arch/arm/include/asm/arch-check.h
new file mode 100644
index 0000000000..2cf1b624a4
--- /dev/null
+++ b/arch/arm/include/asm/arch-check.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ARM_ASM_ARCH_CHECK_H__
+#define __ARM_ASM_ARCH_CHECK_H__
+
+#ifndef __LINUX_ARM_ARCH__
+#error No boards/CPUs selected in Kconfig
+#endif
+
+#endif
diff --git a/arch/arm/include/asm/armlinux.h b/arch/arm/include/asm/armlinux.h
index 6af98968fa..8d8e05105b 100644
--- a/arch/arm/include/asm/armlinux.h
+++ b/arch/arm/include/asm/armlinux.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ARCH_ARMLINUX_H
#define __ARCH_ARMLINUX_H
diff --git a/arch/arm/include/asm/asm-offsets.h b/arch/arm/include/asm/asm-offsets.h
index 2f84e83996..33db5a47e5 100644
--- a/arch/arm/include/asm/asm-offsets.h
+++ b/arch/arm/include/asm/asm-offsets.h
@@ -1 +1,3 @@
-#include <generated/asm-offsets.h> \ No newline at end of file
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#include <generated/asm-offsets.h>
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 6116e4893c..5db0f692ee 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -1,12 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 1996-2000 Russell King */
+
/*
* arch/arm/include/asm/assembler.h
*
- * Copyright (C) 1996-2000 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
* This file contains arm architecture specific defines
* for the different processors.
*
@@ -114,3 +111,233 @@
.align 3; \
.long 9999b,9001f; \
.previous
+
+
+/*
+ * Select code when configured for BE.
+ */
+#ifdef CONFIG_CPU_BIG_ENDIAN
+#define CPU_BE(code...) code
+#else
+#define CPU_BE(code...)
+#endif
+
+/*
+ * Select code when configured for LE.
+ */
+#ifdef CONFIG_CPU_BIG_ENDIAN
+#define CPU_LE(code...)
+#else
+#define CPU_LE(code...) code
+#endif
+
+#ifdef CONFIG_CPU_64
+/*
+ * Pseudo-ops for PC-relative adr/ldr/str <reg>, <symbol> where
+ * <symbol> is within the range +/- 4 GB of the PC.
+ */
+ /*
+ * @dst: destination register (64 bit wide)
+ * @sym: name of the symbol
+ */
+ .macro adr_l, dst, sym
+ adrp \dst, \sym
+ add \dst, \dst, :lo12:\sym
+ .endm
+
+ /*
+ * @dst: destination register (32 or 64 bit wide)
+ * @sym: name of the symbol
+ * @tmp: optional 64-bit scratch register to be used if <dst> is a
+ * 32-bit wide register, in which case it cannot be used to hold
+ * the address
+ */
+ .macro ldr_l, dst, sym, tmp=
+ .ifb \tmp
+ adrp \dst, \sym
+ ldr \dst, [\dst, :lo12:\sym]
+ .else
+ adrp \tmp, \sym
+ ldr \dst, [\tmp, :lo12:\sym]
+ .endif
+ .endm
+
+ /*
+ * @src: source register (32 or 64 bit wide)
+ * @sym: name of the symbol
+ * @tmp: mandatory 64-bit scratch register to calculate the address
+ * while <src> needs to be preserved.
+ */
+ .macro str_l, src, sym, tmp
+ adrp \tmp, \sym
+ str \src, [\tmp, :lo12:\sym]
+ .endm
+
+#else
+
+ .macro __adldst_l, op, reg, sym, tmp, c
+ .if __LINUX_ARM_ARCH__ < 7
+ ldr\c \tmp, .La\@
+ .subsection 1
+ .align 2
+.La\@: .long \sym - .Lpc\@
+ .previous
+ .else
+ .ifnb \c
+ THUMB( ittt \c )
+ .endif
+ movw\c \tmp, #:lower16:\sym - .Lpc\@
+ movt\c \tmp, #:upper16:\sym - .Lpc\@
+ .endif
+
+#ifndef CONFIG_THUMB2_BAREBOX
+ .set .Lpc\@, . + 8 // PC bias
+ .ifc \op, add
+ add\c \reg, \tmp, pc
+ .else
+ \op\c \reg, [pc, \tmp]
+ .endif
+#else
+.Lb\@: add\c \tmp, \tmp, pc
+ /*
+ * In Thumb-2 builds, the PC bias depends on whether we are currently
+ * emitting into a .arm or a .thumb section. The size of the add opcode
+ * above will be 2 bytes when emitting in Thumb mode and 4 bytes when
+ * emitting in ARM mode, so let's use this to account for the bias.
+ */
+ .set .Lpc\@, . + (. - .Lb\@)
+
+ .ifnc \op, add
+ \op\c \reg, [\tmp]
+ .endif
+#endif
+ .endm
+
+ /*
+ * mov_l - move a constant value or [relocated] address into a register
+ */
+ .macro mov_l, dst:req, imm:req, cond
+ .if __LINUX_ARM_ARCH__ < 7
+ ldr\cond \dst, =\imm
+ .else
+ movw\cond \dst, #:lower16:\imm
+ movt\cond \dst, #:upper16:\imm
+ .endif
+ .endm
+
+ /*
+ * adr_l - adr pseudo-op with unlimited range
+ *
+ * @dst: destination register
+ * @sym: name of the symbol
+ * @cond: conditional opcode suffix
+ */
+ .macro adr_l, dst:req, sym:req, cond
+ __adldst_l add, \dst, \sym, \dst, \cond
+ .endm
+
+ /*
+ * ldr_l - ldr <literal> pseudo-op with unlimited range
+ *
+ * @dst: destination register
+ * @sym: name of the symbol
+ * @cond: conditional opcode suffix
+ */
+ .macro ldr_l, dst:req, sym:req, cond
+ __adldst_l ldr, \dst, \sym, \dst, \cond
+ .endm
+
+ /*
+ * str_l - str <literal> pseudo-op with unlimited range
+ *
+ * @src: source register
+ * @sym: name of the symbol
+ * @tmp: mandatory scratch register
+ * @cond: conditional opcode suffix
+ */
+ .macro str_l, src:req, sym:req, tmp:req, cond
+ __adldst_l str, \src, \sym, \tmp, \cond
+ .endm
+
+ .macro __ldst_va, op, reg, tmp, sym, cond, offset
+#if __LINUX_ARM_ARCH__ >= 7 || \
+ (defined(MODULE) && defined(CONFIG_ARM_MODULE_PLTS))
+ mov_l \tmp, \sym, \cond
+#else
+ /*
+ * Avoid a literal load, by emitting a sequence of ADD/LDR instructions
+ * with the appropriate relocations. The combined sequence has a range
+ * of -/+ 256 MiB, which should be sufficient for the core kernel and
+ * for modules loaded into the module region.
+ */
+ .globl \sym
+ .reloc .L0_\@, R_ARM_ALU_PC_G0_NC, \sym
+ .reloc .L1_\@, R_ARM_ALU_PC_G1_NC, \sym
+ .reloc .L2_\@, R_ARM_LDR_PC_G2, \sym
+.L0_\@: sub\cond \tmp, pc, #8 - \offset
+.L1_\@: sub\cond \tmp, \tmp, #4 - \offset
+.L2_\@:
+#endif
+ \op\cond \reg, [\tmp, #\offset]
+ .endm
+
+ /*
+ * ldr_va - load a 32-bit word from the virtual address of \sym
+ */
+ .macro ldr_va, rd:req, sym:req, cond, tmp, offset=0
+ .ifnb \tmp
+ __ldst_va ldr, \rd, \tmp, \sym, \cond, \offset
+ .else
+ __ldst_va ldr, \rd, \rd, \sym, \cond, \offset
+ .endif
+ .endm
+
+ /*
+ * str_va - store a 32-bit word to the virtual address of \sym
+ */
+ .macro str_va, rn:req, sym:req, tmp:req, cond
+ __ldst_va str, \rn, \tmp, \sym, \cond, 0
+ .endm
+
+ /*
+ * ldr_this_cpu - Load a 32-bit word from the per-CPU variable 'sym'
+ * into register 'rd', which may be the stack pointer,
+ * using 't1' and 't2' as general temp registers. These
+ * are permitted to overlap with 'rd' if != sp
+ */
+ .macro ldr_this_cpu, rd:req, sym:req, t1:req, t2:req
+ ldr_va \rd, \sym, tmp=\t1
+ .endm
+
+ /*
+ * rev_l - byte-swap a 32-bit value
+ *
+ * @val: source/destination register
+ * @tmp: scratch register
+ */
+ .macro rev_l, val:req, tmp:req
+ .if __LINUX_ARM_ARCH__ < 6
+ eor \tmp, \val, \val, ror #16
+ bic \tmp, \tmp, #0x00ff0000
+ mov \val, \val, ror #8
+ eor \val, \val, \tmp, lsr #8
+ .else
+ rev \val, \val
+ .endif
+ .endm
+
+ /*
+ * bl_r - branch and link to register
+ *
+ * @dst: target to branch to
+ * @c: conditional opcode suffix
+ */
+ .macro bl_r, dst:req, c
+ .if __LINUX_ARM_ARCH__ < 6
+ mov\c lr, pc
+ mov\c pc, \dst
+ .else
+ blx\c \dst
+ .endif
+ .endm
+#endif
diff --git a/arch/arm/include/asm/assembler64.h b/arch/arm/include/asm/assembler64.h
index 26182aa5f6..615b257671 100644
--- a/arch/arm/include/asm/assembler64.h
+++ b/arch/arm/include/asm/assembler64.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARCH_ASSEMBLY_H
#define __ASM_ARCH_ASSEMBLY_H
@@ -18,4 +20,4 @@
b.eq \el1_label
.endm
-#endif /* __ASM_ARCH_ASSEMBLY_H */ \ No newline at end of file
+#endif /* __ASM_ARCH_ASSEMBLY_H */
diff --git a/arch/arm/include/asm/atf_common.h b/arch/arm/include/asm/atf_common.h
new file mode 100644
index 0000000000..ab99cd3ac1
--- /dev/null
+++ b/arch/arm/include/asm/atf_common.h
@@ -0,0 +1,203 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * This is from the ARM TF Project,
+ * Repository: https://github.com/ARM-software/arm-trusted-firmware.git
+ * File: include/common/bl_common.h
+ * Portions copyright (c) 2013-2016, ARM Limited and Contributors. All rights
+ * reserved.
+ * Copyright (C) 2016-2017 Rockchip Electronic Co.,Ltd
+ */
+
+#ifndef __BL_COMMON_H__
+#define __BL_COMMON_H__
+
+#define ATF_PARAM_EP 0x01
+#define ATF_PARAM_IMAGE_BINARY 0x02
+#define ATF_PARAM_BL31 0x03
+#define ATF_PARAM_BL_PARAMS 0x05
+
+#define ATF_VERSION_1 0x01
+#define ATF_VERSION_2 0x02
+
+#define ATF_BL31_IMAGE_ID 0x03
+#define ATF_BL32_IMAGE_ID 0x04
+#define ATF_BL33_IMAGE_ID 0x05
+
+#define ATF_EP_SECURE 0x0
+#define ATF_EP_NON_SECURE 0x1
+
+#define MODE_RW_SHIFT 0x4
+#define MODE_RW_MASK 0x1
+#define MODE_RW_64 0x0
+#define MODE_RW_32 0x1
+
+#define MODE_EL_SHIFT 0x2
+#define MODE_EL_MASK 0x3
+#define MODE_EL3 0x3
+#define MODE_EL2 0x2
+#define MODE_EL1 0x1
+#define MODE_EL0 0x0
+
+#define MODE_SP_SHIFT 0x0
+#define MODE_SP_MASK 0x1
+#define MODE_SP_EL0 0x0
+#define MODE_SP_ELX 0x1
+
+#define SPSR_DAIF_SHIFT 6
+#define SPSR_DAIF_MASK 0x0f
+
+#define SPSR_64(el, sp, daif) \
+ (MODE_RW_64 << MODE_RW_SHIFT | \
+ ((el) & MODE_EL_MASK) << MODE_EL_SHIFT | \
+ ((sp) & MODE_SP_MASK) << MODE_SP_SHIFT | \
+ ((daif) & SPSR_DAIF_MASK) << SPSR_DAIF_SHIFT)
+
+#define SPSR_FIQ (1 << 6)
+#define SPSR_IRQ (1 << 7)
+#define SPSR_SERROR (1 << 8)
+#define SPSR_DEBUG (1 << 9)
+#define SPSR_EXCEPTION_MASK (SPSR_FIQ | SPSR_IRQ | SPSR_SERROR | SPSR_DEBUG)
+
+#define DAIF_FIQ_BIT (1<<0)
+#define DAIF_IRQ_BIT (1<<1)
+#define DAIF_ABT_BIT (1<<2)
+#define DAIF_DBG_BIT (1<<3)
+#define DISABLE_ALL_EXECPTIONS \
+ (DAIF_FIQ_BIT | DAIF_IRQ_BIT | DAIF_ABT_BIT | DAIF_DBG_BIT)
+
+#ifndef __ASSEMBLY__
+
+/*******************************************************************************
+ * Structure used for telling the next BL how much of a particular type of
+ * memory is available for its use and how much is already used.
+ ******************************************************************************/
+struct aapcs64_params {
+ unsigned long arg0;
+ unsigned long arg1;
+ unsigned long arg2;
+ unsigned long arg3;
+ unsigned long arg4;
+ unsigned long arg5;
+ unsigned long arg6;
+ unsigned long arg7;
+};
+
+/***************************************************************************
+ * This structure provides version information and the size of the
+ * structure, attributes for the structure it represents
+ ***************************************************************************/
+struct param_header {
+ uint8_t type; /* type of the structure */
+ uint8_t version; /* version of this structure */
+ uint16_t size; /* size of this structure in bytes */
+ uint32_t attr; /* attributes: unused bits SBZ */
+};
+
+/*****************************************************************************
+ * This structure represents the superset of information needed while
+ * switching exception levels. The only two mechanisms to do so are
+ * ERET & SMC. Security state is indicated using bit zero of header
+ * attribute
+ * NOTE: BL1 expects entrypoint followed by spsr at an offset from the start
+ * of this structure defined by the macro `ENTRY_POINT_INFO_PC_OFFSET` while
+ * processing SMC to jump to BL31.
+ *****************************************************************************/
+struct entry_point_info {
+ struct param_header h;
+ uintptr_t pc;
+ uint32_t spsr;
+ struct aapcs64_params args;
+};
+
+/*****************************************************************************
+ * Image info binary provides information from the image loader that
+ * can be used by the firmware to manage available trusted RAM.
+ * More advanced firmware image formats can provide additional
+ * information that enables optimization or greater flexibility in the
+ * common firmware code
+ *****************************************************************************/
+struct atf_image_info {
+ struct param_header h;
+ uintptr_t image_base; /* physical address of base of image */
+ uint32_t image_size; /* bytes read from image file */
+};
+
+/*****************************************************************************
+ * The image descriptor struct definition.
+ *****************************************************************************/
+struct image_desc {
+ /* Contains unique image id for the image. */
+ unsigned int image_id;
+ /*
+ * This member contains Image state information.
+ * Refer IMAGE_STATE_XXX defined above.
+ */
+ unsigned int state;
+ uint32_t copied_size; /* image size copied in blocks */
+ struct atf_image_info atf_image_info;
+ struct entry_point_info ep_info;
+};
+
+/*******************************************************************************
+ * This structure represents the superset of information that can be passed to
+ * BL31 e.g. while passing control to it from BL2. The BL32 parameters will be
+ * populated only if BL2 detects its presence. A pointer to a structure of this
+ * type should be passed in X0 to BL31's cold boot entrypoint.
+ *
+ * Use of this structure and the X0 parameter is not mandatory: the BL31
+ * platform code can use other mechanisms to provide the necessary information
+ * about BL32 and BL33 to the common and SPD code.
+ *
+ * BL31 image information is mandatory if this structure is used. If either of
+ * the optional BL32 and BL33 image information is not provided, this is
+ * indicated by the respective image_info pointers being zero.
+ ******************************************************************************/
+struct bl31_params {
+ struct param_header h;
+ struct atf_image_info *bl31_image_info;
+ struct entry_point_info *bl32_ep_info;
+ struct atf_image_info *bl32_image_info;
+ struct entry_point_info *bl33_ep_info;
+ struct atf_image_info *bl33_image_info;
+};
+
+void bl31_entry(uintptr_t bl31_entry, uintptr_t bl32_entry,
+ uintptr_t bl33_entry, uintptr_t fdt_addr);
+
+/* BL image node in the BL image execution sequence */
+struct bl_params_node {
+ unsigned int image_id;
+ struct atf_image_info *image_info;
+ struct entry_point_info *ep_info;
+ struct bl_params_node *next_params_info;
+};
+
+/*
+ * BL image head node in the BL image execution sequence
+ * It is also used to pass information to next BL image.
+ */
+struct bl_params {
+ struct param_header h;
+ struct bl_params_node *head;
+};
+
+struct bl2_to_bl31_params_mem_v2 {
+ struct bl_params bl_params;
+ struct bl_params_node bl31_params_node;
+ struct bl_params_node bl32_params_node;
+ struct bl_params_node bl33_params_node;
+ struct atf_image_info bl31_image_info;
+ struct atf_image_info bl32_image_info;
+ struct atf_image_info bl33_image_info;
+ struct entry_point_info bl31_ep_info;
+ struct entry_point_info bl32_ep_info;
+ struct entry_point_info bl33_ep_info;
+};
+
+struct bl2_to_bl31_params_mem_v2 *bl2_plat_get_bl31_params_v2(uintptr_t bl32_entry,
+ uintptr_t bl33_entry, uintptr_t fdt_addr);
+void bl31_entry_v2(uintptr_t bl31_entry, struct bl_params *params, void *fdt_addr);
+
+#endif /*__ASSEMBLY__ */
+
+#endif /* __BL_COMMON_H__ */
diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
index 9b79506b59..cfc359a5ce 100644
--- a/arch/arm/include/asm/atomic.h
+++ b/arch/arm/include/asm/atomic.h
@@ -1,111 +1,9 @@
-/*
- * linux/include/asm-arm/atomic.h
- *
- * Copyright (c) 1996 Russell King.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * Changelog:
- * 27-06-1996 RMK Created
- * 13-04-1997 RMK Made functions atomic!
- * 07-12-1997 RMK Upgraded for v2.1.
- * 26-08-1998 PJB Added #ifdef __KERNEL__
- */
+// SPDX-License-Identifier: GPL-2.0-only
+
#ifndef __ASM_ARM_ATOMIC_H
#define __ASM_ARM_ATOMIC_H
-#ifdef CONFIG_SMP
-#error SMP not supported
-#endif
-
-typedef struct { volatile int counter; } atomic_t;
-
-#define ATOMIC_INIT(i) { (i) }
-
-#ifdef __KERNEL__
#include <asm/proc-armv/system.h>
+#include <asm-generic/atomic.h>
-#define atomic_read(v) ((v)->counter)
-#define atomic_set(v,i) (((v)->counter) = (i))
-
-static inline void atomic_add(int i, volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter += i;
- local_irq_restore(flags);
-}
-
-static inline void atomic_sub(int i, volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter -= i;
- local_irq_restore(flags);
-}
-
-static inline void atomic_inc(volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter += 1;
- local_irq_restore(flags);
-}
-
-static inline void atomic_dec(volatile atomic_t *v)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- v->counter -= 1;
- local_irq_restore(flags);
-}
-
-static inline int atomic_dec_and_test(volatile atomic_t *v)
-{
- unsigned long flags = 0;
- int val;
-
- local_irq_save(flags);
- val = v->counter;
- v->counter = val -= 1;
- local_irq_restore(flags);
-
- return val == 0;
-}
-
-static inline int atomic_add_negative(int i, volatile atomic_t *v)
-{
- unsigned long flags = 0;
- int val;
-
- local_irq_save(flags);
- val = v->counter;
- v->counter = val += i;
- local_irq_restore(flags);
-
- return val < 0;
-}
-
-static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
-{
- unsigned long flags = 0;
-
- local_irq_save(flags);
- *addr &= ~mask;
- local_irq_restore(flags);
-}
-
-/* Atomic operations are already serializing on ARM */
-#define smp_mb__before_atomic_dec() barrier()
-#define smp_mb__after_atomic_dec() barrier()
-#define smp_mb__before_atomic_inc() barrier()
-#define smp_mb__after_atomic_inc() barrier()
-
-#endif
#endif
diff --git a/arch/arm/include/asm/barebox-arm-head.h b/arch/arm/include/asm/barebox-arm-head.h
index 83a22c4d94..135d0585b1 100644
--- a/arch/arm/include/asm/barebox-arm-head.h
+++ b/arch/arm/include/asm/barebox-arm-head.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_HEAD_H
#define __ASM_ARM_HEAD_H
@@ -16,13 +18,10 @@ void barebox_arm_reset_vector(uint32_t r0, uint32_t r1, uint32_t r2);
#define ARM_HEAD_SPARE_OFS 0x30
#define ARM_HEAD_SPARE_MARKER 0x55555555
-#ifdef CONFIG_HAVE_MACH_ARM_HEAD
-#include <mach/barebox-arm-head.h>
-#else
+#ifdef CONFIG_CPU_32
static inline void __barebox_arm_head(void)
{
__asm__ __volatile__ (
-#ifdef CONFIG_CPU_32
#ifdef CONFIG_THUMB2_BAREBOX
".arm\n"
"adr r9, 1f + 1\n"
@@ -43,22 +42,10 @@ static inline void __barebox_arm_head(void)
"1: b 1b\n"
"1: b 1b\n"
#endif
-#else
- "b 2f\n"
- "nop\n"
- "nop\n"
- "nop\n"
- "nop\n"
- "nop\n"
-#endif
".asciz \"barebox\"\n"
-#ifdef CONFIG_CPU_32
".word _text\n" /* text base. If copied there,
* barebox can skip relocation
*/
-#else
- ".word 0xffffffff\n"
-#endif
".word _barebox_image_size\n" /* image size to copy */
".rept 8\n"
".word 0x55555555\n"
diff --git a/arch/arm/include/asm/barebox-arm.h b/arch/arm/include/asm/barebox-arm.h
index 8b2ecd9ab2..7a7e5a2403 100644
--- a/arch/arm/include/asm/barebox-arm.h
+++ b/arch/arm/include/asm/barebox-arm.h
@@ -1,3 +1,4 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* (C) Copyright 2002
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
@@ -6,20 +7,6 @@
* (C) Copyright 2002
* Sysgo Real-Time Solutions, GmbH <www.elinos.com>
* Alex Zuepke <azu@sysgo.de>
- *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
*/
#ifndef _BAREBOX_ARM_H_
@@ -28,84 +15,33 @@
#include <linux/sizes.h>
#include <asm-generic/memory_layout.h>
#include <linux/kernel.h>
+#include <linux/pagemap.h>
#include <linux/types.h>
#include <linux/compiler.h>
#include <asm/barebox-arm-head.h>
+#include <asm/common.h>
#include <asm/sections.h>
+#include <asm/reloc.h>
+#include <linux/stringify.h>
+#include <boarddata.h>
-/*
- * We have a 4GiB address space split into 1MiB sections, with each
- * section header taking 4 bytes
- */
-#define ARM_TTB_SIZE (SZ_4G / SZ_1M * sizeof(u32))
-
-unsigned long get_runtime_offset(void);
-
-/* global_variable_offset() - Access global variables when not running at link address
- *
- * Get the offset of global variables when not running at the address we are
- * linked at.
- */
-static inline unsigned long global_variable_offset(void)
-{
-#ifdef CONFIG_CPU_V8
- unsigned long text;
-
- __asm__ __volatile__(
- "adr %0, _text\n"
- : "=r" (text)
- :
- : "memory");
- return text - (unsigned long)_text;
-#else
- return get_runtime_offset();
-#endif
-}
+#define ARM_EARLY_PAGETABLE_SIZE SZ_64K
-void setup_c(void);
-void pbl_barebox_break(void);
-void relocate_to_current_adr(void);
-void relocate_to_adr(unsigned long target);
void __noreturn barebox_arm_entry(unsigned long membase, unsigned long memsize, void *boarddata);
-struct barebox_arm_boarddata {
-#define BAREBOX_ARM_BOARDDATA_MAGIC 0xabe742c3
- u32 magic;
- u32 machine; /* machine number to pass to barebox. This may or may
- * not be a ARM machine number registered on arm.linux.org.uk.
- * It must only be unique across barebox. Please use a number
- * that do not potientially clashes with registered machines,
- * i.e. use a number > 0x10000.
- */
-};
-
-/*
- * Create a boarddata struct at given address. Suitable to be passed
- * as boarddata to barebox_arm_entry(). The machine can be retrieved
- * later with barebox_arm_machine().
- */
-static inline void boarddata_create(void *adr, u32 machine)
-{
- struct barebox_arm_boarddata *bd = adr;
-
- bd->magic = BAREBOX_ARM_BOARDDATA_MAGIC;
- bd->machine = machine;
-}
+#define barebox_arm_boarddata barebox_boarddata
+#define BAREBOX_ARM_BOARDDATA_MAGIC BAREBOX_BOARDDATA_MAGIC
u32 barebox_arm_machine(void);
unsigned long arm_mem_ramoops_get(void);
+unsigned long arm_mem_membase_get(void);
unsigned long arm_mem_endmem_get(void);
-struct barebox_arm_boarddata_compressed_dtb {
-#define BAREBOX_ARM_BOARDDATA_COMPRESSED_DTB_MAGIC 0x7b66bcbd
- u32 magic;
- u32 datalen;
- u32 datalen_uncompressed;
-};
-
struct barebox_arm_boarddata *barebox_arm_get_boarddata(void);
+#define barebox_arm_get_boarddata barebox_get_boarddata
+
#if defined(CONFIG_RELOCATABLE) && defined(CONFIG_ARM_EXCEPTIONS)
void arm_fixup_vectors(void);
#else
@@ -116,46 +52,52 @@ static inline void arm_fixup_vectors(void)
void *barebox_arm_boot_dtb(void);
-static inline unsigned long arm_mem_stack_top(unsigned long membase,
- unsigned long endmem)
+static inline unsigned long arm_mem_optee(unsigned long endmem)
{
- if (IS_ENABLED(CONFIG_BOOTM_OPTEE))
- endmem -= OPTEE_SIZE;
+ return endmem - OPTEE_SIZE;
+}
- return endmem - SZ_64K;
+static inline unsigned long arm_mem_scratch(unsigned long endmem)
+{
+ return arm_mem_optee(endmem) - SZ_32K;
}
-static inline unsigned long arm_mem_stack(unsigned long membase,
- unsigned long endmem)
+static inline unsigned long arm_mem_stack(unsigned long endmem)
{
- return arm_mem_stack_top(membase, endmem) - STACK_SIZE;
+ return arm_mem_scratch(endmem) - STACK_SIZE;
}
-static inline unsigned long arm_mem_ttb(unsigned long membase,
- unsigned long endmem)
+static inline unsigned long arm_mem_guard_page(unsigned long endmem)
{
- endmem = arm_mem_stack(membase, endmem);
- endmem = ALIGN_DOWN(endmem, ARM_TTB_SIZE) - ARM_TTB_SIZE;
+ endmem = arm_mem_stack(endmem);
+
+ if (!IS_ENABLED(CONFIG_STACK_GUARD_PAGE))
+ return endmem;
+
+ return ALIGN_DOWN(endmem, PAGE_SIZE) - PAGE_SIZE;
+}
+
+static inline unsigned long arm_mem_ttb(unsigned long endmem)
+{
+ endmem = arm_mem_guard_page(endmem);
+ endmem = ALIGN_DOWN(endmem, ARM_EARLY_PAGETABLE_SIZE) - ARM_EARLY_PAGETABLE_SIZE;
return endmem;
}
-static inline unsigned long arm_mem_early_malloc(unsigned long membase,
- unsigned long endmem)
+static inline unsigned long arm_mem_early_malloc(unsigned long endmem)
{
- return arm_mem_ttb(membase, endmem) - SZ_128K;
+ return arm_mem_ttb(endmem) - SZ_128K;
}
-static inline unsigned long arm_mem_early_malloc_end(unsigned long membase,
- unsigned long endmem)
+static inline unsigned long arm_mem_early_malloc_end(unsigned long endmem)
{
- return arm_mem_ttb(membase, endmem);
+ return arm_mem_ttb(endmem);
}
-static inline unsigned long arm_mem_ramoops(unsigned long membase,
- unsigned long endmem)
+static inline unsigned long arm_mem_ramoops(unsigned long endmem)
{
- endmem = arm_mem_ttb(membase, endmem);
+ endmem = arm_mem_ttb(endmem);
#ifdef CONFIG_FS_PSTORE_RAMOOPS
endmem -= CONFIG_FS_PSTORE_RAMOOPS_SIZE;
endmem = ALIGN_DOWN(endmem, SZ_4K);
@@ -164,11 +106,26 @@ static inline unsigned long arm_mem_ramoops(unsigned long membase,
return endmem;
}
+static inline unsigned long arm_mem_stack_top(unsigned long endmem)
+{
+ return arm_mem_stack(endmem) + STACK_SIZE;
+}
+
+static inline const void *arm_mem_scratch_get(void)
+{
+ return (const void *)arm_mem_scratch(arm_mem_endmem_get());
+}
+
+static inline unsigned long arm_mem_guard_page_get(void)
+{
+ return arm_mem_guard_page(arm_mem_endmem_get());
+}
+
static inline unsigned long arm_mem_barebox_image(unsigned long membase,
unsigned long endmem,
unsigned long size)
{
- endmem = arm_mem_ramoops(membase, endmem);
+ endmem = arm_mem_ramoops(endmem);
if (IS_ENABLED(CONFIG_RELOCATABLE)) {
return ALIGN_DOWN(endmem - size, SZ_1M);
@@ -180,19 +137,75 @@ static inline unsigned long arm_mem_barebox_image(unsigned long membase,
}
}
+/*
+ * Unlike ENTRY_FUNCTION, this can be used to setup stack for a C entry
+ * point on both ARM32 and ARM64. ENTRY_FUNCTION on ARM64 can only be used
+ * if preceding boot stage has initialized the stack pointer.
+ *
+ * Stack top of 0 means stack is already set up. In that case, the follow-up
+ * code block will not be inlined and may spill to stack right away.
+ */
+#ifdef CONFIG_CPU_64
+
+void __barebox_arm64_head(ulong x0, ulong x1, ulong x2);
+
+#define ENTRY_FUNCTION_WITHSTACK_HEAD(name, stack_top, head, arg0, arg1, arg2) \
+ void name(ulong r0, ulong r1, ulong r2); \
+ \
+ static void __##name(ulong, ulong, ulong); \
+ \
+ void __section(.text_head_entry_##name) name \
+ (ulong r0, ulong r1, ulong r2) \
+ { \
+ static __section(.pbl_board_stack_top_##name) \
+ const ulong __stack_top = (stack_top); \
+ __keep_symbolref(head); \
+ __keep_symbolref(__stack_top); \
+ __##name(r0, r1, r2); \
+ } \
+ static void noinline __##name \
+ (ulong arg0, ulong arg1, ulong arg2)
+
+#define ENTRY_FUNCTION_WITHSTACK(name, stack_top, arg0, arg1, arg2) \
+ ENTRY_FUNCTION_WITHSTACK_HEAD(name, stack_top, \
+ __barebox_arm64_head, arg0, arg1, arg2)
+
#define ENTRY_FUNCTION(name, arg0, arg1, arg2) \
- void name (uint32_t r0, uint32_t r1, uint32_t r2); \
+ ENTRY_FUNCTION_WITHSTACK(name, 0, arg0, arg1, arg2)
+
+#else
+#define ENTRY_FUNCTION_WITHSTACK_HEAD(name, stack_top, head, arg0, arg1, arg2) \
+ static void ____##name(ulong, ulong, ulong); \
+ __ENTRY_FUNCTION_HEAD(name, head, arg0, arg1, arg2) \
+ { \
+ if (stack_top) \
+ arm_setup_stack(stack_top); \
+ ____##name(arg0, arg1, arg2); \
+ } \
+ static void noinline ____##name \
+ (ulong arg0, ulong arg1, ulong arg2)
+
+#define __ENTRY_FUNCTION_HEAD(name, head, arg0, arg1, arg2) \
+ void name(ulong r0, ulong r1, ulong r2); \
\
- static void __##name(uint32_t, uint32_t, uint32_t); \
+ static void __##name(ulong, ulong, ulong); \
\
- void NAKED __section(.text_head_entry_##name) name \
- (uint32_t r0, uint32_t r1, uint32_t r2) \
+ void __naked __section(.text_head_entry_##name) name \
+ (ulong r0, ulong r1, ulong r2) \
{ \
- __barebox_arm_head(); \
+ head(); \
__##name(r0, r1, r2); \
} \
- static void NAKED noinline __##name \
- (uint32_t arg0, uint32_t arg1, uint32_t arg2)
+ static void __naked noinline __##name \
+ (ulong arg0, ulong arg1, ulong arg2)
+
+#define ENTRY_FUNCTION(name, arg0, arg1, arg2) \
+ __ENTRY_FUNCTION_HEAD(name, __barebox_arm_head, arg0, arg1, arg2)
+
+#define ENTRY_FUNCTION_WITHSTACK(name, stack_top, arg0, arg1, arg2) \
+ ENTRY_FUNCTION_WITHSTACK_HEAD(name, stack_top, \
+ __barebox_arm_head, arg0, arg1, arg2)
+#endif
/*
* When using compressed images in conjunction with relocatable images
diff --git a/arch/arm/include/asm/barebox.lds.h b/arch/arm/include/asm/barebox.lds.h
new file mode 100644
index 0000000000..a5c74381d8
--- /dev/null
+++ b/arch/arm/include/asm/barebox.lds.h
@@ -0,0 +1,30 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#if defined CONFIG_ARCH_EP93XX
+#include <mach/ep93xx/barebox.lds.h>
+#endif
+
+#ifdef CONFIG_CPU_32
+#define BAREBOX_OUTPUT_FORMAT "elf32-littlearm", "elf32-littlearm", "elf32-littlearm"
+#define BAREBOX_OUTPUT_ARCH "arm"
+#else
+#define BAREBOX_OUTPUT_FORMAT "elf64-littleaarch64", "elf64-littleaarch64", "elf64-littleaarch64"
+#define BAREBOX_OUTPUT_ARCH "aarch64"
+#endif
+
+#ifdef CONFIG_CPU_32
+#define BAREBOX_RELOCATION_TYPE rel
+#else
+#define BAREBOX_RELOCATION_TYPE rela
+#endif
+
+#define BAREBOX_RELOCATION_TABLE \
+ .rel_dyn_start : { *(.__rel_dyn_start) } \
+ .BAREBOX_RELOCATION_TYPE.dyn : { *(.BAREBOX_RELOCATION_TYPE*) } \
+ .rel_dyn_end : { *(.__rel_dyn_end) } \
+ .__dynsym_start : { *(.__dynsym_start) } \
+ .dynsym : { *(.dynsym) } \
+ .__dynsym_end : { *(.__dynsym_end) }
+
+
+#include <asm-generic/barebox.lds.h>
diff --git a/arch/arm/include/asm/bitops.h b/arch/arm/include/asm/bitops.h
index d8a4d9b667..2d0d300da2 100644
--- a/arch/arm/include/asm/bitops.h
+++ b/arch/arm/include/asm/bitops.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
/*
* Copyright 1995, Russell King.
* Various bits and pieces copyrights include:
diff --git a/arch/arm/include/asm/bitsperlong.h b/arch/arm/include/asm/bitsperlong.h
index 6dc0bb0c13..bf000a04cc 100644
--- a/arch/arm/include/asm/bitsperlong.h
+++ b/arch/arm/include/asm/bitsperlong.h
@@ -1 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#include <asm-generic/bitsperlong.h>
diff --git a/arch/arm/include/asm/byteorder.h b/arch/arm/include/asm/byteorder.h
index c3489f1e1f..751dc0e530 100644
--- a/arch/arm/include/asm/byteorder.h
+++ b/arch/arm/include/asm/byteorder.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
/*
* linux/include/asm-arm/byteorder.h
*
diff --git a/arch/arm/include/asm/cache-l2x0.h b/arch/arm/include/asm/cache-l2x0.h
index 9bb245b0be..e325bbbff6 100644
--- a/arch/arm/include/asm/cache-l2x0.h
+++ b/arch/arm/include/asm/cache-l2x0.h
@@ -1,18 +1,7 @@
-/*
- * arch/arm/include/asm/hardware/cache-l2x0.h
- *
- * Copyright (C) 2007 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 2007 ARM Limited */
+
+/* arch/arm/include/asm/hardware/cache-l2x0.h */
#ifndef __ASM_ARM_HARDWARE_L2X0_H
#define __ASM_ARM_HARDWARE_L2X0_H
diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
index bf3a1a0ed2..261c30129a 100644
--- a/arch/arm/include/asm/cache.h
+++ b/arch/arm/include/asm/cache.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_CACHE_H
#define __ASM_CACHE_H
@@ -16,11 +18,12 @@ static inline void icache_invalidate(void)
#endif
}
-int arm_set_cache_functions(void);
-
void arm_early_mmu_cache_flush(void);
void arm_early_mmu_cache_invalidate(void);
+#define sync_caches_for_execution sync_caches_for_execution
void sync_caches_for_execution(void);
+#include <asm-generic/cache.h>
+
#endif
diff --git a/arch/arm/include/asm/common.h b/arch/arm/include/asm/common.h
index d03ee6273f..9832a6a4d2 100644
--- a/arch/arm/include/asm/common.h
+++ b/arch/arm/include/asm/common.h
@@ -1,6 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_COMMON_H
#define __ASM_ARM_COMMON_H
+#include <linux/compiler.h>
+
static inline unsigned long get_pc(void)
{
unsigned long pc;
@@ -46,8 +50,23 @@ static inline unsigned long get_sp(void)
return sp;
}
+extern void __compiletime_error(
+ "arm_setup_stack() called outside of naked function. On ARM64, "
+ "stack should be setup in non-inline assembly before branching to C entry point."
+) __unsafe_setup_stack(void);
+
+/*
+ * Sets up new stack growing down from top within a naked C function.
+ * The first stack word will be top - sizeof(word).
+ *
+ * Avoid interleaving with C code as much as possible and jump
+ * ASAP to a noinline function.
+ */
static inline void arm_setup_stack(unsigned long top)
{
+ if (IS_ENABLED(CONFIG_CPU_64))
+ __unsafe_setup_stack();
+
__asm__ __volatile__("mov sp, %0"
:
: "r"(top));
diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h
index f39939bd44..c3fc057650 100644
--- a/arch/arm/include/asm/cputype.h
+++ b/arch/arm/include/asm/cputype.h
@@ -1,9 +1,28 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_CPUTYPE_H
#define __ASM_ARM_CPUTYPE_H
#include <linux/stringify.h>
#include <linux/kernel.h>
+#ifdef CONFIG_CPU_64v8
+
+#define CPUID_ID midr_el1
+#define CPUID_CACHETYPE ctr_el0
+#define CPUID_MPIDR mpidr_el1
+
+#define read_cpuid(reg) \
+ ({ \
+ unsigned int __val; \
+ asm("mrs %0, " __stringify(reg) \
+ : "=r" (__val) \
+ : \
+ : "cc"); \
+ __val; \
+ })
+#else
+
#define CPUID_ID 0
#define CPUID_CACHETYPE 1
#define CPUID_TCM 2
@@ -25,8 +44,6 @@
#define CPUID_EXT_ISAR4 "c2, 4"
#define CPUID_EXT_ISAR5 "c2, 5"
-extern unsigned int processor_id;
-
#define read_cpuid(reg) \
({ \
unsigned int __val; \
@@ -45,6 +62,9 @@ extern unsigned int processor_id;
: "cc"); \
__val; \
})
+#endif
+
+extern unsigned int processor_id;
/*
* The CPU ID never changes at run time, so we might as well tell the
diff --git a/arch/arm/include/asm/debug_ll.h b/arch/arm/include/asm/debug_ll.h
new file mode 100644
index 0000000000..98a7d0d839
--- /dev/null
+++ b/arch/arm/include/asm/debug_ll.h
@@ -0,0 +1,71 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ASM_DEBUG_LL_H__
+#define __ASM_DEBUG_LL_H__
+
+#ifdef CONFIG_DEBUG_IMX_UART
+#include <mach/imx/debug_ll.h>
+#endif
+
+#ifdef CONFIG_DEBUG_ROCKCHIP_UART
+#include <mach/rockchip/debug_ll.h>
+#endif
+
+#ifdef CONFIG_DEBUG_OMAP_UART
+#include <mach/omap/debug_ll.h>
+#endif
+
+#ifdef CONFIG_DEBUG_ZYNQMP_UART
+#include <mach/zynqmp/debug_ll.h>
+#endif
+
+#ifdef CONFIG_DEBUG_STM32MP_UART
+#include <mach/stm32mp/debug_ll.h>
+#endif
+
+#ifdef CONFIG_DEBUG_VEXPRESS_UART
+#include <mach/vexpress/debug_ll.h>
+#endif
+
+#ifdef CONFIG_DEBUG_BCM283X_UART
+#include <mach/bcm283x/debug_ll.h>
+#endif
+
+#ifdef CONFIG_DEBUG_QEMU_ARM64_VIRT
+#define DEBUG_LL_UART_ADDR 0x9000000
+#include <debug_ll/pl011.h>
+#elif defined CONFIG_ARCH_MVEBU
+#include <mach/mvebu/debug_ll.h>
+#elif defined CONFIG_ARCH_DAVINCI
+#include <mach/davinci/debug_ll.h>
+#elif defined CONFIG_ARCH_ZYNQ
+#include <mach/zynq/debug_ll.h>
+#elif defined CONFIG_ARCH_VERSATILE
+#include <mach/versatile/debug_ll.h>
+#elif defined CONFIG_ARCH_LAYERSCAPE
+#include <mach/layerscape/debug_ll.h>
+#elif defined CONFIG_ARCH_TEGRA
+#include <mach/tegra/debug_ll.h>
+#elif defined CONFIG_ARCH_UEMD
+#include <mach/uemd/debug_ll.h>
+#elif defined CONFIG_ARCH_SOCFPGA
+#include <mach/socfpga/debug_ll.h>
+#elif defined CONFIG_ARCH_PXA
+#include <mach/pxa/debug_ll.h>
+#elif defined CONFIG_ARCH_NOMADIK
+#include <mach/nomadik/debug_ll.h>
+#elif defined CONFIG_ARCH_MXS
+#include <mach/mxs/debug_ll.h>
+#elif defined CONFIG_ARCH_EP93XX
+#include <mach/ep93xx/debug_ll.h>
+#elif defined CONFIG_ARCH_DIGIC
+#include <mach/digic/debug_ll.h>
+#elif defined CONFIG_ARCH_CLPS711X
+#include <mach/clps711x/debug_ll.h>
+#elif defined CONFIG_ARCH_AT91
+#include <mach/at91/debug_ll.h>
+#elif defined CONFIG_ARCH_K3
+#include <mach/k3/debug_ll.h>
+#endif
+
+#endif
diff --git a/arch/arm/include/asm/dma.h b/arch/arm/include/asm/dma.h
index 15999a524d..d045f00c67 100644
--- a/arch/arm/include/asm/dma.h
+++ b/arch/arm/include/asm/dma.h
@@ -1,19 +1,15 @@
-/*
- * Copyright (C) 2012 by Marc Kleine-Budde <mkl@pengutronix.de>
- *
- * This file is released under the GPLv2
- *
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 2012 Marc Kleine-Budde <mkl@pengutronix.de> */
-#include <common.h>
+#include <linux/types.h>
+#include <linux/string.h>
+#include <xfuncs.h>
+#include <malloc.h>
-#define dma_alloc dma_alloc
-static inline void *dma_alloc(size_t size)
-{
- return xmemalign(64, ALIGN(size, 64));
-}
+#define DMA_ALIGNMENT 64
#ifndef CONFIG_MMU
+#define dma_alloc_coherent dma_alloc_coherent
static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
{
void *ret = xmemalign(4096, size);
@@ -25,35 +21,28 @@ static inline void *dma_alloc_coherent(size_t size, dma_addr_t *dma_handle)
return ret;
}
+#define dma_alloc_writecombine dma_alloc_writecombine
static inline void *dma_alloc_writecombine(size_t size, dma_addr_t *dma_handle)
{
return dma_alloc_coherent(size, dma_handle);
}
+#define dma_free_coherent dma_free_coherent
static inline void dma_free_coherent(void *mem, dma_addr_t dma_handle,
size_t size)
{
free(mem);
}
-static inline dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
- enum dma_data_direction dir)
-{
- return (dma_addr_t)ptr;
-}
-
-static inline void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
- enum dma_data_direction dir)
-{
-}
-
-static inline void dma_sync_single_for_cpu(dma_addr_t address, size_t size,
- enum dma_data_direction dir)
+#define arch_sync_dma_for_cpu arch_sync_dma_for_cpu
+static inline void arch_sync_dma_for_cpu(void *vaddr, size_t size,
+ enum dma_data_direction dir)
{
}
-static inline void dma_sync_single_for_device(dma_addr_t address, size_t size,
- enum dma_data_direction dir)
+#define arch_sync_dma_for_device arch_sync_dma_for_device
+static inline void arch_sync_dma_for_device(void *vaddr, size_t size,
+ enum dma_data_direction dir)
{
}
#endif
diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
index b98b3e52a4..4043e6fd5b 100644
--- a/arch/arm/include/asm/elf.h
+++ b/arch/arm/include/asm/elf.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASMARM_ELF_H
#define __ASMARM_ELF_H
@@ -20,6 +22,7 @@ typedef struct user_fp elf_fpregset_t;
#endif
#define EM_ARM 40
+#define EM_AARCH64 183
#define EF_ARM_APCS26 0x08
#define EF_ARM_SOFT_FLOAT 0x200
#define EF_ARM_EABI_MASK 0xFF000000
@@ -30,6 +33,9 @@ typedef struct user_fp elf_fpregset_t;
#define R_ARM_CALL 28
#define R_ARM_JUMP24 29
+#define R_ARM_THM_CALL 10
+#define R_ARM_THM_JUMP24 30
+
/*
* These are used to set parameters in the core dumps.
*/
@@ -39,7 +45,11 @@ typedef struct user_fp elf_fpregset_t;
#else
#define ELF_DATA ELFDATA2LSB
#endif
+#ifdef CONFIG_CPU_64
+#define ELF_ARCH EM_AARCH64
+#else
#define ELF_ARCH EM_ARM
+#endif
#ifdef __KERNEL__
#ifndef __ASSEMBLY__
diff --git a/arch/arm/include/asm/errata.h b/arch/arm/include/asm/errata.h
index f020369916..9bb0e650c7 100644
--- a/arch/arm/include/asm/errata.h
+++ b/arch/arm/include/asm/errata.h
@@ -1,16 +1,5 @@
-/*
- * Copyright (C) 2014 Lucas Stach, Pengutronix
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* SPDX-FileCopyrightText: 2014 Lucas Stach, Pengutronix */
static inline void enable_arm_errata_709718_war(void)
{
diff --git a/arch/arm/include/asm/esr.h b/arch/arm/include/asm/esr.h
index 77eeb2cc64..52347b6862 100644
--- a/arch/arm/include/asm/esr.h
+++ b/arch/arm/include/asm/esr.h
@@ -1,19 +1,7 @@
-/*
- * Copyright (C) 2013 - ARM Ltd
- * Author: Marc Zyngier <marc.zyngier@arm.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 2013 ARM Ltd */
+
+/* Author: Marc Zyngier */
#ifndef __ASM_ESR_H
#define __ASM_ESR_H
diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
new file mode 100644
index 0000000000..9d87ad72e9
--- /dev/null
+++ b/arch/arm/include/asm/fncpy.h
@@ -0,0 +1,70 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * arch/arm/include/asm/fncpy.h - helper macros for function body copying
+ *
+ * Copyright (C) 2011 Linaro Limited
+ */
+
+/*
+ * These macros are intended for use when there is a need to copy a low-level
+ * function body into special memory.
+ *
+ * For example, when reconfiguring the SDRAM controller, the code doing the
+ * reconfiguration may need to run from SRAM.
+ *
+ * NOTE: that the copied function body must be entirely self-contained and
+ * position-independent in order for this to work properly.
+ *
+ * NOTE: in order for embedded literals and data to get referenced correctly,
+ * the alignment of functions must be preserved when copying. To ensure this,
+ * the source and destination addresses for fncpy() must be aligned to a
+ * multiple of 8 bytes: you will be get a BUG() if this condition is not met.
+ * You will typically need a ".align 3" directive in the assembler where the
+ * function to be copied is defined, and ensure that your allocator for the
+ * destination buffer returns 8-byte-aligned pointers.
+ *
+ * Typical usage example:
+ *
+ * extern int f(args);
+ * extern uint32_t size_of_f;
+ * int (*copied_f)(args);
+ * void *sram_buffer;
+ *
+ * copied_f = fncpy(sram_buffer, &f, size_of_f);
+ *
+ * ... later, call the function: ...
+ *
+ * copied_f(args);
+ *
+ * The size of the function to be copied can't be determined from C:
+ * this must be determined by other means, such as adding assmbler directives
+ * in the file where f is defined.
+ */
+
+#ifndef __ASM_FNCPY_H
+#define __ASM_FNCPY_H
+
+#include <linux/types.h>
+#include <linux/string.h>
+
+/*
+ * Minimum alignment requirement for the source and destination addresses
+ * for function copying.
+ */
+#define FNCPY_ALIGN 8
+
+#define fncpy(dest_buf, funcp, size) ({ \
+ uintptr_t __funcp_address; \
+ typeof(funcp) __result; \
+ \
+ asm("" : "=r" (__funcp_address) : "0" (funcp)); \
+ \
+ memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
+ \
+ asm("" : "=r" (__result) \
+ : "0" ((uintptr_t)(dest_buf) | (__funcp_address & 1))); \
+ \
+ __result; \
+})
+
+#endif /* !__ASM_FNCPY_H */
diff --git a/arch/arm/include/asm/gic.h b/arch/arm/include/asm/gic.h
index f83f528141..d7e4c3cbf0 100644
--- a/arch/arm/include/asm/gic.h
+++ b/arch/arm/include/asm/gic.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __GIC_H__
#define __GIC_H__
diff --git a/arch/arm/include/asm/hardware/arm_timer.h b/arch/arm/include/asm/hardware/arm_timer.h
index 8a58390a19..7911628ba7 100644
--- a/arch/arm/include/asm/hardware/arm_timer.h
+++ b/arch/arm/include/asm/hardware/arm_timer.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_HARDWARE_ARM_TIMER_H
#define __ASM_ARM_HARDWARE_ARM_TIMER_H
diff --git a/arch/arm/include/asm/hardware/sp810.h b/arch/arm/include/asm/hardware/sp810.h
index 3e3996a99e..ab6911f914 100644
--- a/arch/arm/include/asm/hardware/sp810.h
+++ b/arch/arm/include/asm/hardware/sp810.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
/*
* arch/arm/include/asm/hardware/sp810.h
*
@@ -5,10 +7,6 @@
*
* Copyright (C) 2009 ST Microelectronics
* Viresh Kumar <viresh.linux@gmail.com>
- *
- * This file is licensed under the terms of the GNU General Public
- * License version 2. This program is licensed "as is" without any
- * warranty of any kind, whether express or implied.
*/
#ifndef __ASM_ARM_SP810_H
diff --git a/arch/arm/include/asm/image.h b/arch/arm/include/asm/image.h
new file mode 100644
index 0000000000..c2b13213c7
--- /dev/null
+++ b/arch/arm/include/asm/image.h
@@ -0,0 +1,59 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ASM_IMAGE_H
+#define __ASM_IMAGE_H
+
+#define ARM64_IMAGE_MAGIC "ARM\x64"
+
+#define ARM64_IMAGE_FLAG_BE_SHIFT 0
+#define ARM64_IMAGE_FLAG_PAGE_SIZE_SHIFT (ARM64_IMAGE_FLAG_BE_SHIFT + 1)
+#define ARM64_IMAGE_FLAG_PHYS_BASE_SHIFT \
+ (ARM64_IMAGE_FLAG_PAGE_SIZE_SHIFT + 2)
+#define ARM64_IMAGE_FLAG_BE_MASK 0x1
+#define ARM64_IMAGE_FLAG_PAGE_SIZE_MASK 0x3
+#define ARM64_IMAGE_FLAG_PHYS_BASE_MASK 0x1
+
+#define ARM64_IMAGE_FLAG_LE 0
+#define ARM64_IMAGE_FLAG_BE 1
+#define ARM64_IMAGE_FLAG_PAGE_SIZE_4K 1
+#define ARM64_IMAGE_FLAG_PAGE_SIZE_16K 2
+#define ARM64_IMAGE_FLAG_PAGE_SIZE_64K 3
+#define ARM64_IMAGE_FLAG_PHYS_BASE 1
+
+#ifndef __ASSEMBLY__
+
+#define arm64_image_flag_field(flags, field) \
+ (((flags) >> field##_SHIFT) & field##_MASK)
+
+/*
+ * struct arm64_image_header - arm64 kernel image header
+ * See Documentation/arm64/booting.rst for details
+ *
+ * @code0: Executable code, or
+ * @mz_header alternatively used for part of MZ header
+ * @code1: Executable code
+ * @text_offset: Image load offset
+ * @image_size: Effective Image size
+ * @flags: kernel flags
+ * @reserved: reserved
+ * @magic: Magic number
+ * @reserved5: reserved, or
+ * @pe_header: alternatively used for PE COFF offset
+ */
+
+struct arm64_image_header {
+ __le32 code0;
+ __le32 code1;
+ __le64 text_offset;
+ __le64 image_size;
+ __le64 flags;
+ __le64 res2;
+ __le64 res3;
+ __le64 res4;
+ __le32 magic;
+ __le32 res5;
+};
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ASM_IMAGE_H */
diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h
index 56db546341..486b142950 100644
--- a/arch/arm/include/asm/io.h
+++ b/arch/arm/include/asm/io.h
@@ -1,8 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_IO_H
#define __ASM_ARM_IO_H
#define IO_SPACE_LIMIT 0
+#define memcpy_fromio memcpy_fromio
+#define memcpy_toio memcpy_toio
+#define memset_io memset_io
+
#include <asm-generic/io.h>
/*
@@ -12,71 +18,4 @@ extern void memcpy_fromio(void *, const volatile void __iomem *, size_t);
extern void memcpy_toio(volatile void __iomem *, const void *, size_t);
extern void memset_io(volatile void __iomem *, int, size_t);
-/*
- * Clear and set bits in one shot. These macros can be used to clear and
- * set multiple bits in a register using a single call. These macros can
- * also be used to set a multiple-bit bit pattern using a mask, by
- * specifying the mask in the 'clear' parameter and the new bit pattern
- * in the 'set' parameter.
- */
-
-#define out_arch(type,endian,a,v) __raw_write##type(cpu_to_##endian(v),a)
-#define in_arch(type,endian,a) endian##_to_cpu(__raw_read##type(a))
-
-#define out_le64(a,v) out_arch(q,le64,a,v)
-#define out_le32(a,v) out_arch(l,le32,a,v)
-#define out_le16(a,v) out_arch(w,le16,a,v)
-
-#define in_le64(a) in_arch(q,le64,a)
-#define in_le32(a) in_arch(l,le32,a)
-#define in_le16(a) in_arch(w,le16,a)
-
-#define out_be32(a,v) out_arch(l,be32,a,v)
-#define out_be16(a,v) out_arch(w,be16,a,v)
-
-#define in_be32(a) in_arch(l,be32,a)
-#define in_be16(a) in_arch(w,be16,a)
-
-#define out_8(a,v) __raw_writeb(v,a)
-#define in_8(a) __raw_readb(a)
-
-#define clrbits(type, addr, clear) \
- out_##type((addr), in_##type(addr) & ~(clear))
-
-#define setbits(type, addr, set) \
- out_##type((addr), in_##type(addr) | (set))
-
-#define clrsetbits(type, addr, clear, set) \
- out_##type((addr), (in_##type(addr) & ~(clear)) | (set))
-
-#define clrbits_be32(addr, clear) clrbits(be32, addr, clear)
-#define setbits_be32(addr, set) setbits(be32, addr, set)
-#define clrsetbits_be32(addr, clear, set) clrsetbits(be32, addr, clear, set)
-
-#define clrbits_le32(addr, clear) clrbits(le32, addr, clear)
-#define setbits_le32(addr, set) setbits(le32, addr, set)
-#define clrsetbits_le32(addr, clear, set) clrsetbits(le32, addr, clear, set)
-
-#define clrbits_be16(addr, clear) clrbits(be16, addr, clear)
-#define setbits_be16(addr, set) setbits(be16, addr, set)
-#define clrsetbits_be16(addr, clear, set) clrsetbits(be16, addr, clear, set)
-
-#define clrbits_le16(addr, clear) clrbits(le16, addr, clear)
-#define setbits_le16(addr, set) setbits(le16, addr, set)
-#define clrsetbits_le16(addr, clear, set) clrsetbits(le16, addr, clear, set)
-
-#define clrbits_8(addr, clear) clrbits(8, addr, clear)
-#define setbits_8(addr, set) setbits(8, addr, set)
-#define clrsetbits_8(addr, clear, set) clrsetbits(8, addr, clear, set)
-
-static inline void *phys_to_virt(unsigned long phys)
-{
- return (void *)phys;
-}
-
-static inline unsigned long virt_to_phys(volatile void *mem)
-{
- return (unsigned long)mem;
-}
-
#endif /* __ASM_ARM_IO_H */
diff --git a/arch/arm/include/asm/linkage.h b/arch/arm/include/asm/linkage.h
index 5a25632b1b..728ebe6f6f 100644
--- a/arch/arm/include/asm/linkage.h
+++ b/arch/arm/include/asm/linkage.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_LINKAGE_H
#define __ASM_LINKAGE_H
diff --git a/arch/arm/include/asm/mach-types.h b/arch/arm/include/asm/mach-types.h
new file mode 100644
index 0000000000..f16aeb88db
--- /dev/null
+++ b/arch/arm/include/asm/mach-types.h
@@ -0,0 +1,868 @@
+/*
+ * Machine type definitions for legacy platforms.
+ */
+
+#ifndef __ASM_ARM_MACH_TYPE_H
+#define __ASM_ARM_MACH_TYPE_H
+
+#ifndef __ASSEMBLY__
+/* The type of machine we're running on */
+extern unsigned int __machine_arch_type;
+#endif
+
+/* see arch/arm/kernel/arch.c for a description of these */
+#define MACH_TYPE_LUBBOCK 89
+#define MACH_TYPE_VERSATILE_PB 387
+#define MACH_TYPE_CSB337 399
+#define MACH_TYPE_MAINSTONE 406
+#define MACH_TYPE_NOMADIK 420
+#define MACH_TYPE_EDB9312 451
+#define MACH_TYPE_EDB9301 462
+#define MACH_TYPE_EDB9315 463
+#define MACH_TYPE_SCB9328 508
+#define MACH_TYPE_EDB9302 538
+#define MACH_TYPE_EDB9307 607
+#define MACH_TYPE_AT91RM9200EK 705
+#define MACH_TYPE_PCM027 732
+#define MACH_TYPE_EDB9315A 772
+#define MACH_TYPE_AT91SAM9261EK 848
+#define MACH_TYPE_AT91SAM9260EK 1099
+#define MACH_TYPE_EDB9302A 1127
+#define MACH_TYPE_EDB9307A 1128
+#define MACH_TYPE_PM9261 1187
+#define MACH_TYPE_AT91SAM9263EK 1202
+#define MACH_TYPE_ZYLONITE 1233
+#define MACH_TYPE_MIOA701 1257
+#define MACH_TYPE_PM9263 1475
+#define MACH_TYPE_OMAP3EVM 1535
+#define MACH_TYPE_OMAP3_BEAGLE 1546
+#define MACH_TYPE_AT91SAM9G20EK 1624
+#define MACH_TYPE_USB_A9260 1709
+#define MACH_TYPE_USB_A9263 1710
+#define MACH_TYPE_QIL_A9260 1711
+#define MACH_TYPE_PICOCOM1 1751
+#define MACH_TYPE_AT91SAM9M10G45EK 1830
+#define MACH_TYPE_USB_A9G20 1841
+#define MACH_TYPE_QIL_A9G20 1844
+#define MACH_TYPE_CHUMBY 1937
+#define MACH_TYPE_TNY_A9260 2058
+#define MACH_TYPE_TNY_A9G20 2059
+#define MACH_TYPE_MX51_BABBAGE 2125
+#define MACH_TYPE_TNY_A9263 2140
+#define MACH_TYPE_AT91SAM9G10EK 2159
+#define MACH_TYPE_TX25 2177
+#define MACH_TYPE_MX23EVK 2629
+#define MACH_TYPE_PM9G45 2672
+#define MACH_TYPE_OMAP4_PANDA 2791
+#define MACH_TYPE_PCAAL1 2843
+#define MACH_TYPE_ARMADA_XP_DB 3036
+#define MACH_TYPE_TX28 3043
+#define MACH_TYPE_BCM2708 3138
+#define MACH_TYPE_MX53_LOCO 3273
+#define MACH_TYPE_TX53 3279
+#define MACH_TYPE_CCMX53 3346
+#define MACH_TYPE_CCWMX53 3348
+#define MACH_TYPE_VMX53 3359
+#define MACH_TYPE_PCM049 3364
+#define MACH_TYPE_DSS11 3787
+#define MACH_TYPE_BEAGLEBONE 3808
+#define MACH_TYPE_PCAAXL2 3912
+#define MACH_TYPE_MX6Q_SABRESD 3980
+#define MACH_TYPE_TQMA53 4004
+#define MACH_TYPE_IMX233_OLINUXINO 4105
+#define MACH_TYPE_CFA10036 4142
+#define MACH_TYPE_PCM051 4144
+#define MACH_TYPE_HABA_KNX_LITE 4310
+#define MACH_TYPE_VAR_SOM_MX6 4419
+#define MACH_TYPE_PCAAXS1 4526
+#define MACH_TYPE_PFLA03 4575
+
+#ifdef CONFIG_ARCH_LUBBOCK
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_LUBBOCK
+# endif
+# define machine_is_lubbock() (machine_arch_type == MACH_TYPE_LUBBOCK)
+#else
+# define machine_is_lubbock() (0)
+#endif
+
+#ifdef CONFIG_ARCH_VERSATILE_PB
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_VERSATILE_PB
+# endif
+# define machine_is_versatile_pb() (machine_arch_type == MACH_TYPE_VERSATILE_PB)
+#else
+# define machine_is_versatile_pb() (0)
+#endif
+
+#ifdef CONFIG_MACH_CSB337
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_CSB337
+# endif
+# define machine_is_csb337() (machine_arch_type == MACH_TYPE_CSB337)
+#else
+# define machine_is_csb337() (0)
+#endif
+
+#ifdef CONFIG_MACH_MAINSTONE
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_MAINSTONE
+# endif
+# define machine_is_mainstone() (machine_arch_type == MACH_TYPE_MAINSTONE)
+#else
+# define machine_is_mainstone() (0)
+#endif
+
+#ifdef CONFIG_MACH_NOMADIK
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_NOMADIK
+# endif
+# define machine_is_nomadik() (machine_arch_type == MACH_TYPE_NOMADIK)
+#else
+# define machine_is_nomadik() (0)
+#endif
+
+#ifdef CONFIG_MACH_EDB9312
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_EDB9312
+# endif
+# define machine_is_edb9312() (machine_arch_type == MACH_TYPE_EDB9312)
+#else
+# define machine_is_edb9312() (0)
+#endif
+
+#ifdef CONFIG_MACH_EDB9301
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_EDB9301
+# endif
+# define machine_is_edb9301() (machine_arch_type == MACH_TYPE_EDB9301)
+#else
+# define machine_is_edb9301() (0)
+#endif
+
+#ifdef CONFIG_MACH_EDB9315
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_EDB9315
+# endif
+# define machine_is_edb9315() (machine_arch_type == MACH_TYPE_EDB9315)
+#else
+# define machine_is_edb9315() (0)
+#endif
+
+#ifdef CONFIG_MACH_SCB9328
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_SCB9328
+# endif
+# define machine_is_scb9328() (machine_arch_type == MACH_TYPE_SCB9328)
+#else
+# define machine_is_scb9328() (0)
+#endif
+
+#ifdef CONFIG_MACH_EDB9302
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_EDB9302
+# endif
+# define machine_is_edb9302() (machine_arch_type == MACH_TYPE_EDB9302)
+#else
+# define machine_is_edb9302() (0)
+#endif
+
+#ifdef CONFIG_MACH_EDB9307
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_EDB9307
+# endif
+# define machine_is_edb9307() (machine_arch_type == MACH_TYPE_EDB9307)
+#else
+# define machine_is_edb9307() (0)
+#endif
+
+#ifdef CONFIG_MACH_AT91RM9200EK
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_AT91RM9200EK
+# endif
+# define machine_is_at91rm9200ek() (machine_arch_type == MACH_TYPE_AT91RM9200EK)
+#else
+# define machine_is_at91rm9200ek() (0)
+#endif
+
+#ifdef CONFIG_MACH_PCM027
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PCM027
+# endif
+# define machine_is_pcm027() (machine_arch_type == MACH_TYPE_PCM027)
+#else
+# define machine_is_pcm027() (0)
+#endif
+
+#ifdef CONFIG_MACH_EDB9315A
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_EDB9315A
+# endif
+# define machine_is_edb9315a() (machine_arch_type == MACH_TYPE_EDB9315A)
+#else
+# define machine_is_edb9315a() (0)
+#endif
+
+#ifdef CONFIG_MACH_AT91SAM9261EK
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_AT91SAM9261EK
+# endif
+# define machine_is_at91sam9261ek() (machine_arch_type == MACH_TYPE_AT91SAM9261EK)
+#else
+# define machine_is_at91sam9261ek() (0)
+#endif
+
+#ifdef CONFIG_MACH_AT91SAM9260EK
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_AT91SAM9260EK
+# endif
+# define machine_is_at91sam9260ek() (machine_arch_type == MACH_TYPE_AT91SAM9260EK)
+#else
+# define machine_is_at91sam9260ek() (0)
+#endif
+
+#ifdef CONFIG_MACH_EDB9302A
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_EDB9302A
+# endif
+# define machine_is_edb9302a() (machine_arch_type == MACH_TYPE_EDB9302A)
+#else
+# define machine_is_edb9302a() (0)
+#endif
+
+#ifdef CONFIG_MACH_EDB9307A
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_EDB9307A
+# endif
+# define machine_is_edb9307a() (machine_arch_type == MACH_TYPE_EDB9307A)
+#else
+# define machine_is_edb9307a() (0)
+#endif
+
+#ifdef CONFIG_MACH_PM9261
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PM9261
+# endif
+# define machine_is_pm9261() (machine_arch_type == MACH_TYPE_PM9261)
+#else
+# define machine_is_pm9261() (0)
+#endif
+
+#ifdef CONFIG_MACH_AT91SAM9263EK
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_AT91SAM9263EK
+# endif
+# define machine_is_at91sam9263ek() (machine_arch_type == MACH_TYPE_AT91SAM9263EK)
+#else
+# define machine_is_at91sam9263ek() (0)
+#endif
+
+#ifdef CONFIG_MACH_ZYLONITE
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_ZYLONITE
+# endif
+# define machine_is_zylonite() (machine_arch_type == MACH_TYPE_ZYLONITE)
+#else
+# define machine_is_zylonite() (0)
+#endif
+
+#ifdef CONFIG_MACH_MIOA701
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_MIOA701
+# endif
+# define machine_is_mioa701() (machine_arch_type == MACH_TYPE_MIOA701)
+#else
+# define machine_is_mioa701() (0)
+#endif
+
+#ifdef CONFIG_MACH_PM9263
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PM9263
+# endif
+# define machine_is_pm9263() (machine_arch_type == MACH_TYPE_PM9263)
+#else
+# define machine_is_pm9263() (0)
+#endif
+
+#ifdef CONFIG_MACH_OMAP3EVM
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_OMAP3EVM
+# endif
+# define machine_is_omap3evm() (machine_arch_type == MACH_TYPE_OMAP3EVM)
+#else
+# define machine_is_omap3evm() (0)
+#endif
+
+#ifdef CONFIG_MACH_OMAP3_BEAGLE
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_OMAP3_BEAGLE
+# endif
+# define machine_is_omap3_beagle() (machine_arch_type == MACH_TYPE_OMAP3_BEAGLE)
+#else
+# define machine_is_omap3_beagle() (0)
+#endif
+
+#ifdef CONFIG_MACH_AT91SAM9G20EK
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_AT91SAM9G20EK
+# endif
+# define machine_is_at91sam9g20ek() (machine_arch_type == MACH_TYPE_AT91SAM9G20EK)
+#else
+# define machine_is_at91sam9g20ek() (0)
+#endif
+
+#ifdef CONFIG_MACH_USB_A9260
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_USB_A9260
+# endif
+# define machine_is_usb_a9260() (machine_arch_type == MACH_TYPE_USB_A9260)
+#else
+# define machine_is_usb_a9260() (0)
+#endif
+
+#ifdef CONFIG_MACH_USB_A9263
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_USB_A9263
+# endif
+# define machine_is_usb_a9263() (machine_arch_type == MACH_TYPE_USB_A9263)
+#else
+# define machine_is_usb_a9263() (0)
+#endif
+
+#ifdef CONFIG_MACH_QIL_A9260
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_QIL_A9260
+# endif
+# define machine_is_qil_a9260() (machine_arch_type == MACH_TYPE_QIL_A9260)
+#else
+# define machine_is_qil_a9260() (0)
+#endif
+
+#ifdef CONFIG_MACH_PICOCOM1
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PICOCOM1
+# endif
+# define machine_is_picocom1() (machine_arch_type == MACH_TYPE_PICOCOM1)
+#else
+# define machine_is_picocom1() (0)
+#endif
+
+#ifdef CONFIG_MACH_AT91SAM9M10G45EK
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_AT91SAM9M10G45EK
+# endif
+# define machine_is_at91sam9m10g45ek() (machine_arch_type == MACH_TYPE_AT91SAM9M10G45EK)
+#else
+# define machine_is_at91sam9m10g45ek() (0)
+#endif
+
+#ifdef CONFIG_MACH_USB_A9G20
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_USB_A9G20
+# endif
+# define machine_is_usb_a9g20() (machine_arch_type == MACH_TYPE_USB_A9G20)
+#else
+# define machine_is_usb_a9g20() (0)
+#endif
+
+#ifdef CONFIG_MACH_QIL_A9G20
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_QIL_A9G20
+# endif
+# define machine_is_qil_a9g20() (machine_arch_type == MACH_TYPE_QIL_A9G20)
+#else
+# define machine_is_qil_a9g20() (0)
+#endif
+
+#ifdef CONFIG_MACH_CHUMBY
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_CHUMBY
+# endif
+# define machine_is_chumby() (machine_arch_type == MACH_TYPE_CHUMBY)
+#else
+# define machine_is_chumby() (0)
+#endif
+
+#ifdef CONFIG_MACH_TNY_A9260
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_TNY_A9260
+# endif
+# define machine_is_tny_a9260() (machine_arch_type == MACH_TYPE_TNY_A9260)
+#else
+# define machine_is_tny_a9260() (0)
+#endif
+
+#ifdef CONFIG_MACH_TNY_A9G20
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_TNY_A9G20
+# endif
+# define machine_is_tny_a9g20() (machine_arch_type == MACH_TYPE_TNY_A9G20)
+#else
+# define machine_is_tny_a9g20() (0)
+#endif
+
+#ifdef CONFIG_MACH_MX51_BABBAGE
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_MX51_BABBAGE
+# endif
+# define machine_is_mx51_babbage() (machine_arch_type == MACH_TYPE_MX51_BABBAGE)
+#else
+# define machine_is_mx51_babbage() (0)
+#endif
+
+#ifdef CONFIG_MACH_TNY_A9263
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_TNY_A9263
+# endif
+# define machine_is_tny_a9263() (machine_arch_type == MACH_TYPE_TNY_A9263)
+#else
+# define machine_is_tny_a9263() (0)
+#endif
+
+#ifdef CONFIG_MACH_AT91SAM9G10EK
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_AT91SAM9G10EK
+# endif
+# define machine_is_at91sam9g10ek() (machine_arch_type == MACH_TYPE_AT91SAM9G10EK)
+#else
+# define machine_is_at91sam9g10ek() (0)
+#endif
+
+#ifdef CONFIG_MACH_TX25
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_TX25
+# endif
+# define machine_is_tx25() (machine_arch_type == MACH_TYPE_TX25)
+#else
+# define machine_is_tx25() (0)
+#endif
+
+#ifdef CONFIG_MACH_MX23EVK
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_MX23EVK
+# endif
+# define machine_is_mx23evk() (machine_arch_type == MACH_TYPE_MX23EVK)
+#else
+# define machine_is_mx23evk() (0)
+#endif
+
+#ifdef CONFIG_MACH_PM9G45
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PM9G45
+# endif
+# define machine_is_pm9g45() (machine_arch_type == MACH_TYPE_PM9G45)
+#else
+# define machine_is_pm9g45() (0)
+#endif
+
+#ifdef CONFIG_MACH_OMAP4_PANDA
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_OMAP4_PANDA
+# endif
+# define machine_is_omap4_panda() (machine_arch_type == MACH_TYPE_OMAP4_PANDA)
+#else
+# define machine_is_omap4_panda() (0)
+#endif
+
+#ifdef CONFIG_MACH_PCAAL1
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PCAAL1
+# endif
+# define machine_is_pcaal1() (machine_arch_type == MACH_TYPE_PCAAL1)
+#else
+# define machine_is_pcaal1() (0)
+#endif
+
+#ifdef CONFIG_MACH_ARMADA_XP_DB
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_ARMADA_XP_DB
+# endif
+# define machine_is_armada_xp_db() (machine_arch_type == MACH_TYPE_ARMADA_XP_DB)
+#else
+# define machine_is_armada_xp_db() (0)
+#endif
+
+#ifdef CONFIG_MACH_TX28
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_TX28
+# endif
+# define machine_is_tx28() (machine_arch_type == MACH_TYPE_TX28)
+#else
+# define machine_is_tx28() (0)
+#endif
+
+#ifdef CONFIG_MACH_BCM2708
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_BCM2708
+# endif
+# define machine_is_bcm2708() (machine_arch_type == MACH_TYPE_BCM2708)
+#else
+# define machine_is_bcm2708() (0)
+#endif
+
+#ifdef CONFIG_MACH_MX53_LOCO
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_MX53_LOCO
+# endif
+# define machine_is_mx53_loco() (machine_arch_type == MACH_TYPE_MX53_LOCO)
+#else
+# define machine_is_mx53_loco() (0)
+#endif
+
+#ifdef CONFIG_MACH_TX53
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_TX53
+# endif
+# define machine_is_tx53() (machine_arch_type == MACH_TYPE_TX53)
+#else
+# define machine_is_tx53() (0)
+#endif
+
+#ifdef CONFIG_MACH_CCMX53
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_CCMX53
+# endif
+# define machine_is_ccmx53() (machine_arch_type == MACH_TYPE_CCMX53)
+#else
+# define machine_is_ccmx53() (0)
+#endif
+
+#ifdef CONFIG_MACH_CCWMX53
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_CCWMX53
+# endif
+# define machine_is_ccwmx53() (machine_arch_type == MACH_TYPE_CCWMX53)
+#else
+# define machine_is_ccwmx53() (0)
+#endif
+
+#ifdef CONFIG_MACH_VMX53
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_VMX53
+# endif
+# define machine_is_vmx53() (machine_arch_type == MACH_TYPE_VMX53)
+#else
+# define machine_is_vmx53() (0)
+#endif
+
+#ifdef CONFIG_MACH_PCM049
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PCM049
+# endif
+# define machine_is_pcm049() (machine_arch_type == MACH_TYPE_PCM049)
+#else
+# define machine_is_pcm049() (0)
+#endif
+
+#ifdef CONFIG_MACH_DSS11
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_DSS11
+# endif
+# define machine_is_dss11() (machine_arch_type == MACH_TYPE_DSS11)
+#else
+# define machine_is_dss11() (0)
+#endif
+
+#ifdef CONFIG_MACH_BEAGLEBONE
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_BEAGLEBONE
+# endif
+# define machine_is_beaglebone() (machine_arch_type == MACH_TYPE_BEAGLEBONE)
+#else
+# define machine_is_beaglebone() (0)
+#endif
+
+#ifdef CONFIG_MACH_PCAAXL2
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PCAAXL2
+# endif
+# define machine_is_pcaaxl2() (machine_arch_type == MACH_TYPE_PCAAXL2)
+#else
+# define machine_is_pcaaxl2() (0)
+#endif
+
+#ifdef CONFIG_MACH_MX6Q_SABRESD
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_MX6Q_SABRESD
+# endif
+# define machine_is_mx6q_sabresd() (machine_arch_type == MACH_TYPE_MX6Q_SABRESD)
+#else
+# define machine_is_mx6q_sabresd() (0)
+#endif
+
+#ifdef CONFIG_MACH_TQMA53
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_TQMA53
+# endif
+# define machine_is_tqma53() (machine_arch_type == MACH_TYPE_TQMA53)
+#else
+# define machine_is_tqma53() (0)
+#endif
+
+#ifdef CONFIG_MACH_IMX233_OLINUXINO
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_IMX233_OLINUXINO
+# endif
+# define machine_is_imx233_olinuxino() (machine_arch_type == MACH_TYPE_IMX233_OLINUXINO)
+#else
+# define machine_is_imx233_olinuxino() (0)
+#endif
+
+#ifdef CONFIG_MACH_CFA10036
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_CFA10036
+# endif
+# define machine_is_cfa10036() (machine_arch_type == MACH_TYPE_CFA10036)
+#else
+# define machine_is_cfa10036() (0)
+#endif
+
+#ifdef CONFIG_MACH_PCM051
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PCM051
+# endif
+# define machine_is_pcm051() (machine_arch_type == MACH_TYPE_PCM051)
+#else
+# define machine_is_pcm051() (0)
+#endif
+
+#ifdef CONFIG_MACH_HABA_KNX_LITE
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_HABA_KNX_LITE
+# endif
+# define machine_is_haba_knx_lite() (machine_arch_type == MACH_TYPE_HABA_KNX_LITE)
+#else
+# define machine_is_haba_knx_lite() (0)
+#endif
+
+#ifdef CONFIG_MACH_VAR_SOM_MX6
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_VAR_SOM_MX6
+# endif
+# define machine_is_var_som_mx6() (machine_arch_type == MACH_TYPE_VAR_SOM_MX6)
+#else
+# define machine_is_var_som_mx6() (0)
+#endif
+
+#ifdef CONFIG_MACH_PCAAXS1
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PCAAXS1
+# endif
+# define machine_is_pcaaxs1() (machine_arch_type == MACH_TYPE_PCAAXS1)
+#else
+# define machine_is_pcaaxs1() (0)
+#endif
+
+#ifdef CONFIG_MACH_PFLA03
+# ifdef machine_arch_type
+# undef machine_arch_type
+# define machine_arch_type __machine_arch_type
+# else
+# define machine_arch_type MACH_TYPE_PFLA03
+# endif
+# define machine_is_pfla03() (machine_arch_type == MACH_TYPE_PFLA03)
+#else
+# define machine_is_pfla03() (0)
+#endif
+
+/*
+ * These have not yet been registered
+ */
+
+#ifndef machine_arch_type
+#define machine_arch_type __machine_arch_type
+#endif
+
+#endif
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 52114d0c4e..765b089beb 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -1,19 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_MEMORY_H
#define __ASM_ARM_MEMORY_H
+#include <linux/sizes.h>
+
+#ifndef __ASSEMBLY__
#include <memory.h>
#include <linux/const.h>
-/*
- * Allow for constants defined here to be used from assembly code
- * by prepending the UL suffix only with actual C code compilation.
- */
-#define UL(x) _AC(x, UL)
-static inline void arm_add_mem_device(const char* name, resource_size_t start,
- resource_size_t size)
+static inline int arm_add_mem_device(const char* name, resource_size_t start,
+ resource_size_t size)
{
- barebox_add_memory_bank(name, start, size);
+ return barebox_add_memory_bank(name, start, size);
}
+#endif
+
+
+/*
+ * Alignment of barebox PBL segments (e.g. .text, .data).
+ *
+ * 4 B granule: Same flat rwx mapping for everything
+ * 4 KB granule: 16 level 3 entries, with contiguous bit
+ * 16 KB granule: 4 level 3 entries, without contiguous bit
+ * 64 KB granule: 1 level 3 entry
+ */
+#ifdef CONFIG_EFI_PAYLOAD
+#define PBL_SEGMENT_ALIGN SZ_64K
+#else
+#define PBL_SEGMENT_ALIGN 4
+#endif
+
#endif /* __ASM_ARM_MEMORY_H */
diff --git a/arch/arm/include/asm/mmu.h b/arch/arm/include/asm/mmu.h
index 417808bfcc..ebf1e096c6 100644
--- a/arch/arm/include/asm/mmu.h
+++ b/arch/arm/include/asm/mmu.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_MMU_H
#define __ASM_MMU_H
@@ -21,7 +23,7 @@ static inline void setup_dma_coherent(unsigned long offset)
#ifdef CONFIG_MMU
#define ARCH_HAS_REMAP
#define MAP_ARCH_DEFAULT MAP_CACHED
-int arch_remap_range(void *_start, size_t size, unsigned flags);
+int arch_remap_range(void *virt_addr, phys_addr_t phys_addr, size_t size, unsigned flags);
void *map_io_sections(unsigned long physaddr, void *start, size_t size);
#else
#define MAP_ARCH_DEFAULT MAP_UNCACHED
@@ -48,14 +50,21 @@ struct outer_cache_fns {
void (*disable)(void);
};
+#ifdef __PBL__
+/* Existing platforms with non-architected outer cache initialize it
+ * outside PBL and new ones will likely only have architected caches,
+ * so we provide a dummy here
+ */
+static __maybe_unused struct outer_cache_fns outer_cache;
+#else
extern struct outer_cache_fns outer_cache;
+#endif
void __dma_clean_range(unsigned long, unsigned long);
void __dma_flush_range(unsigned long, unsigned long);
void __dma_inv_range(unsigned long, unsigned long);
-void mmu_early_enable(unsigned long membase, unsigned long memsize,
- unsigned long ttb);
+void mmu_early_enable(unsigned long membase, unsigned long memsize);
void mmu_early_disable(void);
#endif /* __ASM_MMU_H */
diff --git a/arch/arm/include/asm/mmuinfo.h b/arch/arm/include/asm/mmuinfo.h
new file mode 100644
index 0000000000..3005c388b9
--- /dev/null
+++ b/arch/arm/include/asm/mmuinfo.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ARM_ASM_MMUINFO_H__
+#define __ARM_ASM_MMUINFO_H__
+
+int mmuinfo_v7(void *addr);
+int mmuinfo_v8(void *addr);
+
+#endif
diff --git a/arch/arm/include/asm/module.h b/arch/arm/include/asm/module.h
index 5b4d1a3f36..a4473ff8b6 100644
--- a/arch/arm/include/asm/module.h
+++ b/arch/arm/include/asm/module.h
@@ -1,13 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef _ASM_ARM_MODULE_H
#define _ASM_ARM_MODULE_H
-struct mod_arch_specific
-{
- int foo;
+#include <asm-generic/module.h>
+
+struct unwind_table;
+
+#ifdef CONFIG_ARM_UNWIND
+enum {
+ ARM_SEC_INIT,
+ ARM_SEC_DEVINIT,
+ ARM_SEC_CORE,
+ ARM_SEC_EXIT,
+ ARM_SEC_DEVEXIT,
+ ARM_SEC_HOT,
+ ARM_SEC_UNLIKELY,
+ ARM_SEC_MAX,
+};
+#endif
+
+struct mod_arch_specific {
+#ifdef CONFIG_ARM_UNWIND
+ struct unwind_table *unwind[ARM_SEC_MAX];
+#endif
+#ifdef CONFIG_ARM_MODULE_PLTS
+ struct elf32_shdr *plt;
+ int plt_count;
+#endif
};
-#define Elf_Shdr Elf32_Shdr
-#define Elf_Sym Elf32_Sym
-#define Elf_Ehdr Elf32_Ehdr
+struct module;
+u32 get_module_plt(struct module *mod, unsigned long loc, Elf32_Addr val);
#endif /* _ASM_ARM_MODULE_H */
diff --git a/arch/arm/include/asm/neon.h b/arch/arm/include/asm/neon.h
new file mode 100644
index 0000000000..476462e83e
--- /dev/null
+++ b/arch/arm/include/asm/neon.h
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ARM_ASM_NEON_H__
+#define __ARM_ASM_NEON_H__
+
+#define kernel_neon_begin() ((void)0)
+#define kernel_neon_end() ((void)0)
+
+#endif
diff --git a/arch/arm/include/asm/opcodes-sec.h b/arch/arm/include/asm/opcodes-sec.h
new file mode 100644
index 0000000000..b6f4b35024
--- /dev/null
+++ b/arch/arm/include/asm/opcodes-sec.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ *
+ * Copyright (C) 2012 ARM Limited
+ */
+
+#ifndef __ASM_ARM_OPCODES_SEC_H
+#define __ASM_ARM_OPCODES_SEC_H
+
+#include <asm/opcodes.h>
+
+#define __SMC(imm4) __inst_arm_thumb32( \
+ 0xE1600070 | (((imm4) & 0xF) << 0), \
+ 0xF7F08000 | (((imm4) & 0xF) << 16) \
+)
+
+#endif /* __ASM_ARM_OPCODES_SEC_H */
diff --git a/arch/arm/include/asm/opcodes-virt.h b/arch/arm/include/asm/opcodes-virt.h
index efcfdf92d9..3d98a0b566 100644
--- a/arch/arm/include/asm/opcodes-virt.h
+++ b/arch/arm/include/asm/opcodes-virt.h
@@ -1,21 +1,8 @@
-/*
- * opcodes-virt.h: Opcode definitions for the ARM virtualization extensions
- * Copyright (C) 2012 Linaro Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* SPDX-FileCopyrightText: 2012 Linaro Limited */
+
+/* opcodes-virt.h: Opcode definitions for the ARM virtualization extensions */
+
#ifndef __ASM_ARM_OPCODES_VIRT_H
#define __ASM_ARM_OPCODES_VIRT_H
diff --git a/arch/arm/include/asm/opcodes.h b/arch/arm/include/asm/opcodes.h
index a78bf5d2c5..64e171a818 100644
--- a/arch/arm/include/asm/opcodes.h
+++ b/arch/arm/include/asm/opcodes.h
@@ -1,10 +1,6 @@
-/*
- * arch/arm/include/asm/opcodes.h
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/* arch/arm/include/asm/opcodes.h */
#ifndef __ASM_ARM_OPCODES_H
#define __ASM_ARM_OPCODES_H
diff --git a/arch/arm/include/asm/optee.h b/arch/arm/include/asm/optee.h
new file mode 100644
index 0000000000..f8eb7b4a8b
--- /dev/null
+++ b/arch/arm/include/asm/optee.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ARM_OPTEE_H__
+#define __ARM_OPTEE_H__
+
+#include <linux/types.h>
+
+struct device_node;
+
+struct of_optee_fixup_data {
+ const char *method;
+ size_t shm_size;
+};
+
+int of_optee_fixup(struct device_node *root, void *fixup_data);
+
+#endif /* __ARM_OPTEE_H__ */
+
diff --git a/arch/arm/include/asm/pci.h b/arch/arm/include/asm/pci.h
new file mode 100644
index 0000000000..7c834f1101
--- /dev/null
+++ b/arch/arm/include/asm/pci.h
@@ -0,0 +1,9 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __ASM_PCI_H
+#define __ASM_PCI_H
+
+#include <efi/efi-mode.h>
+
+#define pcibios_assign_all_busses() (!efi_is_payload())
+
+#endif
diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
index fd1521d5cb..5d6a68c0a6 100644
--- a/arch/arm/include/asm/pgtable.h
+++ b/arch/arm/include/asm/pgtable.h
@@ -1,12 +1,8 @@
-/*
- * arch/arm/include/asm/pgtable-hwdef.h
- *
- * Copyright (C) 1995-2002 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 1995-2002 Russell King */
+
+/* arch/arm/include/asm/pgtable-hwdef.h */
+
#ifndef _ASMARM_PGTABLE_HWDEF_H
#define _ASMARM_PGTABLE_HWDEF_H
diff --git a/arch/arm/include/asm/pgtable64.h b/arch/arm/include/asm/pgtable64.h
index d8382505d0..b88ffe6be5 100644
--- a/arch/arm/include/asm/pgtable64.h
+++ b/arch/arm/include/asm/pgtable64.h
@@ -1,27 +1,14 @@
-/*
- * Copyright (C) 2012 ARM Ltd.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 2012 ARM Ltd. */
+
#ifndef __ASM_PGTABLE64_H
#define __ASM_PGTABLE64_H
-#define UL(x) _AC(x, UL)
-
#define UNUSED_DESC 0x6EbAAD0BBADbA6E0
#define VA_START 0x0
-#define BITS_PER_VA 39
+#define BITS_PER_VA 48
+#define BITS_PER_PA 40 // Use 40 Physical address bits
/* Granule size of 4KB is being used */
#define GRANULE_SIZE_SHIFT 12
@@ -30,11 +17,13 @@
#define GRANULE_SIZE_MASK ((1 << GRANULE_SIZE_SHIFT) - 1)
#define BITS_RESOLVED_PER_LVL (GRANULE_SIZE_SHIFT - 3)
+#define L0_ADDR_SHIFT (GRANULE_SIZE_SHIFT + BITS_RESOLVED_PER_LVL * 3)
#define L1_ADDR_SHIFT (GRANULE_SIZE_SHIFT + BITS_RESOLVED_PER_LVL * 2)
#define L2_ADDR_SHIFT (GRANULE_SIZE_SHIFT + BITS_RESOLVED_PER_LVL * 1)
#define L3_ADDR_SHIFT (GRANULE_SIZE_SHIFT + BITS_RESOLVED_PER_LVL * 0)
+#define L0_ADDR_MASK (((1UL << BITS_RESOLVED_PER_LVL) - 1) << L0_ADDR_SHIFT)
#define L1_ADDR_MASK (((1UL << BITS_RESOLVED_PER_LVL) - 1) << L1_ADDR_SHIFT)
#define L2_ADDR_MASK (((1UL << BITS_RESOLVED_PER_LVL) - 1) << L2_ADDR_SHIFT)
#define L3_ADDR_MASK (((1UL << BITS_RESOLVED_PER_LVL) - 1) << L3_ADDR_SHIFT)
@@ -44,6 +33,7 @@
#define L3_XLAT_SIZE (1UL << L3_ADDR_SHIFT)
#define L2_XLAT_SIZE (1UL << L2_ADDR_SHIFT)
#define L1_XLAT_SIZE (1UL << L1_ADDR_SHIFT)
+#define L0_XLAT_SIZE (1UL << L0_ADDR_SHIFT)
#define GRANULE_MASK GRANULE_SIZE
diff --git a/arch/arm/include/asm/posix_types.h b/arch/arm/include/asm/posix_types.h
index 22cae6230c..feaed42471 100644
--- a/arch/arm/include/asm/posix_types.h
+++ b/arch/arm/include/asm/posix_types.h
@@ -1 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#include <asm-generic/posix_types.h>
diff --git a/arch/arm/include/asm/proc-armv/system.h b/arch/arm/include/asm/proc-armv/system.h
index c61374e9f2..75ab503d9d 100644
--- a/arch/arm/include/asm/proc-armv/system.h
+++ b/arch/arm/include/asm/proc-armv/system.h
@@ -1,12 +1,8 @@
-/*
- * linux/include/asm-arm/proc-armv/system.h
- *
- * Copyright (C) 1996 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText 1996 Russell King */
+
+/* linux/include/asm-arm/proc-armv/system.h */
+
#ifndef __ASM_PROC_SYSTEM_H
#define __ASM_PROC_SYSTEM_H
diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h
deleted file mode 100644
index d5dbab0ac2..0000000000
--- a/arch/arm/include/asm/processor.h
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * linux/include/asm-arm/processor.h
- *
- * Copyright (C) 1995-2002 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#ifndef __ASM_ARM_PROCESSOR_H
-#define __ASM_ARM_PROCESSOR_H
-
-/*
- * Default implementation of macro that returns current
- * instruction pointer ("program counter").
- */
-#define current_text_addr() ({ __label__ _l; _l: &&_l;})
-
-#define FP_SIZE 35
-
-struct fp_hard_struct {
- unsigned int save[FP_SIZE]; /* as yet undefined */
-};
-
-struct fp_soft_struct {
- unsigned int save[FP_SIZE]; /* undefined information */
-};
-
-union fp_state {
- struct fp_hard_struct hard;
- struct fp_soft_struct soft;
-};
-
-typedef unsigned long mm_segment_t; /* domain register */
-
-#ifdef __KERNEL__
-
-#define EISA_bus 0
-#define MCA_bus 0
-#define MCA_bus__is_a_macro
-
-#include <asm/atomic.h>
-#include <asm/ptrace.h>
-#include <asm/proc/processor.h>
-#include <asm/types.h>
-
-union debug_insn {
- u32 arm;
- u16 thumb;
-};
-
-struct debug_entry {
- u32 address;
- union debug_insn insn;
-};
-
-struct debug_info {
- int nsaved;
- struct debug_entry bp[2];
-};
-
-struct thread_struct {
- atomic_t refcount;
- /* fault info */
- unsigned long address;
- unsigned long trap_no;
- unsigned long error_code;
- /* floating point */
- union fp_state fpstate;
- /* debugging */
- struct debug_info debug;
- /* context info */
- struct context_save_struct *save;
- EXTRA_THREAD_STRUCT
-};
-
-#define INIT_THREAD { \
- refcount: ATOMIC_INIT(1), \
- EXTRA_THREAD_STRUCT_INIT \
-}
-
-/*
- * Return saved PC of a blocked thread.
- */
-static inline unsigned long thread_saved_pc(struct thread_struct *t)
-{
- return t->save ? pc_pointer(t->save->pc) : 0;
-}
-
-static inline unsigned long thread_saved_fp(struct thread_struct *t)
-{
- return t->save ? t->save->fp : 0;
-}
-
-/* Forward declaration, a strange C thing */
-struct task_struct;
-
-/* Free all resources held by a thread. */
-extern void release_thread(struct task_struct *);
-
-/* Copy and release all segment info associated with a VM */
-#define copy_segments(tsk, mm) do { } while (0)
-#define release_segments(mm) do { } while (0)
-
-unsigned long get_wchan(struct task_struct *p);
-
-#define THREAD_SIZE (8192)
-
-extern struct task_struct *alloc_task_struct(void);
-extern void __free_task_struct(struct task_struct *);
-#define get_task_struct(p) atomic_inc(&(p)->thread.refcount)
-#define free_task_struct(p) \
- do { \
- if (atomic_dec_and_test(&(p)->thread.refcount)) \
- __free_task_struct((p)); \
- } while (0)
-
-#define init_task (init_task_union.task)
-#define init_stack (init_task_union.stack)
-
-#define cpu_relax() barrier()
-
-/*
- * Create a new kernel thread
- */
-extern int arch_kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
-
-#endif
-
-#endif /* __ASM_ARM_PROCESSOR_H */
diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
index b616e4b20e..b342eb85f5 100644
--- a/arch/arm/include/asm/psci.h
+++ b/arch/arm/include/asm/psci.h
@@ -1,23 +1,13 @@
-/*
- * Copyright (C) 2013 - ARM Ltd
- * Author: Marc Zyngier <marc.zyngier@arm.com>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 2013 ARM Ltd */
+
+/* Author: Marc Zyngier */
#ifndef __ARM_PSCI_H__
#define __ARM_PSCI_H__
+struct device_node;
+
#define ARM_PSCI_VER(major, minor) (((major) << 16) | (minor))
#define ARM_PSCI_VER_1_0 ARM_PSCI_VER(1,0)
#define ARM_PSCI_VER_0_2 ARM_PSCI_VER(0,2)
@@ -156,6 +146,7 @@ static inline int psci_printf(const char *fmt, ...)
int psci_get_cpu_id(void);
-int of_psci_fixup(struct device_node *root, unsigned long psci_version);
+int of_psci_fixup(struct device_node *root, unsigned long psci_version,
+ const char *method);
#endif /* __ARM_PSCI_H__ */
diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
index 042e0cef70..e0304501cc 100644
--- a/arch/arm/include/asm/ptrace.h
+++ b/arch/arm/include/asm/ptrace.h
@@ -1,12 +1,8 @@
-/*
- * arch/arm/include/asm/ptrace.h
- *
- * Copyright (C) 1996-2003 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 1996-2003 Russell King */
+
+/* arch/arm/include/asm/ptrace.h */
+
#ifndef __ASM_ARM_PTRACE_H
#define __ASM_ARM_PTRACE_H
diff --git a/arch/arm/include/asm/reloc.h b/arch/arm/include/asm/reloc.h
new file mode 100644
index 0000000000..95b4ef0af8
--- /dev/null
+++ b/arch/arm/include/asm/reloc.h
@@ -0,0 +1,42 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _ASM_RELOC_H_
+#define _ASM_RELOC_H_
+
+#include <asm/sections.h>
+
+unsigned long get_runtime_offset(void);
+
+/* global_variable_offset() - Access global variables when not running at link address
+ *
+ * Get the offset of global variables when not running at the address we are
+ * linked at.
+ */
+static inline __prereloc unsigned long global_variable_offset(void)
+{
+#ifdef CONFIG_CPU_V8
+ unsigned long text;
+
+ __asm__ __volatile__(
+ "adr %0, _text\n"
+ : "=r" (text)
+ :
+ : "memory");
+ return text - (unsigned long)_text;
+#else
+ return get_runtime_offset();
+#endif
+}
+#define global_variable_offset() global_variable_offset()
+
+void relocate_to_current_adr(void);
+void relocate_to_adr(unsigned long target);
+void relocate_to_adr_full(unsigned long target);
+
+void pbl_barebox_break(void);
+
+void setup_c(void);
+
+#include <asm-generic/reloc.h>
+
+#endif
diff --git a/arch/arm/include/asm/sections.h b/arch/arm/include/asm/sections.h
index 8ab01f2b71..15b1a6482a 100644
--- a/arch/arm/include/asm/sections.h
+++ b/arch/arm/include/asm/sections.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_SECTIONS_H
#define __ASM_SECTIONS_H
diff --git a/arch/arm/include/asm/secure.h b/arch/arm/include/asm/secure.h
index e0c2623723..fd10c47c6a 100644
--- a/arch/arm/include/asm/secure.h
+++ b/arch/arm/include/asm/secure.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_SECURE_H
#define __ASM_ARM_SECURE_H
diff --git a/arch/arm/include/asm/semihosting.h b/arch/arm/include/asm/semihosting.h
index b478dadb3a..9e1606c4ae 100644
--- a/arch/arm/include/asm/semihosting.h
+++ b/arch/arm/include/asm/semihosting.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_SEMIHOSTING_H
#define __ASM_ARM_SEMIHOSTING_H
diff --git a/arch/arm/include/asm/setjmp.h b/arch/arm/include/asm/setjmp.h
new file mode 100644
index 0000000000..0cee5bfdda
--- /dev/null
+++ b/arch/arm/include/asm/setjmp.h
@@ -0,0 +1,31 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * (C) Copyright 2017 Theobroma Systems Design und Consulting GmbH
+ * (C) Copyright 2016 Alexander Graf <agraf@suse.de>
+ */
+
+#ifndef _SETJMP_H_
+#define _SETJMP_H_ 1
+
+#include <asm/types.h>
+
+/*
+ * This really should be opaque, but the EFI implementation wrongly
+ * assumes that a 'struct jmp_buf_data' is defined.
+ */
+struct jmp_buf_data {
+#if defined(__aarch64__)
+ u64 regs[13];
+#else
+ u32 regs[10]; /* r4-r9, sl, fp, sp, lr */
+#endif
+};
+
+typedef struct jmp_buf_data jmp_buf[1];
+
+int setjmp(jmp_buf jmp) __attribute__((returns_twice));
+void longjmp(jmp_buf jmp, int ret) __attribute__((noreturn));
+
+int initjmp(jmp_buf jmp, void __attribute__((noreturn)) (*func)(void), void *stack_top);
+
+#endif /* _SETJMP_H_ */
diff --git a/arch/arm/include/asm/setup.h b/arch/arm/include/asm/setup.h
index 6ce35fb8d3..954b777721 100644
--- a/arch/arm/include/asm/setup.h
+++ b/arch/arm/include/asm/setup.h
@@ -1,10 +1,7 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 1997-1999 Russell King */
+
/*
- * Copyright (C) 1997-1999 Russell King
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
* Structure passed to kernel to tell it about the
* hardware it's running on. See linux/Documentation/arm/Setup
* for more info.
diff --git a/arch/arm/include/asm/stacktrace.h b/arch/arm/include/asm/stacktrace.h
index 602e79ced4..bbcd2a5f8e 100644
--- a/arch/arm/include/asm/stacktrace.h
+++ b/arch/arm/include/asm/stacktrace.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_STACKTRACE_H
#define __ASM_STACKTRACE_H
diff --git a/arch/arm/include/asm/string.h b/arch/arm/include/asm/string.h
index 435647abda..2322b846b2 100644
--- a/arch/arm/include/asm/string.h
+++ b/arch/arm/include/asm/string.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_STRING_H
#define __ASM_ARM_STRING_H
@@ -10,4 +12,7 @@ extern void *memset(void *, int, __kernel_size_t);
#endif
+extern void *__memcpy(void *, const void *, __kernel_size_t);
+extern void *__memset(void *, int, __kernel_size_t);
+
#endif
diff --git a/arch/arm/include/asm/swab.h b/arch/arm/include/asm/swab.h
index 3795437831..8dbde9b307 100644
--- a/arch/arm/include/asm/swab.h
+++ b/arch/arm/include/asm/swab.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
/*
* arch/arm/include/asm/byteorder.h
*
diff --git a/arch/arm/include/asm/syscounter.h b/arch/arm/include/asm/syscounter.h
index a644cfaad6..16d52269e3 100644
--- a/arch/arm/include/asm/syscounter.h
+++ b/arch/arm/include/asm/syscounter.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef _ASM_SYSCNT_H_
#define _ASM_SYSCNT_H_
@@ -21,4 +23,4 @@ static inline u32 syscnt_get_cntfrq(void __iomem *syscnt)
return readl(syscnt + SYSCNT_CNTFID(0));
}
-#endif \ No newline at end of file
+#endif
diff --git a/arch/arm/include/asm/sysreg.h b/arch/arm/include/asm/sysreg.h
new file mode 100644
index 0000000000..7d567e08d8
--- /dev/null
+++ b/arch/arm/include/asm/sysreg.h
@@ -0,0 +1,76 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Macros for accessing system registers with older binutils.
+ *
+ * Copyright (C) 2014 ARM Ltd.
+ * Author: Catalin Marinas <catalin.marinas@arm.com>
+ */
+
+#ifndef __ASM_SYSREG_H
+#define __ASM_SYSREG_H
+
+#include <asm/system.h>
+#include <linux/stringify.h>
+
+/*
+ * Unlike read_cpuid, calls to read_sysreg are never expected to be
+ * optimized away or replaced with synthetic values.
+ */
+#define read_sysreg(r) ({ \
+ u64 __val; \
+ asm volatile("mrs %0, " __stringify(r) : "=r" (__val)); \
+ __val; \
+})
+
+/*
+ * The "Z" constraint normally means a zero immediate, but when combined with
+ * the "%x0" template means XZR.
+ */
+#define write_sysreg(v, r) do { \
+ u64 __val = (u64)(v); \
+ asm volatile("msr " __stringify(r) ", %x0" \
+ : : "rZ" (__val)); \
+} while (0)
+
+/*
+ * For registers without architectural names, or simply unsupported by
+ * GAS.
+ */
+#define read_sysreg_s(r) ({ \
+ u64 __val; \
+ asm volatile(__mrs_s("%0", r) : "=r" (__val)); \
+ __val; \
+})
+
+#define write_sysreg_s(v, r) do { \
+ u64 __val = (u64)(v); \
+ asm volatile(__msr_s(r, "%x0") : : "rZ" (__val)); \
+} while (0)
+
+/*
+ * Modify bits in a sysreg. Bits in the clear mask are zeroed, then bits in the
+ * set mask are set. Other bits are left as-is.
+ */
+#define sysreg_clear_set(sysreg, clear, set) do { \
+ u64 __scs_val = read_sysreg(sysreg); \
+ u64 __scs_new = (__scs_val & ~(u64)(clear)) | (set); \
+ if (__scs_new != __scs_val) \
+ write_sysreg(__scs_new, sysreg); \
+} while (0)
+
+#define sysreg_clear_set_s(sysreg, clear, set) do { \
+ u64 __scs_val = read_sysreg_s(sysreg); \
+ u64 __scs_new = (__scs_val & ~(u64)(clear)) | (set); \
+ if (__scs_new != __scs_val) \
+ write_sysreg_s(__scs_new, sysreg); \
+} while (0)
+
+#define read_sysreg_par() ({ \
+ u64 par; \
+ asm("dmb sy"); \
+ par = read_sysreg(par_el1); \
+ asm("dmb sy"); \
+ par; \
+})
+
+#endif /* __ASM_SYSREG_H */
diff --git a/arch/arm/include/asm/system.h b/arch/arm/include/asm/system.h
index a0180f2df8..bf3b7b02e2 100644
--- a/arch/arm/include/asm/system.h
+++ b/arch/arm/include/asm/system.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_SYSTEM_H
#define __ASM_ARM_SYSTEM_H
@@ -23,12 +25,8 @@
#if __LINUX_ARM_ARCH__ >= 7
#define isb() __asm__ __volatile__ ("isb" : : : "memory")
-#ifdef CONFIG_CPU_64v8
#define dsb() __asm__ __volatile__ ("dsb sy" : : : "memory")
-#else
-#define dsb() __asm__ __volatile__ ("dsb" : : : "memory")
-#endif
-#define dmb() __asm__ __volatile__ ("dmb" : : : "memory")
+#define dmb() __asm__ __volatile__ ("dmb sy" : : : "memory")
#elif defined(CONFIG_CPU_XSC3) || __LINUX_ARM_ARCH__ == 6
#define isb() __asm__ __volatile__ ("mcr p15, 0, %0, c7, c5, 4" \
: : "r" (0) : "memory")
diff --git a/arch/arm/include/asm/system_info.h b/arch/arm/include/asm/system_info.h
index a27b79e6dd..5a84fde75b 100644
--- a/arch/arm/include/asm/system_info.h
+++ b/arch/arm/include/asm/system_info.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_SYSTEM_INFO_H
#define __ASM_ARM_SYSTEM_INFO_H
@@ -42,11 +44,11 @@
#define CPU_IS_CORTEX_A15 0x410fc0f0
#define CPU_IS_CORTEX_A15_MASK 0xff0ffff0
-#define CPU_IS_CORTEX_A53 0x410fd034
+#define CPU_IS_CORTEX_A53 0x410fd030
#define CPU_IS_CORTEX_A53_MASK 0xff0ffff0
-#define CPU_IS_CORTEX_A57 0x411fd070
-#define CPU_IS_CORTEX_A57_MASK 0xff0ffff0
+#define CPU_IS_CORTEX_A72 0x410fd080
+#define CPU_IS_CORTEX_A72_MASK 0xff0ffff0
#define CPU_IS_PXA250 0x69052100
#define CPU_IS_PXA250_MASK 0xfffff7f0
@@ -125,11 +127,6 @@
#else
#define ARM_ARCH CPU_ARCH_ARMv8
#endif
-#define cpu_is_cortex_a53() cpu_is_arm(CORTEX_A53)
-#define cpu_is_cortex_a57() cpu_is_arm(CORTEX_A57)
-#else
-#define cpu_is_cortex_a53() (0)
-#define cpu_is_cortex_a57() (0)
#endif
#ifndef __ASSEMBLY__
diff --git a/arch/arm/include/asm/types.h b/arch/arm/include/asm/types.h
index 9c21066882..4adc815bf3 100644
--- a/arch/arm/include/asm/types.h
+++ b/arch/arm/include/asm/types.h
@@ -1,52 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef __ASM_ARM_TYPES_H
#define __ASM_ARM_TYPES_H
-#ifndef __ASSEMBLY__
-
-/*
- * __xx is ok: it doesn't pollute the POSIX namespace. Use these in the
- * header files exported to user space
- */
-
-typedef __signed__ char __s8;
-typedef unsigned char __u8;
-
-typedef __signed__ short __s16;
-typedef unsigned short __u16;
-
-typedef __signed__ int __s32;
-typedef unsigned int __u32;
-
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-typedef __signed__ long long __s64;
-typedef unsigned long long __u64;
-#endif
-
-#endif /* __ASSEMBLY__ */
-
-/*
- * These aren't exported outside the kernel to avoid name space clashes
- */
-#ifdef __KERNEL__
-
-#include <asm/bitsperlong.h>
-
-#ifndef __ASSEMBLY__
-
-typedef signed char s8;
-typedef unsigned char u8;
-
-typedef signed short s16;
-typedef unsigned short u16;
-
-typedef signed int s32;
-typedef unsigned int u32;
-
-typedef signed long long s64;
-typedef unsigned long long u64;
-
-#endif /* __ASSEMBLY__ */
-
-#endif /* __KERNEL__ */
+#include <asm-generic/int-ll64.h>
#endif
diff --git a/arch/arm/include/asm/unaligned.h b/arch/arm/include/asm/unaligned.h
index 44593a8949..b63d39da7f 100644
--- a/arch/arm/include/asm/unaligned.h
+++ b/arch/arm/include/asm/unaligned.h
@@ -1,3 +1,5 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
#ifndef _ASM_ARM_UNALIGNED_H
#define _ASM_ARM_UNALIGNED_H
diff --git a/arch/arm/include/asm/unified.h b/arch/arm/include/asm/unified.h
index 13a2bfffa7..5501d7f703 100644
--- a/arch/arm/include/asm/unified.h
+++ b/arch/arm/include/asm/unified.h
@@ -1,18 +1,7 @@
-/*
- * include/asm-arm/unified.h - Unified Assembler Syntax helper macros
- *
- * Copyright (C) 2008 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 2008 ARM Limited */
+
+/* Unified Assembler Syntax helper macros */
#ifndef __ASM_UNIFIED_H
#define __ASM_UNIFIED_H
diff --git a/arch/arm/include/asm/unwind.h b/arch/arm/include/asm/unwind.h
index a6f3a91743..37aba2aa4c 100644
--- a/arch/arm/include/asm/unwind.h
+++ b/arch/arm/include/asm/unwind.h
@@ -1,18 +1,7 @@
-/*
- * arch/arm/include/asm/unwind.h
- *
- * Copyright (C) 2008 ARM Limited
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- */
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* SPDX-FileCopyrightText: 2008 ARM Limited */
+
+/* arch/arm/include/asm/unwind.h */
#ifndef __ASM_UNWIND_H
#define __ASM_UNWIND_H
@@ -27,14 +16,15 @@ enum unwind_reason_code {
};
struct unwind_idx {
- unsigned long addr;
+ unsigned long addr_offset;
unsigned long insn;
};
struct unwind_table {
struct list_head list;
- struct unwind_idx *start;
- struct unwind_idx *stop;
+ const struct unwind_idx *start;
+ const struct unwind_idx *origin;
+ const struct unwind_idx *stop;
unsigned long begin_addr;
unsigned long end_addr;
};
diff --git a/arch/arm/include/asm/word-at-a-time.h b/arch/arm/include/asm/word-at-a-time.h
new file mode 100644
index 0000000000..a2b20be13d
--- /dev/null
+++ b/arch/arm/include/asm/word-at-a-time.h
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Copyright (C) 2013 ARM Ltd.
+ */
+#ifndef __ASM_WORD_AT_A_TIME_H
+#define __ASM_WORD_AT_A_TIME_H
+
+#if !defined(__AARCH64EB__) && !defined(__ARMEB__)
+
+#include <linux/kernel.h>
+#include <linux/bitops.h>
+
+struct word_at_a_time {
+ const unsigned long one_bits, high_bits;
+};
+
+#define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
+
+static inline unsigned long has_zero(unsigned long a, unsigned long *bits,
+ const struct word_at_a_time *c)
+{
+ unsigned long mask = ((a - c->one_bits) & ~a) & c->high_bits;
+ *bits = mask;
+ return mask;
+}
+
+#define prep_zero_mask(a, bits, c) (bits)
+
+static inline unsigned long create_zero_mask(unsigned long bits)
+{
+ bits = (bits - 1) & ~bits;
+ return bits >> 7;
+}
+
+static inline unsigned long find_zero(unsigned long mask)
+{
+ unsigned long ret;
+
+#if __LINUX_ARM_ARCH__ >= 8
+ ret = fls64(mask) >> 3;
+#elif __LINUX_ARM_ARCH__ >= 5
+ /* We have clz available. */
+ ret = fls(mask) >> 3;
+#else
+ /* (000000 0000ff 00ffff ffffff) -> ( 1 1 2 3 ) */
+ ret = (0x0ff0001 + mask) >> 23;
+ /* Fix the 1 for 00 case */
+ ret &= mask;
+#endif
+
+ return ret;
+}
+
+#define zero_bytemask(mask) (mask)
+
+#else /* __AARCH64EB__ || __ARMEB__ */
+#include <asm-generic/word-at-a-time.h>
+#endif
+
+#endif /* __ASM_WORD_AT_A_TIME_H */