]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/include/asm/arch-am33xx/ddr_defs.h
Unified codebase for TX28, TX48, TX51, TX53
[karo-tx-uboot.git] / arch / arm / include / asm / arch-am33xx / ddr_defs.h
1 /*
2  * ddr_defs.h
3  *
4  * ddr specific header
5  *
6  * Copyright (C) 2011, Texas Instruments, Incorporated - http://www.ti.com/
7  *
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.
12  *
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.
17  */
18
19 #ifndef _DDR_DEFS_H
20 #define _DDR_DEFS_H
21
22 #include <asm/arch/hardware.h>
23
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)
32
33 /**
34  * This structure represents the EMIF registers on AM33XX devices.
35  */
36 struct emif_regs {
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 */
49         unsigned int res1[2];
50         unsigned int sdrmcr;            /* offset 0x38 */
51         unsigned int sdrmcsr;           /* offset 0x3C */
52         unsigned int res2[8];
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 */
58 };
59
60 /**
61  * Encapsulates DDR PHY control and corresponding shadow registers.
62  */
63 struct ddr_phy_control {
64         unsigned long   reg;
65         unsigned long   reg_sh;
66         unsigned long   reg2;
67 };
68
69 /**
70  * Encapsulates SDRAM timing and corresponding shadow registers.
71  */
72 struct sdram_timing {
73         unsigned long   time1;
74         unsigned long   time1_sh;
75         unsigned long   time2;
76         unsigned long   time2_sh;
77         unsigned long   time3;
78         unsigned long   time3_sh;
79 };
80
81 /**
82  * Encapsulates SDRAM configuration.
83  * (Includes refresh control registers)  */
84 struct sdram_config {
85         unsigned long   sdrcr;
86         unsigned long   sdrcr2;
87         unsigned long   refresh;
88         unsigned long   refresh_sh;
89 };
90
91 /**
92  * Configure SDRAM
93  */
94 int config_sdram(struct sdram_config *cfg);
95
96 /**
97  * Set SDRAM timings
98  */
99 int set_sdram_timings(struct sdram_timing *val);
100
101 /**
102  * Configure DDR PHY
103  */
104 int config_ddr_phy(struct ddr_phy_control *cfg);
105
106 /**
107  * This structure represents the DDR registers on AM33XX devices.
108  */
109 /* data macro cells */
110 struct ddr_dt_regs {
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];
132 };
133
134 struct ddr_regs {
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;
156 };
157
158 /**
159  * Encapsulates DDR CMD control registers.
160  */
161 struct cmd_control {
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;
177 };
178
179 /**
180  * Encapsulates DDR DATA registers.
181  */
182 struct ddr_data {
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;
196 };
197
198 /**
199  * Configure DDR CMD control registers
200  */
201 int config_cmd_ctrl(struct cmd_control *cmd);
202
203 /**
204  * Configure DDR DATA registers
205  */
206 int config_ddr_data(int data_macrono, struct ddr_data *data);
207
208 /**
209  * This structure represents the DDR io control on AM33XX devices.
210  */
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;
219 };
220
221 /**
222  * Encapsulates DDR CMD & DATA io control registers.
223  */
224 struct ddr_ioctrl {
225         unsigned long cmd1ctl;
226         unsigned long cmd2ctl;
227         unsigned long cmd3ctl;
228         unsigned long data1ctl;
229         unsigned long data2ctl;
230 };
231
232 /**
233  * Configure DDR io control registers
234  */
235 int config_io_ctrl(struct ddr_ioctrl *ioctrl);
236
237 struct ddr_ctrl {
238         unsigned int ddrioctrl;
239         unsigned int resv1[325];
240         unsigned int ddrckectrl;
241 };
242
243 void config_ddr(void);
244
245 #endif  /* _DDR_DEFS_H */