wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
Wolfgang Denk | 57cac1f | 2006-01-29 19:12:41 +0100 | [diff] [blame] | 2 | * (C) Copyright 2002-2006 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * (C) Copyright 2002 |
| 6 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> |
| 7 | * Marius Groeger <mgroeger@sysgo.de> |
| 8 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 10 | */ |
| 11 | |
Wolfgang Denk | 57cac1f | 2006-01-29 19:12:41 +0100 | [diff] [blame] | 12 | /* |
| 13 | * To match the U-Boot user interface on ARM platforms to the U-Boot |
| 14 | * standard (as on PPC platforms), some messages with debug character |
| 15 | * are removed from the default U-Boot build. |
| 16 | * |
| 17 | * Define DEBUG here if you want additional info as shown below |
| 18 | * printed upon startup: |
| 19 | * |
| 20 | * U-Boot code: 00F00000 -> 00F3C774 BSS: -> 00FC3274 |
| 21 | * IRQ Stack: 00ebff7c |
| 22 | * FIQ Stack: 00ebef7c |
| 23 | */ |
| 24 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 25 | #include <common.h> |
| 26 | #include <command.h> |
Simon Glass | 06fd853 | 2012-11-30 13:01:17 +0000 | [diff] [blame] | 27 | #include <environment.h> |
wdenk | 3595ac4 | 2003-06-22 17:18:28 +0000 | [diff] [blame] | 28 | #include <malloc.h> |
Jean-Christophe PLAGNIOL-VILLARD | 52cb4d4 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 29 | #include <stdio_dev.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 30 | #include <version.h> |
| 31 | #include <net.h> |
Marcel Ziswiler | b71190f | 2008-05-01 09:05:26 +0200 | [diff] [blame] | 32 | #include <serial.h> |
Scott Wood | d6ac2ed | 2008-05-22 10:49:46 -0500 | [diff] [blame] | 33 | #include <nand.h> |
| 34 | #include <onenand_uboot.h> |
Ilya Yanok | 379e9fc | 2009-06-08 04:12:50 +0400 | [diff] [blame] | 35 | #include <mmc.h> |
Ian Campbell | c6f3d50 | 2014-03-07 01:20:56 +0000 | [diff] [blame] | 36 | #include <scsi.h> |
Simon Glass | f5437ad | 2011-10-24 19:15:33 +0000 | [diff] [blame] | 37 | #include <libfdt.h> |
| 38 | #include <fdtdec.h> |
Valentin Longchamp | ea3681a | 2011-09-02 04:59:03 +0000 | [diff] [blame] | 39 | #include <post.h> |
| 40 | #include <logbuff.h> |
Simon Glass | e103b7a | 2013-03-05 14:39:38 +0000 | [diff] [blame] | 41 | #include <asm/sections.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 42 | |
Luigi 'Comio' Mantellini | 310cecb | 2009-10-10 12:42:21 +0200 | [diff] [blame] | 43 | #ifdef CONFIG_BITBANGMII |
| 44 | #include <miiphy.h> |
| 45 | #endif |
| 46 | |
Markus Klotzbücher | b2b4346 | 2006-02-10 11:25:41 +0100 | [diff] [blame] | 47 | DECLARE_GLOBAL_DATA_PTR; |
| 48 | |
wdenk | 3b57fe0 | 2003-05-30 12:48:29 +0000 | [diff] [blame] | 49 | ulong monitor_flash_len; |
| 50 | |
wdenk | 2abbe07 | 2003-06-16 23:50:08 +0000 | [diff] [blame] | 51 | #ifdef CONFIG_HAS_DATAFLASH |
| 52 | extern int AT91F_DataflashInit(void); |
| 53 | extern void dataflash_print_info(void); |
| 54 | #endif |
| 55 | |
Hebbar | f7ad79b | 2007-12-18 16:00:54 -0800 | [diff] [blame] | 56 | #if defined(CONFIG_HARD_I2C) || \ |
Heiko Schocher | 3f4978c | 2012-01-16 21:12:24 +0000 | [diff] [blame] | 57 | defined(CONFIG_SYS_I2C) |
Hebbar | f7ad79b | 2007-12-18 16:00:54 -0800 | [diff] [blame] | 58 | #include <i2c.h> |
| 59 | #endif |
| 60 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 61 | /************************************************************************ |
Peter Pearse | 9f5c3d3 | 2007-09-04 16:18:38 +0100 | [diff] [blame] | 62 | * Coloured LED functionality |
| 63 | ************************************************************************ |
| 64 | * May be supplied by boards if desired |
| 65 | */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 66 | inline void __coloured_LED_init(void) {} |
| 67 | void coloured_LED_init(void) |
| 68 | __attribute__((weak, alias("__coloured_LED_init"))); |
Jason Kridner | 2d3be7c | 2011-09-04 14:40:16 -0400 | [diff] [blame] | 69 | inline void __red_led_on(void) {} |
| 70 | void red_led_on(void) __attribute__((weak, alias("__red_led_on"))); |
| 71 | inline void __red_led_off(void) {} |
| 72 | void red_led_off(void) __attribute__((weak, alias("__red_led_off"))); |
| 73 | inline void __green_led_on(void) {} |
| 74 | void green_led_on(void) __attribute__((weak, alias("__green_led_on"))); |
| 75 | inline void __green_led_off(void) {} |
| 76 | void green_led_off(void) __attribute__((weak, alias("__green_led_off"))); |
| 77 | inline void __yellow_led_on(void) {} |
| 78 | void yellow_led_on(void) __attribute__((weak, alias("__yellow_led_on"))); |
| 79 | inline void __yellow_led_off(void) {} |
| 80 | void yellow_led_off(void) __attribute__((weak, alias("__yellow_led_off"))); |
| 81 | inline void __blue_led_on(void) {} |
| 82 | void blue_led_on(void) __attribute__((weak, alias("__blue_led_on"))); |
| 83 | inline void __blue_led_off(void) {} |
| 84 | void blue_led_off(void) __attribute__((weak, alias("__blue_led_off"))); |
Peter Pearse | 9f5c3d3 | 2007-09-04 16:18:38 +0100 | [diff] [blame] | 85 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 86 | /* |
| 87 | ************************************************************************ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 88 | * Init Utilities * |
| 89 | ************************************************************************ |
| 90 | * Some of this code should be moved into the core functions, |
| 91 | * or dropped completely, |
| 92 | * but let's get it working (again) first... |
| 93 | */ |
| 94 | |
Jean-Christophe PLAGNIOL-VILLARD | 4f57289 | 2009-02-22 15:49:28 +0100 | [diff] [blame] | 95 | #if defined(CONFIG_ARM_DCC) && !defined(CONFIG_BAUDRATE) |
| 96 | #define CONFIG_BAUDRATE 115200 |
| 97 | #endif |
Simon Glass | dc8bbea | 2011-10-13 14:43:06 +0000 | [diff] [blame] | 98 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 99 | static int init_baudrate(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 100 | { |
Simon Glass | dc8bbea | 2011-10-13 14:43:06 +0000 | [diff] [blame] | 101 | gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE); |
| 102 | return 0; |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 103 | } |
| 104 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 105 | static int display_banner(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 106 | { |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 107 | printf("\n\n%s\n\n", version_string); |
| 108 | debug("U-Boot code: %08lX -> %08lX BSS: -> %08lX\n", |
Albert ARIBAUD | b60eff3 | 2014-02-22 17:53:43 +0100 | [diff] [blame] | 109 | (ulong)&_start, |
| 110 | (ulong)&__bss_start, (ulong)&__bss_end); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 111 | #ifdef CONFIG_MODEM_SUPPORT |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 112 | debug("Modem Support enabled\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 113 | #endif |
| 114 | #ifdef CONFIG_USE_IRQ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 115 | debug("IRQ Stack: %08lx\n", IRQ_STACK_START); |
| 116 | debug("FIQ Stack: %08lx\n", FIQ_STACK_START); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 117 | #endif |
wdenk | f72da34 | 2003-10-10 10:05:42 +0000 | [diff] [blame] | 118 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 119 | return (0); |
| 120 | } |
| 121 | |
| 122 | /* |
| 123 | * WARNING: this code looks "cleaner" than the PowerPC version, but |
| 124 | * has the disadvantage that you either get nothing, or everything. |
| 125 | * On PowerPC, you might see "DRAM: " before the system hangs - which |
| 126 | * gives a simple yet clear indication which part of the |
| 127 | * initialization if failing. |
| 128 | */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 129 | static int display_dram_config(void) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 130 | { |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 131 | int i; |
| 132 | |
Wolfgang Denk | 57cac1f | 2006-01-29 19:12:41 +0100 | [diff] [blame] | 133 | #ifdef DEBUG |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 134 | puts("RAM Configuration:\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 135 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 136 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) { |
| 137 | printf("Bank #%d: %08lx ", i, gd->bd->bi_dram[i].start); |
| 138 | print_size(gd->bd->bi_dram[i].size, "\n"); |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 139 | } |
Wolfgang Denk | 57cac1f | 2006-01-29 19:12:41 +0100 | [diff] [blame] | 140 | #else |
| 141 | ulong size = 0; |
| 142 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 143 | for (i = 0; i < CONFIG_NR_DRAM_BANKS; i++) |
Wolfgang Denk | 57cac1f | 2006-01-29 19:12:41 +0100 | [diff] [blame] | 144 | size += gd->bd->bi_dram[i].size; |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 145 | |
Wolfgang Denk | 57cac1f | 2006-01-29 19:12:41 +0100 | [diff] [blame] | 146 | puts("DRAM: "); |
| 147 | print_size(size, "\n"); |
| 148 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 149 | |
| 150 | return (0); |
| 151 | } |
| 152 | |
Heiko Schocher | ea818db | 2013-01-29 08:53:15 +0100 | [diff] [blame] | 153 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C) |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 154 | static int init_func_i2c(void) |
Hebbar | f7ad79b | 2007-12-18 16:00:54 -0800 | [diff] [blame] | 155 | { |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 156 | puts("I2C: "); |
Heiko Schocher | 3f4978c | 2012-01-16 21:12:24 +0000 | [diff] [blame] | 157 | #ifdef CONFIG_SYS_I2C |
| 158 | i2c_init_all(); |
| 159 | #else |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 160 | i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE); |
Heiko Schocher | 3f4978c | 2012-01-16 21:12:24 +0000 | [diff] [blame] | 161 | #endif |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 162 | puts("ready\n"); |
Hebbar | f7ad79b | 2007-12-18 16:00:54 -0800 | [diff] [blame] | 163 | return (0); |
| 164 | } |
| 165 | #endif |
| 166 | |
Jean-Christophe PLAGNIOL-VILLARD | f90c802 | 2009-01-31 09:04:58 +0100 | [diff] [blame] | 167 | #if defined(CONFIG_CMD_PCI) || defined (CONFIG_PCI) |
| 168 | #include <pci.h> |
| 169 | static int arm_pci_init(void) |
| 170 | { |
| 171 | pci_init(); |
| 172 | return 0; |
| 173 | } |
| 174 | #endif /* CONFIG_CMD_PCI || CONFIG_PCI */ |
| 175 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 176 | /* |
wdenk | a8c7c70 | 2003-12-06 19:49:23 +0000 | [diff] [blame] | 177 | * Breathe some life into the board... |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 178 | * |
wdenk | b0639ca | 2003-09-17 22:48:07 +0000 | [diff] [blame] | 179 | * Initialize a serial port as console, and carry out some hardware |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 180 | * tests. |
| 181 | * |
| 182 | * The first part of initialization is running from Flash memory; |
| 183 | * its main purpose is to initialize the RAM so that we |
| 184 | * can relocate the monitor code to RAM. |
| 185 | */ |
| 186 | |
| 187 | /* |
| 188 | * All attempts to come up with a "common" initialization sequence |
| 189 | * that works for all boards and architectures failed: some of the |
| 190 | * requirements are just _too_ different. To get rid of the resulting |
wdenk | f6e20fc | 2004-02-08 19:38:38 +0000 | [diff] [blame] | 191 | * mess of board dependent #ifdef'ed code we now make the whole |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 192 | * initialization sequence configurable to the user. |
| 193 | * |
| 194 | * The requirements for any new initalization function is simple: it |
| 195 | * receives a pointer to the "global data" structure as it's only |
| 196 | * argument, and returns an integer return code, where 0 means |
| 197 | * "continue" and != 0 means "fatal error, hang the system". |
| 198 | */ |
| 199 | typedef int (init_fnc_t) (void); |
| 200 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 201 | void __dram_init_banksize(void) |
| 202 | { |
| 203 | gd->bd->bi_dram[0].start = CONFIG_SYS_SDRAM_BASE; |
| 204 | gd->bd->bi_dram[0].size = gd->ram_size; |
| 205 | } |
| 206 | void dram_init_banksize(void) |
| 207 | __attribute__((weak, alias("__dram_init_banksize"))); |
| 208 | |
Fabio Estevam | a21c651 | 2012-03-01 04:02:38 +0000 | [diff] [blame] | 209 | int __arch_cpu_init(void) |
| 210 | { |
| 211 | return 0; |
| 212 | } |
| 213 | int arch_cpu_init(void) |
| 214 | __attribute__((weak, alias("__arch_cpu_init"))); |
| 215 | |
Łukasz Majewski | 2ffb4be | 2012-11-13 03:21:56 +0000 | [diff] [blame] | 216 | int __power_init_board(void) |
| 217 | { |
| 218 | return 0; |
| 219 | } |
| 220 | int power_init_board(void) |
| 221 | __attribute__((weak, alias("__power_init_board"))); |
| 222 | |
Simon Glass | 2f8d8d6 | 2012-11-30 13:01:22 +0000 | [diff] [blame] | 223 | /* Record the board_init_f() bootstage (after arch_cpu_init()) */ |
| 224 | static int mark_bootstage(void) |
| 225 | { |
| 226 | bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f"); |
| 227 | |
| 228 | return 0; |
| 229 | } |
| 230 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 231 | init_fnc_t *init_sequence[] = { |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 232 | arch_cpu_init, /* basic arch cpu dependent setup */ |
Simon Glass | 2f8d8d6 | 2012-11-30 13:01:22 +0000 | [diff] [blame] | 233 | mark_bootstage, |
Simon Glass | f5437ad | 2011-10-24 19:15:33 +0000 | [diff] [blame] | 234 | #ifdef CONFIG_OF_CONTROL |
| 235 | fdtdec_check_fdt, |
| 236 | #endif |
Simon Glass | eae78c3 | 2012-11-30 13:01:16 +0000 | [diff] [blame] | 237 | #if defined(CONFIG_BOARD_EARLY_INIT_F) |
| 238 | board_early_init_f, |
| 239 | #endif |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 240 | timer_init, /* initialize timer */ |
Markus Hubig | e23e5ee | 2012-08-16 08:22:08 +0000 | [diff] [blame] | 241 | #ifdef CONFIG_BOARD_POSTCLK_INIT |
| 242 | board_postclk_init, |
| 243 | #endif |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 244 | #ifdef CONFIG_FSL_ESDHC |
| 245 | get_clocks, |
| 246 | #endif |
| 247 | env_init, /* initialize environment */ |
| 248 | init_baudrate, /* initialze baudrate settings */ |
| 249 | serial_init, /* serial communications setup */ |
| 250 | console_init_f, /* stage 1 init of console */ |
| 251 | display_banner, /* say that we are here */ |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 252 | print_cpuinfo, /* display cpu info (and speed) */ |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 253 | #if defined(CONFIG_DISPLAY_BOARDINFO) |
| 254 | checkboard, /* display board info */ |
| 255 | #endif |
Heiko Schocher | ea818db | 2013-01-29 08:53:15 +0100 | [diff] [blame] | 256 | #if defined(CONFIG_HARD_I2C) || defined(CONFIG_SYS_I2C) |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 257 | init_func_i2c, |
| 258 | #endif |
| 259 | dram_init, /* configure available RAM banks */ |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 260 | NULL, |
| 261 | }; |
| 262 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 263 | void board_init_f(ulong bootflag) |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 264 | { |
| 265 | bd_t *bd; |
| 266 | init_fnc_t **init_fnc_ptr; |
| 267 | gd_t *id; |
| 268 | ulong addr, addr_sp; |
Simon Glass | dc8bbea | 2011-10-13 14:43:06 +0000 | [diff] [blame] | 269 | #ifdef CONFIG_PRAM |
| 270 | ulong reg; |
| 271 | #endif |
Simon Glass | 39826f0 | 2012-09-27 15:41:55 +0000 | [diff] [blame] | 272 | void *new_fdt = NULL; |
| 273 | size_t fdt_size = 0; |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 274 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 275 | memset((void *)gd, 0, sizeof(gd_t)); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 276 | |
Albert ARIBAUD | b60eff3 | 2014-02-22 17:53:43 +0100 | [diff] [blame] | 277 | gd->mon_len = (ulong)&__bss_end - (ulong)_start; |
Simon Glass | f5437ad | 2011-10-24 19:15:33 +0000 | [diff] [blame] | 278 | #ifdef CONFIG_OF_EMBED |
| 279 | /* Get a pointer to the FDT */ |
Masahiro Yamada | 6ab6b2a | 2014-02-05 11:28:25 +0900 | [diff] [blame] | 280 | gd->fdt_blob = __dtb_db_begin; |
Simon Glass | f5437ad | 2011-10-24 19:15:33 +0000 | [diff] [blame] | 281 | #elif defined CONFIG_OF_SEPARATE |
| 282 | /* FDT is at end of image */ |
Albert ARIBAUD | b60eff3 | 2014-02-22 17:53:43 +0100 | [diff] [blame] | 283 | gd->fdt_blob = &_end; |
Simon Glass | f5437ad | 2011-10-24 19:15:33 +0000 | [diff] [blame] | 284 | #endif |
Simon Glass | eea63e0 | 2011-10-24 19:15:34 +0000 | [diff] [blame] | 285 | /* Allow the early environment to override the fdt address */ |
| 286 | gd->fdt_blob = (void *)getenv_ulong("fdtcontroladdr", 16, |
| 287 | (uintptr_t)gd->fdt_blob); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 288 | |
| 289 | for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) { |
| 290 | if ((*init_fnc_ptr)() != 0) { |
| 291 | hang (); |
| 292 | } |
| 293 | } |
| 294 | |
Simon Glass | 2866903 | 2012-03-28 10:08:25 +0000 | [diff] [blame] | 295 | #ifdef CONFIG_OF_CONTROL |
| 296 | /* For now, put this check after the console is ready */ |
| 297 | if (fdtdec_prepare_fdt()) { |
| 298 | panic("** CONFIG_OF_CONTROL defined but no FDT - please see " |
| 299 | "doc/README.fdt-control"); |
| 300 | } |
| 301 | #endif |
| 302 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 303 | debug("monitor len: %08lX\n", gd->mon_len); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 304 | /* |
| 305 | * Ram is setup, size stored in gd !! |
| 306 | */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 307 | debug("ramsize: %08lX\n", gd->ram_size); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 308 | #if defined(CONFIG_SYS_MEM_TOP_HIDE) |
| 309 | /* |
| 310 | * Subtract specified amount of memory to hide so that it won't |
| 311 | * get "touched" at all by U-Boot. By fixing up gd->ram_size |
| 312 | * the Linux kernel should now get passed the now "corrected" |
| 313 | * memory size and won't touch it either. This should work |
| 314 | * for arch/ppc and arch/powerpc. Only Linux board ports in |
| 315 | * arch/powerpc with bootwrapper support, that recalculate the |
| 316 | * memory size from the SDRAM controller setup will have to |
| 317 | * get fixed. |
| 318 | */ |
| 319 | gd->ram_size -= CONFIG_SYS_MEM_TOP_HIDE; |
| 320 | #endif |
| 321 | |
York Sun | e386616 | 2014-02-11 11:57:26 -0800 | [diff] [blame] | 322 | addr = CONFIG_SYS_SDRAM_BASE + get_effective_memsize(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 323 | |
| 324 | #ifdef CONFIG_LOGBUFFER |
| 325 | #ifndef CONFIG_ALT_LB_ADDR |
| 326 | /* reserve kernel log buffer */ |
| 327 | addr -= (LOGBUFF_RESERVE); |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 328 | debug("Reserving %dk for kernel logbuffer at %08lx\n", LOGBUFF_LEN, |
| 329 | addr); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 330 | #endif |
| 331 | #endif |
| 332 | |
| 333 | #ifdef CONFIG_PRAM |
| 334 | /* |
| 335 | * reserve protected RAM |
| 336 | */ |
Simon Glass | dc8bbea | 2011-10-13 14:43:06 +0000 | [diff] [blame] | 337 | reg = getenv_ulong("pram", 10, CONFIG_PRAM); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 338 | addr -= (reg << 10); /* size is in kB */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 339 | debug("Reserving %ldk for protected RAM at %08lx\n", reg, addr); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 340 | #endif /* CONFIG_PRAM */ |
| 341 | |
Aneesh V | e47f2db | 2011-06-16 23:30:48 +0000 | [diff] [blame] | 342 | #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF)) |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 343 | /* reserve TLB table */ |
David Feng | 0ae7653 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 344 | gd->arch.tlb_size = PGTABLE_SIZE; |
Simon Glass | 34fd5d2 | 2012-12-13 20:48:39 +0000 | [diff] [blame] | 345 | addr -= gd->arch.tlb_size; |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 346 | |
| 347 | /* round down to next 64 kB limit */ |
| 348 | addr &= ~(0x10000 - 1); |
| 349 | |
Simon Glass | 34fd5d2 | 2012-12-13 20:48:39 +0000 | [diff] [blame] | 350 | gd->arch.tlb_addr = addr; |
| 351 | debug("TLB table from %08lx to %08lx\n", addr, addr + gd->arch.tlb_size); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 352 | #endif |
| 353 | |
| 354 | /* round down to next 4 kB limit */ |
| 355 | addr &= ~(4096 - 1); |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 356 | debug("Top of RAM usable for U-Boot at: %08lx\n", addr); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 357 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 358 | #ifdef CONFIG_LCD |
Minkyu Kang | d32a1a4 | 2011-04-24 22:22:34 +0000 | [diff] [blame] | 359 | #ifdef CONFIG_FB_ADDR |
| 360 | gd->fb_base = CONFIG_FB_ADDR; |
| 361 | #else |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 362 | /* reserve memory for LCD display (always full pages) */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 363 | addr = lcd_setmem(addr); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 364 | gd->fb_base = addr; |
Minkyu Kang | d32a1a4 | 2011-04-24 22:22:34 +0000 | [diff] [blame] | 365 | #endif /* CONFIG_FB_ADDR */ |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 366 | #endif /* CONFIG_LCD */ |
| 367 | |
| 368 | /* |
| 369 | * reserve memory for U-Boot code, data & bss |
| 370 | * round down to next 4 kB limit |
| 371 | */ |
| 372 | addr -= gd->mon_len; |
| 373 | addr &= ~(4096 - 1); |
| 374 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 375 | debug("Reserving %ldk for U-Boot at: %08lx\n", gd->mon_len >> 10, addr); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 376 | |
Aneesh V | 401bb30 | 2011-07-13 05:11:07 +0000 | [diff] [blame] | 377 | #ifndef CONFIG_SPL_BUILD |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 378 | /* |
| 379 | * reserve memory for malloc() arena |
| 380 | */ |
| 381 | addr_sp = addr - TOTAL_MALLOC_LEN; |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 382 | debug("Reserving %dk for malloc() at: %08lx\n", |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 383 | TOTAL_MALLOC_LEN >> 10, addr_sp); |
| 384 | /* |
| 385 | * (permanently) allocate a Board Info struct |
| 386 | * and a permanent copy of the "global" data |
| 387 | */ |
| 388 | addr_sp -= sizeof (bd_t); |
| 389 | bd = (bd_t *) addr_sp; |
| 390 | gd->bd = bd; |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 391 | debug("Reserving %zu Bytes for Board Info at: %08lx\n", |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 392 | sizeof (bd_t), addr_sp); |
Igor Grinberg | 15c2e2c | 2011-08-16 23:48:23 +0000 | [diff] [blame] | 393 | |
| 394 | #ifdef CONFIG_MACH_TYPE |
| 395 | gd->bd->bi_arch_number = CONFIG_MACH_TYPE; /* board id for Linux */ |
| 396 | #endif |
| 397 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 398 | addr_sp -= sizeof (gd_t); |
| 399 | id = (gd_t *) addr_sp; |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 400 | debug("Reserving %zu Bytes for Global Data at: %08lx\n", |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 401 | sizeof (gd_t), addr_sp); |
| 402 | |
Simon Glass | 39826f0 | 2012-09-27 15:41:55 +0000 | [diff] [blame] | 403 | #if defined(CONFIG_OF_SEPARATE) && defined(CONFIG_OF_CONTROL) |
| 404 | /* |
| 405 | * If the device tree is sitting immediate above our image then we |
| 406 | * must relocate it. If it is embedded in the data section, then it |
| 407 | * will be relocated with other data. |
| 408 | */ |
| 409 | if (gd->fdt_blob) { |
| 410 | fdt_size = ALIGN(fdt_totalsize(gd->fdt_blob) + 0x1000, 32); |
| 411 | |
| 412 | addr_sp -= fdt_size; |
| 413 | new_fdt = (void *)addr_sp; |
| 414 | debug("Reserving %zu Bytes for FDT at: %08lx\n", |
| 415 | fdt_size, addr_sp); |
| 416 | } |
| 417 | #endif |
| 418 | |
David Feng | 0ae7653 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 419 | #ifndef CONFIG_ARM64 |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 420 | /* setup stackpointer for exeptions */ |
| 421 | gd->irq_sp = addr_sp; |
| 422 | #ifdef CONFIG_USE_IRQ |
| 423 | addr_sp -= (CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ); |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 424 | debug("Reserving %zu Bytes for IRQ stack at: %08lx\n", |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 425 | CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ, addr_sp); |
| 426 | #endif |
| 427 | /* leave 3 words for abort-stack */ |
Eric Cooper | 6445a30 | 2011-04-14 12:32:37 +0000 | [diff] [blame] | 428 | addr_sp -= 12; |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 429 | |
| 430 | /* 8-byte alignment for ABI compliance */ |
| 431 | addr_sp &= ~0x07; |
David Feng | 0ae7653 | 2013-12-14 11:47:35 +0800 | [diff] [blame] | 432 | #else /* CONFIG_ARM64 */ |
| 433 | /* 16-byte alignment for ABI compliance */ |
| 434 | addr_sp &= ~0x0f; |
| 435 | #endif /* CONFIG_ARM64 */ |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 436 | #else |
| 437 | addr_sp += 128; /* leave 32 words for abort-stack */ |
| 438 | gd->irq_sp = addr_sp; |
| 439 | #endif |
| 440 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 441 | debug("New Stack Pointer is: %08lx\n", addr_sp); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 442 | |
| 443 | #ifdef CONFIG_POST |
| 444 | post_bootmode_init(); |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 445 | post_run(NULL, POST_ROM | post_bootmode_get(0)); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 446 | #endif |
| 447 | |
| 448 | gd->bd->bi_baudrate = gd->baudrate; |
| 449 | /* Ram ist board specific, so move it to board code ... */ |
| 450 | dram_init_banksize(); |
| 451 | display_dram_config(); /* and display it */ |
| 452 | |
| 453 | gd->relocaddr = addr; |
| 454 | gd->start_addr_sp = addr_sp; |
Albert ARIBAUD | b60eff3 | 2014-02-22 17:53:43 +0100 | [diff] [blame] | 455 | gd->reloc_off = addr - (ulong)&_start; |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 456 | debug("relocation Offset is: %08lx\n", gd->reloc_off); |
Simon Glass | 39826f0 | 2012-09-27 15:41:55 +0000 | [diff] [blame] | 457 | if (new_fdt) { |
| 458 | memcpy(new_fdt, gd->fdt_blob, fdt_size); |
| 459 | gd->fdt_blob = new_fdt; |
| 460 | } |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 461 | memcpy(id, (void *)gd, sizeof(gd_t)); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 462 | } |
| 463 | |
| 464 | #if !defined(CONFIG_SYS_NO_FLASH) |
| 465 | static char *failed = "*** failed ***\n"; |
| 466 | #endif |
| 467 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 468 | /* |
Simon Glass | 06fd853 | 2012-11-30 13:01:17 +0000 | [diff] [blame] | 469 | * Tell if it's OK to load the environment early in boot. |
| 470 | * |
| 471 | * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see |
| 472 | * if this is OK (defaulting to saying it's not OK). |
| 473 | * |
| 474 | * NOTE: Loading the environment early can be a bad idea if security is |
| 475 | * important, since no verification is done on the environment. |
| 476 | * |
| 477 | * @return 0 if environment should not be loaded, !=0 if it is ok to load |
| 478 | */ |
| 479 | static int should_load_env(void) |
| 480 | { |
| 481 | #ifdef CONFIG_OF_CONTROL |
Lucas Stach | 4e5eb45 | 2013-01-22 00:15:49 +0000 | [diff] [blame] | 482 | return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1); |
Simon Glass | 06fd853 | 2012-11-30 13:01:17 +0000 | [diff] [blame] | 483 | #elif defined CONFIG_DELAY_ENVIRONMENT |
| 484 | return 0; |
| 485 | #else |
| 486 | return 1; |
| 487 | #endif |
| 488 | } |
| 489 | |
Simon Glass | e2e3e2b | 2012-11-30 13:01:19 +0000 | [diff] [blame] | 490 | #if defined(CONFIG_DISPLAY_BOARDINFO_LATE) && defined(CONFIG_OF_CONTROL) |
| 491 | static void display_fdt_model(const void *blob) |
| 492 | { |
| 493 | const char *model; |
| 494 | |
| 495 | model = (char *)fdt_getprop(blob, 0, "model", NULL); |
| 496 | printf("Model: %s\n", model ? model : "<unknown>"); |
| 497 | } |
| 498 | #endif |
| 499 | |
Simon Glass | 06fd853 | 2012-11-30 13:01:17 +0000 | [diff] [blame] | 500 | /************************************************************************ |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 501 | * |
| 502 | * This is the next part if the initialization sequence: we are now |
| 503 | * running from RAM and have a "normal" C environment, i. e. global |
| 504 | * data can be written, BSS has been cleared, the stack size in not |
| 505 | * that critical any more, etc. |
| 506 | * |
| 507 | ************************************************************************ |
| 508 | */ |
Albert Aribaud | 92d5ecb | 2010-10-11 13:13:28 +0200 | [diff] [blame] | 509 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 510 | void board_init_r(gd_t *id, ulong dest_addr) |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 511 | { |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 512 | ulong malloc_start; |
| 513 | #if !defined(CONFIG_SYS_NO_FLASH) |
| 514 | ulong flash_size; |
| 515 | #endif |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 516 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 517 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ |
Simon Glass | f933e84 | 2012-02-13 13:51:21 +0000 | [diff] [blame] | 518 | bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r"); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 519 | |
Albert ARIBAUD | b60eff3 | 2014-02-22 17:53:43 +0100 | [diff] [blame] | 520 | monitor_flash_len = (ulong)&__rel_dyn_end - (ulong)_start; |
Aneesh V | cba4b18 | 2011-08-16 04:33:05 +0000 | [diff] [blame] | 521 | |
| 522 | /* Enable caches */ |
| 523 | enable_caches(); |
Aneesh V | c2dd0d4 | 2011-06-16 23:30:49 +0000 | [diff] [blame] | 524 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 525 | debug("monitor flash len: %08lX\n", monitor_flash_len); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 526 | board_init(); /* Setup chipselects */ |
Hadli, Manjunath | 8f5d468 | 2012-02-06 00:30:44 +0000 | [diff] [blame] | 527 | /* |
| 528 | * TODO: printing of the clock inforamtion of the board is now |
| 529 | * implemented as part of bdinfo command. Currently only support for |
| 530 | * davinci SOC's is added. Remove this check once all the board |
| 531 | * implement this. |
| 532 | */ |
| 533 | #ifdef CONFIG_CLOCKS |
| 534 | set_cpu_clk_info(); /* Setup clock information */ |
| 535 | #endif |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 536 | serial_initialize(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 537 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 538 | debug("Now running in RAM - U-Boot at: %08lx\n", dest_addr); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 539 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 540 | #ifdef CONFIG_LOGBUFFER |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 541 | logbuff_init_ptrs(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 542 | #endif |
| 543 | #ifdef CONFIG_POST |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 544 | post_output_backlog(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 545 | #endif |
| 546 | |
| 547 | /* The Malloc area is immediately below the monitor copy in DRAM */ |
| 548 | malloc_start = dest_addr - TOTAL_MALLOC_LEN; |
| 549 | mem_malloc_init (malloc_start, TOTAL_MALLOC_LEN); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 550 | |
Fabio Estevam | d519b4b | 2012-04-02 11:19:45 +0000 | [diff] [blame] | 551 | #ifdef CONFIG_ARCH_EARLY_INIT_R |
| 552 | arch_early_init_r(); |
| 553 | #endif |
Łukasz Majewski | 2ffb4be | 2012-11-13 03:21:56 +0000 | [diff] [blame] | 554 | power_init_board(); |
Fabio Estevam | d519b4b | 2012-04-02 11:19:45 +0000 | [diff] [blame] | 555 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 556 | #if !defined(CONFIG_SYS_NO_FLASH) |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 557 | puts("Flash: "); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 558 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 559 | flash_size = flash_init(); |
| 560 | if (flash_size > 0) { |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 561 | # ifdef CONFIG_SYS_FLASH_CHECKSUM |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 562 | print_size(flash_size, ""); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 563 | /* |
| 564 | * Compute and print flash CRC if flashchecksum is set to 'y' |
| 565 | * |
| 566 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX |
| 567 | */ |
Joe Hershberger | ec8a252 | 2012-12-11 22:16:22 -0600 | [diff] [blame] | 568 | if (getenv_yesno("flashchecksum") == 1) { |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 569 | printf(" CRC: %08X", crc32(0, |
| 570 | (const unsigned char *) CONFIG_SYS_FLASH_BASE, |
| 571 | flash_size)); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 572 | } |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 573 | putc('\n'); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 574 | # else /* !CONFIG_SYS_FLASH_CHECKSUM */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 575 | print_size(flash_size, "\n"); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 576 | # endif /* CONFIG_SYS_FLASH_CHECKSUM */ |
| 577 | } else { |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 578 | puts(failed); |
| 579 | hang(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 580 | } |
| 581 | #endif |
| 582 | |
| 583 | #if defined(CONFIG_CMD_NAND) |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 584 | puts("NAND: "); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 585 | nand_init(); /* go init the NAND */ |
| 586 | #endif |
| 587 | |
| 588 | #if defined(CONFIG_CMD_ONENAND) |
| 589 | onenand_init(); |
| 590 | #endif |
| 591 | |
Steve Sakoman | d470a6f | 2010-10-11 05:51:39 -0700 | [diff] [blame] | 592 | #ifdef CONFIG_GENERIC_MMC |
Taylor Hutt | 80e4095 | 2012-11-30 13:01:23 +0000 | [diff] [blame] | 593 | puts("MMC: "); |
| 594 | mmc_initialize(gd->bd); |
Steve Sakoman | d470a6f | 2010-10-11 05:51:39 -0700 | [diff] [blame] | 595 | #endif |
| 596 | |
Ian Campbell | c6f3d50 | 2014-03-07 01:20:56 +0000 | [diff] [blame] | 597 | #ifdef CONFIG_CMD_SCSI |
| 598 | puts("SCSI: "); |
| 599 | scsi_init(); |
| 600 | #endif |
| 601 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 602 | #ifdef CONFIG_HAS_DATAFLASH |
| 603 | AT91F_DataflashInit(); |
| 604 | dataflash_print_info(); |
| 605 | #endif |
| 606 | |
| 607 | /* initialize environment */ |
Simon Glass | 06fd853 | 2012-11-30 13:01:17 +0000 | [diff] [blame] | 608 | if (should_load_env()) |
| 609 | env_relocate(); |
| 610 | else |
| 611 | set_default_env(NULL); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 612 | |
Michael Schwingen | 1ed63c5 | 2011-05-23 00:00:13 +0200 | [diff] [blame] | 613 | #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI) |
| 614 | arm_pci_init(); |
| 615 | #endif |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 616 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 617 | stdio_init(); /* get the devices list going. */ |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 618 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 619 | jumptable_init(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 620 | |
| 621 | #if defined(CONFIG_API) |
| 622 | /* Initialize API */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 623 | api_init(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 624 | #endif |
| 625 | |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 626 | console_init_r(); /* fully init console as a device */ |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 627 | |
Simon Glass | e2e3e2b | 2012-11-30 13:01:19 +0000 | [diff] [blame] | 628 | #ifdef CONFIG_DISPLAY_BOARDINFO_LATE |
| 629 | # ifdef CONFIG_OF_CONTROL |
| 630 | /* Put this here so it appears on the LCD, now it is ready */ |
| 631 | display_fdt_model(gd->fdt_blob); |
| 632 | # else |
| 633 | checkboard(); |
| 634 | # endif |
| 635 | #endif |
| 636 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 637 | #if defined(CONFIG_ARCH_MISC_INIT) |
| 638 | /* miscellaneous arch dependent initialisations */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 639 | arch_misc_init(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 640 | #endif |
| 641 | #if defined(CONFIG_MISC_INIT_R) |
| 642 | /* miscellaneous platform dependent initialisations */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 643 | misc_init_r(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 644 | #endif |
| 645 | |
Albert ARIBAUD | bd851c7 | 2013-11-08 22:37:33 +0100 | [diff] [blame] | 646 | /* set up exceptions */ |
| 647 | interrupt_init(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 648 | /* enable exceptions */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 649 | enable_interrupts(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 650 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 651 | /* Initialize from environment */ |
Simon Glass | dc8bbea | 2011-10-13 14:43:06 +0000 | [diff] [blame] | 652 | load_addr = getenv_ulong("loadaddr", 16, load_addr); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 653 | |
Helmut Raiger | 9660e44 | 2011-10-20 04:19:47 +0000 | [diff] [blame] | 654 | #ifdef CONFIG_BOARD_LATE_INIT |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 655 | board_late_init(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 656 | #endif |
| 657 | |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 658 | #ifdef CONFIG_BITBANGMII |
| 659 | bb_miiphy_init(); |
| 660 | #endif |
| 661 | #if defined(CONFIG_CMD_NET) |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 662 | puts("Net: "); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 663 | eth_initialize(gd->bd); |
| 664 | #if defined(CONFIG_RESET_PHY_R) |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 665 | debug("Reset Ethernet PHY\n"); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 666 | reset_phy(); |
| 667 | #endif |
| 668 | #endif |
| 669 | |
| 670 | #ifdef CONFIG_POST |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 671 | post_run(NULL, POST_RAM | post_bootmode_get(0)); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 672 | #endif |
| 673 | |
| 674 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) |
| 675 | /* |
| 676 | * Export available size of memory for Linux, |
| 677 | * taking into account the protected RAM at top of memory |
| 678 | */ |
| 679 | { |
Simon Glass | dc8bbea | 2011-10-13 14:43:06 +0000 | [diff] [blame] | 680 | ulong pram = 0; |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 681 | uchar memsz[32]; |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 682 | |
Simon Glass | dc8bbea | 2011-10-13 14:43:06 +0000 | [diff] [blame] | 683 | #ifdef CONFIG_PRAM |
| 684 | pram = getenv_ulong("pram", 10, CONFIG_PRAM); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 685 | #endif |
| 686 | #ifdef CONFIG_LOGBUFFER |
| 687 | #ifndef CONFIG_ALT_LB_ADDR |
| 688 | /* Also take the logbuffer into account (pram is in kB) */ |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 689 | pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024; |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 690 | #endif |
| 691 | #endif |
Heiko Schocher | b2b8f98 | 2011-06-02 22:11:37 +0000 | [diff] [blame] | 692 | sprintf((char *)memsz, "%ldk", (gd->ram_size / 1024) - pram); |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 693 | setenv("mem", (char *)memsz); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 694 | } |
| 695 | #endif |
| 696 | |
| 697 | /* main_loop() can return to retry autoboot, if so just run it again. */ |
| 698 | for (;;) { |
Heiko Schocher | ceb1d6d | 2011-07-15 19:36:36 +0000 | [diff] [blame] | 699 | main_loop(); |
Heiko Schocher | f1d2b31 | 2010-09-17 13:10:39 +0200 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | /* NOTREACHED - no way out of command loop except booting */ |
| 703 | } |