]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
ARM: mxs: Receive r0 and r1 passed from BootROM
authorMarek Vasut <marex@denx.de>
Sat, 31 Aug 2013 13:53:44 +0000 (15:53 +0200)
committerStefano Babic <sbabic@denx.de>
Tue, 10 Sep 2013 17:12:54 +0000 (19:12 +0200)
Make sure value in register r0 and r1 is preserved and passed to
the board_init_ll() and mxs_common_spl_init() where it can be
processed further. The value in r0 can be configured during the
BootStream generation to arbitary value, r1 contains pointer to
return value from CALL'd function.

This patch also clears the value in r0 before returning to BootROM
to make sure the BootROM is not confused by this value.

Finally, this patch cleans up some comments in the start.S file.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Stefano Babic <sbabic@denx.de>
arch/arm/cpu/arm926ejs/mxs/spl_boot.c
arch/arm/cpu/arm926ejs/mxs/start.S
arch/arm/include/asm/arch-mxs/sys_proto.h
board/bluegiga/apx4devkit/spl_boot.c
board/denx/m28evk/spl_boot.c
board/freescale/mx23evk/spl_boot.c
board/freescale/mx28evk/iomux.c
board/olimex/mx23_olinuxino/spl_boot.c
board/schulercontrol/sc_sps_1/spl_boot.c

index 0392afd9be4b024083be19f7e359dc7f0d4d9957..68c30afc48be85f46cf8e3d4ae0ed8e3372c4212 100644 (file)
@@ -102,8 +102,9 @@ static uint8_t mxs_get_bootmode_index(void)
        return i;
 }
 
-void mxs_common_spl_init(const iomux_cfg_t *iomux_setup,
-                       const unsigned int iomux_size)
+void mxs_common_spl_init(const uint32_t arg, const uint32_t *resptr,
+                        const iomux_cfg_t *iomux_setup,
+                        const unsigned int iomux_size)
 {
        struct mxs_spl_data *data = (struct mxs_spl_data *)
                ((CONFIG_SYS_TEXT_BASE - sizeof(struct mxs_spl_data)) & ~0xf);
index 94b2b3fd30ef1da148fbe9e3a8b1e0f4ec07bf44..3e454ae1bca419c7d3fd1f8517a687a22e1766dd 100644 (file)
@@ -152,39 +152,49 @@ _reset:
        /*
         * Store all registers on old stack pointer, this will allow us later to
         * return to the BootROM and let the BootROM load U-Boot into RAM.
+        *
+        * WARNING: Register r0 and r1 are used by the BootROM to pass data
+        *          to the called code. Register r0 will contain arbitrary
+        *          data that are set in the BootStream. In case this code
+        *          was started with CALL instruction, register r1 will contain
+        *          pointer to the return value this function can then set.
+        *          The code below MUST NOT CHANGE register r0 and r1 !
         */
        push    {r0-r12,r14}
 
-       /* save control register c1 */
-       mrc     p15, 0, r0, c1, c0, 0
-       push    {r0}
+       /* Save control register c1 */
+       mrc     p15, 0, r2, c1, c0, 0
+       push    {r2}
 
-       /*
-        * set the cpu to SVC32 mode and store old CPSR register content
-        */
-       mrs     r0,cpsr
-       push    {r0}
-       bic     r0,r0,#0x1f
-       orr     r0,r0,#0xd3
-       msr     cpsr,r0
+       /* Set the cpu to SVC32 mode and store old CPSR register content. */
+       mrs     r2, cpsr
+       push    {r2}
+       bic     r2, r2, #0x1f
+       orr     r2, r2, #0xd3
+       msr     cpsr, r2
 
        bl      board_init_ll
 
+       /* Restore BootROM's CPU mode (especially FIQ). */
+       pop     {r2}
+       msr     cpsr,r2
+
        /*
-        * restore bootrom's cpu mode (especially FIQ)
+        * Restore c1 register. Especially set exception vector location
+        * back to BootROM space which is required by bootrom for USB boot.
         */
-       pop     {r0}
-       msr     cpsr,r0
+       pop     {r2}
+       mcr     p15, 0, r2, c1, c0, 0
+
+       pop     {r0-r12,r14}
 
        /*
-        * restore c1 register
-        * (especially set exception vector location back to
-        * bootrom space which is required by bootrom for USB boot)
+        * In case this code was started by the CALL instruction, the register
+        * r0 is examined by the BootROM after this code returns. The value in
+        * r0 must be set to 0 to indicate successful return.
         */
-       pop     {r0}
-       mcr     p15, 0, r0, c1, c0, 0
+       mov r0, #0
 
-       pop     {r0-r12,r14}
        bx      lr
 
 _hang:
index 1038592c927a4a364e8409f1a34a9b47b67307ae..43c7dd6bf10e7c274c3272cbae112daf47b45bef 100644 (file)
@@ -28,8 +28,9 @@ int mxsmmc_initialize(bd_t *bis, int id, int (*wp)(int), int (*cd)(int));
 #include <asm/arch/iomux-mx28.h>
 #endif
 
-void mxs_common_spl_init(const iomux_cfg_t *iomux_setup,
-                       const unsigned int iomux_size);
+void mxs_common_spl_init(const uint32_t arg, const uint32_t *resptr,
+                        const iomux_cfg_t *iomux_setup,
+                        const unsigned int iomux_size);
 #endif
 
 struct mxs_pair {
index 3b05baaa708aa1a24e06d6a9e769dfb21d4fe8eb..81419f963599eadb1a6aabc2cb97261ebc915595 100644 (file)
@@ -132,9 +132,9 @@ const iomux_cfg_t iomux_setup[] = {
        MX28_PAD_EMI_CKE__EMI_CKE | MUX_CONFIG_EMI,
 };
 
-void board_init_ll(void)
+void board_init_ll(const uint32_t arg, const uint32_t *resptr)
 {
-       mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
+       mxs_common_spl_init(arg, resptr, iomux_setup, ARRAY_SIZE(iomux_setup));
 
        /* switch LED on */
        gpio_direction_output(MX28_PAD_PWM3__GPIO_3_28, 0);
index 525ba6ae7539c0906d9f9e65450d2c19e1f9c41c..5a1010e59550a4c65d9e2fc2ad3922ae0e5f9660 100644 (file)
@@ -200,7 +200,7 @@ const iomux_cfg_t iomux_setup[] = {
                (MXS_PAD_3V3 | MXS_PAD_8MA | MXS_PAD_PULLUP),
 };
 
-void board_init_ll(void)
+void board_init_ll(const uint32_t arg, const uint32_t *resptr)
 {
-       mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
+       mxs_common_spl_init(arg, resptr, iomux_setup, ARRAY_SIZE(iomux_setup));
 }
index 054ca0a93b0e175fe9814b96134e76009da88d18..603f4dcfd1df034266cf9cbfbeb55f22d3af3d88 100644 (file)
@@ -129,7 +129,7 @@ void mxs_adjust_memory_params(uint32_t *dram_vals)
        dram_vals[HW_DRAM_CTL14] = HW_DRAM_CTL14_CONFIG;
 }
 
-void board_init_ll(void)
+void board_init_ll(const uint32_t arg, const uint32_t *resptr)
 {
-       mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
+       mxs_common_spl_init(arg, resptr, iomux_setup, ARRAY_SIZE(iomux_setup));
 }
index 6ca842ba863a5cb3a4bdaf0a0a85e2c06d7d41d0..97c2376da1bff72e25b8de3fa4b1ef2bc21dcf97 100644 (file)
@@ -200,7 +200,7 @@ void mxs_adjust_memory_params(uint32_t *dram_vals)
        dram_vals[HW_DRAM_CTL29] = HW_DRAM_CTL29_CONFIG;
 }
 
-void board_init_ll(void)
+void board_init_ll(const uint32_t arg, const uint32_t *resptr)
 {
-       mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
+       mxs_common_spl_init(arg, resptr, iomux_setup, ARRAY_SIZE(iomux_setup));
 }
index 0a6630395da981f965de9274d955903b4df5a2b3..5272dfa4e676dbb5e2296f45df6494458083929d 100644 (file)
@@ -85,7 +85,7 @@ const iomux_cfg_t iomux_setup[] = {
                (MXS_PAD_3V3 | MXS_PAD_12MA | MXS_PAD_NOPULL),
 };
 
-void board_init_ll(void)
+void board_init_ll(const uint32_t arg, const uint32_t *resptr)
 {
-       mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
+       mxs_common_spl_init(arg, resptr, iomux_setup, ARRAY_SIZE(iomux_setup));
 }
index 1fe9224e5a1c5d9b6d24198bedfb73f1abb9c12b..60195c3a7d1dee237604a06198b12b62508b8016 100644 (file)
@@ -138,9 +138,9 @@ const iomux_cfg_t iomux_setup[] = {
        MX28_PAD_GPMI_D06__GPIO_0_6 | MUX_CONFIG_LED,
 };
 
-void board_init_ll(void)
+void board_init_ll(const uint32_t arg, const uint32_t *resptr)
 {
-       mxs_common_spl_init(iomux_setup, ARRAY_SIZE(iomux_setup));
+       mxs_common_spl_init(arg, resptr, iomux_setup, ARRAY_SIZE(iomux_setup));
 }
 
 void mxs_adjust_memory_params(uint32_t *dram_vals)