Skip to content

Commit 43c5fa7

Browse files
author
Mircea Caprioru
committed
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. Signed-off-by: Mircea Caprioru <[email protected]>
1 parent b416efe commit 43c5fa7

File tree

1 file changed

+17
-37
lines changed

1 file changed

+17
-37
lines changed

drivers/iio/dac/ad5758.c

Lines changed: 17 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@
7272
#define AD5758_DCDC_CONFIG1_DCDC_VPROG_MODE(x) (((x) & 0x1F) << 0)
7373
#define AD5758_DCDC_CONFIG1_DCDC_MODE_MSK GENMASK(6, 5)
7474
#define AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(x) (((x) & 0x3) << 5)
75-
#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK BIT(7)
76-
#define AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(x) (((x) & 0x1) << 7)
7775

7876
/* AD5758_DCDC_CONFIG2 */
7977
#define AD5758_DCDC_CONFIG2_ILIMIT_MSK GENMASK(3, 1)
@@ -84,6 +82,10 @@
8482
/* AD5758_DIGITAL_DIAG_RESULTS */
8583
#define AD5758_CAL_MEM_UNREFRESHED_MSK BIT(15)
8684

85+
/* AD5758_ADC_CONFIG */
86+
#define AD5758_ADC_CONFIG_PPC_BUF_EN(x) (((x) & 0x1) << 11)
87+
#define AD5758_ADC_CONFIG_PPC_BUF_MSK BIT(11)
88+
8789
#define AD5758_WR_FLAG_MSK(x) (0x80 | ((x) & 0x1F))
8890

8991
#define AD5758_FULL_SCALE_MICRO 65535000000ULL
@@ -315,6 +317,17 @@ static int ad5758_set_dc_dc_conv_mode(struct ad5758_state *st,
315317
{
316318
int ret;
317319

320+
/*The ENABLE_PPC_BUFFERS bit must be set prior to enabling PPC current
321+
* mode.
322+
*/
323+
if (mode == AD5758_DCDC_MODE_PPC_CURRENT) {
324+
ret = ad5758_spi_write_mask(st, AD5758_ADC_CONFIG,
325+
AD5758_ADC_CONFIG_PPC_BUF_MSK,
326+
AD5758_ADC_CONFIG_PPC_BUF_EN(1));
327+
if (ret < 0)
328+
return ret;
329+
}
330+
318331
ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
319332
AD5758_DCDC_CONFIG1_DCDC_MODE_MSK,
320333
AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(mode));
@@ -444,23 +457,6 @@ static int ad5758_set_out_range(struct ad5758_state *st, int range)
444457
AD5758_CAL_MEM_UNREFRESHED_MSK);
445458
}
446459

447-
static int ad5758_fault_prot_switch_en(struct ad5758_state *st, bool enable)
448-
{
449-
int ret;
450-
451-
ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
452-
AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK,
453-
AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(enable));
454-
if (ret < 0)
455-
return ret;
456-
/*
457-
* Poll the BUSY_3WI bit in the DCDC_CONFIG2 register until it is 0.
458-
* This allows the 3-wire interface communication to complete.
459-
*/
460-
return ad5758_wait_for_task_complete(st, AD5758_DCDC_CONFIG2,
461-
AD5758_DCDC_CONFIG2_BUSY_3WI_MSK);
462-
}
463-
464460
static int ad5758_internal_buffers_en(struct ad5758_state *st, bool enable)
465461
{
466462
int ret;
@@ -585,8 +581,8 @@ static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev,
585581
{
586582
struct ad5758_state *st = iio_priv(indio_dev);
587583
bool pwr_down;
588-
unsigned int dcdc_config1_mode, dc_dc_mode, dac_config_mode, val;
589-
unsigned long int dcdc_config1_msk, dac_config_msk;
584+
unsigned int dc_dc_mode, dac_config_mode, val;
585+
unsigned long int dac_config_msk;
590586
int ret;
591587

592588
ret = kstrtobool(buf, &pwr_down);
@@ -602,17 +598,6 @@ static ssize_t ad5758_write_powerdown(struct iio_dev *indio_dev,
602598
val = 1;
603599
}
604600

605-
dcdc_config1_mode = AD5758_DCDC_CONFIG1_DCDC_MODE_MODE(dc_dc_mode) |
606-
AD5758_DCDC_CONFIG1_PROT_SW_EN_MODE(val);
607-
dcdc_config1_msk = AD5758_DCDC_CONFIG1_DCDC_MODE_MSK |
608-
AD5758_DCDC_CONFIG1_PROT_SW_EN_MSK;
609-
610-
ret = ad5758_spi_write_mask(st, AD5758_DCDC_CONFIG1,
611-
dcdc_config1_msk,
612-
dcdc_config1_mode);
613-
if (ret < 0)
614-
goto err_unlock;
615-
616601
dac_config_mode = AD5758_DAC_CONFIG_OUT_EN_MODE(val) |
617602
AD5758_DAC_CONFIG_INT_EN_MODE(val);
618603
dac_config_msk = AD5758_DAC_CONFIG_OUT_EN_MSK |
@@ -841,11 +826,6 @@ static int ad5758_init(struct ad5758_state *st)
841826
return ret;
842827
}
843828

844-
/* Enable the VIOUT fault protection switch (FPS is closed) */
845-
ret = ad5758_fault_prot_switch_en(st, 1);
846-
if (ret < 0)
847-
return ret;
848-
849829
/* Power up the DAC and internal (INT) amplifiers */
850830
ret = ad5758_internal_buffers_en(st, 1);
851831
if (ret < 0)

0 commit comments

Comments
 (0)