Statistics
| Branch: | Revision:

root / hw / omap_sx1.c @ e4c7d2ae

History | View | Annotate | Download (7.8 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 1724f049 Alex Williamson
                                 qemu_ram_alloc(NULL, "omap_sx1.flash0-0",
143 1724f049 Alex Williamson
                                                flash_size) | IO_MEM_ROM);
144 997641a8 balrog
145 1eed09cb Avi Kivity
    io = cpu_register_io_memory(static_readfn, static_writefn, &cs0val);
146 997641a8 balrog
    cpu_register_physical_memory(OMAP_CS0_BASE + flash_size,
147 997641a8 balrog
                    OMAP_CS0_SIZE - flash_size, io);
148 1eed09cb Avi Kivity
    io = cpu_register_io_memory(static_readfn, static_writefn, &cs2val);
149 997641a8 balrog
    cpu_register_physical_memory(OMAP_CS2_BASE, OMAP_CS2_SIZE, io);
150 1eed09cb Avi Kivity
    io = cpu_register_io_memory(static_readfn, static_writefn, &cs3val);
151 997641a8 balrog
    cpu_register_physical_memory(OMAP_CS3_BASE, OMAP_CS3_SIZE, io);
152 997641a8 balrog
153 997641a8 balrog
    fl_idx = 0;
154 3d08ff69 Blue Swirl
#ifdef TARGET_WORDS_BIGENDIAN
155 3d08ff69 Blue Swirl
    be = 1;
156 3d08ff69 Blue Swirl
#else
157 3d08ff69 Blue Swirl
    be = 0;
158 3d08ff69 Blue Swirl
#endif
159 997641a8 balrog
160 751c6a17 Gerd Hoffmann
    if ((dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
161 1724f049 Alex Williamson
        if (!pflash_cfi01_register(OMAP_CS0_BASE, qemu_ram_alloc(NULL,
162 1724f049 Alex Williamson
                                   "omap_sx1.flash0-1", flash_size),
163 3d08ff69 Blue Swirl
                                   dinfo->bdrv, sector_size,
164 3d08ff69 Blue Swirl
                                   flash_size / sector_size,
165 3d08ff69 Blue Swirl
                                   4, 0, 0, 0, 0, be)) {
166 997641a8 balrog
            fprintf(stderr, "qemu: Error registering flash memory %d.\n",
167 997641a8 balrog
                           fl_idx);
168 997641a8 balrog
        }
169 997641a8 balrog
        fl_idx++;
170 997641a8 balrog
    }
171 997641a8 balrog
172 997641a8 balrog
    if ((version == 1) &&
173 751c6a17 Gerd Hoffmann
            (dinfo = drive_get(IF_PFLASH, 0, fl_idx)) != NULL) {
174 997641a8 balrog
        cpu_register_physical_memory(OMAP_CS1_BASE, flash1_size,
175 1724f049 Alex Williamson
                                     qemu_ram_alloc(NULL, "omap_sx1.flash1-0",
176 1724f049 Alex Williamson
                                                    flash1_size) | IO_MEM_ROM);
177 1eed09cb Avi Kivity
        io = cpu_register_io_memory(static_readfn, static_writefn, &cs1val);
178 997641a8 balrog
        cpu_register_physical_memory(OMAP_CS1_BASE + flash1_size,
179 997641a8 balrog
                        OMAP_CS1_SIZE - flash1_size, io);
180 997641a8 balrog
181 1724f049 Alex Williamson
        if (!pflash_cfi01_register(OMAP_CS1_BASE, qemu_ram_alloc(NULL,
182 1724f049 Alex Williamson
                                   "omap_sx1.flash1-1", flash1_size),
183 3d08ff69 Blue Swirl
                                   dinfo->bdrv, sector_size,
184 3d08ff69 Blue Swirl
                                   flash1_size / sector_size,
185 3d08ff69 Blue Swirl
                                   4, 0, 0, 0, 0, be)) {
186 997641a8 balrog
            fprintf(stderr, "qemu: Error registering flash memory %d.\n",
187 997641a8 balrog
                           fl_idx);
188 997641a8 balrog
        }
189 997641a8 balrog
        fl_idx++;
190 997641a8 balrog
    } else {
191 1eed09cb Avi Kivity
        io = cpu_register_io_memory(static_readfn, static_writefn, &cs1val);
192 997641a8 balrog
        cpu_register_physical_memory(OMAP_CS1_BASE, OMAP_CS1_SIZE, io);
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);