mmc: fix infinite loop in mmc_init_stream
[x-load.git] / lib / board.c
blob171cdaf7c915a515cc0793379b2e76b1abe2f865
1 /*
2 * Copyright (C) 2005 Texas Instruments.
4 * (C) Copyright 2004
5 * Jian Zhang, Texas Instruments, jzhang@ti.com.
7 * (C) Copyright 2002
8 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
10 * (C) Copyright 2002
11 * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
12 * Marius Groeger <mgroeger@sysgo.de>
14 * See file CREDITS for list of people who contributed to this
15 * project.
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License as
19 * published by the Free Software Foundation; either version 2 of
20 * the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 * MA 02111-1307 USA
33 #include <common.h>
34 #include <asm/arch/mem.h>
36 #ifdef CFG_PRINTF
37 int print_info(void)
39 printf("\n\nTexas Instruments X-Loader 1.41sms\n");
40 return 0;
42 #endif
44 typedef int (init_fnc_t) (void);
46 init_fnc_t *init_sequence[] = {
47 cpu_init, /* basic cpu dependent setup */
48 board_init, /* basic board dependent setup */
49 #ifdef CFG_PRINTF
50 serial_init, /* serial communications setup */
51 print_info,
52 #endif
53 nand_init, /* board specific nand init */
54 NULL,
57 void start_armboot (void)
59 init_fnc_t **init_fnc_ptr;
60 int i;
61 uchar *buf;
63 for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr) {
64 if ((*init_fnc_ptr)() != 0) {
65 hang ();
69 buf = (uchar*) CFG_LOADADDR;
71 #ifdef CONFIG_MMC
72 /* first try mmc */
73 buf += mmc_boot(buf);
74 #endif
76 if (buf == (uchar *)CFG_LOADADDR) {
77 /* if no u-boot on mmc, try onenand and nand */
78 if (get_mem_type() == GPMC_ONENAND){
79 #ifdef CFG_PRINTF
80 printf("Booting from onenand . . .\n");
81 #endif
82 for (i = ONENAND_START_BLOCK; i < ONENAND_END_BLOCK; i++){
83 if (!onenand_read_block(buf, i))
84 buf += ONENAND_BLOCK_SIZE;
88 if (get_mem_type() == GPMC_NAND){
89 #ifdef CFG_PRINTF
90 printf("Booting from nand . . .\n");
91 #endif
92 for (i = NAND_UBOOT_START; i < NAND_UBOOT_END; i+= NAND_BLOCK_SIZE){
93 if (!nand_read_block(buf, i))
94 buf += NAND_BLOCK_SIZE; /* advance buf ptr */
100 if (buf == (uchar *)CFG_LOADADDR)
101 hang();
103 /* go run U-Boot and never return */
104 printf("Starting OS Bootloader...\n");
105 ((init_fnc_t *)CFG_LOADADDR)();
107 /* should never come here */
110 void hang (void)
112 /* call board specific hang function */
113 board_hang();
115 /* if board_hang() returns, hange here */
116 printf("X-Loader hangs\n");
117 for (;;);