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>
33 #if CONFIG_OF_FLAT_TREE
39 #define deb_printf(fmt,arg...) \
40 printf ("TQM8272 %s %s: " fmt,__FILE__, __FUNCTION__, ##arg)
42 #define deb_printf(fmt,arg...) \
46 #if defined(CONFIG_BOARD_GET_CPU_CLK_F)
47 unsigned long board_get_cpu_clk_f (void);
51 * I/O Port configuration table
53 * if conf is 1, then that port pin will be configured at boot time
54 * according to the five values podr/pdir/ppar/psor/pdat for that entry
57 const iop_conf_t iop_conf_tab[4][32] = {
59 /* Port A configuration */
60 { /* conf ppar psor pdir podr pdat */
61 /* PA31 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 *ATMTXEN */
62 /* PA30 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTCA */
63 /* PA29 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTSOC */
64 /* PA28 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 *ATMRXEN */
65 /* PA27 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRSOC */
66 /* PA26 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRCA */
67 /* PA25 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
68 /* PA24 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
69 /* PA23 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
70 /* PA22 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
71 /* PA21 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
72 /* PA20 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
73 /* PA19 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
74 /* PA18 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
75 /* PA17 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[7] */
76 /* PA16 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[6] */
77 /* PA15 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[5] */
78 /* PA14 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[4] */
79 /* PA13 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[3] */
80 /* PA12 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[2] */
81 /* PA11 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[1] */
82 /* PA10 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[0] */
83 /* PA9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC2 TXD */
84 /* PA8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC2 RXD */
85 /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
86 /* PA6 */ { 0, 0, 0, 1, 0, 0 }, /* PA6 */
87 /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
88 /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
89 /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
90 /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
91 /* PA1 */ { 0, 0, 0, 1, 0, 0 }, /* PA1 */
92 /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
95 /* Port B configuration */
96 { /* conf ppar psor pdir podr pdat */
97 /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
98 /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
99 /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
100 /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
101 /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
102 /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
103 /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
104 /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
105 /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
106 /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
107 /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
108 /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
109 /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
110 /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
111 /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* PB17 */
112 /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* PB16 */
113 /* PB15 */ { 0, 0, 0, 0, 0, 0 }, /* PB15 */
114 /* PB14 */ { 0, 0, 0, 0, 0, 0 }, /* PB14 */
115 /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* PB13 */
116 /* PB12 */ { 0, 0, 0, 0, 0, 0 }, /* PB12 */
117 /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* PB11 */
118 /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* PB10 */
119 /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* PB9 */
120 /* PB8 */ { 0, 0, 0, 0, 0, 0 }, /* PB8 */
121 /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
122 /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* PB6 */
123 /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* PB5 */
124 /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* PB4 */
125 /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
126 /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
127 /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
128 /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
132 { /* conf ppar psor pdir podr pdat */
133 /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
134 /* PC30 */ { 0, 0, 0, 0, 0, 0 }, /* PC30 */
135 /* PC29 */ { 1, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
136 /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
137 /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* PC27 */
138 /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
139 /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
140 /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
141 /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
142 /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
143 /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
144 /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
145 /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK */
146 /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII TX_CLK */
147 /* PC17 */ { 1, 0, 0, 1, 0, 0 }, /* PC17 MDC */
148 /* PC16 */ { 1, 0, 0, 0, 0, 0 }, /* PC16 MDIO*/
149 /* PC15 */ { 0, 0, 0, 1, 0, 0 }, /* PC15 */
150 /* PC14 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
151 /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
152 /* PC12 */ { 0, 0, 0, 1, 0, 0 }, /* PC12 */
153 /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* PC11 */
154 /* PC10 */ { 0, 0, 0, 1, 0, 0 }, /* PC10 */
155 /* PC9 */ { 0, 0, 0, 1, 0, 0 }, /* PC9 */
156 /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
157 /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
158 /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
159 /* PC5 */ { 1, 1, 0, 1, 0, 0 }, /* PC5 SMC1 TXD */
160 /* PC4 */ { 1, 1, 0, 0, 0, 0 }, /* PC4 SMC1 RXD */
161 /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
162 /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
163 /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
164 /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
168 { /* conf ppar psor pdir podr pdat */
169 /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
170 /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
171 /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
172 /* PD28 */ { 0, 0, 0, 1, 0, 0 }, /* PD28 */
173 /* PD27 */ { 0, 0, 0, 1, 0, 0 }, /* PD27 */
174 /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
175 /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
176 /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
177 /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
178 /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
179 /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
180 /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
181 /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
182 /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
183 /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
184 /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
185 #if defined(CONFIG_SOFT_I2C)
186 /* PD15 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SDA */
187 /* PD14 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SCL */
189 #if defined(CONFIG_HARD_I2C)
190 /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
191 /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
192 #else /* normal I/O port pins */
193 /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
194 /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */
197 /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
198 /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
199 /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
200 /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
201 /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
202 /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
203 /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
204 /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
205 /* PD5 */ { 0, 0, 0, 1, 0, 0 }, /* PD5 */
206 /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
207 /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
208 /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
209 /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
210 /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
214 #define _NOT_USED_ 0xFFFFFFFF
216 /* UPM pattern for bus clock = 66.7 MHz */
217 static const uint upmTable67[] =
219 /* Offset UPM Read Single RAM array entry -> NAND Read Data */
220 /* 0x00 */ 0x0fa3f100, 0x0fa3b000, 0x0fa33100, 0x0fa33000,
221 /* 0x04 */ 0x0fa33000, 0x0fa33004, 0xfffffc01, 0xfffffc00,
223 /* UPM Read Burst RAM array entry -> unused */
224 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
225 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
227 /* UPM Read Burst RAM array entry -> unused */
228 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
229 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
231 /* UPM Write Single RAM array entry -> NAND Write Data, ADDR and CMD */
232 /* 0x18 */ 0x00a3fc00, 0x00a3fc00, 0x00a3fc00, 0x00a3fc00,
233 /* 0x1C */ 0x0fa3fc00, 0x0fa3fc04, 0xfffffc01, 0xfffffc00,
235 /* UPM Write Burst RAM array entry -> unused */
236 /* 0x20 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
237 /* 0x24 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
238 /* 0x28 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
239 /* 0x2C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
241 /* UPM Refresh Timer RAM array entry -> unused */
242 /* 0x30 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
243 /* 0x34 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
244 /* 0x38 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
246 /* UPM Exception RAM array entry -> unsused */
247 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
250 /* UPM pattern for bus clock = 100 MHz */
251 static const uint upmTable100[] =
253 /* Offset UPM Read Single RAM array entry -> NAND Read Data */
254 /* 0x00 */ 0x0fa3f200, 0x0fa3b000, 0x0fa33300, 0x0fa33000,
255 /* 0x04 */ 0x0fa33000, 0x0fa33004, 0xfffffc01, 0xfffffc00,
257 /* UPM Read Burst RAM array entry -> unused */
258 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
259 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
261 /* UPM Read Burst RAM array entry -> unused */
262 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
263 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
265 /* UPM Write Single RAM array entry -> NAND Write Data, ADDR and CMD */
266 /* 0x18 */ 0x00a3ff00, 0x00a3fc00, 0x00a3fc00, 0x0fa3fc00,
267 /* 0x1C */ 0x0fa3fc00, 0x0fa3fc04, 0xfffffc01, 0xfffffc00,
269 /* UPM Write Burst RAM array entry -> unused */
270 /* 0x20 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
271 /* 0x24 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
272 /* 0x28 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
273 /* 0x2C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
275 /* UPM Refresh Timer RAM array entry -> unused */
276 /* 0x30 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
277 /* 0x34 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
278 /* 0x38 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
280 /* UPM Exception RAM array entry -> unsused */
281 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
284 /* UPM pattern for bus clock = 133.3 MHz */
285 static const uint upmTable133[] =
287 /* Offset UPM Read Single RAM array entry -> NAND Read Data */
288 /* 0x00 */ 0x0fa3f300, 0x0fa3b000, 0x0fa33300, 0x0fa33000,
289 /* 0x04 */ 0x0fa33200, 0x0fa33004, 0xfffffc01, 0xfffffc00,
291 /* UPM Read Burst RAM array entry -> unused */
292 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
293 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
295 /* UPM Read Burst RAM array entry -> unused */
296 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
297 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
299 /* UPM Write Single RAM array entry -> NAND Write Data, ADDR and CMD */
300 /* 0x18 */ 0x00a3ff00, 0x00a3fc00, 0x00a3fd00, 0x0fa3fc00,
301 /* 0x1C */ 0x0fa3fd00, 0x0fa3fc04, 0xfffffc01, 0xfffffc00,
303 /* UPM Write Burst RAM array entry -> unused */
304 /* 0x20 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
305 /* 0x24 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
306 /* 0x28 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
307 /* 0x2C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
309 /* UPM Refresh Timer RAM array entry -> unused */
310 /* 0x30 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
311 /* 0x34 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
312 /* 0x38 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
314 /* UPM Exception RAM array entry -> unsused */
315 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
318 static int chipsel = 0;
320 /* UPM pattern for slow init */
321 static const uint upmTableSlow[] =
323 /* Offset UPM Read Single RAM array entry */
324 /* 0x00 */ 0xffffee00, 0x00ffcc80, 0x00ffcf00, 0x00ffdc00,
325 /* 0x04 */ 0x00ffce80, 0x00ffcc00, 0x00ffee00, 0x3fffcc07,
327 /* UPM Read Burst RAM array entry -> unused */
328 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
329 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
331 /* UPM Read Burst RAM array entry -> unused */
332 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
333 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
335 /* UPM Write Single RAM array entry */
336 /* 0x18 */ 0xffffee00, 0x00ffec80, 0x00ffef00, 0x00fffc80,
337 /* 0x1C */ 0x00fffe00, 0x00ffec00, 0x0fffef00, 0x3fffec05,
339 /* UPM Write Burst RAM array entry -> unused */
340 /* 0x20 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
341 /* 0x24 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
342 /* 0x28 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
343 /* 0x2C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
345 /* UPM Refresh Timer RAM array entry -> unused */
346 /* 0x30 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
347 /* 0x34 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
348 /* 0x38 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
350 /* UPM Exception RAM array entry -> unused */
351 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
354 /* UPM pattern for fast init */
355 static const uint upmTableFast[] =
357 /* Offset UPM Read Single RAM array entry */
358 /* 0x00 */ 0xffffee00, 0x00ffcc80, 0x00ffcd80, 0x00ffdc00,
359 /* 0x04 */ 0x00ffdc00, 0x00ffcf00, 0x00ffec00, 0x3fffcc07,
361 /* UPM Read Burst RAM array entry -> unused */
362 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
363 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
365 /* UPM Read Burst RAM array entry -> unused */
366 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
367 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
369 /* UPM Write Single RAM array entry */
370 /* 0x18 */ 0xffffee00, 0x00ffec80, 0x00ffee80, 0x00fffc00,
371 /* 0x1C */ 0x00fffc00, 0x00ffec00, 0x0fffef00, 0x3fffec05,
373 /* UPM Write Burst RAM array entry -> unused */
374 /* 0x20 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
375 /* 0x24 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
376 /* 0x28 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
377 /* 0x2C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
379 /* UPM Refresh Timer RAM array entry -> unused */
380 /* 0x30 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
381 /* 0x34 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
382 /* 0x38 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
384 /* UPM Exception RAM array entry -> unused */
385 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
389 /* ------------------------------------------------------------------------- */
391 /* Check Board Identity:
393 int checkboard (void)
395 char *p = (char *) HWIB_INFO_START_ADDR;
398 if (*((unsigned long *)p) == (unsigned long)CFG_HWINFO_MAGIC) {
401 puts ("No HWIB assuming TQM8272");
408 /* ------------------------------------------------------------------------- */
409 #if defined(CONFIG_BOARD_GET_CPU_CLK_F)
410 static int get_cas_latency (void)
412 /* get it from the option -ts in CIB */
416 char *p = (char *) CIB_INFO_START_ADDR;
418 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
419 if (*p < ' ' || *p > '~') { /* ASCII strings! */
423 if ((p[1] == 't') && (p[2] == 's')) {
434 static ulong set_sdram_timing (volatile uint *sdmr_ptr, ulong sdmr, int col)
436 #if defined(CONFIG_BOARD_GET_CPU_CLK_F)
437 int clk = board_get_cpu_clk_f ();
438 volatile immap_t *immr = (immap_t *)CFG_IMMR;
439 int busmode = (immr->im_siu_conf.sc_bcr & BCR_EBM ? 1 : 0);
442 sdmr = sdmr & ~(PSDMR_RFRC_MSK | PSDMR_PRETOACT_MSK | PSDMR_WRC_MSK | \
447 sdmr |= (PSDMR_RFRC_66MHZ_60X | \
448 PSDMR_PRETOACT_66MHZ_60X | \
449 PSDMR_WRC_66MHZ_60X | \
450 PSDMR_BUFCMD_66MHZ_60X);
453 sdmr |= (PSDMR_RFRC_100MHZ_60X | \
454 PSDMR_PRETOACT_100MHZ_60X | \
455 PSDMR_WRC_100MHZ_60X | \
456 PSDMR_BUFCMD_100MHZ_60X);
463 sdmr |= (PSDMR_RFRC_66MHZ_SINGLE | \
464 PSDMR_PRETOACT_66MHZ_SINGLE | \
465 PSDMR_WRC_66MHZ_SINGLE | \
466 PSDMR_BUFCMD_66MHZ_SINGLE);
469 sdmr |= (PSDMR_RFRC_100MHZ_SINGLE | \
470 PSDMR_PRETOACT_100MHZ_SINGLE | \
471 PSDMR_WRC_100MHZ_SINGLE | \
472 PSDMR_BUFCMD_100MHZ_SINGLE);
475 sdmr |= (PSDMR_RFRC_133MHZ_SINGLE | \
476 PSDMR_PRETOACT_133MHZ_SINGLE | \
477 PSDMR_WRC_133MHZ_SINGLE | \
478 PSDMR_BUFCMD_133MHZ_SINGLE);
482 cas = get_cas_latency();
483 sdmr &=~ (PSDMR_CL_MSK | PSDMR_LDOTOPRE_MSK);
485 sdmr |= ((cas - 1) << 6);
492 /* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx
494 * This routine performs standard 8260 initialization sequence
495 * and calculates the available memory size. It may be called
496 * several times to try different SDRAM configurations on both
497 * 60x and local buses.
499 static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
500 ulong orx, volatile uchar * base, int col)
502 volatile uchar c = 0xff;
503 volatile uint *sdmr_ptr;
504 volatile uint *orx_ptr;
508 /* We must be able to test a location outsize the maximum legal size
509 * to find out THAT we are outside; but this address still has to be
510 * mapped by the controller. That means, that the initial mapping has
511 * to be (at least) twice as large as the maximum expected size.
513 maxsize = (1 + (~orx | 0x7fff)) / 2;
515 /* Since CFG_SDRAM_BASE is always 0 (??), we assume that
516 * we are configuring CS1 if base != 0
518 sdmr_ptr = base ? &memctl->memc_lsdmr : &memctl->memc_psdmr;
519 orx_ptr = base ? &memctl->memc_or2 : &memctl->memc_or1;
522 sdmr = set_sdram_timing (sdmr_ptr, sdmr, col);
524 * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
526 * "At system reset, initialization software must set up the
527 * programmable parameters in the memory controller banks registers
528 * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
529 * system software should execute the following initialization sequence
530 * for each SDRAM device.
532 * 1. Issue a PRECHARGE-ALL-BANKS command
533 * 2. Issue eight CBR REFRESH commands
534 * 3. Issue a MODE-SET command to initialize the mode register
536 * The initial commands are executed by setting P/LSDMR[OP] and
537 * accessing the SDRAM with a single-byte transaction."
539 * The appropriate BRx/ORx registers have already been set when we
540 * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
543 *sdmr_ptr = sdmr | PSDMR_OP_PREA;
546 *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
547 for (i = 0; i < 8; i++)
550 *sdmr_ptr = sdmr | PSDMR_OP_MRW;
551 *(base + CFG_MRS_OFFS) = c; /* setting MR on address lines */
553 *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
556 size = get_ram_size((long *)base, maxsize);
557 *orx_ptr = orx | ~(size - 1);
562 long int initdram (int board_type)
564 volatile immap_t *immap = (immap_t *) CFG_IMMR;
565 volatile memctl8260_t *memctl = &immap->im_memctl;
572 psize = 16 * 1024 * 1024;
575 memctl->memc_psrt = CFG_PSRT;
576 memctl->memc_mptpr = CFG_MPTPR;
581 size8 = try_init (memctl, CFG_PSDMR_8COL, CFG_OR1_8COL,
582 (uchar *) CFG_SDRAM_BASE, 8);
583 size9 = try_init (memctl, CFG_PSDMR_9COL, CFG_OR1_9COL,
584 (uchar *) CFG_SDRAM_BASE, 9);
588 printf ("(60x:9COL - %ld MB, ", psize >> 20);
590 psize = try_init (memctl, CFG_PSDMR_8COL, CFG_OR1_8COL,
591 (uchar *) CFG_SDRAM_BASE, 8);
592 printf ("(60x:8COL - %ld MB, ", psize >> 20);
595 #endif /* CFG_RAMBOOT */
603 static inline int scanChar (char *p, int len, unsigned long *number)
609 if ((*p >= '0') && (*p <= '9')) {
614 if (*p == '-') return akt;
633 unsigned long option;
641 unsigned char ethaddr[20];
644 HWIB_INFO hwinf = {0, 0, 1, 0, 1, 0, 0, 0, 0, 8272, 0 ,0,
647 static int dump_hwib(void)
649 HWIB_INFO *hw = &hwinf;
650 volatile immap_t *immr = (immap_t *)CFG_IMMR;
651 char *s = getenv("serial#");
654 printf ("HWIB on %x\n", HWIB_INFO_START_ADDR);
655 printf ("serial : %s\n", s);
656 printf ("ethaddr: %s\n", hw->ethaddr);
657 printf ("FLASH : %x nr:%d\n", hw->flash, hw->flash_nr);
658 printf ("RAM : %x cs:%d\n", hw->ram, hw->ram_cs);
659 printf ("CPU : %d\n", hw->cpunr);
660 printf ("CAN : %d\n", hw->can);
661 if (hw->eeprom) printf ("EEprom : %x\n", hw->eeprom);
662 else printf ("No EEprom\n");
664 printf ("NAND : %x\n", hw->nand);
665 printf ("NAND CS: %d\n", hw->nand_cs);
666 } else { printf ("No NAND\n");}
667 printf ("Bus %s mode.\n", (hw->Bus ? "60x" : "Single PQII"));
668 printf (" real : %s\n", (immr->im_siu_conf.sc_bcr & BCR_EBM ? \
669 "60x" : "Single PQII"));
670 printf ("Option : %x\n", hw->option);
671 printf ("%s Security Engine\n", (hw->SecEng ? "with" : "no"));
672 printf ("CPM Clk: %d\n", hw->cpmcl);
673 printf ("CPU Clk: %d\n", hw->cpucl);
674 printf ("Bus Clk: %d\n", hw->buscl);
675 if (hw->busclk_real_ok) {
676 printf (" real Clk: %d\n", hw->busclk_real);
678 printf ("CAS : %d\n", get_cas_latency());
680 printf("HWIB @%x not OK\n", HWIB_INFO_START_ADDR);
685 static inline int search_real_busclk (int *clk)
687 int part = 0, pos = 0;
688 char *p = (char *) CIB_INFO_START_ADDR;
691 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
692 if (*p < ' ' || *p > '~') { /* ASCII strings! */
734 int analyse_hwib (void)
736 char *p = (char *) HWIB_INFO_START_ADDR;
738 int part = 1, i = 0, pos = 0;
739 HWIB_INFO *hw = &hwinf;
741 deb_printf(" %s pointer: %p\n", __FUNCTION__, p);
743 if (*((unsigned long *)p) != (unsigned long)CFG_HWINFO_MAGIC) {
744 deb_printf("No HWIB\n");
748 if (scanChar (p, 4, &hw->cpunr) < 0) {
749 deb_printf("No CPU\n");
754 hw->flash = 0x200000 << (*p - 'A');
756 hw->flash_nr = *p - '0';
759 hw->ram = 0x2000000 << (*p - 'A');
766 if (*p == 'A') hw->can = 1;
767 if (*p == 'B') hw->can = 2;
769 p +=1; /* connector */
771 hw->eeprom = 0x1000 << (*p - 'A');
775 if ((*p < '0') || (*p > '9')) {
776 /* NAND before z-option */
777 hw->nand = 0x8000000 << (*p - 'A');
779 hw->nand_cs = *p - '0';
783 anz = scanChar (p, 4, &hw->option);
785 deb_printf("No option\n");
788 if (hw->option & 0x8) hw->Bus = 1;
791 deb_printf("No -\n");
801 case 'M': hw->cpucl = 266666666;
803 case 'P': hw->cpucl = 300000000;
805 case 'T': hw->cpucl = 400000000;
808 deb_printf("No CPU Clk: %c\n", *p);
814 case 'I': hw->cpmcl = 200000000;
816 case 'M': hw->cpmcl = 300000000;
819 deb_printf("No CPM Clk\n");
825 case 'B': hw->buscl = 66666666;
827 case 'E': hw->buscl = 100000000;
829 case 'F': hw->buscl = 133333333;
832 deb_printf("No BUS Clk\n");
839 /* search MAC Address */
840 while ((*p != '\0') && (pos < CFG_HWINFO_SIZE)) {
841 if (*p < ' ' || *p > '~') { /* ASCII strings! */
851 case 3: /* Copy MAC address */
857 hw->ethaddr[i++] = *p;
859 hw->ethaddr[i++] = ':';
866 hw->busclk_real_ok = search_real_busclk (&hw->busclk_real);
870 #if defined(CONFIG_GET_CPU_STR_F)
871 /* !! This routine runs from Flash */
872 char get_cpu_str_f (char *buf)
874 char *p = (char *) HWIB_INFO_START_ADDR;
880 if (*((unsigned long *)p) == (unsigned long)CFG_HWINFO_MAGIC) {
896 #if defined(CONFIG_BOARD_GET_CPU_CLK_F)
897 /* !! This routine runs from Flash */
898 unsigned long board_get_cpu_clk_f (void)
900 char *p = (char *) HWIB_INFO_START_ADDR;
903 if (*((unsigned long *)p) == (unsigned long)CFG_HWINFO_MAGIC) {
904 if (search_real_busclk (&i))
907 return CONFIG_8260_CLKIN;
911 #if CONFIG_BOARD_EARLY_INIT_R
913 static int can_test (unsigned long off)
915 volatile unsigned char *base = (unsigned char *) (CFG_CAN_BASE + off);
917 *(base + 0x17) = 'T';
918 *(base + 0x18) = 'Q';
919 *(base + 0x19) = 'M';
920 if ((*(base + 0x17) != 'T') ||
921 (*(base + 0x18) != 'Q') ||
922 (*(base + 0x19) != 'M')) {
928 static int can_config_one (unsigned long off)
930 volatile unsigned char *ctrl = (unsigned char *) (CFG_CAN_BASE + off);
931 volatile unsigned char *cpu_if = (unsigned char *) (CFG_CAN_BASE + off + 0x02);
932 volatile unsigned char *clkout = (unsigned char *) (CFG_CAN_BASE + off + 0x1f);
946 static int can_config (void)
950 if (hwinf.can == 2) {
951 can_config_one (0x100);
953 /* make Test if they really there */
955 ret += can_test (0x100);
959 static int init_can (void)
961 volatile immap_t * immr = (immap_t *)CFG_IMMR;
962 volatile memctl8260_t *memctl = &immr->im_memctl;
965 if ((hwinf.OK) && (hwinf.can)) {
966 memctl->memc_or4 = CFG_CAN_OR;
967 memctl->memc_br4 = CFG_CAN_BR;
969 upmconfig (UPMC, (uint *) upmTableFast,
970 sizeof (upmTableFast) / sizeof (uint));
971 memctl->memc_mcmr = (MxMR_DSx_3_CYCL |
977 count = can_config ();
978 printf ("CAN: %d @ %x\n", count, CFG_CAN_BASE);
979 if (hwinf.can != count) printf("!!! difference to HWIB\n");
981 printf ("CAN: No\n");
986 int board_early_init_r(void)
994 int do_hwib_dump (cmd_tbl_t * cmdtp, int flag, int argc, char *argv[])
1001 hwib, 1, 1, do_hwib_dump,
1002 "hwib - dump HWIB'\n",
1006 #ifdef CFG_UPDATE_FLASH_SIZE
1007 static int get_flash_timing (void)
1009 /* get it from the option -tf in CIB */
1010 /* default is 0x00000c84 */
1011 int ret = 0x00000c84;
1014 char *p = (char *) CIB_INFO_START_ADDR;
1016 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
1017 if (*p < ' ' || *p > '~') { /* ASCII strings! */
1021 if ((p[1] == 't') && (p[2] == 'f')) {
1025 if ((*p >= '0') && (*p <= '9')) {
1030 } else if ((*p >= 'A') && (*p <= 'F')) {
1036 if (nr < 8) return 0x00000c84;
1048 /* Update the Flash_Size and the Flash Timing */
1049 int update_flash_size (int flash_size)
1051 volatile immap_t * immr = (immap_t *)CFG_IMMR;
1052 volatile memctl8260_t *memctl = &immr->im_memctl;
1056 /* I must use reg, otherwise the board hang */
1057 reg = memctl->memc_or0;
1058 reg &= ~ORxU_AM_MSK;
1059 reg |= MEG_TO_AM(flash_size >> 20);
1060 tim = get_flash_timing ();
1062 reg |= (tim & 0xfff);
1063 memctl->memc_or0 = reg;
1068 #if defined(CONFIG_CMD_NAND)
1071 #include <linux/mtd/mtd.h>
1073 static u8 hwctl = 0;
1075 static void upmnand_hwcontrol(struct mtd_info *mtdinfo, int cmd)
1078 case NAND_CTL_SETCLE:
1081 case NAND_CTL_CLRCLE:
1085 case NAND_CTL_SETALE:
1089 case NAND_CTL_CLRALE:
1095 static void upmnand_write_byte(struct mtd_info *mtdinfo, u_char byte)
1097 struct nand_chip *this = mtdinfo->priv;
1098 ulong base = (ulong) (this->IO_ADDR_W + chipsel * CFG_NAND_CS_DIST);
1101 WRITE_NAND_UPM(byte, base, CFG_NAND_UPM_WRITE_CMD_OFS);
1102 } else if (hwctl & 0x2) {
1103 WRITE_NAND_UPM(byte, base, CFG_NAND_UPM_WRITE_ADDR_OFS);
1105 WRITE_NAND(byte, base);
1109 static u_char upmnand_read_byte(struct mtd_info *mtdinfo)
1111 struct nand_chip *this = mtdinfo->priv;
1112 ulong base = (ulong) (this->IO_ADDR_W + chipsel * CFG_NAND_CS_DIST);
1114 return READ_NAND(base);
1117 static int tqm8272_dev_ready(struct mtd_info *mtdinfo)
1119 /* constant delay (see also tR in the datasheet) */
1124 #ifndef CONFIG_NAND_SPL
1125 static void tqm8272_read_buf(struct mtd_info *mtdinfo, uint8_t *buf, int len)
1127 struct nand_chip *this = mtdinfo->priv;
1128 unsigned char *base = (unsigned char *) (this->IO_ADDR_W + chipsel * CFG_NAND_CS_DIST);
1131 for (i = 0; i< len; i++)
1135 static void tqm8272_write_buf(struct mtd_info *mtdinfo, const uint8_t *buf, int len)
1137 struct nand_chip *this = mtdinfo->priv;
1138 unsigned char *base = (unsigned char *) (this->IO_ADDR_W + chipsel * CFG_NAND_CS_DIST);
1141 for (i = 0; i< len; i++)
1145 static int tqm8272_verify_buf(struct mtd_info *mtdinfo, const uint8_t *buf, int len)
1147 struct nand_chip *this = mtdinfo->priv;
1148 unsigned char *base = (unsigned char *) (this->IO_ADDR_W + chipsel * CFG_NAND_CS_DIST);
1151 for (i = 0; i < len; i++)
1152 if (buf[i] != *base)
1156 #endif /* #ifndef CONFIG_NAND_SPL */
1158 void board_nand_select_device(struct nand_chip *nand, int chip)
1163 int board_nand_init(struct nand_chip *nand)
1165 static int UpmInit = 0;
1166 volatile immap_t * immr = (immap_t *)CFG_IMMR;
1167 volatile memctl8260_t *memctl = &immr->im_memctl;
1169 if (hwinf.nand == 0) return -1;
1173 switch (hwinf.busclk_real) {
1175 upmconfig (UPMB, (uint *) upmTable100,
1176 sizeof (upmTable100) / sizeof (uint));
1179 upmconfig (UPMB, (uint *) upmTable133,
1180 sizeof (upmTable133) / sizeof (uint));
1183 upmconfig (UPMB, (uint *) upmTable67,
1184 sizeof (upmTable67) / sizeof (uint));
1190 /* Setup the memctrl */
1191 memctl->memc_or3 = CFG_NAND_OR;
1192 memctl->memc_br3 = CFG_NAND_BR;
1193 memctl->memc_mbmr = (MxMR_OP_NORM);
1195 nand->eccmode = NAND_ECC_SOFT;
1197 nand->hwcontrol = upmnand_hwcontrol;
1198 nand->read_byte = upmnand_read_byte;
1199 nand->write_byte = upmnand_write_byte;
1200 nand->dev_ready = tqm8272_dev_ready;
1202 #ifndef CONFIG_NAND_SPL
1203 nand->write_buf = tqm8272_write_buf;
1204 nand->read_buf = tqm8272_read_buf;
1205 nand->verify_buf = tqm8272_verify_buf;
1209 * Select required NAND chip
1211 board_nand_select_device(nand, 0);
1218 struct pci_controller hose;
1220 int board_early_init_f (void)
1222 volatile immap_t *immap = (immap_t *) CFG_IMMR;
1224 immap->im_clkrst.car_sccr |= M826X_SCCR_PCI_MODE_EN;
1228 extern void pci_mpc8250_init(struct pci_controller *);
1230 void pci_init_board(void)
1232 pci_mpc8250_init(&hose);