staging:iio:dac:ad5446: Do not exit powerdown when writing a sample
Subsystems (4)
PATCH v2 1/11 staging:iio:dac:ad5446: Do not exit powerdown when writing a sample
Both the powerdown mode bits and the sample value are stored in the same register, so writing a sample while the device is powered down will clear the power down bits. To avoid this only update the cached value when the device is powered down.
----
v1 actually had a small bug in that it would still write to the device's register when the sample was updated while the device was powered down. This was not critical since it would send out the powerdown mode again.
--- drivers/staging/iio/dac/ad5446.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/staging/iio/dac/ad5446.c +5 -3
@@ -272,7 +272,7 @@ static int ad5446_write_raw(struct iio_dev *indio_dev, long mask) {struct ad5446_state *st =iio_priv (indio_dev); -int ret; +int ret =0 ;switch (mask) {case IIO_CHAN_INFO_RAW :
@@ -282,8 +282,10 @@ static int ad5446_write_raw(struct iio_dev *indio_dev, val <<= chan->scan_type.shift;mutex_lock (&indio_dev->mlock); st->cached_val = val; - st->chip_info->store_sample (st, val); - ret =spi_sync (st->spi, &st->msg); +if (!st->pwr_down) { + st->chip_info->store_sample (st, val); + ret =spi_sync (st->spi, &st->msg); + }mutex_unlock (&indio_dev->mlock);break ;default :
Signature · 1 line
1.7.9.5
PATCH v2 2/11 staging:iio:dac:ad5446: Remove duplicated write sample functions
AD5620_LOAD and AD5446_LOAD are both 0, so all these three functions are identical and we can replace them with only one.
--- drivers/staging/iio/dac/ad5446.c | 34 ++++++++++++---------------------- 1 file changed, 12 insertions(+), 22 deletions(-)
drivers/staging/iio/dac/ad5446.c +12 -22
@@ -26,19 +26,9 @@static void ad5446_store_sample (struct ad5446_state *st,unsigned val) { - st->data.d16 =cpu_to_be16 (AD5446_LOAD | val); -} - -static void ad5542_store_sample (struct ad5446_state *st,unsigned val) -{ st->data.d16 =cpu_to_be16 (val); } -static void ad5620_store_sample (struct ad5446_state *st,unsigned val) -{ - st->data.d16 =cpu_to_be16 (AD5620_LOAD | val); -} -static void ad5660_store_sample (struct ad5446_state *st,unsigned val) { val |=AD5660_LOAD ;
@@ -174,61 +164,61 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = { }, [ID_AD5541A] = { .channel = AD5446_CHANNEL(16, 16, 0), - .store_sample = ad5542_store_sample, + .store_sample = ad5446_store_sample, }, [ID_AD5542A] = { .channel = AD5446_CHANNEL(16, 16, 0), - .store_sample = ad5542_store_sample, + .store_sample = ad5446_store_sample, }, [ID_AD5543] = { .channel = AD5446_CHANNEL(16, 16, 0), - .store_sample = ad5542_store_sample, + .store_sample = ad5446_store_sample, }, [ID_AD5512A] = { .channel = AD5446_CHANNEL(12, 16, 4), - .store_sample = ad5542_store_sample, + .store_sample = ad5446_store_sample, }, [ID_AD5553] = { .channel = AD5446_CHANNEL(14, 16, 0), - .store_sample = ad5542_store_sample, + .store_sample = ad5446_store_sample, }, [ID_AD5601] = { .channel = AD5446_CHANNEL(8, 16, 6), - .store_sample = ad5542_store_sample, + .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5611] = { .channel = AD5446_CHANNEL(10, 16, 4), - .store_sample = ad5542_store_sample, + .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5621] = { .channel = AD5446_CHANNEL(12, 16, 2), - .store_sample = ad5542_store_sample, + .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5620_2500] = { .channel = AD5446_CHANNEL(12, 16, 2), .int_vref_mv = 2500, - .store_sample = ad5620_store_sample, + .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5620_1250] = { .channel = AD5446_CHANNEL(12, 16, 2), .int_vref_mv = 1250, - .store_sample = ad5620_store_sample, + .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5640_2500] = { .channel = AD5446_CHANNEL(14, 16, 0), .int_vref_mv = 2500, - .store_sample = ad5620_store_sample, + .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5640_1250] = { .channel = AD5446_CHANNEL(14, 16, 0), .int_vref_mv = 1250, - .store_sample = ad5620_store_sample, + .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5660_2500] = {
Signature · 1 line
1.7.9.5
PATCH v2 3/11 staging:iio:dac:ad5446: Fix 24bit transfers
In reply to Lars-Peter ClausenWe currently only write 16 bit in case where we should write 24 bit. The spi message length is calculated from the channel storage_size, but since the storage size is only 16 bit we end up with the wrong value for devices which have power down bits and thus a register with 24 bit. Since each store function knows how many bytes it has to write just use the spi_write function from there instead of going through the hassle of manually preparing a spi_message and keeping buffers in the state struct.
Another advantage of this patch is that it will implementing support for similar I2C based DACs much easier.
--- drivers/staging/iio/dac/ad5446.c | 52 ++++++++++++++++++-------------------- drivers/staging/iio/dac/ad5446.h | 13 ++-------- 2 files changed, 27 insertions(+), 38 deletions(-)
drivers/staging/iio/dac/ad5446.c +25 -27
@@ -24,31 +24,40 @@#include "ad5446.h" -static void ad5446_store_sample (struct ad5446_state *st,unsigned val) +static int ad5446_store_sample (struct ad5446_state *st,unsigned val) { - st->data.d16 =cpu_to_be16 (val); +__be16 data =cpu_to_be16 (val); +return spi_write (st->spi, &data,sizeof (data)); } -static void ad5660_store_sample (struct ad5446_state *st,unsigned val) +static int ad5660_store_sample (struct ad5446_state *st,unsigned val) { +uint8_t data[3 ]; + val |=AD5660_LOAD ; - st->data.d24[0 ] = (val >>16 ) &0xFF ; - st->data.d24[1 ] = (val >>8 ) &0xFF ; - st->data.d24[2 ] = val &0xFF ; + data[0 ] = (val >>16 ) &0xFF ; + data[1 ] = (val >>8 ) &0xFF ; + data[2 ] = val &0xFF ; + +return spi_write (st->spi, data,sizeof (data)); } -static void ad5620_store_pwr_down (struct ad5446_state *st,unsigned mode) +static int ad5620_store_pwr_down (struct ad5446_state *st,unsigned mode) { - st->data.d16 =cpu_to_be16 (mode <<14 ); +__be16 data =cpu_to_be16 (mode <<14 ); +return spi_write (st->spi, &data,sizeof (data)); } -static void ad5660_store_pwr_down (struct ad5446_state *st,unsigned mode) +static int ad5660_store_pwr_down (struct ad5446_state *st,unsigned mode) {unsigned val = mode <<16 ; +uint8_t data[3 ]; + + data[0 ] = (val >>16 ) &0xFF ; + data[1 ] = (val >>8 ) &0xFF ; + data[2 ] = val &0xFF ; - st->data.d24[0 ] = (val >>16 ) &0xFF ; - st->data.d24[1 ] = (val >>8 ) &0xFF ; - st->data.d24[2 ] = val &0xFF ; +return spi_write (st->spi, data,sizeof (data)); } static ssize_t ad5446_write_powerdown_mode(struct device *dev,
@@ -111,11 +120,10 @@ static ssize_t ad5446_write_dac_powerdown(struct device *dev, st->pwr_down = readin;if (st->pwr_down) - st->chip_info->store_pwr_down (st, st->pwr_down_mode); + ret = st->chip_info->store_pwr_down (st, st->pwr_down_mode);else - st->chip_info->store_sample (st, st->cached_val); + ret = st->chip_info->store_sample (st, st->cached_val); - ret =spi_sync (st->spi, &st->msg);mutex_unlock (&indio_dev->mlock);return ret ? ret : len;
@@ -272,10 +280,8 @@ static int ad5446_write_raw(struct iio_dev *indio_dev, val <<= chan->scan_type.shift;mutex_lock (&indio_dev->mlock); st->cached_val = val; -if (!st->pwr_down) { - st->chip_info->store_sample (st, val); - ret =spi_sync (st->spi, &st->msg); - } +if (!st->pwr_down) + ret = st->chip_info->store_sample (st, val);mutex_unlock (&indio_dev->mlock);break ;default :
@@ -338,14 +344,6 @@ static int __devinit ad5446_probe(struct spi_device *spi) indio_dev->channels = &st->chip_info->channel; indio_dev->num_channels =1 ; -/* Setup default message */ - - st->xfer.tx_buf = &st->data; - st->xfer.len = st->chip_info->channel.scan_type.storagebits /8 ; - -spi_message_init (&st->msg); -spi_message_add_tail (&st->xfer, &st->msg); -switch (spi_get_device_id (spi)->driver_data) {case ID_AD5620_2500 :case ID_AD5620_1250 :
drivers/staging/iio/dac/ad5446.h +2 -11
@@ -36,9 +36,6 @@* @reg: supply regulator * @poll_work: bottom half of polling interrupt handler * @vref_mv: actual reference voltage used -* @xfer: default spi transfer -* @msg: default spi message -* @data: spi transmit buffer */ struct ad5446_state {
@@ -50,12 +47,6 @@ struct ad5446_state {unsigned cached_val;unsigned pwr_down_mode;unsigned pwr_down; -struct spi_transfer xfer; -struct spi_message msg; -union { -unsigned short d16; -unsigned char d24[3 ]; - } data; };/**
@@ -69,8 +60,8 @@ struct ad5446_state {struct ad5446_chip_info {struct iio_chan_spec channel;u16 int_vref_mv; -void (*store_sample) (struct ad5446_state *st,unsigned val); -void (*store_pwr_down) (struct ad5446_state *st,unsigned mode); +int (*store_sample) (struct ad5446_state *st,unsigned val); +int (*store_pwr_down) (struct ad5446_state *st,unsigned mode); };/**
Signature · 1 line
1.7.9.5
Re: [PATCH v2 03/11] staging:iio:dac:ad5446: Fix 24bit transfers
Quoted 10 lines · Lars-Peter Clausen
We currently only write 16 bit in case where we should write 24 bit. The spi message length is calculated from the channel
storage_size, but since the storage size is only 16 bit we end up with the wrong value for devices which have power down bits and thus a register with 24 bit. Since each store function knows how many bytes it has to write just use thespi_writefunction from there instead of going through the hassle of manually preparing aspi_messageand keeping buffers in the state struct.Another advantage of this patch is that it will implementing support for similar I2C based DACs much easier.
Nice cleanup.
Quoted 2 lines
Signed-off-by Lars-Peter Clausen <[email protected]>
Quoted 142 lines
--- drivers/staging/iio/dac/ad5446.c | 52 ++++++++++++++++++-------------------- drivers/staging/iio/dac/ad5446.h | 13 ++-------- 2 files changed, 27 insertions(+), 38 deletions(-)drivers/staging/iio/dac/ad5446.c +25
-27@@ -24,31 +24,40 @@#include "ad5446.h" -static void ad5446_store_sample (struct ad5446_state *st,unsigned val) +static int ad5446_store_sample (struct ad5446_state *st,unsigned val) { - st->data.d16 =cpu_to_be16 (val); +__be16 data =cpu_to_be16 (val); +return spi_write (st->spi, &data,sizeof (data)); } -static void ad5660_store_sample (struct ad5446_state *st,unsigned val) +static int ad5660_store_sample (struct ad5446_state *st,unsigned val) { +uint8_t data[3 ]; + val |=AD5660_LOAD ; - st->data.d24[0 ] = (val >>16 ) &0xFF ; - st->data.d24[1 ] = (val >>8 ) &0xFF ; - st->data.d24[2 ] = val &0xFF ; + data[0 ] = (val >>16 ) &0xFF ; + data[1 ] = (val >>8 ) &0xFF ; + data[2 ] = val &0xFF ; + +return spi_write (st->spi, data,sizeof (data)); } -static void ad5620_store_pwr_down (struct ad5446_state *st,unsigned mode) +static int ad5620_store_pwr_down (struct ad5446_state *st,unsigned mode) { - st->data.d16 =cpu_to_be16 (mode <<14 ); +__be16 data =cpu_to_be16 (mode <<14 ); +return spi_write (st->spi, &data,sizeof (data)); } -static void ad5660_store_pwr_down (struct ad5446_state *st,unsigned mode) +static int ad5660_store_pwr_down (struct ad5446_state *st,unsigned mode) {unsigned val = mode <<16 ; +uint8_t data[3 ]; + + data[0 ] = (val >>16 ) &0xFF ; + data[1 ] = (val >>8 ) &0xFF ; + data[2 ] = val &0xFF ; - st->data.d24[0 ] = (val >>16 ) &0xFF ; - st->data.d24[1 ] = (val >>8 ) &0xFF ; - st->data.d24[2 ] = val &0xFF ; +return spi_write (st->spi, data,sizeof (data)); } static ssize_t ad5446_write_powerdown_mode(struct device *dev,@@ -111,11 +120,10 @@ static ssize_t ad5446_write_dac_powerdown(struct device *dev, st->pwr_down = readin;if (st->pwr_down) - st->chip_info->store_pwr_down (st, st->pwr_down_mode); + ret = st->chip_info->store_pwr_down (st, st->pwr_down_mode);else - st->chip_info->store_sample (st, st->cached_val); + ret = st->chip_info->store_sample (st, st->cached_val); - ret =spi_sync (st->spi, &st->msg);mutex_unlock (&indio_dev->mlock);return ret ? ret : len;@@ -272,10 +280,8 @@ static int ad5446_write_raw(struct iio_dev *indio_dev, val <<= chan->scan_type.shift;mutex_lock (&indio_dev->mlock); st->cached_val = val; -if (!st->pwr_down) { - st->chip_info->store_sample (st, val); - ret =spi_sync (st->spi, &st->msg); - } +if (!st->pwr_down) + ret = st->chip_info->store_sample (st, val);mutex_unlock (&indio_dev->mlock);break ;default :@@ -338,14 +344,6 @@ static int __devinit ad5446_probe(struct spi_device *spi) indio_dev->channels = &st->chip_info->channel; indio_dev->num_channels =1 ; -/* Setup default message */ - - st->xfer.tx_buf = &st->data; - st->xfer.len = st->chip_info->channel.scan_type.storagebits /8 ; - -spi_message_init (&st->msg); -spi_message_add_tail (&st->xfer, &st->msg); -switch (spi_get_device_id (spi)->driver_data) {case ID_AD5620_2500 :case ID_AD5620_1250 :drivers/staging/iio/dac/ad5446.h +2
-11@@ -36,9 +36,6 @@* @reg: supply regulator * @poll_work: bottom half of polling interrupt handler * @vref_mv: actual reference voltage used -* @xfer: default spi transfer -* @msg: default spi message -* @data: spi transmit buffer */ struct ad5446_state {@@ -50,12 +47,6 @@ struct ad5446_state {unsigned cached_val;unsigned pwr_down_mode;unsigned pwr_down; -struct spi_transfer xfer; -struct spi_message msg; -union { -unsigned short d16; -unsigned char d24[3 ]; - } data; };/** @@ -69,8 +60,8 @@ struct ad5446_state {struct ad5446_chip_info {struct iio_chan_spec channel;u16 int_vref_mv; -void (*store_sample) (struct ad5446_state *st,unsigned val); -void (*store_pwr_down) (struct ad5446_state *st,unsigned mode); +int (*store_sample) (struct ad5446_state *st,unsigned val); +int (*store_pwr_down) (struct ad5446_state *st,unsigned mode); };/**
PATCH v2 4/11 staging:iio:dac:ad5446: Remove unused struct field
In reply to Lars-Peter ClausenRemove the unused "poll_work" field from the ad5446_state struct.
--- drivers/staging/iio/dac/ad5446.h | 2 -- 1 file changed, 2 deletions(-)
drivers/staging/iio/dac/ad5446.h +0 -2
@@ -34,7 +34,6 @@* @spi: spi_device * @chip_info: chip model specific constants, available modes etc * @reg: supply regulator -* @poll_work: bottom half of polling interrupt handler * @vref_mv: actual reference voltage used */
@@ -42,7 +41,6 @@ struct ad5446_state {struct spi_device *spi;const struct ad5446_chip_info *chip_info;struct regulator *reg; -struct work_struct poll_work;unsigned short vref_mv;unsigned cached_val;unsigned pwr_down_mode;
Signature · 1 line
1.7.9.5
PATCH v2 5/11 staging:iio:dac:ad5446: Do not check for individual chip ids in probe
In reply to Lars-Peter ClausenUse the chip_info's int_vref_mv field to decide whether a certain chip has a internal reference or not. There is no need to check for individual chip ids.
--- drivers/staging/iio/dac/ad5446.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-)
drivers/staging/iio/dac/ad5446.c +5 -15
@@ -344,22 +344,12 @@ static int __devinit ad5446_probe(struct spi_device *spi) indio_dev->channels = &st->chip_info->channel; indio_dev->num_channels =1 ; -switch (spi_get_device_id (spi)->driver_data) { -case ID_AD5620_2500 : -case ID_AD5620_1250 : -case ID_AD5640_2500 : -case ID_AD5640_1250 : -case ID_AD5660_2500 : -case ID_AD5660_1250 : +if (st->chip_info->int_vref_mv) st->vref_mv = st->chip_info->int_vref_mv; -break ; -default : -if (voltage_uv) - st->vref_mv = voltage_uv /1000 ; -else -dev_warn (&spi->dev, -"reference voltage unspecified\n" ); - } +else if (voltage_uv) + st->vref_mv = voltage_uv /1000 ; +else +dev_warn (&spi->dev,"reference voltage unspecified\n" ); ret =iio_device_register (indio_dev);if (ret)
Signature · 1 line
1.7.9.5
PATCH v2 6/11 staging:iio:dac:ad5446: Remove duplicated chip_info entries
In reply to Lars-Peter ClausenThere are three identical chip_info entries. Remove two of them and use the id of the remaining entry for all three device table entries.
--- drivers/staging/iio/dac/ad5446.c | 12 ++---------- drivers/staging/iio/dac/ad5446.h | 2 -- 2 files changed, 2 insertions(+), 12 deletions(-)
drivers/staging/iio/dac/ad5446.c +2 -10
@@ -174,14 +174,6 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = { .channel = AD5446_CHANNEL(16, 16, 0), .store_sample = ad5446_store_sample, }, - [ID_AD5542A] = { - .channel = AD5446_CHANNEL(16, 16, 0), - .store_sample = ad5446_store_sample, - }, - [ID_AD5543] = { - .channel = AD5446_CHANNEL(16, 16, 0), - .store_sample = ad5446_store_sample, - }, [ID_AD5512A] = { .channel = AD5446_CHANNEL(12, 16, 4), .store_sample = ad5446_store_sample,
@@ -389,8 +381,8 @@ static const struct spi_device_id ad5446_id[] = { {"ad5446", ID_AD5446}, {"ad5512a", ID_AD5512A}, {"ad5541a", ID_AD5541A}, - {"ad5542a", ID_AD5542A}, - {"ad5543", ID_AD5543}, + {"ad5542a", ID_AD5541A}, /* ad5541a and ad5542a are compatible */ + {"ad5543", ID_AD5541A}, /* ad5541a and ad5543 are compatible */ {"ad5553", ID_AD5553}, {"ad5601", ID_AD5601}, {"ad5611", ID_AD5611},
drivers/staging/iio/dac/ad5446.h +0 -2
@@ -74,8 +74,6 @@ enum ad5446_supported_device_ids {ID_AD5444 ,ID_AD5446 ,ID_AD5541A , -ID_AD5542A , -ID_AD5543 ,ID_AD5512A ,ID_AD5553 , ID_AD5601,
Signature · 1 line
1.7.9.5
PATCH v2 7/11 staging:iio:dac:ad5446: Convert to extended channel attributes
In reply to Lars-Peter ClausenUse extended channel attributes instead of raw sysfs files for the additional channel attributes.
--- drivers/staging/iio/dac/ad5446.c | 139 +++++++++++++++++++------------------- 1 file changed, 68 insertions(+), 71 deletions(-)
drivers/staging/iio/dac/ad5446.c +68 -71
@@ -60,64 +60,69 @@ static int ad5660_store_pwr_down(struct ad5446_state *st, unsigned mode)return spi_write (st->spi, data,sizeof (data)); } -static ssize_t ad5446_write_powerdown_mode (struct device *dev, -struct device_attribute *attr, -const char *buf,size_t len) +static const char *const ad5446_powerdown_modes[] = { +"" ,"1kohm_to_gnd" ,"100kohm_to_gnd" ,"three_state" +}; + +static ssize_t ad5446_read_powerdown_mode_available (struct iio_dev *indio_dev, +const struct iio_chan_spec *chan,char *buf) +{ +return sprintf (buf,"%s %s %s\n" , ad5446_powerdown_modes[1 ], + ad5446_powerdown_modes[2 ], ad5446_powerdown_modes[3 ]); +} + +static ssize_t ad5446_write_powerdown_mode (struct iio_dev *indio_dev, +const struct iio_chan_spec *chan, +const char *buf,size_t len) { -struct iio_dev *indio_dev =dev_get_drvdata (dev);struct ad5446_state *st =iio_priv (indio_dev); +int i; -if (sysfs_streq (buf,"1kohm_to_gnd" )) - st->pwr_down_mode = MODE_PWRDWN_1k; -else if (sysfs_streq (buf,"100kohm_to_gnd" )) - st->pwr_down_mode = MODE_PWRDWN_100k; -else if (sysfs_streq (buf,"three_state" )) - st->pwr_down_mode =MODE_PWRDWN_TRISTATE ; -else +for (i =1 ; i <ARRAY_SIZE (ad5446_powerdown_modes); i++) { +if (sysfs_streq (buf, ad5446_powerdown_modes[i])) { + st->pwr_down_mode = i; +break ; + } + } + +if (i ==ARRAY_SIZE (ad5446_powerdown_modes))return -EINVAL ;return len; } -static ssize_t ad5446_read_powerdown_mode (struct device *dev, -struct device_attribute *attr,char *buf) +static ssize_t ad5446_read_powerdown_mode (struct iio_dev *indio_dev, +const struct iio_chan_spec *chan, +char *buf) { -struct iio_dev *indio_dev =dev_get_drvdata (dev);struct ad5446_state *st =iio_priv (indio_dev); -char mode[][15 ] = {"" ,"1kohm_to_gnd" ,"100kohm_to_gnd" ,"three_state" }; - -return sprintf (buf,"%s\n" , mode[st->pwr_down_mode]); +return sprintf (buf,"%s\n" , ad5446_powerdown_modes[st->pwr_down_mode]); } -static ssize_t ad5446_read_dac_powerdown (struct device *dev, -struct device_attribute *attr, +static ssize_t ad5446_read_dac_powerdown (struct iio_dev *indio_dev, +const struct iio_chan_spec *chan,char *buf) { -struct iio_dev *indio_dev =dev_get_drvdata (dev);struct ad5446_state *st =iio_priv (indio_dev);return sprintf (buf,"%d\n" , st->pwr_down); } -static ssize_t ad5446_write_dac_powerdown (struct device *dev, -struct device_attribute *attr, +static ssize_t ad5446_write_dac_powerdown (struct iio_dev *indio_dev, +const struct iio_chan_spec *chan,const char *buf,size_t len) { -struct iio_dev *indio_dev =dev_get_drvdata (dev);struct ad5446_state *st =iio_priv (indio_dev); -unsigned long readin; +bool powerdown;int ret; - ret =strict_strtol (buf,10 , &readin); + ret =strtobool (buf, &powerdown);if (ret)return ret; -if (readin >1 ) - ret = -EINVAL ; -mutex_lock (&indio_dev->mlock); - st->pwr_down = readin; + st->pwr_down = powerdown;if (st->pwr_down) ret = st->chip_info->store_pwr_down (st, st->pwr_down_mode);
@@ -129,38 +134,40 @@ static ssize_t ad5446_write_dac_powerdown(struct device *dev,return ret ? ret : len; } -static IIO_DEVICE_ATTR(out_voltage_powerdown_mode, S_IRUGO | S_IWUSR, - ad5446_read_powerdown_mode, - ad5446_write_powerdown_mode, 0); - -static IIO_CONST_ATTR(out_voltage_powerdown_mode_available, - "1kohm_to_gnd 100kohm_to_gnd three_state"); - -static IIO_DEVICE_ATTR(out_voltage0_powerdown, S_IRUGO | S_IWUSR, - ad5446_read_dac_powerdown, - ad5446_write_dac_powerdown, 0); - -static struct attribute *ad5446_attributes[] = { - &iio_dev_attr_out_voltage0_powerdown.dev_attr.attr, - &iio_dev_attr_out_voltage_powerdown_mode.dev_attr.attr, - &iio_const_attr_out_voltage_powerdown_mode_available.dev_attr.attr, -NULL , -}; - -static const struct attribute_group ad5446_attribute_group = { - .attrs = ad5446_attributes, +static const struct iio_chan_spec_ext_info ad5064_ext_info_powerdown[] = { + { + .name ="powerdown" , + .read = ad5446_read_dac_powerdown, + .write = ad5446_write_dac_powerdown, + }, { + .name ="powerdown_mode" , + .read = ad5446_read_powerdown_mode, + .write = ad5446_write_powerdown_mode, + }, { + .name ="powerdown_mode_available" , + .shared = true, + .read = ad5446_read_powerdown_mode_available, + }, + { }, }; -#define AD5446_CHANNEL (bits, storage, shift) { \ +#define _AD5446_CHANNEL (bits, storage, shift, ext) { \ .type = IIO_VOLTAGE, \ .indexed = 1, \ .output = 1, \ .channel = 0, \ .info_mask = IIO_CHAN_INFO_RAW_SEPARATE_BIT | \ IIO_CHAN_INFO_SCALE_SHARED_BIT, \ - .scan_type = IIO_ST('u', (bits), (storage), (shift)) \ + .scan_type = IIO_ST('u', (bits), (storage), (shift)), \ + .ext_info = (ext), \ } +#define AD5446_CHANNEL (bits, storage, shift) \ + _AD5446_CHANNEL(bits, storage, shift, NULL) + +#define AD5446_CHANNEL_POWERDOWN (bits, storage, shift) \ + _AD5446_CHANNEL(bits, storage, shift, ad5064_ext_info_powerdown) +static const struct ad5446_chip_info ad5446_chip_info_tbl[] = { [ID_AD5444 ] = { .channel =AD5446_CHANNEL (12 ,16 ,2 ),
@@ -183,52 +190,52 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = { .store_sample = ad5446_store_sample, }, [ID_AD5601] = { - .channel = AD5446_CHANNEL(8, 16, 6), + .channel = AD5446_CHANNEL_POWERDOWN(8, 16, 6), .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5611] = { - .channel = AD5446_CHANNEL(10, 16, 4), + .channel = AD5446_CHANNEL_POWERDOWN(10, 16, 4), .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5621] = { - .channel = AD5446_CHANNEL(12, 16, 2), + .channel = AD5446_CHANNEL_POWERDOWN(12, 16, 2), .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5620_2500] = { - .channel = AD5446_CHANNEL(12, 16, 2), + .channel = AD5446_CHANNEL_POWERDOWN(12, 16, 2), .int_vref_mv = 2500, .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5620_1250] = { - .channel = AD5446_CHANNEL(12, 16, 2), + .channel = AD5446_CHANNEL_POWERDOWN(12, 16, 2), .int_vref_mv = 1250, .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5640_2500] = { - .channel = AD5446_CHANNEL(14, 16, 0), + .channel = AD5446_CHANNEL_POWERDOWN(14, 16, 0), .int_vref_mv = 2500, .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5640_1250] = { - .channel = AD5446_CHANNEL(14, 16, 0), + .channel = AD5446_CHANNEL_POWERDOWN(14, 16, 0), .int_vref_mv = 1250, .store_sample = ad5446_store_sample, .store_pwr_down = ad5620_store_pwr_down, }, [ID_AD5660_2500] = { - .channel = AD5446_CHANNEL(16, 16, 0), + .channel = AD5446_CHANNEL_POWERDOWN(16, 16, 0), .int_vref_mv = 2500, .store_sample = ad5660_store_sample, .store_pwr_down = ad5660_store_pwr_down, }, [ID_AD5660_1250] = { - .channel = AD5446_CHANNEL(16, 16, 0), + .channel = AD5446_CHANNEL_POWERDOWN(16, 16, 0), .int_vref_mv = 1250, .store_sample = ad5660_store_sample, .store_pwr_down = ad5660_store_pwr_down,
@@ -286,13 +293,6 @@ static int ad5446_write_raw(struct iio_dev *indio_dev,static const struct iio_info ad5446_info = { .read_raw = ad5446_read_raw, .write_raw = ad5446_write_raw, - .attrs = &ad5446_attribute_group, - .driver_module =THIS_MODULE , -}; - -static const struct iio_info ad5446_info_no_pwr_down = { - .read_raw = ad5446_read_raw, - .write_raw = ad5446_write_raw, .driver_module =THIS_MODULE , };
@@ -328,10 +328,7 @@ static int __devinit ad5446_probe(struct spi_device *spi)/* Establish that the iio_dev is a child of the spi device */ indio_dev->dev.parent = &spi->dev; indio_dev->name =spi_get_device_id (spi)->name; -if (st->chip_info->store_pwr_down) - indio_dev->info = &ad5446_info; -else - indio_dev->info = &ad5446_info_no_pwr_down; + indio_dev->info = &ad5446_info; indio_dev->modes =INDIO_DIRECT_MODE ; indio_dev->channels = &st->chip_info->channel; indio_dev->num_channels =1 ;
Signature · 1 line
1.7.9.5
PATCH v2 8/11 staging:iio:dac:ad5446: Consolidate store_sample and store_pwr_down functions
In reply to Lars-Peter ClausenThe devices supported by this drivers only have a single shift register, which contains both the power down mode and the output sample. So writing the power down mode and the output sample can be done by the same function. Call this function prepare_write as it will prepare the spi message for a write. Also introduce a small helper function which performs the whole write by calling the chip the specific prepare function followed by a spi_sync.
The two power down bits are always placed ontop of the msb of the output sample, so we can easily calculate their position by adding the channels shift to the channels realbits.
--- drivers/staging/iio/dac/ad5446.c | 75 +++++++++++++------------------------- drivers/staging/iio/dac/ad5446.h | 6 +-- 2 files changed, 28 insertions(+), 53 deletions(-)
drivers/staging/iio/dac/ad5446.c +26 -49
@@ -24,35 +24,16 @@#include "ad5446.h" -static int ad5446_store_sample (struct ad5446_state *st,unsigned val) +static int ad5446_write (struct ad5446_state *st,unsigned val) {__be16 data =cpu_to_be16 (val);return spi_write (st->spi, &data,sizeof (data)); } -static int ad5660_store_sample (struct ad5446_state *st,unsigned val) +static int ad5660_write (struct ad5446_state *st,unsigned val) {uint8_t data[3 ]; - val |=AD5660_LOAD ; - data[0 ] = (val >>16 ) &0xFF ; - data[1 ] = (val >>8 ) &0xFF ; - data[2 ] = val &0xFF ; - -return spi_write (st->spi, data,sizeof (data)); -} - -static int ad5620_store_pwr_down (struct ad5446_state *st,unsigned mode) -{ -__be16 data =cpu_to_be16 (mode <<14 ); -return spi_write (st->spi, &data,sizeof (data)); -} - -static int ad5660_store_pwr_down (struct ad5446_state *st,unsigned mode) -{ -unsigned val = mode <<16 ; -uint8_t data[3 ]; - data[0 ] = (val >>16 ) &0xFF ; data[1 ] = (val >>8 ) &0xFF ; data[2 ] = val &0xFF ;
@@ -114,6 +95,8 @@ static ssize_t ad5446_write_dac_powerdown(struct iio_dev *indio_dev, const char *buf, size_t len) {struct ad5446_state *st =iio_priv (indio_dev); +unsigned int shift; +unsigned int val;bool powerdown;int ret;
@@ -124,11 +107,14 @@ static ssize_t ad5446_write_dac_powerdown(struct iio_dev *indio_dev,mutex_lock (&indio_dev->mlock); st->pwr_down = powerdown; -if (st->pwr_down) - ret = st->chip_info->store_pwr_down (st, st->pwr_down_mode); -else - ret = st->chip_info->store_sample (st, st->cached_val); +if (st->pwr_down) { + shift = chan->scan_type.realbits + chan->scan_type.shift; + val = st->pwr_down_mode << shift; + }else { + val = st->cached_val; + } + ret = st->chip_info->write (st, val);mutex_unlock (&indio_dev->mlock);return ret ? ret : len;
@@ -171,74 +157,65 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info_powerdown[] = {static const struct ad5446_chip_info ad5446_chip_info_tbl[] = { [ID_AD5444 ] = { .channel =AD5446_CHANNEL (12 ,16 ,2 ), - .store_sample = ad5446_store_sample, + .write = ad5446_write, }, [ID_AD5446 ] = { .channel =AD5446_CHANNEL (14 ,16 ,0 ), - .store_sample = ad5446_store_sample, + .write = ad5446_write, }, [ID_AD5541A ] = { .channel =AD5446_CHANNEL (16 ,16 ,0 ), - .store_sample = ad5446_store_sample, + .write = ad5446_write, }, [ID_AD5512A ] = { .channel =AD5446_CHANNEL (12 ,16 ,4 ), - .store_sample = ad5446_store_sample, + .write = ad5446_write, }, [ID_AD5553 ] = { .channel =AD5446_CHANNEL (14 ,16 ,0 ), - .store_sample = ad5446_store_sample, + .write = ad5446_write, }, [ID_AD5601 ] = { .channel =AD5446_CHANNEL_POWERDOWN (8 ,16 ,6 ), - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5611 ] = { .channel =AD5446_CHANNEL_POWERDOWN (10 ,16 ,4 ), - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5621 ] = { .channel =AD5446_CHANNEL_POWERDOWN (12 ,16 ,2 ), - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5620_2500 ] = { .channel =AD5446_CHANNEL_POWERDOWN (12 ,16 ,2 ), .int_vref_mv =2500 , - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5620_1250 ] = { .channel =AD5446_CHANNEL_POWERDOWN (12 ,16 ,2 ), .int_vref_mv =1250 , - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5640_2500 ] = { .channel =AD5446_CHANNEL_POWERDOWN (14 ,16 ,0 ), .int_vref_mv =2500 , - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5640_1250 ] = { .channel =AD5446_CHANNEL_POWERDOWN (14 ,16 ,0 ), .int_vref_mv =1250 , - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5660_2500 ] = { .channel =AD5446_CHANNEL_POWERDOWN (16 ,16 ,0 ), .int_vref_mv =2500 , - .store_sample = ad5660_store_sample, - .store_pwr_down = ad5660_store_pwr_down, + .write = ad5660_write, }, [ID_AD5660_1250 ] = { .channel =AD5446_CHANNEL_POWERDOWN (16 ,16 ,0 ), .int_vref_mv =1250 , - .store_sample = ad5660_store_sample, - .store_pwr_down = ad5660_store_pwr_down, + .write = ad5660_write, }, };
@@ -280,7 +257,7 @@ static int ad5446_write_raw(struct iio_dev *indio_dev,mutex_lock (&indio_dev->mlock); st->cached_val = val;if (!st->pwr_down) - ret = st->chip_info->store_sample (st, val); + ret = st->chip_info->write (st, val);mutex_unlock (&indio_dev->mlock);break ;default :
drivers/staging/iio/dac/ad5446.h +2 -4
@@ -51,15 +51,13 @@ struct ad5446_state {* struct ad5446_chip_info - chip specific information * @channel: channel spec for the DAC * @int_vref_mv: AD5620/40/60: the internal reference voltage -* @store_sample: chip specific helper function to store the datum -* @store_sample: chip specific helper function to store the powerpown cmd +* @write: chip specific helper function to write to the register */ struct ad5446_chip_info {struct iio_chan_spec channel;u16 int_vref_mv; -int (*store_sample) (struct ad5446_state *st,unsigned val); -int (*store_pwr_down) (struct ad5446_state *st,unsigned mode); +int (*write)(struct ad5446_state *st,unsigned val); };/**
Signature · 1 line
1.7.9.5
Re: [PATCH v2 08/11] staging:iio:dac:ad5446: Consolidate store_sample and store_pwr_down functions
Quoted 7 lines · Lars-Peter Clausen
The devices supported by this drivers only have a single shift register, which contains both the power down mode and the output sample. So writing the power down mode and the output sample can be done by the same function. Call this function
prepare_writeas it will prepare the spi message for a write. Also introduce a small helper function which performs the whole write by calling the chip the specific prepare function followed by aspi_sync.
Quoted 5 lines
The two power down bits are always placed ontop of the msb of the output sample, so we can easily calculate their position by adding the channels shift to the channels realbits.
Signed-off-by Lars-Peter Clausen <[email protected]>
Quoted 195 lines
--- drivers/staging/iio/dac/ad5446.c | 75 +++++++++++++------------------------- drivers/staging/iio/dac/ad5446.h | 6 +-- 2 files changed, 28 insertions(+), 53 deletions(-)drivers/staging/iio/dac/ad5446.c +26
-49@@ -24,35 +24,16 @@#include "ad5446.h" -static int ad5446_store_sample (struct ad5446_state *st,unsigned val) +static int ad5446_write (struct ad5446_state *st,unsigned val) {__be16 data =cpu_to_be16 (val);return spi_write (st->spi, &data,sizeof (data)); } -static int ad5660_store_sample (struct ad5446_state *st,unsigned val) +static int ad5660_write (struct ad5446_state *st,unsigned val) {uint8_t data[3 ]; - val |=AD5660_LOAD ; - data[0 ] = (val >>16 ) &0xFF ; - data[1 ] = (val >>8 ) &0xFF ; - data[2 ] = val &0xFF ; - -return spi_write (st->spi, data,sizeof (data)); -} - -static int ad5620_store_pwr_down (struct ad5446_state *st,unsigned mode) -{ -__be16 data =cpu_to_be16 (mode <<14 ); -return spi_write (st->spi, &data,sizeof (data)); -} - -static int ad5660_store_pwr_down (struct ad5446_state *st,unsigned mode) -{ -unsigned val = mode <<16 ; -uint8_t data[3 ]; - data[0 ] = (val >>16 ) &0xFF ; data[1 ] = (val >>8 ) &0xFF ; data[2 ] = val &0xFF ;@@ -114,6 +95,8 @@ static ssize_t ad5446_write_dac_powerdown(struct iio_dev *indio_dev, const char *buf, size_t len) {struct ad5446_state *st =iio_priv (indio_dev); +unsigned int shift; +unsigned int val;bool powerdown;int ret;@@ -124,11 +107,14 @@ static ssize_t ad5446_write_dac_powerdown(struct iio_dev *indio_dev,mutex_lock (&indio_dev->mlock); st->pwr_down = powerdown; -if (st->pwr_down) - ret = st->chip_info->store_pwr_down (st, st->pwr_down_mode); -else - ret = st->chip_info->store_sample (st, st->cached_val); +if (st->pwr_down) { + shift = chan->scan_type.realbits + chan->scan_type.shift; + val = st->pwr_down_mode << shift; + }else { + val = st->cached_val; + } + ret = st->chip_info->write (st, val);mutex_unlock (&indio_dev->mlock);return ret ? ret : len;@@ -171,74 +157,65 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info_powerdown[] = {static const struct ad5446_chip_info ad5446_chip_info_tbl[] = { [ID_AD5444 ] = { .channel =AD5446_CHANNEL (12 ,16 ,2 ), - .store_sample = ad5446_store_sample, + .write = ad5446_write, }, [ID_AD5446 ] = { .channel =AD5446_CHANNEL (14 ,16 ,0 ), - .store_sample = ad5446_store_sample, + .write = ad5446_write, }, [ID_AD5541A ] = { .channel =AD5446_CHANNEL (16 ,16 ,0 ), - .store_sample = ad5446_store_sample, + .write = ad5446_write, }, [ID_AD5512A ] = { .channel =AD5446_CHANNEL (12 ,16 ,4 ), - .store_sample = ad5446_store_sample, + .write = ad5446_write, }, [ID_AD5553 ] = { .channel =AD5446_CHANNEL (14 ,16 ,0 ), - .store_sample = ad5446_store_sample, + .write = ad5446_write, }, [ID_AD5601 ] = { .channel =AD5446_CHANNEL_POWERDOWN (8 ,16 ,6 ), - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5611 ] = { .channel =AD5446_CHANNEL_POWERDOWN (10 ,16 ,4 ), - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5621 ] = { .channel =AD5446_CHANNEL_POWERDOWN (12 ,16 ,2 ), - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5620_2500 ] = { .channel =AD5446_CHANNEL_POWERDOWN (12 ,16 ,2 ), .int_vref_mv =2500 , - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5620_1250 ] = { .channel =AD5446_CHANNEL_POWERDOWN (12 ,16 ,2 ), .int_vref_mv =1250 , - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5640_2500 ] = { .channel =AD5446_CHANNEL_POWERDOWN (14 ,16 ,0 ), .int_vref_mv =2500 , - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5640_1250 ] = { .channel =AD5446_CHANNEL_POWERDOWN (14 ,16 ,0 ), .int_vref_mv =1250 , - .store_sample = ad5446_store_sample, - .store_pwr_down = ad5620_store_pwr_down, + .write = ad5446_write, }, [ID_AD5660_2500 ] = { .channel =AD5446_CHANNEL_POWERDOWN (16 ,16 ,0 ), .int_vref_mv =2500 , - .store_sample = ad5660_store_sample, - .store_pwr_down = ad5660_store_pwr_down, + .write = ad5660_write, }, [ID_AD5660_1250 ] = { .channel =AD5446_CHANNEL_POWERDOWN (16 ,16 ,0 ), .int_vref_mv =1250 , - .store_sample = ad5660_store_sample, - .store_pwr_down = ad5660_store_pwr_down, + .write = ad5660_write, }, };@@ -280,7 +257,7 @@ static int ad5446_write_raw(struct iio_dev *indio_dev,mutex_lock (&indio_dev->mlock); st->cached_val = val;if (!st->pwr_down) - ret = st->chip_info->store_sample (st, val); + ret = st->chip_info->write (st, val);mutex_unlock (&indio_dev->mlock);break ;default :drivers/staging/iio/dac/ad5446.h +2
-4@@ -51,15 +51,13 @@ struct ad5446_state {* struct ad5446_chip_info - chip specific information * @channel: channel spec for the DAC * @int_vref_mv: AD5620/40/60: the internal reference voltage -* @store_sample: chip specific helper function to store the datum -* @store_sample: chip specific helper function to store the powerpown cmd +* @write: chip specific helper function to write to the register */ struct ad5446_chip_info {struct iio_chan_spec channel;u16 int_vref_mv; -int (*store_sample) (struct ad5446_state *st,unsigned val); -int (*store_pwr_down) (struct ad5446_state *st,unsigned mode); +int (*write)(struct ad5446_state *st,unsigned val); };/**
PATCH v2 9/11 staging:iio:dac:ad5446: Return cached value for 'raw' attribute
In reply to Lars-Peter ClausenWe can not read back the value from the device, but we cache the value anyway so we might as well return the cached value instead of an error.
--- drivers/staging/iio/dac/ad5446.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/staging/iio/dac/ad5446.c +3 -0
@@ -229,6 +229,9 @@ static int ad5446_read_raw(struct iio_dev *indio_dev,unsigned long scale_uv;switch (m) { +case IIO_CHAN_INFO_RAW : + *val = st->cached_val; +return IIO_VAL_INT ;case IIO_CHAN_INFO_SCALE : scale_uv = (st->vref_mv *1000 ) >> chan->scan_type.realbits; *val = scale_uv /1000 ;
Signature · 1 line
1.7.9.5
Re: [PATCH v2 09/11] staging:iio:dac:ad5446: Return cached value for 'raw' attribute
Quoted 4 lines · Lars-Peter Clausen
We can not read back the value from the device, but we cache the value anyway so we might as well return the cached value instead of an error.
Signed-off-by Lars-Peter Clausen <[email protected]>
Quoted 18 lines
--- drivers/staging/iio/dac/ad5446.c | 3 +++ 1 file changed, 3 insertions(+)drivers/staging/iio/dac/ad5446.c +3
-0@@ -229,6 +229,9 @@ static int ad5446_read_raw(struct iio_dev *indio_dev,unsigned long scale_uv;switch (m) { +case IIO_CHAN_INFO_RAW : + *val = st->cached_val; +return IIO_VAL_INT ;case IIO_CHAN_INFO_SCALE : scale_uv = (st->vref_mv *1000 ) >> chan->scan_type.realbits; *val = scale_uv /1000 ;
PATCH v2 10/11 staging:iio:dac:ad5446: Add support for the AD5662
In reply to Lars-Peter ClausenThe AD5662 is compatible to the AD5660, but uses an external reference instead of an internal.
--- drivers/staging/iio/dac/ad5446.c | 5 +++++ drivers/staging/iio/dac/ad5446.h | 1 + 2 files changed, 6 insertions(+)
drivers/staging/iio/dac/ad5446.c +5 -0
@@ -217,6 +217,10 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = { .int_vref_mv = 1250, .write = ad5660_write, }, + [ID_AD5662] = { + .channel = AD5446_CHANNEL_POWERDOWN(16, 16, 0), + .write = ad5660_write, + }, }; static int ad5446_read_raw(struct iio_dev *indio_dev,
@@ -370,6 +374,7 @@ static const struct spi_device_id ad5446_id[] = { {"ad5640-1250", ID_AD5640_1250}, {"ad5660-2500", ID_AD5660_2500}, {"ad5660-1250", ID_AD5660_1250}, + {"ad5662", ID_AD5662}, {} };MODULE_DEVICE_TABLE (spi, ad5446_id);
drivers/staging/iio/dac/ad5446.h +1 -0
@@ -83,6 +83,7 @@ enum ad5446_supported_device_ids {ID_AD5640_1250 ,ID_AD5660_2500 ,ID_AD5660_1250 , + ID_AD5662, };#endif /* IIO_DAC_AD5446_H_ */
Signature · 1 line
1.7.9.5
Re: [PATCH v2 10/11] staging:iio:dac:ad5446: Add support for the AD5662
Quoted 4 lines · Lars-Peter Clausen
The AD5662 is compatible to the AD5660, but uses an external reference instead of an internal.
Signed-off-by Lars-Peter Clausen <[email protected]>
Quoted 40 lines
--- drivers/staging/iio/dac/ad5446.c | 5 +++++ drivers/staging/iio/dac/ad5446.h | 1 + 2 files changed, 6 insertions(+)drivers/staging/iio/dac/ad5446.c +5
-0@@ -217,6 +217,10 @@ static const struct ad5446_chip_info ad5446_chip_info_tbl[] = { .int_vref_mv = 1250, .write = ad5660_write, }, + [ID_AD5662] = { + .channel = AD5446_CHANNEL_POWERDOWN(16, 16, 0), + .write = ad5660_write, + }, }; static int ad5446_read_raw(struct iio_dev *indio_dev,@@ -370,6 +374,7 @@ static const struct spi_device_id ad5446_id[] = { {"ad5640-1250", ID_AD5640_1250}, {"ad5660-2500", ID_AD5660_2500}, {"ad5660-1250", ID_AD5660_1250}, + {"ad5662", ID_AD5662}, {} };MODULE_DEVICE_TABLE (spi, ad5446_id);drivers/staging/iio/dac/ad5446.h +1
-0@@ -83,6 +83,7 @@ enum ad5446_supported_device_ids {ID_AD5640_1250 ,ID_AD5660_2500 ,ID_AD5660_1250 , + ID_AD5662, };#endif /* IIO_DAC_AD5446_H_ */
PATCH v2 11/11 staging:iio:dac:ad5446: Update Kconfig entry
In reply to Lars-Peter ClausenThere is one device supported by the driver which is not listed in the Kconfig help test. This patch adds it. Also we are past the point were we can possible fit all devices supported by the driver in the Kconfig entry title, so just list the initial device that was supported by this driver and note that similar devices are supported as well.
--- drivers/staging/iio/dac/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/staging/iio/dac/Kconfig +3 -3
@@ -56,12 +56,12 @@ config AD5624R_SPI AD5664R converters (DAC). This driver uses the common SPI interface. config AD5446 - tristate "Analog Devices AD5444/6, AD5620/40/60 and AD5542A/12A DAC SPI driver" + tristate "Analog Devices AD5446 and similar single channel DACs driver" depends on SPI help Say yes here to build support for Analog Devices AD5444, AD5446, - AD5512A, AD5542A, AD5543, AD5553, AD5601, AD5611, AD5620, AD5621, - AD5640, AD5660, AD5662 DACs. + AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5601, AD5611, AD5620, + AD5621, AD5640, AD5660, AD5662 DACs. To compile this driver as a module, choose M here: the module will be called ad5446.
Signature · 1 line
1.7.9.5
Re: [PATCH v2 11/11] staging:iio:dac:ad5446: Update Kconfig entry
Quoted 6 lines · Lars-Peter Clausen
There is one device supported by the driver which is not listed in the
Kconfighelp test. This patch adds it. Also we are past the point were we can possible fit all devices supported by the driver in theKconfigentry title, so just list the initial device that was supported by this driver and note that similar devices are supported as well.
Nice cleanup series.
Quoted 1 line
Signed-off-by Lars-Peter Clausen <[email protected]>
Quoted 24 lines
--- drivers/staging/iio/dac/Kconfig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)drivers/staging/iio/dac/Kconfig +3
-3@@ -56,12 +56,12 @@ config AD5624R_SPI AD5664R converters (DAC). This driver uses the common SPI interface. config AD5446 - tristate "Analog Devices AD5444/6, AD5620/40/60 and AD5542A/12A DAC SPI driver" + tristate "Analog Devices AD5446 and similar single channel DACs driver" depends on SPI help Say yes here to build support for Analog Devices AD5444, AD5446, - AD5512A, AD5542A, AD5543, AD5553, AD5601, AD5611, AD5620, AD5621, - AD5640, AD5660, AD5662 DACs. + AD5512A, AD5541A, AD5542A, AD5543, AD5553, AD5601, AD5611, AD5620, + AD5621, AD5640, AD5660, AD5662 DACs. To compile this driver as a module, choose M here: the module will be called ad5446.