summaryrefslogtreecommitdiff
path: root/drivers/iio/adc/ina2xx-adc.c
AgeCommit message (Collapse)Author
2017-08-28Merge 4.13-rc7 into staging-nextGreg Kroah-Hartman
We want the staging and iio fixes in here to handle the merge issues. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-30iio: adc: ina219: Avoid underflow for sleeping timeStefan Brüns
Proper support for the INA219 lowered the minimum sampling period from 2*140us to 2*84us. Subtracting 200us later leads to an underflow and an almost infinite udelay later. Using a signed int for the sampling period provides sufficient range (at most 2*8640*1024us), but catches the underflow when comparing with buffer_us. Fixes: 18edac2e22f4 ("iio: adc: Fix integration time/averaging for INA219/220") Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2017-07-01iio: adc: Fix polling of INA219 conversion ready flagStefan Brüns
While the INA226 has a conversion ready flag (CVRF) in the R/W Mask/Enable register with read-to-clear semantics, the corresponding bit of the INA219 (CNVR) is part of the bus voltage register. The flag is cleared by reading the power register. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-06-03iio: adc: Fix integration time/averaging for INA219/220Stefan Brüns
INA226/230/231 has integration times per voltage channel and common averaging setting for both channels, while the INA219/220 only has a combined integration time/averaging setting per channel. Only expose the averaging attribute for the INA226, and expose the correct integration times for the INA219. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-06-03iio: adc: ina2xx: Make use of attribute flags consistent on all channelsStefan Brüns
Flags for shared channel attributes should be set on all channels of a channel set. I.e. SAMP_FREQUENCY and OVERSAMPLING_RATIO are set on the in_voltage{0,1} channels, thus should be set on in_power, in_current. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-05-07iio: adc: Fix bad GENMASK use, typos, whitespaceStefan Brüns
Commit 7906dd52c5a0 ("iio: ina2xx: Fix whitespace and re-order code") changed the register number of the MASK_ENABLE register from 0x06 to the value equivalent GENMASK(2,1), although its no mask. Also fix a typo (INA2_6_6 instead of INA2_2_6), and use the datasheet name ("Mask/Enable") for the register number define. Fix bad indentation for channel attributes. Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de> Acked-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-03-19iio: adc: ina2xx: Add OF device ID tableJavier Martinez Canillas
The driver doesn't have a struct of_device_id table but supported devices are registered via Device Trees. This is working on the assumption that a I2C device registered via OF will always match a legacy I2C device ID and that the MODALIAS reported will always be of the form i2c:<device>. But this could change in the future so the correct approach is to have an OF device ID table if the devices are registered via OF. Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10iio:kfifo_buf header include push down.Jonathan Cameron
As a precursor to splitting buffer.h, lets make sure all drivers include the relevant headers rather than relying on picking them up from kfifo_buf.h. Signed-off-by: Jonathan Cameron <jic23@kernel.org> Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2016-09-03iio: adc: ina2xx: remove unused debug field from chip global dataAlison Schofield
commit 1961bce76452 "iio: ina2xx: Remove trace_printk debug statements" removed the code that used the chip->prev_ns field. This patch cleans it up further by removing the unused field and assignments. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: Daniel Baluta <daniel.baluta@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-07-03iio: adc: add missing of_node references to iio_devMatt Ranostay
Adding missing indio_dev->dev.of_node references to allow iio consumers to access the device channels. Signed-off-by: Matt Ranostay <mranostay@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-30iio:core: timestamping clock selection supportGregor Boirie
Adds a new per-device sysfs attribute "current_timestamp_clock" to allow userspace to select a particular POSIX clock for buffered samples and events timestamping. Following clocks, as listed in clock_gettime(2), are supported: CLOCK_REALTIME, CLOCK_MONOTONIC, CLOCK_MONOTONIC_RAW, CLOCK_REALTIME_COARSE, CLOCK_MONOTONIC_COARSE, CLOCK_BOOTTIME and CLOCK_TAI. Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com> Acked-by: Sanchayan Maity <maitysanchayan@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-03iio: ina2xx-adc: fix scale for VShuntMarc Titinger
The scale would result in uV instead of expected mV. Mostly cosmetic, since the value of 'Power' was computed OK. Signed-off-by: Marc Titinger <marc.titinger@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-03-21iio: ina2xx-adc: update the CALIB. register when RShunt changesMarc Titinger
The user (or an init script) may setup RShunt via sysfs after the driver was initialized, for instance based on the EEPROM contents of a modular probe. The calibration register must be set accordingly. Signed-off-by: Marc Titinger <marc.titinger@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-02-24iio: ina2xx: Remove trace_printk debug statmentsAndrew F. Davis
These are generally for devlopment use only, remove these from performance-critical code, convert to dev_dbg elswhere. Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-02-24iio: ina2xx: Fix whitespace and re-order codeAndrew F. Davis
Group of probably overly rigorous whitespace and code cleanups. - Alphabetize includes - Assign to variables in the order they are defined - Alignment issues - Group alike statements together - Use helper macros Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-22iio: adc: ina2xx: Fix incorrect report of data endianness to userspace.Jonathan Cameron
This was extracted from a reposting of the driver after it had been applied to the IIO tree. I have fast tracked it as the driver will be in 4.5 and it would be nice to fix this trivial issue before it is. Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-19iio: ina2xx: fix channel order in software bufferMarc Titinger
POWER and CURRENT were swapped out in the buffer: was current2 and power3, correct order is power2 and current3. Signed-off-by: Marc Titinger <mtitinger@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-12iio: ina2xx: give the capture kthread a more useful name string.Marc Titinger
PID PPID USER STAT VSZ %VSZ %CPU COMMAND 144 2 root DW 0 0% 33% [ina226:1-8800us] 141 2 root DW 0 0% 25% [ina226:0-8800us] 40 2 root SW 0 0% 15% [irq/156-4802a00] 147 2 root DW 0 0% 7% [ina226:2-8800us] 145 1 root S 1236 0% 6% dd if /dev/iio:device1 of /dev/null 148 1 root S 1236 0% 4% dd if /dev/iio:device2 of /dev/null 149 137 root R 1244 0% 3% top -d 1 142 1 root S 1236 0% 2% dd if /dev/iio:device0 of /dev/null Signed-off-by: Marc Titinger <mtitinger@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-12iio: ina2xx: re-instate a sysfs show/store for the shunt resistor valueMarc Titinger
Different probe modules use different resistor values. The front-end application may read a probe ID (from eeprom) and set the shunt value accordingly. Signed-off-by: Marc Titinger <mtitinger@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-12iio: ina2xx: provide a sysfs parameter to allow async readout of the ADCsMarc Titinger
This can lead to repeated or skipped samples depending on the clock beat between the capture thread and the chip sampling clock, but will also spare reading/waiting for the Capture Ready Flag and improve the available i2c bandwidth for reading measurements. Output of iio_info: ...snip... 4 device-specific attributes found: attr 0: in_oversampling_ratio value: 4 attr 1: in_allow_async_readout value: 0 attr 2: integration_time_available value: 140 204 332 588 1100 2116... attr 3: in_sampling_frequency value: 114 Signed-off-by: Marc Titinger <mtitinger@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-12iio: ina2xx: add support for TI INA2xx Power MonitorsMarc Titinger
in SOFTWARE buffer mode, a kthread will capture the active scan_elements into a kfifo, then compute the remaining time until the next capture tick and do an active wait (udelay). This will produce a stream of up to fours channels plus a 64bits timestamps (ns). Tested with ina226, on BeagleBoneBlack. Datasheet: http://www.ti.com/lit/gpn/ina226 Signed-off-by: Marc Titinger <mtitinger@baylibre.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>