Lines Matching +full:device +full:- +full:id
1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Driver Header File for FPGA Device Feature List (DFL) Support
5 * Copyright (C) 2017-2018 Intel Corporation, Inc.
24 #include <linux/io-64-nonatomic-lo-hi.h>
28 #include <linux/fpga/fpga-region.h>
32 /* plus one for fme device */
56 * Device Feature Header Register Set
69 /* Device Feature Header Register Bitfield */
70 #define DFH_ID GENMASK_ULL(11, 0) /* Feature ID */
95 #define FME_CAP_FABRIC_VERID GENMASK_ULL(7, 0) /* Fabric version ID */
96 #define FME_CAP_SOCKET_ID BIT_ULL(8) /* Socket ID */
107 /* Offset to port device feature header */
109 /* PCI Bar ID for this port */
111 /* AFU MMIO access permission. 1 - VF, 0 - PF. */
138 #define PORT_CAP_PORT_NUM GENMASK_ULL(1, 0) /* ID of this port */
172 * struct dfl_fpga_port_ops - port ops
174 * @name: name of this port ops, to match with port platform device.
177 * @get_id: get port id from hardware.
195 * struct dfl_feature_id - dfl private feature id
197 * @id: unique dfl private feature id.
200 u16 id; member
204 * struct dfl_feature_driver - dfl private feature driver
215 * struct dfl_feature_irq_ctx - dfl private feature interrupt context
228 * struct dfl_feature - sub feature of the feature devices
230 * @dev: ptr to pdev of the feature device which has the sub feature.
231 * @id: sub feature id.
234 * feature dev (platform device)'s reources.
239 * @ddev: ptr to the dfl device of this sub feature.
244 u16 id; member
254 #define FEATURE_DEV_ID_UNUSED (-1)
257 * struct dfl_feature_platform_data - platform data for feature devices
259 * @node: node to link feature devs to container device's port_dev_list.
262 * @dev: ptr to platform device linked with this platform data.
263 * @dfl_cdev: ptr to container device.
264 * @id: id used for this feature device.
266 * @excl_open: set on feature device exclusive open.
267 * @open_count: count for feature device open.
278 int id; member
291 if (pdata->excl_open) in dfl_feature_dev_use_begin()
292 return -EBUSY; in dfl_feature_dev_use_begin()
295 if (pdata->open_count) in dfl_feature_dev_use_begin()
296 return -EBUSY; in dfl_feature_dev_use_begin()
298 pdata->excl_open = true; in dfl_feature_dev_use_begin()
300 pdata->open_count++; in dfl_feature_dev_use_begin()
308 pdata->excl_open = false; in dfl_feature_dev_use_end()
310 if (WARN_ON(pdata->open_count <= 0)) in dfl_feature_dev_use_end()
313 pdata->open_count--; in dfl_feature_dev_use_end()
319 return pdata->open_count; in dfl_feature_dev_use_count()
326 pdata->private = private; in dfl_fpga_pdata_set_private()
332 return pdata->private; in dfl_fpga_pdata_get_private()
343 #define DFL_FPGA_FEATURE_DEV_FME "dfl-fme"
344 #define DFL_FPGA_FEATURE_DEV_PORT "dfl-port"
360 pdata = container_of(inode->i_cdev, struct dfl_feature_platform_data, in dfl_fpga_inode_to_feature_dev()
362 return pdata->dev; in dfl_fpga_inode_to_feature_dev()
366 for ((feature) = (pdata)->features; \
367 (feature) < (pdata)->features + (pdata)->num; (feature)++)
370 struct dfl_feature *dfl_get_feature_by_id(struct device *dev, u16 id) in dfl_get_feature_by_id() argument
376 if (feature->id == id) in dfl_get_feature_by_id()
383 void __iomem *dfl_get_feature_ioaddr_by_id(struct device *dev, u16 id) in dfl_get_feature_ioaddr_by_id() argument
385 struct dfl_feature *feature = dfl_get_feature_by_id(dev, id); in dfl_get_feature_ioaddr_by_id()
387 if (feature && feature->ioaddr) in dfl_get_feature_ioaddr_by_id()
388 return feature->ioaddr; in dfl_get_feature_ioaddr_by_id()
394 static inline bool is_dfl_feature_present(struct device *dev, u16 id) in is_dfl_feature_present() argument
396 return !!dfl_get_feature_ioaddr_by_id(dev, id); in is_dfl_feature_present()
400 struct device *dfl_fpga_pdata_to_parent(struct dfl_feature_platform_data *pdata) in dfl_fpga_pdata_to_parent()
402 return pdata->dev->dev.parent->parent; in dfl_fpga_pdata_to_parent()
427 * struct dfl_fpga_enum_info - DFL FPGA enumeration information
429 * @dev: parent device.
430 * @dfls: list of device feature lists.
435 struct device *dev;
442 * struct dfl_fpga_enum_dfl - DFL FPGA enumeration device feature list info
444 * @start: base address of this device feature list.
445 * @len: size of this device feature list.
446 * @node: node in list of device feature lists.
454 struct dfl_fpga_enum_info *dfl_fpga_enum_info_alloc(struct device *dev);
462 * struct dfl_fpga_cdev - container device of DFL based FPGA
464 * @parent: parent device of this container device.
466 * @fme_dev: FME feature device under this container device.
467 * @lock: mutex lock to protect the port device list.
468 * @port_dev_list: list of all port feature devices under this container device.
469 * @released_port_num: released port number under this container device.
472 struct device *parent;
474 struct device *fme_dev;
485 * need to drop the device reference with put_device() after use port platform
486 * device returned by __dfl_fpga_cdev_find_port and dfl_fpga_cdev_find_port
499 mutex_lock(&cdev->lock); in dfl_fpga_cdev_find_port()
501 mutex_unlock(&cdev->lock); in dfl_fpga_cdev_find_port()
520 * enum dfl_id_type - define the DFL FIU types
529 * struct dfl_device_id - dfl device identifier
530 * @type: contains 4 bits DFL FIU type of the device. See enum dfl_id_type.
541 * struct dfl_device - represent an dfl device on dfl bus
543 * @dev: generic device interface.
544 * @id: id of the dfl device.
545 * @type: type of DFL FIU of the device. See enum dfl_id_type.
547 * @mmio_res: mmio resource of this dfl device.
548 * @irqs: list of Linux IRQ numbers of this dfl device.
549 * @num_irqs: number of IRQs supported by this dfl device.
550 * @cdev: pointer to DFL FPGA container device this dfl device belongs to.
551 * @id_entry: matched id entry in dfl driver's id table.
554 struct device dev;
555 int id; member
566 * struct dfl_driver - represent an dfl device driver
569 * @id_table: pointer to table of device IDs the driver is interested in.
571 * @probe: mandatory callback for device binding.
572 * @remove: callback for device unbinding.
594 * module_dfl_driver() - Helper macro for drivers that don't do