blob: fed4934afd210b0c515451d49cc6393acbb8803f [file] [log] [blame]
wdenk54387ac2003-10-08 22:45:44 +00001/*
2 * (C) Copyright 2001-2003
3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 *
Wolfgang Denkaba9f1a2006-03-12 01:45:44 +01005 * (C) Copyright 2003-2005 Arabella Software Ltd.
wdenk54387ac2003-10-08 22:45:44 +00006 * Yuli Barcohen <yuli@arabellasw.com>
7 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02008 * SPDX-License-Identifier: GPL-2.0+
wdenk54387ac2003-10-08 22:45:44 +00009 */
10
11#include <common.h>
12#include <ioports.h>
13#include <mpc8260.h>
wdenk54387ac2003-10-08 22:45:44 +000014#include <miiphy.h>
15
16/*
17 * I/O Port configuration table
18 *
19 * if conf is 1, then that port pin will be configured at boot time
20 * according to the five values podr/pdir/ppar/psor/pdat for that entry
21 */
22
23const iop_conf_t iop_conf_tab[4][32] = {
24
25 /* Port A */
26 { /* conf ppar psor pdir podr pdat */
27 /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */
28 /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */
29 /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */
30 /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */
31 /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */
32 /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */
33 /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */
34 /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */
35 /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */
36 /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */
37 /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */
38 /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */
39 /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */
40 /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */
41 /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */
42 /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */
43 /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */
44 /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */
45 /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */
46 /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */
47 /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */
48 /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */
49 /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* SMC2 TXD */
50 /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* SMC2 RXD */
51 /* PA7 */ { 0, 0, 0, 0, 0, 0 }, /* PA7 */
52 /* PA6 */ { 0, 0, 0, 0, 0, 0 }, /* PA6 */
53 /* PA5 */ { 0, 0, 0, 0, 0, 0 }, /* PA5 */
54 /* PA4 */ { 0, 0, 0, 0, 0, 0 }, /* PA4 */
55 /* PA3 */ { 0, 0, 0, 0, 0, 0 }, /* PA3 */
56 /* PA2 */ { 0, 0, 0, 0, 0, 0 }, /* PA2 */
57 /* PA1 */ { 0, 0, 0, 0, 0, 0 }, /* PA1 */
58 /* PA0 */ { 0, 0, 0, 0, 0, 0 } /* PA0 */
59 },
60
61 /* Port B */
62 { /* conf ppar psor pdir podr pdat */
63 /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */
64 /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */
65 /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */
66 /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */
67 /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */
68 /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */
69 /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */
70 /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */
71 /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */
72 /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */
73 /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */
74 /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */
75 /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */
76 /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */
77 /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */
78 /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */
79 /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */
80 /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */
81 /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */
82 /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */
83 /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
84 /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
85 /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
86 /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */
87 /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
88 /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
89 /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
90 /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */
91 /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
92 /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
93 /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
94 /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
95 },
96
97 /* Port C */
98 { /* conf ppar psor pdir podr pdat */
99 /* PC31 */ { 0, 0, 0, 0, 0, 0 }, /* PC31 */
100 /* PC30 */ { 0, 0, 0, 0, 0, 0 }, /* PC30 */
101 /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN CLSN */
102 /* PC28 */ { 0, 0, 0, 0, 0, 0 }, /* PC28 */
103 /* PC27 */ { 0, 0, 0, 0, 0, 0 }, /* PC27 */
104 /* PC26 */ { 0, 0, 0, 0, 0, 0 }, /* PC26 */
105 /* PC25 */ { 0, 0, 0, 0, 0, 0 }, /* PC25 */
106 /* PC24 */ { 0, 0, 0, 0, 0, 0 }, /* PC24 */
107 /* PC23 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */
108 /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */
109 /* PC21 */ { 0, 0, 0, 0, 0, 0 }, /* PC21 */
110 /* PC20 */ { 0, 0, 0, 0, 0, 0 }, /* PC20 */
111 /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII Rx Clock (CLK13) */
112 /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII Tx Clock (CLK14) */
113 /* PC17 */ { 0, 0, 0, 0, 0, 0 }, /* PC17 */
114 /* PC16 */ { 0, 0, 0, 0, 0, 0 }, /* PC16 */
115 /* PC15 */ { 0, 0, 0, 0, 0, 0 }, /* PC15 */
116 /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RENA */
117 /* PC13 */ { 0, 0, 0, 0, 0, 0 }, /* PC13 */
118 /* PC12 */ { 0, 0, 0, 0, 0, 0 }, /* PC12 */
119 /* PC11 */ { 0, 0, 0, 0, 0, 0 }, /* PC11 */
120 /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* LXT972 MDC */
121 /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* LXT972 MDIO */
122 /* PC8 */ { 0, 0, 0, 0, 0, 0 }, /* PC8 */
123 /* PC7 */ { 0, 0, 0, 0, 0, 0 }, /* PC7 */
124 /* PC6 */ { 0, 0, 0, 0, 0, 0 }, /* PC6 */
125 /* PC5 */ { 0, 0, 0, 0, 0, 0 }, /* PC5 */
126 /* PC4 */ { 0, 0, 0, 0, 0, 0 }, /* PC4 */
127 /* PC3 */ { 0, 0, 0, 0, 0, 0 }, /* PC3 */
128 /* PC2 */ { 0, 0, 0, 0, 0, 0 }, /* PC2 */
129 /* PC1 */ { 0, 0, 0, 0, 0, 0 }, /* PC1 */
130 /* PC0 */ { 0, 0, 0, 0, 0, 0 }, /* PC0 */
131 },
132
133 /* Port D */
134 { /* conf ppar psor pdir podr pdat */
135 /* PD31 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */
136 /* PD30 */ { 0, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */
137 /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */
138 /* PD28 */ { 0, 0, 0, 0, 0, 0 }, /* PD28 */
139 /* PD27 */ { 0, 0, 0, 0, 0, 0 }, /* PD27 */
140 /* PD26 */ { 0, 0, 0, 0, 0, 0 }, /* PD26 */
141 /* PD25 */ { 0, 0, 0, 0, 0, 0 }, /* PD25 */
142 /* PD24 */ { 0, 0, 0, 0, 0, 0 }, /* PD24 */
143 /* PD23 */ { 0, 0, 0, 0, 0, 0 }, /* PD23 */
144 /* PD22 */ { 0, 0, 0, 0, 0, 0 }, /* PD22 */
145 /* PD21 */ { 0, 0, 0, 0, 0, 0 }, /* PD21 */
146 /* PD20 */ { 0, 0, 0, 0, 0, 0 }, /* PD20 */
147 /* PD19 */ { 0, 0, 0, 0, 0, 0 }, /* PD19 */
148 /* PD18 */ { 0, 0, 0, 0, 0, 0 }, /* PD18 */
149 /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */
150 /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */
Wolfgang Denkaba9f1a2006-03-12 01:45:44 +0100151 /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */
152 /* PD14 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SCL */
wdenk54387ac2003-10-08 22:45:44 +0000153 /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */
154 /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */
155 /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */
156 /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */
157 /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */
158 /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */
159 /* PD7 */ { 0, 0, 0, 0, 0, 0 }, /* PD7 */
160 /* PD6 */ { 0, 0, 0, 0, 0, 0 }, /* PD6 */
161 /* PD5 */ { 0, 0, 0, 0, 0, 0 }, /* PD5 */
162 /* PD4 */ { 0, 0, 0, 0, 0, 0 }, /* PD4 */
163 /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
164 /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
165 /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */
166 /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */
167 }
168};
169
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200170#ifdef CONFIG_SYS_NVRAM_ACCESS_ROUTINE
wdenk54387ac2003-10-08 22:45:44 +0000171void *nvram_read(void *dest, long src, size_t count)
172{
173 return memcpy(dest, (const void *)src, count);
174}
175
176void nvram_write(long dest, const void *src, size_t count)
177{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200178 vu_char *p1 = (vu_char *)(CONFIG_SYS_EEPROM + 0x1555);
179 vu_char *p2 = (vu_char *)(CONFIG_SYS_EEPROM + 0x0AAA);
wdenk54387ac2003-10-08 22:45:44 +0000180 vu_char *d = (vu_char *)dest;
181 const uchar *s = (const uchar *)src;
182
183 /* Unprotect the EEPROM */
184 *p1 = 0xAA;
185 *p2 = 0x55;
186 *p1 = 0x80;
187 *p1 = 0xAA;
188 *p2 = 0x55;
189 *p1 = 0x20;
190 udelay(10000);
191
192 /* Write the data to the EEPROM */
193 while (count--) {
194 *d++ = *s++;
195 while (*(d - 1) != *(s - 1))
196 /* wait */;
197 }
198
199 /* Protect the EEPROM */
200 *p1 = 0xAA;
201 *p2 = 0x55;
202 *p1 = 0xA0;
203 udelay(10000);
204}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200205#endif /* CONFIG_SYS_NVRAM_ACCESS_ROUTINE */
wdenk54387ac2003-10-08 22:45:44 +0000206
Becky Bruce9973e3c2008-06-09 16:03:40 -0500207phys_size_t initdram(int board_type)
wdenk54387ac2003-10-08 22:45:44 +0000208{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200209 vu_char *bcsr = (vu_char *)CONFIG_SYS_BCSR;
210 volatile immap_t *immap = (immap_t *)CONFIG_SYS_IMMR;
wdenk54387ac2003-10-08 22:45:44 +0000211 volatile memctl8260_t *memctl = &immap->im_memctl;
212 vu_char *ramaddr;
213 uchar c = 0xFF;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200214 long int msize = CONFIG_SYS_SDRAM_SIZE;
wdenk54387ac2003-10-08 22:45:44 +0000215 int i;
216
217 if (bcsr[4] & BCSR_PCI_MODE) { /* PCI mode selected by JP9 */
Wolfgang Denkaba9f1a2006-03-12 01:45:44 +0100218 immap->im_clkrst.car_sccr |= SCCR_PCI_MODE;
wdenk54387ac2003-10-08 22:45:44 +0000219 immap->im_siu_conf.sc_siumcr =
220 (immap->im_siu_conf.sc_siumcr & ~SIUMCR_LBPC11)
221 | SIUMCR_LBPC01;
222 }
223
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200224#ifndef CONFIG_SYS_RAMBOOT
wdenk54387ac2003-10-08 22:45:44 +0000225 immap->im_siu_conf.sc_ppc_acr = 0x03;
226 immap->im_siu_conf.sc_ppc_alrh = 0x30126745;
227 immap->im_siu_conf.sc_tescr1 = 0x00004000;
228
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200229 memctl->memc_mptpr = CONFIG_SYS_MPTPR;
wdenk54387ac2003-10-08 22:45:44 +0000230
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200231#ifdef CONFIG_SYS_LSDRAM_BASE
wdenk54387ac2003-10-08 22:45:44 +0000232 /*
233 Initialise local bus SDRAM only if the pins
234 are configured as local bus pins and not as PCI.
235 */
236 if ((immap->im_siu_conf.sc_siumcr & SIUMCR_LBPC11) == SIUMCR_LBPC00) {
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200237 memctl->memc_lsrt = CONFIG_SYS_LSRT;
238 memctl->memc_or4 = CONFIG_SYS_LSDRAM_OR;
239 memctl->memc_br4 = CONFIG_SYS_LSDRAM_BR;
240 ramaddr = (vu_char *)CONFIG_SYS_LSDRAM_BASE;
241 memctl->memc_lsdmr = CONFIG_SYS_LSDMR | PSDMR_OP_PREA;
wdenk54387ac2003-10-08 22:45:44 +0000242 *ramaddr = c;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200243 memctl->memc_lsdmr = CONFIG_SYS_LSDMR | PSDMR_OP_CBRR;
wdenk54387ac2003-10-08 22:45:44 +0000244 for (i = 0; i < 8; i++)
245 *ramaddr = c;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200246 memctl->memc_lsdmr = CONFIG_SYS_LSDMR | PSDMR_OP_MRW;
wdenk54387ac2003-10-08 22:45:44 +0000247 *ramaddr = c;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200248 memctl->memc_lsdmr = CONFIG_SYS_LSDMR | PSDMR_RFEN;
wdenk54387ac2003-10-08 22:45:44 +0000249 }
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200250#endif /* CONFIG_SYS_LSDRAM_BASE */
wdenk54387ac2003-10-08 22:45:44 +0000251
252 /* Initialise 60x bus SDRAM */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200253 memctl->memc_psrt = CONFIG_SYS_PSRT;
254 memctl->memc_or2 = CONFIG_SYS_PSDRAM_OR;
255 memctl->memc_br2 = CONFIG_SYS_PSDRAM_BR;
wdenk54387ac2003-10-08 22:45:44 +0000256 /*
257 * The mode data for Mode Register Write command must appear on
258 * the address lines during a mode-set cycle. It is driven by
259 * the memory controller, in single PowerQUICC II mode,
260 * according to PSDMR[CL] and PSDMR[BL] fields. In
261 * 60x-compatible mode, software must drive the correct value on
262 * the address lines. BL=0 because for 64-bit port size burst
263 * length must be 4.
264 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200265 ramaddr = (vu_char *)(CONFIG_SYS_SDRAM_BASE |
266 ((CONFIG_SYS_PSDMR & PSDMR_CL_MSK) << 7) | 0x10);
267 memctl->memc_psdmr = CONFIG_SYS_PSDMR | PSDMR_OP_PREA; /* Precharge all banks */
wdenk54387ac2003-10-08 22:45:44 +0000268 *ramaddr = c;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200269 memctl->memc_psdmr = CONFIG_SYS_PSDMR | PSDMR_OP_CBRR; /* CBR refresh */
wdenk54387ac2003-10-08 22:45:44 +0000270 for (i = 0; i < 8; i++)
271 *ramaddr = c;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200272 memctl->memc_psdmr = CONFIG_SYS_PSDMR | PSDMR_OP_MRW; /* Mode Register write */
wdenk54387ac2003-10-08 22:45:44 +0000273 *ramaddr = c;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200274 memctl->memc_psdmr = CONFIG_SYS_PSDMR | PSDMR_RFEN; /* Refresh enable */
wdenk54387ac2003-10-08 22:45:44 +0000275 *ramaddr = c;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200276#endif /* CONFIG_SYS_RAMBOOT */
wdenk54387ac2003-10-08 22:45:44 +0000277
278 /* Return total 60x bus SDRAM size */
279 return msize * 1024 * 1024;
280}
281
282int checkboard(void)
283{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200284 vu_char *bcsr = (vu_char *)CONFIG_SYS_BCSR;
wdenk54387ac2003-10-08 22:45:44 +0000285
286 printf("Board: Zephyr ZPC.1900 Rev. %c\n", bcsr[2] + 0x40);
287 return 0;
288}