root / hw / petalogix_s3adsp1800_mmu.c @ 43997225
History | View | Annotate | Download (4.3 kB)
1 | 6a8b1ae2 | Edgar E. Iglesias | /*
|
---|---|---|---|
2 | 6a8b1ae2 | Edgar E. Iglesias | * Model of Petalogix linux reference design targeting Xilinx Spartan 3ADSP-1800
|
3 | 6a8b1ae2 | Edgar E. Iglesias | * boards.
|
4 | 6a8b1ae2 | Edgar E. Iglesias | *
|
5 | 6a8b1ae2 | Edgar E. Iglesias | * Copyright (c) 2009 Edgar E. Iglesias.
|
6 | 6a8b1ae2 | Edgar E. Iglesias | *
|
7 | 6a8b1ae2 | Edgar E. Iglesias | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
8 | 6a8b1ae2 | Edgar E. Iglesias | * of this software and associated documentation files (the "Software"), to deal
|
9 | 6a8b1ae2 | Edgar E. Iglesias | * in the Software without restriction, including without limitation the rights
|
10 | 6a8b1ae2 | Edgar E. Iglesias | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11 | 6a8b1ae2 | Edgar E. Iglesias | * copies of the Software, and to permit persons to whom the Software is
|
12 | 6a8b1ae2 | Edgar E. Iglesias | * furnished to do so, subject to the following conditions:
|
13 | 6a8b1ae2 | Edgar E. Iglesias | *
|
14 | 6a8b1ae2 | Edgar E. Iglesias | * The above copyright notice and this permission notice shall be included in
|
15 | 6a8b1ae2 | Edgar E. Iglesias | * all copies or substantial portions of the Software.
|
16 | 6a8b1ae2 | Edgar E. Iglesias | *
|
17 | 6a8b1ae2 | Edgar E. Iglesias | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18 | 6a8b1ae2 | Edgar E. Iglesias | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19 | 6a8b1ae2 | Edgar E. Iglesias | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
20 | 6a8b1ae2 | Edgar E. Iglesias | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21 | 6a8b1ae2 | Edgar E. Iglesias | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22 | 6a8b1ae2 | Edgar E. Iglesias | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23 | 6a8b1ae2 | Edgar E. Iglesias | * THE SOFTWARE.
|
24 | 6a8b1ae2 | Edgar E. Iglesias | */
|
25 | 6a8b1ae2 | Edgar E. Iglesias | |
26 | 6a8b1ae2 | Edgar E. Iglesias | #include "sysbus.h" |
27 | 6a8b1ae2 | Edgar E. Iglesias | #include "hw.h" |
28 | 6a8b1ae2 | Edgar E. Iglesias | #include "net.h" |
29 | 6a8b1ae2 | Edgar E. Iglesias | #include "flash.h" |
30 | 6a8b1ae2 | Edgar E. Iglesias | #include "sysemu.h" |
31 | 6a8b1ae2 | Edgar E. Iglesias | #include "devices.h" |
32 | 6a8b1ae2 | Edgar E. Iglesias | #include "boards.h" |
33 | 6a8b1ae2 | Edgar E. Iglesias | #include "xilinx.h" |
34 | 2446333c | Blue Swirl | #include "blockdev.h" |
35 | 589f0aad | Avi Kivity | #include "exec-memory.h" |
36 | 6a8b1ae2 | Edgar E. Iglesias | |
37 | d94e7434 | Peter A. G. Crosthwaite | #include "microblaze_boot.h" |
38 | b861b741 | Peter A. G. Crosthwaite | #include "microblaze_pic_cpu.h" |
39 | b861b741 | Peter A. G. Crosthwaite | |
40 | 6a8b1ae2 | Edgar E. Iglesias | #define LMB_BRAM_SIZE (128 * 1024) |
41 | 6a8b1ae2 | Edgar E. Iglesias | #define FLASH_SIZE (16 * 1024 * 1024) |
42 | 6a8b1ae2 | Edgar E. Iglesias | |
43 | 6a8b1ae2 | Edgar E. Iglesias | #define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb" |
44 | 409dbce5 | Aurelien Jarno | |
45 | cba1fd36 | Peter A. G. Crosthwaite | #define MEMORY_BASEADDR 0x90000000 |
46 | cba1fd36 | Peter A. G. Crosthwaite | #define FLASH_BASEADDR 0xa0000000 |
47 | cba1fd36 | Peter A. G. Crosthwaite | #define INTC_BASEADDR 0x81800000 |
48 | cba1fd36 | Peter A. G. Crosthwaite | #define TIMER_BASEADDR 0x83c00000 |
49 | cba1fd36 | Peter A. G. Crosthwaite | #define UARTLITE_BASEADDR 0x84000000 |
50 | cba1fd36 | Peter A. G. Crosthwaite | #define ETHLITE_BASEADDR 0x81000000 |
51 | cba1fd36 | Peter A. G. Crosthwaite | |
52 | ee118507 | Andreas Färber | static void machine_cpu_reset(CPUMBState *env) |
53 | 1f28fac8 | Peter A. G. Crosthwaite | { |
54 | 1f28fac8 | Peter A. G. Crosthwaite | env->pvr.regs[10] = 0x0c000000; /* spartan 3a dsp family. */ |
55 | 1f28fac8 | Peter A. G. Crosthwaite | } |
56 | 1f28fac8 | Peter A. G. Crosthwaite | |
57 | 6a8b1ae2 | Edgar E. Iglesias | static void |
58 | c227f099 | Anthony Liguori | petalogix_s3adsp1800_init(ram_addr_t ram_size, |
59 | 6a8b1ae2 | Edgar E. Iglesias | const char *boot_device, |
60 | 6a8b1ae2 | Edgar E. Iglesias | const char *kernel_filename, |
61 | 6a8b1ae2 | Edgar E. Iglesias | const char *kernel_cmdline, |
62 | 6a8b1ae2 | Edgar E. Iglesias | const char *initrd_filename, const char *cpu_model) |
63 | 6a8b1ae2 | Edgar E. Iglesias | { |
64 | 6a8b1ae2 | Edgar E. Iglesias | DeviceState *dev; |
65 | ee118507 | Andreas Färber | CPUMBState *env; |
66 | 751c6a17 | Gerd Hoffmann | DriveInfo *dinfo; |
67 | 6a8b1ae2 | Edgar E. Iglesias | int i;
|
68 | cba1fd36 | Peter A. G. Crosthwaite | target_phys_addr_t ddr_base = MEMORY_BASEADDR; |
69 | 589f0aad | Avi Kivity | MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
|
70 | 589f0aad | Avi Kivity | MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
|
71 | 6a8b1ae2 | Edgar E. Iglesias | qemu_irq irq[32], *cpu_irq;
|
72 | 589f0aad | Avi Kivity | MemoryRegion *sysmem = get_system_memory(); |
73 | 6a8b1ae2 | Edgar E. Iglesias | |
74 | 6a8b1ae2 | Edgar E. Iglesias | /* init CPUs */
|
75 | 6a8b1ae2 | Edgar E. Iglesias | if (cpu_model == NULL) { |
76 | 6a8b1ae2 | Edgar E. Iglesias | cpu_model = "microblaze";
|
77 | 6a8b1ae2 | Edgar E. Iglesias | } |
78 | 6a8b1ae2 | Edgar E. Iglesias | env = cpu_init(cpu_model); |
79 | 6a8b1ae2 | Edgar E. Iglesias | |
80 | 6a8b1ae2 | Edgar E. Iglesias | /* Attach emulated BRAM through the LMB. */
|
81 | c5705a77 | Avi Kivity | memory_region_init_ram(phys_lmb_bram, |
82 | 589f0aad | Avi Kivity | "petalogix_s3adsp1800.lmb_bram", LMB_BRAM_SIZE);
|
83 | c5705a77 | Avi Kivity | vmstate_register_ram_global(phys_lmb_bram); |
84 | 589f0aad | Avi Kivity | memory_region_add_subregion(sysmem, 0x00000000, phys_lmb_bram);
|
85 | 6a8b1ae2 | Edgar E. Iglesias | |
86 | c5705a77 | Avi Kivity | memory_region_init_ram(phys_ram, "petalogix_s3adsp1800.ram", ram_size);
|
87 | c5705a77 | Avi Kivity | vmstate_register_ram_global(phys_ram); |
88 | 589f0aad | Avi Kivity | memory_region_add_subregion(sysmem, ddr_base, phys_ram); |
89 | 6a8b1ae2 | Edgar E. Iglesias | |
90 | 751c6a17 | Gerd Hoffmann | dinfo = drive_get(IF_PFLASH, 0, 0); |
91 | cba1fd36 | Peter A. G. Crosthwaite | pflash_cfi01_register(FLASH_BASEADDR, |
92 | cfe5f011 | Avi Kivity | NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE, |
93 | 751c6a17 | Gerd Hoffmann | dinfo ? dinfo->bdrv : NULL, (64 * 1024), |
94 | 6a8b1ae2 | Edgar E. Iglesias | FLASH_SIZE >> 16,
|
95 | 01e0451a | Anthony Liguori | 1, 0x89, 0x18, 0x0000, 0x0, 1); |
96 | 6a8b1ae2 | Edgar E. Iglesias | |
97 | 6a8b1ae2 | Edgar E. Iglesias | cpu_irq = microblaze_pic_init_cpu(env); |
98 | cba1fd36 | Peter A. G. Crosthwaite | dev = xilinx_intc_create(INTC_BASEADDR, cpu_irq[0], 2); |
99 | 6a8b1ae2 | Edgar E. Iglesias | for (i = 0; i < 32; i++) { |
100 | 6a8b1ae2 | Edgar E. Iglesias | irq[i] = qdev_get_gpio_in(dev, i); |
101 | 6a8b1ae2 | Edgar E. Iglesias | } |
102 | 6a8b1ae2 | Edgar E. Iglesias | |
103 | cba1fd36 | Peter A. G. Crosthwaite | sysbus_create_simple("xilinx,uartlite", UARTLITE_BASEADDR, irq[3]); |
104 | 6a8b1ae2 | Edgar E. Iglesias | /* 2 timers at irq 2 @ 62 Mhz. */
|
105 | cba1fd36 | Peter A. G. Crosthwaite | xilinx_timer_create(TIMER_BASEADDR, irq[0], 2, 62 * 1000000); |
106 | cba1fd36 | Peter A. G. Crosthwaite | xilinx_ethlite_create(&nd_table[0], ETHLITE_BASEADDR, irq[1], 0, 0); |
107 | 6a8b1ae2 | Edgar E. Iglesias | |
108 | d94e7434 | Peter A. G. Crosthwaite | microblaze_load_kernel(env, ddr_base, ram_size, |
109 | 1f28fac8 | Peter A. G. Crosthwaite | BINARY_DEVICE_TREE_FILE, machine_cpu_reset); |
110 | 6a8b1ae2 | Edgar E. Iglesias | } |
111 | 6a8b1ae2 | Edgar E. Iglesias | |
112 | 6a8b1ae2 | Edgar E. Iglesias | static QEMUMachine petalogix_s3adsp1800_machine = {
|
113 | 6a8b1ae2 | Edgar E. Iglesias | .name = "petalogix-s3adsp1800",
|
114 | 73ad9e62 | Michal Simek | .desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800",
|
115 | 6a8b1ae2 | Edgar E. Iglesias | .init = petalogix_s3adsp1800_init, |
116 | 6a8b1ae2 | Edgar E. Iglesias | .is_default = 1
|
117 | 6a8b1ae2 | Edgar E. Iglesias | }; |
118 | 6a8b1ae2 | Edgar E. Iglesias | |
119 | 6a8b1ae2 | Edgar E. Iglesias | static void petalogix_s3adsp1800_machine_init(void) |
120 | 6a8b1ae2 | Edgar E. Iglesias | { |
121 | 6a8b1ae2 | Edgar E. Iglesias | qemu_register_machine(&petalogix_s3adsp1800_machine); |
122 | 6a8b1ae2 | Edgar E. Iglesias | } |
123 | 6a8b1ae2 | Edgar E. Iglesias | |
124 | 6a8b1ae2 | Edgar E. Iglesias | machine_init(petalogix_s3adsp1800_machine_init); |