Add support for active low interrupts (IRQF_TRIGGER_LOW and
IRQF_TRIGGER_FALLING). Configure the device as active high or low
according to the requested irq line.
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Configure sensor ODR just in hts221_write_raw() in order to avoid
to set device sample rate multiple times.
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
GENMASK(6, 3) in CTRL_REG1 and GENMASK(6, 2) in CTRL_REG2 are marked
reserved. Do not changed the original value (not declared in the
datasheet) during power-down/suspend routines.
Fixes: e4a70e3e7d (iio: humidity: add support to hts221 rh/temp device)
Fixes: b7079eeac5 (iio: humidity: hts221: add power management support)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Enable Block Data Update in hts221_probe() in order to avoid to reconfigure
it every time the sensor is enabled
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Move bit-shift in hts221_write_with_mask() instead of coding
the shift depth in the configured value. That change will be necessary
to fix an issue in device power-down procedure.
Simplify hts221_avg_list table management
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Add support for CCS811 VOC sensor. This patch adds support
for reading current and voltage across the sensor and TVOC
and equivalent CO2 values.
Scale and offset values have been computed according to datasheet:
- For current: raw value is in microamps
=> 0.001 scale to convert to milliamps
- For voltage: 1.65V = 1023, therefore 1650mV = 1023
=> 1650.0/1023 = 1.612903 scale to convert to millivolts
- For eCO2: raw value range is from 400ppm to 8192ppm.
=> (val - 400) * (100 - 0) / (8192 - 400) + 0 =
(val - 400) * 0.01283367 => offset: -400, scale = 0.012834
to get a percentage value
-For TVOC: raw value range is from 0ppb to 1187ppb.
=> (val - 0) * 100 / (1187 - 0) + 0 = val * 0.0842459 =>
scale = 0.084246 for getting a percentage value
Cc: Daniel Baluta <daniel.baluta@gmail.com>
Cc: Alison Schofield <amsfield22@gmail.com>
Signed-off-by: Narcisa Ana Maria Vasile <narcisaanamaria12@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
The gpiod API checks for NULL descriptors, so there is no need to
duplicate the check in the driver.
Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Drop static on a local variable, when the variable is initialized before
any possible use. Thus, the static has no benefit.
The semantic patch that fixes this problem is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@bad exists@
position p;
identifier x;
type T;
@@
static T x@p;
...
x = <+...x...+>
@@
identifier x;
expression e;
type T;
position p != bad.p;
@@
-static
T x@p;
... when != x
when strict
?x = e;
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
When adding maps to the list, they were added using list_add, which adds
them in LIFO order. When parsing using iio_channel_get_all(), these
elements are hence returned in reverse order. As a result, the iio_hwmon
mapping maps the first entry to the last channel and so on.
Signed-off-by: Gaurav Gupta <gauragup@cisco.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This adds support for STM32F4 Digital-To-Analog converter.
Add compatible configuration data to handle hfsel (not present
in stm32f4).
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Fix error message, there's no 'st,dac-channel' property, but 'reg'
(see https://lkml.org/lkml/2017/4/3/567).
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Don't populate array startup_lookup on the stack but instead make
it static. Makes the object code smaller.
Before:
text data bss dec hex filename
21754 5440 128 27322 6aba drivers/iio/adc/at91_adc.o
After:
text data bss dec hex filename
21613 5496 128 27237 6a65 drivers/iio/adc/at91_adc.o
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
In order to use the standard name convention rename H3LIS331DL_DRIVER_NAME
macro in H3LIS331DL_ACCEL_DEV_NAME
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Add H3LIS331DL, LIS331DL and LIS3LV02DL entries in st_accel_id_table
Fixes: 1e52fefc9b (iio: accel: Add support for the h3lis331dl accel)
Fixes: bbf5f037fa (iio: st_accel: support the LIS331DL sensor)
Fixes: 3acddf74f8 (iio: st-sensors: add support for lis3lv02d accel)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Making the const array startup_lookup static rather having it on the
stack saves 69 bytes. Add in missing int specifier to clean up a
checkpatch warning.
Before:
text data bss dec hex filename
10297 2800 128 13225 33a9 drivers/iio/adc/at91-sama5d2_adc.o
After:
text data bss dec hex filename
10140 2888 128 13156 3364 drivers/iio/adc/at91-sama5d2_adc.o
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Making the const array init_data static rather having it on the
stack saves us a couple hundreds of bytes:
Before:
text data bss dec hex filename
3175 848 0 4023 fb7 drivers/iio/accel/da311.o
After:
text data bss dec hex filename
2860 936 0 3796 ed4 drivers/iio/accel/da311.o
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Check return value from call to of_match_device()
in order to prevent a NULL pointer dereference.
In case of NULL print error message and return -ENODEV
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Check return value from call to of_match_device()
in order to prevent a NULL pointer dereference.
In case of NULL print error message and return -ENODEV
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Acked-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
This patch adds support for Diolan DLN2 ADC via IIO's ADC interface.
ADC is the fourth and final component of the DLN2 for the kernel.
Signed-off-by: Jack Andersen <jackoalan@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Add newlines to the macro definitions and use a more common style.
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
The LTC2741 and LTC2473 are single voltage ADC chips. The LTC2473
is similar to the LTC2471 but outputs a signed differential value.
Datasheet:
http://cds.linear.com/docs/en/datasheet/24713fb.pdf
Signed-off-by: Mike Looijmans <mike.looijmans@topic.nl>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Set up and use triggered buffer if there is irq defined for device in
device tree. Trigger producer triggers from rpr0521 drdy interrupt line.
Trigger consumer reads rpr0521 data to scan buffer.
Depends on previous commits of _scale and _offset.
Signed-off-by: Mikko Koivunen <mikko.koivunen@fi.rohmeurope.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This patch fixes the following checkpatch warnings:
Prefer 'unsigned int' to bare use of 'unsigned
Signed-off-by: Reno Farnesi <nfarnesi4@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Add device tree support for LPS22HB, LPS25H, LPS331AP, LPS001WP
pressure sensors
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Add device tree support for LIS3MDL and LSM303AGR magnetometer sensors
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Don't inflate the kernel size with data that isn't used. The conditional
declaration also fixes the following warning when building with clang:
drivers/iio/magnetometer/ak8975.c:704:36: error: variable 'ak_acpi_match'
is not needed and will not be emitted
[-Werror,-Wunneeded-internal-declaration]
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Add missing hooks in the LTC2497 IIO driver to allow hwmon mapping.
Signed-off-by: Gaurav Gupta <gauragup@cisco.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
The array stm32h7_adc_ckmodes_spec does not need to be in global scope, so
make it static.
Cleans up sparse warning:
"symbol 'stm32h7_adc_ckmodes_spec' was not declared. Should it be static?"
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Some part of the configuration are not touched after the probe
and if something goes wrong on writing the initial one,
the chip will misbehave.
Adding an error checking ensures that the inital configuration will
be written correctly. Moreover ensures that a sensible configuration
will be saved in driver data and used subsequently as intended.
Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Reported-by: Maarten Brock <m.brock@vanmierlo.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Initial channel should be the first available channel on
all configurations, so changing to channel 0 available on
all supported chips.
Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
Reported-by: Maarten Brock <m.brock@vanmierlo.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Open drain should work fine with rising or high level IRQs,
this code was due to some misunderstanding on my part.
Reported-by: Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Add a link to the TCS3472 datasheet in the AMS's website.
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This patch supports auxadc suspend/resume flow.
Disable auxadc clk and power in suspend function.
Enable axuadc clk and power in resume function.
Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Add open drain support in order to share requested IRQ line between
st_lsm6dsx device and other peripherals
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Add of_match_table for Measurement-Specialties htu21 temperature & humidity sensor and humidity part of MS8607 sensor
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Added support for suspend/resume functionality for the ADC IP
in sama5d2 SoC.
In order to enter Suspend to ram mode (backup + self refresh mode for
memory), in which the ADC IP is no longer powered, we need to reset the
pins to default state, for the scenario when they are also used for I2C
bus to communicate with the PMIC.
On resume, we need to reconfigure the ADC IP registers and reconfigure the
trigger registers in the case when the suspend procedure is done while
sysfs has the buffer and trigger enabled.
In the case the suspend happens exactly during a software triggered
conversion, the request will time out, because we reset and power down
the ADC.
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
In order to add proper device tree support give a more general name
to of_device_id table
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Move st_sensors_of_i2c_probe() in st_sensors_core and rename it in
st_sensors_of_name_probe(). That change is necessary to add device-tree
support in spi code otherwise the rest of the autodetection will fail
since spi->modalias (and indio_dev->name) will be set using compatible
string value that differs from standard sensor name
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Enable multiread by default for LIS3MDL since using I2C interface
the subaddr Msb is used to automatically increase the slave address
during multiple data read/write. In the same way, using SPI interface,
bit 1 in register address is used to enable auto-increment of the slave
address in multiple read/write.
Fixes: 872e79add7 (iio:magn: Add STMicroelectronics magn driver)
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@st.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
The integration time is controlled by the ATIME register only. However,
this register is written by i2c_smbus_write_word_data() in write_raw().
We actually don't need to write a subsequent register. So just use
i2c_smbus_write_byte_data() instead.
Cc: Peter Meerwald <pmeerw@pmeerw.net>
Cc: Jonathan Cameron <jic23@kernel.org>
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Acked-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
While the INA226 has a conversion ready flag (CVRF) in the R/W Mask/Enable
register with read-to-clear semantics, the corresponding bit of the INA219
(CNVR) is part of the bus voltage register. The flag is cleared by reading
the power register.
Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Added support for the external hardware trigger on pin ADTRG,
integrated the three possible edges into the driver
and created buffer management for data retrieval
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>