From: Jonathan Cameron <jic23@kernel.org>
To: Matti Vaittinen <mazziesaccount@gmail.com>
Cc: Matti Vaittinen <matti.vaittinen@fi.rohmeurope.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] iio: dac: Support ROHM BD79703 DAC
Date: Thu, 19 Dec 2024 12:34:44 +0000 [thread overview]
Message-ID: <20241219123444.19bd1074@jic23-huawei> (raw)
In-Reply-To: <bc77d7b979ca28408a216f597082fcd94ec63be7.1734608215.git.mazziesaccount@gmail.com>
On Thu, 19 Dec 2024 13:39:37 +0200
Matti Vaittinen <mazziesaccount@gmail.com> wrote:
> The ROHM BD79703 is a 6 channel digital to analog converter.
>
> Based on the data-sheet examples the hardware would support setting the
> DAC word without changing the actual output. The data-sheet is not too
> specific on how the enabling the output of new voltage set by DAC
> should be done - hence this is not implemented by the driver.
I took a quick look and that does seem rather mysterious!
Normally there is either a 'sync' register or pin for setups like this
but no sign of either. Maybe it's legacy from some other use of the
same silicon.
>
> The BD79703 would also support two specific "PULL_DOWN" modes. These
> aren't currently supported by the driver either.
>
> Add a very basic support for controlling the channel outputs one-by-one.
>
> Signed-off-by: Matti Vaittinen <mazziesaccount@gmail.com>
Short and sweet. One totally trivial formatting thing I can fix whilst
applying and a passing comment below. will leave this a little while
to see what other feedback it gets and for DT folk to look at the binding.
Jonathan
> diff --git a/drivers/iio/dac/rohm-bd79703.c b/drivers/iio/dac/rohm-bd79703.c
> new file mode 100644
> index 000000000000..a3df31d81b7c
> --- /dev/null
> +++ b/drivers/iio/dac/rohm-bd79703.c
> @@ -0,0 +1,162 @@
> +
> +static int bd79703_probe(struct spi_device *spi)
> +{
> + struct device *dev = &spi->dev;
> + struct bd79703_data *data;
> + struct iio_dev *idev;
> + int ret;
> +
> + idev = devm_iio_device_alloc(dev, sizeof(*data));
> + if (!idev)
> + return -ENOMEM;
> +
> + data = iio_priv(idev);
> +
> + data->regmap = devm_regmap_init_spi(spi, &bd79703_regmap_config);
> + if (IS_ERR(data->regmap))
> + return dev_err_probe(dev, PTR_ERR(data->regmap),
> + "Failed to initialize Regmap\n");
> +
> + ret = devm_regulator_get_enable(dev, "vcc");
> + if (ret)
> + return dev_err_probe(dev, ret, "Failed to enable VCC\n");
> +
> + ret = devm_regulator_get_enable_read_voltage(dev, "vfs");
> + if (ret < 0)
> + 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->modes = INDIO_DIRECT_MODE;
> + idev->info = &bd79703_info;
> + idev->name = "bd79703";
> +
> + /* Initialize all to output zero */
I can't remember what we tend to do for defaults but I guess this
is safe enough. Alternative would be start the device with HI impedance
(power down state)
> + ret = regmap_write(data->regmap, BD79703_REG_OUT_ALL, 0);
> + if (ret)
> + return ret;
> +
> + return devm_iio_device_register(dev, idev);
> +}
> +
> +static const struct spi_device_id bd79703_id[] = {
> + { "bd79703", },
> + {}
{ }
Keep it consistent. This is the style I prefer though not sure I'll do
a full tidy up of this any time soon.
> +};
> +MODULE_DEVICE_TABLE(spi, bd79703_id);
> +
> +static const struct of_device_id bd79703_of_match[] = {
> + { .compatible = "rohm,bd79703", },
> + { }
> +};
> +MODULE_DEVICE_TABLE(of, bd79703_of_match);
next prev parent reply other threads:[~2024-12-19 12:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-19 11:38 [PATCH 0/3] Support ROHM BD79703 DAC Matti Vaittinen
2024-12-19 11:39 ` [PATCH 1/3] dt-bindings: Add ROHM BD79703 Matti Vaittinen
2024-12-19 18:59 ` Conor Dooley
2024-12-19 11:39 ` [PATCH 2/3] iio: dac: Support ROHM BD79703 DAC Matti Vaittinen
2024-12-19 12:34 ` Jonathan Cameron [this message]
2024-12-19 11:39 ` [PATCH 3/3] MAINTAINERS: Add maintainer for ROHM BD79703 Matti Vaittinen
2024-12-20 19:12 ` [PATCH 0/3] Support ROHM BD79703 DAC Jonathan Cameron
2024-12-22 9:21 ` 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=20241219123444.19bd1074@jic23-huawei \
--to=jic23@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.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=mazziesaccount@gmail.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