iio_configfs.rst 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. ===============================
  2. Industrial IIO configfs support
  3. ===============================
  4. 1. Overview
  5. ===========
  6. Configfs is a filesystem-based manager of kernel objects. IIO uses some
  7. objects that could be easily configured using configfs (e.g.: devices,
  8. triggers).
  9. See Documentation/filesystems/configfs.rst for more information
  10. about how configfs works.
  11. 2. Usage
  12. ========
  13. In order to use configfs support in IIO we need to select it at compile
  14. time via CONFIG_IIO_CONFIGFS config option.
  15. Then, mount the configfs filesystem (usually under /config directory)::
  16. $ mkdir /config
  17. $ mount -t configfs none /config
  18. At this point, all default IIO groups will be created and can be accessed
  19. under /config/iio. Next chapters will describe available IIO configuration
  20. objects.
  21. 3. Software triggers
  22. ====================
  23. One of the IIO default configfs groups is the "triggers" group. It is
  24. automagically accessible when the configfs is mounted and can be found
  25. under /config/iio/triggers.
  26. IIO software triggers implementation offers support for creating multiple
  27. trigger types. A new trigger type is usually implemented as a separate
  28. kernel module following the interface in include/linux/iio/sw_trigger.h::
  29. /*
  30. * drivers/iio/trigger/iio-trig-sample.c
  31. * sample kernel module implementing a new trigger type
  32. */
  33. #include <linux/iio/sw_trigger.h>
  34. static struct iio_sw_trigger *iio_trig_sample_probe(const char *name)
  35. {
  36. /*
  37. * This allocates and registers an IIO trigger plus other
  38. * trigger type specific initialization.
  39. */
  40. }
  41. static int iio_trig_sample_remove(struct iio_sw_trigger *swt)
  42. {
  43. /*
  44. * This undoes the actions in iio_trig_sample_probe
  45. */
  46. }
  47. static const struct iio_sw_trigger_ops iio_trig_sample_ops = {
  48. .probe = iio_trig_sample_probe,
  49. .remove = iio_trig_sample_remove,
  50. };
  51. static struct iio_sw_trigger_type iio_trig_sample = {
  52. .name = "trig-sample",
  53. .owner = THIS_MODULE,
  54. .ops = &iio_trig_sample_ops,
  55. };
  56. module_iio_sw_trigger_driver(iio_trig_sample);
  57. Each trigger type has its own directory under /config/iio/triggers. Loading
  58. iio-trig-sample module will create 'trig-sample' trigger type directory
  59. /config/iio/triggers/trig-sample.
  60. We support the following interrupt sources (trigger types):
  61. * hrtimer, uses high resolution timers as interrupt source
  62. 3.1 Hrtimer triggers creation and destruction
  63. ---------------------------------------------
  64. Loading iio-trig-hrtimer module will register hrtimer trigger types allowing
  65. users to create hrtimer triggers under /config/iio/triggers/hrtimer.
  66. e.g::
  67. $ mkdir /config/iio/triggers/hrtimer/instance1
  68. $ rmdir /config/iio/triggers/hrtimer/instance1
  69. Each trigger can have one or more attributes specific to the trigger type.
  70. 3.2 "hrtimer" trigger types attributes
  71. --------------------------------------
  72. "hrtimer" trigger type doesn't have any configurable attribute from /config dir.
  73. It does introduce the sampling_frequency attribute to trigger directory.