]>
Commit | Line | Data |
---|---|---|
6f6430d7 SG |
1 | /* |
2 | * Copyright (c) 2011 The Chromium OS Authors. | |
3 | * (C) Copyright 2002-2006 | |
4 | * Wolfgang Denk, DENX Software Engineering, [email protected]. | |
5 | * | |
6 | * (C) Copyright 2002 | |
7 | * Sysgo Real-Time Solutions, GmbH <www.elinos.com> | |
8 | * Marius Groeger <[email protected]> | |
9 | * | |
10 | * See file CREDITS for list of people who contributed to this | |
11 | * project. | |
12 | * | |
13 | * This program is free software; you can redistribute it and/or | |
14 | * modify it under the terms of the GNU General Public License as | |
15 | * published by the Free Software Foundation; either version 2 of | |
16 | * the License, or (at your option) any later version. | |
17 | * | |
18 | * This program is distributed in the hope that it will be useful, | |
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | * GNU General Public License for more details. | |
22 | * | |
23 | * You should have received a copy of the GNU General Public License | |
24 | * along with this program; if not, write to the Free Software | |
25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, | |
26 | * MA 02111-1307 USA | |
27 | */ | |
28 | ||
29 | #include <common.h> | |
c2240d4d SG |
30 | /* TODO: can we just include all these headers whether needed or not? */ |
31 | #if defined(CONFIG_CMD_BEDBUG) | |
32 | #include <bedbug/type.h> | |
33 | #endif | |
6f6430d7 SG |
34 | #ifdef CONFIG_HAS_DATAFLASH |
35 | #include <dataflash.h> | |
36 | #endif | |
37 | #include <environment.h> | |
38 | #include <fdtdec.h> | |
c2240d4d SG |
39 | #if defined(CONFIG_CMD_IDE) |
40 | #include <ide.h> | |
41 | #endif | |
6f6430d7 | 42 | #include <initcall.h> |
c2240d4d SG |
43 | #ifdef CONFIG_PS2KBD |
44 | #include <keyboard.h> | |
45 | #endif | |
46 | #if defined(CONFIG_CMD_KGDB) | |
47 | #include <kgdb.h> | |
48 | #endif | |
6f6430d7 SG |
49 | #include <logbuff.h> |
50 | #include <malloc.h> | |
c2240d4d SG |
51 | #ifdef CONFIG_BITBANGMII |
52 | #include <miiphy.h> | |
53 | #endif | |
6f6430d7 SG |
54 | #include <mmc.h> |
55 | #include <nand.h> | |
56 | #include <onenand_uboot.h> | |
c2240d4d | 57 | #include <scsi.h> |
6f6430d7 | 58 | #include <serial.h> |
c2240d4d | 59 | #include <spi.h> |
6f6430d7 | 60 | #include <stdio_dev.h> |
c2240d4d SG |
61 | #include <watchdog.h> |
62 | #ifdef CONFIG_ADDR_MAP | |
63 | #include <asm/mmu.h> | |
64 | #endif | |
6f6430d7 | 65 | #include <asm/sections.h> |
be274b99 SG |
66 | #ifdef CONFIG_X86 |
67 | #include <asm/init_helpers.h> | |
68 | #endif | |
c2240d4d | 69 | #include <linux/compiler.h> |
6f6430d7 SG |
70 | |
71 | DECLARE_GLOBAL_DATA_PTR; | |
72 | ||
73 | ulong monitor_flash_len; | |
74 | ||
c2240d4d SG |
75 | int __board_flash_wp_on(void) |
76 | { | |
77 | /* | |
78 | * Most flashes can't be detected when write protection is enabled, | |
79 | * so provide a way to let U-Boot gracefully ignore write protected | |
80 | * devices. | |
81 | */ | |
82 | return 0; | |
83 | } | |
84 | ||
85 | int board_flash_wp_on(void) | |
86 | __attribute__ ((weak, alias("__board_flash_wp_on"))); | |
87 | ||
88 | void __cpu_secondary_init_r(void) | |
89 | { | |
90 | } | |
91 | ||
92 | void cpu_secondary_init_r(void) | |
93 | __attribute__ ((weak, alias("__cpu_secondary_init_r"))); | |
94 | ||
95 | static int initr_secondary_cpu(void) | |
96 | { | |
97 | /* | |
98 | * after non-volatile devices & environment is setup and cpu code have | |
99 | * another round to deal with any initialization that might require | |
100 | * full access to the environment or loading of some image (firmware) | |
101 | * from a non-volatile device | |
102 | */ | |
103 | /* TODO: maybe define this for all archs? */ | |
104 | cpu_secondary_init_r(); | |
105 | ||
106 | return 0; | |
107 | } | |
6f6430d7 SG |
108 | |
109 | static int initr_reloc(void) | |
110 | { | |
111 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ | |
112 | bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_R, "board_init_r"); | |
113 | ||
114 | return 0; | |
115 | } | |
116 | ||
117 | #ifdef CONFIG_ARM | |
118 | /* | |
119 | * Some of these functions are needed purely because the functions they | |
120 | * call return void. If we change them to return 0, these stubs can go away. | |
121 | */ | |
122 | static int initr_caches(void) | |
123 | { | |
124 | /* Enable caches */ | |
125 | enable_caches(); | |
126 | return 0; | |
127 | } | |
128 | #endif | |
129 | ||
c2240d4d SG |
130 | __weak int fixup_cpu(void) |
131 | { | |
132 | return 0; | |
133 | } | |
134 | ||
6f6430d7 SG |
135 | static int initr_reloc_global_data(void) |
136 | { | |
137 | #ifdef CONFIG_SYS_SYM_OFFSETS | |
138 | monitor_flash_len = _end_ofs; | |
a733b06b | 139 | #elif !defined(CONFIG_SANDBOX) |
6f6430d7 SG |
140 | monitor_flash_len = (ulong)&__init_end - gd->dest_addr; |
141 | #endif | |
c2240d4d SG |
142 | #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC86xx) |
143 | /* | |
144 | * The gd->cpu pointer is set to an address in flash before relocation. | |
145 | * We need to update it to point to the same CPU entry in RAM. | |
146 | * TODO: why not just add gd->reloc_ofs? | |
147 | */ | |
148 | gd->arch.cpu += gd->dest_addr - CONFIG_SYS_MONITOR_BASE; | |
149 | ||
150 | /* | |
151 | * If we didn't know the cpu mask & # cores, we can save them of | |
152 | * now rather than 'computing' them constantly | |
153 | */ | |
154 | fixup_cpu(); | |
155 | #endif | |
156 | #ifdef CONFIG_SYS_EXTRA_ENV_RELOC | |
157 | /* | |
158 | * Some systems need to relocate the env_addr pointer early because the | |
159 | * location it points to will get invalidated before env_relocate is | |
160 | * called. One example is on systems that might use a L2 or L3 cache | |
161 | * in SRAM mode and initialize that cache from SRAM mode back to being | |
162 | * a cache in cpu_init_r. | |
163 | */ | |
164 | gd->env_addr += gd->dest_addr - CONFIG_SYS_MONITOR_BASE; | |
165 | #endif | |
166 | return 0; | |
6f6430d7 SG |
167 | } |
168 | ||
169 | static int initr_serial(void) | |
170 | { | |
171 | serial_initialize(); | |
172 | return 0; | |
173 | } | |
174 | ||
c2240d4d SG |
175 | #ifdef CONFIG_PPC |
176 | static int initr_trap(void) | |
177 | { | |
178 | /* | |
179 | * Setup trap handlers | |
180 | */ | |
181 | trap_init(gd->dest_addr); | |
182 | ||
183 | return 0; | |
184 | } | |
185 | #endif | |
186 | ||
187 | #ifdef CONFIG_ADDR_MAP | |
188 | static int initr_addr_map(void) | |
189 | { | |
190 | init_addr_map(); | |
191 | ||
192 | return 0; | |
193 | } | |
194 | #endif | |
195 | ||
6f6430d7 SG |
196 | #ifdef CONFIG_LOGBUFFER |
197 | unsigned long logbuffer_base(void) | |
198 | { | |
199 | return gd->ram_top - LOGBUFF_LEN; | |
200 | } | |
201 | ||
202 | static int initr_logbuffer(void) | |
203 | { | |
204 | logbuff_init_ptrs(); | |
205 | return 0; | |
206 | } | |
207 | #endif | |
208 | ||
209 | #ifdef CONFIG_POST | |
210 | static int initr_post_backlog(void) | |
211 | { | |
212 | post_output_backlog(); | |
213 | return 0; | |
214 | } | |
215 | #endif | |
216 | ||
c2240d4d SG |
217 | #ifdef CONFIG_SYS_DELAYED_ICACHE |
218 | static int initr_icache_enable(void) | |
219 | { | |
220 | return 0; | |
221 | } | |
222 | #endif | |
223 | ||
224 | #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) | |
225 | static int initr_unlock_ram_in_cache(void) | |
226 | { | |
227 | unlock_ram_in_cache(); /* it's time to unlock D-cache in e500 */ | |
228 | return 0; | |
229 | } | |
230 | #endif | |
231 | ||
232 | #ifdef CONFIG_PCI | |
233 | static int initr_pci(void) | |
234 | { | |
235 | pci_init(); | |
236 | ||
237 | return 0; | |
238 | } | |
239 | #endif | |
240 | ||
241 | #ifdef CONFIG_WINBOND_83C553 | |
242 | static int initr_w83c553f(void) | |
243 | { | |
244 | /* | |
245 | * Initialise the ISA bridge | |
246 | */ | |
247 | initialise_w83c553f(); | |
248 | return 0; | |
249 | } | |
250 | #endif | |
251 | ||
252 | static int initr_barrier(void) | |
253 | { | |
254 | #ifdef CONFIG_PPC | |
255 | /* TODO: Can we not use dmb() macros for this? */ | |
256 | asm("sync ; isync"); | |
257 | #endif | |
258 | return 0; | |
259 | } | |
260 | ||
6f6430d7 SG |
261 | static int initr_malloc(void) |
262 | { | |
263 | ulong malloc_start; | |
264 | ||
265 | /* The malloc area is immediately below the monitor copy in DRAM */ | |
266 | malloc_start = gd->dest_addr - TOTAL_MALLOC_LEN; | |
a733b06b SG |
267 | mem_malloc_init((ulong)map_sysmem(malloc_start, TOTAL_MALLOC_LEN), |
268 | TOTAL_MALLOC_LEN); | |
6f6430d7 SG |
269 | return 0; |
270 | } | |
271 | ||
272 | __weak int power_init_board(void) | |
273 | { | |
274 | return 0; | |
275 | } | |
276 | ||
277 | static int initr_announce(void) | |
278 | { | |
279 | debug("Now running in RAM - U-Boot at: %08lx\n", gd->dest_addr); | |
280 | return 0; | |
281 | } | |
282 | ||
283 | #if !defined(CONFIG_SYS_NO_FLASH) | |
284 | static int initr_flash(void) | |
285 | { | |
c2240d4d SG |
286 | ulong flash_size = 0; |
287 | bd_t *bd = gd->bd; | |
288 | int ok; | |
6f6430d7 SG |
289 | |
290 | puts("Flash: "); | |
291 | ||
c2240d4d SG |
292 | if (board_flash_wp_on()) { |
293 | printf("Uninitialized - Write Protect On\n"); | |
294 | /* Since WP is on, we can't find real size. Set to 0 */ | |
295 | ok = 1; | |
296 | } else { | |
297 | flash_size = flash_init(); | |
298 | ok = flash_size > 0; | |
299 | } | |
300 | if (!ok) { | |
6f6430d7 | 301 | puts("*** failed ***\n"); |
c2240d4d SG |
302 | #ifdef CONFIG_PPC |
303 | /* Why does PPC do this? */ | |
304 | hang(); | |
305 | #endif | |
6f6430d7 SG |
306 | return -1; |
307 | } | |
308 | print_size(flash_size, ""); | |
309 | #ifdef CONFIG_SYS_FLASH_CHECKSUM | |
310 | /* | |
311 | * Compute and print flash CRC if flashchecksum is set to 'y' | |
312 | * | |
313 | * NOTE: Maybe we should add some WATCHDOG_RESET()? XXX | |
314 | */ | |
315 | if (getenv_yesno("flashchecksum") == 1) { | |
316 | printf(" CRC: %08X", crc32(0, | |
317 | (const unsigned char *) CONFIG_SYS_FLASH_BASE, | |
318 | flash_size)); | |
319 | } | |
320 | #endif /* CONFIG_SYS_FLASH_CHECKSUM */ | |
321 | putc('\n'); | |
322 | ||
c2240d4d SG |
323 | /* update start of FLASH memory */ |
324 | #ifdef CONFIG_SYS_FLASH_BASE | |
325 | bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; | |
326 | #endif | |
327 | /* size of FLASH memory (final value) */ | |
328 | bd->bi_flashsize = flash_size; | |
329 | ||
330 | #if defined(CONFIG_SYS_UPDATE_FLASH_SIZE) | |
331 | /* Make a update of the Memctrl. */ | |
332 | update_flash_size(flash_size); | |
333 | #endif | |
334 | ||
335 | ||
336 | #if defined(CONFIG_OXC) || defined(CONFIG_RMU) | |
337 | /* flash mapped at end of memory map */ | |
338 | bd->bi_flashoffset = CONFIG_SYS_TEXT_BASE + flash_size; | |
339 | #elif CONFIG_SYS_MONITOR_BASE == CONFIG_SYS_FLASH_BASE | |
340 | bd->bi_flashoffset = monitor_flash_len; /* reserved area for monitor */ | |
341 | #endif | |
342 | return 0; | |
343 | } | |
344 | #endif | |
345 | ||
346 | #ifdef CONFIG_PPC | |
347 | static int initr_spi(void) | |
348 | { | |
349 | /* PPC does this here */ | |
350 | #ifdef CONFIG_SPI | |
351 | #if !defined(CONFIG_ENV_IS_IN_EEPROM) | |
352 | spi_init_f(); | |
353 | #endif | |
354 | spi_init_r(); | |
355 | #endif | |
6f6430d7 SG |
356 | return 0; |
357 | } | |
358 | #endif | |
359 | ||
360 | #ifdef CONFIG_CMD_NAND | |
361 | /* go init the NAND */ | |
362 | int initr_nand(void) | |
363 | { | |
364 | puts("NAND: "); | |
365 | nand_init(); | |
366 | return 0; | |
367 | } | |
368 | #endif | |
369 | ||
370 | #if defined(CONFIG_CMD_ONENAND) | |
371 | /* go init the NAND */ | |
372 | int initr_onenand(void) | |
373 | { | |
374 | puts("NAND: "); | |
375 | onenand_init(); | |
376 | return 0; | |
377 | } | |
378 | #endif | |
379 | ||
380 | #ifdef CONFIG_GENERIC_MMC | |
381 | int initr_mmc(void) | |
382 | { | |
383 | puts("MMC: "); | |
384 | mmc_initialize(gd->bd); | |
385 | return 0; | |
386 | } | |
387 | #endif | |
388 | ||
389 | #ifdef CONFIG_HAS_DATAFLASH | |
390 | int initr_dataflash(void) | |
391 | { | |
392 | AT91F_DataflashInit(); | |
393 | dataflash_print_info(); | |
394 | return 0; | |
395 | } | |
396 | #endif | |
397 | ||
398 | /* | |
399 | * Tell if it's OK to load the environment early in boot. | |
400 | * | |
401 | * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see | |
402 | * if this is OK (defaulting to saying it's OK). | |
403 | * | |
404 | * NOTE: Loading the environment early can be a bad idea if security is | |
405 | * important, since no verification is done on the environment. | |
406 | * | |
407 | * @return 0 if environment should not be loaded, !=0 if it is ok to load | |
408 | */ | |
409 | static int should_load_env(void) | |
410 | { | |
411 | #ifdef CONFIG_OF_CONTROL | |
412 | return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 1); | |
413 | #elif defined CONFIG_DELAY_ENVIRONMENT | |
414 | return 0; | |
415 | #else | |
416 | return 1; | |
417 | #endif | |
418 | } | |
419 | ||
420 | static int initr_env(void) | |
421 | { | |
422 | /* initialize environment */ | |
423 | if (should_load_env()) | |
424 | env_relocate(); | |
425 | else | |
426 | set_default_env(NULL); | |
427 | ||
428 | /* Initialize from environment */ | |
429 | load_addr = getenv_ulong("loadaddr", 16, load_addr); | |
c2240d4d SG |
430 | #if defined(CONFIG_SYS_EXTBDINFO) |
431 | #if defined(CONFIG_405GP) || defined(CONFIG_405EP) | |
432 | #if defined(CONFIG_I2CFAST) | |
433 | /* | |
434 | * set bi_iic_fast for linux taking environment variable | |
435 | * "i2cfast" into account | |
436 | */ | |
437 | { | |
438 | char *s = getenv("i2cfast"); | |
439 | ||
440 | if (s && ((*s == 'y') || (*s == 'Y'))) { | |
441 | gd->bd->bi_iic_fast[0] = 1; | |
442 | gd->bd->bi_iic_fast[1] = 1; | |
443 | } | |
444 | } | |
445 | #endif /* CONFIG_I2CFAST */ | |
446 | #endif /* CONFIG_405GP, CONFIG_405EP */ | |
447 | #endif /* CONFIG_SYS_EXTBDINFO */ | |
448 | return 0; | |
449 | } | |
450 | ||
451 | #ifdef CONFIG_HERMES | |
452 | static int initr_hermes(void) | |
453 | { | |
454 | if ((gd->board_type >> 16) == 2) | |
455 | gd->bd->bi_ethspeed = gd->board_type & 0xFFFF; | |
456 | else | |
457 | gd->bd->bi_ethspeed = 0xFFFF; | |
458 | return 0; | |
459 | } | |
460 | ||
461 | static int initr_hermes_start(void) | |
462 | { | |
463 | if (gd->bd->bi_ethspeed != 0xFFFF) | |
464 | hermes_start_lxt980((int) gd->bd->bi_ethspeed); | |
6f6430d7 SG |
465 | return 0; |
466 | } | |
c2240d4d SG |
467 | #endif |
468 | ||
469 | #ifdef CONFIG_SC3 | |
470 | /* TODO: with new initcalls, move this into the driver */ | |
471 | extern void sc3_read_eeprom(void); | |
472 | ||
473 | static int initr_sc3_read_eeprom(void) | |
474 | { | |
475 | sc3_read_eeprom(); | |
476 | return 0; | |
477 | } | |
478 | #endif | |
6f6430d7 SG |
479 | |
480 | static int initr_jumptable(void) | |
481 | { | |
482 | jumptable_init(); | |
483 | return 0; | |
484 | } | |
485 | ||
486 | #if defined(CONFIG_API) | |
487 | static int initr_api(void) | |
488 | { | |
489 | /* Initialize API */ | |
490 | api_init(); | |
491 | return 0; | |
492 | } | |
493 | #endif | |
494 | ||
495 | #ifdef CONFIG_DISPLAY_BOARDINFO_LATE | |
496 | static int show_model_r(void) | |
497 | { | |
498 | /* Put this here so it appears on the LCD, now it is ready */ | |
499 | # ifdef CONFIG_OF_CONTROL | |
500 | const char *model; | |
501 | ||
502 | model = (char *)fdt_getprop(gd->fdt_blob, 0, "model", NULL); | |
503 | printf("Model: %s\n", model ? model : "<unknown>"); | |
504 | # else | |
505 | checkboard(); | |
506 | # endif | |
507 | } | |
508 | #endif | |
509 | ||
510 | /* enable exceptions */ | |
e424c15c | 511 | #ifdef CONFIG_ARM |
6f6430d7 SG |
512 | static int initr_enable_interrupts(void) |
513 | { | |
514 | enable_interrupts(); | |
515 | return 0; | |
516 | } | |
e424c15c | 517 | #endif |
6f6430d7 SG |
518 | |
519 | #ifdef CONFIG_CMD_NET | |
520 | static int initr_ethaddr(void) | |
521 | { | |
c2240d4d SG |
522 | bd_t *bd = gd->bd; |
523 | ||
524 | /* kept around for legacy kernels only ... ignore the next section */ | |
525 | eth_getenv_enetaddr("ethaddr", bd->bi_enetaddr); | |
526 | #ifdef CONFIG_HAS_ETH1 | |
527 | eth_getenv_enetaddr("eth1addr", bd->bi_enet1addr); | |
528 | #endif | |
529 | #ifdef CONFIG_HAS_ETH2 | |
530 | eth_getenv_enetaddr("eth2addr", bd->bi_enet2addr); | |
531 | #endif | |
532 | #ifdef CONFIG_HAS_ETH3 | |
533 | eth_getenv_enetaddr("eth3addr", bd->bi_enet3addr); | |
534 | #endif | |
535 | #ifdef CONFIG_HAS_ETH4 | |
536 | eth_getenv_enetaddr("eth4addr", bd->bi_enet4addr); | |
537 | #endif | |
538 | #ifdef CONFIG_HAS_ETH5 | |
539 | eth_getenv_enetaddr("eth5addr", bd->bi_enet5addr); | |
540 | #endif | |
541 | return 0; | |
542 | } | |
543 | #endif /* CONFIG_CMD_NET */ | |
544 | ||
545 | #ifdef CONFIG_CMD_KGDB | |
546 | static int initr_kgdb(void) | |
547 | { | |
548 | puts("KGDB: "); | |
549 | kgdb_init(); | |
550 | return 0; | |
551 | } | |
552 | #endif | |
553 | ||
554 | #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) | |
555 | static int initr_status_led(void) | |
556 | { | |
557 | status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); | |
558 | ||
559 | return 0; | |
560 | } | |
561 | #endif | |
562 | ||
563 | #if defined(CONFIG_CMD_SCSI) | |
564 | static int initr_scsi(void) | |
565 | { | |
566 | /* Not supported properly on ARM yet */ | |
567 | #ifndef CONFIG_ARM | |
568 | puts("SCSI: "); | |
569 | scsi_init(); | |
570 | #endif | |
6f6430d7 SG |
571 | |
572 | return 0; | |
573 | } | |
574 | #endif /* CONFIG_CMD_NET */ | |
575 | ||
c2240d4d SG |
576 | #if defined(CONFIG_CMD_DOC) |
577 | static int initr_doc(void) | |
578 | { | |
579 | puts("DOC: "); | |
580 | doc_init(); | |
581 | } | |
582 | #endif | |
583 | ||
6f6430d7 SG |
584 | #ifdef CONFIG_BITBANGMII |
585 | static int initr_bbmii(void) | |
586 | { | |
587 | bb_miiphy_init(); | |
588 | return 0; | |
589 | } | |
590 | #endif | |
591 | ||
592 | #ifdef CONFIG_CMD_NET | |
593 | static int initr_net(void) | |
594 | { | |
595 | puts("Net: "); | |
596 | eth_initialize(gd->bd); | |
597 | #if defined(CONFIG_RESET_PHY_R) | |
598 | debug("Reset Ethernet PHY\n"); | |
599 | reset_phy(); | |
600 | #endif | |
601 | return 0; | |
602 | } | |
603 | #endif | |
604 | ||
605 | #ifdef CONFIG_POST | |
606 | static int initr_post(void) | |
607 | { | |
608 | post_run(NULL, POST_RAM | post_bootmode_get(0)); | |
609 | return 0; | |
610 | } | |
611 | #endif | |
612 | ||
c2240d4d SG |
613 | #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE) |
614 | static int initr_pcmcia(void) | |
615 | { | |
616 | puts("PCMCIA:"); | |
617 | pcmcia_init(); | |
618 | return 0; | |
619 | } | |
620 | #endif | |
621 | ||
622 | #if defined(CONFIG_CMD_IDE) | |
623 | static int initr_ide(void) | |
624 | { | |
625 | #ifdef CONFIG_IDE_8xx_PCCARD | |
626 | puts("PCMCIA:"); | |
627 | #else | |
628 | puts("IDE: "); | |
629 | #endif | |
630 | #if defined(CONFIG_START_IDE) | |
631 | if (board_start_ide()) | |
632 | ide_init(); | |
633 | #else | |
634 | ide_init(); | |
635 | #endif | |
636 | return 0; | |
637 | } | |
638 | #endif | |
639 | ||
6f6430d7 SG |
640 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) |
641 | /* | |
642 | * Export available size of memory for Linux, taking into account the | |
643 | * protected RAM at top of memory | |
644 | */ | |
645 | int initr_mem(void) | |
646 | { | |
647 | ulong pram = 0; | |
648 | char memsz[32]; | |
649 | ||
650 | # ifdef CONFIG_PRAM | |
651 | pram = getenv_ulong("pram", 10, CONFIG_PRAM); | |
652 | # endif | |
653 | # if defined(CONFIG_LOGBUFFER) && !defined(CONFIG_ALT_LB_ADDR) | |
654 | /* Also take the logbuffer into account (pram is in kB) */ | |
655 | pram += (LOGBUFF_LEN + LOGBUFF_OVERHEAD) / 1024; | |
656 | # endif | |
657 | sprintf(memsz, "%ldk", (gd->ram_size / 1024) - pram); | |
658 | setenv("mem", memsz); | |
c2240d4d SG |
659 | |
660 | return 0; | |
661 | } | |
662 | #endif | |
663 | ||
664 | #ifdef CONFIG_CMD_BEDBUG | |
665 | static int initr_bedbug(void) | |
666 | { | |
667 | bedbug_init(); | |
668 | ||
669 | return 0; | |
670 | } | |
671 | #endif | |
672 | ||
673 | #ifdef CONFIG_PS2KBD | |
674 | static int initr_kbd(void) | |
675 | { | |
676 | puts("PS/2: "); | |
677 | kbd_init(); | |
678 | return 0; | |
679 | } | |
680 | #endif | |
681 | ||
682 | #ifdef CONFIG_MODEM_SUPPORT | |
683 | static int initr_modem(void) | |
684 | { | |
685 | /* TODO: with new initcalls, move this into the driver */ | |
686 | extern int do_mdm_init; | |
687 | ||
688 | do_mdm_init = gd->do_mdm_init; | |
689 | return 0; | |
6f6430d7 SG |
690 | } |
691 | #endif | |
692 | ||
693 | static int run_main_loop(void) | |
694 | { | |
a733b06b SG |
695 | #ifdef CONFIG_SANDBOX |
696 | sandbox_main_loop_init(); | |
697 | #endif | |
6f6430d7 SG |
698 | /* main_loop() can return to retry autoboot, if so just run it again */ |
699 | for (;;) | |
700 | main_loop(); | |
701 | return 0; | |
702 | } | |
703 | ||
704 | /* | |
705 | * Over time we hope to remove these functions with code fragments and | |
706 | * stub funtcions, and instead call the relevant function directly. | |
707 | * | |
708 | * We also hope to remove most of the driver-related init and do it if/when | |
709 | * the driver is later used. | |
c2240d4d SG |
710 | * |
711 | * TODO: perhaps reset the watchdog in the initcall function after each call? | |
6f6430d7 SG |
712 | */ |
713 | init_fnc_t init_sequence_r[] = { | |
714 | initr_reloc, | |
c2240d4d | 715 | /* TODO: could x86/PPC have this also perhaps? */ |
6f6430d7 SG |
716 | #ifdef CONFIG_ARM |
717 | initr_caches, | |
718 | board_init, /* Setup chipselects */ | |
c2240d4d SG |
719 | #endif |
720 | /* | |
721 | * TODO: printing of the clock inforamtion of the board is now | |
722 | * implemented as part of bdinfo command. Currently only support for | |
723 | * davinci SOC's is added. Remove this check once all the board | |
724 | * implement this. | |
725 | */ | |
726 | #ifdef CONFIG_CLOCKS | |
727 | set_cpu_clk_info, /* Setup clock information */ | |
6f6430d7 SG |
728 | #endif |
729 | initr_reloc_global_data, | |
730 | initr_serial, | |
731 | initr_announce, | |
c2240d4d SG |
732 | INIT_FUNC_WATCHDOG_RESET |
733 | #ifdef CONFIG_PPC | |
734 | initr_trap, | |
735 | #endif | |
736 | #ifdef CONFIG_ADDR_MAP | |
737 | initr_addr_map, | |
738 | #endif | |
739 | #if defined(CONFIG_BOARD_EARLY_INIT_R) | |
740 | board_early_init_r, | |
741 | #endif | |
742 | INIT_FUNC_WATCHDOG_RESET | |
6f6430d7 SG |
743 | #ifdef CONFIG_LOGBUFFER |
744 | initr_logbuffer, | |
745 | #endif | |
746 | #ifdef CONFIG_POST | |
747 | initr_post_backlog, | |
748 | #endif | |
c2240d4d SG |
749 | INIT_FUNC_WATCHDOG_RESET |
750 | #ifdef CONFIG_SYS_DELAYED_ICACHE | |
751 | initr_icache_enable, | |
752 | #endif | |
753 | #if defined(CONFIG_SYS_INIT_RAM_LOCK) && defined(CONFIG_E500) | |
754 | initr_unlock_ram_in_cache, | |
755 | #endif | |
756 | #if defined(CONFIG_PCI) && defined(CONFIG_SYS_EARLY_PCI_INIT) | |
757 | /* | |
758 | * Do early PCI configuration _before_ the flash gets initialised, | |
759 | * because PCU ressources are crucial for flash access on some boards. | |
760 | */ | |
761 | initr_pci, | |
762 | #endif | |
763 | #ifdef CONFIG_WINBOND_83C553 | |
764 | initr_w83c553f, | |
765 | #endif | |
766 | initr_barrier, | |
6f6430d7 SG |
767 | initr_malloc, |
768 | #ifdef CONFIG_ARCH_EARLY_INIT_R | |
769 | arch_early_init_r, | |
770 | #endif | |
771 | power_init_board, | |
772 | #ifndef CONFIG_SYS_NO_FLASH | |
773 | initr_flash, | |
c2240d4d SG |
774 | #endif |
775 | INIT_FUNC_WATCHDOG_RESET | |
be274b99 | 776 | #if defined(CONFIG_PPC) || defined(CONFIG_X86) |
c2240d4d SG |
777 | /* initialize higher level parts of CPU like time base and timers */ |
778 | cpu_init_r, | |
be274b99 SG |
779 | #endif |
780 | #ifdef CONFIG_PPC | |
c2240d4d | 781 | initr_spi, |
6f6430d7 | 782 | #endif |
be274b99 SG |
783 | #if defined(CONFIG_X86) && defined(CONFIG_SPI) |
784 | init_func_spi, | |
785 | #endif | |
6f6430d7 SG |
786 | #ifdef CONFIG_CMD_NAND |
787 | initr_nand, | |
788 | #endif | |
789 | #ifdef CONFIG_CMD_ONENAND | |
790 | initr_onenand, | |
791 | #endif | |
792 | #ifdef CONFIG_GENERIC_MMC | |
793 | initr_mmc, | |
794 | #endif | |
795 | #ifdef CONFIG_HAS_DATAFLASH | |
796 | initr_dataflash, | |
797 | #endif | |
798 | initr_env, | |
c2240d4d SG |
799 | INIT_FUNC_WATCHDOG_RESET |
800 | initr_secondary_cpu, | |
801 | #ifdef CONFIG_SC3 | |
802 | initr_sc3_read_eeprom, | |
803 | #endif | |
804 | #ifdef CONFIG_HERMES | |
805 | initr_hermes, | |
806 | #endif | |
807 | #if defined(CONFIG_ID_EEPROM) || defined(CONFIG_SYS_I2C_MAC_OFFSET) | |
808 | mac_read_from_eeprom, | |
809 | #endif | |
810 | INIT_FUNC_WATCHDOG_RESET | |
811 | #if defined(CONFIG_PCI) && !defined(CONFIG_SYS_EARLY_PCI_INIT) | |
812 | /* | |
813 | * Do pci configuration | |
814 | */ | |
815 | initr_pci, | |
816 | #endif | |
6f6430d7 SG |
817 | stdio_init, |
818 | initr_jumptable, | |
819 | #ifdef CONFIG_API | |
820 | initr_api, | |
821 | #endif | |
822 | console_init_r, /* fully init console as a device */ | |
823 | #ifdef CONFIG_DISPLAY_BOARDINFO_LATE | |
824 | show_model_r, | |
825 | #endif | |
826 | #ifdef CONFIG_ARCH_MISC_INIT | |
827 | arch_misc_init, /* miscellaneous arch-dependent init */ | |
828 | #endif | |
829 | #ifdef CONFIG_MISC_INIT_R | |
830 | misc_init_r, /* miscellaneous platform-dependent init */ | |
c2240d4d SG |
831 | #endif |
832 | #ifdef CONFIG_HERMES | |
833 | initr_hermes_start, | |
834 | #endif | |
835 | INIT_FUNC_WATCHDOG_RESET | |
836 | #ifdef CONFIG_CMD_KGDB | |
837 | initr_kgdb, | |
be274b99 SG |
838 | #endif |
839 | #ifdef CONFIG_X86 | |
840 | board_early_init_r, | |
6f6430d7 SG |
841 | #endif |
842 | interrupt_init, | |
be274b99 | 843 | #if defined(CONFIG_ARM) || defined(CONFIG_x86) |
6f6430d7 | 844 | initr_enable_interrupts, |
c2240d4d | 845 | #endif |
be274b99 SG |
846 | #ifdef CONFIG_X86 |
847 | timer_init, /* initialize timer */ | |
848 | #endif | |
c2240d4d SG |
849 | #if defined(CONFIG_STATUS_LED) && defined(STATUS_LED_BOOT) |
850 | initr_status_led, | |
851 | #endif | |
852 | /* PPC has a udelay(20) here dating from 2002. Why? */ | |
6f6430d7 SG |
853 | #ifdef CONFIG_CMD_NET |
854 | initr_ethaddr, | |
855 | #endif | |
856 | #ifdef CONFIG_BOARD_LATE_INIT | |
857 | board_late_init, | |
858 | #endif | |
c2240d4d SG |
859 | #ifdef CONFIG_CMD_SCSI |
860 | INIT_FUNC_WATCHDOG_RESET | |
861 | initr_scsi, | |
862 | #endif | |
863 | #ifdef CONFIG_CMD_DOC | |
864 | INIT_FUNC_WATCHDOG_RESET | |
865 | initr_doc, | |
866 | #endif | |
6f6430d7 SG |
867 | #ifdef CONFIG_BITBANGMII |
868 | initr_bbmii, | |
869 | #endif | |
870 | #ifdef CONFIG_CMD_NET | |
c2240d4d | 871 | INIT_FUNC_WATCHDOG_RESET |
6f6430d7 SG |
872 | initr_net, |
873 | #endif | |
874 | #ifdef CONFIG_POST | |
875 | initr_post, | |
c2240d4d SG |
876 | #endif |
877 | #if defined(CONFIG_CMD_PCMCIA) && !defined(CONFIG_CMD_IDE) | |
878 | initr_pcmcia, | |
879 | #endif | |
880 | #if defined(CONFIG_CMD_IDE) | |
881 | initr_ide, | |
882 | #endif | |
883 | #ifdef CONFIG_LAST_STAGE_INIT | |
884 | INIT_FUNC_WATCHDOG_RESET | |
885 | /* | |
886 | * Some parts can be only initialized if all others (like | |
887 | * Interrupts) are up and running (i.e. the PC-style ISA | |
888 | * keyboard). | |
889 | */ | |
890 | last_stage_init, | |
891 | #endif | |
892 | #ifdef CONFIG_CMD_BEDBUG | |
893 | INIT_FUNC_WATCHDOG_RESET | |
894 | initr_bedbug, | |
895 | #endif | |
896 | #if defined(CONFIG_PRAM) || defined(CONFIG_LOGBUFFER) | |
897 | initr_mem, | |
898 | #endif | |
899 | #ifdef CONFIG_PS2KBD | |
900 | initr_kbd, | |
901 | #endif | |
902 | #ifdef CONFIG_MODEM_SUPPORT | |
903 | initr_modem, | |
6f6430d7 SG |
904 | #endif |
905 | run_main_loop, | |
906 | }; | |
907 | ||
908 | void board_init_r(gd_t *new_gd, ulong dest_addr) | |
909 | { | |
be274b99 | 910 | #ifndef CONFIG_X86 |
6f6430d7 | 911 | gd = new_gd; |
be274b99 | 912 | #endif |
6f6430d7 SG |
913 | if (initcall_run_list(init_sequence_r)) |
914 | hang(); | |
915 | ||
916 | /* NOTREACHED - run_main_loop() does not return */ | |
917 | hang(); | |
918 | } |