1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#include <common.h>
32#include <stdio_dev.h>
33#include <watchdog.h>
34#include <malloc.h>
35#include <mmc.h>
36#include <net.h>
37#ifdef CONFIG_STATUS_LED
38#include <status_led.h>
39#endif
40#ifdef CONFIG_CMD_NAND
41#include <nand.h>
42#endif
43
44#include <timestamp.h>
45#include <version.h>
46
47DECLARE_GLOBAL_DATA_PTR;
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62extern int cache_init(void);
63
64
65
66
67static int (* const init_sequence[])(void) = {
68 cache_init,
69 timer_init,
70 env_init,
71 serial_init,
72 console_init_f,
73 display_options,
74 checkcpu,
75 checkboard,
76};
77
78
79
80void board_init(void)
81{
82 bd_t *bd;
83 int i;
84
85 gd = (gd_t *)CONFIG_SYS_GBL_DATA_ADDR;
86
87 memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE);
88
89 gd->bd = (bd_t *)(gd+1);
90 gd->baudrate = CONFIG_BAUDRATE;
91 gd->cpu_clk = CONFIG_SYS_CLK_FREQ;
92
93 bd = gd->bd;
94 bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
95 bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
96#ifndef CONFIG_SYS_NO_FLASH
97 bd->bi_flashstart = CONFIG_SYS_FLASH_BASE;
98#endif
99#if defined(CONFIG_SYS_SRAM_BASE) && defined(CONFIG_SYS_SRAM_SIZE)
100 bd->bi_sramstart = CONFIG_SYS_SRAM_BASE;
101 bd->bi_sramsize = CONFIG_SYS_SRAM_SIZE;
102#endif
103 bd->bi_baudrate = CONFIG_BAUDRATE;
104
105 for (i = 0; i < ARRAY_SIZE(init_sequence); i++) {
106 WATCHDOG_RESET();
107 if (init_sequence[i]())
108 hang();
109 }
110
111 WATCHDOG_RESET();
112
113
114 mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN);
115
116#ifndef CONFIG_SYS_NO_FLASH
117 WATCHDOG_RESET();
118 bd->bi_flashsize = flash_init();
119#endif
120
121#ifdef CONFIG_CMD_NAND
122 puts("NAND: ");
123 nand_init();
124#endif
125
126#ifdef CONFIG_GENERIC_MMC
127 puts("MMC: ");
128 mmc_initialize(bd);
129#endif
130
131 WATCHDOG_RESET();
132 env_relocate();
133
134 WATCHDOG_RESET();
135 stdio_init();
136 jumptable_init();
137 console_init_r();
138
139 WATCHDOG_RESET();
140 interrupt_init();
141
142#if defined(CONFIG_BOARD_LATE_INIT)
143 board_late_init();
144#endif
145
146#if defined(CONFIG_CMD_NET)
147 puts("NET: ");
148 eth_initialize(bd);
149#endif
150
151
152 for (;;) {
153 WATCHDOG_RESET();
154 main_loop();
155 }
156}
157
158
159
160
161void hang(void)
162{
163 disable_interrupts();
164 puts("### ERROR ### Please reset board ###\n");
165
166 for (;;)
167 ;
168}
169