iio:adc:ad7476: Regulator support and binding doc
Subsystems (4)
Jonathan Cameron
maintainerv2 cover iio:adc:ad7476: Regulator support and binding doc
From: Jonathan Cameron <[email protected]>
This driver supports a whole load of devices with a range of different power supply connections.
Lars-Peter Clausen pointed out v1 did not handle the the ad7091r which an internal voltage reference, but that can be over-driven on the vref_in / vref_out pin. The v2 handles that device properly. I also realized that I'd the binding was more restrictive for devices with internal references than it needed to be (required vcc-supply) so I've relaxed that in the updated bindings. Also reorganized the big allOf block in the binding doc to put all the constraints on reference voltage first.
Given substantial changes in patch 1, I dropped Lars' Reviewed-by.
Jonathan Cameron (2):
iio:adc:ad7476: Handle the different regulators used by various parts. dt-bindings:iio:adc:adi,ad7474: Add missing binding document
.../bindings/iio/adc/adi,ad7476.yaml | 173 ++++++++++++++++++ drivers/iio/adc/ad7476.c | 108 +++++++++-- 2 files changed, 266 insertions(+), 15 deletions(-) create mode 100644 Documentation/devicetree/bindings/iio/adc/adi,ad7476.yaml
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH v2 1/2 iio:adc:ad7476: Handle the different regulators used by various parts.
From: Jonathan Cameron <[email protected]>
Not all of the parts supported by this driver use single supply. Hence we add chip_info fields to say what additional supplies exist and in the case of vref, ensure that is used for the reference voltage rather than vcc.
One corner case is the ad7091r which has an internal reference that can be over-driven by an external reference connected on the vref pin. To handle that force_ext_vref is introduced and set if an optional vref regulator is present.
Tested using really simple QEMU model and some fixed regulators.
The devm_add_action_or_reset() callback is changed to take the regulator as it's parameter so we can use one callback for all the different regulators without having to store pointers to them in the iio_priv() structure.
--- drivers/iio/adc/ad7476.c | 108 +++++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 15 deletions(-)
drivers/iio/adc/ad7476.c +93 -15
@@ -32,12 +32,15 @@ struct ad7476_chip_info {/* channels used when convst gpio is defined */ struct iio_chan_spec convst_channel[2 ];void (*reset)(struct ad7476_state *); +bool has_vref; +bool has_vdrive; };struct ad7476_state {struct spi_device *spi;const struct ad7476_chip_info *chip_info; -struct regulator *reg; +struct regulator *ref_reg; +bool force_ext_vref;struct gpio_desc *convst_gpio;struct spi_transfer xfer;struct spi_message msg;
@@ -52,13 +55,17 @@ struct ad7476_state { };enum ad7476_supported_device_ids { +ID_AD7091 ,ID_AD7091R , +ID_AD7273 , +ID_AD7274 ,ID_AD7276 ,ID_AD7277 ,ID_AD7278 ,ID_AD7466 ,ID_AD7467 ,ID_AD7468 , +ID_AD7475 ,ID_AD7495 ,ID_AD7940 ,ID_ADC081S ,
@@ -145,8 +152,8 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,GENMASK (st->chip_info->channel[0 ].scan_type.realbits -1 ,0 );return IIO_VAL_INT ;case IIO_CHAN_INFO_SCALE : -if (!st->chip_info->int_vref_uv) { - scale_uv =regulator_get_voltage (st->reg); +if (!st->chip_info->int_vref_uv || st->force_ext_vref) { + scale_uv =regulator_get_voltage (st->ref_reg);if (scale_uv <0 )return scale_uv; }else {
@@ -187,13 +194,32 @@ static int ad7476_read_raw(struct iio_dev *indio_dev, BIT(IIO_CHAN_INFO_RAW))static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { + [ID_AD7091 ] = { + .channel[0 ] =AD7091R_CHAN (12 ), + .channel[1 ] =IIO_CHAN_SOFT_TIMESTAMP (1 ), + .convst_channel[0 ] =AD7091R_CONVST_CHAN (12 ), + .convst_channel[1 ] =IIO_CHAN_SOFT_TIMESTAMP (1 ), + .reset = ad7091_reset, + }, [ID_AD7091R ] = { .channel[0 ] =AD7091R_CHAN (12 ), .channel[1 ] =IIO_CHAN_SOFT_TIMESTAMP (1 ), .convst_channel[0 ] =AD7091R_CONVST_CHAN (12 ), .convst_channel[1 ] =IIO_CHAN_SOFT_TIMESTAMP (1 ), + .int_vref_uv =2500000 , + .has_vref = true, .reset = ad7091_reset, }, + [ID_AD7273 ] = { + .channel[0 ] =AD7940_CHAN (10 ), + .channel[1 ] =IIO_CHAN_SOFT_TIMESTAMP (1 ), + .has_vref = true, + }, + [ID_AD7274 ] = { + .channel[0 ] =AD7940_CHAN (12 ), + .channel[1 ] =IIO_CHAN_SOFT_TIMESTAMP (1 ), + .has_vref = true, + }, [ID_AD7276 ] = { .channel[0 ] =AD7940_CHAN (12 ), .channel[1 ] =IIO_CHAN_SOFT_TIMESTAMP (1 ),
@@ -218,10 +244,17 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { .channel[0] = AD7476_CHAN(8), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), }, + [ID_AD7475] = { + .channel[0] = AD7476_CHAN(12), + .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), + .has_vref = true, + .has_vdrive = true, + }, [ID_AD7495] = { .channel[0] = AD7476_CHAN(12), .channel[1] = IIO_CHAN_SOFT_TIMESTAMP(1), .int_vref_uv = 2500000, + .has_vdrive = true, }, [ID_AD7940] = { .channel[0] = AD7940_CHAN(14),
@@ -254,6 +287,7 @@ static const struct ad7476_chip_info ad7476_chip_info_tbl[] = { [ID_LTC2314_14 ] = { .channel[0 ] =AD7940_CHAN (14 ), .channel[1 ] =IIO_CHAN_SOFT_TIMESTAMP (1 ), + .has_vref = true, }, };
@@ -263,15 +297,16 @@ static const struct iio_info ad7476_info = {static void ad7476_reg_disable (void *data) { -struct ad7476_state *st = data; +struct regulator *reg = data; -regulator_disable (st->reg); +regulator_disable (reg); }static int ad7476_probe (struct spi_device *spi) {struct ad7476_state *st;struct iio_dev *indio_dev; +struct regulator *reg;int ret; indio_dev =devm_iio_device_alloc (&spi->dev,sizeof (*st));
@@ -282,19 +317,62 @@ static int ad7476_probe(struct spi_device *spi) st->chip_info = &ad7476_chip_info_tbl[spi_get_device_id (spi)->driver_data]; - st->reg =devm_regulator_get (&spi->dev,"vcc" ); -if (IS_ERR (st->reg)) -return PTR_ERR (st->reg); + reg =devm_regulator_get (&spi->dev,"vcc" ); +if (IS_ERR (reg)) +return PTR_ERR (reg); - ret =regulator_enable (st->reg); + ret =regulator_enable (reg);if (ret)return ret; - ret =devm_add_action_or_reset (&spi->dev, ad7476_reg_disable, - st); + ret =devm_add_action_or_reset (&spi->dev, ad7476_reg_disable, reg);if (ret)return ret; +/* Either vcc or vref (below) as appropriate */ + st->ref_reg = reg; + +if (st->chip_info->has_vref) { + +/* If a device has an internal reference vref is optional */ +if (st->chip_info->int_vref_uv) { + reg =devm_regulator_get_optional (&spi->dev,"vref" ); + }else { + reg =devm_regulator_get (&spi->dev,"vref" ); +if (IS_ERR (reg)) +return PTR_ERR (reg); + } + +if (!IS_ERR (reg)) { + ret =regulator_enable (reg); +if (ret) +return ret; + + ret =devm_add_action_or_reset (&spi->dev, + ad7476_reg_disable, + reg); +if (ret) +return ret; + st->ref_reg = reg; + st->force_ext_vref = true; + } + } + +if (st->chip_info->has_vdrive) { + reg =devm_regulator_get (&spi->dev,"vdrive" ); +if (IS_ERR (reg)) +return PTR_ERR (reg); + + ret =regulator_enable (reg); +if (ret) +return ret; + + ret =devm_add_action_or_reset (&spi->dev, ad7476_reg_disable, + reg); +if (ret) +return ret; + } + st->convst_gpio =devm_gpiod_get_optional (&spi->dev,"adi,conversion-start" ,GPIOD_OUT_LOW );
@@ -333,17 +411,17 @@ static int ad7476_probe(struct spi_device *spi) }static const struct spi_device_id ad7476_id[] = { - {"ad7091" ,ID_AD7091R }, + {"ad7091" ,ID_AD7091 }, {"ad7091r" ,ID_AD7091R }, - {"ad7273" ,ID_AD7277 }, - {"ad7274" ,ID_AD7276 }, + {"ad7273" ,ID_AD7273 }, + {"ad7274" ,ID_AD7274 }, {"ad7276" ,ID_AD7276 }, {"ad7277" ,ID_AD7277 }, {"ad7278" ,ID_AD7278 }, {"ad7466" ,ID_AD7466 }, {"ad7467" ,ID_AD7467 }, {"ad7468" ,ID_AD7468 }, - {"ad7475" ,ID_AD7466 }, + {"ad7475" ,ID_AD7475 }, {"ad7476" ,ID_AD7466 }, {"ad7476a" ,ID_AD7466 }, {"ad7477" ,ID_AD7467 },
Signature · 1 line
2.31.1
Jonathan Cameron
maintainerPATCH v2 2/2 dt-bindings:iio:adc:adi,ad7474: Add missing binding document
In reply to Jonathan CameronFrom: Jonathan Cameron <[email protected]>
This binding covers class of simple SPI ADCs which only provide data output - they don't have MOSI pin.
The only real variation between them is over how many supplies they use and which one is used for the reference.
Michael listed as maintainer for this one as it is his driver and falls under the catch all MAINTAINERS entry for ADI devices.
--- .../bindings/iio/adc/adi,ad7476.yaml | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+)
Documentation/devicetree/bindings/iio/adc/adi,ad7476.yaml new file +173 -0
@@ -0,0 +1,173 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2019 Analog Devices Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ad7476.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AD7476 and similar simple SPI ADCs from multiple manufacturers. + +maintainers: + - Michael Hennerich <[email protected]> + +description: | + A lot of simple SPI ADCs have very straight forward interfaces. + They typically don't provide a MOSI pin, simply reading out data + on MISO when the clock toggles. + +properties: + compatible: + enum: + - adi,ad7091 + - adi,ad7091r + - adi,ad7273 + - adi,ad7274 + - adi,ad7276 + - adi,ad7277 + - adi,ad7278 + - adi,ad7466 + - adi,ad7467 + - adi,ad7468 + - adi,ad7475 + - adi,ad7476 + - adi,ad7476a + - adi,ad7477 + - adi,ad7477a + - adi,ad7478 + - adi,ad7478a + - adi,ad7495 + - adi,ad7910 + - adi,ad7920 + - adi,ad7940 + - ti,adc081s + - ti,adc101s + - ti,adc121s + - ti,ads7866 + - ti,ads7867 + - ti,ads7868 + - lltc,ltc2314-14 + + reg: + maxItems: 1 + + vcc-supply: + description: + Main powersupply voltage for the chips, sometimes referred to as VDD on + datasheets. If there is no separate vref-supply, then this is needed + to establish channel scaling. + + vdrive-supply: + description: + Some devices have separate supply for their digital control side. + + vref-supply: + description: + Some devices have a specific reference voltage supplied on a different pin + to the other supplies. Needed to be able to establish channel scaling + unless there is also an internal reference available (e.g. ad7091r) + + spi-max-frequency: true + + adi,conversion-start-gpios: + description: A GPIO used to trigger the start of a conversion + +required: + - compatible + - reg + +additionalProperties: false + +allOf: + # Devices where reference is vcc + - if: + properties: + compatible: + contains: + enum: + - adi,ad7091 + - adi,ad7276 + - adi,ad7277 + - adi,ad7278 + - adi,ad7466 + - adi,ad7467 + - adi,ad7468 + - adi,ad7940 + - ti,adc081s + - ti,adc101s + - ti,adc121s + - ti,ads7866 + - ti,ads7868 + required: + - vcc-supply + # Devices with a vref + - if: + properties: + compatible: + contains: + enum: + - adi,ad7091r + - adi,ad7273 + - adi,ad7274 + - adi,ad7475 + - lltc,ltc2314-14 + then: + properties: + vref-supply: true + else: + properties: + vref-supply: false + # Devices with a vref where it is not optional + - if: + properties: + compatible: + contains: + enum: + - adi,ad7273 + - adi,ad7274 + - adi,ad7475 + - lltc,ltc2314-14 + then: + required: + - vref-supply + - if: + properties: + compatible: + contains: + enum: + - adi,ad7475 + - adi,ad7495 + then: + properties: + vdrive-supply: true + else: + properties: + vdrive-supply: false + - if: + properties: + compatible: + contains: + enum: + - adi,ad7091 + - adi,ad7091r + then: + properties: + adi,conversion-start-gpios: true + else: + properties: + adi,conversion-start-gpios: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + + adc@0 { + compatible = "adi,ad7091r"; + reg = <0>; + spi-max-frequency = <5000000>; + vcc-supply = <&adc_vcc>; + vref-supply = <&adc_vref>; + }; + }; +...
Signature · 1 line
2.31.1
Re: [PATCH v2 1/2] iio:adc:ad7476: Handle the different regulators used by various parts.
In reply to Jonathan CameronQuoted 65 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
Not all of the parts supported by this driver use single supply. Hence we add
chip_infofields to say what additional supplies exist and in the case of vref, ensure that is used for the reference voltage rather than vcc.One corner case is the ad7091r which has an internal reference that can be over-driven by an external reference connected on the vref pin. To handle that
force_ext_vrefis introduced and set if an optional vref regulator is present.Tested using really simple QEMU model and some fixed regulators.
The
devm_add_action_or_reset()callback is changed to take the regulator as it's parameter so we can use one callback for all the different regulators without having to store pointers to them in theiio_priv()structure.Signed-off-by Jonathan Cameron <[email protected]>Cc Michael Hennerich <[email protected]>--- drivers/iio/adc/ad7476.c | 108 +++++++++++++++++++++++++++++++++------ 1 file changed, 93 insertions(+), 15 deletions(-)drivers/iio/adc/ad7476.c +8
-1@@ -32,12 +32,15 @@ struct ad7476_chip_info {/* channels used when convst gpio is defined */ struct iio_chan_spec convst_channel[2 ];void (*reset)(struct ad7476_state *); +bool has_vref; +bool has_vdrive; };struct ad7476_state {struct spi_device *spi;const struct ad7476_chip_info *chip_info; -struct regulator *reg; +struct regulator *ref_reg; +bool force_ext_vref;struct gpio_desc *convst_gpio;struct spi_transfer xfer;struct spi_message msg;@@ -52,13 +55,17 @@ struct ad7476_state { };enum ad7476_supported_device_ids { +ID_AD7091 ,ID_AD7091R , +ID_AD7273 , +ID_AD7274 ,ID_AD7276 ,ID_AD7277 ,ID_AD7278 ,ID_AD7466 ,ID_AD7467 ,ID_AD7468 , +ID_AD7475 ,ID_AD7495 ,ID_AD7940 ,ID_ADC081S ,
drivers/iio/adc/ad7476.c static int ad7476_read_raw(struct iio_dev *indio_dev, · line 155
Quoted 6 lines
drivers/iio/adc/ad7476.c +1
-2@@ -145,8 +152,8 @@ static int ad7476_read_raw(struct iio_dev *indio_dev,GENMASK (st->chip_info->channel[0 ].scan_type.realbits -1 ,0 );return IIO_VAL_INT ;case IIO_CHAN_INFO_SCALE : -if (!st->chip_info->int_vref_uv) { - scale_uv =regulator_get_voltage (st->reg); +if (!st->chip_info->int_vref_uv || st->force_ext_vref) {
Set set->reg_reg to NULL when not present and check for that instead of adding force_ext_vref?
Quoted 9 lines
drivers/iio/adc/ad7476.c +1
-0+ scale_uv =regulator_get_voltage (st->ref_reg);if (scale_uv <0 )return scale_uv; }else {@@ -187,13 +194,32 @@ static int ad7476_read_raw(struct iio_dev *indio_dev, BIT(IIO_CHAN_INFO_RAW))static int ad7476_probe (struct spi_device *spi)
drivers/iio/adc/ad7476.c static int ad7476_read_raw(struct iio_dev *indio_dev, · line 339
Quoted 10 lines
drivers/iio/adc/ad7476.c +8
-0{ +/* Either vcc or vref (below) as appropriate */ + st->ref_reg = reg; + +if (st->chip_info->has_vref) { + +/* If a device has an internal reference vref is optional */ +if (st->chip_info->int_vref_uv) { + reg =devm_regulator_get_optional (&spi->dev,"vref" );
I think we need to distinguish between -ENODEV and other errors, if not only to handle EPROBE_DEFER.
[...]
kernel test robot
build botRe: [PATCH v2 1/2] iio:adc:ad7476: Handle the different regulators used by various parts.
In reply to Jonathan CameronI love your patch! Yet something to improve:
Hi Jonathan,
I love your patch! Yet something to improve:
[auto build test ERROR on iio/togreg]
[also build test ERROR on v5.12-rc6 next-20210401]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jonathan-Cameron/iio-adc-ad7476-Regulator-support-and-binding-doc/20210406-002735 base: https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg config: riscv-randconfig-r004-20210405 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 2760a808b9916a2839513b7fd7314a464f52481e)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/0c18d053103b05b990e986b54c77a32db4f3f9f4
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jonathan-Cameron/iio-adc-ad7476-Regulator-support-and-binding-doc/20210406-002735 git checkout 0c18d053103b05b990e986b54c77a32db4f3f9f4
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
>> drivers/iio/adc/ad7476.c:418:24: error: no member named 'reg' in 'struct ad7476_state'
regulator_disable(st->reg);
~~ ^1 error generated.
vim +418 drivers/iio/adc/ad7476.c
4bb2b8f94ace32 drivers/iio/adc/ad7476.c Beniamin Bia 2020-03-11 304
fc52692c49969e drivers/iio/adc/ad7476.c Greg Kroah-Hartman 2012-12-21 305 static int ad7476_probe(struct spi_device *spi)
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 306 {
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 307 struct ad7476_state *st;
67688105af8376 drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-06-27 308 struct iio_dev *indio_dev;
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 309 struct regulator *reg;
cb093e444fede7 drivers/staging/iio/adc/ad7476_core.c Lars-Peter Clausen 2012-09-10 310 int ret;
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 311
4ea454d2c1a38d drivers/iio/adc/ad7476.c Sachin Kamat 2013-07-23 312 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
4ea454d2c1a38d drivers/iio/adc/ad7476.c Sachin Kamat 2013-07-23 313 if (!indio_dev)
4ea454d2c1a38d drivers/iio/adc/ad7476.c Sachin Kamat 2013-07-23 314 return -ENOMEM;
4ea454d2c1a38d drivers/iio/adc/ad7476.c Sachin Kamat 2013-07-23 315
67688105af8376 drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-06-27 316 st = iio_priv(indio_dev);
cb093e444fede7 drivers/staging/iio/adc/ad7476_core.c Lars-Peter Clausen 2012-09-10 317 st->chip_info =
cb093e444fede7 drivers/staging/iio/adc/ad7476_core.c Lars-Peter Clausen 2012-09-10 318 &ad7476_chip_info_tbl[spi_get_device_id(spi)->driver_data];
cb093e444fede7 drivers/staging/iio/adc/ad7476_core.c Lars-Peter Clausen 2012-09-10 319
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 320 reg = devm_regulator_get(&spi->dev, "vcc");
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 321 if (IS_ERR(reg))
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 322 return PTR_ERR(reg);
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 323
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 324 ret = regulator_enable(reg);
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 325 if (ret)
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 326 return ret;
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 327
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 328 ret = devm_add_action_or_reset(&spi->dev, ad7476_reg_disable, reg);
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 329 if (ret)
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 330 return ret;
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 331
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 332 /* Either vcc or vref (below) as appropriate */
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 333 st->ref_reg = reg;
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 334
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 335 if (st->chip_info->has_vref) {
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 336
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 337 /* If a device has an internal reference vref is optional */
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 338 if (st->chip_info->int_vref_uv) {
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 339 reg = devm_regulator_get_optional(&spi->dev, "vref");
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 340 } else {
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 341 reg = devm_regulator_get(&spi->dev, "vref");
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 342 if (IS_ERR(reg))
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 343 return PTR_ERR(reg);
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 344 }
cb093e444fede7 drivers/staging/iio/adc/ad7476_core.c Lars-Peter Clausen 2012-09-10 345
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 346 if (!IS_ERR(reg)) {
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 347 ret = regulator_enable(reg);
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 348 if (ret)
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 349 return ret;
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 350
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 351 ret = devm_add_action_or_reset(&spi->dev,
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 352 ad7476_reg_disable,
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 353 reg);
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 354 if (ret)
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 355 return ret;
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 356 st->ref_reg = reg;
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 357 st->force_ext_vref = true;
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 358 }
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 359 }
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 360
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 361 if (st->chip_info->has_vdrive) {
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 362 reg = devm_regulator_get(&spi->dev, "vdrive");
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 363 if (IS_ERR(reg))
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 364 return PTR_ERR(reg);
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 365
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 366 ret = regulator_enable(reg);
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 367 if (ret)
4ea454d2c1a38d drivers/iio/adc/ad7476.c Sachin Kamat 2013-07-23 368 return ret;
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 369
4bb2b8f94ace32 drivers/iio/adc/ad7476.c Beniamin Bia 2020-03-11 370 ret = devm_add_action_or_reset(&spi->dev, ad7476_reg_disable,
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 371 reg);
4bb2b8f94ace32 drivers/iio/adc/ad7476.c Beniamin Bia 2020-03-11 372 if (ret)
4bb2b8f94ace32 drivers/iio/adc/ad7476.c Beniamin Bia 2020-03-11 373 return ret;
0c18d053103b05 drivers/iio/adc/ad7476.c Jonathan Cameron 2021-04-05 374 }
4bb2b8f94ace32 drivers/iio/adc/ad7476.c Beniamin Bia 2020-03-11 375
af37e4703d00ce drivers/iio/adc/ad7476.c Dragos Bogdan 2020-03-11 376 st->convst_gpio = devm_gpiod_get_optional(&spi->dev,
af37e4703d00ce drivers/iio/adc/ad7476.c Dragos Bogdan 2020-03-11 377 "adi,conversion-start",
af37e4703d00ce drivers/iio/adc/ad7476.c Dragos Bogdan 2020-03-11 378 GPIOD_OUT_LOW);
af37e4703d00ce drivers/iio/adc/ad7476.c Dragos Bogdan 2020-03-11 379 if (IS_ERR(st->convst_gpio))
af37e4703d00ce drivers/iio/adc/ad7476.c Dragos Bogdan 2020-03-11 380 return PTR_ERR(st->convst_gpio);
af37e4703d00ce drivers/iio/adc/ad7476.c Dragos Bogdan 2020-03-11 381
38f71aa905c20c drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-07-13 382 spi_set_drvdata(spi, indio_dev);
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 383
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 384 st->spi = spi;
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 385
67688105af8376 drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-06-27 386 indio_dev->name = spi_get_device_id(spi)->name;
67688105af8376 drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-06-27 387 indio_dev->modes = INDIO_DIRECT_MODE;
67688105af8376 drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-06-27 388 indio_dev->channels = st->chip_info->channel;
67688105af8376 drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-06-27 389 indio_dev->num_channels = 2;
67688105af8376 drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-06-27 390 indio_dev->info = &ad7476_info;
3a6af93dd66eba drivers/iio/adc/ad7476.c Dragos Bogdan 2020-03-11 391
a66904b209b6d8 drivers/iio/adc/ad7476.c Colin Ian King 2020-04-24 392 if (st->convst_gpio)
3a6af93dd66eba drivers/iio/adc/ad7476.c Dragos Bogdan 2020-03-11 393 indio_dev->channels = st->chip_info->convst_channel;
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 394 /* Setup default message */
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 395
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 396 st->xfer.rx_buf = &st->data;
c5e0819e2d82c7 drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-05-18 397 st->xfer.len = st->chip_info->channel[0].scan_type.storagebits / 8;
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 398
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 399 spi_message_init(&st->msg);
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 400 spi_message_add_tail(&st->xfer, &st->msg);
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 401
7a28fe3c93d6cd drivers/staging/iio/adc/ad7476.c Lars-Peter Clausen 2012-09-10 402 ret = iio_triggered_buffer_setup(indio_dev, NULL,
7a28fe3c93d6cd drivers/staging/iio/adc/ad7476.c Lars-Peter Clausen 2012-09-10 403 &ad7476_trigger_handler, NULL);
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 404 if (ret)
67688105af8376 drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-06-27 405 goto error_disable_reg;
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 406
87c5b10fd97937 drivers/iio/adc/ad7476.c Lars-Peter Clausen 2012-09-17 407 if (st->chip_info->reset)
87c5b10fd97937 drivers/iio/adc/ad7476.c Lars-Peter Clausen 2012-09-17 408 st->chip_info->reset(st);
87c5b10fd97937 drivers/iio/adc/ad7476.c Lars-Peter Clausen 2012-09-17 409
26d25ae3f0d8ff drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-09-02 410 ret = iio_device_register(indio_dev);
26d25ae3f0d8ff drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-09-02 411 if (ret)
26d25ae3f0d8ff drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-09-02 412 goto error_ring_unregister;
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 413 return 0;
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 414
26d25ae3f0d8ff drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-09-02 415 error_ring_unregister:
7a28fe3c93d6cd drivers/staging/iio/adc/ad7476.c Lars-Peter Clausen 2012-09-10 416 iio_triggered_buffer_cleanup(indio_dev);
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 417 error_disable_reg:
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 @418 regulator_disable(st->reg);
26d25ae3f0d8ff drivers/staging/iio/adc/ad7476_core.c Jonathan Cameron 2011-09-02 419
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 420 return ret;
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 421 }
349282d82e929e drivers/staging/iio/adc/ad7476_core.c Michael Hennerich 2010-10-11 422 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH v2 2/2] dt-bindings:iio:adc:adi,ad7474: Add missing binding document
In reply to Jonathan CameronQuoted 85 lines · Jonathan Cameron
From: Jonathan Cameron <[email protected]>
This binding covers class of simple SPI ADCs which only provide data output - they don't have MOSI pin.
The only real variation between them is over how many supplies they use and which one is used for the reference.
Michael listed as maintainer for this one as it is his driver and falls under the catch all
MAINTAINERSentry for ADI devices.Signed-off-by Jonathan Cameron <[email protected]>Cc Michael Hennerich <[email protected]>--- .../bindings/iio/adc/adi,ad7476.yaml | 173 ++++++++++++++++++ 1 file changed, 173 insertions(+)Documentation/devicetree/bindings/iio/adc/adi,ad7476.yaml new file +62
-0@@ -0,0 +1,173 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2019 Analog Devices Inc. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/adc/adi,ad7476.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: AD7476 and similar simple SPI ADCs from multiple manufacturers. + +maintainers: + - Michael Hennerich <[email protected]> + +description: | + A lot of simple SPI ADCs have very straight forward interfaces. + They typically don't provide a MOSI pin, simply reading out data + on MISO when the clock toggles. + +properties: + compatible: + enum: + - adi,ad7091 + - adi,ad7091r + - adi,ad7273 + - adi,ad7274 + - adi,ad7276 + - adi,ad7277 + - adi,ad7278 + - adi,ad7466 + - adi,ad7467 + - adi,ad7468 + - adi,ad7475 + - adi,ad7476 + - adi,ad7476a + - adi,ad7477 + - adi,ad7477a + - adi,ad7478 + - adi,ad7478a + - adi,ad7495 + - adi,ad7910 + - adi,ad7920 + - adi,ad7940 + - ti,adc081s + - ti,adc101s + - ti,adc121s + - ti,ads7866 + - ti,ads7867 + - ti,ads7868 + - lltc,ltc2314-14 + + reg: + maxItems: 1 + + vcc-supply: + description: + Main powersupply voltage for the chips, sometimes referred to as VDD on + datasheets. If there is no separate vref-supply, then this is needed + to establish channel scaling. + + vdrive-supply: + description: + Some devices have separate supply for their digital control side. +
Documentation/devicetree/bindings/iio/adc/adi,ad7476.yaml line 72
Quoted 10 lines
Documentation/devicetree/bindings/iio/adc/adi,ad7476.yaml new file +10
-0+ vref-supply: + description: + Some devices have a specific reference voltage supplied on a different pin + to the other supplies. Needed to be able to establish channel scaling + unless there is also an internal reference available (e.g. ad7091r) + + spi-max-frequency: true + + adi,conversion-start-gpios: + description: A GPIO used to trigger the start of a conversion
maxItems: 1
With that,