Statistics
| Branch: | Revision:

root / hw / mainstone.c @ cb380f61

History | View | Annotate | Download (4.8 kB)

1
/*
2
 * PXA270-based Intel Mainstone platforms.
3
 *
4
 * Copyright (c) 2007 by Armin Kuster <akuster@kama-aina.net> or
5
 *                                    <akuster@mvista.com>
6
 *
7
 * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org>
8
 *
9
 * This code is licensed under the GNU GPL v2.
10
 */
11
#include "hw.h"
12
#include "pxa.h"
13
#include "arm-misc.h"
14
#include "net.h"
15
#include "devices.h"
16
#include "boards.h"
17
#include "mainstone.h"
18
#include "sysemu.h"
19
#include "flash.h"
20
#include "blockdev.h"
21
#include "sysbus.h"
22

    
23
static struct keymap map[0xE0] = {
24
    [0 ... 0xDF] = { -1, -1 },
25
    [0x1e] = {0,0}, /* a */
26
    [0x30] = {0,1}, /* b */
27
    [0x2e] = {0,2}, /* c */
28
    [0x20] = {0,3}, /* d */
29
    [0x12] = {0,4}, /* e */
30
    [0x21] = {0,5}, /* f */
31
    [0x22] = {1,0}, /* g */
32
    [0x23] = {1,1}, /* h */
33
    [0x17] = {1,2}, /* i */
34
    [0x24] = {1,3}, /* j */
35
    [0x25] = {1,4}, /* k */
36
    [0x26] = {1,5}, /* l */
37
    [0x32] = {2,0}, /* m */
38
    [0x31] = {2,1}, /* n */
39
    [0x18] = {2,2}, /* o */
40
    [0x19] = {2,3}, /* p */
41
    [0x10] = {2,4}, /* q */
42
    [0x13] = {2,5}, /* r */
43
    [0x1f] = {3,0}, /* s */
44
    [0x14] = {3,1}, /* t */
45
    [0x16] = {3,2}, /* u */
46
    [0x2f] = {3,3}, /* v */
47
    [0x11] = {3,4}, /* w */
48
    [0x2d] = {3,5}, /* x */
49
    [0x15] = {4,2}, /* y */
50
    [0x2c] = {4,3}, /* z */
51
    [0xc7] = {5,0}, /* Home */
52
    [0x2a] = {5,1}, /* shift */
53
    [0x39] = {5,2}, /* space */
54
    [0x39] = {5,3}, /* space */
55
    [0x1c] = {5,5}, /*  enter */
56
    [0xc8] = {6,0}, /* up */
57
    [0xd0] = {6,1}, /* down */
58
    [0xcb] = {6,2}, /* left */
59
    [0xcd] = {6,3}, /* right */
60
};
61

    
62
enum mainstone_model_e { mainstone };
63

    
64
#define MAINSTONE_RAM        0x04000000
65
#define MAINSTONE_ROM        0x00800000
66
#define MAINSTONE_FLASH        0x02000000
67

    
68
static struct arm_boot_info mainstone_binfo = {
69
    .loader_start = PXA2XX_SDRAM_BASE,
70
    .ram_size = 0x04000000,
71
};
72

    
73
static void mainstone_common_init(ram_addr_t ram_size,
74
                const char *kernel_filename,
75
                const char *kernel_cmdline, const char *initrd_filename,
76
                const char *cpu_model, enum mainstone_model_e model, int arm_id)
77
{
78
    uint32_t sector_len = 256 * 1024;
79
    target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 };
80
    PXA2xxState *cpu;
81
    DeviceState *mst_irq;
82
    DriveInfo *dinfo;
83
    int i;
84
    int be;
85

    
86
    if (!cpu_model)
87
        cpu_model = "pxa270-c5";
88

    
89
    /* Setup CPU & memory */
90
    cpu = pxa270_init(mainstone_binfo.ram_size, cpu_model);
91
    cpu_register_physical_memory(0, MAINSTONE_ROM,
92
                    qemu_ram_alloc(NULL, "mainstone.rom",
93
                                   MAINSTONE_ROM) | IO_MEM_ROM);
94

    
95
#ifdef TARGET_WORDS_BIGENDIAN
96
    be = 1;
97
#else
98
    be = 0;
99
#endif
100
    /* There are two 32MiB flash devices on the board */
101
    for (i = 0; i < 2; i ++) {
102
        dinfo = drive_get(IF_PFLASH, 0, i);
103
        if (!dinfo) {
104
            fprintf(stderr, "Two flash images must be given with the "
105
                    "'pflash' parameter\n");
106
            exit(1);
107
        }
108

    
109
        if (!pflash_cfi01_register(mainstone_flash_base[i],
110
                                   qemu_ram_alloc(NULL, i ? "mainstone.flash1" :
111
                                                  "mainstone.flash0",
112
                                                  MAINSTONE_FLASH),
113
                                   dinfo->bdrv, sector_len,
114
                                   MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0,
115
                                   be)) {
116
            fprintf(stderr, "qemu: Error registering flash memory.\n");
117
            exit(1);
118
        }
119
    }
120

    
121
    mst_irq = sysbus_create_simple("mainstone-fpga", MST_FPGA_PHYS,
122
                    cpu->pic[PXA2XX_PIC_GPIO_0]);
123

    
124
    /* setup keypad */
125
    printf("map addr %p\n", &map);
126
    pxa27x_register_keypad(cpu->kp, map, 0xe0);
127

    
128
    /* MMC/SD host */
129
    pxa2xx_mmci_handlers(cpu->mmc, NULL, qdev_get_gpio_in(mst_irq, MMC_IRQ));
130

    
131
    smc91c111_init(&nd_table[0], MST_ETH_PHYS,
132
                    qdev_get_gpio_in(mst_irq, ETHERNET_IRQ));
133

    
134
    mainstone_binfo.kernel_filename = kernel_filename;
135
    mainstone_binfo.kernel_cmdline = kernel_cmdline;
136
    mainstone_binfo.initrd_filename = initrd_filename;
137
    mainstone_binfo.board_id = arm_id;
138
    arm_load_kernel(cpu->env, &mainstone_binfo);
139
}
140

    
141
static void mainstone_init(ram_addr_t ram_size,
142
                const char *boot_device,
143
                const char *kernel_filename, const char *kernel_cmdline,
144
                const char *initrd_filename, const char *cpu_model)
145
{
146
    mainstone_common_init(ram_size, kernel_filename,
147
                kernel_cmdline, initrd_filename, cpu_model, mainstone, 0x196);
148
}
149

    
150
static QEMUMachine mainstone2_machine = {
151
    .name = "mainstone",
152
    .desc = "Mainstone II (PXA27x)",
153
    .init = mainstone_init,
154
};
155

    
156
static void mainstone_machine_init(void)
157
{
158
    qemu_register_machine(&mainstone2_machine);
159
}
160

    
161
machine_init(mainstone_machine_init);