0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #include <linux/module.h>
0017 #include <linux/fpga/fpga-mgr.h>
0018 #include <linux/fpga/fpga-region.h>
0019
0020 #include "dfl-fme-pr.h"
0021
0022 static int fme_region_get_bridges(struct fpga_region *region)
0023 {
0024 struct dfl_fme_region_pdata *pdata = region->priv;
0025 struct device *dev = &pdata->br->dev;
0026
0027 return fpga_bridge_get_to_list(dev, region->info, ®ion->bridge_list);
0028 }
0029
0030 static int fme_region_probe(struct platform_device *pdev)
0031 {
0032 struct dfl_fme_region_pdata *pdata = dev_get_platdata(&pdev->dev);
0033 struct fpga_region_info info = { 0 };
0034 struct device *dev = &pdev->dev;
0035 struct fpga_region *region;
0036 struct fpga_manager *mgr;
0037 int ret;
0038
0039 mgr = fpga_mgr_get(&pdata->mgr->dev);
0040 if (IS_ERR(mgr))
0041 return -EPROBE_DEFER;
0042
0043 info.mgr = mgr;
0044 info.compat_id = mgr->compat_id;
0045 info.get_bridges = fme_region_get_bridges;
0046 info.priv = pdata;
0047 region = fpga_region_register_full(dev, &info);
0048 if (IS_ERR(region)) {
0049 ret = PTR_ERR(region);
0050 goto eprobe_mgr_put;
0051 }
0052
0053 platform_set_drvdata(pdev, region);
0054
0055 dev_dbg(dev, "DFL FME FPGA Region probed\n");
0056
0057 return 0;
0058
0059 eprobe_mgr_put:
0060 fpga_mgr_put(mgr);
0061 return ret;
0062 }
0063
0064 static int fme_region_remove(struct platform_device *pdev)
0065 {
0066 struct fpga_region *region = platform_get_drvdata(pdev);
0067 struct fpga_manager *mgr = region->mgr;
0068
0069 fpga_region_unregister(region);
0070 fpga_mgr_put(mgr);
0071
0072 return 0;
0073 }
0074
0075 static struct platform_driver fme_region_driver = {
0076 .driver = {
0077 .name = DFL_FPGA_FME_REGION,
0078 },
0079 .probe = fme_region_probe,
0080 .remove = fme_region_remove,
0081 };
0082
0083 module_platform_driver(fme_region_driver);
0084
0085 MODULE_DESCRIPTION("FPGA Region for DFL FPGA Management Engine");
0086 MODULE_AUTHOR("Intel Corporation");
0087 MODULE_LICENSE("GPL v2");
0088 MODULE_ALIAS("platform:dfl-fme-region");