PCI: Add support to the Cadence PCIe controller
Subsystems (5)
v6 cover PCI: Add support to the Cadence PCIe controller
Hi all,
this series of patches adds support to the Cadence PCIe controller. It was tested on a ARM64 platform emulated by a Palladium running the pci-next kernel.
The host mode was tested with some PCIe devices connected to the Palladium through a speed-bridge. Some of those devices were a USB host controller and a SATA controller. The PCIe host controller was also tested with a second controller configured in endpoint mode and connected back to back to the first controller.
The EndPoint Controller (EPC) driver was tested with 2 PCI functions, both handled by the pci-epf-test driver, using the pcitest userspace program. I used the "-D" optional command line parameter to select the proper PCI function.
For linux-pci/master, I applied this series on top of Kishon's patch ("PCI: endpoint: Use EPC's device in dma_alloc_coherent/dma_free_coherent") otherwise dma_alloc_coherent() fails when called by pci_epf_alloc_space().
Best regards,
Cyrille
ChangeLog
v5 -> v6:
- rebase on linux-pci/master (v4.15-rc4) + Kishon's patch from linux-pci/next:
"PCI: endpoint: Use EPC's device in dma_alloc_coherent()/dma_free_coherent()"
- all patches unchanged
v4 -> v5:
- rebase on today's (20180128) linux-pci/next
- add again the endpoint driver
- Patch 7:
move host driver from drivers/pci/cadence into drivers/pci/host and remove all references to the endpoint mode, as requested by Lorenzo. The host driver will be moved back into drivers/pci/cadence by Patch 11
- Patch 8:
fix comparison of func_no to BAR5: compare to epc->max_functions
- Patch 9:
add new patch to fix support of PCI multi-function devices
- Patch 10:
change the 'cdns,max-outbound-regions' from optional to mandatory as requested by Kishon.
- Patch 11:
take Kishon's comments into account as much as I could.
- Other patches: unchanged
v3 -> v4:
- split patch 3 from v3 into patches 3 and 4.
- remove unused cdns_pcie_reset_outbound_region() from old patch 6 (new patch 7).
- other patches are unchanged.
v2 -> v3:
- rebase on today's linux-pci/next (20180110)
patch1:
- rework the commit message of patch 1 and add two new comments on why endpoint library users must be linked after the endpoint library itself and why the dwc rule uses obj-y instead of obj-$(CONFIG_PCIE_CONFIG_DW).
- update patch 1 to add missing ifdef CONFIG_PCI / endif in drivers/pci/dwc/Makefile around the obj-$(CONFIG_ARM64) += pcie-hisi.o rule, like for the other obj-$(CONFIG_ARM64) rules in drivers/pci/host/Makefile.
patch2: unchanged
patch3:
- update patch 3 so the bridge hooks/members initialization is left to the host bridges probe routines.
patch4: unchanged
patch5:
- collect 'Reviewed-by' tag from Rob Herring for the DT bindings.
patch6:
- remove explanation in the commit message on why obj-$(CONFIG_PCIE_CANDENCE) is placed after obj-$(CONFIG_PCI_ENDPOINT) in drivers/pci/Makefile since a comment on it has been added into patch1.
- remove menuconfig PCI_CADENCE in drivers/pci/cadence/Kconfig to match drivers/pci/dwc/Kconfig.
- adapt patch6 to the changes done in patch3 for the pci_host_probe() function.
v1 -> v2:
- add new properties in the device-tree bindings: 'cdns,max-outbound-regions' and 'cdns,no-bar-match-nbits'.
- add a new patch to regroup all makefile rules in drivers/pci/Makefile, hence cleaning drivers/Makefile up.
- change the license text to use the recommanded format:
// SPDX-License-Identifier: GPL-2.0
- add a new patch updating the API of the EPC library to add support to multi-function devices.
- add a 2 new patches to share more common code between host controller drivers
- remove some useless tests
- add more comments in both drivers.
- fix DT bindings examples
- remove useless init of the primary, secondary and sub-ordinate bus numbers in the PCI configuration space of the root port.
- remove cdns_pcie_ep_stop() function and rework cdns_pcie_ep_start() function
Cyrille Pitchen (10):
PCI: Regroup all PCI related entries into drivers/pci/Makefile
PCI: OF: Add generic function to parse and allocate PCI resources
PCI: generic: fix missing call of pci_free_resource_list()
PCI: Add generic function to probe PCI host controllers
PCI: Add vendor ID for Cadence
PCI: cadence: Add host driver for Cadence PCIe controller
PCI: endpoint: Add the function number as argument to EPC ops
PCI: endpoint: Fix EPF device name to support multi-function devices
dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe endpoint
controller
PCI: cadence: Add EndPoint Controller driver for Cadence PCIe
controller
Scott Telford (1):
dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe host
controller
.../devicetree/bindings/pci/cdns,cdns-pcie-ep.txt | 22 + .../bindings/pci/cdns,cdns-pcie-host.txt | 60 +++ MAINTAINERS | 7 + drivers/Makefile | 5 +- drivers/pci/Kconfig | 2 + drivers/pci/Makefile | 14 +- drivers/pci/cadence/Kconfig | 27 + drivers/pci/cadence/Makefile | 4 + drivers/pci/cadence/pcie-cadence-ep.c | 542 +++++++++++++++++++++ drivers/pci/cadence/pcie-cadence-host.c | 336 +++++++++++++ drivers/pci/cadence/pcie-cadence.c | 126 +++++ drivers/pci/cadence/pcie-cadence.h | 311 ++++++++++++ drivers/pci/dwc/Makefile | 2 + drivers/pci/dwc/pcie-designware-ep.c | 20 +- drivers/pci/endpoint/functions/pci-epf-test.c | 41 +- drivers/pci/endpoint/pci-ep-cfs.c | 46 +- drivers/pci/endpoint/pci-epc-core.c | 62 ++- drivers/pci/host/Makefile | 2 + drivers/pci/host/pci-host-common.c | 72 +-- drivers/pci/of.c | 51 ++ drivers/pci/probe.c | 33 ++ include/linux/pci-epc.h | 43 +- include/linux/pci.h | 10 + include/linux/pci_ids.h | 2 + 24 files changed, 1693 insertions(+), 147 deletions(-) create mode 100644 Documentation/devicetree/bindings/pci/cdns,cdns-pcie-ep.txt create mode 100644 Documentation/devicetree/bindings/pci/cdns,cdns-pcie-host.txt create mode 100644 drivers/pci/cadence/Kconfig create mode 100644 drivers/pci/cadence/Makefile create mode 100644 drivers/pci/cadence/pcie-cadence-ep.c create mode 100644 drivers/pci/cadence/pcie-cadence-host.c create mode 100644 drivers/pci/cadence/pcie-cadence.c create mode 100644 drivers/pci/cadence/pcie-cadence.h
Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v6 1/11 PCI: Regroup all PCI related entries into drivers/pci/Makefile
Clean up drivers/Makefile by moving the pci/endpoint and pci/dwc entries from drivers/Makefile into drivers/pci/Makefile.
Since we don't want to introduce any dependency between CONFIG_PCI and CONFIG_PCI_ENDPOINT, we now always execute drivers/pci/Makefile.
Hence all Makefiles in drivers/pci/ were updated accordingly so no file is compiled when CONFIG_PCI is not defined.
Also, we add a comment to reinforce that EPC and EPF libraries must be initialized before their users. Hence built-in EPC drivers, such as those of Designware, are linked after the endpoint core libraries.
Finally, we add another comment to explain why obj-y has been chosen instead of obj-$(CONFIG_PCIE_DW) to parse the dwc/ sub-folder.
--- drivers/Makefile | 5 +---- drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 13 ++++++++++--- drivers/pci/dwc/Makefile | 2 ++ drivers/pci/host/Makefile | 2 ++ 5 files changed, 16 insertions(+), 7 deletions(-)
drivers/Makefile +1 -4
@@ -16,10 +16,7 @@ obj-$(CONFIG_PINCTRL) += pinctrl/ obj-$(CONFIG_GPIOLIB) += gpio/ obj-y += pwm/ -obj-$(CONFIG_PCI) += pci/ -obj-$(CONFIG_PCI_ENDPOINT) += pci/endpoint/ -# PCI dwc controller drivers -obj-y += pci/dwc/ +obj-y += pci/ obj-$(CONFIG_PARISC) += parisc/ obj-$(CONFIG_RAPIDIO) += rapidio/
drivers/pci/Kconfig +1 -0
@@ -125,6 +125,7 @@ config PCI_PASID config PCI_LABEL def_bool y if (DMI || ACPI) + depends on PCI select NLS config PCI_HYPERV
drivers/pci/Makefile +10 -3
@@ -3,12 +3,15 @@ # Makefile for the PCI bus specific drivers. # -obj-y += access.o bus.o probe.o host-bridge.o remove.o pci.o \ +obj-$(CONFIG_PCI) += access.o bus.o probe.o host-bridge.o remove.o pci.o \ pci-driver.o search.o pci-sysfs.o rom.o setup-res.o \ irq.o vpd.o setup-bus.o vc.o mmap.o setup-irq.o +ifdef CONFIG_PCI obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_SYSFS) += slot.o +obj-$(CONFIG_OF) += of.o +endif obj-$(CONFIG_PCI_QUIRKS) += quirks.o
@@ -44,10 +47,14 @@ obj-$(CONFIG_PCI_ECAM) += ecam.o 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/ obj-y += switch/ + +obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ + +# Endpoint library must be initialized before its users +# pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW +obj-y += dwc/
drivers/pci/dwc/Makefile +2 -0
@@ -27,4 +27,6 @@ obj-$(CONFIG_PCIE_HISI_STB) += pcie-histb.o # ARM64 and use internal ifdefs to only build the pieces we need # depending on whether ACPI, the DT driver, or both are enabled. +ifdef CONFIG_PCI obj-$(CONFIG_ARM64) += pcie-hisi.o +endif
drivers/pci/host/Makefile +2 -0
@@ -34,6 +34,8 @@ obj-$(CONFIG_VMD) += vmd.o # ARM64 and use internal ifdefs to only build the pieces we need # depending on whether ACPI, the DT driver, or both are enabled. +ifdef CONFIG_PCI obj-$(CONFIG_ARM64) += pci-thunder-ecam.o obj-$(CONFIG_ARM64) += pci-thunder-pem.o obj-$(CONFIG_ARM64) += pci-xgene.o +endif
Signature · 1 line
2.11.0
PATCH v6 2/11 PCI: OF: Add generic function to parse and allocate PCI resources
In reply to Cyrille PitchenThe patch moves the gen_pci_parse_request_of_pci_ranges() function from drivers/pci/host/pci-host-common.c into drivers/pci/of.c to easily share common source code between PCI host drivers.
--- drivers/pci/host/pci-host-common.c | 49 ++---------------------------------- drivers/pci/of.c | 51 ++++++++++++++++++++++++++++++++++++++ include/linux/pci.h | 9 +++++++ 3 files changed, 62 insertions(+), 47 deletions(-)
drivers/pci/host/pci-host-common.c +2 -47
@@ -24,50 +24,6 @@#include <linux/pci-ecam.h> #include <linux/platform_device.h> -static int gen_pci_parse_request_of_pci_ranges (struct device *dev, -struct list_head *resources,struct resource **bus_range) -{ -int err, res_valid =0 ; -struct device_node *np = dev->of_node; -resource_size_t iobase; -struct resource_entry *win, *tmp; - - err =of_pci_get_host_bridge_resources (np,0 ,0xff , resources, &iobase); -if (err) -return err; - - err =devm_request_pci_bus_resources (dev, resources); -if (err) -return err; - -resource_list_for_each_entry_safe (win, tmp, resources) { -struct resource *res = win->res; - -switch (resource_type (res)) { -case IORESOURCE_IO : - err =pci_remap_iospace (res, iobase); -if (err) { -dev_warn (dev,"error %d: failed to map resource %pR\n" , - err, res); -resource_list_destroy_entry (win); - } -break ; -case IORESOURCE_MEM : - res_valid |= !(res->flags &IORESOURCE_PREFETCH ); -break ; -case IORESOURCE_BUS : - *bus_range = res; -break ; - } - } - -if (res_valid) -return 0 ; - -dev_err (dev,"non-prefetchable memory resource required\n" ); -return -EINVAL ; -} -static void gen_pci_unmap_cfg (void *ptr) {pci_ecam_free ((struct pci_config_window *)ptr);
@@ -82,9 +38,9 @@ static struct pci_config_window *gen_pci_init(struct device *dev,struct pci_config_window *cfg;/* Parse our PCI ranges and request their resources */ - err =gen_pci_parse_request_of_pci_ranges (dev, resources, &bus_range); + err =pci_parse_request_of_pci_ranges (dev, resources, &bus_range);if (err) - goto err_out; +return ERR_PTR (err); err =of_address_to_resource (dev->of_node,0 , &cfgres);if (err) {
@@ -135,7 +91,6 @@ int pci_host_common_probe(struct platform_device *pdev,of_pci_check_probe_only ();/* Parse and map our Configuration Space windows */ -INIT_LIST_HEAD (&resources); cfg =gen_pci_init (dev, &resources, ops);if (IS_ERR (cfg))return PTR_ERR (cfg);
drivers/pci/of.c +51 -0
54 lines not on this page · raw message
include/linux/pci.h +9 -0
@@ -2182,6 +2182,9 @@ void pci_release_of_node(struct pci_dev *dev);void pci_set_bus_of_node (struct pci_bus *bus);void pci_release_bus_of_node (struct pci_bus *bus);struct irq_domain *pci_host_bridge_of_msi_domain (struct pci_bus *bus); +int pci_parse_request_of_pci_ranges (struct device *dev, +struct list_head *resources, +struct resource **bus_range);/* Arch may override this (weak) */ struct device_node *pcibios_get_phb_of_node (struct pci_bus *bus);
@@ -2206,6 +2209,12 @@ static inline struct device_node * pci_device_to_OF_node(const struct pci_dev *pdev) { return NULL; }static inline struct irq_domain *pci_host_bridge_of_msi_domain (struct pci_bus *bus) {return NULL ; } +static inline int pci_parse_request_of_pci_ranges (struct device *dev, +struct list_head *resources, +struct resource **bus_range) +{ +return -EINVAL ; +}#endif /* CONFIG_OF */ #ifdef CONFIG_ACPI
Signature · 1 line
2.11.0
PATCH v6 3/11 PCI: generic: fix missing call of pci_free_resource_list()
In reply to Cyrille PitchenCall pci_free_resource_list() from pci_host_common_probe() when probing fails, as done inside gen_pci_init() when this later function fails.
--- drivers/pci/host/pci-host-common.c | 1 + 1 file changed, 1 insertion(+)
drivers/pci/host/pci-host-common.c +1 -0
@@ -110,6 +110,7 @@ int pci_host_common_probe(struct platform_device *pdev, ret =pci_scan_root_bus_bridge (bridge);if (ret <0 ) {dev_err (dev,"Scanning root bridge failed" ); +pci_free_resource_list (&resources);return ret; }
Signature · 1 line
2.11.0
PATCH v6 4/11 PCI: Add generic function to probe PCI host controllers
In reply to Cyrille PitchenThis patchs moves generic source code from drivers/pci/host/pci-host-common.c into drivers/pci/probe.c.
Indeed the extracted lines of code were duplicated by many host controller drivers. Regrouping them into a generic function gives a change to properly share this code without introducing a useless dependency to PCI_HOST_COMMON, which selects PCI_ECAM when not needed by most host controller drivers.
--- drivers/pci/host/pci-host-common.c | 22 +--------------------- drivers/pci/probe.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 3 files changed, 35 insertions(+), 21 deletions(-)
drivers/pci/host/pci-host-common.c +1 -21
@@ -72,7 +72,6 @@ int pci_host_common_probe(struct platform_device *pdev,const char *type;struct device *dev = &pdev->dev;struct device_node *np = dev->of_node; -struct pci_bus *bus, *child;struct pci_host_bridge *bridge;struct pci_config_window *cfg;struct list_head resources;
@@ -107,30 +106,11 @@ int pci_host_common_probe(struct platform_device *pdev, bridge->map_irq = of_irq_parse_and_map_pci; bridge->swizzle_irq = pci_common_swizzle; - ret =pci_scan_root_bus_bridge (bridge); + ret =pci_host_probe (bridge);if (ret <0 ) { -dev_err (dev,"Scanning root bridge failed" );pci_free_resource_list (&resources);return ret; } - bus = bridge->bus; - -/* -* We insert PCI resources into the iomem_resource and -* ioport_resource trees in either pci_bus_claim_resources() -* or pci_bus_assign_resources(). -*/ -if (pci_has_flag (PCI_PROBE_ONLY )) { -pci_bus_claim_resources (bus); - }else { -pci_bus_size_bridges (bus); -pci_bus_assign_resources (bus); - -list_for_each_entry (child, &bus->children, node) -pcie_bus_configure_settings (child); - } - -pci_bus_add_devices (bus);return 0 ; }
drivers/pci/probe.c +33 -0
@@ -2620,6 +2620,39 @@ struct pci_bus *pci_create_root_bus(struct device *parent, int bus, }EXPORT_SYMBOL_GPL (pci_create_root_bus); +int pci_host_probe (struct pci_host_bridge *bridge) +{ +struct pci_bus *bus, *child; +int ret; + + ret =pci_scan_root_bus_bridge (bridge); +if (ret <0 ) { +dev_err (bridge->dev.parent,"Scanning root bridge failed" ); +return ret; + } + + bus = bridge->bus; + +/* +* We insert PCI resources into the iomem_resource and +* ioport_resource trees in either pci_bus_claim_resources() +* or pci_bus_assign_resources(). +*/ +if (pci_has_flag (PCI_PROBE_ONLY )) { +pci_bus_claim_resources (bus); + }else { +pci_bus_size_bridges (bus); +pci_bus_assign_resources (bus); + +list_for_each_entry (child, &bus->children, node) +pcie_bus_configure_settings (child); + } + +pci_bus_add_devices (bus); +return 0 ; +} +EXPORT_SYMBOL_GPL (pci_host_probe); +int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int bus_max) {struct resource *res = &b->busn_res;
include/linux/pci.h +1 -0
@@ -887,6 +887,7 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, void *sysdata);struct pci_bus *pci_create_root_bus (struct device *parent,int bus,struct pci_ops *ops,void *sysdata,struct list_head *resources); +int pci_host_probe (struct pci_host_bridge *bridge);int pci_bus_insert_busn_res (struct pci_bus *b,int bus,int busmax);int pci_bus_update_busn_res_end (struct pci_bus *b,int busmax);void pci_bus_release_busn_res (struct pci_bus *b);
Signature · 1 line
2.11.0
PATCH v6 5/11 PCI: Add vendor ID for Cadence
In reply to Cyrille PitchenThis patch adds a new PCI vendor ID for Cadence.
--- include/linux/pci_ids.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/pci_ids.h +2 -0
@@ -2381,6 +2381,8 @@#define PCI_VENDOR_ID_LENOVO 0x17aa +#define PCI_VENDOR_ID_CDNS 0x17cd +#define PCI_VENDOR_ID_ARECA 0x17d3#define PCI_DEVICE_ID_ARECA_1110 0x1110#define PCI_DEVICE_ID_ARECA_1120 0x1120
Signature · 1 line
2.11.0
PATCH v6 6/11 dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe host controller
In reply to Cyrille PitchenFrom: Scott Telford <[email protected]>
This patch adds documentation for the DT bindings of the Cadence PCIe controller when configured in host (Root Complex) mode.
--- .../bindings/pci/cdns,cdns-pcie-host.txt | 60 ++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/cdns,cdns-pcie-host.txt
Documentation/devicetree/bindings/pci/cdns,cdns-pcie-host.txt new file +60 -0
@@ -0,0 +1,60 @@ +* Cadence PCIe host controller + +This PCIe controller inherits the base properties defined in +host-generic-pci.txt. + +Required properties: +- compatible: Should contain "cdns,cdns-pcie-host" to identify the IP used. +- reg: Should contain the controller register base address, PCIe configuration + window base address, and AXI interface region base address respectively. +- reg-names: Must be "reg", "cfg" and "mem" respectively. +- #address-cells: Set to <3> +- #size-cells: Set to <2> +- device_type: Set to "pci" +- ranges: Ranges for the PCI memory and I/O regions +- #interrupt-cells: Set to <1> +- interrupt-map-mask and interrupt-map: Standard PCI properties to define the + mapping of the PCIe interface to interrupt numbers. + +Optional properties: +- cdns,max-outbound-regions: Set to maximum number of outbound regions + (default 32) +- cdns,no-bar-match-nbits: Set into the no BAR match register to configure the + number of least significant bits kept during inbound (PCIe -> AXI) address + translations (default 32) +- vendor-id: The PCI vendor ID (16 bits, default is design dependent) +- device-id: The PCI device ID (16 bits, default is design dependent) + +Example: + +pcie@fb000000 { + compatible = "cdns,cdns-pcie-host"; + device_type = "pci"; + #address-cells = <3>; + #size-cells = <2>; + bus-range = <0x0 0xff>; + linux,pci-domain = <0>; + cdns,max-outbound-regions = <16>; + cdns,no-bar-match-nbits = <32>; + vendor-id = /bits/ 16 <0x17cd>; + device-id = /bits/ 16 <0x0200>; + + reg = <0x0 0xfb000000 0x0 0x01000000>, + <0x0 0x41000000 0x0 0x00001000>, + <0x0 0x40000000 0x0 0x04000000>; + reg-names = "reg", "cfg", "mem"; + + ranges = <0x02000000 0x0 0x42000000 0x0 0x42000000 0x0 0x1000000>, + <0x01000000 0x0 0x43000000 0x0 0x43000000 0x0 0x0010000>; + + #interrupt-cells = <0x1>; + + interrupt-map = <0x0 0x0 0x0 0x1 &gic 0x0 0x0 0x0 14 0x1 + 0x0 0x0 0x0 0x2 &gic 0x0 0x0 0x0 15 0x1 + 0x0 0x0 0x0 0x3 &gic 0x0 0x0 0x0 16 0x1 + 0x0 0x0 0x0 0x4 &gic 0x0 0x0 0x0 17 0x1>; + + interrupt-map-mask = <0x0 0x0 0x0 0x7>; + + msi-parent = <&its_pci>; +};
Signature · 1 line
2.11.0
PATCH v6 7/11 PCI: cadence: Add host driver for Cadence PCIe controller
In reply to Cyrille PitchenThis patch adds support to the Cadence PCIe controller in host mode.
--- MAINTAINERS | 7 + drivers/pci/host/Kconfig | 10 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pcie-cadence-host.c | 397 +++++++++++++++++++++++++++++++++++ drivers/pci/host/pcie-cadence.h | 189 +++++++++++++++++ 5 files changed, 604 insertions(+) create mode 100644 drivers/pci/host/pcie-cadence-host.c create mode 100644 drivers/pci/host/pcie-cadence.h
MAINTAINERS +7 -0
@@ -10402,6 +10402,13 @@ S: Maintained F: Documentation/devicetree/bindings/pci/pci-armada8k.txt F: drivers/pci/dwc/pcie-armada8k.c +PCI DRIVER FOR CADENCE PCIE IP +M: Alan Douglas <[email protected]> +L: [email protected] +S: Maintained +F: Documentation/devicetree/bindings/pci/cdns,*.txt +F: drivers/pci/host/pcie-cadence* + PCI DRIVER FOR FREESCALE LAYERSCAPE M: Minghuan Lian <[email protected]> M: Mingkai Hu <[email protected]>
drivers/pci/host/Kconfig +10 -0
@@ -210,6 +210,16 @@ config PCIE_TANGO_SMP8759 This can lead to data corruption if drivers perform concurrent config and MMIO accesses. +config PCIE_CADENCE_HOST + bool "Cadence PCIe host controller" + depends on OF + depends on PCI + select IRQ_DOMAIN + help + Say Y here if you want to support the Cadence PCIe controller in host + mode. This PCIe controller may be embedded into many different vendors + SoCs. + config VMD depends on PCI_MSI && X86_64 && SRCU tristate "Intel Volume Management Device Driver"
drivers/pci/host/Makefile +1 -0
@@ -22,6 +22,7 @@ obj-$(CONFIG_PCIE_ALTERA_MSI) += pcie-altera-msi.o obj-$(CONFIG_PCIE_ROCKCHIP) += pcie-rockchip.o obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o +obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.o obj-$(CONFIG_VMD) += vmd.o # The following drivers are for devices that use the generic ACPI
drivers/pci/host/pcie-cadence-host.c new file +397 -0
397 lines not on this page · raw message
drivers/pci/host/pcie-cadence.h new file +189 -0
189 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v6 8/11 PCI: endpoint: Add the function number as argument to EPC ops
In reply to Cyrille PitchenThis patch updates the prototype of most handlers from 'struct pci_epc_ops' so the EPC library can now support multi-function devices.
--- drivers/pci/dwc/pcie-designware-ep.c | 20 +++++---- drivers/pci/endpoint/functions/pci-epf-test.c | 41 ++++++++++-------- drivers/pci/endpoint/pci-epc-core.c | 62 ++++++++++++++++----------- include/linux/pci-epc.h | 43 +++++++++++-------- 4 files changed, 96 insertions(+), 70 deletions(-)
drivers/pci/dwc/pcie-designware-ep.c +12 -8
@@ -39,7 +39,7 @@ static void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar)dw_pcie_writel_dbi (pci, reg,0x0 ); } -static int dw_pcie_ep_write_header (struct pci_epc *epc, +static int dw_pcie_ep_write_header (struct pci_epc *epc,u8 func_no,struct pci_epf_header *hdr) {struct dw_pcie_ep *ep =epc_get_drvdata (epc);
@@ -112,7 +112,8 @@ static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, phys_addr_t phys_addr,return 0 ; } -static void dw_pcie_ep_clear_bar (struct pci_epc *epc,enum pci_barno bar) +static void dw_pcie_ep_clear_bar (struct pci_epc *epc,u8 func_no, +enum pci_barno bar) {struct dw_pcie_ep *ep =epc_get_drvdata (epc);struct dw_pcie *pci =to_dw_pcie_from_ep (ep);
@@ -124,7 +125,8 @@ static void dw_pcie_ep_clear_bar(struct pci_epc *epc, enum pci_barno bar)clear_bit (atu_index, &ep->ib_window_map); } -static int dw_pcie_ep_set_bar (struct pci_epc *epc,enum pci_barno bar, +static int dw_pcie_ep_set_bar (struct pci_epc *epc,u8 func_no, +enum pci_barno bar,dma_addr_t bar_phys,size_t size,int flags) {int ret;
@@ -163,7 +165,8 @@ static int dw_pcie_find_index(struct dw_pcie_ep *ep, phys_addr_t addr,return -EINVAL ; } -static void dw_pcie_ep_unmap_addr (struct pci_epc *epc,phys_addr_t addr) +static void dw_pcie_ep_unmap_addr (struct pci_epc *epc,u8 func_no, +phys_addr_t addr) {int ret;u32 atu_index;
@@ -178,7 +181,8 @@ static void dw_pcie_ep_unmap_addr(struct pci_epc *epc, phys_addr_t addr)clear_bit (atu_index, &ep->ob_window_map); } -static int dw_pcie_ep_map_addr (struct pci_epc *epc,phys_addr_t addr, +static int dw_pcie_ep_map_addr (struct pci_epc *epc,u8 func_no, +phys_addr_t addr,u64 pci_addr,size_t size) {int ret;
@@ -194,7 +198,7 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, phys_addr_t addr,return 0 ; } -static int dw_pcie_ep_get_msi (struct pci_epc *epc) +static int dw_pcie_ep_get_msi (struct pci_epc *epc,u8 func_no) {int val;u32 lower_addr;
@@ -214,7 +218,7 @@ static int dw_pcie_ep_get_msi(struct pci_epc *epc)return val; } -static int dw_pcie_ep_set_msi (struct pci_epc *epc,u8 encode_int) +static int dw_pcie_ep_set_msi (struct pci_epc *epc,u8 func_no,u8 encode_int) {int val;struct dw_pcie_ep *ep =epc_get_drvdata (epc);
@@ -226,7 +230,7 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 encode_int)return 0 ; } -static int dw_pcie_ep_raise_irq (struct pci_epc *epc, +static int dw_pcie_ep_raise_irq (struct pci_epc *epc,u8 func_no,enum pci_epc_irq_type type,u8 interrupt_num) {struct dw_pcie_ep *ep =epc_get_drvdata (epc);
drivers/pci/endpoint/functions/pci-epf-test.c +23 -18
135 lines not on this page · raw message
drivers/pci/endpoint/pci-epc-core.c +36 -26
228 lines not on this page · raw message
include/linux/pci-epc.h +25 -18
59 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v6 9/11 PCI: endpoint: Fix EPF device name to support multi-function devices
In reply to Cyrille PitchenFix the pci_epf_make() function so it can now bind many EPF devices to the same EPF driver.
--- drivers/pci/endpoint/pci-ep-cfs.c | 46 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-)
drivers/pci/endpoint/pci-ep-cfs.c +44 -2
@@ -18,18 +18,22 @@*/ #include <linux/module.h> +#include <linux/idr.h> #include <linux/slab.h> #include <linux/pci-epc.h> #include <linux/pci-epf.h> #include <linux/pci-ep-cfs.h> +static DEFINE_IDR (functions_idr); +static DEFINE_MUTEX (functions_mutex);static struct config_group *functions_group;static struct config_group *controllers_group;struct pci_epf_group {struct config_group group;struct pci_epf *epf; +int index; };struct pci_epc_group {
@@ -353,6 +357,9 @@ static void pci_epf_release(struct config_item *item) {struct pci_epf_group *epf_group =to_pci_epf_group (item); +mutex_lock (&functions_mutex); +idr_remove (&functions_idr, epf_group->index); +mutex_unlock (&functions_mutex);pci_epf_destroy (epf_group->epf);kfree (epf_group); }
@@ -372,22 +379,57 @@ static struct config_group *pci_epf_make(struct config_group *group, {struct pci_epf_group *epf_group;struct pci_epf *epf; +char *epf_name; +int index, err; epf_group =kzalloc (sizeof (*epf_group),GFP_KERNEL );if (!epf_group)return ERR_PTR (-ENOMEM ); +mutex_lock (&functions_mutex); + index =idr_alloc (&functions_idr, epf_group,0 ,0 ,GFP_KERNEL ); +mutex_unlock (&functions_mutex); +if (index <0 ) { + err = index; + goto free_group; + } + + epf_group->index = index; +config_group_init_type_name (&epf_group->group, name, &pci_epf_type); - epf =pci_epf_create (group->cg_item.ci_name); + epf_name =kasprintf (GFP_KERNEL ,"%s.%d" , + group->cg_item.ci_name, epf_group->index); +if (!epf_name) { + err = -ENOMEM ; + goto remove_idr; + } + + epf =pci_epf_create (epf_name);if (IS_ERR (epf)) {pr_err ("failed to create endpoint function device\n" ); -return ERR_PTR (-EINVAL ); + err = -EINVAL ; + goto free_name; } epf_group->epf = epf; +kfree (epf_name); +return &epf_group->group; + +free_name: +kfree (epf_name); + +remove_idr: +mutex_lock (&functions_mutex); +idr_remove (&functions_idr, epf_group->index); +mutex_unlock (&functions_mutex); + +free_group: +kfree (epf_group); + +return ERR_PTR (err); }static void pci_epf_drop (struct config_group *group,struct config_item *item)
Signature · 1 line
2.11.0
PATCH v6 10/11 dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe endpoint controller
In reply to Cyrille PitchenThis patch documents the DT bindings for the Cadence PCIe controller when configured in endpoint mode.
--- .../devicetree/bindings/pci/cdns,cdns-pcie-ep.txt | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/cdns,cdns-pcie-ep.txt
Documentation/devicetree/bindings/pci/cdns,cdns-pcie-ep.txt new file +22 -0
@@ -0,0 +1,22 @@ +* Cadence PCIe endpoint controller + +Required properties: +- compatible: Should contain "cdns,cdns-pcie-ep" to identify the IP used. +- reg: Should contain the controller register base address and AXI interface + region base address respectively. +- reg-names: Must be "reg" and "mem" respectively. +- cdns,max-outbound-regions: Set to maximum number of outbound regions + +Optional properties: +- max-functions: Maximum number of functions that can be configured (default 1). + +Example: + +pcie@fc000000 { + compatible = "cdns,cdns-pcie-ep"; + reg = <0x0 0xfc000000 0x0 0x01000000>, + <0x0 0x80000000 0x0 0x40000000>; + reg-names = "reg", "mem"; + cdns,max-outbound-regions = <16>; + max-functions = /bits/ 8 <8>; +};
Signature · 1 line
2.11.0
PATCH v6 11/11 PCI: cadence: Add EndPoint Controller driver for Cadence PCIe controller
In reply to Cyrille PitchenThis patch adds support to the Cadence PCIe controller in endpoint mode.
Since pieces of source code are shared with the host driver (Root Complex mode), we create a new directory under drivers/pci dedicated to the Cadence PCIe controller. The common code is placed into drivers/pci/cadence/pcie-cadence.c and used by both the host and endpoint controller drivers.
---
MAINTAINERS | 2 +-
drivers/pci/Kconfig | 1 +
drivers/pci/Makefile | 1 +
drivers/pci/cadence/Kconfig | 27 ++
drivers/pci/cadence/Makefile | 4 +
drivers/pci/cadence/pcie-cadence-ep.c | 542 ++++++++++++++++++++++
drivers/pci/{host => cadence}/pcie-cadence-host.c | 65 +--
drivers/pci/cadence/pcie-cadence.c | 126 +++++
drivers/pci/{host => cadence}/pcie-cadence.h | 122 +++++
drivers/pci/host/Kconfig | 10 -
drivers/pci/host/Makefile | 1 -
11 files changed, 826 insertions(+), 75 deletions(-)
create mode 100644 drivers/pci/cadence/Kconfig
create mode 100644 drivers/pci/cadence/Makefile
create mode 100644 drivers/pci/cadence/pcie-cadence-ep.c
rename drivers/pci/{host => cadence}/pcie-cadence-host.c (80%)
create mode 100644 drivers/pci/cadence/pcie-cadence.c
rename drivers/pci/{host => cadence}/pcie-cadence.h (63%)MAINTAINERS +1 -1
@@ -10407,7 +10407,7 @@ M: Alan Douglas <[email protected]> L: [email protected] S: Maintained F: Documentation/devicetree/bindings/pci/cdns,*.txt -F: drivers/pci/host/pcie-cadence* +F: drivers/pci/cadence/pcie-cadence* PCI DRIVER FOR FREESCALE LAYERSCAPE M: Minghuan Lian <[email protected]>
drivers/pci/Kconfig +1 -0
@@ -136,6 +136,7 @@ config PCI_HYPERV PCI devices from a PCI backend to support PCI driver domains. source "drivers/pci/hotplug/Kconfig" +source "drivers/pci/cadence/Kconfig" source "drivers/pci/dwc/Kconfig" source "drivers/pci/host/Kconfig" source "drivers/pci/endpoint/Kconfig"
drivers/pci/Makefile +1 -0
@@ -56,5 +56,6 @@ obj-y += switch/ obj-$(CONFIG_PCI_ENDPOINT) += endpoint/ # Endpoint library must be initialized before its users +obj-$(CONFIG_PCIE_CADENCE) += cadence/ # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW obj-y += dwc/
drivers/pci/cadence/Kconfig new file +27 -0
@@ -0,0 +1,27 @@ +menu "Cadence PCIe controllers support" + +config PCIE_CADENCE + bool + +config PCIE_CADENCE_HOST + bool "Cadence PCIe host controller" + depends on OF + depends on PCI + select IRQ_DOMAIN + select PCIE_CADENCE + help + Say Y here if you want to support the Cadence PCIe controller in host + mode. This PCIe controller may be embedded into many different vendors + SoCs. + +config PCIE_CADENCE_EP + bool "Cadence PCIe endpoint controller" + depends on OF + depends on PCI_ENDPOINT + select PCIE_CADENCE + help + Say Y here if you want to support the Cadence PCIe controller in + endpoint mode. This PCIe controller may be embedded into many + different vendors SoCs. + +endmenu
drivers/pci/cadence/Makefile new file +4 -0
@@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence.o +obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.o +obj-$(CONFIG_PCIE_CADENCE_EP) += pcie-cadence-ep.o
drivers/pci/cadence/pcie-cadence-ep.c new file +542 -0
542 lines not on this page · raw message
drivers/pci/cadence/pcie-cadence-host.c renamed from drivers/pci/host/pcie-cadence-host.c +2 -63
83 lines not on this page · raw message
drivers/pci/cadence/pcie-cadence.c new file +126 -0
126 lines not on this page · raw message
drivers/pci/cadence/pcie-cadence.h renamed from drivers/pci/host/pcie-cadence.h +122 -0
153 lines not on this page · raw message
drivers/pci/host/Kconfig +0 -10
@@ -210,16 +210,6 @@ config PCIE_TANGO_SMP8759 This can lead to data corruption if drivers perform concurrent config and MMIO accesses. -config PCIE_CADENCE_HOST - bool "Cadence PCIe host controller" - depends on OF - depends on PCI - select IRQ_DOMAIN - help - Say Y here if you want to support the Cadence PCIe controller in host - mode. This PCIe controller may be embedded into many different vendors - SoCs. - config VMD depends on PCI_MSI && X86_64 && SRCU tristate "Intel Volume Management Device Driver"
drivers/pci/host/Makefile +0 -1
@@ -22,7 +22,6 @@ obj-$(CONFIG_PCIE_ALTERA_MSI) += pcie-altera-msi.o obj-$(CONFIG_PCIE_ROCKCHIP) += pcie-rockchip.o obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o -obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.o obj-$(CONFIG_VMD) += vmd.o # The following drivers are for devices that use the generic ACPI
Signature · 1 line
2.11.0