diff options
Diffstat (limited to 'drivers/iio/dac')
-rw-r--r-- | drivers/iio/dac/ad5064.c | 15 | ||||
-rw-r--r-- | drivers/iio/dac/ad5758.c | 55 | ||||
-rw-r--r-- | drivers/iio/dac/mcp4725.c | 1 | ||||
-rw-r--r-- | drivers/iio/dac/ti-dac5571.c | 2 |
4 files changed, 29 insertions, 44 deletions
diff --git a/drivers/iio/dac/ad5064.c b/drivers/iio/dac/ad5064.c index 2f98cb2a3b96..6c3ba143839b 100644 --- a/drivers/iio/dac/ad5064.c +++ b/drivers/iio/dac/ad5064.c @@ -112,6 +112,8 @@ struct ad5064_state { bool use_internal_vref; ad5064_write_func write; + /* Lock used to maintain consistency between cached and dev state */ + struct mutex lock; /* * DMA (thus cache coherency maintenance) requires the @@ -248,11 +250,11 @@ static int ad5064_set_powerdown_mode(struct iio_dev *indio_dev, struct ad5064_state *st = iio_priv(indio_dev); int ret; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); st->pwr_down_mode[chan->channel] = mode + 1; ret = ad5064_sync_powerdown_mode(st, chan); - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret; } @@ -291,11 +293,11 @@ static ssize_t ad5064_write_dac_powerdown(struct iio_dev *indio_dev, if (ret) return ret; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); st->pwr_down[chan->channel] = pwr_down; ret = ad5064_sync_powerdown_mode(st, chan); - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); return ret ? ret : len; } @@ -349,12 +351,12 @@ static int ad5064_write_raw(struct iio_dev *indio_dev, if (val >= (1 << chan->scan_type.realbits) || val < 0) return -EINVAL; - mutex_lock(&indio_dev->mlock); + mutex_lock(&st->lock); ret = ad5064_write(st, AD5064_CMD_WRITE_INPUT_N_UPDATE_N, chan->address, val, chan->scan_type.shift); if (ret == 0) st->dac_cache[chan->channel] = val; - mutex_unlock(&indio_dev->mlock); + mutex_unlock(&st->lock); break; default: ret = -EINVAL; @@ -856,6 +858,7 @@ static int ad5064_probe(struct device *dev, enum ad5064_type type, return -ENOMEM; st = iio_priv(indio_dev); + mutex_init(&st->lock); dev_set_drvdata(dev, indio_dev); st->chip_info = &ad5064_chip_info_tbl[type]; diff --git a/drivers/iio/dac/ad5758.c b/drivers/iio/dac/ad5758.c index 2bdf1b0aee06..a513c70faefa 100644 --- a/drivers/iio/dac/ad5758.c +++ b/drivers/iio/dac/ad5758.c @@ -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) diff --git a/drivers/iio/dac/mcp4725.c b/drivers/iio/dac/mcp4725.c index 6d71fd905e29..c701a45469f6 100644 --- a/drivers/iio/dac/mcp4725.c +++ b/drivers/iio/dac/mcp4725.c @@ -92,6 +92,7 @@ static ssize_t mcp4725_store_eeprom(struct device *dev, inoutbuf[0] = 0x60; /* write EEPROM */ inoutbuf[0] |= data->ref_mode << 3; + inoutbuf[0] |= data->powerdown ? ((data->powerdown_mode + 1) << 1) : 0; inoutbuf[1] = data->dac_value >> 4; inoutbuf[2] = (data->dac_value & 0xf) << 4; diff --git a/drivers/iio/dac/ti-dac5571.c b/drivers/iio/dac/ti-dac5571.c index f6dcd8bce2b0..891e9cac019e 100644 --- a/drivers/iio/dac/ti-dac5571.c +++ b/drivers/iio/dac/ti-dac5571.c @@ -429,6 +429,6 @@ static struct i2c_driver dac5571_driver = { }; module_i2c_driver(dac5571_driver); -MODULE_AUTHOR("Sean Nyekjaer <sean.nyekjaer@prevas.dk>"); +MODULE_AUTHOR("Sean Nyekjaer <sean@geanix.dk>"); MODULE_DESCRIPTION("Texas Instruments 8/10/12-bit 1/4-channel DAC driver"); MODULE_LICENSE("GPL v2"); |