diff options
-rw-r--r-- | drivers/fpga/fpga-mgr.c | 17 | ||||
-rw-r--r-- | drivers/fpga/socfpga.c | 7 | ||||
-rw-r--r-- | drivers/fpga/zynq-fpga.c | 10 | ||||
-rw-r--r-- | include/linux/fpga/fpga-mgr.h | 23 |
4 files changed, 38 insertions, 19 deletions
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index b690e65d55fe..79ce2eea44db 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c | |||
@@ -32,7 +32,7 @@ static struct class *fpga_mgr_class; | |||
32 | /** | 32 | /** |
33 | * fpga_mgr_buf_load - load fpga from image in buffer | 33 | * fpga_mgr_buf_load - load fpga from image in buffer |
34 | * @mgr: fpga manager | 34 | * @mgr: fpga manager |
35 | * @flags: flags setting fpga confuration modes | 35 | * @info: fpga image specific information |
36 | * @buf: buffer contain fpga image | 36 | * @buf: buffer contain fpga image |
37 | * @count: byte count of buf | 37 | * @count: byte count of buf |
38 | * | 38 | * |
@@ -44,8 +44,8 @@ static struct class *fpga_mgr_class; | |||
44 | * | 44 | * |
45 | * Return: 0 on success, negative error code otherwise. | 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, | 47 | int fpga_mgr_buf_load(struct fpga_manager *mgr, struct fpga_image_info *info, |
48 | size_t count) | 48 | const char *buf, size_t count) |
49 | { | 49 | { |
50 | struct device *dev = &mgr->dev; | 50 | struct device *dev = &mgr->dev; |
51 | int ret; | 51 | int ret; |
@@ -56,7 +56,7 @@ int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, const char *buf, | |||
56 | * ready to receive an FPGA image. | 56 | * ready to receive an FPGA image. |
57 | */ | 57 | */ |
58 | mgr->state = FPGA_MGR_STATE_WRITE_INIT; | 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 | if (ret) { | 60 | if (ret) { |
61 | dev_err(dev, "Error preparing FPGA for writing\n"); | 61 | dev_err(dev, "Error preparing FPGA for writing\n"); |
62 | mgr->state = FPGA_MGR_STATE_WRITE_INIT_ERR; | 62 | mgr->state = FPGA_MGR_STATE_WRITE_INIT_ERR; |
@@ -79,7 +79,7 @@ int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, const char *buf, | |||
79 | * steps to finish and set the FPGA into operating mode. | 79 | * steps to finish and set the FPGA into operating mode. |
80 | */ | 80 | */ |
81 | mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE; | 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 | if (ret) { | 83 | if (ret) { |
84 | dev_err(dev, "Error after writing image data to FPGA\n"); | 84 | dev_err(dev, "Error after writing image data to FPGA\n"); |
85 | mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; | 85 | mgr->state = FPGA_MGR_STATE_WRITE_COMPLETE_ERR; |
@@ -94,7 +94,7 @@ EXPORT_SYMBOL_GPL(fpga_mgr_buf_load); | |||
94 | /** | 94 | /** |
95 | * fpga_mgr_firmware_load - request firmware and load to fpga | 95 | * fpga_mgr_firmware_load - request firmware and load to fpga |
96 | * @mgr: fpga manager | 96 | * @mgr: fpga manager |
97 | * @flags: flags setting fpga confuration modes | 97 | * @info: fpga image specific information |
98 | * @image_name: name of image file on the firmware search path | 98 | * @image_name: name of image file on the firmware search path |
99 | * | 99 | * |
100 | * Request an FPGA image using the firmware class, then write out to the FPGA. | 100 | * Request an FPGA image using the firmware class, then write out to the FPGA. |
@@ -105,7 +105,8 @@ EXPORT_SYMBOL_GPL(fpga_mgr_buf_load); | |||
105 | * | 105 | * |
106 | * Return: 0 on success, negative error code otherwise. | 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 | const char *image_name) | 110 | const char *image_name) |
110 | { | 111 | { |
111 | struct device *dev = &mgr->dev; | 112 | struct device *dev = &mgr->dev; |
@@ -123,7 +124,7 @@ int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags, | |||
123 | return ret; | 124 | return ret; |
124 | } | 125 | } |
125 | 126 | ||
126 | ret = fpga_mgr_buf_load(mgr, flags, fw->data, fw->size); | 127 | ret = fpga_mgr_buf_load(mgr, info, fw->data, fw->size); |
127 | 128 | ||
128 | release_firmware(fw); | 129 | release_firmware(fw); |
129 | 130 | ||
diff --git a/drivers/fpga/socfpga.c b/drivers/fpga/socfpga.c index 27d2ff28132c..b6672e66cda6 100644 --- a/drivers/fpga/socfpga.c +++ b/drivers/fpga/socfpga.c | |||
@@ -407,13 +407,14 @@ static int socfpga_fpga_reset(struct fpga_manager *mgr) | |||
407 | /* | 407 | /* |
408 | * Prepare the FPGA to receive the configuration data. | 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 | const char *buf, size_t count) | 412 | const char *buf, size_t count) |
412 | { | 413 | { |
413 | struct socfpga_fpga_priv *priv = mgr->priv; | 414 | struct socfpga_fpga_priv *priv = mgr->priv; |
414 | int ret; | 415 | int ret; |
415 | 416 | ||
416 | if (flags & FPGA_MGR_PARTIAL_RECONFIG) { | 417 | if (info->flags & FPGA_MGR_PARTIAL_RECONFIG) { |
417 | dev_err(&mgr->dev, "Partial reconfiguration not supported.\n"); | 418 | dev_err(&mgr->dev, "Partial reconfiguration not supported.\n"); |
418 | return -EINVAL; | 419 | return -EINVAL; |
419 | } | 420 | } |
@@ -478,7 +479,7 @@ static int socfpga_fpga_ops_configure_write(struct fpga_manager *mgr, | |||
478 | } | 479 | } |
479 | 480 | ||
480 | static int socfpga_fpga_ops_configure_complete(struct fpga_manager *mgr, | 481 | static int socfpga_fpga_ops_configure_complete(struct fpga_manager *mgr, |
481 | u32 flags) | 482 | struct fpga_image_info *info) |
482 | { | 483 | { |
483 | struct socfpga_fpga_priv *priv = mgr->priv; | 484 | struct socfpga_fpga_priv *priv = mgr->priv; |
484 | u32 status; | 485 | u32 status; |
diff --git a/drivers/fpga/zynq-fpga.c b/drivers/fpga/zynq-fpga.c index c2fb4120bd62..249682e92502 100644 --- a/drivers/fpga/zynq-fpga.c +++ b/drivers/fpga/zynq-fpga.c | |||
@@ -175,7 +175,8 @@ static irqreturn_t zynq_fpga_isr(int irq, void *data) | |||
175 | return IRQ_HANDLED; | 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 | const char *buf, size_t count) | 180 | const char *buf, size_t count) |
180 | { | 181 | { |
181 | struct zynq_fpga_priv *priv; | 182 | struct zynq_fpga_priv *priv; |
@@ -189,7 +190,7 @@ static int zynq_fpga_ops_write_init(struct fpga_manager *mgr, u32 flags, | |||
189 | return err; | 190 | return err; |
190 | 191 | ||
191 | /* don't globally reset PL if we're doing partial reconfig */ | 192 | /* don't globally reset PL if we're doing partial reconfig */ |
192 | if (!(flags & FPGA_MGR_PARTIAL_RECONFIG)) { | 193 | if (!(info->flags & FPGA_MGR_PARTIAL_RECONFIG)) { |
193 | /* assert AXI interface resets */ | 194 | /* assert AXI interface resets */ |
194 | regmap_write(priv->slcr, SLCR_FPGA_RST_CTRL_OFFSET, | 195 | regmap_write(priv->slcr, SLCR_FPGA_RST_CTRL_OFFSET, |
195 | FPGA_RST_ALL_MASK); | 196 | FPGA_RST_ALL_MASK); |
@@ -343,7 +344,8 @@ out_free: | |||
343 | return err; | 344 | return err; |
344 | } | 345 | } |
345 | 346 | ||
346 | static int zynq_fpga_ops_write_complete(struct fpga_manager *mgr, u32 flags) | 347 | static int zynq_fpga_ops_write_complete(struct fpga_manager *mgr, |
348 | struct fpga_image_info *info) | ||
347 | { | 349 | { |
348 | struct zynq_fpga_priv *priv = mgr->priv; | 350 | struct zynq_fpga_priv *priv = mgr->priv; |
349 | int err; | 351 | int err; |
@@ -364,7 +366,7 @@ static int zynq_fpga_ops_write_complete(struct fpga_manager *mgr, u32 flags) | |||
364 | return err; | 366 | return err; |
365 | 367 | ||
366 | /* for the partial reconfig case we didn't touch the level shifters */ | 368 | /* for the partial reconfig case we didn't touch the level shifters */ |
367 | if (!(flags & FPGA_MGR_PARTIAL_RECONFIG)) { | 369 | if (!(info->flags & FPGA_MGR_PARTIAL_RECONFIG)) { |
368 | /* enable level shifters from PL to PS */ | 370 | /* enable level shifters from PL to PS */ |
369 | regmap_write(priv->slcr, SLCR_LVL_SHFTR_EN_OFFSET, | 371 | regmap_write(priv->slcr, SLCR_LVL_SHFTR_EN_OFFSET, |
370 | LVL_SHFTR_ENABLE_PL_TO_PS); | 372 | LVL_SHFTR_ENABLE_PL_TO_PS); |
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h index 957b5ac9428a..55803186e0ea 100644 --- a/include/linux/fpga/fpga-mgr.h +++ b/include/linux/fpga/fpga-mgr.h | |||
@@ -69,6 +69,18 @@ enum fpga_mgr_states { | |||
69 | #define FPGA_MGR_PARTIAL_RECONFIG BIT(0) | 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 | * struct fpga_manager_ops - ops for low level fpga manager drivers | 84 | * struct fpga_manager_ops - ops for low level fpga manager drivers |
73 | * @state: returns an enum value of the FPGA's state | 85 | * @state: returns an enum value of the FPGA's state |
74 | * @write_init: prepare the FPGA to receive confuration data | 86 | * @write_init: prepare the FPGA to receive confuration data |
@@ -82,10 +94,12 @@ enum fpga_mgr_states { | |||
82 | */ | 94 | */ |
83 | struct fpga_manager_ops { | 95 | struct fpga_manager_ops { |
84 | enum fpga_mgr_states (*state)(struct fpga_manager *mgr); | 96 | enum fpga_mgr_states (*state)(struct fpga_manager *mgr); |
85 | int (*write_init)(struct fpga_manager *mgr, u32 flags, | 97 | int (*write_init)(struct fpga_manager *mgr, |
98 | struct fpga_image_info *info, | ||
86 | const char *buf, size_t count); | 99 | const char *buf, size_t count); |
87 | int (*write)(struct fpga_manager *mgr, const char *buf, size_t count); | 100 | int (*write)(struct fpga_manager *mgr, const char *buf, size_t count); |
88 | int (*write_complete)(struct fpga_manager *mgr, u32 flags); | 101 | int (*write_complete)(struct fpga_manager *mgr, |
102 | struct fpga_image_info *info); | ||
89 | void (*fpga_remove)(struct fpga_manager *mgr); | 103 | void (*fpga_remove)(struct fpga_manager *mgr); |
90 | }; | 104 | }; |
91 | 105 | ||
@@ -109,10 +123,11 @@ struct fpga_manager { | |||
109 | 123 | ||
110 | #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) | 124 | #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev) |
111 | 125 | ||
112 | int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, | 126 | int fpga_mgr_buf_load(struct fpga_manager *mgr, struct fpga_image_info *info, |
113 | const char *buf, size_t count); | 127 | const char *buf, size_t count); |
114 | 128 | ||
115 | int fpga_mgr_firmware_load(struct fpga_manager *mgr, u32 flags, | 129 | int fpga_mgr_firmware_load(struct fpga_manager *mgr, |
130 | struct fpga_image_info *info, | ||
116 | const char *image_name); | 131 | const char *image_name); |
117 | 132 | ||
118 | struct fpga_manager *of_fpga_mgr_get(struct device_node *node); | 133 | struct fpga_manager *of_fpga_mgr_get(struct device_node *node); |