i.MX: Add the i.MX6UL SOC and a reference board.
cover i.MX: Add the i.MX6UL SOC and a reference board.
This series adds the i.MX6UL SOC from NXP/Freescale and the reference evaluation board.
This series as tested by booting linux 4.18 (built using imx_v6_v7_defconfig) on the emulated board (with the appropriate device tree).
Jean-Christophe Dubois (3):
i.MX6UL: Add i.MX6UL specific CCM device i.MX6UL: Add i.MX6UL SOC
i.MX6UL: Add Freescale i.MX6 UltraLite 14x14 EVK Board
default-configs/arm-softmmu.mak | 1 + hw/arm/Makefile.objs | 1 + hw/arm/fsl-imx6ul.c | 649 +++++++++++++++++++++++ hw/arm/mcimx6ul-evk.c | 86 ++++ hw/misc/Makefile.objs | 1 + hw/misc/imx6ul_ccm.c | 887 ++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx6ul.h | 339 ++++++++++++ include/hw/misc/imx6ul_ccm.h | 228 ++++++++ 8 files changed, 2192 insertions(+) create mode 100644 hw/arm/fsl-imx6ul.c create mode 100644 hw/arm/mcimx6ul-evk.c create mode 100644 hw/misc/imx6ul_ccm.c create mode 100644 include/hw/arm/fsl-imx6ul.h create mode 100644 include/hw/misc/imx6ul_ccm.h
Signature · 1 line
2.17.1
PATCH 1/3 i.MX6UL: Add i.MX6UL specific CCM device
--- hw/misc/Makefile.objs | 1 + hw/misc/imx6ul_ccm.c | 887 +++++++++++++++++++++++++++++++++++ include/hw/misc/imx6ul_ccm.h | 228 +++++++++ 3 files changed, 1116 insertions(+) create mode 100644 hw/misc/imx6ul_ccm.c create mode 100644 include/hw/misc/imx6ul_ccm.h
hw/misc/Makefile.objs +1 -0
@@ -36,6 +36,7 @@ obj-$(CONFIG_IMX) += imx_ccm.o obj-$(CONFIG_IMX) += imx31_ccm.o obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o +obj-$(CONFIG_IMX) += imx6ul_ccm.o obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_IMX) += imx2_wdt.o
hw/misc/imx6ul_ccm.c new file +887 -0
887 lines not on this page · raw message
include/hw/misc/imx6ul_ccm.h new file +228 -0
228 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 1/3] i.MX6UL: Add i.MX6UL specific CCM device
Quoted 44 lines · Jean-Christophe Dubois
Signed-off-by Jean-Christophe Dubois <[email protected]>--- hw/misc/Makefile.objs | 1 + hw/misc/imx6ul_ccm.c | 887 +++++++++++++++++++++++++++++++++++ include/hw/misc/imx6ul_ccm.h | 228 +++++++++ 3 files changed, 1116 insertions(+) create mode 100644 hw/misc/imx6ul_ccm.c create mode 100644 include/hw/misc/imx6ul_ccm.hhw/misc/Makefile.objs +1
-0@@ -36,6 +36,7 @@ obj-$(CONFIG_IMX) += imx_ccm.o obj-$(CONFIG_IMX) += imx31_ccm.o obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_IMX) += imx6_ccm.o +obj-$(CONFIG_IMX) += imx6ul_ccm.o obj-$(CONFIG_IMX) += imx6_src.o obj-$(CONFIG_IMX) += imx7_ccm.o obj-$(CONFIG_IMX) += imx2_wdt.ohw/misc/imx6ul_ccm.c new file +17
-0@@ -0,0 +1,887 @@ +/* +* IMX6UL Clock Control Module +* +* Copyright (c) 2018 Jean-Christophe Dubois <[email protected]> +* +* This work is licensed under the terms of the GNU GPL, version 2 or later. +* See the COPYING file in the top-level directory. +* +* To get the timer frequencies right, we need to emulate at least part of +* the CCM. +*/ + +#include "qemu/osdep.h" +#include "hw/misc/imx6ul_ccm.h" +#include "qemu/log.h" + +#ifndef DEBUG_IMX6UL_CCM
hw/misc/imx6ul_ccm.c line 27
Quoted 10 lines
hw/misc/imx6ul_ccm.c new file +10
-0+#define DEBUG_IMX6UL_CCM 0 +#endif + +#define DPRINTF(fmt, args...) \ + do { \ + if (DEBUG_IMX6UL_CCM) { \ + fprintf(stderr, "[%s]%s: " fmt , TYPE_IMX6UL_CCM, \ + __func__, ##args); \ + } \ + } while (0)
Tracepoints would be preferable to more DPRINTF macros for new devices, ideally.
Quoted 4 lines
hw/misc/imx6ul_ccm.c new file +4
-0+static uint64_t imx6ul_ccm_get_periph_clk2_sel_clk (IMX6ULCCMState *dev) +{ +uint64_t freq =0 ; +
hw/misc/imx6ul_ccm.c line 325
Quoted 10 lines
hw/misc/imx6ul_ccm.c new file +10
-0+switch (EXTRACT (dev->ccm[CCM_CBCMR ],PERIPH_CLK2_SEL )) { +case 0 : + freq =imx6ul_analog_get_pll3_clk (dev); +break ; +case 1 : + freq =imx6ul_analog_get_osc_clk (dev); +break ; +case 2 : + freq =imx6ul_analog_pll2_bypass_clk (dev); +break ;
PERIPH_CLK2_SEL is a 2-bit field, right? Since there's nothing that prevents the guest from writing 0b11 to it, we need a case 3: here. (The guest should never be able to trigger a QEMU assertion failure.)
hw/misc/imx6ul_ccm.c line 329
Quoted 4 lines
hw/misc/imx6ul_ccm.c new file +4
-0+default : +/* We should never get there */ +g_assert_not_reached (); +break ;
You don't need a 'break' here, as execution never returns from g_assert_not_reached(). The comment I think also can be dropped -- it just tells you what you can already determine from the g_assert_not_reached().
Quoted 5 lines
hw/misc/imx6ul_ccm.c new file +5
-0+ } + +DPRINTF ("freq = %d\n" , (uint32_t )freq); + +return freq;
hw/misc/imx6ul_ccm.c line 585
Quoted 10 lines
hw/misc/imx6ul_ccm.c new file +8
-0+} +static uint64_t imx6ul_ccm_read (void *opaque,hwaddr offset,unsigned size) +{ +uint32_t value =0 ; +uint32_t index = offset >>2 ; +IMX6ULCCMState *s = (IMX6ULCCMState *)opaque; + + value = s->ccm[index];
It looks like the index is forced to be in range by the size of this MemoryRegion. An assertion here will help to convince static analysis tools that this really can't overflow the array. (Similarly in the write fn below.)
hw/misc/imx6ul_ccm.c
Quoted 6 lines
hw/misc/imx6ul_ccm.c new file +6
-0+ +DPRINTF ("reg[%s] => 0x%" PRIx32"\n" ,imx6ul_ccm_reg_name (index), value); + +return (uint64_t )value; +} +#define EXTRACT (value, name) extract32(value, name##_SHIFT, name##_LENGTH)
Please don't define ad-hoc extract macros. Either just use extract32() directly, or use the macros that include/hw/registerfields.h provides.
thanks
-- PMM
PATCH 2/3 i.MX6UL: Add i.MX6UL SOC
In reply to Jean-Christophe Dubois--- default-configs/arm-softmmu.mak | 1 + hw/arm/Makefile.objs | 1 + hw/arm/fsl-imx6ul.c | 649 ++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx6ul.h | 339 +++++++++++++++++ 4 files changed, 990 insertions(+) create mode 100644 hw/arm/fsl-imx6ul.c create mode 100644 include/hw/arm/fsl-imx6ul.h
default-configs/arm-softmmu.mak +1 -0
@@ -133,6 +133,7 @@ CONFIG_FSL_IMX6=y CONFIG_FSL_IMX31=y CONFIG_FSL_IMX25=y CONFIG_FSL_IMX7=y +CONFIG_FSL_IMX6UL=y CONFIG_IMX_I2C=y
hw/arm/Makefile.objs +1 -0
@@ -36,3 +36,4 @@ obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o obj-$(CONFIG_IOTKIT) += iotkit.o obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o +obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o
hw/arm/fsl-imx6ul.c new file +649 -0
649 lines not on this page · raw message
include/hw/arm/fsl-imx6ul.h new file +339 -0
339 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 2/3] i.MX6UL: Add i.MX6UL SOC
Quoted 70 lines · Jean-Christophe Dubois
Signed-off-by Jean-Christophe Dubois <[email protected]>--- default-configs/arm-softmmu.mak | 1 + hw/arm/Makefile.objs | 1 + hw/arm/fsl-imx6ul.c | 649 ++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx6ul.h | 339 +++++++++++++++++ 4 files changed, 990 insertions(+) create mode 100644 hw/arm/fsl-imx6ul.c create mode 100644 include/hw/arm/fsl-imx6ul.hdefault-configs/arm-softmmu.mak +1
-0@@ -133,6 +133,7 @@ CONFIG_FSL_IMX6=y CONFIG_FSL_IMX31=y CONFIG_FSL_IMX25=y CONFIG_FSL_IMX7=y +CONFIG_FSL_IMX6UL=y CONFIG_IMX_I2C=yhw/arm/Makefile.objs +1
-0@@ -36,3 +36,4 @@ obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o obj-$(CONFIG_IOTKIT) += iotkit.o obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o +obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.ohw/arm/fsl-imx6ul.c new file +33
-0@@ -0,0 +1,649 @@ +/* +* Copyright (c) 2018 Jean-Christophe Dubois <[email protected]> +* +* i.MX6UL SOC emulation. +* +* Based on hw/arm/fsl-imx7.c +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu-common.h" +#include "hw/arm/fsl-imx6ul.h" +#include "hw/misc/unimp.h" +#include "sysemu/sysemu.h" +#include "qemu/error-report.h" + +#define NAME_SIZE 20 + +static void fsl_imx6ul_init (Object *obj) +{ +BusState *sysbus =sysbus_get_default (); +FslIMX6ULState *s =FSL_IMX6UL (obj); +char name[NAME_SIZE ];
hw/arm/fsl-imx6ul.c line 43
Quoted 10 lines
hw/arm/fsl-imx6ul.c new file +10
-0+int i; + + +for (i =0 ; i <MIN (smp_cpus,FSL_IMX6UL_NUM_CPUS ); i++) { +object_initialize (&s->cpu[i],sizeof (s->cpu[i]), +ARM_CPU_TYPE_NAME ("cortex-a7" )); +snprintf (name,NAME_SIZE ,"cpu%d" , i); +object_property_add_child (obj, name,OBJECT (&s->cpu[i]), + &error_fatal); + }
It's been discovered recently that initializing child QOM objects like this leaks a reference count to them, which can cause crashes if the device is introspected via the QMP interface. This has been fixed for various devices including the in-tree FSL SoC containers in commits 0210b39d0e8..ccf02d73d18 (which just got pushed to master this afternoon).
Commit e9e4d4d3e18 is the one that fixes fsl-imx6.c, and we should follow that here. Specifically, rather than separate calls to object_initialize() and object_property_add_child() we can have one call to the new object_initialize_child():
object_initialize_child(obj, name, &s->cpu[i], sizeof(s->cpu[i]),
ARM_CPU_TYPE_NAME("cortex-a7"),
&error_abort, NULL);hw/arm/fsl-imx6ul.c line 51
Quoted 8 lines
hw/arm/fsl-imx6ul.c new file +8
-0+ +/* +* A7MPCORE +*/ +object_initialize (&s->a7mpcore,sizeof (s->a7mpcore),TYPE_A15MPCORE_PRIV ); +qdev_set_parent_bus (DEVICE (&s->a7mpcore), sysbus); +object_property_add_child (obj,"a7mpcore" , +OBJECT (&s->a7mpcore), &error_fatal);
and for sysbus devices like this there is now a single sysbus_init_child_obj() which does the work of all three of these calls:
sysbus_init_child_obj(obj, "a7mpcore", &s->a7mpcore, sizeof(s->a7mpcore),
TYPE_A7MPCORE_PRIV);Similarly with the various other child objects here.
thanks
-- PMM
PATCH 3/3 i.MX6UL: Add Freescale i.MX6 UltraLite 14x14 EVK Board
In reply to Jean-Christophe DuboisTested by booting linux 4.18 (built using imx_v6_v7_defconfig) on the emulated board.
--- hw/arm/Makefile.objs | 2 +- hw/arm/mcimx6ul-evk.c | 86 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 hw/arm/mcimx6ul-evk.c
hw/arm/Makefile.objs +1 -1
@@ -36,4 +36,4 @@ obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o obj-$(CONFIG_IOTKIT) += iotkit.o obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o -obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o +obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o mcimx6ul-evk.o
hw/arm/mcimx6ul-evk.c new file +86 -0
86 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [Qemu-devel] [PATCH 3/3] i.MX6UL: Add Freescale i.MX6 UltraLite 14x14 EVK Board
Quoted 68 lines · Jean-Christophe Dubois
Tested by booting linux 4.18 (built using
imx_v6_v7_defconfig) on the emulated board.Signed-off-by Jean-Christophe Dubois <[email protected]>--- hw/arm/Makefile.objs | 2 +- hw/arm/mcimx6ul-evk.c | 86 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 hw/arm/mcimx6ul-evk.chw/arm/Makefile.objs +1
-1@@ -36,4 +36,4 @@ obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o obj-$(CONFIG_IOTKIT) += iotkit.o obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o mcimx7d-sabre.o obj-$(CONFIG_ARM_SMMUV3) += smmu-common.o smmuv3.o -obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o +obj-$(CONFIG_FSL_IMX6UL) += fsl-imx6ul.o mcimx6ul-evk.ohw/arm/mcimx6ul-evk.c new file +42
-0@@ -0,0 +1,86 @@ +/* +* Copyright (c) 2018 Jean-Christophe Dubois <[email protected]> +* +* MCIMX6UL_EVK Board System emulation. +* +* This code is licensed under the GPL, version 2 or later. +* See the file `COPYING' in the top level directory. +* +* It (partially) emulates a mcimx6ul_evk board, with a Freescale +* i.MX6ul SoC +*/ + +#include "qemu/osdep.h" +#include "qapi/error.h" +#include "qemu-common.h" +#include "hw/arm/fsl-imx6ul.h" +#include "hw/boards.h" +#include "sysemu/sysemu.h" +#include "qemu/error-report.h" +#include "sysemu/qtest.h" + +typedef struct { +FslIMX6ULState soc; +MemoryRegion ram; +}MCIMX6ULEVK ; + +static void mcimx6ul_evk_init (MachineState *machine) +{ +static struct arm_boot_info boot_info; +MCIMX6ULEVK *s =g_new0 (MCIMX6ULEVK ,1 ); +Object *soc; +int i; + +if (machine->ram_size >FSL_IMX6UL_MMDC_SIZE ) { +error_report ("RAM size " RAM_ADDR_FMT " above max supported (%08x)" , + machine->ram_size,FSL_IMX6UL_MMDC_SIZE ); +exit (1 ); + } + + boot_info = (struct arm_boot_info ) { + .loader_start =FSL_IMX6UL_MMDC_ADDR , + .board_id =-1 ,
hw/arm/mcimx6ul-evk.c line 52
Quoted 10 lines
hw/arm/mcimx6ul-evk.c new file +10
-0+ .ram_size = machine->ram_size, + .kernel_filename = machine->kernel_filename, + .kernel_cmdline = machine->kernel_cmdline, + .initrd_filename = machine->initrd_filename, + .nb_cpus = smp_cpus, + }; + +object_initialize (&s->soc,sizeof (s->soc),TYPE_FSL_IMX6UL ); + soc =OBJECT (&s->soc); +object_property_add_child (OBJECT (machine),"soc" , soc, &error_fatal);
This should use object_initialize_child() rather than object_initialize() + object_property_add_child().
hw/arm/mcimx6ul-evk.c line 53
Quoted 1 line
hw/arm/mcimx6ul-evk.c new file +1
-0+object_property_set_bool (soc, true,"realized" , &error_fatal);
Otherwise this patch looks good.
thanks
-- PMM
Quoted 10 lines · Jean-Christophe Dubois
This series adds the i.MX6UL SOC from NXP/Freescale and the reference evaluation board.
This series as tested by booting linux 4.18 (built using
imx_v6_v7_defconfig) on the emulated board (with the appropriate device tree).Jean-Christophe Dubois (3):
i.MX6UL: Add i.MX6UL specific CCM device i.MX6UL: Add i.MX6UL SOC
i.MX6UL: Add Freescale i.MX6 UltraLite 14x14 EVK Board
Hi; thanks for this patchset. I've put it on my to-review queue, but since it's too late to get in for softfreeze for 3.0 I'm planning to prioritize release-related work so it may take me a little while to get back to it.
thanks
-- PMM
Le 01/07/2018 à 12:44, Peter Maydell a écrit :
Quoted 11 lines · Jean-Christophe Dubois
Quoted 10 lines
This series adds the i.MX6UL SOC from NXP/Freescale and the reference evaluation board.
This series as tested by booting linux 4.18 (built using
imx_v6_v7_defconfig) on the emulated board (with the appropriate device tree).Jean-Christophe Dubois (3):
i.MX6UL: Add i.MX6UL specific CCM device i.MX6UL: Add i.MX6UL SOC
i.MX6UL: Add Freescale i.MX6 UltraLite 14x14 EVK Board
Quoted 8 lines
Hi; thanks for this patchset. I've put it on my to-review queue, but since it's too late to get in for softfreeze for 3.0 I'm planning to prioritize release-related work so it may take me a little while to get back to it.
thanks
-- PMM
OK, take your time.
Also for the record, I believe the Qemu FEC/ENET device doesn't work with linux 4.18 on the i.MX6Q/DL sabrelite emulation.
JC