2 * (C) Copyright 2001-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * Modified during 2001 by
6 * Advanced Communications Technologies (Australia) Pty. Ltd.
7 * Howard Walker, Tuong Vu-Dinh
9 * (C) Copyright 2001, Stuart Hughes, Lineo Inc, stuarth@lineo.com
10 * Added support for the 16M dram simm on the 8260ads boards
12 * See file CREDITS for list of people who contributed to this
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
38 * I/O Port configuration table
40 * if conf is 1, then that port pin will be configured at boot time
41 * according to the five values podr/pdir/ppar/psor/pdat for that entry
44 const iop_conf_t iop_conf_tab[4][32] = {
46 /* Port A configuration */
47 { /* conf ppar psor pdir podr pdat */
48 /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
49 /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
50 /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
51 /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */
52 /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */
53 /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */
54 /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
55 /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
56 /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
57 /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
58 /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
59 /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
60 /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
61 /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
62 /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
63 /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
64 /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
65 /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
66 /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
67 /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
68 /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
69 /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
70 /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */
71 /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */
72 /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */
73 /* PA6 */ { 1, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */
74 /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */
75 /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */
76 /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */
77 /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */
78 /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */
79 /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */
82 /* Port B configuration */
83 { /* conf ppar psor pdir podr pdat */
84 /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
85 /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
86 /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
87 /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
88 /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
89 /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
90 /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
91 /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
92 /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
93 /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
94 /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
95 /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
96 /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
97 /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
98 /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
99 /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
100 /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
101 /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
102 /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */
103 /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
104 /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
105 /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
106 /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
107 /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
108 /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
109 /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
110 /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
111 /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
112 /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
113 /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
114 /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
115 /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
119 { /* conf ppar psor pdir podr pdat */
120 /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */
121 /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */
122 /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */
123 /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */
124 /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */
125 /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */
126 /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */
127 /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */
128 /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */
129 /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */
130 /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
131 /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
132 /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK CLK13 */
133 /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK14) */
134 /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */
135 /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */
136 /* PC15 */ { 0, 0, 0, 1, 0, 0 }, /* PC15 */
137 /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */
138 /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */
139 /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */
140 /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */
141 /* PC10 */ { 1, 1, 0, 0, 0, 0 }, /* LXT970 FETHMDC */
142 /* PC9 */ { 1, 1, 0, 0, 0, 0 }, /* LXT970 FETHMDIO */
143 /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */
144 /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */
145 /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */
146 /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */
147 /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */
148 /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */
149 /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */
150 /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */
151 /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */
155 { /* conf ppar psor pdir podr pdat */
156 /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
157 /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
158 /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
159 /* PD28 */ { 0, 1, 0, 0, 0, 0 }, /* PD28 */
160 /* PD27 */ { 0, 1, 1, 1, 0, 0 }, /* PD27 */
161 /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */
162 /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */
163 /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */
164 /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */
165 /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */
166 /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */
167 /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */
168 /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */
169 /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */
170 /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
171 /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
172 /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */
173 /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */
174 /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
175 /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
176 /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
177 /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
178 /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
179 /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
180 /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */
181 /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */
182 /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */
183 /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */
184 /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
185 /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
186 /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
187 /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
191 typedef struct bscr_ {
202 void reset_phy (void)
204 volatile bcsr_t *bcsr = (bcsr_t *) CFG_BCSR;
206 /* reset the FEC port */
207 bcsr->bcsr1 &= ~FETH_RST;
208 bcsr->bcsr1 |= FETH_RST;
212 int board_pre_init (void)
214 volatile bcsr_t *bcsr = (bcsr_t *) CFG_BCSR;
216 bcsr->bcsr1 = ~FETHIEN & ~RS232EN_1;
221 #define ns2clk(ns) (ns / (1000000000 / CONFIG_8260_CLKIN) + 1)
223 long int initdram (int board_type)
225 volatile immap_t *immap = (immap_t *) CFG_IMMR;
226 volatile memctl8260_t *memctl = &immap->im_memctl;
227 volatile uchar *ramaddr, c = 0xff;
229 /* Initialisation is for 16MB DIMM the board is shipped with */
231 uint or = 0xFF000CA0;
232 uint psdmr = CFG_PSDMR;
233 uint psrt = CFG_PSRT;
238 immap->im_siu_conf.sc_ppc_acr = 0x00000002;
239 immap->im_siu_conf.sc_ppc_alrh = 0x01267893;
240 immap->im_siu_conf.sc_tescr1 = 0x00004000;
242 memctl->memc_mptpr = CFG_MPTPR;
243 /* init local sdram, bank 4 */
244 memctl->memc_lsrt = 0x00000010;
245 memctl->memc_or4 = 0xFFC01480;
246 memctl->memc_br4 = 0x04001861;
247 memctl->memc_lsdmr = 0x2886A522;
248 ramaddr = (uchar *) CFG_LSDRAM_BASE;
250 memctl->memc_lsdmr = 0x0886A522;
251 for (i = 0; i < 8; i++) {
254 memctl->memc_lsdmr = 0x1886A522;
256 memctl->memc_lsdmr = 0x4086A522;
258 /* init sdram dimm */
259 #ifdef CONFIG_SPD_EEPROM
262 uint pbi, bsel, rowst, lsb, tmp;
264 i2c_read (CONFIG_SPD_ADDR, 0, 1, (uchar *) & spd, sizeof (spd));
266 /* Bank-based interleaving is not supported for physical bank
267 sizes greater than 128MB which is encoded as 0x20 in SPD
269 pbi = (spd.row_dens > 32) ? 1 : CONFIG_SDRAM_PBI;
270 msize = spd.nrows * (4 * spd.row_dens); /* Mixed size not supported */
271 or = ~(msize - 1) << 20; /* SDAM */
272 switch (spd.nbanks) { /* BPD */
285 lsb = 3; /* For 64-bit port, lsb is 3 bits */
287 if (pbi) { /* Bus partition depends on interleaving */
288 rowst = 32 - (spd.nrow_addr + spd.ncol_addr + bsel + lsb);
289 or |= (rowst << 9); /* ROWST */
291 rowst = 32 - (spd.nrow_addr + spd.ncol_addr + lsb);
292 or |= ((rowst * 2 - 12) << 9); /* ROWST */
294 or |= ((spd.nrow_addr - 9) << 6); /* NUMR */
296 psdmr = (pbi << 31); /* PBI */
297 /* Bus multiplexing parameters */
298 tmp = 32 - (lsb + spd.nrow_addr); /* Tables 10-19 and 10-20 */
299 psdmr |= ((tmp - (rowst - 5) - 13) << 24); /* SDAM */
300 psdmr |= ((tmp - 3 - 12) << 21); /* BSMA */
302 tmp = (31 - lsb - 10) - tmp;
303 /* Pin connected to SDA10 is (31 - lsb - 10).
304 rowst is multiplexed over (32 - (lsb + spd.nrow_addr)),
305 so (rowst + tmp) alternates with AP.
307 if (pbi) /* Table 10-7 */
308 psdmr |= ((10 - (rowst + tmp)) << 18); /* SDA10 */
310 psdmr |= ((12 - (rowst + tmp)) << 18); /* SDA10 */
312 /* SDRAM device-specific parameters */
313 tmp = ns2clk (70); /* Refresh recovery is not in SPD, so assume 70ns */
314 switch (tmp) { /* RFRC */
325 psdmr |= ((tmp - 2) << 15);
330 psdmr |= (ns2clk (spd.trp) % 8 << 12); /* PRETOACT */
331 psdmr |= (ns2clk (spd.trcd) % 8 << 9); /* ACTTORW */
332 /* BL=0 because for 64-bit SDRAM burst length must be 4 */
334 for (i = 0, tmp = spd.write_lat; (i < 4) && ((tmp & 1) == 0); i++)
336 switch (i) { /* WRC */
346 /* EAMUX=0 - no external address multiplexing */
347 /* BUFCMD=0 - no external buffers */
348 for (i = 1, tmp = spd.cas_lat; (i < 3) && ((tmp & 1) == 0); i++)
352 switch (spd.refresh & 0x7F) {
371 psrt = tmp / (1000000000 / CONFIG_8260_CLKIN *
372 ((memctl->memc_mptpr >> 8) + 1)) - 1;
374 printf ("\nDIMM type: %-18.18s\n", spd.mpart);
375 printf ("SPD size: %d\n", spd.info_size);
376 printf ("EEPROM size: %d\n", 1 << spd.chip_size);
377 printf ("Memory type: %d\n", spd.mem_type);
378 printf ("Row addr: %d\n", spd.nrow_addr);
379 printf ("Column addr: %d\n", spd.ncol_addr);
380 printf ("# of rows: %d\n", spd.nrows);
381 printf ("Row density: %d\n", spd.row_dens);
382 printf ("# of banks: %d\n", spd.nbanks);
383 printf ("Data width: %d\n",
384 256 * spd.dataw_msb + spd.dataw_lsb);
385 printf ("Chip width: %d\n", spd.primw);
386 printf ("Refresh rate: %02X\n", spd.refresh);
387 printf ("CAS latencies: %02X\n", spd.cas_lat);
388 printf ("Write latencies: %02X\n", spd.write_lat);
389 printf ("tRP: %d\n", spd.trp);
390 printf ("tRCD: %d\n", spd.trcd);
392 printf ("OR=%X, PSDMR=%08X, PSRT=%0X\n", or, psdmr, psrt);
393 #endif /* SPD_DEBUG */
395 #endif /* CONFIG_SPD_EEPROM */
396 memctl->memc_psrt = psrt;
397 memctl->memc_or2 = or;
398 memctl->memc_br2 = CFG_SDRAM_BASE | 0x00000041;
399 ramaddr = (uchar *) CFG_SDRAM_BASE;
400 memctl->memc_psdmr = psdmr | 0x28000000; /* Precharge all banks */
402 memctl->memc_psdmr = psdmr | 0x08000000; /* CBR refresh */
403 for (i = 0; i < 8; i++)
406 memctl->memc_psdmr = psdmr | 0x18000000; /* Mode Register write */
408 memctl->memc_psdmr = psdmr | 0x40000000; /* Refresh enable */
412 /* return total ram size of DIMM */
413 return (msize * 1024 * 1024);
416 int checkboard (void)
418 puts ("Board: Motorola MPC8260ADS\n");