Lines Matching +full:pre +full:- +full:programmed
1 // SPDX-License-Identifier: GPL-2.0
3 * FPGA Region - Device Tree support for FPGA programming under Linux
5 * Copyright (C) 2013-2016 Altera Corporation
8 #include <linux/fpga/fpga-bridge.h>
9 #include <linux/fpga/fpga-mgr.h>
10 #include <linux/fpga/fpga-region.h>
22 { .compatible = "fpga-region", },
28 * of_fpga_region_find - find FPGA region
31 * Caller will need to put_device(®ion->dev) when done.
41 * of_fpga_region_get_mgr - get reference for FPGA manager
44 * Get FPGA Manager from "fpga-mgr" property or from ancestor region.
57 if (of_device_is_compatible(np, "fpga-region")) { in of_fpga_region_get_mgr()
58 mgr_node = of_parse_phandle(np, "fpga-mgr", 0); in of_fpga_region_get_mgr()
70 return ERR_PTR(-EINVAL); in of_fpga_region_get_mgr()
74 * of_fpga_region_get_bridges - create a list of bridges
78 * specified by "fpga-bridges" property. Note that the
82 * Caller should call fpga_bridges_put(®ion->bridge_list) when
86 * or -EBUSY if any of the bridges are in use.
90 struct device *dev = ®ion->dev; in of_fpga_region_get_bridges()
91 struct device_node *region_np = dev->of_node; in of_fpga_region_get_bridges()
92 struct fpga_image_info *info = region->info; in of_fpga_region_get_bridges()
97 ret = of_fpga_bridge_get_to_list(region_np->parent, info, in of_fpga_region_get_bridges()
98 ®ion->bridge_list); in of_fpga_region_get_bridges()
100 /* -EBUSY means parent is a bridge that is under use. Give up. */ in of_fpga_region_get_bridges()
101 if (ret == -EBUSY) in of_fpga_region_get_bridges()
106 parent_br = region_np->parent; in of_fpga_region_get_bridges()
109 br = of_parse_phandle(info->overlay, "fpga-bridges", 0); in of_fpga_region_get_bridges()
112 np = info->overlay; in of_fpga_region_get_bridges()
118 br = of_parse_phandle(np, "fpga-bridges", i); in of_fpga_region_get_bridges()
130 ®ion->bridge_list); in of_fpga_region_get_bridges()
134 if (ret == -EBUSY) { in of_fpga_region_get_bridges()
135 fpga_bridges_put(®ion->bridge_list); in of_fpga_region_get_bridges()
136 return -EBUSY; in of_fpga_region_get_bridges()
144 * child_regions_with_firmware - Used to check the child region info.
148 * firmware-name property.
150 * Return: 0 for OK or -EINVAL if child FPGA region adds firmware-name.
162 if (!of_property_read_string(child_region, "firmware-name", in child_regions_with_firmware()
164 ret = -EINVAL; in child_regions_with_firmware()
174 pr_err("firmware-name not allowed in child FPGA region: %pOF", in child_regions_with_firmware()
181 * of_fpga_region_parse_ov - parse and check overlay applied to region
198 struct device *dev = ®ion->dev; in of_fpga_region_parse_ov()
203 if (region->info) { in of_fpga_region_parse_ov()
205 return ERR_PTR(-EINVAL); in of_fpga_region_parse_ov()
210 * firmware-name property (would mean that an FPGA region that has in of_fpga_region_parse_ov()
219 return ERR_PTR(-ENOMEM); in of_fpga_region_parse_ov()
221 info->overlay = overlay; in of_fpga_region_parse_ov()
224 if (of_property_read_bool(overlay, "partial-fpga-config")) in of_fpga_region_parse_ov()
225 info->flags |= FPGA_MGR_PARTIAL_RECONFIG; in of_fpga_region_parse_ov()
227 if (of_property_read_bool(overlay, "external-fpga-config")) in of_fpga_region_parse_ov()
228 info->flags |= FPGA_MGR_EXTERNAL_CONFIG; in of_fpga_region_parse_ov()
230 if (of_property_read_bool(overlay, "encrypted-fpga-config")) in of_fpga_region_parse_ov()
231 info->flags |= FPGA_MGR_ENCRYPTED_BITSTREAM; in of_fpga_region_parse_ov()
233 if (!of_property_read_string(overlay, "firmware-name", in of_fpga_region_parse_ov()
235 info->firmware_name = devm_kstrdup(dev, firmware_name, in of_fpga_region_parse_ov()
237 if (!info->firmware_name) in of_fpga_region_parse_ov()
238 return ERR_PTR(-ENOMEM); in of_fpga_region_parse_ov()
241 of_property_read_u32(overlay, "region-unfreeze-timeout-us", in of_fpga_region_parse_ov()
242 &info->enable_timeout_us); in of_fpga_region_parse_ov()
244 of_property_read_u32(overlay, "region-freeze-timeout-us", in of_fpga_region_parse_ov()
245 &info->disable_timeout_us); in of_fpga_region_parse_ov()
247 of_property_read_u32(overlay, "config-complete-timeout-us", in of_fpga_region_parse_ov()
248 &info->config_complete_timeout_us); in of_fpga_region_parse_ov()
251 if (!info->firmware_name) { in of_fpga_region_parse_ov()
257 * If overlay informs us FPGA was externally programmed, specifying in of_fpga_region_parse_ov()
260 if (info->flags & FPGA_MGR_EXTERNAL_CONFIG) { in of_fpga_region_parse_ov()
261 dev_err(dev, "error: specified firmware and external-fpga-config"); in of_fpga_region_parse_ov()
262 ret = -EINVAL; in of_fpga_region_parse_ov()
273 * of_fpga_region_notify_pre_apply - pre-apply overlay notification
280 * programmed and does some checking. If the checks pass, programs the FPGA.
289 struct device *dev = ®ion->dev; in of_fpga_region_notify_pre_apply()
293 info = of_fpga_region_parse_ov(region, nd->overlay); in of_fpga_region_notify_pre_apply()
301 if (region->info) { in of_fpga_region_notify_pre_apply()
303 return -EINVAL; in of_fpga_region_notify_pre_apply()
306 region->info = info; in of_fpga_region_notify_pre_apply()
311 region->info = NULL; in of_fpga_region_notify_pre_apply()
318 * of_fpga_region_notify_post_remove - post-remove overlay notification
329 fpga_bridges_disable(®ion->bridge_list); in of_fpga_region_notify_post_remove()
330 fpga_bridges_put(®ion->bridge_list); in of_fpga_region_notify_post_remove()
331 fpga_image_info_free(region->info); in of_fpga_region_notify_post_remove()
332 region->info = NULL; in of_fpga_region_notify_post_remove()
336 * of_fpga_region_notify - reconfig notifier for dynamic DT changes
341 * This notifier handles programming an FPGA when a "firmware-name" property is
342 * added to an fpga-region.
370 region = of_fpga_region_find(nd->target); in of_fpga_region_notify()
385 put_device(®ion->dev); in of_fpga_region_notify()
399 struct device *dev = &pdev->dev; in of_fpga_region_probe()
400 struct device_node *np = dev->of_node; in of_fpga_region_probe()
408 return -EPROBE_DEFER; in of_fpga_region_probe()
416 of_platform_populate(np, fpga_region_of_match, NULL, ®ion->dev); in of_fpga_region_probe()
431 struct fpga_manager *mgr = region->mgr; in of_fpga_region_remove()
441 .name = "of-fpga-region",
447 * of_fpga_region_init - init function for fpga_region class