Received: from eggs.gnu.org ([2001:4830:134:3::10]:36473) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCuEa-0007U9-3G for qemu-devel@nongnu.org; Wed, 08 Jul 2015 14:38:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCuEW-00038j-IV for qemu-devel@nongnu.org; Wed, 08 Jul 2015 14:38:16 -0400 Received: from zose-mta02.web4all.fr ([185.49.20.43]:55417) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCuEW-00038F-95 for qemu-devel@nongnu.org; Wed, 08 Jul 2015 14:38:12 -0400 Message-ID: <559D65CB.10900@tribudubois.net> Date: Wed, 08 Jul 2015 20:02:51 +0200 From: Jean-Christophe DUBOIS MIME-Version: 1.0 References: <52f9182c2de8d77137584883aeaeb23d63d55913.1436138842.git.jcd@tribudubois.net> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v10 15/21] i.MX: KZM now uses the standalone i.MX31 SOC support List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Crosthwaite , Peter Chubb Cc: "qemu-devel@nongnu.org Developers" Le 06/07/2015 09:31, Peter Crosthwaite a =C3=A9crit : > On Sun, Jul 5, 2015 at 5:05 PM, Jean-Christophe Dubois > wrote: >> Tested by booting a minimal linux system on the emulated plateform > "Linux" "platform" > >> Note: Qdev construction helper functions are removed with this patch. >> > So is the goal of the inline header movements to minimise the file > scope of this patch? I would say it is ok to have this one touch them > all or if you are worried about it, what I suggest is you do the soc > conversion as a patch and leave the _create helpers as dead functions. > GCC won't complain about non-static unused functions so it is ok to > leave them dead. OK, I'll put all the Qdev construction helper back to their files and=20 I'll wipe all of them here. > >> Signed-off-by: Jean-Christophe Dubois >> --- >> >> Changes since v1: >> * not present on v1 >> >> Changes since v2: >> * not present on v2 >> >> Changes since v3: >> * not present on v3 >> >> Changes since v4: >> * not present on v4 >> >> Changes since v5: >> * not present on v5 >> >> Changes since v6: >> * not present on v6 >> >> Changes since v7: >> * update KZM target to use new emulators >> >> Changes since v8: >> * update KZM to user i.MX31 SOC >> * rework SDRAM memory initialisation >> >> Changes since v9: >> * remove all Qdev construction helper fucntions. >> >> hw/arm/Makefile.objs | 4 +- >> hw/arm/kzm.c | 213 ++++++++++++++++++++++++++---------------= ---------- >> include/hw/arm/imx.h | 72 ----------------- >> 3 files changed, 112 insertions(+), 177 deletions(-) >> delete mode 100644 include/hw/arm/imx.h >> >> diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs >> index f35f731..2fbe344 100644 >> --- a/hw/arm/Makefile.objs >> +++ b/hw/arm/Makefile.objs >> @@ -1,6 +1,6 @@ >> obj-y +=3D boot.o collie.o exynos4_boards.o gumstix.o highbank.o >> obj-$(CONFIG_DIGIC) +=3D digic_boards.o >> -obj-y +=3D integratorcp.o kzm.o mainstone.o musicpal.o nseries.o >> +obj-y +=3D integratorcp.o mainstone.o musicpal.o nseries.o >> obj-y +=3D omap_sx1.o palm.o realview.o spitz.o stellaris.o >> obj-y +=3D tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o >> obj-$(CONFIG_ACPI) +=3D virt-acpi-build.o >> @@ -13,4 +13,4 @@ obj-y +=3D omap1.o omap2.o strongarm.o >> obj-$(CONFIG_ALLWINNER_A10) +=3D allwinner-a10.o cubieboard.o >> obj-$(CONFIG_STM32F205_SOC) +=3D stm32f205_soc.o >> obj-$(CONFIG_XLNX_ZYNQMP) +=3D xlnx-zynqmp.o xlnx-ep108.o >> -obj-$(CONFIG_FSL_IMX31) +=3D fsl-imx31.o >> +obj-$(CONFIG_FSL_IMX31) +=3D fsl-imx31.o kzm.o >> diff --git a/hw/arm/kzm.c b/hw/arm/kzm.c >> index d7af230..6925833 100644 >> --- a/hw/arm/kzm.c >> +++ b/hw/arm/kzm.c >> @@ -13,131 +13,138 @@ >> * i.MX31 SoC >> */ >> >> -#include "hw/sysbus.h" >> +#include "hw/arm/fsl-imx31.h" >> +#include "hw/boards.h" >> +#include "qemu/error-report.h" >> #include "exec/address-spaces.h" >> -#include "hw/hw.h" >> -#include "hw/arm/arm.h" >> -#include "hw/devices.h" >> #include "net/net.h" >> -#include "sysemu/sysemu.h" >> -#include "hw/boards.h" >> +#include "hw/devices.h" >> #include "hw/char/serial.h" >> -#include "hw/intc/imx_avic.h" >> -#include "hw/arm/imx.h" >> - >> - /* Memory map for Kzm Emulation Baseboard: >> - * 0x00000000-0x00003fff 16k secure ROM IGNORED >> - * 0x00004000-0x00407fff Reserved IGNORED >> - * 0x00404000-0x00407fff ROM IGNORED >> - * 0x00408000-0x0fffffff Reserved IGNORED >> - * 0x10000000-0x1fffbfff RAM aliasing IGNORED >> - * 0x1fffc000-0x1fffffff RAM EMULATED >> - * 0x20000000-0x2fffffff Reserved IGNORED >> - * 0x30000000-0x7fffffff I.MX31 Internal Register Space >> - * 0x43f00000 IO_AREA0 >> - * 0x43f90000 UART1 EMULATED >> - * 0x43f94000 UART2 EMULATED >> - * 0x68000000 AVIC EMULATED >> - * 0x53f80000 CCM EMULATED >> - * 0x53f94000 PIT 1 EMULATED >> - * 0x53f98000 PIT 2 EMULATED >> - * 0x53f90000 GPT EMULATED >> - * 0x80000000-0x87ffffff RAM EMULATED >> - * 0x88000000-0x8fffffff RAM Aliasing EMULATED >> - * 0xa0000000-0xafffffff NAND Flash IGNORED >> - * 0xb0000000-0xb3ffffff Unavailable IGNORED >> - * 0xb4000000-0xb4000fff 8-bit free space IGNORED >> - * 0xb4001000-0xb400100f Board control IGNORED >> - * 0xb4001003 DIP switch >> - * 0xb4001010-0xb400101f 7-segment LED IGNORED >> - * 0xb4001020-0xb400102f LED IGNORED >> - * 0xb4001030-0xb400103f LED IGNORED >> - * 0xb4001040-0xb400104f FPGA, UART EMULATED >> - * 0xb4001050-0xb400105f FPGA, UART EMULATED >> - * 0xb4001060-0xb40fffff FPGA IGNORED >> - * 0xb6000000-0xb61fffff LAN controller EMULATED >> - * 0xb6200000-0xb62fffff FPGA NAND Controller IGNORED >> - * 0xb6300000-0xb7ffffff Free IGNORED >> - * 0xb8000000-0xb8004fff Memory control registers IGNORED >> - * 0xc0000000-0xc3ffffff PCMCIA/CF IGNORED >> - * 0xc4000000-0xffffffff Reserved IGNORED >> - */ >> - >> -#define KZM_RAMADDRESS (0x80000000) >> -#define KZM_FPGA (0xb4001040) >> +#include "sysemu/qtest.h" >> + >> +/* Memory map for Kzm Emulation Baseboard: >> + * 0x00000000-0x7fffffff See i.MX31 SOC for support >> + * 0x80000000-0x8fffffff RAM EMULATED >> + * 0x90000000-0x9fffffff RAM EMULATED >> + * 0xa0000000-0xafffffff Flash IGNORED >> + * 0xb0000000-0xb3ffffff Unavailable IGNORED >> + * 0xb4000000-0xb4000fff 8-bit free space IGNORED >> + * 0xb4001000-0xb400100f Board control IGNORED >> + * 0xb4001003 DIP switch >> + * 0xb4001010-0xb400101f 7-segment LED IGNORED >> + * 0xb4001020-0xb400102f LED IGNORED >> + * 0xb4001030-0xb400103f LED IGNORED >> + * 0xb4001040-0xb400104f FPGA, UART EMULATED >> + * 0xb4001050-0xb400105f FPGA, UART EMULATED >> + * 0xb4001060-0xb40fffff FPGA IGNORED >> + * 0xb6000000-0xb61fffff LAN controller EMULATED >> + * 0xb6200000-0xb62fffff FPGA NAND Controller IGNORED >> + * 0xb6300000-0xb7ffffff Free IGNORED >> + * 0xb8000000-0xb8004fff Memory control registers IGNORED >> + * 0xc0000000-0xc3ffffff PCMCIA/CF IGNORED >> + * 0xc4000000-0xffffffff Reserved IGNORED >> + */ >> + >> +typedef struct imx31_kzm { > CamelCase for Typename. IMX all caps. > >> + FslImx31State soc; >> + MemoryRegion ram[2]; >> + MemoryRegion ram_alias; >> +} imx31_kzm; >> + >> +#define KZM_RAM_ADDR (FSL_IMX31_SDRAM0_ADDR) >> +#define KZM_FPGA_ADDR (FSL_IMX31_CS4_ADDR + 0x1040) >> +#define KZM_LAN9118_ADDR (FSL_IMX31_CS5_ADDR) >> >> static struct arm_boot_info kzm_binfo =3D { >> - .loader_start =3D KZM_RAMADDRESS, >> + .loader_start =3D KZM_RAM_ADDR, >> .board_id =3D 1722, >> }; >> >> static void kzm_init(MachineState *machine) >> { >> - ram_addr_t ram_size =3D machine->ram_size; >> - const char *cpu_model =3D machine->cpu_model; >> - const char *kernel_filename =3D machine->kernel_filename; >> - const char *kernel_cmdline =3D machine->kernel_cmdline; >> - const char *initrd_filename =3D machine->initrd_filename; >> - ARMCPU *cpu; >> - MemoryRegion *address_space_mem =3D get_system_memory(); >> - MemoryRegion *ram =3D g_new(MemoryRegion, 1); >> - MemoryRegion *sram =3D g_new(MemoryRegion, 1); >> - MemoryRegion *ram_alias =3D g_new(MemoryRegion, 1); >> - DeviceState *dev; >> - DeviceState *ccm; >> - >> - if (!cpu_model) { >> - cpu_model =3D "arm1136"; >> - } >> - >> - cpu =3D cpu_arm_init(cpu_model); >> - if (!cpu) { >> - fprintf(stderr, "Unable to find CPU definition\n"); >> + imx31_kzm *s =3D g_new0(imx31_kzm, 1); >> + Error *err =3D NULL; >> + unsigned int ram_size; >> + unsigned int i; >> + >> + object_initialize(&s->soc, sizeof(s->soc), TYPE_FSL_IMX31); >> + object_property_add_child(OBJECT(machine), "soc", OBJECT(&s->soc)= , >> + &error_abort); >> + >> + object_property_set_bool(OBJECT(&s->soc), true, "realized", &err)= ; >> + if (err !=3D NULL) { >> + error_report("%s", error_get_pretty(err)); >> exit(1); >> } >> >> - /* On a real system, the first 16k is a `secure boot rom' */ >> - >> - memory_region_allocate_system_memory(ram, NULL, "kzm.ram", ram_si= ze); >> - memory_region_add_subregion(address_space_mem, KZM_RAMADDRESS, ra= m); >> - >> - memory_region_init_alias(ram_alias, NULL, "ram.alias", ram, 0, ra= m_size); >> - memory_region_add_subregion(address_space_mem, 0x88000000, ram_al= ias); >> - >> - memory_region_init_ram(sram, NULL, "kzm.sram", 0x4000, &error_abo= rt); >> - memory_region_add_subregion(address_space_mem, 0x1FFFC000, sram); >> - >> - dev =3D sysbus_create_varargs(TYPE_IMX_AVIC, 0x68000000, >> - qdev_get_gpio_in(DEVICE(cpu), ARM_CPU= _IRQ), >> - qdev_get_gpio_in(DEVICE(cpu), ARM_CPU= _FIQ), >> - NULL); >> - >> - imx_serial_create(0, 0x43f90000, qdev_get_gpio_in(dev, 45)); >> - imx_serial_create(1, 0x43f94000, qdev_get_gpio_in(dev, 32)); >> - >> - ccm =3D sysbus_create_simple(TYPE_IMX_CCM, 0x53f80000, NULL); >> + /* Check the amount of memory is compatible with the SOC */ >> + if (machine->ram_size > (FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1= _SIZE)) { >> + error_report("WARNING: RAM size " RAM_ADDR_FMT " above max su= pported, " >> + "reduced to %x", machine->ram_size, >> + FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM1_SIZE); >> + machine->ram_size =3D FSL_IMX31_SDRAM0_SIZE + FSL_IMX31_SDRAM= 1_SIZE; >> + } >> >> - imx_timerp_create(0x53f94000, qdev_get_gpio_in(dev, 28), ccm); >> - imx_timerp_create(0x53f98000, qdev_get_gpio_in(dev, 27), ccm); >> - imx_timerg_create(0x53f90000, qdev_get_gpio_in(dev, 29), ccm); >> + ram_size =3D machine->ram_size; >> + i =3D 0; >> + >> + /* initialize our memory */ >> + while (ram_size && (i < 2)) { > for loop. > >> + unsigned int size; >> + char ram_name[20]; >> + static const struct { >> + hwaddr addr; >> + unsigned int size; >> + } ram[2] =3D { >> + { FSL_IMX31_SDRAM0_ADDR, FSL_IMX31_SDRAM0_SIZE }, >> + { FSL_IMX31_SDRAM1_ADDR, FSL_IMX31_SDRAM1_SIZE }, >> + }; >> + >> + if (ram_size > ram[i].size) { >> + size =3D ram[i].size; >> + } else { >> + size =3D ram_size; >> + } >> + >> + sprintf(ram_name, "kzm.ram%d", i); >> + >> + ram_size -=3D size; >> + >> + memory_region_init_ram(&s->ram[i], NULL, ram_name, size, >> + &error_abort); >> + vmstate_register_ram_global(&s->ram[i]); > memory_region_allocate_system_memory(). > >> + memory_region_add_subregion(get_system_memory(), ram[i].addr, >> + &s->ram[i]); >> + if (size < ram[i].size) { >> + memory_region_init_alias(&s->ram_alias, NULL, "ram.alias"= , >> + &s->ram[i], 0, ram[i].size - siz= e); >> + memory_region_add_subregion(get_system_memory(), >> + ram[i].addr + size, &s->ram_a= lias); >> + } >> + >> + i++; >> + } >> >> if (nd_table[0].used) { >> - lan9118_init(&nd_table[0], 0xb6000000, qdev_get_gpio_in(dev, = 52)); >> + lan9118_init(&nd_table[0], KZM_LAN9118_ADDR, >> + qdev_get_gpio_in(DEVICE(&s->soc.avic), 52)); >> } >> >> if (serial_hds[2]) { /* touchscreen */ > Curious to how this does a touchscreen? Looks like a 3rd UART in an > attached FPGA? I don't know ... This was put here by the initial contributor. It sure=20 looks like another UART ... I don't have a KZM myself. > > Regards, > Peter > >> - serial_mm_init(address_space_mem, KZM_FPGA+0x10, 0, >> - qdev_get_gpio_in(dev, 52), >> - 14745600, serial_hds[2], >> - DEVICE_NATIVE_ENDIAN); >> + serial_mm_init(get_system_memory(), KZM_FPGA_ADDR+0x10, 0, >> + qdev_get_gpio_in(DEVICE(&s->soc.avic), 52), >> + 14745600, serial_hds[2], DEVICE_NATIVE_ENDIAN)= ; >> } >> >> - kzm_binfo.ram_size =3D ram_size; >> - kzm_binfo.kernel_filename =3D kernel_filename; >> - kzm_binfo.kernel_cmdline =3D kernel_cmdline; >> - kzm_binfo.initrd_filename =3D initrd_filename; >> + kzm_binfo.ram_size =3D machine->ram_size; >> + kzm_binfo.kernel_filename =3D machine->kernel_filename; >> + kzm_binfo.kernel_cmdline =3D machine->kernel_cmdline; >> + kzm_binfo.initrd_filename =3D machine->initrd_filename; >> kzm_binfo.nb_cpus =3D 1; >> - arm_load_kernel(cpu, &kzm_binfo); >> + >> + if (!qtest_enabled()) { >> + arm_load_kernel(&s->soc.cpu, &kzm_binfo); >> + } >> } >> >> static QEMUMachine kzm_machine =3D { >> diff --git a/include/hw/arm/imx.h b/include/hw/arm/imx.h >> deleted file mode 100644 >> index b7aa4b6..0000000 >> --- a/include/hw/arm/imx.h >> +++ /dev/null >> @@ -1,72 +0,0 @@ >> -/* >> - * i.MX31 emulation >> - * >> - * Copyright (C) 2012 Peter Chubb >> - * NICTA >> - * >> - * This code is released under the GPL, version 2.0 or later >> - * See the file `../COPYING' for details. >> - */ >> - >> -#ifndef IMX_H >> -#define IMX_H >> - >> -#include "hw/qdev-core.h" >> -#include "hw/sysbus.h" >> -#include "hw/char/imx_serial.h" >> -#include "hw/misc/imx_ccm.h" >> -#include "hw/timer/imx_epit.h" >> -#include "hw/timer/imx_gpt.h" >> - >> -/*** >> - * This Qdev construction helper is going to be removed soon >> - */ >> -static inline void imx_serial_create(int uart, const hwaddr addr, qem= u_irq irq) >> -{ >> - /* uart parameter is not used anymore */ >> - DeviceState *dev; >> - >> - dev =3D qdev_create(NULL, TYPE_IMX_SERIAL); >> - >> - if (dev) { >> - SysBusDevice *bus; >> - >> - bus =3D SYS_BUS_DEVICE(dev); >> - >> - qdev_init_nofail(dev); >> - >> - if (addr !=3D (hwaddr)-1) { >> - sysbus_mmio_map(bus, 0, addr); >> - } >> - >> - sysbus_connect_irq(bus, 0, irq); >> - } >> -} >> - >> -static inline >> -void imx_timerp_create(const hwaddr addr, >> - qemu_irq irq, >> - DeviceState *ccm) >> -{ >> - IMXEPITState *pp; >> - DeviceState *dev; >> - >> - dev =3D sysbus_create_simple(TYPE_IMX_EPIT, addr, irq); >> - pp =3D IMX_EPIT(dev); >> - pp->ccm =3D ccm; >> -} >> - >> -static inline >> -void imx_timerg_create(const hwaddr addr, >> - qemu_irq irq, >> - DeviceState *ccm) >> -{ >> - IMXGPTState *pp; >> - DeviceState *dev; >> - >> - dev =3D sysbus_create_simple(TYPE_IMX_GPT, addr, irq); >> - pp =3D IMX_GPT(dev); >> - pp->ccm =3D ccm; >> -} >> - >> -#endif /* IMX_H */ >> -- >> 2.1.4 >> >>