From 8b609af14c7be5388faf5d7a66914946471534e5 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 12 Oct 2012 15:33:06 +0200 Subject: ARM: introduce arm_setup_stack function and use it We have enough places which setup0 a stack to justify a static inline function for it. Signed-off-by: Sascha Hauer --- arch/arm/boards/eukrea_cpuimx25/lowlevel.c | 3 +-- arch/arm/boards/eukrea_cpuimx35/lowlevel.c | 3 +-- arch/arm/boards/guf-cupid/lowlevel.c | 6 ++---- arch/arm/boards/guf-neso/lowlevel.c | 5 +---- arch/arm/boards/karo-tx25/lowlevel.c | 3 +-- arch/arm/boards/panda/lowlevel.c | 6 +----- arch/arm/boards/pcm038/lowlevel.c | 5 +---- arch/arm/boards/pcm043/lowlevel.c | 3 +-- arch/arm/boards/pcm049/lowlevel.c | 6 +----- arch/arm/boards/phycard-a-xl2/lowlevel.c | 5 +---- arch/arm/cpu/start-pbl.c | 3 +-- arch/arm/cpu/start.c | 4 +--- arch/arm/include/asm/common.h | 5 +++++ 13 files changed, 18 insertions(+), 39 deletions(-) diff --git a/arch/arm/boards/eukrea_cpuimx25/lowlevel.c b/arch/arm/boards/eukrea_cpuimx25/lowlevel.c index cd80b251be..8d6cd1f982 100644 --- a/arch/arm/boards/eukrea_cpuimx25/lowlevel.c +++ b/arch/arm/boards/eukrea_cpuimx25/lowlevel.c @@ -36,8 +36,7 @@ static void __bare_init __naked insdram(void) uint32_t r; /* setup a stack to be able to call imx_nand_load_image() */ - r = STACK_BASE + STACK_SIZE - 12; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(STACK_BASE + STACK_SIZE - 12); imx_nand_load_image(_text, barebox_image_size); diff --git a/arch/arm/boards/eukrea_cpuimx35/lowlevel.c b/arch/arm/boards/eukrea_cpuimx35/lowlevel.c index ea932f773e..8689f9ee30 100644 --- a/arch/arm/boards/eukrea_cpuimx35/lowlevel.c +++ b/arch/arm/boards/eukrea_cpuimx35/lowlevel.c @@ -47,8 +47,7 @@ static void __bare_init __naked insdram(void) writel(r, MX35_CCM_BASE_ADDR + CCM_PDR4); /* setup a stack to be able to call imx_nand_load_image() */ - r = STACK_BASE + STACK_SIZE - 12; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(STACK_BASE + STACK_SIZE - 12); imx_nand_load_image(_text, barebox_image_size); diff --git a/arch/arm/boards/guf-cupid/lowlevel.c b/arch/arm/boards/guf-cupid/lowlevel.c index d451fd9393..a1b58cc3c8 100644 --- a/arch/arm/boards/guf-cupid/lowlevel.c +++ b/arch/arm/boards/guf-cupid/lowlevel.c @@ -54,8 +54,7 @@ static void __bare_init __naked insdram(void) writel(r, MX35_CCM_BASE_ADDR + CCM_PDR4); /* setup a stack to be able to call imx_nand_load_image() */ - r = STACK_BASE + STACK_SIZE - 12; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(STACK_BASE + STACK_SIZE - 12); imx_nand_load_image(_text, barebox_image_size); @@ -190,8 +189,7 @@ void __bare_init __naked reset(void) common_reset(); - r0 = 0x10000000 + 128 * 1024 - 16; - __asm__ __volatile__("mov sp, %0" : : "r"(r0)); + arm_setup_stack(0x10000000 + 128 * 1024 - 16); /* * ARM1136 init diff --git a/arch/arm/boards/guf-neso/lowlevel.c b/arch/arm/boards/guf-neso/lowlevel.c index 52fe6cffa8..d45a5b492a 100644 --- a/arch/arm/boards/guf-neso/lowlevel.c +++ b/arch/arm/boards/guf-neso/lowlevel.c @@ -33,13 +33,10 @@ #ifdef CONFIG_NAND_IMX_BOOT static void __bare_init __naked insdram(void) { - uint32_t r; - PCCR1 |= PCCR1_NFC_BAUDEN; /* setup a stack to be able to call imx_nand_load_image() */ - r = STACK_BASE + STACK_SIZE - 12; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(STACK_BASE + STACK_SIZE - 12); imx_nand_load_image(_text, barebox_image_size); diff --git a/arch/arm/boards/karo-tx25/lowlevel.c b/arch/arm/boards/karo-tx25/lowlevel.c index 3192abdeb6..2d09fd70d1 100644 --- a/arch/arm/boards/karo-tx25/lowlevel.c +++ b/arch/arm/boards/karo-tx25/lowlevel.c @@ -34,8 +34,7 @@ static void __bare_init __naked insdram(void) uint32_t r; /* setup a stack to be able to call imx_nand_load_image() */ - r = STACK_BASE + STACK_SIZE - 12; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(STACK_BASE + STACK_SIZE - 12); imx_nand_load_image(_text, barebox_image_size); diff --git a/arch/arm/boards/panda/lowlevel.c b/arch/arm/boards/panda/lowlevel.c index 33d06be29a..36e2bc5886 100644 --- a/arch/arm/boards/panda/lowlevel.c +++ b/arch/arm/boards/panda/lowlevel.c @@ -76,16 +76,12 @@ static void noinline panda_init_lowlevel(void) void reset(void) { - u32 r; - common_reset(); if (get_pc() > 0x80000000) board_init_lowlevel_return(); - r = 0x4030d000; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(0x4030d000); panda_init_lowlevel(); } - diff --git a/arch/arm/boards/pcm038/lowlevel.c b/arch/arm/boards/pcm038/lowlevel.c index 7ecff3afa8..de86a06dfa 100644 --- a/arch/arm/boards/pcm038/lowlevel.c +++ b/arch/arm/boards/pcm038/lowlevel.c @@ -34,13 +34,10 @@ #ifdef CONFIG_NAND_IMX_BOOT static void __bare_init __naked insdram(void) { - uint32_t r; - PCCR1 |= PCCR1_NFC_BAUDEN; /* setup a stack to be able to call imx_nand_load_image() */ - r = STACK_BASE + STACK_SIZE - 12; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(STACK_BASE + STACK_SIZE - 12); imx_nand_load_image(_text, barebox_image_size); diff --git a/arch/arm/boards/pcm043/lowlevel.c b/arch/arm/boards/pcm043/lowlevel.c index 4516e9f017..6bd6508862 100644 --- a/arch/arm/boards/pcm043/lowlevel.c +++ b/arch/arm/boards/pcm043/lowlevel.c @@ -52,8 +52,7 @@ static void __bare_init __naked insdram(void) writel(r, MX35_CCM_BASE_ADDR + CCM_PDR4); /* setup a stack to be able to call imx_nand_load_image() */ - r = STACK_BASE + STACK_SIZE - 12; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(STACK_BASE + STACK_SIZE - 12); imx_nand_load_image(_text, barebox_image_size); diff --git a/arch/arm/boards/pcm049/lowlevel.c b/arch/arm/boards/pcm049/lowlevel.c index c3fc6c7e1f..b64244ca79 100644 --- a/arch/arm/boards/pcm049/lowlevel.c +++ b/arch/arm/boards/pcm049/lowlevel.c @@ -86,16 +86,12 @@ static void noinline pcm049_init_lowlevel(void) void reset(void) { - u32 r; - common_reset(); if (get_pc() > 0x80000000) board_init_lowlevel_return(); - r = 0x4030d000; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(0x4030d000); pcm049_init_lowlevel(); } - diff --git a/arch/arm/boards/phycard-a-xl2/lowlevel.c b/arch/arm/boards/phycard-a-xl2/lowlevel.c index 24b4ab8ea5..5d8693abdd 100644 --- a/arch/arm/boards/phycard-a-xl2/lowlevel.c +++ b/arch/arm/boards/phycard-a-xl2/lowlevel.c @@ -86,15 +86,12 @@ static noinline void pcaaxl2_init_lowlevel(void) void reset(void) { - u32 r; - common_reset(); if (get_pc() > 0x80000000) board_init_lowlevel_return(); - r = 0x4030d000; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(0x4030d000); pcaaxl2_init_lowlevel(); } diff --git a/arch/arm/cpu/start-pbl.c b/arch/arm/cpu/start-pbl.c index 0467dfe832..929cc26055 100644 --- a/arch/arm/cpu/start-pbl.c +++ b/arch/arm/cpu/start-pbl.c @@ -178,8 +178,7 @@ void __naked board_init_lowlevel_return(void) uint32_t pg_start, pg_end, pg_len; /* Setup the stack */ - r = STACK_BASE + STACK_SIZE - 16; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(STACK_BASE + STACK_SIZE - 16); /* Get offset between linked address and runtime address */ offset = get_runtime_offset(); diff --git a/arch/arm/cpu/start.c b/arch/arm/cpu/start.c index 867626758d..af83899ce8 100644 --- a/arch/arm/cpu/start.c +++ b/arch/arm/cpu/start.c @@ -72,9 +72,7 @@ void __naked board_init_lowlevel_return(void) { uint32_t r, offset; - /* Setup the stack */ - r = STACK_BASE + STACK_SIZE - 16; - __asm__ __volatile__("mov sp, %0" : : "r"(r)); + arm_setup_stack(STACK_BASE + STACK_SIZE - 16); /* Get offset between linked address and runtime address */ offset = get_runtime_offset(); diff --git a/arch/arm/include/asm/common.h b/arch/arm/include/asm/common.h index f3a87c81c9..133bb8e1f6 100644 --- a/arch/arm/include/asm/common.h +++ b/arch/arm/include/asm/common.h @@ -16,4 +16,9 @@ static inline unsigned long get_pc(void) return pc; } +static inline void arm_setup_stack(unsigned long top) +{ + __asm__ __volatile__("mov sp, %0" : : "r"(top)); +} + #endif /* __ASM_ARM_COMMON_H */ -- cgit v1.2.3