diff options
Diffstat (limited to 'drivers/staging/iio/Documentation/device.txt')
-rw-r--r-- | drivers/staging/iio/Documentation/device.txt | 78 |
1 files changed, 55 insertions, 23 deletions
diff --git a/drivers/staging/iio/Documentation/device.txt b/drivers/staging/iio/Documentation/device.txt index 69d9570f29fc..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. First allocate one using: -struct iio_dev *indio_dev = iio_allocate_device(); +struct iio_dev *indio_dev = iio_allocate_device(sizeof(struct chip_state)); +where chip_state is a structure of local state data for this instance of +the chip. -Then fill in the following: - -indio_dev->dev.parent - the struct device associated with the underlying hardware. - -indio_dev->num_interrupt_lines - number of event triggering hardware lines the device has. +That data can be accessed using iio_priv(struct iio_dev *) -indio_dev->event_attrs - attributes used to enable / disable hardware events - note the - attributes are embedded in iio_event_attr structures with an - associated iio_event_handler which may or may note be shared. - If num_interrupt_lines = 0, then no need to fill this in. - -indio_dev->attrs - general attributes such as polled access to device channels. +Then fill in the following: -indio_dev->dev_data - private device specific data. +- indio_dev->dev.parent + Struct device associated with the underlying hardware. +- indio_dev->name + Name of the device being driven - made available as the name + attribute in sysfs. -indio_dev->driver_module - typically set to THIS_MODULE. Used to specify ownership of some - iio created resources. +- indio_dev->info + pointer to a structure with elements that tend to be fixed for + large sets of different parts supported by a given driver. + This contains: + * info->driver_module: + Set to THIS_MODULE. Used to ensure correct ownership + of various resources allocate by the core. + * info->num_interrupt_lines: + Number of event triggering hardware lines the device has. + * info->event_attrs: + Attributes used to enable / disable hardware events. + * info->attrs: + General device attributes. Typically used for the weird + and the wonderful bits not covered by the channel specification. + * info->read_raw: + Raw data reading function. Used for both raw channel access + and for associate parameters such as offsets and scales. + * info->write_raw: + Raw value writing function. Used for writable device values such + as DAC values and caliboffset. + * info->read_event_config: + Typically only set if there are some interrupt lines. This + is used to read if an on sensor event detector is enabled. + * info->write_event_config: + Enable / disable an on sensor event detector. + * info->read_event_value: + Read value associated with on sensor event detectors. Note that + the meaning of the returned value is dependent on the event + type. + * info->write_event_value: + Write the value associated with on sensor event detectors. E.g. + a threshold above which an interrupt occurs. Note that the + meaning of the value to be set is event type dependant. -indio_dev->modes - whether direct access and / or ring buffer access is supported. +- indio_dev->modes: + Specify whether direct access and / or ring buffer access is supported. +- indio_dev->ring: + An optional associated buffer. +- indio_dev->pollfunc: + Poll function related elements. This controls what occurs when a trigger + to which this device is attached sends and event. +- indio_dev->channels: + Specification of device channels. Most attributes etc are built + form this spec. +- indio_dev->num_channels: + How many channels are there? Once these are set up, a call to iio_device_register(indio_dev), will register the device with the iio core. |