1
2
3
4
5
6
7
8#include <common.h>
9#include <init.h>
10#include <serial.h>
11#include <spl.h>
12#include <linux/delay.h>
13
14#include <asm/io.h>
15#include <linux/sizes.h>
16
17#include <asm/arch/clock.h>
18#include <asm/arch/crm_regs.h>
19#include <asm/arch/iomux.h>
20#include <asm/arch/mx6-ddr.h>
21#include <asm/arch/mx6-pins.h>
22#include <asm/arch/sys_proto.h>
23
24DECLARE_GLOBAL_DATA_PTR;
25
26#define IMX6SDL_DRIVE_STRENGTH 0x28
27#define UART_PAD_CTRL (PAD_CTL_PUS_100K_UP | PAD_CTL_SPEED_MED | \
28 PAD_CTL_DSE_40ohm | PAD_CTL_SRE_FAST | PAD_CTL_HYS)
29
30static iomux_v3_cfg_t const uart3_pads[] = {
31 IOMUX_PADS(PAD_EIM_D24__UART3_TX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
32 IOMUX_PADS(PAD_EIM_D25__UART3_RX_DATA | MUX_PAD_CTRL(UART_PAD_CTRL)),
33};
34
35#ifdef CONFIG_SPL_OS_BOOT
36int spl_start_uboot(void)
37{
38
39 if (serial_tstc() && serial_getc() == 'c')
40 return 1;
41
42 return 0;
43}
44#endif
45
46struct mx6sdl_iomux_ddr_regs mx6sdl_ddr_ioregs = {
47 .dram_sdclk_0 = IMX6SDL_DRIVE_STRENGTH,
48 .dram_sdclk_1 = IMX6SDL_DRIVE_STRENGTH,
49 .dram_cas = IMX6SDL_DRIVE_STRENGTH,
50 .dram_ras = IMX6SDL_DRIVE_STRENGTH,
51 .dram_reset = IMX6SDL_DRIVE_STRENGTH,
52 .dram_sdcke0 = IMX6SDL_DRIVE_STRENGTH,
53 .dram_sdcke1 = IMX6SDL_DRIVE_STRENGTH,
54 .dram_sdba2 = 0x00000000,
55 .dram_sdodt0 = IMX6SDL_DRIVE_STRENGTH,
56 .dram_sdodt1 = IMX6SDL_DRIVE_STRENGTH,
57 .dram_sdqs0 = IMX6SDL_DRIVE_STRENGTH,
58 .dram_sdqs1 = IMX6SDL_DRIVE_STRENGTH,
59 .dram_sdqs2 = IMX6SDL_DRIVE_STRENGTH,
60 .dram_sdqs3 = IMX6SDL_DRIVE_STRENGTH,
61 .dram_sdqs4 = IMX6SDL_DRIVE_STRENGTH,
62 .dram_sdqs5 = IMX6SDL_DRIVE_STRENGTH,
63 .dram_sdqs6 = IMX6SDL_DRIVE_STRENGTH,
64 .dram_sdqs7 = IMX6SDL_DRIVE_STRENGTH,
65 .dram_dqm0 = IMX6SDL_DRIVE_STRENGTH,
66 .dram_dqm1 = IMX6SDL_DRIVE_STRENGTH,
67 .dram_dqm2 = IMX6SDL_DRIVE_STRENGTH,
68 .dram_dqm3 = IMX6SDL_DRIVE_STRENGTH,
69 .dram_dqm4 = IMX6SDL_DRIVE_STRENGTH,
70 .dram_dqm5 = IMX6SDL_DRIVE_STRENGTH,
71 .dram_dqm6 = IMX6SDL_DRIVE_STRENGTH,
72 .dram_dqm7 = IMX6SDL_DRIVE_STRENGTH,
73};
74
75struct mx6sdl_iomux_grp_regs mx6sdl_grp_ioregs = {
76 .grp_ddr_type = 0x000c0000,
77 .grp_ddrmode_ctl = 0x00020000,
78 .grp_ddrpke = 0x00000000,
79 .grp_addds = IMX6SDL_DRIVE_STRENGTH,
80 .grp_ctlds = IMX6SDL_DRIVE_STRENGTH,
81 .grp_ddrmode = 0x00020000,
82 .grp_b0ds = IMX6SDL_DRIVE_STRENGTH,
83 .grp_b1ds = IMX6SDL_DRIVE_STRENGTH,
84 .grp_b2ds = IMX6SDL_DRIVE_STRENGTH,
85 .grp_b3ds = IMX6SDL_DRIVE_STRENGTH,
86 .grp_b4ds = IMX6SDL_DRIVE_STRENGTH,
87 .grp_b5ds = IMX6SDL_DRIVE_STRENGTH,
88 .grp_b6ds = IMX6SDL_DRIVE_STRENGTH,
89 .grp_b7ds = IMX6SDL_DRIVE_STRENGTH,
90};
91
92static struct mx6_ddr3_cfg mt41k128m16jt_125 = {
93 .mem_speed = 1600,
94 .density = 4,
95 .width = 32,
96 .banks = 8,
97 .rowaddr = 14,
98 .coladdr = 10,
99 .pagesz = 2,
100 .trcd = 1375,
101 .trcmin = 4875,
102 .trasmin = 3500,
103 .SRT = 0,
104};
105
106static struct mx6_mmdc_calibration mx6dl_mmdc_calib = {
107 .p0_mpwldectrl0 = 0x0042004b,
108 .p0_mpwldectrl1 = 0x0038003c,
109 .p0_mpdgctrl0 = 0x42340230,
110 .p0_mpdgctrl1 = 0x0228022c,
111 .p0_mprddlctl = 0x42444646,
112 .p0_mpwrdlctl = 0x38382e2e,
113};
114
115static struct mx6_ddr_sysinfo mem_dl = {
116 .dsize = 1,
117 .cs1_mirror = 0,
118
119 .cs_density = 32,
120 .ncs = 1,
121 .bi_on = 1,
122 .rtt_nom = 1,
123 .rtt_wr = 1,
124 .ralat = 5,
125 .walat = 0,
126 .mif3_mode = 3,
127 .rst_to_cke = 0x23,
128 .sde_to_rst = 0x10,
129 .refsel = 1,
130 .refr = 7,
131};
132
133static void spl_dram_init(void)
134{
135 mx6sdl_dram_iocfg(64, &mx6sdl_ddr_ioregs, &mx6sdl_grp_ioregs);
136 mx6_dram_cfg(&mem_dl, &mx6dl_mmdc_calib, &mt41k128m16jt_125);
137
138 udelay(100);
139}
140
141static void ccgr_init(void)
142{
143 struct mxc_ccm_reg *ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
144
145 writel(0x00003f3f, &ccm->CCGR0);
146 writel(0x0030fc00, &ccm->CCGR1);
147 writel(0x000fc000, &ccm->CCGR2);
148 writel(0x3f300000, &ccm->CCGR3);
149 writel(0xff00f300, &ccm->CCGR4);
150 writel(0x0f0000c3, &ccm->CCGR5);
151 writel(0x000003cc, &ccm->CCGR6);
152}
153
154void board_init_f(ulong dummy)
155{
156 ccgr_init();
157
158
159 arch_cpu_init();
160
161 gpr_init();
162
163
164 SETUP_IOMUX_PADS(uart3_pads);
165
166
167 timer_init();
168
169
170 preloader_console_init();
171
172
173 spl_dram_init();
174}
175