Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 1 | /* |
| 2 | * U-boot - board.c First C file to be called contains init routines |
| 3 | * |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 4 | * Copyright (c) 2005-2008 Analog Devices Inc. |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 5 | * |
| 6 | * (C) Copyright 2000-2004 |
| 7 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 8 | * |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 9 | * Licensed under the GPL-2 or later. |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #include <command.h> |
Jean-Christophe PLAGNIOL-VILLARD | 2a7a031 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 14 | #include <stdio_dev.h> |
Mike Frysinger | 53ba322 | 2011-04-29 23:23:28 -0400 | [diff] [blame] | 15 | #include <serial.h> |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 16 | #include <environment.h> |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 17 | #include <malloc.h> |
Cliff Cai | e463892 | 2009-11-20 08:24:43 +0000 | [diff] [blame] | 18 | #include <mmc.h> |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 19 | #include <net.h> |
Mike Frysinger | c6b978b | 2008-10-06 03:52:24 -0400 | [diff] [blame] | 20 | #include <status_led.h> |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 21 | #include <version.h> |
Sonic Zhang | 70b86bc | 2013-12-09 12:56:27 +0800 | [diff] [blame^] | 22 | #include <watchdog.h> |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 23 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 24 | #include <asm/cplb.h> |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 25 | #include <asm/mach-common/bits/mpu.h> |
Robin Getz | 230d001 | 2009-12-21 16:35:48 -0500 | [diff] [blame] | 26 | #include <kgdb.h> |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 27 | |
| 28 | #ifdef CONFIG_CMD_NAND |
| 29 | #include <nand.h> /* cannot even include nand.h if it isnt configured */ |
| 30 | #endif |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 31 | |
Luigi 'Comio' Mantellini | 01db155 | 2009-10-10 12:42:21 +0200 | [diff] [blame] | 32 | #ifdef CONFIG_BITBANGMII |
| 33 | #include <miiphy.h> |
| 34 | #endif |
| 35 | |
Mike Frysinger | 94bae5c | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 36 | #if defined(CONFIG_POST) |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 37 | #include <post.h> |
| 38 | int post_flag; |
| 39 | #endif |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 40 | |
Heiko Schocher | e0e55bc | 2012-01-16 21:12:24 +0000 | [diff] [blame] | 41 | #if defined(CONFIG_SYS_I2C) |
| 42 | #include <i2c.h> |
| 43 | #endif |
| 44 | |
Wolfgang Denk | d112a2c | 2007-09-15 20:48:41 +0200 | [diff] [blame] | 45 | DECLARE_GLOBAL_DATA_PTR; |
| 46 | |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 47 | __attribute__((always_inline)) |
| 48 | static inline void serial_early_puts(const char *s) |
| 49 | { |
| 50 | #ifdef CONFIG_DEBUG_EARLY_SERIAL |
| 51 | serial_puts("Early: "); |
| 52 | serial_puts(s); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 53 | #endif |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 54 | } |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 55 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 56 | static int display_banner(void) |
| 57 | { |
Mike Frysinger | 5b74f0b | 2011-06-30 18:26:39 -0400 | [diff] [blame] | 58 | display_options(); |
Mike Frysinger | 36e63df | 2010-08-09 17:39:22 -0400 | [diff] [blame] | 59 | printf("CPU: ADSP %s " |
Mike Frysinger | 7e1bbd8 | 2009-01-06 06:16:19 -0500 | [diff] [blame] | 60 | "(Detected Rev: 0.%d) " |
| 61 | "(%s boot)\n", |
Mike Frysinger | 36e63df | 2010-08-09 17:39:22 -0400 | [diff] [blame] | 62 | gd->bd->bi_cpu, |
Mike Frysinger | 7e1bbd8 | 2009-01-06 06:16:19 -0500 | [diff] [blame] | 63 | bfin_revid(), |
| 64 | get_bfin_boot_mode(CONFIG_BFIN_BOOT_MODE)); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 65 | return 0; |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 66 | } |
| 67 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 68 | static int init_baudrate(void) |
| 69 | { |
Simon Glass | 3d87f6b | 2011-10-13 14:43:08 +0000 | [diff] [blame] | 70 | gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE); |
Axel Lin | 06c8dc0 | 2013-07-01 13:16:17 +0800 | [diff] [blame] | 71 | gd->bd->bi_baudrate = gd->baudrate; |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 72 | return 0; |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 73 | } |
| 74 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 75 | static void display_global_data(void) |
| 76 | { |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 77 | bd_t *bd; |
Mike Frysinger | 188cd54 | 2010-01-19 15:39:07 -0500 | [diff] [blame] | 78 | |
| 79 | #ifndef CONFIG_DEBUG_EARLY_SERIAL |
| 80 | return; |
| 81 | #endif |
| 82 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 83 | bd = gd->bd; |
Mike Frysinger | 3429837 | 2009-08-24 19:03:18 -0400 | [diff] [blame] | 84 | printf(" gd: %p\n", gd); |
| 85 | printf(" |-flags: %lx\n", gd->flags); |
Simon Glass | bbeac16 | 2013-03-05 14:39:59 +0000 | [diff] [blame] | 86 | printf(" |-board_type: %lx\n", gd->arch.board_type); |
Simon Glass | 25c2bad | 2012-10-12 14:21:17 +0000 | [diff] [blame] | 87 | printf(" |-baudrate: %u\n", gd->baudrate); |
Mike Frysinger | 3429837 | 2009-08-24 19:03:18 -0400 | [diff] [blame] | 88 | printf(" |-have_console: %lx\n", gd->have_console); |
| 89 | printf(" |-ram_size: %lx\n", gd->ram_size); |
Mike Frysinger | 3429837 | 2009-08-24 19:03:18 -0400 | [diff] [blame] | 90 | printf(" |-env_addr: %lx\n", gd->env_addr); |
| 91 | printf(" |-env_valid: %lx\n", gd->env_valid); |
| 92 | printf(" |-jt(%p): %p\n", gd->jt, *(gd->jt)); |
| 93 | printf(" \\-bd: %p\n", gd->bd); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 94 | printf(" |-bi_baudrate: %x\n", bd->bi_baudrate); |
Mike Frysinger | 3429837 | 2009-08-24 19:03:18 -0400 | [diff] [blame] | 95 | printf(" |-bi_boot_params: %lx\n", bd->bi_boot_params); |
| 96 | printf(" |-bi_memstart: %lx\n", bd->bi_memstart); |
| 97 | printf(" |-bi_memsize: %lx\n", bd->bi_memsize); |
| 98 | printf(" |-bi_flashstart: %lx\n", bd->bi_flashstart); |
| 99 | printf(" |-bi_flashsize: %lx\n", bd->bi_flashsize); |
| 100 | printf(" \\-bi_flashoffset: %lx\n", bd->bi_flashoffset); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 101 | } |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 102 | |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 103 | #define CPLB_PAGE_SIZE (4 * 1024 * 1024) |
| 104 | #define CPLB_PAGE_MASK (~(CPLB_PAGE_SIZE - 1)) |
Bob Liu | 49334b8 | 2011-10-25 18:07:58 +0800 | [diff] [blame] | 105 | #if defined(__ADSPBF60x__) |
| 106 | #define CPLB_EX_PAGE_SIZE (16 * 1024 * 1024) |
| 107 | #define CPLB_EX_PAGE_MASK (~(CPLB_EX_PAGE_SIZE - 1)) |
| 108 | #else |
| 109 | #define CPLB_EX_PAGE_SIZE CPLB_PAGE_SIZE |
| 110 | #define CPLB_EX_PAGE_MASK CPLB_PAGE_MASK |
| 111 | #endif |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 112 | void init_cplbtables(void) |
| 113 | { |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 114 | volatile uint32_t *ICPLB_ADDR, *ICPLB_DATA; |
| 115 | volatile uint32_t *DCPLB_ADDR, *DCPLB_DATA; |
| 116 | uint32_t extern_memory; |
| 117 | size_t i; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 118 | |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 119 | void icplb_add(uint32_t addr, uint32_t data) |
| 120 | { |
| 121 | *(ICPLB_ADDR + i) = addr; |
| 122 | *(ICPLB_DATA + i) = data; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 123 | } |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 124 | void dcplb_add(uint32_t addr, uint32_t data) |
| 125 | { |
| 126 | *(DCPLB_ADDR + i) = addr; |
| 127 | *(DCPLB_DATA + i) = data; |
| 128 | } |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 129 | |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 130 | /* populate a few common entries ... we'll let |
| 131 | * the memory map and cplb exception handler do |
| 132 | * the rest of the work. |
| 133 | */ |
| 134 | i = 0; |
| 135 | ICPLB_ADDR = (uint32_t *)ICPLB_ADDR0; |
| 136 | ICPLB_DATA = (uint32_t *)ICPLB_DATA0; |
| 137 | DCPLB_ADDR = (uint32_t *)DCPLB_ADDR0; |
| 138 | DCPLB_DATA = (uint32_t *)DCPLB_DATA0; |
| 139 | |
| 140 | icplb_add(0xFFA00000, L1_IMEMORY); |
| 141 | dcplb_add(0xFF800000, L1_DMEMORY); |
| 142 | ++i; |
Bob Liu | 49334b8 | 2011-10-25 18:07:58 +0800 | [diff] [blame] | 143 | #if defined(__ADSPBF60x__) |
| 144 | icplb_add(0x0, 0x0); |
| 145 | dcplb_add(CONFIG_SYS_FLASH_BASE, SDRAM_EBIU); |
| 146 | ++i; |
| 147 | #endif |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 148 | |
Mike Frysinger | 4368ea2 | 2009-11-09 19:38:23 -0500 | [diff] [blame] | 149 | if (CONFIG_MEM_SIZE) { |
| 150 | uint32_t mbase = CONFIG_SYS_MONITOR_BASE; |
| 151 | uint32_t mend = mbase + CONFIG_SYS_MONITOR_LEN; |
| 152 | mbase &= CPLB_PAGE_MASK; |
| 153 | mend &= CPLB_PAGE_MASK; |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 154 | |
Mike Frysinger | 4368ea2 | 2009-11-09 19:38:23 -0500 | [diff] [blame] | 155 | icplb_add(mbase, SDRAM_IKERNEL); |
| 156 | dcplb_add(mbase, SDRAM_DKERNEL); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 157 | ++i; |
Mike Frysinger | 4368ea2 | 2009-11-09 19:38:23 -0500 | [diff] [blame] | 158 | |
| 159 | /* |
| 160 | * If the monitor crosses a 4 meg boundary, we'll need |
| 161 | * to lock two entries for it. We assume it doesn't |
| 162 | * cross two 4 meg boundaries ... |
| 163 | */ |
| 164 | if (mbase != mend) { |
| 165 | icplb_add(mend, SDRAM_IKERNEL); |
| 166 | dcplb_add(mend, SDRAM_DKERNEL); |
| 167 | ++i; |
| 168 | } |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 169 | } |
| 170 | |
Bob Liu | 49334b8 | 2011-10-25 18:07:58 +0800 | [diff] [blame] | 171 | #ifndef __ADSPBF60x__ |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 172 | icplb_add(0x20000000, SDRAM_INON_CHBL); |
| 173 | dcplb_add(0x20000000, SDRAM_EBIU); |
| 174 | ++i; |
Bob Liu | 49334b8 | 2011-10-25 18:07:58 +0800 | [diff] [blame] | 175 | #endif |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 176 | |
| 177 | /* Add entries for the rest of external RAM up to the bootrom */ |
| 178 | extern_memory = 0; |
| 179 | |
| 180 | #ifdef CONFIG_DEBUG_NULL_PTR |
| 181 | icplb_add(extern_memory, (SDRAM_IKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB); |
| 182 | dcplb_add(extern_memory, (SDRAM_DKERNEL & ~PAGE_SIZE_MASK) | PAGE_SIZE_1KB); |
| 183 | ++i; |
| 184 | icplb_add(extern_memory, SDRAM_IKERNEL); |
| 185 | dcplb_add(extern_memory, SDRAM_DKERNEL); |
| 186 | extern_memory += CPLB_PAGE_SIZE; |
| 187 | ++i; |
| 188 | #endif |
| 189 | |
Bob Liu | 49334b8 | 2011-10-25 18:07:58 +0800 | [diff] [blame] | 190 | while (i < 16 && extern_memory < |
| 191 | (CONFIG_SYS_MONITOR_BASE & CPLB_EX_PAGE_MASK)) { |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 192 | icplb_add(extern_memory, SDRAM_IGENERIC); |
| 193 | dcplb_add(extern_memory, SDRAM_DGENERIC); |
Bob Liu | 49334b8 | 2011-10-25 18:07:58 +0800 | [diff] [blame] | 194 | extern_memory += CPLB_EX_PAGE_SIZE; |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 195 | ++i; |
| 196 | } |
| 197 | while (i < 16) { |
| 198 | icplb_add(0, 0); |
| 199 | dcplb_add(0, 0); |
| 200 | ++i; |
| 201 | } |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 202 | } |
| 203 | |
Mike Frysinger | a067a5e | 2012-02-29 22:48:10 -0500 | [diff] [blame] | 204 | static int global_board_data_init(void) |
| 205 | { |
| 206 | #ifndef CONFIG_SYS_GBL_DATA_ADDR |
| 207 | # define CONFIG_SYS_GBL_DATA_ADDR 0 |
| 208 | #endif |
| 209 | #ifndef CONFIG_SYS_BD_INFO_ADDR |
| 210 | # define CONFIG_SYS_BD_INFO_ADDR 0 |
| 211 | #endif |
| 212 | |
| 213 | bd_t *bd; |
| 214 | |
| 215 | if (CONFIG_SYS_GBL_DATA_ADDR) { |
| 216 | gd = (gd_t *) (CONFIG_SYS_GBL_DATA_ADDR); |
| 217 | memset((void *)gd, 0, GENERATED_GBL_DATA_SIZE); |
| 218 | } else { |
| 219 | static gd_t _bfin_gd; |
| 220 | gd = &_bfin_gd; |
| 221 | } |
| 222 | |
| 223 | if (CONFIG_SYS_BD_INFO_ADDR) { |
| 224 | bd = (bd_t *) (CONFIG_SYS_BD_INFO_ADDR); |
| 225 | memset(bd, 0, GENERATED_BD_INFO_SIZE); |
| 226 | } else { |
| 227 | static bd_t _bfin_bd; |
| 228 | bd = &_bfin_bd; |
| 229 | } |
| 230 | gd->bd = bd; |
| 231 | |
| 232 | bd->bi_r_version = version_string; |
Marek Vasut | 0b3176c | 2012-09-23 17:41:24 +0200 | [diff] [blame] | 233 | bd->bi_cpu = __stringify(CONFIG_BFIN_CPU); |
Mike Frysinger | a067a5e | 2012-02-29 22:48:10 -0500 | [diff] [blame] | 234 | bd->bi_board_name = BFIN_BOARD_NAME; |
| 235 | bd->bi_vco = get_vco(); |
| 236 | bd->bi_cclk = get_cclk(); |
| 237 | bd->bi_sclk = get_sclk(); |
| 238 | bd->bi_memstart = CONFIG_SYS_SDRAM_BASE; |
| 239 | bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE; |
| 240 | |
| 241 | return 0; |
| 242 | } |
| 243 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 244 | /* |
| 245 | * All attempts to come up with a "common" initialization sequence |
| 246 | * that works for all boards and architectures failed: some of the |
| 247 | * requirements are just _too_ different. To get rid of the resulting |
| 248 | * mess of board dependend #ifdef'ed code we now make the whole |
| 249 | * initialization sequence configurable to the user. |
| 250 | * |
| 251 | * The requirements for any new initalization function is simple: it |
| 252 | * receives a pointer to the "global data" structure as it's only |
| 253 | * argument, and returns an integer return code, where 0 means |
| 254 | * "continue" and != 0 means "fatal error, hang the system". |
| 255 | */ |
| 256 | |
Mike Frysinger | 851b817 | 2010-02-11 20:19:10 -0500 | [diff] [blame] | 257 | extern int watchdog_init(void); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 258 | extern int exception_init(void); |
| 259 | extern int irq_init(void); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 260 | extern int timer_init(void); |
| 261 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 262 | void board_init_f(ulong bootflag) |
| 263 | { |
Mike Frysinger | a267207 | 2008-10-20 16:15:04 -0400 | [diff] [blame] | 264 | char buf[32]; |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 265 | |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 266 | #ifdef CONFIG_BOARD_EARLY_INIT_F |
| 267 | serial_early_puts("Board early init flash\n"); |
| 268 | board_early_init_f(); |
| 269 | #endif |
| 270 | |
| 271 | serial_early_puts("Init CPLB tables\n"); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 272 | init_cplbtables(); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 273 | |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 274 | serial_early_puts("Exceptions setup\n"); |
| 275 | exception_init(); |
| 276 | |
| 277 | #ifndef CONFIG_ICACHE_OFF |
| 278 | serial_early_puts("Turn on ICACHE\n"); |
| 279 | icache_enable(); |
| 280 | #endif |
| 281 | #ifndef CONFIG_DCACHE_OFF |
| 282 | serial_early_puts("Turn on DCACHE\n"); |
| 283 | dcache_enable(); |
| 284 | #endif |
| 285 | |
Sonic Zhang | cde8cef | 2013-04-07 18:02:37 +0800 | [diff] [blame] | 286 | #ifdef CONFIG_HW_WATCHDOG |
Mike Frysinger | 851b817 | 2010-02-11 20:19:10 -0500 | [diff] [blame] | 287 | serial_early_puts("Setting up external watchdog\n"); |
Sonic Zhang | cde8cef | 2013-04-07 18:02:37 +0800 | [diff] [blame] | 288 | hw_watchdog_init(); |
Mike Frysinger | 851b817 | 2010-02-11 20:19:10 -0500 | [diff] [blame] | 289 | #endif |
| 290 | |
Mike Frysinger | f93f030 | 2008-10-06 03:57:39 -0400 | [diff] [blame] | 291 | #ifdef DEBUG |
Wolfgang Denk | 0191e47 | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 292 | if (GENERATED_GBL_DATA_SIZE < sizeof(*gd)) |
Mike Frysinger | f93f030 | 2008-10-06 03:57:39 -0400 | [diff] [blame] | 293 | hang(); |
| 294 | #endif |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 295 | serial_early_puts("Init global data\n"); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 296 | |
Mike Frysinger | a067a5e | 2012-02-29 22:48:10 -0500 | [diff] [blame] | 297 | global_board_data_init(); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 298 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 299 | /* Initialize */ |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 300 | serial_early_puts("IRQ init\n"); |
Mike Frysinger | 94bae5c | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 301 | irq_init(); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 302 | serial_early_puts("Environment init\n"); |
| 303 | env_init(); |
| 304 | serial_early_puts("Baudrate init\n"); |
| 305 | init_baudrate(); |
| 306 | serial_early_puts("Serial init\n"); |
| 307 | serial_init(); |
Mike Frysinger | 53ba322 | 2011-04-29 23:23:28 -0400 | [diff] [blame] | 308 | serial_initialize(); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 309 | serial_early_puts("Console init flash\n"); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 310 | console_init_f(); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 311 | serial_early_puts("End of early debugging\n"); |
| 312 | display_banner(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 313 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 314 | checkboard(); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 315 | timer_init(); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 316 | |
Mike Frysinger | a267207 | 2008-10-20 16:15:04 -0400 | [diff] [blame] | 317 | printf("Clock: VCO: %s MHz, ", strmhz(buf, get_vco())); |
| 318 | printf("Core: %s MHz, ", strmhz(buf, get_cclk())); |
Sonic Zhang | a99f03e | 2012-08-16 11:56:14 +0800 | [diff] [blame] | 319 | #if defined(__ADSPBF60x__) |
| 320 | printf("System0: %s MHz, ", strmhz(buf, get_sclk0())); |
| 321 | printf("System1: %s MHz, ", strmhz(buf, get_sclk1())); |
| 322 | printf("Dclk: %s MHz\n", strmhz(buf, get_dclk())); |
| 323 | #else |
Mike Frysinger | a267207 | 2008-10-20 16:15:04 -0400 | [diff] [blame] | 324 | printf("System: %s MHz\n", strmhz(buf, get_sclk())); |
Sonic Zhang | a99f03e | 2012-08-16 11:56:14 +0800 | [diff] [blame] | 325 | #endif |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 326 | |
Mike Frysinger | 20ea997 | 2010-12-20 05:18:55 -0500 | [diff] [blame] | 327 | if (CONFIG_MEM_SIZE) { |
| 328 | printf("RAM: "); |
Mike Frysinger | a067a5e | 2012-02-29 22:48:10 -0500 | [diff] [blame] | 329 | print_size(gd->bd->bi_memsize, "\n"); |
Mike Frysinger | 20ea997 | 2010-12-20 05:18:55 -0500 | [diff] [blame] | 330 | } |
| 331 | |
Mike Frysinger | 94bae5c | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 332 | #if defined(CONFIG_POST) |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 333 | post_init_f(); |
| 334 | post_bootmode_init(); |
| 335 | post_run(NULL, POST_ROM | post_bootmode_get(0)); |
| 336 | #endif |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 337 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 338 | board_init_r((gd_t *) gd, 0x20000010); |
| 339 | } |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 340 | |
Mike Frysinger | e434b9f | 2009-02-22 16:02:27 -0500 | [diff] [blame] | 341 | static void board_net_init_r(bd_t *bd) |
| 342 | { |
Luigi 'Comio' Mantellini | 01db155 | 2009-10-10 12:42:21 +0200 | [diff] [blame] | 343 | #ifdef CONFIG_BITBANGMII |
| 344 | bb_miiphy_init(); |
| 345 | #endif |
Mike Frysinger | e434b9f | 2009-02-22 16:02:27 -0500 | [diff] [blame] | 346 | #ifdef CONFIG_CMD_NET |
Mike Frysinger | e434b9f | 2009-02-22 16:02:27 -0500 | [diff] [blame] | 347 | printf("Net: "); |
Mike Frysinger | 36fe7db | 2012-04-04 18:53:41 +0000 | [diff] [blame] | 348 | eth_initialize(bd); |
Mike Frysinger | e434b9f | 2009-02-22 16:02:27 -0500 | [diff] [blame] | 349 | #endif |
| 350 | } |
| 351 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 352 | void board_init_r(gd_t * id, ulong dest_addr) |
| 353 | { |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 354 | bd_t *bd; |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 355 | gd = id; |
| 356 | gd->flags |= GD_FLG_RELOC; /* tell others: relocation done */ |
| 357 | bd = gd->bd; |
| 358 | |
Mike Frysinger | 94bae5c | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 359 | #if defined(CONFIG_POST) |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 360 | post_output_backlog(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 361 | #endif |
| 362 | |
Stefan Roese | b81464e | 2009-05-11 15:50:12 +0200 | [diff] [blame] | 363 | /* initialize malloc() area */ |
Peter Tyser | ed52770 | 2009-08-21 23:05:20 -0500 | [diff] [blame] | 364 | mem_malloc_init(CONFIG_SYS_MALLOC_BASE, CONFIG_SYS_MALLOC_LEN); |
Stefan Roese | b81464e | 2009-05-11 15:50:12 +0200 | [diff] [blame] | 365 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 366 | #if !defined(CONFIG_SYS_NO_FLASH) |
Mike Frysinger | 0dc765f | 2008-10-06 04:00:07 -0400 | [diff] [blame] | 367 | /* Initialize the flash and protect u-boot by default */ |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 368 | extern flash_info_t flash_info[]; |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 369 | puts("Flash: "); |
Mike Frysinger | d1c68c1 | 2008-10-06 04:01:26 -0400 | [diff] [blame] | 370 | ulong size = flash_init(); |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 371 | print_size(size, "\n"); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 372 | flash_protect(FLAG_PROTECT_SET, CONFIG_SYS_FLASH_BASE, |
Mike Frysinger | 0dc765f | 2008-10-06 04:00:07 -0400 | [diff] [blame] | 373 | CONFIG_SYS_FLASH_BASE + CONFIG_SYS_MONITOR_LEN - 1, |
| 374 | &flash_info[0]); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 375 | bd->bi_flashstart = CONFIG_SYS_FLASH_BASE; |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 376 | bd->bi_flashsize = size; |
| 377 | bd->bi_flashoffset = 0; |
| 378 | #else |
| 379 | bd->bi_flashstart = 0; |
| 380 | bd->bi_flashsize = 0; |
| 381 | bd->bi_flashoffset = 0; |
| 382 | #endif |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 383 | |
Mike Frysinger | 392bc55 | 2008-10-06 03:55:25 -0400 | [diff] [blame] | 384 | #ifdef CONFIG_CMD_NAND |
| 385 | puts("NAND: "); |
| 386 | nand_init(); /* go init the NAND */ |
| 387 | #endif |
| 388 | |
Cliff Cai | e463892 | 2009-11-20 08:24:43 +0000 | [diff] [blame] | 389 | #ifdef CONFIG_GENERIC_MMC |
Mike Frysinger | d9548e3 | 2010-09-29 14:46:42 -0400 | [diff] [blame] | 390 | puts("MMC: "); |
Cliff Cai | e463892 | 2009-11-20 08:24:43 +0000 | [diff] [blame] | 391 | mmc_initialize(bd); |
| 392 | #endif |
| 393 | |
Heiko Schocher | e0e55bc | 2012-01-16 21:12:24 +0000 | [diff] [blame] | 394 | #if defined(CONFIG_SYS_I2C) |
| 395 | i2c_reloc_fixup(); |
| 396 | #endif |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 397 | /* relocate environment function pointers etc. */ |
| 398 | env_relocate(); |
| 399 | |
Jean-Christophe PLAGNIOL-VILLARD | 2a7a031 | 2009-05-16 12:14:54 +0200 | [diff] [blame] | 400 | /* Initialize stdio devices */ |
| 401 | stdio_init(); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 402 | jumptable_init(); |
| 403 | |
| 404 | /* Initialize the console (after the relocation and devices init) */ |
| 405 | console_init_r(); |
| 406 | |
Robin Getz | 230d001 | 2009-12-21 16:35:48 -0500 | [diff] [blame] | 407 | #ifdef CONFIG_CMD_KGDB |
| 408 | puts("KGDB: "); |
| 409 | kgdb_init(); |
| 410 | #endif |
| 411 | |
Mike Frysinger | c6b978b | 2008-10-06 03:52:24 -0400 | [diff] [blame] | 412 | #ifdef CONFIG_STATUS_LED |
| 413 | status_led_set(STATUS_LED_BOOT, STATUS_LED_BLINKING); |
| 414 | status_led_set(STATUS_LED_CRASH, STATUS_LED_OFF); |
| 415 | #endif |
| 416 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 417 | /* Initialize from environment */ |
Simon Glass | 3d87f6b | 2011-10-13 14:43:08 +0000 | [diff] [blame] | 418 | load_addr = getenv_ulong("loadaddr", 16, load_addr); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 419 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 420 | #if defined(CONFIG_MISC_INIT_R) |
| 421 | /* miscellaneous platform dependent initialisations */ |
| 422 | misc_init_r(); |
| 423 | #endif |
| 424 | |
Mike Frysinger | e434b9f | 2009-02-22 16:02:27 -0500 | [diff] [blame] | 425 | board_net_init_r(bd); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 426 | |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 427 | display_global_data(); |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 428 | |
Mike Frysinger | 94bae5c | 2008-03-30 15:46:13 -0400 | [diff] [blame] | 429 | #if defined(CONFIG_POST) |
Aubrey.Li | 9da597f | 2007-03-09 13:38:44 +0800 | [diff] [blame] | 430 | if (post_flag) |
| 431 | post_run(NULL, POST_RAM | post_bootmode_get(0)); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 432 | #endif |
| 433 | |
Mike Frysinger | 7edbbfa | 2010-12-24 13:19:25 -0500 | [diff] [blame] | 434 | if (CONFIG_MEM_SIZE && bfin_os_log_check()) { |
Mike Frysinger | 0897589 | 2009-07-09 01:15:05 -0400 | [diff] [blame] | 435 | puts("\nLog buffer from operating system:\n"); |
| 436 | bfin_os_log_dump(); |
| 437 | puts("\n"); |
| 438 | } |
| 439 | |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 440 | /* main_loop() can return to retry autoboot, if so just run it again. */ |
Mike Frysinger | 6a67532 | 2008-02-19 00:54:20 -0500 | [diff] [blame] | 441 | for (;;) |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 442 | main_loop(); |
Wolfgang Denk | 97caf67 | 2006-03-12 02:12:27 +0100 | [diff] [blame] | 443 | } |