From: "Nuno Sá" <noname.nuno@gmail.com>
To: Kim Seer Paller <kimseer.paller@analog.com>,
linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Liam Girdwood <lgirdwood@gmail.com>,
Mark Brown <broonie@kernel.org>,
Dimitri Fedrau <dima.fedrau@gmail.com>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Rob Herring <robh@kernel.org>, Conor Dooley <conor+dt@kernel.org>,
Michael Hennerich <michael.hennerich@analog.com>
Subject: Re: [PATCH v4 5/5] iio: dac: ltc2664: Add driver for LTC2664 and LTC2672
Date: Wed, 26 Jun 2024 13:14:32 +0200 [thread overview]
Message-ID: <2c8127ab4e26cc3b12793c942435ccd6cb9f5432.camel@gmail.com> (raw)
In-Reply-To: <20240619064904.73832-6-kimseer.paller@analog.com>
On Wed, 2024-06-19 at 14:49 +0800, Kim Seer Paller wrote:
> LTC2664 4 channel, 12-/16-Bit Voltage Output SoftSpan DAC
> LTC2672 5 channel, 12-/16-Bit Current Output Softspan DAC
>
> Co-developed-by: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
> Signed-off-by: Kim Seer Paller <kimseer.paller@analog.com>
> ---
Just minor nits... Anyways:
Reviewed-by: Nuno Sa <nuno.sa@analog.com>
> MAINTAINERS | 1 +
> drivers/iio/dac/Kconfig | 11 +
> drivers/iio/dac/Makefile | 1 +
> drivers/iio/dac/ltc2664.c | 755 ++++++++++++++++++++++++++++++++++++++
> 4 files changed, 768 insertions(+)
> create mode 100644 drivers/iio/dac/ltc2664.c
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index f4a5b5bc8ccc..7a02d9a196fb 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -13082,6 +13082,7 @@ S: Supported
> W: https://ez.analog.com/linux-software-drivers
> F: Documentation/devicetree/bindings/iio/dac/adi,ltc2664.yaml
> F: Documentation/devicetree/bindings/iio/dac/adi,ltc2672.yaml
> +F: drivers/iio/dac/ltc2664.c
>
> LTC2688 IIO DAC DRIVER
> M: Nuno Sá <nuno.sa@analog.com>
> diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
> index fb48dddbcc20..3a7691db3998 100644
> --- a/drivers/iio/dac/Kconfig
> +++ b/drivers/iio/dac/Kconfig
> @@ -371,6 +371,17 @@ config LTC2632
> To compile this driver as a module, choose M here: the
> module will be called ltc2632.
>
> +config LTC2664
> + tristate "Analog Devices LTC2664 and LTC2672 DAC SPI driver"
> + depends on SPI
> + select REGMAP
> + help
> + Say yes here to build support for Analog Devices
> + LTC2664 and LTC2672 converters (DAC).
> +
> + To compile this driver as a module, choose M here: the
> + module will be called ltc2664.
> +
> config M62332
> tristate "Mitsubishi M62332 DAC driver"
> depends on I2C
> diff --git a/drivers/iio/dac/Makefile b/drivers/iio/dac/Makefile
> index 8432a81a19dc..2cf148f16306 100644
> --- a/drivers/iio/dac/Makefile
> +++ b/drivers/iio/dac/Makefile
> @@ -37,6 +37,7 @@ obj-$(CONFIG_DS4424) += ds4424.o
> obj-$(CONFIG_LPC18XX_DAC) += lpc18xx_dac.o
> obj-$(CONFIG_LTC1660) += ltc1660.o
> obj-$(CONFIG_LTC2632) += ltc2632.o
> +obj-$(CONFIG_LTC2664) += ltc2664.o
> obj-$(CONFIG_LTC2688) += ltc2688.o
> obj-$(CONFIG_M62332) += m62332.o
> obj-$(CONFIG_MAX517) += max517.o
> diff --git a/drivers/iio/dac/ltc2664.c b/drivers/iio/dac/ltc2664.c
> new file mode 100644
> index 000000000000..9b73b9c6a7a7
> --- /dev/null
> +++ b/drivers/iio/dac/ltc2664.c
> @@ -0,0 +1,755 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/*
> + * LTC2664 4 channel, 12-/16-Bit Voltage Output SoftSpan DAC driver
> + * LTC2672 5 channel, 12-/16-Bit Current Output Softspan DAC driver
> + *
> + * Copyright 2024 Analog Devices Inc.
> + */
> +
>
...
> +
> +static int ltc2664_dac_code_read(struct ltc2664_state *st, u32 chan, u32
> input,
> + u32 *code)
> +{
> + guard(mutex)(&st->lock);
> + *code = st->channels[chan].raw[input];
> +
> + return 0;
no need for an error code...
...
>
> +static int ltc2664_probe(struct spi_device *spi)
> +{
> + static const char * const regulators[] = { "vcc", "iovcc", "v-neg" };
> + const struct ltc2664_chip_info *chip_info;
> + struct device *dev = &spi->dev;
> + struct iio_dev *indio_dev;
> + struct ltc2664_state *st;
> + int ret;
> +
> + indio_dev = devm_iio_device_alloc(dev, sizeof(*st));
> + if (!indio_dev)
> + return -ENOMEM;
> +
> + st = iio_priv(indio_dev);
> + st->spi = spi;
> +
> + chip_info = spi_get_device_match_data(spi);
> + if (!chip_info)
> + return -ENODEV;
> +
> + st->chip_info = chip_info;
> +
> + mutex_init(&st->lock);
> +
> + st->regmap = devm_regmap_init_spi(spi, <c2664_regmap_config);
> + if (IS_ERR(st->regmap))
> + return dev_err_probe(dev, PTR_ERR(st->regmap),
> + "Failed to init regmap");
> +
> + ret = devm_regulator_bulk_get_enable(dev, ARRAY_SIZE(regulators),
> + regulators);
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to enable
> regulators\n");
> +
> + ret = devm_regulator_get_enable_read_voltage(dev, "ref");
> + if (ret < 0)
> + return dev_err_probe(dev, ret, "Failed to get vref
> voltage\n");
> + else if (ret == -ENODEV)
> + st->vref_mv = chip_info->internal_vref_mv;
> + else
> + st->vref_mv = ret / 1000;
This could be:
if (ret < 0 && ret != -ENODEV)
return ret;
st->vref_mv = ret > 0 ? ret / 1000 : chip_info->internal_vref_mv;
- Nuno Sá
prev parent reply other threads:[~2024-06-26 11:10 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-19 6:48 [PATCH v4 0/5] Add driver for LTC2664 and LTC2672 Kim Seer Paller
2024-06-19 6:49 ` [PATCH v4 1/5] iio: ABI: Generalize ABI documentation for DAC Kim Seer Paller
2024-06-19 6:49 ` [PATCH v4 2/5] iio: ABI: add DAC 42kohm_to_gnd powerdown mode Kim Seer Paller
2024-06-19 6:49 ` [PATCH v4 3/5] dt-bindings: iio: dac: Add adi,ltc2664.yaml Kim Seer Paller
2024-06-19 17:56 ` Conor Dooley
2024-06-24 15:13 ` Paller, Kim Seer
2024-06-24 16:13 ` Conor Dooley
2024-06-24 16:48 ` David Lechner
2024-06-25 15:41 ` Paller, Kim Seer
2024-06-19 6:49 ` [PATCH v4 4/5] dt-bindings: iio: dac: Add adi,ltc2672.yaml Kim Seer Paller
2024-06-19 17:57 ` Conor Dooley
2024-06-23 13:43 ` Jonathan Cameron
2024-06-23 14:03 ` Conor Dooley
2024-06-23 16:20 ` Jonathan Cameron
2024-06-24 15:26 ` Paller, Kim Seer
2024-06-24 17:00 ` Conor Dooley
2024-06-24 17:37 ` Jonathan Cameron
2024-06-25 15:51 ` Paller, Kim Seer
2024-06-25 16:20 ` Conor Dooley
2024-06-28 19:02 ` Jonathan Cameron
2024-06-19 6:49 ` [PATCH v4 5/5] iio: dac: ltc2664: Add driver for LTC2664 and LTC2672 Kim Seer Paller
2024-06-20 0:00 ` Paller, Kim Seer
2024-06-23 13:50 ` Jonathan Cameron
2024-06-26 11:14 ` Nuno Sá [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2c8127ab4e26cc3b12793c942435ccd6cb9f5432.camel@gmail.com \
--to=noname.nuno@gmail.com \
--cc=broonie@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dima.fedrau@gmail.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=kimseer.paller@analog.com \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=lgirdwood@gmail.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael.hennerich@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).