[PATCH v3 09/34] misc: xlink-pcie: lh: Add PCIe EPF driver for Local Host
From: Srikanth Thokala Add PCIe EPF driver for local host (lh) to configure BAR's and other HW resources. Underlying PCIe HW controller is a Synopsys DWC PCIe core. Cc: Derek Kiernan Cc: Dragan Cvetic Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Reviewed-by: Mark Gross Signed-off-by: Srikanth Thokala --- MAINTAINERS | 6 + drivers/misc/Kconfig| 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-pcie/Kconfig | 9 + drivers/misc/xlink-pcie/Makefile| 1 + drivers/misc/xlink-pcie/local_host/Makefile | 2 + drivers/misc/xlink-pcie/local_host/epf.c| 373 drivers/misc/xlink-pcie/local_host/epf.h| 37 ++ drivers/misc/xlink-pcie/local_host/xpcie.h | 38 ++ 9 files changed, 468 insertions(+) create mode 100644 drivers/misc/xlink-pcie/Kconfig create mode 100644 drivers/misc/xlink-pcie/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/epf.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.h create mode 100644 drivers/misc/xlink-pcie/local_host/xpcie.h diff --git a/MAINTAINERS b/MAINTAINERS index 6742a1827cd9..3ca6c8c6341b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1961,6 +1961,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM KEEM BAY XLINK PCIE SUPPORT +M: Srikanth Thokala +M: Mark Gross +S: Supported +F: drivers/misc/xlink-pcie/ + ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index fafa8b0d8099..dfb98e444c6e 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -481,4 +481,5 @@ source "drivers/misc/ocxl/Kconfig" source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" +source "drivers/misc/xlink-pcie/Kconfig" endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index d23231e73330..d17621fc43d5 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -57,3 +57,4 @@ obj-$(CONFIG_HABANA_AI) += habanalabs/ obj-$(CONFIG_UACCE)+= uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o +obj-y += xlink-pcie/ diff --git a/drivers/misc/xlink-pcie/Kconfig b/drivers/misc/xlink-pcie/Kconfig new file mode 100644 index ..46aa401d79b7 --- /dev/null +++ b/drivers/misc/xlink-pcie/Kconfig @@ -0,0 +1,9 @@ +config XLINK_PCIE_LH_DRIVER + tristate "XLink PCIe Local Host driver" + depends on PCI_ENDPOINT && ARCH_KEEMBAY + help + This option enables XLink PCIe Local Host driver. + + Choose M here to compile this driver as a module, name is mxlk_ep. + This driver is used for XLink communication over PCIe and is to be + loaded on the Intel Keem Bay platform. diff --git a/drivers/misc/xlink-pcie/Makefile b/drivers/misc/xlink-pcie/Makefile new file mode 100644 index ..d693d382e9c6 --- /dev/null +++ b/drivers/misc/xlink-pcie/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += local_host/ diff --git a/drivers/misc/xlink-pcie/local_host/Makefile b/drivers/misc/xlink-pcie/local_host/Makefile new file mode 100644 index ..514d3f0c91bc --- /dev/null +++ b/drivers/misc/xlink-pcie/local_host/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o +mxlk_ep-objs := epf.o diff --git a/drivers/misc/xlink-pcie/local_host/epf.c b/drivers/misc/xlink-pcie/local_host/epf.c new file mode 100644 index ..0234756e89ae --- /dev/null +++ b/drivers/misc/xlink-pcie/local_host/epf.c @@ -0,0 +1,373 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Intel Keem Bay XLink PCIe Driver + * + * Copyright (C) 2021 Intel Corporation + */ + +#include +#include + +#include "epf.h" + +#define BAR2_MIN_SIZE SZ_16K +#define BAR4_MIN_SIZE SZ_16K + +#define PCIE_REGS_PCIE_INTR_ENABLE 0x18 +#define PCIE_REGS_PCIE_INTR_FLAGS 0x1C +#define LBC_CII_EVENT_FLAG BIT(18) +#define PCIE_REGS_PCIE_ERR_INTR_FLAGS 0x24 +#define LINK_REQ_RST_FLG BIT(15) + +static struct pci_epf_header xpcie_header = { + .vendorid = PCI_VENDOR_ID_INTEL, + .deviceid = PCI_DEVICE_ID_INTEL_KEEMBAY, + .baseclass_code = PCI_BASE_CLASS_MULTIMEDIA, + .subclass_code = 0x0, + .subsys_vendor_id = 0x0, + .subsys_id = 0x0, +}; + +static const struct pci_epf_device_id xpcie_epf_ids[] = { + { + .name = "mxlk_pcie_epf", + }, + {}, +}; + +static irqreturn_t intel_xpcie_err_interrupt(int irq, void *args) +{ +
[PATCH v3 09/34] misc: xlink-pcie: lh: Add PCIe EPF driver for Local Host
From: Srikanth Thokala Add PCIe EPF driver for local host (lh) to configure BAR's and other HW resources. Underlying PCIe HW controller is a Synopsys DWC PCIe core. Cc: Derek Kiernan Cc: Dragan Cvetic Cc: Arnd Bergmann Cc: Greg Kroah-Hartman Reviewed-by: Mark Gross Signed-off-by: Srikanth Thokala --- MAINTAINERS | 6 + drivers/misc/Kconfig| 1 + drivers/misc/Makefile | 1 + drivers/misc/xlink-pcie/Kconfig | 9 + drivers/misc/xlink-pcie/Makefile| 1 + drivers/misc/xlink-pcie/local_host/Makefile | 2 + drivers/misc/xlink-pcie/local_host/epf.c| 373 drivers/misc/xlink-pcie/local_host/epf.h| 37 ++ drivers/misc/xlink-pcie/local_host/xpcie.h | 38 ++ 9 files changed, 468 insertions(+) create mode 100644 drivers/misc/xlink-pcie/Kconfig create mode 100644 drivers/misc/xlink-pcie/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/Makefile create mode 100644 drivers/misc/xlink-pcie/local_host/epf.c create mode 100644 drivers/misc/xlink-pcie/local_host/epf.h create mode 100644 drivers/misc/xlink-pcie/local_host/xpcie.h diff --git a/MAINTAINERS b/MAINTAINERS index 6742a1827cd9..3ca6c8c6341b 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1961,6 +1961,12 @@ F: Documentation/devicetree/bindings/arm/intel,keembay.yaml F: arch/arm64/boot/dts/intel/keembay-evm.dts F: arch/arm64/boot/dts/intel/keembay-soc.dtsi +ARM KEEM BAY XLINK PCIE SUPPORT +M: Srikanth Thokala +M: Mark Gross +S: Supported +F: drivers/misc/xlink-pcie/ + ARM/INTEL RESEARCH IMOTE/STARGATE 2 MACHINE SUPPORT M: Jonathan Cameron L: linux-arm-ker...@lists.infradead.org (moderated for non-subscribers) diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index fafa8b0d8099..dfb98e444c6e 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -481,4 +481,5 @@ source "drivers/misc/ocxl/Kconfig" source "drivers/misc/cardreader/Kconfig" source "drivers/misc/habanalabs/Kconfig" source "drivers/misc/uacce/Kconfig" +source "drivers/misc/xlink-pcie/Kconfig" endmenu diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index d23231e73330..d17621fc43d5 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -57,3 +57,4 @@ obj-$(CONFIG_HABANA_AI) += habanalabs/ obj-$(CONFIG_UACCE)+= uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o +obj-y += xlink-pcie/ diff --git a/drivers/misc/xlink-pcie/Kconfig b/drivers/misc/xlink-pcie/Kconfig new file mode 100644 index ..46aa401d79b7 --- /dev/null +++ b/drivers/misc/xlink-pcie/Kconfig @@ -0,0 +1,9 @@ +config XLINK_PCIE_LH_DRIVER + tristate "XLink PCIe Local Host driver" + depends on PCI_ENDPOINT && ARCH_KEEMBAY + help + This option enables XLink PCIe Local Host driver. + + Choose M here to compile this driver as a module, name is mxlk_ep. + This driver is used for XLink communication over PCIe and is to be + loaded on the Intel Keem Bay platform. diff --git a/drivers/misc/xlink-pcie/Makefile b/drivers/misc/xlink-pcie/Makefile new file mode 100644 index ..d693d382e9c6 --- /dev/null +++ b/drivers/misc/xlink-pcie/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += local_host/ diff --git a/drivers/misc/xlink-pcie/local_host/Makefile b/drivers/misc/xlink-pcie/local_host/Makefile new file mode 100644 index ..514d3f0c91bc --- /dev/null +++ b/drivers/misc/xlink-pcie/local_host/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += mxlk_ep.o +mxlk_ep-objs := epf.o diff --git a/drivers/misc/xlink-pcie/local_host/epf.c b/drivers/misc/xlink-pcie/local_host/epf.c new file mode 100644 index ..0234756e89ae --- /dev/null +++ b/drivers/misc/xlink-pcie/local_host/epf.c @@ -0,0 +1,373 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Intel Keem Bay XLink PCIe Driver + * + * Copyright (C) 2021 Intel Corporation + */ + +#include +#include + +#include "epf.h" + +#define BAR2_MIN_SIZE SZ_16K +#define BAR4_MIN_SIZE SZ_16K + +#define PCIE_REGS_PCIE_INTR_ENABLE 0x18 +#define PCIE_REGS_PCIE_INTR_FLAGS 0x1C +#define LBC_CII_EVENT_FLAG BIT(18) +#define PCIE_REGS_PCIE_ERR_INTR_FLAGS 0x24 +#define LINK_REQ_RST_FLG BIT(15) + +static struct pci_epf_header xpcie_header = { + .vendorid = PCI_VENDOR_ID_INTEL, + .deviceid = PCI_DEVICE_ID_INTEL_KEEMBAY, + .baseclass_code = PCI_BASE_CLASS_MULTIMEDIA, + .subclass_code = 0x0, + .subsys_vendor_id = 0x0, + .subsys_id = 0x0, +}; + +static const struct pci_epf_device_id xpcie_epf_ids[] = { + { + .name = "mxlk_pcie_epf", + }, + {}, +}; + +static irqreturn_t intel_xpcie_err_interrupt(int irq, void *args) +{ +