diff options
Diffstat (limited to 'include/linux/fpga')
-rw-r--r-- | include/linux/fpga/fpga-bridge.h | 60 | ||||
-rw-r--r-- | include/linux/fpga/fpga-mgr.h | 29 |
2 files changed, 85 insertions, 4 deletions
diff --git a/include/linux/fpga/fpga-bridge.h b/include/linux/fpga/fpga-bridge.h new file mode 100644 index 000000000000..dba6e3c697c7 --- /dev/null +++ b/include/linux/fpga/fpga-bridge.h | |||
@@ -0,0 +1,60 @@ | |||
1 | #include <linux/device.h> | ||
2 | #include <linux/fpga/fpga-mgr.h> | ||
3 | |||
4 | #ifndef _LINUX_FPGA_BRIDGE_H | ||
5 | #define _LINUX_FPGA_BRIDGE_H | ||
6 | |||
7 | struct fpga_bridge; | ||
8 | |||
9 | /** | ||
10 | * struct fpga_bridge_ops - ops for low level FPGA bridge drivers | ||
11 | * @enable_show: returns the FPGA bridge's status | ||
12 | * @enable_set: set a FPGA bridge as enabled or disabled | ||
13 | * @fpga_bridge_remove: set FPGA into a specific state during driver remove | ||
14 | */ | ||
15 | struct fpga_bridge_ops { | ||
16 | int (*enable_show)(struct fpga_bridge *bridge); | ||
17 | int (*enable_set)(struct fpga_bridge *bridge, bool enable); | ||
18 | void (*fpga_bridge_remove)(struct fpga_bridge *bridge); | ||
19 | }; | ||
20 | |||
21 | /** | ||
22 | * struct fpga_bridge - FPGA bridge structure | ||
23 | * @name: name of low level FPGA bridge | ||
24 | * @dev: FPGA bridge device | ||
25 | * @mutex: enforces exclusive reference to bridge | ||
26 | * @br_ops: pointer to struct of FPGA bridge ops | ||
27 | * @info: fpga image specific information | ||
28 | * @node: FPGA bridge list node | ||
29 | * @priv: low level driver private date | ||
30 | */ | ||
31 | struct fpga_bridge { | ||
32 | const char *name; | ||
33 | struct device dev; | ||
34 | struct mutex mutex; /* for exclusive reference to bridge */ | ||
35 | const struct fpga_bridge_ops *br_ops; | ||
36 | struct fpga_image_info *info; | ||
37 | struct list_head node; | ||
38 | void *priv; | ||
39 | }; | ||
40 | |||
41 | #define to_fpga_bridge(d) container_of(d, struct fpga_bridge, dev) | ||
42 | |||
43 | struct fpga_bridge *of_fpga_bridge_get(struct device_node *node, | ||
44 | struct fpga_image_info *info); | ||
45 | void fpga_bridge_put(struct fpga_bridge *bridge); | ||
46 | int fpga_bridge_enable(struct fpga_bridge *bridge); | ||
47 | int fpga_bridge_disable(struct fpga_bridge *bridge); | ||
48 | |||
49 | int fpga_bridges_enable(struct list_head *bridge_list); | ||
50 | int fpga_bridges_disable(struct list_head *bridge_list); | ||
51 | void fpga_bridges_put(struct list_head *bridge_list); | ||
52 | int fpga_bridge_get_to_list(struct device_node *np, | ||
53 | struct fpga_image_info *info, | ||
54 | struct list_head *bridge_list); | ||
55 | |||
56 | int fpga_bridge_register(struct device *dev, const char *name, | ||
57 | const struct fpga_bridge_ops *br_ops, void *priv); | ||
58 | void fpga_bridge_unregister(struct device *dev); | ||
59 | |||
60 | #endif /* _LINUX_FPGA_BRIDGE_H */ | ||
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 0940bf45e2f2..16551d5eac36 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h | |||
@@ -65,11 +65,26 @@ enum fpga_mgr_states { | |||
65 | /* | 65 | /* |
66 | * FPGA Manager flags | 66 | * FPGA Manager flags |
67 | * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported | 67 | * FPGA_MGR_PARTIAL_RECONFIG: do partial reconfiguration if supported |
68 | * FPGA_MGR_EXTERNAL_CONFIG: FPGA has been configured prior to Linux booting | ||
68 | */ | 69 | */ |
69 | #define FPGA_MGR_PARTIAL_RECONFIG BIT(0) | 70 | #define FPGA_MGR_PARTIAL_RECONFIG BIT(0) |
71 | #define FPGA_MGR_EXTERNAL_CONFIG BIT(1) | ||
72 | |||
73 | /** | ||
74 | * struct fpga_image_info - information specific to a FPGA image | ||
75 | * @flags: boolean flags as defined above | ||
76 | * @enable_timeout_us: maximum time to enable traffic through bridge (uSec) | ||
77 | * @disable_timeout_us: maximum time to disable traffic through bridge (uSec) | ||
78 | */ | ||
79 | struct fpga_image_info { | ||
80 | u32 flags; | ||
81 | u32 enable_timeout_us; | ||
82 | u32 disable_timeout_us; | ||
83 | }; | ||
70 | 84 | ||
71 | /** | 85 | /** |
72 | * struct fpga_manager_ops - ops for low level fpga manager drivers | 86 | * struct fpga_manager_ops - ops for low level fpga manager drivers |
87 | * @initial_header_size: Maximum number of bytes that should be passed into write_init | ||
73 | * @state: returns an enum value of the FPGA's state | 88 | * @state: returns an enum value of the FPGA's state |
74 | * @write_init: prepare the FPGA to receive confuration data | 89 | * @write_init: prepare the FPGA to receive confuration data |
75 | * @write: write count bytes of configuration data to the FPGA | 90 | * @write: write count bytes of configuration data to the FPGA |
@@ -81,11 +96,14 @@ enum fpga_mgr_states { | |||
81 | * called, so leaving them out is fine. | 96 | * called, so leaving them out is fine. |
82 | */ | 97 | */ |
83 | struct fpga_manager_ops { | 98 | struct fpga_manager_ops { |
99 | size_t initial_header_size; | ||
84 | enum fpga_mgr_states (*state)(struct fpga_manager *mgr); | 100 | enum fpga_mgr_states (*state)(struct fpga_manager *mgr); |
85 | int (*write_init)(struct fpga_manager *mgr, u32 flags, | 101 | int (*write_init)(struct fpga_manager *mgr, |
102 | struct fpga_image_info *info, | ||
86 | const char *buf, size_t count); | 103 | const char *buf, size_t count); |
87 | int (*write)(struct fpga_manager *mgr, const char *buf, size_t count); | 104 | int (*write)(struct fpga_manager *mgr, const char *buf, size_t count); |
88 | int (*write_complete)(struct fpga_manager *mgr, u32 flags); | 105 | int (*write_complete)(struct fpga_manager *mgr, |
106 | struct fpga_image_info *info); | ||
89 | void (*fpga_remove)(struct fpga_manager *mgr); | 107 | void (*fpga_remove)(struct fpga_manager *mgr); |
90 | }; | 108 | }; |
91 | 109 | ||
@@ -109,14 +127,17 @@ struct fpga_manager { | |||
109 | 127 | ||
110 | #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) | 128 | #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) |
111 | 129 | ||
112 | int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, | 130 | int fpga_mgr_buf_load(struct fpga_manager *mgr, struct fpga_image_info *info, |
113 | const char *buf, size_t count); | 131 | const char *buf, size_t count); |
114 | 132 | ||
115 | int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags, | 133 | int fpga_mgr_firmware_load(struct fpga_manager *mgr, |
134 | struct fpga_image_info *info, | ||
116 | const char *image_name); | 135 | const char *image_name); |
117 | 136 | ||
118 | struct fpga_manager *of_fpga_mgr_get(struct device_node *node); | 137 | struct fpga_manager *of_fpga_mgr_get(struct device_node *node); |
119 | 138 | ||
139 | struct fpga_manager *fpga_mgr_get(struct device *dev); | ||
140 | |||
120 | void fpga_mgr_put(struct fpga_manager *mgr); | 141 | void fpga_mgr_put(struct fpga_manager *mgr); |
121 | 142 | ||
122 | int fpga_mgr_register(struct device *dev, const char *name, | 143 | int fpga_mgr_register(struct device *dev, const char *name, |