1
2
3
4
5
6
7
8#include <common.h>
9#include <asm/ppc4xx.h>
10#include <asm/processor.h>
11#include <pci.h>
12
13
14u_long pci9054_iobase;
15
16
17#define PCI_PRIMARY_CAR (0x500000dc)
18#define PCI_PRIMARY_CDR (0x80000000)
19
20
21
22
23
24
25
26
27
28
29
30
31
32int pci9054_read_config_dword(struct pci_controller *hose,
33 pci_dev_t dev, int offset, u32* value)
34{
35 unsigned long conAdrVal;
36 unsigned long val;
37
38
39 conAdrVal = dev | (offset & 0xfc) | 0x80000000;
40
41
42 *(unsigned long *)PCI_PRIMARY_CAR = conAdrVal;
43
44
45 val = in32r(PCI_PRIMARY_CDR);
46
47 *value = (unsigned long) val;
48
49 out32r(PCI_PRIMARY_CAR, 0);
50
51 if ((*(unsigned long *)0x50000304) & 0x60000000)
52 {
53
54 *(unsigned long *)0x50000304 = *(unsigned long *)0x50000304;
55 }
56
57 return 0;
58}
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73int pci9054_write_config_dword(struct pci_controller *hose,
74 pci_dev_t dev, int offset, u32 value)
75{
76 unsigned long conAdrVal;
77
78 conAdrVal = dev | (offset & 0xfc) | 0x80000000;
79
80 *(unsigned long *)PCI_PRIMARY_CAR = conAdrVal;
81
82 out32r(PCI_PRIMARY_CDR, value);
83
84 out32r(PCI_PRIMARY_CAR, 0);
85
86
87 *(unsigned long *)0x50000304 = *(unsigned long *)0x50000304;
88
89 return (0);
90}
91
92
93
94
95#ifdef CONFIG_DASA_SIM
96static void pci_dasa_sim_config_pci9054(struct pci_controller *hose, pci_dev_t dev,
97 struct pci_config_table *_)
98{
99 unsigned int iobase;
100 unsigned short status = 0;
101 unsigned char timer;
102
103
104
105
106 pci_read_config_word(CONFIG_SYS_PCI9054_DEV_FN, PCI_COMMAND, &status);
107 status |= PCI_COMMAND_MASTER | PCI_COMMAND_IO | PCI_COMMAND_MEMORY;
108 pci_write_config_word(CONFIG_SYS_PCI9054_DEV_FN, PCI_COMMAND, status);
109
110
111
112 pci_read_config_byte(CONFIG_SYS_PCI9054_DEV_FN, PCI_LATENCY_TIMER, &timer);
113 if (timer < 0x60)
114 {
115 pci_write_config_byte(CONFIG_SYS_PCI9054_DEV_FN, PCI_LATENCY_TIMER, 0x60);
116 }
117
118
119
120 pci_write_config_dword(CONFIG_SYS_PCI9054_DEV_FN, PCI_BASE_ADDRESS_0, CONFIG_SYS_PCI9054_IOBASE);
121 pci_read_config_dword(CONFIG_SYS_PCI9054_DEV_FN, PCI_BASE_ADDRESS_0, &iobase);
122
123 pci9054_iobase = pci_mem_to_phys(CONFIG_SYS_PCI9054_DEV_FN, iobase & PCI_BASE_ADDRESS_MEM_MASK);
124
125 if (pci9054_iobase == 0xffffffff)
126 {
127 printf("Error: Can not set I/O base register.\n");
128 return;
129 }
130}
131#endif
132
133static struct pci_config_table pci9054_config_table[] = {
134#ifndef CONFIG_PCI_PNP
135 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
136 PCI_BUS(CONFIG_SYS_ETH_DEV_FN), PCI_DEV(CONFIG_SYS_ETH_DEV_FN), PCI_FUNC(CONFIG_SYS_ETH_DEV_FN),
137 pci_cfgfunc_config_device, { CONFIG_SYS_ETH_IOBASE,
138 CONFIG_SYS_ETH_IOBASE,
139 PCI_COMMAND_IO | PCI_COMMAND_MASTER }},
140#ifdef CONFIG_DASA_SIM
141 { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID,
142 PCI_BUS(CONFIG_SYS_PCI9054_DEV_FN), PCI_DEV(CONFIG_SYS_PCI9054_DEV_FN), PCI_FUNC(CONFIG_SYS_PCI9054_DEV_FN),
143 pci_dasa_sim_config_pci9054 },
144#endif
145#endif
146 { }
147};
148
149static struct pci_controller pci9054_hose = {
150 config_table: pci9054_config_table,
151};
152
153void pci_init_board(void)
154{
155 struct pci_controller *hose = &pci9054_hose;
156
157
158
159
160 hose->first_busno = 0;
161 hose->last_busno = 0xff;
162
163
164 pci_set_region(hose->regions + 0,
165 0x00000000, 0x00000000, 0x01000000,
166 PCI_REGION_MEM | PCI_REGION_SYS_MEMORY);
167
168
169 pci_set_region(hose->regions + 1,
170 0x00000000, 0xc0000000, 0x10000000,
171 PCI_REGION_MEM);
172
173 pci_set_ops(hose,
174 pci_hose_read_config_byte_via_dword,
175 pci_hose_read_config_word_via_dword,
176 pci9054_read_config_dword,
177 pci_hose_write_config_byte_via_dword,
178 pci_hose_write_config_word_via_dword,
179 pci9054_write_config_dword);
180
181 hose->region_count = 2;
182
183 pci_register_hose(hose);
184
185 hose->last_busno = pci_hose_scan(hose);
186}
187