root / hw / omap_sx1.c @ ad674e53
History | View | Annotate | Download (7.5 kB)
1 | 997641a8 | balrog | /* omap_sx1.c Support for the Siemens SX1 smartphone emulation.
|
---|---|---|---|
2 | 997641a8 | balrog | *
|
3 | 997641a8 | balrog | * Copyright (C) 2008
|
4 | 997641a8 | balrog | * Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
|
5 | 997641a8 | balrog | * Copyright (C) 2007 Vladimir Ananiev <vovan888@gmail.com>
|
6 | 997641a8 | balrog | *
|
7 | 997641a8 | balrog | * based on PalmOne's (TM) PDAs support (palm.c)
|
8 | 997641a8 | balrog | */
|
9 | 997641a8 | balrog | |
10 | 997641a8 | balrog | /*
|
11 | 997641a8 | balrog | * PalmOne's (TM) PDAs.
|
12 | 997641a8 | balrog | *
|
13 | 997641a8 | balrog | * Copyright (C) 2006-2007 Andrzej Zaborowski <balrog@zabor.org>
|
14 | 997641a8 | balrog | *
|
15 | 997641a8 | balrog | * This program is free software; you can redistribute it and/or
|
16 | 997641a8 | balrog | * modify it under the terms of the GNU General Public License as
|
17 | 997641a8 | balrog | * published by the Free Software Foundation; either version 2 of
|
18 | 997641a8 | balrog | * the License, or (at your option) any later version.
|
19 | 997641a8 | balrog | *
|
20 | 997641a8 | balrog | * This program is distributed in the hope that it will be useful,
|
21 | 997641a8 | balrog | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
22 | 997641a8 | balrog | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
23 | 997641a8 | balrog | * GNU General Public License for more details.
|
24 | 997641a8 | balrog | *
|
25 | fad6cb1a | aurel32 | * You should have received a copy of the GNU General Public License along
|
26 | 8167ee88 | Blue Swirl | * with this program; if not, see <http://www.gnu.org/licenses/>.
|
27 | 997641a8 | balrog | */
|
28 | 997641a8 | balrog | #include "hw.h" |
29 | 997641a8 | balrog | #include "sysemu.h" |
30 | 997641a8 | balrog | #include "console.h" |
31 | 997641a8 | balrog | #include "omap.h" |
32 | 997641a8 | balrog | #include "boards.h" |
33 | 997641a8 | balrog | #include "arm-misc.h" |
34 | 997641a8 | balrog | #include "flash.h" |
35 | 997641a8 | balrog | |
36 | 997641a8 | balrog | /*****************************************************************************/
|
37 | 997641a8 | balrog | /* Siemens SX1 Cellphone V1 */
|
38 | 997641a8 | balrog | /* - ARM OMAP310 processor
|
39 | 997641a8 | balrog | * - SRAM 192 kB
|
40 | 997641a8 | balrog | * - SDRAM 32 MB at 0x10000000
|
41 | 997641a8 | balrog | * - Boot flash 16 MB at 0x00000000
|
42 | 997641a8 | balrog | * - Application flash 8 MB at 0x04000000
|
43 | 997641a8 | balrog | * - 3 serial ports
|
44 | 997641a8 | balrog | * - 1 SecureDigital
|
45 | 997641a8 | balrog | * - 1 LCD display
|
46 | 997641a8 | balrog | * - 1 RTC
|
47 | 997641a8 | balrog | */
|
48 | 997641a8 | balrog | |
49 | 997641a8 | balrog | /*****************************************************************************/
|
50 | 997641a8 | balrog | /* Siemens SX1 Cellphone V2 */
|
51 | 997641a8 | balrog | /* - ARM OMAP310 processor
|
52 | 997641a8 | balrog | * - SRAM 192 kB
|
53 | 997641a8 | balrog | * - SDRAM 32 MB at 0x10000000
|
54 | 997641a8 | balrog | * - Boot flash 32 MB at 0x00000000
|
55 | 997641a8 | balrog | * - 3 serial ports
|
56 | 997641a8 | balrog | * - 1 SecureDigital
|
57 | 997641a8 | balrog | * - 1 LCD display
|
58 | 997641a8 | balrog | * - 1 RTC
|
59 | 997641a8 | balrog | */
|
60 | 997641a8 | balrog | |
61 | c227f099 | Anthony Liguori | static uint32_t static_readb(void *opaque, target_phys_addr_t offset) |
62 | 997641a8 | balrog | { |
63 | 997641a8 | balrog | uint32_t *val = (uint32_t *) opaque; |
64 | 997641a8 | balrog | |
65 | 997641a8 | balrog | return *val >> ((offset & 3) << 3); |
66 | 997641a8 | balrog | } |
67 | 997641a8 | balrog | |
68 | c227f099 | Anthony Liguori | static uint32_t static_readh(void *opaque, target_phys_addr_t offset) |
69 | 997641a8 | balrog | { |
70 | 997641a8 | balrog | uint32_t *val = (uint32_t *) opaque; |
71 | 997641a8 | balrog | |
72 | 997641a8 | balrog | return *val >> ((offset & 1) << 3); |
73 | 997641a8 | balrog | } |
74 | 997641a8 | balrog | |
75 | c227f099 | Anthony Liguori | static uint32_t static_readw(void *opaque, target_phys_addr_t offset) |
76 | 997641a8 | balrog | { |
77 | 997641a8 | balrog | uint32_t *val = (uint32_t *) opaque; |
78 | 997641a8 | balrog | |
79 | 997641a8 | balrog | return *val >> ((offset & 0) << 3); |
80 | 997641a8 | balrog | } |
81 | 997641a8 | balrog | |
82 | c227f099 | Anthony Liguori | static void static_write(void *opaque, target_phys_addr_t offset, |
83 | 997641a8 | balrog | uint32_t value) |
84 | 997641a8 | balrog | { |
85 | 997641a8 | balrog | #ifdef SPY
|
86 | 997641a8 | balrog | printf("%s: value %08lx written at " PA_FMT "\n", |
87 | 997641a8 | balrog | __FUNCTION__, value, offset); |
88 | 997641a8 | balrog | #endif
|
89 | 997641a8 | balrog | } |
90 | 997641a8 | balrog | |
91 | d60efc6b | Blue Swirl | static CPUReadMemoryFunc * const static_readfn[] = { |
92 | 997641a8 | balrog | static_readb, |
93 | 997641a8 | balrog | static_readh, |
94 | 997641a8 | balrog | static_readw, |
95 | 997641a8 | balrog | }; |
96 | 997641a8 | balrog | |
97 | d60efc6b | Blue Swirl | static CPUWriteMemoryFunc * const static_writefn[] = { |
98 | 997641a8 | balrog | static_write, |
99 | 997641a8 | balrog | static_write, |
100 | 997641a8 | balrog | static_write, |
101 | 997641a8 | balrog | }; |
102 | 997641a8 | balrog | |
103 | 997641a8 | balrog | #define sdram_size 0x02000000 |
104 | 997641a8 | balrog | #define sector_size (128 * 1024) |
105 | 997641a8 | balrog | #define flash0_size (16 * 1024 * 1024) |
106 | 997641a8 | balrog | #define flash1_size ( 8 * 1024 * 1024) |
107 | 997641a8 | balrog | #define flash2_size (32 * 1024 * 1024) |
108 | 997641a8 | balrog | #define total_ram_v1 (sdram_size + flash0_size + flash1_size + OMAP15XX_SRAM_SIZE)
|
109 | 997641a8 | balrog | #define total_ram_v2 (sdram_size + flash2_size + OMAP15XX_SRAM_SIZE)
|
110 | 997641a8 | balrog | |
111 | 997641a8 | balrog | static struct arm_boot_info sx1_binfo = { |
112 | 997641a8 | balrog | .loader_start = OMAP_EMIFF_BASE, |
113 | 997641a8 | balrog | .ram_size = sdram_size, |
114 | 997641a8 | balrog | .board_id = 0x265,
|
115 | 997641a8 | balrog | }; |
116 | 997641a8 | balrog | |
117 | c227f099 | Anthony Liguori | static void sx1_init(ram_addr_t ram_size, |
118 | 5f70aab1 | aurel32 | const char *boot_device, |
119 | 997641a8 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
120 | 997641a8 | balrog | const char *initrd_filename, const char *cpu_model, |
121 | 997641a8 | balrog | const int version) |
122 | 997641a8 | balrog | { |
123 | 997641a8 | balrog | struct omap_mpu_state_s *cpu;
|
124 | 997641a8 | balrog | int io;
|
125 | 997641a8 | balrog | static uint32_t cs0val = 0x00213090; |
126 | 997641a8 | balrog | static uint32_t cs1val = 0x00215070; |
127 | 997641a8 | balrog | static uint32_t cs2val = 0x00001139; |
128 | 997641a8 | balrog | static uint32_t cs3val = 0x00001139; |
129 | c227f099 | Anthony Liguori | ram_addr_t phys_flash; |
130 | 751c6a17 | Gerd Hoffmann | DriveInfo *dinfo; |
131 | 997641a8 | balrog | int fl_idx;
|
132 | 997641a8 | balrog | uint32_t flash_size = flash0_size; |
133 | 997641a8 | balrog | |
134 | 997641a8 | balrog | if (version == 2) { |
135 | 997641a8 | balrog | flash_size = flash2_size; |
136 | 997641a8 | balrog | } |
137 | 997641a8 | balrog | |
138 | 3023f332 | aliguori | cpu = omap310_mpu_init(sx1_binfo.ram_size, cpu_model); |
139 | 997641a8 | balrog | |
140 | 997641a8 | balrog | /* External Flash (EMIFS) */
|
141 | 997641a8 | balrog | cpu_register_physical_memory(OMAP_CS0_BASE, flash_size, |
142 | 997641a8 | balrog | (phys_flash = qemu_ram_alloc(flash_size)) | IO_MEM_ROM); |
143 | 997641a8 | balrog | |
144 | 1eed09cb | Avi Kivity | io = cpu_register_io_memory(static_readfn, static_writefn, &cs0val); |
145 | 997641a8 | balrog | cpu_register_physical_memory(OMAP_CS0_BASE + flash_size, |
146 | 997641a8 | balrog | OMAP_CS0_SIZE - flash_size, io); |
147 | 1eed09cb | Avi Kivity | io = cpu_register_io_memory(static_readfn, static_writefn, &cs2val); |
148 | 997641a8 | balrog | cpu_register_physical_memory(OMAP_CS2_BASE, OMAP_CS2_SIZE, io); |
149 | 1eed09cb | Avi Kivity | io = cpu_register_io_memory(static_readfn, static_writefn, &cs3val); |
150 | 997641a8 | balrog | cpu_register_physical_memory(OMAP_CS3_BASE, OMAP_CS3_SIZE, io); |
151 | 997641a8 | balrog | |
152 | 997641a8 | balrog | fl_idx = 0;
|
153 | 997641a8 | balrog | |
154 | 751c6a17 | Gerd Hoffmann | if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { |
155 | 997641a8 | balrog | if (!pflash_cfi01_register(OMAP_CS0_BASE, qemu_ram_alloc(flash_size),
|
156 | 751c6a17 | Gerd Hoffmann | dinfo->bdrv, sector_size, flash_size / sector_size, |
157 | 997641a8 | balrog | 4, 0, 0, 0, 0)) { |
158 | 997641a8 | balrog | fprintf(stderr, "qemu: Error registering flash memory %d.\n",
|
159 | 997641a8 | balrog | fl_idx); |
160 | 997641a8 | balrog | } |
161 | 997641a8 | balrog | fl_idx++; |
162 | 997641a8 | balrog | } |
163 | 997641a8 | balrog | |
164 | 997641a8 | balrog | if ((version == 1) && |
165 | 751c6a17 | Gerd Hoffmann | (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { |
166 | 997641a8 | balrog | cpu_register_physical_memory(OMAP_CS1_BASE, flash1_size, |
167 | 997641a8 | balrog | (phys_flash = qemu_ram_alloc(flash1_size)) | |
168 | 997641a8 | balrog | IO_MEM_ROM); |
169 | 1eed09cb | Avi Kivity | io = cpu_register_io_memory(static_readfn, static_writefn, &cs1val); |
170 | 997641a8 | balrog | cpu_register_physical_memory(OMAP_CS1_BASE + flash1_size, |
171 | 997641a8 | balrog | OMAP_CS1_SIZE - flash1_size, io); |
172 | 997641a8 | balrog | |
173 | 997641a8 | balrog | if (!pflash_cfi01_register(OMAP_CS1_BASE, qemu_ram_alloc(flash1_size),
|
174 | 751c6a17 | Gerd Hoffmann | dinfo->bdrv, sector_size, flash1_size / sector_size, |
175 | 997641a8 | balrog | 4, 0, 0, 0, 0)) { |
176 | 997641a8 | balrog | fprintf(stderr, "qemu: Error registering flash memory %d.\n",
|
177 | 997641a8 | balrog | fl_idx); |
178 | 997641a8 | balrog | } |
179 | 997641a8 | balrog | fl_idx++; |
180 | 997641a8 | balrog | } else {
|
181 | 1eed09cb | Avi Kivity | io = cpu_register_io_memory(static_readfn, static_writefn, &cs1val); |
182 | 997641a8 | balrog | cpu_register_physical_memory(OMAP_CS1_BASE, OMAP_CS1_SIZE, io); |
183 | 997641a8 | balrog | } |
184 | 997641a8 | balrog | |
185 | 997641a8 | balrog | if (!kernel_filename && !fl_idx) {
|
186 | 997641a8 | balrog | fprintf(stderr, "Kernel or Flash image must be specified\n");
|
187 | 997641a8 | balrog | exit(1);
|
188 | 997641a8 | balrog | } |
189 | 997641a8 | balrog | |
190 | 997641a8 | balrog | /* Load the kernel. */
|
191 | 997641a8 | balrog | if (kernel_filename) {
|
192 | 997641a8 | balrog | /* Start at bootloader. */
|
193 | 997641a8 | balrog | cpu->env->regs[15] = sx1_binfo.loader_start;
|
194 | 997641a8 | balrog | |
195 | 997641a8 | balrog | sx1_binfo.kernel_filename = kernel_filename; |
196 | 997641a8 | balrog | sx1_binfo.kernel_cmdline = kernel_cmdline; |
197 | 997641a8 | balrog | sx1_binfo.initrd_filename = initrd_filename; |
198 | 997641a8 | balrog | arm_load_kernel(cpu->env, &sx1_binfo); |
199 | 997641a8 | balrog | } else {
|
200 | 997641a8 | balrog | cpu->env->regs[15] = 0x00000000; |
201 | 997641a8 | balrog | } |
202 | 997641a8 | balrog | |
203 | 5f70aab1 | aurel32 | /* TODO: fix next line */
|
204 | 5f70aab1 | aurel32 | //~ qemu_console_resize(ds, 640, 480);
|
205 | 997641a8 | balrog | } |
206 | 997641a8 | balrog | |
207 | c227f099 | Anthony Liguori | static void sx1_init_v1(ram_addr_t ram_size, |
208 | 5f70aab1 | aurel32 | const char *boot_device, |
209 | 997641a8 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
210 | 997641a8 | balrog | const char *initrd_filename, const char *cpu_model) |
211 | 997641a8 | balrog | { |
212 | fbe1b595 | Paul Brook | sx1_init(ram_size, boot_device, kernel_filename, |
213 | 997641a8 | balrog | kernel_cmdline, initrd_filename, cpu_model, 1);
|
214 | 997641a8 | balrog | } |
215 | 997641a8 | balrog | |
216 | c227f099 | Anthony Liguori | static void sx1_init_v2(ram_addr_t ram_size, |
217 | 5f70aab1 | aurel32 | const char *boot_device, |
218 | 997641a8 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
219 | 997641a8 | balrog | const char *initrd_filename, const char *cpu_model) |
220 | 997641a8 | balrog | { |
221 | fbe1b595 | Paul Brook | sx1_init(ram_size, boot_device, kernel_filename, |
222 | 997641a8 | balrog | kernel_cmdline, initrd_filename, cpu_model, 2);
|
223 | 997641a8 | balrog | } |
224 | 997641a8 | balrog | |
225 | f80f9ec9 | Anthony Liguori | static QEMUMachine sx1_machine_v2 = {
|
226 | 997641a8 | balrog | .name = "sx1",
|
227 | 997641a8 | balrog | .desc = "Siemens SX1 (OMAP310) V2",
|
228 | 997641a8 | balrog | .init = sx1_init_v2, |
229 | 997641a8 | balrog | }; |
230 | 997641a8 | balrog | |
231 | f80f9ec9 | Anthony Liguori | static QEMUMachine sx1_machine_v1 = {
|
232 | 997641a8 | balrog | .name = "sx1-v1",
|
233 | 997641a8 | balrog | .desc = "Siemens SX1 (OMAP310) V1",
|
234 | 997641a8 | balrog | .init = sx1_init_v1, |
235 | 997641a8 | balrog | }; |
236 | f80f9ec9 | Anthony Liguori | |
237 | f80f9ec9 | Anthony Liguori | static void sx1_machine_init(void) |
238 | f80f9ec9 | Anthony Liguori | { |
239 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&sx1_machine_v2); |
240 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&sx1_machine_v1); |
241 | f80f9ec9 | Anthony Liguori | } |
242 | f80f9ec9 | Anthony Liguori | |
243 | f80f9ec9 | Anthony Liguori | machine_init(sx1_machine_init); |