Skip to contentSkip to conversation

iio: dac: Add support for the AD5592R/AD5593R ADCs/DACs

PATCH In review [email protected] 3 participants 3 messages Apr 5, 2016 – Apr 10, 2016 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH v6 1/1 iio: dac: Add support for the AD5592R/AD5593R ADCs/DACs

From: Paul Cercueil <[email protected]>

This patch adds support for the AD5592R (spi) and AD5593R (i2c) ADC/DAC/GPIO devices.

---

Changes since v1:
* Fix mutex usage
* Remove unnecessary NULL pointer guards
* Add comment explaining the invalid data read
* AD5593R Remove surplus adc readback

Changes since v2:
* Use child nodes to describe channels
* Fix probe return and driver remove path
* Move locking closer to where its used
* Remove WARN_ON but return error
* Remove OPEN DRAIN configuration option

Changes since v3:
* Documentation: Add missing vendor prefixes in the examples
* Minor function reordering in remove() to match the reverse of probe()

Changes since v4:
* Documentation: Add missing gpio bindings
* Kconfig: Select GPIOLIB and remove ifdefs in code
* Remove surplus error check in ad5592r_gpio_request()
* Add comment about reset magic

Changes since v5:
* Remove surplus error check
* Remove additional ifdef CONFIG_GPIOLIB guards in the header
* Bindings: Add additional comments about CH_MODE_DAC_AND_ADC mode

---
 .../devicetree/bindings/iio/dac/ad5592r.txt        | 155 +++++
 drivers/iio/dac/Kconfig                            |  27 +
 drivers/iio/dac/Makefile                           |   3 +
 drivers/iio/dac/ad5592r-base.c                     | 691 +++++++++++++++++++++
 drivers/iio/dac/ad5592r-base.h                     |  76 +++
 drivers/iio/dac/ad5592r.c                          | 164 +++++
 drivers/iio/dac/ad5593r.c                          | 131 ++++
 include/dt-bindings/iio/adi,ad5592r.h              |  16 +
 8 files changed, 1263 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/dac/ad5592r.txt
 create mode 100644 drivers/iio/dac/ad5592r-base.c
 create mode 100644 drivers/iio/dac/ad5592r-base.h
 create mode 100644 drivers/iio/dac/ad5592r.c
 create mode 100644 drivers/iio/dac/ad5593r.c
 create mode 100644 include/dt-bindings/iio/adi,ad5592r.h
Documentation/devicetree/bindings/iio/dac/ad5592r.txt new file +155 -0
new file mode 100644
index 0000000..989f96f
@@ -0,0 +1,155 @@
+Analog Devices AD5592R/AD5593R DAC/ADC device driver
+
+Required properties for the AD5592R:
+	- compatible: Must be "adi,ad5592r"
+	- reg: SPI chip select number for the device
+	- spi-max-frequency: Max SPI frequency to use (< 30000000)
+	- spi-cpol: The AD5592R requires inverse clock polarity (CPOL) mode
+
+Required properties for the AD5593R:
+	- compatible: Must be "adi,ad5593r"
+	- reg: I2C address of the device
+
+Required properties for all supported chips:
+	- #address-cells: Should be 1.
+	- #size-cells: Should be 0.
+	- channel nodes:
+	  Each child node represents one channel and has the following
+	  Required properties:
+		* reg: Pin on which this channel is connected to.
+		* adi,mode: Mode or function of this channel.
+			    Macros specifying the valid values
+			    can be found in <dt-bindings/iio/adi,ad5592r.h>.
+
+			    The following values are currently supported:
+				* CH_MODE_UNUSED (the pin is unused)
+				* CH_MODE_ADC (the pin is ADC input)
+				* CH_MODE_DAC (the pin is DAC output)
+				* CH_MODE_DAC_AND_ADC (the pin is DAC output
+					but can be monitored by an ADC, since
+					there is no disadvantage this
+					this should be considered as the
+					preferred DAC mode)
+				* CH_MODE_GPIO (the pin is registered
+					with GPIOLIB)
+	 Optional properties:
+		* adi,off-state: State of this channel when unused or the
+				 device gets removed. Macros specifying the
+				 valid values can be found in
+				 <dt-bindings/iio/adi,ad5592r.h>.
+
+				* CH_OFFSTATE_PULLDOWN (the pin is pulled down)
+				* CH_OFFSTATE_OUT_LOW  (the pin is output low)
+				* CH_OFFSTATE_OUT_HIGH (the pin is output high)
+				* CH_OFFSTATE_OUT_TRISTATE (the pin is
+					tristated output)
+
+
+Optional properties:
+	- vref-supply: Phandle to the external reference voltage supply. This should
+	  only be set if there is an external reference voltage connected to the VREF
+	  pin. If the property is not set the internal 2.5V reference is used.
+	- reset-gpios : GPIO spec for the RESET pin. If specified, it will be
+	  asserted during driver probe.
+	- gpio-controller: Marks the device node as a GPIO controller.
+	- #gpio-cells: Should be 2. The first cell is the GPIO number and the second
+	  cell specifies GPIO flags, as defined in <dt-bindings/gpio/gpio.h>.
+
+AD5592R Example:
+
+	#include <dt-bindings/iio/adi,ad5592r.h>
+
+	vref: regulator-vref {
+		compatible = "regulator-fixed";
+		regulator-name = "vref-ad559x";
+		regulator-min-microvolt = <3300000>;
+		regulator-max-microvolt = <3300000>;
+		regulator-always-on;
+	};
+
+	ad5592r@0 {
+		#size-cells = <0>;
+		#address-cells = <1>;
+		#gpio-cells = <2>;
+		compatible = "adi,ad5592r";
+		reg = <0>;
+
+		spi-max-frequency = <1000000>;
+		spi-cpol;
+
+		vref-supply = <&vref>; /* optional */
+		reset-gpios = <&gpio0 86 0>;  /* optional */
+		gpio-controller;
+
+		channel@0 {
+			reg = <0>;
+			adi,mode = <CH_MODE_DAC>;
+		};
+		channel@1 {
+			reg = <1>;
+			adi,mode = <CH_MODE_ADC>;
+		};
+		channel@2 {
+			reg = <2>;
+			adi,mode = <CH_MODE_DAC_AND_ADC>;
+		};
+		channel@3 {
+			reg = <3>;
+			adi,mode = <CH_MODE_DAC_AND_ADC>;
+			adi,off-state = <CH_OFFSTATE_PULLDOWN>;
+		};
+		channel@4 {
+			reg = <4>;
+			adi,mode = <CH_MODE_UNUSED>;
+			adi,off-state = <CH_OFFSTATE_PULLDOWN>;
+		};
+		channel@5 {
+			reg = <5>;
+			adi,mode = <CH_MODE_GPIO>;
+			adi,off-state = <CH_OFFSTATE_PULLDOWN>;
+		};
+		channel@6 {
+			reg = <6>;
+			adi,mode = <CH_MODE_GPIO>;
+			adi,off-state = <CH_OFFSTATE_PULLDOWN>;
+		};
+		channel@7 {
+			reg = <7>;
+			adi,mode = <CH_MODE_GPIO>;
+			adi,off-state = <CH_OFFSTATE_PULLDOWN>;
+		};
+	};
+
+AD5593R Example:
+
+	#include <dt-bindings/iio/adi,ad5592r.h>
+
+	ad5593r@10 {
+		#size-cells = <0>;
+		#address-cells = <1>;
+		#gpio-cells = <2>;
+		compatible = "adi,ad5593r";
+		reg = <0x10>;
+		gpio-controller;
+
+		channel@0 {
+			reg = <0>;
+			adi,mode = <CH_MODE_DAC>;
+			adi,off-state = <CH_OFFSTATE_PULLDOWN>;
+		};
+		channel@1 {
+			reg = <1>;
+			adi,mode = <CH_MODE_ADC>;
+			adi,off-state = <CH_OFFSTATE_PULLDOWN>;
+		};
+		channel@2 {
+			reg = <2>;
+			adi,mode = <CH_MODE_DAC_AND_ADC>;
+			adi,off-state = <CH_OFFSTATE_PULLDOWN>;
+		};
+		channel@6 {
+			reg = <6>;
+			adi,mode = <CH_MODE_GPIO>;
+			adi,off-state = <CH_OFFSTATE_PULLDOWN>;
+		};
+	};
drivers/iio/dac/Kconfig +27 -0
index a995139..233dfb7 100644
@@ -74,6 +74,33 @@ config AD5449
 	  To compile this driver as a module, choose M here: the
 	  module will be called ad5449.
 
+config AD5592R_BASE
+	tristate
+
+config AD5592R
+	tristate "Analog Devices AD5592R ADC/DAC driver"
+	depends on SPI_MASTER
+	select GPIOLIB
+	select AD5592R_BASE
+	help
+	  Say yes here to build support for Analog Devices AD5592R
+	  Digital to Analog / Analog to Digital Converter.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ad5592r.
+
+config AD5593R
+	tristate "Analog Devices AD5593R ADC/DAC driver"
+	depends on I2C
+	select GPIOLIB
+	select AD5592R_BASE
+	help
+	  Say yes here to build support for Analog Devices AD5593R
+	  Digital to Analog / Analog to Digital Converter.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called ad5593r.
+
 config AD5504
 	tristate "Analog Devices AD5504/AD5501 DAC SPI driver"
 	depends on SPI
drivers/iio/dac/Makefile +3 -0
index 67b4842..de28cd2 100644
@@ -11,6 +11,9 @@ obj-$(CONFIG_AD5064) += ad5064.o
 obj-$(CONFIG_AD5504) += ad5504.o
 obj-$(CONFIG_AD5446) += ad5446.o
 obj-$(CONFIG_AD5449) += ad5449.o
+obj-$(CONFIG_AD5592R_BASE) += ad5592r-base.o
+obj-$(CONFIG_AD5592R) += ad5592r.o
+obj-$(CONFIG_AD5593R) += ad5593r.o
 obj-$(CONFIG_AD5755) += ad5755.o
 obj-$(CONFIG_AD5761) += ad5761.o
 obj-$(CONFIG_AD5764) += ad5764.o
drivers/iio/dac/ad5592r-base.c new file +691 -0

691 lines not on this page · raw message

drivers/iio/dac/ad5592r-base.h new file +76 -0

76 lines not on this page · raw message

drivers/iio/dac/ad5592r.c new file +164 -0

164 lines not on this page · raw message

drivers/iio/dac/ad5593r.c new file +131 -0

131 lines not on this page · raw message

include/dt-bindings/iio/adi,ad5592r.h new file +16 -0
new file mode 100644
index 0000000..c48aca1
@@ -0,0 +1,16 @@
+
+#ifndef _DT_BINDINGS_ADI_AD5592R_H
+#define _DT_BINDINGS_ADI_AD5592R_H
+
+#define CH_MODE_UNUSED			0
+#define CH_MODE_ADC			1
+#define CH_MODE_DAC			2
+#define CH_MODE_DAC_AND_ADC		3
+#define CH_MODE_GPIO			8
+
+#define CH_OFFSTATE_PULLDOWN		0
+#define CH_OFFSTATE_OUT_LOW		1
+#define CH_OFFSTATE_OUT_HIGH		2
+#define CH_OFFSTATE_OUT_TRISTATE	3
+
+#endif /* _DT_BINDINGS_ADI_AD5592R_H */
Signature · 1 line
1.9.1

A message that is not in the archive (sent off-list or not yet received): 1459842379-26275-1-git-send-email-michael.hennerich-OyLXuOCK7orQT0dZR+AlfA@public.gmane.org

Acked-by
#2 lore raw
Quoted 34 lines · On Tue, Apr 05, 2016 at 09:46:19AM +0200…

From: Paul Cercueil <[email protected]>

This patch adds support for the AD5592R (spi) and AD5593R (i2c) ADC/DAC/GPIO devices.

---

Changes since v1:
* Fix mutex usage
* Remove unnecessary NULL pointer guards
* Add comment explaining the invalid data read
* AD5593R Remove surplus adc readback

Changes since v2:
* Use child nodes to describe channels
* Fix probe return and driver remove path
* Move locking closer to where its used
* Remove WARN_ON but return error
* Remove OPEN DRAIN configuration option

Changes since v3:
* Documentation: Add missing vendor prefixes in the examples
* Minor function reordering in remove() to match the reverse of probe()

Changes since v4:
* Documentation: Add missing gpio bindings
* Kconfig: Select GPIOLIB and remove ifdefs in code
* Remove surplus error check in ad5592r_gpio_request()
* Add comment about reset magic

Quoted 6 lines

Changes since v5:
* Remove surplus error check
* Remove additional ifdef CONFIG_GPIOLIB guards in the header
* Bindings: Add additional comments about CH_MODE_DAC_AND_ADC mode

---
 .../devicetree/bindings/iio/dac/ad5592r.txt        | 155 +++++

I've acked this twice before, and the last change seems minor. Please add acks unless it is more than minor changes and you need it reviewed again.

Quoted 15 lines
 drivers/iio/dac/Kconfig                            |  27 +
 drivers/iio/dac/Makefile                           |   3 +
 drivers/iio/dac/ad5592r-base.c                     | 691 +++++++++++++++++++++
 drivers/iio/dac/ad5592r-base.h                     |  76 +++
 drivers/iio/dac/ad5592r.c                          | 164 +++++
 drivers/iio/dac/ad5593r.c                          | 131 ++++
 include/dt-bindings/iio/adi,ad5592r.h              |  16 +
 8 files changed, 1263 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/dac/ad5592r.txt
 create mode 100644 drivers/iio/dac/ad5592r-base.c
 create mode 100644 drivers/iio/dac/ad5592r-base.h
 create mode 100644 drivers/iio/dac/ad5592r.c
 create mode 100644 drivers/iio/dac/ad5593r.c
 create mode 100644 include/dt-bindings/iio/adi,ad5592r.h
#3 lore raw
Quoted 42 lines · Rob Herring
Quoted 34 lines · On Tue, Apr 05, 2016 at 09:46:19AM +0200…

From: Paul Cercueil <[email protected]>

This patch adds support for the AD5592R (spi) and AD5593R (i2c) ADC/DAC/GPIO devices.

---

Changes since v1:
* Fix mutex usage
* Remove unnecessary NULL pointer guards
* Add comment explaining the invalid data read
* AD5593R Remove surplus adc readback

Changes since v2:
* Use child nodes to describe channels
* Fix probe return and driver remove path
* Move locking closer to where its used
* Remove WARN_ON but return error
* Remove OPEN DRAIN configuration option

Changes since v3:
* Documentation: Add missing vendor prefixes in the examples
* Minor function reordering in remove() to match the reverse of probe()

Changes since v4:
* Documentation: Add missing gpio bindings
* Kconfig: Select GPIOLIB and remove ifdefs in code
* Remove surplus error check in ad5592r_gpio_request()
* Add comment about reset magic

Quoted 6 lines

Changes since v5:
* Remove surplus error check
* Remove additional ifdef CONFIG_GPIOLIB guards in the header
* Bindings: Add additional comments about CH_MODE_DAC_AND_ADC mode

---
 .../devicetree/bindings/iio/dac/ad5592r.txt        | 155 +++++
Quoted 5 lines

I've acked this twice before, and the last change seems minor. Please add acks unless it is more than minor changes and you need it reviewed again.

Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders to play with it.

Thanks,

Jonathan

Quoted 21 lines
Quoted 16 lines
 drivers/iio/dac/Kconfig                            |  27 +
 drivers/iio/dac/Makefile                           |   3 +
 drivers/iio/dac/ad5592r-base.c                     | 691 +++++++++++++++++++++
 drivers/iio/dac/ad5592r-base.h                     |  76 +++
 drivers/iio/dac/ad5592r.c                          | 164 +++++
 drivers/iio/dac/ad5593r.c                          | 131 ++++
 include/dt-bindings/iio/adi,ad5592r.h              |  16 +
 8 files changed, 1263 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/dac/ad5592r.txt
 create mode 100644 drivers/iio/dac/ad5592r-base.c
 create mode 100644 drivers/iio/dac/ad5592r-base.h
 create mode 100644 drivers/iio/dac/ad5592r.c
 create mode 100644 drivers/iio/dac/ad5593r.c
 create mode 100644 include/dt-bindings/iio/adi,ad5592r.h

--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html