Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2008 Semihalf |
| 3 | * |
| 4 | * (C) Copyright 2000-2006 |
| 5 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 6 | * |
| 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 23 | * MA 02111-1307 USA |
| 24 | */ |
| 25 | |
Marian Balakowicz | f92332b | 2008-01-31 13:20:06 +0100 | [diff] [blame] | 26 | #define DEBUG |
| 27 | |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 28 | #include <common.h> |
| 29 | #include <watchdog.h> |
| 30 | #include <command.h> |
| 31 | #include <image.h> |
| 32 | #include <malloc.h> |
| 33 | #include <zlib.h> |
| 34 | #include <bzlib.h> |
| 35 | #include <environment.h> |
| 36 | #include <asm/byteorder.h> |
| 37 | |
| 38 | #if defined(CONFIG_OF_LIBFDT) |
| 39 | #include <fdt.h> |
| 40 | #include <libfdt.h> |
| 41 | #include <fdt_support.h> |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 42 | |
| 43 | static void fdt_error (const char *msg); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 44 | #endif |
| 45 | |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 46 | #ifdef CFG_INIT_RAM_LOCK |
| 47 | #include <asm/cache.h> |
| 48 | #endif |
| 49 | |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 50 | DECLARE_GLOBAL_DATA_PTR; |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 51 | |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 52 | extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
Marian Balakowicz | 9c701e8 | 2008-01-31 13:57:17 +0100 | [diff] [blame] | 53 | static ulong get_sp (void); |
Marian Balakowicz | 2efc264 | 2008-01-31 13:58:13 +0100 | [diff] [blame^] | 54 | static void set_clocks_in_mhz (bd_t *kbd); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 55 | |
| 56 | void __attribute__((noinline)) |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 57 | do_bootm_linux(cmd_tbl_t *cmdtp, int flag, |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 58 | int argc, char *argv[], |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 59 | image_header_t *hdr, |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 60 | int verify) |
| 61 | { |
Marian Balakowicz | 2efc264 | 2008-01-31 13:58:13 +0100 | [diff] [blame^] | 62 | ulong sp, sp_limit, alloc_current; |
| 63 | |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 64 | ulong initrd_start, initrd_end; |
Marian Balakowicz | 9541850 | 2008-01-31 13:55:39 +0100 | [diff] [blame] | 65 | ulong rd_data_start, rd_data_end, rd_len; |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 66 | |
| 67 | ulong cmd_start, cmd_end; |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 68 | bd_t *kbd; |
| 69 | void (*kernel)(bd_t *, ulong, ulong, ulong, ulong); |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 70 | |
Marian Balakowicz | d216085 | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 71 | #if defined(CONFIG_OF_LIBFDT) |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 72 | image_header_t *fdt_hdr; |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 73 | char *of_flat_tree = NULL; |
| 74 | ulong of_data = 0; |
| 75 | #endif |
| 76 | |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 77 | /* |
| 78 | * Booting a (Linux) kernel image |
| 79 | * |
| 80 | * Allocate space for command line and board info - the |
| 81 | * address should be as high as possible within the reach of |
| 82 | * the kernel (see CFG_BOOTMAPSZ settings), but in unused |
| 83 | * memory, which means far enough below the current stack |
| 84 | * pointer. |
| 85 | */ |
Marian Balakowicz | 2efc264 | 2008-01-31 13:58:13 +0100 | [diff] [blame^] | 86 | sp = get_sp(); |
| 87 | debug ("## Current stack ends at 0x%08lx ", sp); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 88 | |
Marian Balakowicz | 2efc264 | 2008-01-31 13:58:13 +0100 | [diff] [blame^] | 89 | alloc_current = sp_limit = get_boot_sp_limit(sp); |
| 90 | debug ("=> set upper limit to 0x%08lx\n", sp_limit); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 91 | |
Marian Balakowicz | 2efc264 | 2008-01-31 13:58:13 +0100 | [diff] [blame^] | 92 | /* allocate space and init command line */ |
| 93 | alloc_current = get_boot_cmdline (alloc_current, &cmd_start, &cmd_end); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 94 | |
Marian Balakowicz | 2efc264 | 2008-01-31 13:58:13 +0100 | [diff] [blame^] | 95 | /* allocate space for kernel copy of board info */ |
| 96 | alloc_current = get_boot_kbd (alloc_current, &kbd); |
| 97 | set_clocks_in_mhz(kbd); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 98 | |
Marian Balakowicz | 9c701e8 | 2008-01-31 13:57:17 +0100 | [diff] [blame] | 99 | /* find kernel */ |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 100 | kernel = (void (*)(bd_t *, ulong, ulong, ulong, ulong))image_get_ep (hdr); |
| 101 | |
Marian Balakowicz | 9c701e8 | 2008-01-31 13:57:17 +0100 | [diff] [blame] | 102 | /* find ramdisk */ |
Marian Balakowicz | 9541850 | 2008-01-31 13:55:39 +0100 | [diff] [blame] | 103 | get_ramdisk (cmdtp, flag, argc, argv, hdr, verify, |
| 104 | IH_ARCH_PPC, &rd_data_start, &rd_data_end); |
Marian Balakowicz | 9c701e8 | 2008-01-31 13:57:17 +0100 | [diff] [blame] | 105 | |
Marian Balakowicz | 9541850 | 2008-01-31 13:55:39 +0100 | [diff] [blame] | 106 | rd_len = rd_data_end - rd_data_start; |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 107 | |
Marian Balakowicz | 2efc264 | 2008-01-31 13:58:13 +0100 | [diff] [blame^] | 108 | alloc_current = ramdisk_high (alloc_current, rd_data_start, rd_len, |
| 109 | kbd, sp_limit, get_sp (), |
Marian Balakowicz | 9c701e8 | 2008-01-31 13:57:17 +0100 | [diff] [blame] | 110 | &initrd_start, &initrd_end); |
| 111 | |
Marian Balakowicz | d216085 | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 112 | #if defined(CONFIG_OF_LIBFDT) |
Marian Balakowicz | 9c701e8 | 2008-01-31 13:57:17 +0100 | [diff] [blame] | 113 | /* find flattened device tree */ |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 114 | if(argc > 3) { |
| 115 | of_flat_tree = (char *) simple_strtoul(argv[3], NULL, 16); |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 116 | fdt_hdr = (image_header_t *)of_flat_tree; |
Marian Balakowicz | d216085 | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 117 | |
Marian Balakowicz | ed68d47 | 2008-01-08 18:11:44 +0100 | [diff] [blame] | 118 | if (fdt_check_header (of_flat_tree) == 0) { |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 119 | #ifndef CFG_NO_FLASH |
| 120 | if (addr2info((ulong)of_flat_tree) != NULL) |
| 121 | of_data = (ulong)of_flat_tree; |
| 122 | #endif |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 123 | } else if (image_check_magic (fdt_hdr)) { |
Marian Balakowicz | f92332b | 2008-01-31 13:20:06 +0100 | [diff] [blame] | 124 | ulong image_start, image_end; |
| 125 | ulong load_start, load_end; |
| 126 | |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 127 | printf ("## Flat Device Tree at %08lX\n", fdt_hdr); |
| 128 | print_image_hdr (fdt_hdr); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 129 | |
Marian Balakowicz | f92332b | 2008-01-31 13:20:06 +0100 | [diff] [blame] | 130 | image_start = (ulong)fdt_hdr; |
| 131 | image_end = image_get_image_end (fdt_hdr); |
| 132 | |
| 133 | load_start = image_get_load (fdt_hdr); |
| 134 | load_end = load_start + image_get_data_size (fdt_hdr); |
| 135 | |
| 136 | if ((load_start < image_end) && (load_end > image_start)) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 137 | fdt_error ("fdt overwritten"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 138 | do_reset (cmdtp, flag, argc, argv); |
| 139 | } |
| 140 | |
| 141 | puts (" Verifying Checksum ... "); |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 142 | if (!image_check_hcrc (fdt_hdr)) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 143 | fdt_error ("fdt header checksum invalid"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 144 | do_reset (cmdtp, flag, argc, argv); |
| 145 | } |
| 146 | |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 147 | if (!image_check_dcrc (fdt_hdr)) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 148 | fdt_error ("fdt checksum invalid"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 149 | do_reset (cmdtp, flag, argc, argv); |
| 150 | } |
| 151 | puts ("OK\n"); |
| 152 | |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 153 | if (!image_check_type (fdt_hdr, IH_TYPE_FLATDT)) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 154 | fdt_error ("uImage is not a fdt"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 155 | do_reset (cmdtp, flag, argc, argv); |
| 156 | } |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 157 | if (image_get_comp (fdt_hdr) != IH_COMP_NONE) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 158 | fdt_error ("uImage is compressed"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 159 | do_reset (cmdtp, flag, argc, argv); |
| 160 | } |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 161 | if (fdt_check_header (of_flat_tree + image_get_header_size ()) != 0) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 162 | fdt_error ("uImage data is not a fdt"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 163 | do_reset (cmdtp, flag, argc, argv); |
| 164 | } |
| 165 | |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 166 | memmove ((void *)image_get_load (fdt_hdr), |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 167 | (void *)(of_flat_tree + image_get_header_size ()), |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 168 | image_get_data_size (fdt_hdr)); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 169 | |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 170 | of_flat_tree = (char *)image_get_load (fdt_hdr); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 171 | } else { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 172 | fdt_error ("Did not find a Flattened Device Tree"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 173 | do_reset (cmdtp, flag, argc, argv); |
| 174 | } |
| 175 | printf (" Booting using the fdt at 0x%x\n", |
| 176 | of_flat_tree); |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 177 | } else if (image_check_type (hdr, IH_TYPE_MULTI)) { |
| 178 | ulong fdt_data, fdt_len; |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 179 | |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 180 | image_multi_getimg (hdr, 2, &fdt_data, &fdt_len); |
| 181 | if (fdt_len) { |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 182 | |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 183 | of_flat_tree = (char *)fdt_data; |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 184 | |
| 185 | #ifndef CFG_NO_FLASH |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 186 | /* move the blob if it is in flash (set of_data to !null) */ |
| 187 | if (addr2info ((ulong)of_flat_tree) != NULL) |
| 188 | of_data = (ulong)of_flat_tree; |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 189 | #endif |
| 190 | |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 191 | if (fdt_check_header (of_flat_tree) != 0) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 192 | fdt_error ("image is not a fdt"); |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 193 | do_reset (cmdtp, flag, argc, argv); |
| 194 | } |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 195 | |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 196 | if (be32_to_cpu (fdt_totalsize (of_flat_tree)) != fdt_len) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 197 | fdt_error ("fdt size != image size"); |
Marian Balakowicz | b4a12a9 | 2008-01-08 18:12:17 +0100 | [diff] [blame] | 198 | do_reset (cmdtp, flag, argc, argv); |
| 199 | } |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 200 | } |
| 201 | } |
| 202 | #endif |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 203 | |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 204 | |
| 205 | #if defined(CONFIG_OF_LIBFDT) |
| 206 | |
| 207 | #ifdef CFG_BOOTMAPSZ |
| 208 | /* |
| 209 | * The blob must be within CFG_BOOTMAPSZ, |
| 210 | * so we flag it to be copied if it is not. |
| 211 | */ |
| 212 | if (of_flat_tree >= (char *)CFG_BOOTMAPSZ) |
| 213 | of_data = (ulong)of_flat_tree; |
| 214 | #endif |
| 215 | |
| 216 | /* move of_flat_tree if needed */ |
| 217 | if (of_data) { |
| 218 | int err; |
| 219 | ulong of_start, of_len; |
| 220 | |
| 221 | of_len = be32_to_cpu(fdt_totalsize(of_data)); |
| 222 | |
Marian Balakowicz | 2efc264 | 2008-01-31 13:58:13 +0100 | [diff] [blame^] | 223 | /* position on a 4K boundary before the alloc_current */ |
| 224 | of_start = alloc_current - of_len; |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 225 | of_start &= ~(4096 - 1); /* align on page */ |
| 226 | debug ("## device tree at 0x%08lX ... 0x%08lX (len=%ld=0x%lX)\n", |
| 227 | of_data, of_data + of_len - 1, of_len, of_len); |
| 228 | |
| 229 | of_flat_tree = (char *)of_start; |
| 230 | printf (" Loading Device Tree to %08lx, end %08lx ... ", |
| 231 | of_start, of_start + of_len - 1); |
| 232 | err = fdt_open_into((void *)of_data, (void *)of_start, of_len); |
| 233 | if (err != 0) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 234 | fdt_error ("fdt move failed"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 235 | do_reset (cmdtp, flag, argc, argv); |
| 236 | } |
| 237 | puts ("OK\n"); |
| 238 | } |
| 239 | /* |
| 240 | * Add the chosen node if it doesn't exist, add the env and bd_t |
| 241 | * if the user wants it (the logic is in the subroutines). |
| 242 | */ |
| 243 | if (of_flat_tree) { |
| 244 | if (fdt_chosen(of_flat_tree, initrd_start, initrd_end, 0) < 0) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 245 | fdt_error ("/chosen node create failed"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 246 | do_reset (cmdtp, flag, argc, argv); |
| 247 | } |
| 248 | #ifdef CONFIG_OF_HAS_UBOOT_ENV |
| 249 | if (fdt_env(of_flat_tree) < 0) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 250 | fdt_error ("/u-boot-env node create failed"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 251 | do_reset (cmdtp, flag, argc, argv); |
| 252 | } |
| 253 | #endif |
| 254 | #ifdef CONFIG_OF_HAS_BD_T |
| 255 | if (fdt_bd_t(of_flat_tree) < 0) { |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 256 | fdt_error ("/bd_t node create failed"); |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 257 | do_reset (cmdtp, flag, argc, argv); |
| 258 | } |
| 259 | #endif |
| 260 | #ifdef CONFIG_OF_BOARD_SETUP |
| 261 | /* Call the board-specific fixup routine */ |
| 262 | ft_board_setup(of_flat_tree, gd->bd); |
| 263 | #endif |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 264 | } |
Marian Balakowicz | d216085 | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 265 | #endif /* CONFIG_OF_LIBFDT */ |
Marian Balakowicz | 751b2b8 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 266 | |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 267 | debug ("## Transferring control to Linux (at address %08lx) ...\n", |
| 268 | (ulong)kernel); |
| 269 | |
| 270 | show_boot_progress (15); |
| 271 | |
| 272 | #if defined(CFG_INIT_RAM_LOCK) && !defined(CONFIG_E500) |
| 273 | unlock_ram_in_cache(); |
| 274 | #endif |
| 275 | |
Marian Balakowicz | d216085 | 2008-01-31 13:20:07 +0100 | [diff] [blame] | 276 | #if defined(CONFIG_OF_LIBFDT) |
Marian Balakowicz | 2437cf2 | 2008-01-08 18:11:43 +0100 | [diff] [blame] | 277 | if (of_flat_tree) { /* device tree; boot new style */ |
| 278 | /* |
| 279 | * Linux Kernel Parameters (passing device tree): |
| 280 | * r3: pointer to the fdt, followed by the board info data |
| 281 | * r4: physical pointer to the kernel itself |
| 282 | * r5: NULL |
| 283 | * r6: NULL |
| 284 | * r7: NULL |
| 285 | */ |
| 286 | (*kernel) ((bd_t *)of_flat_tree, (ulong)kernel, 0, 0, 0); |
| 287 | /* does not return */ |
| 288 | } |
| 289 | #endif |
| 290 | /* |
| 291 | * Linux Kernel Parameters (passing board info data): |
| 292 | * r3: ptr to board info data |
| 293 | * r4: initrd_start or 0 if no initrd |
| 294 | * r5: initrd_end - unused if r4 is 0 |
| 295 | * r6: Start of command line string |
| 296 | * r7: End of command line string |
| 297 | */ |
| 298 | (*kernel) (kbd, initrd_start, initrd_end, cmd_start, cmd_end); |
| 299 | /* does not return */ |
| 300 | } |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 301 | |
Marian Balakowicz | 9c701e8 | 2008-01-31 13:57:17 +0100 | [diff] [blame] | 302 | static ulong get_sp (void) |
| 303 | { |
| 304 | ulong sp; |
| 305 | |
| 306 | asm( "mr %0,1": "=r"(sp) : ); |
| 307 | return sp; |
| 308 | } |
| 309 | |
Marian Balakowicz | 2efc264 | 2008-01-31 13:58:13 +0100 | [diff] [blame^] | 310 | static void set_clocks_in_mhz (bd_t *kbd) |
| 311 | { |
| 312 | char *s; |
| 313 | |
| 314 | if ((s = getenv ("clocks_in_mhz")) != NULL) { |
| 315 | /* convert all clock information to MHz */ |
| 316 | kbd->bi_intfreq /= 1000000L; |
| 317 | kbd->bi_busfreq /= 1000000L; |
| 318 | #if defined(CONFIG_MPC8220) |
| 319 | kbd->bi_inpfreq /= 1000000L; |
| 320 | kbd->bi_pcifreq /= 1000000L; |
| 321 | kbd->bi_pevfreq /= 1000000L; |
| 322 | kbd->bi_flbfreq /= 1000000L; |
| 323 | kbd->bi_vcofreq /= 1000000L; |
| 324 | #endif |
| 325 | #if defined(CONFIG_CPM2) |
| 326 | kbd->bi_cpmfreq /= 1000000L; |
| 327 | kbd->bi_brgfreq /= 1000000L; |
| 328 | kbd->bi_sccfreq /= 1000000L; |
| 329 | kbd->bi_vco /= 1000000L; |
| 330 | #endif |
| 331 | #if defined(CONFIG_MPC5xxx) |
| 332 | kbd->bi_ipbfreq /= 1000000L; |
| 333 | kbd->bi_pcifreq /= 1000000L; |
| 334 | #endif /* CONFIG_MPC5xxx */ |
| 335 | } |
| 336 | } |
| 337 | |
Marian Balakowicz | 28fb615 | 2008-01-31 13:20:08 +0100 | [diff] [blame] | 338 | #if defined(CONFIG_OF_LIBFDT) |
| 339 | static void fdt_error (const char *msg) |
| 340 | { |
| 341 | puts ("ERROR: "); |
| 342 | puts (msg); |
| 343 | puts (" - must RESET the board to recover.\n"); |
| 344 | } |
| 345 | #endif |