PCI: Support for configurable PCI endpoint
Subsystems (11)
Please find the pull request for PCI endpoint support below. I've also included all the history here.
Changes from v3:
*) fixed a typo and adapted to https://lkml.org/lkml/2017/3/13/562.
Changes from v2:
*) changed the configfs structure as suggested by Christoph Hellwig. With
this change the framework creates configfs entry for EP function driver and EP controller. Previously these entries have to be created by the the user. (Haven't changed the epc core or epf core except for invoking configfs APIs to create entries for EP function driver and EP controller. That's mostly because the EP function device can still be created by directly invoking the epf core API without using configfs).
*) Now the user has to use configfs entry 'start' to start the link.
This was previously done by the function driver. However in the case of multi function EP, the function driver shouldn't start the link.
Changes from v1:
*) The preparation patches for adding EP support is removed and is sent
separately
*) Added device ID for DRA74x/DRA72x and used it instead of
using "PCI_ANY_ID"
*) Added userguide for PCI endpoint test function
Major Improvements from RFC:
*) support multi-function devices (hw supported not virtual) *) Access host side buffers
*) Raise MSI interrupts
*) Add user space program to use the host side PCI driver *) Adapt all other users of designware to use the new design (only
compile tested. Since I have only dra7xx boards, the new design has only been tested in dra7xx. I'd require the help of others to test the platforms they have access to).
This series has been developed over 4.11-rc1 + [1]
[1] -> https://www.mail-archive.com/linux-kernel at vger.kernel.org/msg1348667.html
The following changes since commit 29b1586a2e7d564dd801c5792122bdf00fab0cec:
PCI: dwc: dra7xx: Push request_irq call to the bottom of probe (2017-03-13 19:17:10 +0530)
are available in the git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/kishon/pci-endpoint.git tags/pci-endpoint-for-4.12
for you to fetch changes up to 6a02235543fb24f2468cba3b02f75d6c44ff9262:
ARM: DRA7: clockdomain: Change the CLKTRCTRL of CM_PCIE_CLKSTCTRL to SW_WKUP (2017-03-13 19:23:04 +0530)
----------------------------------------------------------------
pci: endpoint: for 4.12
*) Add PCI endpoint core layer
*) Modify designware and dra7xx driver to be configured in EP mode *) Add a PCI endpoint *test* function driver and corresponding host
driver
----------------------------------------------------------------
Kishon Vijay Abraham I (23):
PCI: endpoint: Add EP core layer to enable EP controller and EP functions
Documentation: PCI: Guide to use PCI Endpoint Core Layer
PCI: endpoint: Introduce configfs entry for configuring EP functions
Documentation: PCI: Guide to use pci endpoint configfs
PCI: endpoint: Create configfs entry for EPC device and EPF driver
Documentation: PCI: Add specification for the *pci test* function device
PCI: endpoint: functions: Add an EP function to test PCI
Documentation: PCI: Add binding documentation for pci-test endpoint function
PCI: dwc: designware: Add EP mode support
dt-bindings: PCI: Add dt bindings for pci designware EP mode
PCI: dwc: dra7xx: Facilitate wrapper and msi interrupts to be enabled independently
PCI: dwc: dra7xx: Add EP mode support
dt-bindings: PCI: dra7xx: Add dt bindings for pci dra7xx EP mode
PCI: dwc: dra7xx: Workaround for errata id i870
dt-bindings: PCI: dra7xx: Add dt bindings to enable unaligned access
PCI: Add device IDs for DRA74x and DRA72x
misc: Add host side pci driver for pci test function device
Documentation: misc-devices: Add Documentation for pci-endpoint-test driver
tools: PCI: Add a userspace tool to test PCI endpoint
tools: PCI: Add sample test script to invoke pcitest
Documentation: PCI: Add userguide for PCI endpoint test function
MAINTAINERS: add PCI EP maintainer
ARM: DRA7: clockdomain: Change the CLKTRCTRL of CM_PCIE_CLKSTCTRL to SW_WKUP
Documentation/PCI/00-INDEX | 10 +++ Documentation/PCI/endpoint/function/binding/pci-test.txt | 17 +++++ Documentation/PCI/endpoint/pci-endpoint-cfs.txt | 105 ++++++++++++++++++++++++++ Documentation/PCI/endpoint/pci-endpoint.txt | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++++ Documentation/PCI/endpoint/pci-test-function.txt | 66 ++++++++++++++++ Documentation/PCI/endpoint/pci-test-howto.txt | 179 +++++++++++++++++++++++++++++++++++++++++++ Documentation/devicetree/bindings/pci/designware-pcie.txt | 26 +++++-- Documentation/devicetree/bindings/pci/ti-pci.txt | 42 +++++++++-- Documentation/misc-devices/pci-endpoint-test.txt | 35 +++++++++ MAINTAINERS | 9 +++ arch/arm/mach-omap2/clockdomains7xx_data.c | 2 +- drivers/Makefile | 2 + drivers/misc/Kconfig | 7 ++ drivers/misc/Makefile | 1 + drivers/misc/pci_endpoint_test.c | 534 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/Kconfig | 1 + drivers/pci/dwc/Kconfig | 36 ++++++++- drivers/pci/dwc/Makefile | 5 +- drivers/pci/dwc/pci-dra7xx.c | 274 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----- drivers/pci/dwc/pcie-designware-ep.c | 342 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/dwc/pcie-designware.c | 125 ++++++++++++++++++++++++++++++ drivers/pci/dwc/pcie-designware.h | 112 +++++++++++++++++++++++++++ drivers/pci/endpoint/Kconfig | 31 ++++++++ drivers/pci/endpoint/Makefile | 7 ++ drivers/pci/endpoint/functions/Kconfig | 12 +++ drivers/pci/endpoint/functions/Makefile | 5 ++ drivers/pci/endpoint/functions/pci-epf-test.c | 510 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-ep-cfs.c | 509 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epc-core.c | 579 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epc-mem.c | 143 +++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epf-core.c | 351 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ include/linux/mod_devicetable.h | 10 +++ include/linux/pci-ep-cfs.h | 41 ++++++++++ include/linux/pci-epc.h | 144 +++++++++++++++++++++++++++++++++++ include/linux/pci-epf.h | 162 +++++++++++++++++++++++++++++++++++++++ include/linux/pci_ids.h | 2 + include/uapi/linux/Kbuild | 1 + include/uapi/linux/pcitest.h | 19 +++++ tools/pci/pcitest.c | 186 +++++++++++++++++++++++++++++++++++++++++++++ tools/pci/pcitest.sh | 56 ++++++++++++++ 40 files changed, 4873 insertions(+), 40 deletions(-) create mode 100644 Documentation/PCI/endpoint/function/binding/pci-test.txt create mode 100644 Documentation/PCI/endpoint/pci-endpoint-cfs.txt create mode 100644 Documentation/PCI/endpoint/pci-endpoint.txt create mode 100644 Documentation/PCI/endpoint/pci-test-function.txt create mode 100644 Documentation/PCI/endpoint/pci-test-howto.txt create mode 100644 Documentation/misc-devices/pci-endpoint-test.txt create mode 100644 drivers/misc/pci_endpoint_test.c create mode 100644 drivers/pci/dwc/pcie-designware-ep.c create mode 100644 drivers/pci/endpoint/Kconfig create mode 100644 drivers/pci/endpoint/Makefile create mode 100644 drivers/pci/endpoint/functions/Kconfig create mode 100644 drivers/pci/endpoint/functions/Makefile create mode 100644 drivers/pci/endpoint/functions/pci-epf-test.c create mode 100644 drivers/pci/endpoint/pci-ep-cfs.c create mode 100644 drivers/pci/endpoint/pci-epc-core.c create mode 100644 drivers/pci/endpoint/pci-epc-mem.c create mode 100644 drivers/pci/endpoint/pci-epf-core.c create mode 100644 include/linux/pci-ep-cfs.h create mode 100644 include/linux/pci-epc.h create mode 100644 include/linux/pci-epf.h create mode 100644 include/uapi/linux/pcitest.h create mode 100644 tools/pci/pcitest.c create mode 100644 tools/pci/pcitest.sh
Signature · 1 line
2.11.0
PATCH v4 1/23 PCI: endpoint: Add EP core layer to enable EP controller and EP functions
Introduce a new EP core layer in order to support endpoint functions in linux kernel. This comprises of EPC library
(Endpoint Controller Library) and EPF library (Endpoint Function Library). EPC library implements functions that is specific to an endpoint controller and EPF library implements functions that is specific to an endpoint function.
--- drivers/Makefile | 2 + drivers/pci/Kconfig | 1 + drivers/pci/endpoint/Kconfig | 20 ++ drivers/pci/endpoint/Makefile | 6 + drivers/pci/endpoint/pci-epc-core.c | 575 ++++++++++++++++++++++++++++++++++++ drivers/pci/endpoint/pci-epc-mem.c | 143 +++++++++ drivers/pci/endpoint/pci-epf-core.c | 347 ++++++++++++++++++++++ include/linux/mod_devicetable.h | 10 + include/linux/pci-epc.h | 142 +++++++++ include/linux/pci-epf.h | 160 ++++++++++ 10 files changed, 1406 insertions(+) create mode 100644 drivers/pci/endpoint/Kconfig create mode 100644 drivers/pci/endpoint/Makefile create mode 100644 drivers/pci/endpoint/pci-epc-core.c create mode 100644 drivers/pci/endpoint/pci-epc-mem.c create mode 100644 drivers/pci/endpoint/pci-epf-core.c create mode 100644 include/linux/pci-epc.h create mode 100644 include/linux/pci-epf.h
drivers/Makefile +2 -0
@@ -14,7 +14,9 @@ obj-$(CONFIG_GENERIC_PHY) += phy/ 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/
drivers/pci/Kconfig +1 -0
@@ -134,3 +134,4 @@ config PCI_HYPERV source "drivers/pci/hotplug/Kconfig" source "drivers/pci/dwc/Kconfig" source "drivers/pci/host/Kconfig" +source "drivers/pci/endpoint/Kconfig"
drivers/pci/endpoint/Kconfig new file +20 -0
@@ -0,0 +1,20 @@ +# +# PCI Endpoint Support +# + +menu "PCI Endpoint" + +config PCI_ENDPOINT + bool "PCI Endpoint Support" + help + Enable this configuration option to support configurable PCI + endpoint. This should be enabled if the platform has a PCI + controller that can operate in endpoint mode. + + Enabling this option will build the endpoint library, which + includes endpoint controller library and endpoint function + library. + + If in doubt, say "N" to disable Endpoint support. + +endmenu
drivers/pci/endpoint/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for PCI Endpoint Support +# + +obj-$(CONFIG_PCI_ENDPOINT) += pci-epc-core.o pci-epf-core.o\ + pci-epc-mem.o
drivers/pci/endpoint/pci-epc-core.c new file +575 -0
575 lines not on this page · raw message
drivers/pci/endpoint/pci-epc-mem.c new file +143 -0
143 lines not on this page · raw message
drivers/pci/endpoint/pci-epf-core.c new file +347 -0
347 lines not on this page · raw message
include/linux/mod_devicetable.h +10 -0
@@ -428,6 +428,16 @@ struct i2c_device_id {kernel_ulong_t driver_data;/* Data private to the driver */ }; +/* pci_epf */ + +#define PCI_EPF_NAME_SIZE 20 +#define PCI_EPF_MODULE_PREFIX "pci_epf:" + +struct pci_epf_device_id { +char name[PCI_EPF_NAME_SIZE ]; +kernel_ulong_t driver_data; +}; +/* spi */ #define SPI_NAME_SIZE 32
include/linux/pci-epc.h new file +142 -0
142 lines not on this page · raw message
include/linux/pci-epf.h new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v4 2/23 Documentation: PCI: Guide to use PCI Endpoint Core Layer
In reply to Kishon Vijay Abraham IAdd Documentation to help users use endpoint library to enable endpoint mode in the PCI controller and add new PCI endpoint functions.
--- Documentation/PCI/00-INDEX | 2 + Documentation/PCI/endpoint/pci-endpoint.txt | 215 ++++++++++++++++++++++++++++ 2 files changed, 217 insertions(+) create mode 100644 Documentation/PCI/endpoint/pci-endpoint.txt
Documentation/PCI/00-INDEX +2 -0
@@ -12,3 +12,5 @@ pci.txt - info on the PCI subsystem for device driver authors pcieaer-howto.txt - the PCI Express Advanced Error Reporting Driver Guide HOWTO +endpoint/pci-endpoint.txt + - guide to add endpoint controller driver and endpoint function driver.
Documentation/PCI/endpoint/pci-endpoint.txt new file +215 -0
215 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v4 3/23 PCI: endpoint: Introduce configfs entry for configuring EP functions
In reply to Kishon Vijay Abraham IIntroduce a new configfs entry to configure the EP function (like configuring the standard configuration header entries) and to bind the EP function with EP controller.
--- drivers/pci/endpoint/Kconfig | 9 + drivers/pci/endpoint/Makefile | 1 + drivers/pci/endpoint/pci-ep-cfs.c | 509 ++++++++++++++++++++++++++++++++++++++ include/linux/pci-ep-cfs.h | 41 +++ 4 files changed, 560 insertions(+) create mode 100644 drivers/pci/endpoint/pci-ep-cfs.c create mode 100644 include/linux/pci-ep-cfs.h
drivers/pci/endpoint/Kconfig +9 -0
@@ -17,4 +17,13 @@ config PCI_ENDPOINT If in doubt, say "N" to disable Endpoint support. +config PCI_ENDPOINT_CONFIGFS + bool "PCI Endpoint Configfs Support" + depends on PCI_ENDPOINT + select CONFIGFS_FS + help + This will enable the configfs entry that can be used to + configure the endpoint function and used to bind the + function with a endpoint controller. + endmenu
drivers/pci/endpoint/Makefile +1 -0
@@ -2,5 +2,6 @@ # Makefile for PCI Endpoint Support # +obj-$(CONFIG_PCI_ENDPOINT_CONFIGFS) += pci-ep-cfs.o obj-$(CONFIG_PCI_ENDPOINT) += pci-epc-core.o pci-epf-core.o\ pci-epc-mem.o
drivers/pci/endpoint/pci-ep-cfs.c new file +509 -0
509 lines not on this page · raw message
include/linux/pci-ep-cfs.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v4 4/23 Documentation: PCI: Guide to use pci endpoint configfs
In reply to Kishon Vijay Abraham IAdd Documentation to help users use pci endpoint to configure pci endpoint function and to bind the endpoint function with endpoint controller.
--- Documentation/PCI/00-INDEX | 2 + Documentation/PCI/endpoint/pci-endpoint-cfs.txt | 105 ++++++++++++++++++++++++ 2 files changed, 107 insertions(+) create mode 100644 Documentation/PCI/endpoint/pci-endpoint-cfs.txt
Documentation/PCI/00-INDEX +2 -0
@@ -14,3 +14,5 @@ pcieaer-howto.txt - the PCI Express Advanced Error Reporting Driver Guide HOWTO endpoint/pci-endpoint.txt - guide to add endpoint controller driver and endpoint function driver. +endpoint/pci-endpoint-cfs.txt + - guide to use configfs to configure the pci endpoint function.
Documentation/PCI/endpoint/pci-endpoint-cfs.txt new file +105 -0
105 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v4 5/23 PCI: endpoint: Create configfs entry for EPC device and EPF driver
In reply to Kishon Vijay Abraham IInvoke API's provided by pci-ep-cfs to create configfs entry for every EPC device and EPF driver to help users in creating EPF device and binding the EPF device to the EPC device.
--- drivers/pci/endpoint/pci-epc-core.c | 4 ++++ drivers/pci/endpoint/pci-epf-core.c | 4 ++++ include/linux/pci-epc.h | 2 ++ include/linux/pci-epf.h | 2 ++ 4 files changed, 12 insertions(+)
drivers/pci/endpoint/pci-epc-core.c +4 -0
@@ -24,6 +24,7 @@#include <linux/pci-epc.h> #include <linux/pci-epf.h> +#include <linux/pci-ep-cfs.h> static struct class *pci_epc_class;
@@ -441,6 +442,7 @@ EXPORT_SYMBOL_GPL(pci_epc_linkup);*/ void pci_epc_destroy (struct pci_epc *epc) { +pci_ep_cfs_remove_epc_group (epc->group);device_unregister (&epc->dev);kfree (epc); }
@@ -507,6 +509,8 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops,if (ret) goto put_dev; + epc->group =pci_ep_cfs_add_epc_group (dev_name (dev)); +return epc; put_dev:
drivers/pci/endpoint/pci-epf-core.c +4 -0
@@ -24,6 +24,7 @@#include <linux/pci-epc.h> #include <linux/pci-epf.h> +#include <linux/pci-ep-cfs.h> static struct bus_type pci_epf_bus_type;static struct device_type pci_epf_type;
@@ -143,6 +144,7 @@ EXPORT_SYMBOL_GPL(pci_epf_alloc_space);*/ void pci_epf_unregister_driver (struct pci_epf_driver *driver) { +pci_ep_cfs_remove_epf_group (driver->group);driver_unregister (&driver->driver); }EXPORT_SYMBOL_GPL (pci_epf_unregister_driver);
@@ -172,6 +174,8 @@ int __pci_epf_register_driver(struct pci_epf_driver *driver,if (ret)return ret; + driver->group =pci_ep_cfs_add_epf_group (driver->driver.name); +return 0 ; }EXPORT_SYMBOL_GPL (__pci_epf_register_driver);
include/linux/pci-epc.h +2 -0
@@ -77,6 +77,7 @@ struct pci_epc_mem {* @ops: function pointers for performing endpoint operations * @mem: address space of the endpoint controller * @max_functions: max number of functions that can be configured in this EPC +* @group: configfs group representing the PCI EPC device * @lock: spinlock to protect pci_epc ops */ struct pci_epc {
@@ -85,6 +86,7 @@ struct pci_epc {const struct pci_epc_ops *ops;struct pci_epc_mem *mem;u8 max_functions; +struct config_group *group;/* spinlock to protect against concurrent access of EP controller */ spinlock_t lock; };
include/linux/pci-epf.h +2 -0
@@ -82,6 +82,7 @@ struct pci_epf_ops {* @driver: PCI EPF driver * @ops: set of function pointers for performing EPF operations * @owner: the owner of the module that registers the PCI EPF driver +* @group: configfs group corresponding to the PCI EPF driver * @id_table: identifies EPF devices for probing */ struct pci_epf_driver {
@@ -91,6 +92,7 @@ struct pci_epf_driver {struct device_driver driver;struct pci_epf_ops *ops;struct module *owner; +struct config_group *group;const struct pci_epf_device_id *id_table; };
Signature · 1 line
2.11.0
PATCH v4 6/23 Documentation: PCI: Add specification for the *pci test* function device
In reply to Kishon Vijay Abraham IAdd specification for the *pci test* virtual function device. The endpoint function driver and the host pci driver should be created based on this specification.
--- Documentation/PCI/00-INDEX | 2 + Documentation/PCI/endpoint/pci-test-function.txt | 66 ++++++++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 Documentation/PCI/endpoint/pci-test-function.txt
Documentation/PCI/00-INDEX +2 -0
@@ -16,3 +16,5 @@ endpoint/pci-endpoint.txt - guide to add endpoint controller driver and endpoint function driver. endpoint/pci-endpoint-cfs.txt - guide to use configfs to configure the pci endpoint function. +endpoint/pci-test-function.txt + - specification of *pci test* function device.
Documentation/PCI/endpoint/pci-test-function.txt new file +66 -0
66 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v4 7/23 PCI: endpoint: functions: Add an EP function to test PCI
In reply to Kishon Vijay Abraham IAdds a new endpoint function driver (to program the virtual test device) making use of the EP-core library.
--- drivers/pci/endpoint/Kconfig | 2 + drivers/pci/endpoint/Makefile | 2 +- drivers/pci/endpoint/functions/Kconfig | 12 + drivers/pci/endpoint/functions/Makefile | 5 + drivers/pci/endpoint/functions/pci-epf-test.c | 510 ++++++++++++++++++++++++++ 5 files changed, 530 insertions(+), 1 deletion(-) create mode 100644 drivers/pci/endpoint/functions/Kconfig create mode 100644 drivers/pci/endpoint/functions/Makefile create mode 100644 drivers/pci/endpoint/functions/pci-epf-test.c
drivers/pci/endpoint/Kconfig +2 -0
@@ -26,4 +26,6 @@ config PCI_ENDPOINT_CONFIGFS configure the endpoint function and used to bind the function with a endpoint controller. +source "drivers/pci/endpoint/functions/Kconfig" + endmenu
drivers/pci/endpoint/Makefile +1 -1
@@ -4,4 +4,4 @@ obj-$(CONFIG_PCI_ENDPOINT_CONFIGFS) += pci-ep-cfs.o obj-$(CONFIG_PCI_ENDPOINT) += pci-epc-core.o pci-epf-core.o\ - pci-epc-mem.o + pci-epc-mem.o functions/
drivers/pci/endpoint/functions/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +# +# PCI Endpoint Functions +# + +config PCI_EPF_TEST + tristate "PCI Endpoint Test driver" + depends on PCI_ENDPOINT + help + Enable this configuration option to enable the test driver + for PCI Endpoint. + + If in doubt, say "N" to disable Endpoint test driver.
drivers/pci/endpoint/functions/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# +# Makefile for PCI Endpoint Functions +# + +obj-$(CONFIG_PCI_EPF_TEST) += pci-epf-test.o
drivers/pci/endpoint/functions/pci-epf-test.c new file +510 -0
510 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v4 8/23 Documentation: PCI: Add binding documentation for pci-test endpoint function
In reply to Kishon Vijay Abraham IAdd binding documentation for pci-test endpoint function that helps in adding and configuring pci-test endpoint function.
--- Documentation/PCI/00-INDEX | 2 ++ .../PCI/endpoint/function/binding/pci-test.txt | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 Documentation/PCI/endpoint/function/binding/pci-test.txt
Documentation/PCI/00-INDEX +2 -0
@@ -18,3 +18,5 @@ endpoint/pci-endpoint-cfs.txt - guide to use configfs to configure the pci endpoint function. endpoint/pci-test-function.txt - specification of *pci test* function device. +endpoint/function/binding/ + - binding documentation for pci endpoint function
Documentation/PCI/endpoint/function/binding/pci-test.txt new file +17 -0
@@ -0,0 +1,17 @@ +PCI TEST ENDPOINT FUNCTION + +name: Should be "pci_epf_test" to bind to the pci_epf_test driver. + +Configurable Fields: +vendorid : should be 0x104c +deviceid : should be 0xb500 for DRA74x and 0xb501 for DRA72x +revid : don't care +progif_code : don't care +subclass_code : don't care +baseclass_code : should be 0xff +cache_line_size : don't care +subsys_vendor_id : don't care +subsys_id : don't care +interrupt_pin : Should be 1 - INTA, 2 - INTB, 3 - INTC, 4 -INTD +msi_interrupts : Should be 1 to 32 depending on the number of msi interrupts + to test
Signature · 1 line
2.11.0
PATCH v4 9/23 PCI: dwc: designware: Add EP mode support
In reply to Kishon Vijay Abraham IAdd endpoint mode support to designware driver. This uses the EP Core layer introduced recently to add endpoint mode support. *Any* function driver can now use this designware device in order to achieve the EP functionality.
--- drivers/pci/dwc/Kconfig | 5 + drivers/pci/dwc/Makefile | 1 + drivers/pci/dwc/pcie-designware-ep.c | 342 +++++++++++++++++++++++++++++++++++ drivers/pci/dwc/pcie-designware.c | 125 +++++++++++++ drivers/pci/dwc/pcie-designware.h | 105 +++++++++++ 5 files changed, 578 insertions(+) create mode 100644 drivers/pci/dwc/pcie-designware-ep.c
drivers/pci/dwc/Kconfig +5 -0
@@ -9,6 +9,11 @@ config PCIE_DW_HOST depends on PCI_MSI_IRQ_DOMAIN select PCIE_DW +config PCIE_DW_EP + bool + depends on PCI_ENDPOINT + select PCIE_DW + config PCI_DRA7XX bool "TI DRA7xx PCIe controller" depends on PCI
drivers/pci/dwc/Makefile +1 -0
@@ -1,5 +1,6 @@ obj-$(CONFIG_PCIE_DW) += pcie-designware.o obj-$(CONFIG_PCIE_DW_HOST) += pcie-designware-host.o +obj-$(CONFIG_PCIE_DW_EP) += pcie-designware-ep.o obj-$(CONFIG_PCIE_DW_PLAT) += pcie-designware-plat.o obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o
drivers/pci/dwc/pcie-designware-ep.c new file +342 -0
342 lines not on this page · raw message
drivers/pci/dwc/pcie-designware.c +125 -0
131 lines not on this page · raw message
drivers/pci/dwc/pcie-designware.h +105 -0
164 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v4 10/23 dt-bindings: PCI: Add dt bindings for pci designware EP mode
In reply to Kishon Vijay Abraham IAdd device tree binding documentation for pci designware EP mode.
--- .../devicetree/bindings/pci/designware-pcie.txt | 26 +++++++++++++++------- 1 file changed, 18 insertions(+), 8 deletions(-)
Documentation/devicetree/bindings/pci/designware-pcie.txt +18 -8
@@ -6,30 +6,40 @@ Required properties: - reg-names: Must be "config" for the PCIe configuration space. (The old way of getting the configuration address space from "ranges" is deprecated and should be avoided.) +- num-lanes: number of lanes to use +RC mode: - #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 +- interrupt-map-mask and interrupt-map: standard PCI + properties to define the mapping of the PCIe interface to interrupt numbers. -- num-lanes: number of lanes to use +EP mode: +- num-ib-windows: number of inbound address translation + windows +- num-ob-windows: number of outbound address translation + windows Optional properties: -- num-viewport: number of view ports configured in hardware. If a platform - does not specify it, the driver assumes 2. - num-lanes: number of lanes to use (this property should be specified unless the link is brought already up in BIOS) - reset-gpio: gpio pin number of power good signal -- bus-range: PCI bus numbers covered (it is recommended for new devicetrees to - specify this property, to keep backwards compatibility a range of 0x00-0xff - is assumed if not present) - clocks: Must contain an entry for each entry in clock-names. See ../clocks/clock-bindings.txt for details. - clock-names: Must include the following entries: - "pcie" - "pcie_bus" +RC mode: +- num-viewport: number of view ports configured in + hardware. If a platform does not specify it, the driver assumes 2. +- bus-range: PCI bus numbers covered (it is recommended + for new devicetrees to specify this property, to keep backwards + compatibility a range of 0x00-0xff is assumed if not present) +EP mode: +- max-functions: maximum number of functions that can be + configured Example configuration:
Signature · 1 line
2.11.0
PATCH v4 11/23 PCI: dwc: dra7xx: Facilitate wrapper and msi interrupts to be enabled independently
In reply to Kishon Vijay Abraham INo functional change. Split dra7xx_pcie_enable_interrupts into dra7xx_pcie_enable_wrapper_interrupts and dra7xx_pcie_enable_msi_interrupts so that wrapper interrupts and msi interrupts can be enabled independently. This is in preparation for adding EP mode support to dra7xx driver since EP mode doesn't have to enable msi_interrupts.
--- drivers/pci/dwc/pci-dra7xx.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-)
drivers/pci/dwc/pci-dra7xx.c +18 -6
@@ -140,18 +140,30 @@ static int dra7xx_pcie_establish_link(struct dra7xx_pcie *dra7xx)return dw_pcie_wait_for_link (pci); } -static void dra7xx_pcie_enable_interrupts (struct dra7xx_pcie *dra7xx) +static void dra7xx_pcie_enable_msi_interrupts (struct dra7xx_pcie *dra7xx) { -dra7xx_pcie_writel (dra7xx,PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN , - ~INTERRUPTS ); -dra7xx_pcie_writel (dra7xx, -PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN ,INTERRUPTS );dra7xx_pcie_writel (dra7xx,PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI , ~LEG_EP_INTERRUPTS & ~MSI ); -dra7xx_pcie_writel (dra7xx,PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI , + +dra7xx_pcie_writel (dra7xx, +PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MSI ,MSI |LEG_EP_INTERRUPTS ); } +static void dra7xx_pcie_enable_wrapper_interrupts (struct dra7xx_pcie *dra7xx) +{ +dra7xx_pcie_writel (dra7xx,PCIECTRL_DRA7XX_CONF_IRQSTATUS_MAIN , + ~INTERRUPTS ); +dra7xx_pcie_writel (dra7xx,PCIECTRL_DRA7XX_CONF_IRQENABLE_SET_MAIN , +INTERRUPTS ); +} + +static void dra7xx_pcie_enable_interrupts (struct dra7xx_pcie *dra7xx) +{ +dra7xx_pcie_enable_wrapper_interrupts (dra7xx); +dra7xx_pcie_enable_msi_interrupts (dra7xx); +} +static void dra7xx_pcie_host_init (struct pcie_port *pp) {struct dw_pcie *pci =to_dw_pcie_from_pp (pp);
Signature · 1 line
2.11.0
PATCH v4 12/23 PCI: dwc: dra7xx: Add EP mode support
In reply to Kishon Vijay Abraham IThe PCIe controller integrated in dra7xx SoCs is capable of operating in endpoint mode. Add endpoint mode support to dra7xx driver.
--- drivers/pci/dwc/Kconfig | 31 +++++- drivers/pci/dwc/Makefile | 4 +- drivers/pci/dwc/pci-dra7xx.c | 197 +++++++++++++++++++++++++++++++++++--- drivers/pci/dwc/pcie-designware.h | 7 ++ 4 files changed, 221 insertions(+), 18 deletions(-)
drivers/pci/dwc/Kconfig +27 -4
@@ -16,14 +16,37 @@ config PCIE_DW_EP config PCI_DRA7XX bool "TI DRA7xx PCIe controller" - depends on PCI + depends on (PCI && PCI_MSI_IRQ_DOMAIN) || PCI_ENDPOINT depends on OF && HAS_IOMEM && TI_PIPE3 + help + Enables support for the PCIe controller in the DRA7xx SoC. There + are two instances of PCIe controller in DRA7xx. This controller can + work either as EP or RC. In order to enable host specific features + PCI_DRA7XX_HOST must be selected and in order to enable device + specific features PCI_DRA7XX_EP must be selected. This uses + the Designware core. + +if PCI_DRA7XX + +config PCI_DRA7XX_HOST + bool "PCI DRA7xx Host Mode" + depends on PCI depends on PCI_MSI_IRQ_DOMAIN select PCIE_DW_HOST + default y help - Enables support for the PCIe controller in the DRA7xx SoC. There - are two instances of PCIe controller in DRA7xx. This controller can - act both as EP and RC. This reuses the Designware core. + Enables support for the PCIe controller in the DRA7xx SoC to work in + host mode. + +config PCI_DRA7XX_EP + bool "PCI DRA7xx Endpoint Mode" + depends on PCI_ENDPOINT + select PCIE_DW_EP + help + Enables support for the PCIe controller in the DRA7xx SoC to work in + endpoint mode. + +endif config PCIE_DW_PLAT bool "Platform bus based DesignWare PCIe Controller"
drivers/pci/dwc/Makefile +3 -1
@@ -2,7 +2,9 @@ obj-$(CONFIG_PCIE_DW) += pcie-designware.o obj-$(CONFIG_PCIE_DW_HOST) += pcie-designware-host.o obj-$(CONFIG_PCIE_DW_EP) += pcie-designware-ep.o obj-$(CONFIG_PCIE_DW_PLAT) += pcie-designware-plat.o -obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o +ifneq ($(filter y,$(CONFIG_PCI_DRA7XX_HOST) $(CONFIG_PCI_DRA7XX_EP)),) + obj-$(CONFIG_PCI_DRA7XX) += pci-dra7xx.o +endif obj-$(CONFIG_PCI_EXYNOS) += pci-exynos.o obj-$(CONFIG_PCI_IMX6) += pci-imx6.o obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o
drivers/pci/dwc/pci-dra7xx.c +184 -13
307 lines not on this page · raw message
drivers/pci/dwc/pcie-designware.h +7 -0
@@ -120,6 +120,13 @@ enum dw_pcie_region_type { DW_PCIE_REGION_OUTBOUND, }; +enum dw_pcie_device_mode { +DW_PCIE_UNKNOWN_TYPE , +DW_PCIE_EP_TYPE , +DW_PCIE_LEG_EP_TYPE , +DW_PCIE_RC_TYPE , +}; +struct dw_pcie_host_ops {int (*rd_own_conf)(struct pcie_port *pp,int where,int size,u32 *val);int (*wr_own_conf)(struct pcie_port *pp,int where,int size,u32 val);
Signature · 1 line
2.11.0
PATCH v4 13/23 dt-bindings: PCI: dra7xx: Add dt bindings for pci dra7xx EP mode
In reply to Kishon Vijay Abraham IAdd device tree binding documentation for pci dra7xx EP mode.
--- Documentation/devicetree/bindings/pci/ti-pci.txt | 37 +++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-)
Documentation/devicetree/bindings/pci/ti-pci.txt +30 -7
@@ -1,17 +1,22 @@ TI PCI Controllers PCIe Designware Controller - - compatible: Should be "ti,dra7-pcie"" - - reg : Two register ranges as listed in the reg-names property - - reg-names : The first entry must be "ti-conf" for the TI specific registers - The second entry must be "rc-dbics" for the designware pcie - registers - The third entry must be "config" for the PCIe configuration space + - compatible: Should be "ti,dra7-pcie" for RC + Should be "ti,dra7-pcie-ep" for EP - phys : list of PHY specifiers (used by generic PHY framework) - phy-names : must be "pcie-phy0", "pcie-phy1", "pcie-phyN".. based on the number of PHYs as specified in *phys* property. - ti,hwmods : Name of the hwmod associated to the pcie, "pcie<X>", where <X> is the instance number of the pcie from the HW spec. + - num-lanes as specified in ../designware-pcie.txt + +HOST MODE +========= + - reg : Two register ranges as listed in the reg-names property + - reg-names : The first entry must be "ti-conf" for the TI specific registers + The second entry must be "rc-dbics" for the designware pcie + registers + The third entry must be "config" for the PCIe configuration space - interrupts : Two interrupt entries must be specified. The first one is for main interrupt line and the second for MSI interrupt line. - #address-cells,
@@ -19,13 +24,31 @@ PCIe Designware Controller #interrupt-cells, device_type, ranges, - num-lanes, interrupt-map-mask, interrupt-map : as specified in ../designware-pcie.txt +DEVICE MODE +=========== + - reg : Four register ranges as listed in the reg-names property + - reg-names : "ti-conf" for the TI specific registers + "ep_dbics" for the standard configuration registers as + they are locally accessed within the DIF CS space + "ep_dbics2" for the standard configuration registers as + they are locally accessed within the DIF CS2 space + "addr_space" used to map remote RC address space + - interrupts : one interrupt entries must be specified for main interrupt. + - num-ib-windows : number of inbound address translation windows + - num-ob-windows : number of outbound address translation windows + Optional Property: - gpios : Should be added if a gpio line is required to drive PERST# line +NOTE: Two dt nodes may be added for each PCI controller; one for host +mode and another for device mode. So in order for PCI to +work in host mode, EP mode dt node should be disabled and in order to PCI to +work in EP mode, host mode dt node should be disabled. And host mode and EP +mode are mutually exclusive. + Example: axi { compatible = "simple-bus";
Signature · 1 line
2.11.0
PATCH v4 14/23 PCI: dwc: dra7xx: Workaround for errata id i870
In reply to Kishon Vijay Abraham IAccording to errata i870, access to the PCIe slave port that are not 32-bit aligned will result in incorrect mapping to TLP Address and Byte enable fields.
Accessing non 32-bit aligned data causes incorrect data in the target buffer if memcpy is used. Implement the workaround for this errata here.
--- drivers/pci/dwc/pci-dra7xx.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/pci/dwc/pci-dra7xx.c +53 -0
@@ -26,6 +26,8 @@#include <linux/pm_runtime.h> #include <linux/resource.h> #include <linux/types.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h> #include "pcie-designware.h"
@@ -528,6 +530,51 @@ static const struct of_device_id of_dra7xx_pcie_match[] = { {}, }; +/* +* dra7xx_pcie_ep_unaligned_memaccess: workaround for AM572x/AM571x Errata i870 +* @dra7xx: the dra7xx device where the workaround should be applied +* +* Access to the PCIe slave port that are not 32-bit aligned will result +* in incorrect mapping to TLP Address and Byte enable fields. Therefore, +* byte and half-word accesses are not possible to byte offset 0x1, 0x2, or +* 0x3. +* +* To avoid this issue set PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE to 1. +*/ +static int dra7xx_pcie_ep_unaligned_memaccess (struct device *dev) +{ +int ret; +struct device_node *np = dev->of_node; +struct regmap *regmap; +unsigned int reg; +unsigned int field; + + regmap =syscon_regmap_lookup_by_phandle (np, +"ti,syscon-unaligned-access" ); +if (IS_ERR (regmap)) { +dev_dbg (dev,"can't get ti,syscon-unaligned-access\n" ); +return -EINVAL ; + } + +if (of_property_read_u32_index (np,"ti,syscon-unaligned-access" ,1 , + ®)) { +dev_err (dev,"couldn't get legacy mode register offset\n" ); +return -EINVAL ; + } + +if (of_property_read_u32_index (np,"ti,syscon-unaligned-access" ,2 , + &field)) { +dev_err (dev,"can't get bit field for setting legacy mode\n" ); +return -EINVAL ; + } + + ret =regmap_update_bits (regmap, reg, field, field); +if (ret) +dev_err (dev,"failed to enable unaligned access\n" ); + +return ret; +} +static int __init dra7xx_pcie_probe (struct platform_device *pdev) {u32 reg;
@@ -637,6 +684,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)case DW_PCIE_RC_TYPE :dra7xx_pcie_writel (dra7xx,PCIECTRL_TI_CONF_DEVICE_TYPE ,DEVICE_TYPE_RC ); + ret =dra7xx_add_pcie_port (dra7xx, pdev);if (ret <0 ) goto err_gpio;
@@ -644,6 +692,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)case DW_PCIE_EP_TYPE :dra7xx_pcie_writel (dra7xx,PCIECTRL_TI_CONF_DEVICE_TYPE ,DEVICE_TYPE_EP ); + + ret =dra7xx_pcie_ep_unaligned_memaccess (dev); +if (ret) + goto err_gpio; + ret =dra7xx_add_pcie_ep (dra7xx, pdev);if (ret <0 ) goto err_gpio;
Signature · 1 line
2.11.0
Rob Herring
maintainerRe: [PATCH v4 14/23] PCI: dwc: dra7xx: Workaround for errata id i870
Quoted 57 lines · Kishon Vijay Abraham I
According to errata i870, access to the PCIe slave port that are not 32-bit aligned will result in incorrect mapping to TLP Address and Byte enable fields.
Accessing non 32-bit aligned data causes incorrect data in the target buffer if memcpy is used. Implement the workaround for this errata here.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/pci/dwc/pci-dra7xx.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)drivers/pci/dwc/pci-dra7xx.c +29
-0@@ -26,6 +26,8 @@#include <linux/pm_runtime.h> #include <linux/resource.h> #include <linux/types.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h> #include "pcie-designware.h" @@ -528,6 +530,51 @@ static const struct of_device_id of_dra7xx_pcie_match[] = { {}, }; +/* +* dra7xx_pcie_ep_unaligned_memaccess: workaround for AM572x/AM571x Errata i870 +* @dra7xx: the dra7xx device where the workaround should be applied +* +* Access to the PCIe slave port that are not 32-bit aligned will result +* in incorrect mapping to TLP Address and Byte enable fields. Therefore, +* byte and half-word accesses are not possible to byte offset 0x1, 0x2, or +* 0x3. +* +* To avoid this issue set PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE to 1. +*/ +static int dra7xx_pcie_ep_unaligned_memaccess (struct device *dev) +{ +int ret; +struct device_node *np = dev->of_node; +struct regmap *regmap; +unsigned int reg; +unsigned int field; + + regmap =syscon_regmap_lookup_by_phandle (np, +"ti,syscon-unaligned-access" ); +if (IS_ERR (regmap)) { +dev_dbg (dev,"can't get ti,syscon-unaligned-access\n" ); +return -EINVAL ; + } + + if (of_property_read_u32_index(np, "ti,syscon-unaligned-access", 1,
drivers/pci/dwc/pci-dra7xx.c static const struct of_device_id of_dra7xx_pcie_match[] = { · line 569
Quoted 10 lines
drivers/pci/dwc/pci-dra7xx.c +10
-0+ ®)) { +dev_err (dev,"couldn't get legacy mode register offset\n" ); +return -EINVAL ; + } + +if (of_property_read_u32_index (np,"ti,syscon-unaligned-access" ,2 , + &field)) { +dev_err (dev,"can't get bit field for setting legacy mode\n" ); +return -EINVAL ; + }
If this remains, it's screaming for a helper function. of_parse_phandle_with_args already exists, but maybe a syscon specific function is in order.
Quoted 12 lines
drivers/pci/dwc/pci-dra7xx.c +8
-0+ + ret =regmap_update_bits (regmap, reg, field, field); +if (ret) +dev_err (dev,"failed to enable unaligned access\n" ); + +return ret; +} +static int __init dra7xx_pcie_probe (struct platform_device *pdev) {u32 reg;
drivers/pci/dwc/pci-dra7xx.c static int __init dra7xx_pcie_probe(struct platform_device *pdev) · line 687
Quoted 4 lines
drivers/pci/dwc/pci-dra7xx.c +1
-0@@ -637,6 +684,7 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)case DW_PCIE_RC_TYPE :dra7xx_pcie_writel (dra7xx,PCIECTRL_TI_CONF_DEVICE_TYPE ,DEVICE_TYPE_RC ); +
Unnecessary WS change.
Quoted 22 lines
drivers/pci/dwc/pci-dra7xx.c +5
-0ret =dra7xx_add_pcie_port (dra7xx, pdev);if (ret <0 ) goto err_gpio;@@ -644,6 +692,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)case DW_PCIE_EP_TYPE :dra7xx_pcie_writel (dra7xx,PCIECTRL_TI_CONF_DEVICE_TYPE ,DEVICE_TYPE_EP ); + + ret =dra7xx_pcie_ep_unaligned_memaccess (dev); +if (ret) + goto err_gpio; + ret =dra7xx_add_pcie_ep (dra7xx, pdev);if (ret <0 ) goto err_gpio;Signature · 6 lines
2.11.0 -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo at vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v4 14/23] PCI: dwc: dra7xx: Workaround for errata id i870
Quoted 64 lines · Rob Herring
Quoted 63 lines · Kishon Vijay Abraham I
According to errata i870, access to the PCIe slave port that are not 32-bit aligned will result in incorrect mapping to TLP Address and Byte enable fields.
Accessing non 32-bit aligned data causes incorrect data in the target buffer if memcpy is used. Implement the workaround for this errata here.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- drivers/pci/dwc/pci-dra7xx.c | 53 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)drivers/pci/dwc/pci-dra7xx.c +35
-0@@ -26,6 +26,8 @@#include <linux/pm_runtime.h> #include <linux/resource.h> #include <linux/types.h> +#include <linux/mfd/syscon.h> +#include <linux/regmap.h> #include "pcie-designware.h" @@ -528,6 +530,51 @@ static const struct of_device_id of_dra7xx_pcie_match[] = { {}, }; +/* +* dra7xx_pcie_ep_unaligned_memaccess: workaround for AM572x/AM571x Errata i870 +* @dra7xx: the dra7xx device where the workaround should be applied +* +* Access to the PCIe slave port that are not 32-bit aligned will result +* in incorrect mapping to TLP Address and Byte enable fields. Therefore, +* byte and half-word accesses are not possible to byte offset 0x1, 0x2, or +* 0x3. +* +* To avoid this issue set PCIE_SS1_AXI2OCP_LEGACY_MODE_ENABLE to 1. +*/ +static int dra7xx_pcie_ep_unaligned_memaccess (struct device *dev) +{ +int ret; +struct device_node *np = dev->of_node; +struct regmap *regmap; +unsigned int reg; +unsigned int field; + + regmap =syscon_regmap_lookup_by_phandle (np, +"ti,syscon-unaligned-access" ); +if (IS_ERR (regmap)) { +dev_dbg (dev,"can't get ti,syscon-unaligned-access\n" ); +return -EINVAL ; + } + +if (of_property_read_u32_index (np,"ti,syscon-unaligned-access" ,1 , + ®)) { +dev_err (dev,"couldn't get legacy mode register offset\n" ); +return -EINVAL ; + } + + if (of_property_read_u32_index(np, "ti,syscon-unaligned-access", 2,
Quoted 8 lines
drivers/pci/dwc/pci-dra7xx.c static const struct of_device_id of_dra7xx_pcie_match[] = { · line 569
Quoted 4 lines
drivers/pci/dwc/pci-dra7xx.c +4
-0+ &field)) { +dev_err (dev,"can't get bit field for setting legacy mode\n" ); +return -EINVAL ; + }If this remains, it's screaming for a helper function.
of_parse_phandle_with_argsalready exists, but maybe a syscon specific function is in order.
hmm, I guess for now I can use of_parse_phandle_with_args. The number of args might vary for different platforms/scenarios?
Thanks
Kishon
PATCH v4 15/23 dt-bindings: PCI: dra7xx: Add dt bindings to enable unaligned access
In reply to Kishon Vijay Abraham IUpdate device tree binding documentation of TI's dra7xx PCI controller to include property for enabling unaligned mem access.
--- Documentation/devicetree/bindings/pci/ti-pci.txt | 5 +++++ 1 file changed, 5 insertions(+)
Documentation/devicetree/bindings/pci/ti-pci.txt +5 -0
@@ -39,6 +39,11 @@ DEVICE MODE - interrupts : one interrupt entries must be specified for main interrupt. - num-ib-windows : number of inbound address translation windows - num-ob-windows : number of outbound address translation windows + - ti,syscon-unaligned-access: phandle to the syscon dt node. The 1st argument + should contain the register offset within syscon + and the 2nd argument should contain the bit field + for setting the bit to enable unaligned + access. Optional Property: - gpios : Should be added if a gpio line is required to drive PERST# line
Signature · 1 line
2.11.0
Rob Herring
maintainerRe: [PATCH v4 15/23] dt-bindings: PCI: dra7xx: Add dt bindings to enable unaligned access
Quoted 13 lines · Kishon Vijay Abraham I
Update device tree binding documentation of TI's dra7xx PCI controller to include property for enabling unaligned mem access.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- Documentation/devicetree/bindings/pci/ti-pci.txt | 5 +++++ 1 file changed, 5 insertions(+)Documentation/devicetree/bindings/pci/ti-pci.txt +0
-0
Documentation/devicetree/bindings/pci/ti-pci.txt DEVICE MODE · line 46
Quoted 8 lines
Documentation/devicetree/bindings/pci/ti-pci.txt +5
-0@@ -39,6 +39,11 @@ DEVICE MODE - interrupts : one interrupt entries must be specified for main interrupt. - num-ib-windows : number of inbound address translation windows - num-ob-windows : number of outbound address translation windows + - ti,syscon-unaligned-access: phandle to the syscon dt node. The 1st argument + should contain the register offset within syscon + and the 2nd argument should contain the bit field + for setting the bit to enable unaligned + access.
This should be setup by the firmware/bootloader or some platform code. Why does the PCI host need to configure this?
Rob
Re: [PATCH v4 15/23] dt-bindings: PCI: dra7xx: Add dt bindings to enable unaligned access
Hi Rob,
Quoted 9 lines · Rob Herring
Quoted 8 lines · Kishon Vijay Abraham I
Update device tree binding documentation of TI's dra7xx PCI controller to include property for enabling unaligned mem access.
Signed-off-by Kishon Vijay Abraham I <[email protected]>--- Documentation/devicetree/bindings/pci/ti-pci.txt | 5 +++++ 1 file changed, 5 insertions(+)
Quoted 16 lines
Documentation/devicetree/bindings/pci/ti-pci.txt DEVICE MODE · line 46
Quoted 13 lines
Documentation/devicetree/bindings/pci/ti-pci.txt +5
-0@@ -39,6 +39,11 @@ DEVICE MODE - interrupts : one interrupt entries must be specified for main interrupt. - num-ib-windows : number of inbound address translation windows - num-ob-windows : number of outbound address translation windows + - ti,syscon-unaligned-access: phandle to the syscon dt node. The 1st argument + should contain the register offset within syscon + and the 2nd argument should contain the bit field + for setting the bit to enable unaligned + access.This should be setup by the
firmware/bootloaderor some platform code. Why does the PCI host need to configure this?
That would create a dependency between the bootloader and kernel which is usually avoided in platforms like dra7xx.
Thanks
Kishon
PATCH v4 16/23 PCI: Add device IDs for DRA74x and DRA72x
In reply to Kishon Vijay Abraham IAdd device IDs for DRA74x and DRA72x devices. These devices have configurable PCI endpoint.
--- include/linux/pci_ids.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/pci_ids.h +2 -0
@@ -862,6 +862,8 @@#define PCI_DEVICE_ID_TI_X620 0xac8d#define PCI_DEVICE_ID_TI_X420 0xac8e#define PCI_DEVICE_ID_TI_XX20_FM 0xac8f +#define PCI_DEVICE_ID_TI_DRA74x 0xb500 +#define PCI_DEVICE_ID_TI_DRA72x 0xb501#define PCI_VENDOR_ID_SONY 0x104d
Signature · 1 line
2.11.0
PATCH v4 17/23 misc: Add host side pci driver for pci test function device
In reply to Kishon Vijay Abraham IAdd PCI endpoint test driver that can verify base address register, legacy interrupt/MSI interrupt and read/write/copy buffers between host and device. The corresponding pci-epf-test function driver should be used on the EP side.
--- drivers/misc/Kconfig | 7 + drivers/misc/Makefile | 1 + drivers/misc/pci_endpoint_test.c | 534 +++++++++++++++++++++++++++++++++++++++ include/uapi/linux/Kbuild | 1 + include/uapi/linux/pcitest.h | 19 ++ 5 files changed, 562 insertions(+) create mode 100644 drivers/misc/pci_endpoint_test.c create mode 100644 include/uapi/linux/pcitest.h
drivers/misc/Kconfig +7 -0
@@ -771,6 +771,13 @@ config PANEL_BOOT_MESSAGE endif # PANEL +config PCI_ENDPOINT_TEST + depends on PCI || COMPILE_TEST + tristate "PCI Endpoint Test driver" + ---help--- + Enable this configuration option to enable the host side test driver + for PCI Endpoint. + source "drivers/misc/c2port/Kconfig" source "drivers/misc/eeprom/Kconfig" source "drivers/misc/cb710/Kconfig"
drivers/misc/Makefile +1 -0
@@ -54,6 +54,7 @@ obj-$(CONFIG_ECHO) += echo/ obj-$(CONFIG_VEXPRESS_SYSCFG) += vexpress-syscfg.o obj-$(CONFIG_CXL_BASE) += cxl/ obj-$(CONFIG_PANEL) += panel.o +obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o lkdtm-$(CONFIG_LKDTM) += lkdtm_core.o lkdtm-$(CONFIG_LKDTM) += lkdtm_bugs.o
drivers/misc/pci_endpoint_test.c new file +534 -0
534 lines not on this page · raw message
include/uapi/linux/Kbuild +1 -0
@@ -333,6 +333,7 @@ header-y += parport.h header-y += patchkey.h header-y += pci.h header-y += pci_regs.h +header-y += pcitest.h header-y += perf_event.h header-y += personality.h header-y += pfkeyv2.h
include/uapi/linux/pcitest.h new file +19 -0
@@ -0,0 +1,19 @@ +/** +* pcitest.h - PCI test uapi defines +* +* Copyright (C) 2017 Texas Instruments +* Author: Kishon Vijay Abraham I <[email protected]> +* +*/ + +#ifndef __UAPI_LINUX_PCITEST_H +#define __UAPI_LINUX_PCITEST_H + +#define PCITEST_BAR _IO('P', 0x1) +#define PCITEST_LEGACY_IRQ _IO('P', 0x2) +#define PCITEST_MSI _IOW('P', 0x3, int) +#define PCITEST_WRITE _IOW('P', 0x4, unsigned long) +#define PCITEST_READ _IOW('P', 0x5, unsigned long) +#define PCITEST_COPY _IOW('P', 0x6, unsigned long) + +#endif /* __UAPI_LINUX_PCITEST_H */
Signature · 1 line
2.11.0
PATCH v4 18/23 Documentation: misc-devices: Add Documentation for pci-endpoint-test driver
In reply to Kishon Vijay Abraham IAdd Documentation for pci-endpoint-test driver.
--- Documentation/misc-devices/pci-endpoint-test.txt | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Documentation/misc-devices/pci-endpoint-test.txt
Documentation/misc-devices/pci-endpoint-test.txt new file +35 -0
@@ -0,0 +1,35 @@ +Driver for PCI Endpoint Test Function + +This driver should be used as a host side driver if the root complex is +connected to a configurable pci endpoint running *pci_epf_test* function +driver configured according to [1]. + +The "pci_endpoint_test" driver can be used to perform the following tests. + +The PCI driver for the test device performs the following tests + *) verifying addresses programmed in BAR + *) raise legacy IRQ + *) raise MSI IRQ + *) read data + *) write data + *) copy data + +This misc driver creates /dev/pci-endpoint-test.<num> for every +*pci_epf_test* function connected to the root complex and "ioctls" +should be used to perform the above tests. + +ioctl +----- + PCITEST_BAR: Tests the BAR. The number of the BAR that has to be tested + should be passed as argument. + PCITEST_LEGACY_IRQ: Tests legacy IRQ + PCITEST_MSI: Tests message signalled interrupts. The MSI number that has + to be tested should be passed as argument. + PCITEST_WRITE: Perform write tests. The size of the buffer should be passed + as argument. + PCITEST_READ: Perform read tests. The size of the buffer should be passed + as argument. + PCITEST_COPY: Perform read tests. The size of the buffer should be passed + as argument. + +[1] -> Documentation/PCI/endpoint/function/binding/pci-test.txt
Signature · 1 line
2.11.0
PATCH v4 19/23 tools: PCI: Add a userspace tool to test PCI endpoint
In reply to Kishon Vijay Abraham IAdd a userspace tool to invoke the ioctls exposed by the PCI endpoint test driver to perform various PCI tests.
--- tools/pci/pcitest.c | 186 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 186 insertions(+) create mode 100644 tools/pci/pcitest.c
tools/pci/pcitest.c new file +186 -0
@@ -0,0 +1,186 @@ +/** +* Userspace PCI Endpoint Test Module +* +* Copyright (C) 2017 Texas Instruments +* Author: Kishon Vijay Abraham I <[email protected]> +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 of +* the License as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see <http://www.gnu.org/licenses/>. +*/ + +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <sys/ioctl.h> +#include <time.h> +#include <unistd.h> + +#include <linux/pcitest.h> + +#define BILLION 1E9 + +static char *result[] = {"NOT OKAY" ,"OKAY" }; + +struct pci_test { +char *device; +char barnum; +bool legacyirq; +unsigned int msinum; +bool read; +bool write; +bool copy; +unsigned long size; +}; + +static int run_test (struct pci_test *test) +{ +long ret; +int fd; +struct timespec start, end; +double time; + + fd =open (test->device,O_RDWR ); +if (fd <0 ) { +perror ("can't open PCI Endpoint Test device" ); +return fd; + } + +if (test->barnum >=0 && test->barnum <=5 ) { + ret =ioctl (fd,PCITEST_BAR , test->barnum); +fprintf (stdout,"BAR%d:\t\t" , test->barnum); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +if (test->legacyirq) { + ret =ioctl (fd,PCITEST_LEGACY_IRQ ,0 ); +fprintf (stdout,"LEGACY IRQ:\t" ); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +if (test->msinum >0 && test->msinum <=32 ) { + ret =ioctl (fd,PCITEST_MSI , test->msinum); +fprintf (stdout,"MSI%d:\t\t" , test->msinum); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +if (test->write) { + ret =ioctl (fd,PCITEST_WRITE , test->size); +fprintf (stdout,"WRITE (%7ld bytes):\t\t" , test->size); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +if (test->read) { + ret =ioctl (fd,PCITEST_READ , test->size); +fprintf (stdout,"READ (%7ld bytes):\t\t" , test->size); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +if (test->copy) { + ret =ioctl (fd,PCITEST_COPY , test->size); +fprintf (stdout,"COPY (%7ld bytes):\t\t" , test->size); +if (ret <0 ) +fprintf (stdout,"TEST FAILED\n" ); +else +fprintf (stdout,"%s\n" , result[ret]); + } + +fflush (stdout); +} + +int main (int argc,char **argv) +{ +int c; +struct pci_test *test; + + test =calloc (1 ,sizeof (*test)); +if (!test) { +perror ("Fail to allocate memory for pci_test\n" ); +return -ENOMEM ; + } + +/* since '0' is a valid BAR number, initialize it to -1 */ + test->barnum =-1 ; + +/* set default size as 100KB */ + test->size =0x19000 ; + +/* set default endpoint device */ + test->device ="/dev/pci-endpoint-test.0" ; + +while ((c =getopt (argc, argv,"D:b:m:lrwcs:" )) !=EOF ) +switch (c) { +case 'D' : + test->device = optarg; +continue ; +case 'b' : + test->barnum =atoi (optarg); +if (test->barnum <0 || test->barnum >5 ) + goto usage; +continue ; +case 'l' : + test->legacyirq = true; +continue ; +case 'm' : + test->msinum =atoi (optarg); +if (test->msinum <1 || test->msinum >32 ) + goto usage; +continue ; +case 'r' : + test->read = true; +continue ; +case 'w' : + test->write = true; +continue ; +case 'c' : + test->copy = true; +continue ; +case 's' : + test->size =strtoul (optarg,NULL ,0 ); +continue ; +case '?' : +case 'h' : +default : +usage: +fprintf (stderr, +"usage: %s [options]\n" +"Options:\n" +"\t-D <dev> pci endpoint test device {default: /dev/pci-endpoint-test.0}\n" +"\t-b <bar num> BAR test (bar number between 0..5)\n" +"\t-m <msi num> MSI test (msi number between 1..32)\n" +"\t-r Read buffer test\n" +"\t-w Write buffer test\n" +"\t-c Copy buffer test\n" +"\t-s <size> Size of buffer {default: 100KB}\n" , + argv[0 ]); +return -EINVAL ; + } + +run_test (test); +return 0 ; +}
Signature · 1 line
2.11.0
PATCH v4 20/23 tools: PCI: Add sample test script to invoke pcitest
In reply to Kishon Vijay Abraham IAdd a simple test script that invokes the pcitest userspace tool to perform all the PCI endpoint tests (BAR tests, interrupt tests, read tests, write tests and copy tests).
--- tools/pci/pcitest.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tools/pci/pcitest.sh
tools/pci/pcitest.sh new file +56 -0
@@ -0,0 +1,56 @@ +#!/bin/sh + +echo "BAR tests" +echo + +bar=0 + +while [ $bar -lt 6 ] +do + pcitest -b $bar + bar=`expr $bar + 1` +done +echo + +echo "Interrupt tests" +echo + +pcitest -l +msi=1 + +while [ $msi -lt 33 ] +do + pcitest -m $msi + msi=`expr $msi + 1` +done +echo + +echo "Read Tests" +echo + +pcitest -r -s 1 +pcitest -r -s 1024 +pcitest -r -s 1025 +pcitest -r -s 1024000 +pcitest -r -s 1024001 +echo + +echo "Write Tests" +echo + +pcitest -w -s 1 +pcitest -w -s 1024 +pcitest -w -s 1025 +pcitest -w -s 1024000 +pcitest -w -s 1024001 +echo + +echo "Copy Tests" +echo + +pcitest -c -s 1 +pcitest -c -s 1024 +pcitest -c -s 1025 +pcitest -c -s 1024000 +pcitest -c -s 1024001 +echo
Signature · 1 line
2.11.0
PATCH v4 21/23 Documentation: PCI: Add userguide for PCI endpoint test function
In reply to Kishon Vijay Abraham IAdd documentation to help users use pci-epf-test function driver and pci_endpoint_test host driver for testing PCI.
--- Documentation/PCI/00-INDEX | 2 + Documentation/PCI/endpoint/pci-test-howto.txt | 179 ++++++++++++++++++++++++++ 2 files changed, 181 insertions(+) create mode 100644 Documentation/PCI/endpoint/pci-test-howto.txt
Documentation/PCI/00-INDEX +2 -0
@@ -18,5 +18,7 @@ endpoint/pci-endpoint-cfs.txt - guide to use configfs to configure the pci endpoint function. endpoint/pci-test-function.txt - specification of *pci test* function device. +endpoint/pci-test-howto.txt + - userguide for PCI endpoint test function. endpoint/function/binding/ - binding documentation for pci endpoint function
Documentation/PCI/endpoint/pci-test-howto.txt new file +179 -0
179 lines not on this page · raw message
Signature · 1 line
2.11.0
PATCH v4 22/23 MAINTAINERS: add PCI EP maintainer
In reply to Kishon Vijay Abraham IAdd maintainer for the newly introduced PCI EP framework.
--- MAINTAINERS | 9 +++++++++ 1 file changed, 9 insertions(+)
MAINTAINERS +9 -0
@@ -9581,6 +9581,15 @@ F: include/linux/pci* F: arch/x86/pci/ F: arch/x86/kernel/quirks.c +PCI EP SUBSYSTEM +M: Kishon Vijay Abraham I <[email protected]> +L: linux-pci at vger.kernel.org +T: git git://git.kernel.org/pub/scm/linux/kernel/git/kishon/pci-endpoint.git +S: Supported +F: drivers/pci/endpoint/ +F: drivers/misc/pci_endpoint_test.c +F: tools/pci/ + PCI DRIVER FOR ALTERA PCIE IP M: Ley Foon Tan <[email protected]> L: rfi at lists.rocketboards.org (moderated for non-subscribers)
Signature · 1 line
2.11.0
PATCH v4 23/23 ARM: DRA7: clockdomain: Change the CLKTRCTRL of CM_PCIE_CLKSTCTRL to SW_WKUP
In reply to Kishon Vijay Abraham IThe PCIe programming sequence in TRM suggests CLKSTCTRL of PCIe should be set to SW_WKUP. There are no issues when CLKSTCTRL is set to HW_AUTO in RC mode. However in EP mode, the host system is not able to access the MEMSPACE and setting the CLKSTCTRL to SW_WKUP fixes it.
--- arch/arm/mach-omap2/clockdomains7xx_data.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-omap2/clockdomains7xx_data.c +1 -1
@@ -524,7 +524,7 @@ static struct clockdomain pcie_7xx_clkdm = { .dep_bit = DRA7XX_PCIE_STATDEP_SHIFT, .wkdep_srcs = pcie_wkup_sleep_deps, .sleepdep_srcs = pcie_wkup_sleep_deps, - .flags = CLKDM_CAN_HWSUP_SWSUP, + .flags = CLKDM_CAN_SWSUP, };static struct clockdomain atl_7xx_clkdm = {
Signature · 1 line
2.11.0