Statistics
| Branch: | Revision:

root / hw / omap_sx1.c @ 22ed1d34

History | View | Annotate | Download (7.7 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 751c6a17 Gerd Hoffmann
    DriveInfo *dinfo;
130 997641a8 balrog
    int fl_idx;
131 997641a8 balrog
    uint32_t flash_size = flash0_size;
132 3d08ff69 Blue Swirl
    int be;
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 22ed1d34 Blue Swirl
                                 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 3d08ff69 Blue Swirl
#ifdef TARGET_WORDS_BIGENDIAN
154 3d08ff69 Blue Swirl
    be = 1;
155 3d08ff69 Blue Swirl
#else
156 3d08ff69 Blue Swirl
    be = 0;
157 3d08ff69 Blue Swirl
#endif
158 997641a8 balrog
159 751c6a17 Gerd Hoffmann
    if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
160 997641a8 balrog
        if (!pflash_cfi01_register(OMAP_CS0_BASE, qemu_ram_alloc(flash_size),
161 3d08ff69 Blue Swirl
                                   dinfo->bdrv, sector_size,
162 3d08ff69 Blue Swirl
                                   flash_size / sector_size,
163 3d08ff69 Blue Swirl
                                   4, 0, 0, 0, 0, be)) {
164 997641a8 balrog
            fprintf(stderr, "qemu: Error registering flash memory %d.\n",
165 997641a8 balrog
                           fl_idx);
166 997641a8 balrog
        }
167 997641a8 balrog
        fl_idx++;
168 997641a8 balrog
    }
169 997641a8 balrog
170 997641a8 balrog
    if ((version == 1) &&
171 751c6a17 Gerd Hoffmann
            (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
172 997641a8 balrog
        cpu_register_physical_memory(OMAP_CS1_BASE, flash1_size,
173 22ed1d34 Blue Swirl
                                     qemu_ram_alloc(flash1_size) | IO_MEM_ROM);
174 1eed09cb Avi Kivity
        io = cpu_register_io_memory(static_readfn, static_writefn, &cs1val);
175 997641a8 balrog
        cpu_register_physical_memory(OMAP_CS1_BASE + flash1_size,
176 997641a8 balrog
                        OMAP_CS1_SIZE - flash1_size, io);
177 997641a8 balrog
178 997641a8 balrog
        if (!pflash_cfi01_register(OMAP_CS1_BASE, qemu_ram_alloc(flash1_size),
179 3d08ff69 Blue Swirl
                                   dinfo->bdrv, sector_size,
180 3d08ff69 Blue Swirl
                                   flash1_size / sector_size,
181 3d08ff69 Blue Swirl
                                   4, 0, 0, 0, 0, be)) {
182 997641a8 balrog
            fprintf(stderr, "qemu: Error registering flash memory %d.\n",
183 997641a8 balrog
                           fl_idx);
184 997641a8 balrog
        }
185 997641a8 balrog
        fl_idx++;
186 997641a8 balrog
    } else {
187 1eed09cb Avi Kivity
        io = cpu_register_io_memory(static_readfn, static_writefn, &cs1val);
188 997641a8 balrog
        cpu_register_physical_memory(OMAP_CS1_BASE, OMAP_CS1_SIZE, io);
189 997641a8 balrog
    }
190 997641a8 balrog
191 997641a8 balrog
    if (!kernel_filename && !fl_idx) {
192 997641a8 balrog
        fprintf(stderr, "Kernel or Flash image must be specified\n");
193 997641a8 balrog
        exit(1);
194 997641a8 balrog
    }
195 997641a8 balrog
196 997641a8 balrog
    /* Load the kernel.  */
197 997641a8 balrog
    if (kernel_filename) {
198 997641a8 balrog
        /* Start at bootloader.  */
199 997641a8 balrog
        cpu->env->regs[15] = sx1_binfo.loader_start;
200 997641a8 balrog
201 997641a8 balrog
        sx1_binfo.kernel_filename = kernel_filename;
202 997641a8 balrog
        sx1_binfo.kernel_cmdline = kernel_cmdline;
203 997641a8 balrog
        sx1_binfo.initrd_filename = initrd_filename;
204 997641a8 balrog
        arm_load_kernel(cpu->env, &sx1_binfo);
205 997641a8 balrog
    } else {
206 997641a8 balrog
        cpu->env->regs[15] = 0x00000000;
207 997641a8 balrog
    }
208 997641a8 balrog
209 5f70aab1 aurel32
    /* TODO: fix next line */
210 5f70aab1 aurel32
    //~ qemu_console_resize(ds, 640, 480);
211 997641a8 balrog
}
212 997641a8 balrog
213 c227f099 Anthony Liguori
static void sx1_init_v1(ram_addr_t ram_size,
214 5f70aab1 aurel32
                const char *boot_device,
215 997641a8 balrog
                const char *kernel_filename, const char *kernel_cmdline,
216 997641a8 balrog
                const char *initrd_filename, const char *cpu_model)
217 997641a8 balrog
{
218 fbe1b595 Paul Brook
    sx1_init(ram_size, boot_device, kernel_filename,
219 997641a8 balrog
                kernel_cmdline, initrd_filename, cpu_model, 1);
220 997641a8 balrog
}
221 997641a8 balrog
222 c227f099 Anthony Liguori
static void sx1_init_v2(ram_addr_t ram_size,
223 5f70aab1 aurel32
                const char *boot_device,
224 997641a8 balrog
                const char *kernel_filename, const char *kernel_cmdline,
225 997641a8 balrog
                const char *initrd_filename, const char *cpu_model)
226 997641a8 balrog
{
227 fbe1b595 Paul Brook
    sx1_init(ram_size, boot_device, kernel_filename,
228 997641a8 balrog
                kernel_cmdline, initrd_filename, cpu_model, 2);
229 997641a8 balrog
}
230 997641a8 balrog
231 f80f9ec9 Anthony Liguori
static QEMUMachine sx1_machine_v2 = {
232 997641a8 balrog
    .name = "sx1",
233 997641a8 balrog
    .desc = "Siemens SX1 (OMAP310) V2",
234 997641a8 balrog
    .init = sx1_init_v2,
235 997641a8 balrog
};
236 997641a8 balrog
237 f80f9ec9 Anthony Liguori
static QEMUMachine sx1_machine_v1 = {
238 997641a8 balrog
    .name = "sx1-v1",
239 997641a8 balrog
    .desc = "Siemens SX1 (OMAP310) V1",
240 997641a8 balrog
    .init = sx1_init_v1,
241 997641a8 balrog
};
242 f80f9ec9 Anthony Liguori
243 f80f9ec9 Anthony Liguori
static void sx1_machine_init(void)
244 f80f9ec9 Anthony Liguori
{
245 f80f9ec9 Anthony Liguori
    qemu_register_machine(&sx1_machine_v2);
246 f80f9ec9 Anthony Liguori
    qemu_register_machine(&sx1_machine_v1);
247 f80f9ec9 Anthony Liguori
}
248 f80f9ec9 Anthony Liguori
249 f80f9ec9 Anthony Liguori
machine_init(sx1_machine_init);