blob: 98ec6abd27971d5f0524fbca75b1ee87731978e3 [file] [log] [blame]
Anton Vorontsovfab6f552008-01-09 20:57:47 +03001/*
2 * Copyright (C) 2006 Freescale Semiconductor, Inc.
3 * Dave Liu <daveliu@freescale.com>
4 *
5 * Copyright (C) 2007 Logic Product Development, Inc.
6 * Peter Barada <peterb@logicpd.com>
7 *
8 * Copyright (C) 2007 MontaVista Software, Inc.
9 * Anton Vorontsov <avorontsov@ru.mvista.com>
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License as
13 * published by the Free Software Foundation; either version 2 of
14 * the License, or (at your option) any later version.
15 */
16
17#include <common.h>
18#include <ioports.h>
19#include <mpc83xx.h>
20#include <i2c.h>
21#include <spd.h>
22#include <miiphy.h>
23#include <asm/io.h>
24#include <asm/mmu.h>
25#include <pci.h>
26#include <libfdt.h>
27
28const qe_iop_conf_t qe_iop_conf_tab[] = {
29 /* MDIO */
30 {0, 1, 3, 0, 2}, /* MDIO */
31 {0, 2, 1, 0, 1}, /* MDC */
32
33 /* UCC1 - UEC (Gigabit) */
34 {0, 3, 1, 0, 1}, /* TxD0 */
35 {0, 4, 1, 0, 1}, /* TxD1 */
36 {0, 5, 1, 0, 1}, /* TxD2 */
37 {0, 6, 1, 0, 1}, /* TxD3 */
38 {0, 9, 2, 0, 1}, /* RxD0 */
39 {0, 10, 2, 0, 1}, /* RxD1 */
40 {0, 11, 2, 0, 1}, /* RxD2 */
41 {0, 12, 2, 0, 1}, /* RxD3 */
42 {0, 7, 1, 0, 1}, /* TX_EN */
43 {0, 8, 1, 0, 1}, /* TX_ER */
44 {0, 15, 2, 0, 1}, /* RX_DV */
45 {0, 0, 2, 0, 1}, /* RX_CLK */
46 {2, 9, 1, 0, 3}, /* GTX_CLK - CLK10 */
47 {2, 8, 2, 0, 1}, /* GTX125 - CLK9 */
48
49 /* UCC2 - UEC (Gigabit) */
50 {0, 17, 1, 0, 1}, /* TxD0 */
51 {0, 18, 1, 0, 1}, /* TxD1 */
52 {0, 19, 1, 0, 1}, /* TxD2 */
53 {0, 20, 1, 0, 1}, /* TxD3 */
54 {0, 23, 2, 0, 1}, /* RxD0 */
55 {0, 24, 2, 0, 1}, /* RxD1 */
56 {0, 25, 2, 0, 1}, /* RxD2 */
57 {0, 26, 2, 0, 1}, /* RxD3 */
58 {0, 21, 1, 0, 1}, /* TX_EN */
59 {0, 22, 1, 0, 1}, /* TX_ER */
60 {0, 29, 2, 0, 1}, /* RX_DV */
61 {0, 31, 2, 0, 1}, /* RX_CLK */
62 {2, 2, 1, 0, 2}, /* GTX_CLK - CLK10 */
63 {2, 3, 2, 0, 1}, /* GTX125 - CLK4 */
64
65 /* UCC7 - UEC */
66 {4, 0, 1, 0, 1}, /* TxD0 */
67 {4, 1, 1, 0, 1}, /* TxD1 */
68 {4, 2, 1, 0, 1}, /* TxD2 */
69 {4, 3, 1, 0, 1}, /* TxD3 */
70 {4, 6, 2, 0, 1}, /* RxD0 */
71 {4, 7, 2, 0, 1}, /* RxD1 */
72 {4, 8, 2, 0, 1}, /* RxD2 */
73 {4, 9, 2, 0, 1}, /* RxD3 */
74 {4, 4, 1, 0, 1}, /* TX_EN */
75 {4, 5, 1, 0, 1}, /* TX_ER */
76 {4, 12, 2, 0, 1}, /* RX_DV */
77 {4, 13, 2, 0, 1}, /* RX_ER */
78 {4, 10, 2, 0, 1}, /* COL */
79 {4, 11, 2, 0, 1}, /* CRS */
80 {2, 18, 2, 0, 1}, /* TX_CLK - CLK19 */
81 {2, 19, 2, 0, 1}, /* RX_CLK - CLK20 */
82
83 /* UCC4 - UEC */
84 {1, 14, 1, 0, 1}, /* TxD0 */
85 {1, 15, 1, 0, 1}, /* TxD1 */
86 {1, 16, 1, 0, 1}, /* TxD2 */
87 {1, 17, 1, 0, 1}, /* TxD3 */
88 {1, 20, 2, 0, 1}, /* RxD0 */
89 {1, 21, 2, 0, 1}, /* RxD1 */
90 {1, 22, 2, 0, 1}, /* RxD2 */
91 {1, 23, 2, 0, 1}, /* RxD3 */
92 {1, 18, 1, 0, 1}, /* TX_EN */
93 {1, 19, 1, 0, 2}, /* TX_ER */
94 {1, 26, 2, 0, 1}, /* RX_DV */
95 {1, 27, 2, 0, 1}, /* RX_ER */
96 {1, 24, 2, 0, 1}, /* COL */
97 {1, 25, 2, 0, 1}, /* CRS */
98 {2, 6, 2, 0, 1}, /* TX_CLK - CLK7 */
99 {2, 7, 2, 0, 1}, /* RX_CLK - CLK8 */
100
101 /* PCI1 */
102 {5, 4, 2, 0, 3}, /* PCI_M66EN */
103 {5, 5, 1, 0, 3}, /* PCI_INTA */
104 {5, 6, 1, 0, 3}, /* PCI_RSTO */
105 {5, 7, 3, 0, 3}, /* PCI_C_BE0 */
106 {5, 8, 3, 0, 3}, /* PCI_C_BE1 */
107 {5, 9, 3, 0, 3}, /* PCI_C_BE2 */
108 {5, 10, 3, 0, 3}, /* PCI_C_BE3 */
109 {5, 11, 3, 0, 3}, /* PCI_PAR */
110 {5, 12, 3, 0, 3}, /* PCI_FRAME */
111 {5, 13, 3, 0, 3}, /* PCI_TRDY */
112 {5, 14, 3, 0, 3}, /* PCI_IRDY */
113 {5, 15, 3, 0, 3}, /* PCI_STOP */
114 {5, 16, 3, 0, 3}, /* PCI_DEVSEL */
115 {5, 17, 0, 0, 0}, /* PCI_IDSEL */
116 {5, 18, 3, 0, 3}, /* PCI_SERR */
117 {5, 19, 3, 0, 3}, /* PCI_PERR */
118 {5, 20, 3, 0, 3}, /* PCI_REQ0 */
119 {5, 21, 2, 0, 3}, /* PCI_REQ1 */
120 {5, 22, 2, 0, 3}, /* PCI_GNT2 */
121 {5, 23, 3, 0, 3}, /* PCI_GNT0 */
122 {5, 24, 1, 0, 3}, /* PCI_GNT1 */
123 {5, 25, 1, 0, 3}, /* PCI_GNT2 */
124 {5, 26, 0, 0, 0}, /* PCI_CLK0 */
125 {5, 27, 0, 0, 0}, /* PCI_CLK1 */
126 {5, 28, 0, 0, 0}, /* PCI_CLK2 */
127 {5, 29, 0, 0, 3}, /* PCI_SYNC_OUT */
128 {6, 0, 3, 0, 3}, /* PCI_AD0 */
129 {6, 1, 3, 0, 3}, /* PCI_AD1 */
130 {6, 2, 3, 0, 3}, /* PCI_AD2 */
131 {6, 3, 3, 0, 3}, /* PCI_AD3 */
132 {6, 4, 3, 0, 3}, /* PCI_AD4 */
133 {6, 5, 3, 0, 3}, /* PCI_AD5 */
134 {6, 6, 3, 0, 3}, /* PCI_AD6 */
135 {6, 7, 3, 0, 3}, /* PCI_AD7 */
136 {6, 8, 3, 0, 3}, /* PCI_AD8 */
137 {6, 9, 3, 0, 3}, /* PCI_AD9 */
138 {6, 10, 3, 0, 3}, /* PCI_AD10 */
139 {6, 11, 3, 0, 3}, /* PCI_AD11 */
140 {6, 12, 3, 0, 3}, /* PCI_AD12 */
141 {6, 13, 3, 0, 3}, /* PCI_AD13 */
142 {6, 14, 3, 0, 3}, /* PCI_AD14 */
143 {6, 15, 3, 0, 3}, /* PCI_AD15 */
144 {6, 16, 3, 0, 3}, /* PCI_AD16 */
145 {6, 17, 3, 0, 3}, /* PCI_AD17 */
146 {6, 18, 3, 0, 3}, /* PCI_AD18 */
147 {6, 19, 3, 0, 3}, /* PCI_AD19 */
148 {6, 20, 3, 0, 3}, /* PCI_AD20 */
149 {6, 21, 3, 0, 3}, /* PCI_AD21 */
150 {6, 22, 3, 0, 3}, /* PCI_AD22 */
151 {6, 23, 3, 0, 3}, /* PCI_AD23 */
152 {6, 24, 3, 0, 3}, /* PCI_AD24 */
153 {6, 25, 3, 0, 3}, /* PCI_AD25 */
154 {6, 26, 3, 0, 3}, /* PCI_AD26 */
155 {6, 27, 3, 0, 3}, /* PCI_AD27 */
156 {6, 28, 3, 0, 3}, /* PCI_AD28 */
157 {6, 29, 3, 0, 3}, /* PCI_AD29 */
158 {6, 30, 3, 0, 3}, /* PCI_AD30 */
159 {6, 31, 3, 0, 3}, /* PCI_AD31 */
160
161 /* NAND */
162 {4, 18, 2, 0, 0}, /* NAND_RYnBY */
163
164 /* DUART - UART2 */
165 {5, 0, 1, 0, 2}, /* UART2_SOUT */
166 {5, 2, 1, 0, 1}, /* UART2_RTS */
167 {5, 3, 2, 0, 2}, /* UART2_SIN */
168 {5, 1, 2, 0, 3}, /* UART2_CTS */
169
170 /* UCC5 - UART3 */
171 {3, 0, 1, 0, 1}, /* UART3_TX */
172 {3, 4, 1, 0, 1}, /* UART3_RTS */
173 {3, 6, 2, 0, 1}, /* UART3_RX */
174 {3, 12, 2, 0, 0}, /* UART3_CTS */
175 {3, 13, 2, 0, 0}, /* UCC5_CD */
176
177 /* UCC6 - UART4 */
178 {3, 14, 1, 0, 1}, /* UART4_TX */
179 {3, 18, 1, 0, 1}, /* UART4_RTS */
180 {3, 20, 2, 0, 1}, /* UART4_RX */
181 {3, 26, 2, 0, 0}, /* UART4_CTS */
182 {3, 27, 2, 0, 0}, /* UCC6_CD */
183
184 /* Fujitsu MB86277 (MINT) graphics controller */
185 {0, 30, 1, 0, 0}, /* nSRESET_GRAPHICS */
186 {1, 5, 1, 0, 0}, /* nXRST_GRAPHICS */
187 {1, 7, 1, 0, 0}, /* LVDS_BKLT_CTR */
188 {2, 16, 1, 0, 0}, /* LVDS_BKLT_EN */
189
190 /* END of table */
191 {0, 0, 0, 0, QE_IOP_TAB_END},
192};
193
194int board_early_init_f(void)
195{
196 return 0;
197}
198
199int board_early_init_r(void)
200{
201 void *reg = (void *)(CFG_IMMR + 0x14a8);
202 u32 val;
203
204 /*
205 * Because of errata in the UCCs, we have to write to the reserved
206 * registers to slow the clocks down.
207 */
208 val = in_be32(reg);
209 /* UCC1 */
210 val |= 0x00003000;
211 /* UCC2 */
212 val |= 0x0c000000;
213 out_be32(reg, val);
214
215 return 0;
216}
217
218int fixed_sdram(void)
219{
220 volatile immap_t *im = (immap_t *)CFG_IMMR;
221 u32 msize = 0;
222 u32 ddr_size;
223 u32 ddr_size_log2;
224
225 msize = CFG_DDR_SIZE;
226 for (ddr_size = msize << 20, ddr_size_log2 = 0;
227 (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
228 if (ddr_size & 1)
229 return -1;
230 }
231
232 im->sysconf.ddrlaw[0].ar =
233 LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
234
235 im->ddr.csbnds[0].csbnds = CFG_DDR_CS0_BNDS;
236 im->ddr.cs_config[0] = CFG_DDR_CS0_CONFIG;
237 im->ddr.timing_cfg_0 = CFG_DDR_TIMING_0;
238 im->ddr.timing_cfg_1 = CFG_DDR_TIMING_1;
239 im->ddr.timing_cfg_2 = CFG_DDR_TIMING_2;
240 im->ddr.timing_cfg_3 = CFG_DDR_TIMING_3;
241 im->ddr.sdram_cfg = CFG_DDR_SDRAM_CFG;
242 im->ddr.sdram_cfg2 = CFG_DDR_SDRAM_CFG2;
243 im->ddr.sdram_mode = CFG_DDR_MODE;
244 im->ddr.sdram_mode2 = CFG_DDR_MODE2;
245 im->ddr.sdram_interval = CFG_DDR_INTERVAL;
246 im->ddr.sdram_clk_cntl = CFG_DDR_CLK_CNTL;
247 udelay(200);
248 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
249
250 return msize;
251}
252
253long int initdram(int board_type)
254{
255#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
256 extern void ddr_enable_ecc(unsigned int dram_size);
257#endif
258 volatile immap_t *im = (immap_t *)CFG_IMMR;
259 u32 msize = 0;
260
261 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
262 return -1;
263
264 /* DDR SDRAM - Main SODIMM */
265 im->sysconf.ddrlaw[0].bar = CFG_DDR_BASE & LAWBAR_BAR;
266 msize = fixed_sdram();
267
268#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRC)
269 /*
270 * Initialize DDR ECC byte
271 */
272 ddr_enable_ecc(msize * 1024 * 1024);
273#endif
274
275 /* return total bus SDRAM size(bytes) -- DDR */
276 return (msize * 1024 * 1024);
277}
278
279int checkboard(void)
280{
281 puts("Board: Freescale/Logic MPC8360ERDK\n");
282 return 0;
283}
284
285static struct pci_region pci_regions[] = {
286 {
287 .bus_start = CFG_PCI1_MEM_BASE,
288 .phys_start = CFG_PCI1_MEM_PHYS,
289 .size = CFG_PCI1_MEM_SIZE,
290 .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH,
291 },
292 {
293 .bus_start = CFG_PCI1_MMIO_BASE,
294 .phys_start = CFG_PCI1_MMIO_PHYS,
295 .size = CFG_PCI1_MMIO_SIZE,
296 .flags = PCI_REGION_MEM,
297 },
298 {
299 .bus_start = CFG_PCI1_IO_BASE,
300 .phys_start = CFG_PCI1_IO_PHYS,
301 .size = CFG_PCI1_IO_SIZE,
302 .flags = PCI_REGION_IO,
303 },
304};
305
306void pci_init_board(void)
307{
308 volatile immap_t *immr = (volatile immap_t *)CFG_IMMR;
309 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
310 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
311 struct pci_region *reg[] = { pci_regions, };
312
313#if defined(PCI_33M)
314 clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2 |
315 OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 | OCCR_PCICR;
316 printf("PCI clock is 33MHz\n");
317#else
318 clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
319 printf("PCI clock is 66MHz\n");
320#endif
321
322 udelay(2000);
323
324 /* Configure PCI Local Access Windows */
325 pci_law[0].bar = CFG_PCI1_MEM_PHYS & LAWBAR_BAR;
326 pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
327
328 pci_law[1].bar = CFG_PCI1_IO_PHYS & LAWBAR_BAR;
329 pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
330
331 mpc83xx_pci_init(1, reg, 0);
332}
333
334#if defined(CONFIG_OF_BOARD_SETUP)
335void ft_board_setup(void *blob, bd_t *bd)
336{
337 ft_cpu_setup(blob, bd);
338 ft_pci_setup(blob, bd);
339}
340#endif