Lines Matching +full:link +full:- +full:signal +full:- +full:sources
1 // SPDX-License-Identifier: GPL-2.0-only
11 * -------------------------------------------------------
12 * ------------------ | ------------ ------------ ------- FPGA|
13 * | ADC |------------------------| | ADC CORE |---------| DMA CORE |------| RAM | |
14 * | (Frontend/IIO) | Serial Data (eg: LVDS) | |(backend) |---------| |------| | |
15 * | |------------------------| ------------ ------------ ------- |
16 * ------------------ -------------------------------------------------------
19 * - Backends should register themselves with devm_iio_backend_register()
20 * - Frontend devices should get backends with devm_iio_backend_get()
27 * the industrialio-backend.c is only left with the really generic stuff. Then,
30 * Copyright (C) 2023-2024 Analog Devices Inc.
32 #define dev_fmt(fmt) "iio-backend: " fmt
86 if (!____back->ops->op) \
87 ____ret = -EOPNOTSUPP; \
98 __ret = __back->ops->op(__back, ##args); \
112 ptr_err = __back->ops->op(__back, ##args); \
123 __back->ops->op(__back, ##args); \
125 dev_dbg(__back->dev, "Op(%s) not implemented\n",\
133 struct iio_backend *back = file->private_data; in iio_backend_debugfs_read_reg()
139 back->cached_reg_addr, 0, &val); in iio_backend_debugfs_read_reg()
152 struct iio_backend *back = file->private_data; in iio_backend_debugfs_write_reg()
162 ret = sscanf(buf, "%i %i", &back->cached_reg_addr, &val); in iio_backend_debugfs_write_reg()
169 back->cached_reg_addr, val, NULL); in iio_backend_debugfs_write_reg()
174 return -EINVAL; in iio_backend_debugfs_write_reg()
188 struct iio_backend *back = file->private_data; in iio_backend_debugfs_read_name()
192 len = scnprintf(name, sizeof(name), "%s\n", back->name); in iio_backend_debugfs_read_name()
203 * iio_backend_debugfs_add - Add debugfs interfaces for Backends
216 if (!back->ops->debugfs_reg_access && !back->name) in iio_backend_debugfs_add()
219 snprintf(name, sizeof(name), "backend%d", back->idx); in iio_backend_debugfs_add()
225 if (back->ops->debugfs_reg_access) in iio_backend_debugfs_add()
229 if (back->name) in iio_backend_debugfs_add()
236 * iio_backend_debugfs_print_chan_status - Print channel status
254 return -ENODEV; in iio_backend_debugfs_print_chan_status()
262 * iio_backend_chan_enable - Enable a backend channel
276 * iio_backend_chan_disable - Disable a backend channel
295 * iio_backend_disable - Backend disable
305 * iio_backend_enable - Backend enable
318 * devm_iio_backend_enable - Device managed backend enable
338 * iio_backend_data_format_set - Configure the channel data format
352 if (!data || data->type >= IIO_BACKEND_DATA_TYPE_MAX) in iio_backend_data_format_set()
353 return -EINVAL; in iio_backend_data_format_set()
360 * iio_backend_data_source_set - Select data source
365 * A given backend may have different sources to stream/sync data. This allows
375 return -EINVAL; in iio_backend_data_source_set()
382 * iio_backend_set_sampling_freq - Set channel sampling rate
398 * iio_backend_test_pattern_set - Configure a test pattern
414 return -EINVAL; in iio_backend_test_pattern_set()
421 * iio_backend_chan_status - Get the channel status
440 * iio_backend_iodelay_set - Set digital I/O delay
463 * iio_backend_data_sample_trigger - Control when to sample data
477 return -EINVAL; in iio_backend_data_sample_trigger()
487 iio_backend_void_op_call(pair->back, free_buffer, pair->buffer); in iio_backend_free_buffer()
491 * devm_iio_backend_request_buffer - Device managed buffer request
514 return -ENOMEM; in devm_iio_backend_request_buffer()
521 pair->back = back; in devm_iio_backend_request_buffer()
522 pair->buffer = buffer; in devm_iio_backend_request_buffer()
529 * iio_backend_read_raw - Read a channel attribute from a backend device.
549 struct iio_backend *back = ERR_PTR(-ENODEV), *iter; in iio_backend_from_indio_dev_parent()
560 if (dev == iter->frontend_dev) { in iio_backend_from_indio_dev_parent()
564 return ERR_PTR(-ENODEV); in iio_backend_from_indio_dev_parent()
575 * iio_backend_ext_info_get - IIO ext_info read callback
601 back = iio_backend_from_indio_dev_parent(indio_dev->dev.parent); in iio_backend_ext_info_get()
610 * iio_backend_ext_info_set - IIO ext_info write callback
631 back = iio_backend_from_indio_dev_parent(indio_dev->dev.parent); in iio_backend_ext_info_set()
640 * iio_backend_extend_chan_spec - Extend an IIO channel
653 const struct iio_chan_spec_ext_info *frontend_ext_info = chan->ext_info; in iio_backend_extend_chan_spec()
665 if (frontend_ext_info && chan->ext_info != frontend_ext_info) in iio_backend_extend_chan_spec()
666 return -EOPNOTSUPP; in iio_backend_extend_chan_spec()
667 if (!chan->ext_info) in iio_backend_extend_chan_spec()
671 for (back_ext_info = chan->ext_info; back_ext_info->name; back_ext_info++) { in iio_backend_extend_chan_spec()
672 if (back_ext_info->read != iio_backend_ext_info_get) in iio_backend_extend_chan_spec()
673 return -EINVAL; in iio_backend_extend_chan_spec()
674 if (back_ext_info->write != iio_backend_ext_info_set) in iio_backend_extend_chan_spec()
675 return -EINVAL; in iio_backend_extend_chan_spec()
686 module_put(back->owner); in iio_backend_release()
691 struct device_link *link; in __devm_iio_backend_get() local
700 if (!try_module_get(back->owner)) in __devm_iio_backend_get()
701 return dev_err_probe(dev, -ENODEV, in __devm_iio_backend_get()
708 link = device_link_add(dev, back->dev, DL_FLAG_AUTOREMOVE_CONSUMER); in __devm_iio_backend_get()
709 if (!link) in __devm_iio_backend_get()
710 return dev_err_probe(dev, -EINVAL, in __devm_iio_backend_get()
711 "Could not link to supplier(%s)\n", in __devm_iio_backend_get()
712 dev_name(back->dev)); in __devm_iio_backend_get()
714 back->frontend_dev = dev; in __devm_iio_backend_get()
716 dev_dbg(dev, "Found backend(%s) device\n", dev_name(back->dev)); in __devm_iio_backend_get()
722 * iio_backend_ddr_enable - Enable interface DDR (Double Data Rate) mode
726 * of the bus clock signal.
738 * iio_backend_ddr_disable - Disable interface DDR (Double Data Rate) mode
753 * iio_backend_data_stream_enable - Enable data stream
768 * iio_backend_data_stream_disable - Disable data stream
783 * iio_backend_data_transfer_addr - Set data address.
808 ret = device_property_match_string(dev, "io-backend-names", in __devm_iio_backend_fwnode_get()
817 fwnode_back = fwnode_find_reference(fwnode, "io-backends", index); in __devm_iio_backend_fwnode_get()
824 if (!device_match_fwnode(back->dev, fwnode_back)) in __devm_iio_backend_fwnode_get()
833 back->idx = index; in __devm_iio_backend_fwnode_get()
839 return ERR_PTR(-EPROBE_DEFER); in __devm_iio_backend_fwnode_get()
843 * devm_iio_backend_get - Device managed backend device get
859 * devm_iio_backend_fwnode_get - Device managed backend firmware node get
878 * __devm_iio_backend_get_from_fwnode_lookup - Device managed fwnode backend device get
898 if (!device_match_fwnode(back->dev, fwnode)) in __devm_iio_backend_get_from_fwnode_lookup()
908 return ERR_PTR(-EPROBE_DEFER); in __devm_iio_backend_get_from_fwnode_lookup()
913 * iio_backend_get_priv - Get driver private data
918 return back->priv; in iio_backend_get_priv()
927 list_del(&back->entry); in iio_backend_unregister()
931 * devm_iio_backend_register - Device managed backend device register
936 * @info is mandatory. Not providing it results in -EINVAL.
946 if (!info || !info->ops) in devm_iio_backend_register()
947 return dev_err_probe(dev, -EINVAL, "No backend ops given\n"); in devm_iio_backend_register()
957 return -ENOMEM; in devm_iio_backend_register()
959 back->ops = info->ops; in devm_iio_backend_register()
960 back->name = info->name; in devm_iio_backend_register()
961 back->owner = dev->driver->owner; in devm_iio_backend_register()
962 back->dev = dev; in devm_iio_backend_register()
963 back->priv = priv; in devm_iio_backend_register()
965 list_add(&back->entry, &iio_back_list); in devm_iio_backend_register()