blob: ecbfdb3afef7e6b470f41e3684fa18550c965ec4 [file] [log] [blame]
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -03001===============================
Daniel Baluta4c3e2a42015-11-09 09:14:02 +02002Industrial IIO configfs support
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -03003===============================
Daniel Baluta4c3e2a42015-11-09 09:14:02 +02004
51. Overview
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -03006===========
Daniel Baluta4c3e2a42015-11-09 09:14:02 +02007
8Configfs is a filesystem-based manager of kernel objects. IIO uses some
9objects that could be easily configured using configfs (e.g.: devices,
10triggers).
11
12See Documentation/filesystems/configfs/configfs.txt for more information
13about how configfs works.
14
152. Usage
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030016========
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020017
18In order to use configfs support in IIO we need to select it at compile
19time via CONFIG_IIO_CONFIGFS config option.
20
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030021Then, mount the configfs filesystem (usually under /config directory)::
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020022
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030023 $ mkdir /config
24 $ mount -t configfs none /config
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020025
26At this point, all default IIO groups will be created and can be accessed
27under /config/iio. Next chapters will describe available IIO configuration
28objects.
29
303. Software triggers
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030031====================
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020032
33One of the IIO default configfs groups is the "triggers" group. It is
34automagically accessible when the configfs is mounted and can be found
35under /config/iio/triggers.
36
37IIO software triggers implementation offers support for creating multiple
38trigger types. A new trigger type is usually implemented as a separate
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030039kernel module following the interface in include/linux/iio/sw_trigger.h::
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020040
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030041 /*
42 * drivers/iio/trigger/iio-trig-sample.c
43 * sample kernel module implementing a new trigger type
44 */
45 #include <linux/iio/sw_trigger.h>
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020046
47
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030048 static struct iio_sw_trigger *iio_trig_sample_probe(const char *name)
49 {
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020050 /*
51 * This allocates and registers an IIO trigger plus other
52 * trigger type specific initialization.
53 */
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030054 }
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020055
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030056 static int iio_trig_hrtimer_remove(struct iio_sw_trigger *swt)
57 {
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020058 /*
59 * This undoes the actions in iio_trig_sample_probe
60 */
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030061 }
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020062
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030063 static const struct iio_sw_trigger_ops iio_trig_sample_ops = {
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020064 .probe = iio_trig_sample_probe,
65 .remove = iio_trig_sample_remove,
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030066 };
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020067
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030068 static struct iio_sw_trigger_type iio_trig_sample = {
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020069 .name = "trig-sample",
70 .owner = THIS_MODULE,
71 .ops = &iio_trig_sample_ops,
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030072 };
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020073
74module_iio_sw_trigger_driver(iio_trig_sample);
75
76Each trigger type has its own directory under /config/iio/triggers. Loading
77iio-trig-sample module will create 'trig-sample' trigger type directory
78/config/iio/triggers/trig-sample.
79
80We support the following interrupt sources (trigger types):
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030081
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020082 * hrtimer, uses high resolution timers as interrupt source
83
843.1 Hrtimer triggers creation and destruction
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030085---------------------------------------------
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020086
87Loading iio-trig-hrtimer module will register hrtimer trigger types allowing
88users to create hrtimer triggers under /config/iio/triggers/hrtimer.
89
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030090e.g::
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020091
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030092 $ mkdir /config/iio/triggers/hrtimer/instance1
93 $ rmdir /config/iio/triggers/hrtimer/instance1
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020094
95Each trigger can have one or more attributes specific to the trigger type.
96
973.2 "hrtimer" trigger types attributes
Mauro Carvalho Chehab1c349f42019-06-18 17:53:40 -030098--------------------------------------
Daniel Baluta4c3e2a42015-11-09 09:14:02 +020099
100"hrtimer" trigger type doesn't have any configurable attribute from /config dir.
101It does introduce the sampling_frequency attribute to trigger directory.