Skip to content

Commit 4ae5e95

Browse files
dbiswas-devRuss Weight
authored andcommitted
fpga: dfl: Move DFH header register macros to linux/dfl.h
Device Feature List (DFL) drivers may be defined in subdirectories other than drivers/fpga, and each DFL driver should have access to the Device Feature Header (DFH) register, which contains revision and type information. This change moves the macros specific to the DFH register from drivers/fpga/dfl.h to include/linux/dfl.h. Signed-off-by: Debarati Biswas <debaratix.biswas@intel.com> Signed-off-by: Russ Weight <russell.h.weight@intel.com>
1 parent ff074ce commit 4ae5e95

2 files changed

Lines changed: 53 additions & 47 deletions

File tree

drivers/fpga/dfl.h

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <linux/bitfield.h>
1818
#include <linux/cdev.h>
1919
#include <linux/delay.h>
20+
#include <linux/dfl.h>
2021
#include <linux/eventfd.h>
2122
#include <linux/fs.h>
2223
#include <linux/interrupt.h>
@@ -53,32 +54,6 @@
5354
#define PORT_FEATURE_ID_UINT 0x12
5455
#define PORT_FEATURE_ID_STP 0x13
5556

56-
/*
57-
* Device Feature Header Register Set
58-
*
59-
* For FIUs, they all have DFH + GUID + NEXT_AFU as common header registers.
60-
* For AFUs, they have DFH + GUID as common header registers.
61-
* For private features, they only have DFH register as common header.
62-
*/
63-
#define DFH 0x0
64-
#define GUID_L 0x8
65-
#define GUID_H 0x10
66-
#define NEXT_AFU 0x18
67-
68-
#define DFH_SIZE 0x8
69-
70-
/* Device Feature Header Register Bitfield */
71-
#define DFH_ID GENMASK_ULL(11, 0) /* Feature ID */
72-
#define DFH_ID_FIU_FME 0
73-
#define DFH_ID_FIU_PORT 1
74-
#define DFH_REVISION GENMASK_ULL(15, 12) /* Feature revision */
75-
#define DFH_NEXT_HDR_OFST GENMASK_ULL(39, 16) /* Offset to next DFH */
76-
#define DFH_EOL BIT_ULL(40) /* End of list */
77-
#define DFH_TYPE GENMASK_ULL(63, 60) /* Feature type */
78-
#define DFH_TYPE_AFU 1
79-
#define DFH_TYPE_PRIVATE 3
80-
#define DFH_TYPE_FIU 4
81-
8257
/* Next AFU Register Bitfield */
8358
#define NEXT_AFU_NEXT_DFH_OFST GENMASK_ULL(23, 0) /* Offset to next AFU */
8459

@@ -403,27 +378,6 @@ struct device *dfl_fpga_pdata_to_parent(struct dfl_feature_platform_data *pdata)
403378
return pdata->dev->dev.parent->parent;
404379
}
405380

406-
static inline bool dfl_feature_is_fme(void __iomem *base)
407-
{
408-
u64 v = readq(base + DFH);
409-
410-
return (FIELD_GET(DFH_TYPE, v) == DFH_TYPE_FIU) &&
411-
(FIELD_GET(DFH_ID, v) == DFH_ID_FIU_FME);
412-
}
413-
414-
static inline bool dfl_feature_is_port(void __iomem *base)
415-
{
416-
u64 v = readq(base + DFH);
417-
418-
return (FIELD_GET(DFH_TYPE, v) == DFH_TYPE_FIU) &&
419-
(FIELD_GET(DFH_ID, v) == DFH_ID_FIU_PORT);
420-
}
421-
422-
static inline u8 dfl_feature_revision(void __iomem *base)
423-
{
424-
return (u8)FIELD_GET(DFH_REVISION, readq(base + DFH));
425-
}
426-
427381
/**
428382
* struct dfl_fpga_enum_info - DFL FPGA enumeration information
429383
*

include/linux/dfl.h

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
#ifndef __LINUX_DFL_H
99
#define __LINUX_DFL_H
1010

11+
#include <linux/bitfield.h>
1112
#include <linux/device.h>
13+
#include <linux/io.h>
1214
#include <linux/mod_devicetable.h>
1315

1416
/**
@@ -83,4 +85,54 @@ void dfl_driver_unregister(struct dfl_driver *dfl_drv);
8385
module_driver(__dfl_driver, dfl_driver_register, \
8486
dfl_driver_unregister)
8587

88+
/*
89+
* Device Feature Header Register Set
90+
*
91+
* For FIUs, they all have DFH + GUID + NEXT_AFU as common header registers.
92+
* For AFUs, they have DFH + GUID as common header registers.
93+
* For private features, they only have DFH register as common header.
94+
*/
95+
#define DFH 0x0
96+
#define GUID_L 0x8
97+
#define GUID_H 0x10
98+
#define NEXT_AFU 0x18
99+
100+
#define DFH_SIZE 0x8
101+
102+
/* Device Feature Header Register Bitfield */
103+
#define DFH_ID GENMASK_ULL(11, 0) /* Feature ID */
104+
#define DFH_ID_FIU_FME 0
105+
#define DFH_ID_FIU_PORT 1
106+
#define DFH_REVISION GENMASK_ULL(15, 12)
107+
#define DFH_NEXT_HDR_OFST GENMASK_ULL(39, 16) /* Offset to next DFH */
108+
#define DFH_EOL BIT_ULL(40) /* End of list */
109+
#define DFH_TYPE GENMASK_ULL(63, 60) /* Feature type */
110+
#define DFH_TYPE_AFU 1
111+
#define DFH_TYPE_PRIVATE 3
112+
#define DFH_TYPE_FIU 4
113+
114+
/* Function to read from DFH and check if the Feature type is FME */
115+
static inline bool dfl_feature_is_fme(void __iomem *base)
116+
{
117+
u64 v = readq(base + DFH);
118+
119+
return (FIELD_GET(DFH_TYPE, v) == DFH_TYPE_FIU) &&
120+
(FIELD_GET(DFH_ID, v) == DFH_ID_FIU_FME);
121+
}
122+
123+
/* Function to read from DFH and check if the Feature type is port*/
124+
static inline bool dfl_feature_is_port(void __iomem *base)
125+
{
126+
u64 v = readq(base + DFH);
127+
128+
return (FIELD_GET(DFH_TYPE, v) == DFH_TYPE_FIU) &&
129+
(FIELD_GET(DFH_ID, v) == DFH_ID_FIU_PORT);
130+
}
131+
132+
/* Function to read feature revision from DFH */
133+
static inline u8 dfl_feature_revision(void __iomem *base)
134+
{
135+
return (u8)FIELD_GET(DFH_REVISION, readq(base + DFH));
136+
}
137+
86138
#endif /* __LINUX_DFL_H */

0 commit comments

Comments
 (0)