Skip to contentSkip to conversation

Add i.MX6 (Single/Dual/Quad) support

PATCH Superseded Jean-Christophe Dubois 3 participants 47 messages Feb 8, 2016 – Mar 1, 2016 Arm i.MX and Layerscape

v2 of 7 Superseded Latest is v7 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add i.MX6 (Single/Dual/Quad) support

This patch series adds support for the Freescale i.MX6 processor.

For now we only support the following devices:
* up to 4 Cortex A9 cores
* A9 MPCORE (SCU, GIC, TWD)
* 5 i.MX UARTs
* 2 EPIT timers
* 1 GPT timer
* 7 GPIO controllers
* 6 SDHC controllers
* 1 CCM device
* 1 SRC device
* 3 I2C devices
* various ROM/RAM areas.

This also adds the sabrelite board as a an actual platform for i.MX6.

This series was tested by booting a 4.4 linux kernel (using the imx_v6_v7_defconfig file as kernel configuration).

Note1: as sabrelite uses uart2 as console, you have to redirect the second QEMU serial port to stdout.
qemu-system-arm -M sabrelite -display none ... -serial null -serial stdio

Note2: as the SPI controller is not yet supported in QEMU for i.MX you need to disable SPI controllers in Linux DTS tree. Otherwise Linux would hang during the boot waiting for a SPI device to respond.

Note3: You need to disable the GPIO section related to physical push buttons in the Linux DTS tree in order to avoid excecive interrupt triggering on GPIO devices for non existant buttons.

Jean-Christophe Dubois (9):
i.MX: Allow GPT timer to rollover.
i.MX: Rename CCM NOCLK to CLK_NONE for naming consistency. i.MX: Remove CCM useless clock computation handling. i.MX: Add the CLK_IPG_HIGH clock
i.MX: Add i.MX6 CCM and ANALOG device.
i.MX: Add i.MX6 System Reset Controller device. i.MX: Add i.MX6 SOC implementation.
i.MX: Add sabrelite i.MX6 emulation.
i.MX: Add missing descriptions in devices.

 default-configs/arm-softmmu.mak |   1 +
 hw/arm/Makefile.objs            |   1 +
 hw/arm/fsl-imx25.c              |   1 +
 hw/arm/fsl-imx31.c              |   1 +
 hw/arm/fsl-imx6.c               | 407 +++++++++++++++++++++
 hw/arm/sabrelite.c              |  93 +++++
 hw/i2c/imx_i2c.c                |   1 +
 hw/misc/Makefile.objs           |   2 +
 hw/misc/imx25_ccm.c             |  29 +-
 hw/misc/imx31_ccm.c             |  35 +-
 hw/misc/imx6_ccm.c              | 773 ++++++++++++++++++++++++++++++++++++++++
 hw/misc/imx6_src.c              | 353 ++++++++++++++++++
 hw/net/imx_fec.c                |   1 +
 hw/timer/imx_epit.c             |   8 +-
 hw/timer/imx_gpt.c              |  43 +--
 include/hw/arm/fsl-imx6.h       | 447 +++++++++++++++++++++++
 include/hw/misc/imx6_ccm.h      | 197 ++++++++++
 include/hw/misc/imx6_src.h      |  73 ++++
 include/hw/misc/imx_ccm.h       |  10 +-
 19 files changed, 2384 insertions(+), 92 deletions(-)
 create mode 100644 hw/arm/fsl-imx6.c
 create mode 100644 hw/arm/sabrelite.c
 create mode 100644 hw/misc/imx6_ccm.c
 create mode 100644 hw/misc/imx6_src.c
 create mode 100644 include/hw/arm/fsl-imx6.h
 create mode 100644 include/hw/misc/imx6_ccm.h
 create mode 100644 include/hw/misc/imx6_src.h
Signature · 1 line
2.5.0
#1 lore raw

PATCH v2 1/9 i.MX: Allow GPT timer to rollover.

GPT timer need to rollover when it reaches 0xffffffff.

It also need to reset to 0 when in "restart mode" and crossing the compare 1 register.

---

Changes since V1:
* None

 hw/timer/imx_gpt.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)
hw/timer/imx_gpt.c +15 -12
index b1893b8..b227256 100644
@@ -133,7 +133,7 @@ static inline uint32_t imx_gpt_find_limit(uint32_t count, uint32_t reg,
 static void imx_gpt_compute_next_timeout(IMXGPTState *s, bool event)
 {
     uint32_t timeout = GPT_TIMER_MAX;
-    uint32_t count = 0;
+    uint32_t count;
     long long limit;
 
     if (!(s->cr & GPT_CR_EN)) {
@@ -141,20 +141,23 @@ static void imx_gpt_compute_next_timeout(IMXGPTState *s, bool event)
         return;
     }
 
-    if (event) {
-        /* This is a timer event  */
+    /* update the count */
+    count = imx_gpt_update_count(s);
 
-        if ((s->cr & GPT_CR_FRR)  && (s->next_timeout != GPT_TIMER_MAX)) {
-            /*
-             * if we are in free running mode and we have not reached
-             * the GPT_TIMER_MAX limit, then update the count
+    if (event) {
+        /*
+         * This is an event (the ptimer reached 0 and stopped), and the
+         * timer counter is now equal to s->next_timeout.
+         */
+        if (!(s->cr & GPT_CR_FRR) && (count == s->ocr1)) {
+            /* We are in restart mode and we crossed the compare channel 1
+             * value. We need to reset the counter to 0.
              */
-            count = imx_gpt_update_count(s);
+            count = s->cnt = s->next_timeout = 0;
+        } else if (count == GPT_TIMER_MAX) {
+            /* We reached GPT_TIMER_MAX so we need to rollover */
+            count = s->cnt = s->next_timeout = 0;
         }
-    } else {
-        /* not a timer event, then just update the count */
-
-        count = imx_gpt_update_count(s);
     }
 
     /* now, find the next timeout related to count */
Signature · 1 line
2.5.0
#3 lore raw

PATCH v2 2/9 i.MX: Rename CCM NOCLK to CLK_NONE for naming consistency.

In reply to Jean-Christophe Dubois

This way all CCM clock defines/enums are named CLK_XXX

---

Changes since V1:
* Not present on V1

 hw/misc/imx25_ccm.c       |  2 +-
 hw/misc/imx31_ccm.c       |  2 +-
 hw/timer/imx_epit.c       |  2 +-
 hw/timer/imx_gpt.c        | 10 +++++-----
 include/hw/misc/imx_ccm.h |  2 +-
 5 files changed, 9 insertions(+), 9 deletions(-)
hw/misc/imx25_ccm.c +1 -1
index 23759ca..cc0e893 100644
@@ -181,7 +181,7 @@ static uint32_t imx25_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)
     DPRINTF("Clock = %d)\n", clock);
 
     switch (clock) {
-    case NOCLK:
+    case CLK_NONE:
         break;
     case CLK_MPLL:
         freq = imx25_ccm_get_mpll_clk(dev);
hw/misc/imx31_ccm.c +1 -1
index 47d6ead..10c78f3 100644
@@ -208,7 +208,7 @@ static uint32_t imx31_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)
     uint32_t freq = 0;
 
     switch (clock) {
-    case NOCLK:
+    case CLK_NONE:
         break;
     case CLK_MCU:
         freq = imx31_ccm_get_mcu_clk(dev);
hw/timer/imx_epit.c +1 -1
index 50bf83c..f7772cc 100644
@@ -51,7 +51,7 @@ static char const *imx_epit_reg_name(uint32_t reg)
  * These are typical.
  */
 static const IMXClk imx_epit_clocks[] =  {
-    NOCLK,    /* 00 disabled */
+    CLK_NONE, /* 00 disabled */
     CLK_IPG,  /* 01 ipg_clk, ~532MHz */
     CLK_IPG,  /* 10 ipg_clk_highfreq */
     CLK_32k,  /* 11 ipg_clk_32k -- ~32kHz */
hw/timer/imx_gpt.c +5 -5
index b227256..d1c0294 100644
@@ -80,14 +80,14 @@ static const VMStateDescription vmstate_imx_timer_gpt = {
 };
 
 static const IMXClk imx_gpt_clocks[] = {
-    NOCLK,    /* 000 No clock source */
+    CLK_NONE, /* 000 No clock source */
     CLK_IPG,  /* 001 ipg_clk, 532MHz*/
     CLK_IPG,  /* 010 ipg_clk_highfreq */
-    NOCLK,    /* 011 not defined */
+    CLK_NONE, /* 011 not defined */
     CLK_32k,  /* 100 ipg_clk_32k */
-    NOCLK,    /* 101 not defined */
-    NOCLK,    /* 110 not defined */
-    NOCLK,    /* 111 not defined */
+    CLK_NONE, /* 101 not defined */
+    CLK_NONE, /* 110 not defined */
+    CLK_NONE, /* 111 not defined */
 };
 
 static void imx_gpt_set_freq(IMXGPTState *s)
include/hw/misc/imx_ccm.h +1 -1
index 5c4b795..74e2705 100644
@@ -43,7 +43,7 @@ typedef struct IMXCCMState {
 } IMXCCMState;
 
 typedef enum  {
-    NOCLK,
+    CLK_NONE,
     CLK_MPLL,
     CLK_UPLL,
     CLK_MCU,
Signature · 1 line
2.5.0
#5 lore raw

PATCH v2 3/9 i.MX: Remove CCM useless clock computation handling.

In reply to Jean-Christophe Dubois

Most clocks supported by the CCM are useless to the qemu framework.

Only clocks related to timers (EPIT, GPT, PWM, WATCHDOG, ...) are usefull to QEMU code.

Therefore this patch removes clock computation handling for all clocks but:
* CLK_NONE,
* CLK_IPG,
* CLK_32k

---

Changes since V1:
* move NOCLK renaming in its own patch
* move CLK_IPG_HIGH addition in its own patch

 hw/misc/imx25_ccm.c       | 26 --------------------------
 hw/misc/imx31_ccm.c       | 32 --------------------------------
 include/hw/misc/imx_ccm.h |  7 -------
 3 files changed, 65 deletions(-)
hw/misc/imx25_ccm.c +0 -26
index cc0e893..e74486f 100644
@@ -119,20 +119,6 @@ static uint32_t imx25_ccm_get_mpll_clk(IMXCCMState *dev)
     return freq;
 }
 
-static uint32_t imx25_ccm_get_upll_clk(IMXCCMState *dev)
-{
-    uint32_t freq = 0;
-    IMX25CCMState *s = IMX25_CCM(dev);
-
-    if (!EXTRACT(s->reg[IMX25_CCM_CCTL_REG], UPLL_DIS)) {
-        freq = imx_ccm_calc_pll(s->reg[IMX25_CCM_UPCTL_REG], CKIH_FREQ);
-    }
-
-    DPRINTF("freq = %d\n", freq);
-
-    return freq;
-}
-
 static uint32_t imx25_ccm_get_mcu_clk(IMXCCMState *dev)
 {
     uint32_t freq;
@@ -183,18 +169,6 @@ static uint32_t imx25_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)
     switch (clock) {
     case CLK_NONE:
         break;
-    case CLK_MPLL:
-        freq = imx25_ccm_get_mpll_clk(dev);
-        break;
-    case CLK_UPLL:
-        freq = imx25_ccm_get_upll_clk(dev);
-        break;
-    case CLK_MCU:
-        freq = imx25_ccm_get_mcu_clk(dev);
-        break;
-    case CLK_AHB:
-        freq = imx25_ccm_get_ahb_clk(dev);
-        break;
     case CLK_IPG:
         freq = imx25_ccm_get_ipg_clk(dev);
         break;
hw/misc/imx31_ccm.c +0 -32
index 10c78f3..dee0b11 100644
@@ -151,32 +151,6 @@ static uint32_t imx31_ccm_get_mcu_main_clk(IMXCCMState *dev)
     return freq;
 }
 
-static uint32_t imx31_ccm_get_mcu_clk(IMXCCMState *dev)
-{
-    uint32_t freq;
-    IMX31CCMState *s = IMX31_CCM(dev);
-
-    freq = imx31_ccm_get_mcu_main_clk(dev)
-           / (1 + EXTRACT(s->reg[IMX31_CCM_PDR0_REG], MCU));
-
-    DPRINTF("freq = %d\n", freq);
-
-    return freq;
-}
-
-static uint32_t imx31_ccm_get_hsp_clk(IMXCCMState *dev)
-{
-    uint32_t freq;
-    IMX31CCMState *s = IMX31_CCM(dev);
-
-    freq = imx31_ccm_get_mcu_main_clk(dev)
-           / (1 + EXTRACT(s->reg[IMX31_CCM_PDR0_REG], HSP));
-
-    DPRINTF("freq = %d\n", freq);
-
-    return freq;
-}
-
 static uint32_t imx31_ccm_get_hclk_clk(IMXCCMState *dev)
 {
     uint32_t freq;
@@ -210,12 +184,6 @@ static uint32_t imx31_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)
     switch (clock) {
     case CLK_NONE:
         break;
-    case CLK_MCU:
-        freq = imx31_ccm_get_mcu_clk(dev);
-        break;
-    case CLK_HSP:
-        freq = imx31_ccm_get_hsp_clk(dev);
-        break;
     case CLK_IPG:
         freq = imx31_ccm_get_ipg_clk(dev);
         break;
include/hw/misc/imx_ccm.h +0 -7
index 74e2705..378b78d 100644
@@ -44,14 +44,7 @@ typedef struct IMXCCMState {
 
 typedef enum  {
     CLK_NONE,
-    CLK_MPLL,
-    CLK_UPLL,
-    CLK_MCU,
-    CLK_HSP,
-    CLK_MAX,
-    CLK_AHB,
     CLK_IPG,
-    CLK_PER,
     CLK_32k
 } IMXClk;
 
Signature · 1 line
2.5.0
#7 lore raw

PATCH v2 4/9 i.MX: Add the CLK_IPG_HIGH clock

In reply to Jean-Christophe Dubois

EPIT, GPT and other i.MX timers are using "abstract" clocks among which a CLK_IPG_HIGH clock.

On i.MX25 and i.MX31 CLK_IPG and CLK_IPG_HIGH are mapped to the same clock but on other SOC like i.MX6 they are mapped to distinct clocks.

This patch add the CLK_IPG_HIGH to prepare for SOC where these 2 clocks are different.

---

Changes since V1:
* Not present on V1

 hw/misc/imx25_ccm.c       |  1 +
 hw/misc/imx31_ccm.c       |  1 +
 hw/timer/imx_epit.c       |  8 ++++----
 hw/timer/imx_gpt.c        | 16 ++++++++--------
 include/hw/misc/imx_ccm.h |  1 +
 5 files changed, 15 insertions(+), 12 deletions(-)
hw/misc/imx25_ccm.c +1 -0
index e74486f..caceb0e 100644
@@ -170,6 +170,7 @@ static uint32_t imx25_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)
     case CLK_NONE:
         break;
     case CLK_IPG:
+    case CLK_IPG_HIGH:
         freq = imx25_ccm_get_ipg_clk(dev);
         break;
     case CLK_32k:
hw/misc/imx31_ccm.c +1 -0
index dee0b11..96ba2cb 100644
@@ -185,6 +185,7 @@ static uint32_t imx31_ccm_get_clock_frequency(IMXCCMState *dev, IMXClk clock)
     case CLK_NONE:
         break;
     case CLK_IPG:
+    case CLK_IPG_HIGH:
         freq = imx31_ccm_get_ipg_clk(dev);
         break;
     case CLK_32k:
hw/timer/imx_epit.c +4 -4
index f7772cc..ecd2e5a 100644
@@ -51,10 +51,10 @@ static char const *imx_epit_reg_name(uint32_t reg)
  * These are typical.
  */
 static const IMXClk imx_epit_clocks[] =  {
-    CLK_NONE, /* 00 disabled */
-    CLK_IPG,  /* 01 ipg_clk, ~532MHz */
-    CLK_IPG,  /* 10 ipg_clk_highfreq */
-    CLK_32k,  /* 11 ipg_clk_32k -- ~32kHz */
+    CLK_NONE,      /* 00 disabled */
+    CLK_IPG,       /* 01 ipg_clk, ~532MHz */
+    CLK_IPG_HIGH,  /* 10 ipg_clk_highfreq */
+    CLK_32k,       /* 11 ipg_clk_32k -- ~32kHz */
 };
 
 /*
hw/timer/imx_gpt.c +8 -8
index d1c0294..e69456d 100644
@@ -80,14 +80,14 @@ static const VMStateDescription vmstate_imx_timer_gpt = {
 };
 
 static const IMXClk imx_gpt_clocks[] = {
-    CLK_NONE, /* 000 No clock source */
-    CLK_IPG,  /* 001 ipg_clk, 532MHz*/
-    CLK_IPG,  /* 010 ipg_clk_highfreq */
-    CLK_NONE, /* 011 not defined */
-    CLK_32k,  /* 100 ipg_clk_32k */
-    CLK_NONE, /* 101 not defined */
-    CLK_NONE, /* 110 not defined */
-    CLK_NONE, /* 111 not defined */
+    CLK_NONE,      /* 000 No clock source */
+    CLK_IPG,       /* 001 ipg_clk, 532MHz*/
+    CLK_IPG_HIGH,  /* 010 ipg_clk_highfreq */
+    CLK_NONE,      /* 011 not defined */
+    CLK_32k,       /* 100 ipg_clk_32k */
+    CLK_NONE,      /* 101 not defined */
+    CLK_NONE,      /* 110 not defined */
+    CLK_NONE,      /* 111 not defined */
 };
 
 static void imx_gpt_set_freq(IMXGPTState *s)
include/hw/misc/imx_ccm.h +1 -0
index 378b78d..48a7afa 100644
@@ -45,6 +45,7 @@ typedef struct IMXCCMState {
 typedef enum  {
     CLK_NONE,
     CLK_IPG,
+    CLK_IPG_HIGH,
     CLK_32k
 } IMXClk;
 
Signature · 1 line
2.5.0
#13 lore raw

PATCH v2 6/9 i.MX: Add i.MX6 System Reset Controller device.

In reply to Jean-Christophe Dubois

This controller is also present in i.MX5X devices but they are not yet emulated by QEMU.

---

Changes since V1:
* Change "reset" sematic to mean full power cyvle.

 hw/misc/Makefile.objs      |   1 +
 hw/misc/imx6_src.c         | 353 +++++++++++++++++++++++++++++++++++++++++++++
 include/hw/misc/imx6_src.h |  73 ++++++++++
 3 files changed, 427 insertions(+)
 create mode 100644 hw/misc/imx6_src.c
 create mode 100644 include/hw/misc/imx6_src.h
hw/misc/Makefile.objs +1 -0
index a2a8e91..6bac654 100644
@@ -29,6 +29,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) += imx6_src.o
 obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o
 obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o
 obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx6_src.c new file +353 -0

353 lines not on this page · raw message

include/hw/misc/imx6_src.h new file +73 -0

73 lines not on this page · raw message

Signature · 1 line
2.5.0
#9 lore raw

PATCH v2 5/9 i.MX: Add i.MX6 CCM and ANALOG device.

In reply to Jean-Christophe Dubois

---

Changes since V1:
* move clk computation to uint64_t to avoid overflow
* added explanation on _SET, _CLR and _TOG registers
* move CCM and ANALOG handling in sub memory regions.

 hw/misc/Makefile.objs      |   1 +
 hw/misc/imx6_ccm.c         | 773 +++++++++++++++++++++++++++++++++++++++++++++
 include/hw/misc/imx6_ccm.h | 197 ++++++++++++
 3 files changed, 971 insertions(+)
 create mode 100644 hw/misc/imx6_ccm.c
 create mode 100644 include/hw/misc/imx6_ccm.h
hw/misc/Makefile.objs +1 -0
index d4765c2..a2a8e91 100644
@@ -28,6 +28,7 @@ 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_IMX) += imx6_ccm.o
 obj-$(CONFIG_MILKYMIST) += milkymist-hpdmc.o
 obj-$(CONFIG_MILKYMIST) += milkymist-pfpu.o
 obj-$(CONFIG_MAINSTONE) += mst_fpga.o
hw/misc/imx6_ccm.c new file +773 -0

773 lines not on this page · raw message

include/hw/misc/imx6_ccm.h new file +197 -0

197 lines not on this page · raw message

Signature · 1 line
2.5.0
#18 lore raw

PATCH v2 7/9 i.MX: Add i.MX6 SOC implementation.

In reply to Jean-Christophe Dubois

For now we only support the following devices:
* up to 4 Cortex A9 cores
* A9 MPCORE (SCU, GIC, TWD)
* 5 i.MX UARTs
* 2 EPIT timers
* 1 GPT timer
* 3 I2C controllers
* 7 GPIO controllers
* 6 SDHC controllers
* 1 CCM device
* 1 SRC device
* various ROM/RAM areas.

---

Changes since V1:
* use g_strdup_printf/g_free instead of local char array.
* output a message on exit for unsupported number of cores.

 default-configs/arm-softmmu.mak |   1 +
 hw/arm/Makefile.objs            |   1 +
 hw/arm/fsl-imx6.c               | 407 ++++++++++++++++++++++++++++++++++++
 include/hw/arm/fsl-imx6.h       | 447 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 856 insertions(+)
 create mode 100644 hw/arm/fsl-imx6.c
 create mode 100644 include/hw/arm/fsl-imx6.h
default-configs/arm-softmmu.mak +1 -0
index d9b90a5..ba3a380 100644
@@ -99,6 +99,7 @@ CONFIG_ALLWINNER_A10_PIT=y
 CONFIG_ALLWINNER_A10_PIC=y
 CONFIG_ALLWINNER_A10=y
 
+CONFIG_FSL_IMX6=y
 CONFIG_FSL_IMX31=y
 CONFIG_FSL_IMX25=y
 
hw/arm/Makefile.objs +1 -0
index 2195b60..ac383df 100644
@@ -15,3 +15,4 @@ obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
 obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o
 obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
 obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
+obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o
hw/arm/fsl-imx6.c new file +407 -0

407 lines not on this page · raw message

include/hw/arm/fsl-imx6.h new file +447 -0

447 lines not on this page · raw message

Signature · 1 line
2.5.0
#40 lore raw

PATCH v2 8/9 i.MX: Add sabrelite i.MX6 emulation.

In reply to Jean-Christophe Dubois

---

Changes since v1:
* output a message and exit if RAM size is unsupported.

 hw/arm/Makefile.objs |  2 +-
 hw/arm/sabrelite.c   | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/sabrelite.c
hw/arm/Makefile.objs +1 -1
index ac383df..fc1df45 100644
@@ -15,4 +15,4 @@ obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
 obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o
 obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
 obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
-obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o
+obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o
hw/arm/sabrelite.c new file +93 -0

93 lines not on this page · raw message

Signature · 1 line
2.5.0
#42 lore raw

PATCH v2 9/9 i.MX: Add missing descriptions in devices.

In reply to Jean-Christophe Dubois

---

Changes since V1:
* Not present on V1

 hw/arm/fsl-imx25.c | 1 +
 hw/arm/fsl-imx31.c | 1 +
 hw/i2c/imx_i2c.c   | 1 +
 hw/net/imx_fec.c   | 1 +
 4 files changed, 4 insertions(+)
hw/arm/fsl-imx25.c +1 -0
index fb743bf..1fbc317 100644
@@ -291,6 +291,7 @@ static void fsl_imx25_class_init(ObjectClass *oc, void *data)
      * arm_cpu_class_init()
      */
     dc->cannot_destroy_with_object_finalize_yet = true;
+    dc->desc = "i.MX25 SOC";
 }
 
 static const TypeInfo fsl_imx25_type_info = {
hw/arm/fsl-imx31.c +1 -0
index f2c2ce5..0d69a2c 100644
@@ -265,6 +265,7 @@ static void fsl_imx31_class_init(ObjectClass *oc, void *data)
      * arm_cpu_class_init()
      */
     dc->cannot_destroy_with_object_finalize_yet = true;
+    dc->desc = "i.MX31 SOC";
 }
 
 static const TypeInfo fsl_imx31_type_info = {
hw/i2c/imx_i2c.c +1 -0
index cb62c7a..aa47a63 100644
@@ -318,6 +318,7 @@ static void imx_i2c_class_init(ObjectClass *klass, void *data)
     dc->vmsd = &imx_i2c_vmstate;
     dc->reset = imx_i2c_reset;
     dc->realize = imx_i2c_realize;
+    dc->desc = "i.MX I2C controller";
 }
 
 static const TypeInfo imx_i2c_type_info = {
hw/net/imx_fec.c +1 -0
index c50bf7f..789a0c1 100644
@@ -692,6 +692,7 @@ static void imx_fec_class_init(ObjectClass *klass, void *data)
     dc->reset = imx_fec_reset;
     dc->props = imx_fec_properties;
     dc->realize = imx_fec_realize;
+    dc->desc = "i.MX FEC Ethernet ccontroller";
 }
 
 static const TypeInfo imx_fec_info = {
Signature · 1 line
2.5.0
Reviewed-by on v2 3/9
#6 lore raw

Re: [Qemu-devel] [PATCH v2 3/9] i.MX: Remove CCM useless clock computation handling.

In reply to Jean-Christophe Dubois
Quoted 11 lines · Jean-Christophe Dubois

Most clocks supported by the CCM are useless to the qemu framework.

Only clocks related to timers (EPIT, GPT, PWM, WATCHDOG, ...) are usefull to QEMU code.

Therefore this patch removes clock computation handling for all clocks but:
* CLK_NONE,
* CLK_IPG,
* CLK_32k

thanks
-- PMM

Reviewed-by on v2 4/9
#8 lore raw

Re: [Qemu-devel] [PATCH v2 4/9] i.MX: Add the CLK_IPG_HIGH clock

In reply to Jean-Christophe Dubois
Quoted 11 lines · Jean-Christophe Dubois

EPIT, GPT and other i.MX timers are using "abstract" clocks among which a CLK_IPG_HIGH clock.

On i.MX25 and i.MX31 CLK_IPG and CLK_IPG_HIGH are mapped to the same clock but on other SOC like i.MX6 they are mapped to distinct clocks.

This patch add the CLK_IPG_HIGH to prepare for SOC where these 2 clocks are different.

---

thanks
-- PMM

Reviewed-by on v2 5/9
#10 lore raw

Re: [Qemu-devel] [PATCH v2 5/9] i.MX: Add i.MX6 CCM and ANALOG device.

In reply to Jean-Christophe Dubois
Quoted 8 lines · Jean-Christophe Dubois

---

Changes since V1:
* move clk computation to uint64_t to avoid overflow
* added explanation on _SET, _CLR and _TOG registers
* move CCM and ANALOG handling in sub memory regions.

Quoted 6 lines
 hw/misc/Makefile.objs      |   1 +
 hw/misc/imx6_ccm.c         | 773 +++++++++++++++++++++++++++++++++++++++++++++
 include/hw/misc/imx6_ccm.h | 197 ++++++++++++
 3 files changed, 971 insertions(+)
 create mode 100644 hw/misc/imx6_ccm.c
 create mode 100644 include/hw/misc/imx6_ccm.h

thanks
-- PMM

Reviewed-by on v2 9/9
#43 lore raw

Re: [Qemu-devel] [PATCH v2 9/9] i.MX: Add missing descriptions in devices.

In reply to Jean-Christophe Dubois
Quoted 12 lines · Jean-Christophe Dubois

---

Changes since V1:
* Not present on V1

 hw/arm/fsl-imx25.c | 1 +
 hw/arm/fsl-imx31.c | 1 +
 hw/i2c/imx_i2c.c   | 1 +
 hw/net/imx_fec.c   | 1 +
 4 files changed, 4 insertions(+)

thanks
-- PMM

Reviewed-by on v2 8/9
#41 lore raw

Re: [Qemu-devel] [PATCH v2 8/9] i.MX: Add sabrelite i.MX6 emulation.

In reply to Jean-Christophe Dubois
Quoted 30 lines · Jean-Christophe Dubois

---

Changes since v1:
* output a message and exit if RAM size is unsupported.

 hw/arm/Makefile.objs |  2 +-
 hw/arm/sabrelite.c   | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 hw/arm/sabrelite.c
hw/arm/Makefile.objs +1 -1
index ac383df..fc1df45 100644
@@ -15,4 +15,4 @@ obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
 obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o
 obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
 obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
-obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o
+obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o
hw/arm/sabrelite.c new file +3 -0
new file mode 100644
index 0000000..8db9bbc
@@ -0,0 +1,93 @@
+/*
+ * SABRELITE Board System emulation.
+ *

hw/arm/sabrelite.c line 13

Quoted 10 lines
hw/arm/sabrelite.c new file +10 -0
+ * Copyright (c) 2015 Jean-Christophe Dubois <[email protected]>
+ *
+ * This code is licensed under the GPL, version 2 or later.
+ * See the file `COPYING' in the top level directory.
+ *
+ * It (partially) emulates a sabrelite board, with a Freescale
+ * i.MX6 SoC
+ */
+
+#include "hw/arm/fsl-imx6.h"

You need to include "qemu/osdep.h" as the first #include in any source file. (I forgot to mention this for the earlier patches; please make sure you fix any other new source files in this patchset).

[This is a new convention we're trying to bring in, so at the moment things will still compile without it, but if you can add the include that will save me coming along later with a fixup patch. And at some point qemu-common.h won't include osdep.h and files will no longer compile without it explicitly included first...]

Otherwise

thanks
-- PMM

#19 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

In reply to Jean-Christophe Dubois
Quoted 67 lines · Jean-Christophe Dubois

For now we only support the following devices:
* up to 4 Cortex A9 cores
* A9 MPCORE (SCU, GIC, TWD)
* 5 i.MX UARTs
* 2 EPIT timers
* 1 GPT timer
* 3 I2C controllers
* 7 GPIO controllers
* 6 SDHC controllers
* 1 CCM device
* 1 SRC device
* various ROM/RAM areas.

---

Changes since V1:
* use g_strdup_printf/g_free instead of local char array.
* output a message on exit for unsupported number of cores.

 default-configs/arm-softmmu.mak |   1 +
 hw/arm/Makefile.objs            |   1 +
 hw/arm/fsl-imx6.c               | 407 ++++++++++++++++++++++++++++++++++++
 include/hw/arm/fsl-imx6.h       | 447 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 856 insertions(+)
 create mode 100644 hw/arm/fsl-imx6.c
 create mode 100644 include/hw/arm/fsl-imx6.h
default-configs/arm-softmmu.mak +1 -0
index d9b90a5..ba3a380 100644
@@ -99,6 +99,7 @@ CONFIG_ALLWINNER_A10_PIT=y
 CONFIG_ALLWINNER_A10_PIC=y
 CONFIG_ALLWINNER_A10=y
 
+CONFIG_FSL_IMX6=y
 CONFIG_FSL_IMX31=y
 CONFIG_FSL_IMX25=y
 
hw/arm/Makefile.objs +1 -0
index 2195b60..ac383df 100644
@@ -15,3 +15,4 @@ obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
 obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o
 obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
 obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
+obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o
hw/arm/fsl-imx6.c new file +12 -0
new file mode 100644
index 0000000..0faae27
@@ -0,0 +1,407 @@
+/*
+ * Copyright (c) 2015 Jean-Christophe Dubois <[email protected]>
+ *
+ * i.MX6 SOC emulation.
+ *
+ * Based on hw/arm/fsl-imx31.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.
+ *

hw/arm/fsl-imx6.c line 22

Quoted 10 lines
hw/arm/fsl-imx6.c new file +10 -0
+ *  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.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "hw/arm/fsl-imx6.h"

Include "osdep/qemu.h" first, please (see comments on patch 8).

Quoted 8 lines
hw/arm/fsl-imx6.c new file +7 -0
+#include "sysemu/sysemu.h"
+#include "exec/address-spaces.h"
+#include "hw/boards.h"
+#include "sysemu/char.h"
+#include "qemu/error-report.h"
 
+static void fsl_imx6_realize(DeviceState *dev, Error **errp)
+{

hw/arm/fsl-imx6.c line 94

Quoted 10 lines
hw/arm/fsl-imx6.c new file +10 -0
+    FslIMX6State *s = FSL_IMX6(dev);
+    uint16_t i;
+    Error *err = NULL;
+
+    for (i = 0; i < smp_cpus; i++) {
+
+        if (smp_cpus == 1) {
+            /* On uniprocessor, the CBAR is set to 0 */
+            object_property_set_int(OBJECT(&s->cpu[i]), 0,
+                                    "reset-cbar", &error_abort);

0 is the default for this property so you don't really need to set this.

hw/arm/fsl-imx6.c line 107

Quoted 13 lines
hw/arm/fsl-imx6.c new file +13 -0
+        } else {
+            object_property_set_int(OBJECT(&s->cpu[i]), FSL_IMX6_A9MPCORE_ADDR,
+                                    "reset-cbar", &error_abort);
+        }
+
+        /* All CPU but CPU 0 start in power off mode */
+        if (i) {
+            object_property_set_bool(OBJECT(&s->cpu[i]), true,
+                                     "start-powered-off", &error_abort);
+        }
+
+        object_property_set_bool(OBJECT(&s->cpu[i]), false,
+                                 "has_el3", &error_abort);

Do the CPUs in this board really not have EL3 ?

Otherwise this looks OK.

thanks
-- PMM

#14 lore raw

Re: [Qemu-devel] [PATCH v2 6/9] i.MX: Add i.MX6 System Reset Controller device.

In reply to Jean-Christophe Dubois
Quoted 9 lines · Jean-Christophe Dubois

This controller is also present in i.MX5X devices but they are not yet emulated by QEMU.

hw/misc/imx6_src.c new file +3 -0
@@ -0,0 +1,353 @@
+/*
+ * IMX6 System Reset Controller
+ *

hw/misc/imx6_src.c line 13

Quoted 10 lines
hw/misc/imx6_src.c new file +10 -0
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#include "hw/misc/imx6_src.h"
+#include "sysemu/sysemu.h"
+#include "qemu/bitops.h"

#include "qemu/osdep.h" as first #include line.

hw/misc/imx6_src.c line 90

Quoted 11 lines
hw/misc/imx6_src.c new file +11 -0
+static void imx6_src_reset(DeviceState *dev)
+{
+    IMX6SRCState *s = IMX6_SRC(dev);
+
+    DPRINTF("\n");
+
+    /*
+     * We only clear the first registers as all GPR registers are preserved
+     * over resets
+     */
+    memset(s->regs, 0, SRC_MAX * sizeof(uint32_t));

Comment doesn't seem to match code?

Quoted 95 lines
hw/misc/imx6_src.c new file +94 -0
+    /* Set reset values */
+    s->regs[SRC_SCR] = 0x521;
+    s->regs[SRC_SRSR] = 0x1;
+    s->regs[SRC_SIMR] = 0x1F;
+}
+
+static CPUState *imx6_src_get_cpu_by_id(uint32_t id)
+{
+    CPUState *cpu;
+
+    DPRINTF("cpu %d\n", id);
+
+    CPU_FOREACH(cpu) {
+        ARMCPU *armcpu = ARM_CPU(cpu);
+
+        if (armcpu->mp_affinity == id) {
+            return cpu;
+        }
+    }
+
+    qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Resquesting unknown CPU %d\n",
+                  TYPE_IMX6_SRC, __func__, id);
+
+    return NULL;
+}
+
+static void imx6_src_cpu_on(uint32_t cpuid, uint32_t entry, uint32_t context_id)
+{
+    CPUState *target_cpu_state;
+    ARMCPU *target_cpu;
+    CPUClass *target_cpu_class;
+
+    DPRINTF("cpu %d @ 0x%08x with R0 = 0x%08x\n", cpuid, entry, context_id);
+
+    /* change to the cpu we are powering up */
+    target_cpu_state = imx6_src_get_cpu_by_id(cpuid);
+    if (!target_cpu_state) {
+        return;
+    }
+    target_cpu = ARM_CPU(target_cpu_state);
+    if (!target_cpu->powered_off) {
+        qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: CPU %d is already running\n",
+                      TYPE_IMX6_SRC, __func__, cpuid);
+        return;
+    }
+    target_cpu_class = CPU_GET_CLASS(target_cpu);
+
+    /* Initialize the cpu we are turning on */
+    cpu_reset(target_cpu_state);
+    target_cpu->powered_off = false;
+    target_cpu_state->halted = 0;
+
+    target_cpu->env.regs[0] = context_id;
+    target_cpu->env.thumb = entry & 1;
+
+    target_cpu_class->set_pc(target_cpu_state, entry);
+}
+
+static void imx6_src_cpu_off(uint32_t cpuid)
+{
+    CPUState *target_cpu_state;
+    ARMCPU *target_cpu;
+
+    DPRINTF("cpu %d\n", cpuid);
+
+    /* change to the cpu we are powering up */
+    target_cpu_state = imx6_src_get_cpu_by_id(cpuid);
+    if (!target_cpu_state) {
+        return;
+    }
+    target_cpu = ARM_CPU(target_cpu_state);
+    if (target_cpu->powered_off) {
+        qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: CPU %d is already off\n",
+                      TYPE_IMX6_SRC, __func__, cpuid);
+        return;
+    }
+
+    target_cpu->powered_off = true;
+    target_cpu_state->halted = 1;
+    target_cpu_state->exception_index = EXCP_HLT;
+    cpu_loop_exit(target_cpu_state);
+}
 
+static void imx6_src_cpu_reset(uint32_t cpuid)
+{
+    CPUState *target_cpu_state;
+    ARMCPU *target_cpu;
+
+    DPRINTF("cpu %d\n", cpuid);
+
+    /* change to the cpu we are powering up */
+    target_cpu_state = imx6_src_get_cpu_by_id(cpuid);
+    if (!target_cpu_state) {
+        return;
+    }

hw/misc/imx6_src.c line 196

Quoted 10 lines
hw/misc/imx6_src.c new file +10 -0
+    target_cpu = ARM_CPU(target_cpu_state);
+    if (target_cpu->powered_off) {
+        qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: CPU %d is off\n",
+                      TYPE_IMX6_SRC, __func__, cpuid);
+        return;
+    }
+
+    /* Reset the cpu we are turning on */
+    cpu_reset(target_cpu_state);
+}

The code that is messing about with target CPUs to power them up and down needs to be abstracted out into a public API in target-arm/, so it can be used both by your device and by target-arm/psci.c. I don't want variations on this code to duplicate into various devices, because chances are good it will need to change for multithreaded TCG.

Quoted 30 lines
(quoted diff) +29 -0
+static void imx6_src_realize(DeviceState *dev, Error **errp)
+{
+    IMX6SRCState *s = IMX6_SRC(dev);
+
+    memory_region_init_io(&s->iomem, OBJECT(dev), &imx6_src_ops, s,
+                          TYPE_IMX6_SRC, 0x1000);
+    sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
+}
+
+static void imx6_src_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->realize = imx6_src_realize;
+    dc->reset = imx6_src_reset;
+    dc->vmsd = &vmstate_imx6_src;
+    dc->desc = "i.MX6 System Reset Controller";
+}
 
+/* SRC_SCR */
+#define CORE3_ENABLE_SHIFT     (24)
+#define CORE3_ENABLE_LENGTH    (1)
+#define CORE2_ENABLE_SHIFT     (23)
+#define CORE2_ENABLE_LENGTH    (1)
+#define CORE1_ENABLE_SHIFT     (22)
+#define CORE1_ENABLE_LENGTH    (1)
+#define CORE3_RST_SHIFT        (16)
+#define CORE3_RST_LENGTH       (1)
+#define CORE2_RST_SHIFT        (15)
+#define CORE2_RST_LENGTH       (1)

Review

Quoted 10 lines
(quoted diff) +10 -0
+#define CORE1_RST_SHIFT        (14)
+#define CORE1_RST_LENGTH       (1)
+#define CORE0_RST_SHIFT        (13)
+#define CORE0_RST_LENGTH       (1)
+#define SW_IPU1_RST_SHIFT      (3)
+#define SW_IPU1_RST_LENGTH     (1)
+#define SW_IPU2_RST_SHIFT      (12)
+#define SW_IPU2_RST_LENGTH     (1)
+#define WARM_RST_ENABLE_SHIFT  (0)
+#define WARM_RST_ENABLE_LENGTH (1)

The brackets here are unnecessary.

thanks
-- PMM

#20 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

In reply to Peter Maydell
Quoted 99 lines · Peter Maydell
Quoted 67 lines · Jean-Christophe Dubois

For now we only support the following devices:
* up to 4 Cortex A9 cores
* A9 MPCORE (SCU, GIC, TWD)
* 5 i.MX UARTs
* 2 EPIT timers
* 1 GPT timer
* 3 I2C controllers
* 7 GPIO controllers
* 6 SDHC controllers
* 1 CCM device
* 1 SRC device
* various ROM/RAM areas.

---

Changes since V1:
* use g_strdup_printf/g_free instead of local char array.
* output a message on exit for unsupported number of cores.

  default-configs/arm-softmmu.mak |   1 +
  hw/arm/Makefile.objs            |   1 +
  hw/arm/fsl-imx6.c               | 407 ++++++++++++++++++++++++++++++++++++
  include/hw/arm/fsl-imx6.h       | 447 ++++++++++++++++++++++++++++++++++++++++
  4 files changed, 856 insertions(+)

create mode 100644 hw/arm/fsl-imx6.c
create mode 100644 include/hw/arm/fsl-imx6.h

default-configs/arm-softmmu.mak +1 -0
index d9b90a5..ba3a380 100644
@@ -99,6 +99,7 @@ CONFIG_ALLWINNER_A10_PIT=y
  CONFIG_ALLWINNER_A10_PIC=y
  CONFIG_ALLWINNER_A10=y
 
+CONFIG_FSL_IMX6=y
  CONFIG_FSL_IMX31=y
  CONFIG_FSL_IMX25=y
 
hw/arm/Makefile.objs +1 -0
index 2195b60..ac383df 100644
@@ -15,3 +15,4 @@ obj-$(CONFIG_STM32F205_SOC) += stm32f205_soc.o
  obj-$(CONFIG_XLNX_ZYNQMP) += xlnx-zynqmp.o xlnx-ep108.o
  obj-$(CONFIG_FSL_IMX25) += fsl-imx25.o imx25_pdk.o
  obj-$(CONFIG_FSL_IMX31) += fsl-imx31.o kzm.o
+obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o
hw/arm/fsl-imx6.c new file +12 -0
new file mode 100644
index 0000000..0faae27
@@ -0,0 +1,407 @@
+/*
+ * Copyright (c) 2015 Jean-Christophe Dubois <[email protected]>
+ *
+ * i.MX6 SOC emulation.
+ *
+ * Based on hw/arm/fsl-imx31.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.
+ *

hw/arm/fsl-imx6.c line 22

Quoted 10 lines
hw/arm/fsl-imx6.c new file +10 -0
+ *  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.
+ *
+ *  You should have received a copy of the GNU General Public License along
+ *  with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "hw/arm/fsl-imx6.h"

Include "osdep/qemu.h" first, please (see comments on patch 8).

Quoted 7 lines
hw/arm/fsl-imx6.c new file +7 -0
+#include "sysemu/sysemu.h"
+#include "exec/address-spaces.h"
+#include "hw/boards.h"
+#include "sysemu/char.h"
+#include "qemu/error-report.h"
+static void fsl_imx6_realize(DeviceState *dev, Error **errp)
+{

hw/arm/fsl-imx6.c line 94

Quoted 10 lines
hw/arm/fsl-imx6.c new file +10 -0
+    FslIMX6State *s = FSL_IMX6(dev);
+    uint16_t i;
+    Error *err = NULL;
+
+    for (i = 0; i < smp_cpus; i++) {
+
+        if (smp_cpus == 1) {
+            /* On uniprocessor, the CBAR is set to 0 */
+            object_property_set_int(OBJECT(&s->cpu[i]), 0,
+                                    "reset-cbar", &error_abort);

0 is the default for this property so you don't really need to set this.

Quoted 14 lines

hw/arm/fsl-imx6.c line 107

Quoted 13 lines
hw/arm/fsl-imx6.c new file +13 -0
+        } else {
+            object_property_set_int(OBJECT(&s->cpu[i]), FSL_IMX6_A9MPCORE_ADDR,
+                                    "reset-cbar", &error_abort);
+        }
+
+        /* All CPU but CPU 0 start in power off mode */
+        if (i) {
+            object_property_set_bool(OBJECT(&s->cpu[i]), true,
+                                     "start-powered-off", &error_abort);
+        }
+
+        object_property_set_bool(OBJECT(&s->cpu[i]), false,
+                                 "has_el3", &error_abort);

Do the CPUs in this board really not have EL3 ?

Well the Cortex A9 is certainly able to get to the secure mode. However, if I enable it (has_el3 set to true), the OS (Linux or Xvisor) will not boot. Disabling it allow both OS to boot on the emulated i.MX6.

Would you have some idea on the reason for this "hang" during the boot when EL3 is enabled?

JC

Quoted 7 lines

Otherwise this looks OK.

thanks
-- PMM

#21 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 9 lines · Jean-Christophe DUBOIS
Quoted 6 lines · Peter Maydell

hw/arm/fsl-imx6.c line 107

Quoted 2 lines · Jean-Christophe Dubois
hw/arm/fsl-imx6.c new file +2 -0
+        object_property_set_bool(OBJECT(&s->cpu[i]), false,
+                                 "has_el3", &error_abort);

Do the CPUs in this board really not have EL3 ?

Quoted 6 lines

Well the Cortex A9 is certainly able to get to the secure mode. However, if I enable it (has_el3 set to true), the OS (Linux or Xvisor) will not boot. Disabling it allow both OS to boot on the emulated i.MX6.

Would you have some idea on the reason for this "hang" during the boot when EL3 is enabled?

How are you booting the OS/hypervisor? Via -kernel or via -bios ? Usually if it doesn't boot this is because there's some bit of boot rom/loader code that runs on the real h/w and isn't being run in your QEMU setup, that does the initial setup of the h/w in secure mode. (In particular, if the secure side doesn't set the GIC interrupts to be NS accessible then things don't work very well.)

I wouldn't have expected that to be an issue for booting linux via -kernel though because there we should be booting the kernel NS and have a hack to configure the GIC appropriately.

Peter C may remember the details of how this should work better than me.

thanks
-- PMM

#22 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 9 lines · Peter Maydell
Quoted 7 lines · Jean-Christophe DUBOIS
Quoted 5 lines · Peter Maydell

hw/arm/fsl-imx6.c line 107

Quoted 2 lines · Jean-Christophe Dubois
hw/arm/fsl-imx6.c new file +2 -0
+        object_property_set_bool(OBJECT(&s->cpu[i]), false,
+                                 "has_el3", &error_abort);

Do the CPUs in this board really not have EL3 ?

Quoted 7 lines
Quoted 6 lines

Well the Cortex A9 is certainly able to get to the secure mode. However, if I enable it (has_el3 set to true), the OS (Linux or Xvisor) will not boot. Disabling it allow both OS to boot on the emulated i.MX6.

Would you have some idea on the reason for this "hang" during the boot when EL3 is enabled?

How are you booting the OS/hypervisor? Via -kernel or via -bios ?

via -kernel ...

Quoted 6 lines

Usually if it doesn't boot this is because there's some bit of boot rom/loader code that runs on the real h/w and isn't being run in your QEMU setup, that does the initial setup of the h/w in secure mode. (In particular, if the secure side doesn't set the GIC interrupts to be NS accessible then things don't work very well.)

Well I guess on real hw uboot is setting things so that everything work thereafter. But here I don't have uboot and I jump directly to Linux ...

In QEMU, other Cortex A9 (Versatilepb.c, Exynos, Zynq ...) are also setting has_el3 to false ...

JC

Quoted 11 lines

I wouldn't have expected that to be an issue for booting linux via -kernel though because there we should be booting the kernel NS and have a hack to configure the GIC appropriately.

Peter C may remember the details of how this should work better than me.

thanks
-- PMM

#23 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 2 lines · Jean-Christophe DUBOIS

In QEMU, other Cortex A9 (Versatilepb.c, Exynos, Zynq ...) are also setting has_el3 to false ...

So these generally are the "legacy" platforms which were added before we ever had EL3 support in QEMU. For them it's hard to turn the EL3 support on for the board even if in theory it ought to be on, because we don't know what users are running on it that we might break. With a new to QEMU board we have an opportunity to get it right from the start.

-kernel I would expect to work, though, at least if the only issue is the interrupt controller setup. It seems worth investigating why it goes wrong.

thanks
-- PMM

#24 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 10 lines · Peter Maydell
Quoted 2 lines · Jean-Christophe DUBOIS

In QEMU, other Cortex A9 (Versatilepb.c, Exynos, Zynq ...) are also setting has_el3 to false ...

So these generally are the "legacy" platforms which were added before we ever had EL3 support in QEMU. For them it's hard to turn the EL3 support on for the board even if in theory it ought to be on, because we don't know what users are running on it that we might break. With a new to QEMU board we have an opportunity to get it right from the start.

OK, so is the "highbank" the only Qemu Cortex A9 board supporting el3 yet?

Quoted 4 lines

-kernel I would expect to work, though, at least if the only issue is the interrupt controller setup. It seems worth investigating why it goes wrong.

Well, I can boot uniprocessor (-smp 1) without trouble but if I turn logs on (guest_errors,unimp) I am getting a lot of

* gic_dist_writeb: Bad offset 38x (a few at startup)
* Ignoring attempt to switch CPSR_A flag from non-secure world with SCR.AW bit clear (a lot)
* Ignoring attempt to switch CPSR_F flag from non-secure world with SCR.FW bit clear (a few)

I am not sure if this is a problem. Do you have some opinion on this?

When I turn SMP (-smp 2 or more), I am unable to complete the boot. As soon as my secondary cpu is started QEMU will continue to boot "very slowly" but doesn't get to the linux user prompt overnight.

JC

Quoted 4 lines

thanks
-- PMM

#25 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 16 lines · Jean-Christophe DUBOIS

Le 16/02/2016 22:57, Peter Maydell a écrit :

On 16 February 2016 at 21:47, Jean-Christophe DUBOIS <[email protected]> wrote:

In QEMU, other Cortex A9 (Versatilepb.c, Exynos, Zynq ...) are also setting has_el3 to false ...

So these generally are the "legacy" platforms which were added before we ever had EL3 support in QEMU. For them it's hard to turn the EL3 support on for the board even if in theory it ought to be on, because we don't know what users are running on it that we might break. With a new to QEMU board we have an opportunity to get it right from the start.

Quoted 2 lines

OK, so is the "highbank" the only Qemu Cortex A9 board supporting el3 yet?

Yep. We don't have many A9 boards and most of those we do have are in the 'legacy' bucket.

Quoted 5 lines

-kernel I would expect to work, though, at least if the only issue is the interrupt controller setup. It seems worth investigating why it goes wrong.

Quoted 8 lines

Well, I can boot uniprocessor (-smp 1) without trouble but if I turn logs on (guest_errors,unimp) I am getting a lot of

gic_dist_writeb: Bad offset 38x (a few at startup) Ignoring attempt to switch CPSR_A flag from non-secure world with SCR.AW bit clear (a lot)
Ignoring attempt to switch CPSR_F flag from non-secure world with SCR.FW bit clear (a few)

This would only be a problem if your kernel needed to use FIQ, I think.

Quoted 5 lines

I am not sure if this is a problem. Do you have some opinion on this?

When I turn SMP (-smp 2 or more), I am unable to complete the boot. As soon as my secondary cpu is started QEMU will continue to boot "very slowly" but doesn't get to the linux user prompt overnight.

Does SMP work with EL3 not enabled, or is this a different bug?

thanks
-- PMM

#26 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 31 lines · Peter Maydell
Quoted 16 lines · Jean-Christophe DUBOIS

Le 16/02/2016 22:57, Peter Maydell a écrit :

On 16 February 2016 at 21:47, Jean-Christophe DUBOIS <[email protected]> wrote:

In QEMU, other Cortex A9 (Versatilepb.c, Exynos, Zynq ...) are also setting has_el3 to false ...

So these generally are the "legacy" platforms which were added before we ever had EL3 support in QEMU. For them it's hard to turn the EL3 support on for the board even if in theory it ought to be on, because we don't know what users are running on it that we might break. With a new to QEMU board we have an opportunity to get it right from the start.

Quoted 2 lines

OK, so is the "highbank" the only Qemu Cortex A9 board supporting el3 yet?

Yep. We don't have many A9 boards and most of those we do have are in the 'legacy' bucket.

Quoted 8 lines

-kernel I would expect to work, though, at least if the only issue is the interrupt controller setup. It seems worth investigating why it goes wrong.

Well, I can boot uniprocessor (-smp 1) without trouble but if I turn logs on (guest_errors,unimp) I am getting a lot of

Quoted 7 lines
Quoted 5 lines

gic_dist_writeb: Bad offset 38x (a few at startup) Ignoring attempt to switch CPSR_A flag from non-secure world with SCR.AW bit clear (a lot)
Ignoring attempt to switch CPSR_F flag from non-secure world with SCR.FW bit clear (a few)

This would only be a problem if your kernel needed to use FIQ, I think.

It is a standard linux (4.5-rc1) so it should not use FIQ I guess.

Now why is the linux code trying to do things it is not allowed to do in its security level ?

Or would Linux expect the secure world to set these bits before running it?

Quoted 7 lines
Quoted 6 lines

I am not sure if this is a problem. Do you have some opinion on this?

When I turn SMP (-smp 2 or more), I am unable to complete the boot. As soon as my secondary cpu is started QEMU will continue to boot "very slowly" but doesn't get to the linux user prompt overnight.

Does SMP work with EL3 not enabled, or is this a different bug?

If I set has_el3 to false, I can boot the 4 cores without problem. With has_el3 set to true (default value) I am getting the above behavior (boot OK in uniprocessor mode, and misbehaving if -smp >= 2).

JC

Quoted 4 lines

thanks
-- PMM

#27 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 7 lines · Jean-Christophe DUBOIS
Quoted 1 line · Peter Maydell

Does SMP work with EL3 not enabled, or is this a different bug?

If I set has_el3 to false, I can boot the 4 cores without problem. With has_el3 set to true (default value) I am getting the above behavior (boot OK in uniprocessor mode, and misbehaving if -smp >= 2).

Odd. If you can point me to a test image I can use to investigate (preferably with System.map and commit hash of kernel used to build it) I'll see if I can find time to have a look at what's going on there.

-- PMM

#28 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 11 lines · Peter Maydell
Quoted 6 lines · Jean-Christophe DUBOIS
Quoted 1 line · Peter Maydell

Does SMP work with EL3 not enabled, or is this a different bug?

If I set has_el3 to false, I can boot the 4 cores without problem. With has_el3 set to true (default value) I am getting the above behavior (boot OK in uniprocessor mode, and misbehaving if -smp >= 2).

Odd. If you can point me to a test image I can use to investigate (preferably with System.map and commit hash of kernel used to build it) I'll see if I can find time to have a look at what's going on there.

I put my test image at the following address:

http://dl.free.fr/rADch1Xnx

You will get a tgz file with the following files in it:

* imx6q-sabrelite.dtb
* README
* rootfs.cpio.gz
* System.map
* zImage

Instruction to run the image are in the README file.

The kernel is compiled using the imx_v6_v7_defconfig file (without modification) in the linux source tree

Thanks

JC

Quoted 3 lines

-- PMM

#29 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Just to compare I tried to run Linux on QEMU emulating highbank.

For now I am unable to start in SMP mode. Only one core is activated.

And there is linux backtrace in L2C-310 init.

My command line:

# qemu-system-arm -smp 4 -M highbank -m 1024M -display none -no-reboot -kernel zImage -initrd rootfs.cpio.gz -dtb highbank.dtb -serial stdio

The kernel output:

   [    0.000000] Booting Linux on physical CPU 0x0
   [    0.000000] Linux version 4.5.0-rc1-00028-g03c21cb-dirty
   (jcd@jcd-U31SG) (gcc version 4.6.3 (GCC) ) #20 SMP Sat Feb 20
   11:27:10 CET 2016
   [    0.000000] CPU: ARMv7 Processor [410fc090] revision 0 (ARMv7),
   cr=10c5387d
   [    0.000000] CPU: PIPT / VIPT nonaliasing data cache, VIPT
   nonaliasing instruction cache
   [    0.000000] Machine model: Calxeda Highbank
   [    0.000000] cma: Reserved 64 MiB at 0x3c000000
   [    0.000000] Memory policy: Data cache writealloc
   [    0.000000] DT missing boot CPU MPIDR[23:0], fall back to default
   cpu_logical_map
   [    0.000000] psci: probing for conduit method from DT.
   [    0.000000] psci: Using PSCI v0.1 Function IDs from DT
   [    0.000000] PERCPU: Embedded 12 pages/cpu @ef7e3000 s18880 r8192
   d22080 u49152
   [    0.000000] Built 1 zonelists in Zone order, mobility grouping
   on.  Total pages: 260608
   [    0.000000] Kernel command line: console=ttyAMA0
   [    0.000000] PID hash table entries: 4096 (order: 2, 16384 bytes)
   [    0.000000] Dentry cache hash table entries: 131072 (order: 7,
   524288 bytes)
   [    0.000000] Inode-cache hash table entries: 65536 (order: 6,
   262144 bytes)
   [    0.000000] Memory: 958304K/1048576K available (8557K kernel
   code, 1112K rwdata, 4036K rodata, 1104K init, 345K bss, 24736K
   reserved, 65536K cma-reserved, 196608K highmem)
   [    0.000000] Virtual kernel memory layout:
   [    0.000000]     vector  : 0xffff0000 - 0xffff1000   (   4 kB)
   [    0.000000]     fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
   [    0.000000]     vmalloc : 0xf0800000 - 0xff800000   ( 240 MB)
   [    0.000000]     lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)
   [    0.000000]     pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
   [    0.000000]     modules : 0xbf000000 - 0xbfe00000   (  14 MB)
   [    0.000000]       .text : 0xc0208000 - 0xc0e554cc   (12598 kB)
   [    0.000000]       .init : 0xc0e56000 - 0xc0f6a000   (1104 kB)
   [    0.000000]       .data : 0xc0f6a000 - 0xc10803c0   (1113 kB)
   [    0.000000]        .bss : 0xc1083000 - 0xc10d9598   ( 346 kB)
   [    0.000000] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=1,
   Nodes=1
   [    0.000000] Hierarchical RCU implementation.
   [    0.000000]     Build-time adjustment of leaf fanout to 32.
   [    0.000000]     RCU restricting CPUs from NR_CPUS=16 to nr_cpu_ids=1.
   [    0.000000] RCU: Adjusting geometry for rcu_fanout_leaf=32,
   nr_cpu_ids=1
   [    0.000000] NR_IRQS:16 nr_irqs:16 16
   [    0.000000] L2C-310 erratum 769419 enabled
   [    0.000000] L2C-310 enabling early BRESP for Cortex-A9
   [    0.000000] ------------[ cut here ]------------
   [    0.000000] WARNING: CPU: 0 PID: 0 at
   arch/arm/mach-highbank/highbank.c:60
   highbank_l2c310_write_sec+0x34/0x58()
   [    0.000000] Highbank L2C310: ignoring write to reg 0x104
   [    0.000000] Modules linked in:
   [    0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted
   4.5.0-rc1-00028-g03c21cb-dirty #20
   [    0.000000] Hardware name: Highbank
   [    0.000000] [<c02187b4>] (unwind_backtrace) from [<c0213e20>]
   (show_stack+0x10/0x14)
   [    0.000000] [<c0213e20>] (show_stack) from [<c048f9a4>]
   (dump_stack+0x70/0x8c)
   [    0.000000] [<c048f9a4>] (dump_stack) from [<c024ab30>]
   (warn_slowpath_common+0x74/0xac)
   [    0.000000] [<c024ab30>] (warn_slowpath_common) from [<c024abfc>]
   (warn_slowpath_fmt+0x30/0x40)
   [    0.000000] [<c024abfc>] (warn_slowpath_fmt) from [<c02292fc>]
   (highbank_l2c310_write_sec+0x34/0x58)
   [    0.000000] [<c02292fc>] (highbank_l2c310_write_sec) from
   [<c0223e44>] (l2c_configure+0x34/0x48)
   [    0.000000] [<c0223e44>] (l2c_configure) from [<c0224128>]
   (l2c310_configure+0xc/0x16c)
   [    0.000000] [<c0224128>] (l2c310_configure) from [<c0223f40>]
   (l2c_enable+0xe8/0xf8)
   [    0.000000] [<c0223f40>] (l2c_enable) from [<c0e5eb90>]
   (l2c310_enable+0x140/0x21c)
   [    0.000000] [<c0e5eb90>] (l2c310_enable) from [<c0e5f474>]
   (__l2c_init.part.6+0x19c/0x234)
   [    0.000000] [<c0e5f474>] (__l2c_init.part.6) from [<c0e5f7b4>]
   (l2x0_of_init+0x208/0x254)
   [    0.000000] [<c0e5f7b4>] (l2x0_of_init) from [<c0e5947c>]
   (init_IRQ+0x5c/0x80)
   [    0.000000] [<c0e5947c>] (init_IRQ) from [<c0e56adc>]
   (start_kernel+0x244/0x3dc)
   [    0.000000] [<c0e56adc>] (start_kernel) from [<0020807c>] (0x20807c)
   [    0.000000] ---[ end trace cb88537fdc8fa200 ]---
   [    0.000000] L2C-310 dynamic clock gating disabled, standby mode
   disabled
   [    0.000000] L2C-310 cache controller enabled, 8 ways, 128 kB
   [    0.000000] L2C-310: CACHE_ID 0x410000c8, AUX_CTRL 0x02020000
   [    0.000000] clocksource: arm,sp804: mask: 0xffffffff max_cycles:
   0xffffffff, max_idle_ns: 12741736309 ns
   [    0.000184] sched_clock: 32 bits at 150MHz, resolution 6ns, wraps
   every 14316557820ns
   [    0.005851] Console: colour dummy device 80x30
   [    0.010978] Calibrating delay loop... 830.66 BogoMIPS (lpj=2076672)
   [    0.066316] pid_max: default: 32768 minimum: 301
   [    0.067955] Mount-cache hash table entries: 2048 (order: 1, 8192
   bytes)
   [    0.068026] Mountpoint-cache hash table entries: 2048 (order: 1,
   8192 bytes)
   [    0.080254] CPU: Testing write buffer coherency: ok
   [    0.091638] missing device node for CPU 0
   [    0.091966] CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
   [    0.092492] Setting up static identity map for 0x209000 - 0x209098
   [    0.105477] Brought up 1 CPUs
   [    0.105595] SMP: Total of 1 processors activated (830.66 BogoMIPS).
   [    0.105723] CPU: All CPU(s) started in SVC mode.
   [    0.161221] devtmpfs: initialized
   [    0.173367] VFP support v0.3: implementor 41 architecture 3 part
   30 variant 9 rev 0
   [    0.191622] clocksource: jiffies: mask: 0xffffffff max_cycles:
   0xffffffff, max_idle_ns: 9556302231375000 ns
   [    0.218111] pinctrl core: initialized pinctrl subsystem
   [    0.240982] NET: Registered protocol family 16
   [    0.264314] DMA: preallocated 256 KiB pool for atomic coherent
   allocations
   [    0.273167] cpuidle: using governor menu
   [    0.291816] of_amba_device_create(): amba_device_add() failed
   (-19) for /soc/ipc@fff20000
   [    0.296693] of_amba_device_create(): amba_device_add() failed
   (-19) for /soc/dma@fff3d000
   [    0.301322] No ATAGs?
   [    0.301473] hw-breakpoint: debug architecture 0x4 unsupported.
   [    0.311969] Serial: AMBA PL011 UART driver
   [    0.314789] fff36000.serial: ttyAMA0 at MMIO 0xfff36000 (irq =
   30, base_baud = 0) is a PL011 rev1
   [    0.361986] console [ttyAMA0] enabled
   [    0.424008] vgaarb: loaded
   [    0.429273] SCSI subsystem initialized
   [    0.432446] usbcore: registered new interface driver usbfs
   [    0.433301] usbcore: registered new interface driver hub
   [    0.434118] usbcore: registered new device driver usb
   [    0.438497] pps_core: LinuxPPS API ver. 1 registered
   [    0.438988] pps_core: Software ver. 5.3.6 - Copyright 2005-2007
   Rodolfo Giometti <[email protected]>
   [    0.439957] PTP clock support registered
   [    0.441054] EDAC MC: Ver: 3.0.0
   [    0.458770] clocksource: Switched to clocksource arm,sp804
   [    0.512003] NET: Registered protocol family 2
   [    0.519451] TCP established hash table entries: 8192 (order: 3,
   32768 bytes)
   [    0.520405] TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
   [    0.522070] TCP: Hash tables configured (established 8192 bind 8192)
   [    0.523533] UDP hash table entries: 512 (order: 2, 16384 bytes)
   [    0.524236] UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
   [    0.526354] NET: Registered protocol family 1
   [    0.531160] RPC: Registered named UNIX socket transport module.
   [    0.531952] RPC: Registered udp transport module.
   [    0.532391] RPC: Registered tcp transport module.
   [    0.532765] RPC: Registered tcp NFSv4.1 backchannel transport module.
   [    0.551747] Trying to unpack rootfs image as initramfs...
   [    0.772458] Freeing initrd memory: 428K (c8000000 - c806b000)
   [    0.774751] hw perfevents: enabled with armv7_cortex_a9 PMU
   driver, 1 counters available
   [    0.780779] futex hash table entries: 256 (order: 2, 16384 bytes)
   [    0.823585] squashfs: version 4.0 (2009/01/31) Phillip Lougher
   [    0.828308] NFS: Registering the id_resolver key type
   [    0.829517] Key type id_resolver registered
   [    0.829774] Key type id_legacy registered
   [    0.830580] ntfs: driver 2.1.32 [Flags: R/O].
   [    0.840916] bounce: pool size: 64 pages
   [    0.843410] Block layer SCSI generic (bsg) driver version 0.4
   loaded (major 249)
   [    0.844144] io scheduler noop registered
   [    0.844440] io scheduler deadline registered
   [    0.844923] io scheduler cfq registered (default)
   [    1.147672] Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
   [    1.155398] SuperH (H)SCI(F) driver initialized
   [    1.158507] msm_serial: driver initialized
   [    1.159302] STMicroelectronics ASC driver initialized
   [    1.164268] [drm] Initialized drm 1.1.0 20060810
   [    1.232423] brd: module loaded
   [    1.272039] loop: module loaded
   [    1.281563] highbank-ahci ffe08000.sata: AHCI 0001.0000 32 slots
   1 ports 1.5 Gbps 0x1 impl platform mode
   [    1.282249] highbank-ahci ffe08000.sata: flags: ncq only
   [    1.290241] scsi host0: sata_highbank
   [    1.296846] ata1: SATA max UDMA/133 mmio [mem
   0xffe08000-0xffe17fff] port 0x100 irq 27
   [    1.317097] libphy: Fixed MDIO Bus: probed
   [    1.319831] CAN device driver interface
   [    1.322883] calxedaxgmac fff50000.ethernet (unnamed net_device)
   (uninitialized): h/w version is 0x1012
   [    1.327766] calxedaxgmac fff51000.ethernet (unnamed net_device)
   (uninitialized): h/w version is 0x1012
   [    1.333222] igb: Intel(R) Gigabit Ethernet Network Driver -
   version 5.3.0-k
   [    1.333607] igb: Copyright (c) 2007-2014 Intel Corporation.
   [    1.342007] pegasus: v0.9.3 (2013/04/25), Pegasus/Pegasus II USB
   Ethernet driver
   [    1.342613] usbcore: registered new interface driver pegasus
   [    1.343188] usbcore: registered new interface driver asix
   [    1.343679] usbcore: registered new interface driver ax88179_178a
   [    1.344164] usbcore: registered new interface driver cdc_ether
   [    1.344760] usbcore: registered new interface driver smsc75xx
   [    1.345337] usbcore: registered new interface driver smsc95xx
   [    1.346240] usbcore: registered new interface driver net1080
   [    1.346742] usbcore: registered new interface driver cdc_subset
   [    1.347219] usbcore: registered new interface driver zaurus
   [    1.347861] usbcore: registered new interface driver cdc_ncm
   [    1.352913] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI)
   Driver
   [    1.353397] ehci-pci: EHCI PCI platform driver
   [    1.354023] ehci-platform: EHCI generic platform driver
   [    1.354755] ehci-omap: OMAP-EHCI Host Controller driver
   [    1.355447] ehci-orion: EHCI orion driver
   [    1.356401] SPEAr-ehci: EHCI SPEAr driver
   [    1.357040] ehci-st: EHCI STMicroelectronics driver
   [    1.357691] ehci-exynos: EHCI EXYNOS driver
   [    1.358307] ehci-atmel: EHCI Atmel driver
   [    1.358907] tegra-ehci: Tegra EHCI driver
   [    1.359672] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
   [    1.360467] ohci-pci: OHCI PCI platform driver
   [    1.361146] ohci-platform: OHCI generic platform driver
   [    1.361889] ohci-omap3: OHCI OMAP3 driver
   [    1.362535] SPEAr-ohci: OHCI SPEAr driver
   [    1.363201] ohci-st: OHCI STMicroelectronics driver
   [    1.364030] ohci-atmel: OHCI Atmel driver
   [    1.366552] usbcore: registered new interface driver usb-storage
   [    1.376379] mousedev: PS/2 mouse device common for all mice
   [    1.389381] rtc-pl031 fff35000.rtc: rtc core: registered pl031 as
   rtc0
   [    1.396441] i2c /dev entries driver
   [    1.424256] hb_mc_edac fff00000.memory-controller: No ECC
   present, or ECC disabled
   [    1.429835] EDAC DEVICE0: Giving out device to module hb_l2_edac
   controller calxeda,hb-sregs-l2-ecc: DEV fff3c200.sregs (INTERRUPT)
   [    1.436472] sdhci: Secure Digital Host Controller Interface driver
   [    1.436868] sdhci: Copyright(c) Pierre Ossman
   [    1.442605] Synopsys Designware Multimedia Card Interface Driver
   [    1.446809] sdhci-pltfm: SDHCI platform and OF driver helper
   [    1.453659] ledtrig-cpu: registered to indicate activity on CPUs
   [    1.455151] usbcore: registered new interface driver usbhid
   [    1.455559] usbhid: USB HID core driver
   [    1.479532] NET: Registered protocol family 10
   [    1.489877] sit: IPv6 over IPv4 tunneling driver
   [    1.494441] NET: Registered protocol family 17
   [    1.494878] can: controller area network core (rev 20120528 abi 9)
   [    1.495609] NET: Registered protocol family 29
   [    1.495939] can: raw protocol (rev 20120528)
   [    1.496268] can: broadcast manager protocol (rev 20120528 t)
   [    1.496630] can: netlink gateway (rev 20130117) max_hops=1
   [    1.499025] Key type dns_resolver registered
   [    1.499704] ThumbEE CPU extension supported.
   [    1.500037] Registering SWP/SWPB emulation handler
   [    1.514185] rtc-pl031 fff35000.rtc: setting system clock to
   2016-02-20 10:36:54 UTC (1455964614)
   [    1.522492] uart-pl011 fff36000.serial: no DMA platform data
   [    1.769068] ata1: SATA link down (SStatus 0 SControl 300)
   [    1.801718] Freeing unused kernel memory: 1104K (c0e56000 - c0f6a000)
   Type exit when done.
   /bin/ash: can't access tty; job control turned off
   (:1) / #

And for sure there is only one CPU activated:

(:1) / # cat /proc/interrupts

               CPU0
     16:       1003     GIC-0  29 Edge      twd
     17:          0     GIC-0  50 Level     timer
     25:          0     GIC-0 103 Level     fff3c200.sregs
     26:          0     GIC-0 104 Level     fff3c200.sregs
     27:          0     GIC-0 115 Level highbank-ahci[ffe08000.sata]
     29:          0     GIC-0  51 Level     rtc-pl031
     30:         30     GIC-0  52 Level     uart-pl011
     33:          8     GIC-0 109 Level     fff50000.ethernet
     34:          0     GIC-0 110 Level     fff50000.ethernet
     36:          0     GIC-0 112 Level     fff51000.ethernet
     37:          0     GIC-0 113 Level     fff51000.ethernet
   IPI0:          0  CPU wakeup interrupts
   IPI1:          0  Timer broadcast interrupts
   IPI2:          0  Rescheduling interrupts
   IPI3:          0  Function call interrupts
   IPI4:          0  CPU stop interrupts
   IPI5:          0  IRQ work interrupts
   IPI6:          0  completion interrupts

Err: 0
(:1) / #

Am I missing something?

JC

Quoted 35 lines · Jean-Christophe DUBOIS
Quoted 10 lines · Peter Maydell
Quoted 5 lines · Jean-Christophe DUBOIS
Quoted 1 line · Peter Maydell

Does SMP work with EL3 not enabled, or is this a different bug?

If I set has_el3 to false, I can boot the 4 cores without problem. With has_el3 set to true (default value) I am getting the above behavior (boot OK in uniprocessor mode, and misbehaving if -smp >= 2).

Odd. If you can point me to a test image I can use to investigate (preferably with System.map and commit hash of kernel used to build it) I'll see if I can find time to have a look at what's going on there.

I put my test image at the following address:

http://dl.free.fr/rADch1Xnx

You will get a tgz file with the following files in it:

* imx6q-sabrelite.dtb
* README
* rootfs.cpio.gz
* System.map
* zImage

Instruction to run the image are in the README file.

The kernel is compiled using the imx_v6_v7_defconfig file (without modification) in the linux source tree

Thanks

JC

Quoted 2 lines

-- PMM

#30 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 4 lines · Jean-Christophe DUBOIS

Just to compare I tried to run Linux on QEMU emulating highbank.

For now I am unable to start in SMP mode. Only one core is activated.

This is probably due to the fact that the PSCI command encodings for Highbank expected by the kernel are mismatched to the ones in QEMU. I had some patches to change them, but once I got the PSCI right, the boot hung (might be just extreme slowdown like you describe) and I never got the time to fully debug it. SO there is a good chance Highbank has the same bug.

Regards,
Peter

#31 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 4 lines · Peter Crosthwaite
Quoted 2 lines · Jean-Christophe DUBOIS

Just to compare I tried to run Linux on QEMU emulating highbank.

Quoted 8 lines
Quoted 2 lines

For now I am unable to start in SMP mode. Only one core is activated.

This is probably due to the fact that the PSCI command encodings for Highbank expected by the kernel are mismatched to the ones in QEMU. I had some patches to change them, but once I got the PSCI right, the boot hung (might be just extreme slowdown like you describe) and I never got the time to fully debug it. SO there is a good chance Highbank has the same bug.

Thanks Peter,

So we are not sure we have a reference Cortex A9 platform working with has_el3 set to true.

This is annoying.

JC

Quoted 4 lines

Regards,
Peter

#32 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 17 lines · Jean-Christophe DUBOIS
Quoted 6 lines · Peter Crosthwaite
Quoted 3 lines · Jean-Christophe DUBOIS

Just to compare I tried to run Linux on QEMU emulating highbank.

Quoted 8 lines
Quoted 2 lines

For now I am unable to start in SMP mode. Only one core is activated.

This is probably due to the fact that the PSCI command encodings for Highbank expected by the kernel are mismatched to the ones in QEMU. I had some patches to change them, but once I got the PSCI right, the boot hung (might be just extreme slowdown like you describe) and I never got the time to fully debug it. SO there is a good chance Highbank has the same bug.

Quoted 5 lines

Thanks Peter,

So we are not sure we have a reference Cortex A9 platform working with has_el3 set to true.

Not for SMP linux.

Regards,
Peter

Quoted 9 lines

This is annoying.

JC

Quoted 4 lines

Regards,
Peter

#33 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 16 lines · Peter Crosthwaite
Quoted 14 lines · Jean-Christophe DUBOIS
Quoted 12 lines · Peter Crosthwaite
Quoted 4 lines · Jean-Christophe DUBOIS

Just to compare I tried to run Linux on QEMU emulating highbank.

For now I am unable to start in SMP mode. Only one core is activated.

This is probably due to the fact that the PSCI command encodings for Highbank expected by the kernel are mismatched to the ones in QEMU. I had some patches to change them, but once I got the PSCI right, the boot hung (might be just extreme slowdown like you describe) and I never got the time to fully debug it. SO there is a good chance Highbank has the same bug.

Quoted 6 lines
Quoted 5 lines

Thanks Peter,

So we are not sure we have a reference Cortex A9 platform working with has_el3 set to true.

Not for SMP linux.

And do we have other 32 bits Cortex (A5/A7/A15/...) that support has_el3 in SMP?

JC

Quoted 11 lines

Regards,
Peter

Quoted 7 lines

This is annoying.

JC

Quoted 3 lines

Regards,
Peter

#15 lore raw

Re: [Qemu-devel] [PATCH v2 6/9] i.MX: Add i.MX6 System Reset Controller device.

In reply to Peter Maydell

Hi Peter and Peter,

I need to test that the changes I did for PSCI (factor out on/off code) do not introduce any regression.

On which QEMU target should I test my changes to PSCI to check I didn't mess up anything?

Thanks

JC

Quoted 190 lines · Peter Maydell
Quoted 8 lines · Jean-Christophe Dubois

This controller is also present in i.MX5X devices but they are not yet emulated by QEMU.

hw/misc/imx6_src.c new file +3 -0
@@ -0,0 +1,353 @@
+/*
+ * IMX6 System Reset Controller
+ *

hw/misc/imx6_src.c line 13

Quoted 10 lines
hw/misc/imx6_src.c new file +10 -0
+ * Copyright (c) 2015 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.
+ *
+ */
+
+#include "hw/misc/imx6_src.h"
+#include "sysemu/sysemu.h"
+#include "qemu/bitops.h"

#include "qemu/osdep.h" as first #include line.

hw/misc/imx6_src.c line 90

Quoted 11 lines
hw/misc/imx6_src.c new file +11 -0
+static void imx6_src_reset(DeviceState *dev)
+{
+    IMX6SRCState *s = IMX6_SRC(dev);
+
+    DPRINTF("\n");
+
+    /*
+     * We only clear the first registers as all GPR registers are preserved
+     * over resets
+     */
+    memset(s->regs, 0, SRC_MAX * sizeof(uint32_t));

Comment doesn't seem to match code?

Quoted 95 lines
hw/misc/imx6_src.c new file +94 -0
+    /* Set reset values */
+    s->regs[SRC_SCR] = 0x521;
+    s->regs[SRC_SRSR] = 0x1;
+    s->regs[SRC_SIMR] = 0x1F;
+}
+
+static CPUState *imx6_src_get_cpu_by_id(uint32_t id)
+{
+    CPUState *cpu;
+
+    DPRINTF("cpu %d\n", id);
+
+    CPU_FOREACH(cpu) {
+        ARMCPU *armcpu = ARM_CPU(cpu);
+
+        if (armcpu->mp_affinity == id) {
+            return cpu;
+        }
+    }
+
+    qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: Resquesting unknown CPU %d\n",
+                  TYPE_IMX6_SRC, __func__, id);
+
+    return NULL;
+}
+
+static void imx6_src_cpu_on(uint32_t cpuid, uint32_t entry, uint32_t context_id)
+{
+    CPUState *target_cpu_state;
+    ARMCPU *target_cpu;
+    CPUClass *target_cpu_class;
+
+    DPRINTF("cpu %d @ 0x%08x with R0 = 0x%08x\n", cpuid, entry, context_id);
+
+    /* change to the cpu we are powering up */
+    target_cpu_state = imx6_src_get_cpu_by_id(cpuid);
+    if (!target_cpu_state) {
+        return;
+    }
+    target_cpu = ARM_CPU(target_cpu_state);
+    if (!target_cpu->powered_off) {
+        qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: CPU %d is already running\n",
+                      TYPE_IMX6_SRC, __func__, cpuid);
+        return;
+    }
+    target_cpu_class = CPU_GET_CLASS(target_cpu);
+
+    /* Initialize the cpu we are turning on */
+    cpu_reset(target_cpu_state);
+    target_cpu->powered_off = false;
+    target_cpu_state->halted = 0;
+
+    target_cpu->env.regs[0] = context_id;
+    target_cpu->env.thumb = entry & 1;
+
+    target_cpu_class->set_pc(target_cpu_state, entry);
+}
+
+static void imx6_src_cpu_off(uint32_t cpuid)
+{
+    CPUState *target_cpu_state;
+    ARMCPU *target_cpu;
+
+    DPRINTF("cpu %d\n", cpuid);
+
+    /* change to the cpu we are powering up */
+    target_cpu_state = imx6_src_get_cpu_by_id(cpuid);
+    if (!target_cpu_state) {
+        return;
+    }
+    target_cpu = ARM_CPU(target_cpu_state);
+    if (target_cpu->powered_off) {
+        qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: CPU %d is already off\n",
+                      TYPE_IMX6_SRC, __func__, cpuid);
+        return;
+    }
+
+    target_cpu->powered_off = true;
+    target_cpu_state->halted = 1;
+    target_cpu_state->exception_index = EXCP_HLT;
+    cpu_loop_exit(target_cpu_state);
+}
 
+static void imx6_src_cpu_reset(uint32_t cpuid)
+{
+    CPUState *target_cpu_state;
+    ARMCPU *target_cpu;
+
+    DPRINTF("cpu %d\n", cpuid);
+
+    /* change to the cpu we are powering up */
+    target_cpu_state = imx6_src_get_cpu_by_id(cpuid);
+    if (!target_cpu_state) {
+        return;
+    }

hw/misc/imx6_src.c line 196

Quoted 10 lines
hw/misc/imx6_src.c new file +10 -0
+    target_cpu = ARM_CPU(target_cpu_state);
+    if (target_cpu->powered_off) {
+        qemu_log_mask(LOG_GUEST_ERROR, "[%s]%s: CPU %d is off\n",
+                      TYPE_IMX6_SRC, __func__, cpuid);
+        return;
+    }
+
+    /* Reset the cpu we are turning on */
+    cpu_reset(target_cpu_state);
+}

The code that is messing about with target CPUs to power them up and down needs to be abstracted out into a public API in target-arm/, so it can be used both by your device and by target-arm/psci.c. I don't want variations on this code to duplicate into various devices, because chances are good it will need to change for multithreaded TCG.

Quoted 29 lines
(quoted diff) +29 -0
+static void imx6_src_realize(DeviceState *dev, Error **errp)
+{
+    IMX6SRCState *s = IMX6_SRC(dev);
+
+    memory_region_init_io(&s->iomem, OBJECT(dev), &imx6_src_ops, s,
+                          TYPE_IMX6_SRC, 0x1000);
+    sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
+}
+
+static void imx6_src_class_init(ObjectClass *klass, void *data)
+{
+    DeviceClass *dc = DEVICE_CLASS(klass);
+
+    dc->realize = imx6_src_realize;
+    dc->reset = imx6_src_reset;
+    dc->vmsd = &vmstate_imx6_src;
+    dc->desc = "i.MX6 System Reset Controller";
+}
+/* SRC_SCR */
+#define CORE3_ENABLE_SHIFT     (24)
+#define CORE3_ENABLE_LENGTH    (1)
+#define CORE2_ENABLE_SHIFT     (23)
+#define CORE2_ENABLE_LENGTH    (1)
+#define CORE1_ENABLE_SHIFT     (22)
+#define CORE1_ENABLE_LENGTH    (1)
+#define CORE3_RST_SHIFT        (16)
+#define CORE3_RST_LENGTH       (1)
+#define CORE2_RST_SHIFT        (15)
+#define CORE2_RST_LENGTH       (1)

Review

Quoted 10 lines
(quoted diff) +10 -0
+#define CORE1_RST_SHIFT        (14)
+#define CORE1_RST_LENGTH       (1)
+#define CORE0_RST_SHIFT        (13)
+#define CORE0_RST_LENGTH       (1)
+#define SW_IPU1_RST_SHIFT      (3)
+#define SW_IPU1_RST_LENGTH     (1)
+#define SW_IPU2_RST_SHIFT      (12)
+#define SW_IPU2_RST_LENGTH     (1)
+#define WARM_RST_ENABLE_SHIFT  (0)
+#define WARM_RST_ENABLE_LENGTH (1)

The brackets here are unnecessary.

thanks
-- PMM

#16 lore raw

Re: [Qemu-devel] [PATCH v2 6/9] i.MX: Add i.MX6 System Reset Controller device.

Quoted 7 lines · Jean-Christophe DUBOIS

Hi Peter and Peter,

I need to test that the changes I did for PSCI (factor out on/off code) do not introduce any regression.

On which QEMU target should I test my changes to PSCI to check I didn't mess up anything?

The 'virt' board uses PSCI.

thanks
-- PMM

#17 lore raw

Re: [Qemu-devel] [PATCH v2 6/9] i.MX: Add i.MX6 System Reset Controller device.

Quoted 10 lines · Peter Maydell
Quoted 7 lines · Jean-Christophe DUBOIS

Hi Peter and Peter,

I need to test that the changes I did for PSCI (factor out on/off code) do not introduce any regression.

On which QEMU target should I test my changes to PSCI to check I didn't mess up anything?

The 'virt' board uses PSCI.

Is there some quick howto somewhere on the 'virt' plateform (which linux defconfig to use, which DT tree to use, which command line t use, ...) ?

Thanks

JC

Quoted 4 lines

thanks
-- PMM

#44 lore raw
In reply to Jean-Christophe Dubois

Peter,

Are you OK if I merge the 2 series (i.MX6 and SPI for i.MX6) into a single series?

Thanks.

JC

Quoted 71 lines · Jean-Christophe Dubois

This patch series adds support for the Freescale i.MX6 processor.

For now we only support the following devices:
* up to 4 Cortex A9 cores
* A9 MPCORE (SCU, GIC, TWD)
* 5 i.MX UARTs
* 2 EPIT timers
* 1 GPT timer
* 7 GPIO controllers
* 6 SDHC controllers
* 1 CCM device
* 1 SRC device
* 3 I2C devices
* various ROM/RAM areas.

This also adds the sabrelite board as a an actual platform for i.MX6.

This series was tested by booting a 4.4 linux kernel (using the imx_v6_v7_defconfig file as kernel configuration).

Note1: as sabrelite uses uart2 as console, you have to redirect the second QEMU serial port to stdout.
qemu-system-arm -M sabrelite -display none ... -serial null -serial stdio

Note2: as the SPI controller is not yet supported in QEMU for i.MX you need to disable SPI controllers in Linux DTS tree. Otherwise Linux would hang during the boot waiting for a SPI device to respond.

Note3: You need to disable the GPIO section related to physical push buttons in the Linux DTS tree in order to avoid excecive interrupt triggering on GPIO devices for non existant buttons.

Jean-Christophe Dubois (9):
i.MX: Allow GPT timer to rollover.
i.MX: Rename CCM NOCLK to CLK_NONE for naming consistency. i.MX: Remove CCM useless clock computation handling. i.MX: Add the CLK_IPG_HIGH clock
i.MX: Add i.MX6 CCM and ANALOG device.
i.MX: Add i.MX6 System Reset Controller device. i.MX: Add i.MX6 SOC implementation.
i.MX: Add sabrelite i.MX6 emulation.
i.MX: Add missing descriptions in devices.

  default-configs/arm-softmmu.mak |   1 +
  hw/arm/Makefile.objs            |   1 +
  hw/arm/fsl-imx25.c              |   1 +
  hw/arm/fsl-imx31.c              |   1 +
  hw/arm/fsl-imx6.c               | 407 +++++++++++++++++++++
  hw/arm/sabrelite.c              |  93 +++++
  hw/i2c/imx_i2c.c                |   1 +
  hw/misc/Makefile.objs           |   2 +
  hw/misc/imx25_ccm.c             |  29 +-
  hw/misc/imx31_ccm.c             |  35 +-
  hw/misc/imx6_ccm.c              | 773 ++++++++++++++++++++++++++++++++++++++++
  hw/misc/imx6_src.c              | 353 ++++++++++++++++++
  hw/net/imx_fec.c                |   1 +
  hw/timer/imx_epit.c             |   8 +-
  hw/timer/imx_gpt.c              |  43 +--
  include/hw/arm/fsl-imx6.h       | 447 +++++++++++++++++++++++
  include/hw/misc/imx6_ccm.h      | 197 ++++++++++
  include/hw/misc/imx6_src.h      |  73 ++++
  include/hw/misc/imx_ccm.h       |  10 +-
  19 files changed, 2384 insertions(+), 92 deletions(-)

create mode 100644 hw/arm/fsl-imx6.c
create mode 100644 hw/arm/sabrelite.c
create mode 100644 hw/misc/imx6_ccm.c
create mode 100644 hw/misc/imx6_src.c
create mode 100644 include/hw/arm/fsl-imx6.h
create mode 100644 include/hw/misc/imx6_ccm.h
create mode 100644 include/hw/misc/imx6_src.h

#11 lore raw

Re: [Qemu-devel] [PATCH v2 5/9] i.MX: Add i.MX6 CCM and ANALOG device.

In reply to Jean-Christophe Dubois

hw/misc/imx6_ccm.c line 470

Quoted 6 lines · Jean-Christophe Dubois

---

hw/misc/imx6_ccm.c new file +3 -0
+static uint64_t imx6_ccm_read(void *opaque, hwaddr offset, unsigned size)
+{
+    uint32 value = 0;

This should be 'uint32_t', not 'uint32'.

(You'll find this doesn't compile on current master if you rebase it; uint32 was a type intended only for use with the softfloat code, and we've just eliminated it.)

Similar issues in imx6_src_read() and imx_spi_read().

You also need to make sure all your new .c files have #include "qemu/osdep.h" as the first include they do, or they won't build on current master.

thanks
-- PMM

#34 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

In reply to Jean-Christophe DUBOIS
Quoted 3 lines · Jean-Christophe DUBOIS

If I set has_el3 to false, I can boot the 4 cores without problem. With has_el3 set to true (default value) I am getting the above behavior (boot OK in uniprocessor mode, and misbehaving if -smp >= 2).

I worked out why this happens -- it's because the secondary CPUs and the primary disagree about whether they're booting in Secure mode. You can either:
(1) have the board code say "boot the primary in Secure mode":

hw/arm/sabrelite.c +1 -0
@@ -85,6 +85,7 @@ static void sabrelite_init(MachineState *machine)
     sabrelite_binfo.kernel_cmdline = machine->kernel_cmdline;
     sabrelite_binfo.initrd_filename = machine->initrd_filename;
     sabrelite_binfo.nb_cpus = smp_cpus;
+    sabrelite_binfo.secure_boot = true;
     sabrelite_binfo.write_secondary_boot = sabrelite_write_secondary;
     sabrelite_binfo.secondary_cpu_reset_hook = sabrelite_reset_secondary;
 

or (2) have the code in imx6_src.c tell the secondaries that they should start in non-secure mode:

hw/misc/imx6_src.c +0 -0
@@ -144,6 +144,7 @@ static void imx6_src_cpu_on(uint32_t cpuid,

uint32_t entry, uint32_t context_id)

     target_cpu->env.regs[0] = context_id;
     target_cpu->env.thumb = entry & 1;

+ target_cpu->env.cp15.scr_el3 |= SCR_NS;

     target_cpu_class->set_pc(target_cpu_state, entry);

}

If you do either of these then the system will boot the kernel that you sent the link to.

To answer the question of "which of these is the correct thing to do" we need to look at what the real hardware does when it's running Linux:
does it run Linux in Secure or Nonsecure?

thanks
-- PMM

#12 lore raw

Re: [Qemu-devel] [PATCH v2 5/9] i.MX: Add i.MX6 CCM and ANALOG device.

In reply to Peter Maydell
Quoted 8 lines · Peter Maydell

hw/misc/imx6_ccm.c line 470

Quoted 5 lines · Jean-Christophe Dubois

---

hw/misc/imx6_ccm.c new file +3 -0
+static uint64_t imx6_ccm_read(void *opaque, hwaddr offset, unsigned size)
+{
+    uint32 value = 0;

This should be 'uint32_t', not 'uint32'.

Quoted 8 lines

(You'll find this doesn't compile on current master if you rebase it; uint32 was a type intended only for use with the softfloat code, and we've just eliminated it.)

Similar issues in imx6_src_read() and imx_spi_read().

You also need to make sure all your new .c files have #include "qemu/osdep.h" as the first include they do, or they won't build on current master.

OK, I'll do.

Quoted 4 lines

thanks
-- PMM

#35 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

In reply to Peter Maydell
Quoted 34 lines · Peter Maydell
Quoted 3 lines · Jean-Christophe DUBOIS

If I set has_el3 to false, I can boot the 4 cores without problem. With has_el3 set to true (default value) I am getting the above behavior (boot OK in uniprocessor mode, and misbehaving if -smp >= 2).

I worked out why this happens -- it's because the secondary CPUs and the primary disagree about whether they're booting in Secure mode. You can either:
(1) have the board code say "boot the primary in Secure mode":

hw/arm/sabrelite.c +1 -0
@@ -85,6 +85,7 @@ static void sabrelite_init(MachineState *machine)
      sabrelite_binfo.kernel_cmdline = machine->kernel_cmdline;
      sabrelite_binfo.initrd_filename = machine->initrd_filename;
      sabrelite_binfo.nb_cpus = smp_cpus;
+    sabrelite_binfo.secure_boot = true;
      sabrelite_binfo.write_secondary_boot = sabrelite_write_secondary;
      sabrelite_binfo.secondary_cpu_reset_hook = sabrelite_reset_secondary;
 

or (2) have the code in imx6_src.c tell the secondaries that they should start in non-secure mode:

hw/misc/imx6_src.c +1 -0
@@ -144,6 +144,7 @@ static void imx6_src_cpu_on(uint32_t cpuid,
 uint32_t entry, uint32_t context_id)
 
      target_cpu->env.regs[0] = context_id;
      target_cpu->env.thumb = entry & 1;
+    target_cpu->env.cp15.scr_el3 |= SCR_NS;
 
      target_cpu_class->set_pc(target_cpu_state, entry);
  }
Quoted 2 lines

If you do either of these then the system will boot the kernel that you sent the link to.

Thanks Peter, It does work.

Quoted 4 lines

To answer the question of "which of these is the correct thing to do" we need to look at what the real hardware does when it's running Linux:
does it run Linux in Secure or Nonsecure?

i.MX6 is definitively able to boot in secure/trustzone mode (there are some demo out there about it) so I guess it might be booting in secure mode.

Quoted 4 lines

thanks
-- PMM

#36 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 8 lines · Jean-Christophe DUBOIS
Quoted 3 lines · Peter Maydell

To answer the question of "which of these is the correct thing to do" we need to look at what the real hardware does when it's running Linux:
does it run Linux in Secure or Nonsecure?

i.MX6 is definitively able to boot in secure/trustzone mode (there are some demo out there about it) so I guess it might be booting in secure mode.

Mmm. The other question I had about the system reset controller is whether it's really purely hardware doing the "start secondary CPU", or is it just a funny way of asking the system firmware to start things, or is the stuff like the register for startup address just a place to leave information that the system firmware on the secondary CPU will read as part of its boot sequence?

Is there a datasheet available for this?

thanks
-- PMM

#37 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 10 lines · Peter Maydell
Quoted 7 lines · Jean-Christophe DUBOIS
Quoted 3 lines · Peter Maydell

To answer the question of "which of these is the correct thing to do" we need to look at what the real hardware does when it's running Linux:
does it run Linux in Secure or Nonsecure?

i.MX6 is definitively able to boot in secure/trustzone mode (there are some demo out there about it) so I guess it might be booting in secure mode.

Quoted 8 lines

Mmm. The other question I had about the system reset controller is whether it's really purely hardware doing the "start secondary CPU", or is it just a funny way of asking the system firmware to start things, or is the stuff like the register for startup address just a place to leave information that the system firmware on the secondary CPU will read as part of its boot sequence?

Is there a datasheet available for this?

Well the SRC device is described in the i.MX6 reference manual.

http://cache.nxp.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf?fpsp=1&WT_TYPE=Reference%20Manuals&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation&fileExt=.pdf

I believe it is hardware based. Now it might involve some of the functions of the internal ROM in the process but we cannot change this behavior in any way.

Quoted 4 lines

thanks
-- PMM

#38 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 6 lines · Jean-Christophe DUBOIS
Quoted 1 line · Peter Maydell

Is there a datasheet available for this?

Well the SRC device is described in the i.MX6 reference manual.

http://cache.nxp.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf?fpsp=1&WT_TYPE=Reference%20Manuals&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation&fileExt=.pdf

Thanks for the link.

Quoted 3 lines

I believe it is hardware based. Now it might involve some of the functions of the internal ROM in the process but we cannot change this behavior in any way.

The datasheet is pretty clear -- registers like the SRC_GPR<n> are just "holds some state" registers, and when the system reset controller starts a secondary CPU it runs through some boot ROM code which reads the GPR controlling the start address and branches to it.

This means the code you have in the SRC emulation is actually implementing a combination of the SRC hardware and the boot ROM software. That's OK, but we should have a comment somewhere that makes it clear that that's what's going on.

(it is possible to implement the "jump to address as per register" as code that runs in the guest; highbank has a variant on this. It doesn't really seem necessary here though.)

On the "secure vs nonsecure" question, I'm not completely sure but I think that the answer is that it will boot in secure. So we should use the patche that adds "sabrelite_binfo.secure_boot = true;" to the board code.

thanks
-- PMM

#39 lore raw

Re: [Qemu-devel] [PATCH v2 7/9] i.MX: Add i.MX6 SOC implementation.

Quoted 17 lines · Peter Maydell
Quoted 5 lines · Jean-Christophe DUBOIS
Quoted 1 line · Peter Maydell

Is there a datasheet available for this?

Well the SRC device is described in the i.MX6 reference manual.

http://cache.nxp.com/files/32bit/doc/ref_manual/IMX6DQRM.pdf?fpsp=1&WT_TYPE=Reference%20Manuals&WT_VENDOR=FREESCALE&WT_FILE_FORMAT=pdf&WT_ASSET=Documentation&fileExt=.pdf

Thanks for the link.

Quoted 3 lines

I believe it is hardware based. Now it might involve some of the functions of the internal ROM in the process but we cannot change this behavior in any way.

The datasheet is pretty clear -- registers like the SRC_GPR<n> are just "holds some state" registers, and when the system reset controller starts a secondary CPU it runs through some boot ROM code which reads the GPR controlling the start address and branches to it.

Quoted 4 lines

This means the code you have in the SRC emulation is actually implementing a combination of the SRC hardware and the boot ROM software. That's OK, but we should have a comment somewhere that makes it clear that that's what's going on.

OK, I'll add the comment.

JC

Quoted 13 lines

(it is possible to implement the "jump to address as per register" as code that runs in the guest; highbank has a variant on this. It doesn't really seem necessary here though.)

On the "secure vs nonsecure" question, I'm not completely sure but I think that the answer is that it will boot in secure. So we should use the patche that adds "sabrelite_binfo.secure_boot = true;" to the board code.

thanks
-- PMM

#45 lore raw
In reply to Jean-Christophe DUBOIS

Peter,

Can I merge the 2 i.MX series as one depend on the other.

Thanks

JC

Quoted 85 lines · Jean-Christophe DUBOIS

Peter,

Are you OK if I merge the 2 series (i.MX6 and SPI for i.MX6) into a single series?

Thanks.

JC

Quoted 73 lines · Jean-Christophe Dubois

This patch series adds support for the Freescale i.MX6 processor.

For now we only support the following devices:
* up to 4 Cortex A9 cores
* A9 MPCORE (SCU, GIC, TWD)
* 5 i.MX UARTs
* 2 EPIT timers
* 1 GPT timer
* 7 GPIO controllers
* 6 SDHC controllers
* 1 CCM device
* 1 SRC device
* 3 I2C devices
* various ROM/RAM areas.

This also adds the sabrelite board as a an actual platform for i.MX6.

This series was tested by booting a 4.4 linux kernel (using the imx_v6_v7_defconfig file as kernel configuration).

Note1: as sabrelite uses uart2 as console, you have to redirect the second QEMU serial port to stdout.
qemu-system-arm -M sabrelite -display none ... -serial null
-serial stdio

Note2: as the SPI controller is not yet supported in QEMU for i.MX you need to disable SPI controllers in Linux DTS tree. Otherwise Linux would hang during the boot waiting for a SPI device to respond.

Note3: You need to disable the GPIO section related to physical push buttons in the Linux DTS tree in order to avoid excecive interrupt triggering on GPIO devices for non existant buttons.

Jean-Christophe Dubois (9):
i.MX: Allow GPT timer to rollover.
i.MX: Rename CCM NOCLK to CLK_NONE for naming consistency. i.MX: Remove CCM useless clock computation handling. i.MX: Add the CLK_IPG_HIGH clock
i.MX: Add i.MX6 CCM and ANALOG device.
i.MX: Add i.MX6 System Reset Controller device. i.MX: Add i.MX6 SOC implementation.
i.MX: Add sabrelite i.MX6 emulation.
i.MX: Add missing descriptions in devices.

  default-configs/arm-softmmu.mak |   1 +
  hw/arm/Makefile.objs            |   1 +
  hw/arm/fsl-imx25.c              |   1 +
  hw/arm/fsl-imx31.c              |   1 +
  hw/arm/fsl-imx6.c               | 407 +++++++++++++++++++++
  hw/arm/sabrelite.c              |  93 +++++
  hw/i2c/imx_i2c.c                |   1 +
  hw/misc/Makefile.objs           |   2 +
  hw/misc/imx25_ccm.c             |  29 +-
  hw/misc/imx31_ccm.c             |  35 +-
  hw/misc/imx6_ccm.c              | 773 
++++++++++++++++++++++++++++++++++++++++
  hw/misc/imx6_src.c              | 353 ++++++++++++++++++
  hw/net/imx_fec.c                |   1 +
  hw/timer/imx_epit.c             |   8 +-
  hw/timer/imx_gpt.c              |  43 +--
  include/hw/arm/fsl-imx6.h       | 447 +++++++++++++++++++++++
  include/hw/misc/imx6_ccm.h      | 197 ++++++++++
  include/hw/misc/imx6_src.h      |  73 ++++
  include/hw/misc/imx_ccm.h       |  10 +-
  19 files changed, 2384 insertions(+), 92 deletions(-)

create mode 100644 hw/arm/fsl-imx6.c
create mode 100644 hw/arm/sabrelite.c
create mode 100644 hw/misc/imx6_ccm.c
create mode 100644 hw/misc/imx6_src.c
create mode 100644 include/hw/arm/fsl-imx6.h
create mode 100644 include/hw/misc/imx6_ccm.h
create mode 100644 include/hw/misc/imx6_src.h

#46 lore raw
Quoted 3 lines · Jean-Christophe DUBOIS

Peter,

Can I merge the 2 i.MX series as one depend on the other.

Yes, go ahead.

thanks
-- PMM