diff options
Diffstat (limited to 'arch/arm/mach-tegra/tegra3_emc.h')
-rw-r--r-- | arch/arm/mach-tegra/tegra3_emc.h | 297 |
1 files changed, 297 insertions, 0 deletions
diff --git a/arch/arm/mach-tegra/tegra3_emc.h b/arch/arm/mach-tegra/tegra3_emc.h new file mode 100644 index 00000000000..cfde92c1355 --- /dev/null +++ b/arch/arm/mach-tegra/tegra3_emc.h | |||
@@ -0,0 +1,297 @@ | |||
1 | /* | ||
2 | * arch/arm/mach-tegra/tegra3_emc.h | ||
3 | * | ||
4 | * Copyright (C) 2011 NVIDIA Corporation | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | * more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | * | ||
20 | */ | ||
21 | |||
22 | #ifndef _MACH_TEGRA_TEGRA3_EMC_H | ||
23 | #define _MACH_TEGRA_TEGRA3_EMC_H | ||
24 | |||
25 | #define TEGRA_EMC_NUM_REGS 110 | ||
26 | |||
27 | #define TEGRA_EMC_BRIDGE_RATE_MIN 300000000 | ||
28 | #define TEGRA_EMC_BRIDGE_MVOLTS_MIN 1200 | ||
29 | |||
30 | struct tegra_emc_table { | ||
31 | u8 rev; | ||
32 | unsigned long rate; | ||
33 | |||
34 | /* unconditionally updated in one burst shot */ | ||
35 | u32 burst_regs[TEGRA_EMC_NUM_REGS]; | ||
36 | |||
37 | /* updated separately under some conditions */ | ||
38 | u32 emc_zcal_cnt_long; | ||
39 | u32 emc_acal_interval; | ||
40 | u32 emc_periodic_qrst; | ||
41 | u32 emc_mode_reset; | ||
42 | u32 emc_mode_1; | ||
43 | u32 emc_mode_2; | ||
44 | u32 emc_dsr; | ||
45 | int emc_min_mv; | ||
46 | }; | ||
47 | |||
48 | enum { | ||
49 | DRAM_OVER_TEMP_NONE = 0, | ||
50 | DRAM_OVER_TEMP_REFRESH, | ||
51 | }; | ||
52 | |||
53 | struct clk; | ||
54 | |||
55 | void tegra_init_emc(const struct tegra_emc_table *table, int table_size); | ||
56 | |||
57 | void tegra_init_dram_bit_map(const u32 *bit_map, int map_size); | ||
58 | void tegra_emc_dram_type_init(struct clk *c); | ||
59 | int tegra_emc_get_dram_type(void); | ||
60 | int tegra_emc_get_dram_temperature(void); | ||
61 | int tegra_emc_set_over_temp_state(unsigned long state); | ||
62 | |||
63 | #ifdef CONFIG_PM_SLEEP | ||
64 | void tegra_mc_timing_restore(void); | ||
65 | #else | ||
66 | static inline void tegra_mc_timing_restore(void) | ||
67 | { } | ||
68 | #endif | ||
69 | |||
70 | #define EMC_INTSTATUS 0x0 | ||
71 | #define EMC_INTSTATUS_CLKCHANGE_COMPLETE (0x1 << 4) | ||
72 | |||
73 | #define EMC_DBG 0x8 | ||
74 | #define EMC_DBG_WRITE_MUX_ACTIVE (0x1 << 1) | ||
75 | |||
76 | #define EMC_CFG 0xc | ||
77 | #define EMC_CFG_PERIODIC_QRST (0x1 << 21) | ||
78 | #define EMC_CFG_DYN_SREF_ENABLE (0x1 << 28) | ||
79 | #define EMC_CFG_PWR_MASK (0xF << 28) | ||
80 | |||
81 | #define EMC_REFCTRL 0x20 | ||
82 | #define EMC_REFCTRL_DEV_SEL_SHIFT 0 | ||
83 | #define EMC_REFCTRL_DEV_SEL_MASK (0x3 << EMC_REFCTRL_DEV_SEL_SHIFT) | ||
84 | #define EMC_REFCTRL_ENABLE (0x1 << 31) | ||
85 | #define EMC_REFCTRL_ENABLE_ALL(num) \ | ||
86 | ((((num > 1) ? 0 : 2) << EMC_REFCTRL_DEV_SEL_SHIFT) \ | ||
87 | | EMC_REFCTRL_ENABLE) | ||
88 | #define EMC_REFCTRL_DISABLE_ALL(num) \ | ||
89 | (((num > 1) ? 0 : 2) << EMC_REFCTRL_DEV_SEL_SHIFT) | ||
90 | |||
91 | #define EMC_TIMING_CONTROL 0x28 | ||
92 | #define EMC_RC 0x2c | ||
93 | #define EMC_RFC 0x30 | ||
94 | #define EMC_RAS 0x34 | ||
95 | #define EMC_RP 0x38 | ||
96 | #define EMC_R2W 0x3c | ||
97 | #define EMC_W2R 0x40 | ||
98 | #define EMC_R2P 0x44 | ||
99 | #define EMC_W2P 0x48 | ||
100 | #define EMC_RD_RCD 0x4c | ||
101 | #define EMC_WR_RCD 0x50 | ||
102 | #define EMC_RRD 0x54 | ||
103 | #define EMC_REXT 0x58 | ||
104 | #define EMC_WDV 0x5c | ||
105 | #define EMC_QUSE 0x60 | ||
106 | #define EMC_QRST 0x64 | ||
107 | #define EMC_QSAFE 0x68 | ||
108 | #define EMC_RDV 0x6c | ||
109 | #define EMC_REFRESH 0x70 | ||
110 | #define EMC_BURST_REFRESH_NUM 0x74 | ||
111 | #define EMC_PDEX2WR 0x78 | ||
112 | #define EMC_PDEX2RD 0x7c | ||
113 | #define EMC_PCHG2PDEN 0x80 | ||
114 | #define EMC_ACT2PDEN 0x84 | ||
115 | #define EMC_AR2PDEN 0x88 | ||
116 | #define EMC_RW2PDEN 0x8c | ||
117 | #define EMC_TXSR 0x90 | ||
118 | #define EMC_TCKE 0x94 | ||
119 | #define EMC_TFAW 0x98 | ||
120 | #define EMC_TRPAB 0x9c | ||
121 | #define EMC_TCLKSTABLE 0xa0 | ||
122 | #define EMC_TCLKSTOP 0xa4 | ||
123 | #define EMC_TREFBW 0xa8 | ||
124 | #define EMC_QUSE_EXTRA 0xac | ||
125 | #define EMC_ODT_WRITE 0xb0 | ||
126 | #define EMC_ODT_READ 0xb4 | ||
127 | #define EMC_WEXT 0xb8 | ||
128 | #define EMC_CTT 0xbc | ||
129 | |||
130 | #define EMC_MRS_WAIT_CNT 0xc8 | ||
131 | #define EMC_MRS_WAIT_CNT_SHORT_WAIT_SHIFT 0 | ||
132 | #define EMC_MRS_WAIT_CNT_SHORT_WAIT_MASK \ | ||
133 | (0x3FF << EMC_MRS_WAIT_CNT_SHORT_WAIT_SHIFT) | ||
134 | #define EMC_MRS_WAIT_CNT_LONG_WAIT_SHIFT 16 | ||
135 | #define EMC_MRS_WAIT_CNT_LONG_WAIT_MASK \ | ||
136 | (0x3FF << EMC_MRS_WAIT_CNT_LONG_WAIT_SHIFT) | ||
137 | |||
138 | #define EMC_MRS 0xcc | ||
139 | #define EMC_MODE_SET_DLL_RESET (0x1 << 8) | ||
140 | #define EMC_MODE_SET_LONG_CNT (0x1 << 26) | ||
141 | #define EMC_EMRS 0xd0 | ||
142 | #define EMC_REF 0xd4 | ||
143 | #define EMC_REF_FORCE_CMD 1 | ||
144 | |||
145 | #define EMC_SELF_REF 0xe0 | ||
146 | #define EMC_SELF_REF_CMD_ENABLED (0x1 << 0) | ||
147 | #define EMC_SELF_REF_DEV_SEL_SHIFT 30 | ||
148 | #define EMC_SELF_REF_DEV_SEL_MASK (0x3 << EMC_SELF_REF_DEV_SEL_SHIFT) | ||
149 | enum { | ||
150 | DRAM_DEV_SEL_ALL = 0, | ||
151 | DRAM_DEV_SEL_0 = (2 << EMC_SELF_REF_DEV_SEL_SHIFT), | ||
152 | DRAM_DEV_SEL_1 = (1 << EMC_SELF_REF_DEV_SEL_SHIFT), | ||
153 | }; | ||
154 | #define DRAM_BROADCAST(num) \ | ||
155 | (((num) > 1) ? DRAM_DEV_SEL_ALL : DRAM_DEV_SEL_0) | ||
156 | |||
157 | #define EMC_MRW 0xe8 | ||
158 | #define EMC_MRR 0xec | ||
159 | #define EMC_MRR_MA_SHIFT 16 | ||
160 | #define EMC_MRR_MA_MASK (0xFF << EMC_MRR_MA_SHIFT) | ||
161 | #define EMC_MRR_DATA_MASK ((0x1 << EMC_MRR_MA_SHIFT) - 1) | ||
162 | #define LPDDR2_MR4_TEMP_SHIFT 0 | ||
163 | #define LPDDR2_MR4_TEMP_MASK (0x7 << LPDDR2_MR4_TEMP_SHIFT) | ||
164 | |||
165 | #define EMC_XM2DQSPADCTRL3 0xf8 | ||
166 | #define EMC_XM2DQSPADCTRL3_VREF_ENABLE (0x1 << 5) | ||
167 | #define EMC_FBIO_SPARE 0x100 | ||
168 | |||
169 | #define EMC_FBIO_CFG5 0x104 | ||
170 | #define EMC_CFG5_TYPE_SHIFT 0x0 | ||
171 | #define EMC_CFG5_TYPE_MASK (0x3 << EMC_CFG5_TYPE_SHIFT) | ||
172 | enum { | ||
173 | DRAM_TYPE_DDR3 = 0, | ||
174 | DRAM_TYPE_LPDDR2 = 2, | ||
175 | }; | ||
176 | #define EMC_CFG5_QUSE_MODE_SHIFT 13 | ||
177 | #define EMC_CFG5_QUSE_MODE_MASK (0x7 << EMC_CFG5_QUSE_MODE_SHIFT) | ||
178 | enum { | ||
179 | EMC_CFG5_QUSE_MODE_NORMAL = 0, | ||
180 | EMC_CFG5_QUSE_MODE_ALWAYS_ON, | ||
181 | EMC_CFG5_QUSE_MODE_INTERNAL_LPBK, | ||
182 | EMC_CFG5_QUSE_MODE_PULSE_INTERN, | ||
183 | EMC_CFG5_QUSE_MODE_PULSE_EXTERN, | ||
184 | }; | ||
185 | |||
186 | #define EMC_FBIO_CFG6 0x114 | ||
187 | #define EMC_CFG_RSV 0x120 | ||
188 | #define EMC_AUTO_CAL_CONFIG 0x2a4 | ||
189 | #define EMC_AUTO_CAL_INTERVAL 0x2a8 | ||
190 | #define EMC_AUTO_CAL_STATUS 0x2ac | ||
191 | #define EMC_AUTO_CAL_STATUS_ACTIVE (0x1 << 31) | ||
192 | #define EMC_STATUS 0x2b4 | ||
193 | #define EMC_STATUS_TIMING_UPDATE_STALLED (0x1 << 23) | ||
194 | #define EMC_STATUS_MRR_DIVLD (0x1 << 20) | ||
195 | |||
196 | #define EMC_CFG_2 0x2b8 | ||
197 | #define EMC_CFG_2_MODE_SHIFT 0 | ||
198 | #define EMC_CFG_2_MODE_MASK (0x7 << EMC_CFG_2_MODE_SHIFT) | ||
199 | #define EMC_CFG_2_SREF_MODE 0x1 | ||
200 | #define EMC_CFG_2_PD_MODE 0x3 | ||
201 | |||
202 | #define EMC_CFG_DIG_DLL 0x2bc | ||
203 | #define EMC_CFG_DIG_DLL_PERIOD 0x2c0 | ||
204 | #define EMC_CTT_DURATION 0x2d8 | ||
205 | #define EMC_CTT_TERM_CTRL 0x2dc | ||
206 | #define EMC_ZCAL_INTERVAL 0x2e0 | ||
207 | #define EMC_ZCAL_WAIT_CNT 0x2e4 | ||
208 | |||
209 | #define EMC_ZQ_CAL 0x2ec | ||
210 | #define EMC_ZQ_CAL_CMD (0x1 << 0) | ||
211 | #define EMC_ZQ_CAL_LONG (0x1 << 4) | ||
212 | #define EMC_ZQ_CAL_LONG_CMD_DEV0 \ | ||
213 | (DRAM_DEV_SEL_0 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD) | ||
214 | #define EMC_ZQ_CAL_LONG_CMD_DEV1 \ | ||
215 | (DRAM_DEV_SEL_1 | EMC_ZQ_CAL_LONG | EMC_ZQ_CAL_CMD) | ||
216 | |||
217 | #define EMC_XM2CMDPADCTRL 0x2f0 | ||
218 | #define EMC_XM2DQSPADCTRL2 0x2fc | ||
219 | #define EMC_XM2DQSPADCTRL2_VREF_ENABLE (0x1 << 5) | ||
220 | #define EMC_XM2DQPADCTRL2 0x304 | ||
221 | #define EMC_XM2CLKPADCTRL 0x308 | ||
222 | #define EMC_XM2COMPPADCTRL 0x30c | ||
223 | #define EMC_XM2COMPPADCTRL_VREF_CAL_ENABLE (0x1 << 10) | ||
224 | #define EMC_XM2VTTGENPADCTRL 0x310 | ||
225 | #define EMC_XM2VTTGENPADCTRL2 0x314 | ||
226 | #define EMC_XM2QUSEPADCTRL 0x318 | ||
227 | #define EMC_XM2QUSEPADCTRL_IVREF_ENABLE (0x1 << 4) | ||
228 | #define EMC_DLL_XFORM_DQS0 0x328 | ||
229 | #define EMC_DLL_XFORM_DQS1 0x32c | ||
230 | #define EMC_DLL_XFORM_DQS2 0x330 | ||
231 | #define EMC_DLL_XFORM_DQS3 0x334 | ||
232 | #define EMC_DLL_XFORM_DQS4 0x338 | ||
233 | #define EMC_DLL_XFORM_DQS5 0x33c | ||
234 | #define EMC_DLL_XFORM_DQS6 0x340 | ||
235 | #define EMC_DLL_XFORM_DQS7 0x344 | ||
236 | #define EMC_DLL_XFORM_QUSE0 0x348 | ||
237 | #define EMC_DLL_XFORM_QUSE1 0x34c | ||
238 | #define EMC_DLL_XFORM_QUSE2 0x350 | ||
239 | #define EMC_DLL_XFORM_QUSE3 0x354 | ||
240 | #define EMC_DLL_XFORM_QUSE4 0x358 | ||
241 | #define EMC_DLL_XFORM_QUSE5 0x35c | ||
242 | #define EMC_DLL_XFORM_QUSE6 0x360 | ||
243 | #define EMC_DLL_XFORM_QUSE7 0x364 | ||
244 | #define EMC_DLL_XFORM_DQ0 0x368 | ||
245 | #define EMC_DLL_XFORM_DQ1 0x36c | ||
246 | #define EMC_DLL_XFORM_DQ2 0x370 | ||
247 | #define EMC_DLL_XFORM_DQ3 0x374 | ||
248 | #define EMC_DLI_TRIM_TXDQS0 0x3a8 | ||
249 | #define EMC_DLI_TRIM_TXDQS1 0x3ac | ||
250 | #define EMC_DLI_TRIM_TXDQS2 0x3b0 | ||
251 | #define EMC_DLI_TRIM_TXDQS3 0x3b4 | ||
252 | #define EMC_DLI_TRIM_TXDQS4 0x3b8 | ||
253 | #define EMC_DLI_TRIM_TXDQS5 0x3bc | ||
254 | #define EMC_DLI_TRIM_TXDQS6 0x3c0 | ||
255 | #define EMC_DLI_TRIM_TXDQS7 0x3c4 | ||
256 | #define EMC_STALL_BEFORE_CLKCHANGE 0x3c8 | ||
257 | #define EMC_STALL_AFTER_CLKCHANGE 0x3cc | ||
258 | #define EMC_UNSTALL_RW_AFTER_CLKCHANGE 0x3d0 | ||
259 | #define EMC_SEL_DPD_CTRL 0x3d8 | ||
260 | #define EMC_SEL_DPD_CTRL_QUSE_DPD_ENABLE (0x1 << 9) | ||
261 | #define EMC_PRE_REFRESH_REQ_CNT 0x3dc | ||
262 | #define EMC_DYN_SELF_REF_CONTROL 0x3e0 | ||
263 | #define EMC_TXSRDLL 0x3e4 | ||
264 | |||
265 | #define MC_EMEM_ADR_CFG 0x54 | ||
266 | #define MC_EMEM_ARB_CFG 0x90 | ||
267 | #define MC_EMEM_ARB_OUTSTANDING_REQ 0x94 | ||
268 | #define MC_EMEM_ARB_OUTSTANDING_REQ_MAX_SHIFT 0 | ||
269 | #define MC_EMEM_ARB_OUTSTANDING_REQ_MAX_MASK \ | ||
270 | (0x1FF << MC_EMEM_ARB_OUTSTANDING_REQ_MAX_SHIFT) | ||
271 | #define MC_EMEM_ARB_OUTSTANDING_REQ_HOLDOFF_OVERRIDE (0x1 << 30) | ||
272 | #define MC_EMEM_ARB_OUTSTANDING_REQ_LIMIT_ENABLE (0x1 << 31) | ||
273 | #define MC_EMEM_ARB_TIMING_RCD 0x98 | ||
274 | #define MC_EMEM_ARB_TIMING_RP 0x9c | ||
275 | #define MC_EMEM_ARB_TIMING_RC 0xa0 | ||
276 | #define MC_EMEM_ARB_TIMING_RAS 0xa4 | ||
277 | #define MC_EMEM_ARB_TIMING_FAW 0xa8 | ||
278 | #define MC_EMEM_ARB_TIMING_RRD 0xac | ||
279 | #define MC_EMEM_ARB_TIMING_RAP2PRE 0xb0 | ||
280 | #define MC_EMEM_ARB_TIMING_WAP2PRE 0xb4 | ||
281 | #define MC_EMEM_ARB_TIMING_R2R 0xb8 | ||
282 | #define MC_EMEM_ARB_TIMING_W2W 0xbc | ||
283 | #define MC_EMEM_ARB_TIMING_R2W 0xc0 | ||
284 | #define MC_EMEM_ARB_TIMING_W2R 0xc4 | ||
285 | #define MC_EMEM_ARB_DA_TURNS 0xd0 | ||
286 | #define MC_EMEM_ARB_DA_COVERS 0xd4 | ||
287 | #define MC_EMEM_ARB_MISC0 0xd8 | ||
288 | #define MC_EMEM_ARB_MISC0_EMC_SAME_FREQ (0x1 << 27) | ||
289 | #define MC_EMEM_ARB_MISC1 0xdc | ||
290 | #define MC_EMEM_ARB_RING1_THROTTLE 0xe0 | ||
291 | #define MC_EMEM_ARB_RING3_THROTTLE 0xe4 | ||
292 | #define MC_EMEM_ARB_OVERRIDE 0xe8 | ||
293 | #define MC_EMEM_ARB_OVERRIDE_EACK_MASK (0x3 << 0) | ||
294 | #define MC_TIMING_CONTROL 0xfc | ||
295 | #define MC_RESERVED_RSV 0x3fc | ||
296 | |||
297 | #endif | ||