2009-05-20 22:16:11 +04: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.
|
|
|
|
*/
|
|
|
|
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/sysbus.h"
|
|
|
|
#include "hw/hw.h"
|
2012-10-24 10:43:34 +04:00
|
|
|
#include "net/net.h"
|
2013-02-05 20:06:20 +04:00
|
|
|
#include "hw/block/flash.h"
|
2012-12-17 21:20:04 +04:00
|
|
|
#include "sysemu/sysemu.h"
|
2013-04-09 18:26:55 +04:00
|
|
|
#include "hw/devices.h"
|
2013-02-04 18:40:22 +04:00
|
|
|
#include "hw/boards.h"
|
2014-10-07 15:59:13 +04:00
|
|
|
#include "sysemu/block-backend.h"
|
2012-12-17 21:19:49 +04:00
|
|
|
#include "exec/address-spaces.h"
|
2009-05-20 22:16:11 +04:00
|
|
|
|
2013-03-18 20:36:02 +04:00
|
|
|
#include "boot.h"
|
2011-08-22 12:15:25 +04:00
|
|
|
|
2009-05-20 22:16:11 +04:00
|
|
|
#define LMB_BRAM_SIZE (128 * 1024)
|
|
|
|
#define FLASH_SIZE (16 * 1024 * 1024)
|
|
|
|
|
|
|
|
#define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb"
|
2010-03-14 23:20:59 +03:00
|
|
|
|
2012-03-04 15:03:53 +04: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
|
|
|
|
|
2014-02-26 04:38:19 +04:00
|
|
|
#define TIMER_IRQ 0
|
|
|
|
#define ETHLITE_IRQ 1
|
|
|
|
#define UARTLITE_IRQ 3
|
|
|
|
|
2009-05-20 22:16:11 +04:00
|
|
|
static void
|
2014-05-07 18:42:57 +04:00
|
|
|
petalogix_s3adsp1800_init(MachineState *machine)
|
2009-05-20 22:16:11 +04:00
|
|
|
{
|
2014-05-07 18:42:57 +04:00
|
|
|
ram_addr_t ram_size = machine->ram_size;
|
2009-05-20 22:16:11 +04:00
|
|
|
DeviceState *dev;
|
2012-05-05 14:20:29 +04:00
|
|
|
MicroBlazeCPU *cpu;
|
2009-07-22 18:42:57 +04:00
|
|
|
DriveInfo *dinfo;
|
2009-05-20 22:16:11 +04:00
|
|
|
int i;
|
2012-10-23 14:30:10 +04:00
|
|
|
hwaddr ddr_base = MEMORY_BASEADDR;
|
2011-09-12 17:31:50 +04:00
|
|
|
MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
|
|
|
|
MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
|
2014-01-13 07:35:26 +04:00
|
|
|
qemu_irq irq[32];
|
2011-09-12 17:31:50 +04:00
|
|
|
MemoryRegion *sysmem = get_system_memory();
|
2009-05-20 22:16:11 +04:00
|
|
|
|
2015-05-25 06:31:40 +03:00
|
|
|
cpu = MICROBLAZE_CPU(object_new(TYPE_MICROBLAZE_CPU));
|
|
|
|
object_property_set_bool(OBJECT(cpu), true, "realized", &error_abort);
|
2009-05-20 22:16:11 +04:00
|
|
|
|
|
|
|
/* Attach emulated BRAM through the LMB. */
|
2013-06-06 13:41:28 +04:00
|
|
|
memory_region_init_ram(phys_lmb_bram, NULL,
|
2014-09-09 09:27:55 +04:00
|
|
|
"petalogix_s3adsp1800.lmb_bram", LMB_BRAM_SIZE,
|
|
|
|
&error_abort);
|
2011-12-20 17:59:12 +04:00
|
|
|
vmstate_register_ram_global(phys_lmb_bram);
|
2011-09-12 17:31:50 +04:00
|
|
|
memory_region_add_subregion(sysmem, 0x00000000, phys_lmb_bram);
|
2009-05-20 22:16:11 +04:00
|
|
|
|
2014-09-09 09:27:55 +04:00
|
|
|
memory_region_init_ram(phys_ram, NULL, "petalogix_s3adsp1800.ram",
|
|
|
|
ram_size, &error_abort);
|
2011-12-20 17:59:12 +04:00
|
|
|
vmstate_register_ram_global(phys_ram);
|
2011-09-12 17:31:50 +04:00
|
|
|
memory_region_add_subregion(sysmem, ddr_base, phys_ram);
|
2009-05-20 22:16:11 +04:00
|
|
|
|
2009-07-22 18:42:57 +04:00
|
|
|
dinfo = drive_get(IF_PFLASH, 0, 0);
|
2012-03-04 15:03:53 +04:00
|
|
|
pflash_cfi01_register(FLASH_BASEADDR,
|
2011-08-04 16:55:30 +04:00
|
|
|
NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE,
|
2014-10-07 15:59:18 +04:00
|
|
|
dinfo ? blk_by_legacy_dinfo(dinfo) : NULL,
|
2014-10-07 15:59:13 +04:00
|
|
|
(64 * 1024), FLASH_SIZE >> 16,
|
2011-08-25 23:39:18 +04:00
|
|
|
1, 0x89, 0x18, 0x0000, 0x0, 1);
|
2009-05-20 22:16:11 +04:00
|
|
|
|
2014-02-26 04:40:04 +04:00
|
|
|
dev = qdev_create(NULL, "xlnx.xps-intc");
|
|
|
|
qdev_prop_set_uint32(dev, "kind-of-intr",
|
|
|
|
1 << ETHLITE_IRQ | 1 << UARTLITE_IRQ);
|
|
|
|
qdev_init_nofail(dev);
|
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, INTC_BASEADDR);
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
|
|
|
|
qdev_get_gpio_in(DEVICE(cpu), MB_CPU_IRQ));
|
2009-05-20 22:16:11 +04:00
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
irq[i] = qdev_get_gpio_in(dev, i);
|
|
|
|
}
|
|
|
|
|
2014-02-26 04:38:19 +04:00
|
|
|
sysbus_create_simple("xlnx.xps-uartlite", UARTLITE_BASEADDR,
|
|
|
|
irq[UARTLITE_IRQ]);
|
2014-02-26 04:40:39 +04:00
|
|
|
|
2009-05-20 22:16:11 +04:00
|
|
|
/* 2 timers at irq 2 @ 62 Mhz. */
|
2014-02-26 04:40:39 +04:00
|
|
|
dev = qdev_create(NULL, "xlnx.xps-timer");
|
|
|
|
qdev_prop_set_uint32(dev, "one-timer-only", 0);
|
|
|
|
qdev_prop_set_uint32(dev, "clock-frequency", 62 * 1000000);
|
|
|
|
qdev_init_nofail(dev);
|
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, TIMER_BASEADDR);
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[TIMER_IRQ]);
|
|
|
|
|
2014-02-26 04:41:14 +04:00
|
|
|
qemu_check_nic_model(&nd_table[0], "xlnx.xps-ethernetlite");
|
|
|
|
dev = qdev_create(NULL, "xlnx.xps-ethernetlite");
|
|
|
|
qdev_set_nic_properties(dev, &nd_table[0]);
|
|
|
|
qdev_prop_set_uint32(dev, "tx-ping-pong", 0);
|
|
|
|
qdev_prop_set_uint32(dev, "rx-ping-pong", 0);
|
|
|
|
qdev_init_nofail(dev);
|
|
|
|
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, ETHLITE_BASEADDR);
|
|
|
|
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, irq[ETHLITE_IRQ]);
|
2009-05-20 22:16:11 +04:00
|
|
|
|
2012-05-05 14:30:53 +04:00
|
|
|
microblaze_load_kernel(cpu, ddr_base, ram_size,
|
2014-05-07 18:42:57 +04:00
|
|
|
machine->initrd_filename,
|
2013-05-05 13:06:37 +04:00
|
|
|
BINARY_DEVICE_TREE_FILE,
|
2015-06-19 07:16:48 +03:00
|
|
|
NULL);
|
2009-05-20 22:16:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static QEMUMachine petalogix_s3adsp1800_machine = {
|
|
|
|
.name = "petalogix-s3adsp1800",
|
2011-03-04 14:31:14 +03:00
|
|
|
.desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800",
|
2009-05-20 22:16:11 +04:00
|
|
|
.init = petalogix_s3adsp1800_init,
|
2013-01-08 11:06:30 +04:00
|
|
|
.is_default = 1,
|
2009-05-20 22:16:11 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static void petalogix_s3adsp1800_machine_init(void)
|
|
|
|
{
|
|
|
|
qemu_register_machine(&petalogix_s3adsp1800_machine);
|
|
|
|
}
|
|
|
|
|
|
|
|
machine_init(petalogix_s3adsp1800_machine_init);
|