Skip to contentSkip to conversation

hw/arm: add PCIe to Freescale i.MX6

PATCH Superseded Nikita Ostrenkov 2 participants 4 messages Jan 7, 2024 – Jan 8, 2024 Arm i.MX and Layerscape

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hw/arm: add PCIe to Freescale i.MX6

---
 hw/arm/Kconfig            |  3 +++
 hw/arm/fsl-imx6.c         | 25 ++++++++++++++++++++++
 include/hw/arm/fsl-imx6.h | 44 ++++++++++++++++++++-------------------
 3 files changed, 51 insertions(+), 21 deletions(-)
hw/arm/Kconfig +3 -0
index 660f49db49..575bb68c76 100644
@@ -530,13 +530,16 @@ config FSL_IMX31
 
 config FSL_IMX6
     bool
+    imply PCI_DEVICES
     imply I2C_DEVICES
     select A9MPCORE
+    select PCI
     select IMX
     select IMX_FEC
     select IMX_I2C
     select IMX_USBPHY
     select WDT_IMX2
+    select PCI_EXPRESS_DESIGNWARE
     select SDHCI
 
 config ASPEED_SOC
hw/arm/fsl-imx6.c +25 -0
index b2153022c0..27702b6d6d 100644
@@ -22,6 +22,7 @@
 #include "qemu/osdep.h"
 #include "qapi/error.h"
 #include "hw/arm/fsl-imx6.h"
+#include "hw/misc/unimp.h"
 #include "hw/usb/imx-usb-phy.h"
 #include "hw/boards.h"
 #include "hw/qdev-properties.h"
@@ -102,6 +103,8 @@ static void fsl_imx6_init(Object *obj)
 
 
     object_initialize_child(obj, "eth", &s->eth, TYPE_IMX_ENET);
+
+    object_initialize_child(obj, "pcie", &s->pcie, TYPE_DESIGNWARE_PCIE_HOST);
 }
 
 static void fsl_imx6_realize(DeviceState *dev, Error **errp)
@@ -109,6 +112,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
     MachineState *ms = MACHINE(qdev_get_machine());
     FslIMX6State *s = FSL_IMX6(dev);
     uint16_t i;
+    qemu_irq irq;
     unsigned int smp_cpus = ms->smp.cpus;
 
     if (smp_cpus > FSL_IMX6_NUM_CPUS) {
@@ -421,6 +425,27 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp)
                                             FSL_IMX6_WDOGn_IRQ[i]));
     }
 
+    /*
+     * PCIe
+     */
+    sysbus_realize(SYS_BUS_DEVICE(&s->pcie), &error_abort);
+    sysbus_mmio_map(SYS_BUS_DEVICE(&s->pcie), 0, FSL_IMX6_PCIe_REG_ADDR);
+
+    irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE1_IRQ);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 0, irq);
+    irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE2_IRQ);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 1, irq);
+    irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE3_IRQ);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 2, irq);
+    irq = qdev_get_gpio_in(DEVICE(&s->a9mpcore), FSL_IMX6_PCIE4_IRQ);
+    sysbus_connect_irq(SYS_BUS_DEVICE(&s->pcie), 3, irq);
+
+    /*
+     * PCIe PHY
+     */
+    create_unimplemented_device("pcie-phy", FSL_IMX6_PCIe_ADDR,
+                                FSL_IMX6_PCIe_SIZE);
+
     /* ROM memory */
     if (!memory_region_init_rom(&s->rom, OBJECT(dev), "imx6.rom",
                                 FSL_IMX6_ROM_SIZE, errp)) {
include/hw/arm/fsl-imx6.h +23 -21

56 lines not on this page · raw message

Signature · 1 line
2.34.1
#1 lore raw

Hi Nikita,

Quoted 12 lines · Nikita Ostrenkov
---
  hw/arm/Kconfig            |  3 +++
  hw/arm/fsl-imx6.c         | 25 ++++++++++++++++++++++
  include/hw/arm/fsl-imx6.h | 44 ++++++++++++++++++++-------------------
  3 files changed, 51 insertions(+), 21 deletions(-)
hw/arm/Kconfig +0 -0
index 660f49db49..575bb68c76 100644

hw/arm/Kconfig config FSL_IMX31 · line 533

Quoted 4 lines
hw/arm/Kconfig +1 -0
@@ -530,13 +530,16 @@ config FSL_IMX31
 
  config FSL_IMX6
      bool
+    imply PCI_DEVICES

This should be PCIE_DEVICES.

hw/arm/Kconfig config FSL_IMX31 · line 536

Quoted 3 lines
hw/arm/Kconfig +1 -0
      imply I2C_DEVICES
      select A9MPCORE
+    select PCI

Incorrect, should be PCI_EXPRESS, but this is already (indirectly) selected by PCI_EXPRESS_DESIGNWARE which you select below, so not needed.

Quoted 7 lines
hw/arm/Kconfig +1 -0
      select IMX
      select IMX_FEC
      select IMX_I2C
      select IMX_USBPHY
      select WDT_IMX2
+    select PCI_EXPRESS_DESIGNWARE
      select SDHCI
#2 lore raw

Hi! Thanks! I'll send a new version of this patch.

But what about fsl imx7? Should it also have PCIE_DEVICES?

пн, 8 янв. 2024 г. в 15:20, Philippe Mathieu-Daudé <[email protected]>:

Quoted 38 lines

Hi Nikita,

Quoted 12 lines · Nikita Ostrenkov
---
  hw/arm/Kconfig            |  3 +++
  hw/arm/fsl-imx6.c         | 25 ++++++++++++++++++++++
  include/hw/arm/fsl-imx6.h | 44 ++++++++++++++++++++-------------------
  3 files changed, 51 insertions(+), 21 deletions(-)
hw/arm/Kconfig +0 -0
index 660f49db49..575bb68c76 100644

hw/arm/Kconfig config FSL_IMX31 · line 533

Quoted 4 lines
hw/arm/Kconfig +1 -0
@@ -530,13 +530,16 @@ config FSL_IMX31
 
  config FSL_IMX6
      bool
+    imply PCI_DEVICES

This should be PCIE_DEVICES.

hw/arm/Kconfig config FSL_IMX31 · line 536

Quoted 3 lines
hw/arm/Kconfig +1 -0
      imply I2C_DEVICES
      select A9MPCORE
+    select PCI

Incorrect, should be PCI_EXPRESS, but this is already (indirectly) selected by PCI_EXPRESS_DESIGNWARE which you select below, so not needed.

Quoted 7 lines
hw/arm/Kconfig +1 -0
      select IMX
      select IMX_FEC
      select IMX_I2C
      select IMX_USBPHY
      select WDT_IMX2
+    select PCI_EXPRESS_DESIGNWARE
      select SDHCI
#3 lore raw

(+Thomas)

Quoted 3 lines · Nikita Ostrenkov

Hi! Thanks! I'll send a new version of this patch.

But what about fsl imx7? Should it also have PCIE_DEVICES?

Yeah I think so, we missed this in commit 02047622b7 ("hw/arm:
Express dependencies of the remaining IMX boards with Kconfig").

Quoted 43 lines

пн, 8 янв. 2024 г. в 15:20, Philippe Mathieu-Daudé <[email protected] <mailto:[email protected]>>:

Hi Nikita,

On 7/1/24 17:57, Nikita Ostrenkov wrote:
> Signed-off-by: Nikita Ostrenkov <[email protected]
<mailto:[email protected]>>
> ---
>   hw/arm/Kconfig            |  3 +++
>   hw/arm/fsl-imx6.c         | 25 ++++++++++++++++++++++ >   include/hw/arm/fsl-imx6.h | 44
++++++++++++++++++++-------------------
>   3 files changed, 51 insertions(+), 21 deletions(-) >
> diff --git a/hw/arm/Kconfig b/hw/arm/Kconfig > index 660f49db49..575bb68c76 100644
> --- a/hw/arm/Kconfig
> +++ b/hw/arm/Kconfig
> @@ -530,13 +530,16 @@ config FSL_IMX31
>
>   config FSL_IMX6
>       bool
> +    imply PCI_DEVICES

This should be PCIE_DEVICES.

>       imply I2C_DEVICES
>       select A9MPCORE
> +    select PCI

Incorrect, should be PCI_EXPRESS, but this is already (indirectly) selected by PCI_EXPRESS_DESIGNWARE which you select below, so not needed.

>       select IMX
>       select IMX_FEC
>       select IMX_I2C
>       select IMX_USBPHY
>       select WDT_IMX2
> +    select PCI_EXPRESS_DESIGNWARE
>       select SDHCI