]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/stx/stxssa/stxssa.c
Merge branch 'master' of git://git.denx.de/u-boot-usb
[karo-tx-uboot.git] / board / stx / stxssa / stxssa.c
1 /*
2  * (C) Copyright 2005, Embedded Alley Solutions, Inc.
3  * Dan Malek, <dan@embeddedalley.com>
4  * Copied from STx GP3.
5  * Updates for Silicon Tx GP3 SSA
6  *
7  * (C) Copyright 2003,Motorola Inc.
8  * Xianghua Xiao, (X.Xiao@motorola.com)
9  *
10  * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com>
11  *
12  * SPDX-License-Identifier:     GPL-2.0+
13  */
14
15
16 #include <common.h>
17 #include <pci.h>
18 #include <asm/processor.h>
19 #include <asm/mmu.h>
20 #include <asm/immap_85xx.h>
21 #include <asm/fsl_pci.h>
22 #include <fsl_ddr_sdram.h>
23 #include <ioports.h>
24 #include <asm/io.h>
25 #include <spd_sdram.h>
26 #include <miiphy.h>
27 #include <netdev.h>
28
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
36 const iop_conf_t iop_conf_tab[4][32] = {
37
38     /* Port A configuration */
39     {   /*            conf ppar psor pdir podr pdat */
40         /* PA31 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 TxENB */
41         /* PA30 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 TxClav   */
42         /* PA29 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 TxSOC  */
43         /* PA28 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 RxENB */
44         /* PA27 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 RxSOC */
45         /* PA26 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 RxClav */
46         /* PA25 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 ATMTXD[0] */
47         /* PA24 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 ATMTXD[1] */
48         /* PA23 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 ATMTXD[2] */
49         /* PA22 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 ATMTXD[3] */
50         /* PA21 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 ATMTXD[4] */
51         /* PA20 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 ATMTXD[5] */
52         /* PA19 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 ATMTXD[6] */
53         /* PA18 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 ATMTXD[7] */
54         /* PA17 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 ATMRXD[7] */
55         /* PA16 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 ATMRXD[6] */
56         /* PA15 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 ATMRXD[5] */
57         /* PA14 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 ATMRXD[4] */
58         /* PA13 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 ATMRXD[3] */
59         /* PA12 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 ATMRXD[2] */
60         /* PA11 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 ATMRXD[1] */
61         /* PA10 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 ATMRXD[0] */
62         /* PA9  */ {   0,   1,   1,   1,   0,   0   }, /* FCC1 L1TXD */
63         /* PA8  */ {   0,   1,   1,   0,   0,   0   }, /* FCC1 L1RXD */
64         /* PA7  */ {   0,   0,   0,   1,   0,   0   }, /* PA7 */
65         /* PA6  */ {   0,   1,   1,   1,   0,   0   }, /* TDM A1 L1RSYNC */
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  */ {   1,   0,   0,   0,   0,   0   }, /* FREERUN */
71         /* PA0  */ {   0,   0,   0,   1,   0,   0   }  /* PA0 */
72     },
73
74     /* Port B configuration */
75     {   /*            conf ppar psor pdir podr pdat */
76         /* PB31 */ {   1,   1,   0,   1,   0,   0   }, /* FCC2 MII TX_ER */
77         /* PB30 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RX_DV */
78         /* PB29 */ {   1,   1,   1,   1,   0,   0   }, /* FCC2 MII TX_EN */
79         /* PB28 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RX_ER */
80         /* PB27 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII COL */
81         /* PB26 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII CRS */
82         /* PB25 */ {   1,   1,   0,   1,   0,   0   }, /* FCC2 MII TxD[3] */
83         /* PB24 */ {   1,   1,   0,   1,   0,   0   }, /* FCC2 MII TxD[2] */
84         /* PB23 */ {   1,   1,   0,   1,   0,   0   }, /* FCC2 MII TxD[1] */
85         /* PB22 */ {   1,   1,   0,   1,   0,   0   }, /* FCC2 MII TxD[0] */
86         /* PB21 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RxD[0] */
87         /* PB20 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RxD[1] */
88         /* PB19 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RxD[2] */
89         /* PB18 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RxD[3] */
90         /* PB17 */ {   0,   1,   0,   0,   0,   0   }, /* FCC3:RX_DIV */
91         /* PB16 */ {   0,   1,   0,   0,   0,   0   }, /* FCC3:RX_ERR */
92         /* PB15 */ {   0,   1,   0,   1,   0,   0   }, /* FCC3:TX_ERR */
93         /* PB14 */ {   0,   1,   0,   1,   0,   0   }, /* FCC3:TX_EN */
94         /* PB13 */ {   0,   1,   0,   0,   0,   0   }, /* FCC3:COL */
95         /* PB12 */ {   0,   1,   0,   0,   0,   0   }, /* FCC3:CRS */
96         /* PB11 */ {   0,   1,   0,   0,   0,   0   }, /* FCC3:RXD */
97         /* PB10 */ {   0,   1,   0,   0,   0,   0   }, /* FCC3:RXD */
98         /* PB9  */ {   0,   1,   0,   0,   0,   0   }, /* FCC3:RXD */
99         /* PB8  */ {   0,   1,   0,   0,   0,   0   }, /* FCC3:RXD */
100         /* PB7  */ {   0,   1,   0,   1,   0,   0   }, /* FCC3:TXD */
101         /* PB6  */ {   0,   1,   0,   1,   0,   0   }, /* FCC3:TXD */
102         /* PB5  */ {   0,   1,   0,   1,   0,   0   }, /* FCC3:TXD */
103         /* PB4  */ {   0,   1,   0,   1,   0,   0   }, /* FCC3:TXD */
104         /* PB3  */ {   0,   0,   0,   0,   0,   0   }, /* pin doesn't exist */
105         /* PB2  */ {   0,   0,   0,   0,   0,   0   }, /* pin doesn't exist */
106         /* PB1  */ {   0,   0,   0,   0,   0,   0   }, /* pin doesn't exist */
107         /* PB0  */ {   0,   0,   0,   0,   0,   0   }  /* pin doesn't exist */
108     },
109
110     /* Port C */
111     {   /*            conf ppar psor pdir podr pdat */
112         /* PC31 */ {   0,   0,   0,   1,   0,   0   }, /* PC31 */
113         /* PC30 */ {   0,   0,   0,   1,   0,   0   }, /* PC30 */
114         /* PC29 */ {   0,   1,   1,   0,   0,   0   }, /* SCC1 EN *CLSN */
115         /* PC28 */ {   0,   0,   0,   1,   0,   0   }, /* PC28 */
116         /* PC27 */ {   0,   0,   0,   1,   0,   0   }, /* UART Clock in */
117         /* PC26 */ {   0,   0,   0,   1,   0,   0   }, /* PC26 */
118         /* PC25 */ {   0,   0,   0,   1,   0,   0   }, /* PC25 */
119         /* PC24 */ {   0,   0,   0,   1,   0,   0   }, /* PC24 */
120         /* PC23 */ {   0,   1,   0,   1,   0,   0   }, /* ATMTFCLK */
121         /* PC22 */ {   0,   1,   0,   0,   0,   0   }, /* ATMRFCLK */
122         /* PC21 */ {   0,   1,   0,   0,   0,   0   }, /* SCC1 EN RXCLK */
123         /* PC20 */ {   0,   1,   0,   0,   0,   0   }, /* SCC1 EN TXCLK */
124         /* PC19 */ {   1,   1,   0,   0,   0,   0   }, /* FCC2 MII RX_CLK CLK13 */
125         /* PC18 */ {   1,   1,   0,   0,   0,   0   }, /* FCC Tx Clock (CLK14) */
126         /* PC17 */ {   0,   0,   0,   1,   0,   0   }, /* PC17 */
127         /* PC16 */ {   0,   1,   0,   0,   0,   0   }, /* FCC Tx Clock (CLK16) */
128         /* PC15 */ {   0,   1,   0,   0,   0,   0   }, /* PC15 */
129         /* PC14 */ {   0,   1,   0,   0,   0,   0   }, /* SCC1 EN *CD */
130         /* PC13 */ {   0,   0,   0,   1,   0,   0   }, /* PC13 */
131         /* PC12 */ {   0,   1,   0,   1,   0,   0   }, /* PC12 */
132         /* PC11 */ {   0,   0,   0,   1,   0,   0   }, /* LXT971 transmit control */
133         /* PC10 */ {   0,   0,   0,   1,   0,   0   }, /* FETHMDC */
134         /* PC9  */ {   0,   0,   0,   0,   0,   0   }, /* FETHMDIO */
135         /* PC8  */ {   0,   0,   0,   1,   0,   0   }, /* PC8 */
136         /* PC7  */ {   0,   0,   0,   1,   0,   0   }, /* PC7 */
137         /* PC6  */ {   0,   0,   0,   1,   0,   0   }, /* PC6 */
138         /* PC5  */ {   0,   0,   0,   1,   0,   0   }, /* PC5 */
139         /* PC4  */ {   0,   0,   0,   1,   0,   0   }, /* PC4 */
140         /* PC3  */ {   0,   0,   0,   1,   0,   0   }, /* PC3 */
141         /* PC2  */ {   0,   0,   0,   1,   0,   1   }, /* ENET FDE */
142         /* PC1  */ {   0,   0,   0,   1,   0,   0   }, /* ENET DSQE */
143         /* PC0  */ {   0,   0,   0,   1,   0,   0   }, /* ENET LBK */
144     },
145
146     /* Port D */
147     {   /*            conf ppar psor pdir podr pdat */
148         /* PD31 */ {   0,   1,   0,   0,   0,   0   }, /* SCC1 EN RxD */
149         /* PD30 */ {   0,   1,   1,   1,   0,   0   }, /* SCC1 EN TxD */
150         /* PD29 */ {   0,   1,   0,   1,   0,   0   }, /* SCC1 EN TENA */
151         /* PD28 */ {   1,   1,   0,   0,   0,   0   }, /* SCC2 RxD */
152         /* PD27 */ {   1,   1,   0,   1,   0,   0   }, /* SCC2 TxD */
153         /* PD26 */ {   0,   0,   0,   1,   0,   0   }, /* PD26 */
154         /* PD25 */ {   0,   0,   0,   1,   0,   0   }, /* PD25 */
155         /* PD24 */ {   0,   0,   0,   1,   0,   0   }, /* PD24 */
156         /* PD23 */ {   0,   0,   0,   1,   0,   0   }, /* PD23 */
157         /* PD22 */ {   0,   0,   0,   1,   0,   0   }, /* PD22 */
158         /* PD21 */ {   0,   0,   0,   1,   0,   0   }, /* PD21 */
159         /* PD20 */ {   0,   0,   0,   1,   0,   0   }, /* PD20 */
160         /* PD19 */ {   0,   0,   0,   1,   0,   0   }, /* PD19 */
161         /* PD18 */ {   0,   0,   0,   1,   0,   0   }, /* PD18 */
162         /* PD17 */ {   0,   1,   0,   0,   0,   0   }, /* FCC1 ATMRXPRTY */
163         /* PD16 */ {   0,   1,   0,   1,   0,   0   }, /* FCC1 ATMTXPRTY */
164         /* PD15 */ {   1,   1,   1,   0,   1,   0   }, /* I2C SDA */
165         /* PD14 */ {   1,   1,   1,   0,   0,   0   }, /* I2C CLK */
166         /* PD13 */ {   0,   0,   0,   0,   0,   0   }, /* PD13 */
167         /* PD12 */ {   0,   0,   0,   0,   0,   0   }, /* PD12 */
168         /* PD11 */ {   0,   0,   0,   0,   0,   0   }, /* PD11 */
169         /* PD10 */ {   0,   0,   0,   0,   0,   0   }, /* PD10 */
170         /* PD9  */ {   0,   1,   0,   1,   0,   0   }, /* SMC1 TXD */
171         /* PD8  */ {   0,   1,   0,   0,   0,   0   }, /* SMC1 RXD */
172         /* PD7  */ {   0,   0,   0,   1,   0,   1   }, /* PD7 */
173         /* PD6  */ {   0,   0,   0,   1,   0,   1   }, /* PD6 */
174         /* PD5  */ {   0,   0,   0,   1,   0,   1   }, /* PD5 */
175         /* PD4  */ {   0,   0,   0,   1,   0,   1   }, /* PD4 */
176         /* PD3  */ {   0,   0,   0,   0,   0,   0   }, /* pin doesn't exist */
177         /* PD2  */ {   0,   0,   0,   0,   0,   0   }, /* pin doesn't exist */
178         /* PD1  */ {   0,   0,   0,   0,   0,   0   }, /* pin doesn't exist */
179         /* PD0  */ {   0,   0,   0,   0,   0,   0   }  /* pin doesn't exist */
180     }
181 };
182
183 static  uint64_t        next_led_update;
184 static  uint            led_bit;
185
186 void
187 reset_phy(void)
188 {
189         volatile uint *blatch;
190 #if 0
191         int     i;
192 #endif
193         blatch = (volatile uint *)CONFIG_SYS_LBC_CFGLATCH_BASE;
194
195         /* reset Giga bit Ethernet port if needed here */
196
197 #if 1
198         *blatch &= ~0x000000c0;
199         udelay(100);
200 #else
201         *blatch = 0;
202         asm("eieio");
203         for (i=0; i<1000; i++)
204                 udelay(1000);
205 #endif
206         *blatch = 0x000000c1;   /* Light one led, too */
207         udelay(1000);
208
209 #if 0   /* This is the port we really want to use for debugging. */
210         /* reset the CPM FEC port */
211 #if (CONFIG_ETHER_INDEX == 2)
212         bcsr->bcsr2 &= ~FETH2_RST;
213         udelay(2);
214         bcsr->bcsr2 |=  FETH2_RST;
215         udelay(1000);
216 #elif (CONFIG_ETHER_INDEX == 3)
217         bcsr->bcsr3 &= ~FETH3_RST;
218         udelay(2);
219         bcsr->bcsr3 |=  FETH3_RST;
220         udelay(1000);
221 #endif
222 #if defined(CONFIG_MII) && defined(CONFIG_ETHER_ON_FCC)
223         /* reset PHY */
224         miiphy_reset("FCC1", 0x0);
225
226         /* change PHY address to 0x02 */
227         bb_miiphy_write(NULL, 0, MII_MIPSCR, 0xf028);
228
229         bb_miiphy_write(NULL, 0x02, MII_BMCR,
230                         BMCR_ANENABLE | BMCR_ANRESTART);
231 #endif /* CONFIG_MII */
232 #endif
233 }
234
235 #ifdef CONFIG_OF_BOARD_SETUP
236 int ft_board_setup(void *blob, bd_t *bd)
237 {
238         ft_cpu_setup (blob, bd);
239
240         return 0;
241 }
242 #endif /* CONFIG_OF_BOARD_SETUP */
243
244 int
245 board_early_init_f(void)
246 {
247 #if defined(CONFIG_PCI)
248         volatile ccsr_pcix_t *pci = (void *)(CONFIG_SYS_MPC85xx_PCIX_ADDR);
249
250         pci->peer &= 0xffffffdf; /* disable master abort */
251 #endif
252
253         /* Why is the phy reset done _after_ the ethernet
254          * initialization in arch/powerpc/lib/board.c?
255          * Do it here so it's done before the TSECs are used.
256          */
257         reset_phy();
258
259         return 0;
260 }
261
262 int
263 checkboard(void)
264 {
265         printf ("Board: Silicon Tx GPPP SSA Board\n");
266         return (0);
267 }
268
269 /* Blinkin' LEDS for Robert.
270 */
271 void
272 show_activity(int flag)
273 {
274         volatile uint *blatch;
275
276         if (next_led_update > get_ticks())
277                 return;
278
279         blatch = (volatile uint *)CONFIG_SYS_LBC_CFGLATCH_BASE;
280
281         led_bit >>= 1;
282         if (led_bit == 0)
283                 led_bit = 0x08;
284         *blatch = (0xc0 | led_bit);
285         eieio();
286         next_led_update += (get_tbclk() / 4);
287 }
288
289 #if defined(CONFIG_SYS_DRAM_TEST)
290 int testdram (void)
291 {
292         uint *pstart = (uint *) CONFIG_SYS_MEMTEST_START;
293         uint *pend = (uint *) CONFIG_SYS_MEMTEST_END;
294         uint *p;
295
296         printf("SDRAM test phase 1:\n");
297         for (p = pstart; p < pend; p++)
298                 *p = 0xaaaaaaaa;
299
300         for (p = pstart; p < pend; p++) {
301                 if (*p != 0xaaaaaaaa) {
302                         printf ("SDRAM test fails at: %08x\n", (uint) p);
303                         return 1;
304                 }
305         }
306
307         printf("SDRAM test phase 2:\n");
308         for (p = pstart; p < pend; p++)
309                 *p = 0x55555555;
310
311         for (p = pstart; p < pend; p++) {
312                 if (*p != 0x55555555) {
313                         printf ("SDRAM test fails at: %08x\n", (uint) p);
314                         return 1;
315                 }
316         }
317
318         printf("SDRAM test passed.\n");
319         return 0;
320 }
321 #endif
322
323 #if defined(CONFIG_PCI)
324
325 /*
326  * Initialize PCI Devices, report devices found.
327  */
328
329 #ifndef CONFIG_PCI_PNP
330 static struct pci_config_table pci_stxgp3_config_table[] = {
331     { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
332       PCI_IDSEL_NUMBER, PCI_ANY_ID,
333       pci_cfgfunc_config_device, { PCI_ENET0_IOADDR,
334                                    PCI_ENET0_MEMADDR,
335                                    PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER
336       } },
337     { }
338 };
339 #endif
340
341
342 static struct pci_controller hose[] = {
343 #ifndef CONFIG_PCI_PNP
344         { config_table: pci_stxgp3_config_table,},
345 #else
346         {},
347 #endif
348 #ifdef CONFIG_MPC85XX_PCI2
349         {},
350 #endif
351 };
352
353 #endif  /* CONFIG_PCI */
354
355
356 void
357 pci_init_board(void)
358 {
359 #ifdef CONFIG_PCI
360         extern void pci_mpc85xx_init(struct pci_controller *hose);
361
362         pci_mpc85xx_init(hose);
363 #endif /* CONFIG_PCI */
364 }
365
366 int board_eth_init(bd_t *bis)
367 {
368         cpu_eth_init(bis);      /* Initialize TSECs first */
369         return pci_eth_init(bis);
370 }