From: Matti Vaittinen <mazziesaccount@gmail.com>
To: Matti Vaittinen <mazziesaccount@gmail.com>,
Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>
Cc: Jonathan Cameron <jic23@kernel.org>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Matti Vaittinen <mazziesaccount@gmail.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/5] dac: bd79703: Add chip data
Date: Wed, 2 Apr 2025 09:46:13 +0300 [thread overview]
Message-ID: <2cacb4bec5455fe1aa58a0b28d2d91b96a396d1a.1743576022.git.mazziesaccount@gmail.com> (raw)
In-Reply-To: <cover.1743576022.git.mazziesaccount@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2740 bytes --]
Add a chip data structure which allows handling the different variants
(ROHM BD79700, BD79701) with different number of channels.
Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
---
drivers/iio/dac/rohm-bd79703.c | 29 ++++++++++++++++++++++++-----
1 file changed, 24 insertions(+), 5 deletions(-)
diff --git a/drivers/iio/dac/rohm-bd79703.c b/drivers/iio/dac/rohm-bd79703.c
index 236aa98bf005..35e1b1134ec6 100644
--- a/drivers/iio/dac/rohm-bd79703.c
+++ b/drivers/iio/dac/rohm-bd79703.c
@@ -38,11 +38,19 @@ static const struct regmap_config bd79703_regmap_config = {
.cache_type = REGCACHE_RBTREE,
};
+/* Dynamic driver private data */
struct bd79703_data {
struct regmap *regmap;
int vfs;
};
+/* Static, IC type specific data for different variants */
+struct bd7970x_chip_data {
+ const char *name;
+ const struct iio_chan_spec *channels;
+ int num_channels;
+};
+
static int bd79703_read_raw(struct iio_dev *idev,
struct iio_chan_spec const *chan, int *val,
int *val2, long mask)
@@ -94,13 +102,24 @@ static const struct iio_chan_spec bd79703_channels[] = {
BD79703_CHAN(5),
};
+static const struct bd7970x_chip_data bd79703_chip_data = {
+ .name = "bd79703",
+ .channels = bd79703_channels,
+ .num_channels = ARRAY_SIZE(bd79703_channels),
+};
+
static int bd79703_probe(struct spi_device *spi)
{
+ const struct bd7970x_chip_data *cd;
struct device *dev = &spi->dev;
struct bd79703_data *data;
struct iio_dev *idev;
int ret;
+ cd = spi_get_device_match_data(spi);
+ if (!cd)
+ return -ENODEV;
+
idev = devm_iio_device_alloc(dev, sizeof(*data));
if (!idev)
return -ENOMEM;
@@ -121,11 +140,11 @@ static int bd79703_probe(struct spi_device *spi)
return dev_err_probe(dev, ret, "Failed to get Vfs\n");
data->vfs = ret;
- idev->channels = bd79703_channels;
- idev->num_channels = ARRAY_SIZE(bd79703_channels);
+ idev->channels = cd->channels;
+ idev->num_channels = cd->num_channels;
idev->modes = INDIO_DIRECT_MODE;
idev->info = &bd79703_info;
- idev->name = "bd79703";
+ idev->name = cd->name;
/* Initialize all to output zero */
ret = regmap_write(data->regmap, BD79703_REG_OUT_ALL, 0);
@@ -136,13 +155,13 @@ static int bd79703_probe(struct spi_device *spi)
}
static const struct spi_device_id bd79703_id[] = {
- { "bd79703", },
+ { "bd79703", (kernel_ulong_t)&bd79703_chip_data },
{ }
};
MODULE_DEVICE_TABLE(spi, bd79703_id);
static const struct of_device_id bd79703_of_match[] = {
- { .compatible = "rohm,bd79703", },
+ { .compatible = "rohm,bd79703", .data = &bd79703_chip_data },
{ }
};
MODULE_DEVICE_TABLE(of, bd79703_of_match);
--
2.49.0
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2025-04-02 6:46 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-02 6:44 [PATCH 0/5] Support ROHM BD797xx DACs Matti Vaittinen
2025-04-02 6:44 ` [PATCH 1/5] dt-bindings: Add ROHM BD7970x variants Matti Vaittinen
2025-04-02 13:27 ` Conor Dooley
2025-04-02 6:45 ` [PATCH 2/5] iio: dac: bd79703 Store device address to 'address' Matti Vaittinen
2025-04-02 6:46 ` Matti Vaittinen [this message]
2025-04-02 6:46 ` [PATCH 4/5] iio: bd79703: Support BD79700 and BD79701 Matti Vaittinen
2025-04-02 6:46 ` [PATCH 5/5] iio: dac: bd79703: Support ROHM BD79702 Matti Vaittinen
2025-04-05 17:18 ` [PATCH 0/5] Support ROHM BD797xx DACs Jonathan Cameron
2025-04-07 5:12 ` Matti Vaittinen
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=2cacb4bec5455fe1aa58a0b28d2d91b96a396d1a.1743576022.git.mazziesaccount@gmail.com \
--to=mazziesaccount@gmail.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=matti.vaittinen@fi.rohmeurope.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
all inboxes | Powered by JetHome®