blob: 9efb54125ec126f1d3fbc90d76a8f3bcb042858d [file] [log] [blame]
Heiko Schocherfa230442006-12-21 17:17:02 +01001/*
2 * (C) Copyright 2006
3 * Heiko Schocher, DENX Software Engineering, hs@denx.de.
4 *
5 * See file CREDITS for list of people who contributed to this
6 * project.
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
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +010015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Heiko Schocherfa230442006-12-21 17:17:02 +010016 * GNU General Public License for more details.
17 *
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,
21 * MA 02111-1307 USA
22 */
23
24#include <common.h>
25#include <ioports.h>
26#include <mpc8260.h>
27
28#include <command.h>
Ben Warren10efa022008-08-31 20:37:00 -070029#include <netdev.h>
Heiko Schocherfa230442006-12-21 17:17:02 +010030#ifdef CONFIG_PCI
31#include <pci.h>
32#include <asm/m8260_pci.h>
33#endif
Heiko Schochera6f2e452008-08-28 13:50:42 +020034#include "tqm8272.h"
Heiko Schocherfa230442006-12-21 17:17:02 +010035
36#if 0
37#define deb_printf(fmt,arg...) \
38 printf ("TQM8272 %s %s: " fmt,__FILE__, __FUNCTION__, ##arg)
39#else
40#define deb_printf(fmt,arg...) \
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +010041 do { } while (0)
Heiko Schocherfa230442006-12-21 17:17:02 +010042#endif
43
44#if defined(CONFIG_BOARD_GET_CPU_CLK_F)
45unsigned long board_get_cpu_clk_f (void);
46#endif
47
48/*
49 * I/O Port configuration table
50 *
51 * if conf is 1, then that port pin will be configured at boot time
52 * according to the five values podr/pdir/ppar/psor/pdat for that entry
53 */
54
55const iop_conf_t iop_conf_tab[4][32] = {
56
57 /* Port A configuration */
58 { /* conf ppar psor pdir podr pdat */
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +010059 /* PA31 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 *ATMTXEN */
60 /* PA30 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTCA */
61 /* PA29 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTSOC */
62 /* PA28 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 *ATMRXEN */
63 /* PA27 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRSOC */
64 /* PA26 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRCA */
65 /* PA25 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
66 /* PA24 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
67 /* PA23 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
68 /* PA22 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
69 /* PA21 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
70 /* PA20 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
71 /* PA19 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
72 /* PA18 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
73 /* PA17 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[7] */
74 /* PA16 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[6] */
75 /* PA15 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[5] */
76 /* PA14 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[4] */
77 /* PA13 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[3] */
78 /* PA12 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[2] */
79 /* PA11 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[1] */
80 /* PA10 */ { 0, 0, 0, 1, 0, 0 }, /* FCC1 ATMRXD[0] */
81 /* PA9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC2 TXD */
82 /* PA8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC2 RXD */
83 /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
84 /* PA6 */ { 0, 0, 0, 1, 0, 0 }, /* PA6 */
85 /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
86 /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
87 /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
88 /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
89 /* PA1 */ { 0, 0, 0, 1, 0, 0 }, /* PA1 */
90 /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
Heiko Schocherfa230442006-12-21 17:17:02 +010091 },
92
93 /* Port B configuration */
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +010094 { /* conf ppar psor pdir podr pdat */
95 /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
96 /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
97 /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
98 /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
99 /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
100 /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
101 /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
102 /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
103 /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
104 /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
105 /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
106 /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
107 /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
108 /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
109 /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* PB17 */
110 /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* PB16 */
111 /* PB15 */ { 0, 0, 0, 0, 0, 0 }, /* PB15 */
112 /* PB14 */ { 0, 0, 0, 0, 0, 0 }, /* PB14 */
113 /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* PB13 */
114 /* PB12 */ { 0, 0, 0, 0, 0, 0 }, /* PB12 */
115 /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* PB11 */
116 /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* PB10 */
117 /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* PB9 */
118 /* PB8 */ { 0, 0, 0, 0, 0, 0 }, /* PB8 */
119 /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
120 /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* PB6 */
121 /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* PB5 */
122 /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* PB4 */
123 /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
124 /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
125 /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
126 /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
Heiko Schocherfa230442006-12-21 17:17:02 +0100127 },
128
129 /* Port C */
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100130 { /* conf ppar psor pdir podr pdat */
131 /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
132 /* PC30 */ { 0, 0, 0, 0, 0, 0 }, /* PC30 */
133 /* PC29 */ { 1, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
134 /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
135 /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* PC27 */
136 /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
137 /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
138 /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
139 /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
140 /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
141 /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
142 /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
143 /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK */
144 /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII TX_CLK */
145 /* PC17 */ { 1, 0, 0, 1, 0, 0 }, /* PC17 MDC */
146 /* PC16 */ { 1, 0, 0, 0, 0, 0 }, /* PC16 MDIO*/
147 /* PC15 */ { 0, 0, 0, 1, 0, 0 }, /* PC15 */
148 /* PC14 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
149 /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
150 /* PC12 */ { 0, 0, 0, 1, 0, 0 }, /* PC12 */
151 /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* PC11 */
152 /* PC10 */ { 0, 0, 0, 1, 0, 0 }, /* PC10 */
153 /* PC9 */ { 0, 0, 0, 1, 0, 0 }, /* PC9 */
154 /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
155 /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
156 /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
157 /* PC5 */ { 1, 1, 0, 1, 0, 0 }, /* PC5 SMC1 TXD */
158 /* PC4 */ { 1, 1, 0, 0, 0, 0 }, /* PC4 SMC1 RXD */
159 /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
160 /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
161 /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
162 /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
Heiko Schocherfa230442006-12-21 17:17:02 +0100163 },
164
165 /* Port D */
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100166 { /* conf ppar psor pdir podr pdat */
167 /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
168 /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
169 /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
170 /* PD28 */ { 0, 0, 0, 1, 0, 0 }, /* PD28 */
171 /* PD27 */ { 0, 0, 0, 1, 0, 0 }, /* PD27 */
172 /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
173 /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
174 /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
175 /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
176 /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
177 /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
178 /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
179 /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
180 /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
181 /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
182 /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
Heiko Schocherfa230442006-12-21 17:17:02 +0100183#if defined(CONFIG_SOFT_I2C)
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100184 /* PD15 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SDA */
185 /* PD14 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SCL */
Heiko Schocherfa230442006-12-21 17:17:02 +0100186#else
187#if defined(CONFIG_HARD_I2C)
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100188 /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
189 /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
Heiko Schocherfa230442006-12-21 17:17:02 +0100190#else /* normal I/O port pins */
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100191 /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
192 /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */
Heiko Schocherfa230442006-12-21 17:17:02 +0100193#endif
194#endif
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100195 /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
196 /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
197 /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
198 /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
199 /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
200 /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
201 /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
202 /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
203 /* PD5 */ { 0, 0, 0, 1, 0, 0 }, /* PD5 */
204 /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
205 /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
206 /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
207 /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
208 /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
Heiko Schocherfa230442006-12-21 17:17:02 +0100209 }
210};
211
Heiko Schocherfa230442006-12-21 17:17:02 +0100212/* UPM pattern for slow init */
213static const uint upmTableSlow[] =
214{
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100215 /* Offset UPM Read Single RAM array entry */
216 /* 0x00 */ 0xffffee00, 0x00ffcc80, 0x00ffcf00, 0x00ffdc00,
217 /* 0x04 */ 0x00ffce80, 0x00ffcc00, 0x00ffee00, 0x3fffcc07,
Heiko Schocherfa230442006-12-21 17:17:02 +0100218
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100219 /* UPM Read Burst RAM array entry -> unused */
220 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
221 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
Heiko Schocherfa230442006-12-21 17:17:02 +0100222
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100223 /* UPM Read Burst RAM array entry -> unused */
224 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
225 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
Heiko Schocherfa230442006-12-21 17:17:02 +0100226
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100227 /* UPM Write Single RAM array entry */
228 /* 0x18 */ 0xffffee00, 0x00ffec80, 0x00ffef00, 0x00fffc80,
229 /* 0x1C */ 0x00fffe00, 0x00ffec00, 0x0fffef00, 0x3fffec05,
Heiko Schocherfa230442006-12-21 17:17:02 +0100230
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100231 /* 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,
Heiko Schocherfa230442006-12-21 17:17:02 +0100236
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100237 /* 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,
Heiko Schocherfa230442006-12-21 17:17:02 +0100241
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100242 /* UPM Exception RAM array entry -> unused */
243 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
Heiko Schocherfa230442006-12-21 17:17:02 +0100244};
245
246/* UPM pattern for fast init */
247static const uint upmTableFast[] =
248{
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100249 /* Offset UPM Read Single RAM array entry */
250 /* 0x00 */ 0xffffee00, 0x00ffcc80, 0x00ffcd80, 0x00ffdc00,
251 /* 0x04 */ 0x00ffdc00, 0x00ffcf00, 0x00ffec00, 0x3fffcc07,
Heiko Schocherfa230442006-12-21 17:17:02 +0100252
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100253 /* UPM Read Burst RAM array entry -> unused */
254 /* 0x08 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
255 /* 0x0C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
Heiko Schocherfa230442006-12-21 17:17:02 +0100256
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100257 /* UPM Read Burst RAM array entry -> unused */
258 /* 0x10 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
259 /* 0x14 */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc00,
Heiko Schocherfa230442006-12-21 17:17:02 +0100260
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100261 /* UPM Write Single RAM array entry */
262 /* 0x18 */ 0xffffee00, 0x00ffec80, 0x00ffee80, 0x00fffc00,
263 /* 0x1C */ 0x00fffc00, 0x00ffec00, 0x0fffef00, 0x3fffec05,
Heiko Schocherfa230442006-12-21 17:17:02 +0100264
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100265 /* 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,
Heiko Schocherfa230442006-12-21 17:17:02 +0100270
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100271 /* 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,
Heiko Schocherfa230442006-12-21 17:17:02 +0100275
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100276 /* UPM Exception RAM array entry -> unused */
277 /* 0x3C */ 0xfffffc00, 0xfffffc00, 0xfffffc00, 0xfffffc01,
Heiko Schocherfa230442006-12-21 17:17:02 +0100278};
279
280
281/* ------------------------------------------------------------------------- */
282
283/* Check Board Identity:
284 */
285int checkboard (void)
286{
287 char *p = (char *) HWIB_INFO_START_ADDR;
288
289 puts ("Board: ");
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200290 if (*((unsigned long *)p) == (unsigned long)CONFIG_SYS_HWINFO_MAGIC) {
Heiko Schocherfa230442006-12-21 17:17:02 +0100291 puts (p);
292 } else {
293 puts ("No HWIB assuming TQM8272");
294 }
295 putc ('\n');
296
297 return 0;
298}
299
300/* ------------------------------------------------------------------------- */
301#if defined(CONFIG_BOARD_GET_CPU_CLK_F)
302static int get_cas_latency (void)
303{
304 /* get it from the option -ts in CIB */
305 /* default is 3 */
306 int ret = 3;
307 int pos = 0;
308 char *p = (char *) CIB_INFO_START_ADDR;
309
310 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
311 if (*p < ' ' || *p > '~') { /* ASCII strings! */
312 return ret;
313 }
314 if (*p == '-') {
315 if ((p[1] == 't') && (p[2] == 's')) {
316 return (p[4] - '0');
317 }
318 }
319 p++;
320 pos++;
321 }
322 return ret;
323}
324#endif
325
326static ulong set_sdram_timing (volatile uint *sdmr_ptr, ulong sdmr, int col)
327{
328#if defined(CONFIG_BOARD_GET_CPU_CLK_F)
329 int clk = board_get_cpu_clk_f ();
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200330 volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
Heiko Schocherfa230442006-12-21 17:17:02 +0100331 int busmode = (immr->im_siu_conf.sc_bcr & BCR_EBM ? 1 : 0);
332 int cas;
333
334 sdmr = sdmr & ~(PSDMR_RFRC_MSK | PSDMR_PRETOACT_MSK | PSDMR_WRC_MSK | \
335 PSDMR_BUFCMD);
336 if (busmode) {
337 switch (clk) {
338 case 66666666:
339 sdmr |= (PSDMR_RFRC_66MHZ_60X | \
340 PSDMR_PRETOACT_66MHZ_60X | \
341 PSDMR_WRC_66MHZ_60X | \
342 PSDMR_BUFCMD_66MHZ_60X);
343 break;
344 case 100000000:
345 sdmr |= (PSDMR_RFRC_100MHZ_60X | \
346 PSDMR_PRETOACT_100MHZ_60X | \
347 PSDMR_WRC_100MHZ_60X | \
348 PSDMR_BUFCMD_100MHZ_60X);
349 break;
350
351 }
352 } else {
353 switch (clk) {
354 case 66666666:
355 sdmr |= (PSDMR_RFRC_66MHZ_SINGLE | \
356 PSDMR_PRETOACT_66MHZ_SINGLE | \
357 PSDMR_WRC_66MHZ_SINGLE | \
358 PSDMR_BUFCMD_66MHZ_SINGLE);
359 break;
360 case 100000000:
361 sdmr |= (PSDMR_RFRC_100MHZ_SINGLE | \
362 PSDMR_PRETOACT_100MHZ_SINGLE | \
363 PSDMR_WRC_100MHZ_SINGLE | \
364 PSDMR_BUFCMD_100MHZ_SINGLE);
365 break;
366 case 133333333:
367 sdmr |= (PSDMR_RFRC_133MHZ_SINGLE | \
368 PSDMR_PRETOACT_133MHZ_SINGLE | \
369 PSDMR_WRC_133MHZ_SINGLE | \
370 PSDMR_BUFCMD_133MHZ_SINGLE);
371 break;
372 }
373 }
374 cas = get_cas_latency();
375 sdmr &=~ (PSDMR_CL_MSK | PSDMR_LDOTOPRE_MSK);
376 sdmr |= cas;
377 sdmr |= ((cas - 1) << 6);
378 return sdmr;
379#else
380 return sdmr;
381#endif
382}
383
384/* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx
385 *
386 * This routine performs standard 8260 initialization sequence
387 * and calculates the available memory size. It may be called
388 * several times to try different SDRAM configurations on both
389 * 60x and local buses.
390 */
391static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
392 ulong orx, volatile uchar * base, int col)
393{
394 volatile uchar c = 0xff;
395 volatile uint *sdmr_ptr;
396 volatile uint *orx_ptr;
397 ulong maxsize, size;
398 int i;
399
400 /* We must be able to test a location outsize the maximum legal size
401 * to find out THAT we are outside; but this address still has to be
402 * mapped by the controller. That means, that the initial mapping has
403 * to be (at least) twice as large as the maximum expected size.
404 */
405 maxsize = (1 + (~orx | 0x7fff)) / 2;
406
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200407 /* Since CONFIG_SYS_SDRAM_BASE is always 0 (??), we assume that
Heiko Schocherfa230442006-12-21 17:17:02 +0100408 * we are configuring CS1 if base != 0
409 */
410 sdmr_ptr = base ? &memctl->memc_lsdmr : &memctl->memc_psdmr;
411 orx_ptr = base ? &memctl->memc_or2 : &memctl->memc_or1;
412
413 *orx_ptr = orx;
414 sdmr = set_sdram_timing (sdmr_ptr, sdmr, col);
415 /*
416 * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
417 *
418 * "At system reset, initialization software must set up the
419 * programmable parameters in the memory controller banks registers
420 * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
421 * system software should execute the following initialization sequence
422 * for each SDRAM device.
423 *
424 * 1. Issue a PRECHARGE-ALL-BANKS command
425 * 2. Issue eight CBR REFRESH commands
426 * 3. Issue a MODE-SET command to initialize the mode register
427 *
428 * The initial commands are executed by setting P/LSDMR[OP] and
429 * accessing the SDRAM with a single-byte transaction."
430 *
431 * The appropriate BRx/ORx registers have already been set when we
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200432 * get here. The SDRAM can be accessed at the address CONFIG_SYS_SDRAM_BASE.
Heiko Schocherfa230442006-12-21 17:17:02 +0100433 */
434
435 *sdmr_ptr = sdmr | PSDMR_OP_PREA;
436 *base = c;
437
438 *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
439 for (i = 0; i < 8; i++)
440 *base = c;
441
442 *sdmr_ptr = sdmr | PSDMR_OP_MRW;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200443 *(base + CONFIG_SYS_MRS_OFFS) = c; /* setting MR on address lines */
Heiko Schocherfa230442006-12-21 17:17:02 +0100444
445 *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
446 *base = c;
447
448 size = get_ram_size((long *)base, maxsize);
449 *orx_ptr = orx | ~(size - 1);
450
451 return (size);
452}
453
Becky Bruce9973e3c2008-06-09 16:03:40 -0500454phys_size_t initdram (int board_type)
Heiko Schocherfa230442006-12-21 17:17:02 +0100455{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200456 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Heiko Schocherfa230442006-12-21 17:17:02 +0100457 volatile memctl8260_t *memctl = &immap->im_memctl;
458
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200459#ifndef CONFIG_SYS_RAMBOOT
Heiko Schocherfa230442006-12-21 17:17:02 +0100460 long size8, size9;
461#endif
462 long psize, lsize;
463
464 psize = 16 * 1024 * 1024;
465 lsize = 0;
466
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200467 memctl->memc_psrt = CONFIG_SYS_PSRT;
468 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
Heiko Schocherfa230442006-12-21 17:17:02 +0100469
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200470#ifndef CONFIG_SYS_RAMBOOT
Heiko Schocherfa230442006-12-21 17:17:02 +0100471 /* 60x SDRAM setup:
472 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200473 size8 = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR1_8COL,
474 (uchar *) CONFIG_SYS_SDRAM_BASE, 8);
475 size9 = try_init (memctl, CONFIG_SYS_PSDMR_9COL, CONFIG_SYS_OR1_9COL,
476 (uchar *) CONFIG_SYS_SDRAM_BASE, 9);
Heiko Schocherfa230442006-12-21 17:17:02 +0100477
478 if (size8 < size9) {
479 psize = size9;
480 printf ("(60x:9COL - %ld MB, ", psize >> 20);
481 } else {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200482 psize = try_init (memctl, CONFIG_SYS_PSDMR_8COL, CONFIG_SYS_OR1_8COL,
483 (uchar *) CONFIG_SYS_SDRAM_BASE, 8);
Heiko Schocherfa230442006-12-21 17:17:02 +0100484 printf ("(60x:8COL - %ld MB, ", psize >> 20);
485 }
486
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200487#endif /* CONFIG_SYS_RAMBOOT */
Heiko Schocherfa230442006-12-21 17:17:02 +0100488
489 icache_enable ();
490
491 return (psize);
492}
493
494
495static inline int scanChar (char *p, int len, unsigned long *number)
496{
497 int akt = 0;
498
499 *number = 0;
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100500 while (akt < len) {
Heiko Schocherfa230442006-12-21 17:17:02 +0100501 if ((*p >= '0') && (*p <= '9')) {
502 *number *= 10;
503 *number += *p - '0';
504 p += 1;
505 } else {
506 if (*p == '-') return akt;
507 return -1;
508 }
509 akt ++;
510 }
511 return akt;
512}
513
Heiko Schocherfa230442006-12-21 17:17:02 +0100514static int dump_hwib(void)
515{
516 HWIB_INFO *hw = &hwinf;
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000517 char buf[64];
518 int i = getenv_f("serial#", buf, sizeof(buf));
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200519 volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000520
521 if (i < 0)
522 buf[0] = '\0';
Heiko Schocherfa230442006-12-21 17:17:02 +0100523
524 if (hw->OK) {
525 printf ("HWIB on %x\n", HWIB_INFO_START_ADDR);
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000526 printf ("serial : %s\n", buf);
Heiko Schocherfa230442006-12-21 17:17:02 +0100527 printf ("ethaddr: %s\n", hw->ethaddr);
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100528 printf ("FLASH : %x nr:%d\n", hw->flash, hw->flash_nr);
529 printf ("RAM : %x cs:%d\n", hw->ram, hw->ram_cs);
Wolfgang Denk9b55a252008-07-11 01:16:00 +0200530 printf ("CPU : %lu\n", hw->cpunr);
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100531 printf ("CAN : %d\n", hw->can);
Heiko Schocherfa230442006-12-21 17:17:02 +0100532 if (hw->eeprom) printf ("EEprom : %x\n", hw->eeprom);
533 else printf ("No EEprom\n");
534 if (hw->nand) {
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100535 printf ("NAND : %x\n", hw->nand);
Heiko Schocherfa230442006-12-21 17:17:02 +0100536 printf ("NAND CS: %d\n", hw->nand_cs);
537 } else { printf ("No NAND\n");}
538 printf ("Bus %s mode.\n", (hw->Bus ? "60x" : "Single PQII"));
539 printf (" real : %s\n", (immr->im_siu_conf.sc_bcr & BCR_EBM ? \
540 "60x" : "Single PQII"));
Wolfgang Denk9b55a252008-07-11 01:16:00 +0200541 printf ("Option : %lx\n", hw->option);
Heiko Schocherfa230442006-12-21 17:17:02 +0100542 printf ("%s Security Engine\n", (hw->SecEng ? "with" : "no"));
543 printf ("CPM Clk: %d\n", hw->cpmcl);
544 printf ("CPU Clk: %d\n", hw->cpucl);
545 printf ("Bus Clk: %d\n", hw->buscl);
546 if (hw->busclk_real_ok) {
547 printf (" real Clk: %d\n", hw->busclk_real);
548 }
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100549 printf ("CAS : %d\n", get_cas_latency());
Heiko Schocherfa230442006-12-21 17:17:02 +0100550 } else {
551 printf("HWIB @%x not OK\n", HWIB_INFO_START_ADDR);
552 }
553 return 0;
554}
555
556static inline int search_real_busclk (int *clk)
557{
558 int part = 0, pos = 0;
559 char *p = (char *) CIB_INFO_START_ADDR;
560 int ok = 0;
561
562 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
563 if (*p < ' ' || *p > '~') { /* ASCII strings! */
564 return 0;
565 }
566 switch (part) {
567 default:
568 if (*p == '-') {
569 ++part;
570 }
571 break;
572 case 3:
573 if (*p == '-') {
574 ++part;
575 break;
576 }
577 if (*p == 'b') {
578 ok = 1;
579 p++;
580 break;
581 }
582 if (ok) {
583 switch (*p) {
584 case '6':
585 *clk = 66666666;
586 return 1;
587 break;
588 case '1':
589 if (p[1] == '3') {
590 *clk = 133333333;
591 } else {
592 *clk = 100000000;
593 }
594 return 1;
595 break;
596 }
597 }
598 break;
599 }
600 p++;
601 }
602 return 0;
603}
604
605int analyse_hwib (void)
606{
607 char *p = (char *) HWIB_INFO_START_ADDR;
608 int anz;
609 int part = 1, i = 0, pos = 0;
610 HWIB_INFO *hw = &hwinf;
611
612 deb_printf(" %s pointer: %p\n", __FUNCTION__, p);
613 /* Head = TQM */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200614 if (*((unsigned long *)p) != (unsigned long)CONFIG_SYS_HWINFO_MAGIC) {
Heiko Schocherfa230442006-12-21 17:17:02 +0100615 deb_printf("No HWIB\n");
616 return -1;
617 }
618 p += 3;
619 if (scanChar (p, 4, &hw->cpunr) < 0) {
620 deb_printf("No CPU\n");
621 return -2;
622 }
623 p +=4;
624
625 hw->flash = 0x200000 << (*p - 'A');
626 p++;
627 hw->flash_nr = *p - '0';
628 p++;
629
630 hw->ram = 0x2000000 << (*p - 'A');
631 p++;
632 if (*p == '2') {
633 hw->ram_cs = 2;
634 p++;
635 }
636
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100637 if (*p == 'A') hw->can = 1;
638 if (*p == 'B') hw->can = 2;
Heiko Schocherfa230442006-12-21 17:17:02 +0100639 p +=1;
640 p +=1; /* connector */
641 if (*p != '0') {
Heiko Schocher07e82cb2007-03-21 08:45:17 +0100642 hw->eeprom = 0x1000 << (*p - 'A');
Heiko Schocherfa230442006-12-21 17:17:02 +0100643 }
644 p++;
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100645
646 if ((*p < '0') || (*p > '9')) {
Heiko Schocherfa230442006-12-21 17:17:02 +0100647 /* NAND before z-option */
648 hw->nand = 0x8000000 << (*p - 'A');
649 p++;
650 hw->nand_cs = *p - '0';
651 p += 2;
652 }
653 /* z-option */
654 anz = scanChar (p, 4, &hw->option);
655 if (anz < 0) {
656 deb_printf("No option\n");
657 return -3;
658 }
659 if (hw->option & 0x8) hw->Bus = 1;
660 p += anz;
661 if (*p != '-') {
662 deb_printf("No -\n");
663 return -4;
664 }
665 p++;
666 /* C option */
667 if (*p == 'E') {
668 hw->SecEng = 1;
669 p++;
670 }
671 switch (*p) {
672 case 'M': hw->cpucl = 266666666;
673 break;
674 case 'P': hw->cpucl = 300000000;
675 break;
676 case 'T': hw->cpucl = 400000000;
677 break;
678 default:
679 deb_printf("No CPU Clk: %c\n", *p);
680 return -5;
681 break;
682 }
683 p++;
684 switch (*p) {
685 case 'I': hw->cpmcl = 200000000;
686 break;
687 case 'M': hw->cpmcl = 300000000;
688 break;
689 default:
690 deb_printf("No CPM Clk\n");
691 return -6;
692 break;
693 }
694 p++;
695 switch (*p) {
696 case 'B': hw->buscl = 66666666;
697 break;
698 case 'E': hw->buscl = 100000000;
699 break;
700 case 'F': hw->buscl = 133333333;
701 break;
702 default:
703 deb_printf("No BUS Clk\n");
704 return -7;
705 break;
706 }
707 p++;
708
709 hw->OK = 1;
710 /* search MAC Address */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200711 while ((*p != '\0') && (pos < CONFIG_SYS_HWINFO_SIZE)) {
Heiko Schocherfa230442006-12-21 17:17:02 +0100712 if (*p < ' ' || *p > '~') { /* ASCII strings! */
713 return 0;
714 }
715 switch (part) {
716 default:
717 if (*p == ' ') {
718 ++part;
719 i = 0;
720 }
721 break;
722 case 3: /* Copy MAC address */
723 if (*p == ' ') {
724 ++part;
725 i = 0;
726 break;
727 }
728 hw->ethaddr[i++] = *p;
729 if ((i % 3) == 2)
730 hw->ethaddr[i++] = ':';
731 break;
732
733 }
734 p++;
735 }
736
737 hw->busclk_real_ok = search_real_busclk (&hw->busclk_real);
738 return 0;
739}
740
741#if defined(CONFIG_GET_CPU_STR_F)
742/* !! This routine runs from Flash */
743char get_cpu_str_f (char *buf)
744{
745 char *p = (char *) HWIB_INFO_START_ADDR;
746 int i = 0;
747
748 buf[i++] = 'M';
749 buf[i++] = 'P';
750 buf[i++] = 'C';
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200751 if (*((unsigned long *)p) == (unsigned long)CONFIG_SYS_HWINFO_MAGIC) {
Heiko Schocherfa230442006-12-21 17:17:02 +0100752 buf[i++] = *&p[3];
753 buf[i++] = *&p[4];
754 buf[i++] = *&p[5];
755 buf[i++] = *&p[6];
756 } else {
757 buf[i++] = '8';
758 buf[i++] = '2';
759 buf[i++] = '7';
760 buf[i++] = 'x';
761 }
762 buf[i++] = 0;
763 return 0;
764}
765#endif
766
767#if defined(CONFIG_BOARD_GET_CPU_CLK_F)
768/* !! This routine runs from Flash */
769unsigned long board_get_cpu_clk_f (void)
770{
771 char *p = (char *) HWIB_INFO_START_ADDR;
772 int i = 0;
773
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200774 if (*((unsigned long *)p) == (unsigned long)CONFIG_SYS_HWINFO_MAGIC) {
Heiko Schocherfa230442006-12-21 17:17:02 +0100775 if (search_real_busclk (&i))
776 return i;
777 }
778 return CONFIG_8260_CLKIN;
779}
780#endif
781
782#if CONFIG_BOARD_EARLY_INIT_R
783
784static int can_test (unsigned long off)
785{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200786 volatile unsigned char *base = (unsigned char *) (CONFIG_SYS_CAN_BASE + off);
Heiko Schocherfa230442006-12-21 17:17:02 +0100787
788 *(base + 0x17) = 'T';
789 *(base + 0x18) = 'Q';
790 *(base + 0x19) = 'M';
791 if ((*(base + 0x17) != 'T') ||
792 (*(base + 0x18) != 'Q') ||
793 (*(base + 0x19) != 'M')) {
794 return 0;
795 }
796 return 1;
797}
798
799static int can_config_one (unsigned long off)
800{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200801 volatile unsigned char *ctrl = (unsigned char *) (CONFIG_SYS_CAN_BASE + off);
802 volatile unsigned char *cpu_if = (unsigned char *) (CONFIG_SYS_CAN_BASE + off + 0x02);
803 volatile unsigned char *clkout = (unsigned char *) (CONFIG_SYS_CAN_BASE + off + 0x1f);
Heiko Schocherfa230442006-12-21 17:17:02 +0100804 unsigned char temp;
805
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100806 *cpu_if = 0x45;
Heiko Schocherfa230442006-12-21 17:17:02 +0100807 temp = *ctrl;
808 temp |= 0x40;
809 *ctrl = temp;
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100810 *clkout = 0x20;
Heiko Schocherfa230442006-12-21 17:17:02 +0100811 temp = *ctrl;
812 temp &= ~0x40;
813 *ctrl = temp;
814 return 0;
815}
816
817static int can_config (void)
818{
819 int ret = 0;
820 can_config_one (0);
821 if (hwinf.can == 2) {
822 can_config_one (0x100);
823 }
824 /* make Test if they really there */
825 ret += can_test (0);
826 ret += can_test (0x100);
827 return ret;
828}
829
830static int init_can (void)
831{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200832 volatile immap_t * immr = (immap_t *)CONFIG_SYS_IMMR;
Heiko Schocherfa230442006-12-21 17:17:02 +0100833 volatile memctl8260_t *memctl = &immr->im_memctl;
834 int count = 0;
835
836 if ((hwinf.OK) && (hwinf.can)) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200837 memctl->memc_or4 = CONFIG_SYS_CAN_OR;
838 memctl->memc_br4 = CONFIG_SYS_CAN_BR;
Heiko Schocherfa230442006-12-21 17:17:02 +0100839 /* upm Init */
840 upmconfig (UPMC, (uint *) upmTableFast,
841 sizeof (upmTableFast) / sizeof (uint));
842 memctl->memc_mcmr = (MxMR_DSx_3_CYCL |
843 MxMR_GPL_x4DIS |
844 MxMR_RLFx_2X |
845 MxMR_WLFx_2X |
846 MxMR_OP_NORM);
847 /* can configure */
848 count = can_config ();
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200849 printf ("CAN: %d @ %x\n", count, CONFIG_SYS_CAN_BASE);
Heiko Schocherfa230442006-12-21 17:17:02 +0100850 if (hwinf.can != count) printf("!!! difference to HWIB\n");
851 } else {
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100852 printf ("CAN: No\n");
Heiko Schocherfa230442006-12-21 17:17:02 +0100853 }
854 return 0;
855}
856
857int board_early_init_r(void)
858{
859 analyse_hwib ();
860 init_can ();
861 return 0;
862}
863#endif
864
Wolfgang Denk54841ab2010-06-28 22:00:46 +0200865int do_hwib_dump (cmd_tbl_t * cmdtp, int flag, int argc, char * const argv[])
Heiko Schocherfa230442006-12-21 17:17:02 +0100866{
867 dump_hwib ();
868 return 0;
869}
870
871U_BOOT_CMD(
Wolfgang Denk9c0f42e2006-12-24 01:42:57 +0100872 hwib, 1, 1, do_hwib_dump,
Peter Tyser2fb26042009-01-27 18:03:12 -0600873 "dump HWIB'",
Wolfgang Denka89c33d2009-05-24 17:06:54 +0200874 ""
Heiko Schocherfa230442006-12-21 17:17:02 +0100875);
876
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200877#ifdef CONFIG_SYS_UPDATE_FLASH_SIZE
Heiko Schocherfa230442006-12-21 17:17:02 +0100878static int get_flash_timing (void)
879{
880 /* get it from the option -tf in CIB */
881 /* default is 0x00000c84 */
882 int ret = 0x00000c84;
883 int pos = 0;
884 int nr = 0;
885 char *p = (char *) CIB_INFO_START_ADDR;
886
887 while ((*p != '\0') && (pos < CIB_INFO_LEN)) {
888 if (*p < ' ' || *p > '~') { /* ASCII strings! */
889 return ret;
890 }
891 if (*p == '-') {
892 if ((p[1] == 't') && (p[2] == 'f')) {
893 p += 6;
894 ret = 0;
895 while (nr < 8) {
896 if ((*p >= '0') && (*p <= '9')) {
897 ret *= 0x10;
898 ret += *p - '0';
899 p += 1;
900 nr ++;
901 } else if ((*p >= 'A') && (*p <= 'F')) {
902 ret *= 10;
903 ret += *p - '7';
904 p += 1;
905 nr ++;
906 } else {
907 if (nr < 8) return 0x00000c84;
908 return ret;
909 }
910 }
911 }
912 }
913 p++;
914 pos++;
915 }
916 return ret;
917}
918
919/* Update the Flash_Size and the Flash Timing */
920int update_flash_size (int flash_size)
921{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200922 volatile immap_t * immr = (immap_t *)CONFIG_SYS_IMMR;
Heiko Schocherfa230442006-12-21 17:17:02 +0100923 volatile memctl8260_t *memctl = &immr->im_memctl;
924 unsigned long reg;
925 unsigned long tim;
926
927 /* I must use reg, otherwise the board hang */
928 reg = memctl->memc_or0;
929 reg &= ~ORxU_AM_MSK;
930 reg |= MEG_TO_AM(flash_size >> 20);
931 tim = get_flash_timing ();
932 reg &= ~0xfff;
933 reg |= (tim & 0xfff);
934 memctl->memc_or0 = reg;
935 return 0;
936}
937#endif
938
Heiko Schocherfa230442006-12-21 17:17:02 +0100939#ifdef CONFIG_PCI
940struct pci_controller hose;
941
942int board_early_init_f (void)
943{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200944 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
Heiko Schocherfa230442006-12-21 17:17:02 +0100945
946 immap->im_clkrst.car_sccr |= M826X_SCCR_PCI_MODE_EN;
947 return 0;
948}
949
950extern void pci_mpc8250_init(struct pci_controller *);
951
952void pci_init_board(void)
953{
954 pci_mpc8250_init(&hose);
955}
956#endif
Ben Warren10efa022008-08-31 20:37:00 -0700957
958int board_eth_init(bd_t *bis)
959{
960 return pci_eth_init(bis);
961}