root / hw / omap_sx1.c @ 771124e1
History | View | Annotate | Download (8.1 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 "console.h" |
30 | 997641a8 | balrog | #include "omap.h" |
31 | 997641a8 | balrog | #include "boards.h" |
32 | 997641a8 | balrog | #include "arm-misc.h" |
33 | 997641a8 | balrog | #include "flash.h" |
34 | 2446333c | Blue Swirl | #include "blockdev.h" |
35 | 4b3fedf3 | Avi Kivity | #include "exec-memory.h" |
36 | 997641a8 | balrog | |
37 | 997641a8 | balrog | /*****************************************************************************/
|
38 | 997641a8 | balrog | /* Siemens SX1 Cellphone V1 */
|
39 | 997641a8 | balrog | /* - ARM OMAP310 processor
|
40 | 997641a8 | balrog | * - SRAM 192 kB
|
41 | 997641a8 | balrog | * - SDRAM 32 MB at 0x10000000
|
42 | 997641a8 | balrog | * - Boot flash 16 MB at 0x00000000
|
43 | 997641a8 | balrog | * - Application flash 8 MB at 0x04000000
|
44 | 997641a8 | balrog | * - 3 serial ports
|
45 | 997641a8 | balrog | * - 1 SecureDigital
|
46 | 997641a8 | balrog | * - 1 LCD display
|
47 | 997641a8 | balrog | * - 1 RTC
|
48 | 997641a8 | balrog | */
|
49 | 997641a8 | balrog | |
50 | 997641a8 | balrog | /*****************************************************************************/
|
51 | 997641a8 | balrog | /* Siemens SX1 Cellphone V2 */
|
52 | 997641a8 | balrog | /* - ARM OMAP310 processor
|
53 | 997641a8 | balrog | * - SRAM 192 kB
|
54 | 997641a8 | balrog | * - SDRAM 32 MB at 0x10000000
|
55 | 997641a8 | balrog | * - Boot flash 32 MB at 0x00000000
|
56 | 997641a8 | balrog | * - 3 serial ports
|
57 | 997641a8 | balrog | * - 1 SecureDigital
|
58 | 997641a8 | balrog | * - 1 LCD display
|
59 | 997641a8 | balrog | * - 1 RTC
|
60 | 997641a8 | balrog | */
|
61 | 997641a8 | balrog | |
62 | ba158029 | Benoît Canet | static uint64_t static_read(void *opaque, target_phys_addr_t offset, |
63 | ba158029 | Benoît Canet | unsigned size)
|
64 | 997641a8 | balrog | { |
65 | 997641a8 | balrog | uint32_t *val = (uint32_t *) opaque; |
66 | ba158029 | Benoît Canet | uint32_t mask = (4 / size) - 1; |
67 | 997641a8 | balrog | |
68 | ba158029 | Benoît Canet | return *val >> ((offset & mask) << 3); |
69 | 997641a8 | balrog | } |
70 | 997641a8 | balrog | |
71 | c227f099 | Anthony Liguori | static void static_write(void *opaque, target_phys_addr_t offset, |
72 | ba158029 | Benoît Canet | uint64_t value, unsigned size)
|
73 | 997641a8 | balrog | { |
74 | 997641a8 | balrog | #ifdef SPY
|
75 | ba158029 | Benoît Canet | printf("%s: value %" PRIx64 " %u bytes written at 0x%x\n", |
76 | ba158029 | Benoît Canet | __func__, value, size, (int)offset);
|
77 | 997641a8 | balrog | #endif
|
78 | 997641a8 | balrog | } |
79 | 997641a8 | balrog | |
80 | ba158029 | Benoît Canet | static const MemoryRegionOps static_ops = { |
81 | ba158029 | Benoît Canet | .read = static_read, |
82 | ba158029 | Benoît Canet | .write = static_write, |
83 | ba158029 | Benoît Canet | .endianness = DEVICE_NATIVE_ENDIAN, |
84 | 997641a8 | balrog | }; |
85 | 997641a8 | balrog | |
86 | 997641a8 | balrog | #define sdram_size 0x02000000 |
87 | 997641a8 | balrog | #define sector_size (128 * 1024) |
88 | 997641a8 | balrog | #define flash0_size (16 * 1024 * 1024) |
89 | 997641a8 | balrog | #define flash1_size ( 8 * 1024 * 1024) |
90 | 997641a8 | balrog | #define flash2_size (32 * 1024 * 1024) |
91 | 997641a8 | balrog | #define total_ram_v1 (sdram_size + flash0_size + flash1_size + OMAP15XX_SRAM_SIZE)
|
92 | 997641a8 | balrog | #define total_ram_v2 (sdram_size + flash2_size + OMAP15XX_SRAM_SIZE)
|
93 | 997641a8 | balrog | |
94 | 997641a8 | balrog | static struct arm_boot_info sx1_binfo = { |
95 | 997641a8 | balrog | .loader_start = OMAP_EMIFF_BASE, |
96 | 997641a8 | balrog | .ram_size = sdram_size, |
97 | 997641a8 | balrog | .board_id = 0x265,
|
98 | 997641a8 | balrog | }; |
99 | 997641a8 | balrog | |
100 | c227f099 | Anthony Liguori | static void sx1_init(ram_addr_t ram_size, |
101 | 5f70aab1 | aurel32 | const char *boot_device, |
102 | 997641a8 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
103 | 997641a8 | balrog | const char *initrd_filename, const char *cpu_model, |
104 | 997641a8 | balrog | const int version) |
105 | 997641a8 | balrog | { |
106 | 997641a8 | balrog | struct omap_mpu_state_s *cpu;
|
107 | 4b3fedf3 | Avi Kivity | MemoryRegion *address_space = get_system_memory(); |
108 | ba158029 | Benoît Canet | MemoryRegion *flash = g_new(MemoryRegion, 1);
|
109 | ba158029 | Benoît Canet | MemoryRegion *flash_1 = g_new(MemoryRegion, 1);
|
110 | ba158029 | Benoît Canet | MemoryRegion *cs = g_new(MemoryRegion, 4);
|
111 | 997641a8 | balrog | static uint32_t cs0val = 0x00213090; |
112 | 997641a8 | balrog | static uint32_t cs1val = 0x00215070; |
113 | 997641a8 | balrog | static uint32_t cs2val = 0x00001139; |
114 | 997641a8 | balrog | static uint32_t cs3val = 0x00001139; |
115 | 751c6a17 | Gerd Hoffmann | DriveInfo *dinfo; |
116 | 997641a8 | balrog | int fl_idx;
|
117 | 997641a8 | balrog | uint32_t flash_size = flash0_size; |
118 | 01e0451a | Anthony Liguori | int be;
|
119 | 997641a8 | balrog | |
120 | 997641a8 | balrog | if (version == 2) { |
121 | 997641a8 | balrog | flash_size = flash2_size; |
122 | 997641a8 | balrog | } |
123 | 997641a8 | balrog | |
124 | 4b3fedf3 | Avi Kivity | cpu = omap310_mpu_init(address_space, sx1_binfo.ram_size, cpu_model); |
125 | 997641a8 | balrog | |
126 | 997641a8 | balrog | /* External Flash (EMIFS) */
|
127 | c5705a77 | Avi Kivity | memory_region_init_ram(flash, "omap_sx1.flash0-0", flash_size);
|
128 | c5705a77 | Avi Kivity | vmstate_register_ram_global(flash); |
129 | ba158029 | Benoît Canet | memory_region_set_readonly(flash, true);
|
130 | ba158029 | Benoît Canet | memory_region_add_subregion(address_space, OMAP_CS0_BASE, flash); |
131 | ba158029 | Benoît Canet | |
132 | ba158029 | Benoît Canet | memory_region_init_io(&cs[0], &static_ops, &cs0val,
|
133 | ba158029 | Benoît Canet | "sx1.cs0", OMAP_CS0_SIZE - flash_size);
|
134 | ba158029 | Benoît Canet | memory_region_add_subregion(address_space, |
135 | ba158029 | Benoît Canet | OMAP_CS0_BASE + flash_size, &cs[0]);
|
136 | ba158029 | Benoît Canet | |
137 | ba158029 | Benoît Canet | |
138 | ba158029 | Benoît Canet | memory_region_init_io(&cs[2], &static_ops, &cs2val,
|
139 | ba158029 | Benoît Canet | "sx1.cs2", OMAP_CS2_SIZE);
|
140 | ba158029 | Benoît Canet | memory_region_add_subregion(address_space, |
141 | ba158029 | Benoît Canet | OMAP_CS2_BASE, &cs[2]);
|
142 | ba158029 | Benoît Canet | |
143 | ba158029 | Benoît Canet | memory_region_init_io(&cs[3], &static_ops, &cs3val,
|
144 | ba158029 | Benoît Canet | "sx1.cs3", OMAP_CS3_SIZE);
|
145 | ba158029 | Benoît Canet | memory_region_add_subregion(address_space, |
146 | ba158029 | Benoît Canet | OMAP_CS2_BASE, &cs[3]);
|
147 | 997641a8 | balrog | |
148 | 997641a8 | balrog | fl_idx = 0;
|
149 | 3d08ff69 | Blue Swirl | #ifdef TARGET_WORDS_BIGENDIAN
|
150 | 01e0451a | Anthony Liguori | be = 1;
|
151 | 3d08ff69 | Blue Swirl | #else
|
152 | 01e0451a | Anthony Liguori | be = 0;
|
153 | 3d08ff69 | Blue Swirl | #endif
|
154 | 997641a8 | balrog | |
155 | 751c6a17 | Gerd Hoffmann | if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { |
156 | cfe5f011 | Avi Kivity | if (!pflash_cfi01_register(OMAP_CS0_BASE, NULL, |
157 | cfe5f011 | Avi Kivity | "omap_sx1.flash0-1", flash_size,
|
158 | 3d08ff69 | Blue Swirl | dinfo->bdrv, sector_size, |
159 | 3d08ff69 | Blue Swirl | flash_size / sector_size, |
160 | 01e0451a | Anthony Liguori | 4, 0, 0, 0, 0, be)) { |
161 | 997641a8 | balrog | fprintf(stderr, "qemu: Error registering flash memory %d.\n",
|
162 | 997641a8 | balrog | fl_idx); |
163 | 997641a8 | balrog | } |
164 | 997641a8 | balrog | fl_idx++; |
165 | 997641a8 | balrog | } |
166 | 997641a8 | balrog | |
167 | 997641a8 | balrog | if ((version == 1) && |
168 | 751c6a17 | Gerd Hoffmann | (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) { |
169 | c5705a77 | Avi Kivity | memory_region_init_ram(flash_1, "omap_sx1.flash1-0", flash1_size);
|
170 | c5705a77 | Avi Kivity | vmstate_register_ram_global(flash_1); |
171 | ba158029 | Benoît Canet | memory_region_set_readonly(flash_1, true);
|
172 | ba158029 | Benoît Canet | memory_region_add_subregion(address_space, OMAP_CS1_BASE, flash_1); |
173 | ba158029 | Benoît Canet | |
174 | ba158029 | Benoît Canet | memory_region_init_io(&cs[1], &static_ops, &cs1val,
|
175 | ba158029 | Benoît Canet | "sx1.cs1", OMAP_CS1_SIZE - flash1_size);
|
176 | ba158029 | Benoît Canet | memory_region_add_subregion(address_space, |
177 | ba158029 | Benoît Canet | OMAP_CS1_BASE + flash1_size, &cs[1]);
|
178 | 997641a8 | balrog | |
179 | cfe5f011 | Avi Kivity | if (!pflash_cfi01_register(OMAP_CS1_BASE, NULL, |
180 | cfe5f011 | Avi Kivity | "omap_sx1.flash1-1", flash1_size,
|
181 | 3d08ff69 | Blue Swirl | dinfo->bdrv, sector_size, |
182 | 3d08ff69 | Blue Swirl | flash1_size / sector_size, |
183 | 01e0451a | Anthony Liguori | 4, 0, 0, 0, 0, be)) { |
184 | 997641a8 | balrog | fprintf(stderr, "qemu: Error registering flash memory %d.\n",
|
185 | 997641a8 | balrog | fl_idx); |
186 | 997641a8 | balrog | } |
187 | 997641a8 | balrog | fl_idx++; |
188 | 997641a8 | balrog | } else {
|
189 | ba158029 | Benoît Canet | memory_region_init_io(&cs[1], &static_ops, &cs1val,
|
190 | ba158029 | Benoît Canet | "sx1.cs1", OMAP_CS1_SIZE);
|
191 | ba158029 | Benoît Canet | memory_region_add_subregion(address_space, |
192 | ba158029 | Benoît Canet | OMAP_CS1_BASE, &cs[1]);
|
193 | 997641a8 | balrog | } |
194 | 997641a8 | balrog | |
195 | 997641a8 | balrog | if (!kernel_filename && !fl_idx) {
|
196 | 997641a8 | balrog | fprintf(stderr, "Kernel or Flash image must be specified\n");
|
197 | 997641a8 | balrog | exit(1);
|
198 | 997641a8 | balrog | } |
199 | 997641a8 | balrog | |
200 | 997641a8 | balrog | /* Load the kernel. */
|
201 | 997641a8 | balrog | if (kernel_filename) {
|
202 | 997641a8 | balrog | sx1_binfo.kernel_filename = kernel_filename; |
203 | 997641a8 | balrog | sx1_binfo.kernel_cmdline = kernel_cmdline; |
204 | 997641a8 | balrog | sx1_binfo.initrd_filename = initrd_filename; |
205 | 997641a8 | balrog | arm_load_kernel(cpu->env, &sx1_binfo); |
206 | 997641a8 | balrog | } |
207 | 997641a8 | balrog | |
208 | 5f70aab1 | aurel32 | /* TODO: fix next line */
|
209 | 5f70aab1 | aurel32 | //~ qemu_console_resize(ds, 640, 480);
|
210 | 997641a8 | balrog | } |
211 | 997641a8 | balrog | |
212 | c227f099 | Anthony Liguori | static void sx1_init_v1(ram_addr_t ram_size, |
213 | 5f70aab1 | aurel32 | const char *boot_device, |
214 | 997641a8 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
215 | 997641a8 | balrog | const char *initrd_filename, const char *cpu_model) |
216 | 997641a8 | balrog | { |
217 | fbe1b595 | Paul Brook | sx1_init(ram_size, boot_device, kernel_filename, |
218 | 997641a8 | balrog | kernel_cmdline, initrd_filename, cpu_model, 1);
|
219 | 997641a8 | balrog | } |
220 | 997641a8 | balrog | |
221 | c227f099 | Anthony Liguori | static void sx1_init_v2(ram_addr_t ram_size, |
222 | 5f70aab1 | aurel32 | const char *boot_device, |
223 | 997641a8 | balrog | const char *kernel_filename, const char *kernel_cmdline, |
224 | 997641a8 | balrog | const char *initrd_filename, const char *cpu_model) |
225 | 997641a8 | balrog | { |
226 | fbe1b595 | Paul Brook | sx1_init(ram_size, boot_device, kernel_filename, |
227 | 997641a8 | balrog | kernel_cmdline, initrd_filename, cpu_model, 2);
|
228 | 997641a8 | balrog | } |
229 | 997641a8 | balrog | |
230 | f80f9ec9 | Anthony Liguori | static QEMUMachine sx1_machine_v2 = {
|
231 | 997641a8 | balrog | .name = "sx1",
|
232 | 997641a8 | balrog | .desc = "Siemens SX1 (OMAP310) V2",
|
233 | 997641a8 | balrog | .init = sx1_init_v2, |
234 | 997641a8 | balrog | }; |
235 | 997641a8 | balrog | |
236 | f80f9ec9 | Anthony Liguori | static QEMUMachine sx1_machine_v1 = {
|
237 | 997641a8 | balrog | .name = "sx1-v1",
|
238 | 997641a8 | balrog | .desc = "Siemens SX1 (OMAP310) V1",
|
239 | 997641a8 | balrog | .init = sx1_init_v1, |
240 | 997641a8 | balrog | }; |
241 | f80f9ec9 | Anthony Liguori | |
242 | f80f9ec9 | Anthony Liguori | static void sx1_machine_init(void) |
243 | f80f9ec9 | Anthony Liguori | { |
244 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&sx1_machine_v2); |
245 | f80f9ec9 | Anthony Liguori | qemu_register_machine(&sx1_machine_v1); |
246 | f80f9ec9 | Anthony Liguori | } |
247 | f80f9ec9 | Anthony Liguori | |
248 | f80f9ec9 | Anthony Liguori | machine_init(sx1_machine_init); |