iio_configfs.txt 2.7 KB

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