petalogix_s3adsp1800_mmu.c 4.3 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
/*
 * 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.
 */

26 27
#include "hw/sysbus.h"
#include "hw/hw.h"
P
Paolo Bonzini 已提交
28
#include "net/net.h"
P
Paolo Bonzini 已提交
29
#include "hw/block/flash.h"
30
#include "sysemu/sysemu.h"
31
#include "hw/devices.h"
32 33
#include "hw/boards.h"
#include "hw/xilinx.h"
34
#include "sysemu/blockdev.h"
35
#include "exec/address-spaces.h"
36

37 38
#include "boot.h"
#include "pic_cpu.h"
39

40 41 42 43
#define LMB_BRAM_SIZE  (128 * 1024)
#define FLASH_SIZE     (16 * 1024 * 1024)

#define BINARY_DEVICE_TREE_FILE "petalogix-s3adsp1800.dtb"
44

45 46 47 48 49 50 51
#define MEMORY_BASEADDR 0x90000000
#define FLASH_BASEADDR 0xa0000000
#define INTC_BASEADDR 0x81800000
#define TIMER_BASEADDR 0x83c00000
#define UARTLITE_BASEADDR 0x84000000
#define ETHLITE_BASEADDR 0x81000000

52
static void machine_cpu_reset(MicroBlazeCPU *cpu)
53
{
54 55
    CPUMBState *env = &cpu->env;

56 57 58
    env->pvr.regs[10] = 0x0c000000; /* spartan 3a dsp family.  */
}

59
static void
60
petalogix_s3adsp1800_init(QEMUMachineInitArgs *args)
61
{
62 63
    ram_addr_t ram_size = args->ram_size;
    const char *cpu_model = args->cpu_model;
64
    DeviceState *dev;
65
    MicroBlazeCPU *cpu;
66
    CPUMBState *env;
G
Gerd Hoffmann 已提交
67
    DriveInfo *dinfo;
68
    int i;
A
Avi Kivity 已提交
69
    hwaddr ddr_base = MEMORY_BASEADDR;
70 71
    MemoryRegion *phys_lmb_bram = g_new(MemoryRegion, 1);
    MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
72
    qemu_irq irq[32], *cpu_irq;
73
    MemoryRegion *sysmem = get_system_memory();
74 75 76 77 78

    /* init CPUs */
    if (cpu_model == NULL) {
        cpu_model = "microblaze";
    }
79 80
    cpu = cpu_mb_init(cpu_model);
    env = &cpu->env;
81 82

    /* Attach emulated BRAM through the LMB.  */
83
    memory_region_init_ram(phys_lmb_bram, NULL,
84
                           "petalogix_s3adsp1800.lmb_bram", LMB_BRAM_SIZE);
85
    vmstate_register_ram_global(phys_lmb_bram);
86
    memory_region_add_subregion(sysmem, 0x00000000, phys_lmb_bram);
87

88
    memory_region_init_ram(phys_ram, NULL, "petalogix_s3adsp1800.ram", ram_size);
89
    vmstate_register_ram_global(phys_ram);
90
    memory_region_add_subregion(sysmem, ddr_base, phys_ram);
91

G
Gerd Hoffmann 已提交
92
    dinfo = drive_get(IF_PFLASH, 0, 0);
93
    pflash_cfi01_register(FLASH_BASEADDR,
94
                          NULL, "petalogix_s3adsp1800.flash", FLASH_SIZE,
G
Gerd Hoffmann 已提交
95
                          dinfo ? dinfo->bdrv : NULL, (64 * 1024),
96
                          FLASH_SIZE >> 16,
97
                          1, 0x89, 0x18, 0x0000, 0x0, 1);
98 99

    cpu_irq = microblaze_pic_init_cpu(env);
100
    dev = xilinx_intc_create(INTC_BASEADDR, cpu_irq[0], 0xA);
101 102 103 104
    for (i = 0; i < 32; i++) {
        irq[i] = qdev_get_gpio_in(dev, i);
    }

105
    sysbus_create_simple("xlnx.xps-uartlite", UARTLITE_BASEADDR, irq[3]);
106
    /* 2 timers at irq 2 @ 62 Mhz.  */
107
    xilinx_timer_create(TIMER_BASEADDR, irq[0], 0, 62 * 1000000);
108
    xilinx_ethlite_create(&nd_table[0], ETHLITE_BASEADDR, irq[1], 0, 0);
109

110
    microblaze_load_kernel(cpu, ddr_base, ram_size,
111
                    BINARY_DEVICE_TREE_FILE, machine_cpu_reset);
112 113 114 115
}

static QEMUMachine petalogix_s3adsp1800_machine = {
    .name = "petalogix-s3adsp1800",
116
    .desc = "PetaLogix linux refdesign for xilinx Spartan 3ADSP1800",
117
    .init = petalogix_s3adsp1800_init,
118
    .is_default = 1,
119 120 121 122 123 124 125 126
};

static void petalogix_s3adsp1800_machine_init(void)
{
    qemu_register_machine(&petalogix_s3adsp1800_machine);
}

machine_init(petalogix_s3adsp1800_machine_init);