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 DDR_PHY_RESET (0x1 << 10)
26 #define DDR_FUNCTIONAL_MODE_EN 0x1
27 #define DDR_PHY_READY (0x1 << 2)
28 #define VTP_CTRL_READY (0x1 << 5)
29 #define VTP_CTRL_ENABLE (0x1 << 6)
30 #define VTP_CTRL_LOCK_EN (0x1 << 4)
31 #define VTP_CTRL_START_EN (0x1 << 0)
34 * This structure represents the EMIF registers on AM33XX devices.
37 unsigned int sdrrev; /* offset 0x00 */
38 unsigned int sdrstat; /* offset 0x04 */
39 unsigned int sdrcr; /* offset 0x08 */
40 unsigned int sdrcr2; /* offset 0x0C */
41 unsigned int sdrrcr; /* offset 0x10 */
42 unsigned int sdrrcsr; /* offset 0x14 */
43 unsigned int sdrtim1; /* offset 0x18 */
44 unsigned int sdrtim1sr; /* offset 0x1C */
45 unsigned int sdrtim2; /* offset 0x20 */
46 unsigned int sdrtim2sr; /* offset 0x24 */
47 unsigned int sdrtim3; /* offset 0x28 */
48 unsigned int sdrtim3sr; /* offset 0x2C */
50 unsigned int sdrmcr; /* offset 0x38 */
51 unsigned int sdrmcsr; /* offset 0x3C */
53 unsigned int sdritr; /* offset 0x60 */
54 unsigned int res3[32];
55 unsigned int ddrphycr; /* offset 0xE4 */
56 unsigned int ddrphycsr; /* offset 0xE8 */
57 unsigned int ddrphycr2; /* offset 0xEC */
61 * Encapsulates DDR PHY control and corresponding shadow registers.
63 struct ddr_phy_control {
70 * Encapsulates SDRAM timing and corresponding shadow registers.
74 unsigned long time1_sh;
76 unsigned long time2_sh;
78 unsigned long time3_sh;
82 * Encapsulates SDRAM configuration.
83 * (Includes refresh control registers) */
87 unsigned long refresh;
88 unsigned long refresh_sh;
94 int config_sdram(struct sdram_config *cfg);
99 int set_sdram_timings(struct sdram_timing *val);
104 int config_ddr_phy(struct ddr_phy_control *cfg);
107 * This structure represents the DDR registers on AM33XX devices.
109 /* data macro cells */
111 unsigned int rdsratio0; /* offset 0x0C8 */
112 unsigned int rdsratio1; /* offset 0x0CC */
113 unsigned int resv4[3];
114 unsigned int wdsratio0; /* offset 0x0DC */
115 unsigned int wdsratio1; /* offset 0x0E0 */
116 unsigned int resv5[3];
117 unsigned int wiratio0; /* offset 0x0F0 */
118 unsigned int wiratio1; /* offset 0x0F4 */
119 unsigned int wimode0; /* offset 0x0F8 */
120 unsigned int giratio0; /* offset 0x0FC */
121 unsigned int giratio1; /* offset 0x100 */
122 unsigned int gimode0; /* offset 0x104 */
123 unsigned int fwsratio0; /* offset 0x108 */
124 unsigned int fwsratio1; /* offset 0x10C */
125 unsigned int resv7[4];
126 unsigned int wrsratio0; /* offset 0x120 */
127 unsigned int wrsratio1; /* offset 0x124 */
128 unsigned int resv8[3];
129 unsigned int rdelays0; /* offset 0x134 */
130 unsigned int dldiff0; /* offset 0x138 */
131 unsigned int resv9[12];
135 unsigned int resv0[7];
136 unsigned int cm0csratio; /* offset 0x01C */
137 unsigned int cm0csforce; /* offset 0x020 */
138 unsigned int cm0csdelay; /* offset 0x024 */
139 unsigned int cm0dldiff; /* offset 0x028 */
140 unsigned int cm0iclkout; /* offset 0x02C */
141 unsigned int resv1[8];
142 unsigned int cm1csratio; /* offset 0x050 */
143 unsigned int cm1csforce; /* offset 0x054 */
144 unsigned int cm1csdelay; /* offset 0x058 */
145 unsigned int cm1dldiff; /* offset 0x05C */
146 unsigned int cm1iclkout; /* offset 0x060 */
147 unsigned int resv2[8];
148 unsigned int cm2csratio; /* offset 0x084 */
149 unsigned int cm2csforce; /* offset 0x088 */
150 unsigned int cm2csdelay; /* offset 0x08C */
151 unsigned int cm2dldiff; /* offset 0x090 */
152 unsigned int cm2iclkout; /* offset 0x094 */
153 unsigned int resv3[12];
154 struct ddr_dt_regs dt0;
155 struct ddr_dt_regs dt1;
159 * Encapsulates DDR CMD control registers.
162 unsigned long cmd0csratio;
163 unsigned long cmd0csforce;
164 unsigned long cmd0csdelay;
165 unsigned long cmd0dldiff;
166 unsigned long cmd0iclkout;
167 unsigned long cmd1csratio;
168 unsigned long cmd1csforce;
169 unsigned long cmd1csdelay;
170 unsigned long cmd1dldiff;
171 unsigned long cmd1iclkout;
172 unsigned long cmd2csratio;
173 unsigned long cmd2csforce;
174 unsigned long cmd2csdelay;
175 unsigned long cmd2dldiff;
176 unsigned long cmd2iclkout;
180 * Encapsulates DDR DATA registers.
183 unsigned long datardsratio0;
184 unsigned long datardsratio1;
185 unsigned long datawdsratio0;
186 unsigned long datawdsratio1;
187 unsigned long datawiratio0;
188 unsigned long datawiratio1;
189 unsigned long datagiratio0;
190 unsigned long datagiratio1;
191 unsigned long datafwsratio0;
192 unsigned long datafwsratio1;
193 unsigned long datawrsratio0;
194 unsigned long datawrsratio1;
195 unsigned long datadldiff0;
199 * Configure DDR CMD control registers
201 int config_cmd_ctrl(struct cmd_control *cmd);
204 * Configure DDR DATA registers
206 int config_ddr_data(int data_macrono, struct ddr_data *data);
209 * This structure represents the DDR io control on AM33XX devices.
211 struct ddr_cmdtctrl {
212 unsigned int resv1[1];
213 unsigned int cm0ioctl;
214 unsigned int cm1ioctl;
215 unsigned int cm2ioctl;
216 unsigned int resv2[12];
217 unsigned int dt0ioctl;
218 unsigned int dt1ioctl;
222 * Encapsulates DDR CMD & DATA io control registers.
225 unsigned long cmd1ctl;
226 unsigned long cmd2ctl;
227 unsigned long cmd3ctl;
228 unsigned long data1ctl;
229 unsigned long data2ctl;
233 * Configure DDR io control registers
235 int config_io_ctrl(struct ddr_ioctrl *ioctrl);
238 unsigned int ddrioctrl;
239 unsigned int resv1[325];
240 unsigned int ddrckectrl;
243 void config_ddr(void);
245 #endif /* _DDR_DEFS_H */