blob: af8b464b888882add0b274741d9eaf27731444ca [file] [log] [blame]
balrog05ee37e2007-11-17 11:50:55 +00001/*
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 */
balrog3e3f6752007-11-24 23:47:38 +000010
11/*
12 * Example usage:
13 *
14 * connex:
15 * =======
16 * create image:
17 * # dd of=flash bs=1k count=16k if=/dev/zero
18 * # dd of=flash bs=1k conv=notrunc if=u-boot.bin
19 * # dd of=flash bs=1k conv=notrunc seek=256 if=rootfs.arm_nofpu.jffs2
20 * start it:
21 * # qemu-system-arm -M connex -pflash flash -monitor null -nographic
22 *
23 * verdex:
24 * =======
25 * create image:
26 * # dd of=flash bs=1k count=32k if=/dev/zero
27 * # dd of=flash bs=1k conv=notrunc if=u-boot.bin
28 * # dd of=flash bs=1k conv=notrunc seek=256 if=rootfs.arm_nofpu.jffs2
29 * # dd of=flash bs=1k conv=notrunc seek=31744 if=uImage
30 * start it:
31 * # qemu-system-arm -M verdex -pflash flash -monitor null -nographic -m 289
32 */
balrog05ee37e2007-11-17 11:50:55 +000033
pbrook87ecb682007-11-17 17:14:51 +000034#include "hw.h"
35#include "pxa.h"
36#include "net.h"
37#include "flash.h"
38#include "sysemu.h"
39#include "devices.h"
40#include "boards.h"
Blue Swirl24463332010-08-24 15:22:24 +000041#include "blockdev.h"
balrog05ee37e2007-11-17 11:50:55 +000042
balrog1fc678c2007-11-25 00:29:23 +000043static const int sector_len = 128 * 1024;
44
Anthony Liguoric227f092009-10-01 16:12:16 -050045static void connex_init(ram_addr_t ram_size,
aliguori3023f332009-01-16 19:04:14 +000046 const char *boot_device,
balrog3e3f6752007-11-24 23:47:38 +000047 const char *kernel_filename, const char *kernel_cmdline,
48 const char *initrd_filename, const char *cpu_model)
balrog05ee37e2007-11-17 11:50:55 +000049{
Paul Brookbc24a222009-05-10 01:44:56 +010050 PXA2xxState *cpu;
Gerd Hoffmann751c6a12009-07-22 16:42:57 +020051 DriveInfo *dinfo;
Blue Swirl3d08ff62010-03-29 19:23:56 +000052 int be;
balrog05ee37e2007-11-17 11:50:55 +000053
balrog3e3f6752007-11-24 23:47:38 +000054 uint32_t connex_rom = 0x01000000;
55 uint32_t connex_ram = 0x04000000;
balrog05ee37e2007-11-17 11:50:55 +000056
aliguori3023f332009-01-16 19:04:14 +000057 cpu = pxa255_init(connex_ram);
balrog05ee37e2007-11-17 11:50:55 +000058
Gerd Hoffmann751c6a12009-07-22 16:42:57 +020059 dinfo = drive_get(IF_PFLASH, 0, 0);
60 if (!dinfo) {
balrog05ee37e2007-11-17 11:50:55 +000061 fprintf(stderr, "A flash image must be given with the "
62 "'pflash' parameter\n");
63 exit(1);
64 }
65
Blue Swirl3d08ff62010-03-29 19:23:56 +000066#ifdef TARGET_WORDS_BIGENDIAN
67 be = 1;
68#else
69 be = 0;
70#endif
Alex Williamson1724f042010-06-25 11:09:35 -060071 if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(NULL, "connext.rom",
72 connex_rom),
Blue Swirl3d08ff62010-03-29 19:23:56 +000073 dinfo->bdrv, sector_len, connex_rom / sector_len,
74 2, 0, 0, 0, 0, be)) {
balrog3e3f6752007-11-24 23:47:38 +000075 fprintf(stderr, "qemu: Error registering flash memory.\n");
balrog05ee37e2007-11-17 11:50:55 +000076 exit(1);
77 }
78
balrog5697ff62008-01-14 02:39:21 +000079 /* Interrupt line of NIC is connected to GPIO line 36 */
balrog38641a52007-11-17 14:07:13 +000080 smc91c111_init(&nd_table[0], 0x04000300,
81 pxa2xx_gpio_in_get(cpu->gpio)[36]);
balrog05ee37e2007-11-17 11:50:55 +000082}
83
Anthony Liguoric227f092009-10-01 16:12:16 -050084static void verdex_init(ram_addr_t ram_size,
aliguori3023f332009-01-16 19:04:14 +000085 const char *boot_device,
balrog05ee37e2007-11-17 11:50:55 +000086 const char *kernel_filename, const char *kernel_cmdline,
87 const char *initrd_filename, const char *cpu_model)
88{
Paul Brookbc24a222009-05-10 01:44:56 +010089 PXA2xxState *cpu;
Gerd Hoffmann751c6a12009-07-22 16:42:57 +020090 DriveInfo *dinfo;
Blue Swirl3d08ff62010-03-29 19:23:56 +000091 int be;
balrog3e3f6752007-11-24 23:47:38 +000092
93 uint32_t verdex_rom = 0x02000000;
94 uint32_t verdex_ram = 0x10000000;
95
aliguori3023f332009-01-16 19:04:14 +000096 cpu = pxa270_init(verdex_ram, cpu_model ?: "pxa270-c0");
balrog3e3f6752007-11-24 23:47:38 +000097
Gerd Hoffmann751c6a12009-07-22 16:42:57 +020098 dinfo = drive_get(IF_PFLASH, 0, 0);
99 if (!dinfo) {
balrog3e3f6752007-11-24 23:47:38 +0000100 fprintf(stderr, "A flash image must be given with the "
101 "'pflash' parameter\n");
102 exit(1);
103 }
104
Blue Swirl3d08ff62010-03-29 19:23:56 +0000105#ifdef TARGET_WORDS_BIGENDIAN
106 be = 1;
107#else
108 be = 0;
109#endif
Alex Williamson1724f042010-06-25 11:09:35 -0600110 if (!pflash_cfi01_register(0x00000000, qemu_ram_alloc(NULL, "verdex.rom",
111 verdex_rom),
Blue Swirl3d08ff62010-03-29 19:23:56 +0000112 dinfo->bdrv, sector_len, verdex_rom / sector_len,
113 2, 0, 0, 0, 0, be)) {
balrog3e3f6752007-11-24 23:47:38 +0000114 fprintf(stderr, "qemu: Error registering flash memory.\n");
115 exit(1);
116 }
117
balrog3e3f6752007-11-24 23:47:38 +0000118 /* Interrupt line of NIC is connected to GPIO line 99 */
119 smc91c111_init(&nd_table[0], 0x04000300,
120 pxa2xx_gpio_in_get(cpu->gpio)[99]);
balrog05ee37e2007-11-17 11:50:55 +0000121}
122
Anthony Liguorif80f9ec2009-05-20 18:38:09 -0500123static QEMUMachine connex_machine = {
aliguori4b32e162008-10-07 20:34:35 +0000124 .name = "connex",
125 .desc = "Gumstix Connex (PXA255)",
126 .init = connex_init,
balrog05ee37e2007-11-17 11:50:55 +0000127};
balrog3e3f6752007-11-24 23:47:38 +0000128
Anthony Liguorif80f9ec2009-05-20 18:38:09 -0500129static QEMUMachine verdex_machine = {
aliguori4b32e162008-10-07 20:34:35 +0000130 .name = "verdex",
131 .desc = "Gumstix Verdex (PXA270)",
132 .init = verdex_init,
balrog3e3f6752007-11-24 23:47:38 +0000133};
Anthony Liguorif80f9ec2009-05-20 18:38:09 -0500134
135static void gumstix_machine_init(void)
136{
137 qemu_register_machine(&connex_machine);
138 qemu_register_machine(&verdex_machine);
139}
140
141machine_init(gumstix_machine_init);