aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/fpga
diff options
context:
space:
mode:
authorZhang Yi <yi.z.zhang@intel.com>2018-06-29 20:53:19 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-07-15 07:55:45 -0400
commit72ddd9f34040a49a221c0d5d1754061e007a10e6 (patch)
tree3f85f9a7ec8e55962b89e566b28db66b19405ddd /drivers/fpga
parentd06b004b99c960828523e581a3b7d109dfc1329b (diff)
fpga: add FPGA DFL PCIe device driver
This patch implements the basic framework of the driver for FPGA PCIe device which implements the Device Feature List (DFL) in its MMIO space. This driver is verified on Intel(R) PCIe-based FPGA DFL devices, including both integrated (e.g. Intel Server Platform with In-package FPGA) and discrete (e.g. Intel FPGA PCIe Acceleration Cards) solutions. Signed-off-by: Tim Whisonant <tim.whisonant@intel.com> Signed-off-by: Enno Luebbers <enno.luebbers@intel.com> Signed-off-by: Shiva Rao <shiva.rao@intel.com> Signed-off-by: Christopher Rauer <christopher.rauer@intel.com> Signed-off-by: Zhang Yi <yi.z.zhang@intel.com> Signed-off-by: Xiao Guangrong <guangrong.xiao@linux.intel.com> Signed-off-by: Wu Hao <hao.wu@intel.com> Acked-by: Alan Tull <atull@kernel.org> Acked-by: Moritz Fischer <mdf@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/fpga')
-rw-r--r--drivers/fpga/Kconfig15
-rw-r--r--drivers/fpga/Makefile3
-rw-r--r--drivers/fpga/dfl-pci.c103
3 files changed, 121 insertions, 0 deletions
diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig
index 4880fd676a19..f2659f10e92e 100644
--- a/drivers/fpga/Kconfig
+++ b/drivers/fpga/Kconfig
@@ -146,4 +146,19 @@ config FPGA_DFL
146 Gate Array (FPGA) solutions which implement Device Feature List. 146 Gate Array (FPGA) solutions which implement Device Feature List.
147 It provides enumeration APIs and feature device infrastructure. 147 It provides enumeration APIs and feature device infrastructure.
148 148
149config FPGA_DFL_PCI
150 tristate "FPGA DFL PCIe Device Driver"
151 depends on PCI && FPGA_DFL
152 help
153 Select this option to enable PCIe driver for PCIe-based
154 Field-Programmable Gate Array (FPGA) solutions which implement
155 the Device Feature List (DFL). This driver provides interfaces
156 for userspace applications to configure, enumerate, open and access
157 FPGA accelerators on the FPGA DFL devices, enables system level
158 management functions such as FPGA partial reconfiguration, power
159 management and virtualization with DFL framework and DFL feature
160 device drivers.
161
162 To compile this as a module, choose M here.
163
149endif # FPGA 164endif # FPGA
diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile
index 7a7a11739e00..02e025398cd5 100644
--- a/drivers/fpga/Makefile
+++ b/drivers/fpga/Makefile
@@ -31,3 +31,6 @@ obj-$(CONFIG_OF_FPGA_REGION) += of-fpga-region.o
31 31
32# FPGA Device Feature List Support 32# FPGA Device Feature List Support
33obj-$(CONFIG_FPGA_DFL) += dfl.o 33obj-$(CONFIG_FPGA_DFL) += dfl.o
34
35# Drivers for FPGAs which implement DFL
36obj-$(CONFIG_FPGA_DFL_PCI) += dfl-pci.o
diff --git a/drivers/fpga/dfl-pci.c b/drivers/fpga/dfl-pci.c
new file mode 100644
index 000000000000..e1e1f0fbe98c
--- /dev/null
+++ b/drivers/fpga/dfl-pci.c
@@ -0,0 +1,103 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Driver for FPGA Device Feature List (DFL) PCIe device
4 *
5 * Copyright (C) 2017-2018 Intel Corporation, Inc.
6 *
7 * Authors:
8 * Zhang Yi <Yi.Z.Zhang@intel.com>
9 * Xiao Guangrong <guangrong.xiao@linux.intel.com>
10 * Joseph Grecco <joe.grecco@intel.com>
11 * Enno Luebbers <enno.luebbers@intel.com>
12 * Tim Whisonant <tim.whisonant@intel.com>
13 * Ananda Ravuri <ananda.ravuri@intel.com>
14 * Henry Mitchel <henry.mitchel@intel.com>
15 */
16
17#include <linux/pci.h>
18#include <linux/types.h>
19#include <linux/kernel.h>
20#include <linux/module.h>
21#include <linux/stddef.h>
22#include <linux/errno.h>
23#include <linux/aer.h>
24
25#define DRV_VERSION "0.8"
26#define DRV_NAME "dfl-pci"
27
28/* PCI Device ID */
29#define PCIE_DEVICE_ID_PF_INT_5_X 0xBCBD
30#define PCIE_DEVICE_ID_PF_INT_6_X 0xBCC0
31#define PCIE_DEVICE_ID_PF_DSC_1_X 0x09C4
32/* VF Device */
33#define PCIE_DEVICE_ID_VF_INT_5_X 0xBCBF
34#define PCIE_DEVICE_ID_VF_INT_6_X 0xBCC1
35#define PCIE_DEVICE_ID_VF_DSC_1_X 0x09C5
36
37static struct pci_device_id cci_pcie_id_tbl[] = {
38 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_INT_5_X),},
39 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_VF_INT_5_X),},
40 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_INT_6_X),},
41 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_VF_INT_6_X),},
42 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_DSC_1_X),},
43 {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_VF_DSC_1_X),},
44 {0,}
45};
46MODULE_DEVICE_TABLE(pci, cci_pcie_id_tbl);
47
48static
49int cci_pci_probe(struct pci_dev *pcidev, const struct pci_device_id *pcidevid)
50{
51 int ret;
52
53 ret = pcim_enable_device(pcidev);
54 if (ret < 0) {
55 dev_err(&pcidev->dev, "Failed to enable device %d.\n", ret);
56 return ret;
57 }
58
59 ret = pci_enable_pcie_error_reporting(pcidev);
60 if (ret && ret != -EINVAL)
61 dev_info(&pcidev->dev, "PCIE AER unavailable %d.\n", ret);
62
63 pci_set_master(pcidev);
64
65 if (!pci_set_dma_mask(pcidev, DMA_BIT_MASK(64))) {
66 ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(64));
67 if (ret)
68 goto disable_error_report_exit;
69 } else if (!pci_set_dma_mask(pcidev, DMA_BIT_MASK(32))) {
70 ret = pci_set_consistent_dma_mask(pcidev, DMA_BIT_MASK(32));
71 if (ret)
72 goto disable_error_report_exit;
73 } else {
74 ret = -EIO;
75 dev_err(&pcidev->dev, "No suitable DMA support available.\n");
76 goto disable_error_report_exit;
77 }
78
79 /* TODO: create and add the platform device per feature list */
80 return 0;
81
82disable_error_report_exit:
83 pci_disable_pcie_error_reporting(pcidev);
84 return ret;
85}
86
87static void cci_pci_remove(struct pci_dev *pcidev)
88{
89 pci_disable_pcie_error_reporting(pcidev);
90}
91
92static struct pci_driver cci_pci_driver = {
93 .name = DRV_NAME,
94 .id_table = cci_pcie_id_tbl,
95 .probe = cci_pci_probe,
96 .remove = cci_pci_remove,
97};
98
99module_pci_driver(cci_pci_driver);
100
101MODULE_DESCRIPTION("FPGA DFL PCIe Device Driver");
102MODULE_AUTHOR("Intel Corporation");
103MODULE_LICENSE("GPL v2");