1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17#include <common.h>
18#include <ioports.h>
19#include <mpc83xx.h>
20#include <i2c.h>
21#include <miiphy.h>
22#include <asm/io.h>
23#include <asm/mmu.h>
24#include <pci.h>
25#include <libfdt.h>
26
27const qe_iop_conf_t qe_iop_conf_tab[] = {
28
29 {0, 1, 3, 0, 2},
30 {0, 2, 1, 0, 1},
31
32
33 {0, 3, 1, 0, 1},
34 {0, 4, 1, 0, 1},
35 {0, 5, 1, 0, 1},
36 {0, 6, 1, 0, 1},
37 {0, 9, 2, 0, 1},
38 {0, 10, 2, 0, 1},
39 {0, 11, 2, 0, 1},
40 {0, 12, 2, 0, 1},
41 {0, 7, 1, 0, 1},
42 {0, 8, 1, 0, 1},
43 {0, 15, 2, 0, 1},
44 {0, 0, 2, 0, 1},
45 {2, 9, 1, 0, 3},
46 {2, 8, 2, 0, 1},
47
48
49 {0, 17, 1, 0, 1},
50 {0, 18, 1, 0, 1},
51 {0, 19, 1, 0, 1},
52 {0, 20, 1, 0, 1},
53 {0, 23, 2, 0, 1},
54 {0, 24, 2, 0, 1},
55 {0, 25, 2, 0, 1},
56 {0, 26, 2, 0, 1},
57 {0, 21, 1, 0, 1},
58 {0, 22, 1, 0, 1},
59 {0, 29, 2, 0, 1},
60 {0, 31, 2, 0, 1},
61 {2, 2, 1, 0, 2},
62 {2, 3, 2, 0, 1},
63
64
65 {4, 0, 1, 0, 1},
66 {4, 1, 1, 0, 1},
67 {4, 2, 1, 0, 1},
68 {4, 3, 1, 0, 1},
69 {4, 6, 2, 0, 1},
70 {4, 7, 2, 0, 1},
71 {4, 8, 2, 0, 1},
72 {4, 9, 2, 0, 1},
73 {4, 4, 1, 0, 1},
74 {4, 5, 1, 0, 1},
75 {4, 12, 2, 0, 1},
76 {4, 13, 2, 0, 1},
77 {4, 10, 2, 0, 1},
78 {4, 11, 2, 0, 1},
79 {2, 18, 2, 0, 1},
80 {2, 19, 2, 0, 1},
81
82
83 {1, 14, 1, 0, 1},
84 {1, 15, 1, 0, 1},
85 {1, 16, 1, 0, 1},
86 {1, 17, 1, 0, 1},
87 {1, 20, 2, 0, 1},
88 {1, 21, 2, 0, 1},
89 {1, 22, 2, 0, 1},
90 {1, 23, 2, 0, 1},
91 {1, 18, 1, 0, 1},
92 {1, 19, 1, 0, 2},
93 {1, 26, 2, 0, 1},
94 {1, 27, 2, 0, 1},
95 {1, 24, 2, 0, 1},
96 {1, 25, 2, 0, 1},
97 {2, 6, 2, 0, 1},
98 {2, 7, 2, 0, 1},
99
100
101 {5, 4, 2, 0, 3},
102 {5, 5, 1, 0, 3},
103 {5, 6, 1, 0, 3},
104 {5, 7, 3, 0, 3},
105 {5, 8, 3, 0, 3},
106 {5, 9, 3, 0, 3},
107 {5, 10, 3, 0, 3},
108 {5, 11, 3, 0, 3},
109 {5, 12, 3, 0, 3},
110 {5, 13, 3, 0, 3},
111 {5, 14, 3, 0, 3},
112 {5, 15, 3, 0, 3},
113 {5, 16, 3, 0, 3},
114 {5, 17, 0, 0, 0},
115 {5, 18, 3, 0, 3},
116 {5, 19, 3, 0, 3},
117 {5, 20, 3, 0, 3},
118 {5, 21, 2, 0, 3},
119 {5, 22, 2, 0, 3},
120 {5, 23, 3, 0, 3},
121 {5, 24, 1, 0, 3},
122 {5, 25, 1, 0, 3},
123 {5, 26, 0, 0, 0},
124 {5, 27, 0, 0, 0},
125 {5, 28, 0, 0, 0},
126 {5, 29, 0, 0, 3},
127 {6, 0, 3, 0, 3},
128 {6, 1, 3, 0, 3},
129 {6, 2, 3, 0, 3},
130 {6, 3, 3, 0, 3},
131 {6, 4, 3, 0, 3},
132 {6, 5, 3, 0, 3},
133 {6, 6, 3, 0, 3},
134 {6, 7, 3, 0, 3},
135 {6, 8, 3, 0, 3},
136 {6, 9, 3, 0, 3},
137 {6, 10, 3, 0, 3},
138 {6, 11, 3, 0, 3},
139 {6, 12, 3, 0, 3},
140 {6, 13, 3, 0, 3},
141 {6, 14, 3, 0, 3},
142 {6, 15, 3, 0, 3},
143 {6, 16, 3, 0, 3},
144 {6, 17, 3, 0, 3},
145 {6, 18, 3, 0, 3},
146 {6, 19, 3, 0, 3},
147 {6, 20, 3, 0, 3},
148 {6, 21, 3, 0, 3},
149 {6, 22, 3, 0, 3},
150 {6, 23, 3, 0, 3},
151 {6, 24, 3, 0, 3},
152 {6, 25, 3, 0, 3},
153 {6, 26, 3, 0, 3},
154 {6, 27, 3, 0, 3},
155 {6, 28, 3, 0, 3},
156 {6, 29, 3, 0, 3},
157 {6, 30, 3, 0, 3},
158 {6, 31, 3, 0, 3},
159
160
161 {4, 18, 2, 0, 0},
162
163
164 {5, 0, 1, 0, 2},
165 {5, 2, 1, 0, 1},
166 {5, 3, 2, 0, 2},
167 {5, 1, 2, 0, 3},
168
169
170 {3, 0, 1, 0, 1},
171 {3, 4, 1, 0, 1},
172 {3, 6, 2, 0, 1},
173 {3, 12, 2, 0, 0},
174 {3, 13, 2, 0, 0},
175
176
177 {3, 14, 1, 0, 1},
178 {3, 18, 1, 0, 1},
179 {3, 20, 2, 0, 1},
180 {3, 26, 2, 0, 0},
181 {3, 27, 2, 0, 0},
182
183
184 {0, 30, 1, 0, 0},
185 {1, 5, 1, 0, 0},
186 {1, 7, 1, 0, 0},
187 {2, 16, 1, 0, 0},
188
189
190 {4, 14, 1, 0, 0},
191 {4, 28, 3, 0, 3},
192 {4, 29, 3, 0, 3},
193 {4, 30, 3, 0, 3},
194
195
196 {1, 2, 1, 0, 3},
197 {1, 3, 1, 0, 3},
198 {1, 8, 1, 0, 1},
199 {1, 9, 2, 1, 3},
200 {1, 10, 2, 0, 3},
201 {1, 11, 2, 1, 3},
202 {2, 20, 2, 0, 1},
203 {4, 20, 1, 0, 0},
204 {4, 21, 1, 0, 0},
205
206
207 {0, 0, 0, 0, QE_IOP_TAB_END},
208};
209
210int board_early_init_f(void)
211{
212 return 0;
213}
214
215int board_early_init_r(void)
216{
217 void *reg = (void *)(CONFIG_SYS_IMMR + 0x14a8);
218 u32 val;
219
220
221
222
223
224 val = in_be32(reg);
225
226 val |= 0x00003000;
227
228 val |= 0x0c000000;
229 out_be32(reg, val);
230
231 return 0;
232}
233
234int fixed_sdram(void)
235{
236 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
237 u32 msize = 0;
238 u32 ddr_size;
239 u32 ddr_size_log2;
240
241 msize = CONFIG_SYS_DDR_SIZE;
242 for (ddr_size = msize << 20, ddr_size_log2 = 0;
243 (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) {
244 if (ddr_size & 1)
245 return -1;
246 }
247
248 im->sysconf.ddrlaw[0].ar =
249 LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE);
250
251 im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS;
252 im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG;
253 im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0;
254 im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1;
255 im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2;
256 im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3;
257 im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG;
258 im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2;
259 im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE;
260 im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2;
261 im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL;
262 im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL;
263 udelay(200);
264 im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN;
265
266 return msize;
267}
268
269phys_size_t initdram(int board_type)
270{
271#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
272 extern void ddr_enable_ecc(unsigned int dram_size);
273#endif
274 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
275 u32 msize = 0;
276
277 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
278 return -1;
279
280
281 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
282 msize = fixed_sdram();
283
284#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
285
286
287
288 ddr_enable_ecc(msize * 1024 * 1024);
289#endif
290
291
292 return (msize * 1024 * 1024);
293}
294
295int checkboard(void)
296{
297 puts("Board: Freescale/Logic MPC8360ERDK\n");
298 return 0;
299}
300
301static struct pci_region pci_regions[] = {
302 {
303 .bus_start = CONFIG_SYS_PCI1_MEM_BASE,
304 .phys_start = CONFIG_SYS_PCI1_MEM_PHYS,
305 .size = CONFIG_SYS_PCI1_MEM_SIZE,
306 .flags = PCI_REGION_MEM | PCI_REGION_PREFETCH,
307 },
308 {
309 .bus_start = CONFIG_SYS_PCI1_MMIO_BASE,
310 .phys_start = CONFIG_SYS_PCI1_MMIO_PHYS,
311 .size = CONFIG_SYS_PCI1_MMIO_SIZE,
312 .flags = PCI_REGION_MEM,
313 },
314 {
315 .bus_start = CONFIG_SYS_PCI1_IO_BASE,
316 .phys_start = CONFIG_SYS_PCI1_IO_PHYS,
317 .size = CONFIG_SYS_PCI1_IO_SIZE,
318 .flags = PCI_REGION_IO,
319 },
320};
321
322void pci_init_board(void)
323{
324 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
325 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
326 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
327 struct pci_region *reg[] = { pci_regions, };
328
329#if defined(PCI_33M)
330 clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2 |
331 OCCR_PCICD0 | OCCR_PCICD1 | OCCR_PCICD2 | OCCR_PCICR;
332 printf("PCI clock is 33MHz\n");
333#else
334 clk->occr = OCCR_PCICOE0 | OCCR_PCICOE1 | OCCR_PCICOE2;
335 printf("PCI clock is 66MHz\n");
336#endif
337
338 udelay(2000);
339
340
341 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
342 pci_law[0].ar = LBLAWAR_EN | LBLAWAR_512MB;
343
344 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
345 pci_law[1].ar = LBLAWAR_EN | LBLAWAR_1MB;
346
347 mpc83xx_pci_init(1, reg, 0);
348}
349
350#if defined(CONFIG_OF_BOARD_SETUP)
351void ft_board_setup(void *blob, bd_t *bd)
352{
353 ft_cpu_setup(blob, bd);
354 ft_pci_setup(blob, bd);
355}
356#endif
357