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
38 /* Beagle board support */
40 struct omap_mpu_state_s *cpu;
42 struct nand_flash_s *nand;
43 struct omap3_lcd_panel_s *lcd_panel;
45 struct twl4030_s *twl4030;
48 static struct arm_boot_info beagle_binfo = {
49 .ram_size = 0x08000000,
52 static void beagle_nand_pread(struct nand_flash_s *nand,
60 if ((len&1) || (addr&1)) {
61 fprintf(stderr, "%s: read byte length and address must be even (x16 device!)\n",
65 /* send command: reset */
66 nand_setpins(nand, 1, 0, 0, 1, 0);
67 nand_setio(nand, 0xff);
69 /* send command: read page (cycle1) */
70 nand_setpins(nand, 1, 0, 0, 1, 0);
73 nand_setpins(nand, 0, 1, 0, 1, 0);
74 nand_setio(nand, (uint32_t)((addr >> 1) & 0xff));
75 nand_setio(nand, (uint32_t)((addr >> 9) & 0x3));
76 nand_setio(nand, (uint32_t)((addr >> 11) & 0xff));
77 nand_setio(nand, (uint32_t)((addr >> 19) & 0xff));
78 nand_setio(nand, (uint32_t)((addr >> 27) & 0x1));
79 /* send command: read page (cycle2) */
80 nand_setpins(nand, 1, 0, 0, 1, 0);
81 nand_setio(nand, 0x30);
83 nand_setpins(nand, 0, 0, 0, 1, 0);
84 for (i = (BEAGLE_NAND_PAGESIZE / 2) - (addr & 0x3ff); i && len; i--) {
86 *(data++) = (uint8_t)(x & 0xff);
87 *(data++) = (uint8_t)((x >> 8) & 0xff);
94 static void beagle_init(ram_addr_t ram_size, int vga_ram_size,
95 const char *boot_device,
96 const char *kernel_filename, const char *kernel_cmdline,
97 const char *initrd_filename, const char *cpu_model)
99 struct beagle_s *s = (struct beagle_s *) qemu_mallocz(sizeof(*s));
100 int sdram_size = beagle_binfo.ram_size;
101 int sdindex = drive_get_index(IF_SD, 0, 0);
104 fprintf(stderr, "qemu: missing SecureDigital device\n");
108 if (ram_size < sdram_size + OMAP3530_SRAM_SIZE) {
109 fprintf(stderr, "This architecture uses %i bytes of memory\n",
110 sdram_size + OMAP3530_SRAM_SIZE);
113 s->cpu = omap3530_mpu_init(sdram_size, NULL);
116 omap_uart_attach(s->cpu->uart[2], serial_hds[0]);
118 s->nand = nand_init(NAND_MFR_MICRON, 0xba); /* MT29F2G16ABC */
119 nand_setpins(s->nand, 0, 0, 0, 1, 0); /* no write-protect */
120 omap_gpmc_attach(s->cpu->gpmc, BEAGLE_NAND_CS, 0, NULL, NULL, s, s->nand);
121 omap3_mmc_attach(s->cpu->omap3_mmc[0], drives_table[sdindex].bdrv);
123 s->i2c = omap_i2c_bus(s->cpu->i2c[0]);
124 s->twl4030 = twl4030_init(s->i2c, s->cpu->irq[0][OMAP_INT_35XX_SYS_NIRQ]);
126 s->lcd_panel = omap3_lcd_panel_init();
127 omap3_lcd_panel_attach(s->cpu->dss, 0, s->lcd_panel);
129 if (!omap3_mmc_boot(s->cpu)
130 && !omap3_nand_boot(s->cpu, s->nand, beagle_nand_pread)) {
131 fprintf(stderr, "%s: boot from MMC and NAND failed\n",
137 QEMUMachine beagle_machine = {
139 .desc = "Beagle board (OMAP3530)",
141 .ram_require = (0x08000000 + OMAP3530_SRAM_SIZE) | RAMSIZE_FIXED,