3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
5 * See file CREDITS for list of people who contributed to this
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.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
31 #include <asm/m8260_pci.h>
35 #define deb_printf(fmt,arg...) \
36 printf ("TQM8272 %s %s: " fmt,__FILE__, __FUNCTION__, ##arg)
38 #define deb_printf(fmt,arg...) \
42 #if defined(CONFIG_BOARD_GET_CPU_CLK_F)
43 unsigned long board_get_cpu_clk_f (void);
47 * I/O Port configuration table
49 * if conf is 1, then that port pin will be configured at boot time
50 * according to the five values podr/pdir/ppar/psor/pdat for that entry
53 const iop_conf_t iop_conf_tab[4][32] = {
55 /* Port A configuration */
56 { /* conf ppar psor pdir podr pdat */
57 /* PA31 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 *ATMTXEN */
58 /* PA30 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTCA */
59 /* PA29 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTSOC */
60 /* PA28 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 *ATMRXEN */
61 /* PA27 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRSOC */
62 /* PA26 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRCA */
63 /* PA25 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
64 /* PA24 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
65 /* PA23 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
66 /* PA22 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
67 /* PA21 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
68 /* PA20 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
69 /* PA19 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
70 /* PA18 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
71 /* PA17 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[7] */
72 /* PA16 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[6] */
73 /* PA15 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[5] */
74 /* PA14 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[4] */
75 /* PA13 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[3] */
76 /* PA12 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[2] */
77 /* PA11 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[1] */
78 /* PA10 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[0] */
79 /* PA9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC2 TXD */
80 /* PA8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC2 RXD */
81 /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
82 /* PA6 */ { 0, 0, 0, 1, 0, 0 }, /* PA6 */
83 /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
84 /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
85 /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
86 /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
87 /* PA1 */ { 0, 0, 0, 1, 0, 0 }, /* PA1 */
88 /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
91 /* Port B configuration */
92 { /* conf ppar psor pdir podr pdat */
93 /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
94 /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
95 /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
96 /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
97 /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
98 /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
99 /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
100 /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
101 /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
102 /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
103 /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
104 /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
105 /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
106 /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
107 /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* PB17 */
108 /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* PB16 */
109 /* PB15 */ { 0, 0, 0, 0, 0, 0 }, /* PB15 */
110 /* PB14 */ { 0, 0, 0, 0, 0, 0 }, /* PB14 */
111 /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* PB13 */
112 /* PB12 */ { 0, 0, 0, 0, 0, 0 }, /* PB12 */
113 /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* PB11 */
114 /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* PB10 */
115 /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* PB9 */
116 /* PB8 */ { 0, 0, 0, 0, 0, 0 }, /* PB8 */
117 /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
118 /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* PB6 */
119 /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* PB5 */
120 /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* PB4 */
121 /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
122 /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
123 /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
124 /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
128 { /* conf ppar psor pdir podr pdat */
129 /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
130 /* PC30 */ { 0, 0, 0, 0, 0, 0 }, /* PC30 */
131 /* PC29 */ { 1, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
132 /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
133 /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* PC27 */
134 /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
135 /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
136 /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
137 /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
138 /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
139 /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
140 /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
141 /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK */
142 /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII TX_CLK */
143 /* PC17 */ { 1, 0, 0, 1, 0, 0 }, /* PC17 MDC */
144 /* PC16 */ { 1, 0, 0, 0, 0, 0 }, /* PC16 MDIO*/
145 /* PC15 */ { 0, 0, 0, 1, 0, 0 }, /* PC15 */
146 /* PC14 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
147 /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
148 /* PC12 */ { 0, 0, 0, 1, 0, 0 }, /* PC12 */
149 /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* PC11 */
150 /* PC10 */ { 0, 0, 0, 1, 0, 0 }, /* PC10 */
151 /* PC9 */ { 0, 0, 0, 1, 0, 0 }, /* PC9 */
152 /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
153 /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
154 /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
155 /* PC5 */ { 1, 1, 0, 1, 0, 0 }, /* PC5 SMC1 TXD */
156 /* PC4 */ { 1, 1, 0, 0, 0, 0 }, /* PC4 SMC1 RXD */
157 /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
158 /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
159 /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
160 /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
164 { /* conf ppar psor pdir podr pdat */
165 /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
166 /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
167 /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
168 /* PD28 */ { 0, 0, 0, 1, 0, 0 }, /* PD28 */
169 /* PD27 */ { 0, 0, 0, 1, 0, 0 }, /* PD27 */
170 /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
171 /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
172 /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
173 /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
174 /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
175 /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
176 /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
177 /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
178 /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
179 /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
180 /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
181 #if defined(CONFIG_SOFT_I2C)
182 /* PD15 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SDA */
183 /* PD14 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SCL */
185 #if defined(CONFIG_HARD_I2C)
186 /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
187 /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
188 #else /* normal I/O port pins */
189 /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
190 /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */
193 /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
194 /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
195 /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
196 /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
197 /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
198 /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
199 /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
200 /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
201 /* PD5 */ { 0, 0, 0, 1, 0, 0 }, /* PD5 */
202 /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
203 /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
204 /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
205 /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
206 /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
210 #define _NOT_USED_ 0xFFFFFFFF
212 /* UPM pattern for bus clock = 66.7 MHz */
213 static const uint upmTable67[] =
215 /* Offset UPM Read Single RAM array entry -> NAND Read Data */
216 /* 0x00 */ 0x0fa3f100, 0x0fa3b000, 0x0fa33100, 0x0fa33000,
217 /* 0x04 */ 0x0fa33000, 0x0fa33004, 0xfffffc01, 0xfffffc00,
219 /* UPM Read Burst RAM array entry -> unused */
220 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
221 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
223 /* UPM Read Burst RAM array entry -> unused */
224 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
225 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
227 /* UPM Write Single RAM array entry -> NAND Write Data, ADDR and CMD */
228 /* 0x18 */ 0x00a3fc00, 0x00a3fc00, 0x00a3fc00, 0x00a3fc00,
229 /* 0x1C */ 0x0fa3fc00, 0x0fa3fc04, 0xfffffc01, 0xfffffc00,
231 /* UPM Write Burst RAM array entry -> unused */
232 /* 0x20 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
233 /* 0x24 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
234 /* 0x28 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
235 /* 0x2C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
237 /* UPM Refresh Timer RAM array entry -> unused */
238 /* 0x30 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
239 /* 0x34 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
240 /* 0x38 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
242 /* UPM Exception RAM array entry -> unsused */
243 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
246 /* UPM pattern for bus clock = 100 MHz */
247 static const uint upmTable100[] =
249 /* Offset UPM Read Single RAM array entry -> NAND Read Data */
250 /* 0x00 */ 0x0fa3f200, 0x0fa3b000, 0x0fa33300, 0x0fa33000,
251 /* 0x04 */ 0x0fa33000, 0x0fa33004, 0xfffffc01, 0xfffffc00,
253 /* UPM Read Burst RAM array entry -> unused */
254 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
255 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
257 /* UPM Read Burst RAM array entry -> unused */
258 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
259 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
261 /* UPM Write Single RAM array entry -> NAND Write Data, ADDR and CMD */
262 /* 0x18 */ 0x00a3ff00, 0x00a3fc00, 0x00a3fc00, 0x0fa3fc00,
263 /* 0x1C */ 0x0fa3fc00, 0x0fa3fc04, 0xfffffc01, 0xfffffc00,
265 /* UPM Write Burst RAM array entry -> unused */
266 /* 0x20 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
267 /* 0x24 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
268 /* 0x28 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
269 /* 0x2C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
271 /* UPM Refresh Timer RAM array entry -> unused */
272 /* 0x30 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
273 /* 0x34 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
274 /* 0x38 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
276 /* UPM Exception RAM array entry -> unsused */
277 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
280 /* UPM pattern for bus clock = 133.3 MHz */
281 static const uint upmTable133[] =
283 /* Offset UPM Read Single RAM array entry -> NAND Read Data */
284 /* 0x00 */ 0x0fa3f300, 0x0fa3b000, 0x0fa33300, 0x0fa33000,
285 /* 0x04 */ 0x0fa33200, 0x0fa33004, 0xfffffc01, 0xfffffc00,
287 /* UPM Read Burst RAM array entry -> unused */
288 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
289 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
291 /* UPM Read Burst RAM array entry -> unused */
292 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
293 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
295 /* UPM Write Single RAM array entry -> NAND Write Data, ADDR and CMD */
296 /* 0x18 */ 0x00a3ff00, 0x00a3fc00, 0x00a3fd00, 0x0fa3fc00,
297 /* 0x1C */ 0x0fa3fd00, 0x0fa3fc04, 0xfffffc01, 0xfffffc00,
299 /* UPM Write Burst RAM array entry -> unused */
300 /* 0x20 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
301 /* 0x24 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
302 /* 0x28 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
303 /* 0x2C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
305 /* UPM Refresh Timer RAM array entry -> unused */
306 /* 0x30 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
307 /* 0x34 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
308 /* 0x38 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
310 /* UPM Exception RAM array entry -> unsused */
311 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
314 static int chipsel = 0;
316 /* UPM pattern for slow init */
317 static const uint upmTableSlow[] =
319 /* Offset UPM Read Single RAM array entry */
320 /* 0x00 */ 0xffffee00, 0x00ffcc80, 0x00ffcf00, 0x00ffdc00,
321 /* 0x04 */ 0x00ffce80, 0x00ffcc00, 0x00ffee00, 0x3fffcc07,
323 /* UPM Read Burst RAM array entry -> unused */
324 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
325 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
327 /* UPM Read Burst RAM array entry -> unused */
328 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
329 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
331 /* UPM Write Single RAM array entry */
332 /* 0x18 */ 0xffffee00, 0x00ffec80, 0x00ffef00, 0x00fffc80,
333 /* 0x1C */ 0x00fffe00, 0x00ffec00, 0x0fffef00, 0x3fffec05,
335 /* UPM Write Burst RAM array entry -> unused */
336 /* 0x20 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
337 /* 0x24 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
338 /* 0x28 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
339 /* 0x2C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
341 /* UPM Refresh Timer RAM array entry -> unused */
342 /* 0x30 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
343 /* 0x34 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
344 /* 0x38 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
346 /* UPM Exception RAM array entry -> unused */
347 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
350 /* UPM pattern for fast init */
351 static const uint upmTableFast[] =
353 /* Offset UPM Read Single RAM array entry */
354 /* 0x00 */ 0xffffee00, 0x00ffcc80, 0x00ffcd80, 0x00ffdc00,
355 /* 0x04 */ 0x00ffdc00, 0x00ffcf00, 0x00ffec00, 0x3fffcc07,
357 /* UPM Read Burst RAM array entry -> unused */
358 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
359 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
361 /* UPM Read Burst RAM array entry -> unused */
362 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
363 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
365 /* UPM Write Single RAM array entry */
366 /* 0x18 */ 0xffffee00, 0x00ffec80, 0x00ffee80, 0x00fffc00,
367 /* 0x1C */ 0x00fffc00, 0x00ffec00, 0x0fffef00, 0x3fffec05,
369 /* UPM Write Burst RAM array entry -> unused */
370 /* 0x20 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
371 /* 0x24 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
372 /* 0x28 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
373 /* 0x2C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
375 /* UPM Refresh Timer RAM array entry -> unused */
376 /* 0x30 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
377 /* 0x34 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
378 /* 0x38 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
380 /* UPM Exception RAM array entry -> unused */
381 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
385 /* ------------------------------------------------------------------------- */
387 /* Check Board Identity:
389 int checkboard (void)
391 char *p = (char *) HWIB_INFO_START_ADDR;
394 if (*((unsigned long *)p) == (unsigned long)CFG_HWINFO_MAGIC) {
397 puts ("No HWIB assuming TQM8272");
404 /* ------------------------------------------------------------------------- */
405 #if defined(CONFIG_BOARD_GET_CPU_CLK_F)
406 static int get_cas_latency (void)
408 /* get it from the option -ts in CIB */
412 char *p = (char *) CIB_INFO_START_ADDR;
414 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
415 if (*p < ' ' || *p > '~') { /* ASCII strings! */
419 if ((p[1] == 't') && (p[2] == 's')) {
430 static ulong set_sdram_timing (volatile uint *sdmr_ptr, ulong sdmr, int col)
432 #if defined(CONFIG_BOARD_GET_CPU_CLK_F)
433 int clk = board_get_cpu_clk_f ();
434 volatile immap_t *immr = (immap_t *)CFG_IMMR;
435 int busmode = (immr->im_siu_conf.sc_bcr & BCR_EBM ? 1 : 0);
438 sdmr = sdmr & ~(PSDMR_RFRC_MSK | PSDMR_PRETOACT_MSK | PSDMR_WRC_MSK | \
443 sdmr |= (PSDMR_RFRC_66MHZ_60X | \
444 PSDMR_PRETOACT_66MHZ_60X | \
445 PSDMR_WRC_66MHZ_60X | \
446 PSDMR_BUFCMD_66MHZ_60X);
449 sdmr |= (PSDMR_RFRC_100MHZ_60X | \
450 PSDMR_PRETOACT_100MHZ_60X | \
451 PSDMR_WRC_100MHZ_60X | \
452 PSDMR_BUFCMD_100MHZ_60X);
459 sdmr |= (PSDMR_RFRC_66MHZ_SINGLE | \
460 PSDMR_PRETOACT_66MHZ_SINGLE | \
461 PSDMR_WRC_66MHZ_SINGLE | \
462 PSDMR_BUFCMD_66MHZ_SINGLE);
465 sdmr |= (PSDMR_RFRC_100MHZ_SINGLE | \
466 PSDMR_PRETOACT_100MHZ_SINGLE | \
467 PSDMR_WRC_100MHZ_SINGLE | \
468 PSDMR_BUFCMD_100MHZ_SINGLE);
471 sdmr |= (PSDMR_RFRC_133MHZ_SINGLE | \
472 PSDMR_PRETOACT_133MHZ_SINGLE | \
473 PSDMR_WRC_133MHZ_SINGLE | \
474 PSDMR_BUFCMD_133MHZ_SINGLE);
478 cas = get_cas_latency();
479 sdmr &=~ (PSDMR_CL_MSK | PSDMR_LDOTOPRE_MSK);
481 sdmr |= ((cas - 1) << 6);
488 /* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx
490 * This routine performs standard 8260 initialization sequence
491 * and calculates the available memory size. It may be called
492 * several times to try different SDRAM configurations on both
493 * 60x and local buses.
495 static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
496 ulong orx, volatile uchar * base, int col)
498 volatile uchar c = 0xff;
499 volatile uint *sdmr_ptr;
500 volatile uint *orx_ptr;
504 /* We must be able to test a location outsize the maximum legal size
505 * to find out THAT we are outside; but this address still has to be
506 * mapped by the controller. That means, that the initial mapping has
507 * to be (at least) twice as large as the maximum expected size.
509 maxsize = (1 + (~orx | 0x7fff)) / 2;
511 /* Since CFG_SDRAM_BASE is always 0 (??), we assume that
512 * we are configuring CS1 if base != 0
514 sdmr_ptr = base ? &memctl->memc_lsdmr : &memctl->memc_psdmr;
515 orx_ptr = base ? &memctl->memc_or2 : &memctl->memc_or1;
518 sdmr = set_sdram_timing (sdmr_ptr, sdmr, col);
520 * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
522 * "At system reset, initialization software must set up the
523 * programmable parameters in the memory controller banks registers
524 * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
525 * system software should execute the following initialization sequence
526 * for each SDRAM device.
528 * 1. Issue a PRECHARGE-ALL-BANKS command
529 * 2. Issue eight CBR REFRESH commands
530 * 3. Issue a MODE-SET command to initialize the mode register
532 * The initial commands are executed by setting P/LSDMR[OP] and
533 * accessing the SDRAM with a single-byte transaction."
535 * The appropriate BRx/ORx registers have already been set when we
536 * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
539 *sdmr_ptr = sdmr | PSDMR_OP_PREA;
542 *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
543 for (i = 0; i < 8; i++)
546 *sdmr_ptr = sdmr | PSDMR_OP_MRW;
547 *(base + CFG_MRS_OFFS) = c; /* setting MR on address lines */
549 *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
552 size = get_ram_size((long *)base, maxsize);
553 *orx_ptr = orx | ~(size - 1);
558 phys_size_t initdram (int board_type)
560 volatile immap_t *immap = (immap_t *) CFG_IMMR;
561 volatile memctl8260_t *memctl = &immap->im_memctl;
568 psize = 16 * 1024 * 1024;
571 memctl->memc_psrt = CFG_PSRT;
572 memctl->memc_mptpr = CFG_MPTPR;
577 size8 = try_init (memctl, CFG_PSDMR_8COL, CFG_OR1_8COL,
578 (uchar *) CFG_SDRAM_BASE, 8);
579 size9 = try_init (memctl, CFG_PSDMR_9COL, CFG_OR1_9COL,
580 (uchar *) CFG_SDRAM_BASE, 9);
584 printf ("(60x:9COL - %ld MB, ", psize >> 20);
586 psize = try_init (memctl, CFG_PSDMR_8COL, CFG_OR1_8COL,
587 (uchar *) CFG_SDRAM_BASE, 8);
588 printf ("(60x:8COL - %ld MB, ", psize >> 20);
591 #endif /* CFG_RAMBOOT */
599 static inline int scanChar (char *p, int len, unsigned long *number)
605 if ((*p >= '0') && (*p <= '9')) {
610 if (*p == '-') return akt;
629 unsigned long option;
637 unsigned char ethaddr[20];
640 HWIB_INFO hwinf = {0, 0, 1, 0, 1, 0, 0, 0, 0, 8272, 0 ,0,
643 static int dump_hwib(void)
645 HWIB_INFO *hw = &hwinf;
646 volatile immap_t *immr = (immap_t *)CFG_IMMR;
647 char *s = getenv("serial#");
650 printf ("HWIB on %x\n", HWIB_INFO_START_ADDR);
651 printf ("serial : %s\n", s);
652 printf ("ethaddr: %s\n", hw->ethaddr);
653 printf ("FLASH : %x nr:%d\n", hw->flash, hw->flash_nr);
654 printf ("RAM : %x cs:%d\n", hw->ram, hw->ram_cs);
655 printf ("CPU : %d\n", hw->cpunr);
656 printf ("CAN : %d\n", hw->can);
657 if (hw->eeprom) printf ("EEprom : %x\n", hw->eeprom);
658 else printf ("No EEprom\n");
660 printf ("NAND : %x\n", hw->nand);
661 printf ("NAND CS: %d\n", hw->nand_cs);
662 } else { printf ("No NAND\n");}
663 printf ("Bus %s mode.\n", (hw->Bus ? "60x" : "Single PQII"));
664 printf (" real : %s\n", (immr->im_siu_conf.sc_bcr & BCR_EBM ? \
665 "60x" : "Single PQII"));
666 printf ("Option : %x\n", hw->option);
667 printf ("%s Security Engine\n", (hw->SecEng ? "with" : "no"));
668 printf ("CPM Clk: %d\n", hw->cpmcl);
669 printf ("CPU Clk: %d\n", hw->cpucl);
670 printf ("Bus Clk: %d\n", hw->buscl);
671 if (hw->busclk_real_ok) {
672 printf (" real Clk: %d\n", hw->busclk_real);
674 printf ("CAS : %d\n", get_cas_latency());
676 printf("HWIB @%x not OK\n", HWIB_INFO_START_ADDR);
681 static inline int search_real_busclk (int *clk)
683 int part = 0, pos = 0;
684 char *p = (char *) CIB_INFO_START_ADDR;
687 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
688 if (*p < ' ' || *p > '~') { /* ASCII strings! */
730 int analyse_hwib (void)
732 char *p = (char *) HWIB_INFO_START_ADDR;
734 int part = 1, i = 0, pos = 0;
735 HWIB_INFO *hw = &hwinf;
737 deb_printf(" %s pointer: %p\n", __FUNCTION__, p);
739 if (*((unsigned long *)p) != (unsigned long)CFG_HWINFO_MAGIC) {
740 deb_printf("No HWIB\n");
744 if (scanChar (p, 4, &hw->cpunr) < 0) {
745 deb_printf("No CPU\n");
750 hw->flash = 0x200000 << (*p - 'A');
752 hw->flash_nr = *p - '0';
755 hw->ram = 0x2000000 << (*p - 'A');
762 if (*p == 'A') hw->can = 1;
763 if (*p == 'B') hw->can = 2;
765 p +=1; /* connector */
767 hw->eeprom = 0x1000 << (*p - 'A');
771 if ((*p < '0') || (*p > '9')) {
772 /* NAND before z-option */
773 hw->nand = 0x8000000 << (*p - 'A');
775 hw->nand_cs = *p - '0';
779 anz = scanChar (p, 4, &hw->option);
781 deb_printf("No option\n");
784 if (hw->option & 0x8) hw->Bus = 1;
787 deb_printf("No -\n");
797 case 'M': hw->cpucl = 266666666;
799 case 'P': hw->cpucl = 300000000;
801 case 'T': hw->cpucl = 400000000;
804 deb_printf("No CPU Clk: %c\n", *p);
810 case 'I': hw->cpmcl = 200000000;
812 case 'M': hw->cpmcl = 300000000;
815 deb_printf("No CPM Clk\n");
821 case 'B': hw->buscl = 66666666;
823 case 'E': hw->buscl = 100000000;
825 case 'F': hw->buscl = 133333333;
828 deb_printf("No BUS Clk\n");
835 /* search MAC Address */
836 while ((*p != '\0') && (pos < CFG_HWINFO_SIZE)) {
837 if (*p < ' ' || *p > '~') { /* ASCII strings! */
847 case 3: /* Copy MAC address */
853 hw->ethaddr[i++] = *p;
855 hw->ethaddr[i++] = ':';
862 hw->busclk_real_ok = search_real_busclk (&hw->busclk_real);
866 #if defined(CONFIG_GET_CPU_STR_F)
867 /* !! This routine runs from Flash */
868 char get_cpu_str_f (char *buf)
870 char *p = (char *) HWIB_INFO_START_ADDR;
876 if (*((unsigned long *)p) == (unsigned long)CFG_HWINFO_MAGIC) {
892 #if defined(CONFIG_BOARD_GET_CPU_CLK_F)
893 /* !! This routine runs from Flash */
894 unsigned long board_get_cpu_clk_f (void)
896 char *p = (char *) HWIB_INFO_START_ADDR;
899 if (*((unsigned long *)p) == (unsigned long)CFG_HWINFO_MAGIC) {
900 if (search_real_busclk (&i))
903 return CONFIG_8260_CLKIN;
907 #if CONFIG_BOARD_EARLY_INIT_R
909 static int can_test (unsigned long off)
911 volatile unsigned char *base = (unsigned char *) (CFG_CAN_BASE + off);
913 *(base + 0x17) = 'T';
914 *(base + 0x18) = 'Q';
915 *(base + 0x19) = 'M';
916 if ((*(base + 0x17) != 'T') ||
917 (*(base + 0x18) != 'Q') ||
918 (*(base + 0x19) != 'M')) {
924 static int can_config_one (unsigned long off)
926 volatile unsigned char *ctrl = (unsigned char *) (CFG_CAN_BASE + off);
927 volatile unsigned char *cpu_if = (unsigned char *) (CFG_CAN_BASE + off + 0x02);
928 volatile unsigned char *clkout = (unsigned char *) (CFG_CAN_BASE + off + 0x1f);
942 static int can_config (void)
946 if (hwinf.can == 2) {
947 can_config_one (0x100);
949 /* make Test if they really there */
951 ret += can_test (0x100);
955 static int init_can (void)
957 volatile immap_t * immr = (immap_t *)CFG_IMMR;
958 volatile memctl8260_t *memctl = &immr->im_memctl;
961 if ((hwinf.OK) && (hwinf.can)) {
962 memctl->memc_or4 = CFG_CAN_OR;
963 memctl->memc_br4 = CFG_CAN_BR;
965 upmconfig (UPMC, (uint *) upmTableFast,
966 sizeof (upmTableFast) / sizeof (uint));
967 memctl->memc_mcmr = (MxMR_DSx_3_CYCL |
973 count = can_config ();
974 printf ("CAN: %d @ %x\n", count, CFG_CAN_BASE);
975 if (hwinf.can != count) printf("!!! difference to HWIB\n");
977 printf ("CAN: No\n");
982 int board_early_init_r(void)
990 int do_hwib_dump (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
997 hwib, 1, 1, do_hwib_dump,
998 "hwib - dump HWIB'\n",
1002 #ifdef CFG_UPDATE_FLASH_SIZE
1003 static int get_flash_timing (void)
1005 /* get it from the option -tf in CIB */
1006 /* default is 0x00000c84 */
1007 int ret = 0x00000c84;
1010 char *p = (char *) CIB_INFO_START_ADDR;
1012 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
1013 if (*p < ' ' || *p > '~') { /* ASCII strings! */
1017 if ((p[1] == 't') && (p[2] == 'f')) {
1021 if ((*p >= '0') && (*p <= '9')) {
1026 } else if ((*p >= 'A') && (*p <= 'F')) {
1032 if (nr < 8) return 0x00000c84;
1044 /* Update the Flash_Size and the Flash Timing */
1045 int update_flash_size (int flash_size)
1047 volatile immap_t * immr = (immap_t *)CFG_IMMR;
1048 volatile memctl8260_t *memctl = &immr->im_memctl;
1052 /* I must use reg, otherwise the board hang */
1053 reg = memctl->memc_or0;
1054 reg &= ~ORxU_AM_MSK;
1055 reg |= MEG_TO_AM(flash_size >> 20);
1056 tim = get_flash_timing ();
1058 reg |= (tim & 0xfff);
1059 memctl->memc_or0 = reg;
1064 #if defined(CONFIG_CMD_NAND)
1067 #include <linux/mtd/mtd.h>
1069 static u8 hwctl = 0;
1071 static void upmnand_hwcontrol(struct mtd_info *mtdinfo, int cmd)
1074 case NAND_CTL_SETCLE:
1077 case NAND_CTL_CLRCLE:
1081 case NAND_CTL_SETALE:
1085 case NAND_CTL_CLRALE:
1091 static void upmnand_write_byte(struct mtd_info *mtdinfo, u_char byte)
1093 struct nand_chip *this = mtdinfo->priv;
1094 ulong base = (ulong) (this->IO_ADDR_W + chipsel * CFG_NAND_CS_DIST);
1097 WRITE_NAND_UPM(byte, base, CFG_NAND_UPM_WRITE_CMD_OFS);
1098 } else if (hwctl & 0x2) {
1099 WRITE_NAND_UPM(byte, base, CFG_NAND_UPM_WRITE_ADDR_OFS);
1101 WRITE_NAND(byte, base);
1105 static u_char upmnand_read_byte(struct mtd_info *mtdinfo)
1107 struct nand_chip *this = mtdinfo->priv;
1108 ulong base = (ulong) (this->IO_ADDR_W + chipsel * CFG_NAND_CS_DIST);
1110 return READ_NAND(base);
1113 static int tqm8272_dev_ready(struct mtd_info *mtdinfo)
1115 /* constant delay (see also tR in the datasheet) */
1120 #ifndef CONFIG_NAND_SPL
1121 static void tqm8272_read_buf(struct mtd_info *mtdinfo, uint8_t *buf, int len)
1123 struct nand_chip *this = mtdinfo->priv;
1124 unsigned char *base = (unsigned char *) (this->IO_ADDR_W + chipsel * CFG_NAND_CS_DIST);
1127 for (i = 0; i< len; i++)
1131 static void tqm8272_write_buf(struct mtd_info *mtdinfo, const uint8_t *buf, int len)
1133 struct nand_chip *this = mtdinfo->priv;
1134 unsigned char *base = (unsigned char *) (this->IO_ADDR_W + chipsel * CFG_NAND_CS_DIST);
1137 for (i = 0; i< len; i++)
1141 static int tqm8272_verify_buf(struct mtd_info *mtdinfo, const uint8_t *buf, int len)
1143 struct nand_chip *this = mtdinfo->priv;
1144 unsigned char *base = (unsigned char *) (this->IO_ADDR_W + chipsel * CFG_NAND_CS_DIST);
1147 for (i = 0; i < len; i++)
1148 if (buf[i] != *base)
1152 #endif /* #ifndef CONFIG_NAND_SPL */
1154 void board_nand_select_device(struct nand_chip *nand, int chip)
1159 int board_nand_init(struct nand_chip *nand)
1161 static int UpmInit = 0;
1162 volatile immap_t * immr = (immap_t *)CFG_IMMR;
1163 volatile memctl8260_t *memctl = &immr->im_memctl;
1165 if (hwinf.nand == 0) return -1;
1169 switch (hwinf.busclk_real) {
1171 upmconfig (UPMB, (uint *) upmTable100,
1172 sizeof (upmTable100) / sizeof (uint));
1175 upmconfig (UPMB, (uint *) upmTable133,
1176 sizeof (upmTable133) / sizeof (uint));
1179 upmconfig (UPMB, (uint *) upmTable67,
1180 sizeof (upmTable67) / sizeof (uint));
1186 /* Setup the memctrl */
1187 memctl->memc_or3 = CFG_NAND_OR;
1188 memctl->memc_br3 = CFG_NAND_BR;
1189 memctl->memc_mbmr = (MxMR_OP_NORM);
1191 nand->eccmode = NAND_ECC_SOFT;
1193 nand->hwcontrol = upmnand_hwcontrol;
1194 nand->read_byte = upmnand_read_byte;
1195 nand->write_byte = upmnand_write_byte;
1196 nand->dev_ready = tqm8272_dev_ready;
1198 #ifndef CONFIG_NAND_SPL
1199 nand->write_buf = tqm8272_write_buf;
1200 nand->read_buf = tqm8272_read_buf;
1201 nand->verify_buf = tqm8272_verify_buf;
1205 * Select required NAND chip
1207 board_nand_select_device(nand, 0);
1214 struct pci_controller hose;
1216 int board_early_init_f (void)
1218 volatile immap_t *immap = (immap_t *) CFG_IMMR;
1220 immap->im_clkrst.car_sccr |= M826X_SCCR_PCI_MODE_EN;
1224 extern void pci_mpc8250_init(struct pci_controller *);
1226 void pci_init_board(void)
1228 pci_mpc8250_init(&hose);