Brian Masney [Thu, 3 Nov 2016 12:56:16 +0000 (08:56 -0400)]
staging: iio: tsl2583: don't shutdown chip when updating the lux table
in_illuminance_lux_table_store() shuts down the chip, updates the
contents of the lux table, and then turns the chip back on. The values
in lux table are not used by the chip and are only used internally by
the driver. It is not necessary to change the power state on the chip.
This patch removes the calls to taos_chip_off() and taos_chip_on()
in in_illuminance_lux_table_store().
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Thu, 3 Nov 2016 12:56:15 +0000 (08:56 -0400)]
staging: iio: tsl2583: remove redundant power off sequence in taos_chip_on()
taos_chip_on() explicitly turns the sensor power on and then writes the
8 registers that are stored in taos_config. The first register in
taos_config is the CONTROL register and the configuration is set to
turn the power off. The existing state sequence in taos_chip_on() is:
- Turn device power on
- Turn device power off (via taos_config)
- Configure other 7 registers (via taos_config)
- Turn device power on, enable ADC
This patch changes the code so that the device is not powered off via
taos_config.
Verified that the driver still functions correctly using a TSL2581
hooked up to a Raspberry Pi 2.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Thu, 3 Nov 2016 12:56:14 +0000 (08:56 -0400)]
staging: iio: tsl2583: fixed ordering of comments
in taos_defaults()
The comments in taos_defaults() appear after the line of code
that they apply to. This patch moves the comments so that they appear
before the code. Some of the comments were updated to be more
informative.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Thu, 3 Nov 2016 12:56:13 +0000 (08:56 -0400)]
staging: iio: tsl2583: removed unused code from device probing
taos_probe() queries the all of the sensor's registers and loads all of
the values into a buffer stored on the stack. Only the chip ID register
was actually used. Change the probe function to just query the chip ID
register on the device.
Verified that the driver still functions correctly using a TSL2581
hooked up to a Raspberry Pi 2.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Thu, 3 Nov 2016 12:56:12 +0000 (08:56 -0400)]
staging: iio: tsl2583: i2c_smbus_write_byte() / i2c_smbus_read_byte() migration
There were several places where the driver would first call
i2c_smbus_write_byte() to select the register on the device, and then
call i2c_smbus_read_byte() to get the contents of that register. The
code would look roughly like:
/* Select register */
i2c_smbus_write_byte(client, REGISTER);
/* Read the the last register that was written to */
int data = i2c_smbus_read_byte(client);
Rewrite this to use i2c_smbus_read_byte_data() to combine the two
calls into one:
int data = i2c_smbus_read_byte_data(chip->client, REGISTER);
Verified that the driver still functions correctly using a TSL2581
hooked up to a Raspberry Pi 2.
This fixes the following warnings that were found by the
kbuild test robot that were introduced by commit
8ba355cce3c6 ("staging:
iio: tsl2583: check for error code from i2c_smbus_read_byte()").
drivers/staging/iio/light/tsl2583.c:365:5-12: WARNING: Unsigned
expression compared with zero: reg_val < 0
drivers/staging/iio/light/tsl2583.c:388:5-12: WARNING: Unsigned
expression compared with zero: reg_val < 0
This also removes the need for the taos_i2c_read() function since all
callers were only calling the function with a length of 1.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Cc: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Jonathan Cameron [Sat, 5 Nov 2016 17:38:00 +0000 (17:38 +0000)]
Merge branch 'ib-iio-mfd-ti335x_dma' into togreg
A local branch created as Lee requested these two patches were applied
in a fashion that would later let him merge the same branch into MFD
if needed.
Mugunthan V N [Wed, 5 Oct 2016 09:04:41 +0000 (14:34 +0530)]
drivers: iio: ti_am335x_adc: add dma support
This patch adds the required pieces to ti_am335x_adc driver for
DMA support
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Reviewed-by: Peter Ujfalusi <peter.ujfalusi@ti.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Mugunthan V N [Wed, 5 Oct 2016 09:04:40 +0000 (14:34 +0530)]
mfd: ti_am335x_tscadc: store physical address
store the physical address of the device in its priv to use it
for DMA addressing in the client drivers.
Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
Acked-for-MFD-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Wenyou Yang [Wed, 2 Nov 2016 09:21:48 +0000 (17:21 +0800)]
iio: adc: at91: add suspend and resume callback
Add suspend/resume callback, support the pinctrl sleep state when
the system suspend as well.
Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com>
Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Song Hongyan [Thu, 3 Nov 2016 00:45:48 +0000 (00:45 +0000)]
iio: hid-sensor-attributes: Check sample_frequency/hysteresis write data legitimacy
Neither sample frequency value nor hysteresis value can be set to be a
negative number, check and return "Invalid argument" if they are negative.
If not do this change, sample_frequency will be set into some unknown
value, read hysteresis value after write negative number will return
"Invalid argument".
Signed-off-by: Song Hongyan <hongyan.song@intel.com>
Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Eva Rachel Retuya [Mon, 31 Oct 2016 17:04:35 +0000 (01:04 +0800)]
staging: iio: ad9832: clean-up regulator 'reg'
Rename regulator 'reg' to 'avdd' so as to be clear what regulator it
stands for specifically. Additionally, get rid of local variable 'reg'
and use direct assignment instead. Update also the goto label pertaining
to the avdd regulator during disable.
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Eva Rachel Retuya [Mon, 31 Oct 2016 17:04:34 +0000 (01:04 +0800)]
staging: iio: ad9832: add DVDD regulator
The AD9832/AD9835 is supplied with two power sources: AVDD as analog
supply voltage and DVDD as digital supply voltage.
Attempt to fetch and enable the regulator 'dvdd'. Bail out if any error
occurs.
Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Eva Rachel Retuya [Mon, 31 Oct 2016 17:04:33 +0000 (01:04 +0800)]
staging: iio: ad7192: rename regulator 'reg' to 'avdd'
Rename regulator 'reg' to 'avdd' so as to be clear what regulator it
stands for specifically. Also, update the goto label accordingly.
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Eva Rachel Retuya [Mon, 31 Oct 2016 17:04:32 +0000 (01:04 +0800)]
staging: iio: ad7192: add DVdd regulator
The AD7190/AD7192/AD7193/AD7195 is supplied with two power sources:
AVdd as analog supply voltage and DVdd as digital supply voltage.
Attempt to fetch and enable the regulator 'dvdd'. Bail out if any error
occurs.
Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Eva Rachel Retuya [Mon, 31 Oct 2016 17:04:31 +0000 (01:04 +0800)]
staging: iio: rework regulator handling
Currently, the affected drivers ignore all errors from regulator_get().
The way it is now, it also breaks probe deferral (EPROBE_DEFER). The
correct behavior is to propagate the error to the upper layers so they
can handle it accordingly.
Rework the regulator handling so that it matches the standard behavior.
If the specific design uses a static always-on regulator and does not
explicitly specify it, regulator_get() will return the dummy regulator.
The following semantic patch was used to apply the change:
@r1@
expression reg, dev, en, volt;
@@
reg = \(devm_regulator_get\|regulator_get\)(dev, ...);
if (
- !
IS_ERR(reg))
+ return PTR_ERR(reg);
(
- { en = regulator_enable(reg);
- if (en) return en; }
+
+ en = regulator_enable(reg);
+ if (en) {
+ dev_err(dev, "Failed to enable specified supply\n");
+ return en; }
|
+
- { en = regulator_enable(reg);
- if (en) return en;
- volt = regulator_get_voltage(reg); }
+ en = regulator_enable(reg);
+ if (en) {
+ dev_err(dev, "Failed to enable specified supply\n");
+ return en;
+ }
+ volt = regulator_get_voltage(reg);
)
@r2@
expression arg;
@@
- if (!IS_ERR(arg)) regulator_disable(arg);
+ regulator_disable(arg);
Hand-edit the debugging prints with the supply name to become more
specific.
Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Eva Rachel Retuya [Mon, 31 Oct 2016 17:04:30 +0000 (01:04 +0800)]
staging: iio: set proper supply name to devm_regulator_get()
The name passed to devm_regulator_get() should match the name of the
supply as specified in the device datasheet. This makes it clear what
power supply is being referred to in case of presence of other
regulators.
Currently, the supply name specified on the affected devices is 'vcc'.
Use lowercase version of the datasheet name to specify the supply
voltage.
Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Jonathan Cameron [Tue, 1 Nov 2016 18:53:11 +0000 (18:53 +0000)]
Merge branch 'ib-iio-mfd-4.9rc1' into togreg
Immutable branch to allow mfd changes to also be available in Lee's MFD tree.
Eva Rachel Retuya [Fri, 28 Oct 2016 08:26:52 +0000 (16:26 +0800)]
staging: iio: cdc: ad7746: add additional config defines
Introduce defines for shifting and mask under the config register for
better readability. Also, introduce helper variables for index
calculation.
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Fri, 28 Oct 2016 10:00:21 +0000 (06:00 -0400)]
staging: iio: tsl2583: add locking to sysfs attributes
in_illuminance_input_target_show(), in_illuminance_input_target_store(),
in_illuminance_calibrate_store(), and in_illuminance_lux_table_store()
accesses data from the tsl2583_chip struct. Some of these fields can be
modified by other parts of the driver concurrently. This patch adds the
mutex locking to these sysfs attributes.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Fri, 28 Oct 2016 10:00:20 +0000 (06:00 -0400)]
staging: iio: tsl2583: add error code to sysfs store functions
in_illuminance_input_target_store() and in_illuminance_calibrate_store()
validated the data from userspace, however it would not return an
error code to userspace if an invalid value was passed in. This patch
changes these functions so that they return -EINVAL if invalid data is
passed in.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Fri, 28 Oct 2016 10:00:19 +0000 (06:00 -0400)]
staging: iio: tsl2583: use IIO_*_ATTR* macros to create sysfs entries
Use the IIO_CONST_ATTR, IIO_DEVICE_ATTR_RW, and IIO_DEVICE_ATTR_WO
macros for creating the in_illuminance_calibscale_available,
in_illuminance_integration_time_available, in_illuminance_input_target,
in_illuminance_calibrate, and in_illuminance_lux_table sysfs entries.
Previously these sysfs entries were prefixed with illuminance0_, however
they are now prefixed with in_illuminance_ to make these sysfs entries
consistent with how the IIO core is creating the other sysfs entries.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Fri, 28 Oct 2016 10:00:18 +0000 (06:00 -0400)]
staging: iio: tsl2583: convert illuminance0_calibscale sysfs attr to use iio_chan_spec
The illuminance0_calibscale sysfs attribute is not currently created by
the IIO core. This patch adds the appropriate mask to iio_chan_spec,
along with the appropriate data handling in the read_raw() and
write_raw() functions, so that the sysfs attribute is created by the IIO
core. With this change, this sysfs entry will have its prefix changed
from illuminance0_ to in_illuminance_.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Fri, 28 Oct 2016 10:00:17 +0000 (06:00 -0400)]
staging: iio: tsl2583: convert to use iio_chan_spec and {read,write}_raw
The tsl2583 driver directly creates sysfs attributes that should instead
be created by the IIO core on behalf of the driver. This patch adds the
iio_chan_spec array, the relevant info_mask elements and the read_raw()
and write_raw() functions to take advantage of features provided by the
IIO core. These sysfs attributes were migrated with this patch:
illuminance0_input, illuminance0_calibbias,
illuminance0_integration_time. This also exposes the raw values read
from the two channels on the sensor.
With this change, these four sysfs entries have their prefix changed
from illuminance0_ to in_illuminance_. This is deemed to be acceptable
since none of the IIO light drivers in mainline use the illuminance0_
prefix, however 8 of the IIO light drivers in mainline use the
in_illuminance_ prefix.
Also fix the units of integration_time to meet with the ABI.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Fri, 28 Oct 2016 10:00:16 +0000 (06:00 -0400)]
staging: iio: tsl2583: check return values from taos_chip_{on,off}
The return value from taos_chip_on() and taos_chip_off() was not
checked in taos_luxtable_store() and taos_probe(). This patch adds
proper error checking to these function calls.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Fri, 28 Oct 2016 10:00:15 +0000 (06:00 -0400)]
staging: iio: tsl2583: remove redundant power_state sysfs attribute
IIO devices have a /sys/bus/iio/devices/iio:deviceX/power/ directory
that allows viewing and controling various power parameters. The tsl2583
driver also has an additional custom sysfs attribute named power_state
that is not needed. This patch removes the redundant power_state sysfs
attribute.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Fri, 28 Oct 2016 10:00:14 +0000 (06:00 -0400)]
staging: iio: tsl2583: return proper error code instead of -1
taos_als_calibrate() has a code path where -1 is returned. This patch
changes the code so that a proper error code is returned.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Fri, 28 Oct 2016 10:00:13 +0000 (06:00 -0400)]
staging: iio: tsl2583: check for error code from i2c_smbus_read_byte()
taos_i2c_read() and taos_als_calibrate() does not check to see if the
value returned by i2c_smbus_read_byte() was an error code. This patch
adds the appropriate error handling.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Brian Masney [Fri, 28 Oct 2016 10:00:12 +0000 (06:00 -0400)]
staging: iio: tsl2583: add of_match table for device tree support
Add device tree support for the tsl2583 IIO driver with no custom
properties.
Signed-off-by: Brian Masney <masneyb@onstation.org>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lorenzo Bianconi [Tue, 25 Oct 2016 21:09:04 +0000 (23:09 +0200)]
Documentation: dt: iio: accel: add lng2dm sensor device binding
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lorenzo Bianconi [Tue, 25 Oct 2016 21:09:03 +0000 (23:09 +0200)]
iio: accel: st_accel: add support to lng2dm
add support to STMicroelectronics LNG2DM accelerometer to
st_accel framework
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Paul Kocialkowski [Tue, 25 Oct 2016 19:20:10 +0000 (21:20 +0200)]
iio: si7020: Add devicetree support and trivial bindings
This adds devicetree support for the si7020 iio driver. Since it works
well without requiring any additional property, its compatible string is
added to the trivial i2c devices bindings list.
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Wei Yongjun [Sat, 29 Oct 2016 16:11:20 +0000 (16:11 +0000)]
iio: humidity: remove duplicated include from hts221_buffer.c
Remove duplicated include.
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Jonathan Cameron [Sun, 30 Oct 2016 12:08:42 +0000 (12:08 +0000)]
iio:cros_ec_sensors: Swap from a select to a depends in Kconfig
Would have merged this into the original patch as a fixup but I've already
pushed that out as an immutable branch for others to use so it'll have
to be a separate patch. The original select had a typo as well.
Trying to do this via a select was opening a can of worms due to
a tree of other elements that would also have needed selecting.
A simple depends seems much mroe straight forward and appropriate in this
case.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Cc: Lee Jones <lee.jones@linaro.org>
Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Enric Balletbo i Serra [Mon, 1 Aug 2016 09:54:38 +0000 (11:54 +0200)]
platform/chrome: cros_ec_dev - Register cros-ec sensors
Check whether the ChromeOS Embedded Controller is a sensor hub and in
such case issue a command to get the number of sensors and register them
all.
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Vincent Palatin [Mon, 1 Aug 2016 09:54:37 +0000 (11:54 +0200)]
platform/chrome: Introduce a new function to check EC features.
Use the EC_CMD_GET_FEATURES message to check the supported features for
each MCU.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
[tomeu: adapted to changes in mainline]
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
[enric: remove references to USB PD feature and do it more generic]
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Reviewed-by: Guenter Roeck <groeck@chromium.org>
For the MFD changes:
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Enric Balletbo i Serra [Mon, 1 Aug 2016 09:54:36 +0000 (11:54 +0200)]
iio: cros_ec_sensors: add ChromeOS EC Contiguous Sensors driver
Handle 3d contiguous sensors like Accelerometers, Gyroscope and
Magnetometer that are presented by the ChromeOS EC Sensor hub.
Signed-off-by: Guenter Roeck <groeck@chromium.org>
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Enric Balletbo i Serra [Mon, 1 Aug 2016 09:54:35 +0000 (11:54 +0200)]
iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub.
Add the core functions to be able to support the sensors attached behind
the ChromeOS Embedded Controller and used by other IIO cros-ec sensor
drivers.
The cros_ec_sensor_core driver matches with current driver in ChromeOS
4.4 tree, so it includes all the fixes at the moment. The support for
this driver was made by Gwendal Grignou. The original patch and all the
fixes has been squashed and rebased on top of mainline.
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Signed-off-by: Guenter Roeck <groeck@chromium.org>
[eballetbo: split, squash and rebase on top of mainline the patches
found in ChromeOS tree]
Signed-off-by: Enric Balletbo i Serra <enric.balletbo@collabora.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Arnd Bergmann [Tue, 25 Oct 2016 15:55:04 +0000 (17:55 +0200)]
iio: maxim_thermocouple: detect invalid storage size in read()
As found by gcc -Wmaybe-uninitialized, having a storage_bytes value other
than 2 or 4 will result in undefined behavior:
drivers/iio/temperature/maxim_thermocouple.c: In function 'maxim_thermocouple_read':
drivers/iio/temperature/maxim_thermocouple.c:141:5: error: 'ret' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This probably cannot happen, but returning -EINVAL here is appropriate
and makes gcc happy and the code more robust.
Fixes:
231147ee77f3 ("iio: maxim_thermocouple: Align 16 bit big endian value of raw reads")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Arnd Bergmann [Tue, 25 Oct 2016 15:56:23 +0000 (17:56 +0200)]
staging: iio: cdc/ad7746: fix missing return value
As found by "gcc -Wmaybe-uninitialized", the latest change to the
driver lacked an initalization for the return code in one of the
added cases:
drivers/staging/iio/cdc/ad7746.c: In function ‘ad7746_read_raw’:
drivers/staging/iio/cdc/ad7746.c:655:2: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
This sets it to IIO_VAL_INT, which I think is what we want here.
Fixes:
2296c0623eb7 ("staging: iio: cdc: ad7746: implement IIO_CHAN_INFO_SAMP_FREQ")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Linus Walleij [Tue, 25 Oct 2016 14:15:54 +0000 (16:15 +0200)]
iio: gyro: Add driver for the MPU-3050 gyroscope
This adds a new driver for the Invensense MPU-3050 gyroscope.
This driver is based on information from the rough input driver
in drivers/input/misc/mpu3050.c and the scratch misc driver
posted by Nathan Royer in 2011. Some years have passed but this
is finally a fully-fledged driver for this gyroscope. It was
developed and tested on the Qualcomm APQ8060 Dragonboard.
The driver supports both raw and buffered input. It also
supports the internal trigger mechanism by registering a trigger
that can fire in response to the internal sample engine of the
component. In addition to reading out the gyroscope sensor
values, the driver also supports reading the temperature from
the sensor.
The driver currently only supports I2C but the MPU-3050 can
also be used from SPI, so the I2C portions are split in their
own file and we just use regmap to access all registers, so
it will be trivial to plug in SPI support if/when someone has
a system requiring this.
To conserve power, the driver utilizes the runtime PM
framework and will put the sensor in off mode and disable the
regulators when unused, after a timeout of 10 seconds.
The fullscale can be set for the sensor to 250, 500, 1000 or
2000 deg/s. This corresponds to scale values of rougly 0.000122,
0.000275, 0.000512 or 0.001068. By writing such values (or close
to these) into "in_anglevel_scale", the corresponding fullscale
can be chosen. It will default to 2000 deg/s (~35 rad/s).
The gyro component can have DC offsets on all axes. These can be
compensated using the standard sysfs ABI property
"in_anglevel_[xyz]_calibbias". This is in positive/negative
values of the raw values, so a suitable calibration bias can be
determined by userspace by reading the "in_anglevel_[xyz]_raw"
for a few iterations while holding the sensor still, create an
average integer, and writing the negative inverse of that into
"in_anglevel_[xyz]_calibbias". After this the hardware will
automatically subtract the bias, also when using buffered
readings.
Since the MPU-3050 has an outgoing I2C port it needs to act as
an I2C mux. This means that the device is switching I2C traffic
to devices beyond it. On my system this is the only way to reach
the accelerometer. The "sensor fusion" ability of the MPU-3050
to directly talk to the device on the outgoing I2C port is
currently not used by the driver, but it has code to allow I2C
traffic to pass through so that the Linux kernel can reach the
device on the other side with a kernel driver.
Example usage with the native trigger:
$ generic_buffer -a -c10 -n mpu3050
iio device number being used is 0
iio trigger number being used is 0
No channels are enabled, enabling all channels
Enabling: in_anglvel_z_en
Enabling: in_timestamp_en
Enabling: in_anglvel_y_en
Enabling: in_temp_en
Enabling: in_anglvel_x_en
/sys/bus/iio/devices/iio:device0 mpu3050-dev0
29607.142578 -0.117493 0.074768 0.012817
180788797150
29639.285156 -0.117493 0.076904 0.013885
180888982335
29696.427734 -0.116425 0.076904 0.012817
180989178039
29742.857422 -0.117493 0.076904 0.012817
181089377742
29764.285156 -0.116425 0.077972 0.012817
181189574187
29860.714844 -0.115356 0.076904 0.012817
181289772705
29864.285156 -0.117493 0.076904 0.012817
181389971520
29910.714844 -0.115356 0.076904 0.013885
181490170483
29917.857422 -0.116425 0.076904 0.011749
181590369742
29975.000000 -0.116425 0.076904 0.012817
181690567075
Disabling: in_anglvel_z_en
Disabling: in_timestamp_en
Disabling: in_anglvel_y_en
Disabling: in_temp_en
Disabling: in_anglvel_x_en
The first column is the temperature in millidegrees, then the x,y,z
axes in succession followed by the timestamp. Also tested successfully
using the HRTimer trigger.
Cc: Nick Vaccaro <nvaccaro@google.com>
Cc: Ge Gao <ggao@invensense.com>
Cc: Anna Si <asi@invensense.com>
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Crestez Dan Leonard <leonard.crestez@intel.com>
Cc: Daniel Baluta <daniel.baluta@intel.com>
Cc: Gregor Boirie <gregor.boirie@parrot.com>
Cc: Peter Rosin <peda@axentia.se>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Linus Walleij [Tue, 25 Oct 2016 14:15:53 +0000 (16:15 +0200)]
iio: gyro: Add MPU-3050 device tree bindings
This adds device tree bindings for the MPU-3050 gyroscope. Since it
is the first set of bindings for a gyroscope, the folder for it
is also created.
Cc: devicetree@vger.kernel.org
Cc: Peter Rosin <peda@axentia.se>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Pankaj Bharadiya [Mon, 17 Oct 2016 09:12:36 +0000 (14:42 +0530)]
staging: greybus: audio: remove redundant slot field
gb_audio_manager_module_descriptor's intf_id field maintains the
information about the interface on which module is connected hence
having an extra slot field is redundant.
Thus remove the slot field and its associated code.
Signed-off-by: Pankaj Bharadiya <pankaj.bharadiya@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rahul Krishnan [Fri, 21 Oct 2016 15:29:28 +0000 (20:59 +0530)]
Staging: Greybus: Fix trailing */ in block comments
This patch fixes the following checkpath.pl warning
WARNING: Block comments use a trailing */ on a separate line
Signed-off-by: Rahul Krishnan <mrahul.krishnan@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Rui Miguel Silva [Wed, 19 Oct 2016 12:44:25 +0000 (13:44 +0100)]
staging: greybus: es2: fix arpc request size
Fix size field of arpc message request by using the header size and not
the pointer size.
Signed-off-by: Rui Miguel Silva <rmfrfs@gmail.com>
Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Elise Lennion [Fri, 14 Oct 2016 22:00:11 +0000 (19:00 -0300)]
staging: greybus: audio_manager_sysfs: Replace sscanf with kstrto* to single variable conversion.
Fix checkpatch warning:
WARNING: Prefer kstrto<type> to single variable sscanf
kstrto* is designed to convert string to numerical value and makes
it easier to understand what the code does.
Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Elise Lennion [Mon, 17 Oct 2016 23:57:58 +0000 (21:57 -0200)]
staging: xgifb: Remove unnecessary parentheses.
The removed parentheses are unnecessary and don't add readability.
Found using Coccinelle semantic patch:
@@ expression e, e1, e2; @@
e &=
(
(e1 == e2)
|
- (e1)
+ e1
)
@@ expression e, e1, e2; @@
e |=
(
(e1 == e2)
|
- (e1)
+ e1
)
Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Elise Lennion [Tue, 18 Oct 2016 00:01:26 +0000 (22:01 -0200)]
staging: vt6656: Remove unnecessary parentheses.
The removed parentheses are unnecessary and don't add readability.
Found using Coccinelle semantic patch:
@@ expression e, e1, e2; @@
e +=
(
(e1 == e2)
|
- (e1)
+ e1
)
@@ expression e, e1, e2; @@
e =
(
(e1 == e2)
|
- (e1)
+ e1
)
Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Mihaela Muraru [Mon, 17 Oct 2016 14:20:18 +0000 (17:20 +0300)]
Staging: android: ion: Make a read-only structure
This patch add const qualifier at the declaration of the structure.
The structure become a read-only data, this increase the security.
Found with Coccinelle:
@r disable optional_qualifier@
identifier s,i;
@@
* static struct s i ={...};
Signed-off-by: Mihaela Muraru <mihaela.muraru21@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Elise Lennion [Tue, 18 Oct 2016 00:00:07 +0000 (22:00 -0200)]
staging: android: Remove unnecessary parentheses.
The removed parentheses are unnecessary and don't add readability.
Found using Coccinelle semantic patch:
@@ expression e, e1, e2; @@
e =
(
(e1 == e2)
|
- (e1)
+ e1
)
Signed-off-by: Elise Lennion <elise.lennion@gmail.com>
Acked-by: Laura Abbott <labbott@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Michael Zoran [Wed, 19 Oct 2016 22:58:54 +0000 (15:58 -0700)]
staging: vc04_services: Add casts to remove warnings in vchiq_core.c
When compiling vchiq_core.c for 64 bit, the compiler
emits a few warnings that are not actual issues. This
change adds a few casts to remove the extra unnecessary
warnings.
Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Michael Zoran [Wed, 19 Oct 2016 22:58:48 +0000 (15:58 -0700)]
staging: vc04_services: Handle conversion from VCHIQ_SERVICE_HANDLE_T to VCHI_SERVICE_HANDLE_T
A VCHIQ_SERVICE_HANDLE_T which is an int is stuffed into a
VCHI_SERVICE_HANDLE_T which is a pointer, passed around, then
converted back to a VCHIQ_SERVICE_HANDLE_T. Since the data is
always actually a VCHIQ_SERVICE_HANDLE_T(int), never actually a
pointer, it is safe to simply cast the two back in forth.
Note that pointers are never stuffed into an int.
Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Michael Zoran [Wed, 19 Oct 2016 22:58:34 +0000 (15:58 -0700)]
staging: vc04_services: Convert pointers in shared state to offsets
The arm processor core and the GPU have a shared data structure.
This structure contains pointers to base linux kernel objects such as
events. The size of the pointer changes between 32 bit and 64 bit,
so it is necessary to convert these pointers to offsets from the
beginning of the state structure.
Luckly, the GPU does not interpret these pointers/offsets,
but this change is necessary to keep the structure the same since
the GPU code is outside the scope of the linux kernel
and can't be easily changed.
Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Michael Zoran [Wed, 19 Oct 2016 22:58:27 +0000 (15:58 -0700)]
staging: vc04_services: Change fields of page list structure to fixed length
The arm processor core and the GPU have shared data structures.
One of these structures is a list of pages of data for messages.
This structure can not change since it is dependent on the GPU
firmware which is external to the kernel. Convert the fields
of this structure to fixed length fields.
Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Michael Zoran [Wed, 19 Oct 2016 22:58:09 +0000 (15:58 -0700)]
staging: vc04_services: Convert dsb() to dsb(sy)
The dsb() macro for 32 arm compiles to dsb(sy) in the binary file.
This macro is no longer supported on arm64, so instead use dsb(sy)
which is completely binary compatible.
Signed-off-by: Michael Zoran <mzoran@crowfest.net>
Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Greg Kroah-Hartman [Mon, 24 Oct 2016 09:34:22 +0000 (11:34 +0200)]
Merge tag 'iio-for-4.10a' of git://git./linux/kernel/git/jic23/iio into staging-next
Jonathan writes:
First round of IIO new device support, features and cleanups for the 4.10 cycle.
Fair number of outreachy related patches in here. Some of these may well
have already been picked up by Greg but git will sort that out for us.
Also some good staging cleanup work from other sources. Thanks Brian and Lars
in particular for this.
New device support
* ACCES 104-quad-8
- New driver for this 8 channel encoder input board. Lots of new ABI with
this one.
* AD7766
- New driver supporting AD7766, AD7766-1, AD7766-2, AD7767, AD7767-1 and
AD7767-2 24 bit ADCs.
* dmard 10
- New driver for this 3 axis accelerometer.
* Honeywell ABP pressure sensors.
- New driver covering 56 parts in this series (too many to list here!)
* HTS221
- New driver to support this relative humidiy and temperature device.
* LMP91000
- New driver for this potentiostat (form of chemical sensor). Nice example
of use of the buffered consumer interfaces and the use of a consumer
provided trigger.
* MiraMEMS DA311
- New driver for this 3 axis accelerometer.
* MiraMEMS DA280
- New driver for this 3 axis accelerometer. Follow up caught up with
vendor prefixes for these.
Staging graduations
* isl29018 light sensor
- Fixes and cleanups listed below (thanks for your hard work on this Brian!)
* sca3000
- Fixes and cleanups listed below. This was one of the small set of drivers
that went into staging when IIO was first added. Turns out it had a few
bugs and needed to be brought into the modern era! Not clear if I am
the only person who actually has one of these still wired to a board.
New features (Core)
- Add an iio_trigger_validate_own_device helper which relies on the device
and trigger having the same parent. Convenient to have this for some
of the more complex trigger / device interactions. Was hand rolled in
a few drivers already so good to bring it into the core.
- Add an iio_read_channel_offset in kernel access helper (similar to
the existing one for scale).
- IIO_ATTR_{RO, WO, RW} and IIO_DEVICE_ATTR_{RO, WO, RW} macros. These
lead some rather contrived function naming, but there is no denying they
do reduced boilerplate. I'm going to resist their introduction in
drivers 'unless' they form part of a larger set of cleanups.
- Counter channel type and index type.
New features (Drivers)
* hdc100x
- Triggered buffer support.
* mcp4725
- Device tree bindings and support.
- Voltage reference selection.
* ti-adc0832
- Triggered buffer support.
* ti-adc161s626
- Add regulator support allowing _scale and _offset values to be established
and exported.
New features (Tools)
* iio_generic_buffer
- -A option to force enable all channels rather than faulting if some are
already enabled (like -a does). Followup patches tidied this support up.
Cleanups (Core)
- Use kmalloc_array in iio_scan_mask_set.
- Take event_attrs field of iio_info structure constant
- Staging todo list updates. Most of it was long done.
- MAINTAINERS had a wrong directory listing.
Cleanups (Drivers)
* Missing i2c trivial devices entries.
* ad5592r
- Fix an endian type related sparse warnings.
* ad7150
- Constify the event attribute_group structures.
* ad7152
- Add some blank lines to improve readability.
- Sampling frequency control via chan-info element rather than hand rolled
attributes.
- add a new lock to avoid use of mlock for non state change related locking.
* ad7280
- Constify atrribute_group structure (second patch covers the event ones)
* ad7606 (Lars is driving most of the cleanup on this with some additions from
Eva)
- Fix improper setting of oversampling pins. This has been broken a very
long time in this staging driver, so not going to push this back to stable.
- Implement oversampling configuration via the chan_info mask element.
- Remove an unused int_vref_mv field.
- Remove a reundant name field from ad7606_chip_info.
- Remove default device configuration from platform_data in favour of
whatever the power on defaults are.
- Remove out of band error reporting in the kernel log as not providing
much information.
- Fix oversampling ratio by having 1 be the value for no oversampling.
- Avoid allocating buffer for each data capture.
- Factor out common code between periodic and one-shot capture.
- Move set_drvdat into common code.
- Let the common probe function return int rather than jumping through
an ERR_PTR.
- Pass struct device * into common remove to simplify code.
- Always run trigger handler only once per event (no one can remember why
it was being possibly done twice).
- Move over to the GPIO descriptor API to shorten and clarify code.
- Move the buffer code into the main file as it's not optional and is
now rather short in this driver.
- Fix the naming of the supply regulator.
- Rework regulator handling to handle errors including deferred probing.
- Tidy up a ptr_err or 0 return.
* ad7746
- Sampling frequency control via info_mask element rather than hand rolled
* ad7758
- Sampling frequency control via info_mask element rather than hand rolled
attributes.
* ad7816
- Constify the event attribute_group structure.
* adt7316
- Constify the event attribute group structures.
* ak8974
- Cleanup some sparse warnings about endian types.
* ak8975
- Cleanup some sparse warnings about endian types.
* bmi160
- Spare endian warning cleanups.
* isl29018 (towards staging graduation)
- Remove unusedvariables and defines.
- Improve consistency of error handling.
- Signed / unsigned comparison fixes.
- Use the IIO_DEVICE_ATTR_{RO, RW} macros
- Fix a race in in_illuminance_scale_available_show.
- Cleanup exit points of _read_raw
- Sanity check if in suspended state during a write_raw call as was already
done for read_raw.
- Document device tree bidnings.
- Document infrared supression controls.
- Add some newlines to improve readability and drop one that shouldn't be
there.
- Fix a poorly named functions name.
- Fix multiline coment syntax.
- Tidy up a pair or return statements by unifying them.
- Rename description in Kconfig for consistency with similar drivers.
* lidar
- cleanup power management by dropping unnecessary call.
* ltr501
- Use the claim_direct_mode helpers. Fix a race condition along the way.
* max1027
- Fix a dubious x | !y sparse warning.
- Use the new iio_trigger_validate_own_device helper.
* max440000
- Clean up some sparse warnings about endian types.
* mcp4725
- Use the regulator framework to establish the reference voltage rather than
getting it from platform data.
- Tidy up a comment typo.
- Fix a wrong PTR_ERR query (wrong regulator).
* mma7660
- Take a mma7660_nscale static.
* mma8452
- Use the new iio_trigger_validate_own_device helper.
- Use claim_direct_mode helpers - fix a race condition along the way.
* mpl3115
- Use claim_direct_mode helpers - fix a race condition along the way.
* ms65611
- Tidy up regulator error handling and clean out a static warning in the mix.
* sca3000
- Avoid a potential unitialized variable if a hardware read returns a value
that isn't actually supported (mostly warning supression).
- Fix a use before setting of the indio_dev->buffer pointer. Broken for
a very long time so not going to rush this into stable.
- Merge buffer file with core file. We used to always split these.
Sometimes it's just not worth the hassle. In this case the device's main
feature is it's hardware fifos so unlikely anyone would want to run it
without.
- Drop the sca3000_register_ring_funcs function as it's a pointless wrapper
once we have only one file.
- Fix cleaning of flag + setting of size of scan. Without this you can't
start the buffer twice and expect sensible (or any) results. Again,
broken for a long time so not heading for stable.
- Drop the custom watershed setting ABI - for now we'll just support one
value.
- Move to a hybrid hard / soft buffer design (how we've been doing it
for similar devices for a while now!)
- Cleanup some unusued variables.
- Use a fake channel to support core handling of freefall event registration.
- Cleanup the register defines.
- Fix an off by one error in axis due to IIO_NO_MOD taking up the 0 value.
Been broken since first admission of IIO to the staging tree.
- Add readback of the 3db low pass filter frequency and later writing
allowing droppign of custom measurement mode attributes as they can
be represented by the filter choices that is their main characteristic.
- Drop non standard revision attr and replace with dev_info on probe.
- Avoid a race in probe.
- Various formatting fixes.
- Kernel-docify docs that were very nearly in the write format.
* tsl2583
- Constify attribute_group structure.
* zpa2326
- Drop a redundant DEBUG ifdef.
Cleanups (Tools)
* iio_generic_buffer
- Fix the ? arguement. Previously it sort of worked as you got the help
message as a result of it not recognising the arguement.
Julia Lawall [Sat, 22 Oct 2016 20:41:32 +0000 (22:41 +0200)]
iio: dac: mcp4725: fix odd_ptr_err.cocci warnings
PTR_ERR should access the value just tested by IS_ERR
Generated by: scripts/coccinelle/tests/odd_ptr_err.cocci
CC: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
kbuild test robot [Sat, 22 Oct 2016 19:12:42 +0000 (03:12 +0800)]
staging:iio:ad7606: fix ptr_ret.cocci warnings
drivers/staging/iio/adc/ad7606.c:357:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
Generated by: scripts/coccinelle/api/ptr_ret.cocci
CC: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Matt Ranostay [Sat, 15 Oct 2016 18:04:37 +0000 (11:04 -0700)]
iio: proximity: pulsedlight-lidar-lite-v2: cleanup power management
Remove pm_runtime_mark_last_busy() call that wasn't need in the probe
since the device should be put to sleep.
Clarification from Matt:
Basically it going to be suspended once pm_runtime_idle() is called,
and setting the last busy is useless and not needed.
Clearly this doesn't affect the device running but just makes the code
more consistent with other uses.
Signed-off-by: Matt Ranostay <matt@ranostay.consulting>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Akinobu Mita [Sun, 16 Oct 2016 15:59:42 +0000 (00:59 +0900)]
iio: ti-adc0832: add triggered buffer support
This adds triggered buffer support for the ti-adc0832 driver. Tested with
ADC0831 and ADC0832 by using SYSFS trigger.
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: Hartmut Knaack <knaack.h@gmx.de>
Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Alison Schofield [Fri, 2 Sep 2016 17:23:17 +0000 (10:23 -0700)]
iio: humidity: hdc100x: add triggered buffer support for HDC100X
Triggered buffer support uses the HDC100X's dual acquisition mode
to read both humidity and temperature in one shot.
This patch depends on
447136effbf4 ("iio: humidity: hdc100x: fix sensor data reads of
temp and humidity")
Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tomas Novotny [Tue, 18 Oct 2016 17:43:09 +0000 (19:43 +0200)]
iio: dac: mcp4725: add devicetree support
Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tomas Novotny [Tue, 18 Oct 2016 17:43:08 +0000 (19:43 +0200)]
iio: dac: mcp4725: support voltage reference selection
MCP47x6 chip supports selection of a voltage reference (VDD, VREF buffered
or unbuffered). MCP4725 doesn't have this feature thus the eventual setting
is ignored and user is warned.
The setting is stored only in the volatile memory of the chip. You need to
manually store it to the EEPROM of the chip via 'store_eeprom' sysfs entry.
Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tomas Novotny [Tue, 18 Oct 2016 17:43:07 +0000 (19:43 +0200)]
Documentation: dt: iio: add mcp4725/6 dac device binding
Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Tomas Novotny [Tue, 18 Oct 2016 17:43:06 +0000 (19:43 +0200)]
iio: dac: mcp4725: fix incorrect comment
Number 2 is referencing to the settings with the largest available
resistor.
No functional change.
Signed-off-by: Tomas Novotny <tomas@novotny.cz>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Eva Rachel Retuya [Thu, 20 Oct 2016 13:08:23 +0000 (21:08 +0800)]
staging: iio: ad7606: rework regulator handling
Currently, this driver ignores all errors from regulator_get(). The way
it is now, it also breaks probe deferral (EPROBE_DEFER). The correct
behavior is to propagate the error to the upper layers so they can
handle it accordingly.
Rework the regulator handling so that it matches the standard behavior.
If the specific design uses a static always-on regulator and does not
explicitly specify it, regulator_get() will return the dummy regulator.
Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Eva Rachel Retuya [Thu, 20 Oct 2016 13:08:22 +0000 (21:08 +0800)]
staging: iio: ad7606: set proper supply name to devm_regulator_get()
The name passed to devm_regulator_get() should match the name of the
supply as specified in the device datasheet. The supply on this device
is called 'AVcc' while currently, the driver uses just 'vcc'.
Use 'avcc' to specify the supply voltage since it is custom to use the
lower-caps version of the datasheet name.
Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Acked-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:08 +0000 (19:07 +0200)]
staging:iio:ad7606: Move buffer code to main source file
Currently the ad7606 buffer handling code resides in its own source file.
But this file contains only 4 small functions of which half are just
wrappers around other functions. Buffer support is also always enabled for
this driver, so move them over to the main source file. This reduces the
amount of boilerplate code.
Also rename the main function from ad7606_core.c to ad7606.c since there is
only a single file now.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:07 +0000 (19:07 +0200)]
staging:iio:ad7606: Use GPIO descriptor API
Convert the ad7606 driver away from the deprecated legacy GPIO API and use
the new GPIO descriptor API.
This also means that the platform data struct is now empty and can be
removed.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:06 +0000 (19:07 +0200)]
staging:iio:ad7606: Run trigger handler only once per trigger event
Currently the ad7606 driver installs the same function for the hard-irq and
threaded trigger handlers. This was introduced in commit
1caf7cb46135
("staging:iio:adc:ad7606 Convert to new channel registration method Update
Add missing call to iio_trigger_notify_done() Set pollfunc top and bottom
half handler"). Unfortunately the commit message does not mention why this
was done and Michael does not remember either.
Since the trigger handler function is idempotent (set a GPIO to 1) running
it twice does not do any harm, but is simply not necessary either. So set
the threaded trigger handler for the driver to NULL.
While we are at it also remove the function description comment that does
no say anything that can't be derived from the function name itself.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:05 +0000 (19:07 +0200)]
staging:iio:ad7606: Let common remove function take a struct device *
Currently the common remove function takes a struct iio_dev *. This
parameter is retrieved by the individual driver remove functions by calling
get_drvdata() on their device. To simplify the code let the common remove
function directly take a struct dev * and do the IIO device in retrieval
the common remove function.
This also aligns the interface with the common probe function.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:04 +0000 (19:07 +0200)]
staging:iio:ad7606: Let the common probe function return int
The common probe function for the ad7606 currently returns a struct iio_dev
pointer. The returned value is not used by the individual driver probe
functions other than for error checking.
Let the common probe function return a int instead to report the error
value directly (or 0 on success). This allows to simplify the code.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:03 +0000 (19:07 +0200)]
staging:iio:ad7606: Move set_drvdata() into common code
Both the platform_device and SPI driver call set_drvdata() at the end of
their probe function. Move this into the common probe() function to reduce
duplicated code.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:02 +0000 (19:07 +0200)]
staging:iio:ad7606: Factor out common code between periodic and one-shot capture
Both the periodic buffer based and one-shot sysfs based capture methods
share a large portion of their code. Factor this out into a common helper
function.
Also provide a comment that better explains in more detail what is going on
in the capture function.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:01 +0000 (19:07 +0200)]
staging:iio:ad7606: Avoid allocating buffer for each data capture
Currently the ad7606 driver dynamically allocates and frees a transfer
buffer each time a sample capture is performed in buffered mode, which
introduces unnecessary overhead. The driver state struct already contains a
buffer that is used for transfers in one-shot mode. This buffer is large
enough to hold all samples, but not the timestamp that might be present in
buffered mode. Extend the buffer size to be able to contain the timestamp
and update the buffered capture function to use this buffer.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:07:00 +0000 (19:07 +0200)]
staging:iio:ad7606: Use oversampling ratio of 1 for no oversampling
Currently the ad7606 driver uses a value of 0 for the oversampling ratio to
express that no oversampling is done. Strictly speaking this means though
that no data capture is done at all. Instead change the driver to use a
value of 1, this is in accordance with what other drivers do and what the
IIO spec suggests.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:06:59 +0000 (19:06 +0200)]
staging:iio:ad7606: Remove out-of-band error reporting
Currently the ad7606 driver prints a error message to the kernel log when
an application writes an invalid value to a sysfs attribute. While for
initial driver development and testing this might be useful it is quite
disadvantageous in a production environment. The write() call to the sysfs
attribute will already return an error if the value was invalid so the
application is aware that the operation failed. And generally speaking it
is impossible for an application to reliably match a log message in the
kernel log to a specific operation it performed, so the message becomes
just noise and might distract from more critical messages.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:06:58 +0000 (19:06 +0200)]
staging:iio:ad7606: Remove default device configuration from platform data
While for some very selected setups it might be useful to be able to
provide default configuration data via the platform data, generally this
becomes very impractical as the number of configuration options increases.
So the general policy is to use the power-on default values of the device
and let the application using the device configure it according to its
needs.
Implement this scheme for the ad7606 driver by removing support for
specifying a default configuration via the platform data.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:06:57 +0000 (19:06 +0200)]
staging:iio:ad7606: Remove redundant name field from ad7606_chip_info
The name field in the ad7606_chip_info struct is set to the same value as
the as the name field in the corresponding {platform,spi}_device_id table
entry. Remove it from the ad7606_chip_info struct and pass the name from
the ID to the probe function. This slightly reduces the size of the
chip_info table and adding new entries requires less boilerplate.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lars-Peter Clausen [Wed, 19 Oct 2016 17:06:56 +0000 (19:06 +0200)]
staging:iio:ad7606: Remove unused int_vref_mv field
Remove the int_vref_mv field from the ad7606_chip_info struct since the
field is never used by the driver. The value is also the same for all
derivatives of this chip, so if it will ever be used in the driver a
constant value will work just fine.
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Eva Rachel Retuya [Thu, 20 Oct 2016 09:19:24 +0000 (17:19 +0800)]
tools: iio: iio_generic_buffer: drop unneeded parentheses
Remove extra parentheses introduced in commit <73e176a tools: iio:
iio_generic_buffer: add -A to force-enable all channels>.
Suggested-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Eva Rachel Retuya [Thu, 20 Oct 2016 09:19:23 +0000 (17:19 +0800)]
tools: iio: iio_generic_buffer: rename and change type of force variable
Replace the type of 'force' flag from int to bool and at the same time
rename it to 'force_autochannels' for better readability.
Suggested-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Eva Rachel Retuya <eraretuya@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lorenzo Bianconi [Thu, 13 Oct 2016 20:06:05 +0000 (22:06 +0200)]
Documentation: dt: iio: humidity: add hts221 sensor device binding
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Lorenzo Bianconi [Thu, 13 Oct 2016 20:06:04 +0000 (22:06 +0200)]
iio: humidity: add support to hts221 rh/temp combo device
Add support to STM HTS221 humidity + temperature sensor
http://www.st.com/resource/en/datasheet/hts221.pdf
- continuous mode support
- i2c support
- spi support
- trigger mode support
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Alison Schofield [Sun, 16 Oct 2016 05:02:19 +0000 (22:02 -0700)]
iio: light: ltr501: claim direct mode during raw writes
Driver was checking for direct mode but not locking it. Use
claim/release helper functions to guarantee the device stays
in direct mode during all raw write operations.
Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Alison Schofield [Sun, 16 Oct 2016 05:00:53 +0000 (22:00 -0700)]
iio: light: ltr501: claim direct mode during select raw reads
Driver was checking for direct mode but not locking it. Use
claim/release helper functions to guarantee the device stays
in direct mode during required raw read cases.
Signed-off-by: Alison Schofield <amsfield22@gmail.com>
Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:18 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Move out of staging.
Now the driver is in a reasonable state, lets get it (finally) out
of staging.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:17 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 kernel docify comments that were nearly kernel doc.
Basic tidy up of comments to bring them into a standard style.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:16 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 small checkpatch fixes (alignment etc)
Tidied up where checkpatch warning suppressions doesn't effect the
readability of the code.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:15 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Tidy up probe order to avoid a race.
Previously the device was exposed to userspace and in kernel consumers
before the interrupts had been configured. As nothing stopped them being
enabled in the interval this could cause unhandled interrupts.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:14 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 replace non standard revision attr with dev_info on probe
There seems little point in being able to query the part revision number
via sysfs. Hence just put it in the kernel logs during probe incase
anyone ever wants to know.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:13 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Drop custom measurement mode attributes
This is now represented by the standard 3db filter frequency controls.
Things get complex wrt to the sampling frequency as these modes change
but that is fine under the IIO ABI where any value is allowed to effect
any other.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:12 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Add write support to the low pass filter control
Also includes an available attribute. The ordering of values appears
a bit random, but as the ABI doesn't specify this and we already have
both rising and falling lists I think this is fine.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:11 +0000 (17:39 +0100)]
staging:iio:accel:sca3000: Fix off by one error in axis due to IIO_NO_MOD
Given the introduction of IIO_NO_MOD was prior to the first submission
prior to IIO entering staging this has been broken for a while.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:10 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 add readback of the 3db low pass filter frequency
Driving towards getting rid of the non standard mode control interface.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:09 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Clean up register defines.
Introduce some more masks and generally drive towards consistent naming.
Note the small indents used to indicate parts of registers + parts of
multiplexed registers.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:08 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 use a 'fake' channel to handle freefall event registration.
This is an approach used in some newer drivers as it exposes the
compound channel events to the core rather than hiding their control
in sysfs attributes entirely via the driver.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:07 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 drop some unused variables.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:06 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 move to hybrid hard / soft buffer design.
In a similar fashion to other newer drivers (e.g. ti_am335x), instead
of using the hardware buffer support in IIO to directly access the hardware
fifo, insert a software fifo and feed that from the hardware one when
interrupts occur. This gives a simpler structure to the data flows and
allows more flexibility over how often data is shipped to userspace etc.
This was also the only direct user of the simplistic generalization found
in ring_hw.h so that header is removed.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:05 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Drop custom ABI for watersheds.
For now we support only the 50% watershed interrupt and start and stop it
as part of the buffer bring up. The 75% case may come back in future.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Jonathan Cameron [Sat, 8 Oct 2016 16:39:04 +0000 (17:39 +0100)]
staging:iio:accel:sca3000 Fix clearing of flag + setting of size of scan.
Not clearing the stuff_to_read flag can lead to a false flag being set
on restarting the buffer if the data was not all read the previous time.
The size of the scan is needed to ensure the function
iio_buffer_read_first_n_outer actually tries to read the data.
This stuff has been broken for some time so not stable material.
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>