]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - arch/arm/include/asm/arch-am33xx/ddr_defs.h
add VTP_CTRL_FILTER definition
[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 #include <asm/emif.h>
24
25 /* AM335X EMIF Register values */
26 #define VTP_CTRL_READY          (0x1 << 5)
27 #define VTP_CTRL_ENABLE         (0x1 << 6)
28 #define VTP_CTRL_FILTER_SHIFT   1
29 #define VTP_CTRL_FILTER_MASK    (0x7 << VTP_CTRL_FILTER_SHIFT)
30 #define VTP_CTRL_FILTER(n)      (((n) << VTP_CTRL_FILTER_SHIFT) & VTP_CTRL_FILTER_MASK)
31 #define VTP_CTRL_START_EN       (0x1 << 0)
32 #define PHY_DLL_LOCK_DIFF       0x0
33 #define DDR_CKE_CTRL_NORMAL     0x1
34
35 /* Micron MT47H128M16RT-25E */
36 #define MT47H128M16RT25E_EMIF_READ_LATENCY      0x100005
37 #define MT47H128M16RT25E_EMIF_TIM1              0x0666B3C9
38 #define MT47H128M16RT25E_EMIF_TIM2              0x243631CA
39 #define MT47H128M16RT25E_EMIF_TIM3              0x0000033F
40 #define MT47H128M16RT25E_EMIF_SDCFG             0x41805332
41 #define MT47H128M16RT25E_EMIF_SDREF             0x0000081a
42 #define MT47H128M16RT25E_DLL_LOCK_DIFF          0x0
43 #define MT47H128M16RT25E_RATIO                  0x80
44 #define MT47H128M16RT25E_INVERT_CLKOUT          0x00
45 #define MT47H128M16RT25E_RD_DQS                 0x12
46 #define MT47H128M16RT25E_WR_DQS                 0x00
47 #define MT47H128M16RT25E_PHY_WRLVL              0x00
48 #define MT47H128M16RT25E_PHY_GATELVL            0x00
49 #define MT47H128M16RT25E_PHY_WR_DATA            0x40
50 #define MT47H128M16RT25E_PHY_FIFO_WE            0x80
51 #define MT47H128M16RT25E_PHY_RANK0_DELAY                0x1
52 #define MT47H128M16RT25E_IOCTRL_VALUE           0x18B
53
54 /* Micron MT41J128M16JT-125 */
55 #define MT41J128MJT125_EMIF_READ_LATENCY        0x06
56 #define MT41J128MJT125_EMIF_TIM1                0x0888A39B
57 #define MT41J128MJT125_EMIF_TIM2                0x26337FDA
58 #define MT41J128MJT125_EMIF_TIM3                0x501F830F
59 #define MT41J128MJT125_EMIF_SDCFG               0x61C04AB2
60 #define MT41J128MJT125_EMIF_SDREF               0x0000093B
61 #define MT41J128MJT125_ZQ_CFG                   0x50074BE4
62 #define MT41J128MJT125_DLL_LOCK_DIFF            0x1
63 #define MT41J128MJT125_RATIO                    0x40
64 #define MT41J128MJT125_INVERT_CLKOUT            0x1
65 #define MT41J128MJT125_RD_DQS                   0x3B
66 #define MT41J128MJT125_WR_DQS                   0x85
67 #define MT41J128MJT125_PHY_WR_DATA              0xC1
68 #define MT41J128MJT125_PHY_FIFO_WE              0x100
69 #define MT41J128MJT125_IOCTRL_VALUE             0x18B
70
71 /**
72  * Configure SDRAM
73  */
74 void config_sdram(const struct emif_regs *regs);
75
76 /**
77  * Set SDRAM timings
78  */
79 void set_sdram_timings(const struct emif_regs *regs);
80
81 /**
82  * Configure DDR PHY
83  */
84 void config_ddr_phy(const struct emif_regs *regs);
85
86 /**
87  * This structure represents the DDR registers on AM33XX devices.
88  * We make use of DDR_PHY_BASE_ADDR2 to address the DATA1 registers that
89  * correspond to DATA1 registers defined here.
90  */
91 struct ddr_regs {
92         unsigned int resv0[7];
93         unsigned int cm0csratio;        /* offset 0x01C */
94         unsigned int resv1[2];
95         unsigned int cm0dldiff;         /* offset 0x028 */
96         unsigned int cm0iclkout;        /* offset 0x02C */
97         unsigned int resv2[8];
98         unsigned int cm1csratio;        /* offset 0x050 */
99         unsigned int resv3[2];
100         unsigned int cm1dldiff;         /* offset 0x05C */
101         unsigned int cm1iclkout;        /* offset 0x060 */
102         unsigned int resv4[8];
103         unsigned int cm2csratio;        /* offset 0x084 */
104         unsigned int resv5[2];
105         unsigned int cm2dldiff;         /* offset 0x090 */
106         unsigned int cm2iclkout;        /* offset 0x094 */
107         unsigned int resv6[12];
108         unsigned int dt0rdsratio0;      /* offset 0x0C8 */
109         unsigned int resv7[4];
110         unsigned int dt0wdsratio0;      /* offset 0x0DC */
111         unsigned int resv8[4];
112         unsigned int dt0wiratio0;       /* offset 0x0F0 */
113         unsigned int resv9;
114         unsigned int dt0wimode0;        /* offset 0x0F8 */
115         unsigned int dt0giratio0;       /* offset 0x0FC */
116         unsigned int resv10;
117         unsigned int dt0gimode0;        /* offset 0x104 */
118         unsigned int dt0fwsratio0;      /* offset 0x108 */
119         unsigned int resv11[4];
120         unsigned int dt0dqoffset;       /* offset 0x11C */
121         unsigned int dt0wrsratio0;      /* offset 0x120 */
122         unsigned int resv12[4];
123         unsigned int dt0rdelays0;       /* offset 0x134 */
124         unsigned int dt0dldiff0;        /* offset 0x138 */
125 };
126
127 /**
128  * Encapsulates DDR CMD control registers.
129  */
130 struct cmd_control {
131         unsigned long cmd0csratio;
132         unsigned long cmd0csforce;
133         unsigned long cmd0csdelay;
134         unsigned long cmd0dldiff;
135         unsigned long cmd0iclkout;
136         unsigned long cmd1csratio;
137         unsigned long cmd1csforce;
138         unsigned long cmd1csdelay;
139         unsigned long cmd1dldiff;
140         unsigned long cmd1iclkout;
141         unsigned long cmd2csratio;
142         unsigned long cmd2csforce;
143         unsigned long cmd2csdelay;
144         unsigned long cmd2dldiff;
145         unsigned long cmd2iclkout;
146 };
147
148 /**
149  * Encapsulates DDR DATA registers.
150  */
151 struct ddr_data {
152         unsigned long datardsratio0;
153         unsigned long datawdsratio0;
154         unsigned long datawiratio0;
155         unsigned long datagiratio0;
156         unsigned long datafwsratio0;
157         unsigned long datawrsratio0;
158         unsigned long datauserank0delay;
159         unsigned long datadldiff0;
160 };
161
162 /**
163  * Configure DDR CMD control registers
164  */
165 void config_cmd_ctrl(const struct cmd_control *cmd);
166
167 /**
168  * Configure DDR DATA registers
169  */
170 void config_ddr_data(int data_macrono, const struct ddr_data *data);
171
172 /**
173  * This structure represents the DDR io control on AM33XX devices.
174  */
175 struct ddr_cmdtctrl {
176         unsigned int cm0ioctl;
177         unsigned int cm1ioctl;
178         unsigned int cm2ioctl;
179         unsigned int resv2[12];
180         unsigned int dt0ioctl;
181         unsigned int dt1ioctl;
182 };
183
184 /**
185  * Configure DDR io control registers
186  */
187 void config_io_ctrl(unsigned long val);
188
189 struct ddr_ctrl {
190         unsigned int ddrioctrl;
191         unsigned int resv1[325];
192         unsigned int ddrckectrl;
193 };
194
195 void config_ddr(unsigned int pll, unsigned int ioctrl,
196                 const struct ddr_data *data, const struct cmd_control *ctrl,
197                 const struct emif_regs *regs);
198
199 #endif  /* _DDR_DEFS_H */