Statistics
| Branch: | Revision:

root / hw / mainstone.c @ 83c9f4ca

History | View | Annotate | Download (5.6 kB)

1 ef056e43 balrog
/*
2 ef056e43 balrog
 * PXA270-based Intel Mainstone platforms.
3 ef056e43 balrog
 *
4 ef056e43 balrog
 * Copyright (c) 2007 by Armin Kuster <akuster@kama-aina.net> or
5 ef056e43 balrog
 *                                    <akuster@mvista.com>
6 ef056e43 balrog
 *
7 ef056e43 balrog
 * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org>
8 ef056e43 balrog
 *
9 ef056e43 balrog
 * This code is licensed under the GNU GPL v2.
10 6b620ca3 Paolo Bonzini
 *
11 6b620ca3 Paolo Bonzini
 * Contributions after 2012-01-13 are licensed under the terms of the
12 6b620ca3 Paolo Bonzini
 * GNU GPL, version 2 or (at your option) any later version.
13 ef056e43 balrog
 */
14 83c9f4ca Paolo Bonzini
#include "hw/hw.h"
15 83c9f4ca Paolo Bonzini
#include "hw/pxa.h"
16 83c9f4ca Paolo Bonzini
#include "hw/arm-misc.h"
17 1422e32d Paolo Bonzini
#include "net/net.h"
18 83c9f4ca Paolo Bonzini
#include "hw/devices.h"
19 83c9f4ca Paolo Bonzini
#include "hw/boards.h"
20 83c9f4ca Paolo Bonzini
#include "hw/flash.h"
21 9c17d615 Paolo Bonzini
#include "sysemu/blockdev.h"
22 83c9f4ca Paolo Bonzini
#include "hw/sysbus.h"
23 022c62cb Paolo Bonzini
#include "exec/address-spaces.h"
24 ef056e43 balrog
25 459505a2 Dmitry Eremin-Solenikov
/* Device addresses */
26 459505a2 Dmitry Eremin-Solenikov
#define MST_FPGA_PHYS        0x08000000
27 459505a2 Dmitry Eremin-Solenikov
#define MST_ETH_PHYS        0x10000300
28 459505a2 Dmitry Eremin-Solenikov
#define MST_FLASH_0                0x00000000
29 459505a2 Dmitry Eremin-Solenikov
#define MST_FLASH_1                0x04000000
30 459505a2 Dmitry Eremin-Solenikov
31 459505a2 Dmitry Eremin-Solenikov
/* IRQ definitions */
32 459505a2 Dmitry Eremin-Solenikov
#define MMC_IRQ       0
33 459505a2 Dmitry Eremin-Solenikov
#define USIM_IRQ      1
34 459505a2 Dmitry Eremin-Solenikov
#define USBC_IRQ      2
35 459505a2 Dmitry Eremin-Solenikov
#define ETHERNET_IRQ  3
36 459505a2 Dmitry Eremin-Solenikov
#define AC97_IRQ      4
37 459505a2 Dmitry Eremin-Solenikov
#define PEN_IRQ       5
38 459505a2 Dmitry Eremin-Solenikov
#define MSINS_IRQ     6
39 459505a2 Dmitry Eremin-Solenikov
#define EXBRD_IRQ     7
40 459505a2 Dmitry Eremin-Solenikov
#define S0_CD_IRQ     9
41 459505a2 Dmitry Eremin-Solenikov
#define S0_STSCHG_IRQ 10
42 459505a2 Dmitry Eremin-Solenikov
#define S0_IRQ        11
43 459505a2 Dmitry Eremin-Solenikov
#define S1_CD_IRQ     13
44 459505a2 Dmitry Eremin-Solenikov
#define S1_STSCHG_IRQ 14
45 459505a2 Dmitry Eremin-Solenikov
#define S1_IRQ        15
46 459505a2 Dmitry Eremin-Solenikov
47 bd464c2e balrog
static struct keymap map[0xE0] = {
48 bd464c2e balrog
    [0 ... 0xDF] = { -1, -1 },
49 bd464c2e balrog
    [0x1e] = {0,0}, /* a */
50 bd464c2e balrog
    [0x30] = {0,1}, /* b */
51 bd464c2e balrog
    [0x2e] = {0,2}, /* c */
52 bd464c2e balrog
    [0x20] = {0,3}, /* d */
53 bd464c2e balrog
    [0x12] = {0,4}, /* e */
54 bd464c2e balrog
    [0x21] = {0,5}, /* f */
55 bd464c2e balrog
    [0x22] = {1,0}, /* g */
56 bd464c2e balrog
    [0x23] = {1,1}, /* h */
57 bd464c2e balrog
    [0x17] = {1,2}, /* i */
58 bd464c2e balrog
    [0x24] = {1,3}, /* j */
59 bd464c2e balrog
    [0x25] = {1,4}, /* k */
60 bd464c2e balrog
    [0x26] = {1,5}, /* l */
61 bd464c2e balrog
    [0x32] = {2,0}, /* m */
62 bd464c2e balrog
    [0x31] = {2,1}, /* n */
63 bd464c2e balrog
    [0x18] = {2,2}, /* o */
64 bd464c2e balrog
    [0x19] = {2,3}, /* p */
65 bd464c2e balrog
    [0x10] = {2,4}, /* q */
66 bd464c2e balrog
    [0x13] = {2,5}, /* r */
67 bd464c2e balrog
    [0x1f] = {3,0}, /* s */
68 bd464c2e balrog
    [0x14] = {3,1}, /* t */
69 bd464c2e balrog
    [0x16] = {3,2}, /* u */
70 bd464c2e balrog
    [0x2f] = {3,3}, /* v */
71 bd464c2e balrog
    [0x11] = {3,4}, /* w */
72 bd464c2e balrog
    [0x2d] = {3,5}, /* x */
73 bd464c2e balrog
    [0x15] = {4,2}, /* y */
74 bd464c2e balrog
    [0x2c] = {4,3}, /* z */
75 bd464c2e balrog
    [0xc7] = {5,0}, /* Home */
76 bd464c2e balrog
    [0x2a] = {5,1}, /* shift */
77 bd464c2e balrog
    [0x39] = {5,2}, /* space */
78 bd464c2e balrog
    [0x39] = {5,3}, /* space */
79 bd464c2e balrog
    [0x1c] = {5,5}, /*  enter */
80 bd464c2e balrog
    [0xc8] = {6,0}, /* up */
81 bd464c2e balrog
    [0xd0] = {6,1}, /* down */
82 bd464c2e balrog
    [0xcb] = {6,2}, /* left */
83 bd464c2e balrog
    [0xcd] = {6,3}, /* right */
84 bd464c2e balrog
};
85 bd464c2e balrog
86 ef056e43 balrog
enum mainstone_model_e { mainstone };
87 ef056e43 balrog
88 7fb4fdcf balrog
#define MAINSTONE_RAM        0x04000000
89 7fb4fdcf balrog
#define MAINSTONE_ROM        0x00800000
90 7fb4fdcf balrog
#define MAINSTONE_FLASH        0x02000000
91 7fb4fdcf balrog
92 f93eb9ff balrog
static struct arm_boot_info mainstone_binfo = {
93 f93eb9ff balrog
    .loader_start = PXA2XX_SDRAM_BASE,
94 f93eb9ff balrog
    .ram_size = 0x04000000,
95 f93eb9ff balrog
};
96 f93eb9ff balrog
97 02e5c167 Avi Kivity
static void mainstone_common_init(MemoryRegion *address_space_mem,
98 6efa6d50 Peter Maydell
                                  QEMUMachineInitArgs *args,
99 6efa6d50 Peter Maydell
                                  enum mainstone_model_e model, int arm_id)
100 ef056e43 balrog
{
101 6d1f1778 balrog
    uint32_t sector_len = 256 * 1024;
102 a8170e5e Avi Kivity
    hwaddr mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
103 1c88de67 Andreas Färber
    PXA2xxState *mpu;
104 cb380f61 Dmitry Eremin-Solenikov
    DeviceState *mst_irq;
105 751c6a17 Gerd Hoffmann
    DriveInfo *dinfo;
106 751c6a17 Gerd Hoffmann
    int i;
107 01e0451a Anthony Liguori
    int be;
108 02e5c167 Avi Kivity
    MemoryRegion *rom = g_new(MemoryRegion, 1);
109 6efa6d50 Peter Maydell
    const char *cpu_model = args->cpu_model;
110 ef056e43 balrog
111 ef056e43 balrog
    if (!cpu_model)
112 ef056e43 balrog
        cpu_model = "pxa270-c5";
113 ef056e43 balrog
114 ef056e43 balrog
    /* Setup CPU & memory */
115 1c88de67 Andreas Färber
    mpu = pxa270_init(address_space_mem, mainstone_binfo.ram_size, cpu_model);
116 c5705a77 Avi Kivity
    memory_region_init_ram(rom, "mainstone.rom", MAINSTONE_ROM);
117 c5705a77 Avi Kivity
    vmstate_register_ram_global(rom);
118 02e5c167 Avi Kivity
    memory_region_set_readonly(rom, true);
119 02e5c167 Avi Kivity
    memory_region_add_subregion(address_space_mem, 0, rom);
120 ef056e43 balrog
121 3d08ff69 Blue Swirl
#ifdef TARGET_WORDS_BIGENDIAN
122 01e0451a Anthony Liguori
    be = 1;
123 3d08ff69 Blue Swirl
#else
124 01e0451a Anthony Liguori
    be = 0;
125 3d08ff69 Blue Swirl
#endif
126 e4bcb14c ths
    /* There are two 32MiB flash devices on the board */
127 6d1f1778 balrog
    for (i = 0; i < 2; i ++) {
128 751c6a17 Gerd Hoffmann
        dinfo = drive_get(IF_PFLASH, 0, i);
129 751c6a17 Gerd Hoffmann
        if (!dinfo) {
130 6d1f1778 balrog
            fprintf(stderr, "Two flash images must be given with the "
131 6d1f1778 balrog
                    "'pflash' parameter\n");
132 6d1f1778 balrog
            exit(1);
133 6d1f1778 balrog
        }
134 6d1f1778 balrog
135 cfe5f011 Avi Kivity
        if (!pflash_cfi01_register(mainstone_flash_base[i], NULL,
136 cfe5f011 Avi Kivity
                                   i ? "mainstone.flash1" : "mainstone.flash0",
137 cfe5f011 Avi Kivity
                                   MAINSTONE_FLASH,
138 01e0451a Anthony Liguori
                                   dinfo->bdrv, sector_len,
139 01e0451a Anthony Liguori
                                   MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0,
140 01e0451a Anthony Liguori
                                   be)) {
141 6d1f1778 balrog
            fprintf(stderr, "qemu: Error registering flash memory.\n");
142 6d1f1778 balrog
            exit(1);
143 6d1f1778 balrog
        }
144 e4bcb14c ths
    }
145 7233b355 ths
146 cb380f61 Dmitry Eremin-Solenikov
    mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
147 1c88de67 Andreas Färber
                    qdev_get_gpio_in(mpu->gpio, 0));
148 f1de1334 ths
149 bd464c2e balrog
    /* setup keypad */
150 bd464c2e balrog
    printf("map addr %p\n", &map);
151 1c88de67 Andreas Färber
    pxa27x_register_keypad(mpu->kp, map, 0xe0);
152 bd464c2e balrog
153 f1de1334 ths
    /* MMC/SD host */
154 1c88de67 Andreas Färber
    pxa2xx_mmci_handlers(mpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ));
155 f1de1334 ths
156 1c88de67 Andreas Färber
    pxa2xx_pcmcia_set_irq_cb(mpu->pcmcia[0],
157 b651fc6f Dmitry Eremin-Solenikov
            qdev_get_gpio_in(mst_irq, S0_IRQ),
158 b651fc6f Dmitry Eremin-Solenikov
            qdev_get_gpio_in(mst_irq, S0_CD_IRQ));
159 1c88de67 Andreas Färber
    pxa2xx_pcmcia_set_irq_cb(mpu->pcmcia[1],
160 b651fc6f Dmitry Eremin-Solenikov
            qdev_get_gpio_in(mst_irq, S1_IRQ),
161 b651fc6f Dmitry Eremin-Solenikov
            qdev_get_gpio_in(mst_irq, S1_CD_IRQ));
162 b651fc6f Dmitry Eremin-Solenikov
163 cb380f61 Dmitry Eremin-Solenikov
    smc91c111_init(&nd_table[0], MST_ETH_PHYS,
164 cb380f61 Dmitry Eremin-Solenikov
                    qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
165 ef056e43 balrog
166 6efa6d50 Peter Maydell
    mainstone_binfo.kernel_filename = args->kernel_filename;
167 6efa6d50 Peter Maydell
    mainstone_binfo.kernel_cmdline = args->kernel_cmdline;
168 6efa6d50 Peter Maydell
    mainstone_binfo.initrd_filename = args->initrd_filename;
169 f93eb9ff balrog
    mainstone_binfo.board_id = arm_id;
170 3aaa8dfa Andreas Färber
    arm_load_kernel(mpu->cpu, &mainstone_binfo);
171 ef056e43 balrog
}
172 ef056e43 balrog
173 5f072e1f Eduardo Habkost
static void mainstone_init(QEMUMachineInitArgs *args)
174 ef056e43 balrog
{
175 6efa6d50 Peter Maydell
    mainstone_common_init(get_system_memory(), args, mainstone, 0x196);
176 ef056e43 balrog
}
177 ef056e43 balrog
178 f80f9ec9 Anthony Liguori
static QEMUMachine mainstone2_machine = {
179 4b32e168 aliguori
    .name = "mainstone",
180 4b32e168 aliguori
    .desc = "Mainstone II (PXA27x)",
181 4b32e168 aliguori
    .init = mainstone_init,
182 e4ada29e Avik Sil
    DEFAULT_MACHINE_OPTIONS,
183 ef056e43 balrog
};
184 f80f9ec9 Anthony Liguori
185 f80f9ec9 Anthony Liguori
static void mainstone_machine_init(void)
186 f80f9ec9 Anthony Liguori
{
187 f80f9ec9 Anthony Liguori
    qemu_register_machine(&mainstone2_machine);
188 f80f9ec9 Anthony Liguori
}
189 f80f9ec9 Anthony Liguori
190 f80f9ec9 Anthony Liguori
machine_init(mainstone_machine_init);