Statistics
| Branch: | Revision:

root / hw / omap_sx1.c @ 6f3279b5

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 "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 2446333c Blue Swirl
#include "blockdev.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 c227f099 Anthony Liguori
static uint32_t static_readb(void *opaque, target_phys_addr_t offset)
63 997641a8 balrog
{
64 997641a8 balrog
    uint32_t *val = (uint32_t *) opaque;
65 997641a8 balrog
66 997641a8 balrog
    return *val >> ((offset & 3) << 3);
67 997641a8 balrog
}
68 997641a8 balrog
69 c227f099 Anthony Liguori
static uint32_t static_readh(void *opaque, target_phys_addr_t offset)
70 997641a8 balrog
{
71 997641a8 balrog
    uint32_t *val = (uint32_t *) opaque;
72 997641a8 balrog
73 997641a8 balrog
    return *val >> ((offset & 1) << 3);
74 997641a8 balrog
}
75 997641a8 balrog
76 c227f099 Anthony Liguori
static uint32_t static_readw(void *opaque, target_phys_addr_t offset)
77 997641a8 balrog
{
78 997641a8 balrog
    uint32_t *val = (uint32_t *) opaque;
79 997641a8 balrog
80 997641a8 balrog
    return *val >> ((offset & 0) << 3);
81 997641a8 balrog
}
82 997641a8 balrog
83 c227f099 Anthony Liguori
static void static_write(void *opaque, target_phys_addr_t offset,
84 997641a8 balrog
                uint32_t value)
85 997641a8 balrog
{
86 997641a8 balrog
#ifdef SPY
87 997641a8 balrog
    printf("%s: value %08lx written at " PA_FMT "\n",
88 997641a8 balrog
                    __FUNCTION__, value, offset);
89 997641a8 balrog
#endif
90 997641a8 balrog
}
91 997641a8 balrog
92 d60efc6b Blue Swirl
static CPUReadMemoryFunc * const static_readfn[] = {
93 997641a8 balrog
    static_readb,
94 997641a8 balrog
    static_readh,
95 997641a8 balrog
    static_readw,
96 997641a8 balrog
};
97 997641a8 balrog
98 d60efc6b Blue Swirl
static CPUWriteMemoryFunc * const static_writefn[] = {
99 997641a8 balrog
    static_write,
100 997641a8 balrog
    static_write,
101 997641a8 balrog
    static_write,
102 997641a8 balrog
};
103 997641a8 balrog
104 997641a8 balrog
#define sdram_size        0x02000000
105 997641a8 balrog
#define sector_size        (128 * 1024)
106 997641a8 balrog
#define flash0_size        (16 * 1024 * 1024)
107 997641a8 balrog
#define flash1_size        ( 8 * 1024 * 1024)
108 997641a8 balrog
#define flash2_size        (32 * 1024 * 1024)
109 997641a8 balrog
#define total_ram_v1        (sdram_size + flash0_size + flash1_size + OMAP15XX_SRAM_SIZE)
110 997641a8 balrog
#define total_ram_v2        (sdram_size + flash2_size + OMAP15XX_SRAM_SIZE)
111 997641a8 balrog
112 997641a8 balrog
static struct arm_boot_info sx1_binfo = {
113 997641a8 balrog
    .loader_start = OMAP_EMIFF_BASE,
114 997641a8 balrog
    .ram_size = sdram_size,
115 997641a8 balrog
    .board_id = 0x265,
116 997641a8 balrog
};
117 997641a8 balrog
118 c227f099 Anthony Liguori
static void sx1_init(ram_addr_t ram_size,
119 5f70aab1 aurel32
                const char *boot_device,
120 997641a8 balrog
                const char *kernel_filename, const char *kernel_cmdline,
121 997641a8 balrog
                const char *initrd_filename, const char *cpu_model,
122 997641a8 balrog
                const int version)
123 997641a8 balrog
{
124 997641a8 balrog
    struct omap_mpu_state_s *cpu;
125 997641a8 balrog
    int io;
126 997641a8 balrog
    static uint32_t cs0val = 0x00213090;
127 997641a8 balrog
    static uint32_t cs1val = 0x00215070;
128 997641a8 balrog
    static uint32_t cs2val = 0x00001139;
129 997641a8 balrog
    static uint32_t cs3val = 0x00001139;
130 751c6a17 Gerd Hoffmann
    DriveInfo *dinfo;
131 997641a8 balrog
    int fl_idx;
132 997641a8 balrog
    uint32_t flash_size = flash0_size;
133 3d08ff69 Blue Swirl
    int be;
134 997641a8 balrog
135 997641a8 balrog
    if (version == 2) {
136 997641a8 balrog
        flash_size = flash2_size;
137 997641a8 balrog
    }
138 997641a8 balrog
139 3023f332 aliguori
    cpu = omap310_mpu_init(sx1_binfo.ram_size, cpu_model);
140 997641a8 balrog
141 997641a8 balrog
    /* External Flash (EMIFS) */
142 997641a8 balrog
    cpu_register_physical_memory(OMAP_CS0_BASE, flash_size,
143 1724f049 Alex Williamson
                                 qemu_ram_alloc(NULL, "omap_sx1.flash0-0",
144 1724f049 Alex Williamson
                                                flash_size) | IO_MEM_ROM);
145 997641a8 balrog
146 2507c12a Alexander Graf
    io = cpu_register_io_memory(static_readfn, static_writefn, &cs0val,
147 2507c12a Alexander Graf
                                DEVICE_NATIVE_ENDIAN);
148 997641a8 balrog
    cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,
149 997641a8 balrog
                    OMAP_CS0_SIZE - flash_size, io);
150 2507c12a Alexander Graf
    io = cpu_register_io_memory(static_readfn, static_writefn, &cs2val,
151 2507c12a Alexander Graf
                                DEVICE_NATIVE_ENDIAN);
152 997641a8 balrog
    cpu_register_physical_memory(OMAP_CS2_BASE, OMAP_CS2_SIZE, io);
153 2507c12a Alexander Graf
    io = cpu_register_io_memory(static_readfn, static_writefn, &cs3val,
154 2507c12a Alexander Graf
                                DEVICE_NATIVE_ENDIAN);
155 997641a8 balrog
    cpu_register_physical_memory(OMAP_CS3_BASE, OMAP_CS3_SIZE, io);
156 997641a8 balrog
157 997641a8 balrog
    fl_idx = 0;
158 3d08ff69 Blue Swirl
#ifdef TARGET_WORDS_BIGENDIAN
159 3d08ff69 Blue Swirl
    be = 1;
160 3d08ff69 Blue Swirl
#else
161 3d08ff69 Blue Swirl
    be = 0;
162 3d08ff69 Blue Swirl
#endif
163 997641a8 balrog
164 751c6a17 Gerd Hoffmann
    if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
165 1724f049 Alex Williamson
        if (!pflash_cfi01_register(OMAP_CS0_BASE, qemu_ram_alloc(NULL,
166 1724f049 Alex Williamson
                                   "omap_sx1.flash0-1", flash_size),
167 3d08ff69 Blue Swirl
                                   dinfo->bdrv, sector_size,
168 3d08ff69 Blue Swirl
                                   flash_size / sector_size,
169 3d08ff69 Blue Swirl
                                   4, 0, 0, 0, 0, be)) {
170 997641a8 balrog
            fprintf(stderr, "qemu: Error registering flash memory %d.\n",
171 997641a8 balrog
                           fl_idx);
172 997641a8 balrog
        }
173 997641a8 balrog
        fl_idx++;
174 997641a8 balrog
    }
175 997641a8 balrog
176 997641a8 balrog
    if ((version == 1) &&
177 751c6a17 Gerd Hoffmann
            (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
178 997641a8 balrog
        cpu_register_physical_memory(OMAP_CS1_BASE, flash1_size,
179 1724f049 Alex Williamson
                                     qemu_ram_alloc(NULL, "omap_sx1.flash1-0",
180 1724f049 Alex Williamson
                                                    flash1_size) | IO_MEM_ROM);
181 2507c12a Alexander Graf
        io = cpu_register_io_memory(static_readfn, static_writefn, &cs1val,
182 2507c12a Alexander Graf
                                    DEVICE_NATIVE_ENDIAN);
183 997641a8 balrog
        cpu_register_physical_memory(OMAP_CS1_BASE + flash1_size,
184 997641a8 balrog
                        OMAP_CS1_SIZE - flash1_size, io);
185 997641a8 balrog
186 1724f049 Alex Williamson
        if (!pflash_cfi01_register(OMAP_CS1_BASE, qemu_ram_alloc(NULL,
187 1724f049 Alex Williamson
                                   "omap_sx1.flash1-1", flash1_size),
188 3d08ff69 Blue Swirl
                                   dinfo->bdrv, sector_size,
189 3d08ff69 Blue Swirl
                                   flash1_size / sector_size,
190 3d08ff69 Blue Swirl
                                   4, 0, 0, 0, 0, be)) {
191 997641a8 balrog
            fprintf(stderr, "qemu: Error registering flash memory %d.\n",
192 997641a8 balrog
                           fl_idx);
193 997641a8 balrog
        }
194 997641a8 balrog
        fl_idx++;
195 997641a8 balrog
    } else {
196 2507c12a Alexander Graf
        io = cpu_register_io_memory(static_readfn, static_writefn, &cs1val,
197 2507c12a Alexander Graf
                                    DEVICE_NATIVE_ENDIAN);
198 997641a8 balrog
        cpu_register_physical_memory(OMAP_CS1_BASE, OMAP_CS1_SIZE, io);
199 997641a8 balrog
    }
200 997641a8 balrog
201 997641a8 balrog
    if (!kernel_filename && !fl_idx) {
202 997641a8 balrog
        fprintf(stderr, "Kernel or Flash image must be specified\n");
203 997641a8 balrog
        exit(1);
204 997641a8 balrog
    }
205 997641a8 balrog
206 997641a8 balrog
    /* Load the kernel.  */
207 997641a8 balrog
    if (kernel_filename) {
208 997641a8 balrog
        sx1_binfo.kernel_filename = kernel_filename;
209 997641a8 balrog
        sx1_binfo.kernel_cmdline = kernel_cmdline;
210 997641a8 balrog
        sx1_binfo.initrd_filename = initrd_filename;
211 997641a8 balrog
        arm_load_kernel(cpu->env, &sx1_binfo);
212 997641a8 balrog
    }
213 997641a8 balrog
214 5f70aab1 aurel32
    /* TODO: fix next line */
215 5f70aab1 aurel32
    //~ qemu_console_resize(ds, 640, 480);
216 997641a8 balrog
}
217 997641a8 balrog
218 c227f099 Anthony Liguori
static void sx1_init_v1(ram_addr_t ram_size,
219 5f70aab1 aurel32
                const char *boot_device,
220 997641a8 balrog
                const char *kernel_filename, const char *kernel_cmdline,
221 997641a8 balrog
                const char *initrd_filename, const char *cpu_model)
222 997641a8 balrog
{
223 fbe1b595 Paul Brook
    sx1_init(ram_size, boot_device, kernel_filename,
224 997641a8 balrog
                kernel_cmdline, initrd_filename, cpu_model, 1);
225 997641a8 balrog
}
226 997641a8 balrog
227 c227f099 Anthony Liguori
static void sx1_init_v2(ram_addr_t ram_size,
228 5f70aab1 aurel32
                const char *boot_device,
229 997641a8 balrog
                const char *kernel_filename, const char *kernel_cmdline,
230 997641a8 balrog
                const char *initrd_filename, const char *cpu_model)
231 997641a8 balrog
{
232 fbe1b595 Paul Brook
    sx1_init(ram_size, boot_device, kernel_filename,
233 997641a8 balrog
                kernel_cmdline, initrd_filename, cpu_model, 2);
234 997641a8 balrog
}
235 997641a8 balrog
236 f80f9ec9 Anthony Liguori
static QEMUMachine sx1_machine_v2 = {
237 997641a8 balrog
    .name = "sx1",
238 997641a8 balrog
    .desc = "Siemens SX1 (OMAP310) V2",
239 997641a8 balrog
    .init = sx1_init_v2,
240 997641a8 balrog
};
241 997641a8 balrog
242 f80f9ec9 Anthony Liguori
static QEMUMachine sx1_machine_v1 = {
243 997641a8 balrog
    .name = "sx1-v1",
244 997641a8 balrog
    .desc = "Siemens SX1 (OMAP310) V1",
245 997641a8 balrog
    .init = sx1_init_v1,
246 997641a8 balrog
};
247 f80f9ec9 Anthony Liguori
248 f80f9ec9 Anthony Liguori
static void sx1_machine_init(void)
249 f80f9ec9 Anthony Liguori
{
250 f80f9ec9 Anthony Liguori
    qemu_register_machine(&sx1_machine_v2);
251 f80f9ec9 Anthony Liguori
    qemu_register_machine(&sx1_machine_v1);
252 f80f9ec9 Anthony Liguori
}
253 f80f9ec9 Anthony Liguori
254 f80f9ec9 Anthony Liguori
machine_init(sx1_machine_init);