1 /* SPDX-License-Identifier: GPL-2.0 */
6 #include <linux/device.h>
7 #include <linux/fpga/fpga-mgr.h>
8 #include <linux/fpga/fpga-bridge.h>
13 * struct fpga_region_info - collection of parameters an FPGA Region
14 * @mgr: fpga region manager
15 * @compat_id: FPGA region id for compatibility check.
16 * @priv: fpga region private data
17 * @get_bridges: optional function to get bridges to a list
19 * fpga_region_info contains parameters for the register_full function.
20 * These are separated into an info structure because they some are optional
21 * others could be added to in the future. The info structure facilitates
22 * maintaining a stable API.
24 struct fpga_region_info
{
25 struct fpga_manager
*mgr
;
26 struct fpga_compat_id
*compat_id
;
28 int (*get_bridges
)(struct fpga_region
*region
);
32 * struct fpga_region - FPGA Region structure
33 * @dev: FPGA Region device
34 * @mutex: enforces exclusive reference to region
35 * @bridge_list: list of FPGA bridges specified in region
37 * @info: FPGA image info
38 * @compat_id: FPGA region id for compatibility check.
39 * @ops_owner: module containing the get_bridges function
41 * @get_bridges: optional function to get bridges to a list
45 struct mutex mutex
; /* for exclusive reference to region */
46 struct list_head bridge_list
;
47 struct fpga_manager
*mgr
;
48 struct fpga_image_info
*info
;
49 struct fpga_compat_id
*compat_id
;
50 struct module
*ops_owner
;
52 int (*get_bridges
)(struct fpga_region
*region
);
55 #define to_fpga_region(d) container_of(d, struct fpga_region, dev)
58 fpga_region_class_find(struct device
*start
, const void *data
,
59 int (*match
)(struct device
*, const void *));
61 int fpga_region_program_fpga(struct fpga_region
*region
);
63 #define fpga_region_register_full(parent, info) \
64 __fpga_region_register_full(parent, info, THIS_MODULE)
66 __fpga_region_register_full(struct device
*parent
, const struct fpga_region_info
*info
,
67 struct module
*owner
);
69 #define fpga_region_register(parent, mgr, get_bridges) \
70 __fpga_region_register(parent, mgr, get_bridges, THIS_MODULE)
72 __fpga_region_register(struct device
*parent
, struct fpga_manager
*mgr
,
73 int (*get_bridges
)(struct fpga_region
*), struct module
*owner
);
74 void fpga_region_unregister(struct fpga_region
*region
);
76 #endif /* _FPGA_REGION_H */