Skip to content

Commit 0a27ff2

Browse files
Kang Luweigregkh
authored andcommitted
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 <[email protected]> Signed-off-by: Enno Luebbers <[email protected]> Signed-off-by: Shiva Rao <[email protected]> Signed-off-by: Christopher Rauer <[email protected]> Signed-off-by: Kang Luwei <[email protected]> Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Wu Hao <[email protected]> Acked-by: Alan Tull <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 322ddeb commit 0a27ff2

File tree

2 files changed

+91
-0
lines changed

2 files changed

+91
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
What: /sys/bus/platform/devices/dfl-fme.0/ports_num
2+
Date: June 2018
3+
KernelVersion: 4.19
4+
Contact: Wu Hao <[email protected]>
5+
Description: 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+
9+
What: /sys/bus/platform/devices/dfl-fme.0/bitstream_id
10+
Date: June 2018
11+
KernelVersion: 4.19
12+
Contact: Wu Hao <[email protected]>
13+
Description: 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+
17+
What: /sys/bus/platform/devices/dfl-fme.0/bitstream_metadata
18+
Date: June 2018
19+
KernelVersion: 4.19
20+
Contact: Wu Hao <[email protected]>
21+
Description: 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.

drivers/fpga/dfl-fme-main.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,77 @@
1919

2020
#include "dfl.h"
2121

22+
static 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+
}
35+
static 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+
*/
41+
static 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+
}
53+
static 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+
*/
59+
static 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+
}
71+
static DEVICE_ATTR_RO(bitstream_metadata);
72+
73+
static 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+
2280
static int fme_hdr_init(struct platform_device *pdev,
2381
struct dfl_feature *feature)
2482
{
83+
void __iomem *base = feature->ioaddr;
84+
int ret;
85+
2586
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;
2693

2794
return 0;
2895
}
@@ -31,6 +98,7 @@ static void fme_hdr_uinit(struct platform_device *pdev,
3198
struct dfl_feature *feature)
3299
{
33100
dev_dbg(&pdev->dev, "FME HDR UInit.\n");
101+
sysfs_remove_files(&pdev->dev.kobj, fme_hdr_attrs);
34102
}
35103

36104
static const struct dfl_feature_ops fme_hdr_ops = {

0 commit comments

Comments
 (0)