1 =============================== 1 =============================== 2 Industrial IIO configfs support 2 Industrial IIO configfs support 3 =============================== 3 =============================== 4 4 5 1. Overview 5 1. Overview 6 =========== 6 =========== 7 7 8 Configfs is a filesystem-based manager of kern 8 Configfs is a filesystem-based manager of kernel objects. IIO uses some 9 objects that could be easily configured using 9 objects that could be easily configured using configfs (e.g.: devices, 10 triggers). 10 triggers). 11 11 12 See Documentation/filesystems/configfs.rst for !! 12 See Documentation/filesystems/configfs/configfs.txt for more information 13 about how configfs works. 13 about how configfs works. 14 14 15 2. Usage 15 2. Usage 16 ======== 16 ======== 17 17 18 In order to use configfs support in IIO we nee 18 In order to use configfs support in IIO we need to select it at compile 19 time via CONFIG_IIO_CONFIGFS config option. 19 time via CONFIG_IIO_CONFIGFS config option. 20 20 21 Then, mount the configfs filesystem (usually u 21 Then, mount the configfs filesystem (usually under /config directory):: 22 22 23 $ mkdir /config 23 $ mkdir /config 24 $ mount -t configfs none /config 24 $ mount -t configfs none /config 25 25 26 At this point, all default IIO groups will be 26 At this point, all default IIO groups will be created and can be accessed 27 under /config/iio. Next chapters will describe 27 under /config/iio. Next chapters will describe available IIO configuration 28 objects. 28 objects. 29 29 30 3. Software triggers 30 3. Software triggers 31 ==================== 31 ==================== 32 32 33 One of the IIO default configfs groups is the 33 One of the IIO default configfs groups is the "triggers" group. It is 34 automagically accessible when the configfs is 34 automagically accessible when the configfs is mounted and can be found 35 under /config/iio/triggers. 35 under /config/iio/triggers. 36 36 37 IIO software triggers implementation offers su 37 IIO software triggers implementation offers support for creating multiple 38 trigger types. A new trigger type is usually i 38 trigger types. A new trigger type is usually implemented as a separate 39 kernel module following the interface in inclu 39 kernel module following the interface in include/linux/iio/sw_trigger.h:: 40 40 41 /* 41 /* 42 * drivers/iio/trigger/iio-trig-sample.c 42 * drivers/iio/trigger/iio-trig-sample.c 43 * sample kernel module implementing a new t 43 * sample kernel module implementing a new trigger type 44 */ 44 */ 45 #include <linux/iio/sw_trigger.h> 45 #include <linux/iio/sw_trigger.h> 46 46 47 47 48 static struct iio_sw_trigger *iio_trig_sampl 48 static struct iio_sw_trigger *iio_trig_sample_probe(const char *name) 49 { 49 { 50 /* 50 /* 51 * This allocates and registers an IIO 51 * This allocates and registers an IIO trigger plus other 52 * trigger type specific initializatio 52 * trigger type specific initialization. 53 */ 53 */ 54 } 54 } 55 55 56 static int iio_trig_sample_remove(struct iio !! 56 static int iio_trig_hrtimer_remove(struct iio_sw_trigger *swt) 57 { 57 { 58 /* 58 /* 59 * This undoes the actions in iio_trig 59 * This undoes the actions in iio_trig_sample_probe 60 */ 60 */ 61 } 61 } 62 62 63 static const struct iio_sw_trigger_ops iio_t 63 static const struct iio_sw_trigger_ops iio_trig_sample_ops = { 64 .probe = iio_trig_sample_prob 64 .probe = iio_trig_sample_probe, 65 .remove = iio_trig_sample_remo 65 .remove = iio_trig_sample_remove, 66 }; 66 }; 67 67 68 static struct iio_sw_trigger_type iio_trig_s 68 static struct iio_sw_trigger_type iio_trig_sample = { 69 .name = "trig-sample", 69 .name = "trig-sample", 70 .owner = THIS_MODULE, 70 .owner = THIS_MODULE, 71 .ops = &iio_trig_sample_ops, 71 .ops = &iio_trig_sample_ops, 72 }; 72 }; 73 73 74 module_iio_sw_trigger_driver(iio_trig_sample !! 74 module_iio_sw_trigger_driver(iio_trig_sample); 75 75 76 Each trigger type has its own directory under 76 Each trigger type has its own directory under /config/iio/triggers. Loading 77 iio-trig-sample module will create 'trig-sampl 77 iio-trig-sample module will create 'trig-sample' trigger type directory 78 /config/iio/triggers/trig-sample. 78 /config/iio/triggers/trig-sample. 79 79 80 We support the following interrupt sources (tr 80 We support the following interrupt sources (trigger types): 81 81 82 * hrtimer, uses high resolution timers 82 * hrtimer, uses high resolution timers as interrupt source 83 83 84 3.1 Hrtimer triggers creation and destruction 84 3.1 Hrtimer triggers creation and destruction 85 --------------------------------------------- 85 --------------------------------------------- 86 86 87 Loading iio-trig-hrtimer module will register 87 Loading iio-trig-hrtimer module will register hrtimer trigger types allowing 88 users to create hrtimer triggers under /config 88 users to create hrtimer triggers under /config/iio/triggers/hrtimer. 89 89 90 e.g:: 90 e.g:: 91 91 92 $ mkdir /config/iio/triggers/hrtimer/instanc 92 $ mkdir /config/iio/triggers/hrtimer/instance1 93 $ rmdir /config/iio/triggers/hrtimer/instanc 93 $ rmdir /config/iio/triggers/hrtimer/instance1 94 94 95 Each trigger can have one or more attributes s 95 Each trigger can have one or more attributes specific to the trigger type. 96 96 97 3.2 "hrtimer" trigger types attributes 97 3.2 "hrtimer" trigger types attributes 98 -------------------------------------- 98 -------------------------------------- 99 99 100 "hrtimer" trigger type doesn't have any config 100 "hrtimer" trigger type doesn't have any configurable attribute from /config dir. 101 It does introduce the sampling_frequency attri 101 It does introduce the sampling_frequency attribute to trigger directory. 102 That attribute sets the polling frequency in H <<
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.