1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31#include <asm/mmu.h>
32#include <asm/io.h>
33#include <common.h>
34#include <mpc83xx.h>
35#include <pci.h>
36#include <i2c.h>
37#include <asm/fsl_i2c.h>
38#include "vme8349pin.h"
39
40DECLARE_GLOBAL_DATA_PTR;
41
42static struct pci_region pci1_regions[] = {
43 {
44 bus_start: CONFIG_SYS_PCI1_MEM_BASE,
45 phys_start: CONFIG_SYS_PCI1_MEM_PHYS,
46 size: CONFIG_SYS_PCI1_MEM_SIZE,
47 flags: PCI_REGION_MEM | PCI_REGION_PREFETCH
48 },
49 {
50 bus_start: CONFIG_SYS_PCI1_IO_BASE,
51 phys_start: CONFIG_SYS_PCI1_IO_PHYS,
52 size: CONFIG_SYS_PCI1_IO_SIZE,
53 flags: PCI_REGION_IO
54 },
55 {
56 bus_start: CONFIG_SYS_PCI1_MMIO_BASE,
57 phys_start: CONFIG_SYS_PCI1_MMIO_PHYS,
58 size: CONFIG_SYS_PCI1_MMIO_SIZE,
59 flags: PCI_REGION_MEM
60 },
61};
62
63
64
65
66
67
68
69
70void
71pci_init_board(void)
72{
73 volatile immap_t *immr = (volatile immap_t *)CONFIG_SYS_IMMR;
74 volatile clk83xx_t *clk = (volatile clk83xx_t *)&immr->clk;
75 volatile law83xx_t *pci_law = immr->sysconf.pcilaw;
76 struct pci_region *reg[] = { pci1_regions };
77 u8 reg8;
78 int monarch = 0;
79
80 i2c_set_bus_num(1);
81
82 if ((i2c_read(CONFIG_SYS_I2C_8574_ADDR2, 0, 0, ®8, 1) == 0) ||
83 (i2c_read(0x38 , 0, 0, ®8, 1) == 0)) {
84 if (reg8 & 0x40) {
85 clk->occr = 0xff000000;
86 printf("PCI: 66MHz\n");
87 } else {
88 clk->occr = 0xffff0003;
89 printf("PCI: 33MHz\n");
90 }
91 if (((reg8 & 0x01) == 0) || ((reg8 & 0x02) == 0))
92 monarch = 1;
93 } else {
94 clk->occr = 0xffff0003;
95 printf("PCI: 33MHz (I2C read failed)\n");
96 }
97 udelay(2000);
98
99
100
101
102 clrsetbits_be32(&immr->gpio[1].dat,
103 GPIO2_TSI_POWERUP_RESET_N | GPIO2_TSI_PLL_RESET_N,
104 GPIO2_VME_RESET_N | GPIO2_L_RESET_EN_N);
105 setbits_be32(&immr->gpio[1].dir, GPIO2_TSI_PLL_RESET_N |
106 GPIO2_TSI_POWERUP_RESET_N |
107 GPIO2_VME_RESET_N |
108 GPIO2_L_RESET_EN_N);
109 clrbits_be32(&immr->gpio[1].dir, GPIO2_V_SCON);
110 udelay(200);
111 setbits_be32(&immr->gpio[1].dat, GPIO2_TSI_PLL_RESET_N);
112 udelay(200);
113 setbits_be32(&immr->gpio[1].dat, GPIO2_TSI_POWERUP_RESET_N);
114 udelay(600000);
115 clrbits_be32(&immr->gpio[1].dat, GPIO2_L_RESET_EN_N);
116
117
118 pci_law[0].bar = CONFIG_SYS_PCI1_MEM_PHYS & LAWBAR_BAR;
119 pci_law[0].ar = LAWAR_EN | LAWAR_SIZE_1G;
120
121 pci_law[1].bar = CONFIG_SYS_PCI1_IO_PHYS & LAWBAR_BAR;
122 pci_law[1].ar = LAWAR_EN | LAWAR_SIZE_4M;
123
124 udelay(2000);
125
126 if (monarch == 0) {
127 mpc83xx_pci_init(1, reg);
128 } else {
129
130
131
132 out_be32(&immr->pci_ctrl[0].gcr, 0);
133 udelay(2000);
134 out_be32(&immr->pci_ctrl[0].gcr, 1);
135 }
136}
137