]> Git Repo - qemu.git/blame - hw/microblaze/petalogix_s3adsp1800_mmu.c
block: Eliminate DriveInfo member bdrv, use blk_by_legacy_dinfo()
[qemu.git] / hw / microblaze / petalogix_s3adsp1800_mmu.c
CommitLineData
6a8b1ae2
EI
1/*
2 * Model of Petalogix linux reference design targeting Xilinx Spartan 3ADSP-1800
3 * boards.
4 *
5 * Copyright (c) 2009 Edgar E. Iglesias.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 */
25
83c9f4ca
PB
26#include "hw/sysbus.h"
27#include "hw/hw.h"
1422e32d 28#include "net/net.h"
0d09e41a 29#include "hw/block/flash.h"
9c17d615 30#include "sysemu/sysemu.h"
bd2be150 31#include "hw/devices.h"
83c9f4ca 32#include "hw/boards.h"
fa1d36df 33#include "sysemu/block-backend.h"
9c17d615 34#include "sysemu/blockdev.h"
022c62cb 35#include "exec/address-spaces.h"
6a8b1ae2 36
47b43a1f 37#include "boot.h"
b861b741 38
6a8b1ae2
EI
39#define LMB_BRAM_SIZE (128 * 1024)
40#define FLASH_SIZE (16 * 1024 * 1024)
41
6a8b1ae2 42#define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb"
409dbce5 43
cba1fd36
PC
44#define MEMORY_BASEADDR 0x90000000
45#define FLASH_BASEADDR 0xa0000000
46#define INTC_BASEADDR 0x81800000
47#define TIMER_BASEADDR 0x83c00000
48#define UARTLITE_BASEADDR 0x84000000
49#define ETHLITE_BASEADDR 0x81000000
50
05a738c4
PC
51#define TIMER_IRQ 0
52#define ETHLITE_IRQ 1
53#define UARTLITE_IRQ 3
54
bf494367 55static void machine_cpu_reset(MicroBlazeCPU *cpu)
1f28fac8 56{
bf494367
AF
57 CPUMBState *env = &cpu->env;
58
1f28fac8
PC
59 env->pvr.regs[10] = 0x0c000000; /* spartan 3a dsp family. */
60}
61
6a8b1ae2 62static void
3ef96221 63petalogix_s3adsp1800_init(MachineState *machine)
6a8b1ae2 64{
3ef96221
MA
65 ram_addr_t ram_size = machine->ram_size;
66 const char *cpu_model = machine->cpu_model;
6a8b1ae2 67 DeviceState *dev;
3ed60733 68 MicroBlazeCPU *cpu;
751c6a17 69 DriveInfo *dinfo;
6a8b1ae2 70 int i;
a8170e5e 71 hwaddr ddr_base = MEMORY_BASEADDR;
589f0aad
AK
72 MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
73 MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
73c69456 74 qemu_irq irq[32];
589f0aad 75 MemoryRegion *sysmem = get_system_memory();
6a8b1ae2
EI
76
77 /* init CPUs */
78 if (cpu_model == NULL) {
79 cpu_model = "microblaze";
80 }
3ed60733 81 cpu = cpu_mb_init(cpu_model);
6a8b1ae2 82
6a8b1ae2 83 /* Attach emulated BRAM through the LMB. */
2c9b15ca 84 memory_region_init_ram(phys_lmb_bram, NULL,
49946538
HT
85 "petalogix_s3adsp1800.lmb_bram", LMB_BRAM_SIZE,
86 &error_abort);
c5705a77 87 vmstate_register_ram_global(phys_lmb_bram);
589f0aad 88 memory_region_add_subregion(sysmem, 0x00000000, phys_lmb_bram);
6a8b1ae2 89
49946538
HT
90 memory_region_init_ram(phys_ram, NULL, "petalogix_s3adsp1800.ram",
91 ram_size, &error_abort);
c5705a77 92 vmstate_register_ram_global(phys_ram);
589f0aad 93 memory_region_add_subregion(sysmem, ddr_base, phys_ram);
6a8b1ae2 94
751c6a17 95 dinfo = drive_get(IF_PFLASH, 0, 0);
cba1fd36 96 pflash_cfi01_register(FLASH_BASEADDR,
cfe5f011 97 NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE,
fa1d36df
MA
98 dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL,
99 (64 * 1024), FLASH_SIZE >> 16,
01e0451a 100 1, 0x89, 0x18, 0x0000, 0x0, 1);
6a8b1ae2 101
13c9bfbf
PC
102 dev = qdev_create(NULL, "xlnx.xps-intc");
103 qdev_prop_set_uint32(dev, "kind-of-intr",
104 1 << ETHLITE_IRQ | 1 << UARTLITE_IRQ);
105 qdev_init_nofail(dev);
106 sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR);
107 sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
108 qdev_get_gpio_in(DEVICE(cpu), MB_CPU_IRQ));
6a8b1ae2
EI
109 for (i = 0; i < 32; i++) {
110 irq[i] = qdev_get_gpio_in(dev, i);
111 }
112
05a738c4
PC
113 sysbus_create_simple("xlnx.xps-uartlite", UARTLITE_BASEADDR,
114 irq[UARTLITE_IRQ]);
29873712 115
6a8b1ae2 116 /* 2 timers at irq 2 @ 62 Mhz. */
29873712
PC
117 dev = qdev_create(NULL, "xlnx.xps-timer");
118 qdev_prop_set_uint32(dev, "one-timer-only", 0);
119 qdev_prop_set_uint32(dev, "clock-frequency", 62 * 1000000);
120 qdev_init_nofail(dev);
121 sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, TIMER_BASEADDR);
122 sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[TIMER_IRQ]);
123
b8d4e1c4
PC
124 qemu_check_nic_model(&nd_table[0], "xlnx.xps-ethernetlite");
125 dev = qdev_create(NULL, "xlnx.xps-ethernetlite");
126 qdev_set_nic_properties(dev, &nd_table[0]);
127 qdev_prop_set_uint32(dev, "tx-ping-pong", 0);
128 qdev_prop_set_uint32(dev, "rx-ping-pong", 0);
129 qdev_init_nofail(dev);
130 sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, ETHLITE_BASEADDR);
131 sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[ETHLITE_IRQ]);
6a8b1ae2 132
bf494367 133 microblaze_load_kernel(cpu, ddr_base, ram_size,
3ef96221 134 machine->initrd_filename,
ec426ff8
EI
135 BINARY_DEVICE_TREE_FILE,
136 machine_cpu_reset);
6a8b1ae2
EI
137}
138
139static QEMUMachine petalogix_s3adsp1800_machine = {
140 .name = "petalogix-s3adsp1800",
73ad9e62 141 .desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800",
6a8b1ae2 142 .init = petalogix_s3adsp1800_init,
e4ada29e 143 .is_default = 1,
6a8b1ae2
EI
144};
145
146static void petalogix_s3adsp1800_machine_init(void)
147{
148 qemu_register_machine(&petalogix_s3adsp1800_machine);
149}
150
151machine_init(petalogix_s3adsp1800_machine_init);
This page took 0.615169 seconds and 4 git commands to generate.