Skip to content
Permalink
Browse files
misc: xlink-pcie: rh: Add PCIe EP driver for Remote Host
Add PCIe Endpoint driver that configures PCIe BARs and MSIs on the
Remote Host

Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Mark Gross <mgross@linux.intel.com>
Signed-off-by: Srikanth Thokala <srikanth.thokala@intel.com>
  • Loading branch information
srikuIntel authored and zhoufuro committed Jun 3, 2021
1 parent 0372424 commit 7dbe73d93ab1bc48db1e01693756d1354b577364
Show file tree
Hide file tree
Showing 8 changed files with 624 additions and 1 deletion.
@@ -1965,7 +1965,7 @@ 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 KEEMBAY XLINK PCIE SUPPORT
ARM/INTEL KEEMBAY XLINK PCIE SUPPORT
M: Srikanth Thokala <srikanth.thokala@intel.com>
M: Mark Gross <mgross@linux.intel.com>
S: Maintained
@@ -1,3 +1,14 @@
config XLINK_PCIE_RH_DRIVER
tristate "XLink PCIe Remote Host driver"
depends on PCI && X86_64
help
This option enables XLink PCIe Remote Host driver.

Choose M here to compile this driver as a module, name is mxlk.
This driver is used for XLink communication over PCIe,
and is to be loaded on the IA host which is connected to
the Intel Keem Bay.

config XLINK_PCIE_LH_DRIVER
tristate "XLink PCIe Local Host driver"
depends on PCI_ENDPOINT && ARCH_KEEMBAY
@@ -1 +1,2 @@
obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += remote_host/
obj-$(CONFIG_XLINK_PCIE_LH_DRIVER) += local_host/
@@ -71,6 +71,7 @@ struct xpcie_mmio {
struct xpcie {
u32 status;
bool legacy_a0;
void *bar0;
void *mmio;
void *bar4;

@@ -0,0 +1,3 @@
obj-$(CONFIG_XLINK_PCIE_RH_DRIVER) += mxlk.o
mxlk-objs := main.o
mxlk-objs += pci.o
@@ -0,0 +1,92 @@
// SPDX-License-Identifier: GPL-2.0-only
/*****************************************************************************
*
* Intel Keem Bay XLink PCIe Driver
*
* Copyright (C) 2020 Intel Corporation
*
****************************************************************************/

#include "pci.h"
#include "../common/core.h"

#define HW_ID_LO_MASK GENMASK(7, 0)
#define HW_ID_HI_MASK GENMASK(15, 8)

static const struct pci_device_id xpcie_pci_table[] = {
{ PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_KEEMBAY), 0 },
{ 0 }
};

static int intel_xpcie_probe(struct pci_dev *pdev,
const struct pci_device_id *ent)
{
bool new_device = false;
struct xpcie_dev *xdev;
u32 sw_devid;
u16 hw_id;
int ret;

hw_id = FIELD_PREP(HW_ID_HI_MASK, pdev->bus->number) |
FIELD_PREP(HW_ID_LO_MASK, PCI_SLOT(pdev->devfn));

sw_devid = FIELD_PREP(XLINK_DEV_INF_TYPE_MASK,
XLINK_DEV_INF_PCIE) |
FIELD_PREP(XLINK_DEV_PHYS_ID_MASK, hw_id) |
FIELD_PREP(XLINK_DEV_TYPE_MASK, XLINK_DEV_TYPE_KMB) |
FIELD_PREP(XLINK_DEV_PCIE_ID_MASK, XLINK_DEV_PCIE_0) |
FIELD_PREP(XLINK_DEV_FUNC_MASK, XLINK_DEV_FUNC_VPU);

xdev = intel_xpcie_get_device_by_id(sw_devid);
if (!xdev) {
xdev = intel_xpcie_create_device(sw_devid, pdev);
if (!xdev)
return -ENOMEM;

new_device = true;
}

ret = intel_xpcie_pci_init(xdev, pdev);
if (ret) {
intel_xpcie_remove_device(xdev);
return ret;
}

if (new_device)
intel_xpcie_list_add_device(xdev);

return ret;
}

static void intel_xpcie_remove(struct pci_dev *pdev)
{
struct xpcie_dev *xdev = pci_get_drvdata(pdev);

if (xdev) {
intel_xpcie_pci_cleanup(xdev);
intel_xpcie_remove_device(xdev);
}
}

static struct pci_driver xpcie_driver = {
.name = XPCIE_DRIVER_NAME,
.id_table = xpcie_pci_table,
.probe = intel_xpcie_probe,
.remove = intel_xpcie_remove
};

static int __init intel_xpcie_init_module(void)
{
return pci_register_driver(&xpcie_driver);
}

static void __exit intel_xpcie_exit_module(void)
{
pci_unregister_driver(&xpcie_driver);
}

module_init(intel_xpcie_init_module);
module_exit(intel_xpcie_exit_module);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Intel Corporation");
MODULE_DESCRIPTION(XPCIE_DRIVER_DESC);

0 comments on commit 7dbe73d

Please sign in to comment.