Re: [PATCH v3 9/9] iio: adc: ti-ads1262: support common mode supplies

David Lechner <[email protected]>
Newsgroups org.kernel.vger.linux-iio,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-gpio,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 8/7/26 10:58 PM, Kurt Borja wrote:
> Enable common mode regulators. The usual configuration is to have our
> own 'vbias' regulator connected internally as common mode voltage on the
> AINCOM pin.
> 
> Signed-off-by: Kurt Borja <[email protected]>
> ---
>  drivers/iio/adc/ti-ads1262.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/iio/adc/ti-ads1262.c b/drivers/iio/adc/ti-ads1262.c
> index 533574169b04..238d803abc50 100644
> --- a/drivers/iio/adc/ti-ads1262.c
> +++ b/drivers/iio/adc/ti-ads1262.c
> @@ -962,6 +962,27 @@ static irqreturn_t ads1262_irq_handler(int irq, void *dev_id)
>  	return IRQ_HANDLED;
>  }
>  
> +static int ads1262_common_mode_setup(struct ads1262 *st)
> +{
> +	struct device *dev = &st->spi->dev;
> +	char name[sizeof("aincom")];
> +	int ret;
> +
> +	for (unsigned int i = 0; i <= ADS1262_INPMUX_AINCOM; i++) {
> +		if (i < ADS1262_INPMUX_AINCOM)
> +			scnprintf(name, sizeof(name), "ain%u", i);
> +		else
> +			scnprintf(name, sizeof(name), "aincom");
> +
> +		ret = devm_regulator_get_enable_optional(dev, name);

We need to get the voltage which is then used to provide an offset
(IIO_CHAN_INFO_OFFSET) for the channel.

> +		if (ret < 0 && ret != -ENODEV)
> +			return dev_err_probe(dev, ret,
> +					     "failed to get common mode supply: %s\n", name);
> +	}
> +
> +	return 0;
> +}
> +
>  static int ads1262_regulator_enable(struct regulator_dev *rdev)
>  {
>  	struct ads1262 *st = rdev_get_drvdata(rdev);
> @@ -1797,6 +1818,10 @@ static int ads1262_spi_probe(struct spi_device *spi)
>  	if (ret)
>  		return ret;
>  
> +	ret = ads1262_common_mode_setup(st);
> +	if (ret)
> +		return ret;
> +
>  	ret = devm_iio_triggered_buffer_setup(dev, indio_dev,
>  					      iio_pollfunc_store_time,
>  					      ads1262_trigger_handler,
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.