1
0
Fork 0
Commit Graph

16 Commits (1d4345eb51a185b2ecd11834dbddca79cb922eb5)

Author SHA1 Message Date
Greg Kroah-Hartman 12ec5408d2 First set of IIO and counter fixes for the 5.12 cycle
adi,ad7949
 * Fix a wrong bitmask that could lead to an undefined bit being included.
 adi,adi-axi-adc
 * Add missing Kconfig dependencies
 adi,adis16400
 * Wrong error code handling in adis16400 that could lead to failed probe.
 hid-sensor-humidity, temperature
 * Fix alignment and space for timestamp channel.
 hid-sensor-prox
 * Fix an issue with handling of exponent on the channel scaling.
 invensense,mpu3050
 * Fix a hole in error handling.
 qcom,spi-vadc
 * Correct scaling
 st,ab8500-adc
 * Fix wrong scaling (by factor of 1000)
 st,stm32-adc
 * Add missing HAS_IOMEM dependency
 st,stm32-timer-cnt
 * Report count when running off internal clock
 * Fix issue with not checking ceiling before trying to write to hardware
 * Ensure driver doesn't have stashed state which doesn't match hardware by
   rereading from hardware in a slow path.
 -----BEGIN PGP SIGNATURE-----
 
 iQJFBAABCAAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmBOGa4RHGppYzIzQGtl
 cm5lbC5vcmcACgkQVIU0mcT0FojkDw//YDGkDIUEsx/je8xBjLevNvMd1+6Hc2TA
 eKxzQ8ihwJtc8o2ShHuqYdUXvZJIJjtzu9BA/kuEUGE1EmjPZztWGT3mJFwUuA82
 Woy9G/NStX6Cy/3z9rMEusGqIKysSWfvIVnEX3zLoyGUpskJYn6QDqifcFBLTyDa
 uXPSQ0x2sB0wufGxhAMXGAzUClqzcGIFp/VZSaLTYqT1P30WgQ5N2D/epYdVTQHD
 WbYn+HHP8+74sz2ozj/g5mCG/pE0FB9PyjoCqFz1kRdIm/4K/EGfsBRu4rjVhcNz
 NEsM+B+54MUcQv0vzop8Ip6J5XEy6zHNIlXT5B0ckxuU46s8vQnAZhtA03jXgWOT
 JbnonjMMJv/04q3dMbkYxvFpy4mBFlYmsQu+8JUfXMYlCPTHVHbkZhWE36Q7zT63
 wMX/yIMYTuNGozBrQkQeymrQpaa8zUlVjwPzkAmMt+w0Bh3mR5XXyxh7EncmevdG
 ZR8Znd7g0WidaEnXeuFy2sEJwljIGBiUbO2UurWD5EBsFshu9ZC7n9+gS1gaICva
 dEh2JmdYAq9cB2Enqw7jq8WyIsAmc++M3XXz6prgq1g0tcm/5od7AqeU7AiqPQVX
 Gxd0YyL4ihGBMcrZLJcB1HxBGv27w7fQzwfxW2e1fa8bPNepUajsyXpRj/iz9vRR
 x+IiixCgKbw=
 =L5Yl
 -----END PGP SIGNATURE-----

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

Jonathan writes:

First set of IIO and counter fixes for the 5.12 cycle

adi,ad7949
* Fix a wrong bitmask that could lead to an undefined bit being included.
adi,adi-axi-adc
* Add missing Kconfig dependencies
adi,adis16400
* Wrong error code handling in adis16400 that could lead to failed probe.
hid-sensor-humidity, temperature
* Fix alignment and space for timestamp channel.
hid-sensor-prox
* Fix an issue with handling of exponent on the channel scaling.
invensense,mpu3050
* Fix a hole in error handling.
qcom,spi-vadc
* Correct scaling
st,ab8500-adc
* Fix wrong scaling (by factor of 1000)
st,stm32-adc
* Add missing HAS_IOMEM dependency
st,stm32-timer-cnt
* Report count when running off internal clock
* Fix issue with not checking ceiling before trying to write to hardware
* Ensure driver doesn't have stashed state which doesn't match hardware by
  rereading from hardware in a slow path.

* tag 'iio-fixes-for-5.12a' of https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio:
  iio: gyro: mpu3050: Fix error handling in mpu3050_trigger_handler
  iio: hid-sensor-temperature: Fix issues of timestamp channel
  iio: hid-sensor-humidity: Fix alignment issue of timestamp channel
  counter: stm32-timer-cnt: fix ceiling miss-alignment with reload register
  counter: stm32-timer-cnt: fix ceiling write max value
  counter: stm32-timer-cnt: Report count function when SLAVE_MODE_DISABLED
  iio: adc: ab8500-gpadc: Fix off by 10 to 3
  iio:adc:stm32-adc: Add HAS_IOMEM dependency
  iio: adis16400: Fix an error code in adis16400_initial_setup()
  iio: adc: adi-axi-adc: add proper Kconfig dependencies
  iio: adc: ad7949: fix wrong ADC result due to incorrect bit mask
  iio: hid-sensor-prox: Fix scale not correct issue
  iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel
2021-03-15 16:34:39 +01:00
Dmitry Baryshkov ec82edb258 iio: adc: move qcom-vadc-common.h to include dir
qcom-vadc-common module will be used by ADC thermal monitoring driver,
so move it to global include dir.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20201204025509.1075506-6-dmitry.baryshkov@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16 18:20:56 +00:00
Jonathan Albrieux 7d200b283a iio:adc:qcom-spmi-vadc: add default scale to LR_MUX2_BAT_ID channel
Checking at both msm8909-pm8916.dtsi and msm8916.dtsi from downstream
it is indicated that "batt_id" channel has to be scaled with the default
function:

	chan@31 {
		label = "batt_id";
		reg = <0x31>;
		qcom,decimation = <0>;
		qcom,pre-div-channel-scaling = <0>;
		qcom,calibration-type = "ratiometric";
		qcom,scale-function = <0>;
		qcom,hw-settle-time = <0xb>;
		qcom,fast-avg-setup = <0>;
	};

Change LR_MUX2_BAT_ID scaling accordingly.

Signed-off-by: Jonathan Albrieux <jonathan.albrieux@gmail.com>
Acked-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Fixes: 7c271eea7b ("iio: adc: spmi-vadc: Changes to support different scaling")
Link: https://lore.kernel.org/r/20210113151808.4628-2-jonathan.albrieux@gmail.com
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
2021-01-16 17:45:47 +00: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 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
Thomas Gleixner 97fb5e8d9b treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 284
Based on 1 normalized pattern(s):

  this program is free software you can redistribute it and or modify
  it under the terms of the gnu general public license version 2 and
  only version 2 as published by the free software foundation this
  program is distributed in the hope that it will be useful but
  without any warranty without even the implied warranty of
  merchantability or fitness for a particular purpose see the gnu
  general public license for more details

extracted by the scancode license scanner the SPDX license identifier

  GPL-2.0-only

has been chosen to replace the boilerplate/reference in 294 file(s).

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Allison Randal <allison@lohutok.net>
Reviewed-by: Alexios Zavras <alexios.zavras@intel.com>
Cc: linux-spdx@vger.kernel.org
Link: https://lkml.kernel.org/r/20190529141900.825281744@linutronix.de
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-06-05 17:36:37 +02:00
Jonathan Cameron 52b31bcc93 iio:adc: drop assign iio_info.driver_module and iio_trigger_ops.owner
The equivalent of both of these are now done via macro magic when
the relevant register calls are made.  The actual structure
elements will shortly go away.

Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Lars-Peter Clausen <lars@metafoo.de>
2017-08-22 21:22:25 +01:00
Linus Walleij e932d4f041 iio: adc: break out common code from SPMI VADC
The SPMI VADC and the earlier XOADC share a subset of
common code, so to be able to use the same code in both
drivers, we break out a separate file with the common code,
prefix exported functions that are no longer static with
qcom_* and bake an object qcom-spmi-vadc.o that contains both
files: qcom-vadc-common.o and qcom-spmi-vadc-core.o.

As we need to follow the procedure for making a kernel module
or compiled in object from several files, but still want to
produce the same module name, rename the qcom-spmi-vadc.c
file to qcom-spmi-vadc-core.c so we can bake the two objects
into qcom-spmi-vadc.o

Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-arm-msm@vger.kernel.org
Cc: Ivan T. Ivanov <iivanov.xz@gmail.com>
Cc: Andy Gross <andy.gross@linaro.org>
Cc: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Cc: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Cc: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-04-08 17:40:49 +01:00
Jonathan Cameron e30eca0e69 iio:adc:qcom-spmi-vadc: use div64_s64 instead of direct 64 bit division.
Another one of these that we missed previously which prevents test builds
of this driver on 32 bit platforms as it gives an undefined __divdi3 warning.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10 21:13:39 +00:00
Jonathan Cameron 292ccbd3c4 iio:adc:qcom-spmi-vadc silence a long constant warning.
It is meant to be long and is only added to an s64.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Cc: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10 19:55:00 +00:00
Jonathan Cameron 2bd72d84f6 iio:adc:qcom-spmi-vadc : fix undefined __divdi3
A simple do_div call works here as all the signed 64 bit is
actually small and unsigned at this point, and the numerator is
u32.

Introduce a temporary u64 variable to avoid type comparison warnings
on some architectures.

Signed-off-by: Jonathan Cameron <jic23@kernel.org>
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Cc: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2017-01-10 19:54:59 +00:00
Rama Krishna Phani A 7c271eea7b iio: adc: spmi-vadc: Changes to support different scaling
Several ADC channels are supported in PMIC which can be used to
measure voltage, temperature, current etc. Different scaling can be
applied on the obtained voltage to report in physical units. Scaling
functionality can be different per channel. Add scaling support per
channel. Every channel present in adc has an unique conversion formula
for obtained voltage. Add support to report in Raw as well as in
processed format. Scaling is applied when processed read is requested
and is not applied when a Raw read is requested.

Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-10 17:28:21 +00:00
Rama Krishna Phani A ba71704af4 iio: adc: spmi-vadc: Update function for generic voltage conversion
Several channels are supported in ADC of PMIC which can be used to
measure voltage, temperature, current etc., Hardware provides
readings for all channels in adc code. That adc code needs to be
converted to voltage. Logic for conversion of adc code to voltage
is common for all ADC channels(voltage, temperature, current
.,etc). Implement separate function for generic conversion logic.

Signed-off-by: Rama Krishna Phani A <rphani@codeaurora.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2016-12-10 17:25:48 +00:00
Julia Lawall d4c65fe4ed iio: adc: spmi-vadc: add missing of_node_put
for_each_available_child_of_node performs an of_node_get on each iteration,
so a break out of the loop requires an of_node_put.

A simplified version of the semantic patch that fixes this problem is as
follows (http://coccinelle.lip6.fr):

// <smpl>
@@
expression root,e;
local idexpression child;
@@

 for_each_available_child_of_node(root, child) {
   ... when != of_node_put(child)
       when != e = child
(
   return child;
|
+  of_node_put(child);
?  return ...;
)
   ...
 }
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-11-21 18:24:44 +00:00
Ivan T. Ivanov 937125aca0 iio: adc: spmi-vadc: Fix overflow in output value normalization
With 'dx' equal to 0.625V and 15 bit ADC, calculations overflow
when difference against GND is ~20% of the ADC range. Fix this.

Signed-off-by: Ivan T. Ivanov <ivan.ivanov@linaro.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-04-18 17:40:04 +01:00
Stanimir Varbanov 0917de94c0 iio: vadc: Qualcomm SPMI PMIC voltage ADC driver
The voltage ADC is peripheral of Qualcomm SPMI PMIC chips. It has
15bits resolution and register space inside PMIC accessible across
SPMI bus.

The vadc driver registers itself through IIO interface.

Signed-off-by: Stanimir Varbanov <svarbanov@mm-sol.com>
Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
2015-01-28 18:42:08 +00:00