Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fpga-mgr: add fpga image information struct

This patch adds a minor change in the FPGA Manager API
to hold information that is specific to an FPGA image
file. This change is expected to bring little, if any,
pain. The socfpga and zynq drivers are fixed up in
this patch.

An FPGA image file will have particulars that affect how the
image is programmed to the FPGA. One example is that
current 'flags' currently has one bit which shows whether the
FPGA image was built for full reconfiguration or partial
reconfiguration. Another example is timeout values for
enabling or disabling the bridges in the FPGA. As the
complexity of the FPGA design increases, the bridges in the
FPGA may take longer times to enable or disable.

This patch adds a new 'struct fpga_image_info', moves the
current 'u32 flags' to it. Two other image-specific u32's
are added for the bridge enable/disable timeouts. The FPGA
Manager API functions are changed, replacing the 'u32 flag'
parameter with a pointer to struct fpga_image_info.
Subsequent patches fix the existing low level FPGA manager
drivers.

Signed-off-by: Alan Tull <atull@opensource.altera.com>
Acked-by: Moritz Fischer <moritz.fischer@ettus.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alan Tull and committed by
Greg Kroah-Hartman
1df2865f a33ddf80

+38 -19
+9 -8
drivers/fpga/fpga-mgr.c
··· 32 32 /** 33 33 * fpga_mgr_buf_load - load fpga from image in buffer 34 34 * @mgr: fpga manager 35 - * @flags: flags setting fpga confuration modes 35 + * @info: fpga image specific information 36 36 * @buf: buffer contain fpga image 37 37 * @count: byte count of buf 38 38 * ··· 44 44 * 45 45 * Return: 0 on success, negative error code otherwise. 46 46 */ 47 - int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, const char *buf, 48 - size_t count) 47 + int fpga_mgr_buf_load(struct fpga_manager *mgr, struct fpga_image_info *info, 48 + const char *buf, size_t count) 49 49 { 50 50 struct device *dev = &mgr->dev; 51 51 int ret; ··· 56 56 * ready to receive an FPGA image. 57 57 */ 58 58 mgr->state = FPGA_MGR_STATE_WRITE_INIT; 59 - ret = mgr->mops->write_init(mgr, flags, buf, count); 59 + ret = mgr->mops->write_init(mgr, info, buf, count); 60 60 if (ret) { 61 61 dev_err(dev, "Error preparing FPGA for writing\n"); 62 62 mgr->state = FPGA_MGR_STATE_WRITE_INIT_ERR; ··· 79 79 * steps to finish and set the FPGA into operating mode. 80 80 */ 81 81 mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; 82 - ret = mgr->mops->write_complete(mgr, flags); 82 + ret = mgr->mops->write_complete(mgr, info); 83 83 if (ret) { 84 84 dev_err(dev, "Error after writing image data to FPGA\n"); 85 85 mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; ··· 94 94 /** 95 95 * fpga_mgr_firmware_load - request firmware and load to fpga 96 96 * @mgr: fpga manager 97 - * @flags: flags setting fpga confuration modes 97 + * @info: fpga image specific information 98 98 * @image_name: name of image file on the firmware search path 99 99 * 100 100 * Request an FPGA image using the firmware class, then write out to the FPGA. ··· 105 105 * 106 106 * Return: 0 on success, negative error code otherwise. 107 107 */ 108 - int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags, 108 + int fpga_mgr_firmware_load(struct fpga_manager *mgr, 109 + struct fpga_image_info *info, 109 110 const char *image_name) 110 111 { 111 112 struct device *dev = &mgr->dev; ··· 124 123 return ret; 125 124 } 126 125 127 - ret = fpga_mgr_buf_load(mgr, flags, fw->data, fw->size); 126 + ret = fpga_mgr_buf_load(mgr, info, fw->data, fw->size); 128 127 129 128 release_firmware(fw); 130 129
+4 -3
drivers/fpga/socfpga.c
··· 407 407 /* 408 408 * Prepare the FPGA to receive the configuration data. 409 409 */ 410 - static int socfpga_fpga_ops_configure_init(struct fpga_manager *mgr, u32 flags, 410 + static int socfpga_fpga_ops_configure_init(struct fpga_manager *mgr, 411 + struct fpga_image_info *info, 411 412 const char *buf, size_t count) 412 413 { 413 414 struct socfpga_fpga_priv *priv = mgr->priv; 414 415 int ret; 415 416 416 - if (flags & FPGA_MGR_PARTIAL_RECONFIG) { 417 + if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) { 417 418 dev_err(&mgr->dev, "Partial reconfiguration not supported.\n"); 418 419 return -EINVAL; 419 420 } ··· 479 478 } 480 479 481 480 static int socfpga_fpga_ops_configure_complete(struct fpga_manager *mgr, 482 - u32 flags) 481 + struct fpga_image_info *info) 483 482 { 484 483 struct socfpga_fpga_priv *priv = mgr->priv; 485 484 u32 status;
+6 -4
drivers/fpga/zynq-fpga.c
··· 175 175 return IRQ_HANDLED; 176 176 } 177 177 178 - static int zynq_fpga_ops_write_init(struct fpga_manager *mgr, u32 flags, 178 + static int zynq_fpga_ops_write_init(struct fpga_manager *mgr, 179 + struct fpga_image_info *info, 179 180 const char *buf, size_t count) 180 181 { 181 182 struct zynq_fpga_priv *priv; ··· 190 189 return err; 191 190 192 191 /* don't globally reset PL if we're doing partial reconfig */ 193 - if (!(flags & FPGA_MGR_PARTIAL_RECONFIG)) { 192 + if (!(info->flags & FPGA_MGR_PARTIAL_RECONFIG)) { 194 193 /* assert AXI interface resets */ 195 194 regmap_write(priv->slcr, SLCR_FPGA_RST_CTRL_OFFSET, 196 195 FPGA_RST_ALL_MASK); ··· 344 343 return err; 345 344 } 346 345 347 - static int zynq_fpga_ops_write_complete(struct fpga_manager *mgr, u32 flags) 346 + static int zynq_fpga_ops_write_complete(struct fpga_manager *mgr, 347 + struct fpga_image_info *info) 348 348 { 349 349 struct zynq_fpga_priv *priv = mgr->priv; 350 350 int err; ··· 366 364 return err; 367 365 368 366 /* for the partial reconfig case we didn't touch the level shifters */ 369 - if (!(flags & FPGA_MGR_PARTIAL_RECONFIG)) { 367 + if (!(info->flags & FPGA_MGR_PARTIAL_RECONFIG)) { 370 368 /* enable level shifters from PL to PS */ 371 369 regmap_write(priv->slcr, SLCR_LVL_SHFTR_EN_OFFSET, 372 370 LVL_SHFTR_ENABLE_PL_TO_PS);
+19 -4
include/linux/fpga/fpga-mgr.h
··· 69 69 #define FPGA_MGR_PARTIAL_RECONFIG BIT(0) 70 70 71 71 /** 72 + * struct fpga_image_info - information specific to a FPGA image 73 + * @flags: boolean flags as defined above 74 + * @enable_timeout_us: maximum time to enable traffic through bridge (uSec) 75 + * @disable_timeout_us: maximum time to disable traffic through bridge (uSec) 76 + */ 77 + struct fpga_image_info { 78 + u32 flags; 79 + u32 enable_timeout_us; 80 + u32 disable_timeout_us; 81 + }; 82 + 83 + /** 72 84 * struct fpga_manager_ops - ops for low level fpga manager drivers 73 85 * @state: returns an enum value of the FPGA's state 74 86 * @write_init: prepare the FPGA to receive confuration data ··· 94 82 */ 95 83 struct fpga_manager_ops { 96 84 enum fpga_mgr_states (*state)(struct fpga_manager *mgr); 97 - int (*write_init)(struct fpga_manager *mgr, u32 flags, 85 + int (*write_init)(struct fpga_manager *mgr, 86 + struct fpga_image_info *info, 98 87 const char *buf, size_t count); 99 88 int (*write)(struct fpga_manager *mgr, const char *buf, size_t count); 100 - int (*write_complete)(struct fpga_manager *mgr, u32 flags); 89 + int (*write_complete)(struct fpga_manager *mgr, 90 + struct fpga_image_info *info); 101 91 void (*fpga_remove)(struct fpga_manager *mgr); 102 92 }; 103 93 ··· 123 109 124 110 #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) 125 111 126 - int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, 112 + int fpga_mgr_buf_load(struct fpga_manager *mgr, struct fpga_image_info *info, 127 113 const char *buf, size_t count); 128 114 129 - int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags, 115 + int fpga_mgr_firmware_load(struct fpga_manager *mgr, 116 + struct fpga_image_info *info, 130 117 const char *image_name); 131 118 132 119 struct fpga_manager *of_fpga_mgr_get(struct device_node *node);