1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2018 Technexion Ltd.
5 * Author: Richard Hu <richard.hu@technexion.com>
8 #include <asm/arch/imx-regs.h>
9 #include <asm/arch/crm_regs.h>
10 #include <asm/arch/sys_proto.h>
11 #include <asm/arch-mx7/mx7-ddr.h>
15 #if defined(CONFIG_SPL_BUILD)
17 #ifdef CONFIG_SPL_OS_BOOT
18 int spl_start_uboot(void)
24 static struct ddrc ddrc_regs_val = {
26 .rfshtmg = 0x00400046,
32 .rankctl = 0x0000033F,
33 .dramtmg0 = 0x09081109,
34 .dramtmg1 = 0x0007020d,
35 .dramtmg2 = 0x03040407,
36 .dramtmg3 = 0x00002006,
37 .dramtmg4 = 0x04020205,
38 .dramtmg5 = 0x03030202,
39 .dramtmg8 = 0x00000803,
41 .dfitmg0 = 0x02098204,
42 .dfitmg1 = 0x00030303,
43 .dfiupd0 = 0x80400003,
44 .dfiupd1 = 0x00100020,
45 .dfiupd2 = 0x80100004,
46 .addrmap4 = 0x00000F0F,
49 .rfshtmg = 0x00400046,
50 .dramtmg0 = 0x09081109,
51 .addrmap0 = 0x0000001f,
52 .addrmap1 = 0x00080808,
53 .addrmap4 = 0x00000f0f,
54 .addrmap5 = 0x07070707,
55 .addrmap6 = 0x0f0f0707,
58 static struct ddrc_mp ddrc_mp_val = {
59 .pctrl_0 = 0x00000001,
62 static struct ddr_phy ddr_phy_regs_val = {
63 .phy_con0 = 0x17420f40,
64 .phy_con1 = 0x10210100,
65 .phy_con4 = 0x00060807,
66 .mdll_con0 = 0x1010007e,
67 .drvds_con0 = 0x00000d6e,
68 .cmd_sdll_con0 = 0x00000010,
69 .offset_lp_con0 = 0x0000000f,
70 .offset_rd_con0 = 0x08080808,
71 .offset_wr_con0 = 0x08080808,
74 static struct mx7_calibration calib_param = {
85 static void gpr_init(void)
87 struct iomuxc_gpr_base_regs *gpr_regs =
88 (struct iomuxc_gpr_base_regs *)IOMUXC_GPR_BASE_ADDR;
89 writel(0x4F400005, &gpr_regs->gpr[1]);
92 static bool is_1g(void)
94 gpio_direction_input(IMX_GPIO_NR(1, 12));
95 return !gpio_get_value(IMX_GPIO_NR(1, 12));
98 static void ddr_init(void)
101 ddrc_regs_val.addrmap6 = 0x0f070707;
103 mx7_dram_cfg(&ddrc_regs_val, &ddrc_mp_val, &ddr_phy_regs_val,
107 void board_init_f(ulong dummy)
111 board_early_init_f();
113 preloader_console_init();
115 memset(__bss_start, 0, __bss_end - __bss_start);
116 board_init_r(NULL, 0);
119 void reset_cpu(ulong addr)