1 // SPDX-License-Identifier: GPL-2.0+
2 /* Copyright 2013 Freescale Semiconductor, Inc.
6 #include <clock_legacy.h>
8 #include <env_internal.h>
15 #include <fsl_esdhc.h>
16 #include <spi_flash.h>
17 #include <asm/global_data.h>
18 #include "../common/spl.h"
20 DECLARE_GLOBAL_DATA_PTR;
22 phys_size_t get_effective_memsize(void)
24 return CONFIG_SYS_L3_SIZE;
27 void board_init_f(ulong bootflag)
29 u32 plat_ratio, sys_clk, ccb_clk;
30 ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
32 /* Memcpy existing GD at CONFIG_SPL_GD_ADDR */
33 memcpy((void *)CONFIG_SPL_GD_ADDR, (void *)gd, sizeof(gd_t));
35 /* Update GD pointer */
36 gd = (gd_t *)(CONFIG_SPL_GD_ADDR);
40 /* initialize selected port with appropriate baud rate */
41 sys_clk = get_board_sys_clk();
42 plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
43 ccb_clk = sys_clk * plat_ratio / 2;
45 ns16550_init((struct ns16550 *)CONFIG_SYS_NS16550_COM1,
46 ccb_clk / 16 / CONFIG_BAUDRATE);
48 #if defined(CONFIG_SPL_MMC_BOOT)
49 puts("\nSD boot...\n");
50 #elif defined(CONFIG_SPL_SPI_BOOT)
51 puts("\nSPI boot...\n");
52 #elif defined(CONFIG_SPL_NAND_BOOT)
53 puts("\nNAND boot...\n");
56 relocate_code(CONFIG_SPL_RELOC_STACK, (gd_t *)CONFIG_SPL_GD_ADDR, 0x0);
59 void board_init_r(gd_t *gd, ulong dest_addr)
63 bd = (struct bd_info *)(gd + sizeof(gd_t));
64 memset(bd, 0, sizeof(struct bd_info));
69 mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR,
70 CONFIG_SPL_RELOC_MALLOC_SIZE);
71 gd->flags |= GD_FLG_FULL_MALLOC_INIT;
73 #ifdef CONFIG_SPL_NAND_BOOT
74 nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
75 (uchar *)SPL_ENV_ADDR);
77 #ifdef CONFIG_SPL_MMC_BOOT
79 mmc_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
80 (uchar *)SPL_ENV_ADDR);
82 #ifdef CONFIG_SPL_SPI_BOOT
83 fsl_spi_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
84 (uchar *)SPL_ENV_ADDR);
87 gd->env_addr = (ulong)(SPL_ENV_ADDR);
88 gd->env_valid = ENV_VALID;
94 #ifdef CONFIG_SPL_MMC_BOOT
96 #elif defined(CONFIG_SPL_SPI_BOOT)
98 #elif defined(CONFIG_SPL_NAND_BOOT)