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