Skip to contentSkip to conversation

iio: dac: ad5758: Modifications for new revision

PATCH In review Mircea Caprioru 2 participants 4 messages Apr 9, 2019 – Apr 22, 2019 1 message not in the archive

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

PATCH 1/1 iio: dac: ad5758: Modifications for new revision

This patch will ensure compatibility with the new revision of the AD5758 dac converter. The modifications consist of removing the fault_prot_switch function since this option is no longer available, and enabling the ENABLE_PPC_BUFFERS bit in ADC_CONFIG register before setting the PPC current mode.

---
 drivers/iio/dac/ad5758.c | 55 +++++++++++++---------------------------
 1 file changed, 18 insertions(+), 37 deletions(-)
drivers/iio/dac/ad5758.c +18 -37
index 2bdf1b0aee06..a513c70faefa 100644
@@ -72,8 +72,6 @@
 #define AD5758_DCDC_CONFIG1_DCDC_VPROG_MODE(x)	(((x) & 0x1F) << 0)
 #define AD5758_DCDC_CONFIG1_DCDC_MODE_MSK	GENMASK(6, 5)
 #define AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(x)	(((x) & 0x3) << 5)
-#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK	BIT(7)
-#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(x)	(((x) & 0x1) << 7)
 
 /* AD5758_DCDC_CONFIG2 */
 #define AD5758_DCDC_CONFIG2_ILIMIT_MSK		GENMASK(3, 1)
@@ -84,6 +82,10 @@
 /* AD5758_DIGITAL_DIAG_RESULTS */
 #define AD5758_CAL_MEM_UNREFRESHED_MSK		BIT(15)
 
+/* AD5758_ADC_CONFIG */
+#define AD5758_ADC_CONFIG_PPC_BUF_EN(x)		(((x) & 0x1) << 11)
+#define AD5758_ADC_CONFIG_PPC_BUF_MSK		BIT(11)
+
 #define AD5758_WR_FLAG_MSK(x)		(0x80 | ((x) & 0x1F))
 
 #define AD5758_FULL_SCALE_MICRO	65535000000ULL
@@ -315,6 +317,18 @@ static int ad5758_set_dc_dc_conv_mode(struct ad5758_state *st,
 {
 	int ret;
 
+	/*
+	 * The ENABLE_PPC_BUFFERS bit must be set prior to enabling PPC current
+	 * mode.
+	 */
+	if (mode == AD5758_DCDC_MODE_PPC_CURRENT) {
+		ret  = ad5758_spi_write_mask(st, AD5758_ADC_CONFIG,
+				    AD5758_ADC_CONFIG_PPC_BUF_MSK,
+				    AD5758_ADC_CONFIG_PPC_BUF_EN(1));
+		if (ret < 0)
+			return ret;
+	}
+
 	ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
 				    AD5758_DCDC_CONFIG1_DCDC_MODE_MSK,
 				    AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(mode));
@@ -444,23 +458,6 @@ static int ad5758_set_out_range(struct ad5758_state *st, int range)
 					     AD5758_CAL_MEM_UNREFRESHED_MSK);
 }
 
-static int ad5758_fault_prot_switch_en(struct ad5758_state *st, bool enable)
-{
-	int ret;
-
-	ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
-			AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK,
-			AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(enable));
-	if (ret < 0)
-		return ret;
-	/*
-	 * Poll the BUSY_3WI bit in the DCDC_CONFIG2 register until it is 0.
-	 * This allows the 3-wire interface communication to complete.
-	 */
-	return ad5758_wait_for_task_complete(st, AD5758_DCDC_CONFIG2,
-					     AD5758_DCDC_CONFIG2_BUSY_3WI_MSK);
-}
-
 static int ad5758_internal_buffers_en(struct ad5758_state *st, bool enable)
 {
 	int ret;
@@ -585,8 +582,8 @@ static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev,
 {
 	struct ad5758_state *st = iio_priv(indio_dev);
 	bool pwr_down;
-	unsigned int dcdc_config1_mode, dc_dc_mode, dac_config_mode, val;
-	unsigned long int dcdc_config1_msk, dac_config_msk;
+	unsigned int dc_dc_mode, dac_config_mode, val;
+	unsigned long int dac_config_msk;
 	int ret;
 
 	ret = kstrtobool(buf, &pwr_down);
@@ -602,17 +599,6 @@ static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev,
 		val = 1;
 	}
 
-	dcdc_config1_mode = AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(dc_dc_mode) |
-			    AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(val);
-	dcdc_config1_msk = AD5758_DCDC_CONFIG1_DCDC_MODE_MSK |
-			   AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK;
-
-	ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
-				    dcdc_config1_msk,
-				    dcdc_config1_mode);
-	if (ret < 0)
-		goto err_unlock;
-
 	dac_config_mode = AD5758_DAC_CONFIG_OUT_EN_MODE(val) |
 			  AD5758_DAC_CONFIG_INT_EN_MODE(val);
 	dac_config_msk = AD5758_DAC_CONFIG_OUT_EN_MSK |
@@ -841,11 +827,6 @@ static int ad5758_init(struct ad5758_state *st)
 			return ret;
 	}
 
-	/* Enable the VIOUT fault protection switch (FPS is closed) */
-	ret = ad5758_fault_prot_switch_en(st, 1);
-	if (ret < 0)
-		return ret;
-
 	/* Power up the DAC and internal (INT) amplifiers */
 	ret = ad5758_internal_buffers_en(st, 1);
 	if (ret < 0)
Signature · 1 line
2.17.1
maintainer
#1 lore raw
Quoted 7 lines · On Tue, 9 Apr 2019 16:35:21 +0300 Mircea Caprioru <[email protected]>…

This patch will ensure compatibility with the new revision of the AD5758 dac converter. The modifications consist of removing the fault_prot_switch function since this option is no longer available, and enabling the ENABLE_PPC_BUFFERS bit in ADC_CONFIG register before setting the PPC current mode.

Hi Mircea,

Talk me through the implications of this change.

1. Any changes to functionality that might break users of the older revisions?
2. Any userspace visible changes?
3. Do we want to think about back porting to older kernels?
4. Should we support this explicitly by detecting or describing the hardware revision in some fashion?

Thanks,

Jonathan

Quoted 112 lines
---
 drivers/iio/dac/ad5758.c | 55 +++++++++++++---------------------------
 1 file changed, 18 insertions(+), 37 deletions(-)
drivers/iio/dac/ad5758.c +18 -37
index 2bdf1b0aee06..a513c70faefa 100644
@@ -72,8 +72,6 @@
 #define AD5758_DCDC_CONFIG1_DCDC_VPROG_MODE(x)	(((x) & 0x1F) << 0)
 #define AD5758_DCDC_CONFIG1_DCDC_MODE_MSK	GENMASK(6, 5)
 #define AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(x)	(((x) & 0x3) << 5)
-#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK	BIT(7)
-#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(x)	(((x) & 0x1) << 7)
 
 /* AD5758_DCDC_CONFIG2 */
 #define AD5758_DCDC_CONFIG2_ILIMIT_MSK		GENMASK(3, 1)
@@ -84,6 +82,10 @@
 /* AD5758_DIGITAL_DIAG_RESULTS */
 #define AD5758_CAL_MEM_UNREFRESHED_MSK		BIT(15)
 
+/* AD5758_ADC_CONFIG */
+#define AD5758_ADC_CONFIG_PPC_BUF_EN(x)		(((x) & 0x1) << 11)
+#define AD5758_ADC_CONFIG_PPC_BUF_MSK		BIT(11)
+
 #define AD5758_WR_FLAG_MSK(x)		(0x80 | ((x) & 0x1F))
 
 #define AD5758_FULL_SCALE_MICRO	65535000000ULL
@@ -315,6 +317,18 @@ static int ad5758_set_dc_dc_conv_mode(struct ad5758_state *st,
 {
 	int ret;
 
+	/*
+	 * The ENABLE_PPC_BUFFERS bit must be set prior to enabling PPC current
+	 * mode.
+	 */
+	if (mode == AD5758_DCDC_MODE_PPC_CURRENT) {
+		ret  = ad5758_spi_write_mask(st, AD5758_ADC_CONFIG,
+				    AD5758_ADC_CONFIG_PPC_BUF_MSK,
+				    AD5758_ADC_CONFIG_PPC_BUF_EN(1));
+		if (ret < 0)
+			return ret;
+	}
+
 	ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
 				    AD5758_DCDC_CONFIG1_DCDC_MODE_MSK,
 				    AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(mode));
@@ -444,23 +458,6 @@ static int ad5758_set_out_range(struct ad5758_state *st, int range)
 					     AD5758_CAL_MEM_UNREFRESHED_MSK);
 }
 
-static int ad5758_fault_prot_switch_en(struct ad5758_state *st, bool enable)
-{
-	int ret;
-
-	ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
-			AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK,
-			AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(enable));
-	if (ret < 0)
-		return ret;
-	/*
-	 * Poll the BUSY_3WI bit in the DCDC_CONFIG2 register until it is 0.
-	 * This allows the 3-wire interface communication to complete.
-	 */
-	return ad5758_wait_for_task_complete(st, AD5758_DCDC_CONFIG2,
-					     AD5758_DCDC_CONFIG2_BUSY_3WI_MSK);
-}
-
 static int ad5758_internal_buffers_en(struct ad5758_state *st, bool enable)
 {
 	int ret;
@@ -585,8 +582,8 @@ static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev,
 {
 	struct ad5758_state *st = iio_priv(indio_dev);
 	bool pwr_down;
-	unsigned int dcdc_config1_mode, dc_dc_mode, dac_config_mode, val;
-	unsigned long int dcdc_config1_msk, dac_config_msk;
+	unsigned int dc_dc_mode, dac_config_mode, val;
+	unsigned long int dac_config_msk;
 	int ret;
 
 	ret = kstrtobool(buf, &pwr_down);
@@ -602,17 +599,6 @@ static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev,
 		val = 1;
 	}
 
-	dcdc_config1_mode = AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(dc_dc_mode) |
-			    AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(val);
-	dcdc_config1_msk = AD5758_DCDC_CONFIG1_DCDC_MODE_MSK |
-			   AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK;
-
-	ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
-				    dcdc_config1_msk,
-				    dcdc_config1_mode);
-	if (ret < 0)
-		goto err_unlock;
-
 	dac_config_mode = AD5758_DAC_CONFIG_OUT_EN_MODE(val) |
 			  AD5758_DAC_CONFIG_INT_EN_MODE(val);
 	dac_config_msk = AD5758_DAC_CONFIG_OUT_EN_MSK |
@@ -841,11 +827,6 @@ static int ad5758_init(struct ad5758_state *st)
 			return ret;
 	}
 
-	/* Enable the VIOUT fault protection switch (FPS is closed) */
-	ret = ad5758_fault_prot_switch_en(st, 1);
-	if (ret < 0)
-		return ret;
-
 	/* Power up the DAC and internal (INT) amplifiers */
 	ret = ad5758_internal_buffers_en(st, 1);
 	if (ret < 0)
#2 lore raw

Hi Jonathan,

1. Any changes to functionality that might break users of the older revisions?
From what i have found out there are no users of the older revision since it has not been available for purchasing. Only this new revision.
2. Any userspace visible changes?
There are no userspace visible changes.
3. Do we want to think about back porting to older kernels?
This could be a benefit, but i don't think the impact will be significant.
4. Should we support this explicitly by detecting or describing the
hardware revision in some fashion?
Yes I could use the CHIP_ID register to check the revision and do a V2. Just wondering if it is needed if there are no older revision chips in use.

Thanks,
Mircea

-----Original Message-----
From: Jonathan Cameron [mailto:[email protected]]
Sent: Sunday, April 14, 2019 4:02 PM
To: Caprioru, Mircea <[email protected]>
Cc: Hennerich, Michael <[email protected]>; Popa, Stefan Serban <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [PATCH] iio: dac: ad5758: Modifications for new revision

[External]

Quoted 7 lines · On Tue, 9 Apr 2019 16:35:21 +0300 Mircea Caprioru <[email protected]>…

This patch will ensure compatibility with the new revision of the AD5758 dac converter. The modifications consist of removing the fault_prot_switch function since this option is no longer available, and enabling the ENABLE_PPC_BUFFERS bit in ADC_CONFIG register before setting the PPC current mode.

Hi Mircea,

Talk me through the implications of this change.

1. Any changes to functionality that might break users of the older revisions?
2. Any userspace visible changes?
3. Do we want to think about back porting to older kernels?
4. Should we support this explicitly by detecting or describing the hardware revision in some fashion?

Thanks,

Jonathan

Quoted 114 lines
---
 drivers/iio/dac/ad5758.c | 55 
+++++++++++++---------------------------
 1 file changed, 18 insertions(+), 37 deletions(-)
drivers/iio/dac/ad5758.c index renamed from drivers/iio/dac/ad5758.c +0 -0

2bdf1b0aee06..a513c70faefa 100644

drivers/iio/dac/ad5758.c +16 -2
@@ -72,8 +72,6 @@
 #define AD5758_DCDC_CONFIG1_DCDC_VPROG_MODE(x)       (((x) & 0x1F) << 0)
 #define AD5758_DCDC_CONFIG1_DCDC_MODE_MSK    GENMASK(6, 5)
 #define AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(x)        (((x) & 0x3) << 5)
-#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK   BIT(7)
-#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(x)       (((x) & 0x1) << 7)
 
 /* AD5758_DCDC_CONFIG2 */
 #define AD5758_DCDC_CONFIG2_ILIMIT_MSK               GENMASK(3, 1)
@@ -84,6 +82,10 @@
 /* AD5758_DIGITAL_DIAG_RESULTS */
 #define AD5758_CAL_MEM_UNREFRESHED_MSK               BIT(15)
 
+/* AD5758_ADC_CONFIG */
+#define AD5758_ADC_CONFIG_PPC_BUF_EN(x)              (((x) & 0x1) << 11)
+#define AD5758_ADC_CONFIG_PPC_BUF_MSK                BIT(11)
+
 #define AD5758_WR_FLAG_MSK(x)                (0x80 | ((x) & 0x1F))
 
 #define AD5758_FULL_SCALE_MICRO      65535000000ULL
@@ -315,6 +317,18 @@ static int ad5758_set_dc_dc_conv_mode(struct 
 ad5758_state *st,  {
      int ret;
 
+     /*
+      * The ENABLE_PPC_BUFFERS bit must be set prior to enabling PPC current
+      * mode.
+      */
+     if (mode == AD5758_DCDC_MODE_PPC_CURRENT) {
+             ret  = ad5758_spi_write_mask(st, AD5758_ADC_CONFIG,
+                                 AD5758_ADC_CONFIG_PPC_BUF_MSK,
+                                 AD5758_ADC_CONFIG_PPC_BUF_EN(1));
+             if (ret < 0)
+                     return ret;
+     }
+
      ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
                                  AD5758_DCDC_CONFIG1_DCDC_MODE_MSK,
 

AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(mode));

drivers/iio/dac/ad5758.c +2 -18
@@ -444,23 +458,6 @@ static int ad5758_set_out_range(struct ad5758_state *st, int range)
 
 AD5758_CAL_MEM_UNREFRESHED_MSK);  }
 
-static int ad5758_fault_prot_switch_en(struct ad5758_state *st, bool 
 enable) -{
-     int ret;
-
-     ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
-                     AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK,
-                     AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(enable));
-     if (ret < 0)
-             return ret;
-     /*
-      * Poll the BUSY_3WI bit in the DCDC_CONFIG2 register until it is 0.
-      * This allows the 3-wire interface communication to complete.
-      */
-     return ad5758_wait_for_task_complete(st, AD5758_DCDC_CONFIG2,
-                                          AD5758_DCDC_CONFIG2_BUSY_3WI_MSK);
-}
-
 static int ad5758_internal_buffers_en(struct ad5758_state *st, bool 
 enable)  {
      int ret;
@@ -585,8 +582,8 @@ static ssize_t ad5758_write_powerdown(struct 
 iio_dev *indio_dev,  {
      struct ad5758_state *st = iio_priv(indio_dev);
      bool pwr_down;
-     unsigned int dcdc_config1_mode, dc_dc_mode, dac_config_mode, val;
-     unsigned long int dcdc_config1_msk, dac_config_msk;
+     unsigned int dc_dc_mode, dac_config_mode, val;
+     unsigned long int dac_config_msk;
      int ret;
 
      ret = kstrtobool(buf, &pwr_down); @@ -602,17 +599,6 @@ static 

ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev,

              val = 1;
      }
drivers/iio/dac/ad5758.c +1 -16
-     dcdc_config1_mode = AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(dc_dc_mode) |
-                         AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(val);
-     dcdc_config1_msk = AD5758_DCDC_CONFIG1_DCDC_MODE_MSK |
-                        AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK;
-
-     ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
-                                 dcdc_config1_msk,
-                                 dcdc_config1_mode);
-     if (ret < 0)
-             goto err_unlock;
-
      dac_config_mode = AD5758_DAC_CONFIG_OUT_EN_MODE(val) |
                        AD5758_DAC_CONFIG_INT_EN_MODE(val);
      dac_config_msk = AD5758_DAC_CONFIG_OUT_EN_MSK | @@ -841,11 
+827,6 @@ static int ad5758_init(struct ad5758_state *st)
                      return ret;
      }
 
-     /* Enable the VIOUT fault protection switch (FPS is closed) */
-     ret = ad5758_fault_prot_switch_en(st, 1);
-     if (ret < 0)
-             return ret;
-
      /* Power up the DAC and internal (INT) amplifiers */
      ret = ad5758_internal_buffers_en(st, 1);
      if (ret < 0)

A message that is not in the archive (sent off-list or not yet received): CAC+2QaGbUtoSRnkcD-LrHC27t-m1NBY_v86w2iAwdpkHisPrJQ@mail.gmail.com

maintainer
#4 lore raw
Quoted 14 lines · On Mon, 15 Apr 2019 13:36:55 +0300 Mircea Caprioru <[email protected]>…

Hi Jonathan,

1. Any changes to functionality that might break users of the older

Quoted 2 lines

revisions?

From what i have found out there are no users of the older revision since it has not been available for purchasing. Only this new revision.

Quoted 2 lines

2. Any userspace visible changes?

There are no userspace visible changes.

Quoted 2 lines

3. Do we want to think about back porting to older kernels?

Quoted 7 lines

This could be a benefit, but i don't think the impact will be significant.

Quoted 3 lines

4. Should we support this explicitly by detecting or describing the hardware revision in some fashion?

Yes I could use the CHIP_ID register to check the revision and do a V2. Just wondering if it is needed if there are no older revision chips in use.

Thanks for the info. I've applied the patch as it stands with a line added to the description noting that no customers have the previous version so there is no need to support it going forwards.

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

Thanks,

Jonathan

Quoted 164 lines

Thanks,
Mircea

Quoted 10 lines · Jonathan Cameron
Quoted 2 lines · On Tue, 9 Apr 2019 16:35:21 +0300 Mircea Caprioru <[email protected]>…

This patch will ensure compatibility with the new revision of the AD5758 dac converter. The modifications consist of removing the

fault_prot_switch

Quoted 4 lines

function since this option is no longer available, and enabling the ENABLE_PPC_BUFFERS bit in ADC_CONFIG register before setting the PPC current mode.

Quoted 8 lines
Quoted 1 line

Hi Mircea,

Talk me through the implications of this change.

1. Any changes to functionality that might break users of the older revisions?

2. Any userspace visible changes?

Quoted 1 line

3. Do we want to think about back porting to older kernels?

Quoted 1 line

4. Should we support this explicitly by detecting or describing the

Quoted 135 lines

hardware revision in some fashion?

Thanks,

Jonathan

drivers/iio/dac/ad5758.c static int ad5758_set_dc_dc_conv_mode(struct

Quoted 29 lines
---
 drivers/iio/dac/ad5758.c | 55 +++++++++++++---------------------------
 1 file changed, 18 insertions(+), 37 deletions(-)
drivers/iio/dac/ad5758.c +4 -2
index 2bdf1b0aee06..a513c70faefa 100644
@@ -72,8 +72,6 @@
 #define AD5758_DCDC_CONFIG1_DCDC_VPROG_MODE(x)       (((x) & 0x1F) << 0)
 #define AD5758_DCDC_CONFIG1_DCDC_MODE_MSK    GENMASK(6, 5)
 #define AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(x)        (((x) & 0x3) << 5)
-#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK   BIT(7)
-#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(x)       (((x) & 0x1) << 7)
 
 /* AD5758_DCDC_CONFIG2 */
 #define AD5758_DCDC_CONFIG2_ILIMIT_MSK               GENMASK(3, 1)
@@ -84,6 +82,10 @@
 /* AD5758_DIGITAL_DIAG_RESULTS */
 #define AD5758_CAL_MEM_UNREFRESHED_MSK               BIT(15)
 
+/* AD5758_ADC_CONFIG */
+#define AD5758_ADC_CONFIG_PPC_BUF_EN(x)              (((x) & 0x1) << 11)
+#define AD5758_ADC_CONFIG_PPC_BUF_MSK                BIT(11)
+
 #define AD5758_WR_FLAG_MSK(x)                (0x80 | ((x) & 0x1F))
 
 #define AD5758_FULL_SCALE_MICRO      65535000000ULL
@@ -315,6 +317,18 @@ static int ad5758_set_dc_dc_conv_mode(struct  

ad5758_state *st,

drivers/iio/dac/ad5758.c static int ad5758_set_dc_dc_conv_mode(struct ad5758_state *st,

Quoted 5 lines
drivers/iio/dac/ad5758.c +2 -0
 {
      int ret;
 
+     /*
+      * The ENABLE_PPC_BUFFERS bit must be set prior to enabling PPC  

current

drivers/iio/dac/ad5758.c static int ad5758_set_dc_dc_conv_mode(struct ad5758_state *st,

Quoted 13 lines
drivers/iio/dac/ad5758.c +10 -0
+      * mode.
+      */
+     if (mode == AD5758_DCDC_MODE_PPC_CURRENT) {
+             ret  = ad5758_spi_write_mask(st, AD5758_ADC_CONFIG,
+                                 AD5758_ADC_CONFIG_PPC_BUF_MSK,
+                                 AD5758_ADC_CONFIG_PPC_BUF_EN(1));
+             if (ret < 0)
+                     return ret;
+     }
+
      ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
                                  AD5758_DCDC_CONFIG1_DCDC_MODE_MSK,
 

AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(mode));

drivers/iio/dac/ad5758.c static int ad5758_set_out_range(struct ad5758_state

Quoted 1 line
drivers/iio/dac/ad5758.c +0 -0
@@ -444,23 +458,6 @@ static int ad5758_set_out_range(struct ad5758_state  

*st, int range)

Quoted 1 line

AD5758_CAL_MEM_UNREFRESHED_MSK);

Quoted 3 lines

}

-static int ad5758_fault_prot_switch_en(struct ad5758_state *st, bool

enable)

drivers/iio/dac/ad5758.c static int ad5758_set_out_range(struct ad5758_state *st, int range)

Quoted 10 lines
drivers/iio/dac/ad5758.c +0 -10
-{
-     int ret;
-
-     ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
-                     AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK,
-                     AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(enable));
-     if (ret < 0)
-             return ret;
-     /*
-      * Poll the BUSY_3WI bit in the DCDC_CONFIG2 register until it is  

0.

drivers/iio/dac/ad5758.c static int ad5758_set_out_range(struct ad5758_state *st, int range) · line 463

Quoted 4 lines
drivers/iio/dac/ad5758.c +0 -4
-      * This allows the 3-wire interface communication to complete.
-      */
-     return ad5758_wait_for_task_complete(st, AD5758_DCDC_CONFIG2,
-  

AD5758_DCDC_CONFIG2_BUSY_3WI_MSK);

drivers/iio/dac/ad5758.c static int ad5758_set_out_range(struct ad5758_state *st, int range)

Quoted 3 lines
drivers/iio/dac/ad5758.c +0 -2
-}
-
 static int ad5758_internal_buffers_en(struct ad5758_state *st, bool  

enable)

drivers/iio/dac/ad5758.c static ssize_t ad5758_write_powerdown(struct iio_dev

Quoted 3 lines
 {
      int ret;
drivers/iio/dac/ad5758.c +0 -0
@@ -585,8 +582,8 @@ static ssize_t ad5758_write_powerdown(struct iio_dev  

*indio_dev,

drivers/iio/dac/ad5758.c static ssize_t ad5758_write_powerdown(struct

Quoted 11 lines
drivers/iio/dac/ad5758.c +2 -2
 {
      struct ad5758_state *st = iio_priv(indio_dev);
      bool pwr_down;
-     unsigned int dcdc_config1_mode, dc_dc_mode, dac_config_mode, val;
-     unsigned long int dcdc_config1_msk, dac_config_msk;
+     unsigned int dc_dc_mode, dac_config_mode, val;
+     unsigned long int dac_config_msk;
      int ret;
 
      ret = kstrtobool(buf, &pwr_down);
@@ -602,17 +599,6 @@ static ssize_t ad5758_write_powerdown(struct  

iio_dev *indio_dev,

drivers/iio/dac/ad5758.c static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev,

Quoted 4 lines
drivers/iio/dac/ad5758.c +0 -1
              val = 1;
      }
 
-     dcdc_config1_mode = AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(dc_dc_mode)  

|

Quoted 25 lines
drivers/iio/dac/ad5758.c +0 -15
-                         AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(val);
-     dcdc_config1_msk = AD5758_DCDC_CONFIG1_DCDC_MODE_MSK |
-                        AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK;
-
-     ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
-                                 dcdc_config1_msk,
-                                 dcdc_config1_mode);
-     if (ret < 0)
-             goto err_unlock;
-
      dac_config_mode = AD5758_DAC_CONFIG_OUT_EN_MODE(val) |
                        AD5758_DAC_CONFIG_INT_EN_MODE(val);
      dac_config_msk = AD5758_DAC_CONFIG_OUT_EN_MSK |
@@ -841,11 +827,6 @@ static int ad5758_init(struct ad5758_state *st)
                      return ret;
      }
 
-     /* Enable the VIOUT fault protection switch (FPS is closed) */
-     ret = ad5758_fault_prot_switch_en(st, 1);
-     if (ret < 0)
-             return ret;
-
      /* Power up the DAC and internal (INT) amplifiers */
      ret = ad5758_internal_buffers_en(st, 1);
      if (ret < 0)