Fix setting counter limit to 0 (Robert Reif)
[qemu/qemu_0_9_1_stable.git] / hw / mainstone.c
blob63f17840dea068705110a2ead649452b93cf6369
1 /*
2 * PXA270-based Intel Mainstone platforms.
4 * Copyright (c) 2007 by Armin Kuster <akuster@kama-aina.net> or
5 * <akuster@mvista.com>
7 * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org>
9 * This code is licensed under the GNU GPL v2.
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"
21 static struct keymap map[0xE0] = {
22 [0 ... 0xDF] = { -1, -1 },
23 [0x1e] = {0,0}, /* a */
24 [0x30] = {0,1}, /* b */
25 [0x2e] = {0,2}, /* c */
26 [0x20] = {0,3}, /* d */
27 [0x12] = {0,4}, /* e */
28 [0x21] = {0,5}, /* f */
29 [0x22] = {1,0}, /* g */
30 [0x23] = {1,1}, /* h */
31 [0x17] = {1,2}, /* i */
32 [0x24] = {1,3}, /* j */
33 [0x25] = {1,4}, /* k */
34 [0x26] = {1,5}, /* l */
35 [0x32] = {2,0}, /* m */
36 [0x31] = {2,1}, /* n */
37 [0x18] = {2,2}, /* o */
38 [0x19] = {2,3}, /* p */
39 [0x10] = {2,4}, /* q */
40 [0x13] = {2,5}, /* r */
41 [0x1f] = {3,0}, /* s */
42 [0x14] = {3,1}, /* t */
43 [0x16] = {3,2}, /* u */
44 [0x2f] = {3,3}, /* v */
45 [0x11] = {3,4}, /* w */
46 [0x2d] = {3,5}, /* x */
47 [0x15] = {4,2}, /* y */
48 [0x2c] = {4,3}, /* z */
49 [0xc7] = {5,0}, /* Home */
50 [0x2a] = {5,1}, /* shift */
51 [0x39] = {5,2}, /* space */
52 [0x39] = {5,3}, /* space */
53 [0x1c] = {5,5}, /* enter */
54 [0xc8] = {6,0}, /* up */
55 [0xd0] = {6,1}, /* down */
56 [0xcb] = {6,2}, /* left */
57 [0xcd] = {6,3}, /* right */
60 enum mainstone_model_e { mainstone };
62 static void mainstone_common_init(int ram_size, int vga_ram_size,
63 DisplayState *ds, const char *kernel_filename,
64 const char *kernel_cmdline, const char *initrd_filename,
65 const char *cpu_model, enum mainstone_model_e model, int arm_id)
67 uint32_t mainstone_ram = 0x04000000;
68 uint32_t mainstone_rom = 0x00800000;
69 struct pxa2xx_state_s *cpu;
70 qemu_irq *mst_irq;
71 int index;
73 if (!cpu_model)
74 cpu_model = "pxa270-c5";
76 /* Setup CPU & memory */
77 if (ram_size < mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE) {
78 fprintf(stderr, "This platform requires %i bytes of memory\n",
79 mainstone_ram + mainstone_rom + PXA2XX_INTERNAL_SIZE);
80 exit(1);
83 cpu = pxa270_init(mainstone_ram, ds, cpu_model);
84 cpu_register_physical_memory(0, mainstone_rom,
85 qemu_ram_alloc(mainstone_rom) | IO_MEM_ROM);
87 /* Setup initial (reset) machine state */
88 cpu->env->regs[15] = PXA2XX_SDRAM_BASE;
90 /* There are two 32MiB flash devices on the board */
91 index = drive_get_index(IF_PFLASH, 0, 0);
92 if (index == -1) {
93 fprintf(stderr, "Two flash images must be given with the "
94 "'pflash' parameter\n");
95 exit(1);
97 if (!pflash_cfi01_register(MST_FLASH_0,
98 mainstone_ram + PXA2XX_INTERNAL_SIZE,
99 drives_table[index].bdrv,
100 256 * 1024, 128, 4, 0, 0, 0, 0)) {
101 fprintf(stderr, "qemu: Error registering flash memory.\n");
102 exit(1);
105 index = drive_get_index(IF_PFLASH, 0, 1);
106 if (index == -1) {
107 fprintf(stderr, "Two flash images must be given with the "
108 "'pflash' parameter\n");
109 exit(1);
111 if (!pflash_cfi01_register(MST_FLASH_1,
112 mainstone_ram + PXA2XX_INTERNAL_SIZE,
113 drives_table[index].bdrv,
114 256 * 1024, 128, 4, 0, 0, 0, 0)) {
115 fprintf(stderr, "qemu: Error registering flash memory.\n");
116 exit(1);
119 mst_irq = mst_irq_init(cpu, MST_FPGA_PHYS, PXA2XX_PIC_GPIO_0);
121 /* setup keypad */
122 printf("map addr %p\n", &map);
123 pxa27x_register_keypad(cpu->kp, map, 0xe0);
125 /* MMC/SD host */
126 pxa2xx_mmci_handlers(cpu->mmc, NULL, mst_irq[MMC_IRQ]);
128 smc91c111_init(&nd_table[0], MST_ETH_PHYS, mst_irq[ETHERNET_IRQ]);
130 arm_load_kernel(cpu->env, mainstone_ram, kernel_filename, kernel_cmdline,
131 initrd_filename, arm_id, PXA2XX_SDRAM_BASE);
134 static void mainstone_init(int ram_size, int vga_ram_size,
135 const char *boot_device, DisplayState *ds,
136 const char *kernel_filename, const char *kernel_cmdline,
137 const char *initrd_filename, const char *cpu_model)
139 mainstone_common_init(ram_size, vga_ram_size, ds, kernel_filename,
140 kernel_cmdline, initrd_filename, cpu_model, mainstone, 0x196);
143 QEMUMachine mainstone2_machine = {
144 "mainstone",
145 "Mainstone II (PXA27x)",
146 mainstone_init,