Lines Matching full:bridge

3  * FPGA Bridge Framework Driver
8 #include <linux/fpga/fpga-bridge.h>
23 * fpga_bridge_enable - Enable transactions on the bridge
25 * @bridge: FPGA bridge
29 int fpga_bridge_enable(struct fpga_bridge *bridge) in fpga_bridge_enable() argument
31 dev_dbg(&bridge->dev, "enable\n"); in fpga_bridge_enable()
33 if (bridge->br_ops && bridge->br_ops->enable_set) in fpga_bridge_enable()
34 return bridge->br_ops->enable_set(bridge, 1); in fpga_bridge_enable()
41 * fpga_bridge_disable - Disable transactions on the bridge
43 * @bridge: FPGA bridge
47 int fpga_bridge_disable(struct fpga_bridge *bridge) in fpga_bridge_disable() argument
49 dev_dbg(&bridge->dev, "disable\n"); in fpga_bridge_disable()
51 if (bridge->br_ops && bridge->br_ops->enable_set) in fpga_bridge_disable()
52 return bridge->br_ops->enable_set(bridge, 0); in fpga_bridge_disable()
61 struct fpga_bridge *bridge; in __fpga_bridge_get() local
64 bridge = to_fpga_bridge(dev); in __fpga_bridge_get()
66 bridge->info = info; in __fpga_bridge_get()
68 if (!mutex_trylock(&bridge->mutex)) { in __fpga_bridge_get()
76 dev_dbg(&bridge->dev, "get\n"); in __fpga_bridge_get()
78 return bridge; in __fpga_bridge_get()
81 mutex_unlock(&bridge->mutex); in __fpga_bridge_get()
88 * of_fpga_bridge_get - get an exclusive reference to a fpga bridge
90 * @np: node pointer of a FPGA bridge
94 * Return -EBUSY if someone already has a reference to the bridge.
95 * Return -ENODEV if @np is not a FPGA Bridge.
116 * fpga_bridge_get - get an exclusive reference to a fpga bridge
117 * @dev: parent device that fpga bridge was registered with
120 * Given a device, get an exclusive reference to a fpga bridge.
122 * Return: fpga bridge struct or IS_ERR() condition containing error code.
139 * fpga_bridge_put - release a reference to a bridge
141 * @bridge: FPGA bridge
143 void fpga_bridge_put(struct fpga_bridge *bridge) in fpga_bridge_put() argument
145 dev_dbg(&bridge->dev, "put\n"); in fpga_bridge_put()
147 bridge->info = NULL; in fpga_bridge_put()
148 module_put(bridge->dev.parent->driver->owner); in fpga_bridge_put()
149 mutex_unlock(&bridge->mutex); in fpga_bridge_put()
150 put_device(&bridge->dev); in fpga_bridge_put()
158 * Enable each bridge in the list. If list is empty, do nothing.
160 * Return 0 for success or empty bridge list; return error code otherwise.
164 struct fpga_bridge *bridge; in fpga_bridges_enable() local
167 list_for_each_entry(bridge, bridge_list, node) { in fpga_bridges_enable()
168 ret = fpga_bridge_enable(bridge); in fpga_bridges_enable()
182 * Disable each bridge in the list. If list is empty, do nothing.
184 * Return 0 for success or empty bridge list; return error code otherwise.
188 struct fpga_bridge *bridge; in fpga_bridges_disable() local
191 list_for_each_entry(bridge, bridge_list, node) { in fpga_bridges_disable()
192 ret = fpga_bridge_disable(bridge); in fpga_bridges_disable()
206 * For each bridge in the list, put the bridge and remove it from the list.
211 struct fpga_bridge *bridge, *next; in fpga_bridges_put() local
214 list_for_each_entry_safe(bridge, next, bridge_list, node) { in fpga_bridges_put()
215 fpga_bridge_put(bridge); in fpga_bridges_put()
218 list_del(&bridge->node); in fpga_bridges_put()
225 * of_fpga_bridge_get_to_list - get a bridge, add it to a list
227 * @np: node pointer of a FPGA bridge
231 * Get an exclusive reference to the bridge and and it to the list.
239 struct fpga_bridge *bridge; in of_fpga_bridge_get_to_list() local
242 bridge = of_fpga_bridge_get(np, info); in of_fpga_bridge_get_to_list()
243 if (IS_ERR(bridge)) in of_fpga_bridge_get_to_list()
244 return PTR_ERR(bridge); in of_fpga_bridge_get_to_list()
247 list_add(&bridge->node, bridge_list); in of_fpga_bridge_get_to_list()
255 * fpga_bridge_get_to_list - given device, get a bridge, add it to a list
257 * @dev: FPGA bridge device
261 * Get an exclusive reference to the bridge and and it to the list.
269 struct fpga_bridge *bridge; in fpga_bridge_get_to_list() local
272 bridge = fpga_bridge_get(dev, info); in fpga_bridge_get_to_list()
273 if (IS_ERR(bridge)) in fpga_bridge_get_to_list()
274 return PTR_ERR(bridge); in fpga_bridge_get_to_list()
277 list_add(&bridge->node, bridge_list); in fpga_bridge_get_to_list()
287 struct fpga_bridge *bridge = to_fpga_bridge(dev); in name_show() local
289 return sprintf(buf, "%s\n", bridge->name); in name_show()
295 struct fpga_bridge *bridge = to_fpga_bridge(dev); in state_show() local
298 if (bridge->br_ops && bridge->br_ops->enable_show) in state_show()
299 enable = bridge->br_ops->enable_show(bridge); in state_show()
316 * @dev: FPGA bridge device from pdev
317 * @name: FPGA bridge name
318 * @br_ops: pointer to structure of fpga bridge ops
319 * @priv: FPGA bridge private data
321 * The caller of this function is responsible for freeing the bridge with
330 struct fpga_bridge *bridge; in fpga_bridge_create() local
338 bridge = kzalloc(sizeof(*bridge), GFP_KERNEL); in fpga_bridge_create()
339 if (!bridge) in fpga_bridge_create()
346 mutex_init(&bridge->mutex); in fpga_bridge_create()
347 INIT_LIST_HEAD(&bridge->node); in fpga_bridge_create()
349 bridge->name = name; in fpga_bridge_create()
350 bridge->br_ops = br_ops; in fpga_bridge_create()
351 bridge->priv = priv; in fpga_bridge_create()
353 device_initialize(&bridge->dev); in fpga_bridge_create()
354 bridge->dev.groups = br_ops->groups; in fpga_bridge_create()
355 bridge->dev.class = fpga_bridge_class; in fpga_bridge_create()
356 bridge->dev.parent = dev; in fpga_bridge_create()
357 bridge->dev.of_node = dev->of_node; in fpga_bridge_create()
358 bridge->dev.id = id; in fpga_bridge_create()
360 ret = dev_set_name(&bridge->dev, "br%d", id); in fpga_bridge_create()
364 return bridge; in fpga_bridge_create()
369 kfree(bridge); in fpga_bridge_create()
376 * fpga_bridge_free - free a fpga bridge created by fpga_bridge_create()
377 * @bridge: FPGA bridge struct
379 void fpga_bridge_free(struct fpga_bridge *bridge) in fpga_bridge_free() argument
381 ida_simple_remove(&fpga_bridge_ida, bridge->dev.id); in fpga_bridge_free()
382 kfree(bridge); in fpga_bridge_free()
388 struct fpga_bridge *bridge = *(struct fpga_bridge **)res; in devm_fpga_bridge_release() local
390 fpga_bridge_free(bridge); in devm_fpga_bridge_release()
395 * @dev: FPGA bridge device from pdev
396 * @name: FPGA bridge name
397 * @br_ops: pointer to structure of fpga bridge ops
398 * @priv: FPGA bridge private data
400 * This function is intended for use in a FPGA bridge driver's probe function.
401 * After the bridge driver creates the struct with devm_fpga_bridge_create(), it
402 * should register the bridge with fpga_bridge_register(). The bridge driver's
403 * remove function should call fpga_bridge_unregister(). The bridge struct
414 struct fpga_bridge **ptr, *bridge; in devm_fpga_bridge_create() local
420 bridge = fpga_bridge_create(dev, name, br_ops, priv); in devm_fpga_bridge_create()
421 if (!bridge) { in devm_fpga_bridge_create()
424 *ptr = bridge; in devm_fpga_bridge_create()
428 return bridge; in devm_fpga_bridge_create()
433 * fpga_bridge_register - register a FPGA bridge
435 * @bridge: FPGA bridge struct
439 int fpga_bridge_register(struct fpga_bridge *bridge) in fpga_bridge_register() argument
441 struct device *dev = &bridge->dev; in fpga_bridge_register()
450 dev_info(dev->parent, "fpga bridge [%s] registered\n", bridge->name); in fpga_bridge_register()
457 * fpga_bridge_unregister - unregister a FPGA bridge
459 * @bridge: FPGA bridge struct
461 * This function is intended for use in a FPGA bridge driver's remove function.
463 void fpga_bridge_unregister(struct fpga_bridge *bridge) in fpga_bridge_unregister() argument
466 * If the low level driver provides a method for putting bridge into in fpga_bridge_unregister()
469 if (bridge->br_ops && bridge->br_ops->fpga_bridge_remove) in fpga_bridge_unregister()
470 bridge->br_ops->fpga_bridge_remove(bridge); in fpga_bridge_unregister()
472 device_unregister(&bridge->dev); in fpga_bridge_unregister()
500 MODULE_DESCRIPTION("FPGA Bridge Driver");