summaryrefslogtreecommitdiff
path: root/drivers/iio/light
AgeCommit message (Collapse)Author
2016-07-03drivers:iio:light:isl29125: added macros for sensing rangeBijosh Thykkoottathil
Added macros for sensing range as the corresponding magic numbers were used at multiple places. - ISL29125_SENSING_RANGE_0 for 375 lux full range - ISL29125_SENSING_RANGE_1 for 10k lux full range Signed-off-by: Bijosh Thykkoottathil <bijosh.t@hotmail.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-06-29Merge tag 'iio-for-4.8b' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: Second round of new iio device support, features and cleanups in the 4.8 cycle Firstly some contact detail updates: * NXP took over freescale. Update the mma8452 header to reflect this. * Martin Kepplinger email address change in mma8452 header. * Adriana Reus has changed email address. Update .mailmap. * Matt Ranostay has changed email address. Update .mailmap. New Device Support * max1363 - add the missing i2c_device_ids for a couple of parts so they can actually be used. * ms5867 - add device ids for ms5805 and ms5837 parts. New Features * ad5755 - DT support. This one was a bit controversial and under review for a long time. Still no one could come up with a better solution. * stx104 - add gpio support * ti-adc081c - Add ACPI device ID matching. Core changes * Refuse to register triggers with duplicate names. There is no way to distinguish between them so this makes no sense. A few drivers do not generate unique names for each instance of the device present. We can't fix this without changing ABI so leave them and wait for someone to actually take the rare step of two identical accelerometers on the same board. * buffer-dma - use ARRAY_SIZE in a few appropriate locations. Tools * Fix the fact that the --trigger-num option in generic_buffer didn't allow 0 which is perfectly valid in the ABI. Cleanups * as3935 - improve error reporting. - remove redundant zeroing of a field in iio_priv. * gp2ap020a00f - use the iio_device_claim_*_mode helpers rather than open coding locking around mode changes. * isl29125 - use the iio_device_claim_*_mode helpers rather than open coding locking. * lidar - use the iio_device_claim_*_mode helpers rather than open coding locking. * mma8452 - more detail in devices supported description in comments (addresses and similar) * sca3000 - add a missing error check. * tcs3414 - use the iio_device_claim_*_mode helpers rather than open coding locking. * tcs3472 - use the iio_device_claim_*_mode helpers rather than open coding locking.
2016-06-20Merge 4.7-rc4 into staging-nextGreg Kroah-Hartman
We want the fixes in here, and we can resolve a merge issue in drivers/iio/industrialio-trigger.c Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-06-11iio: light: gp2ap020a00f: use iio helper function to lock direct modeAlison Schofield
Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. Includes a tiny bit of refactoring (single case -> if) and simplified return flow. Also prevents a theoretical race condition by effectively taking the lock a little earlier than before. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: Daniel Baluta <daniel.baluta@gmail.com> Acked-by: Jacek Anaszewski <j.anaszewski@samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-11iio: light: isl29125: use iio helper function to guarantee direct modeAlison Schofield
Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. This allows removal of an unused lock in the device private global data. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: Daniel Baluta <daniel.baluta@gmail.com> Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-11iio: light: tcs3472: use iio helper function to guarantee direct modeAlison Schofield
Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. This allows removal of an unused lock in the device private global data. Also prevents a previous race condition when a buffer is enabled whilst a raw read is going on. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: Daniel Baluta <daniel.baluta@gmail.com> Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-11iio: light: tcs3414: use iio helper function to guarantee direct modeAlison Schofield
Replace the code that guarantees the device stays in direct mode with iio_device_claim_direct_mode() which does same. This allows removal of an unused lock in the device private global data. Also prevents a possible race around a buffer being enabled whilst a read is going on. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: Daniel Baluta <daniel.baluta@gmail.com> Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-06-09Merge tag 'iio-for-4.8a' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: First round of IIO new device support, features and cleanups for the 4.8 cycle. New device support * ads1015 - add ads1115 support * bma220 accelerometer - new driver - triggered buffer support. * bmc150 - add bmm150 support. * bmp280 - bme280 support with addition of humidity channel. * max5487 potentiometer - new driver * MMA7660FC accelerometer. - New driver * st-pressure - support for the lps22hb * loop trigger. - This one is *nasty* but we have real applications (parrot drones) where it is useful. The trigger basically spins as hard as it can firing off a new trigger each time all triggered devices come back to say they are done. It doesn't hang a machine even when doing it on a dummy driver. A lot nicer than having this implemented within lots of device drivers anyway. Core stuff * Add support to create IIO devices via configfs (similar to we did for triggers a while back) + docs. * New channel types - IIO_ELECTRICAL_CONDUCTIVITY * Couple of MAINTAINERS patches to list the device tree bindings. * Make trigger ops structure non optional (comment fix). It hasn't been for an awful long time, but that's not what the description said. New features * ak8975 - support adapters that are limited to byte data only by allowing the emulated block read i2c function that was recently introduced. * atlas-ph - support atlas-ec (electrical conductivity sensor) * bmi160 - add available frequency and scale attributes to make the driver more user friendly (and avoid having to read the datasheet to know what will work). * dummy - move creation to configfs interface. It's not real hardware so we are not that worried about the ABI breakage ;) * mma8452 - oversampling ration support * nau7802 - expose available gains to make life easier for userspace. * st-sensors - allow use of emulation for SMBus block reads as all the st parts support it. * ti-ads1015 - list datasheet names to allow their use by inkernel consumers. * Various module alias additions to help auto probing. Drop one redundant one as well. Cleanups * ad7266, ad7476, ad7887, ad7923, ad799x - use direct mode claim function rather than open coding it during sensor read (prevents switching on buffers mid read). * ad7793, ad7791 - use direct mode claim to prevent frequency changes when buffers running. * afe440x - These are ABI breaking but the driver requires custom userspace code to do anything useful anyway and that is still being written and under control of TI. Ultimately we may have other libraries to do pulse oximetry with these devices but we aren't aware of any yet. - kernel-doc format fixes - drop ifdef fun around of_match_ptr - it's not worth the mess to save a tiny amount of space. - drop some unnecessary register initializations. - drop the weird locked gain modes as they gain us nothing (can just set all gains separately). - remove handling of offset attributes seeing as no channels actually have them (oops) - Drop the LED3 input channel as it's an alias for ALED2. - *big one* remove channel names - an experiment that turned out to not make sense - see patch for details. - use regmap fields to clean up code. - tie the tia gain stages to appropriate channels in the ABI as that is what they really effect. Same with the LED currents. - cleanout some unused defines and fix a missnamed one. * atlas-ph - reorganise to allow support of other similar parts. * bmc150 - document supported chips in kconfig help. * jsa1212 - drop an unneeded i2c functionality check for functionality the driver doesn't use. * mxs-lradc - simply touch screen registration code. - remove the touch screen unregister as all devm based now. - disable only those channels that are masked in hardware stop (others are already dealt with elsewhere) * st-sensors - unexport st_sensors_get_buffer_element as nothing outside the st-sensors core driver uses it. - fix handling of failure to start up regulators. * tpl0102 - drop an i2c functionality test for features that aren't needed. * ti-am335x - use variable name rather than type in sizeof for clarity. - use SIMPLE_DEV_PM_OPS helper macro to tidy up a bit. Tools * Add install / uninstall to makefile. Someone cares, so presumably some people will find it useful! * generic_buffer - rename to iio_generic_buffer to line up with other tools. - handle cleanup when receiving signals - Add a --device-num option and a --trigger-num option rather than relying on naming which doesn't work if you have two of the same part.
2016-06-03iio: light apds9960: Add the missing dev.parentYong Li
Without this, the iio:deviceX is missing in the /sys/bus/i2c/devices/0-0039 Some userspace tools use this path to identify a specific instance of the device. Signed-off-by: Yong Li <sdliyong@gmail.com> Reviewed-By: Matt Ranostay <mranostay@gmail.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-29iio: light: bh1780: assign a static nameLinus Walleij
Using the struct i2c_device->id field for naming the light sensor is a bad idea: when booting from the pure device tree this is NULL and that causes the device not to have the "name" property in sysfs and that in turn confuses the "lsiio" command to stop listing devices. So instead of using the device .id, use the hard string "bh1780", which works just fine. Fixes: 1f0477f18306 ("iio: light: new driver for the ROHM BH1780") Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-29iio: bh1780: dereference the client properlyLinus Walleij
The code in runtime_[suspend|resume] was assuming that the i2c client data was the bh1780 state container, but it contains the IIO device. So first dereference the IIO device from the i2c client, then get the state container using the iio_priv() call. Fixes: 1f0477f18306 ("iio: light: new driver for the ROHM BH1780") Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-21max44000: Remove scale from proximityCrestez Dan Leonard
This is not implemented and doesn't really make sense because IIO proximity is unit-less. Remove IIO_CHAN_INFO_SCALE from info_mask because so that the _scale sysfs entry won't appear. This fixes userspace tools like generic_buffer which abort when reads returns an error. Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-21iio: light: jsa1212: remove unneeded i2c check functionality testAlison Schofield
This driver does not call i2c_smbus_read|write_byte_data(), so remove the corresponding functionality test. It uses regmap to handle byte transfers transparently. Signed-off-by: Alison Schofield <amsfield22@gmail.com> Reviewed-by:Kuppuswamy Sathyanarayanan <sathyanarayanan.kuppuswamy@linux.intel.com> Reviewed-by: Matt Ranostay <matt.ranostay@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-05-04iio: light: bh1780: return after writeLinus Walleij
When writing a value using direct reg access from debugfs we need to return and not fall through to reading the value, lest we'll dereference a NULL pointer. Cc: Dan Carpenter <dan.carpenter@oracle.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-26Merge tag 'iio-for-4.7b' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-testing Jonathan writes: 2nd set of new device support, features and cleanup for IIO in the 4.7 cycle. Bit of a bumper set for new drivers but plenty of other stuff here as well! New device support * ad5592R ADC/DAC - new driver supporting ad5592r and ad5593r combined ADC/DAC and gpio chips. * Aosong am2315 relative humidity - new driver with triggered buffer support in follow up patch. * bmi160 imu - new driver * bmp280 - bmp180 support - note there is support in the misc/bmp085 driver. Intent is to remove that driver long term. * invensense mpu6050 - cleanup leading to explicit support of mpu9150 with a good few cleanups along the way. * Hope RF hp03 pressure and temperature sensor. - new driver * maxim DS1803 potentiometer - new driver * maxim max44000 light and proximity sensor - new driver built in a series of steps to support pretty much everything. * ROHM BH1780 light sensor - new driver. There is an existing driver in misc that this is pretty much intended to replace. The discussion on whether to support the non standard interface of that driver is some way is continuing. * st-gyro - lsm9ds0-gyro. The accel/magn side of this will take a while longer as extensions to the st library are needed for cases where two types of sensor share a single i2c address. * ti-adc081c - support the adc101c and adc121c * Vishay VEML6070 UV sensor - new driver. New features * core - devm_ APIs for channel_get and channel_get_all. The first user of these is the generic ADC based thermal driver. As it is going through the thermal tree these will be picked up as a patch to that next cycle as that is how the author preferred to do it. - mounting matrix support. This new core support allows devices to provide to userspace (typically from the device tree) allowing compensation for how the sensor is mounted on the device. First examples are on UAVs but it has a more mundane use on typical phone where the chip may be on the front or the back of the circuit board and soldered at any angle. Includes support for this ABI in ak8975 (which has an older interface, now deprecated) and mpu6050. * tools - add a -a option to enable all available channels in generic_buffer sample. Makes it somewhat easier to use. * adis library and drivers - support manual self test flag clearing. This has technically been broken for a very long time - result is an offset on readings as the applied field is on all the time. * ak8975 - triggered buffer support * bmc150 - spi support (including splitting the driver into core and i2c parts) * bmp280 - oversampling support. * dht11 - improved logging - useful to debug timing issues on this quirky device. * st-sensors - read each channel invidivually as not all support the optimization of reading in bulk. This is technically a fix, but will need to be backported if desired. - support open drain and shared interrupts. * ti-adc081c - triggered buffer support. Cleanups * inkern - white space fix. * ad7606 - use the iio_device_claim_direct_mode call rather than open coding equiv. * ad799x - white space fix. * ad9523 - unsigned -> unsigned int * apds9660 - brace location tidying up. - silence an uninitialized variable warning. * ak8975 - else and brace on same line fix. * at91_adc - white space fixes. * bmc150 - use regmap stored copy of the device pointer rather than having an additional copy. * bmg160 - use regmap stored copy of the device pointer rather than having an additional copy. * hid-sensors - white space fixes. * mcp3422 - white space fix. * mma7455 - use regmap to retrieve the device struct rather than carrying another copy in the private data. * ms_sensors - white space fix. * mxs-lradc - move current bindings out of staging - some will be shortly deprecated but the reality is that we have device trees out there using them so they will need to be supported for some time. They accidentally got left behind when the driver graduated from staging. - white space cleanup. - set INPUT_PROP_DIRECT. - move ts config into a better function. - move the STMP reset out of the ADC init. * vf610_adc - case label indenting fix.
2016-04-24max44000: Initial triggered buffer supportCrestez Dan Leonard
Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-24max44000: Expose ambient sensor scalingCrestez Dan Leonard
This patch exposes ALSTIM as illuminance_integration_time and ALSPGA as illuminance_scale. Changing ALSTIM also changes the number of bits available in the data register. This is handled inside raw value reading because: * It's very easy to shift a few bits * It allows SCALE and INT_TIME to be completely independent controls * Buffer support requires constant scan_type.realbits per-channel Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-24max44000: Support controlling LED current outputCrestez Dan Leonard
This is exposed as an output channel with "led" as an extend_name. Other sensors also have support for controlling an external LED. It's not clear that simply exposing an undecorated output channel is the correct approach. Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-24max44000: Initial support for proximity readingCrestez Dan Leonard
The proximity sensor relies on sending pulses to an external IR led and it is disabled by default on powerup. The driver will enable it with a default power setting. Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-24max44000: Initial supportCrestez Dan Leonard
This just adds support for reporting illuminance with default settings. Important default registers are written on probe because the device otherwise lacks a reset function. Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-23iio: light: apds9960: silence uninitialized variable warningDan Carpenter
It causes a static checker warning if we use "buf" on the failure path so move that inside the if statement. Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-19iio: Add Vishay VEML6070 UV A light sensor driverPeter Meerwald-Stadler
ultraviolet (UV) light sensor with I2C interface with a peak sensitivity at 355 nm strangely, chip uses two addresses 0x38 and 0x39 for LSB and MSB data, resp. datasheet: http://www.vishay.com/docs/84277/veml6070.pdf Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-16iio: light: new driver for the ROHM BH1780Linus Walleij
This is a reimplementation of the old misc device driver for the ROHM BH1780 ambient light sensor (drivers/misc/bh1780gli.c). Differences from the old driver: - Uses the IIO framework - Uses runtime PM to idle the hardware after 5 seconds - No weird custom power management from userspace - No homebrewn values in sysfs This uses the same (undocumented) device tree compatible-string as the old driver ("rohm,bh1780gli"). Cc: Arnd Bergmann <arnd@arndb.de> Cc: Ulf Hansson <ulf.hansson@linaro.org> Cc: Daniel Mack <daniel@caiaq.de> Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-16iio: light apds9960: fix wrong use of braceSlawomir Stepien
This fixes the error reported by checkpatch.pl: ERROR: that open brace { should be on the previous line Signed-off-by: Slawomir Stepien <sst@poczta.fm> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-04-11Merge 4.6-rc3 into staging-nextGreg Kroah-Hartman
This resolves a lot of merge issues with PAGE_CACHE_* changes, and an iio driver merge issue. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-04-04Merge tag 'iio-fixes-for-4.6a' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into usb-linus Jonathan writes: First round of IIO fixes for the 4.6 cycle. Again I've ended up with two early fix sets, depending on whether they are dependent on elements of the merge window or simply came in after I had patches with that dependency already, vs older fixes that were just too late for the last cycle. This first set is for the older ones. - max1353 * Add a missing adc to max1363_id - the driver has supported the max11644-11647 for a while, but as they weren't in the id table there was no way of actually initializing it. * Fix a wrong reference voltage for the above models. Given you couldn't initialize the driver for these parts without patching, no one noticed that the reference voltage used in computing the scaling was wrong. - apds9960 * The fifo last enelement was read twice (and hence pushed out twice) due to a small logic bug.
2016-04-03iio: remove unused gpio consumer.h includeIrina Tirdea
GPIO handling code has been removed from the drivers (since this is now handled by the ACPI core) in commit 0f0796509c07 ("iio: remove gpio interrupt probing from drivers that use a single interrupt"). Remove the include for linux/gpio/consumer.h since it is no longer used. Signed-off-by: Irina Tirdea <irina.tirdea@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-03-20iio: light: tsl2563: Remove flush_scheduled_workAmitoj Kaur Chawla
flush_scheduled_work is scheduled for deprecation. Replace cancel_delayed_work and flush_scheduled_work with cancel_delayed_work_sync instead to ensure there is no pending or running work item. Since there is only one work item, chip->poweroff_work, there are no further dependencies of flush_scheduled_work(). Acked-by: Tejun Heo <tj@kernel.org> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-03-20iio: light: apds9960: correct FIFO check conditionMatt Ranostay
Correct issue that the last entry in FIFO was being read twice due to an incorrect decrement of entry count variable before condition check. Signed-off-by: Matt Ranostay <mranostay@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-02-27iio: convert to common i2c_check_functionality() return valueMatt Ranostay
Previously most drivers that used a i2c_check_functionality() check condition required various error codes on failure. This patchset converts to a standard of -EOPNOTSUPP Signed-off-by: Matt Ranostay <mranostay@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-02-08Merge 4.5-rc3 into staging-nextGreg Kroah-Hartman
We want the upstream staging fixes in here as well. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2016-02-01Merge tag 'iio-fixes-for-4.5a' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus Jonathan writes: First set of IIO fixes for the 4.5 cycle. This set comprises those not dependent on patches in the 4.5 merge cycle. A second set will follow shortly with ones that are. * core in kernel interfaces - fix a possible NULL dereference that is a theoretical possibility via odd usage of iio_channel_release. Pretty much a hardening of the interface, but observed in the wild with the twl4030_charger driver. * acpi-als - report the data as processed as it is in lux. This fixes a wrong use of the IIO ABI. However, old _raw version retained to avoid breaking any userspace in the wild that is relying on that (none known but it doesn't hurt us much to retain it) * ade7753 - fix some error handling to avoid use of unitialized data. * ltr501 - use a signed return type for ltr501_match_samp_freq so as to allow returning of an error code. * mcp4725 - set name field of struct iio_dev to ensure the sysfs name attribute doesn't give NULL. * mpl115 - temperature offset sign is wrong. * stk8ba50 - IIO_TRIGGER dependency added * ti_am335x_adc - Label buffer as a software buffer. It's actually a hybrid of a true hardware buffer feeding a kfifo, but the meaning of these fields has changed a little recently and in this case it should be labeled a software buffer ensure it is allowed to use the kfifo. * vf610_adc - HAS_IOMEM dependency
2016-01-30iio: light: opt3001: enable operation w/o IRQAlexander Koch
Enable operation of the TI OPT3001 light sensor without having an interrupt line available to connect the INT pin to. In this operation mode, we issue a conversion request and simply wait for the conversion time available as timeout value, determined from integration time configuration and the worst-case time given in the data sheet (sect. 6.5, table on p. 5): short integration time (100ms): 110ms + 3ms = 113ms long integration time (800ms): 880ms + 3ms = 883ms This change is transparent as behaviour defaults to using the interrupt method if an interrupt no. is configured via device tree. Interrupt-less operation mode is performed when no valid interrupt no. is given. Signed-off-by: Alexander Koch <mail@alexanderkoch.net> Signed-off-by: Michael Hornung <mhornung.linux@gmail.com> Tested-by: Andreas Dannenberg <dannenberg@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-30iio: light: opt3001: trivial type refactoringAlexander Koch
Change variable type of struct opt3001 members 'ok_to_ignore_lock' and 'result_ready' uint16-bitfield of length one to bool. They are used as bool, let the compiler do the optimization. Signed-off-by: Alexander Koch <mail@alexanderkoch.net> Signed-off-by: Michael Hornung <mhornung.linux@gmail.com> Tested-by: Andreas Dannenberg <dannenberg@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-30iio: light: opt3001: extract int. time constantsAlexander Koch
Extract integration times as #define constants. This prepares using them for delay/timeout length determination. Signed-off-by: Alexander Koch <mail@alexanderkoch.net> Signed-off-by: Michael Hornung <mhornung.linux@gmail.com> Tested-by: Andreas Dannenberg <dannenberg@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-01-16iio: light: acpi-als: Report data as processedGabriele Mazzotta
As per the ACPI specification (Revision 5.0) [1], the data coming from the sensor represent the ambient light illuminance reading expressed in lux. So use IIO_CHAN_INFO_PROCESSED to signify that the data are pre-processed. However, to keep backward ABI compatibility, the IIO_CHAN_INFO_RAW bit is not removed. [1] http://www.acpi.info/DOWNLOADS/ACPIspec50.pdf This issue has also been responsible for at least one userspace bug report hence marking what is a small semantic fix really for stable. [2] https://github.com/hadess/iio-sensor-proxy/issues/46 Signed-off-by: Gabriele Mazzotta <gabriele.mzt@gmail.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-27Merge tag 'iio-for-4.5c' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: Third set of new stuff for IIO in the 4.5 cycle. New driver features - us5182 * Add interrupt support and rising / falling threshold events. Cleanups / fixes to new stuff / minor additions * Expose the IIO value formatting function for drivers to make use of internally. - ina2xx * Fix wrong channel order * Fix incorrect reporting of endianness * Adding documentation of ABI unique to this device - mma8452 * Drop an unused register description * Use an enum for the channel index to aid readability - sca3000 * Use standard NULL comparison style - us5182 * fix an inconsistency in status of enable (a bug with no real effect until above patches are applied) * refactor the read_raw function to improve maintainability / readability.
2015-12-27Merge tag 'iio-for-4.5b' of ↵Greg Kroah-Hartman
git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next Jonathan writes: Second set of IIO new drivers, functionality and cleanups for the 4.5 cycle. The big one here is the configfs support which has been a long time in the works but should allow for cleaner ways to do instantiation of those elements of IIO that aren't directly connected to specific hardware. Lots of cool new stuff we can use this for in the works! New core stuff (basically all configfs support related) * Configfs support - Core support (was waiting for a configfs patch that went in around 4.4rc2) - A little fixlet to add a configfs.h to contain a reference to the configfs_subsystem structure. * Some infrastructure to simplify handling of software based triggers (i.e. ones with no actual hardware associated with them) * A high resolution timer based trigger. This has been around for years but until the configfs support was ready we didn't have a sensible way of instantiating instances of it (the method used for the sysfs_trigger has never been really satisfactory) New Device Support * AMS iAQ Volatile Organic Compounds sensor support. * Freescale imx7d ADC driver * Maxim MAX30100 oximeter driver (note that for these devices most of the smart stuff will be in userspace - effectively they are just light sensors with some interesting led synchronization as far as the kernel is concerned). * Microchip mcp3421 support added to the mcp3422 driver. * TI adc124s021 support added to the adc128s052 driver. * TI ina219, inda226 power monitors. Note that there is an existing hwmon driver for these parts, the usecase is somewhat different so it is unclear at this point if the hwmon driver will eventually be replaced by a bridge from this driver. In the meantime the Kconfig dependencies should prevent both from being built. New driver functionality * us8152d power management support. Cleanups, fixups * Use list_for_each_entry_safe instead of list_for_each_safe with the entry bit coded longhand. * Select IRQ_WORK for IIO_DUMMY_EVGEN. This is a fix that somehow got lost when the driver was moved so lets do it again. * st-accel - drop an unused define. * vz89x, lidar - optimize i2c transactions by using a single i2c tranfers instead of multiple calls where supported (fall back to smbus calls as before if not). * Use dev_get_platdata() in staging drivers: tsl2x7x, adcs and frequency drivers instead of direct access to the structure element.
2015-12-22iio: light: us5182d: Refactor read_raw functionAdriana Reus
A bit of refactoring for better readability. Moved and slightly reorganized all the activity necessary for reading als and proximity into a different function. This way the switch in read raw becomes clearer and more compact. Signed-off-by: Adriana Reus <adriana.reus@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-22iio: light: us5182d: Add interrupt support and eventsAdriana Reus
Add interrupt support for proximity. Add two threshold events to signal rising and falling directions. Signed-off-by: Adriana Reus <adriana.reus@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-22iio: light: us5182d: Fix enable status inconcistencyAdriana Reus
When setting als only or proximity only modes make sure that we mark the other component as disabled. This fix is in preparation of adding event support because that will make it possible to switch between one-shot and continuous modes and not tracking these correctly may cause faulty behaviour (e.g wrongfully considering px enabled and not setting an appropriate mode in the chip). Signed-off-by: Adriana Reus <adriana.reus@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-19iio-light: Use a signed return type for ltr501_match_samp_freq()Markus Elfring
The return type "unsigned int" was used by the ltr501_match_samp_freq() function despite of the aspect that it will eventually return a negative error code. Improve this implementation detail by deletion of the type modifier then. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-14Merge 4.4-rc5 into staging-nextGreg Kroah-Hartman
We want those fixes in here for testing. Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-12-02iio: light: us8152d: Add power management supportAdriana Reus
Add power management for sleep as well as runtime pm. Signed-off-by: Adriana Reus <adriana.reus@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-02iio: light: us5182d: Add functions for selectively enabling als and proximityAdriana Reus
Keep track of the als and px enabled/disabled status in order to enable them selectively. Signed-off-by: Adriana Reus <adriana.reus@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-12-02iio: light: us5182d: Add property for choosing default power modeAdriana Reus
This chip supports two power modes. 1. "one-shot" mode - the chip activates and executes one complete conversion loop and then shuts itself down. This is the default mode chosen for raw reads. 2. "continuous" mode - the chip takes continuous measurements. Continuous mode is more expensive power-wise but may be more reliable. Add a property so that if preferred, the default power mode for raw reads can be set to continuous. Separate one-shot enabling in a separate function that will be used depending on the chosen power mode. Also create a function for powering the chip on and off. Signed-off-by: Adriana Reus <adriana.reus@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-11-21iio: light: apds9960: correct ->last_busy countMatt Ranostay
Add missing pm_runtime_mark_last_busy to apds9960_set_power_state function. Unless pm_runtime_mark_last_busy is called the pm_runtime_put_autosuspend may put the device into suspend before the delay time requested. Signed-off-by: Matt Ranostay <mranostay@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-11-08iio: Reconcile operation order between iio_register/unregister and pm functionsAdriana Reus
At probe, runtime pm should be setup before registering the sysfs interface so that all the power attributes are accurate and functional when registering. Also, when removing the device we should unregister first to make sure that the interfaces that may result in wakeups are no longer available. Fix this behaviour for the following drivers: bmc150, bmg160, kmx61, kxcj-1013, mma9551, mma9553, rpr0521. Signed-off-by: Adriana Reus <adriana.reus@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-11-08iio: light: pa12203001: Poweroff chip if register failsAdriana Reus
Make sure we poweroff the chip if for any reason iio_register returns an error. Signed-off-by: Adriana Reus <adriana.reus@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>