From: Angelo Dureghello <adureghello@baylibre.com>
To: jic23@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org
Cc: nuno.sa@analog.com, lars@metafoo.de,
Michael.Hennerich@analog.com, linux-iio@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
Angelo Dureghello <adureghello@baylibre.com>
Subject: [PATCH 2/3] iio: dac: ad3552r: add support for ad3541r and ad3551r
Date: Fri, 10 May 2024 16:18:35 +0200 [thread overview]
Message-ID: <20240510141836.1624009-2-adureghello@baylibre.org> (raw)
In-Reply-To: <20240510141836.1624009-1-adureghello@baylibre.org>
From: Angelo Dureghello <adureghello@baylibre.com>
Add support for single-output dac variants.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
drivers/iio/dac/ad3552r.c | 39 +++++++++++++++++++++++++++++----------
1 file changed, 29 insertions(+), 10 deletions(-)
diff --git a/drivers/iio/dac/ad3552r.c b/drivers/iio/dac/ad3552r.c
index a492e8f2fc0f..0dd6f995c3e2 100644
--- a/drivers/iio/dac/ad3552r.c
+++ b/drivers/iio/dac/ad3552r.c
@@ -140,7 +140,9 @@ enum ad3552r_ch_vref_select {
};
enum ad3542r_id {
+ AD3541R_ID = 0x400b,
AD3542R_ID = 0x4009,
+ AD3551R_ID = 0x400a,
AD3552R_ID = 0x4008,
};
@@ -745,7 +747,8 @@ static void ad3552r_calc_gain_and_offset(struct ad3552r_desc *dac, s32 ch)
} else {
/* Normal range */
idx = dac->ch_data[ch].range;
- if (dac->chip_id == AD3542R_ID) {
+ if (dac->chip_id == AD3541R_ID ||
+ dac->chip_id == AD3542R_ID) {
v_min = ad3542r_ch_ranges[idx][0];
v_max = ad3542r_ch_ranges[idx][1];
} else {
@@ -780,7 +783,7 @@ static int ad3552r_find_range(u16 id, s32 *vals)
int i, len;
const s32 (*ranges)[2];
- if (id == AD3542R_ID) {
+ if (id == AD3541R_ID || id == AD3542R_ID) {
len = ARRAY_SIZE(ad3542r_ch_ranges);
ranges = ad3542r_ch_ranges;
} else {
@@ -955,9 +958,10 @@ static int ad3552r_configure_device(struct ad3552r_desc *dac)
dev_err(dev, "mandatory reg property missing\n");
goto put_child;
}
- if (ch >= AD3552R_NUM_CH) {
- dev_err(dev, "reg must be less than %d\n",
- AD3552R_NUM_CH);
+ if (ch >= AD3552R_NUM_CH ||
+ (dac->chip_id == AD3541R_ID && ch) ||
+ (dac->chip_id == AD3551R_ID && ch)) {
+ dev_err(dev, "channel %d is not supported\n", ch);
err = -EINVAL;
goto put_child;
}
@@ -987,9 +991,10 @@ static int ad3552r_configure_device(struct ad3552r_desc *dac)
goto put_child;
dac->ch_data[ch].range = val;
- } else if (dac->chip_id == AD3542R_ID) {
+ } else if (dac->chip_id == AD3541R_ID ||
+ dac->chip_id == AD3542R_ID) {
dev_err(dev,
- "adi,output-range-microvolt is required for ad3542r\n");
+ "adi,output-range-microvolt is required for ad354xr\n");
err = -EINVAL;
goto put_child;
} else {
@@ -1088,10 +1093,20 @@ static int ad3552r_probe(struct spi_device *spi)
return err;
/* Config triggered buffer device */
- if (dac->chip_id == AD3552R_ID)
- indio_dev->name = "ad3552r";
- else
+ switch (dac->chip_id) {
+ case AD3541R_ID:
+ indio_dev->name = "ad3541r";
+ break;
+ case AD3542R_ID:
indio_dev->name = "ad3542r";
+ break;
+ case AD3551R_ID:
+ indio_dev->name = "ad3551r";
+ break;
+ case AD3552R_ID:
+ indio_dev->name = "ad3552r";
+ break;
+ }
indio_dev->dev.parent = &spi->dev;
indio_dev->info = &ad3552r_iio_info;
indio_dev->num_channels = dac->num_ch;
@@ -1110,14 +1125,18 @@ static int ad3552r_probe(struct spi_device *spi)
}
static const struct spi_device_id ad3552r_id[] = {
+ { "ad3541r", AD3541R_ID },
{ "ad3542r", AD3542R_ID },
+ { "ad3551r", AD3551R_ID },
{ "ad3552r", AD3552R_ID },
{ }
};
MODULE_DEVICE_TABLE(spi, ad3552r_id);
static const struct of_device_id ad3552r_of_match[] = {
+ { .compatible = "adi,ad3541r"},
{ .compatible = "adi,ad3542r"},
+ { .compatible = "adi,ad3551r"},
{ .compatible = "adi,ad3552r"},
{ }
};
--
2.45.0.rc1
next prev parent reply other threads:[~2024-05-10 14:19 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-10 14:18 [PATCH 1/3] dt-bindings: iio: dac: add ad35xxr single output variants Angelo Dureghello
2024-05-10 14:18 ` Angelo Dureghello [this message]
2024-05-10 15:42 ` [PATCH 2/3] iio: dac: ad3552r: add support for ad3541r and ad3551r David Lechner
2024-05-16 13:17 ` Angelo Dureghello
2024-05-10 14:18 ` [PATCH 3/3] dt-bindings: iio: dac: fix ad3552r gain parameter names Angelo Dureghello
2024-05-10 15:43 ` David Lechner
2024-05-13 18:52 ` Rob Herring
2024-05-13 19:03 ` David Lechner
2024-05-10 15:39 ` [PATCH 1/3] dt-bindings: iio: dac: add ad35xxr single output variants David Lechner
2024-05-11 16:05 ` Jonathan Cameron
2024-05-16 13:20 ` Angelo Dureghello
2024-05-11 16:04 ` Jonathan Cameron
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=20240510141836.1624009-2-adureghello@baylibre.org \
--to=adureghello@baylibre.com \
--cc=Michael.Hennerich@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@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 read-only IMAP folder(s) and NNTP newsgroup(s).