Initial i.MX7 support
v6 cover Initial i.MX7 support
Hi everyone,
This v6 of the patch series containing the work that I've done in order to enable support for i.MX7 emulation in QEMU.
As the one before last commit in the series states the supported i.MX7 features are:
* up to 2 Cortex A9 cores (SMP works with PSCI)
* A7 MPCORE (identical to A15 MPCORE)
* 4 GPTs modules
* 7 GPIO controllers
* 2 IOMUXC controllers
* 1 CCM module
* 1 SVNS module
* 1 SRC module
* 1 GPCv2 controller
* 4 eCSPI controllers
* 4 I2C controllers
* 7 i.MX UART controllers
* 2 FlexCAN controllers
* 2 Ethernet controllers (FEC)
* 3 SD controllers (USDHC)
* 4 WDT modules
* 1 SDMA module
* 1 GPR module
* 2 USBMISC modules
* 2 ADC modules
* 1 PCIe controller
* 3 USB controllers
* 1 LCD controller
* 1 ARMv7 DAP IP block
Feedback is welcome!
Changes since [v5]:
- Rebase patchest on top of latest QEMU master, so now the patchset is down to three patches
- Reverted the change to use pci_data_* functions becuase the patch supporting this change was causing trouble
- Fixed endiannes of MSI and configuration space accessors to be LITTLE_ENDIAN
Changes since [v4]:
- Rebase patchest on top of latest QEMU master
- Reworked PCIE emulation code to create MemoryRegions only once
- Fixed incorrect usages of PCI instead of PCIE
- Fixed device class reported by PCIE bridge
- Added patch to make pci_data_read() and pci_data_write() usable for PCIE devices as well
- Converted PCIE code to use pci_data_read() and pci_data_write()
- Added VMStateDescription code for PCIE
- Collected Reviewed-by tag from Philippe
Changes since [v3]:
- Changes to FEC were split into a separate set and merged to master
- Patchest is rebased on latest master
- Converted to use PSCI DT fixup code that is shared with virt platform (now relocated to live in arm/boot.c)
- Large number of dummy block were converted to use create_unimplemented_device() as opposed to its own dedicated type
- Incorporated varios small feedback items
- Collected Reviewed-by tags from Peter
Changes since [v2]:
- Added stubs for more blocks that were causing memory transactions when booting Linux guest as were revealed by additional testing of the patchest
- Added proper USB emulation code, so now it should be possible to emulated guest's USB bus
Changes since [v1]:
- Patchset no longer relies on "ignore_memory_transaction_failures = false" for its functionality
- As a consequnce of implementing the above a number of patches implementing dummy IP block emulation as well as PCIe emulation patches that I alluded to in [v1] are now included in this patch series
- "has_el3" property is no longer being set to "false" as a part of intialization of A7 CPU. I couldn't reproduce the issues that I thought I was having, so I just dropped that code.
- A number of smaller feedback items from Peter and other has been incorporated into the patches.
Thanks,
Andrey Smirnov
[v5] https://lists.gnu.org/archive/html/qemu-devel/2018-02/msg01558.html
[v4] https://lists.gnu.org/archive/html/qemu-devel/2018-01/msg03264.html
[v3] https://lists.gnu.org/archive/html/qemu-devel/2017-11/msg04236.html
[v2] https://lists.gnu.org/archive/html/qemu-devel/2017-10/msg05516.html
[v1] https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg04770.html
Andrey Smirnov (3):
pci: Add support for Designware IP block
i.MX: Add i.MX7 SOC implementation.
Implement support for i.MX7 Sabre board
default-configs/arm-softmmu.mak | 3 + include/hw/arm/fsl-imx7.h | 222 ++++++++++++ include/hw/pci-host/designware.h | 102 ++++++ include/hw/pci/pci_ids.h | 2 + hw/arm/fsl-imx7.c | 580 ++++++++++++++++++++++++++++++ hw/arm/mcimx7d-sabre.c | 90 +++++ hw/pci-host/designware.c | 755 +++++++++++++++++++++++++++++++++++++++ hw/arm/Makefile.objs | 3 + hw/pci-host/Makefile.objs | 2 + 9 files changed, 1759 insertions(+) create mode 100644 include/hw/arm/fsl-imx7.h create mode 100644 include/hw/pci-host/designware.h create mode 100644 hw/arm/fsl-imx7.c create mode 100644 hw/arm/mcimx7d-sabre.c create mode 100644 hw/pci-host/designware.c
Signature · 1 line
2.14.3
PATCH v6 1/3 pci: Add support for Designware IP block
Add code needed to get a functional PCI subsytem when using in conjunction with upstream Linux guest (4.13+). Tested to work against "e1000e" (network adapter, using MSI interrupts) as well as "usb-ehci" (USB controller, using legacy PCI interrupts).
Based on "i.MX6 Applications Processor Reference Manual" (Document
Number: IMX6DQRM Rev. 4) as well as corresponding dirver in Linux kernel (circa 4.13 - 4.16 found in drivers/pci/dwc/*)
--- default-configs/arm-softmmu.mak | 2 + include/hw/pci-host/designware.h | 102 ++++++ include/hw/pci/pci_ids.h | 2 + hw/pci-host/designware.c | 755 +++++++++++++++++++++++++++++++++++++++ hw/pci-host/Makefile.objs | 2 + 5 files changed, 863 insertions(+) create mode 100644 include/hw/pci-host/designware.h create mode 100644 hw/pci-host/designware.c
default-configs/arm-softmmu.mak +2 -0
@@ -133,3 +133,5 @@ CONFIG_GPIO_KEY=y CONFIG_MSF2=y CONFIG_FW_CFG_DMA=y CONFIG_XILINX_AXI=y +CONFIG_PCI_DESIGNWARE=y +
include/hw/pci-host/designware.h new file +102 -0
102 lines not on this page · raw message
include/hw/pci/pci_ids.h +2 -0
@@ -266,4 +266,6 @@#define PCI_VENDOR_ID_TEWS 0x1498#define PCI_DEVICE_ID_TEWS_TPCI200 0x30C8 +#define PCI_VENDOR_ID_SYNOPSYS 0x16C3 +#endif
hw/pci-host/designware.c new file +755 -0
755 lines not on this page · raw message
hw/pci-host/Makefile.objs +2 -0
@@ -17,3 +17,5 @@ common-obj-$(CONFIG_PCI_PIIX) += piix.o common-obj-$(CONFIG_PCI_Q35) += q35.o common-obj-$(CONFIG_PCI_GENERIC) += gpex.o common-obj-$(CONFIG_PCI_XILINX) += xilinx-pcie.o + +common-obj-$(CONFIG_PCI_DESIGNWARE) += designware.o
Signature · 1 line
2.14.3
Re: [Qemu-devel] [PATCH v6 1/3] pci: Add support for Designware IP block
Quoted 57 lines · Andrey Smirnov
hw/pci-host/designware.c new file +57
-0+static void designware_pcie_root_class_init (ObjectClass *klass,void *data) +{ +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + + k->vendor_id =PCI_VENDOR_ID_SYNOPSYS ; + k->device_id =0xABCD ; + k->revision =0 ; + k->class_id =PCI_CLASS_BRIDGE_PCI ; + k->is_express = true; + k->is_bridge = true; + k->exit = pci_bridge_exitfn; + k->realize = designware_pcie_root_realize; + k->config_read = designware_pcie_root_config_read; + k->config_write = designware_pcie_root_config_write; + + dc->reset = pci_bridge_reset; +/* +* PCI-facing part of the host bridge, not usable without the +* host-facing part, which can't be device_add'ed, yet. +*/ + dc->user_creatable = false; + dc->vmsd = &vmstate_designware_pcie_root; +} + +static uint64_t designware_pcie_host_mmio_read (void *opaque,hwaddr addr, +unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_read_common (device, + addr, +pci_config_size (device), + size); +} + +static void designware_pcie_host_mmio_write (void *opaque,hwaddr addr, +uint64_t val,unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_write_common (device, + addr, +pci_config_size (device), + val, size); +} + +static const MemoryRegionOps designware_pci_mmio_ops = { + .read = designware_pcie_host_mmio_read, + .write = designware_pcie_host_mmio_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { +/*
hw/pci-host/designware.c line 637
Quoted 10 lines
hw/pci-host/designware.c new file +10
-0+* Our device would not work correctly if the guest was doing +* unaligned access. This might not be a limitation on the real +* device but in practice there is no reason for a guest to access +* this device unaligned. +*/ + .min_access_size = 4, + .max_access_size = 4, + .unaligned = false, + }, +};
Could you pls add some comments explaining why is DEVICE_NATIVE_ENDIAN appropriate here? Most of these cases are plain "we never bothered about cross-endian setups". Some are "there's a mix of different endian-ness values, need to handle in a special way".
I suspect you really need DEVICE_LITTLE_ENDIAN.
Signature · 1 line
MST
Re: [Qemu-arm] [PATCH v6 1/3] pci: Add support for Designware IP block
Quoted 74 lines · Michael S. Tsirkin
Quoted 57 lines · Andrey Smirnov
hw/pci-host/designware.c new file +57
-0+static void designware_pcie_root_class_init (ObjectClass *klass,void *data) +{ +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + + k->vendor_id =PCI_VENDOR_ID_SYNOPSYS ; + k->device_id =0xABCD ; + k->revision =0 ; + k->class_id =PCI_CLASS_BRIDGE_PCI ; + k->is_express = true; + k->is_bridge = true; + k->exit = pci_bridge_exitfn; + k->realize = designware_pcie_root_realize; + k->config_read = designware_pcie_root_config_read; + k->config_write = designware_pcie_root_config_write; + + dc->reset = pci_bridge_reset; +/* +* PCI-facing part of the host bridge, not usable without the +* host-facing part, which can't be device_add'ed, yet. +*/ + dc->user_creatable = false; + dc->vmsd = &vmstate_designware_pcie_root; +} + +static uint64_t designware_pcie_host_mmio_read (void *opaque,hwaddr addr, +unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_read_common (device, + addr, +pci_config_size (device), + size); +} + +static void designware_pcie_host_mmio_write (void *opaque,hwaddr addr, +uint64_t val,unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_write_common (device, + addr, +pci_config_size (device), + val, size); +} + +static const MemoryRegionOps designware_pci_mmio_ops = { + .read = designware_pcie_host_mmio_read, + .write = designware_pcie_host_mmio_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { +/* hw/pci-host/designware.c line 637
Quoted 10 lines
hw/pci-host/designware.c new file +10
-0+* Our device would not work correctly if the guest was doing +* unaligned access. This might not be a limitation on the real +* device but in practice there is no reason for a guest to access +* this device unaligned. +*/ + .min_access_size = 4, + .max_access_size = 4, + .unaligned = false, + }, +};Could you pls add some comments explaining why is
DEVICE_NATIVE_ENDIANappropriate here? Most of these cases are plain "we never bothered about cross-endian setups". Some are "there's a mix of different endian-ness values, need to handle in a special way".
Quoted 2 lines
I suspect you really need
DEVICE_LITTLE_ENDIAN.
That MemoryRegion corresponds to a register file permanently mapped into CPU's address space, so my assumption is that SoC designers will wire it according to CPUs endianness be it big or little. I am not aware of any big-endian CPU based SoC on the market using Designware's IP block, so I don't think there are any precedent confirming or denying correctness of my assumption. IMHO, this is also the reason why all of Linux driver code for that IP assumes little endianness.
I can't say that I testing this code against a big-endian guest/CPU, but that is primarily due to the fact that there's no real use case and any test set up I can put toghere would be a contrived example pointlessly proving my point.
Anyway, I am more than happy to switch it to use DEVICE_LITTLE_ENDIAN, I just don't know if doing so is any more justified than keeping it DEVICE_NATIVE_ENDIAN.
Thanks,
Andrey Smirnov
Re: [Qemu-arm] [PATCH v6 1/3] pci: Add support for Designware IP block
Quoted 78 lines · Andrey Smirnov
Quoted 74 lines · Michael S. Tsirkin
Quoted 57 lines · Andrey Smirnov
hw/pci-host/designware.c new file +57
-0+static void designware_pcie_root_class_init (ObjectClass *klass,void *data) +{ +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + + k->vendor_id =PCI_VENDOR_ID_SYNOPSYS ; + k->device_id =0xABCD ; + k->revision =0 ; + k->class_id =PCI_CLASS_BRIDGE_PCI ; + k->is_express = true; + k->is_bridge = true; + k->exit = pci_bridge_exitfn; + k->realize = designware_pcie_root_realize; + k->config_read = designware_pcie_root_config_read; + k->config_write = designware_pcie_root_config_write; + + dc->reset = pci_bridge_reset; +/* +* PCI-facing part of the host bridge, not usable without the +* host-facing part, which can't be device_add'ed, yet. +*/ + dc->user_creatable = false; + dc->vmsd = &vmstate_designware_pcie_root; +} + +static uint64_t designware_pcie_host_mmio_read (void *opaque,hwaddr addr, +unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_read_common (device, + addr, +pci_config_size (device), + size); +} + +static void designware_pcie_host_mmio_write (void *opaque,hwaddr addr, +uint64_t val,unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_write_common (device, + addr, +pci_config_size (device), + val, size); +} + +static const MemoryRegionOps designware_pci_mmio_ops = { + .read = designware_pcie_host_mmio_read, + .write = designware_pcie_host_mmio_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { +/* hw/pci-host/designware.c line 637
Quoted 10 lines
hw/pci-host/designware.c new file +10
-0+* Our device would not work correctly if the guest was doing +* unaligned access. This might not be a limitation on the real +* device but in practice there is no reason for a guest to access +* this device unaligned. +*/ + .min_access_size = 4, + .max_access_size = 4, + .unaligned = false, + }, +};Could you pls add some comments explaining why is
DEVICE_NATIVE_ENDIANappropriate here? Most of these cases are plain "we never bothered about cross-endian setups". Some are "there's a mix of different endian-ness values, need to handle in a special way".Quoted 2 lines
I suspect you really need
DEVICE_LITTLE_ENDIAN.
Quoted 7 lines
That MemoryRegion corresponds to a register file permanently mapped into CPU's address space, so my assumption is that SoC designers will wire it according to CPUs endianness be it big or little. I am not aware of any big-endian CPU based SoC on the market using Designware's IP block, so I don't think there are any precedent confirming or denying correctness of my assumption. IMHO, this is also the reason why all of Linux driver code for that IP assumes little endianness.
IMHO if Linux driver code does cpu_to_le then it seems best to be consistent with that.
Quoted 11 lines
I can't say that I testing this code against a big-endian guest/CPU, but that is primarily due to the fact that there's no real use case and any test set up I can put toghere would be a contrived example pointlessly proving my point.
Anyway, I am more than happy to switch it to use
DEVICE_LITTLE_ENDIAN, I just don't know if doing so is any more justified than keeping itDEVICE_NATIVE_ENDIAN.Thanks,
Andrey Smirnov
I agree it's probably not critical for a target-specific device.
Signature · 1 line
MST
Re: [Qemu-arm] [PATCH v6 1/3] pci: Add support for Designware IP block
Quoted 87 lines · Michael S. Tsirkin
Quoted 78 lines · Andrey Smirnov
Quoted 74 lines · Michael S. Tsirkin
Quoted 57 lines · Andrey Smirnov
hw/pci-host/designware.c new file +57
-0+static void designware_pcie_root_class_init (ObjectClass *klass,void *data) +{ +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + + k->vendor_id =PCI_VENDOR_ID_SYNOPSYS ; + k->device_id =0xABCD ; + k->revision =0 ; + k->class_id =PCI_CLASS_BRIDGE_PCI ; + k->is_express = true; + k->is_bridge = true; + k->exit = pci_bridge_exitfn; + k->realize = designware_pcie_root_realize; + k->config_read = designware_pcie_root_config_read; + k->config_write = designware_pcie_root_config_write; + + dc->reset = pci_bridge_reset; +/* +* PCI-facing part of the host bridge, not usable without the +* host-facing part, which can't be device_add'ed, yet. +*/ + dc->user_creatable = false; + dc->vmsd = &vmstate_designware_pcie_root; +} + +static uint64_t designware_pcie_host_mmio_read (void *opaque,hwaddr addr, +unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_read_common (device, + addr, +pci_config_size (device), + size); +} + +static void designware_pcie_host_mmio_write (void *opaque,hwaddr addr, +uint64_t val,unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_write_common (device, + addr, +pci_config_size (device), + val, size); +} + +static const MemoryRegionOps designware_pci_mmio_ops = { + .read = designware_pcie_host_mmio_read, + .write = designware_pcie_host_mmio_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { +/* hw/pci-host/designware.c line 637
Quoted 10 lines
hw/pci-host/designware.c new file +10
-0+* Our device would not work correctly if the guest was doing +* unaligned access. This might not be a limitation on the real +* device but in practice there is no reason for a guest to access +* this device unaligned. +*/ + .min_access_size = 4, + .max_access_size = 4, + .unaligned = false, + }, +};Could you pls add some comments explaining why is
DEVICE_NATIVE_ENDIANappropriate here? Most of these cases are plain "we never bothered about cross-endian setups". Some are "there's a mix of different endian-ness values, need to handle in a special way".Quoted 2 lines
I suspect you really need
DEVICE_LITTLE_ENDIAN.Quoted 7 lines
That MemoryRegion corresponds to a register file permanently mapped into CPU's address space, so my assumption is that SoC designers will wire it according to CPUs endianness be it big or little. I am not aware of any big-endian CPU based SoC on the market using Designware's IP block, so I don't think there are any precedent confirming or denying correctness of my assumption. IMHO, this is also the reason why all of Linux driver code for that IP assumes little endianness.
Quoted 3 lines
IMHO if Linux driver code does
cpu_to_lethen it seems best to be consistent with that.
Well, all of the DW code does so implicitly by using readl()/writel() helpers which will perform cpu_to_le/le_to_cpu under the hood. But is seems to me that it could be either because the access does have to be LE always or simply because readl()/writel() are goto memory helpers on ARM/LE-platforms.
FWIW: Somewhat similar precedent of MIPS/Boston machine can serve as counter-example to my assumption, since Xilinx PCIE IP there seem to be wired to be LE despite being attached to BE CPU.
Thanks,
Andrey Smirnov
Re: [Qemu-arm] [PATCH v6 1/3] pci: Add support for Designware IP block
Quoted 98 lines · Andrey Smirnov
Quoted 87 lines · Michael S. Tsirkin
Quoted 78 lines · Andrey Smirnov
Quoted 74 lines · Michael S. Tsirkin
Quoted 57 lines · Andrey Smirnov
hw/pci-host/designware.c new file +57
-0+static void designware_pcie_root_class_init (ObjectClass *klass,void *data) +{ +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + + k->vendor_id =PCI_VENDOR_ID_SYNOPSYS ; + k->device_id =0xABCD ; + k->revision =0 ; + k->class_id =PCI_CLASS_BRIDGE_PCI ; + k->is_express = true; + k->is_bridge = true; + k->exit = pci_bridge_exitfn; + k->realize = designware_pcie_root_realize; + k->config_read = designware_pcie_root_config_read; + k->config_write = designware_pcie_root_config_write; + + dc->reset = pci_bridge_reset; +/* +* PCI-facing part of the host bridge, not usable without the +* host-facing part, which can't be device_add'ed, yet. +*/ + dc->user_creatable = false; + dc->vmsd = &vmstate_designware_pcie_root; +} + +static uint64_t designware_pcie_host_mmio_read (void *opaque,hwaddr addr, +unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_read_common (device, + addr, +pci_config_size (device), + size); +} + +static void designware_pcie_host_mmio_write (void *opaque,hwaddr addr, +uint64_t val,unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_write_common (device, + addr, +pci_config_size (device), + val, size); +} + +static const MemoryRegionOps designware_pci_mmio_ops = { + .read = designware_pcie_host_mmio_read, + .write = designware_pcie_host_mmio_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { +/* hw/pci-host/designware.c line 637
Quoted 10 lines
hw/pci-host/designware.c new file +10
-0+* Our device would not work correctly if the guest was doing +* unaligned access. This might not be a limitation on the real +* device but in practice there is no reason for a guest to access +* this device unaligned. +*/ + .min_access_size = 4, + .max_access_size = 4, + .unaligned = false, + }, +};Could you pls add some comments explaining why is
DEVICE_NATIVE_ENDIANappropriate here? Most of these cases are plain "we never bothered about cross-endian setups". Some are "there's a mix of different endian-ness values, need to handle in a special way".Quoted 2 lines
I suspect you really need
DEVICE_LITTLE_ENDIAN.Quoted 7 lines
That MemoryRegion corresponds to a register file permanently mapped into CPU's address space, so my assumption is that SoC designers will wire it according to CPUs endianness be it big or little. I am not aware of any big-endian CPU based SoC on the market using Designware's IP block, so I don't think there are any precedent confirming or denying correctness of my assumption. IMHO, this is also the reason why all of Linux driver code for that IP assumes little endianness.
Quoted 3 lines
IMHO if Linux driver code does
cpu_to_lethen it seems best to be consistent with that.Well, all of the DW code does so implicitly by using readl()/writel() helpers which will perform cpu_to_le/le_to_cpu under the hood. But is seems to me that it could be either because the access does have to be LE always or simply because readl()/writel() are goto memory helpers on ARM/LE-platforms.
Quoted 4 lines
FWIW: Somewhat similar precedent of MIPS/Boston machine can serve as counter-example to my assumption, since Xilinx PCIE IP there seem to be wired to be LE despite being attached to BE CPU.
Michael, Peter:
Just in case we are in an accidental deadlock waiting on each other, my assumption is that this patch in particular and the rest in the series are good as is to be applied. Please let me know if any changes need to be made and I'll submit v7.
Thanks,
Andrey Smirnov
Re: [Qemu-arm] [PATCH v6 1/3] pci: Add support for Designware IP block
In reply to Andrey SmirnovQuoted 92 lines · Andrey Smirnov
Quoted 87 lines · Michael S. Tsirkin
Quoted 78 lines · Andrey Smirnov
Quoted 74 lines · Michael S. Tsirkin
Quoted 57 lines · Andrey Smirnov
hw/pci-host/designware.c new file +57
-0+static void designware_pcie_root_class_init (ObjectClass *klass,void *data) +{ +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + + k->vendor_id =PCI_VENDOR_ID_SYNOPSYS ; + k->device_id =0xABCD ; + k->revision =0 ; + k->class_id =PCI_CLASS_BRIDGE_PCI ; + k->is_express = true; + k->is_bridge = true; + k->exit = pci_bridge_exitfn; + k->realize = designware_pcie_root_realize; + k->config_read = designware_pcie_root_config_read; + k->config_write = designware_pcie_root_config_write; + + dc->reset = pci_bridge_reset; +/* +* PCI-facing part of the host bridge, not usable without the +* host-facing part, which can't be device_add'ed, yet. +*/ + dc->user_creatable = false; + dc->vmsd = &vmstate_designware_pcie_root; +} + +static uint64_t designware_pcie_host_mmio_read (void *opaque,hwaddr addr, +unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_read_common (device, + addr, +pci_config_size (device), + size); +} + +static void designware_pcie_host_mmio_write (void *opaque,hwaddr addr, +uint64_t val,unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_write_common (device, + addr, +pci_config_size (device), + val, size); +} + +static const MemoryRegionOps designware_pci_mmio_ops = { + .read = designware_pcie_host_mmio_read, + .write = designware_pcie_host_mmio_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { +/* hw/pci-host/designware.c line 637
Quoted 10 lines
hw/pci-host/designware.c new file +10
-0+* Our device would not work correctly if the guest was doing +* unaligned access. This might not be a limitation on the real +* device but in practice there is no reason for a guest to access +* this device unaligned. +*/ + .min_access_size = 4, + .max_access_size = 4, + .unaligned = false, + }, +};Could you pls add some comments explaining why is
DEVICE_NATIVE_ENDIANappropriate here? Most of these cases are plain "we never bothered about cross-endian setups". Some are "there's a mix of different endian-ness values, need to handle in a special way".Quoted 2 lines
I suspect you really need
DEVICE_LITTLE_ENDIAN.Quoted 7 lines
That MemoryRegion corresponds to a register file permanently mapped into CPU's address space, so my assumption is that SoC designers will wire it according to CPUs endianness be it big or little. I am not aware of any big-endian CPU based SoC on the market using Designware's IP block, so I don't think there are any precedent confirming or denying correctness of my assumption. IMHO, this is also the reason why all of Linux driver code for that IP assumes little endianness.
Quoted 3 lines
IMHO if Linux driver code does
cpu_to_lethen it seems best to be consistent with that.
Quoted 5 lines
Well, all of the DW code does so implicitly by using readl()/writel() helpers which will perform cpu_to_le/le_to_cpu under the hood. But is seems to me that it could be either because the access does have to be LE always or simply because readl()/writel() are goto memory helpers on ARM/LE-platforms.
PCI things generally tend to be LE since that's how standard PCI registers are defined, and being consistent avoids confusion.
Quoted 6 lines
FWIW: Somewhat similar precedent of MIPS/Boston machine can serve as counter-example to my assumption, since Xilinx PCIE IP there seem to be wired to be LE despite being attached to BE CPU.
Thanks,
Andrey Smirnov
OK so the above seems to imply it really should be LE, right?
Signature · 1 line
MST
Re: [Qemu-arm] [PATCH v6 1/3] pci: Add support for Designware IP block
Quoted 102 lines · Michael S. Tsirkin
Quoted 92 lines · Andrey Smirnov
Quoted 87 lines · Michael S. Tsirkin
Quoted 78 lines · Andrey Smirnov
Quoted 74 lines · Michael S. Tsirkin
Quoted 57 lines · Andrey Smirnov
hw/pci-host/designware.c new file +57
-0+static void designware_pcie_root_class_init (ObjectClass *klass,void *data) +{ +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); +DeviceClass *dc =DEVICE_CLASS (klass); + +set_bit (DEVICE_CATEGORY_BRIDGE , dc->categories); + + k->vendor_id =PCI_VENDOR_ID_SYNOPSYS ; + k->device_id =0xABCD ; + k->revision =0 ; + k->class_id =PCI_CLASS_BRIDGE_PCI ; + k->is_express = true; + k->is_bridge = true; + k->exit = pci_bridge_exitfn; + k->realize = designware_pcie_root_realize; + k->config_read = designware_pcie_root_config_read; + k->config_write = designware_pcie_root_config_write; + + dc->reset = pci_bridge_reset; +/* +* PCI-facing part of the host bridge, not usable without the +* host-facing part, which can't be device_add'ed, yet. +*/ + dc->user_creatable = false; + dc->vmsd = &vmstate_designware_pcie_root; +} + +static uint64_t designware_pcie_host_mmio_read (void *opaque,hwaddr addr, +unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_read_common (device, + addr, +pci_config_size (device), + size); +} + +static void designware_pcie_host_mmio_write (void *opaque,hwaddr addr, +uint64_t val,unsigned int size) +{ +PCIHostState *pci =PCI_HOST_BRIDGE (opaque); +PCIDevice *device =pci_find_device (pci->bus,0 ,0 ); + +return pci_host_config_write_common (device, + addr, +pci_config_size (device), + val, size); +} + +static const MemoryRegionOps designware_pci_mmio_ops = { + .read = designware_pcie_host_mmio_read, + .write = designware_pcie_host_mmio_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { +/* hw/pci-host/designware.c line 637
Quoted 10 lines
hw/pci-host/designware.c new file +10
-0+* Our device would not work correctly if the guest was doing +* unaligned access. This might not be a limitation on the real +* device but in practice there is no reason for a guest to access +* this device unaligned. +*/ + .min_access_size = 4, + .max_access_size = 4, + .unaligned = false, + }, +};Could you pls add some comments explaining why is
DEVICE_NATIVE_ENDIANappropriate here? Most of these cases are plain "we never bothered about cross-endian setups". Some are "there's a mix of different endian-ness values, need to handle in a special way".Quoted 2 lines
I suspect you really need
DEVICE_LITTLE_ENDIAN.Quoted 7 lines
That MemoryRegion corresponds to a register file permanently mapped into CPU's address space, so my assumption is that SoC designers will wire it according to CPUs endianness be it big or little. I am not aware of any big-endian CPU based SoC on the market using Designware's IP block, so I don't think there are any precedent confirming or denying correctness of my assumption. IMHO, this is also the reason why all of Linux driver code for that IP assumes little endianness.
Quoted 3 lines
IMHO if Linux driver code does
cpu_to_lethen it seems best to be consistent with that.Quoted 5 lines
Well, all of the DW code does so implicitly by using readl()/writel() helpers which will perform cpu_to_le/le_to_cpu under the hood. But is seems to me that it could be either because the access does have to be LE always or simply because readl()/writel() are goto memory helpers on ARM/LE-platforms.
PCI things generally tend to be LE since that's how standard PCI registers are defined, and being consistent avoids confusion.
Quoted 9 lines
Quoted 6 lines
FWIW: Somewhat similar precedent of MIPS/Boston machine can serve as counter-example to my assumption, since Xilinx PCIE IP there seem to be wired to be LE despite being attached to BE CPU.
Thanks,
Andrey SmirnovOK so the above seems to imply it really should be LE, right?
Sure, I'll change the endianness and submit v7.
Thanks,
Andrey Smrinov
PATCH v6 2/3 i.MX: Add i.MX7 SOC implementation.
In reply to Andrey SmirnovThe following interfaces are partially or fully emulated:
* up to 2 Cortex A9 cores (SMP works with PSCI)
* A7 MPCORE (identical to A15 MPCORE)
* 4 GPTs modules
* 7 GPIO controllers
* 2 IOMUXC controllers
* 1 CCM module
* 1 SVNS module
* 1 SRC module
* 1 GPCv2 controller
* 4 eCSPI controllers
* 4 I2C controllers
* 7 i.MX UART controllers
* 2 FlexCAN controllers
* 2 Ethernet controllers (FEC)
* 3 SD controllers (USDHC)
* 4 WDT modules
* 1 SDMA module
* 1 GPR module
* 2 USBMISC modules
* 2 ADC modules
* 1 PCIe controller
Tested to boot and work with upstream Linux (4.13+) guest.
--- default-configs/arm-softmmu.mak | 1 + include/hw/arm/fsl-imx7.h | 222 +++++++++++++++ hw/arm/fsl-imx7.c | 580 ++++++++++++++++++++++++++++++++++++++++ hw/arm/Makefile.objs | 2 + 4 files changed, 805 insertions(+) create mode 100644 include/hw/arm/fsl-imx7.h create mode 100644 hw/arm/fsl-imx7.c
default-configs/arm-softmmu.mak +1 -0
@@ -119,6 +119,7 @@ CONFIG_ALLWINNER_A10=y CONFIG_FSL_IMX6=y CONFIG_FSL_IMX31=y CONFIG_FSL_IMX25=y +CONFIG_FSL_IMX7=y CONFIG_IMX_I2C=y
include/hw/arm/fsl-imx7.h new file +222 -0
222 lines not on this page · raw message
hw/arm/fsl-imx7.c new file +580 -0
580 lines not on this page · raw message
hw/arm/Makefile.objs +2 -0
@@ -20,3 +20,5 @@ obj-$(CONFIG_FSL_IMX6) += fsl-imx6.o sabrelite.o obj-$(CONFIG_ASPEED_SOC) += aspeed_soc.o aspeed.o obj-$(CONFIG_MPS2) += mps2.o obj-$(CONFIG_MSF2) += msf2-soc.o msf2-som.o +obj-$(CONFIG_FSL_IMX7) += fsl-imx7.o +
Signature · 1 line
2.14.3