1 /* Copyright 2013 Freescale Semiconductor, Inc.
3 * SPDX-License-Identifier: GPL-2.0+
13 #include <fsl_esdhc.h>
14 #include <spi_flash.h>
15 #include "../common/qixis.h"
16 #include "t208xqds_qixis.h"
17 #include "../common/spl.h"
19 DECLARE_GLOBAL_DATA_PTR;
21 phys_size_t get_effective_memsize(void)
23 return CONFIG_SYS_L3_SIZE;
26 unsigned long get_board_sys_clk(void)
28 u8 sysclk_conf = QIXIS_READ(brdcfg[1]);
30 switch (sysclk_conf & 0x0F) {
33 case QIXIS_SYSCLK_100:
35 case QIXIS_SYSCLK_125:
37 case QIXIS_SYSCLK_133:
39 case QIXIS_SYSCLK_150:
41 case QIXIS_SYSCLK_160:
43 case QIXIS_SYSCLK_166:
49 unsigned long get_board_ddr_clk(void)
51 u8 ddrclk_conf = QIXIS_READ(brdcfg[1]);
53 switch ((ddrclk_conf & 0x30) >> 4) {
54 case QIXIS_DDRCLK_100:
56 case QIXIS_DDRCLK_125:
58 case QIXIS_DDRCLK_133:
64 void board_init_f(ulong bootflag)
66 u32 plat_ratio, sys_clk, ccb_clk;
67 ccsr_gur_t *gur = (void *)CONFIG_SYS_MPC85xx_GUTS_ADDR;
69 /* Memcpy existing GD at CONFIG_SPL_GD_ADDR */
70 memcpy((void *)CONFIG_SPL_GD_ADDR, (void *)gd, sizeof(gd_t));
72 /* Update GD pointer */
73 gd = (gd_t *)(CONFIG_SPL_GD_ADDR);
77 /* initialize selected port with appropriate baud rate */
78 sys_clk = get_board_sys_clk();
79 plat_ratio = (in_be32(&gur->rcwsr[0]) >> 25) & 0x1f;
80 ccb_clk = sys_clk * plat_ratio / 2;
82 NS16550_init((NS16550_t)CONFIG_SYS_NS16550_COM1,
83 ccb_clk / 16 / CONFIG_BAUDRATE);
85 #if defined(CONFIG_SPL_MMC_BOOT)
86 puts("\nSD boot...\n");
87 #elif defined(CONFIG_SPL_SPI_BOOT)
88 puts("\nSPI boot...\n");
89 #elif defined(CONFIG_SPL_NAND_BOOT)
90 puts("\nNAND boot...\n");
93 relocate_code(CONFIG_SPL_RELOC_STACK, (gd_t *)CONFIG_SPL_GD_ADDR, 0x0);
96 void board_init_r(gd_t *gd, ulong dest_addr)
100 bd = (bd_t *)(gd + sizeof(gd_t));
101 memset(bd, 0, sizeof(bd_t));
103 bd->bi_memstart = CONFIG_SYS_INIT_L3_ADDR;
104 bd->bi_memsize = CONFIG_SYS_L3_SIZE;
108 mem_malloc_init(CONFIG_SPL_RELOC_MALLOC_ADDR,
109 CONFIG_SPL_RELOC_MALLOC_SIZE);
110 gd->flags |= GD_FLG_FULL_MALLOC_INIT;
112 #ifdef CONFIG_SPL_NAND_BOOT
113 nand_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
114 (uchar *)CONFIG_ENV_ADDR);
116 #ifdef CONFIG_SPL_MMC_BOOT
118 mmc_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
119 (uchar *)CONFIG_ENV_ADDR);
121 #ifdef CONFIG_SPL_SPI_BOOT
122 fsl_spi_spl_load_image(CONFIG_ENV_OFFSET, CONFIG_ENV_SIZE,
123 (uchar *)CONFIG_ENV_ADDR);
126 gd->env_addr = (ulong)(CONFIG_ENV_ADDR);
133 #ifdef CONFIG_SPL_MMC_BOOT
135 #elif defined(CONFIG_SPL_SPI_BOOT)
137 #elif defined(CONFIG_SPL_NAND_BOOT)