I see there is linux kernel driver support for the ad7887, but the very similar ad7888 does not seem to have a driver anywhere. Can I use the same driver? Can I read all 8 channels using this driver, since the 7887 is only a 2 channel device?
I created a driver for the ad7888 a while ago, unfortunately never had the chance to properly test it, but I think it should work. I've pushed the driver to the iio-ad7888 branch on the ADI linux repository. You can find the patch that adds support for the ad7888 to the ad7887 here.
Let me know if it works.
Thanks for the updated code. I see that someone has merged this patch into the git repo that was referenced. I am compiling this on Marvel ARM (Armada). Upon using the new kernel, this driver seems to load fine and creates a series of file handles in /sys/class/spi_master/spi1/spi1.1/iio\:device0/ :
buffer in_voltage2_raw in_voltage6_raw power uevent
dev in_voltage3_raw in_voltage7_raw scan_elements
in_voltage0_raw in_voltage4_raw in_voltage_scale subsystem
in_voltage1_raw in_voltage5_raw name trigger
but when I try to cat a voltage reading, it crashes the OS or throws a segmentation fault. Note I am using the ad7887.c file and not your patch. Anyone have a theory as to why this would happen? I am using a Marvell based uboot and a 3.16 kernel. the old driver worked ok for the first channel with this setup.
Thank you very much for the update. The patched driver source is working much better for me now, and I did not get any crashes. However:
When catting the dev files as described above, it looks like in_voltage0_raw is reading the correct value, but it appears that in_voltage(1-7)_raw are all reading ADC channel 0 not their respective channels, as they read the same value as channel 0 when their voltages are removed. Any idea why this would happen?
Also, the in_voltage_scale seems to be wrong. I am reading 0.610351562 from it, and according to the datasheet it should be 0.001220703125 (5V/4096). Not a big deal since I can use a local value for this instead of a driver call.
I am building this driver as a kernel driver, not a loadable module. dmesg does not seem to provide any info about it in that mode.
Sorry for the delay. So one more try, I think this one should work better. I've updated the patch.
Regrading the scale the unit is in millivolts. So a scale of 0.601... is equal to a reference of 2.5V, which should be the internal reference. If you are using a external reference you need to specify the voltage for it as explained in the driver documentation.