aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/iio (follow)
AgeCommit message (Collapse)AuthorFilesLines
2019-10-27iio: imu: st_lsm6dsx: add support to LSM6DSRXLorenzo Bianconi6-5/+21
Add support to STM LSM6DSRX 6-axis (acc + gyro) Mems sensor https://www.st.com/resource/en/datasheet/lsm6dsrx.pdf Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-27iio: st: Drop GPIO includeLinus Walleij4-4/+0
None of the ST sensor drivers use any symbols from <linux/gpio.h>, just drop the include from all of them. Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22iio: adc: hx711: optimize performance in read cycleAndreas Klinger1-17/+5
Set gain in hx711_reset() to its default value after a reset cycle. This omits one precautionary read cycle, because the read is performed in hx711_set_gain_for_channel() anyway if gain has changed. Check for DOUT low and if its high wait some time if it goes down instead of doing a blind reset cycle when DOUT is not down. This is a performance optimization which allows to query the sensor with a higher frequency. Signed-off-by: Andreas Klinger <ak@it-klinger.de> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22iio: adc: stm32-adc: fix kernel-doc warningsFabrice Gasnier2-13/+19
Fix the following warnings when documentation is built: drivers/iio/adc/stm32-adc-core.c:62: warning: cannot understand function prototype: 'struct stm32_adc_common_regs ' drivers/iio/adc/stm32-adc-core.c:78: warning: cannot understand function prototype: 'struct stm32_adc_priv_cfg ' drivers/iio/adc/stm32-adc-core.c:123: warning: Function parameter or member 'pdev' not described in 'stm32f4_adc_clk_sel' drivers/iio/adc/stm32-adc.c:219: warning: cannot understand function prototype: 'struct stm32_adc_regs ' drivers/iio/adc/stm32-adc.c:237: warning: cannot understand function prototype: 'struct stm32_adc_regspec ' drivers/iio/adc/stm32-adc.c:264: warning: cannot understand function prototype: 'struct stm32_adc_cfg ' drivers/iio/adc/stm32-adc.c:323: warning: Function parameter or member 'difsel' not described in 'N' drivers/iio/adc/stm32-adc.c:323: warning: Function parameter or member 'pcsel' not described in 'stm32_adc' drivers/iio/adc/stm32-adc.c:371: warning: cannot understand function prototype: 'const struct stm32_adc_regs stm32f4_sq[STM32_ADC_MAX_SQ + 1] drivers/iio/adc/stm32-adc.c:417: warning: cannot understand function prototype: 'const struct stm32_adc_regs stm32f4_smp_bits[] = ' drivers/iio/adc/stm32-adc.c:508: warning: cannot understand function prototype: 'const struct stm32_adc_regs stm32h7_smp_bits[] = ' drivers/iio/adc/stm32-adc.c:1112: warning: Function parameter or member 'indio_dev' not described in 'stm32_adc_get_trig_extsel' drivers/iio/adc/stm32-adc.c:1420: warning: Function parameter or member 'indio_dev' not described in 'stm32_adc_debugfs_reg_access' drivers/iio/adc/stm32-adc.c:1420: warning: Function parameter or member 'reg' not described in 'stm32_adc_debugfs_reg_access' drivers/iio/adc/stm32-adc.c:1420: warning: Function parameter or member 'writeval' not described in 'stm32_adc_debugfs_reg_access' drivers/iio/adc/stm32-adc.c:1420: warning: Function parameter or member 'readval' not described in 'stm32_adc_debugfs_reg_access' Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22iio: pressure: zpa2326: fix iio_triggered_buffer_postenable positionAlexandru Ardelean1-7/+9
The iio_triggered_buffer_{predisable,postenable} functions attach/detach the poll functions. The iio_triggered_buffer_postenable() should be called before (to attach the poll func) and then the The iio_triggered_buffer_predisable() function is hooked directly without anything, which is probably fine, as the postenable() version seems to also do some reset/wake-up of the device. This will mean it will be easier when removing it; i.e. it just gets removed. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22iio: chemical: sgp30: drop excess semicolonJonathan Cameron1-1/+1
Suggested by coccinelle / coccicheck. CHECK drivers/iio/chemical/sgp30.c drivers/iio/chemical/sgp30.c:486:2-3: Unneeded semicolon Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Andreas Brauchli <a.brauchli@elementarea.net>
2019-10-22iio: adc: twl4030: Use false / true instead of 0 / 1 with booleansJonathan Cameron1-9/+9
Suggestion from coccinelle / coccicheck CHECK drivers/iio/adc/twl4030-madc.c drivers/iio/adc/twl4030-madc.c:524:6-15: WARNING: Comparison of 0/1 to bool variable drivers/iio/adc/twl4030-madc.c:655:1-43: WARNING: Assignment of 0/1 to bool variable drivers/iio/adc/twl4030-madc.c:659:2-44: WARNING: Assignment of 0/1 to bool variable drivers/iio/adc/twl4030-madc.c:664:1-43: WARNING: Assignment of 0/1 to bool variable drivers/iio/adc/twl4030-madc.c:498:2-34: WARNING: Assignment of 0/1 to bool variable drivers/iio/adc/twl4030-madc.c:510:2-19: WARNING: Assignment of 0/1 to bool variable drivers/iio/adc/twl4030-madc.c:511:2-11: WARNING: Assignment of 0/1 to bool variable drivers/iio/adc/twl4030-madc.c:531:2-19: WARNING: Assignment of 0/1 to bool variable drivers/iio/adc/twl4030-madc.c:532:2-11: WARNING: Assignment of 0/1 to bool variable Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Sebastian Reichel <sre@kernel.org>
2019-10-22iio: temperature: Add support for LTC2983Nuno Sá3-0/+1569
The LTC2983 is a Multi-Sensor High Accuracy Digital Temperature Measurement System. It measures a wide variety of temperature sensors and digitally outputs the result, in °C or °F, with 0.1°C accuracy and 0.001°C resolution. It can measure the temperature of all standard thermocouples (type B,E,J,K,N,S,R,T), standard 2-,3-,4-wire RTDs, thermistors and diodes. Signed-off-by: Nuno Sá <nuno.sa@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22iio: pressure: bmp280: use devm action and remove labels from probeBartosz Golaszewski4-45/+30
We can drop some duplicate code if we use devm_action for disabling regulators and pm and the managed variant of iio_device_register(). This allows us to completely remove all remove() callbacks from both i2c and spi code. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22iio: pressure: bmp280: use bulk regulator opsBartosz Golaszewski1-39/+30
The vddd and vdda supplies are always operated on together. We can shrink the code a bit by using the bulk regulator helpers. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-22iio: imu: Add support for the FXOS8700 IMURobert Jones6-0/+821
FXOS8700CQ is a small, low-power, 3-axis linear accelerometer and 3-axis magnetometer combined into a single package. The device features a selectable I2C or point-to-point SPI serial interface with 14-bit accelerometer and 16-bit magnetometer ADC resolution along with smart-embedded functions. FXOS8700CQ has dynamically selectable accelerationfull-scale ranges of ±2 g/±4 g/±8 g and a fixed magnetic measurement range of ±1200 μT. Output data rates (ODR) from 1.563 Hz to 800 Hz are selectable by the user for each sensor. Interleaved magnetic and acceleration data is available at ODR rates of up to 400 Hz. FXOS8700CQ is available in a plastic QFN package and it is guaranteed to operate over the extended temperature range of –40 °C to +85 °C. TODO: Trigger and IRQ configuration support Datasheet: http://cache.freescale.com/files/sensors/doc/data_sheet/FXOS8700CQ.pdf Signed-off-by: Robert Jones <rjones@gateworks.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-18iio: adc: xilinx-xadc: use devm_platform_ioremap_resourceJonathan Cameron1-3/+1
Reduces local boilerplate. Suggested by coccinelle. CHECK drivers/iio/adc/xilinx-xadc-core.c drivers/iio/adc/xilinx-xadc-core.c:1184:1-11: WARNING: Use devm_platform_ioremap_resource for xadc -> base Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Manish Narani <manish.narani@xilinx.com> Reviewed-by: Sven Van Asbroeck <TheSven73@gmail.com>
2019-10-18iio: temp: maxim thermocouple: Drop unneeded semi colon.Jonathan Cameron1-1/+1
Identified by coccinelle CHECK drivers/iio/temperature/maxim_thermocouple.c drivers/iio/temperature/maxim_thermocouple.c:197:3-4: Unneeded semicolon Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
2019-10-18iio: adc: cpcap-adc: Fix missing IRQF_ONESHOT as only threaded handler.Jonathan Cameron1-1/+1
Coccinelle noticed: CHECK drivers/iio/adc/cpcap-adc.c drivers/iio/adc/cpcap-adc.c:1009:9-34: ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT As far as I can see this is a simple case of it should be specified but isn't. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Tony Lindgren <tony@atomide.com>
2019-10-18iio: adc: meson_saradc: use devm_platform_ioremap_resourceJonathan Cameron1-3/+1
Avoid local boilerplate. Suggested by coccinelle via coccicheck. CHECK drivers/iio/adc/meson_saradc.c drivers/iio/adc/meson_saradc.c:1218:1-5: WARNING: Use devm_platform_ioremap_resource for base Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com> Cc: Neil Armstrong <narmstrong@baylibre.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-18iio: adc: exynos: use devm_platform_ioremap_resourceJonathan Cameron1-3/+1
Reduce local boilerplate. Identified by coccinelle drivers/iio/adc/exynos_adc.c:792:1-11: WARNING: Use devm_platform_ioremap_resource for info -> regs Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-10-18iio: adc: exynos: Drop a stray semicolonJonathan Cameron1-1/+1
Identified by coccinelle drivers/iio/adc/exynos_adc.c:654:2-3: Unneeded semicolon Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
2019-10-18iio: proximity: pulsedlight v2: Tidy up an endian issueJonathan Cameron1-2/+3
Sparse identified the following CHECK drivers/iio/proximity/pulsedlight-lidar-lite-v2.c drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16 drivers/iio/proximity/pulsedlight-lidar-lite-v2.c:144:24: warning: cast to restricted __be16 This cleans up by adding a local variable to hold the value whilst it is __be16 before applying endian converstion into eventual destination. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Matt Ranostay <matt.ranostay@konsulko.com>
2019-10-18iio: pressure: bmp280 endian tidy upsJonathan Cameron1-7/+9
There is a somewhat interesting mixture of be16 and le16 going on in this one function. Changes here formalize that a little more. CHECK drivers/iio/pressure/bmp280-core.c drivers/iio/pressure/bmp280-core.c:215:35: warning: cast to restricted __le16 drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:229:37: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:230:36: warning: cast to restricted __be16 drivers/iio/pressure/bmp280-core.c:237:37: warning: cast to restricted __le16 Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
2019-10-18iio: gyro: mpu3050: Explicity make a 'poison' value big endianJonathan Cameron1-1/+1
This clearly has no actual affect but it does show sparse and similar static analysers that we are doing this intentionally. CHECK drivers/iio/gyro/mpu3050-core.c drivers/iio/gyro/mpu3050-core.c:546:48: warning: incorrect type in assignment (different base types) drivers/iio/gyro/mpu3050-core.c:546:48: expected restricted __be16 <noident> drivers/iio/gyro/mpu3050-core.c:546:48: got int Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
2019-10-18iio: chemical: sps30: Explicity truncate constant by maskingJonathan Cameron1-1/+1
When breaking up a constant to write to two 8 bit registers it isn't obvious to sparse that it was intentional. CHECK drivers/iio/chemical/sps30.c drivers/iio/chemical/sps30.c:120:30: warning: cast truncates bits from constant value (8004 becomes 4) So in the interests of minimising noisy warnings, let us add a mask. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Tomasz Duszynski <tduszyns@gmail.com>
2019-10-18iio: adc: stmpe-adc: Cleanup endian type of local variableJonathan Cameron1-1/+1
Nothing stops data being of type __be16, which fixes the warning: CHECK drivers/iio/adc/stmpe-adc.c drivers/iio/adc/stmpe-adc.c:202:29: warning: cast to restricted __be16 drivers/iio/adc/stmpe-adc.c:202:29: warning: cast to restricted __be16 drivers/iio/adc/stmpe-adc.c:202:29: warning: cast to restricted __be16 drivers/iio/adc/stmpe-adc.c:202:29: warning: cast to restricted __be16 Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: <philippe.schenker@toradex.com>
2019-10-18iio: adc: mcp320x: Tidy up endian types in type cast.Jonathan Cameron1-1/+1
Fixes the sparse warning: drivers/iio/adc/mcp320x.c:167:41: warning: incorrect type in argument 1 (different base types) drivers/iio/adc/mcp320x.c:167:41: expected restricted __be32 const [usertype] *p drivers/iio/adc/mcp320x.c:167:41: got unsigned int [usertype] *<noident> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Lukas Wunner <lukas@wunner.de>
2019-10-18iio: adc: at91-sama5d2: Replace 0 with NULL when clearing some pointers.Jonathan Cameron1-2/+2
Cleans up the sparse warning: CHECK drivers/iio/adc/at91-sama5d2_adc.c drivers/iio/adc/at91-sama5d2_adc.c:1486:31: warning: Using plain integer as NULL pointer drivers/iio/adc/at91-sama5d2_adc.c:1509:31: warning: Using plain integer as NULL pointer Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Eugen Hristev <eugen.hristev@microchip.com>
2019-10-18Merge branch 'ib-ab8500-5.4-rc1' into HEADJonathan Cameron3-0/+1229
Immutable branch as considerable overlap with mfd, power and hwmon.
2019-10-18iio: adc: New driver for the AB8500 GPADCLinus Walleij3-0/+1229
This is a new driver for the ST-Ericsson AB8500 GPADC, which replaces the old driver in drivers/mfd/ab8500-gpadc.c and thus gets rid of another necessarily different custom driver from the times before IIO existed. The AB8500 GPADC can convert 10 different channels and these are used for monitoring voltages in the U8500 chipset, some are used for battery charging, some for temperature monitoring. As this is very core functionality that a lot of drivers depend on and was formerly compiled in with the AB8500 core driver, we deafault it to 'y' in Kconfig: it can be compiled out but it is really not advisible: the platform can for example overheat if we do. Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: adc: intel_mrfld_adc: Add Basin Cove ADC driverVincent Pelletier3-0/+274
Exposes the ADC device present on, at least, Intel Merrifield platform. Based on work done by: Yang Bin <bin.yang@intel.com> Huiquan Zhong <huiquan.zhong@intel.com> Sumeet Pawnikar <sumeet.r.pawnikar@intel.com> Pavan Kumar S <pavan.kumar.s@intel.com> Though it has been heavily rewritten for upstream. Signed-off-by: Vincent Pelletier <plr.vincent@gmail.com> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: add support to LSM6DS0Lorenzo Bianconi5-2/+17
Add support to STM LSM6DS0 6-axis (acc + gyro) Mems sensor Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: fix gyro gain definitions for LSM9DS1Lorenzo Bianconi1-3/+4
Fix typos in gyro gain definitions for LSM9DS1 sensor Fixes: 52f4b1f19679 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: dac: ad7303: replace mlock with own lockAlexandru Ardelean1-4/+9
This change replaces indio_dev's mlock with the driver's own lock. The lock is mostly needed to protect state when changing the `dac_cache` info. The lock has been extended to `ad7303_read_raw()`, to make sure that the cache is updated if an SPI-write is already in progress. Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: add odr calibration featureMario Tesi3-3/+29
On LSM6DSO/LSM6DSR/LSM6DSOX/ASM330LHH and ISH330DHCX devices it is possible to trim the hardware timestamp resolution through the FREQ_FINE[7:0] bits of the INTERNAL_FREQ_FINE register, which contains the difference in percentage of the effective ODR (and timestamp rate) with respect to the typical value. The formula for calculating the effective ODR reported in the application notes has been linearized to the first order to simplify the calculation (pls. see note on source code). This change may be useful in the outcome of CTS tests regarding the SingleSensorTests and the SensorTest#testSensorTimeStamps for high ODRs Signed-off-by: Mario Tesi <mario.tesi@st.com> Acked-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: enable drdy-mask if availableLorenzo Bianconi3-0/+29
Enable drdy mask if available in order to mark invalid samples during sensor bootstrap phase Tested-by: Mario Tesi <mario.tesi@st.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: dac: stm32: add power management supportFabrice Gasnier2-33/+199
Add support for runtime PM & sleep. Provide pclk to regmap as registers access doesn't need full power (e.g. regulator). Always restore HFSEL when resuming. It may get lost depending on low power level that has been achieved. Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: enable wake-up event for LSM6DSOLorenzo Bianconi1-1/+24
Add missing wake-up register info for LSM6DSO/LSM6DSOX sensor Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: add missing kernel documenationLorenzo Bianconi1-0/+3
Add missing kernel doc for st_lsm6dsx_hw data structure Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Reviewed-by: Sean Nyekjaer <sean@geanix.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: add wakeup_source in st_sensors_platform_dataLorenzo Bianconi1-2/+4
Add the possibility to enable/disable wakeup source through st_sensors_platform_data and not only through device tree Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: fix checkpatch warningLorenzo Bianconi1-16/+19
Fix following checkpatch warnings: CHECK: Alignment should match open parenthesis +static int st_lsm6dsx_read_event(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, CHECK: Alignment should match open parenthesis +static int st_lsm6dsx_write_event(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, CHECK: Alignment should match open parenthesis +static int st_lsm6dsx_read_event_config(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, CHECK: Alignment should match open parenthesis +static int st_lsm6dsx_write_event_config(struct iio_dev *iio_dev, + const struct iio_chan_spec *chan, WARNING: line over 80 characters + if (dev->of_node && of_property_read_bool(dev->of_node, "wakeup-source")) Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: grab conf mutex in st_lsm6dsx_write_event_configLorenzo Bianconi1-0/+2
Always grub conf mutex in st_lsm6dsx_write_event_config since it can run concurrently with FIFO configuration Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: rely on st_lsm6dsx_update_bits_locked configuring eventsLorenzo Bianconi1-11/+14
Rely on st_lsm6dsx_update_bits_locked in st_lsm6dsx_write_event and st_lsm6dsx_event_setup routines since they can run concurrently with sensor hub configuration Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: always check enable_reg in st_lsm6dsx_event_setupLorenzo Bianconi1-12/+11
Check if enable_reg of event_settings data structure is defined before writing on it Fixes: b5969abfa8b8 ("iio: imu: st_lsm6dsx: add motion events") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Tested-by: Sean Nyekjaer <sean@geanix.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: move bdu/boot and reset register info in hw_settingsLorenzo Bianconi2-22/+99
Move bdu, boot and reset register definitions in hw_settings register map since not all supported sensors (e.g lsm9ds1) rely on the same definitions Fixes: 52f4b1f19679 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: do not access active-low/open-drain regs if not supportedLorenzo Bianconi2-14/+67
Move active low and open drain register definitions in hw_settings register map since not all supported sensors (e.g lsm9ds1) rely on the same definitions Fixes: 52f4b1f19679 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: move irq related definitions in irq_configLorenzo Bianconi2-108/+179
Group irq related definition in irq_config structure in st_lsm6dsx_settings. This is a preliminary patch to move OpenDrain/Active low registers in st_lsm6dsx_settings. Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Tested-by: Sean Nyekjaer <sean@geanix.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: add sanity check for read_fifo pointerLorenzo Bianconi2-0/+6
Check read_fifo pointer before using it since we can't assume it is always set adding new sensors. This patch fixes the following crash: irq 277: nobody cared (try booting with the "irqpoll" option) CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.3.0-rc5-00322-g792b824-dirty #7 Hardware name: Freescale i.MX6 Quad/DualLite (Device Tree) [<c0112750>] (unwind_backtrace) from [<c010d018>] (show_stack+0x10/0x14) [<c010d018>] (show_stack) from [<c0c2bfc8>] (dump_stack+0xd8/0x10c) [<c0c2bfc8>] (dump_stack) from [<c01923fc>] (__report_bad_irq+0x24/0xc0) [<c01923fc>] (__report_bad_irq) from [<c0192820>] (note_interrupt+0x27c/0x2dc) [<c0192820>] (note_interrupt) from [<c018f174>] (handle_irq_event_percpu+0x54/0x7c) [<c018f174>] (handle_irq_event_percpu) from [<c018f1d4>] (handle_irq_event+0x38/0x5c) [<c018f1d4>] (handle_irq_event) from [<c0193664>] (handle_level_irq+0xc8/0x154) [<c0193664>] (handle_level_irq) from [<c018df58>] (generic_handle_irq+0x20/0x34) [<c018df58>] (generic_handle_irq) from [<c053c348>] (mxc_gpio_irq_handler+0xc4/0xf8) [<c053c348>] (mxc_gpio_irq_handler) from [<c053c3e0>] (mx3_gpio_irq_handler+0x64/0xb8) [<c053c3e0>] (mx3_gpio_irq_handler) from [<c018df58>] (generic_handle_irq+0x20/0x34) [<c018df58>] (generic_handle_irq) from [<c018e550>] (__handle_domain_irq+0x64/0xe0) [<c018e550>] (__handle_domain_irq) from [<c0529610>] (gic_handle_irq+0x4c/0xa0) [<c0529610>] (gic_handle_irq) from [<c0101a70>] (__irq_svc+0x70/0x98) Exception stack(0xc1301f10 to 0xc1301f58 1f00: 00000001 00000006 00000000 c130c340 1f20: c1300000 c1308928 00000001 c1308960 00000000 c12b9db0 c1308908 00000000 1f40: 00000000 c1301f60 c0182010 c0109508 20000013 ffffffff [<c0101a70>] (__irq_svc) from [<c0109508>] (arch_cpu_idle+0x20/0x3c) [<c0109508>] (arch_cpu_idle) from [<c015ed70>] (do_idle+0x1bc/0x2bc) [<c015ed70>] (do_idle) from [<c015f204>] (cpu_startup_entry+0x18/0x1c) [<c015f204>] (cpu_startup_entry) from [<c1200e68>] (start_kernel+0x440/0x504) [<c1200e68>] (start_kernel) from [<00000000>] (0x0) handlers: [<62052c0d>] st_lsm6dsx_handler_irq threaded [<f2004b92>] st_lsm6dsx_handler_thread Fixes: 52f4b1f19679 ("iio: imu: st_lsm6dsx: add support for accel/gyro unit of lsm9ds1") Tested-by: Bobby Jones <rjones@gateworks.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: imu: st_lsm6dsx: use st_lsm6dsx_read_locked in st_lsm6dsx_report_motion_eventLorenzo Bianconi1-14/+20
Rely on st_lsm6dsx_read_locked in st_lsm6dsx_report_motion_event since it can run concurrently with sensor hub configuration. Move event related code in st_lsm6dsx_report_motion_event Fixes: 1aabad1fb5e9 ("iio: imu: st_lsm6dsx: add motion report function and call from interrupt") Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Tested-by: Sean Nyekjaer <sean@geanix.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: adc: max1027: Introduce 12-bit devices supportMiquel Raynal2-3/+39
Maxim's max12xx series is very similar to the max10xx series, with the difference of the measurements depth which is upgraded from 10 to 12 bits per channel. Everything else looks the same. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: adc: max1027: Prepare the introduction of different resolutionsMiquel Raynal1-42/+32
Maxim's max1027/29/31 series returns the measured voltages with a resolution of 10 bits. There is a very similar series, max1227/29/31 which works identically but uses a resolution of 12 bits. Prepare the support for these chips by turning the 'depth' into a macro parameter instead of hardcoding it everywhere. Also reorganize just a bit the macros at the top to avoid repeating tens of lines when adding support for a new chip. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: adc: max1027: Reset the device at probe timeMiquel Raynal1-0/+8
All the registers are configured by the driver, let's reset the chip at probe time, avoiding any conflict with a possible earlier configuration. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: adc: max1027: Make it optional to use interruptsMiquel Raynal1-27/+32
The chip has a 'start conversion' and a 'end of conversion' pair of pins. They can be used but this is absolutely not mandatory as regular polling of the value is totally fine with the current internal clocking setup. Turn the interrupts optional and do not error out if they are not inquired in the device tree. This has the effect to prevent triggered buffers use though. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2019-10-15iio: adc: max1027: Add debugfs register read supportMiquel Raynal1-2/+5
Until now, only write operations were supported. Force two bytes read operation when reading, which should fit most of the development purposes. Of course, extended operations like buffered reads on multiple channels or even temperature + voltage reads will not be read entirely. Usually, just starting a new operation will work but in any case a software reset (done through the debufs interface too) will return the device in a usable state. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>