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