From mboxrd@z Thu Jan 1 00:00:00 1970 From: thomas.petazzoni@free-electrons.com (Thomas Petazzoni) Date: Tue, 12 Feb 2013 17:28:34 +0100 Subject: [PATCH v3] PCIe support for the Armada 370 and Armada XP SoCs Message-ID: <1360686546-24277-1-git-send-email-thomas.petazzoni@free-electrons.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Hello, This series of patches introduces PCIe support for the Marvell Armada 370 and Armada XP. This PATCHv3 follows: * PATCHv2, sent on January, 28th 2013 * RFCv1, sent on December, 7th 2012 Thanks to all the people who discussed on the previous version of the patch set. The discussions have been long and complicated, but certainly very useful. In order to make progress on this, and help reducing the size of the patch set, I would ask if it would be possible to merge patches 1 to 17 from the series for 3.9 (only preparation work), keeping the rest for 3.10. The patches in question are PCI-related, ARM-related, and mvebu/orion-related. Changes between v2 and v3: * Use of_irq_map_pci() instead of of_irq_map_raw(), as suggested by Andrew Murray. In order to do this, we moved the interrupt-map and interrupt-map-mask DT properties from the main PCIe controller node to the DT subnodes representing each PCIe interface. * Remove the usage of the emulated host bridge. * Move the emulated PCI-to-PCI bridge code into the Marvell PCI driver itself, in order to allow a tighter integration. Suggested by Bjorn Helgaas and Jason Gunthorpe. * Make the allocation of address decoding windows dynamic: it's when memory accesses or I/O accesses are enabled at the PCI-to-PCI bridge level that we allocate and setup the corresponding address decoding window. Requested by Bjorn Helgaas. * Fixed the implementation of I/O accesses to use I/O addresses that fall within the normal IO_SPACE_LIMIT. This required using the "remap" functionality of address decoding windows, and therefore some changes in the address decoding window allocator. Follows a long discussion about I/O accesses. * Set up a correct bus number in the configuration of the PCIe interfaces so that we don't have to fake bus numbers anymore. Requested by Jason Gunthorpe. * Fix the of_pci_get_devfn() implementation according to Stephen Warren's comment. * Use CFLAGS_ instead of ccflags to add the mach-mvebu and plat-orion include paths when building the pci-mvebu driver. This ensures that the include paths are only added when building this specific driver. Requested by Stephen Warren. * Fix the ->resource_align() to only apply on bus 0 (the one on which the emulated PCI-to-PCI bridges sit), and to request an alignment on the size of the window (and not only 64 KB for I/O windows and 1 MB for memory windows). * Clarified the commit log of "clk: mvebu: create parent-child relation for PCIe clocks on Armada 370" A quick description of the patches: * Patches 1 to 3 add PCI-related Device Tree parsing functions. Those patches are common with the Nvidia Tegra PCIe patch set from Thierry Redding. They are included in this series so that it can be tested easily. * Patch 4 extends the ARM PCI core to store a per-controller private data pointer. This patch is common with the Nvidia Tegra PCIe patch set from Thierry Redding. It is included in this series so that it can be tested easily. * Patch 5 fixes a problem in lib/devres.c that prevents certain PCI-related functions from being visible on NO_IOPORT platforms. I know this patch isn't acceptable by itself, but the discussion about this has been so huge and went in so many directions that in the end, I don't know what is the correct way of fixing this. If an agreement is found on how to fix this properly, I'm willing to work on it if needed. * Patch 6 extends the ARM PCI core with an additional hook that a PCI controller driver can register and get called to realign PCI ressource addresses. This is needed for the support of Marvell PCIe interfaces because the address decoding windows for I/O ranges have a granularity of 64 KB, while the PCI standard requires only a 4 KB alignement. See the patch itself for details. * Patch 7 fixes a mistake in the interrupt controller node of the Armada 370/XP Device Tree, which was invisible until we started using the of_irq_map_raw() function, needed in our PCIe support. * Patches 8 and 9 fix some issues in the Armada 370/XP clock gating driver, related to PCIe interfaces. * Patches 10 and 11 are cleanup/refactoring of the common plat-orion address decoding code, in preparation for further changes related to PCIe. * Patches 12 to 17 introduce a ORION_ADDR_MAP_NO_REMAP define that is used by existing Marvell SoC code to say "I don't need this window to remap anything". Previously a -1 value was used as the remap address to communicate the fact that no remap is needed, but this prevents any remap address higher than 2 GB. * Patch 18 removes __init from a few address window decoding functions that are now needed after boot. * Patch 19 introduces in the common plat-orion address decoding code functions to allocate/free an address decoding window. Until now, the address decoding windows were configured statically. With Armada XP having up to 10 PCIe interfaces, we don't want to allocate useless address decoding windows statically, so we move to a more dynamic model in which address decoding windows are configured only for the PCIe interfaces that are actually in use. * Patch 20 removes __init from a few PCIe functions that are now needed after boot. * Patch 21 improves the Armada 370/XP specific address decoding code to provide functions that add and remove an address decoding window for a given PCIe interface. It relies on the common functions added in patch 19. * Patch 22 makes the common plat-orion PCIe code available on PLAT_ORION platforms such as ARCH_MVEBU. * Patch 23 creates the drivers/pci/host directory and makes the related minimal changes to Kconfig/Makefile. This patch will trivially conflict with the NVidia Tegra PCIe support posted by Thierry Redding, which also creates the drivers/pci/host directory. * Patch 24 contains the Armada 370/XP PCIe driver itself, that implements the necessary operations required by the ARM PCI core, and configures the address decoding windows as needed. This driver relies on a Device Tree description of the PCIe interfaces. * Patch 25 marks the ARCH_MVEBU platform has having PCI available, which allows the compilation of the PCIe support. * Patches 26 and 27 add the SoC-level Device Tree informations related to PCIe for Armada 370 and Armada XP. * Patch 28 to 31 add the board-level Device Tree informations related to PCIe for the Armada XP DB, Armada 370 DB, PlatHome OpenBlocks AX3-4 and GlobalScale Mirabox boards. * Patch 32 updates mvebu_defconfig with PCI and USB support. This patch set applies on top of v3.8-rc7, and has been pushed at: git://github.com/MISL-EBU-System-SW/mainline-public.git marvell-pcie-v3 Thanks, Thomas --- Output of lspci -vvv: 00:01.0 PCI bridge: Marvell Technology Group Ltd. Device 7846 (prog-if 00 [Normal decode]) Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx- Status: Cap+ 66MHz+ UDF+ FastB2B+ ParErr+ DEVSEL=?? >TAbort+ SERR+ TAbort- Reset+ FastB2B+ PriDiscTmr+ SecDiscTmr+ DiscTmrStat+ DiscTmrSERREn+ Capabilities: [fc] 00:02.0 PCI bridge: Marvell Technology Group Ltd. Device 7846 (prog-if 00 [Normal decode]) Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx- Status: Cap+ 66MHz+ UDF+ FastB2B+ ParErr+ DEVSEL=?? >TAbort+ SERR+ TAbort- Reset+ FastB2B+ PriDiscTmr+ SecDiscTmr+ DiscTmrStat+ DiscTmrSERREn+ Capabilities: [fc] 00:03.0 PCI bridge: Marvell Technology Group Ltd. Device 7846 (prog-if 00 [Normal decode]) Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx- Status: Cap+ 66MHz+ UDF+ FastB2B+ ParErr+ DEVSEL=?? >TAbort+ SERR+ TAbort- Reset+ FastB2B+ PriDiscTmr+ SecDiscTmr+ DiscTmrStat+ DiscTmrSERREn+ Capabilities: [fc] 00:04.0 PCI bridge: Marvell Technology Group Ltd. Device 7846 (prog-if 00 [Normal decode]) Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx- Status: Cap+ 66MHz+ UDF+ FastB2B+ ParErr+ DEVSEL=?? >TAbort+ SERR+ TAbort- Reset+ FastB2B+ PriDiscTmr+ SecDiscTmr+ DiscTmrStat+ DiscTmrSERREn+ Capabilities: [fc] 00:05.0 PCI bridge: Marvell Technology Group Ltd. Device 7846 (prog-if 00 [Normal decode]) Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx- Status: Cap+ 66MHz+ UDF+ FastB2B+ ParErr+ DEVSEL=?? >TAbort+ SERR+ TAbort- Reset+ FastB2B+ PriDiscTmr+ SecDiscTmr+ DiscTmrStat+ DiscTmrSERREn+ Capabilities: [fc] 00:06.0 PCI bridge: Marvell Technology Group Ltd. Device 7846 (prog-if 00 [Normal decode]) Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx- Status: Cap+ 66MHz+ UDF+ FastB2B+ ParErr+ DEVSEL=?? >TAbort+ SERR+ TAbort- Reset+ FastB2B+ PriDiscTmr+ SecDiscTmr+ DiscTmrStat+ DiscTmrSERREn+ Capabilities: [fc] 03:00.0 SCSI storage controller: Marvell Technology Group Ltd. 88SX7042 PCI-e 4-port SATA-II (rev 02) Subsystem: Marvell Technology Group Ltd. Device 11ab Control: I/O+ Mem+ BusMaster+ SpecCycle- MemWINV- VGASnoop- ParErr+ Stepping- SERR+ FastB2B- DisINTx- Status: Cap+ 66MHz- UDF- FastB2B- ParErr- DEVSEL=fast >TAbort- SERR- TAbort- SERR- 0143) PCI: enabling device 0000:00:02.0 (0140 -> 0143) PCI: enabling device 0000:00:03.0 (0140 -> 0143) PCI: enabling device 0000:00:04.0 (0140 -> 0143) PCI: enabling device 0000:00:05.0 (0140 -> 0143) PCI: enabling device 0000:00:06.0 (0140 -> 0143)