Statistics
| Branch: | Revision:

root / hw / mainstone.c @ 7bd427d8

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 ef056e43 balrog
 */
11 ef056e43 balrog
#include "hw.h"
12 ef056e43 balrog
#include "pxa.h"
13 ef056e43 balrog
#include "arm-misc.h"
14 ef056e43 balrog
#include "net.h"
15 ef056e43 balrog
#include "devices.h"
16 ef056e43 balrog
#include "boards.h"
17 7233b355 ths
#include "sysemu.h"
18 7233b355 ths
#include "flash.h"
19 2446333c Blue Swirl
#include "blockdev.h"
20 cb380f61 Dmitry Eremin-Solenikov
#include "sysbus.h"
21 ef056e43 balrog
22 459505a2 Dmitry Eremin-Solenikov
/* Device addresses */
23 459505a2 Dmitry Eremin-Solenikov
#define MST_FPGA_PHYS        0x08000000
24 459505a2 Dmitry Eremin-Solenikov
#define MST_ETH_PHYS        0x10000300
25 459505a2 Dmitry Eremin-Solenikov
#define MST_FLASH_0                0x00000000
26 459505a2 Dmitry Eremin-Solenikov
#define MST_FLASH_1                0x04000000
27 459505a2 Dmitry Eremin-Solenikov
28 459505a2 Dmitry Eremin-Solenikov
/* IRQ definitions */
29 459505a2 Dmitry Eremin-Solenikov
#define MMC_IRQ       0
30 459505a2 Dmitry Eremin-Solenikov
#define USIM_IRQ      1
31 459505a2 Dmitry Eremin-Solenikov
#define USBC_IRQ      2
32 459505a2 Dmitry Eremin-Solenikov
#define ETHERNET_IRQ  3
33 459505a2 Dmitry Eremin-Solenikov
#define AC97_IRQ      4
34 459505a2 Dmitry Eremin-Solenikov
#define PEN_IRQ       5
35 459505a2 Dmitry Eremin-Solenikov
#define MSINS_IRQ     6
36 459505a2 Dmitry Eremin-Solenikov
#define EXBRD_IRQ     7
37 459505a2 Dmitry Eremin-Solenikov
#define S0_CD_IRQ     9
38 459505a2 Dmitry Eremin-Solenikov
#define S0_STSCHG_IRQ 10
39 459505a2 Dmitry Eremin-Solenikov
#define S0_IRQ        11
40 459505a2 Dmitry Eremin-Solenikov
#define S1_CD_IRQ     13
41 459505a2 Dmitry Eremin-Solenikov
#define S1_STSCHG_IRQ 14
42 459505a2 Dmitry Eremin-Solenikov
#define S1_IRQ        15
43 459505a2 Dmitry Eremin-Solenikov
44 bd464c2e balrog
static struct keymap map[0xE0] = {
45 bd464c2e balrog
    [0 ... 0xDF] = { -1, -1 },
46 bd464c2e balrog
    [0x1e] = {0,0}, /* a */
47 bd464c2e balrog
    [0x30] = {0,1}, /* b */
48 bd464c2e balrog
    [0x2e] = {0,2}, /* c */
49 bd464c2e balrog
    [0x20] = {0,3}, /* d */
50 bd464c2e balrog
    [0x12] = {0,4}, /* e */
51 bd464c2e balrog
    [0x21] = {0,5}, /* f */
52 bd464c2e balrog
    [0x22] = {1,0}, /* g */
53 bd464c2e balrog
    [0x23] = {1,1}, /* h */
54 bd464c2e balrog
    [0x17] = {1,2}, /* i */
55 bd464c2e balrog
    [0x24] = {1,3}, /* j */
56 bd464c2e balrog
    [0x25] = {1,4}, /* k */
57 bd464c2e balrog
    [0x26] = {1,5}, /* l */
58 bd464c2e balrog
    [0x32] = {2,0}, /* m */
59 bd464c2e balrog
    [0x31] = {2,1}, /* n */
60 bd464c2e balrog
    [0x18] = {2,2}, /* o */
61 bd464c2e balrog
    [0x19] = {2,3}, /* p */
62 bd464c2e balrog
    [0x10] = {2,4}, /* q */
63 bd464c2e balrog
    [0x13] = {2,5}, /* r */
64 bd464c2e balrog
    [0x1f] = {3,0}, /* s */
65 bd464c2e balrog
    [0x14] = {3,1}, /* t */
66 bd464c2e balrog
    [0x16] = {3,2}, /* u */
67 bd464c2e balrog
    [0x2f] = {3,3}, /* v */
68 bd464c2e balrog
    [0x11] = {3,4}, /* w */
69 bd464c2e balrog
    [0x2d] = {3,5}, /* x */
70 bd464c2e balrog
    [0x15] = {4,2}, /* y */
71 bd464c2e balrog
    [0x2c] = {4,3}, /* z */
72 bd464c2e balrog
    [0xc7] = {5,0}, /* Home */
73 bd464c2e balrog
    [0x2a] = {5,1}, /* shift */
74 bd464c2e balrog
    [0x39] = {5,2}, /* space */
75 bd464c2e balrog
    [0x39] = {5,3}, /* space */
76 bd464c2e balrog
    [0x1c] = {5,5}, /*  enter */
77 bd464c2e balrog
    [0xc8] = {6,0}, /* up */
78 bd464c2e balrog
    [0xd0] = {6,1}, /* down */
79 bd464c2e balrog
    [0xcb] = {6,2}, /* left */
80 bd464c2e balrog
    [0xcd] = {6,3}, /* right */
81 bd464c2e balrog
};
82 bd464c2e balrog
83 ef056e43 balrog
enum mainstone_model_e { mainstone };
84 ef056e43 balrog
85 7fb4fdcf balrog
#define MAINSTONE_RAM        0x04000000
86 7fb4fdcf balrog
#define MAINSTONE_ROM        0x00800000
87 7fb4fdcf balrog
#define MAINSTONE_FLASH        0x02000000
88 7fb4fdcf balrog
89 f93eb9ff balrog
static struct arm_boot_info mainstone_binfo = {
90 f93eb9ff balrog
    .loader_start = PXA2XX_SDRAM_BASE,
91 f93eb9ff balrog
    .ram_size = 0x04000000,
92 f93eb9ff balrog
};
93 f93eb9ff balrog
94 c227f099 Anthony Liguori
static void mainstone_common_init(ram_addr_t ram_size,
95 3023f332 aliguori
                const char *kernel_filename,
96 ef056e43 balrog
                const char *kernel_cmdline, const char *initrd_filename,
97 ef056e43 balrog
                const char *cpu_model, enum mainstone_model_e model, int arm_id)
98 ef056e43 balrog
{
99 6d1f1778 balrog
    uint32_t sector_len = 256 * 1024;
100 c227f099 Anthony Liguori
    target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
101 bc24a225 Paul Brook
    PXA2xxState *cpu;
102 cb380f61 Dmitry Eremin-Solenikov
    DeviceState *mst_irq;
103 751c6a17 Gerd Hoffmann
    DriveInfo *dinfo;
104 751c6a17 Gerd Hoffmann
    int i;
105 3d08ff69 Blue Swirl
    int be;
106 ef056e43 balrog
107 ef056e43 balrog
    if (!cpu_model)
108 ef056e43 balrog
        cpu_model = "pxa270-c5";
109 ef056e43 balrog
110 ef056e43 balrog
    /* Setup CPU & memory */
111 3023f332 aliguori
    cpu = pxa270_init(mainstone_binfo.ram_size, cpu_model);
112 7fb4fdcf balrog
    cpu_register_physical_memory(0, MAINSTONE_ROM,
113 1724f049 Alex Williamson
                    qemu_ram_alloc(NULL, "mainstone.rom",
114 1724f049 Alex Williamson
                                   MAINSTONE_ROM) | IO_MEM_ROM);
115 ef056e43 balrog
116 3d08ff69 Blue Swirl
#ifdef TARGET_WORDS_BIGENDIAN
117 3d08ff69 Blue Swirl
    be = 1;
118 3d08ff69 Blue Swirl
#else
119 3d08ff69 Blue Swirl
    be = 0;
120 3d08ff69 Blue Swirl
#endif
121 e4bcb14c ths
    /* There are two 32MiB flash devices on the board */
122 6d1f1778 balrog
    for (i = 0; i < 2; i ++) {
123 751c6a17 Gerd Hoffmann
        dinfo = drive_get(IF_PFLASH, 0, i);
124 751c6a17 Gerd Hoffmann
        if (!dinfo) {
125 6d1f1778 balrog
            fprintf(stderr, "Two flash images must be given with the "
126 6d1f1778 balrog
                    "'pflash' parameter\n");
127 6d1f1778 balrog
            exit(1);
128 6d1f1778 balrog
        }
129 6d1f1778 balrog
130 6d1f1778 balrog
        if (!pflash_cfi01_register(mainstone_flash_base[i],
131 f75d216a Dmitry Eremin-Solenikov
                                   qemu_ram_alloc(NULL, i ? "mainstone.flash1" :
132 f75d216a Dmitry Eremin-Solenikov
                                                  "mainstone.flash0",
133 1724f049 Alex Williamson
                                                  MAINSTONE_FLASH),
134 3d08ff69 Blue Swirl
                                   dinfo->bdrv, sector_len,
135 3d08ff69 Blue Swirl
                                   MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0,
136 3d08ff69 Blue Swirl
                                   be)) {
137 6d1f1778 balrog
            fprintf(stderr, "qemu: Error registering flash memory.\n");
138 6d1f1778 balrog
            exit(1);
139 6d1f1778 balrog
        }
140 e4bcb14c ths
    }
141 7233b355 ths
142 cb380f61 Dmitry Eremin-Solenikov
    mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
143 95499a1d Dmitry Eremin-Solenikov
                    qdev_get_gpio_in(cpu->gpio, 0));
144 f1de1334 ths
145 bd464c2e balrog
    /* setup keypad */
146 bd464c2e balrog
    printf("map addr %p\n", &map);
147 bd464c2e balrog
    pxa27x_register_keypad(cpu->kp, map, 0xe0);
148 bd464c2e balrog
149 f1de1334 ths
    /* MMC/SD host */
150 cb380f61 Dmitry Eremin-Solenikov
    pxa2xx_mmci_handlers(cpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ));
151 f1de1334 ths
152 b651fc6f Dmitry Eremin-Solenikov
    pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[0],
153 b651fc6f Dmitry Eremin-Solenikov
            qdev_get_gpio_in(mst_irq, S0_IRQ),
154 b651fc6f Dmitry Eremin-Solenikov
            qdev_get_gpio_in(mst_irq, S0_CD_IRQ));
155 b651fc6f Dmitry Eremin-Solenikov
    pxa2xx_pcmcia_set_irq_cb(cpu->pcmcia[1],
156 b651fc6f Dmitry Eremin-Solenikov
            qdev_get_gpio_in(mst_irq, S1_IRQ),
157 b651fc6f Dmitry Eremin-Solenikov
            qdev_get_gpio_in(mst_irq, S1_CD_IRQ));
158 b651fc6f Dmitry Eremin-Solenikov
159 cb380f61 Dmitry Eremin-Solenikov
    smc91c111_init(&nd_table[0], MST_ETH_PHYS,
160 cb380f61 Dmitry Eremin-Solenikov
                    qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
161 ef056e43 balrog
162 f93eb9ff balrog
    mainstone_binfo.kernel_filename = kernel_filename;
163 f93eb9ff balrog
    mainstone_binfo.kernel_cmdline = kernel_cmdline;
164 f93eb9ff balrog
    mainstone_binfo.initrd_filename = initrd_filename;
165 f93eb9ff balrog
    mainstone_binfo.board_id = arm_id;
166 f93eb9ff balrog
    arm_load_kernel(cpu->env, &mainstone_binfo);
167 ef056e43 balrog
}
168 ef056e43 balrog
169 c227f099 Anthony Liguori
static void mainstone_init(ram_addr_t ram_size,
170 3023f332 aliguori
                const char *boot_device,
171 ef056e43 balrog
                const char *kernel_filename, const char *kernel_cmdline,
172 ef056e43 balrog
                const char *initrd_filename, const char *cpu_model)
173 ef056e43 balrog
{
174 fbe1b595 Paul Brook
    mainstone_common_init(ram_size, kernel_filename,
175 ef056e43 balrog
                kernel_cmdline, initrd_filename, cpu_model, 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 ef056e43 balrog
};
183 f80f9ec9 Anthony Liguori
184 f80f9ec9 Anthony Liguori
static void mainstone_machine_init(void)
185 f80f9ec9 Anthony Liguori
{
186 f80f9ec9 Anthony Liguori
    qemu_register_machine(&mainstone2_machine);
187 f80f9ec9 Anthony Liguori
}
188 f80f9ec9 Anthony Liguori
189 f80f9ec9 Anthony Liguori
machine_init(mainstone_machine_init);