sh: add shared relocate_code() function and call board_init_r()
authorVladimir Zapolskiy <vz@mleia.com>
Sun, 27 Nov 2016 22:15:32 +0000 (00:15 +0200)
committerTom Rini <trini@konsulko.com>
Sat, 3 Dec 2016 02:32:52 +0000 (21:32 -0500)
Commits b61e90e6fd83 ("sh: Drop the arch-specific board init") and
f41e6088eb1a ("sh: Fix build errors for generic board") left code and
data relocation done in start.S, however further actual U-boot
configuration is not started anymore. Practically SH boards with the
code relocated into the expected position by start.S still can be
booted, so the change adds this option and provides an option how to
relocate code for board_init_r() execution.

Signed-off-by: Vladimir Zapolskiy <vz@mleia.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
arch/sh/cpu/sh2/cpu.c
arch/sh/cpu/sh3/cpu.c
arch/sh/cpu/sh4/cpu.c
arch/sh/lib/board.c

index 9a93cf573fe8203c9b5fec230c1c8b8bd5f36175..a2f856f4594510f5aaeaa366894f03c1de2249a8 100644 (file)
@@ -83,9 +83,3 @@ int dcache_status(void)
 {
        return 0;
 }
-
-void relocate_code(ulong start_addr_sp, gd_t *new_gd, ulong relocaaddr)
-{
-       /* TODO(sh maintainer): Implement this */
-       while (1);
-}
index 494f908f64e158d9721b6ad68384a387820f2d7d..ea0006a6505247365e73c0b65a597b709b72bdd8 100644 (file)
@@ -66,9 +66,3 @@ int dcache_status(void)
 {
        return 0;
 }
-
-void relocate_code(ulong start_addr_sp, gd_t *new_gd, ulong relocaaddr)
-{
-       /* TODO(sh maintainer): Implement this */
-       while (1);
-}
index 49c58aeb20954920e05592268edf45e539c9b253..aa8d4dfcd1c259224e54d0142c267d8f78b564d4 100644 (file)
@@ -41,9 +41,3 @@ int cpu_eth_init(bd_t *bis)
 #endif
        return 0;
 }
-
-void relocate_code(ulong start_addr_sp, gd_t *new_gd, ulong relocaaddr)
-{
-       /* TODO(sh maintainer): Implement this */
-       while (1);
-}
index 7cb594e31a3e47de446a1a1bf770e755486a9db9..aa967c04e7aa4cfc6af1430eb3142703c71fb5fa 100644 (file)
@@ -15,3 +15,21 @@ int dram_init(void)
 
        return 0;
 }
+
+void relocate_code(ulong start_addr_sp, gd_t *new_gd, ulong relocaddr)
+{
+       void (*reloc_board_init_r)(gd_t *gd, ulong dest) = board_init_r;
+
+       if (new_gd->reloc_off) {
+               memcpy((void *)new_gd->relocaddr,
+                      (void *)(new_gd->relocaddr - new_gd->reloc_off),
+                      new_gd->mon_len);
+
+               reloc_board_init_r += new_gd->reloc_off;
+       }
+
+       __asm__ __volatile__("mov.l %0, r15\n" : : "m" (new_gd->start_addr_sp));
+
+       while (1)
+               reloc_board_init_r(new_gd, 0x0);
+}