2 * Beagle board emulation. http://beagleboard.org/
4 * Copyright (C) 2008 yajin(yajin@vm-kernel.org)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 or
9 * (at your option) version 3 of the License.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
22 #include "qemu-common.h"
35 #define BEAGLE_NAND_CS 0
36 #define BEAGLE_NAND_PAGESIZE 0x800
41 #define GPMC_ONENAND 3
46 #define TST_DEVICE 0x0
47 #define EMU_DEVICE 0x1
51 /* Beagle board support */
53 struct omap_mpu_state_s *cpu;
55 struct nand_flash_s *nand;
56 struct omap3_lcd_panel_s *lcd_panel;
58 struct twl4030_s *twl4030;
61 static struct arm_boot_info beagle_binfo = {
62 .ram_size = 0x08000000,
65 static void beagle_nand_pread(struct nand_flash_s *nand,
73 if ((len&1) || (addr&1)) {
74 fprintf(stderr, "%s: read byte length and address must be even (x16 device!)\n",
78 /* send command: reset */
79 nand_setpins(nand, 1, 0, 0, 1, 0);
80 nand_setio(nand, 0xff);
82 /* send command: read page (cycle1) */
83 nand_setpins(nand, 1, 0, 0, 1, 0);
86 nand_setpins(nand, 0, 1, 0, 1, 0);
87 nand_setio(nand, (uint32_t)((addr >> 1) & 0xff));
88 nand_setio(nand, (uint32_t)((addr >> 9) & 0x3));
89 nand_setio(nand, (uint32_t)((addr >> 11) & 0xff));
90 nand_setio(nand, (uint32_t)((addr >> 19) & 0xff));
91 nand_setio(nand, (uint32_t)((addr >> 27) & 0x1));
92 /* send command: read page (cycle2) */
93 nand_setpins(nand, 1, 0, 0, 1, 0);
94 nand_setio(nand, 0x30);
96 nand_setpins(nand, 0, 0, 0, 1, 0);
97 for (i = (BEAGLE_NAND_PAGESIZE / 2) - (addr & 0x3ff); i && len; i--) {
99 *(data++) = (uint8_t)(x & 0xff);
100 *(data++) = (uint8_t)((x >> 8) & 0xff);
107 static void beagle_init(ram_addr_t ram_size, int vga_ram_size,
108 const char *boot_device,
109 const char *kernel_filename, const char *kernel_cmdline,
110 const char *initrd_filename, const char *cpu_model)
112 struct beagle_s *s = (struct beagle_s *) qemu_mallocz(sizeof(*s));
113 int sdram_size = beagle_binfo.ram_size;
114 int sdindex = drive_get_index(IF_SD, 0, 0);
117 fprintf(stderr, "qemu: missing SecureDigital device\n");
121 if (ram_size < sdram_size + OMAP3530_SRAM_SIZE) {
122 fprintf(stderr, "This architecture uses %i bytes of memory\n",
123 sdram_size + OMAP3530_SRAM_SIZE);
126 s->cpu = omap3530_mpu_init(sdram_size, NULL);
129 omap_uart_attach(s->cpu->uart[2], serial_hds[0]);
131 s->nand = nand_init(NAND_MFR_MICRON, 0xba); /* MT29F2G16ABC */
132 nand_setpins(s->nand, 0, 0, 0, 1, 0); /* no write-protect */
133 omap_gpmc_attach(s->cpu->gpmc, BEAGLE_NAND_CS, 0, NULL, NULL, s, s->nand);
134 omap3_mmc_attach(s->cpu->omap3_mmc[0], drives_table[sdindex].bdrv);
136 s->i2c = omap_i2c_bus(s->cpu->i2c[0]);
137 s->twl4030 = twl4030_init(s->i2c, s->cpu->irq[0][OMAP_INT_35XX_SYS_NIRQ]);
139 s->lcd_panel = omap3_lcd_panel_init();
140 omap3_lcd_panel_attach(s->cpu->dss, 0, s->lcd_panel);
142 omap3_set_mem_type(s->cpu, GPMC_NAND);
143 omap3_set_device_type(s->cpu,GP_DEVICE);
144 if (!omap3_mmc_boot(s->cpu)
145 && !omap3_nand_boot(s->cpu, s->nand, beagle_nand_pread)) {
146 fprintf(stderr, "%s: boot from MMC and NAND failed\n",
152 QEMUMachine beagle_machine = {
154 .desc = "Beagle board (OMAP3530)",
156 .ram_require = (0x08000000 + OMAP3530_SRAM_SIZE) | RAMSIZE_FIXED,