diff options
Diffstat (limited to 'include/linux/fpga')
-rw-r--r-- | include/linux/fpga/fpga-bridge.h | 14 | ||||
-rw-r--r-- | include/linux/fpga/fpga-mgr.h | 39 | ||||
-rw-r--r-- | include/linux/fpga/fpga-region.h | 40 |
3 files changed, 79 insertions, 14 deletions
diff --git a/include/linux/fpga/fpga-bridge.h b/include/linux/fpga/fpga-bridge.h index aa66c87c120b..3694821a6d2d 100644 --- a/include/linux/fpga/fpga-bridge.h +++ b/include/linux/fpga/fpga-bridge.h | |||
@@ -1,10 +1,11 @@ | |||
1 | /* SPDX-License-Identifier: GPL-2.0 */ | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
2 | #include <linux/device.h> | ||
3 | #include <linux/fpga/fpga-mgr.h> | ||
4 | 2 | ||
5 | #ifndef _LINUX_FPGA_BRIDGE_H | 3 | #ifndef _LINUX_FPGA_BRIDGE_H |
6 | #define _LINUX_FPGA_BRIDGE_H | 4 | #define _LINUX_FPGA_BRIDGE_H |
7 | 5 | ||
6 | #include <linux/device.h> | ||
7 | #include <linux/fpga/fpga-mgr.h> | ||
8 | |||
8 | struct fpga_bridge; | 9 | struct fpga_bridge; |
9 | 10 | ||
10 | /** | 11 | /** |
@@ -12,11 +13,13 @@ struct fpga_bridge; | |||
12 | * @enable_show: returns the FPGA bridge's status | 13 | * @enable_show: returns the FPGA bridge's status |
13 | * @enable_set: set a FPGA bridge as enabled or disabled | 14 | * @enable_set: set a FPGA bridge as enabled or disabled |
14 | * @fpga_bridge_remove: set FPGA into a specific state during driver remove | 15 | * @fpga_bridge_remove: set FPGA into a specific state during driver remove |
16 | * @groups: optional attribute groups. | ||
15 | */ | 17 | */ |
16 | struct fpga_bridge_ops { | 18 | struct fpga_bridge_ops { |
17 | int (*enable_show)(struct fpga_bridge *bridge); | 19 | int (*enable_show)(struct fpga_bridge *bridge); |
18 | int (*enable_set)(struct fpga_bridge *bridge, bool enable); | 20 | int (*enable_set)(struct fpga_bridge *bridge, bool enable); |
19 | void (*fpga_bridge_remove)(struct fpga_bridge *bridge); | 21 | void (*fpga_bridge_remove)(struct fpga_bridge *bridge); |
22 | const struct attribute_group **groups; | ||
20 | }; | 23 | }; |
21 | 24 | ||
22 | /** | 25 | /** |
@@ -43,6 +46,8 @@ struct fpga_bridge { | |||
43 | 46 | ||
44 | struct fpga_bridge *of_fpga_bridge_get(struct device_node *node, | 47 | struct fpga_bridge *of_fpga_bridge_get(struct device_node *node, |
45 | struct fpga_image_info *info); | 48 | struct fpga_image_info *info); |
49 | struct fpga_bridge *fpga_bridge_get(struct device *dev, | ||
50 | struct fpga_image_info *info); | ||
46 | void fpga_bridge_put(struct fpga_bridge *bridge); | 51 | void fpga_bridge_put(struct fpga_bridge *bridge); |
47 | int fpga_bridge_enable(struct fpga_bridge *bridge); | 52 | int fpga_bridge_enable(struct fpga_bridge *bridge); |
48 | int fpga_bridge_disable(struct fpga_bridge *bridge); | 53 | int fpga_bridge_disable(struct fpga_bridge *bridge); |
@@ -50,9 +55,12 @@ int fpga_bridge_disable(struct fpga_bridge *bridge); | |||
50 | int fpga_bridges_enable(struct list_head *bridge_list); | 55 | int fpga_bridges_enable(struct list_head *bridge_list); |
51 | int fpga_bridges_disable(struct list_head *bridge_list); | 56 | int fpga_bridges_disable(struct list_head *bridge_list); |
52 | void fpga_bridges_put(struct list_head *bridge_list); | 57 | void fpga_bridges_put(struct list_head *bridge_list); |
53 | int fpga_bridge_get_to_list(struct device_node *np, | 58 | int fpga_bridge_get_to_list(struct device *dev, |
54 | struct fpga_image_info *info, | 59 | struct fpga_image_info *info, |
55 | struct list_head *bridge_list); | 60 | struct list_head *bridge_list); |
61 | int of_fpga_bridge_get_to_list(struct device_node *np, | ||
62 | struct fpga_image_info *info, | ||
63 | struct list_head *bridge_list); | ||
56 | 64 | ||
57 | int fpga_bridge_register(struct device *dev, const char *name, | 65 | int fpga_bridge_register(struct device *dev, const char *name, |
58 | const struct fpga_bridge_ops *br_ops, void *priv); | 66 | const struct fpga_bridge_ops *br_ops, void *priv); |
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index bfa14bc023fb..3c6de23aabdf 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h | |||
@@ -1,7 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * FPGA Framework | 2 | * FPGA Framework |
3 | * | 3 | * |
4 | * Copyright (C) 2013-2015 Altera Corporation | 4 | * Copyright (C) 2013-2016 Altera Corporation |
5 | * Copyright (C) 2017 Intel Corporation | ||
5 | * | 6 | * |
6 | * This program is free software; you can redistribute it and/or modify it | 7 | * This program is free software; you can redistribute it and/or modify it |
7 | * under the terms and conditions of the GNU General Public License, | 8 | * under the terms and conditions of the GNU General Public License, |
@@ -15,12 +16,12 @@ | |||
15 | * You should have received a copy of the GNU General Public License along with | 16 | * You should have received a copy of the GNU General Public License along with |
16 | * this program. If not, see <http://www.gnu.org/licenses/>. | 17 | * this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 18 | */ |
18 | #include <linux/mutex.h> | ||
19 | #include <linux/platform_device.h> | ||
20 | |||
21 | #ifndef _LINUX_FPGA_MGR_H | 19 | #ifndef _LINUX_FPGA_MGR_H |
22 | #define _LINUX_FPGA_MGR_H | 20 | #define _LINUX_FPGA_MGR_H |
23 | 21 | ||
22 | #include <linux/mutex.h> | ||
23 | #include <linux/platform_device.h> | ||
24 | |||
24 | struct fpga_manager; | 25 | struct fpga_manager; |
25 | struct sg_table; | 26 | struct sg_table; |
26 | 27 | ||
@@ -83,12 +84,26 @@ enum fpga_mgr_states { | |||
83 | * @disable_timeout_us: maximum time to disable traffic through bridge (uSec) | 84 | * @disable_timeout_us: maximum time to disable traffic through bridge (uSec) |
84 | * @config_complete_timeout_us: maximum time for FPGA to switch to operating | 85 | * @config_complete_timeout_us: maximum time for FPGA to switch to operating |
85 | * status in the write_complete op. | 86 | * status in the write_complete op. |
87 | * @firmware_name: name of FPGA image firmware file | ||
88 | * @sgt: scatter/gather table containing FPGA image | ||
89 | * @buf: contiguous buffer containing FPGA image | ||
90 | * @count: size of buf | ||
91 | * @dev: device that owns this | ||
92 | * @overlay: Device Tree overlay | ||
86 | */ | 93 | */ |
87 | struct fpga_image_info { | 94 | struct fpga_image_info { |
88 | u32 flags; | 95 | u32 flags; |
89 | u32 enable_timeout_us; | 96 | u32 enable_timeout_us; |
90 | u32 disable_timeout_us; | 97 | u32 disable_timeout_us; |
91 | u32 config_complete_timeout_us; | 98 | u32 config_complete_timeout_us; |
99 | char *firmware_name; | ||
100 | struct sg_table *sgt; | ||
101 | const char *buf; | ||
102 | size_t count; | ||
103 | struct device *dev; | ||
104 | #ifdef CONFIG_OF | ||
105 | struct device_node *overlay; | ||
106 | #endif | ||
92 | }; | 107 | }; |
93 | 108 | ||
94 | /** | 109 | /** |
@@ -100,6 +115,7 @@ struct fpga_image_info { | |||
100 | * @write_sg: write the scatter list of configuration data to the FPGA | 115 | * @write_sg: write the scatter list of configuration data to the FPGA |
101 | * @write_complete: set FPGA to operating state after writing is done | 116 | * @write_complete: set FPGA to operating state after writing is done |
102 | * @fpga_remove: optional: Set FPGA into a specific state during driver remove | 117 | * @fpga_remove: optional: Set FPGA into a specific state during driver remove |
118 | * @groups: optional attribute groups. | ||
103 | * | 119 | * |
104 | * fpga_manager_ops are the low level functions implemented by a specific | 120 | * fpga_manager_ops are the low level functions implemented by a specific |
105 | * fpga manager driver. The optional ones are tested for NULL before being | 121 | * fpga manager driver. The optional ones are tested for NULL before being |
@@ -116,6 +132,7 @@ struct fpga_manager_ops { | |||
116 | int (*write_complete)(struct fpga_manager *mgr, | 132 | int (*write_complete)(struct fpga_manager *mgr, |
117 | struct fpga_image_info *info); | 133 | struct fpga_image_info *info); |
118 | void (*fpga_remove)(struct fpga_manager *mgr); | 134 | void (*fpga_remove)(struct fpga_manager *mgr); |
135 | const struct attribute_group **groups; | ||
119 | }; | 136 | }; |
120 | 137 | ||
121 | /** | 138 | /** |
@@ -138,14 +155,14 @@ struct fpga_manager { | |||
138 | 155 | ||
139 | #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) | 156 | #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) |
140 | 157 | ||
141 | int fpga_mgr_buf_load(struct fpga_manager *mgr, struct fpga_image_info *info, | 158 | struct fpga_image_info *fpga_image_info_alloc(struct device *dev); |
142 | const char *buf, size_t count); | 159 | |
143 | int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, struct fpga_image_info *info, | 160 | void fpga_image_info_free(struct fpga_image_info *info); |
144 | struct sg_table *sgt); | 161 | |
162 | int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info); | ||
145 | 163 | ||
146 | int fpga_mgr_firmware_load(struct fpga_manager *mgr, | 164 | int fpga_mgr_lock(struct fpga_manager *mgr); |
147 | struct fpga_image_info *info, | 165 | void fpga_mgr_unlock(struct fpga_manager *mgr); |
148 | const char *image_name); | ||
149 | 166 | ||
150 | struct fpga_manager *of_fpga_mgr_get(struct device_node *node); | 167 | struct fpga_manager *of_fpga_mgr_get(struct device_node *node); |
151 | 168 | ||
diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h new file mode 100644 index 000000000000..b6520318ab9c --- /dev/null +++ b/include/linux/fpga/fpga-region.h | |||
@@ -0,0 +1,40 @@ | |||
1 | #ifndef _FPGA_REGION_H | ||
2 | #define _FPGA_REGION_H | ||
3 | |||
4 | #include <linux/device.h> | ||
5 | #include <linux/fpga/fpga-mgr.h> | ||
6 | #include <linux/fpga/fpga-bridge.h> | ||
7 | |||
8 | /** | ||
9 | * struct fpga_region - FPGA Region structure | ||
10 | * @dev: FPGA Region device | ||
11 | * @mutex: enforces exclusive reference to region | ||
12 | * @bridge_list: list of FPGA bridges specified in region | ||
13 | * @mgr: FPGA manager | ||
14 | * @info: FPGA image info | ||
15 | * @priv: private data | ||
16 | * @get_bridges: optional function to get bridges to a list | ||
17 | * @groups: optional attribute groups. | ||
18 | */ | ||
19 | struct fpga_region { | ||
20 | struct device dev; | ||
21 | struct mutex mutex; /* for exclusive reference to region */ | ||
22 | struct list_head bridge_list; | ||
23 | struct fpga_manager *mgr; | ||
24 | struct fpga_image_info *info; | ||
25 | void *priv; | ||
26 | int (*get_bridges)(struct fpga_region *region); | ||
27 | const struct attribute_group **groups; | ||
28 | }; | ||
29 | |||
30 | #define to_fpga_region(d) container_of(d, struct fpga_region, dev) | ||
31 | |||
32 | struct fpga_region *fpga_region_class_find( | ||
33 | struct device *start, const void *data, | ||
34 | int (*match)(struct device *, const void *)); | ||
35 | |||
36 | int fpga_region_program_fpga(struct fpga_region *region); | ||
37 | int fpga_region_register(struct device *dev, struct fpga_region *region); | ||
38 | int fpga_region_unregister(struct fpga_region *region); | ||
39 | |||
40 | #endif /* _FPGA_REGION_H */ | ||