Matt Ranostay [Mon, 6 Jun 2016 03:37:57 +0000 (20:37 -0700)]
mailmap: update Matt Ranostay email address
Set current email address to replace previous employers email addresses.
Cc: Jonathan Cameron <jic23@kernel.org> Cc: Daniel Baluta <daniel.baluta@intel.com> Cc: linux-iio@vger.kernel.org Signed-off-by: Matt Ranostay <mranostay@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: light: gp2ap020a00f: use iio helper function to lock direct mode
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>
iio: light: isl29125: use iio helper function to guarantee direct mode
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>
iio: light: tcs3472: use iio helper function to guarantee direct mode
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>
iio: light: tcs3414: use iio helper function to guarantee direct mode
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>
This patch is in response to that of
Gregor Boirie <gregor.boirie@parrot.com>
who proposed using a tight kthread within a device driver (be it with the
support factored out into a helper library) in order to basically spin as
fast as possible.
It is meant as a talking point rather than a formal proposal of the code
(though we are heading towards that I think).
Also gives people some working code to mess around with.
I proposed that this could be done with a trigger with a few constraints
and this is the proof (be it ugly) of that.
There are some constraints though, some of which we would want to relax
if this were to move forward.
* Will only run the thread part of the registered pollfunc. This is to
avoid the overhead of jumping in and out of interrupt context. Is the
overhead significant? Not certain but feels like it should be!
* This limitation precludes any device that 'must' do some work in
interrupt context. However, that is true of few if any drivers and
I suspect that any that do will be restricted to using triggers they
provide themselves. Usually we have a top half mainly to grab a
timestamp as soon after the dataready type signal as possible.
Signed-off-by: Jonathan Cameron <jic23@kernel.org> Acked-by: Daniel Baluta <daniel.baluta@intel.com>
iio: adc: ad7791: claim direct mode when writing frequency
Driver was checking for direct mode and trying to lock it, but
left a gap where mode could change before the desired operation.
Use iio_device_claim_direct_mode() to guarantee device stays in
direct mode.
Refactor function to clarify look-up followed by lock sequence.
Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: Daniel Baluta <daniel.baluta@gmail.com> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: adc: ad7793: claim direct mode when writing frequency
Driver was checking for direct mode and trying to lock it, but
left a gap where mode could change before the desired operation.
Use iio_device_claim_direct_mode() to guarantee device stays in
direct mode.
Refactor function to clarify look-up followed by lock sequence.
Signed-off-by: Alison Schofield <amsfield22@gmail.com> Cc: Daniel Baluta <daniel.baluta@gmail.com> Acked-by: Lars-Peter Clausen <lars@metafoo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: iio_generic_buffer: Cleanup when receiving signals
This will clean (disable buffer/trigger/channels) when doing
something like a CTRL-C. Otherwise restarting generic_buffer requires a
manual echo 0 > buffer/enable
This also cleanup up all the code freeing string buffers at
the end of main. We initialize all pointers to NULL so that cleanup can
all be done under a single error label.
Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Jonathan Cameron [Sat, 14 May 2016 17:42:08 +0000 (18:42 +0100)]
iio: triggers: Make trigger ops structure explicitly non optional.
This structure has not been optional for a long time (if ever) but the
code implies that it is. As we then use it later in a fashion that would
crash if it was in fact NULL, it's inconsistent so fix it up by removing
unnecessary checks.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Matt Ranostay [Tue, 17 May 2016 22:02:03 +0000 (15:02 -0700)]
iio: adc: ti-ads1015: add datasheet names
Add datasheet names for ADC channels to allow iio consumers access.
Signed-off-by: Matt Ranostay <matt.ranostay@intel.com> Acked-by: Daniel Baluta <daniel.baluta@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Alison Schofield [Sun, 15 May 2016 18:37:27 +0000 (11:37 -0700)]
iio: light: jsa1212: remove unneeded i2c check functionality test
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>
Quentin Schulz [Wed, 18 May 2016 15:16:18 +0000 (17:16 +0200)]
iio: adc: nau7802: Expose possible gains in sysfs
The Nuvoton NAU7802 ADC is able to adjust its gain but prior knowledge of
its possible values was required to adjust it. Users had to guess the
possible gain values based on the ADC datasheet or on this driver's code.
This exposes the possible values in the in_voltage_scale_available file of
each nau7802 ADC device. The gain is set for the whole ADC and is therefore
not configurable by channel. Thus, there exists only one
in_voltage_scale_available file for each nau7802 ADC device even if it has
two separate channels.
The I2C drivers have an i2c_device_id array but that information isn't
exported to the modules using the MODULE_DEVICE_TABLE() macro. So the
modules autoloading won't work if the I2C device is registered using
OF or legacy board files due missing alias information in the modules.
The issue was found using Kieran Bingham's coccinelle semantic patch:
https://lkml.org/lkml/2016/5/10/520
Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Matt Ranostay [Mon, 16 May 2016 05:18:46 +0000 (22:18 -0700)]
iio: adc: ti-ads1015: add support for ADS1115 part
TI ADS1115 is a 16-bit resolution ADC that is register map
compatible with the ADS1015 device.
Signed-off-by: Matt Ranostay <matt.ranostay@intel.com> Acked-by: Daniel Baluta <daniel.baluta@intel.com> Acked-by: Crt Mori <cmo@melexis.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Internally, the device knows about 4 different power modes that differ
in oversampling ratio (and power consumption). We just show the user
what oversampling ratio(s) is/are available, depending on the current
frequency.
The referenced table in the datasheets makes it easier to understand.
Signed-off-by: Martin Kepplinger <martink@posteo.de> Signed-off-by: Christoph Muellner <christoph.muellner@theobroma-systems.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Andrew F. Davis [Sun, 1 May 2016 20:37:02 +0000 (15:37 -0500)]
iio: health/afe440x: Remove unused definitions
These definitions are not currently used and if the functionality
they represent is needed the values should be added back to a table
for easy userspace use.
Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Andrew F. Davis [Sun, 1 May 2016 20:37:00 +0000 (15:37 -0500)]
iio: health/afe440x: Make gain settings a modifier for the stages
Currently the TIA gain settings are exported to userspace as sysfs
entries that do not clearly represent their internal relation to the
sampling stages. The gain settings are enabled on a per-stage basis,
this can be seen in figure 24 of the current AFE4404 datasheet.
These gain settings should therefore be tied to the channels that are
read during these stages. Make this change here.
Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Andrew F. Davis [Sun, 1 May 2016 20:36:58 +0000 (15:36 -0500)]
iio: health/afe440x: Remove channel names
These AFEs have 4 ADC mesuring stages (called LED2, ALED2, LED1, and
ALED1 in the datasheet), we map these as channels, these stages can serve
different purposes depending on the application. For instance the AFE4404
has an additional LED (LED3), this LED can be timed to be active during
stage 2 (or anystage, but the datasheet describes this case and the name
of the stage reflects this use). This ability is used further in upcoming
parts that tie the front-end gain and the LED timings together. For these
reasons we remove explicit naming the channels.
Without channel names it is best that the index numbers are in order to
match the stage number, reorder the channel numbers.
Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Andrew F. Davis [Sun, 1 May 2016 20:36:54 +0000 (15:36 -0500)]
iio: health/afe440x: Always use separate gain values
Locking the two gain stages to the same setting adds no value for us,
so initialize them as unlocked and remove the sysfs for unlocking them.
This also allows us to greatly simplify showing and setting the gain
registers.
Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Andrew F. Davis [Sun, 1 May 2016 20:36:53 +0000 (15:36 -0500)]
iio: health/afe440x: Remove unneeded initializers
The drivers set some register values during initialization that can be
set at runtime, these defaults were used in testing but are not
necessary, remove these.
Signed-off-by: Andrew F. Davis <afd@ti.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Stefan Wahren [Sat, 23 Apr 2016 19:57:59 +0000 (19:57 +0000)]
iio: mxs-lradc: disable only masked channels in mxs_lradc_hw_stop
Disabling of the touchscreen IRQs should be done in
mxs_lradc_disable_ts. So disable only the masked virtual channels
in mxs_lradc_hw_stop and finally remove the unused function
mxs_lradc_irq_en_mask.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Reviewed-by: Marek Vasut <marex@denx.de> Tested-by: Marek Vasut <marex@denx.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Stefan Wahren [Sat, 23 Apr 2016 19:57:58 +0000 (19:57 +0000)]
iio: mxs-lradc: remove mxs_lradc_ts_unregister
After using devm_input_allocate_device for registration
the function mxs_lradc_ts_unregister isn't necessary anymore
since mxs_lradc_ts_close already does the job.
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Suggested-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Minimal implementation of an IIO driver for the Freescale
MMA7660FC 3-axis accelerometer. Datasheet:
http://www.nxp.com/files/sensors/doc/data_sheet/MMA7660FC.pdf
Includes:
- ACPI support;
- read_raw for x,y,z axes;
- reading and setting the scale (range) parameter.
- power management
Signed-off-by: Constantin Musca <constantin.musca@intel.com> Reviewed-by: Martin Klepplinger <martink@posteo.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: ak8975: Support adapters limited to BYTE_DATA
The device has simple 8-bit registers but the driver incorrectly uses
block or word reads without checking functionality bits.
Fix by using i2c_smbus_read_i2c_block_data_or_emulated instead of
i2c_smbus_read_i2c_block_data or i2c_smbus_read_word_data. This will
check functionality bits and use the fastest available transfer method.
Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: inv_mpu6050: Add explicit support for MPU9150
This device is a package containing a MPU6050-like sensor and an AK8975
magnetometer. The magnetometer component is supported by the existing
ak8975 driver.
This patch also rephrases the Kconfig descriptions.
Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Acked-by: Ge Gao <ggao@invensense.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: inv_mpu6050: Add spi_device_id for INV_MPU6500
Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Acked-by: Ge Gao <ggao@invensense.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: inv_mpu6050: Check WHO_AM_I register on probe
This can be used to distinguish mpu6500. This is a warning rather than
an error because the differences are mostly irrelevant and it's nice to
avoid breaking users with slightly incorrect ACPI/DT.
Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Acked-by: Ge Gao <ggao@invensense.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
The hw_info array was indexed by enum inv_devices chip_type despite the
fact that the enumeration had more members than the array and was
ordered differently.
The patch cleans this up and adds explicit chip_types to i2c/spi/acpi
IDs. It also adds some stricter checks inside the driver core.
This happened to work so far because the differences between the
supported models are very minor.
Signed-off-by: Crestez Dan Leonard <leonard.crestez@intel.com> Acked-by: Ge Gao <ggao@invensense.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Akinobu Mita [Sun, 24 Apr 2016 13:52:10 +0000 (22:52 +0900)]
iio: pressure: bmp280: add support for BMP180
This adds support for the BMP180 to the bmp280 iio driver.
The BMP180 has already been supported by misc/bmp085 driver but it
doesn't use iio framework. This change adds the kconfig dependency
not to be selected both of them in order to avoid any issues.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Acked-by: Vlad Dogaru <vlad.dogaru@intel.com> Cc: Christoph Mair <christoph.mair@gmail.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
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>
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>
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>
Marek Vasut [Mon, 18 Apr 2016 14:05:24 +0000 (16:05 +0200)]
iio: pressure: hp03: Add Hope RF HP03 sensor support
Add support for HopeRF pressure and temperature sensor.
This device uses two fixed I2C addresses, one for storing
calibration coefficients and another for accessing the ADC.
Signed-off-by: Marek Vasut <marex@denx.de> Cc: Matt Ranostay <mranostay@gmail.com> Cc: Jonathan Cameron <jic23@kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Gregor Boirie [Wed, 20 Apr 2016 17:23:45 +0000 (19:23 +0200)]
iio:imu:mpu6050: enhance mounting matrix support
Add a new rotation matrix sysfs attribute compliant with IIO core
mounting matrix API.
Matrix is retrieved from "in_anglvel_mount_matrix" and
"in_accel_mount_matrix" sysfs attributes. It is declared into mpu6050 DTS
entry as a "mount-matrix" property.
Old interface is kept for backward userspace compatibility and may be
retrieved from legacy platform_data mechanism only.
Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Gregor Boirie [Wed, 20 Apr 2016 17:23:44 +0000 (19:23 +0200)]
iio:ak8975: add mounting matrix support
Expose a rotation matrix to indicate userspace the chip orientation with
respect to the overall hardware system.
Matrix is retrieved from "in_mount_matrix". It is declared into ak8975 DTS
entry as a "mount-matrix" property.
Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Gregor Boirie [Wed, 20 Apr 2016 17:23:43 +0000 (19:23 +0200)]
iio:core: mounting matrix support
Expose a rotation matrix to indicate userspace the chip placement with
respect to the overall hardware system. This is needed to adjust
coordinates sampled from a sensor chip when its position deviates from the
main hardware system.
Final coordinates computation is delegated to userspace since:
* computation may involve floating point arithmetics ;
* it allows an application to combine adjustments with arbitrary
transformations.
This 3 dimentional space rotation matrix is expressed as 3x3 array of
strings to support floating point numbers. It may be retrieved from a
"[<dir>_][<type>_]mount_matrix" sysfs attribute file. It is declared into a
device / driver specific DTS property or platform data.
Signed-off-by: Gregor Boirie <gregor.boirie@parrot.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: Add resource managed APIs devm_iio_channel_{get,release) in devres
Add following APIs in the list of managed resources of IIO:
devm_iio_channel_get()
devm_iio_channel_get_all()
devm_iio_channel_release()
devm_iio_channel_release_all()
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: core: Add devm_ APIs for iio_channel_{get,release}_all
Some of kernel driver uses the IIO framework to get the sensor
value via ADC or IIO HW driver. The client driver get iio channel
by iio_channel_get_all() and release it by calling
iio_channel_release_all().
Add resource managed version (devm_*) of these APIs so that if client
calls the devm_iio_channel_get_all() then it need not to release it
explicitly, it can be done by managed device framework when driver
get un-binded.
This reduces the code in error path and also need of .remove callback in
some cases.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
iio: core: Add devm_ APIs for iio_channel_{get,release}
Some of kernel driver uses the IIO framework to get the sensor
value via ADC or IIO HW driver. The client driver get iio channel
by iio_channel_get() and release it by calling iio_channel_release().
Add resource managed version (devm_*) of these APIs so that if client
calls the devm_iio_channel_get() then it need not to release it explicitly,
it can be done by managed device framework when driver get un-binded.
This reduces the code in error path and also need of .remove callback in
some cases.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
If no channels are enabled when we run generic_buffer on a
device, add a command-line option to just enable all of them,
run the sampling and disable them all again afterwards.
This is extremely useful when I'm low-level testing my
sensors with interrupts and triggers, sample session: