linux/drivers/staging/iio/Documentation/inkernel.txt
<<
>>
Prefs
   1Industrial I/O Subsystem in kernel consumers.
   2
   3The IIO subsystem can act as a layer under other elements of the kernel
   4providing a means of obtaining ADC type readings or of driving DAC type
   5signals.  The functionality supported will grow as use cases arise.
   6
   7Describing the channel mapping (iio/machine.h)
   8
   9Channel associations are described using:
  10
  11struct iio_map {
  12        const char *adc_channel_label;
  13        const char *consumer_dev_name;
  14        const char *consumer_channel;
  15};
  16
  17adc_channel_label identifies the channel on the IIO device by being
  18matched against the datasheet_name field of the iio_chan_spec.
  19
  20consumer_dev_name allows identification of the consumer device.
  21This are then used to find the channel mapping from the consumer device (see
  22below).
  23
  24Finally consumer_channel is a string identifying the channel to the consumer.
  25(Perhaps 'battery_voltage' or similar).
  26
  27An array of these structures is then passed to the IIO driver.
  28
  29Supporting in kernel interfaces in the driver (driver.h)
  30
  31The driver must provide datasheet_name values for its channels and
  32must pass the iio_map structures and a pointer to its own iio_dev structure
  33 on to the core via a call to iio_map_array_register.  On removal,
  34iio_map_array_unregister reverses this process.
  35
  36The result of this is that the IIO core now has all the information needed
  37to associate a given channel with the consumer requesting it.
  38
  39Acting as an IIO consumer (consumer.h)
  40
  41The consumer first has to obtain an iio_channel structure from the core
  42by calling iio_channel_get().  The correct channel is identified by:
  43
  44* matching dev or dev_name against consumer_dev and consumer_dev_name
  45* matching consumer_channel against consumer_channel in the map
  46
  47There are then a number of functions that can be used to get information
  48about this channel such as it's current reading.
  49
  50e.g.
  51iio_read_channel_raw() - get a reading
  52iio_get_channel_type() - get the type of channel
  53
  54There is also provision for retrieving all of the channels associated
  55with a given consumer.  This is useful for generic drivers such as
  56iio_hwmon where the number and naming of channels is not known by the
  57consumer driver.  To do this, use iio_channel_get_all.
  58
  59