[RFC] Staging:IIO: New ABI
From: Jonathan Cameron
Date: Wed Jan 20 2010 - 10:13:50 EST
An extensive conversation with Manuel Stahl that grew out of his
work on an ADIS16400 driver and the userspace IIO tools at
iioutils.sourceforge.net showed that there were a number of
significant short comings in the current IIO ABI. Some of these
were simply things that have never been pinned down, others
are down to silly issues with how the code has developed.
Hence Manuel and I have drawn up a new ABI specification.
With hindsight we should probably have held the entire
conversation publicly but this document will hopefully
act as summary.
Please forgive the flagrant abuse of syntax in large parts
of this file. This will all be cleaned up before a formal
submission. At this stage what we are after is comments on
the actual IIO sysfs ABI. There are doubtlessly unclear sections
and elements we have forgotten completely so if you know of
something that is missing (along with a concrete example
of where it is needed, please do point it out!)
To avoid an insanely long ABI spec, I've suppressed fields
that are not of interest to this discussion and not specified
some items that are similar in purpose to those given for
All comments welcome. One area of extreme complexity currently
is that of event handling and specifically how come up with
a consistent generalizable specification when there are so
many different options. Comments / suggestions on this are
As ever, if people could forward / cc anyone how they think
may be interested that would be great. The current cc list
is based on a fairly rapid dash through previous threads.
Hardware chip or device accessed by on communication port.
Corresponds to a grouping of sensor channels.
An event driven driver of data capture to an in kernel buffer.
May be provided a device driver that also has an IIO device
based on hardware generated events (e.g. data ready) or
provided by other hardware (e.g. periodic timer or gpio)
Contains trigger type specific elements. These do not
Link to /sys/class/iio/device[n]/ring_buffer[m]. Ring buffer
numbering may not match that of device as some devices do not
have ring buffers.
Description of the physical chip / device. Typically a part
Raw (unscaled no bias removal etc) voltage measurement from
channel m. name is used in special cases where this does
not correspond to externally available input (e.g. supply
If known for a device, offset to be added to volt[m]_raw prior
to scaling by volt[m]_scale in order to obtain voltage in
Volts. Not present if the offset is always 0 or unknown.
If m is not present, then voltage offset applies to all volt
channels. May be writable if a variable offset is controlled
by the device. Note that this is different to calibbias which
is for devices that apply offsets to compensate for variation
between different instances of the part.
If a small number of discrete offset values are available, this
will be a space separated list. If these are independant (but
options the same) for individual offsets then m should not be
If a more or less continuous range of voltage offsets are supported
then this specifies the minimum / maximum. If shared by all
volt channels then m is not present.
Hardware applied calibration offset. (assumed to fix production
Hardware applied calibration scale factor. (assumed to fix production
If known for a device, scale to be applied to volt[m]_raw post
addition of volt[m]_offset in order to obtain the measured voltage
in volts. If shared across all voltage channels the m is not present.
Acceleration in direction x, y or z (may be arbitrarily assigned
but should match other such assignments on device)
channel m (not present if only one accelerometer channel at
this orientation). Has all of the equivalent parameters as per volt[m].
Units after application of scale and offset are m/s^2.
Angular velocity about axis x,y or z (may be arbitrarily assigned)
channel m (not present if only one gyroscope at this orientation).
Data converted by application of offset then scale to
radians per second. Has all the equivalent parameters as per volt[m].
Magnetic field along axis x, y or z (may be arbitrarily assigned)
channel m (not present if only one magnetometer at this orientation).
Data converted by application of offset then scale to Gauss
Has all the equivalent modifiers as per volt[m].
//Lots more to add along a similar vain.
Configuration of which hardware generated events are passed up to
userspace. Some of these are a bit complex to generalize so this
section is a work in progress.
major:minor character device numbers.
Again taking accel_x0 as example and serious liberties with ABI spec.
Event generated when accel_x0 passes a threshold in correction direction
(or stays beyond one). If direction isn't specified, either triggers it.
Note driver will assume last p events requested are enabled where p is
however many it supports. So if you want to be sure you have
set what you think you have, check the contents of these. Drivers
may have to buffer any parameters so that they are consistent when a
given event type is enabled a future point (and not those for whatever
alarm was previously enabled).
Same as above but based on the first differential of the value.
A period of time (microsecs) for which the condition must be broken
before an interrupt is triggered. Applies to all alarms if type is not
The actual value of the threshold either in raw device units
obtained by reverse application of scale and offfset to the
acceleration in m/s^2.
Common hardware event in accelerometers. Takes no parameters.
There are many other weird and wonderful event types that we'll deal with as and when.
Taking accel_x0 for example of next section.
Scan element control for triggered data capture. m implies the
ordering within the buffer. Next the type is specified with
modifier and channel number as per the sysfs single channel
Scan element precision within the ring buffer. Note that the
data alignment must restrictions must be read from in
ring_buffer to work out full data alignment for data read
via ring_access chrdev. _x0 dropped if shared across all
A bit shift (to right) that must be applied prior to
extracting the bits specified by accel[_x0]_precision.
Ring buffer specific parameters separate. Some are influenced
Ring buffer m event character device o major:minor numbers.
Ring buffer m access character device o major:minor numbers.
The name of the trigger source being used, as per string given
Number of scans contained by the buffer.
Bytes per scan. Due to alignment fun, the scan may be larger
than implied directly by the scan_element parameters.
Actually start the ring buffer capture up. Will start trigger
if first device and appropriate.
Minimum data alignment. Scan elements larger than this are aligned
to the nearest power of 2 times this. (may not be true in weird
hardware ring buffers that pack data well)
So an example, adis16350
accel_scale (applies to all accel channels)
accel_x_raw (the raw reading)
accel_x_calibbias (calibration value - in reg XACCEL_OFF
accel_x_raw_offset assumed to be 0 so not provided).
temp_gyrox_raw (These are somewhat unusual!)
frequency (applies even when trigger not running)
//some stuff that may not generalise...
//associated trigger can be navigated to via device directory. Also the default
//trigger will be set correctly. Not in ring_buffer as that directory may become
//dependent on live configurable ring buffer types. (spurious argument?)
//etc. This may seem overkill but this the only option that I
//can think of that generalizes well. Other suggestions welcome!
//device specific (may generalize)
trigger0/ (adis16350 is providing a data ready trigger)
//there are no other parameters here as the datardy frequency is dependent
//on how device is configured. (I think it makes more sense in device).
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/