]>
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 | ||
26 | #include "sysbus.h" | |
27 | #include "hw.h" | |
28 | #include "net.h" | |
29 | #include "flash.h" | |
30 | #include "sysemu.h" | |
31 | #include "devices.h" | |
32 | #include "boards.h" | |
6a8b1ae2 | 33 | #include "xilinx.h" |
2446333c | 34 | #include "blockdev.h" |
589f0aad | 35 | #include "exec-memory.h" |
6a8b1ae2 | 36 | |
d94e7434 | 37 | #include "microblaze_boot.h" |
b861b741 PC |
38 | #include "microblaze_pic_cpu.h" |
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 | |
6a8b1ae2 | 45 | static void |
c227f099 | 46 | petalogix_s3adsp1800_init(ram_addr_t ram_size, |
6a8b1ae2 EI |
47 | const char *boot_device, |
48 | const char *kernel_filename, | |
49 | const char *kernel_cmdline, | |
50 | const char *initrd_filename, const char *cpu_model) | |
51 | { | |
52 | DeviceState *dev; | |
53 | CPUState *env; | |
751c6a17 | 54 | DriveInfo *dinfo; |
6a8b1ae2 | 55 | int i; |
c227f099 | 56 | target_phys_addr_t ddr_base = 0x90000000; |
589f0aad AK |
57 | MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1); |
58 | MemoryRegion *phys_ram = g_new(MemoryRegion, 1); | |
6a8b1ae2 | 59 | qemu_irq irq[32], *cpu_irq; |
589f0aad | 60 | MemoryRegion *sysmem = get_system_memory(); |
6a8b1ae2 EI |
61 | |
62 | /* init CPUs */ | |
63 | if (cpu_model == NULL) { | |
64 | cpu_model = "microblaze"; | |
65 | } | |
66 | env = cpu_init(cpu_model); | |
67 | ||
d94e7434 | 68 | /* FIXME: move to machine specfic cpu reset */ |
6a8b1ae2 | 69 | env->pvr.regs[10] = 0x0c000000; /* spartan 3a dsp family. */ |
6a8b1ae2 EI |
70 | |
71 | /* Attach emulated BRAM through the LMB. */ | |
c5705a77 | 72 | memory_region_init_ram(phys_lmb_bram, |
589f0aad | 73 | "petalogix_s3adsp1800.lmb_bram", LMB_BRAM_SIZE); |
c5705a77 | 74 | vmstate_register_ram_global(phys_lmb_bram); |
589f0aad | 75 | memory_region_add_subregion(sysmem, 0x00000000, phys_lmb_bram); |
6a8b1ae2 | 76 | |
c5705a77 AK |
77 | memory_region_init_ram(phys_ram, "petalogix_s3adsp1800.ram", ram_size); |
78 | vmstate_register_ram_global(phys_ram); | |
589f0aad | 79 | memory_region_add_subregion(sysmem, ddr_base, phys_ram); |
6a8b1ae2 | 80 | |
751c6a17 | 81 | dinfo = drive_get(IF_PFLASH, 0, 0); |
cfe5f011 AK |
82 | pflash_cfi01_register(0xa0000000, |
83 | NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE, | |
751c6a17 | 84 | dinfo ? dinfo->bdrv : NULL, (64 * 1024), |
6a8b1ae2 | 85 | FLASH_SIZE >> 16, |
01e0451a | 86 | 1, 0x89, 0x18, 0x0000, 0x0, 1); |
6a8b1ae2 EI |
87 | |
88 | cpu_irq = microblaze_pic_init_cpu(env); | |
89 | dev = xilinx_intc_create(0x81800000, cpu_irq[0], 2); | |
90 | for (i = 0; i < 32; i++) { | |
91 | irq[i] = qdev_get_gpio_in(dev, i); | |
92 | } | |
93 | ||
94 | sysbus_create_simple("xilinx,uartlite", 0x84000000, irq[3]); | |
95 | /* 2 timers at irq 2 @ 62 Mhz. */ | |
96 | xilinx_timer_create(0x83c00000, irq[0], 2, 62 * 1000000); | |
97 | xilinx_ethlite_create(&nd_table[0], 0x81000000, irq[1], 0, 0); | |
98 | ||
d94e7434 PC |
99 | microblaze_load_kernel(env, ddr_base, ram_size, |
100 | BINARY_DEVICE_TREE_FILE, NULL); | |
6a8b1ae2 EI |
101 | } |
102 | ||
103 | static QEMUMachine petalogix_s3adsp1800_machine = { | |
104 | .name = "petalogix-s3adsp1800", | |
73ad9e62 | 105 | .desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800", |
6a8b1ae2 EI |
106 | .init = petalogix_s3adsp1800_init, |
107 | .is_default = 1 | |
108 | }; | |
109 | ||
110 | static void petalogix_s3adsp1800_machine_init(void) | |
111 | { | |
112 | qemu_register_machine(&petalogix_s3adsp1800_machine); | |
113 | } | |
114 | ||
115 | machine_init(petalogix_s3adsp1800_machine_init); |