root / hw / realview.c @ 771124e1
History | View | Annotate | Download (15.6 kB)
1 | 5fafdf24 | ths | /*
|
---|---|---|---|
2 | e69954b9 | pbrook | * ARM RealView Baseboard System emulation.
|
3 | e69954b9 | pbrook | *
|
4 | a1bb27b1 | pbrook | * Copyright (c) 2006-2007 CodeSourcery.
|
5 | e69954b9 | pbrook | * Written by Paul Brook
|
6 | e69954b9 | pbrook | *
|
7 | 8e31bf38 | Matthew Fernandez | * This code is licensed under the GPL.
|
8 | e69954b9 | pbrook | */
|
9 | e69954b9 | pbrook | |
10 | 2e9bdce5 | Paul Brook | #include "sysbus.h" |
11 | 87ecb68b | pbrook | #include "arm-misc.h" |
12 | 87ecb68b | pbrook | #include "primecell.h" |
13 | 87ecb68b | pbrook | #include "devices.h" |
14 | 87ecb68b | pbrook | #include "pci.h" |
15 | 18e08a55 | Michael S. Tsirkin | #include "usb-ohci.h" |
16 | 87ecb68b | pbrook | #include "net.h" |
17 | 87ecb68b | pbrook | #include "sysemu.h" |
18 | 87ecb68b | pbrook | #include "boards.h" |
19 | eee48504 | Paul Brook | #include "bitbang_i2c.h" |
20 | 2446333c | Blue Swirl | #include "blockdev.h" |
21 | 35e87820 | Avi Kivity | #include "exec-memory.h" |
22 | e69954b9 | pbrook | |
23 | 0ef849d7 | Paul Brook | #define SMP_BOOT_ADDR 0xe0000000 |
24 | 078758d0 | Evgeny Voevodin | #define SMP_BOOTREG_ADDR 0x10000030 |
25 | eee48504 | Paul Brook | |
26 | eee48504 | Paul Brook | typedef struct { |
27 | eee48504 | Paul Brook | SysBusDevice busdev; |
28 | 35e87820 | Avi Kivity | MemoryRegion iomem; |
29 | eee48504 | Paul Brook | bitbang_i2c_interface *bitbang; |
30 | eee48504 | Paul Brook | int out;
|
31 | eee48504 | Paul Brook | int in;
|
32 | eee48504 | Paul Brook | } RealViewI2CState; |
33 | eee48504 | Paul Brook | |
34 | 35e87820 | Avi Kivity | static uint64_t realview_i2c_read(void *opaque, target_phys_addr_t offset, |
35 | 35e87820 | Avi Kivity | unsigned size)
|
36 | eee48504 | Paul Brook | { |
37 | eee48504 | Paul Brook | RealViewI2CState *s = (RealViewI2CState *)opaque; |
38 | eee48504 | Paul Brook | |
39 | eee48504 | Paul Brook | if (offset == 0) { |
40 | eee48504 | Paul Brook | return (s->out & 1) | (s->in << 1); |
41 | eee48504 | Paul Brook | } else {
|
42 | eee48504 | Paul Brook | hw_error("realview_i2c_read: Bad offset 0x%x\n", (int)offset); |
43 | eee48504 | Paul Brook | return -1; |
44 | eee48504 | Paul Brook | } |
45 | eee48504 | Paul Brook | } |
46 | eee48504 | Paul Brook | |
47 | eee48504 | Paul Brook | static void realview_i2c_write(void *opaque, target_phys_addr_t offset, |
48 | 35e87820 | Avi Kivity | uint64_t value, unsigned size)
|
49 | eee48504 | Paul Brook | { |
50 | eee48504 | Paul Brook | RealViewI2CState *s = (RealViewI2CState *)opaque; |
51 | eee48504 | Paul Brook | |
52 | eee48504 | Paul Brook | switch (offset) {
|
53 | eee48504 | Paul Brook | case 0: |
54 | eee48504 | Paul Brook | s->out |= value & 3;
|
55 | eee48504 | Paul Brook | break;
|
56 | eee48504 | Paul Brook | case 4: |
57 | eee48504 | Paul Brook | s->out &= ~value; |
58 | eee48504 | Paul Brook | break;
|
59 | eee48504 | Paul Brook | default:
|
60 | eee48504 | Paul Brook | hw_error("realview_i2c_write: Bad offset 0x%x\n", (int)offset); |
61 | eee48504 | Paul Brook | } |
62 | eee48504 | Paul Brook | bitbang_i2c_set(s->bitbang, BITBANG_I2C_SCL, (s->out & 1) != 0); |
63 | eee48504 | Paul Brook | s->in = bitbang_i2c_set(s->bitbang, BITBANG_I2C_SDA, (s->out & 2) != 0); |
64 | eee48504 | Paul Brook | } |
65 | eee48504 | Paul Brook | |
66 | 35e87820 | Avi Kivity | static const MemoryRegionOps realview_i2c_ops = { |
67 | 35e87820 | Avi Kivity | .read = realview_i2c_read, |
68 | 35e87820 | Avi Kivity | .write = realview_i2c_write, |
69 | 35e87820 | Avi Kivity | .endianness = DEVICE_NATIVE_ENDIAN, |
70 | eee48504 | Paul Brook | }; |
71 | eee48504 | Paul Brook | |
72 | eee48504 | Paul Brook | static int realview_i2c_init(SysBusDevice *dev) |
73 | eee48504 | Paul Brook | { |
74 | eee48504 | Paul Brook | RealViewI2CState *s = FROM_SYSBUS(RealViewI2CState, dev); |
75 | eee48504 | Paul Brook | i2c_bus *bus; |
76 | eee48504 | Paul Brook | |
77 | eee48504 | Paul Brook | bus = i2c_init_bus(&dev->qdev, "i2c");
|
78 | eee48504 | Paul Brook | s->bitbang = bitbang_i2c_init(bus); |
79 | 35e87820 | Avi Kivity | memory_region_init_io(&s->iomem, &realview_i2c_ops, s, |
80 | 35e87820 | Avi Kivity | "realview-i2c", 0x1000); |
81 | 750ecd44 | Avi Kivity | sysbus_init_mmio(dev, &s->iomem); |
82 | eee48504 | Paul Brook | return 0; |
83 | eee48504 | Paul Brook | } |
84 | eee48504 | Paul Brook | |
85 | 999e12bb | Anthony Liguori | static void realview_i2c_class_init(ObjectClass *klass, void *data) |
86 | 999e12bb | Anthony Liguori | { |
87 | 999e12bb | Anthony Liguori | SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass); |
88 | 999e12bb | Anthony Liguori | |
89 | 999e12bb | Anthony Liguori | k->init = realview_i2c_init; |
90 | 999e12bb | Anthony Liguori | } |
91 | 999e12bb | Anthony Liguori | |
92 | 999e12bb | Anthony Liguori | static DeviceInfo realview_i2c_info = {
|
93 | 999e12bb | Anthony Liguori | .name = "realview_i2c",
|
94 | 999e12bb | Anthony Liguori | .size = sizeof(RealViewI2CState),
|
95 | 999e12bb | Anthony Liguori | .class_init = realview_i2c_class_init, |
96 | eee48504 | Paul Brook | }; |
97 | eee48504 | Paul Brook | |
98 | eee48504 | Paul Brook | static void realview_register_devices(void) |
99 | eee48504 | Paul Brook | { |
100 | eee48504 | Paul Brook | sysbus_register_withprop(&realview_i2c_info); |
101 | eee48504 | Paul Brook | } |
102 | eee48504 | Paul Brook | |
103 | e69954b9 | pbrook | /* Board init. */
|
104 | e69954b9 | pbrook | |
105 | f93eb9ff | balrog | static struct arm_boot_info realview_binfo = { |
106 | 0ef849d7 | Paul Brook | .smp_loader_start = SMP_BOOT_ADDR, |
107 | 078758d0 | Evgeny Voevodin | .smp_bootreg_addr = SMP_BOOTREG_ADDR, |
108 | f93eb9ff | balrog | }; |
109 | f93eb9ff | balrog | |
110 | f7c70325 | Paul Brook | /* The following two lists must be consistent. */
|
111 | c988bfad | Paul Brook | enum realview_board_type {
|
112 | c988bfad | Paul Brook | BOARD_EB, |
113 | 0ef849d7 | Paul Brook | BOARD_EB_MPCORE, |
114 | f7c70325 | Paul Brook | BOARD_PB_A8, |
115 | f7c70325 | Paul Brook | BOARD_PBX_A9, |
116 | f7c70325 | Paul Brook | }; |
117 | f7c70325 | Paul Brook | |
118 | d05ac8fa | Blue Swirl | static const int realview_board_id[] = { |
119 | f7c70325 | Paul Brook | 0x33b,
|
120 | f7c70325 | Paul Brook | 0x33b,
|
121 | f7c70325 | Paul Brook | 0x769,
|
122 | f7c70325 | Paul Brook | 0x76d
|
123 | c988bfad | Paul Brook | }; |
124 | c988bfad | Paul Brook | |
125 | c227f099 | Anthony Liguori | static void realview_init(ram_addr_t ram_size, |
126 | 3023f332 | aliguori | const char *boot_device, |
127 | e69954b9 | pbrook | const char *kernel_filename, const char *kernel_cmdline, |
128 | c988bfad | Paul Brook | const char *initrd_filename, const char *cpu_model, |
129 | c988bfad | Paul Brook | enum realview_board_type board_type)
|
130 | e69954b9 | pbrook | { |
131 | c988bfad | Paul Brook | CPUState *env = NULL;
|
132 | 35e87820 | Avi Kivity | MemoryRegion *sysmem = get_system_memory(); |
133 | 35e87820 | Avi Kivity | MemoryRegion *ram_lo = g_new(MemoryRegion, 1);
|
134 | 35e87820 | Avi Kivity | MemoryRegion *ram_hi = g_new(MemoryRegion, 1);
|
135 | 35e87820 | Avi Kivity | MemoryRegion *ram_alias = g_new(MemoryRegion, 1);
|
136 | 35e87820 | Avi Kivity | MemoryRegion *ram_hack = g_new(MemoryRegion, 1);
|
137 | 03a0e944 | Peter Maydell | DeviceState *dev, *sysctl, *gpio2, *pl041; |
138 | c988bfad | Paul Brook | SysBusDevice *busdev; |
139 | fe7e8758 | Paul Brook | qemu_irq *irqp; |
140 | fe7e8758 | Paul Brook | qemu_irq pic[64];
|
141 | 26883c69 | Peter Maydell | qemu_irq mmc_irq[2];
|
142 | e69954b9 | pbrook | PCIBus *pci_bus; |
143 | e69954b9 | pbrook | NICInfo *nd; |
144 | eee48504 | Paul Brook | i2c_bus *i2c; |
145 | e69954b9 | pbrook | int n;
|
146 | 0ef849d7 | Paul Brook | int done_nic = 0; |
147 | 9ee6e8bb | pbrook | qemu_irq cpu_irq[4];
|
148 | f7c70325 | Paul Brook | int is_mpcore = 0; |
149 | f7c70325 | Paul Brook | int is_pb = 0; |
150 | 26e92f65 | Paul Brook | uint32_t proc_id = 0;
|
151 | 0ef849d7 | Paul Brook | uint32_t sys_id; |
152 | 0ef849d7 | Paul Brook | ram_addr_t low_ram_size; |
153 | e69954b9 | pbrook | |
154 | f7c70325 | Paul Brook | switch (board_type) {
|
155 | f7c70325 | Paul Brook | case BOARD_EB:
|
156 | f7c70325 | Paul Brook | break;
|
157 | f7c70325 | Paul Brook | case BOARD_EB_MPCORE:
|
158 | f7c70325 | Paul Brook | is_mpcore = 1;
|
159 | f7c70325 | Paul Brook | break;
|
160 | f7c70325 | Paul Brook | case BOARD_PB_A8:
|
161 | f7c70325 | Paul Brook | is_pb = 1;
|
162 | f7c70325 | Paul Brook | break;
|
163 | f7c70325 | Paul Brook | case BOARD_PBX_A9:
|
164 | f7c70325 | Paul Brook | is_mpcore = 1;
|
165 | f7c70325 | Paul Brook | is_pb = 1;
|
166 | f7c70325 | Paul Brook | break;
|
167 | f7c70325 | Paul Brook | } |
168 | c988bfad | Paul Brook | for (n = 0; n < smp_cpus; n++) { |
169 | 9ee6e8bb | pbrook | env = cpu_init(cpu_model); |
170 | 9ee6e8bb | pbrook | if (!env) {
|
171 | 9ee6e8bb | pbrook | fprintf(stderr, "Unable to find CPU definition\n");
|
172 | 9ee6e8bb | pbrook | exit(1);
|
173 | 9ee6e8bb | pbrook | } |
174 | fe7e8758 | Paul Brook | irqp = arm_pic_init_cpu(env); |
175 | fe7e8758 | Paul Brook | cpu_irq[n] = irqp[ARM_PIC_CPU_IRQ]; |
176 | aaed909a | bellard | } |
177 | 26e92f65 | Paul Brook | if (arm_feature(env, ARM_FEATURE_V7)) {
|
178 | f7c70325 | Paul Brook | if (is_mpcore) {
|
179 | f7c70325 | Paul Brook | proc_id = 0x0c000000;
|
180 | f7c70325 | Paul Brook | } else {
|
181 | f7c70325 | Paul Brook | proc_id = 0x0e000000;
|
182 | f7c70325 | Paul Brook | } |
183 | 26e92f65 | Paul Brook | } else if (arm_feature(env, ARM_FEATURE_V6K)) { |
184 | 26e92f65 | Paul Brook | proc_id = 0x06000000;
|
185 | 26e92f65 | Paul Brook | } else if (arm_feature(env, ARM_FEATURE_V6)) { |
186 | 26e92f65 | Paul Brook | proc_id = 0x04000000;
|
187 | 26e92f65 | Paul Brook | } else {
|
188 | 26e92f65 | Paul Brook | proc_id = 0x02000000;
|
189 | 26e92f65 | Paul Brook | } |
190 | aaed909a | bellard | |
191 | 21a88941 | Paul Brook | if (is_pb && ram_size > 0x20000000) { |
192 | 21a88941 | Paul Brook | /* Core tile RAM. */
|
193 | 21a88941 | Paul Brook | low_ram_size = ram_size - 0x20000000;
|
194 | 21a88941 | Paul Brook | ram_size = 0x20000000;
|
195 | c5705a77 | Avi Kivity | memory_region_init_ram(ram_lo, "realview.lowmem", low_ram_size);
|
196 | c5705a77 | Avi Kivity | vmstate_register_ram_global(ram_lo); |
197 | 35e87820 | Avi Kivity | memory_region_add_subregion(sysmem, 0x20000000, ram_lo);
|
198 | 21a88941 | Paul Brook | } |
199 | 21a88941 | Paul Brook | |
200 | c5705a77 | Avi Kivity | memory_region_init_ram(ram_hi, "realview.highmem", ram_size);
|
201 | c5705a77 | Avi Kivity | vmstate_register_ram_global(ram_hi); |
202 | 0ef849d7 | Paul Brook | low_ram_size = ram_size; |
203 | 0ef849d7 | Paul Brook | if (low_ram_size > 0x10000000) |
204 | 0ef849d7 | Paul Brook | low_ram_size = 0x10000000;
|
205 | e69954b9 | pbrook | /* SDRAM at address zero. */
|
206 | 35e87820 | Avi Kivity | memory_region_init_alias(ram_alias, "realview.alias",
|
207 | 35e87820 | Avi Kivity | ram_hi, 0, low_ram_size);
|
208 | 35e87820 | Avi Kivity | memory_region_add_subregion(sysmem, 0, ram_alias);
|
209 | 0ef849d7 | Paul Brook | if (is_pb) {
|
210 | 0ef849d7 | Paul Brook | /* And again at a high address. */
|
211 | 35e87820 | Avi Kivity | memory_region_add_subregion(sysmem, 0x70000000, ram_hi);
|
212 | 0ef849d7 | Paul Brook | } else {
|
213 | 0ef849d7 | Paul Brook | ram_size = low_ram_size; |
214 | 0ef849d7 | Paul Brook | } |
215 | e69954b9 | pbrook | |
216 | 0ef849d7 | Paul Brook | sys_id = is_pb ? 0x01780500 : 0xc1400400; |
217 | 26883c69 | Peter Maydell | sysctl = qdev_create(NULL, "realview_sysctl"); |
218 | 26883c69 | Peter Maydell | qdev_prop_set_uint32(sysctl, "sys_id", sys_id);
|
219 | 26883c69 | Peter Maydell | qdev_init_nofail(sysctl); |
220 | 26883c69 | Peter Maydell | qdev_prop_set_uint32(sysctl, "proc_id", proc_id);
|
221 | 26883c69 | Peter Maydell | sysbus_mmio_map(sysbus_from_qdev(sysctl), 0, 0x10000000); |
222 | 9ee6e8bb | pbrook | |
223 | c988bfad | Paul Brook | if (is_mpcore) {
|
224 | f7c70325 | Paul Brook | dev = qdev_create(NULL, is_pb ? "a9mpcore_priv": "realview_mpcore"); |
225 | c988bfad | Paul Brook | qdev_prop_set_uint32(dev, "num-cpu", smp_cpus);
|
226 | c988bfad | Paul Brook | qdev_init_nofail(dev); |
227 | c988bfad | Paul Brook | busdev = sysbus_from_qdev(dev); |
228 | f7c70325 | Paul Brook | if (is_pb) {
|
229 | f7c70325 | Paul Brook | realview_binfo.smp_priv_base = 0x1f000000;
|
230 | f7c70325 | Paul Brook | } else {
|
231 | f7c70325 | Paul Brook | realview_binfo.smp_priv_base = 0x10100000;
|
232 | f7c70325 | Paul Brook | } |
233 | f7c70325 | Paul Brook | sysbus_mmio_map(busdev, 0, realview_binfo.smp_priv_base);
|
234 | c988bfad | Paul Brook | for (n = 0; n < smp_cpus; n++) { |
235 | c988bfad | Paul Brook | sysbus_connect_irq(busdev, n, cpu_irq[n]); |
236 | c988bfad | Paul Brook | } |
237 | 5a157588 | Peter Maydell | sysbus_create_varargs("l2x0", realview_binfo.smp_priv_base + 0x2000, |
238 | 5a157588 | Peter Maydell | NULL);
|
239 | 9ee6e8bb | pbrook | } else {
|
240 | 0ef849d7 | Paul Brook | uint32_t gic_addr = is_pb ? 0x1e000000 : 0x10040000; |
241 | 0ef849d7 | Paul Brook | /* For now just create the nIRQ GIC, and ignore the others. */
|
242 | 0ef849d7 | Paul Brook | dev = sysbus_create_simple("realview_gic", gic_addr, cpu_irq[0]); |
243 | fe7e8758 | Paul Brook | } |
244 | fe7e8758 | Paul Brook | for (n = 0; n < 64; n++) { |
245 | 067a3ddc | Paul Brook | pic[n] = qdev_get_gpio_in(dev, n); |
246 | 9ee6e8bb | pbrook | } |
247 | 9ee6e8bb | pbrook | |
248 | 03a0e944 | Peter Maydell | pl041 = qdev_create(NULL, "pl041"); |
249 | 03a0e944 | Peter Maydell | qdev_prop_set_uint32(pl041, "nc_fifo_depth", 512); |
250 | 03a0e944 | Peter Maydell | qdev_init_nofail(pl041); |
251 | 03a0e944 | Peter Maydell | sysbus_mmio_map(sysbus_from_qdev(pl041), 0, 0x10004000); |
252 | 03a0e944 | Peter Maydell | sysbus_connect_irq(sysbus_from_qdev(pl041), 0, pic[19]); |
253 | 03a0e944 | Peter Maydell | |
254 | 86394e96 | Paul Brook | sysbus_create_simple("pl050_keyboard", 0x10006000, pic[20]); |
255 | 86394e96 | Paul Brook | sysbus_create_simple("pl050_mouse", 0x10007000, pic[21]); |
256 | e69954b9 | pbrook | |
257 | a7d518a6 | Paul Brook | sysbus_create_simple("pl011", 0x10009000, pic[12]); |
258 | a7d518a6 | Paul Brook | sysbus_create_simple("pl011", 0x1000a000, pic[13]); |
259 | a7d518a6 | Paul Brook | sysbus_create_simple("pl011", 0x1000b000, pic[14]); |
260 | a7d518a6 | Paul Brook | sysbus_create_simple("pl011", 0x1000c000, pic[15]); |
261 | e69954b9 | pbrook | |
262 | e69954b9 | pbrook | /* DMA controller is optional, apparently. */
|
263 | b4496b13 | Paul Brook | sysbus_create_simple("pl081", 0x10030000, pic[24]); |
264 | e69954b9 | pbrook | |
265 | 6a824ec3 | Paul Brook | sysbus_create_simple("sp804", 0x10011000, pic[4]); |
266 | 6a824ec3 | Paul Brook | sysbus_create_simple("sp804", 0x10012000, pic[5]); |
267 | e69954b9 | pbrook | |
268 | 26883c69 | Peter Maydell | sysbus_create_simple("pl061", 0x10013000, pic[6]); |
269 | 26883c69 | Peter Maydell | sysbus_create_simple("pl061", 0x10014000, pic[7]); |
270 | 26883c69 | Peter Maydell | gpio2 = sysbus_create_simple("pl061", 0x10015000, pic[8]); |
271 | 26883c69 | Peter Maydell | |
272 | acb9b722 | Peter Maydell | sysbus_create_simple("pl111", 0x10020000, pic[23]); |
273 | e69954b9 | pbrook | |
274 | 26883c69 | Peter Maydell | dev = sysbus_create_varargs("pl181", 0x10005000, pic[17], pic[18], NULL); |
275 | 26883c69 | Peter Maydell | /* Wire up MMC card detect and read-only signals. These have
|
276 | 26883c69 | Peter Maydell | * to go to both the PL061 GPIO and the sysctl register.
|
277 | 26883c69 | Peter Maydell | * Note that the PL181 orders these lines (readonly,inserted)
|
278 | 26883c69 | Peter Maydell | * and the PL061 has them the other way about. Also the card
|
279 | 26883c69 | Peter Maydell | * detect line is inverted.
|
280 | 26883c69 | Peter Maydell | */
|
281 | 26883c69 | Peter Maydell | mmc_irq[0] = qemu_irq_split(
|
282 | 26883c69 | Peter Maydell | qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_WPROT), |
283 | 26883c69 | Peter Maydell | qdev_get_gpio_in(gpio2, 1));
|
284 | 26883c69 | Peter Maydell | mmc_irq[1] = qemu_irq_split(
|
285 | 26883c69 | Peter Maydell | qdev_get_gpio_in(sysctl, ARM_SYSCTL_GPIO_MMC_CARDIN), |
286 | 26883c69 | Peter Maydell | qemu_irq_invert(qdev_get_gpio_in(gpio2, 0)));
|
287 | 26883c69 | Peter Maydell | qdev_connect_gpio_out(dev, 0, mmc_irq[0]); |
288 | 26883c69 | Peter Maydell | qdev_connect_gpio_out(dev, 1, mmc_irq[1]); |
289 | a1bb27b1 | pbrook | |
290 | a63bdb31 | Paul Brook | sysbus_create_simple("pl031", 0x10017000, pic[10]); |
291 | 7e1543c2 | pbrook | |
292 | 0ef849d7 | Paul Brook | if (!is_pb) {
|
293 | 7d6e771f | Peter Maydell | dev = qdev_create(NULL, "realview_pci"); |
294 | 7d6e771f | Peter Maydell | busdev = sysbus_from_qdev(dev); |
295 | 7d6e771f | Peter Maydell | qdev_init_nofail(dev); |
296 | 7d6e771f | Peter Maydell | sysbus_mmio_map(busdev, 0, 0x61000000); /* PCI self-config */ |
297 | 7d6e771f | Peter Maydell | sysbus_mmio_map(busdev, 1, 0x62000000); /* PCI config */ |
298 | 7d6e771f | Peter Maydell | sysbus_mmio_map(busdev, 2, 0x63000000); /* PCI I/O */ |
299 | 7d6e771f | Peter Maydell | sysbus_connect_irq(busdev, 0, pic[48]); |
300 | 7d6e771f | Peter Maydell | sysbus_connect_irq(busdev, 1, pic[49]); |
301 | 7d6e771f | Peter Maydell | sysbus_connect_irq(busdev, 2, pic[50]); |
302 | 7d6e771f | Peter Maydell | sysbus_connect_irq(busdev, 3, pic[51]); |
303 | 0ef849d7 | Paul Brook | pci_bus = (PCIBus *)qdev_get_child_bus(dev, "pci");
|
304 | 0ef849d7 | Paul Brook | if (usb_enabled) {
|
305 | a67ba3b6 | Paul Brook | usb_ohci_init_pci(pci_bus, -1);
|
306 | 0ef849d7 | Paul Brook | } |
307 | 0ef849d7 | Paul Brook | n = drive_get_max_bus(IF_SCSI); |
308 | 0ef849d7 | Paul Brook | while (n >= 0) { |
309 | 0ef849d7 | Paul Brook | pci_create_simple(pci_bus, -1, "lsi53c895a"); |
310 | 0ef849d7 | Paul Brook | n--; |
311 | 0ef849d7 | Paul Brook | } |
312 | e69954b9 | pbrook | } |
313 | e69954b9 | pbrook | for(n = 0; n < nb_nics; n++) { |
314 | e69954b9 | pbrook | nd = &nd_table[n]; |
315 | 0ae18cee | aliguori | |
316 | e6b3c8ca | Peter Maydell | if (!done_nic && (!nd->model ||
|
317 | e6b3c8ca | Peter Maydell | strcmp(nd->model, is_pb ? "lan9118" : "smc91c111") == 0)) { |
318 | 0ef849d7 | Paul Brook | if (is_pb) {
|
319 | 0ef849d7 | Paul Brook | lan9118_init(nd, 0x4e000000, pic[28]); |
320 | 0ef849d7 | Paul Brook | } else {
|
321 | 0ef849d7 | Paul Brook | smc91c111_init(nd, 0x4e000000, pic[28]); |
322 | 0ef849d7 | Paul Brook | } |
323 | 0ef849d7 | Paul Brook | done_nic = 1;
|
324 | e69954b9 | pbrook | } else {
|
325 | 07caea31 | Markus Armbruster | pci_nic_init_nofail(nd, "rtl8139", NULL); |
326 | e69954b9 | pbrook | } |
327 | e69954b9 | pbrook | } |
328 | e69954b9 | pbrook | |
329 | eee48504 | Paul Brook | dev = sysbus_create_simple("realview_i2c", 0x10002000, NULL); |
330 | eee48504 | Paul Brook | i2c = (i2c_bus *)qdev_get_child_bus(dev, "i2c");
|
331 | eee48504 | Paul Brook | i2c_create_slave(i2c, "ds1338", 0x68); |
332 | eee48504 | Paul Brook | |
333 | e69954b9 | pbrook | /* Memory map for RealView Emulation Baseboard: */
|
334 | e69954b9 | pbrook | /* 0x10000000 System registers. */
|
335 | e69954b9 | pbrook | /* 0x10001000 System controller. */
|
336 | eee48504 | Paul Brook | /* 0x10002000 Two-Wire Serial Bus. */
|
337 | e69954b9 | pbrook | /* 0x10003000 Reserved. */
|
338 | e69954b9 | pbrook | /* 0x10004000 AACI. */
|
339 | e69954b9 | pbrook | /* 0x10005000 MCI. */
|
340 | e69954b9 | pbrook | /* 0x10006000 KMI0. */
|
341 | e69954b9 | pbrook | /* 0x10007000 KMI1. */
|
342 | 0ef849d7 | Paul Brook | /* 0x10008000 Character LCD. (EB) */
|
343 | e69954b9 | pbrook | /* 0x10009000 UART0. */
|
344 | e69954b9 | pbrook | /* 0x1000a000 UART1. */
|
345 | e69954b9 | pbrook | /* 0x1000b000 UART2. */
|
346 | e69954b9 | pbrook | /* 0x1000c000 UART3. */
|
347 | e69954b9 | pbrook | /* 0x1000d000 SSPI. */
|
348 | e69954b9 | pbrook | /* 0x1000e000 SCI. */
|
349 | e69954b9 | pbrook | /* 0x1000f000 Reserved. */
|
350 | e69954b9 | pbrook | /* 0x10010000 Watchdog. */
|
351 | e69954b9 | pbrook | /* 0x10011000 Timer 0+1. */
|
352 | e69954b9 | pbrook | /* 0x10012000 Timer 2+3. */
|
353 | e69954b9 | pbrook | /* 0x10013000 GPIO 0. */
|
354 | e69954b9 | pbrook | /* 0x10014000 GPIO 1. */
|
355 | e69954b9 | pbrook | /* 0x10015000 GPIO 2. */
|
356 | 0ef849d7 | Paul Brook | /* 0x10002000 Two-Wire Serial Bus - DVI. (PB) */
|
357 | 7e1543c2 | pbrook | /* 0x10017000 RTC. */
|
358 | e69954b9 | pbrook | /* 0x10018000 DMC. */
|
359 | e69954b9 | pbrook | /* 0x10019000 PCI controller config. */
|
360 | e69954b9 | pbrook | /* 0x10020000 CLCD. */
|
361 | e69954b9 | pbrook | /* 0x10030000 DMA Controller. */
|
362 | 0ef849d7 | Paul Brook | /* 0x10040000 GIC1. (EB) */
|
363 | 0ef849d7 | Paul Brook | /* 0x10050000 GIC2. (EB) */
|
364 | 0ef849d7 | Paul Brook | /* 0x10060000 GIC3. (EB) */
|
365 | 0ef849d7 | Paul Brook | /* 0x10070000 GIC4. (EB) */
|
366 | e69954b9 | pbrook | /* 0x10080000 SMC. */
|
367 | 0ef849d7 | Paul Brook | /* 0x1e000000 GIC1. (PB) */
|
368 | 0ef849d7 | Paul Brook | /* 0x1e001000 GIC2. (PB) */
|
369 | 0ef849d7 | Paul Brook | /* 0x1e002000 GIC3. (PB) */
|
370 | 0ef849d7 | Paul Brook | /* 0x1e003000 GIC4. (PB) */
|
371 | e69954b9 | pbrook | /* 0x40000000 NOR flash. */
|
372 | e69954b9 | pbrook | /* 0x44000000 DoC flash. */
|
373 | e69954b9 | pbrook | /* 0x48000000 SRAM. */
|
374 | e69954b9 | pbrook | /* 0x4c000000 Configuration flash. */
|
375 | e69954b9 | pbrook | /* 0x4e000000 Ethernet. */
|
376 | e69954b9 | pbrook | /* 0x4f000000 USB. */
|
377 | e69954b9 | pbrook | /* 0x50000000 PISMO. */
|
378 | e69954b9 | pbrook | /* 0x54000000 PISMO. */
|
379 | e69954b9 | pbrook | /* 0x58000000 PISMO. */
|
380 | e69954b9 | pbrook | /* 0x5c000000 PISMO. */
|
381 | e69954b9 | pbrook | /* 0x60000000 PCI. */
|
382 | e69954b9 | pbrook | /* 0x61000000 PCI Self Config. */
|
383 | e69954b9 | pbrook | /* 0x62000000 PCI Config. */
|
384 | e69954b9 | pbrook | /* 0x63000000 PCI IO. */
|
385 | e69954b9 | pbrook | /* 0x64000000 PCI mem 0. */
|
386 | e69954b9 | pbrook | /* 0x68000000 PCI mem 1. */
|
387 | e69954b9 | pbrook | /* 0x6c000000 PCI mem 2. */
|
388 | e69954b9 | pbrook | |
389 | 7ffab4d7 | pbrook | /* ??? Hack to map an additional page of ram for the secondary CPU
|
390 | 7ffab4d7 | pbrook | startup code. I guess this works on real hardware because the
|
391 | 7ffab4d7 | pbrook | BootROM happens to be in ROM/flash or in memory that isn't clobbered
|
392 | 7ffab4d7 | pbrook | until after Linux boots the secondary CPUs. */
|
393 | c5705a77 | Avi Kivity | memory_region_init_ram(ram_hack, "realview.hack", 0x1000); |
394 | c5705a77 | Avi Kivity | vmstate_register_ram_global(ram_hack); |
395 | 35e87820 | Avi Kivity | memory_region_add_subregion(sysmem, SMP_BOOT_ADDR, ram_hack); |
396 | 7ffab4d7 | pbrook | |
397 | f93eb9ff | balrog | realview_binfo.ram_size = ram_size; |
398 | f93eb9ff | balrog | realview_binfo.kernel_filename = kernel_filename; |
399 | f93eb9ff | balrog | realview_binfo.kernel_cmdline = kernel_cmdline; |
400 | f93eb9ff | balrog | realview_binfo.initrd_filename = initrd_filename; |
401 | c988bfad | Paul Brook | realview_binfo.nb_cpus = smp_cpus; |
402 | f7c70325 | Paul Brook | realview_binfo.board_id = realview_board_id[board_type]; |
403 | 21a88941 | Paul Brook | realview_binfo.loader_start = (board_type == BOARD_PB_A8 ? 0x70000000 : 0); |
404 | f93eb9ff | balrog | arm_load_kernel(first_cpu, &realview_binfo); |
405 | e69954b9 | pbrook | } |
406 | e69954b9 | pbrook | |
407 | c988bfad | Paul Brook | static void realview_eb_init(ram_addr_t ram_size, |
408 | c988bfad | Paul Brook | const char *boot_device, |
409 | c988bfad | Paul Brook | const char *kernel_filename, const char *kernel_cmdline, |
410 | c988bfad | Paul Brook | const char *initrd_filename, const char *cpu_model) |
411 | c988bfad | Paul Brook | { |
412 | c988bfad | Paul Brook | if (!cpu_model) {
|
413 | c988bfad | Paul Brook | cpu_model = "arm926";
|
414 | c988bfad | Paul Brook | } |
415 | c988bfad | Paul Brook | realview_init(ram_size, boot_device, kernel_filename, kernel_cmdline, |
416 | c988bfad | Paul Brook | initrd_filename, cpu_model, BOARD_EB); |
417 | c988bfad | Paul Brook | } |
418 | c988bfad | Paul Brook | |
419 | c988bfad | Paul Brook | static void realview_eb_mpcore_init(ram_addr_t ram_size, |
420 | c988bfad | Paul Brook | const char *boot_device, |
421 | c988bfad | Paul Brook | const char *kernel_filename, const char *kernel_cmdline, |
422 | c988bfad | Paul Brook | const char *initrd_filename, const char *cpu_model) |
423 | c988bfad | Paul Brook | { |
424 | c988bfad | Paul Brook | if (!cpu_model) {
|
425 | c988bfad | Paul Brook | cpu_model = "arm11mpcore";
|
426 | c988bfad | Paul Brook | } |
427 | c988bfad | Paul Brook | realview_init(ram_size, boot_device, kernel_filename, kernel_cmdline, |
428 | c988bfad | Paul Brook | initrd_filename, cpu_model, BOARD_EB_MPCORE); |
429 | c988bfad | Paul Brook | } |
430 | c988bfad | Paul Brook | |
431 | 0ef849d7 | Paul Brook | static void realview_pb_a8_init(ram_addr_t ram_size, |
432 | 0ef849d7 | Paul Brook | const char *boot_device, |
433 | 0ef849d7 | Paul Brook | const char *kernel_filename, const char *kernel_cmdline, |
434 | 0ef849d7 | Paul Brook | const char *initrd_filename, const char *cpu_model) |
435 | 0ef849d7 | Paul Brook | { |
436 | 0ef849d7 | Paul Brook | if (!cpu_model) {
|
437 | 0ef849d7 | Paul Brook | cpu_model = "cortex-a8";
|
438 | 0ef849d7 | Paul Brook | } |
439 | 0ef849d7 | Paul Brook | realview_init(ram_size, boot_device, kernel_filename, kernel_cmdline, |
440 | 0ef849d7 | Paul Brook | initrd_filename, cpu_model, BOARD_PB_A8); |
441 | 0ef849d7 | Paul Brook | } |
442 | 0ef849d7 | Paul Brook | |
443 | f7c70325 | Paul Brook | static void realview_pbx_a9_init(ram_addr_t ram_size, |
444 | f7c70325 | Paul Brook | const char *boot_device, |
445 | f7c70325 | Paul Brook | const char *kernel_filename, const char *kernel_cmdline, |
446 | f7c70325 | Paul Brook | const char *initrd_filename, const char *cpu_model) |
447 | f7c70325 | Paul Brook | { |
448 | f7c70325 | Paul Brook | if (!cpu_model) {
|
449 | f7c70325 | Paul Brook | cpu_model = "cortex-a9";
|
450 | f7c70325 | Paul Brook | } |
451 | f7c70325 | Paul Brook | realview_init(ram_size, boot_device, kernel_filename, kernel_cmdline, |
452 | f7c70325 | Paul Brook | initrd_filename, cpu_model, BOARD_PBX_A9); |
453 | f7c70325 | Paul Brook | } |
454 | f7c70325 | Paul Brook | |
455 | c988bfad | Paul Brook | static QEMUMachine realview_eb_machine = {
|
456 | c988bfad | Paul Brook | .name = "realview-eb",
|
457 | c9b1ae2c | blueswir1 | .desc = "ARM RealView Emulation Baseboard (ARM926EJ-S)",
|
458 | c988bfad | Paul Brook | .init = realview_eb_init, |
459 | c988bfad | Paul Brook | .use_scsi = 1,
|
460 | c988bfad | Paul Brook | }; |
461 | c988bfad | Paul Brook | |
462 | c988bfad | Paul Brook | static QEMUMachine realview_eb_mpcore_machine = {
|
463 | c988bfad | Paul Brook | .name = "realview-eb-mpcore",
|
464 | c988bfad | Paul Brook | .desc = "ARM RealView Emulation Baseboard (ARM11MPCore)",
|
465 | c988bfad | Paul Brook | .init = realview_eb_mpcore_init, |
466 | c9b1ae2c | blueswir1 | .use_scsi = 1,
|
467 | c988bfad | Paul Brook | .max_cpus = 4,
|
468 | e69954b9 | pbrook | }; |
469 | f80f9ec9 | Anthony Liguori | |
470 | 0ef849d7 | Paul Brook | static QEMUMachine realview_pb_a8_machine = {
|
471 | 0ef849d7 | Paul Brook | .name = "realview-pb-a8",
|
472 | 0ef849d7 | Paul Brook | .desc = "ARM RealView Platform Baseboard for Cortex-A8",
|
473 | 0ef849d7 | Paul Brook | .init = realview_pb_a8_init, |
474 | f7c70325 | Paul Brook | }; |
475 | f7c70325 | Paul Brook | |
476 | f7c70325 | Paul Brook | static QEMUMachine realview_pbx_a9_machine = {
|
477 | f7c70325 | Paul Brook | .name = "realview-pbx-a9",
|
478 | f7c70325 | Paul Brook | .desc = "ARM RealView Platform Baseboard Explore for Cortex-A9",
|
479 | f7c70325 | Paul Brook | .init = realview_pbx_a9_init, |
480 | 0ef849d7 | Paul Brook | .use_scsi = 1,
|
481 | f7c70325 | Paul Brook | .max_cpus = 4,
|
482 | 0ef849d7 | Paul Brook | }; |
483 | 0ef849d7 | Paul Brook | |
484 | f80f9ec9 | Anthony Liguori | static void realview_machine_init(void) |
485 | f80f9ec9 | Anthony Liguori | { |
486 | c988bfad | Paul Brook | qemu_register_machine(&realview_eb_machine); |
487 | c988bfad | Paul Brook | qemu_register_machine(&realview_eb_mpcore_machine); |
488 | 0ef849d7 | Paul Brook | qemu_register_machine(&realview_pb_a8_machine); |
489 | f7c70325 | Paul Brook | qemu_register_machine(&realview_pbx_a9_machine); |
490 | f80f9ec9 | Anthony Liguori | } |
491 | f80f9ec9 | Anthony Liguori | |
492 | f80f9ec9 | Anthony Liguori | machine_init(realview_machine_init); |
493 | eee48504 | Paul Brook | device_init(realview_register_devices) |