summaryrefslogtreecommitdiffstats
path: root/drivers/iio/proximity
AgeCommit message (Collapse)AuthorFilesLines
2022-10-08Merge tag 'char-misc-6.1-rc1' of ↵Linus Torvalds4-17/+17
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc Pull char/misc and other driver updates from Greg KH: "Here is the large set of char/misc and other small driver subsystem changes for 6.1-rc1. Loads of different things in here: - IIO driver updates, additions, and changes. Probably the largest part of the diffstat - habanalabs driver update with support for new hardware and features, the second largest part of the diff. - fpga subsystem driver updates and additions - mhi subsystem updates - Coresight driver updates - gnss subsystem updates - extcon driver updates - icc subsystem updates - fsi subsystem updates - nvmem subsystem and driver updates - misc driver updates - speakup driver additions for new features - lots of tiny driver updates and cleanups All of these have been in the linux-next tree for a while with no reported issues" * tag 'char-misc-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc: (411 commits) w1: Split memcpy() of struct cn_msg flexible array spmi: pmic-arb: increase SPMI transaction timeout delay spmi: pmic-arb: block access for invalid PMIC arbiter v5 SPMI writes spmi: pmic-arb: correct duplicate APID to PPID mapping logic spmi: pmic-arb: add support to dispatch interrupt based on IRQ status spmi: pmic-arb: check apid against limits before calling irq handler spmi: pmic-arb: do not ack and clear peripheral interrupts in cleanup_irq spmi: pmic-arb: handle spurious interrupt spmi: pmic-arb: add a print in cleanup_irq drivers: spmi: Directly use ida_alloc()/free() MAINTAINERS: add TI ECAP driver info counter: ti-ecap-capture: capture driver support for ECAP Documentation: ABI: sysfs-bus-counter: add frequency & num_overflows items dt-bindings: counter: add ti,am62-ecap-capture.yaml counter: Introduce the COUNTER_COMP_ARRAY component type counter: Consolidate Counter extension sysfs attribute creation counter: Introduce the Count capture component counter: 104-quad-8: Add Signal polarity component counter: Introduce the Signal polarity component counter: interrupt-cnt: Implement watch_validate callback ...
2022-09-21iio: proximity: srf04: Use pm_ptr() to remove unused struct dev_pm_opsJonathan Cameron1-5/+5
If CONFIG_PM is not set, the pm_ptr() will ensure that the struct dev_pm_ops and callbacks are removed without the need for __maybe_unused markings. In this case we can't simply use DEFINE_RUNTIME_DEV_PM_OPS() because that would provide suspend and resume functions without the checks the driver is doing before calling runtime_pm functions (whether the necessary GPIO is provided). It may be possible to clean that up in future by moving the checks into the callbacks. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Andreas Klinger <ak@it-klinger.de> Link: https://lore.kernel.org/r/20220807185618.1038812-5-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: proximity: sx9360: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()Jonathan Cameron1-4/+4
These new macros avoid the need for marking the callbacks __maybe_unused whilst ensuring both callbacks and structure may be dropped by the compiler if CONFIG_PM_SLEEP is not enabled. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20220807185618.1038812-4-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: proximity: sx9324: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()Jonathan Cameron1-4/+4
These new macros avoid the need for marking the callbacks __maybe_unused whilst ensuring both callbacks and structure may be dropped by the compiler if CONFIG_PM_SLEEP is not enabled. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20220807185618.1038812-3-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-09-21iio: proximity: sx9310: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr()Jonathan Cameron1-4/+4
These new macros avoid the need for marking the callbacks __maybe_unused whilst ensuring both callbacks and structure may be dropped by the compiler if CONFIG_PM_SLEEP is not enabled. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Cc: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20220807185618.1038812-2-jic23@kernel.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-08-16i2c: Make remove callback return voidUwe Kleine-König2-6/+2
The value returned by an i2c driver's remove function is mostly ignored. (Only an error message is printed if the value is non-zero that the error is ignored.) So change the prototype of the remove function to return no value. This way driver authors are not tempted to assume that passing an error to the upper layer is a good idea. All drivers are adapted accordingly. There is no intended change of behaviour, all callbacks were prepared to return 0 before. Reviewed-by: Peter Senna Tschudin <peter.senna@gmail.com> Reviewed-by: Jeremy Kerr <jk@codeconstruct.com.au> Reviewed-by: Benjamin Mugnier <benjamin.mugnier@foss.st.com> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Reviewed-by: Crt Mori <cmo@melexis.com> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com> Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Acked-by: Marek Behún <kabel@kernel.org> # for leds-turris-omnia Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Petr Machata <petrm@nvidia.com> # for mlxsw Reviewed-by: Maximilian Luz <luzmaximilian@gmail.com> # for surface3_power Acked-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> # for bmc150-accel-i2c + kxcjk-1013 Reviewed-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> # for media/* + staging/media/* Acked-by: Miguel Ojeda <ojeda@kernel.org> # for auxdisplay/ht16k33 + auxdisplay/lcd2s Reviewed-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # for versaclock5 Reviewed-by: Ajay Gupta <ajayg@nvidia.com> # for ucsi_ccg Acked-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> # for iio Acked-by: Peter Rosin <peda@axentia.se> # for i2c-mux-*, max9860 Acked-by: Adrien Grassein <adrien.grassein@gmail.com> # for lontium-lt8912b Reviewed-by: Jean Delvare <jdelvare@suse.de> # for hwmon, i2c-core and i2c/muxes Acked-by: Corey Minyard <cminyard@mvista.com> # for IPMI Reviewed-by: Vladimir Oltean <olteanv@gmail.com> Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com> Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> # for drivers/power Acked-by: Krzysztof Hałasa <khalasa@piap.pl> Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfram Sang <wsa@kernel.org>
2022-07-18iio: proximity: cros_ec_mkbp: Switch to DEFINE_SIMPLE_DEV_PM_OPS() and ↵Jonathan Cameron1-4/+4
pm_sleep_ptr() Using these newer macros allows the compiler to remove the unused structure and functions when !CONFIG_PM_SLEEP + removes the need to mark pm functions __maybe_unused. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Enric Balletbo i Serra <enric.balletbo@collabora.com> Cc: Gwendal Grignou <gwendal@chromium.org> Cc: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20220621202719.13644-25-jic23@kernel.org
2022-07-16iio: proximity: sx_common: Allow IIO core to take care of firmware nodeAndy Shevchenko1-3/+0
IIO core correctly will take care of firmware node if it's not set in the driver. Drop ACPI and OF specifics from the driver and allow IIO core to handle this. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20220615114746.2767-2-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-07-16iio: proximity: sx_common: Don't use IIO device for propertiesAndy Shevchenko1-4/+3
It's not correct to use artificial device created by IIO core to retrieve device properties. Even ->get_default_reg() callback takes a simple struct device pointer which suggests it wants to operate on the real device. Correct this by replacing pointer to IIO device by a real device pointer in the caller of ->get_default_reg(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20220615114746.2767-1-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-07-14Merge tag 'iio-for-5.20a' of ↵Greg Kroah-Hartman8-17/+150
https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: IIO new device support, features and minor fixes for 5.20 Several on-running cleanup efforts dominate this time, plus the DMA safety alignment issue identified due to improved understanding of the restrictions as a result of Catalin Marinas' efforts in that area. One immutable branch in here due to MFD and SPMI elements needed for the qcom-rradc driver. Device support * bmi088 - Add support for bmi085 (accelerometer part of IMU) - Add support for bmi090l (accelerometer part of IMU) * mcp4922 - Add support for single channel device MCP4921 * rzg2l-adc - Add compatible and minor tweaks to support RZ/G2UL ADC * sca3300 - Add support for scl3300 including refactoring driver to support multiple device types and cleanup noticed whilst working on driver. * spmi-rradc - New driver for Qualcomm SPMI Round Robin ADC including necessary additional utility functions in SPMI core and related MFD driver. * ti-dac55781 - Add compatible for DAC121C081 which is very similar to existing parts. Features * core - Warn on iio_trigger_get() on an unregistered IIO trigger. * bma400 - Triggered buffer support - Activity and step counting - Misc driver improvements such as devm and header ordering * cm32181 - Add PM support. * cros_ec - Sensor location support * sx9324 - Add precharge resistor setting - Add internal compensation resistor setting - Add CS idle/sleep mode. * sx9360 - Add precharge resistor setting * vl53l0x - Handle reset GPIO, regulator and relax handling of irq type. Cleanup and minor fixes: Treewide changes - Cleanup of error handling in remove functions in many drivers. - Update dt-binding maintainers for a number of ADI bindings. - Several sets of conversion of drivers from device tree specific to generic device properties. Includes fixing up various related header and Kconfig issues. - Drop include of of.h from iio.h and fix up drivers that need to include it directly. - More moves of clusters of drivers into appropriate IIO_XXX namespaces. - Tree wide fix of a long running bug around DMA safety requirements. IIO was using __cacheline_aligned to pad iio_priv() structures. This worked for a long time by coincidence, but correct alignment is ARCH_KMALLOC_MINALIGN. As there is activity around this area, introduce an IIO local IIO_DMA_MINALIGN to allow for changing it in one place rather than every driver in future. Note, there have been no reports of this bug in the wild, and it may not happen on any platforms supported by upstream, so no rush to backport these fixes. Other cleanup * core - Switch to ida_alloc()/free() - Drop unused iio_get_time_res() - Octal permissions and DEVICE_ATTR_* macros. - Cleanup bared unsigned usage. * MAINTAINERS - Add include/dt-bindings/iio/ to the main IIO entry. * ad5380 - Comment syntax fix. * ad74413r - Call to for_each_set_bit_from(), with from value as 0 replaced. * ad7768-1 - Drop explicit setting of INDIO_BUFFER_TRIGGERED as now done by the core. * adxl345 - Fix wrong address in dt-binding example. * adxl367 - Drop extra update of FIFO watermark. * at91-sama5d2 - Limit requested watermark to the hwfifo size. * bmg160, bme680 - Typos * cio-dac - Switch to iomap rather than direct use of ioports * kxsd9 - Replace CONFIG_PM guards with new PM macros that let the compiler cleanly remove the unused code and structures when !CONFIG_PM * lsm6dsx - Use new pm_sleep_ptr() and EXPORT_SIMPLE_DEV_PM_OPS(). Then move to Namespace. * meson_saradc - general cleanup. - Avoid attaching resources to iio_dev->dev - Use same struct device for all error messages - Convert to dev_err_probe() and use local struct device *dev to reduce code complexity. - Use devm_clk_get_optional() instead of hand rolling. - Use regmap_read_poll_timeout() instead of hand rolling. * mma7660 - Drop ACPI_PTR() use that is unhelpful. * mpu3050 - Stop exporting symbols not used outside of module - Switch to new DEFINE_RUNTIME_DEV_PM_OPS() macro and move to Namespace. * ping - Typo fix * qcom-spmi-rradc - Typo fix * sc27xx - Convert to generic struct u32_fract * srf08 - Drop a redundant check on !val * st_lsm6dsx - Limit the requested watermark to the hwfifo size. * stm32-adc - Use generic_handle_domain_irq() instead of opencoding. - Fix handling of ADC disable. * stm32-dac - Use str_enabled_disable() instead of open coding. * stx104 - Switch to iomap rather than direct use of ioports * tsc2046 - Drop explicit setting of INDIO_BUFFER_TRIGGERED as now done by the core. * tsl2563 - Replace flush_scheduled_work() with cancel_delayed_work_sync() - Replace cancel_delayed_work() with cancel_delayed_work_sync() * vl53l0x - Make the VDD regulator optional by allowing a dummy regulator. * tag 'iio-for-5.20a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (244 commits) iio: adc: xilinx-xadc: Drop duplicate NULL check in xadc_parse_dt() iio: adc: xilinx-xadc: Make use of device properties iio: light: cm32181: Add PM support iio: adc: ad778-1: do not explicity set INDIO_BUFFER_TRIGGERED mode iio: adc: ti-tsc2046: do not explicity set INDIO_BUFFER_TRIGGERED mode iio: adc: stm32-adc: disable adc before calibration iio: adc: stm32-adc: make safe adc disable iio: dac: ad5380: align '*' each line and drop unneeded blank line iio: adc: qcom-spmi-rradc: Fix spelling mistake "coherrency" -> "coherency" iio: Don't use bare "unsigned" dt-bindings: iio: dac: mcp4922: expand for mcp4921 support iio: dac: mcp4922: add support to mcp4921 iio: chemical: sps30: Move symbol exports into IIO_SPS30 namespace iio: pressure: bmp280: Move symbol exports to IIO_BMP280 namespace iio: imu: bmi160: Move exported symbols to IIO_BMI160 namespace iio: adc: stm32-adc: Use generic_handle_domain_irq() proximity: vl53l0x: Make VDD regulator actually optional MAINTAINERS: add include/dt-bindings/iio to IIO SUBSYSTEM AND DRIVERS dt-bindings: iio/accel: Fix adi,adxl345/6 example I2C address iio: gyro: bmg160: Fix typo in comment ...
2022-06-20Merge tag 'iio-fixes-for-5.19a' of ↵Greg Kroah-Hartman1-0/+3
https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: 1st set of IIO fixes for the 5.19 cycle. Most of these have been in next for a long time. Unfortunately there was one stray patch in the branch (wasn't a fix), so I've just rebased to remove that. * testing - Fix a missing MODULE_LICENSE() warning by restricting possible build configs. * Various drivers - Fix ordering of iio_get_trigger() being called before iio_trigger_register() * adi,admv1014 - Fix dubious x & !y warning. * adi,axi-adc - Fix missing of_node_put() in error and normal paths. * aspeed,adc - Add missing of_node_put() * fsl,mma8452 - Fix broken probing from device tree. - Drop check on return value of i2c write to device to cause reset as ACK will be missing (device reset before sending it). * fsl,vf610 - Fix documentation of in_conversion_mode ABI. * iio-trig-sysfs - Ensure irq work has finished before freeing the trigger. * invensense,mpu3050 - Disable regulators in error path. * invensense,icm42600 - Fix collision of enum value of 0 with error path where 0 is no match. * renesas,rzg2l_Adc - Add missing fwnode_handle_put() in error path. * rescale - Fix a boolean logic bug for detection of raw + scale affecting an obscure corner case. * semtech,sx9324 - Check return value of read of pin_defs * st,stm32-adc: - Fix interaction across ADC instances for some supported devices. - Drop false spurious IRQ messages. - Fix calibration value handling. If we can't calibrate don't expose the vref_int channel. - Fix maximum clock rate for stm32pm15x * ti,ads131e08 - Add missing fwnode_handle_put() in error paths. * xilinx,ams - Fix variable checked for error from platform_get_irq() * x-powers,axp288 - Overide TS_PIN bias current for boards where it is not correctly initialized. * yamaha,yas530 - Fix inverted check on calibration data being all zeros. * tag 'iio-fixes-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (26 commits) iio:proximity:sx9324: Check ret value of device_property_read_u32_array() iio: accel: mma8452: ignore the return value of reset operation iio: adc: stm32: fix maximum clock rate for stm32mp15x iio: adc: stm32: fix vrefint wrong calibration value handling iio: imu: inv_icm42600: Fix broken icm42600 (chip id 0 value) iio: adc: vf610: fix conversion mode sysfs node name iio: adc: adi-axi-adc: Fix refcount leak in adi_axi_adc_attach_client iio: test: fix missing MODULE_LICENSE for IIO_RESCALE=m iio:humidity:hts221: rearrange iio trigger get and register iio:chemical:ccs811: rearrange iio trigger get and register iio:accel:mxc4005: rearrange iio trigger get and register iio:accel:kxcjk-1013: rearrange iio trigger get and register iio:accel:bma180: rearrange iio trigger get and register iio: afe: rescale: Fix boolean logic bug iio: adc: aspeed: Fix refcount leak in aspeed_adc_set_trim_data iio: adc: stm32: Fix IRQs on STM32F4 by removing custom spurious IRQs message iio: adc: stm32: Fix ADCs iteration in irq handler iio: adc: ti-ads131e08: add missing fwnode_handle_put() in ads131e08_alloc_channels() iio: adc: rzg2l_adc: add missing fwnode_handle_put() in rzg2l_adc_parse_properties() iio: trigger: sysfs: fix use-after-free on remove ...
2022-06-19iio:proximity:sx9324: Check ret value of device_property_read_u32_array()Aashish Sharma1-0/+3
0-day reports: drivers/iio/proximity/sx9324.c:868:3: warning: Value stored to 'ret' is never read [clang-analyzer-deadcode.DeadStores] Put an if condition to break out of switch if ret is non-zero. Signed-off-by: Aashish Sharma <shraash@google.com> Fixes: a8ee3b32f5da ("iio:proximity:sx9324: Add dt_binding support") Reported-by: kernel test robot <lkp@intel.com> [swboyd@chromium.org: Reword commit subject, add fixes tag] Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20220613232224.2466278-1-swboyd@chromium.org Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-18proximity: vl53l0x: Make VDD regulator actually optionalLuca Weiss1-1/+1
Contrary to what the naming might suggest, devm_regulator_get_optional returns -ENODEV in case the regulator is not found which will trigger probe error in this driver. Use devm_regulator_get instead which will return a dummy regulator that we can just use as if it was a proper regulator. Fixes: d3d6dba56dab ("proximity: vl53l0x: Handle the VDD regulator") Signed-off-by: Luca Weiss <luca.weiss@fairphone.com> Link: https://lore.kernel.org/r/20220614112049.302278-1-luca.weiss@fairphone.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-14iio: proximity: vcnl3020: Drop unnecessary alignment requirement for i2c deviceJonathan Cameron1-2/+2
I2C does not by default use buffers directly for DMA so there is no need to ensure they are DMA safe. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Ivan Mikhaylov <i.mikhaylov@yadro.com> Acked-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20220508175712.647246-88-jic23@kernel.org
2022-06-14iio: proximity: as3935: Fix alignment for DMA safetyJonathan Cameron1-1/+1
____cacheline_aligned is an insufficient guarantee for non-coherent DMA on platforms with 128 byte cachelines above L1. Switch to the updated IIO_DMA_MINALIGN definition. Fixes: 24ddb0e4bba4 ("iio: Add AS3935 lightning sensor support") Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Matt Ranostay <mranostay@gmail.com> Acked-by: Nuno Sá <nuno.sa@analog.com> Link: https://lore.kernel.org/r/20220508175712.647246-87-jic23@kernel.org
2022-06-14iio: sx9324: Add setting for CS idle modeStephen Boyd1-0/+16
Based on device tree setting, set the CS idle mode. Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220503193937.3794477-3-swboyd@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-14iio: sx9360: Add pre-charge resistor settingGwendal Grignou1-1/+14
Add ability to set the precharge internal resistance from the device tree. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220429220144.1476049-11-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-14iio: sx9324: Add Setting for internal analog gainGwendal Grignou1-0/+22
Based on device tree setting, set the internal analog gain. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220429220144.1476049-9-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-14iio: sx9324: Add Setting for internal compensation resistorGwendal Grignou1-1/+20
Based on device tree setting, set the internal compensation resistor. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220429220144.1476049-7-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-14iio: sx9324: Add precharge internal resistance settingGwendal Grignou1-0/+13
Add ability to set the precharge internal resistance from the device tree. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220429220144.1476049-5-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-14iio: sx9324: Fix register field spellingGwendal Grignou1-2/+2
Field for PROX_CTRL4 should contain PROX_CTRL4. Fixes: 4c18a890dff8d ("iio:proximity:sx9324: Add SX9324 support") Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220429220144.1476049-3-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11proximity: vl53l0x: Handle the reset GPIOMarkuss Broks1-0/+11
Handle the GPIO connected to the XSHUT/RST_N pin of VL53L0X. Signed-off-by: Markuss Broks <markuss.broks@gmail.com> Link: https://lore.kernel.org/r/20220523175344.5845-5-markuss.broks@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11proximity: vl53l0x: Handle the VDD regulatorMarkuss Broks1-0/+37
Handle the regulator supplying the VDD pin of VL53L0X. Signed-off-by: Markuss Broks <markuss.broks@gmail.com> Link: https://lore.kernel.org/r/20220523175344.5845-4-markuss.broks@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11proximity: vl53l0x: Prefer pre-initialized interrupt flagsMarkuss Broks1-1/+6
On some boards interrupt type might be different than falling edge, like hardcoded in driver. Leave interrupt flags as they were pre-configured from the device-tree. If they're not provided, default to falling edge interrupts. Signed-off-by: Markuss Broks <markuss.broks@gmail.com> Link: https://lore.kernel.org/r/20220523175344.5845-3-markuss.broks@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11iio: srf08: Remove redundant if statementLi Zhengyu1-1/+1
(!val) has been checked outside the loop, remove redundant (val &&) from loop. Signed-off-by: Li Zhengyu <lizhengyu3@huawei.com> Acked-by: Andreas Klinger <ak@it-klinger.de> Link: https://lore.kernel.org/r/20220523122755.90638-1-lizhengyu3@huawei.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11iio: proximity: ping: fix typo in commentJulia Lawall1-1/+1
Spelling mistake (triple letters) in comment. Detected with the help of Coccinelle. Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr> Link: https://lore.kernel.org/r/20220521111145.81697-54-Julia.Lawall@inria.fr Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-06-11iio: proximity: srf04: Make use of device propertiesAndy Shevchenko1-7/+4
Convert the module to be property provider agnostic and allow it to be used on non-OF platforms. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220504113557.59048-1-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-05-19Merge tag 'iio-for-5.19a' of ↵Greg Kroah-Hartman3-10/+10
https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next Jonathan writes: First set of IIO new device support, features and cleanup for 5.19 Usual mixed bag. Stand out this time is Andy Shevchenko's continuing effort to move drivers over the generic firmware interfaces. Device support * sprd,sc2720 - upm9620 binding addition. - Refactor and support for sc2720, sc2721 and sc2730. * ti,ads1015 - Refactor driver and add support for TLA2024. Device support (IDs only) * invensense,mpu6050 - Add ID for ICM-20608-D. * st,accel: - Add ID for lis302dl. * st,lsm6dsx - Add support for ASM330LHHX (can fallback to LSM6DSR.) Features * convert drivers to device properties - IIO core - adi,ad7266 - adi,adis16480 - adi,adxl355 - bosch,bmi160 - domintech,dmard06 - fsl,fxas21002c - invensense,mpu3050 - linear,ltc2983 - linear,ltc2632 - maxbotix,mb1232 - maxim,max31856 - maxim,max31865 - multiplexer - ping - rescale - taos,tsl2772 * core - Add runtime check on whether realbits fit in storagebits for each channel. * adi,ad_sigma_delta - Add sequencer support and relevant update_scan_mode callbacks for adi,ad7192 and adi,ad7124. Cleanup and minor fixes * MAINTAINERS - Update Lorenzo Bianconi's email address for IIO drivers. - Add entry for ad3552r and update maintainer in dt-binding doc. * tree-wide - Replace strtobool() with kstrtobool(). - Drop false OF dependencies. * core - Tidy up and document IIO modes. - Take iio_buffer_enabled() out of header allowing current_mode to be moved to the opaque structure. - As all kfifo buffers use the same mode value, drop that parameter and set it unconditionally. - White space fixes and similar. - Drop use of list iterator variable for list_for_each_entry_continue_reverse and use list_prepare_entry to restart. * sysfs-trigger - Replace use of 'found' variable with dedicate list iterator variable. * adi,ad7124 - Drop misleading shift. * adi,ad2s1210 - Remove redundant local variable assignment. * adi,adis16480 - Use local device pointer to reduce repetition. - Improve handling of clocks. * domintech,dmard09 - White space. * dummy driver - Improve error handling. * fsl,mma8452 - Add missing documentation of name element. * invensense,mpu3050 - Stop remove() returning non 0. * kionix,kxsd9 - White space. * linear,ltc2688 - Use local variable for struct device. - Combine of_node_put() error handling paths. * linear,ltc2983 - Avoid use of constants in messages where a define is available. * microchip,mcp4131 - Fix compatible in dt example. * pni,rm3100 - Stop directly accessing iio_dev->current_mode just to find out if the buffer is enabled. * renesas,rzg2l - Relax kconfig constraint to include newer devices. * sprd,sc27xx - Fix wrong scaling mask. - Improve the calibration values. * samsung,ssp - Replace a 'found' variable in favor of an explicit value that was found. * sensortek,stk3xx - Add proximity-near-level binding and driver support. * st,st_sensors: - Drop unused accel_type enum. - Return early in *_write_raw() - Drop unnecessary locking in _avail functions. - Add local lock to protect odr against concurrent updates allowing mlock to no longer be used outside of the core. - Use iio_device_claim_direct_mode() rather than racy checking of the current mode. * st,stmpe-adc - Fix checks on wait_for_completion_timeout(). - Allow use of of_device_id for matching. * st,stm32-dfsdm - Stop accessing iio_dev->current_mode to find out if the buffer is enabled (so we can hide that variable in the opaque structure) * st,vl53l0x - Fix checks on wait_for_completion_timeout. * ti,ads1015 - Add missing ID for ti,ads1115 in binding doc. - Convert from repeated chip ID look up to selecting static const data. - Switch to read_avail() callback. * ti,ads8688 - Use of_device_id for driver matching. * ti,palmas-adc - Drop a warning on minor calibration mismatch leading to slightly negative values after applying the calibration. * tag 'iio-for-5.19a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (95 commits) iio: ti-ads8688: use of_device_id for OF matching iio: stmpe-adc: use of_device_id for OF matching dt-bindings: iio: Fix incorrect compatible strings in examples iio: gyro: mpu3050: Make mpu3050_common_remove() return void iio: dac: ltc2632: Make use of device properties iio: temperature: max31865: Make use of device properties iio: proximity: mb1232: Switch to use fwnode_irq_get() iio: imu: adis16480: Improve getting the optional clocks iio: imu: adis16480: Use temporary variable for struct device iio: imu: adis16480: Make use of device properties staging: iio: ad2s1210: remove redundant assignment to variable negative iio: adc: sc27xx: add support for PMIC sc2730 iio: adc: sc27xx: add support for PMIC sc2720 and sc2721 iio: adc: sc27xx: refactor some functions for support more PMiCs iio: adc: sc27xx: structure adjustment and optimization iio: adc: sc27xx: Fine tune the scale calibration values iio: adc: sc27xx: fix read big scale voltage not right dt-bindings:iio:adc: add sprd,ump9620-adc dt-binding iio: proximity: stk3310: Export near level property for proximity sensor dt-bindings: iio: light: stk33xx: Add proximity-near-level ...
2022-04-28iio: proximity: mb1232: Switch to use fwnode_irq_get()Andy Shevchenko1-3/+5
We have OF-centric variant of fwnode_irq_get() in the driver. Replace it with a call to an agnostic implementation. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Acked-by: Andreas Klinger <ak@it-klinger.de> Link: https://lore.kernel.org/r/20220413183123.20292-1-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-28iio: proximity: vl53l0x: Fix return value check of wait_for_completion_timeoutMiaoqian Lin1-4/+3
wait_for_completion_timeout() returns unsigned long not int. It returns 0 if timed out, and positive if completed. The check for <= 0 is ambiguous and should be == 0 here indicating timeout which is the only error case. Fixes: 3cef2e31b54b ("iio: proximity: vl53l0x: Add IRQ support") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Link: https://lore.kernel.org/r/20220412064210.10734-1-linmq006@gmail.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-28iio: proximity: ping: Replace OF specific code by device_get_match_data()Andy Shevchenko1-3/+2
Instead of calling the OF specific API, use device_get_match_data(). Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Link: https://lore.kernel.org/r/20220413183421.20427-1-andriy.shevchenko@linux.intel.com Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-10iio: sx9324: Fix default precharge internal resistance registerGwendal Grignou1-2/+4
Fix the default value for the register that set the resistance: it has to be 0x10 per datasheet. Fixes: 4c18a890dff8d ("iio:proximity:sx9324: Add SX9324 support") Cc: stable@vger.kernel.org Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220406165011.10202-2-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-04iio:proximity:sx9324: Fix hardware gain read/writeStephen Boyd1-5/+21
There are four possible gain values according to 'sx9324_gain_vals[]': 1, 2, 4, and 8 The values are off by one when writing and reading the register. The bits should be set according to this equation: ilog2(<gain>) + 1 so that a gain of 8 is 0x4 in the register field and a gain of 4 is 0x3 in the register field, etc. Note that a gain of 0 is reserved per the datasheet. The default gain (SX9324_REG_PROX_CTRL0_GAIN_1) is also wrong. It should be 0x1 << 3, i.e. 0x8, not 0x80 which is setting the reserved bit 7. Fix this all up to properly handle the hardware gain and return errors for invalid settings. Fixes: 4c18a890dff8 ("iio:proximity:sx9324: Add SX9324 support") Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20220324222928.874522-1-swboyd@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-04-04iio:proximity:sx_common: Fix device property parsing on DT systemsStephen Boyd1-0/+1
After commit 7a3605bef878 ("iio: sx9310: Support ACPI property") we started using the 'indio_dev->dev' to extract device properties for various register settings in sx9310_get_default_reg(). This broke DT based systems because dev_fwnode() used in the device_property*() APIs can't find an 'of_node'. That's because the 'indio_dev->dev.of_node' pointer isn't set until iio_device_register() is called. Set the pointer earlier, next to where the ACPI companion is set, so that the device property APIs work on DT systems. Cc: Gwendal Grignou <gwendal@chromium.org> Fixes: 7a3605bef878 ("iio: sx9310: Support ACPI property") Signed-off-by: Stephen Boyd <swboyd@chromium.org> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20220331210425.3908278-1-swboyd@chromium.org Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-02-21iio:proximity:pulsedlight: Switch from CONFIG_PM guards to pm_ptr() etcJonathan Cameron1-5/+2
Letting the compiler remove these functions when the kernel is built without CONFIG_PM support is simpler and less error prone than the use of #ifdef based config guards. Removing instances of this approach from IIO also stops them being copied into new drivers. Acked-by: Matt Ranostay <matt.ranostay@konsulko.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20220130193147.279148-48-jic23@kernel.org
2022-02-18iio:proximity:sx9500: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etcJonathan Cameron1-6/+2
Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based config guards. Removing instances of this approach from IIO also stops them being copied into new drivers. Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20220130193147.279148-36-jic23@kernel.org
2022-02-18iio:proximity:rfd77492: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etcJonathan Cameron1-4/+3
Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based config guards. Removing instances of this approach from IIO also stops them being copied into new drivers. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20220130193147.279148-35-jic23@kernel.org
2022-02-18iio:proximity:as3935: Switch from CONFIG_PM_SLEEP guards to pm_sleep_ptr() etcJonathan Cameron1-8/+2
Letting the compiler remove these functions when the kernel is built without CONFIG_PM_SLEEP support is simpler and less error prone than the use of #ifdef based config guards. Removing instances of this approach from IIO also stops them being copied into new drivers. Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Acked-by: Matt Ranostay <matt.ranostay@konsulko.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Paul Cercueil <paul@crapouillou.net> Link: https://lore.kernel.org/r/20220130193147.279148-34-jic23@kernel.org
2022-02-13iio: as3935: Use devm_delayed_work_autocancel()Christophe JAILLET1-10/+2
Use devm_delayed_work_autocancel() instead of hand writing it. It saves a few lines of code. Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Link: https://lore.kernel.org/r/8d5c50f191bd8f751849d72127f83b14a7636d64.1644755396.git.christophe.jaillet@wanadoo.fr Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-30iio: sx9360: fix iio event generationJongpil Jung2-2/+2
To convert SX9360 status register ["REG_STAT"], into a channel index, we need to right shift by |stat_offset|, not left shift. Also the PROXSTAT bit (3) is for channel 1 (PHM, Phase Measured), not (PHR, Phase Reference, channel 0), so the offset is 2 instead of 3. Fixes: 1cdb4c47f7f5 ("iio:proximity:sx9360: Add sx9360 support") Signed-off-by: Jongpil Jung <jongpil19.jung@samsung.com> Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20220122213444.745152-1-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-23iio: as3935: Use sysfs_emit()Lars-Peter Clausen1-2/+2
sysfs_emit() is preferred over raw s*printf() for sysfs attributes since it knows about the sysfs buffer specifics and has some built-in checks for size and alignment. Use sysfs_emit() to format the custom `noise_level_tripped` device attribute of the as3935 driver. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Link: https://lore.kernel.org/r/20211216185217.1054495-6-lars@metafoo.de Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-23iio:proximity:vl53l0x: Tidy up white space around {} in id tablesJonathan Cameron1-1/+1
Previously inconsistent with a space after { but not before }. Tidy that up to avoid providing a bad example that might get copied into other drivers. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Ivan Drobyshevskyi <drobyshevskyi@gmail.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20211230174911.78291-16-jic23@kernel.org
2022-01-23iio:proximity:srf08: White space cleanup of spacing around {} in id tablesJonathan Cameron1-3/+3
The spacing in this driver was inconsistent with a space after the { but not before the }. Tidy this up to avoid providing a bad example to copy into new drivers. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Andreas Klinger <ak@it-klinger.de> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20211230174911.78291-10-jic23@kernel.org
2022-01-23iio:proximity:srf04: White space cleanup of spacing around {} in id tablesJonathan Cameron1-6/+6
The spacing in this driver was inconsistent with a space after the { but not before the }. Tidy this up to avoid providing a bad example to copy into new drivers. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Andreas Klinger <ak@it-klinger.de> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20211230174911.78291-9-jic23@kernel.org
2022-01-23iio:proximity:rfd77402: White space cleanup of spacing around {} in id tablesJonathan Cameron1-1/+1
The spacing in this driver was inconsistent with a space after the { but not before the }. Tidy this up to avoid providing a bad example to copy into new drivers. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20211230174911.78291-8-jic23@kernel.org
2022-01-23iio:proximity:ping: White space cleanup of spacing around {} in id tablesJonathan Cameron1-2/+2
The spacing in this driver was inconsistent so make sure we have a space after { and before } for the two id tables. Avoid providing examples of this inconsistency that get copied into new drivers. Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Cc: Andreas Klinger <ak@it-klinger.de> Reviewed-by: Gwendal Grignou <gwendal@chromium.org> Link: https://lore.kernel.org/r/20211230174911.78291-7-jic23@kernel.org
2022-01-23iio:proximity:sx9360: Add dt-binding supportGwendal Grignou1-0/+84
Add support to configure sx9360 from dt-binding, to match device hardware setup. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220101203800.290387-4-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-23iio:proximity:sx9360: Add sx9360 supportGwendal Grignou3-0/+824
A simplified version of SX9324, it only have one pin and 2 phases (aka channels). Only one event is presented. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220101203800.290387-2-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-23iio:proximity:sx9324: Add dt_binding supportGwendal Grignou1-0/+164
Based on bindings/iio/proximity/semtech,sx9324.yaml, implement retrieving sensor hardware property and alter default values. Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220101203817.290512-6-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2022-01-23iio:proximity:sx9324: Add SX9324 supportGwendal Grignou3-0/+919
Semtech SAR sensor SX9324 is an evolution of the SX9310: It has 4 phases that can be configured to capture and process data from any of 3 CS pins and provide independent detection: proximity, table proximity or body proximity. Gather antenna data: echo sx9324-dev3 > trigger/current_trigger echo 1 > scan_elements/in_proximity0_en echo 1 > buffer/enable od -v -An --endian=big -t d2 -w2 /dev/iio\:device3 (at 10Hz, the default). Trigger events: Setting: thresh_falling_period: 2 (events) thresh_rising_period: 2 (events) in_proximity0_thresh_either_value: 300 in_proximity0_thresh_either_hysteresis: 72 using iio_event_monitor /dev/iio\:deviceX, approaching my hand to the antenna pad, I see: ... Event: time: 1634763907532035297, type: proximity, channel: 0, evtype: thresh, direction: falling Event: time: 1634763910138104640, type: proximity, channel: 0, evtype: thresh, direction: rising ... Datasheet: https://edit.wpgdadawant.com/uploads/news_file/program/2019/30184/tech_files/program_30184_suggest_other_file.pdf Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-by: Stephen Boyd <swboyd@chromium.org> Link: https://lore.kernel.org/r/20220101203817.290512-4-gwendal@chromium.org Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>