1
2
3
4
5
6
7
8
9
10
11
12#include <common.h>
13
14#ifdef CONFIG_PCI
15
16#include <pci.h>
17#include <mpc8260.h>
18#include <asm/m8260_pci.h>
19#include <asm/io.h>
20#ifdef CONFIG_OF_LIBFDT
21#include <libfdt.h>
22#include <fdt_support.h>
23#endif
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53#ifndef CONFIG_SYS_PCI_SLV_MEM_LOCAL
54#define PCI_SLV_MEM_LOCAL CONFIG_SYS_SDRAM_BASE
55#else
56#define PCI_SLV_MEM_LOCAL CONFIG_SYS_PCI_SLV_MEM_LOCAL
57#endif
58
59#ifndef CONFIG_SYS_PCI_SLV_MEM_BUS
60#define PCI_SLV_MEM_BUS 0x00000000
61#else
62#define PCI_SLV_MEM_BUS CONFIG_SYS_PCI_SLV_MEM_BUS
63#endif
64
65#ifndef CONFIG_SYS_PICMR0_MASK_ATTRIB
66#define PICMR0_MASK_ATTRIB (PICMR_MASK_512MB | PICMR_ENABLE | \
67 PICMR_PREFETCH_EN)
68#else
69#define PICMR0_MASK_ATTRIB CONFIG_SYS_PICMR0_MASK_ATTRIB
70#endif
71
72
73
74
75
76
77
78
79
80#ifndef CONFIG_SYS_PCI_MSTR0_LOCAL
81#define PCI_MSTR0_LOCAL 0x80000000
82#else
83#define PCI_MSTR0_LOCAL CONFIG_SYS_PCI_MSTR0_LOCAL
84#endif
85
86#ifndef CONFIG_SYS_PCIMSK0_MASK
87#define PCIMSK0_MASK PCIMSK_1GB
88#else
89#define PCIMSK0_MASK CONFIG_SYS_PCIMSK0_MASK
90#endif
91
92
93#ifndef CONFIG_SYS_PCI_MSTR1_LOCAL
94#define PCI_MSTR1_LOCAL 0xF4000000
95#else
96#define PCI_MSTR1_LOCAL CONFIG_SYS_PCI_MSTR1_LOCAL
97#endif
98
99#ifndef CONFIG_SYS_PCIMSK1_MASK
100#define PCIMSK1_MASK PCIMSK_64MB
101#else
102#define PCIMSK1_MASK CONFIG_SYS_PCIMSK1_MASK
103#endif
104
105
106
107
108
109
110
111#ifndef CONFIG_SYS_PCI_MSTR_MEM_LOCAL
112#define PCI_MSTR_MEM_LOCAL 0x80000000
113#else
114#define PCI_MSTR_MEM_LOCAL CONFIG_SYS_PCI_MSTR_MEM_LOCAL
115#endif
116
117#ifndef CONFIG_SYS_PCI_MSTR_MEM_BUS
118#define PCI_MSTR_MEM_BUS 0x80000000
119#else
120#define PCI_MSTR_MEM_BUS CONFIG_SYS_PCI_MSTR_MEM_BUS
121#endif
122
123#ifndef CONFIG_SYS_CPU_PCI_MEM_START
124#define CPU_PCI_MEM_START PCI_MSTR_MEM_LOCAL
125#else
126#define CPU_PCI_MEM_START CONFIG_SYS_CPU_PCI_MEM_START
127#endif
128
129#ifndef CONFIG_SYS_PCI_MSTR_MEM_SIZE
130#define PCI_MSTR_MEM_SIZE 0x10000000
131#else
132#define PCI_MSTR_MEM_SIZE CONFIG_SYS_PCI_MSTR_MEM_SIZE
133#endif
134
135#ifndef CONFIG_SYS_POCMR0_MASK_ATTRIB
136#define POCMR0_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PREFETCH_EN)
137#else
138#define POCMR0_MASK_ATTRIB CONFIG_SYS_POCMR0_MASK_ATTRIB
139#endif
140
141
142
143
144
145
146
147#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL
148#define PCI_MSTR_MEMIO_LOCAL 0x90000000
149#else
150#define PCI_MSTR_MEMIO_LOCAL CONFIG_SYS_PCI_MSTR_MEMIO_LOCAL
151#endif
152
153#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_BUS
154#define PCI_MSTR_MEMIO_BUS 0x90000000
155#else
156#define PCI_MSTR_MEMIO_BUS CONFIG_SYS_PCI_MSTR_MEMIO_BUS
157#endif
158
159#ifndef CONFIG_SYS_CPU_PCI_MEMIO_START
160#define CPU_PCI_MEMIO_START PCI_MSTR_MEMIO_LOCAL
161#else
162#define CPU_PCI_MEMIO_START CONFIG_SYS_CPU_PCI_MEMIO_START
163#endif
164
165#ifndef CONFIG_SYS_PCI_MSTR_MEMIO_SIZE
166#define PCI_MSTR_MEMIO_SIZE 0x10000000
167#else
168#define PCI_MSTR_MEMIO_SIZE CONFIG_SYS_PCI_MSTR_MEMIO_SIZE
169#endif
170
171#ifndef CONFIG_SYS_POCMR1_MASK_ATTRIB
172#define POCMR1_MASK_ATTRIB (POCMR_MASK_512MB | POCMR_ENABLE)
173#else
174#define POCMR1_MASK_ATTRIB CONFIG_SYS_POCMR1_MASK_ATTRIB
175#endif
176
177
178
179
180
181
182
183#ifndef CONFIG_SYS_PCI_MSTR_IO_LOCAL
184#define PCI_MSTR_IO_LOCAL 0xA0000000
185#else
186#define PCI_MSTR_IO_LOCAL CONFIG_SYS_PCI_MSTR_IO_LOCAL
187#endif
188
189#ifndef CONFIG_SYS_PCI_MSTR_IO_BUS
190#define PCI_MSTR_IO_BUS 0xA0000000
191#else
192#define PCI_MSTR_IO_BUS CONFIG_SYS_PCI_MSTR_IO_BUS
193#endif
194
195#ifndef CONFIG_SYS_CPU_PCI_IO_START
196#define CPU_PCI_IO_START PCI_MSTR_IO_LOCAL
197#else
198#define CPU_PCI_IO_START CONFIG_SYS_CPU_PCI_IO_START
199#endif
200
201#ifndef CONFIG_SYS_PCI_MSTR_IO_SIZE
202#define PCI_MSTR_IO_SIZE 0x10000000
203#else
204#define PCI_MSTR_IO_SIZE CONFIG_SYS_PCI_MSTR_IO_SIZE
205#endif
206
207#ifndef CONFIG_SYS_POCMR2_MASK_ATTRIB
208#define POCMR2_MASK_ATTRIB (POCMR_MASK_256MB | POCMR_ENABLE | POCMR_PCI_IO)
209#else
210#define POCMR2_MASK_ATTRIB CONFIG_SYS_POCMR2_MASK_ATTRIB
211#endif
212
213
214
215
216#define PCI_CLASS_BRIDGE_CTLR 0x06
217
218
219static inline void pci_outl (u32 addr, u32 data)
220{
221 *(volatile u32 *) addr = cpu_to_le32 (data);
222}
223
224void pci_mpc8250_init (struct pci_controller *hose)
225{
226 u16 tempShort;
227
228 volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
229 pci_dev_t host_devno = PCI_BDF (0, 0, 0);
230
231 pci_setup_indirect (hose, CONFIG_SYS_IMMR + PCI_CFG_ADDR_REG,
232 CONFIG_SYS_IMMR + PCI_CFG_DATA_REG);
233
234
235
236
237
238 immap->im_siu_conf.sc_siumcr = (immap->im_siu_conf.sc_siumcr &
239 ~SIUMCR_LBPC11 &
240 ~SIUMCR_CS10PC11 &
241 ~SIUMCR_LBPC11) |
242 SIUMCR_LBPC01 |
243 SIUMCR_CS10PC01 |
244 SIUMCR_APPC10;
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262 immap->im_siu_conf.sc_ppc_alrh = 0x61207893;
263
264
265 immap->im_siu_conf.sc_ppc_acr = 0x6;
266
267
268
269
270
271 immap->im_memctl.memc_pcimsk0 = PCIMSK0_MASK;
272 immap->im_memctl.memc_pcibr0 = PCI_MSTR0_LOCAL | PCIBR_ENABLE;
273
274
275 immap->im_pci.pci_gcr = cpu_to_le32 (PCIGCR_PCI_BUS_EN);
276
277
278 {
279 udelay (1000);
280 }
281
282
283
284
285
286 immap->im_pci.pci_potar0 = cpu_to_le32 (PCI_MSTR_MEM_BUS >> 12);
287 immap->im_pci.pci_pobar0 = cpu_to_le32 (PCI_MSTR_MEM_LOCAL >> 12);
288 immap->im_pci.pci_pocmr0 = cpu_to_le32 (POCMR0_MASK_ATTRIB);
289
290
291
292
293
294 immap->im_pci.pci_potar1 = cpu_to_le32 (PCI_MSTR_MEMIO_BUS >> 12);
295 immap->im_pci.pci_pobar1 = cpu_to_le32 (PCI_MSTR_MEMIO_LOCAL >> 12);
296 immap->im_pci.pci_pocmr1 = cpu_to_le32 (POCMR1_MASK_ATTRIB);
297
298
299
300
301
302 immap->im_pci.pci_potar2 = cpu_to_le32 (PCI_MSTR_IO_BUS >> 12);
303 immap->im_pci.pci_pobar2 = cpu_to_le32 (PCI_MSTR_IO_LOCAL >> 12);
304 immap->im_pci.pci_pocmr2 = cpu_to_le32 (POCMR2_MASK_ATTRIB);
305
306
307
308
309
310 immap->im_pci.pci_pitar0 = cpu_to_le32 (PCI_SLV_MEM_LOCAL >> 12);
311 immap->im_pci.pci_pibar0 = cpu_to_le32 (PCI_SLV_MEM_BUS >> 12);
312 immap->im_pci.pci_picmr0 = cpu_to_le32 (PICMR0_MASK_ATTRIB);
313
314
315 immap->im_siu_conf.sc_ppc_alrh = 0x03124567;
316
317
318 immap->im_siu_conf.sc_ppc_acr = PPC_ACR_BUS_PARK_PCI;
319
320
321
322 pci_hose_write_config_byte (hose, host_devno, PCI_CLASS_CODE,
323 PCI_CLASS_BRIDGE_CTLR);
324
325
326 pci_hose_read_config_word (hose, host_devno, PCI_COMMAND, &tempShort);
327 pci_hose_write_config_word (hose, host_devno, PCI_COMMAND,
328 tempShort | PCI_COMMAND_MASTER |
329 PCI_COMMAND_MEMORY);
330
331
332 pci_hose_write_config_byte (hose, host_devno, PCI_CACHE_LINE_SIZE,
333 0x08);
334 pci_hose_write_config_byte (hose, host_devno, PCI_LATENCY_TIMER,
335 0xF8);
336
337 hose->first_busno = 0;
338 hose->last_busno = 0xff;
339
340
341 pci_set_region (hose->regions + 0,
342 CONFIG_SYS_SDRAM_BASE,
343 CONFIG_SYS_SDRAM_BASE,
344 0x4000000, PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
345
346
347 pci_set_region (hose->regions + 1,
348 PCI_MSTR_MEM_BUS,
349 PCI_MSTR_MEM_LOCAL,
350 PCI_MSTR_MEM_SIZE, PCI_REGION_MEM);
351
352
353 pci_set_region (hose->regions + 2,
354 PCI_MSTR_IO_BUS,
355 PCI_MSTR_IO_LOCAL, PCI_MSTR_IO_SIZE, PCI_REGION_IO);
356
357 hose->region_count = 3;
358
359 pci_register_hose (hose);
360
361 immap->im_pci.pci_emr &= cpu_to_le32 (~PCI_ERROR_PCI_NO_RSP);
362 eieio ();
363
364 hose->last_busno = pci_hose_scan (hose);
365
366
367
368 immap->im_pci.pci_esr = cpu_to_le32 (PCI_ERROR_PCI_NO_RSP);
369
370
371 immap->im_pci.pci_emr |= cpu_to_le32 (PCI_ERROR_PCI_NO_RSP);
372}
373
374#if defined(CONFIG_OF_LIBFDT)
375void ft_pci_setup(void *blob, bd_t *bd)
376{
377 do_fixup_by_prop_u32(blob, "device_type", "pci", 4,
378 "clock-frequency", gd->pci_clk, 1);
379}
380#endif
381
382#endif
383