inkernel.txt 2.1 KB

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