Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

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