diff options
-rw-r--r-- | drivers/staging/iio/Documentation/device.txt | 78 | ||||
-rw-r--r-- | drivers/staging/iio/Documentation/overview.txt | 19 | ||||
-rw-r--r-- | drivers/staging/iio/Documentation/ring.txt | 44 | ||||
-rw-r--r-- | drivers/staging/iio/Documentation/trigger.txt | 16 | ||||
-rw-r--r-- | drivers/staging/iio/Documentation/userspace.txt | 12 |
5 files changed, 91 insertions, 78 deletions
diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt index c81e5172aec8..1abb80cb884e 100644 --- a/drivers/staging/iio/Documentation/device.txt +++ b/drivers/staging/iio/Documentation/device.txt | |||
@@ -8,34 +8,66 @@ The crucial structure for device drivers in iio is iio_dev. | |||
8 | 8 | ||
9 | First allocate one using: | 9 | First allocate one using: |
10 | 10 | ||
11 | struct iio_dev *indio_dev = iio_allocate_device(0); | 11 | struct iio_dev *indio_dev = iio_allocate_device(sizeof(struct chip_state)); |
12 | where chip_state is a structure of local state data for this instance of | ||
13 | the chip. | ||
12 | 14 | ||
13 | Then fill in the following: | 15 | That data can be accessed using iio_priv(struct iio_dev *) |
14 | |||
15 | indio_dev->dev.parent | ||
16 | the struct device associated with the underlying hardware. | ||
17 | |||
18 | indio_dev->num_interrupt_lines | ||
19 | number of event triggering hardware lines the device has. | ||
20 | 16 | ||
21 | indio_dev->event_attrs | 17 | Then fill in the following: |
22 | attributes used to enable / disable hardware events - note the | ||
23 | attributes are embedded in iio_event_attr structures with an | ||
24 | associated iio_event_handler which may or may note be shared. | ||
25 | If num_interrupt_lines = 0, then no need to fill this in. | ||
26 | |||
27 | indio_dev->attrs | ||
28 | general attributes such as polled access to device channels. | ||
29 | 18 | ||
30 | indio_dev->dev_data | 19 | - indio_dev->dev.parent |
31 | private device specific data. | 20 | Struct device associated with the underlying hardware. |
21 | - indio_dev->name | ||
22 | Name of the device being driven - made available as the name | ||
23 | attribute in sysfs. | ||
32 | 24 | ||
33 | indio_dev->driver_module | 25 | - indio_dev->info |
34 | typically set to THIS_MODULE. Used to specify ownership of some | 26 | pointer to a structure with elements that tend to be fixed for |
35 | iio created resources. | 27 | large sets of different parts supported by a given driver. |
28 | This contains: | ||
29 | * info->driver_module: | ||
30 | Set to THIS_MODULE. Used to ensure correct ownership | ||
31 | of various resources allocate by the core. | ||
32 | * info->num_interrupt_lines: | ||
33 | Number of event triggering hardware lines the device has. | ||
34 | * info->event_attrs: | ||
35 | Attributes used to enable / disable hardware events. | ||
36 | * info->attrs: | ||
37 | General device attributes. Typically used for the weird | ||
38 | and the wonderful bits not covered by the channel specification. | ||
39 | * info->read_raw: | ||
40 | Raw data reading function. Used for both raw channel access | ||
41 | and for associate parameters such as offsets and scales. | ||
42 | * info->write_raw: | ||
43 | Raw value writing function. Used for writable device values such | ||
44 | as DAC values and caliboffset. | ||
45 | * info->read_event_config: | ||
46 | Typically only set if there are some interrupt lines. This | ||
47 | is used to read if an on sensor event detector is enabled. | ||
48 | * info->write_event_config: | ||
49 | Enable / disable an on sensor event detector. | ||
50 | * info->read_event_value: | ||
51 | Read value associated with on sensor event detectors. Note that | ||
52 | the meaning of the returned value is dependent on the event | ||
53 | type. | ||
54 | * info->write_event_value: | ||
55 | Write the value associated with on sensor event detectors. E.g. | ||
56 | a threshold above which an interrupt occurs. Note that the | ||
57 | meaning of the value to be set is event type dependant. | ||
36 | 58 | ||
37 | indio_dev->modes | 59 | - indio_dev->modes: |
38 | whether direct access and / or ring buffer access is supported. | 60 | Specify whether direct access and / or ring buffer access is supported. |
61 | - indio_dev->ring: | ||
62 | An optional associated buffer. | ||
63 | - indio_dev->pollfunc: | ||
64 | Poll function related elements. This controls what occurs when a trigger | ||
65 | to which this device is attached sends and event. | ||
66 | - indio_dev->channels: | ||
67 | Specification of device channels. Most attributes etc are built | ||
68 | form this spec. | ||
69 | - indio_dev->num_channels: | ||
70 | How many channels are there? | ||
39 | 71 | ||
40 | Once these are set up, a call to iio_device_register(indio_dev), | 72 | Once these are set up, a call to iio_device_register(indio_dev), |
41 | will register the device with the iio core. | 73 | will register the device with the iio core. |
diff --git a/drivers/staging/iio/Documentation/overview.txt b/drivers/staging/iio/Documentation/overview.txt index d97106cb2b96..afc39ecde9ca 100644 --- a/drivers/staging/iio/Documentation/overview.txt +++ b/drivers/staging/iio/Documentation/overview.txt | |||
@@ -3,8 +3,7 @@ Overview of IIO | |||
3 | The Industrial I/O subsystem is intended to provide support for devices | 3 | The Industrial I/O subsystem is intended to provide support for devices |
4 | that in some sense are analog to digital converters (ADCs). As many | 4 | that in some sense are analog to digital converters (ADCs). As many |
5 | actual devices combine some ADCs with digital to analog converters | 5 | actual devices combine some ADCs with digital to analog converters |
6 | (DACs) the intention is to add that functionality at a future date | 6 | (DACs) that functionality is also supported. |
7 | (hence the name). | ||
8 | 7 | ||
9 | The aim is to fill the gap between the somewhat similar hwmon and | 8 | The aim is to fill the gap between the somewhat similar hwmon and |
10 | input subsystems. Hwmon is very much directed at low sample rate | 9 | input subsystems. Hwmon is very much directed at low sample rate |
@@ -31,32 +30,28 @@ event must be accessed via polling. | |||
31 | Note: A given device may have one or more event channel. These events are | 30 | Note: A given device may have one or more event channel. These events are |
32 | turned on or off (if possible) via sysfs interfaces. | 31 | turned on or off (if possible) via sysfs interfaces. |
33 | 32 | ||
34 | * Hardware ring buffer support. Some recent sensors have included | 33 | * Hardware buffer support. Some recent sensors have included |
35 | fifo / ring buffers on the sensor chip. These greatly reduce the load | 34 | fifo / ring buffers on the sensor chip. These greatly reduce the load |
36 | on the host CPU by buffering relatively large numbers of data samples | 35 | on the host CPU by buffering relatively large numbers of data samples |
37 | based on an internal sampling clock. Examples include VTI SCA3000 | 36 | based on an internal sampling clock. Examples include VTI SCA3000 |
38 | series and Analog Device ADXL345 accelerometers. Each ring buffer | 37 | series and Analog Device ADXL345 accelerometers. Each buffer supports |
39 | typically has an event chrdev (similar to the more general ones above) | 38 | polling to establish when data is available. |
40 | to pass on events such as buffer 50% full and an access chrdev via | ||
41 | which the raw data it self may be read back. | ||
42 | 39 | ||
43 | * Trigger and software ring buffer support. In many data analysis | 40 | * Trigger and software buffer support. In many data analysis |
44 | applications it it useful to be able to capture data based on some | 41 | applications it it useful to be able to capture data based on some |
45 | external signal (trigger). These triggers might be a data ready | 42 | external signal (trigger). These triggers might be a data ready |
46 | signal, a gpio line connected to some external system or an on | 43 | signal, a gpio line connected to some external system or an on |
47 | processor periodic interrupt. A single trigger may initialize data | 44 | processor periodic interrupt. A single trigger may initialize data |
48 | capture or reading from a number of sensors. These triggers are | 45 | capture or reading from a number of sensors. These triggers are |
49 | used in IIO to fill software ring buffers acting in a very similar | 46 | used in IIO to fill software buffers acting in a very similar |
50 | fashion to the hardware buffers described above. | 47 | fashion to the hardware buffers described above. |
51 | 48 | ||
52 | Other documentation: | 49 | Other documentation: |
53 | 50 | ||
54 | userspace.txt - overview of ring buffer reading from userspace. | ||
55 | |||
56 | device.txt - elements of a typical device driver. | 51 | device.txt - elements of a typical device driver. |
57 | 52 | ||
58 | trigger.txt - elements of a typical trigger driver. | 53 | trigger.txt - elements of a typical trigger driver. |
59 | 54 | ||
60 | ring.txt - additional elements required for ring buffer support. | 55 | ring.txt - additional elements required for buffer support. |
61 | 56 | ||
62 | sysfs-bus-iio - abi documentation file. | 57 | sysfs-bus-iio - abi documentation file. |
diff --git a/drivers/staging/iio/Documentation/ring.txt b/drivers/staging/iio/Documentation/ring.txt index 3696c364e644..7e99ef2b7bc0 100644 --- a/drivers/staging/iio/Documentation/ring.txt +++ b/drivers/staging/iio/Documentation/ring.txt | |||
@@ -1,57 +1,55 @@ | |||
1 | Ring buffer support within IIO | 1 | Buffer support within IIO |
2 | 2 | ||
3 | This document is intended as a general overview of the functionality | 3 | This document is intended as a general overview of the functionality |
4 | a ring buffer may supply and how it is specified within IIO. For more | 4 | a buffer may supply and how it is specified within IIO. For more |
5 | specific information on a given ring buffer implementation, see the | 5 | specific information on a given buffer implementation, see the |
6 | comments in the source code. Note that the intention is to allow | 6 | comments in the source code. Note that some drivers allow buffer |
7 | some drivers to specify ring buffers choice at probe or runtime, but | 7 | implementation to be selected at compile time via Kconfig options. |
8 | for now the selection is hard coded within a given driver. | ||
9 | 8 | ||
10 | A given ring buffer implementation typically embedded a struct | 9 | A given buffer implementation typically embeds a struct |
11 | iio_ring_buffer and it is a pointer to this that is provided to the | 10 | iio_ring_buffer and it is a pointer to this that is provided to the |
12 | IIO core. Access to the embedding structure is typically done via | 11 | IIO core. Access to the embedding structure is typically done via |
13 | container_of functions. | 12 | container_of functions. |
14 | 13 | ||
15 | struct iio_ring_buffer contains 4 function pointers | 14 | struct iio_ring_buffer contains a struct iio_ring_setup_ops *setup_ops |
16 | (preenable, postenable, predisable, postdisable). | 15 | which in turn contains the 4 function pointers |
17 | These are used to perform implementation specific steps on either side | 16 | (preenable, postenable, predisable and postdisable). |
18 | of the core changing it's current mode to indicate that the ring buffer | 17 | These are used to perform device specific steps on either side |
18 | of the core changing it's current mode to indicate that the buffer | ||
19 | is enabled or disabled (along with enabling triggering etc as appropriate). | 19 | is enabled or disabled (along with enabling triggering etc as appropriate). |
20 | 20 | ||
21 | Also in struct iio_ring_buffer is a struct iio_ring_access_funcs. | 21 | Also in struct iio_ring_buffer is a struct iio_ring_access_funcs. |
22 | The function pointers within here are used to allow the core to handle | 22 | The function pointers within here are used to allow the core to handle |
23 | as much ring buffer functionality as possible. Note almost all of these | 23 | as much buffer functionality as possible. Note almost all of these |
24 | are optional. | 24 | are optional. |
25 | 25 | ||
26 | mark_in_use, unmark_in_use | 26 | mark_in_use, unmark_in_use |
27 | Basically indicate that not changes should be made to the ring | 27 | Basically indicate that not changes should be made to the buffer state that |
28 | buffer state that will effect the form of the data being captures | 28 | will effect the form of the data being captures (e.g. scan elements or length) |
29 | (e.g. scan elements or length) | ||
30 | 29 | ||
31 | store_to | 30 | store_to |
32 | If possible, push data to ring buffer. | 31 | If possible, push data to the buffer. |
33 | 32 | ||
34 | read_last | 33 | read_last |
35 | If possible get the most recent entry from the buffer (without removal). | 34 | If possible, get the most recent scan from the buffer (without removal). |
36 | This provides polling like functionality whilst the ring buffering is in | 35 | This provides polling like functionality whilst the ring buffering is in |
37 | use without a separate read from the device. | 36 | use without a separate read from the device. |
38 | 37 | ||
39 | rip_lots | 38 | rip_first_n |
40 | The primary ring buffer reading function. Note that it may well not return | 39 | The primary buffer reading function. Note that it may well not return |
41 | as much data as requested. The deadoffset is used to indicate that some | 40 | as much data as requested. |
42 | initial data in the data array is not guaranteed to be valid. | ||
43 | 41 | ||
44 | mark_param_changed | 42 | mark_param_changed |
45 | Used to indicate that something has changed. Used in conjunction with | 43 | Used to indicate that something has changed. Used in conjunction with |
46 | request_update | 44 | request_update |
47 | If parameters have changed that require reinitialization or configuration of | 45 | If parameters have changed that require reinitialization or configuration of |
48 | the ring buffer this will trigger it. | 46 | the buffer this will trigger it. |
49 | 47 | ||
50 | get_bytes_per_datum, set_bytes_per_datum | 48 | get_bytes_per_datum, set_bytes_per_datum |
51 | Get/set the number of bytes for a complete scan. (All samples + timestamp) | 49 | Get/set the number of bytes for a complete scan. (All samples + timestamp) |
52 | 50 | ||
53 | get_length / set_length | 51 | get_length / set_length |
54 | Get/set the number of sample sets that may be held by the buffer. | 52 | Get/set the number of complete scans that may be held by the buffer. |
55 | 53 | ||
56 | is_enabled | 54 | is_enabled |
57 | Query if ring buffer is in use | 55 | Query if ring buffer is in use |
diff --git a/drivers/staging/iio/Documentation/trigger.txt b/drivers/staging/iio/Documentation/trigger.txt index 650157f5c9de..fc2012ebc100 100644 --- a/drivers/staging/iio/Documentation/trigger.txt +++ b/drivers/staging/iio/Documentation/trigger.txt | |||
@@ -5,14 +5,11 @@ an IIO device. Whilst this can create device specific complexities | |||
5 | such triggers are registered with the core in the same way as | 5 | such triggers are registered with the core in the same way as |
6 | stand-alone triggers. | 6 | stand-alone triggers. |
7 | 7 | ||
8 | struct iio_trig *trig = iio_allocate_trigger(); | 8 | struct iio_trig *trig = iio_allocate_trigger("<trigger format string>", ...); |
9 | 9 | ||
10 | allocates a trigger structure. The key elements to then fill in within | 10 | allocates a trigger structure. The key elements to then fill in within |
11 | a driver are: | 11 | a driver are: |
12 | 12 | ||
13 | trig->control_attrs | ||
14 | Any sysfs attributes needed to control parameters of the trigger | ||
15 | |||
16 | trig->private_data | 13 | trig->private_data |
17 | Device specific private data. | 14 | Device specific private data. |
18 | 15 | ||
@@ -20,8 +17,12 @@ trig->owner | |||
20 | Typically set to THIS_MODULE. Used to ensure correct | 17 | Typically set to THIS_MODULE. Used to ensure correct |
21 | ownership of core allocated resources. | 18 | ownership of core allocated resources. |
22 | 19 | ||
23 | trig->name | 20 | trig->set_trigger_state: |
24 | A unique name for the trigger. | 21 | Function that enables / disables the underlying source of the trigger. |
22 | |||
23 | There is also a | ||
24 | trig->alloc_list which is useful for drivers that allocate multiple | ||
25 | triggers to keep track of what they have created. | ||
25 | 26 | ||
26 | When these have been set call: | 27 | When these have been set call: |
27 | 28 | ||
@@ -30,9 +31,8 @@ iio_trigger_register(trig); | |||
30 | to register the trigger with the core, making it available to trigger | 31 | to register the trigger with the core, making it available to trigger |
31 | consumers. | 32 | consumers. |
32 | 33 | ||
33 | |||
34 | Trigger Consumers | 34 | Trigger Consumers |
35 | 35 | ||
36 | Currently triggers are only used for the filling of software ring | 36 | Currently triggers are only used for the filling of software |
37 | buffers and as such any device supporting INDIO_RING_TRIGGERED has the | 37 | buffers and as such any device supporting INDIO_RING_TRIGGERED has the |
38 | consumer interface automatically created. | 38 | consumer interface automatically created. |
diff --git a/drivers/staging/iio/Documentation/userspace.txt b/drivers/staging/iio/Documentation/userspace.txt deleted file mode 100644 index ff06e5dc7188..000000000000 --- a/drivers/staging/iio/Documentation/userspace.txt +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | Userspace access to IIO | ||
2 | |||
3 | The sysfs attributes are documented in sysfs-bus-iio. | ||
4 | |||
5 | Udev will create the following entries under /dev by default: | ||
6 | |||
7 | device0:buffer0:access0 - ring access chrdev | ||
8 | device0:buffer0:event0 - ring event chrdev | ||
9 | device0:event0 - general event chrdev. | ||
10 | |||
11 | The files, lis3l02dqbuffersimple.c and iio_utils.h in this directory provide an example | ||
12 | of how to use the ring buffer and event interfaces. | ||