dfl.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * Driver Header File for FPGA Device Feature List (DFL) Support
  4. *
  5. * Copyright (C) 2017-2018 Intel Corporation, Inc.
  6. *
  7. * Authors:
  8. * Kang Luwei <luwei.kang@intel.com>
  9. * Zhang Yi <yi.z.zhang@intel.com>
  10. * Wu Hao <hao.wu@intel.com>
  11. * Xiao Guangrong <guangrong.xiao@linux.intel.com>
  12. */
  13. #ifndef __FPGA_DFL_H
  14. #define __FPGA_DFL_H
  15. #include <linux/bitfield.h>
  16. #include <linux/cdev.h>
  17. #include <linux/delay.h>
  18. #include <linux/eventfd.h>
  19. #include <linux/fs.h>
  20. #include <linux/interrupt.h>
  21. #include <linux/iopoll.h>
  22. #include <linux/io-64-nonatomic-lo-hi.h>
  23. #include <linux/mod_devicetable.h>
  24. #include <linux/platform_device.h>
  25. #include <linux/slab.h>
  26. #include <linux/uuid.h>
  27. #include <linux/fpga/fpga-region.h>
  28. /* maximum supported number of ports */
  29. #define MAX_DFL_FPGA_PORT_NUM 4
  30. /* plus one for fme device */
  31. #define MAX_DFL_FEATURE_DEV_NUM (MAX_DFL_FPGA_PORT_NUM + 1)
  32. /* Reserved 0xfe for Header Group Register and 0xff for AFU */
  33. #define FEATURE_ID_FIU_HEADER 0xfe
  34. #define FEATURE_ID_AFU 0xff
  35. #define FME_FEATURE_ID_HEADER FEATURE_ID_FIU_HEADER
  36. #define FME_FEATURE_ID_THERMAL_MGMT 0x1
  37. #define FME_FEATURE_ID_POWER_MGMT 0x2
  38. #define FME_FEATURE_ID_GLOBAL_IPERF 0x3
  39. #define FME_FEATURE_ID_GLOBAL_ERR 0x4
  40. #define FME_FEATURE_ID_PR_MGMT 0x5
  41. #define FME_FEATURE_ID_HSSI 0x6
  42. #define FME_FEATURE_ID_GLOBAL_DPERF 0x7
  43. #define PORT_FEATURE_ID_HEADER FEATURE_ID_FIU_HEADER
  44. #define PORT_FEATURE_ID_AFU FEATURE_ID_AFU
  45. #define PORT_FEATURE_ID_ERROR 0x10
  46. #define PORT_FEATURE_ID_UMSG 0x11
  47. #define PORT_FEATURE_ID_UINT 0x12
  48. #define PORT_FEATURE_ID_STP 0x13
  49. /*
  50. * Device Feature Header Register Set
  51. *
  52. * For FIUs, they all have DFH + GUID + NEXT_AFU as common header registers.
  53. * For AFUs, they have DFH + GUID as common header registers.
  54. * For private features, they only have DFH register as common header.
  55. */
  56. #define DFH 0x0
  57. #define GUID_L 0x8
  58. #define GUID_H 0x10
  59. #define NEXT_AFU 0x18
  60. #define DFH_SIZE 0x8
  61. /* Device Feature Header Register Bitfield */
  62. #define DFH_ID GENMASK_ULL(11, 0) /* Feature ID */
  63. #define DFH_ID_FIU_FME 0
  64. #define DFH_ID_FIU_PORT 1
  65. #define DFH_REVISION GENMASK_ULL(15, 12) /* Feature revision */
  66. #define DFH_NEXT_HDR_OFST GENMASK_ULL(39, 16) /* Offset to next DFH */
  67. #define DFH_EOL BIT_ULL(40) /* End of list */
  68. #define DFH_VERSION GENMASK_ULL(59, 52) /* DFH version */
  69. #define DFH_TYPE GENMASK_ULL(63, 60) /* Feature type */
  70. #define DFH_TYPE_AFU 1
  71. #define DFH_TYPE_PRIVATE 3
  72. #define DFH_TYPE_FIU 4
  73. /*
  74. * DFHv1 Register Offset definitons
  75. * In DHFv1, DFH + GUID + CSR_START + CSR_SIZE_GROUP + PARAM_HDR + PARAM_DATA
  76. * as common header registers
  77. */
  78. #define DFHv1_CSR_ADDR 0x18 /* CSR Register start address */
  79. #define DFHv1_CSR_SIZE_GRP 0x20 /* Size of Reg Block and Group/tag */
  80. #define DFHv1_PARAM_HDR 0x28 /* Optional First Param header */
  81. /*
  82. * CSR Rel Bit, 1'b0 = relative (offset from feature DFH start),
  83. * 1'b1 = absolute (ARM or other non-PCIe use)
  84. */
  85. #define DFHv1_CSR_ADDR_REL BIT_ULL(0)
  86. /* CSR Header Register Bit Definitions */
  87. #define DFHv1_CSR_ADDR_MASK GENMASK_ULL(63, 1) /* 63:1 of CSR address */
  88. /* CSR SIZE Goup Register Bit Definitions */
  89. #define DFHv1_CSR_SIZE_GRP_INSTANCE_ID GENMASK_ULL(15, 0) /* Enumeration instantiated IP */
  90. #define DFHv1_CSR_SIZE_GRP_GROUPING_ID GENMASK_ULL(30, 16) /* Group Features/interfaces */
  91. #define DFHv1_CSR_SIZE_GRP_HAS_PARAMS BIT_ULL(31) /* Presence of Parameters */
  92. #define DFHv1_CSR_SIZE_GRP_SIZE GENMASK_ULL(63, 32) /* Size of CSR Block in bytes */
  93. /* PARAM Header Register Bit Definitions */
  94. #define DFHv1_PARAM_HDR_ID GENMASK_ULL(15, 0) /* Id of this Param */
  95. #define DFHv1_PARAM_HDR_VER GENMASK_ULL(31, 16) /* Version Param */
  96. #define DFHv1_PARAM_HDR_NEXT_OFFSET GENMASK_ULL(63, 35) /* Offset of next Param */
  97. #define DFHv1_PARAM_HDR_NEXT_EOP BIT_ULL(32)
  98. #define DFHv1_PARAM_DATA 0x08 /* Offset of Param data from Param header */
  99. #define DFHv1_PARAM_ID_MSI_X 0x1
  100. #define DFHv1_PARAM_MSI_X_NUMV GENMASK_ULL(63, 32)
  101. #define DFHv1_PARAM_MSI_X_STARTV GENMASK_ULL(31, 0)
  102. /* Next AFU Register Bitfield */
  103. #define NEXT_AFU_NEXT_DFH_OFST GENMASK_ULL(23, 0) /* Offset to next AFU */
  104. /* FME Header Register Set */
  105. #define FME_HDR_DFH DFH
  106. #define FME_HDR_GUID_L GUID_L
  107. #define FME_HDR_GUID_H GUID_H
  108. #define FME_HDR_NEXT_AFU NEXT_AFU
  109. #define FME_HDR_CAP 0x30
  110. #define FME_HDR_PORT_OFST(n) (0x38 + ((n) * 0x8))
  111. #define FME_PORT_OFST_BAR_SKIP 7
  112. #define FME_HDR_BITSTREAM_ID 0x60
  113. #define FME_HDR_BITSTREAM_MD 0x68
  114. /* FME Fab Capability Register Bitfield */
  115. #define FME_CAP_FABRIC_VERID GENMASK_ULL(7, 0) /* Fabric version ID */
  116. #define FME_CAP_SOCKET_ID BIT_ULL(8) /* Socket ID */
  117. #define FME_CAP_PCIE0_LINK_AVL BIT_ULL(12) /* PCIE0 Link */
  118. #define FME_CAP_PCIE1_LINK_AVL BIT_ULL(13) /* PCIE1 Link */
  119. #define FME_CAP_COHR_LINK_AVL BIT_ULL(14) /* Coherent Link */
  120. #define FME_CAP_IOMMU_AVL BIT_ULL(16) /* IOMMU available */
  121. #define FME_CAP_NUM_PORTS GENMASK_ULL(19, 17) /* Number of ports */
  122. #define FME_CAP_ADDR_WIDTH GENMASK_ULL(29, 24) /* Address bus width */
  123. #define FME_CAP_CACHE_SIZE GENMASK_ULL(43, 32) /* cache size in KB */
  124. #define FME_CAP_CACHE_ASSOC GENMASK_ULL(47, 44) /* Associativity */
  125. /* FME Port Offset Register Bitfield */
  126. /* Offset to port device feature header */
  127. #define FME_PORT_OFST_DFH_OFST GENMASK_ULL(23, 0)
  128. /* PCI Bar ID for this port */
  129. #define FME_PORT_OFST_BAR_ID GENMASK_ULL(34, 32)
  130. /* AFU MMIO access permission. 1 - VF, 0 - PF. */
  131. #define FME_PORT_OFST_ACC_CTRL BIT_ULL(55)
  132. #define FME_PORT_OFST_ACC_PF 0
  133. #define FME_PORT_OFST_ACC_VF 1
  134. #define FME_PORT_OFST_IMP BIT_ULL(60)
  135. /* FME Error Capability Register */
  136. #define FME_ERROR_CAP 0x70
  137. /* FME Error Capability Register Bitfield */
  138. #define FME_ERROR_CAP_SUPP_INT BIT_ULL(0) /* Interrupt Support */
  139. #define FME_ERROR_CAP_INT_VECT GENMASK_ULL(12, 1) /* Interrupt vector */
  140. /* PORT Header Register Set */
  141. #define PORT_HDR_DFH DFH
  142. #define PORT_HDR_GUID_L GUID_L
  143. #define PORT_HDR_GUID_H GUID_H
  144. #define PORT_HDR_NEXT_AFU NEXT_AFU
  145. #define PORT_HDR_CAP 0x30
  146. #define PORT_HDR_CTRL 0x38
  147. #define PORT_HDR_STS 0x40
  148. #define PORT_HDR_USRCLK_CMD0 0x50
  149. #define PORT_HDR_USRCLK_CMD1 0x58
  150. #define PORT_HDR_USRCLK_STS0 0x60
  151. #define PORT_HDR_USRCLK_STS1 0x68
  152. /* Port Capability Register Bitfield */
  153. #define PORT_CAP_PORT_NUM GENMASK_ULL(1, 0) /* ID of this port */
  154. #define PORT_CAP_MMIO_SIZE GENMASK_ULL(23, 8) /* MMIO size in KB */
  155. #define PORT_CAP_SUPP_INT_NUM GENMASK_ULL(35, 32) /* Interrupts num */
  156. /* Port Control Register Bitfield */
  157. #define PORT_CTRL_SFTRST BIT_ULL(0) /* Port soft reset */
  158. /* Latency tolerance reporting. '1' >= 40us, '0' < 40us.*/
  159. #define PORT_CTRL_LATENCY BIT_ULL(2)
  160. #define PORT_CTRL_SFTRST_ACK BIT_ULL(4) /* HW ack for reset */
  161. /* Port Status Register Bitfield */
  162. #define PORT_STS_AP2_EVT BIT_ULL(13) /* AP2 event detected */
  163. #define PORT_STS_AP1_EVT BIT_ULL(12) /* AP1 event detected */
  164. #define PORT_STS_PWR_STATE GENMASK_ULL(11, 8) /* AFU power states */
  165. #define PORT_STS_PWR_STATE_NORM 0
  166. #define PORT_STS_PWR_STATE_AP1 1 /* 50% throttling */
  167. #define PORT_STS_PWR_STATE_AP2 2 /* 90% throttling */
  168. #define PORT_STS_PWR_STATE_AP6 6 /* 100% throttling */
  169. /* Port Error Capability Register */
  170. #define PORT_ERROR_CAP 0x38
  171. /* Port Error Capability Register Bitfield */
  172. #define PORT_ERROR_CAP_SUPP_INT BIT_ULL(0) /* Interrupt Support */
  173. #define PORT_ERROR_CAP_INT_VECT GENMASK_ULL(12, 1) /* Interrupt vector */
  174. /* Port Uint Capability Register */
  175. #define PORT_UINT_CAP 0x8
  176. /* Port Uint Capability Register Bitfield */
  177. #define PORT_UINT_CAP_INT_NUM GENMASK_ULL(11, 0) /* Interrupts num */
  178. #define PORT_UINT_CAP_FST_VECT GENMASK_ULL(23, 12) /* First Vector */
  179. /**
  180. * struct dfl_fpga_port_ops - port ops
  181. *
  182. * @name: name of this port ops, to match with port platform device.
  183. * @owner: pointer to the module which owns this port ops.
  184. * @node: node to link port ops to global list.
  185. * @get_id: get port id from hardware.
  186. * @enable_set: enable/disable the port.
  187. */
  188. struct dfl_fpga_port_ops {
  189. const char *name;
  190. struct module *owner;
  191. struct list_head node;
  192. int (*get_id)(struct platform_device *pdev);
  193. int (*enable_set)(struct platform_device *pdev, bool enable);
  194. };
  195. void dfl_fpga_port_ops_add(struct dfl_fpga_port_ops *ops);
  196. void dfl_fpga_port_ops_del(struct dfl_fpga_port_ops *ops);
  197. struct dfl_fpga_port_ops *dfl_fpga_port_ops_get(struct platform_device *pdev);
  198. void dfl_fpga_port_ops_put(struct dfl_fpga_port_ops *ops);
  199. int dfl_fpga_check_port_id(struct platform_device *pdev, void *pport_id);
  200. /**
  201. * struct dfl_feature_id - dfl private feature id
  202. *
  203. * @id: unique dfl private feature id.
  204. */
  205. struct dfl_feature_id {
  206. u16 id;
  207. };
  208. /**
  209. * struct dfl_feature_driver - dfl private feature driver
  210. *
  211. * @id_table: id_table for dfl private features supported by this driver.
  212. * @ops: ops of this dfl private feature driver.
  213. */
  214. struct dfl_feature_driver {
  215. const struct dfl_feature_id *id_table;
  216. const struct dfl_feature_ops *ops;
  217. };
  218. /**
  219. * struct dfl_feature_irq_ctx - dfl private feature interrupt context
  220. *
  221. * @irq: Linux IRQ number of this interrupt.
  222. * @trigger: eventfd context to signal when interrupt happens.
  223. * @name: irq name needed when requesting irq.
  224. */
  225. struct dfl_feature_irq_ctx {
  226. int irq;
  227. struct eventfd_ctx *trigger;
  228. char *name;
  229. };
  230. /**
  231. * struct dfl_feature - sub feature of the feature devices
  232. *
  233. * @dev: ptr to pdev of the feature device which has the sub feature.
  234. * @id: sub feature id.
  235. * @revision: revision of this sub feature.
  236. * @resource_index: each sub feature has one mmio resource for its registers.
  237. * this index is used to find its mmio resource from the
  238. * feature dev (platform device)'s resources.
  239. * @ioaddr: mapped mmio resource address.
  240. * @irq_ctx: interrupt context list.
  241. * @nr_irqs: number of interrupt contexts.
  242. * @ops: ops of this sub feature.
  243. * @ddev: ptr to the dfl device of this sub feature.
  244. * @priv: priv data of this feature.
  245. * @dfh_version: version of the DFH
  246. * @param_size: size of dfh parameters
  247. * @params: point to memory copy of dfh parameters
  248. */
  249. struct dfl_feature {
  250. struct platform_device *dev;
  251. u16 id;
  252. u8 revision;
  253. int resource_index;
  254. void __iomem *ioaddr;
  255. struct dfl_feature_irq_ctx *irq_ctx;
  256. unsigned int nr_irqs;
  257. const struct dfl_feature_ops *ops;
  258. struct dfl_device *ddev;
  259. void *priv;
  260. u8 dfh_version;
  261. unsigned int param_size;
  262. void *params;
  263. };
  264. #define FEATURE_DEV_ID_UNUSED (-1)
  265. /**
  266. * struct dfl_feature_platform_data - platform data for feature devices
  267. *
  268. * @node: node to link feature devs to container device's port_dev_list.
  269. * @lock: mutex to protect platform data.
  270. * @cdev: cdev of feature dev.
  271. * @dev: ptr to platform device linked with this platform data.
  272. * @dfl_cdev: ptr to container device.
  273. * @id: id used for this feature device.
  274. * @disable_count: count for port disable.
  275. * @excl_open: set on feature device exclusive open.
  276. * @open_count: count for feature device open.
  277. * @num: number for sub features.
  278. * @private: ptr to feature dev private data.
  279. * @features: sub features of this feature dev.
  280. */
  281. struct dfl_feature_platform_data {
  282. struct list_head node;
  283. struct mutex lock;
  284. struct cdev cdev;
  285. struct platform_device *dev;
  286. struct dfl_fpga_cdev *dfl_cdev;
  287. int id;
  288. unsigned int disable_count;
  289. bool excl_open;
  290. int open_count;
  291. void *private;
  292. int num;
  293. struct dfl_feature features[];
  294. };
  295. static inline
  296. int dfl_feature_dev_use_begin(struct dfl_feature_platform_data *pdata,
  297. bool excl)
  298. {
  299. if (pdata->excl_open)
  300. return -EBUSY;
  301. if (excl) {
  302. if (pdata->open_count)
  303. return -EBUSY;
  304. pdata->excl_open = true;
  305. }
  306. pdata->open_count++;
  307. return 0;
  308. }
  309. static inline
  310. void dfl_feature_dev_use_end(struct dfl_feature_platform_data *pdata)
  311. {
  312. pdata->excl_open = false;
  313. if (WARN_ON(pdata->open_count <= 0))
  314. return;
  315. pdata->open_count--;
  316. }
  317. static inline
  318. int dfl_feature_dev_use_count(struct dfl_feature_platform_data *pdata)
  319. {
  320. return pdata->open_count;
  321. }
  322. static inline
  323. void dfl_fpga_pdata_set_private(struct dfl_feature_platform_data *pdata,
  324. void *private)
  325. {
  326. pdata->private = private;
  327. }
  328. static inline
  329. void *dfl_fpga_pdata_get_private(struct dfl_feature_platform_data *pdata)
  330. {
  331. return pdata->private;
  332. }
  333. struct dfl_feature_ops {
  334. int (*init)(struct platform_device *pdev, struct dfl_feature *feature);
  335. void (*uinit)(struct platform_device *pdev,
  336. struct dfl_feature *feature);
  337. long (*ioctl)(struct platform_device *pdev, struct dfl_feature *feature,
  338. unsigned int cmd, unsigned long arg);
  339. };
  340. #define DFL_FPGA_FEATURE_DEV_FME "dfl-fme"
  341. #define DFL_FPGA_FEATURE_DEV_PORT "dfl-port"
  342. void dfl_fpga_dev_feature_uinit(struct platform_device *pdev);
  343. int dfl_fpga_dev_feature_init(struct platform_device *pdev,
  344. struct dfl_feature_driver *feature_drvs);
  345. int dfl_fpga_dev_ops_register(struct platform_device *pdev,
  346. const struct file_operations *fops,
  347. struct module *owner);
  348. void dfl_fpga_dev_ops_unregister(struct platform_device *pdev);
  349. static inline
  350. struct platform_device *dfl_fpga_inode_to_feature_dev(struct inode *inode)
  351. {
  352. struct dfl_feature_platform_data *pdata;
  353. pdata = container_of(inode->i_cdev, struct dfl_feature_platform_data,
  354. cdev);
  355. return pdata->dev;
  356. }
  357. #define dfl_fpga_dev_for_each_feature(pdata, feature) \
  358. for ((feature) = (pdata)->features; \
  359. (feature) < (pdata)->features + (pdata)->num; (feature)++)
  360. static inline
  361. struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u16 id)
  362. {
  363. struct dfl_feature_platform_data *pdata = dev_get_platdata(dev);
  364. struct dfl_feature *feature;
  365. dfl_fpga_dev_for_each_feature(pdata, feature)
  366. if (feature->id == id)
  367. return feature;
  368. return NULL;
  369. }
  370. static inline
  371. void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u16 id)
  372. {
  373. struct dfl_feature *feature = dfl_get_feature_by_id(dev, id);
  374. if (feature && feature->ioaddr)
  375. return feature->ioaddr;
  376. WARN_ON(1);
  377. return NULL;
  378. }
  379. static inline
  380. struct device *dfl_fpga_pdata_to_parent(struct dfl_feature_platform_data *pdata)
  381. {
  382. return pdata->dev->dev.parent->parent;
  383. }
  384. static inline bool dfl_feature_is_fme(void __iomem *base)
  385. {
  386. u64 v = readq(base + DFH);
  387. return (FIELD_GET(DFH_TYPE, v) == DFH_TYPE_FIU) &&
  388. (FIELD_GET(DFH_ID, v) == DFH_ID_FIU_FME);
  389. }
  390. static inline bool dfl_feature_is_port(void __iomem *base)
  391. {
  392. u64 v = readq(base + DFH);
  393. return (FIELD_GET(DFH_TYPE, v) == DFH_TYPE_FIU) &&
  394. (FIELD_GET(DFH_ID, v) == DFH_ID_FIU_PORT);
  395. }
  396. static inline u8 dfl_feature_revision(void __iomem *base)
  397. {
  398. return (u8)FIELD_GET(DFH_REVISION, readq(base + DFH));
  399. }
  400. /**
  401. * struct dfl_fpga_enum_info - DFL FPGA enumeration information
  402. *
  403. * @dev: parent device.
  404. * @dfls: list of device feature lists.
  405. * @nr_irqs: number of irqs for all feature devices.
  406. * @irq_table: Linux IRQ numbers for all irqs, indexed by hw irq numbers.
  407. */
  408. struct dfl_fpga_enum_info {
  409. struct device *dev;
  410. struct list_head dfls;
  411. unsigned int nr_irqs;
  412. int *irq_table;
  413. };
  414. /**
  415. * struct dfl_fpga_enum_dfl - DFL FPGA enumeration device feature list info
  416. *
  417. * @start: base address of this device feature list.
  418. * @len: size of this device feature list.
  419. * @node: node in list of device feature lists.
  420. */
  421. struct dfl_fpga_enum_dfl {
  422. resource_size_t start;
  423. resource_size_t len;
  424. struct list_head node;
  425. };
  426. struct dfl_fpga_enum_info *dfl_fpga_enum_info_alloc(struct device *dev);
  427. int dfl_fpga_enum_info_add_dfl(struct dfl_fpga_enum_info *info,
  428. resource_size_t start, resource_size_t len);
  429. int dfl_fpga_enum_info_add_irq(struct dfl_fpga_enum_info *info,
  430. unsigned int nr_irqs, int *irq_table);
  431. void dfl_fpga_enum_info_free(struct dfl_fpga_enum_info *info);
  432. /**
  433. * struct dfl_fpga_cdev - container device of DFL based FPGA
  434. *
  435. * @parent: parent device of this container device.
  436. * @region: base fpga region.
  437. * @fme_dev: FME feature device under this container device.
  438. * @lock: mutex lock to protect the port device list.
  439. * @port_dev_list: list of all port feature devices under this container device.
  440. * @released_port_num: released port number under this container device.
  441. */
  442. struct dfl_fpga_cdev {
  443. struct device *parent;
  444. struct fpga_region *region;
  445. struct device *fme_dev;
  446. struct mutex lock;
  447. struct list_head port_dev_list;
  448. int released_port_num;
  449. };
  450. struct dfl_fpga_cdev *
  451. dfl_fpga_feature_devs_enumerate(struct dfl_fpga_enum_info *info);
  452. void dfl_fpga_feature_devs_remove(struct dfl_fpga_cdev *cdev);
  453. /*
  454. * need to drop the device reference with put_device() after use port platform
  455. * device returned by __dfl_fpga_cdev_find_port and dfl_fpga_cdev_find_port
  456. * functions.
  457. */
  458. struct platform_device *
  459. __dfl_fpga_cdev_find_port(struct dfl_fpga_cdev *cdev, void *data,
  460. int (*match)(struct platform_device *, void *));
  461. static inline struct platform_device *
  462. dfl_fpga_cdev_find_port(struct dfl_fpga_cdev *cdev, void *data,
  463. int (*match)(struct platform_device *, void *))
  464. {
  465. struct platform_device *pdev;
  466. mutex_lock(&cdev->lock);
  467. pdev = __dfl_fpga_cdev_find_port(cdev, data, match);
  468. mutex_unlock(&cdev->lock);
  469. return pdev;
  470. }
  471. int dfl_fpga_cdev_release_port(struct dfl_fpga_cdev *cdev, int port_id);
  472. int dfl_fpga_cdev_assign_port(struct dfl_fpga_cdev *cdev, int port_id);
  473. void dfl_fpga_cdev_config_ports_pf(struct dfl_fpga_cdev *cdev);
  474. int dfl_fpga_cdev_config_ports_vf(struct dfl_fpga_cdev *cdev, int num_vf);
  475. int dfl_fpga_set_irq_triggers(struct dfl_feature *feature, unsigned int start,
  476. unsigned int count, int32_t *fds);
  477. long dfl_feature_ioctl_get_num_irqs(struct platform_device *pdev,
  478. struct dfl_feature *feature,
  479. unsigned long arg);
  480. long dfl_feature_ioctl_set_irq(struct platform_device *pdev,
  481. struct dfl_feature *feature,
  482. unsigned long arg);
  483. #endif /* __FPGA_DFL_H */