blob: 079840fd31af6e9919838ae69b6dc73820e5d375 [file] [log] [blame]
wdenkf8cac652002-08-26 22:36:39 +00001/*
2 * (C) Copyright 2001
3 * Wolfgang Denk, DENX Software Engineering, wd@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
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * 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>
wdenk4d75a502003-03-25 16:50:56 +000027#include <pci.h>
wdenkf8cac652002-08-26 22:36:39 +000028
29/*
30 * I/O Port configuration table
31 *
32 * if conf is 1, then that port pin will be configured at boot time
33 * according to the five values podr/pdir/ppar/psor/pdat for that entry
34 */
35
36const iop_conf_t iop_conf_tab[4][32] = {
37
38 /* Port A configuration */
39 { /* conf ppar psor pdir podr pdat */
40 /* PA31 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 COL */
41 /* PA30 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 CRS */
42 /* PA29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC1 TXER */
43 /* PA28 */ { 1, 1, 1, 1, 0, 0 }, /* FCC1 TXEN */
44 /* PA27 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 RXDV */
45 /* PA26 */ { 1, 1, 1, 0, 0, 0 }, /* FCC1 RXER */
46 /* PA25 */ { 0, 0, 0, 1, 0, 0 }, /* PA25 */
47 /* PA24 */ { 0, 0, 0, 1, 0, 0 }, /* PA24 */
48 /* PA23 */ { 0, 0, 0, 1, 0, 0 }, /* PA23 */
49 /* PA22 */ { 0, 0, 0, 1, 0, 0 }, /* PA22 */
50 /* PA21 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD3 */
51 /* PA20 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD2 */
52 /* PA19 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD1 */
53 /* PA18 */ { 1, 1, 0, 1, 0, 0 }, /* FCC1 TXD0 */
54 /* PA17 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD0 */
55 /* PA16 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD1*/
56 /* PA15 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD2 */
57 /* PA14 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXD3 */
58 /* PA13 */ { 0, 0, 0, 1, 0, 0 }, /* PA13 */
59 /* PA12 */ { 0, 0, 0, 1, 0, 0 }, /* PA12 */
60 /* PA11 */ { 0, 0, 0, 1, 0, 0 }, /* PA11 */
61 /* PA10 */ { 0, 0, 0, 1, 0, 0 }, /* PA10 */
62 /* PA9 */ { 0, 1, 0, 1, 0, 0 }, /* PA9 */
63 /* PA8 */ { 0, 1, 0, 0, 0, 0 }, /* PA8 */
64 /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
65 /* PA6 */ { 0, 0, 0, 1, 0, 0 }, /* PA6 */
66 /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
67 /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
68 /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
69 /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
70 /* PA1 */ { 0, 0, 0, 1, 0, 0 }, /* PA1 */
71 /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
72 },
73
74 /* Port B configuration */
75 { /* conf ppar psor pdir podr pdat */
wdenkaacf9a42003-01-17 16:27:01 +000076 /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 TX_ER */
77 /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RX_DV */
78 /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 TX_EN */
79#if defined(CONFIG_ETHER_ON_SCC) && (CONFIG_ETHER_INDEX == 1)
80#ifdef CONFIG_ETHER_ON_FCC2
81#error "SCC1 conflicts with FCC2"
82#endif
wdenkf8cac652002-08-26 22:36:39 +000083 /* PB28 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 TXD */
wdenkaacf9a42003-01-17 16:27:01 +000084#else
85 /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RX_ER */
86#endif
87 /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 COL */
88 /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 CRS */
89 /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 TxD[3] */
90 /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 TxD[2] */
91 /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 TxD[1] */
92 /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 TxD[0] */
93 /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RxD[0] */
94 /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RxD[1] */
95 /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RxD[2] */
96 /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RxD[3] */
wdenkf8cac652002-08-26 22:36:39 +000097 /* PB17 */ { 0, 0, 0, 0, 0, 0 }, /* PB17 */
98 /* PB16 */ { 0, 0, 0, 0, 0, 0 }, /* PB16 */
99 /* PB15 */ { 1, 1, 0, 0, 0, 0 }, /* SCC2 RXD */
100 /* PB14 */ { 1, 1, 0, 0, 0, 0 }, /* SCC3 RXD */
101 /* PB13 */ { 0, 0, 0, 0, 0, 0 }, /* PB13 */
102 /* PB12 */ { 0, 0, 0, 0, 0, 0 }, /* PB12 */
103 /* PB11 */ { 0, 0, 0, 0, 0, 0 }, /* PB11 */
104 /* PB10 */ { 0, 0, 0, 0, 0, 0 }, /* PB10 */
105 /* PB9 */ { 0, 0, 0, 0, 0, 0 }, /* PB9 */
106 /* PB8 */ { 1, 1, 1, 1, 0, 0 }, /* SCC3 TXD */
107 /* PB7 */ { 0, 0, 0, 0, 0, 0 }, /* PB7 */
108 /* PB6 */ { 0, 0, 0, 0, 0, 0 }, /* PB6 */
109 /* PB5 */ { 0, 0, 0, 0, 0, 0 }, /* PB5 */
110 /* PB4 */ { 0, 0, 0, 0, 0, 0 }, /* PB4 */
111 /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
112 /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
113 /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
114 /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
115 },
116
117 /* Port C */
118 { /* conf ppar psor pdir podr pdat */
119 /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
120 /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
121 /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 CTS */
122 /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* SCC2 CTS */
123 /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* PC27 */
124 /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
125 /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
126 /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
127 /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* PC23 */
128 /* PC22 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 TXCK */
129 /* PC21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 RXCK */
wdenkaacf9a42003-01-17 16:27:01 +0000130 /* PC20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC1 TXCK(2) */
131 /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 RXCK */
132 /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 TXCK */
wdenkf8cac652002-08-26 22:36:39 +0000133 /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
134 /* PC16 */ { 0, 0, 0, 1, 0, 0 }, /* PC16 */
135 /* PC15 */ { 1, 1, 0, 1, 0, 0 }, /* SMC2 TXD */
136 /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 DCD */
137 /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
138 /* PC12 */ { 0, 0, 0, 1, 0, 0 }, /* SCC2 DCD */
139 /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* SCC3 CTS */
140 /* PC10 */ { 0, 0, 0, 1, 0, 0 }, /* SCC3 DCD */
141 /* PC9 */ { 0, 0, 0, 1, 0, 0 }, /* SCC4 CTS */
142 /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* SCC4 DCD */
143 /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
144 /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
145 /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
146 /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
147 /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
148 /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* PC2 */
149 /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* PC1 */
150 /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* PC0 */
151 },
152
153 /* Port D */
154 { /* conf ppar psor pdir podr pdat */
155 /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 RXD */
156 /* PD30 */ { 0, 1, 1, 1, 0, 0 }, /* PD30 */
157 /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 RTS */
158 /* PD28 */ { 0, 0, 0, 1, 0, 0 }, /* PD28 */
159 /* PD27 */ { 0, 1, 0, 1, 0, 0 }, /* SCC2 RTS */
160 /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
161 /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
162 /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
163 /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* SCC3 RTS */
164 /* PD22 */ { 1, 1, 0, 0, 0, 0 }, /* SCC4 RXD */
165 /* PD21 */ { 1, 1, 0, 1, 0, 0 }, /* SCC4 TXD */
166 /* PD20 */ { 0, 0, 1, 1, 0, 0 }, /* SCC4 RTS */
167 /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
168 /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */
169 /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* PD17 */
170 /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* PD16 */
171#if defined(CONFIG_SOFT_I2C)
172 /* PD15 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SDA */
173 /* PD14 */ { 1, 0, 0, 1, 1, 1 }, /* I2C SCL */
174#else
175#if defined(CONFIG_HARD_I2C)
176 /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
177 /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
178#else /* normal I/O port pins */
179 /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
180 /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */
181#endif
182#endif
183 /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
184 /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
185 /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
186 /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
187 /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* PD9 */
188 /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* PD8 */
189 /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
190 /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
191 /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
192 /* PD4 */ { 1, 1, 1, 0, 0, 0 }, /* SMC2 RXD */
193 /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
194 /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
195 /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
196 /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
197 }
198};
199
200/* ------------------------------------------------------------------------- */
201
202/* Check Board Identity:
203 */
204int checkboard (void)
205{
206 puts ("Board: PM826\n");
207 return 0;
208}
209
210/* ------------------------------------------------------------------------- */
211
212
213/* Try SDRAM initialization with P/LSDMR=sdmr and ORx=orx
214 *
215 * This routine performs standard 8260 initialization sequence
216 * and calculates the available memory size. It may be called
217 * several times to try different SDRAM configurations on both
218 * 60x and local buses.
219 */
220static long int try_init (volatile memctl8260_t * memctl, ulong sdmr,
221 ulong orx, volatile uchar * base)
222{
223 volatile uchar c = 0xff;
wdenkf8cac652002-08-26 22:36:39 +0000224 volatile uint *sdmr_ptr;
225 volatile uint *orx_ptr;
wdenkc83bf6a2004-01-06 22:38:14 +0000226 ulong maxsize, size;
wdenkf8cac652002-08-26 22:36:39 +0000227 int i;
wdenkf8cac652002-08-26 22:36:39 +0000228
229 /* We must be able to test a location outsize the maximum legal size
230 * to find out THAT we are outside; but this address still has to be
231 * mapped by the controller. That means, that the initial mapping has
232 * to be (at least) twice as large as the maximum expected size.
233 */
234 maxsize = (1 + (~orx | 0x7fff)) / 2;
235
236 sdmr_ptr = &memctl->memc_psdmr;
237 orx_ptr = &memctl->memc_or2;
238
239 *orx_ptr = orx;
240
241 /*
242 * Quote from 8260 UM (10.4.2 SDRAM Power-On Initialization, 10-35):
243 *
244 * "At system reset, initialization software must set up the
245 * programmable parameters in the memory controller banks registers
246 * (ORx, BRx, P/LSDMR). After all memory parameters are configured,
247 * system software should execute the following initialization sequence
248 * for each SDRAM device.
249 *
250 * 1. Issue a PRECHARGE-ALL-BANKS command
251 * 2. Issue eight CBR REFRESH commands
252 * 3. Issue a MODE-SET command to initialize the mode register
253 *
254 * The initial commands are executed by setting P/LSDMR[OP] and
255 * accessing the SDRAM with a single-byte transaction."
256 *
257 * The appropriate BRx/ORx registers have already been set when we
258 * get here. The SDRAM can be accessed at the address CFG_SDRAM_BASE.
259 */
260
261 *sdmr_ptr = sdmr | PSDMR_OP_PREA;
262 *base = c;
263
264 *sdmr_ptr = sdmr | PSDMR_OP_CBRR;
265 for (i = 0; i < 8; i++)
266 *base = c;
267
268 *sdmr_ptr = sdmr | PSDMR_OP_MRW;
269 *(base + CFG_MRS_OFFS) = c; /* setting MR on address lines */
270
271 *sdmr_ptr = sdmr | PSDMR_OP_NORM | PSDMR_RFEN;
272 *base = c;
273
wdenkc83bf6a2004-01-06 22:38:14 +0000274 size = get_ram_size((long *)base, maxsize);
wdenkf8cac652002-08-26 22:36:39 +0000275
wdenkc83bf6a2004-01-06 22:38:14 +0000276 *orx_ptr = orx | ~(size - 1);
wdenkf8cac652002-08-26 22:36:39 +0000277
wdenkc83bf6a2004-01-06 22:38:14 +0000278 return (size);
wdenkf8cac652002-08-26 22:36:39 +0000279}
280
281
282long int initdram (int board_type)
283{
284 volatile immap_t *immap = (immap_t *) CFG_IMMR;
285 volatile memctl8260_t *memctl = &immap->im_memctl;
286
287#ifndef CFG_RAMBOOT
288 ulong size8, size9;
289#endif
290 ulong psize = 32 * 1024 * 1024;
291
292 memctl->memc_psrt = CFG_PSRT;
293 memctl->memc_mptpr = CFG_MPTPR;
294
295#ifndef CFG_RAMBOOT
296 size8 = try_init (memctl, CFG_PSDMR_8COL, CFG_OR2_8COL,
297 (uchar *) CFG_SDRAM_BASE);
298 size9 = try_init (memctl, CFG_PSDMR_9COL, CFG_OR2_9COL,
299 (uchar *) CFG_SDRAM_BASE);
300
301 if (size8 < size9) {
302 psize = size9;
303 printf ("(60x:9COL) ");
304 } else {
305 psize = try_init (memctl, CFG_PSDMR_8COL, CFG_OR2_8COL,
306 (uchar *) CFG_SDRAM_BASE);
307 printf ("(60x:8COL) ");
308 }
309#endif
310 return (psize);
311}
312
Jon Loeliger9107ebe2007-06-11 19:03:23 -0500313#if (CONFIG_COMMANDS & CFG_CMD_DOC) || defined(CONFIG_CMD_DOC)
wdenkf8cac652002-08-26 22:36:39 +0000314extern void doc_probe (ulong physadr);
315void doc_init (void)
316{
317 doc_probe (CFG_DOC_BASE);
318}
319#endif
wdenk4d75a502003-03-25 16:50:56 +0000320
wdenkac6dbb82003-03-26 11:42:53 +0000321#ifdef CONFIG_PCI
wdenk4d75a502003-03-25 16:50:56 +0000322struct pci_controller hose;
323
324extern void pci_mpc8250_init(struct pci_controller *);
325
326void pci_init_board(void)
327{
328 pci_mpc8250_init(&hose);
329}
wdenkac6dbb82003-03-26 11:42:53 +0000330#endif