root / hw / ppce500_pci.c @ 4b816985
History | View | Annotate | Download (10.6 kB)
1 | 74c62ba8 | aurel32 | /*
|
---|---|---|---|
2 | 74c62ba8 | aurel32 | * QEMU PowerPC E500 embedded processors pci controller emulation
|
3 | 74c62ba8 | aurel32 | *
|
4 | 74c62ba8 | aurel32 | * Copyright (C) 2009 Freescale Semiconductor, Inc. All rights reserved.
|
5 | 74c62ba8 | aurel32 | *
|
6 | 74c62ba8 | aurel32 | * Author: Yu Liu, <yu.liu@freescale.com>
|
7 | 74c62ba8 | aurel32 | *
|
8 | 74c62ba8 | aurel32 | * This file is derived from hw/ppc4xx_pci.c,
|
9 | 74c62ba8 | aurel32 | * the copyright for that material belongs to the original owners.
|
10 | 74c62ba8 | aurel32 | *
|
11 | 74c62ba8 | aurel32 | * This is free software; you can redistribute it and/or modify
|
12 | 74c62ba8 | aurel32 | * it under the terms of the GNU General Public License as published by
|
13 | 74c62ba8 | aurel32 | * the Free Software Foundation; either version 2 of the License, or
|
14 | 74c62ba8 | aurel32 | * (at your option) any later version.
|
15 | 74c62ba8 | aurel32 | */
|
16 | 74c62ba8 | aurel32 | |
17 | 74c62ba8 | aurel32 | #include "hw.h" |
18 | 74c62ba8 | aurel32 | #include "ppc.h" |
19 | 74c62ba8 | aurel32 | #include "ppce500.h" |
20 | 74c62ba8 | aurel32 | typedef target_phys_addr_t pci_addr_t;
|
21 | 74c62ba8 | aurel32 | #include "pci.h" |
22 | 74c62ba8 | aurel32 | #include "pci_host.h" |
23 | 74c62ba8 | aurel32 | #include "bswap.h" |
24 | 74c62ba8 | aurel32 | #include "qemu-log.h" |
25 | 74c62ba8 | aurel32 | |
26 | 74c62ba8 | aurel32 | #ifdef DEBUG_PCI
|
27 | 001faf32 | Blue Swirl | #define pci_debug(fmt, ...) fprintf(stderr, fmt, ## __VA_ARGS__) |
28 | 74c62ba8 | aurel32 | #else
|
29 | 001faf32 | Blue Swirl | #define pci_debug(fmt, ...)
|
30 | 74c62ba8 | aurel32 | #endif
|
31 | 74c62ba8 | aurel32 | |
32 | 74c62ba8 | aurel32 | #define PCIE500_CFGADDR 0x0 |
33 | 74c62ba8 | aurel32 | #define PCIE500_CFGDATA 0x4 |
34 | 74c62ba8 | aurel32 | #define PCIE500_REG_BASE 0xC00 |
35 | 74c62ba8 | aurel32 | #define PCIE500_REG_SIZE (0x1000 - PCIE500_REG_BASE) |
36 | 74c62ba8 | aurel32 | |
37 | 74c62ba8 | aurel32 | #define PPCE500_PCI_CONFIG_ADDR 0x0 |
38 | 74c62ba8 | aurel32 | #define PPCE500_PCI_CONFIG_DATA 0x4 |
39 | 74c62ba8 | aurel32 | #define PPCE500_PCI_INTACK 0x8 |
40 | 74c62ba8 | aurel32 | |
41 | 74c62ba8 | aurel32 | #define PPCE500_PCI_OW1 (0xC20 - PCIE500_REG_BASE) |
42 | 74c62ba8 | aurel32 | #define PPCE500_PCI_OW2 (0xC40 - PCIE500_REG_BASE) |
43 | 74c62ba8 | aurel32 | #define PPCE500_PCI_OW3 (0xC60 - PCIE500_REG_BASE) |
44 | 74c62ba8 | aurel32 | #define PPCE500_PCI_OW4 (0xC80 - PCIE500_REG_BASE) |
45 | 74c62ba8 | aurel32 | #define PPCE500_PCI_IW3 (0xDA0 - PCIE500_REG_BASE) |
46 | 74c62ba8 | aurel32 | #define PPCE500_PCI_IW2 (0xDC0 - PCIE500_REG_BASE) |
47 | 74c62ba8 | aurel32 | #define PPCE500_PCI_IW1 (0xDE0 - PCIE500_REG_BASE) |
48 | 74c62ba8 | aurel32 | |
49 | 74c62ba8 | aurel32 | #define PPCE500_PCI_GASKET_TIMR (0xE20 - PCIE500_REG_BASE) |
50 | 74c62ba8 | aurel32 | |
51 | 74c62ba8 | aurel32 | #define PCI_POTAR 0x0 |
52 | 74c62ba8 | aurel32 | #define PCI_POTEAR 0x4 |
53 | 74c62ba8 | aurel32 | #define PCI_POWBAR 0x8 |
54 | 74c62ba8 | aurel32 | #define PCI_POWAR 0x10 |
55 | 74c62ba8 | aurel32 | |
56 | 74c62ba8 | aurel32 | #define PCI_PITAR 0x0 |
57 | 74c62ba8 | aurel32 | #define PCI_PIWBAR 0x8 |
58 | 74c62ba8 | aurel32 | #define PCI_PIWBEAR 0xC |
59 | 74c62ba8 | aurel32 | #define PCI_PIWAR 0x10 |
60 | 74c62ba8 | aurel32 | |
61 | 74c62ba8 | aurel32 | #define PPCE500_PCI_NR_POBS 5 |
62 | 74c62ba8 | aurel32 | #define PPCE500_PCI_NR_PIBS 3 |
63 | 74c62ba8 | aurel32 | |
64 | 74c62ba8 | aurel32 | struct pci_outbound {
|
65 | 74c62ba8 | aurel32 | uint32_t potar; |
66 | 74c62ba8 | aurel32 | uint32_t potear; |
67 | 74c62ba8 | aurel32 | uint32_t powbar; |
68 | 74c62ba8 | aurel32 | uint32_t powar; |
69 | 74c62ba8 | aurel32 | }; |
70 | 74c62ba8 | aurel32 | |
71 | 74c62ba8 | aurel32 | struct pci_inbound {
|
72 | 74c62ba8 | aurel32 | uint32_t pitar; |
73 | 74c62ba8 | aurel32 | uint32_t piwbar; |
74 | 74c62ba8 | aurel32 | uint32_t piwbear; |
75 | 74c62ba8 | aurel32 | uint32_t piwar; |
76 | 74c62ba8 | aurel32 | }; |
77 | 74c62ba8 | aurel32 | |
78 | 74c62ba8 | aurel32 | struct PPCE500PCIState {
|
79 | 74c62ba8 | aurel32 | struct pci_outbound pob[PPCE500_PCI_NR_POBS];
|
80 | 74c62ba8 | aurel32 | struct pci_inbound pib[PPCE500_PCI_NR_PIBS];
|
81 | 74c62ba8 | aurel32 | uint32_t gasket_time; |
82 | 74c62ba8 | aurel32 | PCIHostState pci_state; |
83 | 74c62ba8 | aurel32 | PCIDevice *pci_dev; |
84 | 74c62ba8 | aurel32 | }; |
85 | 74c62ba8 | aurel32 | |
86 | 74c62ba8 | aurel32 | typedef struct PPCE500PCIState PPCE500PCIState; |
87 | 74c62ba8 | aurel32 | |
88 | 74c62ba8 | aurel32 | static uint32_t pcie500_cfgaddr_readl(void *opaque, target_phys_addr_t addr) |
89 | 74c62ba8 | aurel32 | { |
90 | 74c62ba8 | aurel32 | PPCE500PCIState *pci = opaque; |
91 | 74c62ba8 | aurel32 | |
92 | 74c62ba8 | aurel32 | pci_debug("%s: (addr:%Lx) -> value:%x\n", __func__, addr,
|
93 | 74c62ba8 | aurel32 | pci->pci_state.config_reg); |
94 | 74c62ba8 | aurel32 | return pci->pci_state.config_reg;
|
95 | 74c62ba8 | aurel32 | } |
96 | 74c62ba8 | aurel32 | |
97 | 74c62ba8 | aurel32 | static CPUReadMemoryFunc *pcie500_cfgaddr_read[] = {
|
98 | 74c62ba8 | aurel32 | &pcie500_cfgaddr_readl, |
99 | 74c62ba8 | aurel32 | &pcie500_cfgaddr_readl, |
100 | 74c62ba8 | aurel32 | &pcie500_cfgaddr_readl, |
101 | 74c62ba8 | aurel32 | }; |
102 | 74c62ba8 | aurel32 | |
103 | 74c62ba8 | aurel32 | static void pcie500_cfgaddr_writel(void *opaque, target_phys_addr_t addr, |
104 | 74c62ba8 | aurel32 | uint32_t value) |
105 | 74c62ba8 | aurel32 | { |
106 | 74c62ba8 | aurel32 | PPCE500PCIState *controller = opaque; |
107 | 74c62ba8 | aurel32 | |
108 | 74c62ba8 | aurel32 | pci_debug("%s: value:%x -> (addr%Lx)\n", __func__, value, addr);
|
109 | 74c62ba8 | aurel32 | controller->pci_state.config_reg = value & ~0x3;
|
110 | 74c62ba8 | aurel32 | } |
111 | 74c62ba8 | aurel32 | |
112 | 74c62ba8 | aurel32 | static CPUWriteMemoryFunc *pcie500_cfgaddr_write[] = {
|
113 | 74c62ba8 | aurel32 | &pcie500_cfgaddr_writel, |
114 | 74c62ba8 | aurel32 | &pcie500_cfgaddr_writel, |
115 | 74c62ba8 | aurel32 | &pcie500_cfgaddr_writel, |
116 | 74c62ba8 | aurel32 | }; |
117 | 74c62ba8 | aurel32 | |
118 | 74c62ba8 | aurel32 | static CPUReadMemoryFunc *pcie500_cfgdata_read[] = {
|
119 | 74c62ba8 | aurel32 | &pci_host_data_readb, |
120 | 74c62ba8 | aurel32 | &pci_host_data_readw, |
121 | 74c62ba8 | aurel32 | &pci_host_data_readl, |
122 | 74c62ba8 | aurel32 | }; |
123 | 74c62ba8 | aurel32 | |
124 | 74c62ba8 | aurel32 | static CPUWriteMemoryFunc *pcie500_cfgdata_write[] = {
|
125 | 74c62ba8 | aurel32 | &pci_host_data_writeb, |
126 | 74c62ba8 | aurel32 | &pci_host_data_writew, |
127 | 74c62ba8 | aurel32 | &pci_host_data_writel, |
128 | 74c62ba8 | aurel32 | }; |
129 | 74c62ba8 | aurel32 | |
130 | 74c62ba8 | aurel32 | static uint32_t pci_reg_read4(void *opaque, target_phys_addr_t addr) |
131 | 74c62ba8 | aurel32 | { |
132 | 74c62ba8 | aurel32 | PPCE500PCIState *pci = opaque; |
133 | 74c62ba8 | aurel32 | unsigned long win; |
134 | 74c62ba8 | aurel32 | uint32_t value = 0;
|
135 | 74c62ba8 | aurel32 | |
136 | 74c62ba8 | aurel32 | win = addr & 0xfe0;
|
137 | 74c62ba8 | aurel32 | |
138 | 74c62ba8 | aurel32 | switch (win) {
|
139 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW1:
|
140 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW2:
|
141 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW3:
|
142 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW4:
|
143 | 74c62ba8 | aurel32 | switch (addr & 0xC) { |
144 | 74c62ba8 | aurel32 | case PCI_POTAR: value = pci->pob[(addr >> 5) & 0x7].potar; break; |
145 | 74c62ba8 | aurel32 | case PCI_POTEAR: value = pci->pob[(addr >> 5) & 0x7].potear; break; |
146 | 74c62ba8 | aurel32 | case PCI_POWBAR: value = pci->pob[(addr >> 5) & 0x7].powbar; break; |
147 | 74c62ba8 | aurel32 | case PCI_POWAR: value = pci->pob[(addr >> 5) & 0x7].powar; break; |
148 | 74c62ba8 | aurel32 | default: break; |
149 | 74c62ba8 | aurel32 | } |
150 | 74c62ba8 | aurel32 | break;
|
151 | 74c62ba8 | aurel32 | |
152 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW3:
|
153 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW2:
|
154 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW1:
|
155 | 74c62ba8 | aurel32 | switch (addr & 0xC) { |
156 | 74c62ba8 | aurel32 | case PCI_PITAR: value = pci->pib[(addr >> 5) & 0x3].pitar; break; |
157 | 74c62ba8 | aurel32 | case PCI_PIWBAR: value = pci->pib[(addr >> 5) & 0x3].piwbar; break; |
158 | 74c62ba8 | aurel32 | case PCI_PIWBEAR: value = pci->pib[(addr >> 5) & 0x3].piwbear; break; |
159 | 74c62ba8 | aurel32 | case PCI_PIWAR: value = pci->pib[(addr >> 5) & 0x3].piwar; break; |
160 | 74c62ba8 | aurel32 | default: break; |
161 | 74c62ba8 | aurel32 | }; |
162 | 74c62ba8 | aurel32 | break;
|
163 | 74c62ba8 | aurel32 | |
164 | 74c62ba8 | aurel32 | case PPCE500_PCI_GASKET_TIMR:
|
165 | 74c62ba8 | aurel32 | value = pci->gasket_time; |
166 | 74c62ba8 | aurel32 | break;
|
167 | 74c62ba8 | aurel32 | |
168 | 74c62ba8 | aurel32 | default:
|
169 | 74c62ba8 | aurel32 | break;
|
170 | 74c62ba8 | aurel32 | } |
171 | 74c62ba8 | aurel32 | |
172 | 74c62ba8 | aurel32 | pci_debug("%s: win:%lx(addr:%Lx) -> value:%x\n",__func__,win,addr,value);
|
173 | 74c62ba8 | aurel32 | return value;
|
174 | 74c62ba8 | aurel32 | } |
175 | 74c62ba8 | aurel32 | |
176 | 74c62ba8 | aurel32 | static CPUReadMemoryFunc *e500_pci_reg_read[] = {
|
177 | 74c62ba8 | aurel32 | &pci_reg_read4, |
178 | 74c62ba8 | aurel32 | &pci_reg_read4, |
179 | 74c62ba8 | aurel32 | &pci_reg_read4, |
180 | 74c62ba8 | aurel32 | }; |
181 | 74c62ba8 | aurel32 | |
182 | 74c62ba8 | aurel32 | static void pci_reg_write4(void *opaque, target_phys_addr_t addr, |
183 | 74c62ba8 | aurel32 | uint32_t value) |
184 | 74c62ba8 | aurel32 | { |
185 | 74c62ba8 | aurel32 | PPCE500PCIState *pci = opaque; |
186 | 74c62ba8 | aurel32 | unsigned long win; |
187 | 74c62ba8 | aurel32 | |
188 | 74c62ba8 | aurel32 | win = addr & 0xfe0;
|
189 | 74c62ba8 | aurel32 | |
190 | 74c62ba8 | aurel32 | pci_debug("%s: value:%x -> win:%lx(addr:%Lx)\n",__func__,value,win,addr);
|
191 | 74c62ba8 | aurel32 | |
192 | 74c62ba8 | aurel32 | switch (win) {
|
193 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW1:
|
194 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW2:
|
195 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW3:
|
196 | 74c62ba8 | aurel32 | case PPCE500_PCI_OW4:
|
197 | 74c62ba8 | aurel32 | switch (addr & 0xC) { |
198 | 74c62ba8 | aurel32 | case PCI_POTAR: pci->pob[(addr >> 5) & 0x7].potar = value; break; |
199 | 74c62ba8 | aurel32 | case PCI_POTEAR: pci->pob[(addr >> 5) & 0x7].potear = value; break; |
200 | 74c62ba8 | aurel32 | case PCI_POWBAR: pci->pob[(addr >> 5) & 0x7].powbar = value; break; |
201 | 74c62ba8 | aurel32 | case PCI_POWAR: pci->pob[(addr >> 5) & 0x7].powar = value; break; |
202 | 74c62ba8 | aurel32 | default: break; |
203 | 74c62ba8 | aurel32 | }; |
204 | 74c62ba8 | aurel32 | break;
|
205 | 74c62ba8 | aurel32 | |
206 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW3:
|
207 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW2:
|
208 | 74c62ba8 | aurel32 | case PPCE500_PCI_IW1:
|
209 | 74c62ba8 | aurel32 | switch (addr & 0xC) { |
210 | 74c62ba8 | aurel32 | case PCI_PITAR: pci->pib[(addr >> 5) & 0x3].pitar = value; break; |
211 | 74c62ba8 | aurel32 | case PCI_PIWBAR: pci->pib[(addr >> 5) & 0x3].piwbar = value; break; |
212 | 74c62ba8 | aurel32 | case PCI_PIWBEAR: pci->pib[(addr >> 5) & 0x3].piwbear = value; break; |
213 | 74c62ba8 | aurel32 | case PCI_PIWAR: pci->pib[(addr >> 5) & 0x3].piwar = value; break; |
214 | 74c62ba8 | aurel32 | default: break; |
215 | 74c62ba8 | aurel32 | }; |
216 | 74c62ba8 | aurel32 | break;
|
217 | 74c62ba8 | aurel32 | |
218 | 74c62ba8 | aurel32 | case PPCE500_PCI_GASKET_TIMR:
|
219 | 74c62ba8 | aurel32 | pci->gasket_time = value; |
220 | 74c62ba8 | aurel32 | break;
|
221 | 74c62ba8 | aurel32 | |
222 | 74c62ba8 | aurel32 | default:
|
223 | 74c62ba8 | aurel32 | break;
|
224 | 74c62ba8 | aurel32 | }; |
225 | 74c62ba8 | aurel32 | } |
226 | 74c62ba8 | aurel32 | |
227 | 74c62ba8 | aurel32 | static CPUWriteMemoryFunc *e500_pci_reg_write[] = {
|
228 | 74c62ba8 | aurel32 | &pci_reg_write4, |
229 | 74c62ba8 | aurel32 | &pci_reg_write4, |
230 | 74c62ba8 | aurel32 | &pci_reg_write4, |
231 | 74c62ba8 | aurel32 | }; |
232 | 74c62ba8 | aurel32 | |
233 | 74c62ba8 | aurel32 | static int mpc85xx_pci_map_irq(PCIDevice *pci_dev, int irq_num) |
234 | 74c62ba8 | aurel32 | { |
235 | 74c62ba8 | aurel32 | int devno = pci_dev->devfn >> 3, ret = 0; |
236 | 74c62ba8 | aurel32 | |
237 | 74c62ba8 | aurel32 | switch (devno) {
|
238 | 74c62ba8 | aurel32 | /* Two PCI slot */
|
239 | 74c62ba8 | aurel32 | case 0x11: |
240 | 74c62ba8 | aurel32 | case 0x12: |
241 | 74c62ba8 | aurel32 | ret = (irq_num + devno - 0x10) % 4; |
242 | 74c62ba8 | aurel32 | break;
|
243 | 74c62ba8 | aurel32 | default:
|
244 | 74c62ba8 | aurel32 | printf("Error:%s:unknow dev number\n", __func__);
|
245 | 74c62ba8 | aurel32 | } |
246 | 74c62ba8 | aurel32 | |
247 | 74c62ba8 | aurel32 | pci_debug("%s: devfn %x irq %d -> %d devno:%x\n", __func__,
|
248 | 74c62ba8 | aurel32 | pci_dev->devfn, irq_num, ret, devno); |
249 | 74c62ba8 | aurel32 | |
250 | 74c62ba8 | aurel32 | return ret;
|
251 | 74c62ba8 | aurel32 | } |
252 | 74c62ba8 | aurel32 | |
253 | 74c62ba8 | aurel32 | static void mpc85xx_pci_set_irq(qemu_irq *pic, int irq_num, int level) |
254 | 74c62ba8 | aurel32 | { |
255 | 74c62ba8 | aurel32 | pci_debug("%s: PCI irq %d, level:%d\n", __func__, irq_num, level);
|
256 | 74c62ba8 | aurel32 | |
257 | 74c62ba8 | aurel32 | qemu_set_irq(pic[irq_num], level); |
258 | 74c62ba8 | aurel32 | } |
259 | 74c62ba8 | aurel32 | |
260 | 74c62ba8 | aurel32 | static void ppce500_pci_save(QEMUFile *f, void *opaque) |
261 | 74c62ba8 | aurel32 | { |
262 | 74c62ba8 | aurel32 | PPCE500PCIState *controller = opaque; |
263 | 74c62ba8 | aurel32 | int i;
|
264 | 74c62ba8 | aurel32 | |
265 | 74c62ba8 | aurel32 | pci_device_save(controller->pci_dev, f); |
266 | 74c62ba8 | aurel32 | |
267 | 74c62ba8 | aurel32 | for (i = 0; i < PPCE500_PCI_NR_POBS; i++) { |
268 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pob[i].potar); |
269 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pob[i].potear); |
270 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pob[i].powbar); |
271 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pob[i].powar); |
272 | 74c62ba8 | aurel32 | } |
273 | 74c62ba8 | aurel32 | |
274 | 74c62ba8 | aurel32 | for (i = 0; i < PPCE500_PCI_NR_PIBS; i++) { |
275 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pib[i].pitar); |
276 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pib[i].piwbar); |
277 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pib[i].piwbear); |
278 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->pib[i].piwar); |
279 | 74c62ba8 | aurel32 | } |
280 | 74c62ba8 | aurel32 | qemu_put_be32s(f, &controller->gasket_time); |
281 | 74c62ba8 | aurel32 | } |
282 | 74c62ba8 | aurel32 | |
283 | 74c62ba8 | aurel32 | static int ppce500_pci_load(QEMUFile *f, void *opaque, int version_id) |
284 | 74c62ba8 | aurel32 | { |
285 | 74c62ba8 | aurel32 | PPCE500PCIState *controller = opaque; |
286 | 74c62ba8 | aurel32 | int i;
|
287 | 74c62ba8 | aurel32 | |
288 | 74c62ba8 | aurel32 | if (version_id != 1) |
289 | 74c62ba8 | aurel32 | return -EINVAL;
|
290 | 74c62ba8 | aurel32 | |
291 | 74c62ba8 | aurel32 | pci_device_load(controller->pci_dev, f); |
292 | 74c62ba8 | aurel32 | |
293 | 74c62ba8 | aurel32 | for (i = 0; i < PPCE500_PCI_NR_POBS; i++) { |
294 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pob[i].potar); |
295 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pob[i].potear); |
296 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pob[i].powbar); |
297 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pob[i].powar); |
298 | 74c62ba8 | aurel32 | } |
299 | 74c62ba8 | aurel32 | |
300 | 74c62ba8 | aurel32 | for (i = 0; i < PPCE500_PCI_NR_PIBS; i++) { |
301 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pib[i].pitar); |
302 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pib[i].piwbar); |
303 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pib[i].piwbear); |
304 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->pib[i].piwar); |
305 | 74c62ba8 | aurel32 | } |
306 | 74c62ba8 | aurel32 | qemu_get_be32s(f, &controller->gasket_time); |
307 | 74c62ba8 | aurel32 | |
308 | 74c62ba8 | aurel32 | return 0; |
309 | 74c62ba8 | aurel32 | } |
310 | 74c62ba8 | aurel32 | |
311 | 74c62ba8 | aurel32 | PCIBus *ppce500_pci_init(qemu_irq pci_irqs[4], target_phys_addr_t registers)
|
312 | 74c62ba8 | aurel32 | { |
313 | 74c62ba8 | aurel32 | PPCE500PCIState *controller; |
314 | 74c62ba8 | aurel32 | PCIDevice *d; |
315 | 74c62ba8 | aurel32 | int index;
|
316 | 74c62ba8 | aurel32 | static int ppce500_pci_id; |
317 | 74c62ba8 | aurel32 | |
318 | 74c62ba8 | aurel32 | controller = qemu_mallocz(sizeof(PPCE500PCIState));
|
319 | 74c62ba8 | aurel32 | |
320 | 74c62ba8 | aurel32 | controller->pci_state.bus = pci_register_bus(mpc85xx_pci_set_irq, |
321 | 74c62ba8 | aurel32 | mpc85xx_pci_map_irq, |
322 | 74c62ba8 | aurel32 | pci_irqs, 0x88, 4); |
323 | 74c62ba8 | aurel32 | d = pci_register_device(controller->pci_state.bus, |
324 | 74c62ba8 | aurel32 | "host bridge", sizeof(PCIDevice), |
325 | 74c62ba8 | aurel32 | 0, NULL, NULL); |
326 | 74c62ba8 | aurel32 | |
327 | a770dc7e | aliguori | pci_config_set_vendor_id(d->config, PCI_VENDOR_ID_FREESCALE); |
328 | a770dc7e | aliguori | pci_config_set_device_id(d->config, PCI_DEVICE_ID_MPC8533E); |
329 | 74c62ba8 | aurel32 | pci_config_set_class(d->config, PCI_CLASS_PROCESSOR_POWERPC); |
330 | 74c62ba8 | aurel32 | |
331 | 74c62ba8 | aurel32 | controller->pci_dev = d; |
332 | 74c62ba8 | aurel32 | |
333 | 74c62ba8 | aurel32 | /* CFGADDR */
|
334 | 74c62ba8 | aurel32 | index = cpu_register_io_memory(0, pcie500_cfgaddr_read,
|
335 | 74c62ba8 | aurel32 | pcie500_cfgaddr_write, controller); |
336 | 74c62ba8 | aurel32 | if (index < 0) |
337 | 74c62ba8 | aurel32 | goto free;
|
338 | 74c62ba8 | aurel32 | cpu_register_physical_memory(registers + PCIE500_CFGADDR, 4, index);
|
339 | 74c62ba8 | aurel32 | |
340 | 74c62ba8 | aurel32 | /* CFGDATA */
|
341 | 74c62ba8 | aurel32 | index = cpu_register_io_memory(0, pcie500_cfgdata_read,
|
342 | 74c62ba8 | aurel32 | pcie500_cfgdata_write, |
343 | 74c62ba8 | aurel32 | &controller->pci_state); |
344 | 74c62ba8 | aurel32 | if (index < 0) |
345 | 74c62ba8 | aurel32 | goto free;
|
346 | 74c62ba8 | aurel32 | cpu_register_physical_memory(registers + PCIE500_CFGDATA, 4, index);
|
347 | 74c62ba8 | aurel32 | |
348 | 74c62ba8 | aurel32 | index = cpu_register_io_memory(0, e500_pci_reg_read,
|
349 | 74c62ba8 | aurel32 | e500_pci_reg_write, controller); |
350 | 74c62ba8 | aurel32 | if (index < 0) |
351 | 74c62ba8 | aurel32 | goto free;
|
352 | 74c62ba8 | aurel32 | cpu_register_physical_memory(registers + PCIE500_REG_BASE, |
353 | 74c62ba8 | aurel32 | PCIE500_REG_SIZE, index); |
354 | 74c62ba8 | aurel32 | |
355 | 74c62ba8 | aurel32 | /* XXX load/save code not tested. */
|
356 | 74c62ba8 | aurel32 | register_savevm("ppce500_pci", ppce500_pci_id++, 1, |
357 | 74c62ba8 | aurel32 | ppce500_pci_save, ppce500_pci_load, controller); |
358 | 74c62ba8 | aurel32 | |
359 | 74c62ba8 | aurel32 | return controller->pci_state.bus;
|
360 | 74c62ba8 | aurel32 | |
361 | 74c62ba8 | aurel32 | free:
|
362 | 74c62ba8 | aurel32 | printf("%s error\n", __func__);
|
363 | 74c62ba8 | aurel32 | qemu_free(controller); |
364 | 74c62ba8 | aurel32 | return NULL; |
365 | 74c62ba8 | aurel32 | } |