1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2015 Freescale Semiconductor, Inc.
9 #include <clock_legacy.h>
11 #include <env_internal.h>
18 #include <fsl_esdhc.h>
23 #define FSL_CORENET_CCSR_PORSR1_RCW_MASK 0xFF800000
25 DECLARE_GLOBAL_DATA_PTR;
27 phys_size_t get_effective_memsize(void)
29 return CONFIG_SYS_L3_SIZE;
32 unsigned long get_board_sys_clk(void)
34 return CONFIG_SYS_CLK_FREQ;
37 unsigned long get_board_ddr_clk(void)
39 return CONFIG_DDR_CLK_FREQ;
42 void board_init_f(ulong bootflag)
44 u32 plat_ratio, sys_clk, ccb_clk;
45 ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
47 /* Memcpy existing GD at CONFIG_SPL_GD_ADDR */
48 memcpy((void *)CONFIG_SPL_GD_ADDR, (void *)gd, sizeof(gd_t));
50 /* Update GD pointer */
51 gd = (gd_t *)(CONFIG_SPL_GD_ADDR);
53 /* compiler optimization barrier needed for GCC >= 3.4 */
54 __asm__ __volatile__("" : : : "memory");
58 /* initialize selected port with appropriate baud rate */
59 sys_clk = get_board_sys_clk();
60 plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
61 ccb_clk = sys_clk * plat_ratio / 2;
63 NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
64 ccb_clk / 16 / CONFIG_BAUDRATE);
66 puts("\nSD boot...\n");
68 relocate_code(CONFIG_SPL_RELOC_STACK, (gd_t *)CONFIG_SPL_GD_ADDR, 0x0);
71 void board_init_r(gd_t *gd, ulong dest_addr)
75 bd = (struct bd_info *)(gd + sizeof(gd_t));
76 memset(bd, 0, sizeof(struct bd_info));
78 bd->bi_memstart = CONFIG_SYS_INIT_L3_ADDR;
79 bd->bi_memsize = CONFIG_SYS_L3_SIZE;
83 mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR,
84 CONFIG_SPL_RELOC_MALLOC_SIZE);
85 gd->flags |= GD_FLG_FULL_MALLOC_INIT;
88 mmc_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
89 (uchar *)SPL_ENV_ADDR);
91 gd->env_addr = (ulong)(SPL_ENV_ADDR);
92 gd->env_valid = ENV_VALID;