Skip to contentSkip to conversation

staging: iio: dac: Add support for AD5541A, AD5512A digital to analog convertors

PATCH In review [email protected] 2 participants 4 messages Nov 19, 2010

Subsystems (4)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 staging: iio: dac: Add support for AD5541A, AD5512A digital to analog convertors

From: Michael Hennerich <[email protected]>

---
 drivers/staging/iio/dac/Kconfig  |    6 +++---
 drivers/staging/iio/dac/ad5446.c |   27 +++++++++++++++++++++++++--
 drivers/staging/iio/dac/ad5446.h |    2 ++
 3 files changed, 30 insertions(+), 5 deletions(-)
drivers/staging/iio/dac/Kconfig +3 -3
index 88914e9..9c497cc 100644
@@ -11,11 +11,11 @@ config AD5624R_SPI
 	  AD5664R convertors (DAC). This driver uses the common SPI interface.
 
 config AD5446
-	tristate "Analog Devices AD5444, AD5446 DAC SPI driver"
+	tristate "Analog Devices AD5444, AD5446 and AD5541A, AD5512A DAC SPI driver"
 	depends on SPI
 	help
-	  Say yes here to build support for Analog Devices AD5444 and AD5446
-	  multiplying DACs.
+	  Say yes here to build support for Analog Devices AD5444, AD5446
+	  and AD5541A, AD5512A DACs.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called ad5446.
drivers/staging/iio/dac/ad5446.c +25 -2
index c70243a..154a7c2 100644
@@ -43,8 +43,17 @@ static ssize_t ad5446_write(struct device *dev,
 	}
 
 	mutex_lock(&dev_info->mlock);
-	st->data = cpu_to_be16(AD5446_LOAD |
-			       (val << st->chip_info->res_shift));
+	switch (spi_get_device_id(st->spi)->driver_data) {
+	case ID_AD5444:
+	case ID_AD5446:
+			st->data = cpu_to_be16(AD5446_LOAD |
+					(val << st->chip_info->res_shift));
+			break;
+	case ID_AD5542A:
+	case ID_AD5512A:
+			st->data = cpu_to_be16(val << st->chip_info->res_shift);
+			break;
+	}
 
 	ret = spi_sync(st->spi, &st->msg);
 	mutex_unlock(&dev_info->mlock);
@@ -103,6 +112,18 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = {
 		.res_shift = 0,
 		.sign = 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
 	},
+	[ID_AD5542A] = {
+		.bits = 16,
+		.storagebits = 16,
+		.res_shift = 0,
+		.sign = 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
+	},
+	[ID_AD5512A] = {
+		.bits = 12,
+		.storagebits = 16,
+		.res_shift = 4,
+		.sign = 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
+	},
 };
 
 static int __devinit ad5446_probe(struct spi_device *spi)
@@ -196,6 +217,8 @@ static int ad5446_remove(struct spi_device *spi)
 static const struct spi_device_id ad5446_id[] = {
 	{"ad5444", ID_AD5444},
 	{"ad5446", ID_AD5446},
+	{"ad5542a", ID_AD5542A},
+	{"ad5512a", ID_AD5512A},
 	{}
 };
 
drivers/staging/iio/dac/ad5446.h +2 -0
index 3456382..0a655f1 100644
@@ -39,6 +39,8 @@ struct ad5446_state {
 enum ad5446_supported_device_ids {
 	ID_AD5444,
 	ID_AD5446,
+	ID_AD5542A,
+	ID_AD5512A,
 };
 
 #endif /* IIO_ADC_AD5446_H_ */
Signature · 1 line
1.6.0.2
Acked-by on v1 1/1
#1 lore raw
Quoted 2 lines · On 11/19/10 13:56, [email protected] wrote:

From: Michael Hennerich <[email protected]>

Looks fine to me.

Quoted 1 line
Quoted 90 lines
---
 drivers/staging/iio/dac/Kconfig  |    6 +++---
 drivers/staging/iio/dac/ad5446.c |   27 +++++++++++++++++++++++++--
 drivers/staging/iio/dac/ad5446.h |    2 ++
 3 files changed, 30 insertions(+), 5 deletions(-)
drivers/staging/iio/dac/Kconfig +3 -3
index 88914e9..9c497cc 100644
@@ -11,11 +11,11 @@ config AD5624R_SPI
 	  AD5664R convertors (DAC). This driver uses the common SPI interface.
 
 config AD5446
-	tristate "Analog Devices AD5444, AD5446 DAC SPI driver"
+	tristate "Analog Devices AD5444, AD5446 and AD5541A, AD5512A DAC SPI driver"
 	depends on SPI
 	help
-	  Say yes here to build support for Analog Devices AD5444 and AD5446
-	  multiplying DACs.
+	  Say yes here to build support for Analog Devices AD5444, AD5446
+	  and AD5541A, AD5512A DACs.
 
 	  To compile this driver as a module, choose M here: the
 	  module will be called ad5446.
drivers/staging/iio/dac/ad5446.c +25 -2
index c70243a..154a7c2 100644
@@ -43,8 +43,17 @@ static ssize_t ad5446_write(struct device *dev,
 	}
 
 	mutex_lock(&dev_info->mlock);
-	st->data = cpu_to_be16(AD5446_LOAD |
-			       (val << st->chip_info->res_shift));
+	switch (spi_get_device_id(st->spi)->driver_data) {
+	case ID_AD5444:
+	case ID_AD5446:
+			st->data = cpu_to_be16(AD5446_LOAD |
+					(val << st->chip_info->res_shift));
+			break;
+	case ID_AD5542A:
+	case ID_AD5512A:
+			st->data = cpu_to_be16(val << st->chip_info->res_shift);
+			break;
+	}
 
 	ret = spi_sync(st->spi, &st->msg);
 	mutex_unlock(&dev_info->mlock);
@@ -103,6 +112,18 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = {
 		.res_shift = 0,
 		.sign = 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
 	},
+	[ID_AD5542A] = {
+		.bits = 16,
+		.storagebits = 16,
+		.res_shift = 0,
+		.sign = 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
+	},
+	[ID_AD5512A] = {
+		.bits = 12,
+		.storagebits = 16,
+		.res_shift = 4,
+		.sign = 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
+	},
 };
 
 static int __devinit ad5446_probe(struct spi_device *spi)
@@ -196,6 +217,8 @@ static int ad5446_remove(struct spi_device *spi)
 static const struct spi_device_id ad5446_id[] = {
 	{"ad5444", ID_AD5444},
 	{"ad5446", ID_AD5446},
+	{"ad5542a", ID_AD5542A},
+	{"ad5512a", ID_AD5512A},
 	{}
 };
 
drivers/staging/iio/dac/ad5446.h +2 -0
index 3456382..0a655f1 100644
@@ -39,6 +39,8 @@ struct ad5446_state {
 enum ad5446_supported_device_ids {
 	ID_AD5444,
 	ID_AD5446,
+	ID_AD5542A,
+	ID_AD5512A,
 };
 
 #endif /* IIO_ADC_AD5446_H_ */
author maintainer
#2 lore raw

Jonathan Cameron wrote on 2010-11-19:

Quoted 4 lines · On 11/19/10 13:56, [email protected] wrote:
Quoted 3 lines

From: Michael Hennerich <[email protected]>

Looks fine to me.

This one is for a new driver, that you haven't reviewed yet.

Quoted 15 lines

drivers/staging/iio/dac/Kconfig config AD5624R_SPI · line 11

Quoted 13 lines

Signed-off-by: Michael Hennerich <[email protected]> Acked-by: Jonathan Cameron <[email protected]> ---

 drivers/staging/iio/dac/Kconfig  |    6 +++---
 drivers/staging/iio/dac/ad5446.c |   27 +++++++++++++++++++++++++--
 drivers/staging/iio/dac/ad5446.h |    2 ++
 3 files changed, 30 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/iio/dac/Kconfig index 88914e9..9c497cc 100644

drivers/staging/iio/dac/Kconfig +0 -0
@@ -11,11 +11,11 @@ config AD5624R_SPI
       AD5664R convertors (DAC). This driver uses the common SPI

interface.

Quoted 1 line
Quoted 7 lines

drivers/staging/iio/dac/Kconfig

Quoted 3 lines

config AD5446

drivers/staging/iio/dac/Kconfig +1 -1
-    tristate "Analog Devices AD5444, AD5446 DAC SPI driver"
+    tristate "Analog Devices AD5444, AD5446 and AD5541A, AD5512A DAC

SPI driver"

Quoted 3 lines

depends on SPI
help
- Say yes here to build support for Analog Devices AD5444 and AD544=

6

Quoted 72 lines

drivers/staging/iio/dac/ad5446.c static const struct ad5446_chip_info

Quoted 32 lines

- multiplying DACs. + Say yes here to build support for Analog
Devices AD5444, AD5446 + and AD5541A, AD5512A DACs.

To compile this driver as a module, choose M here: the module will be called ad5446.

drivers/staging/iio/dac/ad5446.c +11 -2
index c70243a..154a7c2 100644
@@ -43,8 +43,17 @@ static ssize_t ad5446_write(struct device *dev,
     }
 
     mutex_lock(&dev_info->mlock);
-    st->data =3D cpu_to_be16(AD5446_LOAD |
-                           (val << st->chip_info->res_shift));
+    switch (spi_get_device_id(st->spi)->driver_data) {
+    case ID_AD5444:
+    case ID_AD5446:
+                    st->data =3D cpu_to_be16(AD5446_LOAD |
+                                    (val << st->chip_info->res_shift));
+                    break;
+    case ID_AD5542A:
+    case ID_AD5512A:
+                    st->data =3D cpu_to_be16(val << st->chip_info-
 res_shift);
+                    break;
+    }
 
     ret =3D spi_sync(st->spi, &st->msg);
     mutex_unlock(&dev_info->mlock);
drivers/staging/iio/dac/ad5446.c +0 -0
@@ -103,6 +112,18 @@ static const struct ad5446_chip_info

ad5446_chip_info_tbl[] =3D {

Quoted 39 lines
drivers/staging/iio/dac/ad5446.c +13 -0
             .res_shift =3D 0,
             .sign =3D 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
     },
+    [ID_AD5542A] =3D {
+            .bits =3D 16,
+            .storagebits =3D 16,
+            .res_shift =3D 0,
+            .sign =3D 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
+    },
+    [ID_AD5512A] =3D {
+            .bits =3D 12,
+            .storagebits =3D 16,
+            .res_shift =3D 4,
+            .sign =3D 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
+    },
 };
 
 static int __devinit ad5446_probe(struct spi_device *spi) @@ -196,6
+217,8 @@ static int ad5446_remove(struct spi_device *spi)  static
const struct spi_device_id ad5446_id[] =3D {
     {"ad5444", ID_AD5444},
     {"ad5446", ID_AD5446},
drivers/staging/iio/dac/ad5446.c +2 -0
+    {"ad5542a", ID_AD5542A},
+    {"ad5512a", ID_AD5512A},
     {}
 };
drivers/staging/iio/dac/ad5446.h +2 -0
index 3456382..0a655f1 100644
@@ -39,6 +39,8 @@ struct ad5446_state {  enum
 ad5446_supported_device_ids {
     ID_AD5444,
     ID_AD5446,
+    ID_AD5542A,
+    ID_AD5512A,
 };
 
Quoted 1 line

drivers/staging/iio/dac/ad5446.h struct ad5446_state { · line 46

Quoted 1 line
drivers/staging/iio/dac/ad5446.h +0 -0
 #endif /* IIO_ADC_AD5446_H_ */

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 4036 Geschaeft= sfuehrer Thomas Wessel, William A. Martin, Margaret Seif

#3 lore raw
Quoted 7 lines · Michael

Jonathan Cameron wrote on 2010-11-19:

Quoted 4 lines · On 11/19/10 13:56, [email protected] wrote:
Quoted 3 lines

From: Michael Hennerich <[email protected]>

Looks fine to me.

This one is for a new driver, that you haven't reviewed yet.

lol. That kind of shows up that I never tested if it applies. Must be getting lazy ;)

Quoted 106 lines
Quoted 95 lines
Quoted 13 lines

Signed-off-by: Michael Hennerich <[email protected]> Acked-by: Jonathan Cameron <[email protected]> ---

 drivers/staging/iio/dac/Kconfig  |    6 +++---
 drivers/staging/iio/dac/ad5446.c |   27 +++++++++++++++++++++++++--
 drivers/staging/iio/dac/ad5446.h |    2 ++
 3 files changed, 30 insertions(+), 5 deletions(-)
(quoted diff) +0 -0

b/drivers/staging/iio/dac/Kconfig index 88914e9..9c497cc 100644

drivers/staging/iio/dac/Kconfig config AD5624R_SPI · line 11

Quoted 1 line
drivers/staging/iio/dac/Kconfig +0 -0
@@ -11,11 +11,11 @@ config AD5624R_SPI
       AD5664R convertors (DAC). This driver uses the common SPI

interface.

drivers/staging/iio/dac/Kconfig config AD5624R_SPI

Quoted 4 lines
drivers/staging/iio/dac/Kconfig +1 -1
 config AD5446
-    tristate "Analog Devices AD5444, AD5446 DAC SPI driver"
+    tristate "Analog Devices AD5444, AD5446 and AD5541A, AD5512A DAC

SPI driver"

drivers/staging/iio/dac/ad5446.c static const struct ad5446_chip_info

Quoted 35 lines
drivers/staging/iio/dac/Kconfig +0 -2
     depends on SPI
     help
-      Say yes here to build support for Analog Devices AD5444 and AD5446
-      multiplying DACs. +     Say yes here to build support for Analog

Devices AD5444, AD5446 + and AD5541A, AD5512A DACs.

To compile this driver as a module, choose M here: the module will be called ad5446.

drivers/staging/iio/dac/ad5446.c +11 -2
index c70243a..154a7c2 100644
@@ -43,8 +43,17 @@ static ssize_t ad5446_write(struct device *dev,
     }
 
     mutex_lock(&dev_info->mlock);
-    st->data = cpu_to_be16(AD5446_LOAD |
-                           (val << st->chip_info->res_shift));
+    switch (spi_get_device_id(st->spi)->driver_data) {
+    case ID_AD5444:
+    case ID_AD5446:
+                    st->data = cpu_to_be16(AD5446_LOAD |
+                                    (val << st->chip_info->res_shift));
+                    break;
+    case ID_AD5542A:
+    case ID_AD5512A:
+                    st->data = cpu_to_be16(val << st->chip_info-
 res_shift);
+                    break;
+    }
 
     ret = spi_sync(st->spi, &st->msg);
     mutex_unlock(&dev_info->mlock);
drivers/staging/iio/dac/ad5446.c +0 -0
@@ -103,6 +112,18 @@ static const struct ad5446_chip_info

ad5446_chip_info_tbl[] = {

Quoted 39 lines
drivers/staging/iio/dac/ad5446.c +13 -0
             .res_shift = 0,
             .sign = 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
     },
+    [ID_AD5542A] = {
+            .bits = 16,
+            .storagebits = 16,
+            .res_shift = 0,
+            .sign = 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
+    },
+    [ID_AD5512A] = {
+            .bits = 12,
+            .storagebits = 16,
+            .res_shift = 4,
+            .sign = 'u', /* IIO_SCAN_EL_TYPE_UNSIGNED */
+    },
 };
 
 static int __devinit ad5446_probe(struct spi_device *spi) @@ -196,6
+217,8 @@ static int ad5446_remove(struct spi_device *spi)  static
const struct spi_device_id ad5446_id[] = {
     {"ad5444", ID_AD5444},
     {"ad5446", ID_AD5446},
drivers/staging/iio/dac/ad5446.c +2 -0
+    {"ad5542a", ID_AD5542A},
+    {"ad5512a", ID_AD5512A},
     {}
 };
drivers/staging/iio/dac/ad5446.h +2 -0
index 3456382..0a655f1 100644
@@ -39,6 +39,8 @@ struct ad5446_state {  enum
 ad5446_supported_device_ids {
     ID_AD5444,
     ID_AD5446,
+    ID_AD5542A,
+    ID_AD5512A,
 };
 
Quoted 1 line

drivers/staging/iio/dac/ad5446.h struct ad5446_state { · line 46

Quoted 1 line
drivers/staging/iio/dac/ad5446.h +0 -0
 #endif /* IIO_ADC_AD5446_H_ */

Greetings,
Michael

--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft Muenchen, Registergericht Muenchen HRB 4036 Geschaeftsfuehrer Thomas Wessel, William A. Martin, Margaret Seif