root / hw / mainstone.c @ de956597
History | View | Annotate | Download (4.9 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 | 7fb4fdcf | balrog | #define MAINSTONE_RAM 0x04000000 |
63 | 7fb4fdcf | balrog | #define MAINSTONE_ROM 0x00800000 |
64 | 7fb4fdcf | balrog | #define MAINSTONE_FLASH 0x02000000 |
65 | 7fb4fdcf | balrog | |
66 | f93eb9ff | balrog | static struct arm_boot_info mainstone_binfo = { |
67 | f93eb9ff | balrog | .loader_start = PXA2XX_SDRAM_BASE, |
68 | f93eb9ff | balrog | .ram_size = 0x04000000,
|
69 | f93eb9ff | balrog | }; |
70 | f93eb9ff | balrog | |
71 | 00f82b8a | aurel32 | static void mainstone_common_init(ram_addr_t ram_size, int vga_ram_size, |
72 | ef056e43 | balrog | DisplayState *ds, const char *kernel_filename, |
73 | ef056e43 | balrog | const char *kernel_cmdline, const char *initrd_filename, |
74 | ef056e43 | balrog | const char *cpu_model, enum mainstone_model_e model, int arm_id) |
75 | ef056e43 | balrog | { |
76 | 6d1f1778 | balrog | uint32_t sector_len = 256 * 1024; |
77 | 6d1f1778 | balrog | target_phys_addr_t mainstone_flash_base[] = { MST_FLASH_0, MST_FLASH_1 }; |
78 | ef056e43 | balrog | struct pxa2xx_state_s *cpu;
|
79 | ef056e43 | balrog | qemu_irq *mst_irq; |
80 | 6d1f1778 | balrog | int i, index;
|
81 | ef056e43 | balrog | |
82 | ef056e43 | balrog | if (!cpu_model)
|
83 | ef056e43 | balrog | cpu_model = "pxa270-c5";
|
84 | ef056e43 | balrog | |
85 | ef056e43 | balrog | /* Setup CPU & memory */
|
86 | 7fb4fdcf | balrog | if (ram_size < MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH + |
87 | 6d1f1778 | balrog | PXA2XX_INTERNAL_SIZE) { |
88 | ef056e43 | balrog | fprintf(stderr, "This platform requires %i bytes of memory\n",
|
89 | 7fb4fdcf | balrog | MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
|
90 | 6d1f1778 | balrog | PXA2XX_INTERNAL_SIZE); |
91 | ef056e43 | balrog | exit(1);
|
92 | ef056e43 | balrog | } |
93 | ef056e43 | balrog | |
94 | 7fb4fdcf | balrog | cpu = pxa270_init(mainstone_binfo.ram_size, ds, cpu_model); |
95 | 7fb4fdcf | balrog | cpu_register_physical_memory(0, MAINSTONE_ROM,
|
96 | 7fb4fdcf | balrog | qemu_ram_alloc(MAINSTONE_ROM) | IO_MEM_ROM); |
97 | ef056e43 | balrog | |
98 | ef056e43 | balrog | /* Setup initial (reset) machine state */
|
99 | f93eb9ff | balrog | cpu->env->regs[15] = mainstone_binfo.loader_start;
|
100 | ef056e43 | balrog | |
101 | e4bcb14c | ths | /* There are two 32MiB flash devices on the board */
|
102 | 6d1f1778 | balrog | for (i = 0; i < 2; i ++) { |
103 | 6d1f1778 | balrog | index = drive_get_index(IF_PFLASH, 0, i);
|
104 | 6d1f1778 | balrog | if (index == -1) { |
105 | 6d1f1778 | balrog | fprintf(stderr, "Two flash images must be given with the "
|
106 | 6d1f1778 | balrog | "'pflash' parameter\n");
|
107 | 6d1f1778 | balrog | exit(1);
|
108 | 6d1f1778 | balrog | } |
109 | 6d1f1778 | balrog | |
110 | 6d1f1778 | balrog | if (!pflash_cfi01_register(mainstone_flash_base[i],
|
111 | 7fb4fdcf | balrog | qemu_ram_alloc(MAINSTONE_FLASH), |
112 | 6d1f1778 | balrog | drives_table[index].bdrv, sector_len, |
113 | 7fb4fdcf | balrog | MAINSTONE_FLASH / sector_len, 4, 0, 0, 0, 0)) { |
114 | 6d1f1778 | balrog | fprintf(stderr, "qemu: Error registering flash memory.\n");
|
115 | 6d1f1778 | balrog | exit(1);
|
116 | 6d1f1778 | balrog | } |
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 | f93eb9ff | balrog | mainstone_binfo.kernel_filename = kernel_filename; |
131 | f93eb9ff | balrog | mainstone_binfo.kernel_cmdline = kernel_cmdline; |
132 | f93eb9ff | balrog | mainstone_binfo.initrd_filename = initrd_filename; |
133 | f93eb9ff | balrog | mainstone_binfo.board_id = arm_id; |
134 | f93eb9ff | balrog | arm_load_kernel(cpu->env, &mainstone_binfo); |
135 | ef056e43 | balrog | } |
136 | ef056e43 | balrog | |
137 | 00f82b8a | aurel32 | static void mainstone_init(ram_addr_t ram_size, int vga_ram_size, |
138 | ef056e43 | balrog | const char *boot_device, DisplayState *ds, |
139 | ef056e43 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
140 | ef056e43 | balrog | const char *initrd_filename, const char *cpu_model) |
141 | ef056e43 | balrog | { |
142 | ef056e43 | balrog | mainstone_common_init(ram_size, vga_ram_size, ds, kernel_filename, |
143 | ef056e43 | balrog | kernel_cmdline, initrd_filename, cpu_model, mainstone, 0x196);
|
144 | ef056e43 | balrog | } |
145 | ef056e43 | balrog | |
146 | ef056e43 | balrog | QEMUMachine mainstone2_machine = { |
147 | 4b32e168 | aliguori | .name = "mainstone",
|
148 | 4b32e168 | aliguori | .desc = "Mainstone II (PXA27x)",
|
149 | 4b32e168 | aliguori | .init = mainstone_init, |
150 | 4b32e168 | aliguori | .ram_require = (MAINSTONE_RAM + MAINSTONE_ROM + 2 * MAINSTONE_FLASH +
|
151 | 3d878caa | balrog | PXA2XX_INTERNAL_SIZE) | RAMSIZE_FIXED, |
152 | ef056e43 | balrog | }; |