blob: 69d9570f29fca10eb33702af17f88bfb6ae0c351 [file] [log] [blame]
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +01001IIO Device drivers
2
3This is not intended to provide a comprehensive guide to writing an
4IIO device driver. For further information see the drivers within the
5subsystem.
6
7The crucial structure for device drivers in iio is iio_dev.
8
9First allocate one using:
10
11struct iio_dev *indio_dev = iio_allocate_device();
12
Amit Kucheria51bf00a2009-11-09 15:10:15 +020013Then fill in the following:
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010014
15indio_dev->dev.parent
16 the struct device associated with the underlying hardware.
17
18indio_dev->num_interrupt_lines
19 number of event triggering hardware lines the device has.
20
21indio_dev->event_attrs
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
27indio_dev->attrs
28 general attributes such as polled access to device channels.
29
30indio_dev->dev_data
31 private device specific data.
32
33indio_dev->driver_module
34 typically set to THIS_MODULE. Used to specify ownership of some
35 iio created resources.
36
37indio_dev->modes
38 whether direct access and / or ring buffer access is supported.
39
40Once these are set up, a call to iio_device_register(indio_dev),
41will register the device with the iio core.
42
43Worth noting here is that, if a ring buffer is to be used, it can be
44allocated prior to registering the device with the iio-core, but must
45be registered afterwards (otherwise the whole parentage of devices
46gets confused)
47
Amit Kucheria51bf00a2009-11-09 15:10:15 +020048On remove, iio_device_unregister(indio_dev) will remove the device from
Jonathan Cameronc57f1ba2009-08-18 18:06:32 +010049the core, and iio_free_device will clean up.