xref: /openbmc/qemu/hw/arm/gumstix.c (revision fa1d36df)
1 /*
2  * Gumstix Platforms
3  *
4  * Copyright (c) 2007 by Thorsten Zitterell <info@bitmux.org>
5  *
6  * Code based on spitz platform by Andrzej Zaborowski <balrog@zabor.org>
7  *
8  * This code is licensed under the GNU GPL v2.
9  *
10  * Contributions after 2012-01-13 are licensed under the terms of the
11  * GNU GPL, version 2 or (at your option) any later version.
12  */
13 
14 /*
15  * Example usage:
16  *
17  * connex:
18  * =======
19  * create image:
20  * # dd of=flash bs=1k count=16k if=/dev/zero
21  * # dd of=flash bs=1k conv=notrunc if=u-boot.bin
22  * # dd of=flash bs=1k conv=notrunc seek=256 if=rootfs.arm_nofpu.jffs2
23  * start it:
24  * # qemu-system-arm -M connex -pflash flash -monitor null -nographic
25  *
26  * verdex:
27  * =======
28  * create image:
29  * # dd of=flash bs=1k count=32k if=/dev/zero
30  * # dd of=flash bs=1k conv=notrunc if=u-boot.bin
31  * # dd of=flash bs=1k conv=notrunc seek=256 if=rootfs.arm_nofpu.jffs2
32  * # dd of=flash bs=1k conv=notrunc seek=31744 if=uImage
33  * start it:
34  * # qemu-system-arm -M verdex -pflash flash -monitor null -nographic -m 289
35  */
36 
37 #include "hw/hw.h"
38 #include "hw/arm/pxa.h"
39 #include "net/net.h"
40 #include "hw/block/flash.h"
41 #include "hw/devices.h"
42 #include "hw/boards.h"
43 #include "sysemu/block-backend.h"
44 #include "sysemu/blockdev.h"
45 #include "exec/address-spaces.h"
46 #include "sysemu/qtest.h"
47 
48 static const int sector_len = 128 * 1024;
49 
50 static void connex_init(MachineState *machine)
51 {
52     PXA2xxState *cpu;
53     DriveInfo *dinfo;
54     int be;
55     MemoryRegion *address_space_mem = get_system_memory();
56 
57     uint32_t connex_rom = 0x01000000;
58     uint32_t connex_ram = 0x04000000;
59 
60     cpu = pxa255_init(address_space_mem, connex_ram);
61 
62     dinfo = drive_get(IF_PFLASH, 0, 0);
63     if (!dinfo && !qtest_enabled()) {
64         fprintf(stderr, "A flash image must be given with the "
65                 "'pflash' parameter\n");
66         exit(1);
67     }
68 
69 #ifdef TARGET_WORDS_BIGENDIAN
70     be = 1;
71 #else
72     be = 0;
73 #endif
74     if (!pflash_cfi01_register(0x00000000, NULL, "connext.rom", connex_rom,
75                                dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL,
76                                sector_len, connex_rom / sector_len,
77                                2, 0, 0, 0, 0, be)) {
78         fprintf(stderr, "qemu: Error registering flash memory.\n");
79         exit(1);
80     }
81 
82     /* Interrupt line of NIC is connected to GPIO line 36 */
83     smc91c111_init(&nd_table[0], 0x04000300,
84                     qdev_get_gpio_in(cpu->gpio, 36));
85 }
86 
87 static void verdex_init(MachineState *machine)
88 {
89     const char *cpu_model = machine->cpu_model;
90     PXA2xxState *cpu;
91     DriveInfo *dinfo;
92     int be;
93     MemoryRegion *address_space_mem = get_system_memory();
94 
95     uint32_t verdex_rom = 0x02000000;
96     uint32_t verdex_ram = 0x10000000;
97 
98     cpu = pxa270_init(address_space_mem, verdex_ram, cpu_model ?: "pxa270-c0");
99 
100     dinfo = drive_get(IF_PFLASH, 0, 0);
101     if (!dinfo && !qtest_enabled()) {
102         fprintf(stderr, "A flash image must be given with the "
103                 "'pflash' parameter\n");
104         exit(1);
105     }
106 
107 #ifdef TARGET_WORDS_BIGENDIAN
108     be = 1;
109 #else
110     be = 0;
111 #endif
112     if (!pflash_cfi01_register(0x00000000, NULL, "verdex.rom", verdex_rom,
113                                dinfo ? blk_bs(blk_by_legacy_dinfo(dinfo)) : NULL,
114                                sector_len, verdex_rom / sector_len,
115                                2, 0, 0, 0, 0, be)) {
116         fprintf(stderr, "qemu: Error registering flash memory.\n");
117         exit(1);
118     }
119 
120     /* Interrupt line of NIC is connected to GPIO line 99 */
121     smc91c111_init(&nd_table[0], 0x04000300,
122                     qdev_get_gpio_in(cpu->gpio, 99));
123 }
124 
125 static QEMUMachine connex_machine = {
126     .name = "connex",
127     .desc = "Gumstix Connex (PXA255)",
128     .init = connex_init,
129 };
130 
131 static QEMUMachine verdex_machine = {
132     .name = "verdex",
133     .desc = "Gumstix Verdex (PXA270)",
134     .init = verdex_init,
135 };
136 
137 static void gumstix_machine_init(void)
138 {
139     qemu_register_machine(&connex_machine);
140     qemu_register_machine(&verdex_machine);
141 }
142 
143 machine_init(gumstix_machine_init);
144