6 * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR /PURPOSE. See the
16 * GNU General Public License for more details.
22 #include <asm/arch/hardware.h>
24 /* AM335X EMIF Register values */
25 #define VTP_CTRL_READY (0x1 << 5)
26 #define VTP_CTRL_ENABLE (0x1 << 6)
27 #define VTP_CTRL_START_EN (0x1)
28 #define CMD_FORCE 0x00
29 #define CMD_DELAY 0x00
30 #define PHY_DLL_LOCK_DIFF 0x0
31 #define DDR_CKE_CTRL_NORMAL 0x1
33 #define DDR2_EMIF_READ_LATENCY 0x100005 /* Enable Dynamic Power Down */
34 #define DDR2_EMIF_TIM1 0x0666B3C9
35 #define DDR2_EMIF_TIM2 0x243631CA
36 #define DDR2_EMIF_TIM3 0x0000033F
37 #define DDR2_EMIF_SDCFG 0x41805332
38 #define DDR2_EMIF_SDREF 0x0000081a
39 #define DDR2_DLL_LOCK_DIFF 0x0
40 #define DDR2_RATIO 0x80
41 #define DDR2_INVERT_CLKOUT 0x00
42 #define DDR2_RD_DQS 0x12
43 #define DDR2_WR_DQS 0x00
44 #define DDR2_PHY_WRLVL 0x00
45 #define DDR2_PHY_GATELVL 0x00
46 #define DDR2_PHY_WR_DATA 0x40
47 #define DDR2_PHY_FIFO_WE 0x80
48 #define DDR2_PHY_RANK0_DELAY 0x1
49 #define DDR2_IOCTRL_VALUE 0x18B
52 * Encapsulates DDR PHY control and corresponding shadow registers.
54 struct ddr_phy_control {
61 * Encapsulates SDRAM timing and corresponding shadow registers.
65 unsigned long time1_sh;
67 unsigned long time2_sh;
69 unsigned long time3_sh;
73 * Encapsulates SDRAM configuration.
74 * (Includes refresh control registers) */
78 unsigned long refresh;
79 unsigned long refresh_sh;
85 void config_sdram(struct sdram_config *cfg);
90 void set_sdram_timings(struct sdram_timing *val);
95 void config_ddr_phy(struct ddr_phy_control *cfg);
98 * This structure represents the DDR registers on AM33XX devices.
101 unsigned int resv0[7];
102 unsigned int cm0csratio; /* offset 0x01C */
103 unsigned int cm0csforce; /* offset 0x020 */
104 unsigned int cm0csdelay; /* offset 0x024 */
105 unsigned int cm0dldiff; /* offset 0x028 */
106 unsigned int cm0iclkout; /* offset 0x02C */
107 unsigned int resv1[8];
108 unsigned int cm1csratio; /* offset 0x050 */
109 unsigned int cm1csforce; /* offset 0x054 */
110 unsigned int cm1csdelay; /* offset 0x058 */
111 unsigned int cm1dldiff; /* offset 0x05C */
112 unsigned int cm1iclkout; /* offset 0x060 */
113 unsigned int resv2[8];
114 unsigned int cm2csratio; /* offset 0x084 */
115 unsigned int cm2csforce; /* offset 0x088 */
116 unsigned int cm2csdelay; /* offset 0x08C */
117 unsigned int cm2dldiff; /* offset 0x090 */
118 unsigned int cm2iclkout; /* offset 0x094 */
119 unsigned int resv3[12];
120 unsigned int dt0rdsratio0; /* offset 0x0C8 */
121 unsigned int dt0rdsratio1; /* offset 0x0CC */
122 unsigned int resv4[3];
123 unsigned int dt0wdsratio0; /* offset 0x0DC */
124 unsigned int dt0wdsratio1; /* offset 0x0E0 */
125 unsigned int resv5[3];
126 unsigned int dt0wiratio0; /* offset 0x0F0 */
127 unsigned int dt0wiratio1; /* offset 0x0F4 */
128 unsigned int dt0giratio0; /* offset 0x0FC */
129 unsigned int dt0giratio1; /* offset 0x100 */
130 unsigned int resv6[1];
131 unsigned int dt0fwsratio0; /* offset 0x108 */
132 unsigned int dt0fwsratio1; /* offset 0x10C */
133 unsigned int resv7[4];
134 unsigned int dt0wrsratio0; /* offset 0x120 */
135 unsigned int dt0wrsratio1; /* offset 0x124 */
136 unsigned int resv8[3];
137 unsigned int dt0rdelays0; /* offset 0x134 */
138 unsigned int dt0dldiff0; /* offset 0x138 */
139 unsigned int resv9[39];
140 unsigned int dt1rdelays0; /* offset 0x1D8 */
144 * Encapsulates DDR CMD control registers.
147 unsigned long cmd0csratio;
148 unsigned long cmd0csforce;
149 unsigned long cmd0csdelay;
150 unsigned long cmd0dldiff;
151 unsigned long cmd0iclkout;
152 unsigned long cmd1csratio;
153 unsigned long cmd1csforce;
154 unsigned long cmd1csdelay;
155 unsigned long cmd1dldiff;
156 unsigned long cmd1iclkout;
157 unsigned long cmd2csratio;
158 unsigned long cmd2csforce;
159 unsigned long cmd2csdelay;
160 unsigned long cmd2dldiff;
161 unsigned long cmd2iclkout;
165 * Encapsulates DDR DATA registers.
168 unsigned long datardsratio0;
169 unsigned long datardsratio1;
170 unsigned long datawdsratio0;
171 unsigned long datawdsratio1;
172 unsigned long datawiratio0;
173 unsigned long datawiratio1;
174 unsigned long datagiratio0;
175 unsigned long datagiratio1;
176 unsigned long datafwsratio0;
177 unsigned long datafwsratio1;
178 unsigned long datawrsratio0;
179 unsigned long datawrsratio1;
180 unsigned long datadldiff0;
184 * Configure DDR CMD control registers
186 void config_cmd_ctrl(const struct cmd_control *cmd);
189 * Configure DDR DATA registers
191 void config_ddr_data(int data_macrono, const struct ddr_data *data);
194 * This structure represents the DDR io control on AM33XX devices.
196 struct ddr_cmdtctrl {
197 unsigned int resv1[1];
198 unsigned int cm0ioctl;
199 unsigned int cm1ioctl;
200 unsigned int cm2ioctl;
201 unsigned int resv2[12];
202 unsigned int dt0ioctl;
203 unsigned int dt1ioctl;
207 * Encapsulates DDR CMD & DATA io control registers.
210 unsigned long cmd1ctl;
211 unsigned long cmd2ctl;
212 unsigned long cmd3ctl;
213 unsigned long data1ctl;
214 unsigned long data2ctl;
218 * Configure DDR io control registers
220 void config_io_ctrl(struct ddr_ioctrl *ioctrl);
223 unsigned int ddrioctrl;
224 unsigned int resv1[325];
225 unsigned int ddrckectrl;
228 void config_ddr(short ddr_type);
230 #endif /* _DDR_DEFS_H */