PCI: Add support to the Cadence PCIe controller
Subsystems (4)
v3 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 removed only because I didn't have time to take all Kishon's comments into account. However, using a fixed patch based on patch 7 of the v2 series + another patch fixing the EPF device name chosen by pci_epf_make(), I was abled to probe both function 0 and function 1 of the of the 2nd Cadence PCIe controller configured in endpoint mode (new hardware design since v2 so function 1 is now available).
Currently I'm facing 2 issues, which I didn't have enough time to investigate and to fix yet:
1 - when the vendor:device IDs are set to 104c:b500 for both functions, then I remove both devfn (echo 1 > /sys/bus/pci/devices/$BDF/remove) before scanning the PCI bus again (echo 1 > /sys/bus/pci/rescan), the PCI enumeration fails reporting that the PCI memory is exhausted.
2 - when I set the vendor:device IDs to 104c:0100 for function 0 and 104c:b500 and remove only function 1 before scanning the PCI bus again, I now pass the PCI enumeration. I also pass the 'pcitest -b <BAR>' test but I fail on the MSI test ('pcitest -m <MSI>').
I'm still investigating on those issues.
Best regards,
Cyrille
ChangeLog
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 (5):
PCI: Regroup all PCI related entries into drivers/pci/Makefile
PCI: OF: Add generic function to parse and allocate PCI resources
PCI: Add generic function to probe PCI host controllers
PCI: Add vendor ID for Cadence
PCI: cadence: Add host driver for Cadence PCIe controller
Scott Telford (1):
dt-bindings: PCI: cadence: Add DT bindings for Cadence PCIe host
controller
.../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 | 16 + drivers/pci/cadence/Makefile | 3 + drivers/pci/cadence/pcie-cadence-host.c | 336 +++++++++++++++++++++ drivers/pci/cadence/pcie-cadence.c | 68 +++++ drivers/pci/cadence/pcie-cadence.h | 196 ++++++++++++ drivers/pci/dwc/Makefile | 2 + drivers/pci/host/Makefile | 2 + drivers/pci/host/pci-host-common.c | 74 +---- drivers/pci/of.c | 51 ++++ drivers/pci/probe.c | 33 ++ include/linux/pci.h | 10 + include/linux/pci_ids.h | 2 + 17 files changed, 805 insertions(+), 76 deletions(-) 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-host.c create mode 100644 drivers/pci/cadence/pcie-cadence.c create mode 100644 drivers/pci/cadence/pcie-cadence.h
Signature · 1 line
2.11.0
PATCH v3 1/6 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
@@ -25,4 +25,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 v3 2/6 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
@@ -2163,6 +2163,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);
@@ -2187,6 +2190,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 · 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 v3 3/6 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.
We also add a missing call of 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 | 25 +++---------------------- drivers/pci/probe.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 3 files changed, 37 insertions(+), 22 deletions(-)
drivers/pci/host/pci-host-common.c +3 -22
@@ -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,29 +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); -if (ret <0 ) { -dev_err (dev,"Scanning root bridge failed" ); + ret =pci_host_probe (bridge); +if (ret) { +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
@@ -2685,6 +2685,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
@@ -879,6 +879,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 v3 4/6 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 v3 5/6 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 v3 6/6 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/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/cadence/Kconfig | 16 ++ drivers/pci/cadence/Makefile | 3 + drivers/pci/cadence/pcie-cadence-host.c | 336 ++++++++++++++++++++++++++++++++ drivers/pci/cadence/pcie-cadence.c | 68 +++++++ drivers/pci/cadence/pcie-cadence.h | 196 +++++++++++++++++++ 8 files changed, 628 insertions(+) create mode 100644 drivers/pci/cadence/Kconfig create mode 100644 drivers/pci/cadence/Makefile 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
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/cadence/pcie-cadence* + PCI DRIVER FOR FREESCALE LAYERSCAPE M: Minghuan Lian <[email protected]> M: Mingkai Hu <[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 +16 -0
@@ -0,0 +1,16 @@ +menu "Cadence PCIe controllers support" + +config PCIE_CADENCE + bool + +config PCIE_CADENCE_HOST + bool "Cadence PCIe host controller" + depends on OF + 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. + +endmenu
drivers/pci/cadence/Makefile new file +3 -0
@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence.o +obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.o
drivers/pci/cadence/pcie-cadence-host.c new file +336 -0
336 lines not on this page · raw message
drivers/pci/cadence/pcie-cadence.c new file +68 -0
68 lines not on this page · raw message
drivers/pci/cadence/pcie-cadence.h new file +196 -0
196 lines not on this page · raw message
Signature · 1 line
2.11.0
Re: [PATCH v3 6/6] PCI: cadence: Add host driver for Cadence PCIe controller
Hi Cyrille,
Quoted 422 lines · Cyrille Pitchen
This patch adds support to the Cadence PCIe controller in host mode.
Signed-off-by Cyrille Pitchen <[email protected]>--- MAINTAINERS | 7 + drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/cadence/Kconfig | 16 ++ drivers/pci/cadence/Makefile | 3 + drivers/pci/cadence/pcie-cadence-host.c | 336 ++++++++++++++++++++++++++++++++ drivers/pci/cadence/pcie-cadence.c | 68 +++++++ drivers/pci/cadence/pcie-cadence.h | 196 +++++++++++++++++++ 8 files changed, 628 insertions(+) create mode 100644 drivers/pci/cadence/Kconfig create mode 100644 drivers/pci/cadence/Makefile 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.hMAINTAINERS +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/cadence/pcie-cadence* + PCI DRIVER FOR FREESCALE LAYERSCAPE M: Minghuan Lian <[email protected]> M: Mingkai Hu <[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 +16
-0@@ -0,0 +1,16 @@ +menu "Cadence PCIe controllers support" + +config PCIE_CADENCE + bool + +config PCIE_CADENCE_HOST + bool "Cadence PCIe host controller" + depends on OF + 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. + +endmenudrivers/pci/cadence/Makefile new file +3
-0@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence.o +obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.odrivers/pci/cadence/pcie-cadence-host.c new file +325
-0@@ -0,0 +1,336 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2017 Cadence +// Cadence PCIe host controller driver. +// Author: Cyrille Pitchen <[email protected]> + +#include <linux/kernel.h> +#include <linux/of_address.h> +#include <linux/of_pci.h> +#include <linux/platform_device.h> +#include <linux/pm_runtime.h> + +#include "pcie-cadence.h" + +/** +* struct cdns_pcie_rc - private data for this PCIe Root Complex driver +* @pcie: Cadence PCIe controller +* @dev: pointer to PCIe device +* @cfg_res: start/end offsets in the physical system memory to map PCI +* configuration space accesses +* @bus_range: first/last buses behind the PCIe host controller +* @cfg_base: IO mapped window to access the PCI configuration space of a +* single function at a time +* @max_regions: maximum number of regions supported by the hardware +* @no_bar_nbits: Number of bits to keep for inbound (PCIe -> CPU) address +* translation (nbits sets into the "no BAR match" register) +* @vendor_id: PCI vendor ID +* @device_id: PCI device ID +*/ +struct cdns_pcie_rc { +struct cdns_pcie pcie; +struct device *dev; +struct resource *cfg_res; +struct resource *bus_range; +void __iomem *cfg_base; +u32 max_regions; +u32 no_bar_nbits; +u16 vendor_id; +u16 device_id; +}; + +static void __iomem *cdns_pci_map_bus (struct pci_bus *bus,unsigned int devfn, +int where) +{ +struct pci_host_bridge *bridge =pci_find_host_bridge (bus); +struct cdns_pcie_rc *rc =pci_host_bridge_priv (bridge); +struct cdns_pcie *pcie = &rc->pcie; +unsigned int busn = bus->number; +u32 addr0, desc0; + +if (busn == rc->bus_range->start) { +/* +* Only the root port (devfn == 0) is connected to this bus. +* All other PCI devices are behind some bridge hence on another +* bus. +*/ +if (devfn) +return NULL ; + +return pcie->reg_base + (where &0xfff ); + } + +/* Update Output registers for AXI region 0. */ + addr0 =CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS (12 ) | +CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN (devfn) | +CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS (busn); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_PCI_ADDR0 (0 ), addr0); + +/* Configuration Type 0 or Type 1 access. */ + desc0 =CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID | +CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN (0 ); +/* +* The bus number was already set once for all in desc1 by +* cdns_pcie_host_init_address_translation(). +*/ +if (busn == rc->bus_range->start +1 ) + desc0 |=CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE0 ; +else + desc0 |=CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE1 ; +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_DESC0 (0 ), desc0); + +return rc->cfg_base + (where &0xfff ); +} + +static struct pci_ops cdns_pcie_host_ops = { + .map_bus = cdns_pci_map_bus, + .read = pci_generic_config_read, + .write = pci_generic_config_write, +}; + +static const struct of_device_id cdns_pcie_host_of_match[] = { + { .compatible ="cdns,cdns-pcie-host" }, + + { }, +}; + +static int cdns_pcie_host_init_root_port (struct cdns_pcie_rc *rc) +{ +struct cdns_pcie *pcie = &rc->pcie; +u32 value, ctrl; + +/* +* Set the root complex BAR configuration register: +* - disable both BAR0 and BAR1. +* - enable Prefetchable Memory Base and Limit registers in type 1 +* config space (64 bits). +* - enable IO Base and Limit registers in type 1 config +* space (32 bits). +*/ + ctrl =CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED ; + value =CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL (ctrl) | +CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL (ctrl) | +CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_ENABLE | +CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_64BITS | +CDNS_PCIE_LM_RC_BAR_CFG_IO_ENABLE | +CDNS_PCIE_LM_RC_BAR_CFG_IO_32BITS ; +cdns_pcie_writel (pcie,CDNS_PCIE_LM_RC_BAR_CFG , value); + +/* Set root port configuration space */ +if (rc->vendor_id !=0xffff ) +cdns_pcie_rp_writew (pcie,PCI_VENDOR_ID , rc->vendor_id); +if (rc->device_id !=0xffff ) +cdns_pcie_rp_writew (pcie,PCI_DEVICE_ID , rc->device_id); + +cdns_pcie_rp_writeb (pcie,PCI_CLASS_REVISION ,0 ); +cdns_pcie_rp_writeb (pcie,PCI_CLASS_PROG ,0 ); +cdns_pcie_rp_writew (pcie,PCI_CLASS_DEVICE ,PCI_CLASS_BRIDGE_PCI ); + +return 0 ; +} + +static int cdns_pcie_host_init_address_translation (struct cdns_pcie_rc *rc) +{ +struct cdns_pcie *pcie = &rc->pcie; +struct resource *cfg_res = rc->cfg_res; +struct resource *mem_res = pcie->mem_res; +struct resource *bus_range = rc->bus_range; +struct device *dev = rc->dev; +struct device_node *np = dev->of_node; +struct of_pci_range_parser parser; +struct of_pci_range range; +u32 addr0, addr1, desc1; +u64 cpu_addr; +int r, err; + +/* +* Reserve region 0 for PCI configure space accesses: +* OB_REGION_PCI_ADDR0 and OB_REGION_DESC0 are updated dynamically by +* cdns_pci_map_bus(), other region registers are set here once for all. +*/ + addr1 =0 ;/* Should be programmed to zero. */ + desc1 =CDNS_PCIE_AT_OB_REGION_DESC1_BUS (bus_range->start); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_PCI_ADDR1 (0 ), addr1); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_DESC1 (0 ), desc1); + + cpu_addr = cfg_res->start - mem_res->start; + addr0 =CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS (12 ) | + (lower_32_bits (cpu_addr) &GENMASK (31 ,8 )); + addr1 =upper_32_bits (cpu_addr); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR0 (0 ), addr0); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR1 (0 ), addr1); + + err =of_pci_range_parser_init (&parser, np); +if (err) +return err; + + r =1 ; +for_each_of_pci_range (&parser, &range) { +bool is_io; + +if (r >= rc->max_regions) +break ; + +if ((range.flags &IORESOURCE_TYPE_BITS ) ==IORESOURCE_MEM ) + is_io = false; +else if ((range.flags &IORESOURCE_TYPE_BITS ) ==IORESOURCE_IO ) + is_io = true; +else +continue ; + +cdns_pcie_set_outbound_region (pcie, r, is_io, + range.cpu_addr, + range.pci_addr, + range.size); + r++; + } + +/* +* Set Root Port no BAR match Inbound Translation registers: +* needed for MSI and DMA. +* Root Port BAR0 and BAR1 are disabled, hence no need to set their +* inbound translation registers. +*/ + addr0 =CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS (rc->no_bar_nbits); + addr1 =0 ; +cdns_pcie_writel (pcie,CDNS_PCIE_AT_IB_RP_BAR_ADDR0 (RP_NO_BAR ), addr0); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_IB_RP_BAR_ADDR1 (RP_NO_BAR ), addr1); + +return 0 ; +} + +static int cdns_pcie_host_init (struct device *dev, +struct list_head *resources, +struct cdns_pcie_rc *rc) +{ +struct resource *bus_range =NULL ; +int err; + +/* Parse our PCI ranges and request their resources */ + err =pci_parse_request_of_pci_ranges (dev, resources, &bus_range); +if (err) +return err; + + rc->bus_range = bus_range; + rc->pcie.bus = bus_range->start; + + err =cdns_pcie_host_init_root_port (rc); +if (err) + goto err_out; + + err =cdns_pcie_host_init_address_translation (rc); +if (err) + goto err_out; + +return 0 ; + + err_out: +pci_free_resource_list (resources); +return err; +} + +static int cdns_pcie_host_probe (struct platform_device *pdev) +{ +const char *type; +struct device *dev = &pdev->dev; +struct device_node *np = dev->of_node; +struct pci_host_bridge *bridge; +struct list_head resources; +struct cdns_pcie_rc *rc; +struct cdns_pcie *pcie; +struct resource *res; +int ret; + + bridge =devm_pci_alloc_host_bridge (dev,sizeof (*rc)); +if (!bridge) +return -ENOMEM ; + + rc =pci_host_bridge_priv (bridge); + rc->dev = dev; + + pcie = &rc->pcie; + pcie->is_rc = true; + + rc->max_regions =32 ; +of_property_read_u32 (np,"cdns,max-outbound-regions" , &rc->max_regions); + + rc->no_bar_nbits =32 ; +of_property_read_u32 (np,"cdns,no-bar-match-nbits" , &rc->no_bar_nbits); + + rc->vendor_id =0xffff ; +of_property_read_u16 (np,"vendor-id" , &rc->vendor_id); + + rc->device_id =0xffff ; +of_property_read_u16 (np,"device-id" , &rc->device_id); + + type =of_get_property (np,"device_type" ,NULL ); +if (!type ||strcmp (type,"pci" )) { +dev_err (dev,"invalid \"device_type\" %s\n" , type); +return -EINVAL ; + } + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"reg" ); + pcie->reg_base =devm_ioremap_resource (dev, res); +if (IS_ERR (pcie->reg_base)) { +dev_err (dev,"missing \"reg\"\n" ); +return PTR_ERR (pcie->reg_base); + } + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"cfg" ); + rc->cfg_base =devm_pci_remap_cfg_resource (dev, res); +if (IS_ERR (rc->cfg_base)) { +dev_err (dev,"missing \"cfg\"\n" ); +return PTR_ERR (rc->cfg_base); + } + rc->cfg_res = res; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"mem" ); +if (!res) { +dev_err (dev,"missing \"mem\"\n" ); +return -EINVAL ; + } + pcie->mem_res = res; + +pm_runtime_enable (dev); + ret =pm_runtime_get_sync (dev); +if (ret <0 ) { +dev_err (dev,"pm_runtime_get_sync() failed\n" ); + goto err_get_sync; + } + + ret =cdns_pcie_host_init (dev, &resources, rc); +if (ret) + goto err_init; + +list_splice_init (&resources, &bridge->windows); + bridge->dev.parent = dev; + bridge->busnr = pcie->bus; + bridge->ops = &cdns_pcie_host_ops; + bridge->map_irq = of_irq_parse_and_map_pci; + bridge->swizzle_irq = pci_common_swizzle; + + ret =pci_host_probe (bridge); +if (ret <0 ) + goto err_host_probe; + +return 0 ; + + err_host_probe: +pci_free_resource_list (&resources); + + err_init: +pm_runtime_put_sync (dev); + + err_get_sync: +pm_runtime_disable (dev); +
drivers/pci/cadence/pcie-cadence-host.c line 335
Quoted 10 lines
drivers/pci/cadence/pcie-cadence-host.c new file +10
-0+return ret; +} + +static struct platform_driver cdns_pcie_host_driver = { + .driver = { + .name ="cdns-pcie-host" , + .of_match_table = cdns_pcie_host_of_match, + }, + .probe = cdns_pcie_host_probe, +};
In the case of DWC, designware core is modeled as a library which has API's to be invoked by various platform specific glue drivers.
But with the cadence approach we'll have two separate drivers: the cadence core driver and the platform specific glue drivers. Is this approach chosen for a specific reason?
Thanks
Kishon
Re: [PATCH v3 6/6] PCI: cadence: Add host driver for Cadence PCIe controller
On Tue, Jan 16, 2018 at 04:46:12PM +0530, Kishon Vijay Abraham I wrote:
[...]
Quoted 11 lines
drivers/pci/cadence/pcie-cadence-host.c line 335
Quoted 7 lines
drivers/pci/cadence/pcie-cadence-host.c new file +7
-0+static struct platform_driver cdns_pcie_host_driver = { + .driver = { + .name ="cdns-pcie-host" , + .of_match_table = cdns_pcie_host_of_match, + }, + .probe = cdns_pcie_host_probe, +};In the case of DWC, designware core is modeled as a library which has API's to be invoked by various platform specific glue drivers.
Quoted 3 lines
But with the cadence approach we'll have two separate drivers: the cadence core driver and the platform specific glue drivers. Is this approach chosen for a specific reason?
That's a fair point but I do not think that's a concern at the moment.
If/when other platform drivers are built around the generic IP we just have to refactor this driver and turn into a core library + a PCI host bridge driver like dwc does, at the moment I do not necessarily see the reason for splitting them.
Cyrille ?
Thanks,
Lorenzo
Re: [PATCH v3 3/6] PCI: Add generic function to probe PCI host controllers
In reply to Cyrille PitchenQuoted 11 lines · Cyrille Pitchen
This patchs moves generic source code from
drivers/pci/host/pci-host-common.cintodrivers/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 selectsPCI_ECAMwhen not needed by most host controller drivers.We also add a missing call of
pci_free_resource_list()frompci_host_common_probe()when probing fails, as done insidegen_pci_init()
I have to ask you to split this change into another patch.
First add the missing pci_free_resource_list() then add this patch.
Do you have time to respin quickly ? I would like to merge this series for v4.16.
Thanks,
Lorenzo
Quoted 113 lines
when this later function fails.
Signed-off-by Cyrille Pitchen <[email protected]>--- drivers/pci/host/pci-host-common.c | 25 +++---------------------- drivers/pci/probe.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 3 files changed, 37 insertions(+), 22 deletions(-)drivers/pci/host/pci-host-common.c +3
-22@@ -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,29 +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); -if (ret <0 ) { -dev_err (dev,"Scanning root bridge failed" ); + ret =pci_host_probe (bridge); +if (ret) { +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@@ -2685,6 +2685,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@@ -879,6 +879,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
Re: [PATCH v3 6/6] PCI: cadence: Add host driver for Cadence PCIe controller
In reply to Cyrille PitchenQuoted 12 lines · Cyrille Pitchen
This patch adds support to the Cadence PCIe controller in host mode.
Signed-off-by Cyrille Pitchen <[email protected]>--- MAINTAINERS | 7 + drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/cadence/Kconfig | 16 ++ drivers/pci/cadence/Makefile | 3 + drivers/pci/cadence/pcie-cadence-host.c | 336 ++++++++++++++++++++++++++++++++ drivers/pci/cadence/pcie-cadence.c | 68 +++++++ drivers/pci/cadence/pcie-cadence.h | 196 +++++++++++++++++++
[...]
drivers/pci/cadence/pcie-cadence.c line 68
Quoted 11 lines
drivers/pci/cadence/pcie-cadence.c new file +11
-0+void cdns_pcie_reset_outbound_region (struct cdns_pcie *pcie,u32 r) +{ +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_PCI_ADDR0 (r),0 ); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_PCI_ADDR1 (r),0 ); + +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_DESC0 (r),0 ); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_DESC1 (r),0 ); + +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR0 (r),0 ); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR1 (r),0 ); +}
Unused function, please remove it.
Quoted 190 lines
drivers/pci/cadence/pcie-cadence.h new file +184
-0@@ -0,0 +1,196 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2017 Cadence +// Cadence PCIe controller driver. +// Author: Cyrille Pitchen <[email protected]> + +#ifndef _PCIE_CADENCE_H +#define _PCIE_CADENCE_H + +#include <linux/kernel.h> +#include <linux/pci.h> + +/* +* Local Management Registers +*/ +#define CDNS_PCIE_LM_BASE 0x00100000 + +/* Vendor ID Register */ +#define CDNS_PCIE_LM_ID (CDNS_PCIE_LM_BASE + 0x0044) +#define CDNS_PCIE_LM_ID_VENDOR_MASK GENMASK(15, 0) +#define CDNS_PCIE_LM_ID_VENDOR_SHIFT 0 +#define CDNS_PCIE_LM_ID_VENDOR (vid) \ + (((vid) << CDNS_PCIE_LM_ID_VENDOR_SHIFT) & CDNS_PCIE_LM_ID_VENDOR_MASK) +#define CDNS_PCIE_LM_ID_SUBSYS_MASK GENMASK(31, 16) +#define CDNS_PCIE_LM_ID_SUBSYS_SHIFT 16 +#define CDNS_PCIE_LM_ID_SUBSYS (sub) \ + (((sub) << CDNS_PCIE_LM_ID_SUBSYS_SHIFT) & CDNS_PCIE_LM_ID_SUBSYS_MASK) + +/* Root Port Requestor ID Register */ +#define CDNS_PCIE_LM_RP_RID (CDNS_PCIE_LM_BASE + 0x0228) +#define CDNS_PCIE_LM_RP_RID_MASK GENMASK(15, 0) +#define CDNS_PCIE_LM_RP_RID_SHIFT 0 +#define CDNS_PCIE_LM_RP_RID_ (rid) \ + (((rid) << CDNS_PCIE_LM_RP_RID_SHIFT) & CDNS_PCIE_LM_RP_RID_MASK) + +/* Root Complex BAR Configuration Register */ +#define CDNS_PCIE_LM_RC_BAR_CFG (CDNS_PCIE_LM_BASE + 0x0300) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE_MASK GENMASK(5, 0) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE (a) \ + (((a) << 0) & CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE_MASK) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL_MASK GENMASK(8, 6) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL (c) \ + (((c) << 6) & CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL_MASK) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE_MASK GENMASK(13, 9) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE (a) \ + (((a) << 9) & CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE_MASK) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL_MASK GENMASK(16, 14) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL (c) \ + (((c) << 14) & CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL_MASK) +#define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_ENABLE BIT(17) +#define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_32BITS 0 +#define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_64BITS BIT(18) +#define CDNS_PCIE_LM_RC_BAR_CFG_IO_ENABLE BIT(19) +#define CDNS_PCIE_LM_RC_BAR_CFG_IO_16BITS 0 +#define CDNS_PCIE_LM_RC_BAR_CFG_IO_32BITS BIT(20) +#define CDNS_PCIE_LM_RC_BAR_CFG_CHECK_ENABLE BIT(31) + +/* BAR control values applicable to both Endpoint Function and Root Complex */ +#define CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED 0x0 +#define CDNS_PCIE_LM_BAR_CFG_CTRL_IO_32BITS 0x1 +#define CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_32BITS 0x4 +#define CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_32BITS 0x5 +#define CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_64BITS 0x6 +#define CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_64BITS 0x7 + + +/* +* Root Port Registers (PCI configuration space for the root port function) +*/ +#define CDNS_PCIE_RP_BASE 0x00200000 + + +/* +* Address Translation Registers +*/ +#define CDNS_PCIE_AT_BASE 0x00400000 + +/* Region r Outbound AXI to PCIe Address Translation Register 0 */ +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0 (r) \ + (CDNS_PCIE_AT_BASE + 0x0000 + ((r) & 0x1f) * 0x0020) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS_MASK GENMASK(5, 0) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS (nbits) \ + (((nbits) - 1) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS_MASK) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN_MASK GENMASK(19, 12) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN (devfn) \ + (((devfn) << 12) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN_MASK) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS_MASK GENMASK(27, 20) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS (bus) \ + (((bus) << 20) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS_MASK) + +/* Region r Outbound AXI to PCIe Address Translation Register 1 */ +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR1 (r) \ + (CDNS_PCIE_AT_BASE + 0x0004 + ((r) & 0x1f) * 0x0020) + +/* Region r Outbound PCIe Descriptor Register 0 */ +#define CDNS_PCIE_AT_OB_REGION_DESC0 (r) \ + (CDNS_PCIE_AT_BASE + 0x0008 + ((r) & 0x1f) * 0x0020) +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MASK GENMASK(3, 0) +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MEM 0x2 +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_IO 0x6 +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE0 0xa +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE1 0xb +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_NORMAL_MSG 0xc +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_VENDOR_MSG 0xd +/* Bit 23 MUST be set in RC mode. */ +#define CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID BIT(23) +#define CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN_MASK GENMASK(31, 24) +#define CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN (devfn) \ + (((devfn) << 24) & CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN_MASK) + +/* Region r Outbound PCIe Descriptor Register 1 */ +#define CDNS_PCIE_AT_OB_REGION_DESC1 (r) \ + (CDNS_PCIE_AT_BASE + 0x000c + ((r) & 0x1f) * 0x0020) +#define CDNS_PCIE_AT_OB_REGION_DESC1_BUS_MASK GENMASK(7, 0) +#define CDNS_PCIE_AT_OB_REGION_DESC1_BUS (bus) \ + ((bus) & CDNS_PCIE_AT_OB_REGION_DESC1_BUS_MASK) + +/* Region r AXI Region Base Address Register 0 */ +#define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0 (r) \ + (CDNS_PCIE_AT_BASE + 0x0018 + ((r) & 0x1f) * 0x0020) +#define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS_MASK GENMASK(5, 0) +#define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS (nbits) \ + (((nbits) - 1) & CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS_MASK) + +/* Region r AXI Region Base Address Register 1 */ +#define CDNS_PCIE_AT_OB_REGION_CPU_ADDR1 (r) \ + (CDNS_PCIE_AT_BASE + 0x001c + ((r) & 0x1f) * 0x0020) + +/* Root Port BAR Inbound PCIe to AXI Address Translation Register */ +#define CDNS_PCIE_AT_IB_RP_BAR_ADDR0 (bar) \ + (CDNS_PCIE_AT_BASE + 0x0800 + (bar) * 0x0008) +#define CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS_MASK GENMASK(5, 0) +#define CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS (nbits) \ + (((nbits) - 1) & CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS_MASK) +#define CDNS_PCIE_AT_IB_RP_BAR_ADDR1 (bar) \ + (CDNS_PCIE_AT_BASE + 0x0804 + (bar) * 0x0008) + +enum cdns_pcie_rp_bar { +RP_BAR0 , +RP_BAR1 , +RP_NO_BAR +}; + +/** +* struct cdns_pcie - private data for Cadence PCIe controller drivers +* @reg_base: IO mapped register base +* @mem_res: start/end offsets in the physical system memory to map PCI accesses +* @is_rc: tell whether the PCIe controller mode is Root Complex or Endpoint. +* @bus: In Root Complex mode, the bus number +*/ +struct cdns_pcie { +void __iomem *reg_base; +struct resource *mem_res; +bool is_rc; +u8 bus; +}; + +/* Register access */ +static inline void cdns_pcie_writeb (struct cdns_pcie *pcie,u32 reg,u8 value) +{ +writeb (value, pcie->reg_base + reg); +} + +static inline void cdns_pcie_writew (struct cdns_pcie *pcie,u32 reg,u16 value) +{ +writew (value, pcie->reg_base + reg); +} + +static inline void cdns_pcie_writel (struct cdns_pcie *pcie,u32 reg,u32 value) +{ +writel (value, pcie->reg_base + reg); +} + +static inline u32 cdns_pcie_readl (struct cdns_pcie *pcie,u32 reg) +{ +return readl (pcie->reg_base + reg); +} + +/* Root Port register access */ +static inline void cdns_pcie_rp_writeb (struct cdns_pcie *pcie, +u32 reg,u8 value) +{ +writeb (value, pcie->reg_base +CDNS_PCIE_RP_BASE + reg); +} +
drivers/pci/cadence/pcie-cadence.h line 194
Quoted 10 lines
drivers/pci/cadence/pcie-cadence.h new file +10
-0+static inline void cdns_pcie_rp_writew (struct cdns_pcie *pcie, +u32 reg,u16 value) +{ +writew (value, pcie->reg_base +CDNS_PCIE_RP_BASE + reg); +} + +void cdns_pcie_set_outbound_region (struct cdns_pcie *pcie,u32 r,bool is_io, +u64 cpu_addr,u64 pci_addr,size_t size); + +void cdns_pcie_reset_outbound_region (struct cdns_pcie *pcie,u32 r);
Ditto. I understand it is hard to untangle code that was written with both EP and host bridge support in mind but, as I state below every patch has to make sense on its own.
drivers/pci/cadence/pcie-cadence.h line 196
Quoted 2 lines
drivers/pci/cadence/pcie-cadence.h new file +2
-0+ +#endif /* _PCIE_CADENCE_H */
Technically speaking, this 3-file (.c .h) split is not necessary and can turn out unnecessary churn if we never merge the endpoint code - actually you would not even need a special cadence directory, just a host bridge driver file.
Bottom line, as you know: every patch has to be self contained.
It is already quite late -rc, I understand that changes this late are error prone so I will accept that this file splitting is necessary for "future" patches - if you manage to squash changes into a file I'd appreciate though, it does not make sense to export functions that are used in just one compilation unit (and some that are not used at all).
Thanks,
Lorenzo
Re: [PATCH v3 3/6] PCI: Add generic function to probe PCI host controllers
In reply to Lorenzo PieralisiHi Lorenzo,
Le 16/01/2018 à 16:25, Lorenzo Pieralisi a écrit :
Quoted 10 lines · Cyrille Pitchen
Quoted 9 lines
This patchs moves generic source code from
drivers/pci/host/pci-host-common.cintodrivers/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 selectsPCI_ECAMwhen not needed by most host controller drivers.
Quoted 9 lines
Quoted 2 lines
We also add a missing call of
pci_free_resource_list()frompci_host_common_probe()when probing fails, as done insidegen_pci_init()I have to ask you to split this change into another patch.
First add the missing
pci_free_resource_list()then add this patch.Do you have time to respin quickly ? I would like to merge this series for v4.16.
Sorry, I've been a little bit busy. I've just done it and submit v4. patch 3 from v3 split into patches 3 and 4 in v4.
Best regards,
Cyrille
Quoted 117 lines
Thanks,
LorenzoQuoted 113 lines
when this later function fails.
--- drivers/pci/host/pci-host-common.c | 25 +++---------------------- drivers/pci/probe.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pci.h | 1 + 3 files changed, 37 insertions(+), 22 deletions(-)drivers/pci/host/pci-host-common.c +3
-22@@ -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,29 +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); -if (ret <0 ) { -dev_err (dev,"Scanning root bridge failed" ); + ret =pci_host_probe (bridge); +if (ret) { +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@@ -2685,6 +2685,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@@ -879,6 +879,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
Signature · 7 lines
Cyrille Pitchen, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- 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
Re: [PATCH v3 6/6] PCI: cadence: Add host driver for Cadence PCIe controller
In reply to Kishon Vijay Abraham IHi Kishon,
Quoted 439 lines · Kishon Vijay Abraham I
Hi Cyrille,
Quoted 422 lines · Cyrille Pitchen
This patch adds support to the Cadence PCIe controller in host mode.
--- MAINTAINERS | 7 + drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/cadence/Kconfig | 16 ++ drivers/pci/cadence/Makefile | 3 + drivers/pci/cadence/pcie-cadence-host.c | 336 ++++++++++++++++++++++++++++++++ drivers/pci/cadence/pcie-cadence.c | 68 +++++++ drivers/pci/cadence/pcie-cadence.h | 196 +++++++++++++++++++ 8 files changed, 628 insertions(+) create mode 100644 drivers/pci/cadence/Kconfig create mode 100644 drivers/pci/cadence/Makefile 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.hMAINTAINERS +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/cadence/pcie-cadence* + PCI DRIVER FOR FREESCALE LAYERSCAPE M: Minghuan Lian <[email protected]> M: Mingkai Hu <[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 +16
-0@@ -0,0 +1,16 @@ +menu "Cadence PCIe controllers support" + +config PCIE_CADENCE + bool + +config PCIE_CADENCE_HOST + bool "Cadence PCIe host controller" + depends on OF + 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. + +endmenudrivers/pci/cadence/Makefile new file +3
-0@@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_PCIE_CADENCE) += pcie-cadence.o +obj-$(CONFIG_PCIE_CADENCE_HOST) += pcie-cadence-host.odrivers/pci/cadence/pcie-cadence-host.c new file +325
-0@@ -0,0 +1,336 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2017 Cadence +// Cadence PCIe host controller driver. +// Author: Cyrille Pitchen <cyrille.pitchen-wi1+55ScJUtKEb57/[email protected]> + +#include <linux/kernel.h> +#include <linux/of_address.h> +#include <linux/of_pci.h> +#include <linux/platform_device.h> +#include <linux/pm_runtime.h> + +#include "pcie-cadence.h" + +/** +* struct cdns_pcie_rc - private data for this PCIe Root Complex driver +* @pcie: Cadence PCIe controller +* @dev: pointer to PCIe device +* @cfg_res: start/end offsets in the physical system memory to map PCI +* configuration space accesses +* @bus_range: first/last buses behind the PCIe host controller +* @cfg_base: IO mapped window to access the PCI configuration space of a +* single function at a time +* @max_regions: maximum number of regions supported by the hardware +* @no_bar_nbits: Number of bits to keep for inbound (PCIe -> CPU) address +* translation (nbits sets into the "no BAR match" register) +* @vendor_id: PCI vendor ID +* @device_id: PCI device ID +*/ +struct cdns_pcie_rc { +struct cdns_pcie pcie; +struct device *dev; +struct resource *cfg_res; +struct resource *bus_range; +void __iomem *cfg_base; +u32 max_regions; +u32 no_bar_nbits; +u16 vendor_id; +u16 device_id; +}; + +static void __iomem *cdns_pci_map_bus (struct pci_bus *bus,unsigned int devfn, +int where) +{ +struct pci_host_bridge *bridge =pci_find_host_bridge (bus); +struct cdns_pcie_rc *rc =pci_host_bridge_priv (bridge); +struct cdns_pcie *pcie = &rc->pcie; +unsigned int busn = bus->number; +u32 addr0, desc0; + +if (busn == rc->bus_range->start) { +/* +* Only the root port (devfn == 0) is connected to this bus. +* All other PCI devices are behind some bridge hence on another +* bus. +*/ +if (devfn) +return NULL ; + +return pcie->reg_base + (where &0xfff ); + } + +/* Update Output registers for AXI region 0. */ + addr0 =CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS (12 ) | +CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN (devfn) | +CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS (busn); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_PCI_ADDR0 (0 ), addr0); + +/* Configuration Type 0 or Type 1 access. */ + desc0 =CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID | +CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN (0 ); +/* +* The bus number was already set once for all in desc1 by +* cdns_pcie_host_init_address_translation(). +*/ +if (busn == rc->bus_range->start +1 ) + desc0 |=CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE0 ; +else + desc0 |=CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE1 ; +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_DESC0 (0 ), desc0); + +return rc->cfg_base + (where &0xfff ); +} + +static struct pci_ops cdns_pcie_host_ops = { + .map_bus = cdns_pci_map_bus, + .read = pci_generic_config_read, + .write = pci_generic_config_write, +}; + +static const struct of_device_id cdns_pcie_host_of_match[] = { + { .compatible ="cdns,cdns-pcie-host" }, + + { }, +}; + +static int cdns_pcie_host_init_root_port (struct cdns_pcie_rc *rc) +{ +struct cdns_pcie *pcie = &rc->pcie; +u32 value, ctrl; + +/* +* Set the root complex BAR configuration register: +* - disable both BAR0 and BAR1. +* - enable Prefetchable Memory Base and Limit registers in type 1 +* config space (64 bits). +* - enable IO Base and Limit registers in type 1 config +* space (32 bits). +*/ + ctrl =CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED ; + value =CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL (ctrl) | +CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL (ctrl) | +CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_ENABLE | +CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_64BITS | +CDNS_PCIE_LM_RC_BAR_CFG_IO_ENABLE | +CDNS_PCIE_LM_RC_BAR_CFG_IO_32BITS ; +cdns_pcie_writel (pcie,CDNS_PCIE_LM_RC_BAR_CFG , value); + +/* Set root port configuration space */ +if (rc->vendor_id !=0xffff ) +cdns_pcie_rp_writew (pcie,PCI_VENDOR_ID , rc->vendor_id); +if (rc->device_id !=0xffff ) +cdns_pcie_rp_writew (pcie,PCI_DEVICE_ID , rc->device_id); + +cdns_pcie_rp_writeb (pcie,PCI_CLASS_REVISION ,0 ); +cdns_pcie_rp_writeb (pcie,PCI_CLASS_PROG ,0 ); +cdns_pcie_rp_writew (pcie,PCI_CLASS_DEVICE ,PCI_CLASS_BRIDGE_PCI ); + +return 0 ; +} + +static int cdns_pcie_host_init_address_translation (struct cdns_pcie_rc *rc) +{ +struct cdns_pcie *pcie = &rc->pcie; +struct resource *cfg_res = rc->cfg_res; +struct resource *mem_res = pcie->mem_res; +struct resource *bus_range = rc->bus_range; +struct device *dev = rc->dev; +struct device_node *np = dev->of_node; +struct of_pci_range_parser parser; +struct of_pci_range range; +u32 addr0, addr1, desc1; +u64 cpu_addr; +int r, err; + +/* +* Reserve region 0 for PCI configure space accesses: +* OB_REGION_PCI_ADDR0 and OB_REGION_DESC0 are updated dynamically by +* cdns_pci_map_bus(), other region registers are set here once for all. +*/ + addr1 =0 ;/* Should be programmed to zero. */ + desc1 =CDNS_PCIE_AT_OB_REGION_DESC1_BUS (bus_range->start); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_PCI_ADDR1 (0 ), addr1); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_DESC1 (0 ), desc1); + + cpu_addr = cfg_res->start - mem_res->start; + addr0 =CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS (12 ) | + (lower_32_bits (cpu_addr) &GENMASK (31 ,8 )); + addr1 =upper_32_bits (cpu_addr); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR0 (0 ), addr0); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR1 (0 ), addr1); + + err =of_pci_range_parser_init (&parser, np); +if (err) +return err; + + r =1 ; +for_each_of_pci_range (&parser, &range) { +bool is_io; + +if (r >= rc->max_regions) +break ; + +if ((range.flags &IORESOURCE_TYPE_BITS ) ==IORESOURCE_MEM ) + is_io = false; +else if ((range.flags &IORESOURCE_TYPE_BITS ) ==IORESOURCE_IO ) + is_io = true; +else +continue ; + +cdns_pcie_set_outbound_region (pcie, r, is_io, + range.cpu_addr, + range.pci_addr, + range.size); + r++; + } + +/* +* Set Root Port no BAR match Inbound Translation registers: +* needed for MSI and DMA. +* Root Port BAR0 and BAR1 are disabled, hence no need to set their +* inbound translation registers. +*/ + addr0 =CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS (rc->no_bar_nbits); + addr1 =0 ; +cdns_pcie_writel (pcie,CDNS_PCIE_AT_IB_RP_BAR_ADDR0 (RP_NO_BAR ), addr0); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_IB_RP_BAR_ADDR1 (RP_NO_BAR ), addr1); + +return 0 ; +} + +static int cdns_pcie_host_init (struct device *dev, +struct list_head *resources, +struct cdns_pcie_rc *rc) +{ +struct resource *bus_range =NULL ; +int err; + +/* Parse our PCI ranges and request their resources */ + err =pci_parse_request_of_pci_ranges (dev, resources, &bus_range); +if (err) +return err; + + rc->bus_range = bus_range; + rc->pcie.bus = bus_range->start; + + err =cdns_pcie_host_init_root_port (rc); +if (err) + goto err_out; + + err =cdns_pcie_host_init_address_translation (rc); +if (err) + goto err_out; + +return 0 ; + + err_out: +pci_free_resource_list (resources); +return err; +} + +static int cdns_pcie_host_probe (struct platform_device *pdev) +{ +const char *type; +struct device *dev = &pdev->dev; +struct device_node *np = dev->of_node; +struct pci_host_bridge *bridge; +struct list_head resources; +struct cdns_pcie_rc *rc; +struct cdns_pcie *pcie; +struct resource *res; +int ret; + + bridge =devm_pci_alloc_host_bridge (dev,sizeof (*rc)); +if (!bridge) +return -ENOMEM ; + + rc =pci_host_bridge_priv (bridge); + rc->dev = dev; + + pcie = &rc->pcie; + pcie->is_rc = true; + + rc->max_regions =32 ; +of_property_read_u32 (np,"cdns,max-outbound-regions" , &rc->max_regions); + + rc->no_bar_nbits =32 ; +of_property_read_u32 (np,"cdns,no-bar-match-nbits" , &rc->no_bar_nbits); + + rc->vendor_id =0xffff ; +of_property_read_u16 (np,"vendor-id" , &rc->vendor_id); + + rc->device_id =0xffff ; +of_property_read_u16 (np,"device-id" , &rc->device_id); + + type =of_get_property (np,"device_type" ,NULL ); +if (!type ||strcmp (type,"pci" )) { +dev_err (dev,"invalid \"device_type\" %s\n" , type); +return -EINVAL ; + } + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"reg" ); + pcie->reg_base =devm_ioremap_resource (dev, res); +if (IS_ERR (pcie->reg_base)) { +dev_err (dev,"missing \"reg\"\n" ); +return PTR_ERR (pcie->reg_base); + } + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"cfg" ); + rc->cfg_base =devm_pci_remap_cfg_resource (dev, res); +if (IS_ERR (rc->cfg_base)) { +dev_err (dev,"missing \"cfg\"\n" ); +return PTR_ERR (rc->cfg_base); + } + rc->cfg_res = res; + + res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"mem" ); +if (!res) { +dev_err (dev,"missing \"mem\"\n" ); +return -EINVAL ; + } + pcie->mem_res = res; + +pm_runtime_enable (dev); + ret =pm_runtime_get_sync (dev); +if (ret <0 ) { +dev_err (dev,"pm_runtime_get_sync() failed\n" ); + goto err_get_sync; + } + + ret =cdns_pcie_host_init (dev, &resources, rc); +if (ret) + goto err_init; + +list_splice_init (&resources, &bridge->windows); + bridge->dev.parent = dev; + bridge->busnr = pcie->bus; + bridge->ops = &cdns_pcie_host_ops; + bridge->map_irq = of_irq_parse_and_map_pci; + bridge->swizzle_irq = pci_common_swizzle; + + ret =pci_host_probe (bridge); +if (ret <0 ) + goto err_host_probe; + +return 0 ; + + err_host_probe: +pci_free_resource_list (&resources); + + err_init: +pm_runtime_put_sync (dev); + + err_get_sync: +pm_runtime_disable (dev); +drivers/pci/cadence/pcie-cadence-host.c line 335
Quoted 10 lines
drivers/pci/cadence/pcie-cadence-host.c new file +10
-0+return ret; +} + +static struct platform_driver cdns_pcie_host_driver = { + .driver = { + .name ="cdns-pcie-host" , + .of_match_table = cdns_pcie_host_of_match, + }, + .probe = cdns_pcie_host_probe, +};In the case of DWC, designware core is modeled as a library which has API's to be invoked by various platform specific glue drivers.
Quoted 3 lines
But with the cadence approach we'll have two separate drivers: the cadence core driver and the platform specific glue drivers. Is this approach chosen for a specific reason?
I don't know yet how many chips will integrate the Cadence PCIe controller or what customizations would be required. I thought we may have a chance to handle all the variants with different 'compatible' DT values and their associated .data in the 'struct of_device_id', or maybe with some additional DT properties but still the single pcie-cadence-host.c file to drive all host flavors.
Also I was thinking about regrouping all endpoint flavors in pcie-cadence-enpoint.c.
I can't figure out yet whether it would be enough.
Best regards,
Cyrille
Quoted 4 lines
Thanks
Kishon
Signature · 7 lines
Cyrille Pitchen, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- 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
Re: [PATCH v3 6/6] PCI: cadence: Add host driver for Cadence PCIe controller
In reply to Lorenzo PieralisiHi Lorenzo
Le 16/01/2018 à 17:07, Lorenzo Pieralisi a écrit :
Quoted 16 lines · Cyrille Pitchen
Quoted 12 lines
This patch adds support to the Cadence PCIe controller in host mode.
--- MAINTAINERS | 7 + drivers/pci/Kconfig | 1 + drivers/pci/Makefile | 1 + drivers/pci/cadence/Kconfig | 16 ++ drivers/pci/cadence/Makefile | 3 + drivers/pci/cadence/pcie-cadence-host.c | 336 ++++++++++++++++++++++++++++++++ drivers/pci/cadence/pcie-cadence.c | 68 +++++++ drivers/pci/cadence/pcie-cadence.h | 196 +++++++++++++++++++[...]
Quoted 13 lines
drivers/pci/cadence/pcie-cadence.c line 68
Quoted 11 lines
drivers/pci/cadence/pcie-cadence.c new file +11
-0+void cdns_pcie_reset_outbound_region (struct cdns_pcie *pcie,u32 r) +{ +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_PCI_ADDR0 (r),0 ); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_PCI_ADDR1 (r),0 ); + +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_DESC0 (r),0 ); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_DESC1 (r),0 ); + +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR0 (r),0 ); +cdns_pcie_writel (pcie,CDNS_PCIE_AT_OB_REGION_CPU_ADDR1 (r),0 ); +}Unused function, please remove it.
done in v4.
Quoted 197 lines
Quoted 197 lines
drivers/pci/cadence/pcie-cadence.h new file +190
-0@@ -0,0 +1,196 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2017 Cadence +// Cadence PCIe controller driver. +// Author: Cyrille Pitchen <cyrille.pitchen-wi1+55ScJUtKEb57/[email protected]> + +#ifndef _PCIE_CADENCE_H +#define _PCIE_CADENCE_H + +#include <linux/kernel.h> +#include <linux/pci.h> + +/* +* Local Management Registers +*/ +#define CDNS_PCIE_LM_BASE 0x00100000 + +/* Vendor ID Register */ +#define CDNS_PCIE_LM_ID (CDNS_PCIE_LM_BASE + 0x0044) +#define CDNS_PCIE_LM_ID_VENDOR_MASK GENMASK(15, 0) +#define CDNS_PCIE_LM_ID_VENDOR_SHIFT 0 +#define CDNS_PCIE_LM_ID_VENDOR (vid) \ + (((vid) << CDNS_PCIE_LM_ID_VENDOR_SHIFT) & CDNS_PCIE_LM_ID_VENDOR_MASK) +#define CDNS_PCIE_LM_ID_SUBSYS_MASK GENMASK(31, 16) +#define CDNS_PCIE_LM_ID_SUBSYS_SHIFT 16 +#define CDNS_PCIE_LM_ID_SUBSYS (sub) \ + (((sub) << CDNS_PCIE_LM_ID_SUBSYS_SHIFT) & CDNS_PCIE_LM_ID_SUBSYS_MASK) + +/* Root Port Requestor ID Register */ +#define CDNS_PCIE_LM_RP_RID (CDNS_PCIE_LM_BASE + 0x0228) +#define CDNS_PCIE_LM_RP_RID_MASK GENMASK(15, 0) +#define CDNS_PCIE_LM_RP_RID_SHIFT 0 +#define CDNS_PCIE_LM_RP_RID_ (rid) \ + (((rid) << CDNS_PCIE_LM_RP_RID_SHIFT) & CDNS_PCIE_LM_RP_RID_MASK) + +/* Root Complex BAR Configuration Register */ +#define CDNS_PCIE_LM_RC_BAR_CFG (CDNS_PCIE_LM_BASE + 0x0300) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE_MASK GENMASK(5, 0) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE (a) \ + (((a) << 0) & CDNS_PCIE_LM_RC_BAR_CFG_BAR0_APERTURE_MASK) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL_MASK GENMASK(8, 6) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL (c) \ + (((c) << 6) & CDNS_PCIE_LM_RC_BAR_CFG_BAR0_CTRL_MASK) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE_MASK GENMASK(13, 9) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE (a) \ + (((a) << 9) & CDNS_PCIE_LM_RC_BAR_CFG_BAR1_APERTURE_MASK) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL_MASK GENMASK(16, 14) +#define CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL (c) \ + (((c) << 14) & CDNS_PCIE_LM_RC_BAR_CFG_BAR1_CTRL_MASK) +#define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_ENABLE BIT(17) +#define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_32BITS 0 +#define CDNS_PCIE_LM_RC_BAR_CFG_PREFETCH_MEM_64BITS BIT(18) +#define CDNS_PCIE_LM_RC_BAR_CFG_IO_ENABLE BIT(19) +#define CDNS_PCIE_LM_RC_BAR_CFG_IO_16BITS 0 +#define CDNS_PCIE_LM_RC_BAR_CFG_IO_32BITS BIT(20) +#define CDNS_PCIE_LM_RC_BAR_CFG_CHECK_ENABLE BIT(31) + +/* BAR control values applicable to both Endpoint Function and Root Complex */ +#define CDNS_PCIE_LM_BAR_CFG_CTRL_DISABLED 0x0 +#define CDNS_PCIE_LM_BAR_CFG_CTRL_IO_32BITS 0x1 +#define CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_32BITS 0x4 +#define CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_32BITS 0x5 +#define CDNS_PCIE_LM_BAR_CFG_CTRL_MEM_64BITS 0x6 +#define CDNS_PCIE_LM_BAR_CFG_CTRL_PREFETCH_MEM_64BITS 0x7 + + +/* +* Root Port Registers (PCI configuration space for the root port function) +*/ +#define CDNS_PCIE_RP_BASE 0x00200000 + + +/* +* Address Translation Registers +*/ +#define CDNS_PCIE_AT_BASE 0x00400000 + +/* Region r Outbound AXI to PCIe Address Translation Register 0 */ +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0 (r) \ + (CDNS_PCIE_AT_BASE + 0x0000 + ((r) & 0x1f) * 0x0020) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS_MASK GENMASK(5, 0) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS (nbits) \ + (((nbits) - 1) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_NBITS_MASK) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN_MASK GENMASK(19, 12) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN (devfn) \ + (((devfn) << 12) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_DEVFN_MASK) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS_MASK GENMASK(27, 20) +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS (bus) \ + (((bus) << 20) & CDNS_PCIE_AT_OB_REGION_PCI_ADDR0_BUS_MASK) + +/* Region r Outbound AXI to PCIe Address Translation Register 1 */ +#define CDNS_PCIE_AT_OB_REGION_PCI_ADDR1 (r) \ + (CDNS_PCIE_AT_BASE + 0x0004 + ((r) & 0x1f) * 0x0020) + +/* Region r Outbound PCIe Descriptor Register 0 */ +#define CDNS_PCIE_AT_OB_REGION_DESC0 (r) \ + (CDNS_PCIE_AT_BASE + 0x0008 + ((r) & 0x1f) * 0x0020) +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MASK GENMASK(3, 0) +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_MEM 0x2 +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_IO 0x6 +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE0 0xa +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_CONF_TYPE1 0xb +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_NORMAL_MSG 0xc +#define CDNS_PCIE_AT_OB_REGION_DESC0_TYPE_VENDOR_MSG 0xd +/* Bit 23 MUST be set in RC mode. */ +#define CDNS_PCIE_AT_OB_REGION_DESC0_HARDCODED_RID BIT(23) +#define CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN_MASK GENMASK(31, 24) +#define CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN (devfn) \ + (((devfn) << 24) & CDNS_PCIE_AT_OB_REGION_DESC0_DEVFN_MASK) + +/* Region r Outbound PCIe Descriptor Register 1 */ +#define CDNS_PCIE_AT_OB_REGION_DESC1 (r) \ + (CDNS_PCIE_AT_BASE + 0x000c + ((r) & 0x1f) * 0x0020) +#define CDNS_PCIE_AT_OB_REGION_DESC1_BUS_MASK GENMASK(7, 0) +#define CDNS_PCIE_AT_OB_REGION_DESC1_BUS (bus) \ + ((bus) & CDNS_PCIE_AT_OB_REGION_DESC1_BUS_MASK) + +/* Region r AXI Region Base Address Register 0 */ +#define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0 (r) \ + (CDNS_PCIE_AT_BASE + 0x0018 + ((r) & 0x1f) * 0x0020) +#define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS_MASK GENMASK(5, 0) +#define CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS (nbits) \ + (((nbits) - 1) & CDNS_PCIE_AT_OB_REGION_CPU_ADDR0_NBITS_MASK) + +/* Region r AXI Region Base Address Register 1 */ +#define CDNS_PCIE_AT_OB_REGION_CPU_ADDR1 (r) \ + (CDNS_PCIE_AT_BASE + 0x001c + ((r) & 0x1f) * 0x0020) + +/* Root Port BAR Inbound PCIe to AXI Address Translation Register */ +#define CDNS_PCIE_AT_IB_RP_BAR_ADDR0 (bar) \ + (CDNS_PCIE_AT_BASE + 0x0800 + (bar) * 0x0008) +#define CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS_MASK GENMASK(5, 0) +#define CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS (nbits) \ + (((nbits) - 1) & CDNS_PCIE_AT_IB_RP_BAR_ADDR0_NBITS_MASK) +#define CDNS_PCIE_AT_IB_RP_BAR_ADDR1 (bar) \ + (CDNS_PCIE_AT_BASE + 0x0804 + (bar) * 0x0008) + +enum cdns_pcie_rp_bar { +RP_BAR0 , +RP_BAR1 , +RP_NO_BAR +}; + +/** +* struct cdns_pcie - private data for Cadence PCIe controller drivers +* @reg_base: IO mapped register base +* @mem_res: start/end offsets in the physical system memory to map PCI accesses +* @is_rc: tell whether the PCIe controller mode is Root Complex or Endpoint. +* @bus: In Root Complex mode, the bus number +*/ +struct cdns_pcie { +void __iomem *reg_base; +struct resource *mem_res; +bool is_rc; +u8 bus; +}; + +/* Register access */ +static inline void cdns_pcie_writeb (struct cdns_pcie *pcie,u32 reg,u8 value) +{ +writeb (value, pcie->reg_base + reg); +} + +static inline void cdns_pcie_writew (struct cdns_pcie *pcie,u32 reg,u16 value) +{ +writew (value, pcie->reg_base + reg); +} + +static inline void cdns_pcie_writel (struct cdns_pcie *pcie,u32 reg,u32 value) +{ +writel (value, pcie->reg_base + reg); +} + +static inline u32 cdns_pcie_readl (struct cdns_pcie *pcie,u32 reg) +{ +return readl (pcie->reg_base + reg); +} + +/* Root Port register access */ +static inline void cdns_pcie_rp_writeb (struct cdns_pcie *pcie, +u32 reg,u8 value) +{ +writeb (value, pcie->reg_base +CDNS_PCIE_RP_BASE + reg); +} + +static inline void cdns_pcie_rp_writew (struct cdns_pcie *pcie, +u32 reg,u16 value) +{ +writew (value, pcie->reg_base +CDNS_PCIE_RP_BASE + reg); +} +
Quoted 8 lines
drivers/pci/cadence/pcie-cadence.h line 194
Quoted 4 lines
drivers/pci/cadence/pcie-cadence.h new file +4
-0+void cdns_pcie_set_outbound_region (struct cdns_pcie *pcie,u32 r,bool is_io, +u64 cpu_addr,u64 pci_addr,size_t size); + +void cdns_pcie_reset_outbound_region (struct cdns_pcie *pcie,u32 r);Ditto. I understand it is hard to untangle code that was written with both EP and host bridge support in mind but, as I state below every patch has to make sense on its own.
done in v4.
Quoted 9 lines
drivers/pci/cadence/pcie-cadence.h line 196
Quoted 3 lines
drivers/pci/cadence/pcie-cadence.h new file +2
-0+ +#endif /* _PCIE_CADENCE_H */ Technically speaking, this 3-file (.c .h) split is not necessary and can turn out unnecessary churn if we never merge the endpoint code - actually you would not even need a special cadence directory, just a host bridge driver file.
Quoted 7 lines
Bottom line, as you know: every patch has to be self contained.
It is already quite late -rc, I understand that changes this late are error prone so I will accept that this file splitting is necessary for "future" patches - if you manage to squash changes into a file I'd appreciate though, it does not make sense to export functions that are used in just one compilation unit (and some that are not used at all).
Sorry, I didn't have time to squash the 3 files into a single one. I can do it in v5 if you think it's better. I plan to work on the endpoint driver with multi-functions this week-end, hence I hope I will be able to add this driver back in v5.
I've just been sending v4 anyway so at least you will have former patch 3 from v3 split into new patches 3 and 4 in v4 as you requested. So if you want to merge at least the new generic patches [1 - 4] for v4.16, they are available :)
Best regards,
Cyrille
Quoted 4 lines
Thanks,
Lorenzo
Signature · 7 lines
Cyrille Pitchen, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com -- 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