]>
Commit | Line | Data |
---|---|---|
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 PB |
32 | #include "hw/boards.h" |
33 | #include "hw/xilinx.h" | |
9c17d615 | 34 | #include "sysemu/blockdev.h" |
022c62cb | 35 | #include "exec/address-spaces.h" |
6a8b1ae2 | 36 | |
47b43a1f PB |
37 | #include "boot.h" |
38 | #include "pic_cpu.h" | |
b861b741 | 39 | |
6a8b1ae2 EI |
40 | #define LMB_BRAM_SIZE (128 * 1024) |
41 | #define FLASH_SIZE (16 * 1024 * 1024) | |
42 | ||
6a8b1ae2 | 43 | #define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb" |
409dbce5 | 44 | |
cba1fd36 PC |
45 | #define MEMORY_BASEADDR 0x90000000 |
46 | #define FLASH_BASEADDR 0xa0000000 | |
47 | #define INTC_BASEADDR 0x81800000 | |
48 | #define TIMER_BASEADDR 0x83c00000 | |
49 | #define UARTLITE_BASEADDR 0x84000000 | |
50 | #define ETHLITE_BASEADDR 0x81000000 | |
51 | ||
bf494367 | 52 | static void machine_cpu_reset(MicroBlazeCPU *cpu) |
1f28fac8 | 53 | { |
bf494367 AF |
54 | CPUMBState *env = &cpu->env; |
55 | ||
1f28fac8 PC |
56 | env->pvr.regs[10] = 0x0c000000; /* spartan 3a dsp family. */ |
57 | } | |
58 | ||
6a8b1ae2 | 59 | static void |
5f072e1f | 60 | petalogix_s3adsp1800_init(QEMUMachineInitArgs *args) |
6a8b1ae2 | 61 | { |
5f072e1f EH |
62 | ram_addr_t ram_size = args->ram_size; |
63 | const char *cpu_model = args->cpu_model; | |
6a8b1ae2 | 64 | DeviceState *dev; |
3ed60733 | 65 | MicroBlazeCPU *cpu; |
ee118507 | 66 | CPUMBState *env; |
751c6a17 | 67 | DriveInfo *dinfo; |
6a8b1ae2 | 68 | int i; |
a8170e5e | 69 | hwaddr ddr_base = MEMORY_BASEADDR; |
589f0aad AK |
70 | MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1); |
71 | MemoryRegion *phys_ram = g_new(MemoryRegion, 1); | |
6a8b1ae2 | 72 | qemu_irq irq[32], *cpu_irq; |
589f0aad | 73 | MemoryRegion *sysmem = get_system_memory(); |
6a8b1ae2 EI |
74 | |
75 | /* init CPUs */ | |
76 | if (cpu_model == NULL) { | |
77 | cpu_model = "microblaze"; | |
78 | } | |
3ed60733 AF |
79 | cpu = cpu_mb_init(cpu_model); |
80 | env = &cpu->env; | |
6a8b1ae2 | 81 | |
6a8b1ae2 | 82 | /* Attach emulated BRAM through the LMB. */ |
c5705a77 | 83 | memory_region_init_ram(phys_lmb_bram, |
589f0aad | 84 | "petalogix_s3adsp1800.lmb_bram", LMB_BRAM_SIZE); |
c5705a77 | 85 | vmstate_register_ram_global(phys_lmb_bram); |
589f0aad | 86 | memory_region_add_subregion(sysmem, 0x00000000, phys_lmb_bram); |
6a8b1ae2 | 87 | |
c5705a77 AK |
88 | memory_region_init_ram(phys_ram, "petalogix_s3adsp1800.ram", ram_size); |
89 | vmstate_register_ram_global(phys_ram); | |
589f0aad | 90 | memory_region_add_subregion(sysmem, ddr_base, phys_ram); |
6a8b1ae2 | 91 | |
751c6a17 | 92 | dinfo = drive_get(IF_PFLASH, 0, 0); |
cba1fd36 | 93 | pflash_cfi01_register(FLASH_BASEADDR, |
cfe5f011 | 94 | NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE, |
751c6a17 | 95 | dinfo ? dinfo->bdrv : NULL, (64 * 1024), |
6a8b1ae2 | 96 | FLASH_SIZE >> 16, |
01e0451a | 97 | 1, 0x89, 0x18, 0x0000, 0x0, 1); |
6a8b1ae2 EI |
98 | |
99 | cpu_irq = microblaze_pic_init_cpu(env); | |
cba1fd36 | 100 | dev = xilinx_intc_create(INTC_BASEADDR, cpu_irq[0], 2); |
6a8b1ae2 EI |
101 | for (i = 0; i < 32; i++) { |
102 | irq[i] = qdev_get_gpio_in(dev, i); | |
103 | } | |
104 | ||
23d6055e | 105 | sysbus_create_simple("xlnx.xps-uartlite", UARTLITE_BASEADDR, irq[3]); |
6a8b1ae2 | 106 | /* 2 timers at irq 2 @ 62 Mhz. */ |
abe098e4 | 107 | xilinx_timer_create(TIMER_BASEADDR, irq[0], 0, 62 * 1000000); |
cba1fd36 | 108 | xilinx_ethlite_create(&nd_table[0], ETHLITE_BASEADDR, irq[1], 0, 0); |
6a8b1ae2 | 109 | |
bf494367 | 110 | microblaze_load_kernel(cpu, ddr_base, ram_size, |
1f28fac8 | 111 | BINARY_DEVICE_TREE_FILE, machine_cpu_reset); |
6a8b1ae2 EI |
112 | } |
113 | ||
114 | static QEMUMachine petalogix_s3adsp1800_machine = { | |
115 | .name = "petalogix-s3adsp1800", | |
73ad9e62 | 116 | .desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800", |
6a8b1ae2 | 117 | .init = petalogix_s3adsp1800_init, |
e4ada29e AS |
118 | .is_default = 1, |
119 | DEFAULT_MACHINE_OPTIONS, | |
6a8b1ae2 EI |
120 | }; |
121 | ||
122 | static void petalogix_s3adsp1800_machine_init(void) | |
123 | { | |
124 | qemu_register_machine(&petalogix_s3adsp1800_machine); | |
125 | } | |
126 | ||
127 | machine_init(petalogix_s3adsp1800_machine_init); |