2009-05-20 20:16:11 +02:00
|
|
|
/*
|
|
|
|
* Model of Petalogix linux reference design targeting Xilinx Spartan 3ADSP-1800
|
|
|
|
* boards.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2009 Edgar E. Iglesias.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "sysbus.h"
|
|
|
|
#include "hw.h"
|
|
|
|
#include "net.h"
|
|
|
|
#include "flash.h"
|
|
|
|
#include "sysemu.h"
|
|
|
|
#include "devices.h"
|
|
|
|
#include "boards.h"
|
|
|
|
#include "xilinx.h"
|
2010-08-24 17:22:24 +02:00
|
|
|
#include "blockdev.h"
|
2011-09-12 15:31:50 +02:00
|
|
|
#include "exec-memory.h"
|
2009-05-20 20:16:11 +02:00
|
|
|
|
2012-03-04 12:03:51 +01:00
|
|
|
#include "microblaze_boot.h"
|
2011-08-22 10:15:25 +02:00
|
|
|
#include "microblaze_pic_cpu.h"
|
|
|
|
|
2009-05-20 20:16:11 +02:00
|
|
|
#define LMB_BRAM_SIZE (128 * 1024)
|
|
|
|
#define FLASH_SIZE (16 * 1024 * 1024)
|
|
|
|
|
|
|
|
#define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb"
|
2010-03-14 21:20:59 +01:00
|
|
|
|
2012-03-04 12:03:53 +01:00
|
|
|
#define MEMORY_BASEADDR 0x90000000
|
|
|
|
#define FLASH_BASEADDR 0xa0000000
|
|
|
|
#define INTC_BASEADDR 0x81800000
|
|
|
|
#define TIMER_BASEADDR 0x83c00000
|
|
|
|
#define UARTLITE_BASEADDR 0x84000000
|
|
|
|
#define ETHLITE_BASEADDR 0x81000000
|
|
|
|
|
2012-03-14 01:38:23 +01:00
|
|
|
static void machine_cpu_reset(CPUMBState *env)
|
2012-03-04 12:03:52 +01:00
|
|
|
{
|
|
|
|
env->pvr.regs[10] = 0x0c000000; /* spartan 3a dsp family. */
|
|
|
|
}
|
|
|
|
|
2009-05-20 20:16:11 +02:00
|
|
|
static void
|
2009-10-01 23:12:16 +02:00
|
|
|
petalogix_s3adsp1800_init(ram_addr_t ram_size,
|
2009-05-20 20:16:11 +02:00
|
|
|
const char *boot_device,
|
|
|
|
const char *kernel_filename,
|
|
|
|
const char *kernel_cmdline,
|
|
|
|
const char *initrd_filename, const char *cpu_model)
|
|
|
|
{
|
|
|
|
DeviceState *dev;
|
2012-03-14 01:38:23 +01:00
|
|
|
CPUMBState *env;
|
2009-07-22 16:42:57 +02:00
|
|
|
DriveInfo *dinfo;
|
2009-05-20 20:16:11 +02:00
|
|
|
int i;
|
2012-03-04 12:03:53 +01:00
|
|
|
target_phys_addr_t ddr_base = MEMORY_BASEADDR;
|
2011-09-12 15:31:50 +02:00
|
|
|
MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
|
|
|
|
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
|
2009-05-20 20:16:11 +02:00
|
|
|
qemu_irq irq[32], *cpu_irq;
|
2011-09-12 15:31:50 +02:00
|
|
|
MemoryRegion *sysmem = get_system_memory();
|
2009-05-20 20:16:11 +02:00
|
|
|
|
|
|
|
/* init CPUs */
|
|
|
|
if (cpu_model == NULL) {
|
|
|
|
cpu_model = "microblaze";
|
|
|
|
}
|
|
|
|
env = cpu_init(cpu_model);
|
|
|
|
|
|
|
|
/* Attach emulated BRAM through the LMB. */
|
2011-12-20 14:59:12 +01:00
|
|
|
memory_region_init_ram(phys_lmb_bram,
|
2011-09-12 15:31:50 +02:00
|
|
|
"petalogix_s3adsp1800.lmb_bram", LMB_BRAM_SIZE);
|
2011-12-20 14:59:12 +01:00
|
|
|
vmstate_register_ram_global(phys_lmb_bram);
|
2011-09-12 15:31:50 +02:00
|
|
|
memory_region_add_subregion(sysmem, 0x00000000, phys_lmb_bram);
|
2009-05-20 20:16:11 +02:00
|
|
|
|
2011-12-20 14:59:12 +01:00
|
|
|
memory_region_init_ram(phys_ram, "petalogix_s3adsp1800.ram", ram_size);
|
|
|
|
vmstate_register_ram_global(phys_ram);
|
2011-09-12 15:31:50 +02:00
|
|
|
memory_region_add_subregion(sysmem, ddr_base, phys_ram);
|
2009-05-20 20:16:11 +02:00
|
|
|
|
2009-07-22 16:42:57 +02:00
|
|
|
dinfo = drive_get(IF_PFLASH, 0, 0);
|
2012-03-04 12:03:53 +01:00
|
|
|
pflash_cfi01_register(FLASH_BASEADDR,
|
2011-08-04 14:55:30 +02:00
|
|
|
NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE,
|
2009-07-22 16:42:57 +02:00
|
|
|
dinfo ? dinfo->bdrv : NULL, (64 * 1024),
|
2009-05-20 20:16:11 +02:00
|
|
|
FLASH_SIZE >> 16,
|
2011-08-25 21:39:18 +02:00
|
|
|
1, 0x89, 0x18, 0x0000, 0x0, 1);
|
2009-05-20 20:16:11 +02:00
|
|
|
|
|
|
|
cpu_irq = microblaze_pic_init_cpu(env);
|
2012-03-04 12:03:53 +01:00
|
|
|
dev = xilinx_intc_create(INTC_BASEADDR, cpu_irq[0], 2);
|
2009-05-20 20:16:11 +02:00
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
irq[i] = qdev_get_gpio_in(dev, i);
|
|
|
|
}
|
|
|
|
|
2012-03-04 12:03:53 +01:00
|
|
|
sysbus_create_simple("xilinx,uartlite", UARTLITE_BASEADDR, irq[3]);
|
2009-05-20 20:16:11 +02:00
|
|
|
/* 2 timers at irq 2 @ 62 Mhz. */
|
2012-03-04 12:03:53 +01:00
|
|
|
xilinx_timer_create(TIMER_BASEADDR, irq[0], 2, 62 * 1000000);
|
|
|
|
xilinx_ethlite_create(&nd_table[0], ETHLITE_BASEADDR, irq[1], 0, 0);
|
2009-05-20 20:16:11 +02:00
|
|
|
|
2012-03-04 12:03:51 +01:00
|
|
|
microblaze_load_kernel(env, ddr_base, ram_size,
|
2012-03-04 12:03:52 +01:00
|
|
|
BINARY_DEVICE_TREE_FILE, machine_cpu_reset);
|
2009-05-20 20:16:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static QEMUMachine petalogix_s3adsp1800_machine = {
|
|
|
|
.name = "petalogix-s3adsp1800",
|
2011-03-04 12:31:14 +01:00
|
|
|
.desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800",
|
2009-05-20 20:16:11 +02:00
|
|
|
.init = petalogix_s3adsp1800_init,
|
|
|
|
.is_default = 1
|
|
|
|
};
|
|
|
|
|
|
|
|
static void petalogix_s3adsp1800_machine_init(void)
|
|
|
|
{
|
|
|
|
qemu_register_machine(&petalogix_s3adsp1800_machine);
|
|
|
|
}
|
|
|
|
|
|
|
|
machine_init(petalogix_s3adsp1800_machine_init);
|