2 * File: include/asm-blackfin/mach-bf548/mem_init.h
12 * Copyright 2004-2006 Analog Devices Inc.
14 * Bugs: Enter bugs at http://blackfin.uclinux.org/
16 * This program is free software; you can redistribute it and/or modify
17 * it under the terms of the GNU General Public License as published by
18 * the Free Software Foundation; either version 2, or (at your option)
21 * This program is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU General Public License for more details.
26 * You should have received a copy of the GNU General Public License
27 * along with this program; see the file COPYING.
28 * If not, write to the Free Software Foundation,
29 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
31 #define MIN_DDR_SCLK(x) (x*(CONFIG_SCLK_HZ/1000/1000)/1000 + 1)
32 #define MAX_DDR_SCLK(x) (x*(CONFIG_SCLK_HZ/1000/1000)/1000)
33 #define DDR_CLK_HZ(x) (1000*1000*1000/x)
35 #if (CONFIG_MEM_MT46V32M16_6T)
36 #define DDR_SIZE DEVSZ_512
37 #define DDR_WIDTH DEVWD_16
38 #define DDR_MAX_tCK 13
40 #define DDR_tRC DDR_TRC(MIN_DDR_SCLK(60))
41 #define DDR_tRAS DDR_TRAS(MIN_DDR_SCLK(42))
42 #define DDR_tRP DDR_TRP(MIN_DDR_SCLK(15))
43 #define DDR_tRFC DDR_TRFC(MIN_DDR_SCLK(72))
44 #define DDR_tREFI DDR_TREFI(MAX_DDR_SCLK(7800))
46 #define DDR_tRCD DDR_TRCD(MIN_DDR_SCLK(15))
47 #define DDR_tWTR DDR_TWTR(1)
48 #define DDR_tMRD DDR_TMRD(MIN_DDR_SCLK(12))
49 #define DDR_tWR DDR_TWR(MIN_DDR_SCLK(15))
52 #if (CONFIG_MEM_MT46V32M16_5B)
53 #define DDR_SIZE DEVSZ_512
54 #define DDR_WIDTH DEVWD_16
55 #define DDR_MAX_tCK 13
57 #define DDR_tRC DDR_TRC(MIN_DDR_SCLK(55))
58 #define DDR_tRAS DDR_TRAS(MIN_DDR_SCLK(40))
59 #define DDR_tRP DDR_TRP(MIN_DDR_SCLK(15))
60 #define DDR_tRFC DDR_TRFC(MIN_DDR_SCLK(70))
61 #define DDR_tREFI DDR_TREFI(MAX_DDR_SCLK(7800))
63 #define DDR_tRCD DDR_TRCD(MIN_DDR_SCLK(15))
64 #define DDR_tWTR DDR_TWTR(2)
65 #define DDR_tMRD DDR_TMRD(MIN_DDR_SCLK(10))
66 #define DDR_tWR DDR_TWR(MIN_DDR_SCLK(15))
69 #if (CONFIG_MEM_GENERIC_BOARD)
70 #define DDR_SIZE DEVSZ_512
71 #define DDR_WIDTH DEVWD_16
72 #define DDR_MAX_tCK 13
74 #define DDR_tRCD DDR_TRCD(3)
75 #define DDR_tWTR DDR_TWTR(2)
76 #define DDR_tWR DDR_TWR(2)
77 #define DDR_tMRD DDR_TMRD(2)
78 #define DDR_tRP DDR_TRP(3)
79 #define DDR_tRAS DDR_TRAS(7)
80 #define DDR_tRC DDR_TRC(10)
81 #define DDR_tRFC DDR_TRFC(12)
82 #define DDR_tREFI DDR_TREFI(1288)
85 #if (CONFIG_SCLK_HZ < DDR_CLK_HZ(DDR_MAX_tCK))
86 # error "CONFIG_SCLK_HZ is too small (<DDR_CLK_HZ(DDR_MAX_tCK) Hz)."
87 #elif(CONFIG_SCLK_HZ <= 133333333)
90 # error "CONFIG_SCLK_HZ is too large (>133333333 Hz)."
94 #define mem_DDRCTL0 (DDR_tRP | DDR_tRAS | DDR_tRC | DDR_tRFC | DDR_tREFI)
95 #define mem_DDRCTL1 (DDR_DATWIDTH | EXTBANK_1 | DDR_SIZE | DDR_WIDTH | DDR_tWTR \
96 | DDR_tMRD | DDR_tWR | DDR_tRCD)
97 #define mem_DDRCTL2 DDR_CL
100 #if defined CONFIG_CLKIN_HALF
106 #if defined CONFIG_PLL_BYPASS
112 /***************************************Currently Not Being Used *********************************/
113 #define flash_EBIU_AMBCTL_WAT ((CONFIG_FLASH_SPEED_BWAT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
114 #define flash_EBIU_AMBCTL_RAT ((CONFIG_FLASH_SPEED_BRAT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
115 #define flash_EBIU_AMBCTL_HT ((CONFIG_FLASH_SPEED_BHT * 4) / (4000000000 / CONFIG_SCLK_HZ))
116 #define flash_EBIU_AMBCTL_ST ((CONFIG_FLASH_SPEED_BST * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
117 #define flash_EBIU_AMBCTL_TT ((CONFIG_FLASH_SPEED_BTT * 4) / (4000000000 / CONFIG_SCLK_HZ)) + 1
119 #if (flash_EBIU_AMBCTL_TT > 3)
120 #define flash_EBIU_AMBCTL0_TT B0TT_4
122 #if (flash_EBIU_AMBCTL_TT == 3)
123 #define flash_EBIU_AMBCTL0_TT B0TT_3
125 #if (flash_EBIU_AMBCTL_TT == 2)
126 #define flash_EBIU_AMBCTL0_TT B0TT_2
128 #if (flash_EBIU_AMBCTL_TT < 2)
129 #define flash_EBIU_AMBCTL0_TT B0TT_1
132 #if (flash_EBIU_AMBCTL_ST > 3)
133 #define flash_EBIU_AMBCTL0_ST B0ST_4
135 #if (flash_EBIU_AMBCTL_ST == 3)
136 #define flash_EBIU_AMBCTL0_ST B0ST_3
138 #if (flash_EBIU_AMBCTL_ST == 2)
139 #define flash_EBIU_AMBCTL0_ST B0ST_2
141 #if (flash_EBIU_AMBCTL_ST < 2)
142 #define flash_EBIU_AMBCTL0_ST B0ST_1
145 #if (flash_EBIU_AMBCTL_HT > 2)
146 #define flash_EBIU_AMBCTL0_HT B0HT_3
148 #if (flash_EBIU_AMBCTL_HT == 2)
149 #define flash_EBIU_AMBCTL0_HT B0HT_2
151 #if (flash_EBIU_AMBCTL_HT == 1)
152 #define flash_EBIU_AMBCTL0_HT B0HT_1
154 #if (flash_EBIU_AMBCTL_HT == 0 && CONFIG_FLASH_SPEED_BHT == 0)
155 #define flash_EBIU_AMBCTL0_HT B0HT_0
157 #if (flash_EBIU_AMBCTL_HT == 0 && CONFIG_FLASH_SPEED_BHT != 0)
158 #define flash_EBIU_AMBCTL0_HT B0HT_1
161 #if (flash_EBIU_AMBCTL_WAT > 14)
162 #define flash_EBIU_AMBCTL0_WAT B0WAT_15
164 #if (flash_EBIU_AMBCTL_WAT == 14)
165 #define flash_EBIU_AMBCTL0_WAT B0WAT_14
167 #if (flash_EBIU_AMBCTL_WAT == 13)
168 #define flash_EBIU_AMBCTL0_WAT B0WAT_13
170 #if (flash_EBIU_AMBCTL_WAT == 12)
171 #define flash_EBIU_AMBCTL0_WAT B0WAT_12
173 #if (flash_EBIU_AMBCTL_WAT == 11)
174 #define flash_EBIU_AMBCTL0_WAT B0WAT_11
176 #if (flash_EBIU_AMBCTL_WAT == 10)
177 #define flash_EBIU_AMBCTL0_WAT B0WAT_10
179 #if (flash_EBIU_AMBCTL_WAT == 9)
180 #define flash_EBIU_AMBCTL0_WAT B0WAT_9
182 #if (flash_EBIU_AMBCTL_WAT == 8)
183 #define flash_EBIU_AMBCTL0_WAT B0WAT_8
185 #if (flash_EBIU_AMBCTL_WAT == 7)
186 #define flash_EBIU_AMBCTL0_WAT B0WAT_7
188 #if (flash_EBIU_AMBCTL_WAT == 6)
189 #define flash_EBIU_AMBCTL0_WAT B0WAT_6
191 #if (flash_EBIU_AMBCTL_WAT == 5)
192 #define flash_EBIU_AMBCTL0_WAT B0WAT_5
194 #if (flash_EBIU_AMBCTL_WAT == 4)
195 #define flash_EBIU_AMBCTL0_WAT B0WAT_4
197 #if (flash_EBIU_AMBCTL_WAT == 3)
198 #define flash_EBIU_AMBCTL0_WAT B0WAT_3
200 #if (flash_EBIU_AMBCTL_WAT == 2)
201 #define flash_EBIU_AMBCTL0_WAT B0WAT_2
203 #if (flash_EBIU_AMBCTL_WAT == 1)
204 #define flash_EBIU_AMBCTL0_WAT B0WAT_1
207 #if (flash_EBIU_AMBCTL_RAT > 14)
208 #define flash_EBIU_AMBCTL0_RAT B0RAT_15
210 #if (flash_EBIU_AMBCTL_RAT == 14)
211 #define flash_EBIU_AMBCTL0_RAT B0RAT_14
213 #if (flash_EBIU_AMBCTL_RAT == 13)
214 #define flash_EBIU_AMBCTL0_RAT B0RAT_13
216 #if (flash_EBIU_AMBCTL_RAT == 12)
217 #define flash_EBIU_AMBCTL0_RAT B0RAT_12
219 #if (flash_EBIU_AMBCTL_RAT == 11)
220 #define flash_EBIU_AMBCTL0_RAT B0RAT_11
222 #if (flash_EBIU_AMBCTL_RAT == 10)
223 #define flash_EBIU_AMBCTL0_RAT B0RAT_10
225 #if (flash_EBIU_AMBCTL_RAT == 9)
226 #define flash_EBIU_AMBCTL0_RAT B0RAT_9
228 #if (flash_EBIU_AMBCTL_RAT == 8)
229 #define flash_EBIU_AMBCTL0_RAT B0RAT_8
231 #if (flash_EBIU_AMBCTL_RAT == 7)
232 #define flash_EBIU_AMBCTL0_RAT B0RAT_7
234 #if (flash_EBIU_AMBCTL_RAT == 6)
235 #define flash_EBIU_AMBCTL0_RAT B0RAT_6
237 #if (flash_EBIU_AMBCTL_RAT == 5)
238 #define flash_EBIU_AMBCTL0_RAT B0RAT_5
240 #if (flash_EBIU_AMBCTL_RAT == 4)
241 #define flash_EBIU_AMBCTL0_RAT B0RAT_4
243 #if (flash_EBIU_AMBCTL_RAT == 3)
244 #define flash_EBIU_AMBCTL0_RAT B0RAT_3
246 #if (flash_EBIU_AMBCTL_RAT == 2)
247 #define flash_EBIU_AMBCTL0_RAT B0RAT_2
249 #if (flash_EBIU_AMBCTL_RAT == 1)
250 #define flash_EBIU_AMBCTL0_RAT B0RAT_1
253 #define flash_EBIU_AMBCTL0 \
254 (flash_EBIU_AMBCTL0_WAT | flash_EBIU_AMBCTL0_RAT | flash_EBIU_AMBCTL0_HT | \
255 flash_EBIU_AMBCTL0_ST | flash_EBIU_AMBCTL0_TT | CONFIG_FLASH_SPEED_RDYEN)