fpga mgr: Introduce FPGA capabilities
Subsystems (2)
RFC 1/1 fpga mgr: Introduce FPGA capabilities
Add FPGA capabilities as a way to express the capabilities of a given FPGA manager.
Removes code duplication by comparing the low-level driver's capabilities at the framework level rather than having each driver check for supported operations in the write_init() callback.
This allows for extending with additional capabilities, similar to the the dmaengine framework's implementation.
---
Hi all,
this is another RFC (this one is against mainline) implementing fpga capabilities to centralize the checks for different operations.
If we agree this is the way forward, I'll rebase it on top of Alan's series once that went in (and add potential drivers we added by then.
Cheers,
Moritz
PS: I'm not sure if the checkpatch warning is a false positive ...
--- drivers/fpga/fpga-mgr.c | 14 +++++++++++++ drivers/fpga/socfpga.c | 10 +++++----- drivers/fpga/zynq-fpga.c | 7 ++++++- include/linux/fpga/fpga-mgr.h | 46 ++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 70 insertions(+), 7 deletions(-)
drivers/fpga/fpga-mgr.c +14 -0
@@ -49,6 +49,18 @@ int fpga_mgr_buf_load(struct fpga_manager *mgr, u32 flags, const char *buf,struct device *dev = &mgr->dev;int ret; +if (flags &FPGA_MGR_PARTIAL_RECONFIG && + !fpga_mgr_has_cap (FPGA_MGR_CAP_PARTIAL_RECONF , mgr->caps)) { +dev_err (dev,"Partial reconfiguration not supported\n" ); +return -ENOTSUPP ; + } + +if (flags &FPGA_MGR_FULL_RECONFIG && + !fpga_mgr_has_cap (FPGA_MGR_CAP_FULL_RECONF , mgr->caps)) { +dev_err (dev,"Full reconfiguration not supported\n" ); +return -ENOTSUPP ; + } +/* * Call the low level driver's write_init function. This will do the * device-specific things to get the FPGA into the state where it is
@@ -245,12 +257,14 @@ EXPORT_SYMBOL_GPL(fpga_mgr_put);* @dev: fpga manager device from pdev * @name: fpga manager name * @mops: pointer to structure of fpga manager ops +* @caps: fpga manager capabilites * @priv: fpga manager private data * * Return: 0 on success, negative error code otherwise. */ int fpga_mgr_register (struct device *dev,const char *name,const struct fpga_manager_ops *mops, +fpga_mgr_cap_mask_t caps,void *priv) {struct fpga_manager *mgr;
drivers/fpga/socfpga.c +5 -5
@@ -413,10 +413,6 @@ static int socfpga_fpga_ops_configure_init(struct fpga_manager *mgr, u32 flags,struct socfpga_fpga_priv *priv = mgr->priv;int ret; -if (flags &FPGA_MGR_PARTIAL_RECONFIG ) { -dev_err (&mgr->dev,"Partial reconfiguration not supported.\n" ); -return -EINVAL ; - }/* Steps 1 - 5: Reset the FPGA */ ret =socfpga_fpga_reset (mgr);if (ret)
@@ -555,6 +551,7 @@ static int socfpga_fpga_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct socfpga_fpga_priv *priv;struct resource *res; +fpga_mgr_cap_mask_t caps;int ret; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );
@@ -580,8 +577,11 @@ static int socfpga_fpga_probe(struct platform_device *pdev)if (ret)return ret; +fpga_mgr_cap_zero (&caps); +fpga_mgr_cap_set (FPGA_MGR_CAP_FULL_RECONF , caps); +return fpga_mgr_register (dev,"Altera SOCFPGA FPGA Manager" , - &socfpga_fpga_ops, priv); + &socfpga_fpga_ops, caps, priv); }static int socfpga_fpga_remove (struct platform_device *pdev)
drivers/fpga/zynq-fpga.c +6 -1
@@ -410,6 +410,7 @@ static int zynq_fpga_probe(struct platform_device *pdev)struct device *dev = &pdev->dev;struct zynq_fpga_priv *priv;struct resource *res; +fpga_mgr_cap_mask_t caps;int err; priv =devm_kzalloc (dev,sizeof (*priv),GFP_KERNEL );
@@ -461,9 +462,13 @@ static int zynq_fpga_probe(struct platform_device *pdev)zynq_fpga_write (priv,UNLOCK_OFFSET ,UNLOCK_MASK );clk_disable (priv->clk); +fpga_mgr_cap_zero (&caps); +fpga_mgr_cap_set (FPGA_MGR_CAP_FULL_RECONF , caps); +fpga_mgr_cap_set (FPGA_MGR_CAP_PARTIAL_RECONF , caps); + err =fpga_mgr_register (dev,"Xilinx Zynq FPGA Manager" , - &zynq_fpga_ops, priv); + &zynq_fpga_ops, caps, priv);if (err) {dev_err (dev,"unable to register FPGA manager" );clk_unprepare (priv->clk);
include/linux/fpga/fpga-mgr.h +45 -1
64 lines not on this page · raw message
Signature · 1 line
2.10.0