0001 ===============================
0002 Industrial IIO configfs support
0003 ===============================
0004
0005 1. Overview
0006 ===========
0007
0008 Configfs is a filesystem-based manager of kernel objects. IIO uses some
0009 objects that could be easily configured using configfs (e.g.: devices,
0010 triggers).
0011
0012 See Documentation/filesystems/configfs.rst for more information
0013 about how configfs works.
0014
0015 2. Usage
0016 ========
0017
0018 In order to use configfs support in IIO we need to select it at compile
0019 time via CONFIG_IIO_CONFIGFS config option.
0020
0021 Then, mount the configfs filesystem (usually under /config directory)::
0022
0023 $ mkdir /config
0024 $ mount -t configfs none /config
0025
0026 At this point, all default IIO groups will be created and can be accessed
0027 under /config/iio. Next chapters will describe available IIO configuration
0028 objects.
0029
0030 3. Software triggers
0031 ====================
0032
0033 One of the IIO default configfs groups is the "triggers" group. It is
0034 automagically accessible when the configfs is mounted and can be found
0035 under /config/iio/triggers.
0036
0037 IIO software triggers implementation offers support for creating multiple
0038 trigger types. A new trigger type is usually implemented as a separate
0039 kernel module following the interface in include/linux/iio/sw_trigger.h::
0040
0041 /*
0042 * drivers/iio/trigger/iio-trig-sample.c
0043 * sample kernel module implementing a new trigger type
0044 */
0045 #include <linux/iio/sw_trigger.h>
0046
0047
0048 static struct iio_sw_trigger *iio_trig_sample_probe(const char *name)
0049 {
0050 /*
0051 * This allocates and registers an IIO trigger plus other
0052 * trigger type specific initialization.
0053 */
0054 }
0055
0056 static int iio_trig_sample_remove(struct iio_sw_trigger *swt)
0057 {
0058 /*
0059 * This undoes the actions in iio_trig_sample_probe
0060 */
0061 }
0062
0063 static const struct iio_sw_trigger_ops iio_trig_sample_ops = {
0064 .probe = iio_trig_sample_probe,
0065 .remove = iio_trig_sample_remove,
0066 };
0067
0068 static struct iio_sw_trigger_type iio_trig_sample = {
0069 .name = "trig-sample",
0070 .owner = THIS_MODULE,
0071 .ops = &iio_trig_sample_ops,
0072 };
0073
0074 module_iio_sw_trigger_driver(iio_trig_sample);
0075
0076 Each trigger type has its own directory under /config/iio/triggers. Loading
0077 iio-trig-sample module will create 'trig-sample' trigger type directory
0078 /config/iio/triggers/trig-sample.
0079
0080 We support the following interrupt sources (trigger types):
0081
0082 * hrtimer, uses high resolution timers as interrupt source
0083
0084 3.1 Hrtimer triggers creation and destruction
0085 ---------------------------------------------
0086
0087 Loading iio-trig-hrtimer module will register hrtimer trigger types allowing
0088 users to create hrtimer triggers under /config/iio/triggers/hrtimer.
0089
0090 e.g::
0091
0092 $ mkdir /config/iio/triggers/hrtimer/instance1
0093 $ rmdir /config/iio/triggers/hrtimer/instance1
0094
0095 Each trigger can have one or more attributes specific to the trigger type.
0096
0097 3.2 "hrtimer" trigger types attributes
0098 --------------------------------------
0099
0100 "hrtimer" trigger type doesn't have any configurable attribute from /config dir.
0101 It does introduce the sampling_frequency attribute to trigger directory.
0102 That attribute sets the polling frequency in Hz, with mHz precision.