2 * QEMU GT64120 PCI host
4 * Copyright (c) 2006,2007 Aurelien Jarno
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
34 #define DPRINTF(fmt, ...) fprintf(stderr, "%s: " fmt, __FUNCTION__, ##__VA_ARGS__)
36 #define DPRINTF(fmt, ...)
39 #define GT_REGS (0x1000 >> 2)
41 /* CPU Configuration */
42 #define GT_CPU (0x000 >> 2)
43 #define GT_MULTI (0x120 >> 2)
45 /* CPU Address Decode */
46 #define GT_SCS10LD (0x008 >> 2)
47 #define GT_SCS10HD (0x010 >> 2)
48 #define GT_SCS32LD (0x018 >> 2)
49 #define GT_SCS32HD (0x020 >> 2)
50 #define GT_CS20LD (0x028 >> 2)
51 #define GT_CS20HD (0x030 >> 2)
52 #define GT_CS3BOOTLD (0x038 >> 2)
53 #define GT_CS3BOOTHD (0x040 >> 2)
54 #define GT_PCI0IOLD (0x048 >> 2)
55 #define GT_PCI0IOHD (0x050 >> 2)
56 #define GT_PCI0M0LD (0x058 >> 2)
57 #define GT_PCI0M0HD (0x060 >> 2)
58 #define GT_PCI0M1LD (0x080 >> 2)
59 #define GT_PCI0M1HD (0x088 >> 2)
60 #define GT_PCI1IOLD (0x090 >> 2)
61 #define GT_PCI1IOHD (0x098 >> 2)
62 #define GT_PCI1M0LD (0x0a0 >> 2)
63 #define GT_PCI1M0HD (0x0a8 >> 2)
64 #define GT_PCI1M1LD (0x0b0 >> 2)
65 #define GT_PCI1M1HD (0x0b8 >> 2)
66 #define GT_ISD (0x068 >> 2)
68 #define GT_SCS10AR (0x0d0 >> 2)
69 #define GT_SCS32AR (0x0d8 >> 2)
70 #define GT_CS20R (0x0e0 >> 2)
71 #define GT_CS3BOOTR (0x0e8 >> 2)
73 #define GT_PCI0IOREMAP (0x0f0 >> 2)
74 #define GT_PCI0M0REMAP (0x0f8 >> 2)
75 #define GT_PCI0M1REMAP (0x100 >> 2)
76 #define GT_PCI1IOREMAP (0x108 >> 2)
77 #define GT_PCI1M0REMAP (0x110 >> 2)
78 #define GT_PCI1M1REMAP (0x118 >> 2)
80 /* CPU Error Report */
81 #define GT_CPUERR_ADDRLO (0x070 >> 2)
82 #define GT_CPUERR_ADDRHI (0x078 >> 2)
83 #define GT_CPUERR_DATALO (0x128 >> 2) /* GT-64120A only */
84 #define GT_CPUERR_DATAHI (0x130 >> 2) /* GT-64120A only */
85 #define GT_CPUERR_PARITY (0x138 >> 2) /* GT-64120A only */
87 /* CPU Sync Barrier */
88 #define GT_PCI0SYNC (0x0c0 >> 2)
89 #define GT_PCI1SYNC (0x0c8 >> 2)
91 /* SDRAM and Device Address Decode */
92 #define GT_SCS0LD (0x400 >> 2)
93 #define GT_SCS0HD (0x404 >> 2)
94 #define GT_SCS1LD (0x408 >> 2)
95 #define GT_SCS1HD (0x40c >> 2)
96 #define GT_SCS2LD (0x410 >> 2)
97 #define GT_SCS2HD (0x414 >> 2)
98 #define GT_SCS3LD (0x418 >> 2)
99 #define GT_SCS3HD (0x41c >> 2)
100 #define GT_CS0LD (0x420 >> 2)
101 #define GT_CS0HD (0x424 >> 2)
102 #define GT_CS1LD (0x428 >> 2)
103 #define GT_CS1HD (0x42c >> 2)
104 #define GT_CS2LD (0x430 >> 2)
105 #define GT_CS2HD (0x434 >> 2)
106 #define GT_CS3LD (0x438 >> 2)
107 #define GT_CS3HD (0x43c >> 2)
108 #define GT_BOOTLD (0x440 >> 2)
109 #define GT_BOOTHD (0x444 >> 2)
110 #define GT_ADERR (0x470 >> 2)
112 /* SDRAM Configuration */
113 #define GT_SDRAM_CFG (0x448 >> 2)
114 #define GT_SDRAM_OPMODE (0x474 >> 2)
115 #define GT_SDRAM_BM (0x478 >> 2)
116 #define GT_SDRAM_ADDRDECODE (0x47c >> 2)
118 /* SDRAM Parameters */
119 #define GT_SDRAM_B0 (0x44c >> 2)
120 #define GT_SDRAM_B1 (0x450 >> 2)
121 #define GT_SDRAM_B2 (0x454 >> 2)
122 #define GT_SDRAM_B3 (0x458 >> 2)
124 /* Device Parameters */
125 #define GT_DEV_B0 (0x45c >> 2)
126 #define GT_DEV_B1 (0x460 >> 2)
127 #define GT_DEV_B2 (0x464 >> 2)
128 #define GT_DEV_B3 (0x468 >> 2)
129 #define GT_DEV_BOOT (0x46c >> 2)
132 #define GT_ECC_ERRDATALO (0x480 >> 2) /* GT-64120A only */
133 #define GT_ECC_ERRDATAHI (0x484 >> 2) /* GT-64120A only */
134 #define GT_ECC_MEM (0x488 >> 2) /* GT-64120A only */
135 #define GT_ECC_CALC (0x48c >> 2) /* GT-64120A only */
136 #define GT_ECC_ERRADDR (0x490 >> 2) /* GT-64120A only */
139 #define GT_DMA0_CNT (0x800 >> 2)
140 #define GT_DMA1_CNT (0x804 >> 2)
141 #define GT_DMA2_CNT (0x808 >> 2)
142 #define GT_DMA3_CNT (0x80c >> 2)
143 #define GT_DMA0_SA (0x810 >> 2)
144 #define GT_DMA1_SA (0x814 >> 2)
145 #define GT_DMA2_SA (0x818 >> 2)
146 #define GT_DMA3_SA (0x81c >> 2)
147 #define GT_DMA0_DA (0x820 >> 2)
148 #define GT_DMA1_DA (0x824 >> 2)
149 #define GT_DMA2_DA (0x828 >> 2)
150 #define GT_DMA3_DA (0x82c >> 2)
151 #define GT_DMA0_NEXT (0x830 >> 2)
152 #define GT_DMA1_NEXT (0x834 >> 2)
153 #define GT_DMA2_NEXT (0x838 >> 2)
154 #define GT_DMA3_NEXT (0x83c >> 2)
155 #define GT_DMA0_CUR (0x870 >> 2)
156 #define GT_DMA1_CUR (0x874 >> 2)
157 #define GT_DMA2_CUR (0x878 >> 2)
158 #define GT_DMA3_CUR (0x87c >> 2)
160 /* DMA Channel Control */
161 #define GT_DMA0_CTRL (0x840 >> 2)
162 #define GT_DMA1_CTRL (0x844 >> 2)
163 #define GT_DMA2_CTRL (0x848 >> 2)
164 #define GT_DMA3_CTRL (0x84c >> 2)
167 #define GT_DMA_ARB (0x860 >> 2)
170 #define GT_TC0 (0x850 >> 2)
171 #define GT_TC1 (0x854 >> 2)
172 #define GT_TC2 (0x858 >> 2)
173 #define GT_TC3 (0x85c >> 2)
174 #define GT_TC_CONTROL (0x864 >> 2)
177 #define GT_PCI0_CMD (0xc00 >> 2)
178 #define GT_PCI0_TOR (0xc04 >> 2)
179 #define GT_PCI0_BS_SCS10 (0xc08 >> 2)
180 #define GT_PCI0_BS_SCS32 (0xc0c >> 2)
181 #define GT_PCI0_BS_CS20 (0xc10 >> 2)
182 #define GT_PCI0_BS_CS3BT (0xc14 >> 2)
183 #define GT_PCI1_IACK (0xc30 >> 2)
184 #define GT_PCI0_IACK (0xc34 >> 2)
185 #define GT_PCI0_BARE (0xc3c >> 2)
186 #define GT_PCI0_PREFMBR (0xc40 >> 2)
187 #define GT_PCI0_SCS10_BAR (0xc48 >> 2)
188 #define GT_PCI0_SCS32_BAR (0xc4c >> 2)
189 #define GT_PCI0_CS20_BAR (0xc50 >> 2)
190 #define GT_PCI0_CS3BT_BAR (0xc54 >> 2)
191 #define GT_PCI0_SSCS10_BAR (0xc58 >> 2)
192 #define GT_PCI0_SSCS32_BAR (0xc5c >> 2)
193 #define GT_PCI0_SCS3BT_BAR (0xc64 >> 2)
194 #define GT_PCI1_CMD (0xc80 >> 2)
195 #define GT_PCI1_TOR (0xc84 >> 2)
196 #define GT_PCI1_BS_SCS10 (0xc88 >> 2)
197 #define GT_PCI1_BS_SCS32 (0xc8c >> 2)
198 #define GT_PCI1_BS_CS20 (0xc90 >> 2)
199 #define GT_PCI1_BS_CS3BT (0xc94 >> 2)
200 #define GT_PCI1_BARE (0xcbc >> 2)
201 #define GT_PCI1_PREFMBR (0xcc0 >> 2)
202 #define GT_PCI1_SCS10_BAR (0xcc8 >> 2)
203 #define GT_PCI1_SCS32_BAR (0xccc >> 2)
204 #define GT_PCI1_CS20_BAR (0xcd0 >> 2)
205 #define GT_PCI1_CS3BT_BAR (0xcd4 >> 2)
206 #define GT_PCI1_SSCS10_BAR (0xcd8 >> 2)
207 #define GT_PCI1_SSCS32_BAR (0xcdc >> 2)
208 #define GT_PCI1_SCS3BT_BAR (0xce4 >> 2)
209 #define GT_PCI1_CFGADDR (0xcf0 >> 2)
210 #define GT_PCI1_CFGDATA (0xcf4 >> 2)
211 #define GT_PCI0_CFGADDR (0xcf8 >> 2)
212 #define GT_PCI0_CFGDATA (0xcfc >> 2)
215 #define GT_INTRCAUSE (0xc18 >> 2)
216 #define GT_INTRMASK (0xc1c >> 2)
217 #define GT_PCI0_ICMASK (0xc24 >> 2)
218 #define GT_PCI0_SERR0MASK (0xc28 >> 2)
219 #define GT_CPU_INTSEL (0xc70 >> 2)
220 #define GT_PCI0_INTSEL (0xc74 >> 2)
221 #define GT_HINTRCAUSE (0xc98 >> 2)
222 #define GT_HINTRMASK (0xc9c >> 2)
223 #define GT_PCI0_HICMASK (0xca4 >> 2)
224 #define GT_PCI1_SERR1MASK (0xca8 >> 2)
227 typedef PCIHostState GT64120PCIState
;
229 #define PCI_MAPPING_ENTRY(regname) \
230 target_phys_addr_t regname ##_start; \
231 target_phys_addr_t regname ##_length; \
232 int regname ##_handle
234 typedef struct GT64120State
{
235 GT64120PCIState
*pci
;
236 uint32_t regs
[GT_REGS
];
237 PCI_MAPPING_ENTRY(PCI0IO
);
238 PCI_MAPPING_ENTRY(ISD
);
241 /* Adjust range to avoid touching space which isn't mappable via PCI */
242 /* XXX: Hardcoded values for Malta: 0x1e000000 - 0x1f100000
243 0x1fc00000 - 0x1fd00000 */
244 static void check_reserved_space (target_phys_addr_t
*start
,
245 target_phys_addr_t
*length
)
247 target_phys_addr_t begin
= *start
;
248 target_phys_addr_t end
= *start
+ *length
;
250 if (end
>= 0x1e000000LL
&& end
< 0x1f100000LL
)
252 if (begin
>= 0x1e000000LL
&& begin
< 0x1f100000LL
)
253 begin
= 0x1f100000LL
;
254 if (end
>= 0x1fc00000LL
&& end
< 0x1fd00000LL
)
256 if (begin
>= 0x1fc00000LL
&& begin
< 0x1fd00000LL
)
257 begin
= 0x1fd00000LL
;
258 /* XXX: This is broken when a reserved range splits the requested range */
259 if (end
>= 0x1f100000LL
&& begin
< 0x1e000000LL
)
261 if (end
>= 0x1fd00000LL
&& begin
< 0x1fc00000LL
)
265 *length
= end
- begin
;
268 static void gt64120_isd_mapping(GT64120State
*s
)
270 target_phys_addr_t start
= s
->regs
[GT_ISD
] << 21;
271 target_phys_addr_t length
= 0x1000;
274 cpu_register_physical_memory(s
->ISD_start
, s
->ISD_length
,
276 check_reserved_space(&start
, &length
);
278 /* Map new address */
279 DPRINTF("ISD: "TARGET_FMT_plx
"@"TARGET_FMT_plx
" -> "TARGET_FMT_plx
"@"TARGET_FMT_plx
", %x\n", s
->ISD_length
, s
->ISD_start
,
280 length
, start
, s
->ISD_handle
);
281 s
->ISD_start
= start
;
282 s
->ISD_length
= length
;
283 cpu_register_physical_memory(s
->ISD_start
, s
->ISD_length
, s
->ISD_handle
);
286 static void gt64120_pci_mapping(GT64120State
*s
)
288 /* Update IO mapping */
289 if ((s
->regs
[GT_PCI0IOLD
] & 0x7f) <= s
->regs
[GT_PCI0IOHD
])
291 /* Unmap old IO address */
292 if (s
->PCI0IO_length
)
294 cpu_register_physical_memory(s
->PCI0IO_start
, s
->PCI0IO_length
, IO_MEM_UNASSIGNED
);
296 /* Map new IO address */
297 s
->PCI0IO_start
= s
->regs
[GT_PCI0IOLD
] << 21;
298 s
->PCI0IO_length
= ((s
->regs
[GT_PCI0IOHD
] + 1) - (s
->regs
[GT_PCI0IOLD
] & 0x7f)) << 21;
299 isa_mem_base
= s
->PCI0IO_start
;
300 isa_mmio_init(s
->PCI0IO_start
, s
->PCI0IO_length
);
304 static void gt64120_writel (void *opaque
, target_phys_addr_t addr
,
307 GT64120State
*s
= opaque
;
310 if (!(s
->regs
[GT_CPU
] & 0x00001000))
313 saddr
= (addr
& 0xfff) >> 2;
316 /* CPU Configuration */
318 s
->regs
[GT_CPU
] = val
;
321 /* Read-only register as only one GT64xxx is present on the CPU bus */
324 /* CPU Address Decode */
326 s
->regs
[GT_PCI0IOLD
] = val
& 0x00007fff;
327 s
->regs
[GT_PCI0IOREMAP
] = val
& 0x000007ff;
328 gt64120_pci_mapping(s
);
331 s
->regs
[GT_PCI0M0LD
] = val
& 0x00007fff;
332 s
->regs
[GT_PCI0M0REMAP
] = val
& 0x000007ff;
335 s
->regs
[GT_PCI0M1LD
] = val
& 0x00007fff;
336 s
->regs
[GT_PCI0M1REMAP
] = val
& 0x000007ff;
339 s
->regs
[GT_PCI1IOLD
] = val
& 0x00007fff;
340 s
->regs
[GT_PCI1IOREMAP
] = val
& 0x000007ff;
343 s
->regs
[GT_PCI1M0LD
] = val
& 0x00007fff;
344 s
->regs
[GT_PCI1M0REMAP
] = val
& 0x000007ff;
347 s
->regs
[GT_PCI1M1LD
] = val
& 0x00007fff;
348 s
->regs
[GT_PCI1M1REMAP
] = val
& 0x000007ff;
351 s
->regs
[saddr
] = val
& 0x0000007f;
352 gt64120_pci_mapping(s
);
359 s
->regs
[saddr
] = val
& 0x0000007f;
362 s
->regs
[saddr
] = val
& 0x00007fff;
363 gt64120_isd_mapping(s
);
372 s
->regs
[saddr
] = val
& 0x000007ff;
375 /* CPU Error Report */
376 case GT_CPUERR_ADDRLO
:
377 case GT_CPUERR_ADDRHI
:
378 case GT_CPUERR_DATALO
:
379 case GT_CPUERR_DATAHI
:
380 case GT_CPUERR_PARITY
:
381 /* Read-only registers, do nothing */
384 /* CPU Sync Barrier */
387 /* Read-only registers, do nothing */
390 /* SDRAM and Device Address Decode */
410 /* SDRAM Configuration */
412 case GT_SDRAM_OPMODE
:
414 case GT_SDRAM_ADDRDECODE
:
415 /* Accept and ignore SDRAM interleave configuration */
416 s
->regs
[saddr
] = val
;
419 /* Device Parameters */
425 /* Not implemented */
426 DPRINTF ("Unimplemented device register offset 0x%x\n", saddr
<< 2);
430 case GT_ECC_ERRDATALO
:
431 case GT_ECC_ERRDATAHI
:
435 /* Read-only registers, do nothing */
459 /* Not implemented */
460 DPRINTF ("Unimplemented DMA register offset 0x%x\n", saddr
<< 2);
463 /* DMA Channel Control */
468 /* Not implemented */
469 DPRINTF ("Unimplemented DMA register offset 0x%x\n", saddr
<< 2);
474 /* Not implemented */
475 DPRINTF ("Unimplemented DMA register offset 0x%x\n", saddr
<< 2);
484 /* Not implemented */
485 DPRINTF ("Unimplemented timer register offset 0x%x\n", saddr
<< 2);
491 s
->regs
[saddr
] = val
& 0x0401fc0f;
494 case GT_PCI0_BS_SCS10
:
495 case GT_PCI0_BS_SCS32
:
496 case GT_PCI0_BS_CS20
:
497 case GT_PCI0_BS_CS3BT
:
501 case GT_PCI0_PREFMBR
:
502 case GT_PCI0_SCS10_BAR
:
503 case GT_PCI0_SCS32_BAR
:
504 case GT_PCI0_CS20_BAR
:
505 case GT_PCI0_CS3BT_BAR
:
506 case GT_PCI0_SSCS10_BAR
:
507 case GT_PCI0_SSCS32_BAR
:
508 case GT_PCI0_SCS3BT_BAR
:
510 case GT_PCI1_BS_SCS10
:
511 case GT_PCI1_BS_SCS32
:
512 case GT_PCI1_BS_CS20
:
513 case GT_PCI1_BS_CS3BT
:
515 case GT_PCI1_PREFMBR
:
516 case GT_PCI1_SCS10_BAR
:
517 case GT_PCI1_SCS32_BAR
:
518 case GT_PCI1_CS20_BAR
:
519 case GT_PCI1_CS3BT_BAR
:
520 case GT_PCI1_SSCS10_BAR
:
521 case GT_PCI1_SSCS32_BAR
:
522 case GT_PCI1_SCS3BT_BAR
:
523 case GT_PCI1_CFGADDR
:
524 case GT_PCI1_CFGDATA
:
525 /* not implemented */
527 case GT_PCI0_CFGADDR
:
528 s
->pci
->config_reg
= val
& 0x80fffffc;
530 case GT_PCI0_CFGDATA
:
531 if (!(s
->regs
[GT_PCI0_CMD
] & 1) && (s
->pci
->config_reg
& 0x00fff800))
533 if (s
->pci
->config_reg
& (1u << 31))
534 pci_data_write(s
->pci
->bus
, s
->pci
->config_reg
, val
, 4);
539 /* not really implemented */
540 s
->regs
[saddr
] = ~(~(s
->regs
[saddr
]) | ~(val
& 0xfffffffe));
541 s
->regs
[saddr
] |= !!(s
->regs
[saddr
] & 0xfffffffe);
542 DPRINTF("INTRCAUSE %x\n", val
);
545 s
->regs
[saddr
] = val
& 0x3c3ffffe;
546 DPRINTF("INTRMASK %x\n", val
);
549 s
->regs
[saddr
] = val
& 0x03fffffe;
550 DPRINTF("ICMASK %x\n", val
);
552 case GT_PCI0_SERR0MASK
:
553 s
->regs
[saddr
] = val
& 0x0000003f;
554 DPRINTF("SERR0MASK %x\n", val
);
557 /* Reserved when only PCI_0 is configured. */
562 case GT_PCI0_HICMASK
:
563 case GT_PCI1_SERR1MASK
:
564 /* not implemented */
567 /* SDRAM Parameters */
572 /* We don't simulate electrical parameters of the SDRAM.
573 Accept, but ignore the values. */
574 s
->regs
[saddr
] = val
;
578 DPRINTF ("Bad register offset 0x%x\n", (int)addr
);
583 static uint32_t gt64120_readl (void *opaque
,
584 target_phys_addr_t addr
)
586 GT64120State
*s
= opaque
;
590 saddr
= (addr
& 0xfff) >> 2;
593 /* CPU Configuration */
595 /* Only one GT64xxx is present on the CPU bus, return
597 val
= s
->regs
[saddr
];
600 /* CPU Error Report */
601 case GT_CPUERR_ADDRLO
:
602 case GT_CPUERR_ADDRHI
:
603 case GT_CPUERR_DATALO
:
604 case GT_CPUERR_DATAHI
:
605 case GT_CPUERR_PARITY
:
606 /* Emulated memory has no error, always return the initial
608 val
= s
->regs
[saddr
];
611 /* CPU Sync Barrier */
614 /* Reading those register should empty all FIFO on the PCI
615 bus, which are not emulated. The return value should be
616 a random value that should be ignored. */
621 case GT_ECC_ERRDATALO
:
622 case GT_ECC_ERRDATAHI
:
626 /* Emulated memory has no error, always return the initial
628 val
= s
->regs
[saddr
];
663 val
= s
->regs
[saddr
];
666 /* Read the IRQ number */
667 val
= pic_read_irq(isa_pic
);
670 /* SDRAM and Device Address Decode */
690 val
= s
->regs
[saddr
];
693 /* SDRAM Configuration */
695 case GT_SDRAM_OPMODE
:
697 case GT_SDRAM_ADDRDECODE
:
698 val
= s
->regs
[saddr
];
701 /* SDRAM Parameters */
706 /* We don't simulate electrical parameters of the SDRAM.
707 Just return the last written value. */
708 val
= s
->regs
[saddr
];
711 /* Device Parameters */
717 val
= s
->regs
[saddr
];
741 val
= s
->regs
[saddr
];
744 /* DMA Channel Control */
749 val
= s
->regs
[saddr
];
754 val
= s
->regs
[saddr
];
763 val
= s
->regs
[saddr
];
767 case GT_PCI0_CFGADDR
:
768 val
= s
->pci
->config_reg
;
770 case GT_PCI0_CFGDATA
:
771 if (!(s
->pci
->config_reg
& (1 << 31)))
774 val
= pci_data_read(s
->pci
->bus
, s
->pci
->config_reg
, 4);
775 if (!(s
->regs
[GT_PCI0_CMD
] & 1) && (s
->pci
->config_reg
& 0x00fff800))
781 case GT_PCI0_BS_SCS10
:
782 case GT_PCI0_BS_SCS32
:
783 case GT_PCI0_BS_CS20
:
784 case GT_PCI0_BS_CS3BT
:
787 case GT_PCI0_PREFMBR
:
788 case GT_PCI0_SCS10_BAR
:
789 case GT_PCI0_SCS32_BAR
:
790 case GT_PCI0_CS20_BAR
:
791 case GT_PCI0_CS3BT_BAR
:
792 case GT_PCI0_SSCS10_BAR
:
793 case GT_PCI0_SSCS32_BAR
:
794 case GT_PCI0_SCS3BT_BAR
:
797 case GT_PCI1_BS_SCS10
:
798 case GT_PCI1_BS_SCS32
:
799 case GT_PCI1_BS_CS20
:
800 case GT_PCI1_BS_CS3BT
:
802 case GT_PCI1_PREFMBR
:
803 case GT_PCI1_SCS10_BAR
:
804 case GT_PCI1_SCS32_BAR
:
805 case GT_PCI1_CS20_BAR
:
806 case GT_PCI1_CS3BT_BAR
:
807 case GT_PCI1_SSCS10_BAR
:
808 case GT_PCI1_SSCS32_BAR
:
809 case GT_PCI1_SCS3BT_BAR
:
810 case GT_PCI1_CFGADDR
:
811 case GT_PCI1_CFGDATA
:
812 val
= s
->regs
[saddr
];
817 val
= s
->regs
[saddr
];
818 DPRINTF("INTRCAUSE %x\n", val
);
821 val
= s
->regs
[saddr
];
822 DPRINTF("INTRMASK %x\n", val
);
825 val
= s
->regs
[saddr
];
826 DPRINTF("ICMASK %x\n", val
);
828 case GT_PCI0_SERR0MASK
:
829 val
= s
->regs
[saddr
];
830 DPRINTF("SERR0MASK %x\n", val
);
833 /* Reserved when only PCI_0 is configured. */
838 case GT_PCI0_HICMASK
:
839 case GT_PCI1_SERR1MASK
:
840 val
= s
->regs
[saddr
];
844 val
= s
->regs
[saddr
];
845 DPRINTF ("Bad register offset 0x%x\n", (int)addr
);
849 if (!(s
->regs
[GT_CPU
] & 0x00001000))
855 static CPUWriteMemoryFunc
* const gt64120_write
[] = {
861 static CPUReadMemoryFunc
* const gt64120_read
[] = {
867 static int pci_gt64120_map_irq(PCIDevice
*pci_dev
, int irq_num
)
871 slot
= (pci_dev
->devfn
>> 3);
877 /* AMD 79C973 Ethernet */
880 /* Crystal 4281 Sound */
883 /* PCI slot 1 to 4 */
885 return ((slot
- 18) + irq_num
) & 0x03;
886 /* Unknown device, don't do any translation */
892 static int pci_irq_levels
[4];
894 static void pci_gt64120_set_irq(void *opaque
, int irq_num
, int level
)
896 int i
, pic_irq
, pic_level
;
897 qemu_irq
*pic
= opaque
;
899 pci_irq_levels
[irq_num
] = level
;
901 /* now we change the pic irq level according to the piix irq mappings */
903 pic_irq
= piix4_dev
->config
[0x60 + irq_num
];
905 /* The pic level is the logical OR of all the PCI irqs mapped
908 for (i
= 0; i
< 4; i
++) {
909 if (pic_irq
== piix4_dev
->config
[0x60 + i
])
910 pic_level
|= pci_irq_levels
[i
];
912 qemu_set_irq(pic
[pic_irq
], pic_level
);
917 static void gt64120_reset(void *opaque
)
919 GT64120State
*s
= opaque
;
921 /* FIXME: Malta specific hw assumptions ahead */
923 /* CPU Configuration */
924 #ifdef TARGET_WORDS_BIGENDIAN
925 s
->regs
[GT_CPU
] = 0x00000000;
927 s
->regs
[GT_CPU
] = 0x00001000;
929 s
->regs
[GT_MULTI
] = 0x00000003;
931 /* CPU Address decode */
932 s
->regs
[GT_SCS10LD
] = 0x00000000;
933 s
->regs
[GT_SCS10HD
] = 0x00000007;
934 s
->regs
[GT_SCS32LD
] = 0x00000008;
935 s
->regs
[GT_SCS32HD
] = 0x0000000f;
936 s
->regs
[GT_CS20LD
] = 0x000000e0;
937 s
->regs
[GT_CS20HD
] = 0x00000070;
938 s
->regs
[GT_CS3BOOTLD
] = 0x000000f8;
939 s
->regs
[GT_CS3BOOTHD
] = 0x0000007f;
941 s
->regs
[GT_PCI0IOLD
] = 0x00000080;
942 s
->regs
[GT_PCI0IOHD
] = 0x0000000f;
943 s
->regs
[GT_PCI0M0LD
] = 0x00000090;
944 s
->regs
[GT_PCI0M0HD
] = 0x0000001f;
945 s
->regs
[GT_ISD
] = 0x000000a0;
946 s
->regs
[GT_PCI0M1LD
] = 0x00000790;
947 s
->regs
[GT_PCI0M1HD
] = 0x0000001f;
948 s
->regs
[GT_PCI1IOLD
] = 0x00000100;
949 s
->regs
[GT_PCI1IOHD
] = 0x0000000f;
950 s
->regs
[GT_PCI1M0LD
] = 0x00000110;
951 s
->regs
[GT_PCI1M0HD
] = 0x0000001f;
952 s
->regs
[GT_PCI1M1LD
] = 0x00000120;
953 s
->regs
[GT_PCI1M1HD
] = 0x0000002f;
955 s
->regs
[GT_SCS10AR
] = 0x00000000;
956 s
->regs
[GT_SCS32AR
] = 0x00000008;
957 s
->regs
[GT_CS20R
] = 0x000000e0;
958 s
->regs
[GT_CS3BOOTR
] = 0x000000f8;
960 s
->regs
[GT_PCI0IOREMAP
] = 0x00000080;
961 s
->regs
[GT_PCI0M0REMAP
] = 0x00000090;
962 s
->regs
[GT_PCI0M1REMAP
] = 0x00000790;
963 s
->regs
[GT_PCI1IOREMAP
] = 0x00000100;
964 s
->regs
[GT_PCI1M0REMAP
] = 0x00000110;
965 s
->regs
[GT_PCI1M1REMAP
] = 0x00000120;
967 /* CPU Error Report */
968 s
->regs
[GT_CPUERR_ADDRLO
] = 0x00000000;
969 s
->regs
[GT_CPUERR_ADDRHI
] = 0x00000000;
970 s
->regs
[GT_CPUERR_DATALO
] = 0xffffffff;
971 s
->regs
[GT_CPUERR_DATAHI
] = 0xffffffff;
972 s
->regs
[GT_CPUERR_PARITY
] = 0x000000ff;
974 /* CPU Sync Barrier */
975 s
->regs
[GT_PCI0SYNC
] = 0x00000000;
976 s
->regs
[GT_PCI1SYNC
] = 0x00000000;
978 /* SDRAM and Device Address Decode */
979 s
->regs
[GT_SCS0LD
] = 0x00000000;
980 s
->regs
[GT_SCS0HD
] = 0x00000007;
981 s
->regs
[GT_SCS1LD
] = 0x00000008;
982 s
->regs
[GT_SCS1HD
] = 0x0000000f;
983 s
->regs
[GT_SCS2LD
] = 0x00000010;
984 s
->regs
[GT_SCS2HD
] = 0x00000017;
985 s
->regs
[GT_SCS3LD
] = 0x00000018;
986 s
->regs
[GT_SCS3HD
] = 0x0000001f;
987 s
->regs
[GT_CS0LD
] = 0x000000c0;
988 s
->regs
[GT_CS0HD
] = 0x000000c7;
989 s
->regs
[GT_CS1LD
] = 0x000000c8;
990 s
->regs
[GT_CS1HD
] = 0x000000cf;
991 s
->regs
[GT_CS2LD
] = 0x000000d0;
992 s
->regs
[GT_CS2HD
] = 0x000000df;
993 s
->regs
[GT_CS3LD
] = 0x000000f0;
994 s
->regs
[GT_CS3HD
] = 0x000000fb;
995 s
->regs
[GT_BOOTLD
] = 0x000000fc;
996 s
->regs
[GT_BOOTHD
] = 0x000000ff;
997 s
->regs
[GT_ADERR
] = 0xffffffff;
999 /* SDRAM Configuration */
1000 s
->regs
[GT_SDRAM_CFG
] = 0x00000200;
1001 s
->regs
[GT_SDRAM_OPMODE
] = 0x00000000;
1002 s
->regs
[GT_SDRAM_BM
] = 0x00000007;
1003 s
->regs
[GT_SDRAM_ADDRDECODE
] = 0x00000002;
1005 /* SDRAM Parameters */
1006 s
->regs
[GT_SDRAM_B0
] = 0x00000005;
1007 s
->regs
[GT_SDRAM_B1
] = 0x00000005;
1008 s
->regs
[GT_SDRAM_B2
] = 0x00000005;
1009 s
->regs
[GT_SDRAM_B3
] = 0x00000005;
1012 s
->regs
[GT_ECC_ERRDATALO
] = 0x00000000;
1013 s
->regs
[GT_ECC_ERRDATAHI
] = 0x00000000;
1014 s
->regs
[GT_ECC_MEM
] = 0x00000000;
1015 s
->regs
[GT_ECC_CALC
] = 0x00000000;
1016 s
->regs
[GT_ECC_ERRADDR
] = 0x00000000;
1018 /* Device Parameters */
1019 s
->regs
[GT_DEV_B0
] = 0x386fffff;
1020 s
->regs
[GT_DEV_B1
] = 0x386fffff;
1021 s
->regs
[GT_DEV_B2
] = 0x386fffff;
1022 s
->regs
[GT_DEV_B3
] = 0x386fffff;
1023 s
->regs
[GT_DEV_BOOT
] = 0x146fffff;
1025 /* DMA registers are all zeroed at reset */
1028 s
->regs
[GT_TC0
] = 0xffffffff;
1029 s
->regs
[GT_TC1
] = 0x00ffffff;
1030 s
->regs
[GT_TC2
] = 0x00ffffff;
1031 s
->regs
[GT_TC3
] = 0x00ffffff;
1032 s
->regs
[GT_TC_CONTROL
] = 0x00000000;
1035 #ifdef TARGET_WORDS_BIGENDIAN
1036 s
->regs
[GT_PCI0_CMD
] = 0x00000000;
1038 s
->regs
[GT_PCI0_CMD
] = 0x00010001;
1040 s
->regs
[GT_PCI0_TOR
] = 0x0000070f;
1041 s
->regs
[GT_PCI0_BS_SCS10
] = 0x00fff000;
1042 s
->regs
[GT_PCI0_BS_SCS32
] = 0x00fff000;
1043 s
->regs
[GT_PCI0_BS_CS20
] = 0x01fff000;
1044 s
->regs
[GT_PCI0_BS_CS3BT
] = 0x00fff000;
1045 s
->regs
[GT_PCI1_IACK
] = 0x00000000;
1046 s
->regs
[GT_PCI0_IACK
] = 0x00000000;
1047 s
->regs
[GT_PCI0_BARE
] = 0x0000000f;
1048 s
->regs
[GT_PCI0_PREFMBR
] = 0x00000040;
1049 s
->regs
[GT_PCI0_SCS10_BAR
] = 0x00000000;
1050 s
->regs
[GT_PCI0_SCS32_BAR
] = 0x01000000;
1051 s
->regs
[GT_PCI0_CS20_BAR
] = 0x1c000000;
1052 s
->regs
[GT_PCI0_CS3BT_BAR
] = 0x1f000000;
1053 s
->regs
[GT_PCI0_SSCS10_BAR
] = 0x00000000;
1054 s
->regs
[GT_PCI0_SSCS32_BAR
] = 0x01000000;
1055 s
->regs
[GT_PCI0_SCS3BT_BAR
] = 0x1f000000;
1056 #ifdef TARGET_WORDS_BIGENDIAN
1057 s
->regs
[GT_PCI1_CMD
] = 0x00000000;
1059 s
->regs
[GT_PCI1_CMD
] = 0x00010001;
1061 s
->regs
[GT_PCI1_TOR
] = 0x0000070f;
1062 s
->regs
[GT_PCI1_BS_SCS10
] = 0x00fff000;
1063 s
->regs
[GT_PCI1_BS_SCS32
] = 0x00fff000;
1064 s
->regs
[GT_PCI1_BS_CS20
] = 0x01fff000;
1065 s
->regs
[GT_PCI1_BS_CS3BT
] = 0x00fff000;
1066 s
->regs
[GT_PCI1_BARE
] = 0x0000000f;
1067 s
->regs
[GT_PCI1_PREFMBR
] = 0x00000040;
1068 s
->regs
[GT_PCI1_SCS10_BAR
] = 0x00000000;
1069 s
->regs
[GT_PCI1_SCS32_BAR
] = 0x01000000;
1070 s
->regs
[GT_PCI1_CS20_BAR
] = 0x1c000000;
1071 s
->regs
[GT_PCI1_CS3BT_BAR
] = 0x1f000000;
1072 s
->regs
[GT_PCI1_SSCS10_BAR
] = 0x00000000;
1073 s
->regs
[GT_PCI1_SSCS32_BAR
] = 0x01000000;
1074 s
->regs
[GT_PCI1_SCS3BT_BAR
] = 0x1f000000;
1075 s
->regs
[GT_PCI1_CFGADDR
] = 0x00000000;
1076 s
->regs
[GT_PCI1_CFGDATA
] = 0x00000000;
1077 s
->regs
[GT_PCI0_CFGADDR
] = 0x00000000;
1079 /* Interrupt registers are all zeroed at reset */
1081 gt64120_isd_mapping(s
);
1082 gt64120_pci_mapping(s
);
1085 static void gt64120_save(QEMUFile
* f
, void *opaque
)
1087 PCIDevice
*d
= opaque
;
1088 pci_device_save(d
, f
);
1091 static int gt64120_load(QEMUFile
* f
, void *opaque
, int version_id
)
1093 PCIDevice
*d
= opaque
;
1096 if (version_id
!= 1)
1098 ret
= pci_device_load(d
, f
);
1104 PCIBus
*pci_gt64120_init(qemu_irq
*pic
)
1109 s
= qemu_mallocz(sizeof(GT64120State
));
1110 s
->pci
= qemu_mallocz(sizeof(GT64120PCIState
));
1112 s
->pci
->bus
= pci_register_bus(NULL
, "pci",
1113 pci_gt64120_set_irq
, pci_gt64120_map_irq
,
1114 pic
, PCI_DEVFN(18, 0), 4);
1115 s
->ISD_handle
= cpu_register_io_memory(gt64120_read
, gt64120_write
, s
,
1116 DEVICE_NATIVE_ENDIAN
);
1117 d
= pci_register_device(s
->pci
->bus
, "GT64120 PCI Bus", sizeof(PCIDevice
),
1120 /* FIXME: Malta specific hw assumptions ahead */
1122 pci_config_set_vendor_id(d
->config
, PCI_VENDOR_ID_MARVELL
);
1123 pci_config_set_device_id(d
->config
, PCI_DEVICE_ID_MARVELL_GT6412X
);
1125 d
->config
[0x04] = 0x00;
1126 d
->config
[0x05] = 0x00;
1127 d
->config
[0x06] = 0x80;
1128 d
->config
[0x07] = 0x02;
1130 d
->config
[0x08] = 0x10;
1131 d
->config
[0x09] = 0x00;
1132 pci_config_set_class(d
->config
, PCI_CLASS_BRIDGE_HOST
);
1134 d
->config
[0x10] = 0x08;
1135 d
->config
[0x14] = 0x08;
1136 d
->config
[0x17] = 0x01;
1137 d
->config
[0x1B] = 0x1c;
1138 d
->config
[0x1F] = 0x1f;
1139 d
->config
[0x23] = 0x14;
1140 d
->config
[0x24] = 0x01;
1141 d
->config
[0x27] = 0x14;
1142 d
->config
[0x3D] = 0x01;
1146 register_savevm(&d
->qdev
, "GT64120 PCI Bus", 0, 1,
1147 gt64120_save
, gt64120_load
, d
);