blob: 3d31d41a4f6de59b70628ac8e2ca78e4f897e216 [file] [log] [blame]
Po Liueb6b4582014-01-10 10:10:59 +08001/* Copyright 2013 Freescale Semiconductor, Inc.
2 *
3 * SPDX-License-Identifier: GPL-2.0+
4 */
5
6#include <common.h>
Simon Glass24b852a2015-11-08 23:47:45 -07007#include <console.h>
Po Liueb6b4582014-01-10 10:10:59 +08008#include <ns16550.h>
9#include <malloc.h>
10#include <mmc.h>
11#include <nand.h>
12#include <i2c.h>
13
14DECLARE_GLOBAL_DATA_PTR;
15
York Sune3866162014-02-11 11:57:26 -080016phys_size_t get_effective_memsize(void)
Po Liueb6b4582014-01-10 10:10:59 +080017{
18 return CONFIG_SYS_L2_SIZE;
19}
20
21void board_init_f(ulong bootflag)
22{
23 u32 plat_ratio;
24 ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
25
26 console_init_f();
27
28 /* initialize selected port with appropriate baud rate */
29 plat_ratio = in_be32(&gur->porpllsr) & MPC85xx_PORPLLSR_PLAT_RATIO;
30 plat_ratio >>= 1;
31 gd->bus_clk = CONFIG_SYS_CLK_FREQ * plat_ratio;
32
33 NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
34 gd->bus_clk / 16 / CONFIG_BAUDRATE);
35
36 /* copy code to RAM and jump to it - this should not return */
37 /* NOTE - code has to be copied out of NAND buffer before
38 * other blocks can be read.
39 */
40 relocate_code(CONFIG_SPL_RELOC_STACK, 0, CONFIG_SPL_RELOC_TEXT_BASE);
41}
42
43void board_init_r(gd_t *gd, ulong dest_addr)
44{
45 /* Pointer is writable since we allocated a register for it */
46 gd = (gd_t *)CONFIG_SPL_GD_ADDR;
47 bd_t *bd;
48
49 memset(gd, 0, sizeof(gd_t));
50 bd = (bd_t *)(CONFIG_SPL_GD_ADDR + sizeof(gd_t));
51 memset(bd, 0, sizeof(bd_t));
52 gd->bd = bd;
53 bd->bi_memstart = CONFIG_SYS_INIT_L2_ADDR;
54 bd->bi_memsize = CONFIG_SYS_L2_SIZE;
55
56 probecpu();
57 get_clocks();
58 mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR,
59 CONFIG_SPL_RELOC_MALLOC_SIZE);
60
61 /* relocate environment function pointers etc. */
62 nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
63 (uchar *)CONFIG_ENV_ADDR);
64 gd->env_addr = (ulong)(CONFIG_ENV_ADDR);
65 gd->env_valid = 1;
66
67 i2c_init_all();
68
69 gd->ram_size = initdram(0);
70
71#ifdef CONFIG_SPL_NAND_BOOT
72 puts("TPL\n");
73#else
74 puts("SPL\n");
75#endif
76
77 nand_boot();
78}