diff options
author | Alan Tull <atull@kernel.org> | 2017-11-15 15:20:12 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2017-11-28 10:30:37 -0500 |
commit | 5cf0c7f6502f26332b46fa87914553a4d6ae75ac (patch) | |
tree | 56814a3ec0bf179797e7d9fed89136954f937d3e /include/linux/fpga | |
parent | 9c1c4b2753fea36a072e78a5efc82fca0d13b455 (diff) |
fpga: mgr: API change to replace fpga load functions with single function
fpga-mgr has three methods for programming FPGAs, depending on
whether the image is in a scatter gather list, a contiguous
buffer, or a firmware file. This makes it difficult to write
upper layers as the caller has to assume whether the FPGA image
is in a sg table, as a single buffer, or a firmware file.
This commit moves these parameters to struct fpga_image_info
and adds a single function for programming fpgas.
New functions:
* fpga_mgr_load - given fpga manager and struct fpga_image_info,
program the fpga.
* fpga_image_info_alloc - alloc a struct fpga_image_info.
* fpga_image_info_free - free a struct fpga_image_info.
These three functions are unexported:
* fpga_mgr_buf_load_sg
* fpga_mgr_buf_load
* fpga_mgr_firmware_load
Also use devm_kstrdup to copy firmware_name so we aren't making
assumptions about where it comes from when allocing/freeing the
struct fpga_image_info.
API documentation has been updated and a new document for
FPGA region has been added.
Signed-off-by: Alan Tull <atull@kernel.org>
Acked-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include/linux/fpga')
-rw-r--r-- | include/linux/fpga/fpga-mgr.h | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index bfa14bc023fb..6b791348023b 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,22 @@ 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 | ||
86 | */ | 92 | */ |
87 | struct fpga_image_info { | 93 | struct fpga_image_info { |
88 | u32 flags; | 94 | u32 flags; |
89 | u32 enable_timeout_us; | 95 | u32 enable_timeout_us; |
90 | u32 disable_timeout_us; | 96 | u32 disable_timeout_us; |
91 | u32 config_complete_timeout_us; | 97 | u32 config_complete_timeout_us; |
98 | char *firmware_name; | ||
99 | struct sg_table *sgt; | ||
100 | const char *buf; | ||
101 | size_t count; | ||
102 | struct device *dev; | ||
92 | }; | 103 | }; |
93 | 104 | ||
94 | /** | 105 | /** |
@@ -138,14 +149,11 @@ struct fpga_manager { | |||
138 | 149 | ||
139 | #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) | 150 | #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) |
140 | 151 | ||
141 | int fpga_mgr_buf_load(struct fpga_manager *mgr, struct fpga_image_info *info, | 152 | struct fpga_image_info *fpga_image_info_alloc(struct device *dev); |
142 | const char *buf, size_t count); | 153 | |
143 | int fpga_mgr_buf_load_sg(struct fpga_manager *mgr, struct fpga_image_info *info, | 154 | void fpga_image_info_free(struct fpga_image_info *info); |
144 | struct sg_table *sgt); | ||
145 | 155 | ||
146 | int fpga_mgr_firmware_load(struct fpga_manager *mgr, | 156 | int fpga_mgr_load(struct fpga_manager *mgr, struct fpga_image_info *info); |
147 | struct fpga_image_info *info, | ||
148 | const char *image_name); | ||
149 | 157 | ||
150 | struct fpga_manager *of_fpga_mgr_get(struct device_node *node); | 158 | struct fpga_manager *of_fpga_mgr_get(struct device_node *node); |
151 | 159 | ||