summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-10-12 15:33:06 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-10-13 14:17:31 +0200
commit8b609af14c7be5388faf5d7a66914946471534e5 (patch)
tree63ac04be3230cc46df9628cc1c1bacfc9548dc54
parent1dbfd5ed82fd2b6b0ba6df98e2e23aaf3cd1a197 (diff)
downloadbarebox-8b609af14c7be5388faf5d7a66914946471534e5.tar.gz
barebox-8b609af14c7be5388faf5d7a66914946471534e5.tar.xz
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 <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/boards/eukrea_cpuimx25/lowlevel.c3
-rw-r--r--arch/arm/boards/eukrea_cpuimx35/lowlevel.c3
-rw-r--r--arch/arm/boards/guf-cupid/lowlevel.c6
-rw-r--r--arch/arm/boards/guf-neso/lowlevel.c5
-rw-r--r--arch/arm/boards/karo-tx25/lowlevel.c3
-rw-r--r--arch/arm/boards/panda/lowlevel.c6
-rw-r--r--arch/arm/boards/pcm038/lowlevel.c5
-rw-r--r--arch/arm/boards/pcm043/lowlevel.c3
-rw-r--r--arch/arm/boards/pcm049/lowlevel.c6
-rw-r--r--arch/arm/boards/phycard-a-xl2/lowlevel.c5
-rw-r--r--arch/arm/cpu/start-pbl.c3
-rw-r--r--arch/arm/cpu/start.c4
-rw-r--r--arch/arm/include/asm/common.h5
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 */