blob: 2cf68828ed9e3dddafbfe497e4abcb11cf59a341 [file] [log] [blame]
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +02001/*
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"
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020033#include "xilinx.h"
Blue Swirl24463332010-08-24 15:22:24 +000034#include "blockdev.h"
Avi Kivity589f0aa2011-09-12 16:31:50 +030035#include "exec-memory.h"
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020036
Peter A. G. Crosthwaited94e7432012-03-04 21:03:51 +100037#include "microblaze_boot.h"
Peter A. G. Crosthwaiteb861b742011-08-22 18:15:25 +100038#include "microblaze_pic_cpu.h"
39
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020040#define LMB_BRAM_SIZE (128 * 1024)
41#define FLASH_SIZE (16 * 1024 * 1024)
42
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020043#define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb"
Aurelien Jarno409dbce2010-03-14 21:20:59 +010044
Peter A. G. Crosthwaitecba1fd32012-03-04 21:03:53 +100045#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
Andreas Färberbf494362012-05-05 12:30:53 +020052static void machine_cpu_reset(MicroBlazeCPU *cpu)
Peter A. G. Crosthwaite1f28fac2012-03-04 21:03:52 +100053{
Andreas Färberbf494362012-05-05 12:30:53 +020054 CPUMBState *env = &cpu->env;
55
Peter A. G. Crosthwaite1f28fac2012-03-04 21:03:52 +100056 env->pvr.regs[10] = 0x0c000000; /* spartan 3a dsp family. */
57}
58
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020059static void
Anthony Liguoric227f092009-10-01 16:12:16 -050060petalogix_s3adsp1800_init(ram_addr_t ram_size,
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020061 const char *boot_device,
62 const char *kernel_filename,
63 const char *kernel_cmdline,
64 const char *initrd_filename, const char *cpu_model)
65{
66 DeviceState *dev;
Andreas Färber3ed60732012-05-05 12:20:29 +020067 MicroBlazeCPU *cpu;
Andreas Färberee118502012-03-14 01:38:23 +010068 CPUMBState *env;
Gerd Hoffmann751c6a12009-07-22 16:42:57 +020069 DriveInfo *dinfo;
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020070 int i;
Peter A. G. Crosthwaitecba1fd32012-03-04 21:03:53 +100071 target_phys_addr_t ddr_base = MEMORY_BASEADDR;
Avi Kivity589f0aa2011-09-12 16:31:50 +030072 MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
73 MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020074 qemu_irq irq[32], *cpu_irq;
Avi Kivity589f0aa2011-09-12 16:31:50 +030075 MemoryRegion *sysmem = get_system_memory();
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020076
77 /* init CPUs */
78 if (cpu_model == NULL) {
79 cpu_model = "microblaze";
80 }
Andreas Färber3ed60732012-05-05 12:20:29 +020081 cpu = cpu_mb_init(cpu_model);
82 env = &cpu->env;
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020083
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020084 /* Attach emulated BRAM through the LMB. */
Avi Kivityc5705a72011-12-20 15:59:12 +020085 memory_region_init_ram(phys_lmb_bram,
Avi Kivity589f0aa2011-09-12 16:31:50 +030086 "petalogix_s3adsp1800.lmb_bram", LMB_BRAM_SIZE);
Avi Kivityc5705a72011-12-20 15:59:12 +020087 vmstate_register_ram_global(phys_lmb_bram);
Avi Kivity589f0aa2011-09-12 16:31:50 +030088 memory_region_add_subregion(sysmem, 0x00000000, phys_lmb_bram);
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020089
Avi Kivityc5705a72011-12-20 15:59:12 +020090 memory_region_init_ram(phys_ram, "petalogix_s3adsp1800.ram", ram_size);
91 vmstate_register_ram_global(phys_ram);
Avi Kivity589f0aa2011-09-12 16:31:50 +030092 memory_region_add_subregion(sysmem, ddr_base, phys_ram);
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020093
Gerd Hoffmann751c6a12009-07-22 16:42:57 +020094 dinfo = drive_get(IF_PFLASH, 0, 0);
Peter A. G. Crosthwaitecba1fd32012-03-04 21:03:53 +100095 pflash_cfi01_register(FLASH_BASEADDR,
Avi Kivitycfe5f012011-08-04 15:55:30 +030096 NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE,
Gerd Hoffmann751c6a12009-07-22 16:42:57 +020097 dinfo ? dinfo->bdrv : NULL, (64 * 1024),
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +020098 FLASH_SIZE >> 16,
Anthony Liguori01e04512011-08-25 14:39:18 -050099 1, 0x89, 0x18, 0x0000, 0x0, 1);
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +0200100
101 cpu_irq = microblaze_pic_init_cpu(env);
Peter A. G. Crosthwaitecba1fd32012-03-04 21:03:53 +1000102 dev = xilinx_intc_create(INTC_BASEADDR, cpu_irq[0], 2);
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +0200103 for (i = 0; i < 32; i++) {
104 irq[i] = qdev_get_gpio_in(dev, i);
105 }
106
Peter A. G. Crosthwaite23d60552012-06-13 14:46:41 +1000107 sysbus_create_simple("xlnx.xps-uartlite", UARTLITE_BASEADDR, irq[3]);
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +0200108 /* 2 timers at irq 2 @ 62 Mhz. */
Peter A. G. Crosthwaiteabe098e2012-06-13 14:46:43 +1000109 xilinx_timer_create(TIMER_BASEADDR, irq[0], 0, 62 * 1000000);
Peter A. G. Crosthwaitecba1fd32012-03-04 21:03:53 +1000110 xilinx_ethlite_create(&nd_table[0], ETHLITE_BASEADDR, irq[1], 0, 0);
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +0200111
Andreas Färberbf494362012-05-05 12:30:53 +0200112 microblaze_load_kernel(cpu, ddr_base, ram_size,
Peter A. G. Crosthwaite1f28fac2012-03-04 21:03:52 +1000113 BINARY_DEVICE_TREE_FILE, machine_cpu_reset);
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +0200114}
115
116static QEMUMachine petalogix_s3adsp1800_machine = {
117 .name = "petalogix-s3adsp1800",
Michal Simek73ad9e62011-03-04 12:31:14 +0100118 .desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800",
Edgar E. Iglesias6a8b1ae2009-05-20 20:16:11 +0200119 .init = petalogix_s3adsp1800_init,
120 .is_default = 1
121};
122
123static void petalogix_s3adsp1800_machine_init(void)
124{
125 qemu_register_machine(&petalogix_s3adsp1800_machine);
126}
127
128machine_init(petalogix_s3adsp1800_machine_init);