PCIe support for the Armada 370 and Armada XP SoCs
Subsystems (8)
v9 cover PCIe support for the Armada 370 and Armada XP SoCs
Hello,
This series of patches introduces PCIe support for the Marvell Armada 370 and Armada XP. It has been rebased on top of 3.10-rc1, uses the latest of/pci code from Andrew Murray, fixes the build failure that was detected on powerpc64, and a regression that was introduced between the v7 and the v8 of this patch set. See below for a detailed changelog.
I'd like this code to be merged for 3.11.
For easier testing, the code has been pushed to:
git://github.com/MISL-EBU-System-SW/mainline-public.git marvell-pcie-v9
This PATCHv9 follows:
* PATCHv8, sent on April, 9th 2013
* PATCHv7, sent on March, 27th 2013
* PATCHv6, sent on March, 26st 2013
* PATCHv5, sent on March, 21st 2013
* PATCHv4, sent on March, 8th 2013
* PATCHv3, sent on February, 12th 2013
* PATCHv2, sent on January, 28th 2013
* RFCv1, sent on December, 7th 2012
Changes between v8 and v9:
* Rebased on top of 3.10-rc1. Since the PCIe Device Tree informations were merged in 3.10-rc1, it allowed to reduce quite significantly the size of this patch set.
* A fix for the PCIe Device Tree information is added as the first patch, it adds a missing range entry to let the global PCIe memory/IO window addresses be correctly translated. It should be merged into the 3.10-rc cycle, to fix the hardware definition of the platform.
* The patch set now integrates the latest version of Andrew Murray of/pci patch, that adds the PCI range parsing functions. The one I've integrated is:
[PATCH v9 1/3] of/pci: Provide support for parsing PCI DT ranges property
* I've fixed the PowerPC64 build problem, which was the reason why this driver was not taken for 3.10. In fact, the patch 'pci:
infrastructure to add drivers in drivers/pci/host' was introducing a drivers/pci/host directory, with just an empty Makefile. Unfortunately, an empty Makefile doesn't trigger the generation of drivers/pci/host/built-in.o. So if you try to build the kernel with just this patch applied, and not the PCIe driver itself, the Makefile is empty, and the build breaks.
To solve this, I've simply merged this patch with the PCIe driver patch itself. The PCIe driver patch adds the drivers/pci/host/ directory and the related Kconfig/Makefile bits.
* Fixed a regression in the driver introduced between the v7 and the v8. A #define <something> 1 was changed to #define <something> BIT(1), which obviously doesn't work. Changed to BIT(0), which is correct.
Changes between v7 and v8:
* In the patch introducing the drivers/pci/host directory, add an empty drivers/pci/host/Makefile to ensure that the kernel still build. This Makefile will actually gets its first useful line when the Marvell PCIe driver gets added. Noted by Neil Greatorex.
* Remove bogus (and useless) CFLAGS in drivers/pci/host/Makefile for the compilation of the Marvell PCIe driver. Noticed by Bjorn Helgaas.
* Added missing parenthesis in the definition of the PCIE_BAR_CTRL_OFF macro. Noticed by Bjorn Helgaas.
* Make mvebu_pcie_link_up() return 'bool' instead of 'int'. Suggested by Bjorn Helgaas.
* Change mvebu_pcie_link_up(), mvebu_pcie_set_local_bus_nr(), mvebu_pcie_setup_wins(), mvebu_pcie_setup_hw(), mvebu_pcie_hw_rd_conf(), mvebu_pcie_hw_wr_conf() so that they take a 'struct mvebu_pcie_port *' instead of a 'void __iomem *' as first argument. The base address of the PCIe interface register are available using the 'base' field of 'struct mvebu_pcie_port'. Suggested by Bjorn Helgaas.
* Fixed multi-line comments that should have been one line comments. Noticed by Bjorn Helgaas.
* Fixed a for() loop in mvebu_pcie_setup_wins() to use the more conventional 'ii < 3' ending condition instead of 'i <= 2'. Suggested by Bjorn Helgaas.
* Add a #define instead of an hardcoded magic value when enabling interrupts A-D in mvebu_pcie_setup_hw(). Suggested by Bjorn Helgaas.
* Add a PCIE_CONF_ADDR() to simplify the code in mvebu_pcie_hw_rd_conf() and mvebu_pcie_hw_wr_conf(). Suggested by Bjorn Helgaas.
* Clarify the comments in mvebu_pcie_handle_iobase_change() and mvebu_pcie_handle_membase_change() so that it is clear we look at the new iobase/iolimit (respectively membase/memlimit) values. Suggested by Bjorn Helgaas.
* Replace mvebu_pcie_find_port_by_bus() and mvebu_pcie_find_port_by_devfn() by a single mvebu_pcie_find_port() function, and simplify the mvebu_pcie_rd_conf() and mvebu_pcie_wr_conf() functions. Suggested by Bjorn Helgaas.
* Fix the computation of the real I/O resource start and end addresses, according to the suggestions of Arnd Bergmann and Jason Gunthorpe.
* Remove the MASK/OFFS definition, and use definitions more in the style of pci_regs.h. Suggested by Bjorn Helgaas.
* Integrate the latest version of 'of/pci: Provide support for parsing PCI DT ranges property' from Andrew Murray, fixed according to the review of Rob Herring.
* Added the Acked-by tags from Bjorn Helgaas on the PCI patches.
Changes between v6 and v7:
* Use assigned-addresses in the DT subnodes for the MMIO PCIe registers, in order to align with what Thierry is doing on the Tegra PCIe driver.
* Added empty 'ranges;' properties in the subnodes, as requested by Arnd. Note that due to this, it is not possible to remove the #address-cells and #size-cells properties from the subnodes, as Jason Gunthorpe requested, otherwise the DT compiler complains with:
Warning (ranges_format): /soc/pcie-controller/pcie at 1,0 has empty "ranges" property but its #address-cells (2) differs from /soc/pcie-controller (3)
Warning (ranges_format): /soc/pcie-controller/pcie at 1,0 has empty "ranges" property but its #size-cells (1) differs from /soc/pcie-controller (2)
* Use the new RFCv3 patch from Andrew Murray for 'of/pci: Provide support for parsing PCI DT ranges property'.
* Updated the DT binding documentation accordingly.
Changes between v5 and v6:
* Use pci_create_root_bus() + pci_scan_child_bus() instead of pci_scan_root_bus(). This is needed to be able to add MSI support later on. Moreover Thierry Reding suggested that pci_scan_root_bus() "does a pci_bus_add_devices(), which is called again in pci_common_init() in the ARM code". Thanks Thierry for pointing out this issue.
Changes between v4 and v5:
* Rebased on top of 3.9-rc2 + the new mvebu-mbus driver (v3).
* Changed the names of the PCI DT sub-nodes to match the OF
specifications: they should be named pcie at DD,FF where DD is the device number and FF the function number. Requested by Mitch Bradley.
* Add the device_type = "pci" property@the pcie-controller level. Requested by Mitch Bradley.
* Drop patch 'of/pci: Add of_pci_get_bus() function' because it wasn't actually used in the rest of the patch series.
* Updated the patch 'of/pci: Provide support for parsing PCI DT ranges property' to use the latest version proposed by Andrew Murray on the devicetree-discuss@ mailing list.
Changes between v3 and v4:
* Rebased on top of 3.9-rc1.
* Drop patch "ARM: pci: Allow passing per-controller private data" because it was merged in 3.9.
* Drop patch "lib: devres: don't enclose pcim_*() functions in CONFIG_HAS_IOPORT", because it was merged in 3.9.
* Added CONFIG_PCI_MVEBU=y in mvebu_defconfig, so that the right PCI host controller driver is automatically enabled.
* Instead of using the DT 'ranges' property to encode the PCIe register ranges, use a 'reg' property on the main PCIe controller DT node together with a 'reg-names' property. Suggested by Jason Gunthorpe.
* Don't select PCI_SW_HOST_BRIDGE and PCI_SW_PCI_PCI_BRIDGE, they don't exist anymore. Reported by Bjorn Helgaas.
* Added support for the Armada XP GP board.
* Fix the 'ranges' property so that the memory range is an identity map between CPU addresses and bus addresses. Suggested by Arnd Bergmann.
* Changed the 'ranges' property to have the I/O region after the memory region.
* Use the new mvebu-mbus driver API to create/remove address decoding windows when needed. This remove the need to include <mach/addr-map.h>. Requested by Arnd Bergmann.
* Include directly into the driver the few common PCIe functions we were using from arch/arm/plat-orion/pcie.c. This allows to remove the inclusion of <plat/pcie.h>. Requested by Arnd Bergmann.
* Directly set up the address decoding windows when the memory base/limit and I/O base/limit are configured in the PCI-to-PCI bridge instead of relying on the memory and I/O accesses being enabled in the PCI_COMMAND register. Suggested by Bjorn Helgaas.
* Added some comments on top of the calculations of the I/O base/limit and memory base/limit. Suggested by Arnd Bergmann.
* Changed a bit the way the "realio" resource is created, from suggestions given by Arnd Bergmann.
* Updated the Device Tree binding documentation. Reported by Jason Gunthorpe.
* Instead of using "marvell,armada-370-xp-pcie" as the DT compatible string, use two separate compatible strings:
"marvell,armada-370-pcie" and "marvell,armada-xp-pcie". For now, the driver does the same thing for both.
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"
Thanks,
Thomas
Andrew Murray (1):
of/pci: Provide support for parsing PCI DT ranges property
Thierry Reding (2):
of/pci: Add of_pci_get_devfn() function
of/pci: Add of_pci_parse_bus_range() function
Thomas Petazzoni (6):
arm: mvebu: fix the 'ranges' property to handle PCIe
clk: mvebu: create parent-child relation for PCIe clocks on Armada
370
clk: mvebu: add more PCIe clocks for Armada XP
pci: PCIe driver for Marvell Armada 370/XP systems
arm: mvebu: PCIe support is now available on mvebu
arm: mvebu: update defconfig with PCI and USB support
.../devicetree/bindings/pci/mvebu-pci.txt | 220 +++++ arch/arm/boot/dts/armada-370-xp.dtsi | 3 +- arch/arm/boot/dts/armada-370.dtsi | 3 +- arch/arm/configs/mvebu_defconfig | 3 + arch/arm/mach-mvebu/Kconfig | 2 + drivers/clk/mvebu/clk-gating-ctrl.c | 18 +- drivers/of/address.c | 67 ++ drivers/of/of_pci.c | 59 +- drivers/pci/Kconfig | 2 + drivers/pci/Makefile | 3 + drivers/pci/host/Kconfig | 8 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-mvebu.c | 879 ++++++++++++++++++++ include/linux/of_address.h | 48 ++ include/linux/of_pci.h | 2 + 15 files changed, 1305 insertions(+), 13 deletions(-) create mode 100644 Documentation/devicetree/bindings/pci/mvebu-pci.txt create mode 100644 drivers/pci/host/Kconfig create mode 100644 drivers/pci/host/Makefile create mode 100644 drivers/pci/host/pci-mvebu.c
Signature · 1 line
1.7.9.5
PATCH v9 1/9 arm: mvebu: fix the 'ranges' property to handle PCIe
Since 82a682676 ('ARM: dts: mvebu: Convert all the mvebu files to use the range property') all the device nodes of Armada 370/XP are under a common 'ranges' property that translates the device register addresses into their absolute address, thanks to the base address of the internal register space.
However, beyond just the register areas, there are also PCIe I/O and memory regions, whose addresses should be properly translated. This patch fixes the Armada 370 and XP ranges property to take PCIe into account properly.
---
Since the PCIe Device Tree description has been merged in 3.10-rc1, this commit should go in 3.10-rc as well.
--- arch/arm/boot/dts/armada-370-xp.dtsi | 3 ++- arch/arm/boot/dts/armada-370.dtsi | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/boot/dts/armada-370-xp.dtsi +2 -1
@@ -33,7 +33,8 @@ #size-cells = <1>; compatible = "simple-bus"; interrupt-parent = <&mpic>; - ranges = <0 0 0xd0000000 0x100000>; + ranges = <0 0 0xd0000000 0x0100000 /* internal registers */ + 0xe0000000 0 0xe0000000 0x8100000 /* PCIe */>; internal-regs { compatible = "simple-bus";
arch/arm/boot/dts/armada-370.dtsi +2 -1
@@ -29,7 +29,8 @@ }; soc { - ranges = <0 0xd0000000 0x100000>; + ranges = <0 0xd0000000 0x0100000 /* internal registers */ + 0xe0000000 0xe0000000 0x8100000 /* PCIe */>; internal-regs { system-controller at 18200 { compatible = "marvell,armada-370-xp-system-controller";
Signature · 1 line
1.7.9.5
PATCH v9 2/9 of/pci: Provide support for parsing PCI DT ranges property
In reply to Thomas PetazzoniFrom: Andrew Murray <[email protected]>
This patch factors out common implementation patterns to reduce overall kernel code and provide a means for host bridge drivers to directly obtain struct resources from the DT's ranges property without relying on architecture specific DT handling. This will make it easier to write archiecture independent host bridge drivers and mitigate against further duplication of DT parsing code.
This patch can be used in the following way:
struct of_pci_range_parser parser;
struct of_pci_range range;
if (of_pci_range_parser_init(&parser, np))
; //no ranges property
for_each_of_pci_range(&parser, &range) {
/*
directly access properties of the address range, e.g.:
range.pci_space, range.pci_addr, range.cpu_addr,
range.size, range.flags
alternatively obtain a struct resource, e.g.:
struct resource res;
of_pci_range_to_resource(&range, np, &res);
*/
}Additionally the implementation takes care of adjacent ranges and merges them into a single range (as was the case with powerpc and microblaze).
--- drivers/of/address.c | 67 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/of_address.h | 48 +++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+)
drivers/of/address.c +67 -0
@@ -227,6 +227,73 @@ int of_pci_address_to_resource(struct device_node *dev, int bar,return __of_address_to_resource (dev, addrp, size, flags,NULL , r); }EXPORT_SYMBOL_GPL (of_pci_address_to_resource); + +int of_pci_range_parser_init (struct of_pci_range_parser *parser, +struct device_node *node) +{ +const int na =3 , ns =2 ; +int rlen; + + parser->node = node; + parser->pna =of_n_addr_cells (node); + parser->np = parser->pna + na + ns; + + parser->range =of_get_property (node,"ranges" , &rlen); +if (parser->range ==NULL ) +return -ENOENT ; + + parser->end = parser->range + rlen /sizeof (__be32); + +return 0 ; +} +EXPORT_SYMBOL_GPL (of_pci_range_parser_init); + +struct of_pci_range *of_pci_range_parser_one (struct of_pci_range_parser *parser, +struct of_pci_range *range) +{ +const int na =3 , ns =2 ; + +if (!range) +return NULL ; + +if (!parser->range || parser->range + parser->np > parser->end) +return NULL ; + + range->pci_space = parser->range[0 ]; + range->flags =of_bus_pci_get_flags (parser->range); + range->pci_addr =of_read_number (parser->range +1 , ns); + range->cpu_addr =of_translate_address (parser->node, + parser->range + na); + range->size =of_read_number (parser->range + parser->pna + na, ns); + + parser->range += parser->np; + +/* Now consume following elements while they are contiguous */ +while (parser->range + parser->np <= parser->end) { +u32 flags, pci_space; +u64 pci_addr, cpu_addr, size; + + pci_space =be32_to_cpup (parser->range); + flags =of_bus_pci_get_flags (parser->range); + pci_addr =of_read_number (parser->range +1 , ns); + cpu_addr =of_translate_address (parser->node, + parser->range + na); + size =of_read_number (parser->range + parser->pna + na, ns); + +if (flags != range->flags) +break ; +if (pci_addr != range->pci_addr + range->size || + cpu_addr != range->cpu_addr + range->size) +break ; + + range->size += size; + parser->range += parser->np; + } + +return range; +} +EXPORT_SYMBOL_GPL (of_pci_range_parser_one); +#endif /* CONFIG_PCI */ /*
include/linux/of_address.h +48 -0
66 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v9 3/9 of/pci: Add of_pci_get_devfn() function
In reply to Thomas PetazzoniFrom: Thierry Reding <[email protected]>
This function can be used to parse the device and function number from a standard 5-cell PCI resource. PCI_SLOT() and PCI_FUNC() can be used on the returned value obtain the device and function numbers respectively.
--- drivers/of/of_pci.c | 34 +++++++++++++++++++++++++++++----- include/linux/of_pci.h | 1 + 2 files changed, 30 insertions(+), 5 deletions(-)
drivers/of/of_pci.c +29 -5
@@ -5,14 +5,15 @@#include <asm/prom.h> static inline int __of_pci_pci_compare (struct device_node *node, -unsigned int devfn) +unsigned int data) { -unsigned int size; -const __be32 *reg =of_get_property (node,"reg" , &size); +int devfn; -if (!reg || size <5 *sizeof (__be32)) + devfn =of_pci_get_devfn (node); +if (devfn <0 )return 0 ; -return ((be32_to_cpup (®[0 ]) >>8 ) &0xff ) == devfn; + +return devfn == data; } struct device_node *of_pci_find_child_device(struct device_node *parent,
@@ -40,3 +41,26 @@ struct device_node *of_pci_find_child_device(struct device_node *parent,return NULL ; }EXPORT_SYMBOL_GPL (of_pci_find_child_device); + +/** +* of_pci_get_devfn() - Get device and function numbers for a device node +* @np: device node +* +* Parses a standard 5-cell PCI resource and returns an 8-bit value that can +* be passed to the PCI_SLOT() and PCI_FUNC() macros to extract the device +* and function numbers respectively. On error a negative error code is +* returned. +*/ +int of_pci_get_devfn (struct device_node *np) +{ +unsigned int size; +const __be32 *reg; + + reg =of_get_property (np,"reg" , &size); + +if (!reg || size <5 *sizeof (__be32)) +return -EINVAL ; + +return (be32_to_cpup (reg) >>8 ) &0xff ; +} +EXPORT_SYMBOL_GPL (of_pci_get_devfn);
include/linux/of_pci.h +1 -0
@@ -10,5 +10,6 @@ int of_irq_map_pci(const struct pci_dev *pdev, struct of_irq *out_irq);struct device_node ;struct device_node *of_pci_find_child_device (struct device_node *parent,unsigned int devfn); +int of_pci_get_devfn (struct device_node *np);#endif
Signature · 1 line
1.7.9.5
PATCH v9 4/9 of/pci: Add of_pci_parse_bus_range() function
In reply to Thomas PetazzoniFrom: Thierry Reding <[email protected]>
This function can be used to parse a bus-range property as specified by device nodes representing PCI bridges.
--- drivers/of/of_pci.c | 25 +++++++++++++++++++++++++ include/linux/of_pci.h | 1 + 2 files changed, 26 insertions(+)
drivers/of/of_pci.c +25 -0
@@ -64,3 +64,28 @@ int of_pci_get_devfn(struct device_node *np)return (be32_to_cpup (reg) >>8 ) &0xff ; }EXPORT_SYMBOL_GPL (of_pci_get_devfn); + +/** +* of_pci_parse_bus_range() - parse the bus-range property of a PCI device +* @node: device node +* @res: address to a struct resource to return the bus-range +* +* Returns 0 on success or a negative error-code on failure. +*/ +int of_pci_parse_bus_range (struct device_node *node,struct resource *res) +{ +const __be32 *values; +int len; + + values =of_get_property (node,"bus-range" , &len); +if (!values || len <sizeof (*values) *2 ) +return -EINVAL ; + + res->name = node->name; + res->start =be32_to_cpup (values++); + res->end =be32_to_cpup (values); + res->flags =IORESOURCE_BUS ; + +return 0 ; +} +EXPORT_SYMBOL_GPL (of_pci_parse_bus_range);
include/linux/of_pci.h +1 -0
@@ -11,5 +11,6 @@ struct device_node;struct device_node *of_pci_find_child_device (struct device_node *parent,unsigned int devfn);int of_pci_get_devfn (struct device_node *np); +int of_pci_parse_bus_range (struct device_node *node,struct resource *res);#endif
Signature · 1 line
1.7.9.5
PATCH v9 5/9 clk: mvebu: create parent-child relation for PCIe clocks on Armada 370
In reply to Thomas PetazzoniThe Armada 370 has two gatable clocks for each PCIe interface, and we want both of them to be enabled. We therefore make one of the two clocks a child of the other, as we did for the sataX and sataXlnk clocks on Armada XP.
--- drivers/clk/mvebu/clk-gating-ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/mvebu/clk-gating-ctrl.c +2 -2
@@ -119,8 +119,8 @@ static const struct mvebu_soc_descr __initconst armada_370_gating_descr[] = { { "pex1_en", NULL, 2 }, { "ge1", NULL, 3 }, { "ge0", NULL, 4 }, - { "pex0", NULL, 5 }, - { "pex1", NULL, 9 }, + { "pex0", "pex0_en", 5 }, + { "pex1", "pex1_en", 9 }, { "sata0", NULL, 15 }, { "sdio", NULL, 17 }, { "tdm", NULL, 25 },
Signature · 1 line
1.7.9.5
PATCH v9 5/9 clk: mvebu: create parent-child relation for PCIe clocks on Armada 370
Quoting Thomas Petazzoni (2013-05-15 06:25:19)
Quoted 5 lines
The Armada 370 has two gatable clocks for each PCIe interface, and we want both of them to be enabled. We therefore make one of the two clocks a child of the other, as we did for the sataX and sataXlnk clocks on Armada XP.
Ack for patches #5 and #6. Do you want me to take them?
Regards,
Mike
Quoted 23 lines
Signed-off-by Thomas Petazzoni <[email protected]>Cc Mike Turquette <[email protected]>--- drivers/clk/mvebu/clk-gating-ctrl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/clk/mvebu/clk-gating-ctrl.c +2
-2@@ -119,8 +119,8 @@ static const struct mvebu_soc_descr __initconst armada_370_gating_descr[] = { { "pex1_en", NULL, 2 }, { "ge1", NULL, 3 }, { "ge0", NULL, 4 }, - { "pex0", NULL, 5 }, - { "pex1", NULL, 9 }, + { "pex0", "pex0_en", 5 }, + { "pex1", "pex1_en", 9 }, { "sata0", NULL, 15 }, { "sdio", NULL, 17 }, { "tdm", NULL, 25 },Signature · 1 line
1.7.9.5
PATCH v9 5/9 clk: mvebu: create parent-child relation for PCIe clocks on Armada 370
Dear Mike Turquette,
Quoted 7 lines · Mike Turquette
Quoting Thomas Petazzoni (2013-05-15 06:25:19)
Quoted 4 lines
The Armada 370 has two gatable clocks for each PCIe interface, and we want both of them to be enabled. We therefore make one of the two clocks a child of the other, as we did for the sataX and sataXlnk clocks on Armada XP.
Ack for patches #5 and #6. Do you want me to take them?
I don't know, I guess with your Ack, it would be easier to carry them through the Marvell maintainers and then the arm-soc tree, so that we can test arm-soc and have all the pieces needed in here.
That said, Sebastian Hesselbarth has submitted a big rework of the mvebu clock drivers, which would conflict with this patch, and Sebastian's rework would most likely go through your tree. If that's the case, I guess it would be better to let you take #5 and #6 in this patch series.
That's something to be discussed with the Marvell maintainers (Jason Cooper, Andrew Lunn, Gregory Clement).
Thanks!
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
Sebastian Hesselbarth
maintainerPATCH v9 5/9 clk: mvebu: create parent-child relation for PCIe clocks on Armada 370
Quoted 15 lines · Thomas Petazzoni
Dear Mike Turquette,
Quoted 7 lines · Mike Turquette
Quoting Thomas Petazzoni (2013-05-15 06:25:19)
Quoted 4 lines
The Armada 370 has two gatable clocks for each PCIe interface, and we want both of them to be enabled. We therefore make one of the two clocks a child of the other, as we did for the sataX and sataXlnk clocks on Armada XP.
Ack for patches #5 and #6. Do you want me to take them?
I don't know, I guess with your Ack, it would be easier to carry them through the Marvell maintainers and then the arm-soc tree, so that we can test arm-soc and have all the pieces needed in here.
Quoted 5 lines
That said, Sebastian Hesselbarth has submitted a big rework of the mvebu clock drivers, which would conflict with this patch, and Sebastian's rework would most likely go through your tree. If that's the case, I guess it would be better to let you take #5 and #6 in this patch series.
I also requested to take the restructure patches through ARM tree. They are only touching files in drivers/clk/mvebu and by taking them through ARM, we can update PCIe clock patches easily. The dependency between Thomas' and my patches basically is that I renamed files that Thomas now commits to. (I switched clk/mvebu from per-function files to per-soc files).
Quoted 2 lines
That's something to be discussed with the Marvell maintainers (Jason Cooper, Andrew Lunn, Gregory Clement).
Sebastian
PATCH v9 5/9 clk: mvebu: create parent-child relation for PCIe clocks on Armada 370
Mike, Sebastian,
Quoted 11 lines · Sebastian Hesselbarth
Quoted 10 lines · Thomas Petazzoni
Dear Mike Turquette,
Quoted 7 lines · Mike Turquette
Quoting Thomas Petazzoni (2013-05-15 06:25:19)
Quoted 4 lines
The Armada 370 has two gatable clocks for each PCIe interface, and we want both of them to be enabled. We therefore make one of the two clocks a child of the other, as we did for the sataX and sataXlnk clocks on Armada XP.
Ack for patches #5 and #6. Do you want me to take them?
Thanks for the Ack!
Quoted 10 lines
Quoted 9 lines
I don't know, I guess with your Ack, it would be easier to carry them through the Marvell maintainers and then the arm-soc tree, so that we can test arm-soc and have all the pieces needed in here.
That said, Sebastian Hesselbarth has submitted a big rework of the mvebu clock drivers, which would conflict with this patch, and Sebastian's rework would most likely go through your tree. If that's the case, I guess it would be better to let you take #5 and #6 in this patch series.
Quoted 6 lines
I also requested to take the restructure patches through ARM tree. They are only touching files in
drivers/clk/mvebuand by taking them through ARM, we can update PCIe clock patches easily. The dependency between Thomas' and my patches basically is that I renamed files that Thomas now commits to. (I switched clk/mvebu from per-function files to per-soc files).
I agree. My heart jumped into my throat a little there :) Mike, if it's ok with you, I'd prefer to take these through arm-soc. Any merge conflicts should be minimal. And at any rate, resolving the conflicts are *much* easier to handle than having arm-soc depend on an outside tree (then Linus has to take care in the order he merges them, no rebasing for clk tree, dogs and cats living together, etc ;-) )
thx,
Jason.
PATCH v9 5/9 clk: mvebu: create parent-child relation for PCIe clocks on Armada 370
Quoting Jason Cooper (2013-05-16 08:06:16)
Quoted 34 lines
Mike, Sebastian,
Quoted 11 lines · Sebastian Hesselbarth
Quoted 10 lines · Thomas Petazzoni
Dear Mike Turquette,
Quoted 7 lines · Mike Turquette
Quoting Thomas Petazzoni (2013-05-15 06:25:19)
Quoted 4 lines
The Armada 370 has two gatable clocks for each PCIe interface, and we want both of them to be enabled. We therefore make one of the two clocks a child of the other, as we did for the sataX and sataXlnk clocks on Armada XP.
Ack for patches #5 and #6. Do you want me to take them?
Thanks for the Ack!
Quoted 10 lines
Quoted 9 lines
I don't know, I guess with your Ack, it would be easier to carry them through the Marvell maintainers and then the arm-soc tree, so that we can test arm-soc and have all the pieces needed in here.
That said, Sebastian Hesselbarth has submitted a big rework of the mvebu clock drivers, which would conflict with this patch, and Sebastian's rework would most likely go through your tree. If that's the case, I guess it would be better to let you take #5 and #6 in this patch series.
Quoted 6 lines
I also requested to take the restructure patches through ARM tree. They are only touching files in
drivers/clk/mvebuand by taking them through ARM, we can update PCIe clock patches easily. The dependency between Thomas' and my patches basically is that I renamed files that Thomas now commits to. (I switched clk/mvebu from per-function files to per-soc files).
Quoted 7 lines
I agree. My heart jumped into my throat a little there :) Mike, if it's ok with you, I'd prefer to take these through arm-soc. Any merge conflicts should be minimal. And at any rate, resolving the conflicts are *much* easier to handle than having arm-soc depend on an outside tree (then Linus has to take care in the order he merges them, no rebasing for clk tree, dogs and cats living together, etc ;-) )
Yeah that all sounds good to me. I'll review the restructure patches shortly.
Regards,
Mike
Quoted 3 lines
thx,
Jason.
PATCH v9 5/9 clk: mvebu: create parent-child relation for PCIe clocks on Armada 370
Quoted 43 lines · Mike Turquette
Quoting Jason Cooper (2013-05-16 08:06:16)
Quoted 34 lines
Mike, Sebastian,
Quoted 11 lines · Sebastian Hesselbarth
Quoted 10 lines · Thomas Petazzoni
Dear Mike Turquette,
Quoted 7 lines · Mike Turquette
Quoting Thomas Petazzoni (2013-05-15 06:25:19)
Quoted 4 lines
The Armada 370 has two gatable clocks for each PCIe interface, and we want both of them to be enabled. We therefore make one of the two clocks a child of the other, as we did for the sataX and sataXlnk clocks on Armada XP.
Ack for patches #5 and #6. Do you want me to take them?
Thanks for the Ack!
Quoted 10 lines
Quoted 9 lines
I don't know, I guess with your Ack, it would be easier to carry them through the Marvell maintainers and then the arm-soc tree, so that we can test arm-soc and have all the pieces needed in here.
That said, Sebastian Hesselbarth has submitted a big rework of the mvebu clock drivers, which would conflict with this patch, and Sebastian's rework would most likely go through your tree. If that's the case, I guess it would be better to let you take #5 and #6 in this patch series.
Quoted 6 lines
I also requested to take the restructure patches through ARM tree. They are only touching files in
drivers/clk/mvebuand by taking them through ARM, we can update PCIe clock patches easily. The dependency between Thomas' and my patches basically is that I renamed files that Thomas now commits to. (I switched clk/mvebu from per-function files to per-soc files).Quoted 7 lines
I agree. My heart jumped into my throat a little there :) Mike, if it's ok with you, I'd prefer to take these through arm-soc. Any merge conflicts should be minimal. And at any rate, resolving the conflicts are *much* easier to handle than having arm-soc depend on an outside tree (then Linus has to take care in the order he merges them, no rebasing for clk tree, dogs and cats living together, etc ;-) )
Quoted 2 lines
Yeah that all sounds good to me. I'll review the restructure patches shortly.
Awesome, thanks.
Jason.
PATCH v9 6/9 clk: mvebu: add more PCIe clocks for Armada XP
In reply to Thomas PetazzoniThe current revision of the datasheet only mentions the gatable clocks for the PCIe 0.0, 0.1, 0.2 and 0.3 interfaces, and forgot to mention the ones for the PCIe 1.0, 1.1, 1.2, 1.3, 2.0 and 3.0 interfaces. After confirmation with Marvell engineers, this patch adds the missing gatable clocks for those PCIe interfaces.
It also changes the name of the previously existing PCIe gatable clocks, in order to match the naming using the datasheets.
--- drivers/clk/mvebu/clk-gating-ctrl.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/clk/mvebu/clk-gating-ctrl.c +10 -4
@@ -137,10 +137,14 @@ static const struct mvebu_soc_descr __initconst armada_xp_gating_descr[] = { { "ge2", NULL, 2 }, { "ge1", NULL, 3 }, { "ge0", NULL, 4 }, - { "pex0", NULL, 5 }, - { "pex1", NULL, 6 }, - { "pex2", NULL, 7 }, - { "pex3", NULL, 8 }, + { "pex00", NULL, 5 }, + { "pex01", NULL, 6 }, + { "pex02", NULL, 7 }, + { "pex03", NULL, 8 }, + { "pex10", NULL, 9 }, + { "pex11", NULL, 10 }, + { "pex12", NULL, 11 }, + { "pex13", NULL, 12 }, { "bp", NULL, 13 }, { "sata0lnk", NULL, 14 }, { "sata0", "sata0lnk", 15 },
@@ -152,6 +156,8 @@ static const struct mvebu_soc_descr __initconst armada_xp_gating_descr[] = { { "xor0", NULL, 22 }, { "crypto", NULL, 23 }, { "tdm", NULL, 25 }, + { "pex20", NULL, 26 }, + { "pex30", NULL, 27 }, { "xor1", NULL, 28 }, { "sata1lnk", NULL, 29 }, { "sata1", "sata1lnk", 30 },
Signature · 1 line
1.7.9.5
PATCH v9 7/9 pci: PCIe driver for Marvell Armada 370/XP systems
In reply to Thomas PetazzoniThis driver implements the support for the PCIe interfaces on the Marvell Armada 370/XP ARM SoCs. In the future, it might be extended to cover earlier families of Marvell SoCs, such as Dove, Orion and Kirkwood.
The driver implements the hw_pci operations needed by the core ARM PCI code to setup PCI devices and get their corresponding IRQs, and the pci_ops operations that are used by the PCI core to read/write the configuration space of PCI devices.
Since the PCIe interfaces of Marvell SoCs are completely separate and not linked together in a bus, this driver sets up an emulated PCI host bridge, with one PCI-to-PCI bridge as child for each hardware PCIe interface.
In addition, this driver enumerates the different PCIe slots, and for those having a device plugged in, it sets up the necessary address decoding windows, using the mvebu-mbus driver.
--- .../devicetree/bindings/pci/mvebu-pci.txt | 220 +++++ drivers/pci/Kconfig | 2 + drivers/pci/Makefile | 3 + drivers/pci/host/Kconfig | 8 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-mvebu.c | 879 ++++++++++++++++++++ 6 files changed, 1113 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/mvebu-pci.txt create mode 100644 drivers/pci/host/Kconfig create mode 100644 drivers/pci/host/Makefile create mode 100644 drivers/pci/host/pci-mvebu.c
Documentation/devicetree/bindings/pci/mvebu-pci.txt new file +220 -0
@@ -0,0 +1,220 @@ +* Marvell EBU PCIe interfaces + +Mandatory properties: +- compatible: one of the following values: + marvell,armada-370-pcie + marvell,armada-xp-pcie +- #address-cells, set to <3> +- #size-cells, set to <2> +- #interrupt-cells, set to <1> +- bus-range: PCI bus numbers covered +- device_type, set to "pci" +- ranges: ranges for the PCI memory and I/O regions, as well as the + MMIO registers to control the PCIe interfaces. + +In addition, the Device Tree node must have sub-nodes describing each +PCIe interface, having the following mandatory properties: +- reg: used only for interrupt mapping, so only the first four bytes + are used to refer to the correct bus number and device number. +- assigned-addresses: reference to the MMIO registers used to control + this PCIe interface. +- clocks: the clock associated to this PCIe interface +- marvell,pcie-port: the physical PCIe port number +- status: either "disabled" or "okay" +- device_type, set to "pci" +- #address-cells, set to <3> +- #size-cells, set to <2> +- #interrupt-cells, set to <1> +- ranges, empty property. +- interrupt-map-mask and interrupt-map, standard PCI properties to + define the mapping of the PCIe interface to interrupt numbers. + +and the following optional properties: +- marvell,pcie-lane: the physical PCIe lane number, for ports having + multiple lanes. If this property is not found, we assume that the + value is 0. + +Example: + +pcie-controller { + compatible = "marvell,armada-xp-pcie"; + status = "disabled"; + device_type = "pci"; + + #address-cells = <3>; + #size-cells = <2>; + + bus-range = <0x00 0xff>; + + ranges = <0x82000000 0 0xd0040000 0xd0040000 0 0x00002000 /* Port 0.0 registers */ + 0x82000000 0 0xd0042000 0xd0042000 0 0x00002000 /* Port 2.0 registers */ + 0x82000000 0 0xd0044000 0xd0044000 0 0x00002000 /* Port 0.1 registers */ + 0x82000000 0 0xd0048000 0xd0048000 0 0x00002000 /* Port 0.2 registers */ + 0x82000000 0 0xd004c000 0xd004c000 0 0x00002000 /* Port 0.3 registers */ + 0x82000000 0 0xd0080000 0xd0080000 0 0x00002000 /* Port 1.0 registers */ + 0x82000000 0 0xd0082000 0xd0082000 0 0x00002000 /* Port 3.0 registers */ + 0x82000000 0 0xd0084000 0xd0084000 0 0x00002000 /* Port 1.1 registers */ + 0x82000000 0 0xd0088000 0xd0088000 0 0x00002000 /* Port 1.2 registers */ + 0x82000000 0 0xd008c000 0xd008c000 0 0x00002000 /* Port 1.3 registers */ + 0x82000000 0 0xe0000000 0xe0000000 0 0x08000000 /* non-prefetchable memory */ + 0x81000000 0 0 0xe8000000 0 0x00100000>; /* downstream I/O */ + + pcie at 1,0 { + device_type = "pci"; + assigned-addresses = <0x82000800 0 0xd0040000 0 0x2000>; + reg = <0x0800 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &mpic 58>; + marvell,pcie-port = <0>; + marvell,pcie-lane = <0>; + clocks = <&gateclk 5>; + status = "disabled"; + }; + + pcie at 2,0 { + device_type = "pci"; + assigned-addresses = <0x82001000 0 0xd0044000 0 0x2000>; + reg = <0x1000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &mpic 59>; + marvell,pcie-port = <0>; + marvell,pcie-lane = <1>; + clocks = <&gateclk 6>; + status = "disabled"; + }; + + pcie at 3,0 { + device_type = "pci"; + assigned-addresses = <0x82001800 0 0xd0048000 0 0x2000>; + reg = <0x1800 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &mpic 60>; + marvell,pcie-port = <0>; + marvell,pcie-lane = <2>; + clocks = <&gateclk 7>; + status = "disabled"; + }; + + pcie at 4,0 { + device_type = "pci"; + assigned-addresses = <0x82002000 0 0xd004c000 0 0x2000>; + reg = <0x2000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &mpic 61>; + marvell,pcie-port = <0>; + marvell,pcie-lane = <3>; + clocks = <&gateclk 8>; + status = "disabled"; + }; + + pcie at 5,0 { + device_type = "pci"; + assigned-addresses = <0x82002800 0 0xd0080000 0 0x2000>; + reg = <0x2800 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &mpic 62>; + marvell,pcie-port = <1>; + marvell,pcie-lane = <0>; + clocks = <&gateclk 9>; + status = "disabled"; + }; + + pcie at 6,0 { + device_type = "pci"; + assigned-addresses = <0x82003000 0 0xd0084000 0 0x2000>; + reg = <0x3000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &mpic 63>; + marvell,pcie-port = <1>; + marvell,pcie-lane = <1>; + clocks = <&gateclk 10>; + status = "disabled"; + }; + + pcie at 7,0 { + device_type = "pci"; + assigned-addresses = <0x82003800 0 0xd0088000 0 0x2000>; + reg = <0x3800 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &mpic 64>; + marvell,pcie-port = <1>; + marvell,pcie-lane = <2>; + clocks = <&gateclk 11>; + status = "disabled"; + }; + + pcie at 8,0 { + device_type = "pci"; + assigned-addresses = <0x82004000 0 0xd008c000 0 0x2000>; + reg = <0x4000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &mpic 65>; + marvell,pcie-port = <1>; + marvell,pcie-lane = <3>; + clocks = <&gateclk 12>; + status = "disabled"; + }; + pcie at 9,0 { + device_type = "pci"; + assigned-addresses = <0x82004800 0 0xd0042000 0 0x2000>; + reg = <0x4800 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &mpic 99>; + marvell,pcie-port = <2>; + marvell,pcie-lane = <0>; + clocks = <&gateclk 26>; + status = "disabled"; + }; + + pcie at 10,0 { + device_type = "pci"; + assigned-addresses = <0x82005000 0 0xd0082000 0 0x2000>; + reg = <0x5000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + ranges; + interrupt-map-mask = <0 0 0 0>; + interrupt-map = <0 0 0 0 &mpic 103>; + marvell,pcie-port = <3>; + marvell,pcie-lane = <0>; + clocks = <&gateclk 27>; + status = "disabled"; + }; +};
drivers/pci/Kconfig +2 -0
@@ -119,3 +119,5 @@ config PCI_IOAPIC config PCI_LABEL def_bool y if (DMI || ACPI) select NLS + +source "drivers/pci/host/Kconfig"
drivers/pci/Makefile +3 -0
@@ -67,3 +67,6 @@ obj-$(CONFIG_XEN_PCIDEV_FRONTEND) += xen-pcifront.o obj-$(CONFIG_OF) += of.o ccflags-$(CONFIG_PCI_DEBUG) := -DDEBUG + +# PCI host controller drivers +obj-y += host/
drivers/pci/host/Kconfig new file +8 -0
@@ -0,0 +1,8 @@ +menu "PCI host controller drivers" + depends on PCI + +config PCI_MVEBU + bool "Marvell EBU PCIe controller" + depends on ARCH_MVEBU + +endmenu
drivers/pci/host/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o
drivers/pci/host/pci-mvebu.c new file +879 -0
879 lines not on this page · raw message
Signature · 1 line
1.7.9.5
PATCH v9 7/9 pci: PCIe driver for Marvell Armada 370/XP systems
On Wed, May 15, 2013 at 03:25:21PM +0200, Thomas Petazzoni wrote:
[..]
Quoted 135 lines
drivers/pci/host/pci-mvebu.c new file +135
-0+ +static int __init mvebu_pcie_probe (struct platform_device *pdev) +{ +struct mvebu_pcie *pcie; +struct device_node *np = pdev->dev.of_node; +struct of_pci_range range; +struct of_pci_range_parser parser; +struct device_node *child; +int i, ret; + + pcie =devm_kzalloc (&pdev->dev,sizeof (struct mvebu_pcie ), +GFP_KERNEL ); +if (!pcie) +return -ENOMEM ; + + pcie->pdev = pdev; + +if (of_pci_range_parser_init (&parser, np)) +return -EINVAL ; + +/* Get the I/O and memory ranges from DT */ +for_each_of_pci_range (&parser, &range) { +unsigned long restype = range.flags &IORESOURCE_TYPE_BITS ; +if (restype ==IORESOURCE_IO ) { +of_pci_range_to_resource (&range, np, &pcie->io); +of_pci_range_to_resource (&range, np, &pcie->realio); + pcie->io.name ="I/O" ; + pcie->realio.start =max_t (resource_size_t, +PCIBIOS_MIN_IO , + range.pci_addr); + pcie->realio.end =min_t (resource_size_t, +IO_SPACE_LIMIT , + range.pci_addr + range.size); + } +if (restype ==IORESOURCE_MEM ) { +of_pci_range_to_resource (&range, np, &pcie->mem); + pcie->mem.name ="MEM" ; + } + } + +/* Get the bus range */ + ret =of_pci_parse_bus_range (np, &pcie->busn); +if (ret) { +dev_err (&pdev->dev,"failed to parse bus-range property: %d\n" , + ret); +return ret; + } + +for_each_child_of_node (pdev->dev.of_node, child) { +if (!of_device_is_available (child)) +continue ; + pcie->nports++; + } + + pcie->ports =devm_kzalloc (&pdev->dev, pcie->nports * +sizeof (struct mvebu_pcie_port ), +GFP_KERNEL ); +if (!pcie->ports) +return -ENOMEM ; + + i =0 ; +for_each_child_of_node (pdev->dev.of_node, child) { +struct mvebu_pcie_port *port = &pcie->ports[i]; + +if (!of_device_is_available (child)) +continue ; + + port->pcie = pcie; + +if (of_property_read_u32 (child,"marvell,pcie-port" , + &port->port)) { +dev_warn (&pdev->dev, +"ignoring PCIe DT node, missing pcie-port property\n" ); +continue ; + } + +if (of_property_read_u32 (child,"marvell,pcie-lane" , + &port->lane)) + port->lane =0 ; + + port->name =kasprintf (GFP_KERNEL ,"pcie%d.%d" , + port->port, port->lane); + + port->devfn =of_pci_get_devfn (child); +if (port->devfn <0 ) +continue ; + + port->base =mvebu_pcie_map_registers (pdev, child, port); +if (!port->base) { +dev_err (&pdev->dev,"PCIe%d.%d: cannot map registers\n" , + port->port, port->lane); +continue ; + } + +if (mvebu_pcie_link_up (port)) { + port->haslink =1 ; +dev_info (&pdev->dev,"PCIe%d.%d: link up\n" , + port->port, port->lane); + }else { + port->haslink =0 ; +dev_info (&pdev->dev,"PCIe%d.%d: link down\n" , + port->port, port->lane); + } + + port->clk =of_clk_get_by_name (child,NULL ); +if (!port->clk) { +dev_err (&pdev->dev,"PCIe%d.%d: cannot get clock\n" , + port->port, port->lane); +iounmap (port->base); + port->haslink =0 ; +continue ; + } + + port->dn = child; + +clk_prepare_enable (port->clk); +spin_lock_init (&port->conf_lock); + +mvebu_sw_pci_bridge_init (port); + + i++; + } + +mvebu_pcie_enable (pcie); + +return 0 ; +} + +static const struct of_device_id mvebu_pcie_of_match_table[] = { + { .compatible ="marvell,armada-xp-pcie" , }, + { .compatible ="marvell,armada-370-pcie" , }, + {}, +}; +MODULE_DEVICE_TABLE (of, mvebu_pcie_of_match_table); +
drivers/pci/host/pci-mvebu.c line 869
Quoted 10 lines
drivers/pci/host/pci-mvebu.c new file +10
-0+static struct platform_driver mvebu_pcie_driver = { + .driver = { + .owner =THIS_MODULE , + .name ="mvebu-pcie" , + .of_match_table = +of_match_ptr (mvebu_pcie_of_match_table), + }, +}; + +static int mvebu_pcie_init (void )
Building this showed a warning here. It seems you forgot to mark this one as __init.
Signature · 3 lines
Ezequiel Garc?a, Free Electrons Embedded Linux, Kernel and Android Engineering http://free-electrons.com
PATCH v9 7/9 pci: PCIe driver for Marvell Armada 370/XP systems
Quoted 142 lines · Ezequiel Garcia
On Wed, May 15, 2013 at 03:25:21PM +0200, Thomas Petazzoni wrote:
[..]Quoted 140 lines
drivers/pci/host/pci-mvebu.c new file +140
-0+ +static int __init mvebu_pcie_probe (struct platform_device *pdev) +{ +struct mvebu_pcie *pcie; +struct device_node *np = pdev->dev.of_node; +struct of_pci_range range; +struct of_pci_range_parser parser; +struct device_node *child; +int i, ret; + + pcie =devm_kzalloc (&pdev->dev,sizeof (struct mvebu_pcie ), +GFP_KERNEL ); +if (!pcie) +return -ENOMEM ; + + pcie->pdev = pdev; + +if (of_pci_range_parser_init (&parser, np)) +return -EINVAL ; + +/* Get the I/O and memory ranges from DT */ +for_each_of_pci_range (&parser, &range) { +unsigned long restype = range.flags &IORESOURCE_TYPE_BITS ; +if (restype ==IORESOURCE_IO ) { +of_pci_range_to_resource (&range, np, &pcie->io); +of_pci_range_to_resource (&range, np, &pcie->realio); + pcie->io.name ="I/O" ; + pcie->realio.start =max_t (resource_size_t, +PCIBIOS_MIN_IO , + range.pci_addr); + pcie->realio.end =min_t (resource_size_t, +IO_SPACE_LIMIT , + range.pci_addr + range.size); + } +if (restype ==IORESOURCE_MEM ) { +of_pci_range_to_resource (&range, np, &pcie->mem); + pcie->mem.name ="MEM" ; + } + } + +/* Get the bus range */ + ret =of_pci_parse_bus_range (np, &pcie->busn); +if (ret) { +dev_err (&pdev->dev,"failed to parse bus-range property: %d\n" , + ret); +return ret; + } + +for_each_child_of_node (pdev->dev.of_node, child) { +if (!of_device_is_available (child)) +continue ; + pcie->nports++; + } + + pcie->ports =devm_kzalloc (&pdev->dev, pcie->nports * +sizeof (struct mvebu_pcie_port ), +GFP_KERNEL ); +if (!pcie->ports) +return -ENOMEM ; + + i =0 ; +for_each_child_of_node (pdev->dev.of_node, child) { +struct mvebu_pcie_port *port = &pcie->ports[i]; + +if (!of_device_is_available (child)) +continue ; + + port->pcie = pcie; + +if (of_property_read_u32 (child,"marvell,pcie-port" , + &port->port)) { +dev_warn (&pdev->dev, +"ignoring PCIe DT node, missing pcie-port property\n" ); +continue ; + } + +if (of_property_read_u32 (child,"marvell,pcie-lane" , + &port->lane)) + port->lane =0 ; + + port->name =kasprintf (GFP_KERNEL ,"pcie%d.%d" , + port->port, port->lane); + + port->devfn =of_pci_get_devfn (child); +if (port->devfn <0 ) +continue ; + + port->base =mvebu_pcie_map_registers (pdev, child, port); +if (!port->base) { +dev_err (&pdev->dev,"PCIe%d.%d: cannot map registers\n" , + port->port, port->lane); +continue ; + } + +if (mvebu_pcie_link_up (port)) { + port->haslink =1 ; +dev_info (&pdev->dev,"PCIe%d.%d: link up\n" , + port->port, port->lane); + }else { + port->haslink =0 ; +dev_info (&pdev->dev,"PCIe%d.%d: link down\n" , + port->port, port->lane); + } + + port->clk =of_clk_get_by_name (child,NULL ); +if (!port->clk) { +dev_err (&pdev->dev,"PCIe%d.%d: cannot get clock\n" , + port->port, port->lane); +iounmap (port->base); + port->haslink =0 ; +continue ; + } + + port->dn = child; + +clk_prepare_enable (port->clk); +spin_lock_init (&port->conf_lock); + +mvebu_sw_pci_bridge_init (port); + + i++; + } + +mvebu_pcie_enable (pcie); + +return 0 ; +} + +static const struct of_device_id mvebu_pcie_of_match_table[] = { + { .compatible ="marvell,armada-xp-pcie" , }, + { .compatible ="marvell,armada-370-pcie" , }, + {}, +}; +MODULE_DEVICE_TABLE (of, mvebu_pcie_of_match_table); + +static struct platform_driver mvebu_pcie_driver = { + .driver = { + .owner =THIS_MODULE , + .name ="mvebu-pcie" , + .of_match_table =
Quoted 8 lines
drivers/pci/host/pci-mvebu.c line 869
Quoted 5 lines
drivers/pci/host/pci-mvebu.c new file +5
-0+ of_match_ptr(mvebu_pcie_of_match_table), + }, +}; + +static int mvebu_pcie_init (void )Building this showed a warning here. It seems you forgot to mark this one as
__init.
Thomas, I'll fix this up when I pull this in, no need to resend. :)
thx,
Jason.
PATCH v9 7/9 pci: PCIe driver for Marvell Armada 370/XP systems
Dear Jason Cooper,
Quoted 6 lines · Jason Cooper
Quoted 4 lines
Quoted 1 line
+static int
mvebu_pcie_init(void)Building this showed a warning here. It seems you forgot to mark this one as
__init.Thomas, I'll fix this up when I pull this in, no need to resend. :)
I'll resend, because beyond this function pointed by Ezequiel, there are two other functions that can be marked __init. The one pointed by Ezequiel is important because it causes a section mismatch when !CONFIG_MODULES, because in this case platform_driver_probe() is __init (and this explains what I wasn't seeing the warning, since I'm building CONFIG_MODULES=y). The two other functions are more cosmetic, but good to have as well.
It would already been sent if git hadn't decided to do a 'git gc' right after my rebase. It's been gc-ing for quite some time now...
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v9 7/9 pci: PCIe driver for Marvell Armada 370/XP systems
Quoted 19 lines · Thomas Petazzoni
Dear Jason Cooper,
Quoted 6 lines · Jason Cooper
Quoted 4 lines
Quoted 1 line
+static int
mvebu_pcie_init(void)Building this showed a warning here. It seems you forgot to mark this one as
__init.Thomas, I'll fix this up when I pull this in, no need to resend. :)
I'll resend, because beyond this function pointed by Ezequiel, there are two other functions that can be marked
__init. The one pointed by Ezequiel is important because it causes a section mismatch when !CONFIG_MODULES, because in this caseplatform_driver_probe()is__init(and this explains what I wasn't seeing the warning, since I'm buildingCONFIG_MODULES=y). The two other functions are more cosmetic, but good to have as well.
Quoted 2 lines
It would already been sent if git hadn't decided to do a 'git gc' right after my rebase. It's been gc-ing for quite some time now...
Dear boss,
I am in desperate need of a 500GB SSD on which to do my kernel work.
Thanks,
Kranky Kernel Developer
hehehe...
I'll pull in once you send.
thx,
Jason.
PATCH v9 7/9 pci: PCIe driver for Marvell Armada 370/XP systems
Dear Jason Cooper,
Quoted 18 lines · Jason Cooper
Quoted 13 lines
Quoted 4 lines
Quoted 2 lines
Building this showed a warning here. It seems you forgot to mark this one as
__init.Thomas, I'll fix this up when I pull this in, no need to resend. :)
I'll resend, because beyond this function pointed by Ezequiel, there are two other functions that can be marked
__init. The one pointed by Ezequiel is important because it causes a section mismatch when !CONFIG_MODULES, because in this caseplatform_driver_probe()is__init(and this explains what I wasn't seeing the warning, since I'm buildingCONFIG_MODULES=y). The two other functions are more cosmetic, but good to have as well.Quoted 2 lines
It would already been sent if git hadn't decided to do a 'git gc' right after my rebase. It's been gc-ing for quite some time now...
Dear boss,
Quoted 7 lines
I am in desperate need of a 500GB SSD on which to do my kernel work.
Thanks,
Kranky Kernel Developer
hehehe...
Adding boss in the Cc list :-)
Thanks!
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v9 7/9 pci: PCIe driver for Marvell Armada 370/XP systems
Quoted 24 lines · Thomas Petazzoni
Dear Jason Cooper,
Quoted 20 lines · Jason Cooper
Quoted 13 lines
Quoted 4 lines
Quoted 2 lines
Building this showed a warning here. It seems you forgot to mark this one as
__init.Thomas, I'll fix this up when I pull this in, no need to resend. :)
I'll resend, because beyond this function pointed by Ezequiel, there are two other functions that can be marked
__init. The one pointed by Ezequiel is important because it causes a section mismatch when !CONFIG_MODULES, because in this caseplatform_driver_probe()is__init(and this explains what I wasn't seeing the warning, since I'm buildingCONFIG_MODULES=y). The two other functions are more cosmetic, but good to have as well.Quoted 2 lines
It would already been sent if git hadn't decided to do a 'git gc' right after my rebase. It's been gc-ing for quite some time now...
Dear boss,
I am in desperate need of a 500GB SSD on which to do my kernel work.
Quoted 7 lines
Quoted 5 lines
Thanks,
Kranky Kernel Developer
hehehe...
Adding boss in the Cc list :-)
Hey, whatever works for you. Good luck!
thx,
Jason.
PATCH v9 7/9 pci: PCIe driver for Marvell Armada 370/XP systems
Quoted 27 lines · Jason Cooper
Quoted 26 lines · Thomas Petazzoni
Dear Jason Cooper,
Quoted 22 lines · Jason Cooper
Quoted 13 lines
Quoted 4 lines
Quoted 2 lines
Building this showed a warning here. It seems you forgot to mark this one as
__init.Thomas, I'll fix this up when I pull this in, no need to resend. :)
I'll resend, because beyond this function pointed by Ezequiel, there are two other functions that can be marked
__init. The one pointed by Ezequiel is important because it causes a section mismatch when !CONFIG_MODULES, because in this caseplatform_driver_probe()is__init(and this explains what I wasn't seeing the warning, since I'm buildingCONFIG_MODULES=y). The two other functions are more cosmetic, but good to have as well.Quoted 2 lines
It would already been sent if git hadn't decided to do a 'git gc' right after my rebase. It's been gc-ing for quite some time now...
Dear boss,
I am in desperate need of a 500GB SSD on which to do my kernel work.
Thanks,
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Kranky Kernel Developer
hehehe...
Adding boss in the Cc list :-)
Hey, whatever works for you. Good luck!
Ok, you motivated me, I just ordered this one:
http://www.amazon.com/Crucial-512GB-2-5-Inch-9-5mm-CT512M4SSD2/dp/B004W2JL3Y
I'd've gone with Intel, but it ships in 2 to 5 weeks, and it costs 20% more with comparable capacity.
thx,
Jason.
PATCH v9 8/9 arm: mvebu: PCIe support is now available on mvebu
In reply to Thomas PetazzoniNow that the PCIe driver for mvebu has been integrated and all its relevant dependencies, we can mark the ARCH_MVEBU platform has MIGHT_HAVE_PCI, which allows to select the PCI bus support if needed.
--- arch/arm/mach-mvebu/Kconfig | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/mach-mvebu/Kconfig +2 -0
@@ -15,6 +15,8 @@ config ARCH_MVEBU select MVEBU_CLK_GATING select MVEBU_MBUS select ZONE_DMA if ARM_LPAE + select MIGHT_HAVE_PCI + select PCI_QUIRKS if PCI if ARCH_MVEBU
Signature · 1 line
1.7.9.5
PATCH v9 9/9 arm: mvebu: update defconfig with PCI and USB support
In reply to Thomas PetazzoniNow that we have the necessary drivers and Device Tree informations to support PCIe on Armada 370 and Armada XP, enable the CONFIG_PCI option.
Also, since the Armada 370 Mirabox has a built-in USB XHCI controller connected on the PCIe bus, enable the corresponding options as well.
--- arch/arm/configs/mvebu_defconfig | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/configs/mvebu_defconfig +3 -0
@@ -13,6 +13,8 @@ CONFIG_MACH_ARMADA_370=y CONFIG_MACH_ARMADA_XP=y # CONFIG_CACHE_L2X0 is not set # CONFIG_SWP_EMULATE is not set +CONFIG_PCI=y +CONFIG_PCI_MVEBU=y CONFIG_SMP=y CONFIG_AEABI=y CONFIG_HIGHMEM=y
@@ -60,6 +62,7 @@ CONFIG_USB_SUPPORT=y CONFIG_USB=y CONFIG_USB_EHCI_HCD=y CONFIG_USB_EHCI_ROOT_HUB_TT=y +CONFIG_USB_XHCI_HCD=y CONFIG_MMC=y CONFIG_MMC_MVSDIO=y CONFIG_NEW_LEDS=y
Signature · 1 line
1.7.9.5