Statistics
| Branch: | Revision:

root / hw / mainstone.c @ 85e3023e

History | View | Annotate | Download (4.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 "mainstone.h"
18 7233b355 ths
#include "sysemu.h"
19 7233b355 ths
#include "flash.h"
20 ef056e43 balrog
21 bd464c2e balrog
static struct keymap map[0xE0] = {
22 bd464c2e balrog
    [0 ... 0xDF] = { -1, -1 },
23 bd464c2e balrog
    [0x1e] = {0,0}, /* a */
24 bd464c2e balrog
    [0x30] = {0,1}, /* b */
25 bd464c2e balrog
    [0x2e] = {0,2}, /* c */
26 bd464c2e balrog
    [0x20] = {0,3}, /* d */
27 bd464c2e balrog
    [0x12] = {0,4}, /* e */
28 bd464c2e balrog
    [0x21] = {0,5}, /* f */
29 bd464c2e balrog
    [0x22] = {1,0}, /* g */
30 bd464c2e balrog
    [0x23] = {1,1}, /* h */
31 bd464c2e balrog
    [0x17] = {1,2}, /* i */
32 bd464c2e balrog
    [0x24] = {1,3}, /* j */
33 bd464c2e balrog
    [0x25] = {1,4}, /* k */
34 bd464c2e balrog
    [0x26] = {1,5}, /* l */
35 bd464c2e balrog
    [0x32] = {2,0}, /* m */
36 bd464c2e balrog
    [0x31] = {2,1}, /* n */
37 bd464c2e balrog
    [0x18] = {2,2}, /* o */
38 bd464c2e balrog
    [0x19] = {2,3}, /* p */
39 bd464c2e balrog
    [0x10] = {2,4}, /* q */
40 bd464c2e balrog
    [0x13] = {2,5}, /* r */
41 bd464c2e balrog
    [0x1f] = {3,0}, /* s */
42 bd464c2e balrog
    [0x14] = {3,1}, /* t */
43 bd464c2e balrog
    [0x16] = {3,2}, /* u */
44 bd464c2e balrog
    [0x2f] = {3,3}, /* v */
45 bd464c2e balrog
    [0x11] = {3,4}, /* w */
46 bd464c2e balrog
    [0x2d] = {3,5}, /* x */
47 bd464c2e balrog
    [0x15] = {4,2}, /* y */
48 bd464c2e balrog
    [0x2c] = {4,3}, /* z */
49 bd464c2e balrog
    [0xc7] = {5,0}, /* Home */
50 bd464c2e balrog
    [0x2a] = {5,1}, /* shift */
51 bd464c2e balrog
    [0x39] = {5,2}, /* space */
52 bd464c2e balrog
    [0x39] = {5,3}, /* space */
53 bd464c2e balrog
    [0x1c] = {5,5}, /*  enter */
54 bd464c2e balrog
    [0xc8] = {6,0}, /* up */
55 bd464c2e balrog
    [0xd0] = {6,1}, /* down */
56 bd464c2e balrog
    [0xcb] = {6,2}, /* left */
57 bd464c2e balrog
    [0xcd] = {6,3}, /* right */
58 bd464c2e balrog
};
59 bd464c2e balrog
60 ef056e43 balrog
enum mainstone_model_e { mainstone };
61 ef056e43 balrog
62 ef056e43 balrog
static void mainstone_common_init(int ram_size, int vga_ram_size,
63 ef056e43 balrog
                DisplayState *ds, const char *kernel_filename,
64 ef056e43 balrog
                const char *kernel_cmdline, const char *initrd_filename,
65 ef056e43 balrog
                const char *cpu_model, enum mainstone_model_e model, int arm_id)
66 ef056e43 balrog
{
67 ef056e43 balrog
    uint32_t mainstone_ram = 0x04000000;
68 ef056e43 balrog
    uint32_t mainstone_rom = 0x00800000;
69 ef056e43 balrog
    struct pxa2xx_state_s *cpu;
70 ef056e43 balrog
    qemu_irq *mst_irq;
71 e4bcb14c ths
    int index;
72 ef056e43 balrog
73 ef056e43 balrog
    if (!cpu_model)
74 ef056e43 balrog
        cpu_model = "pxa270-c5";
75 ef056e43 balrog
76 ef056e43 balrog
    /* Setup CPU & memory */
77 ef056e43 balrog
    if (ram_size < mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE) {
78 ef056e43 balrog
        fprintf(stderr, "This platform requires %i bytes of memory\n",
79 ef056e43 balrog
                        mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE);
80 ef056e43 balrog
        exit(1);
81 ef056e43 balrog
    }
82 ef056e43 balrog
83 ef056e43 balrog
    cpu = pxa270_init(mainstone_ram, ds, cpu_model);
84 ef056e43 balrog
    cpu_register_physical_memory(0, mainstone_rom,
85 ef056e43 balrog
                    qemu_ram_alloc(mainstone_rom) | IO_MEM_ROM);
86 ef056e43 balrog
87 ef056e43 balrog
    /* Setup initial (reset) machine state */
88 ef056e43 balrog
    cpu->env->regs[15] = PXA2XX_SDRAM_BASE;
89 ef056e43 balrog
90 e4bcb14c ths
    /* There are two 32MiB flash devices on the board */
91 e4bcb14c ths
    index = drive_get_index(IF_PFLASH, 0, 0);
92 e4bcb14c ths
    if (index == -1) {
93 e4bcb14c ths
        fprintf(stderr, "Two flash images must be given with the "
94 e4bcb14c ths
                "'pflash' parameter\n");
95 e4bcb14c ths
        exit(1);
96 e4bcb14c ths
    }
97 88eeee0a balrog
    if (!pflash_cfi01_register(MST_FLASH_0,
98 88eeee0a balrog
                         mainstone_ram + PXA2XX_INTERNAL_SIZE,
99 e4bcb14c ths
                         drives_table[index].bdrv,
100 e4bcb14c ths
                         256 * 1024, 128, 4, 0, 0, 0, 0)) {
101 e4bcb14c ths
        fprintf(stderr, "qemu: Error registering flash memory.\n");
102 e4bcb14c ths
        exit(1);
103 e4bcb14c ths
    }
104 7233b355 ths
105 e4bcb14c ths
    index = drive_get_index(IF_PFLASH, 0, 1);
106 e4bcb14c ths
    if (index == -1) {
107 e4bcb14c ths
        fprintf(stderr, "Two flash images must be given with the "
108 e4bcb14c ths
                "'pflash' parameter\n");
109 e4bcb14c ths
        exit(1);
110 e4bcb14c ths
    }
111 88eeee0a balrog
    if (!pflash_cfi01_register(MST_FLASH_1,
112 88eeee0a balrog
                         mainstone_ram + PXA2XX_INTERNAL_SIZE,
113 e4bcb14c ths
                         drives_table[index].bdrv,
114 e4bcb14c ths
                         256 * 1024, 128, 4, 0, 0, 0, 0)) {
115 e4bcb14c ths
        fprintf(stderr, "qemu: Error registering flash memory.\n");
116 e4bcb14c ths
        exit(1);
117 e4bcb14c ths
    }
118 7233b355 ths
119 7233b355 ths
    mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0);
120 f1de1334 ths
121 bd464c2e balrog
    /* setup keypad */
122 bd464c2e balrog
    printf("map addr %p\n", &map);
123 bd464c2e balrog
    pxa27x_register_keypad(cpu->kp, map, 0xe0);
124 bd464c2e balrog
125 f1de1334 ths
    /* MMC/SD host */
126 8543243c balrog
    pxa2xx_mmci_handlers(cpu->mmc, NULL, mst_irq[MMC_IRQ]);
127 f1de1334 ths
128 ef056e43 balrog
    smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]);
129 ef056e43 balrog
130 ef056e43 balrog
    arm_load_kernel(cpu->env, mainstone_ram, kernel_filename, kernel_cmdline,
131 ef056e43 balrog
                    initrd_filename, arm_id, PXA2XX_SDRAM_BASE);
132 ef056e43 balrog
}
133 ef056e43 balrog
134 ef056e43 balrog
static void mainstone_init(int ram_size, int vga_ram_size,
135 ef056e43 balrog
                const char *boot_device, DisplayState *ds,
136 ef056e43 balrog
                const char *kernel_filename, const char *kernel_cmdline,
137 ef056e43 balrog
                const char *initrd_filename, const char *cpu_model)
138 ef056e43 balrog
{
139 ef056e43 balrog
    mainstone_common_init(ram_size, vga_ram_size, ds, kernel_filename,
140 ef056e43 balrog
                kernel_cmdline, initrd_filename, cpu_model, mainstone, 0x196);
141 ef056e43 balrog
}
142 ef056e43 balrog
143 ef056e43 balrog
QEMUMachine mainstone2_machine = {
144 ef056e43 balrog
    "mainstone",
145 ef056e43 balrog
    "Mainstone II (PXA27x)",
146 ef056e43 balrog
    mainstone_init,
147 ef056e43 balrog
};