Gumstix 'connex' board support by Thorsten Zitterell.
[qemu] / hw / gumstix.c
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
11 #include "vl.h"
12
13 static void connex_smc_irq(void *opaque, int line, int level)
14 {
15     /* Interrupt line of NIC is connected to GPIO line 36 */
16     struct pxa2xx_state_s *cpu = (struct pxa2xx_state_s *) opaque;
17     pxa2xx_gpio_set(cpu->gpio, 36, level);
18 }
19
20 /* Board init. */
21 enum gumstix_model_e { connex };
22
23 static void gumstix_common_init(int ram_size, int vga_ram_size,
24                 DisplayState *ds, const char *kernel_filename,
25                 const char *kernel_cmdline, const char *initrd_filename,
26                 const char *cpu_model, enum gumstix_model_e model)
27 {
28     struct pxa2xx_state_s *cpu;
29
30     uint32_t gumstix_rom = 0x02000000;
31     uint32_t gumstix_ram = 0x08000000;
32
33     if (ram_size < (gumstix_ram + gumstix_rom + PXA2XX_INTERNAL_SIZE)) {
34         fprintf(stderr, "This platform requires %i bytes of memory\n",
35                 gumstix_ram + gumstix_rom + PXA2XX_INTERNAL_SIZE);
36         exit(1);
37     }
38
39     cpu = pxa255_init(gumstix_ram, ds);
40
41     if (pflash_table[0] == NULL) {
42         fprintf(stderr, "A flash image must be given with the "
43                 "'pflash' parameter\n");
44         exit(1);
45     }
46
47     if (!pflash_register(0x00000000, gumstix_ram + PXA2XX_INTERNAL_SIZE,
48             pflash_table[0], 128 * 1024, 128, 2, 0, 0, 0, 0)) {
49         fprintf(stderr, "qemu: Error register flash memory.\n");
50         exit(1);
51     }
52
53     cpu->env->regs[15] = 0x00000000;
54
55     qemu_irq *irq = qemu_allocate_irqs(connex_smc_irq, cpu, 1);
56     smc91c111_init(&nd_table[0], 0x04000300, *irq);
57 }
58
59 static void connex_init(int ram_size, int vga_ram_size,
60                 const char *boot_device, DisplayState *ds,
61                 const char **fd_filename, int snapshot,
62                 const char *kernel_filename, const char *kernel_cmdline,
63                 const char *initrd_filename, const char *cpu_model)
64 {
65     gumstix_common_init(ram_size, vga_ram_size, ds, kernel_filename,
66                 kernel_cmdline, initrd_filename, cpu_model, connex);
67 }
68
69 QEMUMachine connex_machine = {
70     "connex",
71     "Gumstix Connex (PXA255)",
72     connex_init,
73 };