165f57c43SJean-Christophe Dubois /* 265f57c43SJean-Christophe Dubois * Copyright (c) 2013 Jean-Christophe Dubois <jcd@tribudubois.net> 365f57c43SJean-Christophe Dubois * 465f57c43SJean-Christophe Dubois * PDK Board System emulation. 565f57c43SJean-Christophe Dubois * 665f57c43SJean-Christophe Dubois * Based on hw/arm/kzm.c 765f57c43SJean-Christophe Dubois * 865f57c43SJean-Christophe Dubois * Copyright (c) 2008 OKL and 2011 NICTA 965f57c43SJean-Christophe Dubois * Written by Hans at OK-Labs 1065f57c43SJean-Christophe Dubois * Updated by Peter Chubb. 1165f57c43SJean-Christophe Dubois * 1265f57c43SJean-Christophe Dubois * This program is free software; you can redistribute it and/or modify it 1365f57c43SJean-Christophe Dubois * under the terms of the GNU General Public License as published by the 1465f57c43SJean-Christophe Dubois * Free Software Foundation; either version 2 of the License, or 1565f57c43SJean-Christophe Dubois * (at your option) any later version. 1665f57c43SJean-Christophe Dubois * 1765f57c43SJean-Christophe Dubois * This program is distributed in the hope that it will be useful, but WITHOUT 1865f57c43SJean-Christophe Dubois * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1965f57c43SJean-Christophe Dubois * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2065f57c43SJean-Christophe Dubois * for more details. 2165f57c43SJean-Christophe Dubois * 2265f57c43SJean-Christophe Dubois * You should have received a copy of the GNU General Public License along 2365f57c43SJean-Christophe Dubois * with this program; if not, see <http://www.gnu.org/licenses/>. 2465f57c43SJean-Christophe Dubois */ 2565f57c43SJean-Christophe Dubois 2612b16722SPeter Maydell #include "qemu/osdep.h" 27da34e65cSMarkus Armbruster #include "qapi/error.h" 284771d756SPaolo Bonzini #include "cpu.h" 2965f57c43SJean-Christophe Dubois #include "hw/arm/fsl-imx25.h" 3065f57c43SJean-Christophe Dubois #include "hw/boards.h" 3165f57c43SJean-Christophe Dubois #include "qemu/error-report.h" 3265f57c43SJean-Christophe Dubois #include "exec/address-spaces.h" 3365f57c43SJean-Christophe Dubois #include "sysemu/qtest.h" 3465f57c43SJean-Christophe Dubois #include "hw/i2c/i2c.h" 3565f57c43SJean-Christophe Dubois 3665f57c43SJean-Christophe Dubois /* Memory map for PDK Emulation Baseboard: 3765f57c43SJean-Christophe Dubois * 0x00000000-0x7fffffff See i.MX25 SOC fr support 3865f57c43SJean-Christophe Dubois * 0x80000000-0x87ffffff RAM + Alias EMULATED 3965f57c43SJean-Christophe Dubois * 0x90000000-0x9fffffff RAM + Alias EMULATED 4065f57c43SJean-Christophe Dubois * 0xa0000000-0xa7ffffff Flash IGNORED 4165f57c43SJean-Christophe Dubois * 0xa8000000-0xafffffff Flash IGNORED 4265f57c43SJean-Christophe Dubois * 0xb0000000-0xb1ffffff SRAM IGNORED 4365f57c43SJean-Christophe Dubois * 0xb2000000-0xb3ffffff SRAM IGNORED 4465f57c43SJean-Christophe Dubois * 0xb4000000-0xb5ffffff CS4 IGNORED 4565f57c43SJean-Christophe Dubois * 0xb6000000-0xb8000fff Reserved IGNORED 4665f57c43SJean-Christophe Dubois * 0xb8001000-0xb8001fff SDRAM CTRL reg IGNORED 4765f57c43SJean-Christophe Dubois * 0xb8002000-0xb8002fff WEIM CTRL reg IGNORED 4865f57c43SJean-Christophe Dubois * 0xb8003000-0xb8003fff M3IF CTRL reg IGNORED 4965f57c43SJean-Christophe Dubois * 0xb8004000-0xb8004fff EMI CTRL reg IGNORED 5065f57c43SJean-Christophe Dubois * 0xb8005000-0xbaffffff Reserved IGNORED 5165f57c43SJean-Christophe Dubois * 0xbb000000-0xbb000fff NAND flash area buf IGNORED 5265f57c43SJean-Christophe Dubois * 0xbb001000-0xbb0011ff NAND flash reserved IGNORED 5365f57c43SJean-Christophe Dubois * 0xbb001200-0xbb001dff Reserved IGNORED 5465f57c43SJean-Christophe Dubois * 0xbb001e00-0xbb001fff NAN flash CTRL reg IGNORED 5565f57c43SJean-Christophe Dubois * 0xbb012000-0xbfffffff Reserved IGNORED 5665f57c43SJean-Christophe Dubois * 0xc0000000-0xffffffff Reserved IGNORED 5765f57c43SJean-Christophe Dubois */ 5865f57c43SJean-Christophe Dubois 5965f57c43SJean-Christophe Dubois typedef struct IMX25PDK { 6065f57c43SJean-Christophe Dubois FslIMX25State soc; 6165f57c43SJean-Christophe Dubois MemoryRegion ram; 6265f57c43SJean-Christophe Dubois MemoryRegion ram_alias; 6365f57c43SJean-Christophe Dubois } IMX25PDK; 6465f57c43SJean-Christophe Dubois 6565f57c43SJean-Christophe Dubois static struct arm_boot_info imx25_pdk_binfo; 6665f57c43SJean-Christophe Dubois 6765f57c43SJean-Christophe Dubois static void imx25_pdk_init(MachineState *machine) 6865f57c43SJean-Christophe Dubois { 6965f57c43SJean-Christophe Dubois IMX25PDK *s = g_new0(IMX25PDK, 1); 7065f57c43SJean-Christophe Dubois unsigned int ram_size; 7165f57c43SJean-Christophe Dubois unsigned int alias_offset; 7265f57c43SJean-Christophe Dubois int i; 7365f57c43SJean-Christophe Dubois 74d0313798SPhilippe Mathieu-Daudé object_initialize_child(OBJECT(machine), "soc", &s->soc, sizeof(s->soc), 75d0313798SPhilippe Mathieu-Daudé TYPE_FSL_IMX25, &error_abort, NULL); 7665f57c43SJean-Christophe Dubois 7707d04a02SMarkus Armbruster object_property_set_bool(OBJECT(&s->soc), true, "realized", &error_fatal); 7865f57c43SJean-Christophe Dubois 7965f57c43SJean-Christophe Dubois /* We need to initialize our memory */ 8065f57c43SJean-Christophe Dubois if (machine->ram_size > (FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE)) { 813dc6f869SAlistair Francis warn_report("RAM size " RAM_ADDR_FMT " above max supported, " 8265f57c43SJean-Christophe Dubois "reduced to %x", machine->ram_size, 8365f57c43SJean-Christophe Dubois FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE); 8465f57c43SJean-Christophe Dubois machine->ram_size = FSL_IMX25_SDRAM0_SIZE + FSL_IMX25_SDRAM1_SIZE; 8565f57c43SJean-Christophe Dubois } 8665f57c43SJean-Christophe Dubois 8765f57c43SJean-Christophe Dubois memory_region_allocate_system_memory(&s->ram, NULL, "imx25.ram", 8865f57c43SJean-Christophe Dubois machine->ram_size); 8965f57c43SJean-Christophe Dubois memory_region_add_subregion(get_system_memory(), FSL_IMX25_SDRAM0_ADDR, 9065f57c43SJean-Christophe Dubois &s->ram); 9165f57c43SJean-Christophe Dubois 9265f57c43SJean-Christophe Dubois /* initialize the alias memory if any */ 9365f57c43SJean-Christophe Dubois for (i = 0, ram_size = machine->ram_size, alias_offset = 0; 9465f57c43SJean-Christophe Dubois (i < 2) && ram_size; i++) { 9565f57c43SJean-Christophe Dubois unsigned int size; 9665f57c43SJean-Christophe Dubois static const struct { 9765f57c43SJean-Christophe Dubois hwaddr addr; 9865f57c43SJean-Christophe Dubois unsigned int size; 9965f57c43SJean-Christophe Dubois } ram[2] = { 10065f57c43SJean-Christophe Dubois { FSL_IMX25_SDRAM0_ADDR, FSL_IMX25_SDRAM0_SIZE }, 10165f57c43SJean-Christophe Dubois { FSL_IMX25_SDRAM1_ADDR, FSL_IMX25_SDRAM1_SIZE }, 10265f57c43SJean-Christophe Dubois }; 10365f57c43SJean-Christophe Dubois 10465f57c43SJean-Christophe Dubois size = MIN(ram_size, ram[i].size); 10565f57c43SJean-Christophe Dubois 10665f57c43SJean-Christophe Dubois ram_size -= size; 10765f57c43SJean-Christophe Dubois 10865f57c43SJean-Christophe Dubois if (size < ram[i].size) { 10965f57c43SJean-Christophe Dubois memory_region_init_alias(&s->ram_alias, NULL, "ram.alias", 11065f57c43SJean-Christophe Dubois &s->ram, alias_offset, ram[i].size - size); 11165f57c43SJean-Christophe Dubois memory_region_add_subregion(get_system_memory(), 11265f57c43SJean-Christophe Dubois ram[i].addr + size, &s->ram_alias); 11365f57c43SJean-Christophe Dubois } 11465f57c43SJean-Christophe Dubois 11565f57c43SJean-Christophe Dubois alias_offset += ram[i].size; 11665f57c43SJean-Christophe Dubois } 11765f57c43SJean-Christophe Dubois 11865f57c43SJean-Christophe Dubois imx25_pdk_binfo.ram_size = machine->ram_size; 11965f57c43SJean-Christophe Dubois imx25_pdk_binfo.loader_start = FSL_IMX25_SDRAM0_ADDR; 12065f57c43SJean-Christophe Dubois imx25_pdk_binfo.board_id = 1771, 12165f57c43SJean-Christophe Dubois imx25_pdk_binfo.nb_cpus = 1; 12265f57c43SJean-Christophe Dubois 12365f57c43SJean-Christophe Dubois /* 12465f57c43SJean-Christophe Dubois * We test explicitly for qtest here as it is not done (yet?) in 12565f57c43SJean-Christophe Dubois * arm_load_kernel(). Without this the "make check" command would 12665f57c43SJean-Christophe Dubois * fail. 12765f57c43SJean-Christophe Dubois */ 12865f57c43SJean-Christophe Dubois if (!qtest_enabled()) { 129*2744ece8STao Xu arm_load_kernel(&s->soc.cpu, machine, &imx25_pdk_binfo); 13065f57c43SJean-Christophe Dubois } 13165f57c43SJean-Christophe Dubois } 13265f57c43SJean-Christophe Dubois 133e264d29dSEduardo Habkost static void imx25_pdk_machine_init(MachineClass *mc) 13465f57c43SJean-Christophe Dubois { 135e264d29dSEduardo Habkost mc->desc = "ARM i.MX25 PDK board (ARM926)"; 136e264d29dSEduardo Habkost mc->init = imx25_pdk_init; 1374672cbd7SPeter Maydell mc->ignore_memory_transaction_failures = true; 13865f57c43SJean-Christophe Dubois } 13965f57c43SJean-Christophe Dubois 140b64d64deSPeter Crosthwaite DEFINE_MACHINE("imx25-pdk", imx25_pdk_machine_init) 141