blob: 27cb706275dba81b8286ed46dcd252b5964f391f [file] [log] [blame]
Alan Tull473f01f2018-05-16 18:49:58 -05001/* SPDX-License-Identifier: GPL-2.0 */
2
Alan Tull59460a92017-11-15 14:20:21 -06003#ifndef _FPGA_REGION_H
4#define _FPGA_REGION_H
5
6#include <linux/device.h>
7#include <linux/fpga/fpga-mgr.h>
8#include <linux/fpga/fpga-bridge.h>
9
10/**
11 * struct fpga_region - FPGA Region structure
12 * @dev: FPGA Region device
13 * @mutex: enforces exclusive reference to region
14 * @bridge_list: list of FPGA bridges specified in region
15 * @mgr: FPGA manager
16 * @info: FPGA image info
Wu Hao41a8b2c2018-06-30 08:53:12 +080017 * @compat_id: FPGA region id for compatibility check.
Alan Tull52a3a7c2017-11-15 14:20:23 -060018 * @priv: private data
19 * @get_bridges: optional function to get bridges to a list
Alan Tull59460a92017-11-15 14:20:21 -060020 */
21struct fpga_region {
22 struct device dev;
23 struct mutex mutex; /* for exclusive reference to region */
24 struct list_head bridge_list;
25 struct fpga_manager *mgr;
26 struct fpga_image_info *info;
Wu Hao41a8b2c2018-06-30 08:53:12 +080027 struct fpga_compat_id *compat_id;
Alan Tull52a3a7c2017-11-15 14:20:23 -060028 void *priv;
29 int (*get_bridges)(struct fpga_region *region);
Alan Tull59460a92017-11-15 14:20:21 -060030};
31
32#define to_fpga_region(d) container_of(d, struct fpga_region, dev)
33
Alan Tull503d4b72017-11-15 14:20:24 -060034struct fpga_region *fpga_region_class_find(
35 struct device *start, const void *data,
36 int (*match)(struct device *, const void *));
Alan Tull59460a92017-11-15 14:20:21 -060037
Alan Tull503d4b72017-11-15 14:20:24 -060038int fpga_region_program_fpga(struct fpga_region *region);
Alan Tull9f368972018-05-16 18:49:57 -050039
40struct fpga_region
41*fpga_region_create(struct device *dev, struct fpga_manager *mgr,
42 int (*get_bridges)(struct fpga_region *));
43void fpga_region_free(struct fpga_region *region);
44int fpga_region_register(struct fpga_region *region);
45void fpga_region_unregister(struct fpga_region *region);
Alan Tull52a3a7c2017-11-15 14:20:23 -060046
Alan Tullfea82b72018-10-15 17:20:03 -050047struct fpga_region
48*devm_fpga_region_create(struct device *dev, struct fpga_manager *mgr,
49 int (*get_bridges)(struct fpga_region *));
50
Alan Tull59460a92017-11-15 14:20:21 -060051#endif /* _FPGA_REGION_H */