Support ROHM BD79703 DAC
Subsystems (3)
Matti Vaittinen
maintainercover Support ROHM BD79703 DAC
Add support for the ROHM BD79703 DAC
The ROHM BD79703 DAC is a 6-channel 8-bit digital to analog converter which can be controlled over SPI bus. This series adds support for controlling the analog channels via IIO direct mode.
Matti Vaittinen (3):
dt-bindings: Add ROHM BD79703
iio: dac: Support ROHM BD79703 DAC
MAINTAINERS: Add maintainer for ROHM BD79703
.../bindings/iio/dac/rohm,bd79703.yaml | 61 +++++++ MAINTAINERS | 5 + drivers/iio/dac/Kconfig | 8 + drivers/iio/dac/Makefile | 1 + drivers/iio/dac/rohm-bd79703.c | 162 ++++++++++++++++++ 5 files changed, 237 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml create mode 100644 drivers/iio/dac/rohm-bd79703.c
base-commit: 4d112ebd02d10faf202aa8335b06de0aca8b536b
Signature · 1 line
2.47.0
Matti Vaittinen
maintainerPATCH 1/3 dt-bindings: Add ROHM BD79703
The ROHM BD79703 is a 8-bit, 6 channel DAC.
Describe the dt-bindings.
--- .../bindings/iio/dac/rohm,bd79703.yaml | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml
Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml new file +61 -0
@@ -0,0 +1,61 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +# Copyright 2024 ROHM Semiconductor. +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/iio/dac/rohm,bd79703.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ROHM BD79703 DAC device driver + +maintainers: + - Matti Vaittinen <[email protected]> + +description: | + The ROHM BD79703 is a 6 channel, 8-bit DAC. + Datasheet can be found here: + https://fscdn.rohm.com/en/products/databook/datasheet/ic/data_converter/dac/bd79702fv-lb_bd79703fv-lb-e.pdf + +properties: + compatible: + const: rohm,bd79703 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 30000000 + + vfs-supply: + description: + The regulator to use as a full scale voltage. The voltage should be between 2.7V .. VCC + + vcc-supply: + description: + The regulator supplying the operating voltage. Should be between 2.7V ... 5.5V + +required: + - compatible + - reg + - spi-max-frequency + - vfs-supply + - vcc-supply + +allOf: + - $ref: /schemas/spi/spi-peripheral-props.yaml# + +additionalProperties: false + +examples: + - | + spi { + #address-cells = <1>; + #size-cells = <0>; + dac@0 { + compatible = "rohm,bd79703"; + reg = <0>; + spi-max-frequency = <30000000>; + vcc-supply = <&vcc>; + vfs-supply = <&vref>; + }; + }; +...
Signature · 1 line
2.47.0
Re: [PATCH 1/3] dt-bindings: Add ROHM BD79703
Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml line 53
Quoted 4 lines · Matti Vaittinen
Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml new file +4
-0+ spi { + #address-cells = <1>; + #size-cells = <0>; + dac@0 {
nit: should be a blank line before the child node.
Cheers,
Conor.
Quoted 11 lines
Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml new file +8
-0+ compatible = "rohm,bd79703"; + reg = <0>; + spi-max-frequency = <30000000>; + vcc-supply = <&vcc>; + vfs-supply = <&vref>; + }; + }; +...Signature · 1 line
2.47.0
Matti Vaittinen
maintainerPATCH 2/3 iio: dac: Support ROHM BD79703 DAC
In reply to Matti VaittinenThe 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.
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.
--- drivers/iio/dac/Kconfig | 8 ++ drivers/iio/dac/Makefile | 1 + drivers/iio/dac/rohm-bd79703.c | 162 +++++++++++++++++++++++++++++++++ 3 files changed, 171 insertions(+) create mode 100644 drivers/iio/dac/rohm-bd79703.c
drivers/iio/dac/Kconfig +8 -0
@@ -348,6 +348,14 @@ config AD8801 To compile this driver as a module choose M here: the module will be called ad8801. +config BD79703 + tristate "ROHM Semiconductor BD79703 DAC driver" + depends on SPI + select REGMAP_SPI + help + Say yes here to build support for ROHM Semiconductor BD79703 Digital + to Analog Converter (DAC). + config CIO_DAC tristate "Measurement Computing CIO-DAC IIO driver" depends on X86 && (ISA_BUS || PC104)
drivers/iio/dac/Makefile +1 -0
@@ -34,6 +34,7 @@ obj-$(CONFIG_AD8460) += ad8460.o obj-$(CONFIG_AD8801) += ad8801.o obj-$(CONFIG_AD9739A) += ad9739a.o obj-$(CONFIG_ADI_AXI_DAC) += adi-axi-dac.o +obj-$(CONFIG_BD79703) += rohm-bd79703.o obj-$(CONFIG_CIO_DAC) += cio-dac.o obj-$(CONFIG_DPOT_DAC) += dpot-dac.o obj-$(CONFIG_DS4424) += ds4424.o
drivers/iio/dac/rohm-bd79703.c new file +162 -0
162 lines not on this page · raw message
Signature · 1 line
2.47.0
Jonathan Cameron
maintainerRe: [PATCH 2/3] iio: dac: Support ROHM BD79703 DAC
Quoted 6 lines · On Thu, 19 Dec 2024 13:39:37 +0200 Matti Vaittinen <[email protected]>…
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.
Quoted 7 lines
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 <[email protected]>
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
Quoted 33 lines
drivers/iio/dac/rohm-bd79703.c new file +25
-0@@ -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 )
drivers/iio/dac/rohm-bd79703.c line 130
Quoted 10 lines
drivers/iio/dac/rohm-bd79703.c new file +10
-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)
drivers/iio/dac/rohm-bd79703.c line 140
Quoted 10 lines
drivers/iio/dac/rohm-bd79703.c new file +10
-0+ 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.
Quoted 8 lines
drivers/iio/dac/rohm-bd79703.c new file +8
-0+}; +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);
Matti Vaittinen
maintainerPATCH 3/3 MAINTAINERS: Add maintainer for ROHM BD79703
In reply to Matti VaittinenAdd undersigned as a maintainer for the ROHM BD79703 DAC driver.
--- MAINTAINERS | 5 +++++ 1 file changed, 5 insertions(+)
MAINTAINERS +5 -0
@@ -20286,6 +20286,11 @@ L: [email protected] S: Odd Fixes F: drivers/tty/serial/rp2.* +ROHM BD79703 DAC +M: Matti Vaittinen <[email protected]> +S: Supported +F: drivers/iio/dac/rohm-bd79703.c + ROHM BD99954 CHARGER IC M: Matti Vaittinen <[email protected]> S: Supported
Signature · 1 line
2.47.0
Jonathan Cameron
maintainerQuoted 5 lines · On Thu, 19 Dec 2024 13:38:54 +0200 Matti Vaittinen <[email protected]>…
Add support for the ROHM BD79703 DAC
The ROHM BD79703 DAC is a 6-channel 8-bit digital to analog converter which can be controlled over SPI bus. This series adds support for controlling the analog channels via IIO direct mode.
Tweaked the two trivial comments from Conor and I and applied.
Pushed out as testing for all the normal reasons plus that this was only on the list for a day so there may be more reviews! :)
What can I say, it's near Christmas and I was feeling impatient!
Quoted 17 lines
Matti Vaittinen (3):
dt-bindings: Add ROHM BD79703
iio: dac: Support ROHM BD79703 DAC
MAINTAINERS: Add maintainer for ROHM BD79703.../bindings/iio/dac/rohm,bd79703.yaml | 61 +++++++ MAINTAINERS | 5 + drivers/iio/dac/Kconfig | 8 + drivers/iio/dac/Makefile | 1 + drivers/iio/dac/rohm-bd79703.c | 162 ++++++++++++++++++ 5 files changed, 237 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/dac/rohm,bd79703.yaml create mode 100644 drivers/iio/dac/rohm-bd79703.cbase-commit:
4d112ebd02d10faf202aa8335b06de0aca8b536b
Matti Vaittinen
maintainerQuoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Thu, 19 Dec 2024 13:38:54 +0200 Matti Vaittinen <[email protected]>…
Add support for the ROHM BD79703 DAC
The ROHM BD79703 DAC is a 6-channel 8-bit digital to analog converter which can be controlled over SPI bus. This series adds support for controlling the analog channels via IIO direct mode.
Quoted 6 lines
Tweaked the two trivial comments from Conor and I and applied.
Pushed out as testing for all the normal reasons plus that this was only on the list for a day so there may be more reviews! :)
What can I say, it's near Christmas and I was feeling impatient!
Whoah!
I think I received your comments maybe around an hour after sending the series. And just couple of days later the series got merged to your tree. I'd say this is a new record for drivers I've written! It must be the holiday spirits XD
Quite effective! Thanks! ;)
Yours,
-- Matti