summaryrefslogtreecommitdiff
path: root/drivers/staging/iio/adc
AgeCommit message (Collapse)Author
2012-11-05staging:iio:ad7887: Preallocate sample bufferLars-Peter Clausen
We know that the sample buffer will at most need to hold two 16 bit samples and the 64 bit aligned 64 bit timestamp. Preallocate a buffer large enough to hold this instead of allocating and freeing it each time a sample is read. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-11-02staging: iio: adc: ad7280a.c: fixed macro coding styleKumar Amit Mehta
remove unnecessary semicolon from the macro definition Signed-off-by: Kumar Amit Mehta <gmate.amit@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-31staging:iio: Consolidate adt7310 and adt7410 driverLars-Peter Clausen
The adt7310 is the SPI version of the adt7410, so there is no need to have a separate driver for it. The register map layout is a bit different, i.e. the addresses of the register differ, but the individual register layouts are identical. We solve this by adding a small look-up table, which translates adt7410 register addresses to ad7310 register addresses. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-19staging:iio:lpc32xx_adc: Use resource_size instead of opencoding itLars-Peter Clausen
Fixes the following error from coccicheck: drivers/staging/iio/adc/lpc32xx_adc.c:153:43-46: ERROR: Missing resource_size with res Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Acked-by: Roland Stigge <stigge@antcom.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-10-19drivers/staging/iio: Remove unnecessary semicolonPeter Senna Tschudin
A simplified version of the semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr/) // <smpl> @r1@ statement S; position p,p1; @@ S@p1;@p @script:python r2@ p << r1.p; p1 << r1.p1; @@ if p[0].line != p1[0].line_end: cocci.include_match(False) @@ position r1.p; @@ -;@p // </smpl> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22staging:iio:ad7780: Add support for the ad7170/ad7171Lars-Peter Clausen
The ad7170/ad7171 have a software interface similar to the ad7780. They do not have an external pin which allows to change the internal gain and the what is used for the gain bit in the ad7780/ad7781 becomes part of the check pattern. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-22staging:iio:ad7780: Make powerdown GPIO optionalLars-Peter Clausen
Some designs hardwire the PDRST pin to always on. In this case there is no GPIO to control the mode of the device, so make the GPIO optional. Since now all of the the platform data fields are optional now, make the platform data as a whole optional as well. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-17Merge tag 'iio-for-v3.7d' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next IIO new drivers, features and rework for the 3.7 cycle, 4th set. Here we have 1) a set cleaning up and moving the ad7476 driver out of staging. Support for a number of additional parts is also added to that driver. 2) cleanups from various people for the in kernel interface code as that is getting more an more real use and hence people are picking up on minor issues that made it through review. Also a related useful set of utility functions to avoid duplicate code for converting IIO representations to other forms. 3) a new fractional type for our read_raw / write_raw functions. This allows avoiding loss of accuracy via the in kernel interfaces in some cases as well as being rather convenient for a lot of range -> scale conversions. 4) New AD5755 DAC driver. 5) Some Blackfin timer trigger improvements including hardware pulse control for device triggering. 6) Support for the ad7091r in the ad7476 driver.
2012-09-16Merge 3.6-rc6 into staging-nextGreg Kroah-Hartman
This pulls in the staging tree fixes in 3.6-rc6 into our branch to resolve the merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-09-15iio: Move ad7476 driver out of stagingLars-Peter Clausen
The ad7476 driver is a driver for simple single channel ADCs. The driver does not export any experimental or custom ABI files nor do the static code check tools report any issues, so move the driver out of staging. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15staging:iio:ad7476: Use be16_to_cpup instead of open-coding itLars-Peter Clausen
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15staging:iio:ad7476: Squash driver into a single file.Lars-Peter Clausen
After the recent cleanups the buffer support is just a single 23 line function. This does not really justify a file on its own, so move it to the main driver file. And with only one source file left the header file containing the device state struct becomes superflousious so move the content of the header file to the main driver source file as well. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-15staging:iio:ad7476: Rework reference voltage handlingLars-Peter Clausen
Slightly rework the reference voltage handling for the ad7476 driver. Now the only way to specify a external reference voltage is to use the regulator API, previously it was possible to use either platform_data or the regulator API. The new way is more consistent with what other drivers do. Also do not ignore errors when requesting the regulator, since this will cope very poorly with e.g. deferred probing. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-13staging:iio:ad7476: Avoid alloc/free for each sample in buffered modeLars-Peter Clausen
The ad7476 driver has only support for 1 channel ADCs. So the upper limit for the buffer size is the size of one sample plus the size of the timestamp. Preallocate a buffer large enough to hold this to avoid having to allocate and free a new buffer for each sample being captured. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-13staging:iio:ad7476: Remove duplicated chip info entriesLars-Peter Clausen
Some of the parts supported by this driver are software compatible. The difference between them is only in the operating voltage range. So we do not need extra chip info entries for them. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-12staging:iio:ad7476: Fix off by one error for channel shiftLars-Peter Clausen
The datasheet is a bit confusing about this. It says that a dataword has 4 leading zeros, but the first zero is already put on the bus when CS is pulled low and the second zero is put on the bus on the first leading edge of SCLK, so when the first bit is sampled on the first trailing edge it will sample what the datasheet refers to as the second leading zero. Subsequently we only see 3 leading zeros in the 16 bit dataword and the result we get is shifted to the left by one bit. Fix this by adjusting the channel shift by 1. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-08iio: Drop timestamp parameter from buffer store_to callbackLars-Peter Clausen
Drop timestamp parameter from buffer store_to callback and subsequently from iio_push_to_buffer. The timestamp parameter is unused and it seems likely that it will stay unused in the future, so it should be safe to remove it. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-06staging:iio: Use iio_push_to_bufferLars-Peter Clausen
Consistently use iio_push_to_buffer instead of manually calling the buffers store_to callback. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03staging:iio: Update email address for Jonathan Cameron.iio-for-v3.7bJonathan Cameron
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-09-03drivers/staging/iio/adc/spear_adc.c: use clk_prepare_enable and ↵Julia Lawall
clk_disable_unprepare Clk_prepare_enable and clk_disable_unprepare combine clk_prepare and clk_enable, and clk_disable and clk_unprepare. They make the code more concise, and ensure that clk_unprepare is called when clk_enable fails. A simplified version of the semantic patch that introduces calls to these functions is as follows: (http://coccinelle.lip6.fr/) // <smpl> @@ expression e; @@ - clk_prepare(e); - clk_enable(e); + clk_prepare_enable(e); @@ expression e; @@ - clk_disable(e); - clk_unprepare(e); + clk_disable_unprepare(e); // </smpl> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27staging:iio: prevent divide by zero bugsDan Carpenter
"val" is used as a divisor later, so we should check for zero here to avoid a division by zero. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27staging:iio: Add missing __devinit and __devexit annotationsLars-Peter Clausen
Autogenerated using the following coccinelle semantic patch: // <smpl> @r1@ identifier driver; identifier fn; position p; type T; @@ T driver = { .remove = ( fn@p | __devexit_p(fn@p) ) }; @r2@ identifier r1.fn; position p != r1.p; @@ fn@p @r3@ identifier r1.fn; position r1.p; @@ ( __devexit_p(fn@p) | -fn@p +__devexit_p(fn) ) @depends on !r2@ identifier r1.fn; @@ static -int fn +int __devexit fn (...) { ... } @r11@ identifier driver; identifier fn; position p; type T; @@ T driver = { .probe = fn@p }; @r12@ identifier r11.fn; position p != r11.p; @@ fn@p @depends on !r12@ identifier r11.fn; @@ static -int fn +int __devinit fn (...) { ... } // </smpl> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27staging:iio:ad7793: Add ad7785 supportLars-Peter Clausen
The ad7785 is similar to the ad7792/ad7793, but has 20 bit wide data samples. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27staging:iio:ad7793: Add support for ad7794/ad7795Lars-Peter Clausen
The ad7794/ad7795 are similar to the ad7792/ad7793, but have 6 channels instead of 3. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27staging:iio:ad7192: Use common Sigma Delta libraryLars-Peter Clausen
Convert the ad7192 driver to make use of the new common code for devices from the Analog Devices Sigma Delta family. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27staging:iio:ad7793: Use common Sigma Delta libraryLars-Peter Clausen
Convert the ad7793 driver to make use of the new common code for devices from the Analog Devices Sigma Delta family. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27staging:iio:ad7780: Use common Sigma Delta libraryLars-Peter Clausen
Convert the ad7780 driver to make use of the new common code for devices from the Analog Devices Sigma Delta family. As a bonus the ad7780 driver gains support for buffered mode. Although this is a bit tricky. The ad7780 reports in the lower 4 unused bits of the data word the internal gain used. The driver will update the scale attribute value depending on the gain accordingly, but obviously this will only work if the gain does not change while sampling. This is not perfect, but since we store the raw value in the buffer an application which is aware of this can extract the gain factor from the buffer as well an apply it accordingly. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27staging:iio:ad7192: Remove unused platform_data from device state structLars-Peter Clausen
The platform data for the device is only used from within the drivers probe callback, so there is no need to keep it around in the devices state struct. While we are at it mark the platform data struct as const. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27staging:iio:ad7793: Remove unused platform_data from device state structLars-Peter Clausen
The platform data for the device is only used from within the drivers probe callback, so there is no need to keep it around in the devices state struct. While we are at it mark the platform data struct as const. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-27Merge 3.6-rc3 into staging-nextGreg Kroah-Hartman
This picks up fixes we want in this branch to allow us to properly test. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-08-16staging:iio:ad7780: Mark channels as unsignedLars-Peter Clausen
The values reported by the AD7780 are unsigned with a binary offset: 0x000000 is negative fullscale 0x800000 is zeroscale 0xffffff is positive fullscale So mark the channel in the channel spec as unsigned rather than signed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16staging:iio:ad7192: Report offset and scale for temperature channelLars-Peter Clausen
The temperature channel reports values in degree Kelvin with sensitivity of 5630 codes per degree. If the chip is configured in bipolar mode there is an additional binary offset of 0x800000 and the sensitivity is divided by two. Currently the driver does the mapping from the raw value to degree Celsius when doing a manual conversion. This has several disadvantages, the major one being that it does not work for buffered mode, also by doing the division by the sensitivity in the driver the precession of the reported value is needlessly reduced. Furthermore the current calculation only works in bipolar mode and the current scale is of by a factor of 1000. This patch modifies the driver to report correct offset and scale values in both unipolar and bipolar mode and to report the raw temperature value for manual conversions. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16staging:iio:ad7192: Report channel offsetLars-Peter Clausen
In bipolar mode there is a a binary offset of 2**(N-1) (with N being the number of bits) on the reported value. Currently this value is subtracted when doing a manual read. While this works for manual channel readings it does not work for buffered mode. So report the offset in the channels offset property, which will work in both modes. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-08-16staging:iio:ad7192: Mark channels as unsignedLars-Peter Clausen
The values reported by the AD7793 are unsigned. In uniploar mode: 0x000000 is zeroscale 0xffffff is fullscale In bipolar mode: 0x000000 is negative fullscale 0x800000 is zeroscale 0xffffff is positive fullscale In bipolar mode there is a binary offset, but the values are still unsigned. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16staging:iio:ad7192: Fix setting ACXLars-Peter Clausen
Write to the correct register when setting the ACX bit. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16staging:iio:ad7192: Add missing break in switch statementLars-Peter Clausen
Without the break statement we fall right through to the default case and return an error value. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16staging:iio:ad7793: Fix internal reference valueLars-Peter Clausen
The internal reference for the ad7793 and similar is 1.17V Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16staging:iio:ad7793: Follow new IIO naming specLars-Peter Clausen
Make the "in-in_scale_available" attribute follow the new naming spec and rename it to "in_voltage-voltage_scale_available". Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16staging:iio:ad7793: Fix temperature scale and offsetLars-Peter Clausen
The temperature channel uses the internal 1.17V reference with 0.81 mv/C. The reported temperature is in Kevlin, so we need to add the Kelvin to Celcius offset when reporting the offset for the temperature channel. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16staging:iio:ad7793: Report channel offsetLars-Peter Clausen
In bipolar mode there is a a binary offset of 2**(N-1) (with N being the number of bits) on the reported value. Currently this value is subtracted when doing a manual read. While this works for manual channel readings it does not work for buffered mode. So report the offset in the channels offset property, which will work in both modes. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16staging:iio:ad7793: Mark channels as unsignedLars-Peter Clausen
The values reported by the AD7793 are unsigned. In uniploar mode: 0x000000 is zeroscale 0xffffff is fullscale In bipolar mode: 0x000000 is negative fullscale 0x800000 is zeroscale 0xffffff is positive fullscale In bipolar mode there is a binary offset, but the values are still unsigned. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16staging:iio:ad7793: Add missing break in switch statementLars-Peter Clausen
Without the break statement we fall right through to the default case and return an error value. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16iio: staging: ad7298_ring: Fix maybe-uninitialized warningMichael Hennerich
drivers/staging/iio/adc/ad7298_ring.c:97:37: warning: 'time_ns' may be used uninitialized in this function [-Wmaybe-uninitialized] Reported-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-08-16IIO: Add basic MXS LRADC driveriio-for-v3.7aMarek Vasut
This driver is very basic. It supports userland trigger, buffer and raw access to channels. The support for delay channels is missing altogether. Signed-off-by: Marek Vasut <marex@denx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org> Cc: Jonathan Cameron <jic23@kernel.org> Cc: Juergen Beisert <jbe@pengutronix.de> Cc: Lars-Peter Clausen <lars@metafoo.de> Cc: Shawn Guo <shawn.guo@linaro.org> Cc: Wolfgang Denk <wd@denx.de>
2012-08-14staging:iio: Constify static iio_chan_spec arraysLars-Peter Clausen
The per driver iio_chan_spec arrays are usually shared between multiple device instances. So a single device instance may not modify the iio_chan_spec array since this would also affect the other device instances. To make this restriction explicit mark the per driver iio_chan_spec arrays as const. Conversion was done automatically using the following coccinelle semantic patch: // <smpl> @disable optional_qualifier@ identifier channels; @@ static +const struct iio_chan_spec channels[] = ...; // </smpl> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-14staging:iio:lpc32xx_adc: Ensure request_irq and free_irq dev_id parameter matchLars-Peter Clausen
The data parameters for request_irq and free_irq have to match, otherwise the IRQ wont be freed. The issue has been discovered using the following coccinelle patch: // <smpl> @r1@ type T; T data; @@ ( request_irq(..., (void *)data) | request_irq(..., data) | request_threaded_irq(..., (void *)data) | request_threaded_irq(..., data) ) @r2@ type r1.T; T data; position p; @@ ( free_irq@p(..., (void *)data) | free_irq@p(..., data) ) @depends on r1@ position p != r2.p; @@ *free_irq@p(...) // </smpl> Cc: Roland Stigge <stigge@antcom.de> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2012-07-12Merge tag 'togreg-3.6a' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next IIO: One new driver and a couple of nice cleanups.
2012-07-12Merge tag 'fixes-togreg-3.6a' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into work-next Various minor IIO fixes for staging-next.
2012-07-12staging:iio:max1363: Don't free uninitialized variableLars-Peter Clausen
It is possible that on one of the error paths we are going to try to free 'rxbuf', even though it has not been allocated yet, which cause the following warning: drivers/staging/iio/adc/max1363_ring.c: In function 'max1363_trigger_handler': drivers/staging/iio/adc/max1363_ring.c:87:7: warning: 'rxbuf' may be used uninitialized in this function Reported-by: Fengguang Wu <wfg@linux.intel.com> Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
2012-07-09Merge tag 'togreg_8_7_2012' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Mixed back of updates and trivial examples fixes. Nothing terribly interesting in this one. 8 July 2012