Граф коммитов

1233 Коммитов

Автор SHA1 Сообщение Дата
Alexandru Ardelean 07b6c9dc46 iio: stm32-dfsdm-adc: remove usage of iio_priv_to_dev() helper
We may want to get rid of the iio_priv_to_dev() helper. The reason is that
we will hide some of the members of the iio_dev structure (to prevent
drivers from accessing them directly), and that will also mean hiding the
implementation of the iio_priv_to_dev() helper inside the IIO core.

Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
may not be fast anymore, so a general idea is to try to get rid of the
iio_priv_to_dev() altogether.
The iio_priv() helper won't be affected by the rework, as the iio_dev
struct will keep a reference to the private information.

For this driver, not using iio_priv_to_dev(), means reworking some paths to
pass the iio device and using iio_priv() to access the private information.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-20 17:26:21 +01:00
Lars-Peter Clausen 8cb631ccbb iio: Remove superfluous of_node assignments
If a driver does not assign an of_node to a IIO device to IIO core will
automatically assign the of_node of the parent device. This automatic
assignment is done in the iio_device_register() function.

There is a fair amount of drivers that currently manually assign the
of_node of the IIO device. All but 4 of them can make use of the automatic
assignment though.

The exceptions are:
 * mxs-lradc-adc: Which uses the of_node of the parent of the parent.
 * stm32-dfsdm-adc, stm32-adc and stm32-dac: Which reference the of_node
   assigned to the IIO device before iio_device_register() is called.

All other drivers are updated to use automatic assignment. This reduces
the amount of boilerplate code involved in setting up the IIO device.

The patch has mostly been auto-generated with the following semantic patch

// <smpl>
@exists@
expression indio_dev;
expression parent;
@@
indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(&parent, ...)
...
-indio_dev->dev.of_node = parent.of_node;

@exists@
expression indio_dev;
expression parent;
@@
indio_dev = \(devm_iio_device_alloc\|iio_device_alloc\)(parent, ...)
...
-indio_dev->dev.of_node = parent->of_node;
// </smpl>

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 14:20:08 +01:00
Alexandru Ardelean 8f73a13f74 iio: remove left-over parent assignments
These were found by doing some shell magic:
------------
for file in $(git grep -w devm_iio_device_alloc | cut -d: -f1 | sort | uniq) ; do
	if grep 'parent =' $file | grep -v trig | grep -vq devm_; then
		echo "$file -> $(grep "parent =" $file)"
	fi
done
-----------

The output is bearable [after the semantic patch is applied].
There is a mix of trigger assignments with some iio device parent
assignments that are removed via this patch.

JC: A few more added via inspection of all parent =
statements in drivers/iio. Some of these may just have crossed with this
series, others were less obvious to scripting due to some cross
file / module boundary calls.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:50:04 +01:00
Alexandru Ardelean 2cbd54129f iio: remove left-over comments about parent assignment
These were obtained by doing a 'git diff | grep \/\*', in the previous diff
to find comments. These needed a bit more manual review, as the semantic
patch isn't great for catching these.

The result is:
 	/* Initialize Counter device and driver data */
 	/* Initialize IIO device */
 	/* Establish that the iio_dev is a child of the spi device */
 	/* Estabilish that the iio_dev is a child of the spi device */
 	/* Initiate the Industrial I/O device */
 	/* Establish that the iio_dev is a child of the device */
-	/* establish that the iio_dev is a child of the i2c device */
-	/* establish that the iio_dev is a child of the i2c device */
 	/* This is only used for removal purposes */
 	/* setup the industrialio driver allocated elements */
 	/* variant specific configuration */
 	/* Setup for userspace synchronous on demand sampling. */
 	st->readback_delay_us += 5; /* Add tWAIT */
-	/* Establish that the iio_dev is a child of the i2c device */
 	/* Establish that the iio_dev is a child of the i2c device */

Out of which, 4 are really left-over comments about parent assignment.
3 of them are removed by the semantic patch, as the comment removed (by
spatch) would be for an empty line.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:50:00 +01:00
Alexandru Ardelean d3be83244c iio: remove explicit IIO device parent assignment
This patch applies the semantic patch:
@@
expression I, P, SP;
@@
   I = devm_iio_device_alloc(P, SP);
   ...
-  I->dev.parent = P;

It updates 302 files and does 307 deletions.
This semantic patch also removes some comments like
'/* Establish that the iio_dev is a child of the i2c device */'

But this is is only done in case where the block is left empty.

The patch does not seem to cover all cases. It looks like in some cases a
different variable is used in some cases to assign the parent, but it
points to the same reference.
In other cases, the block covered by ... may be just too big to be covered
by the semantic patch.

However, this looks pretty good as well, as it does cover a big bulk of the
drivers that should remove the parent assignment.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:59 +01:00
Alexandru Ardelean 4027860dcc iio: Kconfig: at91_adc: add COMPILE_TEST dependency to driver
Since changes can come from all sort of places, it may make sense to have
this symbol as a dependency to make sure that the 'make allmodconfig' &&
'make allyesconfig' build rules cover this driver as well for a
compile-build/test.

It seemed useful [recently] when trying to apply a change for this.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Acked-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:52 +01:00
Alexandru Ardelean cd64d3579d iio: stm32-adc: remove usage of iio_priv_to_dev() helper
We may want to get rid of the iio_priv_to_dev() helper. The reason is that
we will hide some of the members of the iio_dev structure (to prevent
drivers from accessing them directly), and that will also mean hiding the
implementation of the iio_priv_to_dev() helper inside the IIO core.

Hiding the implementation of iio_priv_to_dev() implies that some fast-paths
may not be fast anymore, so a general idea is to try to get rid of the
iio_priv_to_dev() altogether.
The iio_priv() helper won't be affected by the rework, as the iio_dev
struct will keep a reference to the private information.

For this driver, not using iio_priv_to_dev(), means reworking some paths to
pass the iio device and using iio_priv() to access the private information.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Acked-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:49 +01:00
Rikard Falkeborn ce6c3736d9 iio: adc: max11100: Constify struct iio_chan_spec
max11100_channels is not modified and can therefore be made const to
allow the compiler to put it in read-only memory.

Before:
   text    data     bss     dec     hex filename
   3776    1168       0    4944    1350 drivers/iio/adc/max11100.o

After:
   text    data     bss     dec     hex filename
   3968     976       0    4944    1350 drivers/iio/adc/max11100.o

Signed-off-by: Rikard Falkeborn <rikard.falkeborn@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:33 +01:00
Jishnu Prakash 603375df11 iio: adc: Update debug prints
Change pr_err/pr_debug statements to dev_err/dev_dbg for
increased clarity.

Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:23 +01:00
Jishnu Prakash 35fbb7f00d iio: adc: Update return value checks
Clean up some return value checks to make code more compact.

Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:22 +01:00
Jishnu Prakash 082111e559 iio: adc: Add support for PMIC7 ADC
The ADC architecture on PMIC7 is changed as compared to PMIC5. The
major change from PMIC5 is that all SW communication to ADC goes through
PMK8350, which communicates with other PMICs through PBS when the ADC
on PMK8350 works in master mode. The SID register is used to identify the
PMICs with which the PBS needs to communicate. Add support for the same.

Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:21 +01:00
Jishnu Prakash 572e76e381 iio: adc: Add info property under adc_data
Add info property under adc_data to support adding ADC variants
which may use different iio_info than the one defined for PMIC5.

Signed-off-by: Jishnu Prakash <jprakash@codeaurora.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-06-14 11:49:19 +01:00
Linus Torvalds 80ef846e99 Staging/IIO driver patches for 5.8-rc1
Here is the large set of staging and IIO driver changes for 5.8-rc1
 
 Nothing major, but a lot of new IIO drivers are included in here, along
 with other core iio cleanups and changes.
 
 On the staging driver front, again, nothing noticable.  No new deletions
 or additions, just a ton of tiny cleanups all over the tree done by a
 lot of different people.  Most coding style, but many actual real fixes
 and cleanups that are nice to see.
 
 All of these have been in linux-next for a while with no reported
 issues.
 
 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
 -----BEGIN PGP SIGNATURE-----
 
 iG0EABECAC0WIQT0tgzFv3jCIUoxPcsxR9QN2y37KQUCXtzoAQ8cZ3JlZ0Brcm9h
 aC5jb20ACgkQMUfUDdst+ym9FwCgkW8WZJGnvHLjuuG8C01azCEh/KUAoJRji8jK
 4zCG8NxAPFsQ1QP2SZPq
 =jEyw
 -----END PGP SIGNATURE-----

Merge tag 'staging-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging

Pull staging/IIO driver updates from Greg KH:
 "Here is the large set of staging and IIO driver changes for 5.8-rc1

  Nothing major, but a lot of new IIO drivers are included in here,
  along with other core iio cleanups and changes.

  On the staging driver front, again, nothing noticable. No new
  deletions or additions, just a ton of tiny cleanups all over the tree
  done by a lot of different people. Most coding style, but many actual
  real fixes and cleanups that are nice to see.

  All of these have been in linux-next for a while with no reported
  issues"

* tag 'staging-5.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging: (618 commits)
  staging: rtl8723bs: Use common packet header constants
  staging: sm750fb: Add names to proc_setBLANK args
  staging: most: usb: init return value in default path of switch/case expression
  staging: vchiq: Get rid of VCHIQ_SERVICE_OPENEND callback reason
  staging: vchiq: move vchiq_release_message() into vchiq
  staging: vchi: Get rid of C++ guards
  staging: vchi: Get rid of not implemented function declarations
  staging: vchi: Get rid of vchiq_status_to_vchi()
  staging: vchi: Get rid of vchi_service_set_option()
  staging: vchi: Merge vchi_msg_queue() into vchi_queue_kernel_message()
  staging: vchiq: Move copy callback handling into vchiq
  staging: vchi: Get rid of vchi_queue_user_message()
  staging: vchi: Get rid of vchi_service_destroy()
  staging: most: usb: use function sysfs_streq
  staging: most: usb: add missing put_device calls
  staging: most: usb: use correct error codes
  staging: most: usb: replace code to calculate array index
  staging: most: usb: don't use error path to exit function on success
  staging: most: usb: move allocation of URB out of critical section
  staging: most: usb: return 0 instead of variable
  ...
2020-06-07 10:45:08 -07:00
Linus Torvalds 512b7d37ee - Core Frameworks
- Constify 'properties' attribute in core header file
 
  - New Drivers
    - Add support for Gateworks System Controller
    - Add support for MediaTek MT6358 PMIC
    - Add support for Mediatek MT6360 PMIC
    - Add support for Monolithic Power Systems MP2629 ADC and Battery charger
    - Rework Intel's SCU IPC collection
      - Eliminate near duplicate IPC functionality
      - Split out MFD related activities into a dedicated MFD driver
 
  - Fix-ups
    - Use new I2C API; htc-i2cpld
    - Remove superfluous code; sprd-sc27xx-spi
    - Improve error handling; stm32-timers
    - Device Tree additions/fixes; mt6397
    - Defer probe betterment; wm8994-core
    - Improve module handling; wm8994-core
    - Staticify; stpmic1
    - Trivial (spelling, formatting); tqmx86
 
  - Bug Fixes
    - Fix incorrect register/PCI IDs; intel-lpss-pci
    - Fix unbalanced Regulator API calls; wm8994-core
    - Fix double free(); wcd934x
    - Remove IRQ domain on failure; stmfx
    - Reset chip on resume; stmfx
    - Disable/enable IRQs on suspend/resume; stmfx
    - Do not use bulk writes on H/W which does not support them; max77620
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdrbJNaO+IJqU8IdIUa+KL4f8d2EFAl7XZXwACgkQUa+KL4f8
 d2FvCg/+M9ShYDptg1twDnCtMs9yAWpnTHVwTGeoAF4RkKapdAytlPfz2V8cr+jF
 5iiZM2iTRkkCdK9OQI+hPxRFXaRh3Ng6bgmzkp1VUGCT6VrcHCUmIpEcdOYnlzuY
 iLufFtXrcYGLSzfOn01jI25teeWfX4zuuNfeCWKESHAPHEZH2W5iep82s7GUP7c7
 a9IXOmQmvNYVIy7STswASI1qBcanc7MsDEN44fGZ5HbEONbFvogaQ26BUQJ+Ezc7
 YbV1QCvPFXYXvFD7S0oiAFhCEU0y1eWcrK8YUxVroGMt+Gx1FHWrDqUGFvJ5hE//
 itPr4ws9oiZHKn4xeItp7x8YVdxW6plor9h0j7NZkfVJV4/mjbPxQWpCvv3dHXKm
 NAbpeodEdxlrRdLI3HGiC6ZvIFjkUtrf+WFZoXS42F9BcxraSVxbK8LTaET4spja
 25VfswjIa3IUy1BB1eMl+Gd4LgcqIJ+FuSV6e4CCD7COhRQGEG3eyUOVNAC5Q/xI
 NcS9KhrDIayjPNZoNZPNHfiGxI+aWn4W71qMgx+t9wsDCMkjbN0xqcFaxoN/niti
 /GfaNZur/kjsewbg4oMjsjB1ytoG3saxFgWmL1XGGXJ3sxJaEyDa8iy8mhqVpj7m
 8C0g6uZiODveHRj4kn9hv1aR5AX1rTXADXrBJYvoxIU+43NWwhg=
 =746a
 -----END PGP SIGNATURE-----

Merge tag 'mfd-next-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd

Pull MFD updates from Lee Jones:
 "Core Frameworks:
   - Constify 'properties' attribute in core header file

  New Drivers:
   - Add support for Gateworks System Controller
   - Add support for MediaTek MT6358 PMIC
   - Add support for Mediatek MT6360 PMIC
   - Add support for Monolithic Power Systems MP2629 ADC and Battery charger

  Fix-ups:
   - Use new I2C API in htc-i2cpld
   - Remove superfluous code in sprd-sc27xx-spi
   - Improve error handling in stm32-timers
   - Device Tree additions/fixes in mt6397
   - Defer probe betterment in wm8994-core
   - Improve module handling in wm8994-core
   - Staticify in stpmic1
   - Trivial (spelling, formatting) in tqmx86

  Bug Fixes:
   - Fix incorrect register/PCI IDs in intel-lpss-pci
   - Fix unbalanced Regulator API calls in wm8994-core
   - Fix double free() in wcd934x
   - Remove IRQ domain on failure in stmfx
   - Reset chip on resume in stmfx
   - Disable/enable IRQs on suspend/resume in stmfx
   - Do not use bulk writes on H/W which does not support them in max77620"

* tag 'mfd-next-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (29 commits)
  mfd: mt6360: Remove duplicate REGMAP_IRQ_REG_LINE() entry
  mfd: Add support for PMIC MT6360
  mfd: max77620: Use single-byte writes on MAX77620
  mfd: wcd934x: Drop kfree for memory allocated with devm_kzalloc
  mfd: stmfx: Disable IRQ in suspend to avoid spurious interrupt
  mfd: stmfx: Fix stmfx_irq_init error path
  mfd: stmfx: Reset chip on resume as supply was disabled
  mfd: wm8994: Silence warning about supplies during deferred probe
  mfd: wm8994: Fix unbalanced calls to regulator_bulk_disable()
  mfd: wm8994: Fix driver operation if loaded as modules
  dt-bindings: mfd: mediatek: Add MT6397 Pin Controller
  mfd: Constify properties in mfd_cell
  mfd: stm32-timers: Use dma_request_chan() instead dma_request_slave_channel()
  mfd: sprd: Remove unnecessary spi_bus_type setting
  mfd: intel-lpss: Update LPSS UART #2 PCI ID for Jasper Lake
  mfd: tqmx86: Fix a typo in MODULE_DESCRIPTION
  mfd: stpmic1: Make stpmic1_regmap_config static
  mfd: htc-i2cpld: Convert to use i2c_new_client_device()
  MAINTAINERS: Add entry for mp2629 Battery Charger driver
  power: supply: mp2629: Add impedance compensation config
  ...
2020-06-04 10:38:42 -07:00
Saravanan Sekar 7abd9fb646 iio: adc: mp2629: Add support for mp2629 ADC driver
Add support for 8-bit resolution ADC readings for input power
supply and battery charging measurement. Provides voltage, current
readings to mp2629 power supply driver.

Signed-off-by: Saravanan Sekar <sravanhome@gmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
2020-05-26 10:41:47 +01:00
Greg Kroah-Hartman c2312ff575 Merge 5.7-rc7 into staging-next
We need the staging/iio fixes in here as well.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-05-25 09:11:19 +02:00
Fabrice Gasnier 10134ec3f8 iio: adc: stm32-adc: fix a wrong error message when probing interrupts
A wrong error message is printed out currently, like on STM32MP15:
- stm32-adc-core 48003000.adc: IRQ index 2 not found.

This is seen since commit 7723f4c5ec ("driver core: platform: Add an
error message to platform_get_irq*()").
The STM32 ADC core driver wrongly requests up to 3 interrupt lines. It
should request only the necessary IRQs, based on the compatible:
- stm32f4/h7 ADCs share a common interrupt
- stm32mp1, has one interrupt line per ADC.
So add the number of required interrupts to the compatible data.

Fixes: d58c67d1d8 ("iio: adc: stm32-adc: add support for STM32MP1")
Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-22 17:29:25 +01:00
Krzysztof Kozlowski 786b44a3b5 iio: adc: exynos: Simplify Exynos7-specific init
The Exynos7-specific code bits in ADC driver do not play with PHY:
the field exynos_adc_data.needs_adc_phy is not set in exynos7_adc_data
instance.  Therefore the initialization code does not have to check if
it is true.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com>
Tested-by:  Alim Akhtar <alim.akhtar@samsung.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-16 17:36:53 +01:00
Jonathan Bakker 754718a5b4 iio: adc: Add scaling support to exynos adc driver
Currently the driver only exposes the raw counts.  As we
have the regulator voltage and the maximum value (stored in
the data mask), we can trivially produce a scaling fraction
of voltage / max value.

This assumes that the regulator voltage is in fact the max
voltage, which appears to be the case for all mainline dts
and cross referenced with the public Exynos4412 and S5PV210
datasheets.

Signed-off-by: Jonathan Bakker <xc-racer2@live.ca>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-16 17:31:12 +01:00
Greg Kroah-Hartman cef077e6aa Second set of new device support, cleanups and features for IIO in the 5.8 cycle
Usual mixed back but with a few subsystem wide or device type
 wide cleanups.
 
 New device support
 
 * adis16475
   - New driver supporting adis16470, adis16475, adis16477, adis16465,
     adis16467, adis16500, adis16505 and adis16507.
     Includes some rework of the adis library to simplify using it
     for this new driver.
 * ak8974
   - Add support for Alps hscdt008a. ID only. Related patches add support
     for scale.
 * atlas-sensor
   - Add support for RTD-SM OEM temperature sensor.
 * cm32181
   - Add support for CM3218 including support for SMBUS alert via
     ACPI resources.
 * ltc2632
   - Add support for ltc2634-12/10/8 DACS including handling per
     device type numbers of channels.
 
 Major Features
 
 * cm32181
   - ACPI bindings including parsing CPM0 and CPM1 custom ACPI tables.
     Includes minor tidy ups and fixes.
 * vcnl4000
   - Add event support
   - Add buffered data capture support
   - Add control of sampling frequency
 
 Cleanups and minor fixes.
 
 * core
   - Trivial rework of iio_device_alloc to use an early return and
     improve readability.
   - Precursors to addition of multiple buffer support. So far
     minor refactoring.
 * subsystem wide
   - Use get_unaligned_be24 slightly improve readability over open
     coding it.
 * adis drivers
   - Use iio_get_debugfs_dentry access function.
 * bh1780, cm32181, cm3232, gp2ap02a00f, opt3001, st_uvis25, vl6180,
   dmard06, kxsd9
   - Drop use of of_match_ptr to allow ACPI based probing via PRP0001.
     Part of clear out of this to avoid cut and paste into new drivers.
 * ad5592r, ad5593r
   - Fix typos
 * ad5933
   - Use managed interfaces to automate error handling and remove.
 * ak8974
   - Fix wrong number of 'real bits' for buffered data.
   - Refactor to pull measurement code out as separate function.
     bmp280
   - Fix lack of clamp on range during data capture.
 * at91-sama5d2_adc
   - Handle unfinished conversions correctly.
   - Allow use of triggers other than it's own.
   - Reorganize buffer setup and tear down as part of long running
     subsystem wide rework.
 * ccs811
   - Add DT binding docs and match table.
   - Support external reset and wakeup pins.
 * hid-sensors
   - Reorganize buffer setup and tear down as part of long running
     subsystem wide rework.
 * ltr501
   - Constify some structs.
 * vcnl4000
   - Fix an endian issue by using explicit byte swapped i2c accessors.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl666PYRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FohMRQ//ZvDdYRB883lW11iRZJhnzpFhClNbzEp1
 2wxEqMOaLQmf6MntRX6LWmN15EGmQw1Eu2SBCt3G5XRMWKvtxaLnERKYxds67qtP
 uhTJDnfcDUYa6ACEHYs0FSfdmUL3S/7qmdKsABU+86o4LGzyb/jblWruB+6jOWyJ
 vRtMGUC8QP2RA2hq5UNJ3au1tlIS3IYqkmh1A1IXD8OtNW/EGpwFUMsmtRGd99gI
 lJb9VtlAF2bxqUBJuvludrRs8HMHafKRm9WM7+pJX7w2waSsiMMFojB7jDlJTAW/
 J2Zb5UGSUHMwJNLmhr+t1BjeAtO9AVzQsK80e+GXxjyb7rv1IKSt9eFUfev1jCuR
 lws3+QhwamGrxh7sFG4NFaWkZmmj5SSPTMqI+GCjm1VTL+vb3rh0MBjgn9/RNPux
 lEhscgEmq0w3BJPX08G8tZ4yipZbO4ZMmuQC3Gx2iPqO80xJqD+XpD5jz4MciGBC
 MDfWMamlnGk3n1sb4TIm0vPCtkz471DX5TyVLPLatcPnwWtu1zH380BD9HGVfnBN
 Fommp6YKvlpOCHOgl4vNg9pLKyUAukQbM8V0lPfk3NWQdswABmzDYJqh4HJWADxT
 uLiW8VgDfeq7CVPL+wwfWV3S9edu/REZa2f9y6qV/3eCyK0XId2CVHr8WpqbQIOR
 p6jjJHfzPNU=
 =mYqq
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

Second set of new device support, cleanups and features for IIO in the 5.8 cycle

Usual mixed back but with a few subsystem wide or device type
wide cleanups.

New device support

* adis16475
  - New driver supporting adis16470, adis16475, adis16477, adis16465,
    adis16467, adis16500, adis16505 and adis16507.
    Includes some rework of the adis library to simplify using it
    for this new driver.
* ak8974
  - Add support for Alps hscdt008a. ID only. Related patches add support
    for scale.
* atlas-sensor
  - Add support for RTD-SM OEM temperature sensor.
* cm32181
  - Add support for CM3218 including support for SMBUS alert via
    ACPI resources.
* ltc2632
  - Add support for ltc2634-12/10/8 DACS including handling per
    device type numbers of channels.

Major Features

* cm32181
  - ACPI bindings including parsing CPM0 and CPM1 custom ACPI tables.
    Includes minor tidy ups and fixes.
* vcnl4000
  - Add event support
  - Add buffered data capture support
  - Add control of sampling frequency

Cleanups and minor fixes.

* core
  - Trivial rework of iio_device_alloc to use an early return and
    improve readability.
  - Precursors to addition of multiple buffer support. So far
    minor refactoring.
* subsystem wide
  - Use get_unaligned_be24 slightly improve readability over open
    coding it.
* adis drivers
  - Use iio_get_debugfs_dentry access function.
* bh1780, cm32181, cm3232, gp2ap02a00f, opt3001, st_uvis25, vl6180,
  dmard06, kxsd9
  - Drop use of of_match_ptr to allow ACPI based probing via PRP0001.
    Part of clear out of this to avoid cut and paste into new drivers.
* ad5592r, ad5593r
  - Fix typos
* ad5933
  - Use managed interfaces to automate error handling and remove.
* ak8974
  - Fix wrong number of 'real bits' for buffered data.
  - Refactor to pull measurement code out as separate function.
    bmp280
  - Fix lack of clamp on range during data capture.
* at91-sama5d2_adc
  - Handle unfinished conversions correctly.
  - Allow use of triggers other than it's own.
  - Reorganize buffer setup and tear down as part of long running
    subsystem wide rework.
* ccs811
  - Add DT binding docs and match table.
  - Support external reset and wakeup pins.
* hid-sensors
  - Reorganize buffer setup and tear down as part of long running
    subsystem wide rework.
* ltr501
  - Constify some structs.
* vcnl4000
  - Fix an endian issue by using explicit byte swapped i2c accessors.

* tag 'iio-for-5.8b' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (74 commits)
  iio: light: ltr501: Constify structs
  staging: iio: ad5933: attach life-cycle of kfifo buffer to parent device and use managed calls throughout
  iio: bmp280: fix compensation of humidity
  iio: light: cm32181: Fix integartion time typo
  iio: light: cm32181: Add support for parsing CPM0 and CPM1 ACPI tables
  iio: light: cm32181: Make lux_per_bit and lux_per_bit_base_it runtime settings
  iio: light: cm32181: Use units of 1/100000th for calibscale and lux_per_bit
  iio: light: cm32181: Change reg_init to use a bitmap of which registers to init
  iio: light: cm32181: Handle CM3218 ACPI devices with 2 I2C resources
  iio: light: cm32181: Clean up the probe function a bit
  iio: light: cm32181: Add support for the CM3218
  iio: light: cm32181: Add some extra register defines
  iio: light: cm32181: Add support for ACPI enumeration
  iio: light: cm32181: Switch to new style i2c-driver probe function
  iio: hid-sensors: move triggered buffer setup into hid_sensor_setup_trigger
  iio: vcnl4000: Add buffer support for VCNL4010/20.
  iio: vcnl4000: Add sampling frequency support for VCNL4010/20.
  iio: vcnl4000: Add event support for VCNL4010/20.
  iio: vcnl4000: Factorize data reading and writing.
  iio: vcnl4000: Fix i2c swapped word reading.
  ...
2020-05-15 16:03:28 +02:00
Fabrice Gasnier b455d06e6f iio: adc: stm32-dfsdm: fix device used to request dma
DMA channel request should use device struct from platform device struct.
Currently it's using iio device struct. But at this stage when probing,
device struct isn't yet registered (e.g. device_register is done in
iio_device_register). Since commit 71723a96b8 ("dmaengine: Create
symlinks between DMA channels and slaves"), a warning message is printed
as the links in sysfs can't be created, due to device isn't yet registered:
- Cannot create DMA slave symlink
- Cannot create DMA dma:rx symlink

Fix this by using device struct from platform device to request dma chan.

Fixes: eca949800d ("IIO: ADC: add stm32 DFSDM support for PDM microphone")

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 14:16:49 +01:00
Fabrice Gasnier 52cd91c27f iio: adc: stm32-adc: fix device used to request dma
DMA channel request should use device struct from platform device struct.
Currently it's using iio device struct. But at this stage when probing,
device struct isn't yet registered (e.g. device_register is done in
iio_device_register). Since commit 71723a96b8 ("dmaengine: Create
symlinks between DMA channels and slaves"), a warning message is printed
as the links in sysfs can't be created, due to device isn't yet registered:
- Cannot create DMA slave symlink
- Cannot create DMA dma:rx symlink

Fix this by using device struct from platform device to request dma chan.

Fixes: 2763ea0585 ("iio: adc: stm32: add optional dma support")

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 14:15:38 +01:00
Gregory CLEMENT bcfa1e253d iio: adc: ti-ads8344: Fix channel selection
During initial submission the selection of the channel was done using
the scan_index member of the iio_chan_spec structure. It was an abuse
because this member is supposed to be used with a buffer so it was
removed.

However there was still the need to be able to known how to select a
channel, the correct member to store this information is address.

Thanks to this it is possible to select any other channel than the
channel 0.

Fixes: 8dd2d7c0fe ("iio: adc: Add driver for the TI ADS8344 A/DC chips")
Signed-off-by: Gregory CLEMENT <gregory.clement@bootlin.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 14:09:25 +01:00
Colin Ian King a66904b209 iio: adc: ad7476: remove redundant null check on an array
The null check on st->chip_info->convst_channel is redundant because
convst_channel is a 2 element array of struct iio_chan_spec objects
and this can never be null. Fix this by removing the null check.

Addresses-Coverity: ("Array compared against 0")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 09:47:21 +01:00
Andy Shevchenko 3321f29e4f iio: adc: ti-ads124s08: Use get_unaligned_be24()
This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 09:47:18 +01:00
Andy Shevchenko 1608327636 iio: adc: mpc3422: Use get_unaligned_beXX()
This makes the driver code slightly easier to read.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 09:47:18 +01:00
Andy Shevchenko c1909ab07f iio: adc: ad_sigma_delta: Use {get,put}_unaligned_be24()
This makes the driver code slightly easier to read.

Cc: Lars-Peter Clausen <lars@metafoo.de>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-05-03 09:47:18 +01:00
Greg Kroah-Hartman e8014d83f6 Merge 5.7-rc3 into staging-next
We need the staging fixes in here too, and this resolves a merge issue
with the vt6656 driver.

Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2020-04-27 12:20:40 +02:00
Alexandru Ardelean f3c034f617 iio: at91-sama5d2_adc: adjust iio_triggered_buffer_{predisable,postenable} positions
The iio_triggered_buffer_{predisable,postenable} functions attach/detach
poll functions.

In most cases the iio_triggered_buffer_postenable() should be called first
to attach the poll function, and then the driver can init the data to be
triggered.
In this case it's the other way around: the DMA code should be initialized
before the attaching the poll function and the reverse should be done when
un-initializing.

To make things easier when removing the iio_triggered_buffer_postenable() &
iio_triggered_buffer_predisable() functions from the IIO core API, the DMA
code has been moved into preenable() for init, and postdisable() for
uninit.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Reviewed-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 16:04:19 +01:00
Alexandru Ardelean 065056cb0d iio: at91-sama5d2_adc: split at91_adc_current_chan_is_touch() helper
This change moves the logic to check if the current channel is the
touchscreen channel to a separate helper.
This reduces some code duplication, but the main intent is to re-use this
in the next patches.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Reviewed-by: Eugen Hristev <eugen.hristev@microchip.com>
Reviewed-by: Ludovic Desroches <ludovic.desroches@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 15:57:07 +01:00
Eugen Hristev abb7e84d29 iio: adc: at91-sama5d2_adc: update for other trigger usage
This change will allow the at91-sama5d2_adc driver to use other triggers
than it's own.
In particular, tested with the sysfs trigger.
To be able to achieve this functionality, some changes were required:
1) Do not enable/disable channels when enabling/disabling the trigger.
This is because the trigger is enabled/disabled only for our trigger
(obviously). We need channels enabled/disabled regardless of what trigger is
being used.
2) Cope with DMA : DMA cannot be used when using another type of trigger.
Other triggers work through pollfunc, so we get polled anyway on every trigger.
Thus we have to obtain data at every trigger.
3) When to start conversion? The usual pollfunc (store time from subsystem)
would be in hard irq and this would be a good way, but current iio subsystem
recommends to have it in the threaded irq. Thus adding software start
code in this handler.
4) Buffer config: we need to setup buffer regardless of our own device's
trigger. We may get one attached later.
5) IRQ handling: we use our own device IRQ only if it's our own trigger
and we do not use DMA . If we use DMA, we use the DMA controller's IRQ.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 15:52:35 +01:00
Eugen Hristev 97c54cf2a4 iio: adc: at91-sama5d2_adc: handle unfinished conversions
It can happen that on IRQ trigger, not all conversions are done if
we are enabling multiple channels.
The IRQ is triggered on first EOC (end of channel), but it can happen
that not all channels are done. This leads into erroneous reports to
userspace (zero values or previous values).
To solve this, in trigger handler, check if the mask of done channels
is the same as the mask of active scan channels.
If it's the same, proceed and push to buffers. Otherwise, use usleep
to sleep until the conversion is done or we timeout.
Normally, it should happen that in a short time fashion, all channels are
ready, since the first IRQ triggered.
If a hardware fault happens (for example the clock suddently dissappears),
the handler will not be completed, in which case we do not report anything to
userspace anymore.
Also, change from using the EOC interrupts to DRDY interrupt.
This helps with the fact that not 'n' interrupt statuses are enabled,
each being able to trigger an interrupt, and instead only data ready
interrupt can wake up the CPU. Like this, when data is ready, check in
handler which and how many channels are done. While the DRDY is raised,
other IRQs cannot occur. Once the channel data is being read, we ack the
IRQ and finish the conversion.

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-25 15:51:21 +01:00
Greg Kroah-Hartman 4e1d96306d First set of new IIO device support, features and cleanup for the 5.8 cycle
Usual mix of new drivers, new support in old drivers and lots of minor
 cleanup. Yaml conversions also continue to trickle in (plenty more to go!)
 
 New device support
 * ad7476
   - Add ad7091 support (ID only)
 * ad9467
   - New driver for this 200/250 MSPS adi-axi-adc and SPI attached ADC.
 * adi-axi-adc
   - New driver to support ADIs generic AXI ADC IP core, used to provide
     high speed interfaces to ADCs (JESD204B/C or parallel interfaces). Usually
     paired with a device using a slow configuration interface (spi etc)
     Includes DT bindings and some fixes for fpga headers.
 * bmg160
   - Add support for BMI088 (ID only)
 * max1241
   - New driver for this ADC.
 * st_sensors
   - Add support for LIS2HH12 accelerometer
 * sx9310
   - New driver supporting sx9310 and sx9311 proximity sensors.
 
 Yaml DT binding conversions
 * rockchip-saradc (including adding some missing parts)
 * stm32-dac
 * tsl2563
 * vcnl4000
 
 Features
 * st_lsm6dsx
   - Add LIS3MDL as a possible sensor hub device.
 * vcnl4000
   - Add new concept of near level (from DT) to provide to userspace which
     often needs to have some calibrated concept of 'near'.
 
 Cleanups, minor fixes etc.
 * core
   - Use snprintf for functions where strings are built and there is
     potential for overflow.
   - Correct docs to indicate mlock should not be used directly by drivers.
   - Fix up accidental dropping of a patch to use bitmap_zalloc.
   - Stop allowing enabling of buffers with no channels enabled.
   - Drop unused 'stufftoread' from iio_buffer.
   - Drop scan_el_attrs form iio_buffer as unused.
   - Reorder sanity checks in __iio_device_register to fail earlier.
   - Drop all the devm_ runregister / free functions from IIO as they
     were never used and encourage poor design.
 * dma-buffer
   - Tidy up includes.
 * dma-engine-buffer
   - Provide dev-managed allocator.
   - Fix an issue with printing a size_t
 * cross subsystem (kxsd9, bmg160, mpu3050, bmi160, mpu6050, bmc150)
   - Replace some unnecessary casts of error ptrs and whilst there.
     use the %pe printf parameter to print them in a more useful fashion.
 * cross subsystem
   - Drop casts in calls to regmap_bulk_read as they make no sense.
   - Use devm_platform_ioremap_resource to reduce boilerplate.
   - Fix typos in Analog Devices.
 * counters/104-quad
   - Add Syed Nayyar Waris as an additional maintainer.
 * ad7476
   - Generate CONVST signal internally rather than requiring external
     trigger.  Add sysfs read back as can now do so.
   - use devm_add_action_or_reset to tidy up error and remove handling.
 * ad7793
   - Switch to read_avail from explicit attribute. Mostly done to avoid
     confusing people with a - sign (without surounding spaces) that
     was correct but checkpatch didn't like.
 * adis library
   - Add missing newlines at end of error messages.
 * adis16400
   - Use DEFINE_DEBUGS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTR.
 * adis16460
   - Use DEFINE_DEBUGS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTR.
 * ad_sigma_delta
   - Move some channel definitions into individual drivers to avoid
     having to deal with complex options.
 * ak8974
   - Silence an error on deffered probe.
 * bmp280
   - Harden against IRQ before registration.
   - Convert to read_avail instead of opencoding the equivalent.
   - Explicitly mark GPIO as optional.
   - Cleanup casts.
   - Remove line breaks from strings.
 * htts221
   - Replace direct access to platform_data with dev_get_platdata().
   - Use device properties rather than device tree ones to allow ACPI
     probing.
   - Casting cleanups.
 * intel_mrfld_adc
   - Don't use unaligned accessor for aligned data.
 * isl29125
   - Reorder buer pre and post hooks to allow for coming core rework.
 * ltc2983
   - Remove comp to bool.
 * max1363
   - Stop using mlock from the iio_dev directly in favour of a local lock
     with clearly defined scope.
 * max30100
   - Use generic device properties to allow ACPI probe.
 * mpu6050
   - Convert to i2c_new_client_device.
   - Add debugfs register access.
 * st_lsm6dsx
   - Provide means of configuring full scale on slave device if supported.
   - Drop include of st_sensors header to get one value. Its not otherwise
     used by this driver.
 * st-sensors
   - Replace direct access to platform_data with dev_get_platdata().
   - Casting cleanups.
   - Avoid splitting strings.
 * st_uvis25
   - Casting cleanups.
 * tsl2563
   - Typo fix.
 * tsl2772
   - scnprintf in a non obvious string building usecase. Note also 'fixes'
     a wrong calculation of remaining space that couldn't actually cause
     any trouble as there was lots of room.
 * xilinx-xadc
   - Fix Lars-Peter spelling his own name wrong :) + additional typos.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl6gicARHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foj3ig//XRAAHRSfzXFpvYxITVKDIGwP/giYdp91
 OflGw/0aOZFExr72ENLmCArXZPOT2qAZyNNoDNvuJ9SkcVDf4bT3w9gYwWtJ1sd7
 Hhh+1JpPspSo6vS85FMjm37UDfSbmYqB6wC57cZ5pKQIiJwi6W2hGsyOoOXmfLLc
 57d3mlg4g3KLl9Hl4UTU84gE1ushKQgNxVH21Y71pOTa8p+xbWWcspWjR2Jf+kVZ
 qPr2+2rP/AjeAVLu9SKfdBiczYQCNR3uFWKkOKsBE9fq3sbcN6NT5DktrSJUH+qU
 zfUGmShCEP908/9fARazXQZcTOX1tIUOnrpHG9l54GNPh3S2Qk9xGaZxvQy5sguC
 AmC4p+MaIMrMcgWMk9po+nE5INJq7HBV/0jnADG307wEhFrKrjh/2PtP4f9k/Mcv
 sHB7K1+dcJAUwFb5gccdDBfmKMnwfnGS8OFGLXZZKBIDqSvptmIs/pmavjEPgqhV
 GwGTDPyZKeyDnyhTXGafxii03Q2I62Zte5l4jcZ+q8Q4UMxQovEkX6IvUpXwA0Kk
 eoxedbgdvzxrDNiNrXa0k6CLzqSQW+aVHgJG+HEig4IXQse8zXb11HCs35zq5r4j
 JI2UjLk3zUHLiNR/Ir9fKAbPwWSWv3IWkfmFEEUWvUFjM+Xot1Hg+61vBTFKo4iK
 EIqqPZmd5Mk=
 =DyTF
 -----END PGP SIGNATURE-----

Merge tag 'iio-for-5.8a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-next

Jonathan writes:

First set of new IIO device support, features and cleanup for the 5.8 cycle

Usual mix of new drivers, new support in old drivers and lots of minor
cleanup. Yaml conversions also continue to trickle in (plenty more to go!)

New device support
* ad7476
  - Add ad7091 support (ID only)
* ad9467
  - New driver for this 200/250 MSPS adi-axi-adc and SPI attached ADC.
* adi-axi-adc
  - New driver to support ADIs generic AXI ADC IP core, used to provide
    high speed interfaces to ADCs (JESD204B/C or parallel interfaces). Usually
    paired with a device using a slow configuration interface (spi etc)
    Includes DT bindings and some fixes for fpga headers.
* bmg160
  - Add support for BMI088 (ID only)
* max1241
  - New driver for this ADC.
* st_sensors
  - Add support for LIS2HH12 accelerometer
* sx9310
  - New driver supporting sx9310 and sx9311 proximity sensors.

Yaml DT binding conversions
* rockchip-saradc (including adding some missing parts)
* stm32-dac
* tsl2563
* vcnl4000

Features
* st_lsm6dsx
  - Add LIS3MDL as a possible sensor hub device.
* vcnl4000
  - Add new concept of near level (from DT) to provide to userspace which
    often needs to have some calibrated concept of 'near'.

Cleanups, minor fixes etc.
* core
  - Use snprintf for functions where strings are built and there is
    potential for overflow.
  - Correct docs to indicate mlock should not be used directly by drivers.
  - Fix up accidental dropping of a patch to use bitmap_zalloc.
  - Stop allowing enabling of buffers with no channels enabled.
  - Drop unused 'stufftoread' from iio_buffer.
  - Drop scan_el_attrs form iio_buffer as unused.
  - Reorder sanity checks in __iio_device_register to fail earlier.
  - Drop all the devm_ runregister / free functions from IIO as they
    were never used and encourage poor design.
* dma-buffer
  - Tidy up includes.
* dma-engine-buffer
  - Provide dev-managed allocator.
  - Fix an issue with printing a size_t
* cross subsystem (kxsd9, bmg160, mpu3050, bmi160, mpu6050, bmc150)
  - Replace some unnecessary casts of error ptrs and whilst there.
    use the %pe printf parameter to print them in a more useful fashion.
* cross subsystem
  - Drop casts in calls to regmap_bulk_read as they make no sense.
  - Use devm_platform_ioremap_resource to reduce boilerplate.
  - Fix typos in Analog Devices.
* counters/104-quad
  - Add Syed Nayyar Waris as an additional maintainer.
* ad7476
  - Generate CONVST signal internally rather than requiring external
    trigger.  Add sysfs read back as can now do so.
  - use devm_add_action_or_reset to tidy up error and remove handling.
* ad7793
  - Switch to read_avail from explicit attribute. Mostly done to avoid
    confusing people with a - sign (without surounding spaces) that
    was correct but checkpatch didn't like.
* adis library
  - Add missing newlines at end of error messages.
* adis16400
  - Use DEFINE_DEBUGS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTR.
* adis16460
  - Use DEFINE_DEBUGS_ATTRIBUTE rather than DEFINE_SIMPLE_ATTR.
* ad_sigma_delta
  - Move some channel definitions into individual drivers to avoid
    having to deal with complex options.
* ak8974
  - Silence an error on deffered probe.
* bmp280
  - Harden against IRQ before registration.
  - Convert to read_avail instead of opencoding the equivalent.
  - Explicitly mark GPIO as optional.
  - Cleanup casts.
  - Remove line breaks from strings.
* htts221
  - Replace direct access to platform_data with dev_get_platdata().
  - Use device properties rather than device tree ones to allow ACPI
    probing.
  - Casting cleanups.
* intel_mrfld_adc
  - Don't use unaligned accessor for aligned data.
* isl29125
  - Reorder buer pre and post hooks to allow for coming core rework.
* ltc2983
  - Remove comp to bool.
* max1363
  - Stop using mlock from the iio_dev directly in favour of a local lock
    with clearly defined scope.
* max30100
  - Use generic device properties to allow ACPI probe.
* mpu6050
  - Convert to i2c_new_client_device.
  - Add debugfs register access.
* st_lsm6dsx
  - Provide means of configuring full scale on slave device if supported.
  - Drop include of st_sensors header to get one value. Its not otherwise
    used by this driver.
* st-sensors
  - Replace direct access to platform_data with dev_get_platdata().
  - Casting cleanups.
  - Avoid splitting strings.
* st_uvis25
  - Casting cleanups.
* tsl2563
  - Typo fix.
* tsl2772
  - scnprintf in a non obvious string building usecase. Note also 'fixes'
    a wrong calculation of remaining space that couldn't actually cause
    any trouble as there was lots of room.
* xilinx-xadc
  - Fix Lars-Peter spelling his own name wrong :) + additional typos.

* tag 'iio-for-5.8a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio: (101 commits)
  iio: magnetometer: ak8974: Silence deferred-probe error
  Documentation: ABI: document IIO in_proximity_nearlevel file
  iio: vcnl4000: Export near level property for proximity sensor
  dt-bindings: iio: light: vcnl4000: Add proximity-near-level
  dt-bindings: iio: Introduce common properties for iio sensors
  dt-bindings: iio: vcnl4000: convert bindings to YAML format
  iio: Fix misspellings of "Analog Devices"
  iio: light: isl29125: fix iio_triggered_buffer_{predisable,postenable} positions
  iio: adc: fsl-imx25-gcq: Use devm_platform_ioremap_resource
  iio: adc: at91-adc: Use devm_platform_ioremap_resource
  iio: adc: sun4i-gpadc-iio: Use devm_platform_ioremap_resource
  iio:light:ltr501: Drop unnecessary cast of parameter in regmap_bulk_read
  iio:magn:mmc35240: Drop unnecessary casts of val parameter in regmap_bulk*
  iio:imu:mpu6050: Tidy up parameters to regmap_bulk functions.
  iio:chemical:bme680: Tidy up parameters to regmap_bulk_read
  iio:chemical:atlas-sensor: Drop unnecessary explicit casts in regmap_bulk_read calls
  iio:accel:mxc4005: Drop unnecessary explicit casts in regmap_bulk_read calls
  iio: imu: st_lsm6dsx: drop huge include in sensor-hub driver
  iio: buffer: drop devm_iio_kfifo_free() API call
  iio: buffer: drop devm_iio_hw_consumer_free() API call
  ...
2020-04-23 11:06:48 +02:00
Greg Kroah-Hartman c532cc617e First set of IIO fixes for the 5.7 cycle.
Includes one MAINTAINERS update to avoid people getting a lot of bounce
 messages and complaining about it.
 
 * MAINTAINERS
   - Drop Stefan Popa's Analog Devices email address in favour of
     Michael Hennerich.
 * core
   - Fix handling of dB sysfs inputs.
   - Drop a stray semi colon in macro definition.
 * ad5770r
   - Fix an off by one in chec on maximum number of channels.
 * ad7192
   - Fix a null pointer de-reference due to the name previously being
     retrieved from the spi_get_device_id call which no longer works as
     the relevant table was removed.
 * ad7797
   - Use correct attribute group.
 * counter/104-quad-8
   - Add locks to prevent some race conditions.
 * inv-mpu6050
   - Fix issues around suspend / resume clashing with runtime PM.
 * stm32-adc
   - Fix sleep in invalid context
   - Fix id relative path error in device tree binding doc.
 * st_lsm6dsx
   - Fix a read alignment issue on an untagged FIFO.
   - Handle odr for slave to properly compute the FIFO data layout / pattern.
   - Flush the HW FIFO before resettting the device to avoid a race on
     interrupt line 1.
 * st_sensors
   - Rely on ODR mask not ODR address to identify if the ODR can be set.
     Some devices have an ODR address of 0.
 * ti-ads8344
   - Byte ordering was wrong - fix it.
 * xilinx-xadc
   - Fix inverted logic in powering down the second ADC.
   - Fix clearing interrupt when enabling the trigger.
   - Fix configuration of sequencer when in simultaneous sampling mode.
   - Limit initial sampling rate as done for runtime configured ones.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAl6cgbkRHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0Foj/qg//c1TF2fhXEuGNua2M9PzaO+UgEkymF5lD
 R9bQPOPLXesTxmIZDIPWuIYaoFOIBrB6Kc9DvE8+7apVc0I/JFYmuXSjY1LGoBj5
 6WSrbtfAHYD5HBY/ZQq92iw+feFlctWtpp7H6Ngy2c7lQy8OKMhrHOA1NgbC++HH
 5OA5uoMD7Fo0mvAGY7/74DiJFEKG/PUUrGWSbH792Mh0EmvXgyFkWyHEXCUrS6Qo
 gbaLk8mZsTac3iwYoLk7AdYyQpEdQD/tnCHpBzHHdTdDcQuKHbknP9t/zFuEkM/e
 hAH6H/cOr+IMOkMvYe1HDRQsOwkPQppz2GnxtWAUwCV8Shkn7khOExnV17zqUfJx
 NSzX60/iZWj53cAJkp4ZW4Uf6dqEEeCvV9jzWngXsCTRz96tpwJoLDilTEStSp1r
 0d17OpFSkrPoJQR6miK+wCeoA4CcLLfGJXG1BcDpsT0qgHq/TNx7P7AX55Ip//IL
 uu7qCDzFHAct8C50r1725pthsX/69PI34F8wHQ+bSt8eBlEMc/+iDavXO7MPvNNi
 Xd/Je0c+6pV15X9lCN7RqujDjBb2yMzX9f3Omq0txc4ughYGYb3QLwAfBidjW6Wy
 fI6AgBXOdqUOlFgq0ncDUVmS73AMfb2ilvstfY+cfhLrtGIzZNwin1znSIxcesaS
 tUGD9Xk/bPc=
 =SmJy
 -----END PGP SIGNATURE-----

Merge tag 'iio-fixes-for-5.7a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio into staging-linus

Jonathan writes:

First set of IIO fixes for the 5.7 cycle.

Includes one MAINTAINERS update to avoid people getting a lot of bounce
messages and complaining about it.

* MAINTAINERS
  - Drop Stefan Popa's Analog Devices email address in favour of
    Michael Hennerich.
* core
  - Fix handling of dB sysfs inputs.
  - Drop a stray semi colon in macro definition.
* ad5770r
  - Fix an off by one in chec on maximum number of channels.
* ad7192
  - Fix a null pointer de-reference due to the name previously being
    retrieved from the spi_get_device_id call which no longer works as
    the relevant table was removed.
* ad7797
  - Use correct attribute group.
* counter/104-quad-8
  - Add locks to prevent some race conditions.
* inv-mpu6050
  - Fix issues around suspend / resume clashing with runtime PM.
* stm32-adc
  - Fix sleep in invalid context
  - Fix id relative path error in device tree binding doc.
* st_lsm6dsx
  - Fix a read alignment issue on an untagged FIFO.
  - Handle odr for slave to properly compute the FIFO data layout / pattern.
  - Flush the HW FIFO before resettting the device to avoid a race on
    interrupt line 1.
* st_sensors
  - Rely on ODR mask not ODR address to identify if the ODR can be set.
    Some devices have an ODR address of 0.
* ti-ads8344
  - Byte ordering was wrong - fix it.
* xilinx-xadc
  - Fix inverted logic in powering down the second ADC.
  - Fix clearing interrupt when enabling the trigger.
  - Fix configuration of sequencer when in simultaneous sampling mode.
  - Limit initial sampling rate as done for runtime configured ones.

* tag 'iio-fixes-for-5.7a' of git://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  MAINTAINERS: remove Stefan Popa's email
  iio: adc: ad7192: fix null pointer de-reference crash during probe
  iio: core: remove extra semi-colon from devm_iio_device_register() macro
  iio: adc: ti-ads8344: properly byte swap value
  iio: imu: inv_mpu6050: fix suspend/resume with runtime power
  iio: st_sensors: rely on odr mask to know if odr can be set
  iio: xilinx-xadc: Make sure not exceed maximum samplerate
  iio: xilinx-xadc: Fix sequencer configuration for aux channels in simultaneous mode
  iio: xilinx-xadc: Fix clearing interrupt when enabling trigger
  iio: xilinx-xadc: Fix ADC-B powerdown
  iio: dac: ad5770r: fix off-by-one check on maximum number of channels
  iio: imu: st_lsm6dsx: flush hw FIFO before resetting the device
  iio: core: Fix handling of 'dB'
  dt-bindings: iio: adc: stm32-adc: fix id relative path
  counter: 104-quad-8: Add lock guards - generic interface
  iio: imu: st_lsm6dsx: specify slave odr in slv_odr
  iio: imu: st_lsm6dsx: fix read misalignment on untagged FIFO
  iio: adc: stm32-adc: fix sleep in atomic context
  iio:ad7797: Use correct attribute_group
2020-04-20 14:07:00 +02:00
Alexandru Ardelean 8f2273b1e0 iio: adc: ad7192: fix null pointer de-reference crash during probe
When the 'spi_device_id' table was removed, it omitted to cleanup/fix the
assignment:
   'indio_dev->name = spi_get_device_id(spi)->name;'

After that patch 'spi_get_device_id(spi)' returns NULL, so this crashes
during probe with null de-ref.

This change fixes this by introducing an ad7192_chip_info struct, and
defines all part-names [that should be assigned to indio_dev->name] in a
'ad7192_chip_info_tbl' table.

With this change, the old 'st->devid' is also moved to be a
'chip_info->chip_id'. And the old 'ID_AD719X' macros have been renamed to
'CHIPID_AD719X'. Tld identifiers have been re-purposed to be enum/index
values in the new 'ad7192_chip_info_tbl'.

This should fix the bug, and maintain the ABI for the 'indio_dev->name'
field.

Fixes: 66614ab2be ("staging: iio: adc: ad7192: removed spi_device_id")
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 17:50:03 +01:00
Alexandre Belloni dd7de4c002 iio: adc: ti-ads8344: properly byte swap value
The first received byte is the MSB, followed by the LSB so the value needs
to be byte swapped.

Also, the ADC actually has a delay of one clock on the SPI bus. Read three
bytes to get the last bit.

Fixes: 8dd2d7c0fe ("iio: adc: Add driver for the TI ADS8344 A/DC chips")
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 17:50:02 +01:00
Lars-Peter Clausen 3b7f9dbb82 iio: xilinx-xadc: Make sure not exceed maximum samplerate
The XADC supports a samplerate of up to 1MSPS. Unfortunately the hardware
does not have a FIFO, which means it generates an interrupt for each
conversion sequence. At one 1MSPS this creates an interrupt storm that
causes the system to soft-lock.

For this reason the driver limits the maximum samplerate to 150kSPS.
Currently this check is only done when setting a new samplerate. But it is
also possible that the initial samplerate configured in the FPGA bitstream
exceeds the limit.

In this case when starting to capture data without first changing the
samplerate the system can overload.

To prevent this check the currently configured samplerate in the probe
function and reduce it to the maximum if necessary.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Fixes: bdc8cda1d0 ("iio:adc: Add Xilinx XADC driver")
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 17:50:02 +01:00
Lars-Peter Clausen 8bef455c8b iio: xilinx-xadc: Fix sequencer configuration for aux channels in simultaneous mode
The XADC has two internal ADCs. Depending on the mode it is operating in
either one or both of them are used. The device manual calls this
continuous (one ADC) and simultaneous (both ADCs) mode.

The meaning of the sequencing register for the aux channels changes
depending on the mode.

In continuous mode each bit corresponds to one of the 16 aux channels. And
the single ADC will convert them one by one in order.

In simultaneous mode the aux channels are split into two groups the first 8
channels are assigned to the first ADC and the other 8 channels to the
second ADC. The upper 8 bits of the sequencing register are unused and the
lower 8 bits control both ADCs. This means a bit needs to be set if either
the corresponding channel from the first group or the second group (or
both) are set.

Currently the driver does not have the special handling required for
simultaneous mode. Add it.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Fixes: bdc8cda1d0 ("iio:adc: Add Xilinx XADC driver")
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 17:50:02 +01:00
Lars-Peter Clausen f954b098fb iio: xilinx-xadc: Fix clearing interrupt when enabling trigger
When enabling the trigger and unmasking the end-of-sequence (EOS) interrupt
the EOS interrupt should be cleared from the status register. Otherwise it
is possible that it was still set from a previous capture. If that is the
case the interrupt would fire immediately even though no conversion has
been done yet and stale data is being read from the device.

The old code only clears the interrupt if the interrupt was previously
unmasked. Which does not make much sense since the interrupt is always
masked at this point and in addition masking the interrupt does not clear
the interrupt from the status register. So the clearing needs to be done
unconditionally.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Fixes: bdc8cda1d0 ("iio:adc: Add Xilinx XADC driver")
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 17:50:01 +01:00
Lars-Peter Clausen e44ec7794d iio: xilinx-xadc: Fix ADC-B powerdown
The check for shutting down the second ADC is inverted. This causes it to
be powered down when it should be enabled. As a result channels that are
supposed to be handled by the second ADC return invalid conversion results.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Fixes: bdc8cda1d0 ("iio:adc: Add Xilinx XADC driver")
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 17:50:01 +01:00
Geert Uytterhoeven 8cba4a9927 iio: Fix misspellings of "Analog Devices"
According to https://www.analog.com/, the company name is spelled
"Analog Devices".

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:41 +01:00
Aishwarya Ramakrishnan 587122cb8b iio: adc: fsl-imx25-gcq: Use devm_platform_ioremap_resource
Use the helper function that wraps the calls to
platform_get_resource() and devm_ioremap_resource()
together. It reduces boilerplate and suggested by coccinelle.

Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:41 +01:00
Aishwarya Ramakrishnan af5c2174ca iio: adc: at91-adc: Use devm_platform_ioremap_resource
Use the helper function that wraps the calls to
platform_get_resource() and devm_ioremap_resource()
together. It reduces boilerplate and suggested by coccinelle.

Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:41 +01:00
Aishwarya Ramakrishnan fd1cadd6ca iio: adc: sun4i-gpadc-iio: Use devm_platform_ioremap_resource
Use the helper function that wraps the calls to platform_get_resource()
and devm_ioremap_resource() together.  Reduces boilerplate and suggested
by coccinelle.

Signed-off-by: Aishwarya Ramakrishnan <aishwaryarj100@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:40 +01:00
Lars-Peter Clausen 903b6a07d9 iio: xilinx-xadc: Fix typo
Fix a typo. 'at the a time' -> 'at a time'.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:33 +01:00
Alexandru Lazar 8a80a71d90 iio: adc: Add MAX1241 driver
Add driver for the Maxim MAX1241 12-bit, single-channel ADC.

Datasheet: https://datasheets.maximintegrated.com/en/ds/MAX1240-MAX1241.pdf
Reviewed-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Alexandru Lazar <alazar@startmail.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:31 +01:00
Michael Hennerich ad67971202 iio: adc: ad9467: add support AD9467 ADC
The AD9467 is a 16-bit, monolithic, IF sampling analog-to-digital converter
(ADC). It is optimized for high performanceover wide bandwidths and ease of
use. The product operates at a 250 MSPS conversion rate and is designed for
wireless receivers, instrumentation, and test equipment that require a high
dynamic range. The ADC requires 1.8 V and 3.3 V power supplies and a low
voltage differential input clock for full performance operation. No
external reference or driver components are required for many applications.
Data outputs are LVDS compatible (ANSI-644 compatible) and include the
means to reduce the overall current needed for short trace distances.

Since the chip can operate at such high sample-rates (much higher than
classical interfaces), it requires that a DMA controller be used to
interface directly to the chip and push data into memory.
Typically, the AXI ADC IP core is used to interface with it.

Datasheet: https://www.analog.com/media/en/technical-documentation/data-sheets/AD9467.pdf

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:23 +01:00
Michael Hennerich ef04070692 iio: adc: adi-axi-adc: add support for AXI ADC IP core
This change adds support for the Analog Devices Generic AXI ADC IP core.
The IP core is used for interfacing with analog-to-digital (ADC) converters
that require either a high-speed serial interface (JESD204B/C) or a source
synchronous parallel interface (LVDS/CMOS).

Usually, some other interface type (i.e SPI) is used as a control interface
for the actual ADC, while the IP core (controlled via this driver), will
interface to the data-lines of the ADC and handle  the streaming of data
into memory via DMA.

Because of this, the AXI ADC driver needs the other SPI-ADC driver to
register with it. The SPI-ADC needs to be register via the SPI framework,
while the AXI ADC registers as a platform driver. The two cannot be ordered
in a hierarchy as both drivers have their own registers, and trying to
organize this [in a hierarchy becomes] problematic when trying to map
memory/registers.

There are some modes where the AXI ADC can operate as standalone ADC, but
those will be implemented at a later point in time.

DocLink: https://wiki.analog.com/resources/fpga/docs/axi_adc_ip

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:22 +01:00
Alexandru Ardelean 1cfe38fc40 iio: adc: ad7793: use read_avail iio hook for scale available
This change uses the read_avail and '.info_mask_shared_by_type_available'
modifier to set the available scale.
Essentially, nothing changes to the driver's ABI.

The main idea for this patch is to remove the AD7793 driver from
checkpatch's radar. There have been about ~3 attempts to fix/break the
'in_voltage-voltage_scale_available' attribute, because checkpatch assumed
it to be an arithmetic operation and people were trying to change that.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:15 +01:00
Rohit Sarkar bf09cddb2c iio: adc: max1363: replace uses of mlock
Replace usage indio_dev's mlock with either local lock or
iio_device_claim_direct_mode.

Signed-off-by: Rohit Sarkar <rohitsarkar5398@gmail.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2020-04-19 16:56:13 +01:00