i.MX: Add an i.MX25 specific CCM driver
cover i.MX: Add an i.MX25 specific CCM driver
i.MX25 SOC has a different CCM device than i.MX31.
Qemu i.MX25 emulation was built with i.MX31 CCM driver. This allows Linux to work on top of the i.MX25 emultion but this is not correct.
Furthermore, other SOC we could emulate like i.MX6 have yet a different implementation of the CCM device.
We then add an i.MX25 specific CCM Device and have the i.MX25 SOC use it.
Jean-Christophe Dubois (2):
i.MX: rework CCM driver.
i.MX: Add i.MX25 CCM driver
hw/arm/fsl-imx25.c | 6 +- hw/arm/fsl-imx31.c | 6 +- hw/misc/Makefile.objs | 2 + hw/misc/imx25_ccm.c | 224 +++++++++++++++++++++++++++++++++++++++ hw/misc/imx31_ccm.c | 240 ++++++++++++++++++++++++++++++++++++++++++ hw/misc/imx_ccm.c | 249 +++----------------------------------------- hw/timer/imx_epit.c | 8 +- hw/timer/imx_gpt.c | 12 +-- include/hw/arm/fsl-imx25.h | 4 +- include/hw/arm/fsl-imx31.h | 4 +- include/hw/misc/imx25_ccm.h | 61 +++++++++++ include/hw/misc/imx31_ccm.h | 68 ++++++++++++ include/hw/misc/imx_ccm.h | 73 +++---------- include/hw/timer/imx_epit.h | 1 - include/hw/timer/imx_gpt.h | 1 - 15 files changed, 640 insertions(+), 319 deletions(-) create mode 100644 hw/misc/imx25_ccm.c create mode 100644 hw/misc/imx31_ccm.c create mode 100644 include/hw/misc/imx25_ccm.h create mode 100644 include/hw/misc/imx31_ccm.h
Signature · 1 line
2.5.0
PATCH 1/2 i.MX: rework CCM driver.
The CCM driver is in fact specific to the i.MX31. We need to add an i.MX25 CCM driver.
As a first step, we split the CCM driver into 2 parts:
1) A common/utility part that allow to compute an manipulate clock freq for any CCM driver
2) The i.MX31 CCM specifc driver.
We also remove EPIT/GPT timer reference to CCM. These objects now use the utility function we added in 1) instead of direct reference to CCM object.
--- hw/arm/fsl-imx25.c | 6 +- hw/arm/fsl-imx31.c | 6 +- hw/misc/Makefile.objs | 1 + hw/misc/imx31_ccm.c | 240 ++++++++++++++++++++++++++++++++++++++++++ hw/misc/imx_ccm.c | 249 +++----------------------------------------- hw/timer/imx_epit.c | 8 +- hw/timer/imx_gpt.c | 12 +-- include/hw/arm/fsl-imx25.h | 4 +- include/hw/arm/fsl-imx31.h | 4 +- include/hw/misc/imx31_ccm.h | 68 ++++++++++++ include/hw/misc/imx_ccm.h | 73 +++---------- include/hw/timer/imx_epit.h | 1 - include/hw/timer/imx_gpt.h | 1 - 13 files changed, 354 insertions(+), 319 deletions(-) create mode 100644 hw/misc/imx31_ccm.c create mode 100644 include/hw/misc/imx31_ccm.h
hw/arm/fsl-imx25.c +1 -5
@@ -38,7 +38,7 @@ static void fsl_imx25_init(Object *obj)object_initialize (&s->avic,sizeof (s->avic),TYPE_IMX_AVIC );qdev_set_parent_bus (DEVICE (&s->avic),sysbus_get_default ()); -object_initialize (&s->ccm,sizeof (s->ccm),TYPE_IMX_CCM ); +object_initialize (&s->ccm,sizeof (s->ccm),TYPE_IMX31_CCM );qdev_set_parent_bus (DEVICE (&s->ccm),sysbus_get_default ());for (i =0 ; i <FSL_IMX25_NUM_UARTS ; i++) {
@@ -150,8 +150,6 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) { FSL_IMX25_GPT4_ADDR, FSL_IMX25_GPT4_IRQ } }; - s->gpt[i].ccm =DEVICE (&s->ccm); -object_property_set_bool (OBJECT (&s->gpt[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
@@ -173,8 +171,6 @@ static void fsl_imx25_realize(DeviceState *dev, Error **errp) { FSL_IMX25_EPIT2_ADDR, FSL_IMX25_EPIT2_IRQ } }; - s->epit[i].ccm =DEVICE (&s->ccm); -object_property_set_bool (OBJECT (&s->epit[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
hw/arm/fsl-imx31.c +1 -5
@@ -35,7 +35,7 @@ static void fsl_imx31_init(Object *obj)object_initialize (&s->avic,sizeof (s->avic),TYPE_IMX_AVIC );qdev_set_parent_bus (DEVICE (&s->avic),sysbus_get_default ()); -object_initialize (&s->ccm,sizeof (s->ccm),TYPE_IMX_CCM ); +object_initialize (&s->ccm,sizeof (s->ccm),TYPE_IMX31_CCM );qdev_set_parent_bus (DEVICE (&s->ccm),sysbus_get_default ());for (i =0 ; i <FSL_IMX31_NUM_UARTS ; i++) {
@@ -128,8 +128,6 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp) serial_table[i].irq)); } - s->gpt.ccm =DEVICE (&s->ccm); -object_property_set_bool (OBJECT (&s->gpt), true,"realized" , &err);if (err) {error_propagate (errp, err);
@@ -150,8 +148,6 @@ static void fsl_imx31_realize(DeviceState *dev, Error **errp) { FSL_IMX31_EPIT2_ADDR, FSL_IMX31_EPIT2_IRQ }, }; - s->epit[i].ccm =DEVICE (&s->ccm); -object_property_set_bool (OBJECT (&s->epit[i]), true,"realized" , &err);if (err) {error_propagate (errp, err);
hw/misc/Makefile.objs +1 -0
@@ -26,6 +26,7 @@ obj-$(CONFIG_NSERIES) += cbus.o obj-$(CONFIG_ECCMEMCTL) += eccmemctl.o obj-$(CONFIG_EXYNOS4) += exynos4210_pmu.o obj-$(CONFIG_IMX) += imx_ccm.o +obj-$(CONFIG_IMX) += imx31_ccm.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx31_ccm.c new file +240 -0
240 lines not on this page · raw message
hw/misc/imx_ccm.c +14 -235
275 lines not on this page · raw message
hw/timer/imx_epit.c +4 -4
@@ -51,9 +51,9 @@ static char const *imx_epit_reg_name(uint32_t reg)* These are typical. */ static const IMXClk imx_epit_clocks[] = { -0 ,/* 00 disabled */ -IPG ,/* 01 ipg_clk, ~532MHz */ -IPG ,/* 10 ipg_clk_highfreq */ +NOCLK ,/* 00 disabled */ +CLK_IPG ,/* 01 ipg_clk, ~532MHz */ +CLK_IPG ,/* 10 ipg_clk_highfreq */ CLK_32k,/* 11 ipg_clk_32k -- ~32kHz */ };
@@ -78,7 +78,7 @@ static void imx_epit_set_freq(IMXEPITState *s) clksrc =extract32 (s->cr,CR_CLKSRC_SHIFT ,2 ); prescaler =1 +extract32 (s->cr,CR_PRESCALE_SHIFT ,12 ); - freq =imx_clock_frequency (s->ccm, imx_epit_clocks[clksrc]) / prescaler; + freq =imx_ccm_get_clock_frequency (imx_epit_clocks[clksrc]) / prescaler; s->freq = freq;
hw/timer/imx_gpt.c +6 -6
@@ -81,19 +81,19 @@ static const VMStateDescription vmstate_imx_timer_gpt = {static const IMXClk imx_gpt_clocks[] = {NOCLK ,/* 000 No clock source */ -IPG ,/* 001 ipg_clk, 532MHz*/ -IPG ,/* 010 ipg_clk_highfreq */ +CLK_IPG ,/* 001 ipg_clk, 532MHz*/ +CLK_IPG ,/* 010 ipg_clk_highfreq */ NOCLK ,/* 011 not defined */ CLK_32k,/* 100 ipg_clk_32k */ -NOCLK ,/* 101 not defined */ -NOCLK ,/* 110 not defined */ -NOCLK ,/* 111 not defined */ + CLK_32k,/* 101 not defined */ + CLK_32k,/* 110 not defined */ + CLK_32k,/* 111 not defined */ };static void imx_gpt_set_freq (IMXGPTState *s) {uint32_t clksrc =extract32 (s->cr,GPT_CR_CLKSRC_SHIFT ,3 ); -uint32_t freq =imx_clock_frequency (s->ccm, imx_gpt_clocks[clksrc]) +uint32_t freq =imx_ccm_get_clock_frequency (imx_gpt_clocks[clksrc]) / (1 + s->pr); s->freq = freq;
include/hw/arm/fsl-imx25.h +2 -2
@@ -19,7 +19,7 @@#include "hw/arm/arm.h" #include "hw/intc/imx_avic.h" -#include "hw/misc/imx_ccm.h" +#include "hw/misc/imx31_ccm.h" #include "hw/char/imx_serial.h" #include "hw/timer/imx_gpt.h" #include "hw/timer/imx_epit.h"
@@ -44,7 +44,7 @@ typedef struct FslIMX25State {/*< public >*/ ARMCPU cpu;IMXAVICState avic; -IMXCCMState ccm; +IMX31CCMState ccm;IMXSerialState uart[FSL_IMX25_NUM_UARTS ];IMXGPTState gpt[FSL_IMX25_NUM_GPTS ];IMXEPITState epit[FSL_IMX25_NUM_EPITS ];
include/hw/arm/fsl-imx31.h +2 -2
@@ -19,7 +19,7 @@#include "hw/arm/arm.h" #include "hw/intc/imx_avic.h" -#include "hw/misc/imx_ccm.h" +#include "hw/misc/imx31_ccm.h" #include "hw/char/imx_serial.h" #include "hw/timer/imx_gpt.h" #include "hw/timer/imx_epit.h"
@@ -42,7 +42,7 @@ typedef struct FslIMX31State {/*< public >*/ ARMCPU cpu;IMXAVICState avic; -IMXCCMState ccm; +IMX31CCMState ccm;IMXSerialState uart[FSL_IMX31_NUM_UARTS ];IMXGPTState gpt;IMXEPITState epit[FSL_IMX31_NUM_EPITS ];
include/hw/misc/imx31_ccm.h new file +68 -0
68 lines not on this page · raw message
include/hw/misc/imx_ccm.h +15 -58
93 lines not on this page · raw message
include/hw/timer/imx_epit.h +0 -1
@@ -64,7 +64,6 @@ typedef struct IMXEPITState{ptimer_state *timer_reload;ptimer_state *timer_cmp;MemoryRegion iomem; -DeviceState *ccm;uint32_t cr;uint32_t sr;
include/hw/timer/imx_gpt.h +0 -1
@@ -83,7 +83,6 @@ typedef struct IMXGPTState{/*< public >*/ ptimer_state *timer;MemoryRegion iomem; -DeviceState *ccm;uint32_t cr;uint32_t pr;
Signature · 1 line
2.5.0
PATCH 2/2 i.MX: Add i.MX25 CCM driver
In reply to Jean-Christophe DuboisThe i.MX25 CCM device is different from the i.MX31 one.
So for now the emulation was not correct even if linux was working OK on top of the i.MX25 emulation.
We add an i.MX25 specific CCM driver and use it in the i.MX25 SOC emulation.
--- hw/arm/fsl-imx25.c | 2 +- hw/misc/Makefile.objs | 1 + hw/misc/imx25_ccm.c | 224 ++++++++++++++++++++++++++++++++++++++++++++ include/hw/arm/fsl-imx25.h | 4 +- include/hw/misc/imx25_ccm.h | 61 ++++++++++++ 5 files changed, 289 insertions(+), 3 deletions(-) create mode 100644 hw/misc/imx25_ccm.c create mode 100644 include/hw/misc/imx25_ccm.h
hw/arm/fsl-imx25.c +1 -1
@@ -38,7 +38,7 @@ static void fsl_imx25_init(Object *obj)object_initialize (&s->avic,sizeof (s->avic),TYPE_IMX_AVIC );qdev_set_parent_bus (DEVICE (&s->avic),sysbus_get_default ()); -object_initialize (&s->ccm,sizeof (s->ccm),TYPE_IMX31_CCM ); +object_initialize (&s->ccm,sizeof (s->ccm),TYPE_IMX25_CCM );qdev_set_parent_bus (DEVICE (&s->ccm),sysbus_get_default ());for (i =0 ; i <FSL_IMX25_NUM_UARTS ; i++) {
hw/misc/Makefile.objs +1 -0
@@ -27,6 +27,7 @@ obj-$(CONFIG_ECCMEMCTL) += eccmemctl.o obj-$(CONFIG_EXYNOS4) += exynos4210_pmu.o obj-$(CONFIG_IMX) += imx_ccm.o obj-$(CONFIG_IMX) += imx31_ccm.o +obj-$(CONFIG_IMX) += imx25_ccm.o obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx25_ccm.c new file +224 -0
224 lines not on this page · raw message
include/hw/arm/fsl-imx25.h +2 -2
@@ -19,7 +19,7 @@#include "hw/arm/arm.h" #include "hw/intc/imx_avic.h" -#include "hw/misc/imx31_ccm.h" +#include "hw/misc/imx25_ccm.h" #include "hw/char/imx_serial.h" #include "hw/timer/imx_gpt.h" #include "hw/timer/imx_epit.h"
@@ -44,7 +44,7 @@ typedef struct FslIMX25State {/*< public >*/ ARMCPU cpu;IMXAVICState avic; -IMX31CCMState ccm; +IMX25CCMState ccm;IMXSerialState uart[FSL_IMX25_NUM_UARTS ];IMXGPTState gpt[FSL_IMX25_NUM_GPTS ];IMXEPITState epit[FSL_IMX25_NUM_EPITS ];
include/hw/misc/imx25_ccm.h new file +61 -0
61 lines not on this page · raw message
Signature · 1 line
2.5.0