i.MX: Add i.MX25 support through the PDK evaluation board
v15 cover i.MX: Add i.MX25 support through the PDK evaluation board
This series of patches is generated against Peter Maydell GIT tree:
https://git.linaro.org/people/peter.maydell/qemu-arm.git
branch target-arm-post-2.4
This series of patches add the support for the i.MX25 processor through the Freescale PDK evaluation board.
For now a limited set of devices is supported.
* GPT timers (from i.MX31)
* EPIT timers (from i.MX31)
* Serial ports (from i.MX31)
* Ethernet FEC port
* I2C controller
In the process the KZM platform was split into an i.MX31 SOC and a plateform part.
Also, I2C devices was added to the i.MX31 SOC.
This was tested by:
* booting a minimal linux system on the i.MX25 PDK platform
* booting the Xvisor hypervisor on the i.MX25 PDK platform
* booting a minimal linux system on the KZM platform
Jean-Christophe Dubois (8):
i.MX: Add SOC support for i.MX31
i.MX: KZM: use standalone i.MX31 SOC support i.MX: Add I2C controller emulator
i.MX: Add FEC Ethernet Emulator
i.MX: Add SOC support for i.MX25
i.MX: Add the i.MX25 PDK platform
i.MX: Add qtest support for I2C device emulator. i.MX: Add i2C devices to i.MX31 SOC
default-configs/arm-softmmu.mak | 6 + hw/arm/Makefile.objs | 4 +- hw/arm/fsl-imx25.c | 273 ++++++++++++++++ hw/arm/fsl-imx31.c | 246 ++++++++++++++ hw/arm/imx25_pdk.c | 159 +++++++++ hw/arm/kzm.c | 205 ++++++------ hw/char/imx_serial.c | 35 -- hw/i2c/Makefile.objs | 1 + hw/i2c/imx_i2c.c | 339 +++++++++++++++++++ hw/net/Makefile.objs | 1 + hw/net/imx_fec.c | 709 ++++++++++++++++++++++++++++++++++++++++ hw/timer/imx_epit.c | 11 - hw/timer/imx_gpt.c | 11 - include/hw/arm/fsl-imx25.h | 234 +++++++++++++ include/hw/arm/fsl-imx31.h | 110 +++++++ include/hw/arm/imx.h | 26 -- include/hw/i2c/imx_i2c.h | 87 +++++ include/hw/net/imx_fec.h | 113 +++++++ tests/Makefile | 3 + tests/ds1338-test.c | 78 +++++ tests/libqos/i2c-imx.c | 209 ++++++++++++ tests/libqos/i2c.h | 3 + 22 files changed, 2676 insertions(+), 187 deletions(-) create mode 100644 hw/arm/fsl-imx25.c create mode 100644 hw/arm/fsl-imx31.c create mode 100644 hw/arm/imx25_pdk.c create mode 100644 hw/i2c/imx_i2c.c create mode 100644 hw/net/imx_fec.c create mode 100644 include/hw/arm/fsl-imx25.h create mode 100644 include/hw/arm/fsl-imx31.h delete mode 100644 include/hw/arm/imx.h create mode 100644 include/hw/i2c/imx_i2c.h create mode 100644 include/hw/net/imx_fec.h create mode 100644 tests/ds1338-test.c create mode 100644 tests/libqos/i2c-imx.c
Signature · 1 line
2.1.4
PATCH v15 1/8 i.MX: Add SOC support for i.MX31
For now we support the following devices:
* CPU: ARM1136
* Interrupt Controller: AVIC
* CCM
* UART x 2
* EPIT x 2
* GPT
---
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:
* not present on v7
Changes since v8:
* use defines instead of hardcoded values for IRQ and ADDR
* Add i.MX31 SOC support
Changes since v9:
* no change.
Changes since v10:
* added description of supported devices
* rework of UART init to use chardev property
* use memory_region_allocate_system_memory()
* Fix coding style.
Changes since v11:
* no change.
Changes since v12:
* no change.
Changes since v13:
* Don't use memory_region_allocate_system_memory() to init internal iram
* improve error handling
Changes since v14:
* checkpatch related code style fixes
default-configs/arm-softmmu.mak | 2 + hw/arm/Makefile.objs | 3 +- hw/arm/fsl-imx31.c | 216 ++++++++++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx31.h | 98 ++++++++++++++++++ 4 files changed, 318 insertions(+), 1 deletion(-) create mode 100644 hw/arm/fsl-imx31.c create mode 100644 include/hw/arm/fsl-imx31.h
default-configs/arm-softmmu.mak +2 -0
@@ -98,6 +98,8 @@ CONFIG_ALLWINNER_A10_PIT=y CONFIG_ALLWINNER_A10_PIC=y CONFIG_ALLWINNER_A10=y +CONFIG_FSL_IMX31=y + CONFIG_XIO3130=y CONFIG_IOH3420=y CONFIG_I82801B11=y
hw/arm/Makefile.objs +2 -1
@@ -1,6 +1,6 @@ obj-y += boot.o collie.o exynos4_boards.o gumstix.o highbank.o obj-$(CONFIG_DIGIC) += digic_boards.o -obj-y += integratorcp.o kzm.o mainstone.o musicpal.o nseries.o +obj-y += integratorcp.o mainstone.o musicpal.o nseries.o obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o obj-y += tosa.o versatilepb.o vexpress.o virt.o xilinx_zynq.o z2.o obj-$(CONFIG_ACPI) += virt-acpi-build.o
@@ -13,3 +13,4 @@ obj-y += omap1.o omap2.o strongarm.o obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o +obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
hw/arm/fsl-imx31.c new file +216 -0
216 lines not on this page · raw message
include/hw/arm/fsl-imx31.h new file +98 -0
98 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v15 2/8 i.MX: KZM: use standalone i.MX31 SOC support
In reply to Jean-Christophe DuboisConvert the KZM board to use the i.MX31 SoC defintition instead of redefining the entire SoC on the machine level. Major rewrite of the machine init code.
While touching the memory map comment de-indent to the correct level of indentation.
This obsoletes the legacy i.MX device device creation helpers which are removed.
Tested by booting a minimal Linux system on the emulated platform
---
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.
Changes since v10:
* use memory_region_allocate_system_memory()
* rework of memory initialization loop.
* remove all Qdev construction helper in device files.
Changes since v10:
* no change.
Changes since v11:
* no change.
Changes since v12:
* no change.
Changes since v13:
* Use memory_region_allocate_system_memory() only once for the 2 SDRAM controlers.
* rework memory alias init.
Changes since v14:
* checkpatch related code style fixes
* change patch description
* Fix code for coding style naming convention.
hw/arm/kzm.c | 205 +++++++++++++++++++++++++-------------------------- hw/char/imx_serial.c | 35 --------- hw/timer/imx_epit.c | 11 --- hw/timer/imx_gpt.c | 11 --- include/hw/arm/imx.h | 26 ------- 5 files changed, 102 insertions(+), 186 deletions(-) delete mode 100644 include/hw/arm/imx.h
hw/arm/kzm.c +102 -103
@@ -13,131 +13,130 @@* 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 IMX31KZM { +FslIMX31State soc; +MemoryRegion ram; +MemoryRegion ram_alias; +}IMX31KZM ; + +#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 = { - .loader_start =KZM_RAMADDRESS , + .loader_start =KZM_RAM_ADDR , .board_id =1722 , };static void kzm_init (MachineState *machine) { -ram_addr_t ram_size = machine->ram_size; -const char *cpu_model = machine->cpu_model; -const char *kernel_filename = machine->kernel_filename; -const char *kernel_cmdline = machine->kernel_cmdline; -const char *initrd_filename = machine->initrd_filename; -ARMCPU *cpu; -MemoryRegion *address_space_mem =get_system_memory (); -MemoryRegion *ram =g_new (MemoryRegion,1 ); -MemoryRegion *sram =g_new (MemoryRegion,1 ); -MemoryRegion *ram_alias =g_new (MemoryRegion,1 ); -DeviceState *dev; -DeviceState *ccm; - -if (!cpu_model) { - cpu_model ="arm1136" ; - } - - cpu =cpu_arm_init (cpu_model); -if (!cpu) { -fprintf (stderr,"Unable to find CPU definition\n" ); +IMX31KZM *s =g_new0 (IMX31KZM ,1 ); +Error *err =NULL ; +unsigned int ram_size; +unsigned int alias_offset; +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 !=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_size); -memory_region_add_subregion (address_space_mem,KZM_RAMADDRESS , ram); - -memory_region_init_alias (ram_alias,NULL ,"ram.alias" , ram,0 , ram_size); -memory_region_add_subregion (address_space_mem,0x88000000 , ram_alias); - -memory_region_init_ram (sram,NULL ,"kzm.sram" ,0x4000 , &error_abort); -memory_region_add_subregion (address_space_mem,0x1FFFC000 , sram); - - dev =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 =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 supported, " +"reduced to %x" , machine->ram_size, +FSL_IMX31_SDRAM0_SIZE +FSL_IMX31_SDRAM1_SIZE ); + machine->ram_size =FSL_IMX31_SDRAM0_SIZE +FSL_IMX31_SDRAM1_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); +memory_region_allocate_system_memory (&s->ram,NULL ,"kzm.ram" , + machine->ram_size); +memory_region_add_subregion (get_system_memory (),FSL_IMX31_SDRAM0_ADDR , + &s->ram); + +/* initialize the alias memory if any */ +for (i =0 , ram_size = machine->ram_size, alias_offset =0 ; + (i <2 ) && ram_size; i++) { +unsigned int size; +static const struct { +hwaddr addr; +unsigned int size; + } ram[2 ] = { + {FSL_IMX31_SDRAM0_ADDR ,FSL_IMX31_SDRAM0_SIZE }, + {FSL_IMX31_SDRAM1_ADDR ,FSL_IMX31_SDRAM1_SIZE }, + }; + + size =MIN (ram_size, ram[i].size); + + ram_size -= size; + +if (size < ram[i].size) { +memory_region_init_alias (&s->ram_alias,NULL ,"ram.alias" , + &s->ram, alias_offset, ram[i].size - size); +memory_region_add_subregion (get_system_memory (), + ram[i].addr + size, &s->ram_alias); + } + + alias_offset += ram[i].size; + }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 */ -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 = ram_size; - kzm_binfo.kernel_filename = kernel_filename; - kzm_binfo.kernel_cmdline = kernel_cmdline; - kzm_binfo.initrd_filename = initrd_filename; + kzm_binfo.ram_size = machine->ram_size; + kzm_binfo.kernel_filename = machine->kernel_filename; + kzm_binfo.kernel_cmdline = machine->kernel_cmdline; + kzm_binfo.initrd_filename = machine->initrd_filename; kzm_binfo.nb_cpus =1 ; -arm_load_kernel (cpu, &kzm_binfo); + +if (!qtest_enabled ()) { +arm_load_kernel (&s->soc.cpu, &kzm_binfo); + } }static QEMUMachine kzm_machine = {
hw/char/imx_serial.c +0 -35
@@ -21,7 +21,6 @@#include "hw/char/imx_serial.h" #include "sysemu/sysemu.h" #include "sysemu/char.h" -#include "hw/arm/imx.h" //#define DEBUG_SERIAL 1 #ifdef DEBUG_SERIAL
@@ -330,40 +329,6 @@ static void imx_serial_init(Object *obj)sysbus_init_irq (sbd, &s->irq); } -void imx_serial_create (int uart,const hwaddr addr,qemu_irq irq) -{ -DeviceState *dev; -SysBusDevice *bus; -CharDriverState *chr; -const char chr_name[] ="serial" ; -char label[ARRAY_SIZE (chr_name) +1 ]; - - dev =qdev_create (NULL ,TYPE_IMX_SERIAL ); - -if (uart >=MAX_SERIAL_PORTS ) { -hw_error ("Cannot assign uart %d: QEMU supports only %d ports\n" , - uart,MAX_SERIAL_PORTS ); - } - chr = serial_hds[uart]; -if (!chr) { -snprintf (label,ARRAY_SIZE (label),"%s%d" , chr_name, uart); - chr =qemu_chr_new (label,"null" ,NULL ); -if (!(chr)) { -hw_error ("Can't assign serial port to imx-uart%d.\n" , uart); - } - } - -qdev_prop_set_chr (dev,"chardev" , chr); - bus =SYS_BUS_DEVICE (dev); -qdev_init_nofail (dev); -if (addr != (hwaddr)-1 ) { -sysbus_mmio_map (bus,0 , addr); - } -sysbus_connect_irq (bus,0 , irq); - -} - -static Property imx_serial_properties[] = {DEFINE_PROP_CHR ("chardev" , IMXSerialState, chr),DEFINE_PROP_END_OF_LIST (),
hw/timer/imx_epit.c +0 -11
@@ -12,7 +12,6 @@* */ -#include "hw/arm/imx.h" #include "hw/timer/imx_epit.h" #include "hw/misc/imx_ccm.h" #include "qemu/main-loop.h"
@@ -287,16 +286,6 @@ static void imx_epit_cmp(void *opaque)imx_epit_update_int (s); } -void imx_timerp_create (const hwaddr addr,qemu_irq irq,DeviceState *ccm) -{ -IMXEPITState *pp; -DeviceState *dev; - - dev =sysbus_create_simple (TYPE_IMX_EPIT , addr, irq); - pp =IMX_EPIT (dev); - pp->ccm = ccm; -} -static const MemoryRegionOps imx_epit_ops = { .read = imx_epit_read, .write = imx_epit_write,
hw/timer/imx_gpt.c +0 -11
@@ -12,7 +12,6 @@* */ -#include "hw/arm/imx.h" #include "hw/timer/imx_gpt.h" #include "hw/misc/imx_ccm.h" #include "qemu/main-loop.h"
@@ -449,16 +448,6 @@ static void imx_gpt_realize(DeviceState *dev, Error **errp) s->timer =ptimer_init (bh); } -void imx_timerg_create (const hwaddr addr,qemu_irq irq,DeviceState *ccm) -{ -IMXGPTState *pp; -DeviceState *dev; - - dev =sysbus_create_simple (TYPE_IMX_GPT , addr, irq); - pp =IMX_GPT (dev); - pp->ccm = ccm; -} -static void imx_gpt_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);
include/hw/arm/imx.h deleted +0 -26
@@ -1,26 +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/misc/imx_ccm.h" - -void imx_serial_create (int uart,const hwaddr addr,qemu_irq irq); - -void imx_timerp_create (const hwaddr addr, -qemu_irq irq, -DeviceState *ccm); -void imx_timerg_create (const hwaddr addr, -qemu_irq irq, -DeviceState *ccm); - - -#endif /* IMX_H */
Signature · 1 line
2.1.4
PATCH v15 3/8 i.MX: Add I2C controller emulator
In reply to Jean-Christophe DuboisThe slave mode is not implemented.
---
Changes since v1:
* none
Changes since v2:
* use QOM cast
* reworked debug printf
* use CamelCase for state type
* warn with qemu_log_mask(LOG_GUEST_ERROR) or qemu_log_mask(LOG_UNIMP)
* move to dma_memory_read/write API
* rework interrupt handling
* use qemu_flush_queued_packets() in rx_enable()
Changes since v3:
* use realise for device initialization
* More QOM cast
* reworked debug printf some more
* standardise GPL header
* use CamelCase for buffer descriptor type
Changes since v4:
* none
Changes since v5:
* replace hw_error() with qemu_log_mask(LOG_GUEST_ERROR, ...)
* remove reformating of imx.h header file.
* remove unnecessary spaces.
Changes since v6:
* port to new memory API
Change since v7:
* refactor emulator to be used by SOC
Changes since v8:
* no change
Changes since v9:
* no change
Changes since v10:
* no change.
Changes since v11:
* no change.
Changes since v12:
* no change.
Changes since v13:
* no change.
Changes since v14:
* Revert reviewer address back to [email protected]
* Add private/public comment in I2C state struct
* remove useless comments.
default-configs/arm-softmmu.mak | 2 + hw/i2c/Makefile.objs | 1 + hw/i2c/imx_i2c.c | 339 ++++++++++++++++++++++++++++++++++++++++ include/hw/i2c/imx_i2c.h | 87 +++++++++++ 4 files changed, 429 insertions(+) create mode 100644 hw/i2c/imx_i2c.c create mode 100644 include/hw/i2c/imx_i2c.h
default-configs/arm-softmmu.mak +2 -0
@@ -100,6 +100,8 @@ CONFIG_ALLWINNER_A10=y CONFIG_FSL_IMX31=y +CONFIG_IMX_I2C=y + CONFIG_XIO3130=y CONFIG_IOH3420=y CONFIG_I82801B11=y
hw/i2c/Makefile.objs +1 -0
@@ -4,4 +4,5 @@ common-obj-$(CONFIG_ACPI_X86) += smbus_ich9.o common-obj-$(CONFIG_APM) += pm_smbus.o common-obj-$(CONFIG_BITBANG_I2C) += bitbang_i2c.o common-obj-$(CONFIG_EXYNOS4) += exynos4210_i2c.o +common-obj-$(CONFIG_IMX_I2C) += imx_i2c.o obj-$(CONFIG_OMAP) += omap_i2c.o
hw/i2c/imx_i2c.c new file +339 -0
339 lines not on this page · raw message
include/hw/i2c/imx_i2c.h new file +87 -0
87 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v15 4/8 i.MX: Add FEC Ethernet Emulator
In reply to Jean-Christophe DuboisThis is based on mcf_fec.c FEC implementation for Coldfire
* A generic PHY was added (borrowwed from LAN9118)
* The buffer management is also modified as buffers are slightly different between Coldfire and i.MX
---
Changes since v1:
* none
Changes since v2:
* use QOM cast
* reworked debug printf
* use CamelCase for state type
* warn with qemu_log_mask(LOG_GUEST_ERROR) or qemu_log_mask(LOG_UNIMP)
* move to dma_memory_read/write API
* rework interrupt handling
* use qemu_flush_queued_packets() in rx_enable()
Changes since v3:
* use realise for device initialization
* More QOM cast
* reworked debug printf some more
* standardise GPL header
* use CamelCase for buffer descriptor type
Changes since v4:
* none
Changes since v5:
* replace hw_error() with qemu_log_mask(LOG_GUEST_ERROR, ...)
* remove reformating of imx.h header file.
* remove unnecessary spaces.
Changes since v6:
* port to new memory API
Changes since v7:
* refactor to be used by SOC
Changes since v8:
* no change
Changes since v9:
* no change
Changes since v10:
* no change
Changes since v11:
* no change
Changes since v12:
* no change
Changes since v13:
* no change
Change since v14:
* Revert reviewer address back to [email protected]
default-configs/arm-softmmu.mak | 1 + hw/net/Makefile.objs | 1 + hw/net/imx_fec.c | 709 ++++++++++++++++++++++++++++++++++++++++ include/hw/net/imx_fec.h | 113 +++++++ 4 files changed, 824 insertions(+) create mode 100644 hw/net/imx_fec.c create mode 100644 include/hw/net/imx_fec.h
default-configs/arm-softmmu.mak +1 -0
@@ -28,6 +28,7 @@ CONFIG_SSI_M25P80=y CONFIG_LAN9118=y CONFIG_SMC91C111=y CONFIG_ALLWINNER_EMAC=y +CONFIG_IMX_FEC=y CONFIG_DS1338=y CONFIG_PFLASH_CFI01=y CONFIG_PFLASH_CFI02=y
hw/net/Makefile.objs +1 -0
@@ -19,6 +19,7 @@ common-obj-$(CONFIG_XGMAC) += xgmac.o common-obj-$(CONFIG_MIPSNET) += mipsnet.o common-obj-$(CONFIG_XILINX_AXI) += xilinx_axienet.o common-obj-$(CONFIG_ALLWINNER_EMAC) += allwinner_emac.o +common-obj-$(CONFIG_IMX_FEC) += imx_fec.o common-obj-$(CONFIG_CADENCE) += cadence_gem.o common-obj-$(CONFIG_STELLARIS_ENET) += stellaris_enet.o
hw/net/imx_fec.c new file +709 -0
709 lines not on this page · raw message
include/hw/net/imx_fec.h new file +113 -0
113 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v15 5/8 i.MX: Add SOC support for i.MX25
In reply to Jean-Christophe Dubois For now we support the following devices:
* CPU: ARM926
* Interrupt Controller: AVIC
* CCM
* UART x 5
* EPIT x 2
* GPT x 4
* FEC
* I2C x 3
---
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:
* Added a SOC specific file for i.MX25
Changes since v8:
* use defines instead of hardcoded values for IRQ and ADDR
* reworked the memory allocation for SOC memory
Changes since v9:
* no change
Changes since v10:
* added deescription of supported devices
* rework of UART init to use chardev property
* use memory_region_allocate_system_memory()
* Fix coding style.
Changes since v11:
* no change
Changes since v12:
* no change
Changes since v13:
* Don't use memory_region_allocate_system_memory() to init internl iram
* improve error handling
Changes since v14:
* checkpatch related code style fixes
default-configs/arm-softmmu.mak | 1 + hw/arm/Makefile.objs | 1 + hw/arm/fsl-imx25.c | 273 ++++++++++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx25.h | 234 ++++++++++++++++++++++++++++++++++ 4 files changed, 509 insertions(+) create mode 100644 hw/arm/fsl-imx25.c create mode 100644 include/hw/arm/fsl-imx25.h
default-configs/arm-softmmu.mak +1 -0
@@ -100,6 +100,7 @@ CONFIG_ALLWINNER_A10_PIC=y CONFIG_ALLWINNER_A10=y CONFIG_FSL_IMX31=y +CONFIG_FSL_IMX25=y CONFIG_IMX_I2C=y
hw/arm/Makefile.objs +1 -0
@@ -13,4 +13,5 @@ obj-y += omap1.o omap2.o strongarm.o obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o +obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
hw/arm/fsl-imx25.c new file +273 -0
273 lines not on this page · raw message
include/hw/arm/fsl-imx25.h new file +234 -0
234 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v15 6/8 i.MX: Add the i.MX25 PDK platform
In reply to Jean-Christophe DuboisTested by booting a minimal Linux system on the emulated platform Tested by booting the Xvisor hypervisor on the emulated platform
---
Changes since v1:
* Added a ds1338 I2C device for qtest purpose.
Changes since v2:
* none
Changes since v3:
* Rework GPL header
* use I2C constructor helper.
Changes since v4:
* use sysbus_create_simple() instead of I2C constructor helper
Changes since v5:
* Add ds1338 only for qtest mode.
* small comment fixes.
Changes since v6:
* Allow for more than 4 serial if suppoted by Qemu.
Changes since v7:
* Move the SOC part into its own file.
Changes since v8:
* rework SDRAM memory initialisation
Changes since v9:
* no change
Changes since v10:
* rename board from 3DS to PDK
* use memory_region_allocate_system_memory()
* rework of memory initialization loop.
Changes since v11:
* no change
Changes since v12:
* no change
Changes since v13:
* Call memory_region_allocate_system_memory() only once for the 2 SDRAM controlers
* rework memory alias init.
Changes since v14:
* checkpatch related code style fixes
* Fix types in patch description
* Fix code for coding style naming convention.
* remove an indemediate define for memory boot address.
hw/arm/Makefile.objs | 2 +- hw/arm/imx25_pdk.c | 159 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 160 insertions(+), 1 deletion(-) create mode 100644 hw/arm/imx25_pdk.c
hw/arm/Makefile.objs +1 -1
@@ -13,5 +13,5 @@ obj-y += omap1.o omap2.o strongarm.o obj-$(CONFIG_ALLWINNER_A10) += allwinner-a10.o cubieboard.o obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o -obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o +obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
hw/arm/imx25_pdk.c new file +159 -0
159 lines not on this page · raw message
Signature · 1 line
2.1.4
PATCH v15 7/8 i.MX: Add qtest support for I2C device emulator.
In reply to Jean-Christophe DuboisThis is using a ds1338 RTC chip on the I2C bus. This RTC chip is not present on the real 3DS PDK board.
---
Changes since v1:
* not present on v1
Changes since v2:
* use a common header file for I2C regs definition
Changes since v3:
* rework GPL headers.
Changes since v4:
* none
Changes since v5:
* none
Changes since v6:
* none
Changes since v7:
* adapt to new i.MX I2C header file.
Changes since v8:
* no change
Changes since v9:
* no change
Changes since v10:
* no change
Changes since v11:
* no change
Changes since v12:
* no change
Changes since v13:
* Fix imx25_3ds to imx25_pdk for "make check" target
* move bcd2bin() as inline function
* Spelling fix.
Changes since v14:
* no change
include/hw/arm/fsl-imx31.h | 1 + tests/Makefile | 3 + tests/ds1338-test.c | 78 +++++++++++++++++ tests/libqos/i2c-imx.c | 209 +++++++++++++++++++++++++++++++++++++++++++++ tests/libqos/i2c.h | 3 + 5 files changed, 294 insertions(+) create mode 100644 tests/ds1338-test.c create mode 100644 tests/libqos/i2c-imx.c
include/hw/arm/fsl-imx31.h +1 -0
@@ -23,6 +23,7 @@#include "hw/char/imx_serial.h" #include "hw/timer/imx_gpt.h" #include "hw/timer/imx_epit.h" +#include "hw/i2c/imx_i2c.h" #include "exec/memory.h" #define TYPE_FSL_IMX31 "fsl,imx31"
tests/Makefile +3 -0
@@ -201,6 +201,7 @@ check-qtest-sparc64-y = tests/endianness-test$(EXESUF) gcov-files-sparc-y += hw/timer/m48t59.c gcov-files-sparc64-y += hw/timer/m48t59.c check-qtest-arm-y = tests/tmp105-test$(EXESUF) +check-qtest-arm-y = tests/ds1338-test$(EXESUF) gcov-files-arm-y += hw/misc/tmp105.c check-qtest-arm-y += tests/virtio-blk-test$(EXESUF) gcov-files-arm-y += arm-softmmu/hw/block/virtio-blk.c
@@ -354,6 +355,7 @@ libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o libqos-pc-obj-y += tests/libqos/malloc-pc.o tests/libqos/libqos-pc.o libqos-pc-obj-y += tests/libqos/ahci.o libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o +libqos-imx-obj-y = $(libqos-obj-y) tests/libqos/i2c-imx.o libqos-usb-obj-y = $(libqos-pc-obj-y) tests/libqos/usb.o libqos-virtio-obj-y = $(libqos-pc-obj-y) tests/libqos/virtio.o tests/libqos/virtio-pci.o tests/libqos/virtio-mmio.o tests/libqos/malloc-generic.o
@@ -368,6 +370,7 @@ tests/hd-geo-test$(EXESUF): tests/hd-geo-test.o tests/boot-order-test$(EXESUF): tests/boot-order-test.o $(libqos-obj-y) tests/bios-tables-test$(EXESUF): tests/bios-tables-test.o $(libqos-obj-y) tests/tmp105-test$(EXESUF): tests/tmp105-test.o $(libqos-omap-obj-y) +tests/ds1338-test$(EXESUF): tests/ds1338-test.o $(libqos-imx-obj-y) tests/i440fx-test$(EXESUF): tests/i440fx-test.o $(libqos-pc-obj-y) tests/q35-test$(EXESUF): tests/q35-test.o $(libqos-pc-obj-y) tests/fw_cfg-test$(EXESUF): tests/fw_cfg-test.o $(libqos-pc-obj-y)
tests/ds1338-test.c new file +78 -0
78 lines not on this page · raw message
tests/libqos/i2c-imx.c new file +209 -0
209 lines not on this page · raw message
tests/libqos/i2c.h +3 -0
@@ -27,4 +27,7 @@ void i2c_recv(I2CAdapter *i2c, uint8_t addr,/* libi2c-omap.c */ I2CAdapter *omap_i2c_create (uint64_t addr); +/* libi2c-imx.c */ +I2CAdapter *imx_i2c_create (uint64_t addr); +#endif
Signature · 1 line
2.1.4
PATCH v15 8/8 i.MX: Add i2C devices to i.MX31 SOC
In reply to 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:
* not present on v7
Changes since v8:
* not present on v8
Changes since v9:
* Added 3 I2C devices to i.MX31 SOC
Changes since v10:
* no change.
Changes since v11:
* no change.
Changes since v12:
* no change.
Changes since v13:
* Spelling fix in comments
* Space cleanup
* Patch title fix.
Changes since v14:
* no change.
hw/arm/fsl-imx31.c | 30 ++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx31.h | 11 +++++++++++ 2 files changed, 41 insertions(+)
hw/arm/fsl-imx31.c +30 -0
@@ -50,6 +50,11 @@ static void fsl_imx31_init(Object *obj)object_initialize (&s->epit[i],sizeof (s->epit[i]),TYPE_IMX_EPIT );qdev_set_parent_bus (DEVICE (&s->epit[i]),sysbus_get_default ()); } + +for (i =0 ; i <FSL_IMX31_NUM_I2CS ; i++) { +object_initialize (&s->i2c[i],sizeof (s->i2c[i]),TYPE_IMX_I2C ); +qdev_set_parent_bus (DEVICE (&s->i2c[i]),sysbus_get_default ()); + } }static void fsl_imx31_realize (DeviceState *dev,Error **errp)
@@ -154,6 +159,31 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp) epit_table[i].irq)); } +/* Initialize all I2C */ +for (i =0 ; i <FSL_IMX31_NUM_I2CS ; i++) { +static const struct { +hwaddr addr; +unsigned int irq; + } i2c_table[FSL_IMX31_NUM_I2CS ] = { + {FSL_IMX31_I2C1_ADDR ,FSL_IMX31_I2C1_IRQ }, + {FSL_IMX31_I2C2_ADDR ,FSL_IMX31_I2C2_IRQ }, + {FSL_IMX31_I2C3_ADDR ,FSL_IMX31_I2C3_IRQ } + }; + +/* Initialize the I2C */ +object_property_set_bool (OBJECT (&s->i2c[i]), true,"realized" , &err); +if (err) { +error_propagate (errp, err); +return ; + } +/* Map I2C memory */ +sysbus_mmio_map (SYS_BUS_DEVICE (&s->i2c[i]),0 , i2c_table[i].addr); +/* Connect I2C IRQ to PIC */ +sysbus_connect_irq (SYS_BUS_DEVICE (&s->i2c[i]),0 , +qdev_get_gpio_in (DEVICE (&s->avic), + i2c_table[i].irq)); + } +/* On a real system, the first 16k is a `secure boot rom' */ memory_region_init_rom_device(&s->secure_rom, NULL, NULL, NULL, "imx31.secure_rom",
include/hw/arm/fsl-imx31.h +11 -0
@@ -31,6 +31,7 @@#define FSL_IMX31_NUM_UARTS 2#define FSL_IMX31_NUM_EPITS 2 +#define FSL_IMX31_NUM_I2CS 3 typedef struct FslIMX31State { /*< private >*/
@@ -43,6 +44,7 @@ typedef struct FslIMX31State {IMXSerialState uart[FSL_IMX31_NUM_UARTS ];IMXGPTState gpt;IMXEPITState epit[FSL_IMX31_NUM_EPITS ]; +IMXI2CState i2c[FSL_IMX31_NUM_I2CS ];MemoryRegion secure_rom;MemoryRegion rom;MemoryRegion iram;
@@ -57,10 +59,16 @@ typedef struct FslIMX31State {#define FSL_IMX31_IRAM_ALIAS_SIZE 0xFFC0000#define FSL_IMX31_IRAM_ADDR 0x1FFFC000#define FSL_IMX31_IRAM_SIZE 0x4000 +#define FSL_IMX31_I2C1_ADDR 0x43F80000 +#define FSL_IMX31_I2C1_SIZE 0x4000 +#define FSL_IMX31_I2C3_ADDR 0x43F84000 +#define FSL_IMX31_I2C3_SIZE 0x4000#define FSL_IMX31_UART1_ADDR 0x43F90000#define FSL_IMX31_UART1_SIZE 0x4000#define FSL_IMX31_UART2_ADDR 0x43F94000#define FSL_IMX31_UART2_SIZE 0x4000 +#define FSL_IMX31_I2C2_ADDR 0x43F98000 +#define FSL_IMX31_I2C2_SIZE 0x4000#define FSL_IMX31_CCM_ADDR 0x53F80000#define FSL_IMX31_CCM_SIZE 0x4000#define FSL_IMX31_GPT_ADDR 0x53F90000
@@ -95,5 +103,8 @@ typedef struct FslIMX31State {#define FSL_IMX31_GPT_IRQ 29#define FSL_IMX31_UART2_IRQ 32#define FSL_IMX31_UART1_IRQ 45 +#define FSL_IMX31_I2C1_IRQ 10 +#define FSL_IMX31_I2C2_IRQ 4 +#define FSL_IMX31_I2C3_IRQ 3#endif /* FSL_IMX31_H */
Signature · 1 line
2.1.4
Peter Maydell
AppliedQuoted 17 lines · Jean-Christophe Dubois
This series of patches is generated against Peter Maydell GIT tree:
https://git.linaro.org/people/peter.maydell/qemu-arm.git
branch target-arm-post-2.4This series of patches add the support for the i.MX25 processor through the Freescale PDK evaluation board.
For now a limited set of devices is supported.
* GPT timers (from i.MX31)
* EPIT timers (from i.MX31)
* Serial ports (from i.MX31)
* Ethernet FEC port
* I2C controllerIn the process the KZM platform was split into an i.MX31 SOC and a plateform part.
Quoted 6 lines
Also, I2C devices was added to the i.MX31 SOC.
This was tested by:
* booting a minimal linux system on the i.MX25 PDK platform
* booting the Xvisor hypervisor on the i.MX25 PDK platform
* booting a minimal linux system on the KZM platform
Thanks, applied to target-arm.next.
-- PMM