aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKang Luwei <luwei.kang@intel.com>2018-06-29 20:53:22 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2018-07-15 07:55:46 -0400
commit0a27ff24d59662b1ca8b3f7721a965918f115074 (patch)
tree0a0bbd2c4deec56400aabb84f146c738de175e85
parent322ddebe54ae2b18c86a3bffb2b76bc5e67762ac (diff)
fpga: dfl: fme: add header sub feature support
The Header Register set is always present for FPGA Management Engine (FME), this patch implements init and uinit function for header sub feature and introduces several read-only sysfs interfaces for the capability and status. Sysfs interfaces: * /sys/class/fpga_region/<regionX>/<dfl-fme.x>/ports_num Read-only. Number of ports implemented * /sys/class/fpga_region/<regionX>/<dfl-fme.x>/bitstream_id Read-only. Bitstream (static FPGA region) identifier number. It contains the detailed version and other information of this static FPGA region. * /sys/class/fpga_region/<regionX>/<dfl-fme.x>/bitstream_metadata Read-only. Bitstream (static FPGA region) meta data. It contains the synthesis date, seed and other information of this static FPGA region. 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: Kang Luwei <luwei.kang@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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--Documentation/ABI/testing/sysfs-platform-dfl-fme23
-rw-r--r--drivers/fpga/dfl-fme-main.c68
2 files changed, 91 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-platform-dfl-fme b/Documentation/ABI/testing/sysfs-platform-dfl-fme
new file mode 100644
index 000000000000..8fa4febfa4b2
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-platform-dfl-fme
@@ -0,0 +1,23 @@
1What: /sys/bus/platform/devices/dfl-fme.0/ports_num
2Date: June 2018
3KernelVersion: 4.19
4Contact: Wu Hao <hao.wu@intel.com>
5Description: Read-only. One DFL FPGA device may have more than 1
6 port/Accelerator Function Unit (AFU). It returns the
7 number of ports on the FPGA device when read it.
8
9What: /sys/bus/platform/devices/dfl-fme.0/bitstream_id
10Date: June 2018
11KernelVersion: 4.19
12Contact: Wu Hao <hao.wu@intel.com>
13Description: Read-only. It returns Bitstream (static FPGA region)
14 identifier number, which includes the detailed version
15 and other information of this static FPGA region.
16
17What: /sys/bus/platform/devices/dfl-fme.0/bitstream_metadata
18Date: June 2018
19KernelVersion: 4.19
20Contact: Wu Hao <hao.wu@intel.com>
21Description: Read-only. It returns Bitstream (static FPGA region) meta
22 data, which includes the synthesis date, seed and other
23 information of this static FPGA region.
diff --git a/drivers/fpga/dfl-fme-main.c b/drivers/fpga/dfl-fme-main.c
index bdcfe951d939..c23c56fe3f4b 100644
--- a/drivers/fpga/dfl-fme-main.c
+++ b/drivers/fpga/dfl-fme-main.c
@@ -19,10 +19,77 @@
19 19
20#include "dfl.h" 20#include "dfl.h"
21 21
22static ssize_t ports_num_show(struct device *dev,
23 struct device_attribute *attr, char *buf)
24{
25 void __iomem *base;
26 u64 v;
27
28 base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER);
29
30 v = readq(base + FME_HDR_CAP);
31
32 return scnprintf(buf, PAGE_SIZE, "%u\n",
33 (unsigned int)FIELD_GET(FME_CAP_NUM_PORTS, v));
34}
35static DEVICE_ATTR_RO(ports_num);
36
37/*
38 * Bitstream (static FPGA region) identifier number. It contains the
39 * detailed version and other information of this static FPGA region.
40 */
41static ssize_t bitstream_id_show(struct device *dev,
42 struct device_attribute *attr, char *buf)
43{
44 void __iomem *base;
45 u64 v;
46
47 base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER);
48
49 v = readq(base + FME_HDR_BITSTREAM_ID);
50
51 return scnprintf(buf, PAGE_SIZE, "0x%llx\n", (unsigned long long)v);
52}
53static DEVICE_ATTR_RO(bitstream_id);
54
55/*
56 * Bitstream (static FPGA region) meta data. It contains the synthesis
57 * date, seed and other information of this static FPGA region.
58 */
59static ssize_t bitstream_metadata_show(struct device *dev,
60 struct device_attribute *attr, char *buf)
61{
62 void __iomem *base;
63 u64 v;
64
65 base = dfl_get_feature_ioaddr_by_id(dev, FME_FEATURE_ID_HEADER);
66
67 v = readq(base + FME_HDR_BITSTREAM_MD);
68
69 return scnprintf(buf, PAGE_SIZE, "0x%llx\n", (unsigned long long)v);
70}
71static DEVICE_ATTR_RO(bitstream_metadata);
72
73static const struct attribute *fme_hdr_attrs[] = {
74 &dev_attr_ports_num.attr,
75 &dev_attr_bitstream_id.attr,
76 &dev_attr_bitstream_metadata.attr,
77 NULL,
78};
79
22static int fme_hdr_init(struct platform_device *pdev, 80static int fme_hdr_init(struct platform_device *pdev,
23 struct dfl_feature *feature) 81 struct dfl_feature *feature)
24{ 82{
83 void __iomem *base = feature->ioaddr;
84 int ret;
85
25 dev_dbg(&pdev->dev, "FME HDR Init.\n"); 86 dev_dbg(&pdev->dev, "FME HDR Init.\n");
87 dev_dbg(&pdev->dev, "FME cap %llx.\n",
88 (unsigned long long)readq(base + FME_HDR_CAP));
89
90 ret = sysfs_create_files(&pdev->dev.kobj, fme_hdr_attrs);
91 if (ret)
92 return ret;
26 93
27 return 0; 94 return 0;
28} 95}
@@ -31,6 +98,7 @@ static void fme_hdr_uinit(struct platform_device *pdev,
31 struct dfl_feature *feature) 98 struct dfl_feature *feature)
32{ 99{
33 dev_dbg(&pdev->dev, "FME HDR UInit.\n"); 100 dev_dbg(&pdev->dev, "FME HDR UInit.\n");
101 sysfs_remove_files(&pdev->dev.kobj, fme_hdr_attrs);
34} 102}
35 103
36static const struct dfl_feature_ops fme_hdr_ops = { 104static const struct dfl_feature_ops fme_hdr_ops = {