Merge commit 'gnu/master' into test
[qemu] / hw / beagle.c
1 /*
2  * Beagle board emulation. http://beagleboard.org/
3  * 
4  * Original code Copyright (C) 2008 yajin(yajin@vm-kernel.org)
5  * Rewrite Copyright (C) 2009 Nokia Corporation
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 or
10  * (at your option) version 3 of the License.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20  * MA 02111-1307 USA
21  */
22
23 #include "qemu-common.h"
24 #include "sysemu.h"
25 #include "omap.h"
26 #include "arm-misc.h"
27 #include "boards.h"
28 #include "i2c.h"
29 #include "net.h"
30 #include "devices.h"
31 #include "flash.h"
32
33 #define BEAGLE_NAND_CS       0
34 #define BEAGLE_SMC_CS        1
35 #define BEAGLE_NAND_PAGESIZE 0x800
36 #define BEAGLE_SDRAM_SIZE    (128 * 1024 * 1024) /* 128MB */
37
38 /* Beagle board support */
39 struct beagle_s {
40     struct omap_mpu_state_s *cpu;
41     
42     NANDFlashState *nand;
43     struct omap3_lcd_panel_s *lcd_panel;
44     i2c_bus *i2c;
45     void *twl4030;
46 };
47
48 static void beagle_init(ram_addr_t ram_size,
49                         const char *boot_device,
50                         const char *kernel_filename,
51                         const char *kernel_cmdline,
52                         const char *initrd_filename,
53                         const char *cpu_model)
54 {
55     struct beagle_s *s = (struct beagle_s *) qemu_mallocz(sizeof(*s));
56     int sdindex = drive_get_index(IF_SD, 0, 0);
57     void *opaque;
58     
59     if (sdindex == -1) {
60         fprintf(stderr, "%s: missing SecureDigital device\n", __FUNCTION__);
61         exit(1);
62     }
63         s->cpu = omap3530_mpu_init(ram_size, NULL, NULL, serial_hds[0]);
64
65         s->nand = nand_init(NAND_MFR_MICRON, 0xba); /* MT29F2G16ABC */
66         nand_setpins(s->nand, 0, 0, 0, 1, 0); /* no write-protect */
67     omap_gpmc_attach(s->cpu->gpmc, BEAGLE_NAND_CS, 0, NULL, NULL, s->nand, 2);
68     omap3_mmc_attach(s->cpu->omap3_mmc[0], drives_table[sdindex].bdrv);
69
70     s->i2c = omap_i2c_bus(s->cpu->i2c[0]);
71     s->twl4030 = twl4030_init(s->i2c, s->cpu->irq[0][OMAP_INT_3XXX_SYS_NIRQ]);
72     opaque = smc91c111_init_lite(&nd_table[0], /*0x08000000,*/
73                     omap2_gpio_in_get(s->cpu->gpif, 54)[0]);
74     omap_gpmc_attach(s->cpu->gpmc, BEAGLE_SMC_CS, smc91c111_iomemtype(opaque),
75                      NULL, NULL, opaque, 0);
76
77         s->lcd_panel = omap3_lcd_panel_init();
78         omap3_lcd_panel_attach(s->cpu->dss, 0, s->lcd_panel);
79     
80     omap3_boot_rom_emu(s->cpu);
81 }
82
83 QEMUMachine beagle_machine = {
84     .name =        "beagle",
85     .desc =        "Beagle board (OMAP3530)",
86     .init =        beagle_init,
87 };
88
89 static void beagle_machine_init(void)
90 {
91     qemu_register_machine(&beagle_machine);
92 }
93
94 machine_init(beagle_machine_init);