iio:ad5064: Add support for LTC2617
Subsystems (2)
Based on the discussion after submitting my patch to add a new driver for LTC2617, I've now implemented the support for the LTC2617 (and similar) devices into the AD5064 driver.
I've split the implementation into two patches. The first patch adds basic support for LTC2617. The second patch fixes the power down functionality because the LTC handle that differently than the AD devices.
Datasheet for LTC devices:
LTC2606, LTC2616, LTC2626: http://www.linear.com/docs/6398
LTC2607, LTC2617, LTC2627: http://www.linear.com/docs/8977
LTC2709, LTC2619, LTC2629: http://www.linear.com/docs/8477
Best regards,
Marc
[PATCH 1/2] iio:ad5064: Add support for ltc2617 and similar devices [PATCH 2/2] iio:ad5064: Fix power down operation with LTC2617
PATCH 1/2 iio:ad5064: Add support for ltc2617 and similar devices
The Linear Technology LTC2606, LTC2607, LTC2609, LTC2616, LTC2617, LTC2619, LTC2626, LTC2627 and LTC2629 devices are very similar to the AD5064 device.
This patch adds basic support for those devices.
--- drivers/iio/dac/ad5064.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5064.c +76 -1
@@ -1,6 +1,8 @@/* * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5629R, -* AD5648, AD5666, AD5668, AD5669R Digital to analog converters driver +* AD5648, AD5666, AD5668, AD5669R, LTC2606, LTC2607, LTC2609, LTC2616, +* LTC2617, LTC2619, LTC2626, LTC2627, LTC2629 +* Digital to analog converters driver * * Copyright 2011 Analog Devices Inc. *
@@ -123,6 +125,15 @@ enum ad5064_type {ID_AD5668_2 ,ID_AD5669_1 ,ID_AD5669_2 , +ID_LTC2606 , +ID_LTC2607 , +ID_LTC2609 , +ID_LTC2616 , +ID_LTC2617 , +ID_LTC2619 , +ID_LTC2626 , +ID_LTC2627 , + ID_LTC2629, }; static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
@@ -339,6 +350,7 @@ static DECLARE_AD5065_CHANNELS(ad5045_channels, 14, 6); static DECLARE_AD5065_CHANNELS(ad5065_channels, 16, 4); static DECLARE_AD5064_CHANNELS(ad5629_channels, 12, 4); +static DECLARE_AD5064_CHANNELS(ltc2617_channels, 14, 2); static DECLARE_AD5064_CHANNELS(ad5669_channels, 16, 0);static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
@@ -449,6 +461,60 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = { .channels = ad5669_channels, .num_channels = 8, }, + [ID_LTC2606] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ad5669_channels, + .num_channels = 1, + }, + [ID_LTC2607] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ad5669_channels, + .num_channels = 2, + }, + [ID_LTC2609] = { + .shared_vref = false, + .internal_vref = 0, + .channels = ad5669_channels, + .num_channels = 4, + }, + [ID_LTC2616] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ltc2617_channels, + .num_channels = 1, + }, + [ID_LTC2617] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ltc2617_channels, + .num_channels = 2, + }, + [ID_LTC2619] = { + .shared_vref = false, + .internal_vref = 0, + .channels = ltc2617_channels, + .num_channels = 4, + }, + [ID_LTC2626] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ad5629_channels, + .num_channels = 1, + }, + [ID_LTC2627] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ad5629_channels, + .num_channels = 2, + }, + [ID_LTC2629] = { + .shared_vref = false, + .internal_vref = 0, + .channels = ad5629_channels, + .num_channels = 4, + }, };static inline unsigned int ad5064_num_vref (struct ad5064_state *st)
@@ -660,6 +726,15 @@ static const struct i2c_device_id ad5064_i2c_ids[] = { {"ad5669-1", ID_AD5669_1}, {"ad5669-2", ID_AD5669_2}, {"ad5669-3", ID_AD5669_2}, /* similar enough to ad5669-2 */ + {"ltc2606", ID_LTC2606}, + {"ltc2607", ID_LTC2607}, + {"ltc2609", ID_LTC2609}, + {"ltc2616", ID_LTC2616}, + {"ltc2617", ID_LTC2617}, + {"ltc2619", ID_LTC2619}, + {"ltc2626", ID_LTC2626}, + {"ltc2627", ID_LTC2627}, + {"ltc2629", ID_LTC2629}, {} };MODULE_DEVICE_TABLE (i2c, ad5064_i2c_ids);
Signature · 1 line
1.9.1
PATCH 2/2 iio:ad5064: Fix power down operation with LTC2617
In reply to Marc AndreLTC2617 device (and the other devices from Linear Technology) have a different behavior for power down than the Analog Device devices. The command must be addressed with the right channel address. Also, only a single power down mode (90k to ground) is available.
This patch adjusts the driver to handle the LTC case specifically.
I decided to implement the different power down modes as a separate iio_ext_info structure. An alternative implementation would be to set the iio_ext_info structure not const and then adjust the enum in the probe() function based on a chip_info setting. In my view this would be less ideal because it uses more memory for the kernel.
The different addressing is handled with a flag in the chip_info structure. Alternatively we could implement a copy of all set_powerdown_...() functions. I think this is less nice.
--- drivers/iio/dac/ad5064.c | 120 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 38 deletions(-)
drivers/iio/dac/ad5064.c +82 -38
@@ -1,8 +1,8 @@/* * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5629R, * AD5648, AD5666, AD5668, AD5669R, LTC2606, LTC2607, LTC2609, LTC2616, -* LTC2617, LTC2619, LTC2626, LTC2627, LTC2629 -* Digital to analog converters driver +* LTC2617, LTC2619, LTC2626, LTC2627, LTC2629 Digital to analog converters +* driver * * Copyright 2011 Analog Devices Inc. *
@@ -52,10 +52,12 @@/** * struct ad5064_chip_info - chip specific information * @shared_vref: whether the vref supply is shared between channels -* @internal_vref: internal reference voltage. 0 if the chip has no internal -* vref. +* @internal_vref: internal reference voltage. 0 if the chip has no +internal vref. * @channel: channel specification * @num_channels: number of channels +* @powerdown_ltc: Use alternative power down addressing as required by +* ltc2617 and others. */ struct ad5064_chip_info {
@@ -63,6 +65,7 @@ struct ad5064_chip_info {unsigned long internal_vref;const struct iio_chan_spec *channels;unsigned int num_channels; +bool powerdown_ltc; };struct ad5064_state ;
@@ -147,15 +150,21 @@ static int ad5064_write(struct ad5064_state *st, unsigned int cmd,static int ad5064_sync_powerdown_mode (struct ad5064_state *st,const struct iio_chan_spec *chan) { -unsigned int val; +unsigned int val, address;int ret; - val = (0x1 << chan->address); +if (st->chip_info->powerdown_ltc) { + val =0 ; + address = chan->address; + }else { + address =0 ; + val = (0x1 << chan->address); -if (st->pwr_down[chan->channel]) - val |= st->pwr_down_mode[chan->channel] <<8 ; +if (st->pwr_down[chan->channel]) + val |= st->pwr_down_mode[chan->channel] <<8 ; + } - ret =ad5064_write (st,AD5064_CMD_POWERDOWN_DAC ,0 , val,0 ); + ret =ad5064_write (st,AD5064_CMD_POWERDOWN_DAC , address, val,0 );return ret; }
@@ -166,6 +175,10 @@ static const char * const ad5064_powerdown_modes[] = { "three_state", }; +static const char *const ltc2617_powerdown_modes[] = { +"90kohm_to_gnd" , +}; +static int ad5064_get_powerdown_mode (struct iio_dev *indio_dev,const struct iio_chan_spec *chan) {
@@ -196,6 +209,13 @@ static const struct iio_enum ad5064_powerdown_mode_enum = { .set = ad5064_set_powerdown_mode, }; +static const struct iio_enum ltc2617_powerdown_mode_enum = { + .items = ltc2617_powerdown_modes, + .num_items =ARRAY_SIZE (ltc2617_powerdown_modes), + .get = ad5064_get_powerdown_mode, + .set = ad5064_set_powerdown_mode, +}; +static ssize_t ad5064_read_dac_powerdown (struct iio_dev *indio_dev,uintptr_t private,const struct iio_chan_spec *chan,char *buf) {
@@ -306,7 +326,19 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = { { }, }; -#define AD5064_CHANNEL (chan, addr, bits, _shift) { \ +static const struct iio_chan_spec_ext_info ltc2617_ext_info[] = { + { + .name ="powerdown" , + .read = ad5064_read_dac_powerdown, + .write = ad5064_write_dac_powerdown, + .shared =IIO_SEPARATE , + }, +IIO_ENUM ("powerdown_mode" ,IIO_SEPARATE , <c2617_powerdown_mode_enum), +IIO_ENUM_AVAILABLE ("powerdown_mode" , <c2617_powerdown_mode_enum), + { }, +}; + +#define AD5064_CHANNEL (chan, addr, bits, _shift, _ext_info) { \ .type = IIO_VOLTAGE, \ .indexed = 1, \ .output = 1, \
@@ -320,38 +352,41 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = { .storagebits = 16, \ .shift = (_shift), \ }, \ - .ext_info = ad5064_ext_info, \ + .ext_info = (_ext_info), \ } -#define DECLARE_AD5064_CHANNELS (name, bits, shift) \ +#define DECLARE_AD5064_CHANNELS (name, bits, shift, ext_info) \ const struct iio_chan_spec name[] = { \ - AD5064_CHANNEL(0, 0, bits, shift), \ - AD5064_CHANNEL(1, 1, bits, shift), \ - AD5064_CHANNEL(2, 2, bits, shift), \ - AD5064_CHANNEL(3, 3, bits, shift), \ - AD5064_CHANNEL(4, 4, bits, shift), \ - AD5064_CHANNEL(5, 5, bits, shift), \ - AD5064_CHANNEL(6, 6, bits, shift), \ - AD5064_CHANNEL(7, 7, bits, shift), \ + AD5064_CHANNEL(0, 0, bits, shift, ext_info), \ + AD5064_CHANNEL(1, 1, bits, shift, ext_info), \ + AD5064_CHANNEL(2, 2, bits, shift, ext_info), \ + AD5064_CHANNEL(3, 3, bits, shift, ext_info), \ + AD5064_CHANNEL(4, 4, bits, shift, ext_info), \ + AD5064_CHANNEL(5, 5, bits, shift, ext_info), \ + AD5064_CHANNEL(6, 6, bits, shift, ext_info), \ + AD5064_CHANNEL(7, 7, bits, shift, ext_info), \ } -#define DECLARE_AD5065_CHANNELS (name, bits, shift) \ +#define DECLARE_AD5065_CHANNELS (name, bits, shift, ext_info) \ const struct iio_chan_spec name[] = { \ - AD5064_CHANNEL(0, 0, bits, shift), \ - AD5064_CHANNEL(1, 3, bits, shift), \ + AD5064_CHANNEL(0, 0, bits, shift, ext_info), \ + AD5064_CHANNEL(1, 3, bits, shift, ext_info), \ } -static DECLARE_AD5064_CHANNELS(ad5024_channels, 12, 8); -static DECLARE_AD5064_CHANNELS(ad5044_channels, 14, 6); -static DECLARE_AD5064_CHANNELS(ad5064_channels, 16, 4); +static DECLARE_AD5064_CHANNELS(ad5024_channels, 12, 8, ad5064_ext_info); +static DECLARE_AD5064_CHANNELS(ad5044_channels, 14, 6, ad5064_ext_info); +static DECLARE_AD5064_CHANNELS(ad5064_channels, 16, 4, ad5064_ext_info); + +static DECLARE_AD5065_CHANNELS(ad5025_channels, 12, 8, ad5064_ext_info); +static DECLARE_AD5065_CHANNELS(ad5045_channels, 14, 6, ad5064_ext_info); +static DECLARE_AD5065_CHANNELS(ad5065_channels, 16, 4, ad5064_ext_info); -static DECLARE_AD5065_CHANNELS(ad5025_channels, 12, 8); -static DECLARE_AD5065_CHANNELS(ad5045_channels, 14, 6); -static DECLARE_AD5065_CHANNELS(ad5065_channels, 16, 4); +static DECLARE_AD5064_CHANNELS(ad5629_channels, 12, 4, ad5064_ext_info); +static DECLARE_AD5064_CHANNELS(ad5669_channels, 16, 0, ad5064_ext_info); -static DECLARE_AD5064_CHANNELS(ad5629_channels, 12, 4); -static DECLARE_AD5064_CHANNELS(ltc2617_channels, 14, 2); -static DECLARE_AD5064_CHANNELS(ad5669_channels, 16, 0); +static DECLARE_AD5064_CHANNELS(ltc2607_channels, 16, 0, ltc2617_ext_info); +static DECLARE_AD5064_CHANNELS(ltc2617_channels, 14, 2, ltc2617_ext_info); +static DECLARE_AD5064_CHANNELS(ltc2627_channels, 12, 4, ltc2617_ext_info);static const struct ad5064_chip_info ad5064_chip_info_tbl[] = { [ID_AD5024 ] = {
@@ -464,56 +499,65 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = { [ID_LTC2606 ] = { .shared_vref = true, .internal_vref =0 , - .channels = ad5669_channels, + .channels = ltc2607_channels, .num_channels =1 , + .powerdown_ltc = true, }, [ID_LTC2607 ] = { .shared_vref = true, .internal_vref =0 , - .channels = ad5669_channels, + .channels = ltc2607_channels, .num_channels =2 , + .powerdown_ltc = true, }, [ID_LTC2609 ] = { .shared_vref = false, .internal_vref =0 , - .channels = ad5669_channels, + .channels = ltc2607_channels, .num_channels =4 , + .powerdown_ltc = true, }, [ID_LTC2616 ] = { .shared_vref = true, .internal_vref =0 , .channels = ltc2617_channels, .num_channels =1 , + .powerdown_ltc = true, }, [ID_LTC2617 ] = { .shared_vref = true, .internal_vref =0 , .channels = ltc2617_channels, .num_channels =2 , + .powerdown_ltc = true, }, [ID_LTC2619 ] = { .shared_vref = false, .internal_vref =0 , .channels = ltc2617_channels, .num_channels =4 , + .powerdown_ltc = true, }, [ID_LTC2626 ] = { .shared_vref = true, .internal_vref =0 , - .channels = ad5629_channels, + .channels = ltc2627_channels, .num_channels =1 , + .powerdown_ltc = true, }, [ID_LTC2627 ] = { .shared_vref = true, .internal_vref =0 , - .channels = ad5629_channels, + .channels = ltc2627_channels, .num_channels =2 , + .powerdown_ltc = true, }, [ID_LTC2629 ] = { .shared_vref = false, .internal_vref =0 , - .channels = ad5629_channels, + .channels = ltc2627_channels, .num_channels =4 , + .powerdown_ltc = true, }, };
Signature · 1 line
1.9.1
Re: [PATCH 2/2] iio:ad5064: Fix power down operation with LTC2617
Quoted 4 lines · Marc Andre
LTC2617 device (and the other devices from Linear Technology) have a different behavior for power down than the Analog Device devices. The command must be addressed with the right channel address. Also, only a single power down mode (90k to ground) is available.
please update Documentation/ABI/testing/sysfs-bus-iio for the 90k_to_gnd mode, out_voltageY_powerdown_mode
Quoted 266 lines
This patch adjusts the driver to handle the LTC case specifically.
I decided to implement the different power down modes as a separate
iio_ext_infostructure. An alternative implementation would be to set theiio_ext_infostructure not const and then adjust the enum in theprobe()function based on achip_infosetting. In my view this would be less ideal because it uses more memory for the kernel.The different addressing is handled with a flag in the
chip_infostructure. Alternatively we could implement a copy of all set_powerdown_...() functions. I think this is less nice.Signed-off-by Marc Andre <[email protected]>--- drivers/iio/dac/ad5064.c | 120 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 38 deletions(-)drivers/iio/dac/ad5064.c +82
-38@@ -1,8 +1,8 @@/* * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5629R, * AD5648, AD5666, AD5668, AD5669R, LTC2606, LTC2607, LTC2609, LTC2616, -* LTC2617, LTC2619, LTC2626, LTC2627, LTC2629 -* Digital to analog converters driver +* LTC2617, LTC2619, LTC2626, LTC2627, LTC2629 Digital to analog converters +* driver * * Copyright 2011 Analog Devices Inc. * @@ -52,10 +52,12 @@/** * struct ad5064_chip_info - chip specific information * @shared_vref: whether the vref supply is shared between channels -* @internal_vref: internal reference voltage. 0 if the chip has no internal -* vref. +* @internal_vref: internal reference voltage. 0 if the chip has no +internal vref. * @channel: channel specification * @num_channels: number of channels +* @powerdown_ltc: Use alternative power down addressing as required by +* ltc2617 and others. */ struct ad5064_chip_info {@@ -63,6 +65,7 @@ struct ad5064_chip_info {unsigned long internal_vref;const struct iio_chan_spec *channels;unsigned int num_channels; +bool powerdown_ltc; };struct ad5064_state ;@@ -147,15 +150,21 @@ static int ad5064_write(struct ad5064_state *st, unsigned int cmd,static int ad5064_sync_powerdown_mode (struct ad5064_state *st,const struct iio_chan_spec *chan) { -unsigned int val; +unsigned int val, address;int ret; - val = (0x1 << chan->address); +if (st->chip_info->powerdown_ltc) { + val =0 ; + address = chan->address; + }else { + address =0 ; + val = (0x1 << chan->address); -if (st->pwr_down[chan->channel]) - val |= st->pwr_down_mode[chan->channel] <<8 ; +if (st->pwr_down[chan->channel]) + val |= st->pwr_down_mode[chan->channel] <<8 ; + } - ret =ad5064_write (st,AD5064_CMD_POWERDOWN_DAC ,0 , val,0 ); + ret =ad5064_write (st,AD5064_CMD_POWERDOWN_DAC , address, val,0 );return ret; }@@ -166,6 +175,10 @@ static const char * const ad5064_powerdown_modes[] = { "three_state", }; +static const char *const ltc2617_powerdown_modes[] = { +"90kohm_to_gnd" , +}; +static int ad5064_get_powerdown_mode (struct iio_dev *indio_dev,const struct iio_chan_spec *chan) {@@ -196,6 +209,13 @@ static const struct iio_enum ad5064_powerdown_mode_enum = { .set = ad5064_set_powerdown_mode, }; +static const struct iio_enum ltc2617_powerdown_mode_enum = { + .items = ltc2617_powerdown_modes, + .num_items =ARRAY_SIZE (ltc2617_powerdown_modes), + .get = ad5064_get_powerdown_mode, + .set = ad5064_set_powerdown_mode, +}; +static ssize_t ad5064_read_dac_powerdown (struct iio_dev *indio_dev,uintptr_t private,const struct iio_chan_spec *chan,char *buf) {@@ -306,7 +326,19 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = { { }, }; -#define AD5064_CHANNEL (chan, addr, bits, _shift) { \ +static const struct iio_chan_spec_ext_info ltc2617_ext_info[] = { + { + .name ="powerdown" , + .read = ad5064_read_dac_powerdown, + .write = ad5064_write_dac_powerdown, + .shared =IIO_SEPARATE , + }, +IIO_ENUM ("powerdown_mode" ,IIO_SEPARATE , <c2617_powerdown_mode_enum), +IIO_ENUM_AVAILABLE ("powerdown_mode" , <c2617_powerdown_mode_enum), + { }, +}; + +#define AD5064_CHANNEL (chan, addr, bits, _shift, _ext_info) { \ .type = IIO_VOLTAGE, \ .indexed = 1, \ .output = 1, \@@ -320,38 +352,41 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = { .storagebits = 16, \ .shift = (_shift), \ }, \ - .ext_info = ad5064_ext_info, \ + .ext_info = (_ext_info), \ } -#define DECLARE_AD5064_CHANNELS (name, bits, shift) \ +#define DECLARE_AD5064_CHANNELS (name, bits, shift, ext_info) \ const struct iio_chan_spec name[] = { \ - AD5064_CHANNEL(0, 0, bits, shift), \ - AD5064_CHANNEL(1, 1, bits, shift), \ - AD5064_CHANNEL(2, 2, bits, shift), \ - AD5064_CHANNEL(3, 3, bits, shift), \ - AD5064_CHANNEL(4, 4, bits, shift), \ - AD5064_CHANNEL(5, 5, bits, shift), \ - AD5064_CHANNEL(6, 6, bits, shift), \ - AD5064_CHANNEL(7, 7, bits, shift), \ + AD5064_CHANNEL(0, 0, bits, shift, ext_info), \ + AD5064_CHANNEL(1, 1, bits, shift, ext_info), \ + AD5064_CHANNEL(2, 2, bits, shift, ext_info), \ + AD5064_CHANNEL(3, 3, bits, shift, ext_info), \ + AD5064_CHANNEL(4, 4, bits, shift, ext_info), \ + AD5064_CHANNEL(5, 5, bits, shift, ext_info), \ + AD5064_CHANNEL(6, 6, bits, shift, ext_info), \ + AD5064_CHANNEL(7, 7, bits, shift, ext_info), \ } -#define DECLARE_AD5065_CHANNELS (name, bits, shift) \ +#define DECLARE_AD5065_CHANNELS (name, bits, shift, ext_info) \ const struct iio_chan_spec name[] = { \ - AD5064_CHANNEL(0, 0, bits, shift), \ - AD5064_CHANNEL(1, 3, bits, shift), \ + AD5064_CHANNEL(0, 0, bits, shift, ext_info), \ + AD5064_CHANNEL(1, 3, bits, shift, ext_info), \ } -static DECLARE_AD5064_CHANNELS(ad5024_channels, 12, 8); -static DECLARE_AD5064_CHANNELS(ad5044_channels, 14, 6); -static DECLARE_AD5064_CHANNELS(ad5064_channels, 16, 4); +static DECLARE_AD5064_CHANNELS(ad5024_channels, 12, 8, ad5064_ext_info); +static DECLARE_AD5064_CHANNELS(ad5044_channels, 14, 6, ad5064_ext_info); +static DECLARE_AD5064_CHANNELS(ad5064_channels, 16, 4, ad5064_ext_info); + +static DECLARE_AD5065_CHANNELS(ad5025_channels, 12, 8, ad5064_ext_info); +static DECLARE_AD5065_CHANNELS(ad5045_channels, 14, 6, ad5064_ext_info); +static DECLARE_AD5065_CHANNELS(ad5065_channels, 16, 4, ad5064_ext_info); -static DECLARE_AD5065_CHANNELS(ad5025_channels, 12, 8); -static DECLARE_AD5065_CHANNELS(ad5045_channels, 14, 6); -static DECLARE_AD5065_CHANNELS(ad5065_channels, 16, 4); +static DECLARE_AD5064_CHANNELS(ad5629_channels, 12, 4, ad5064_ext_info); +static DECLARE_AD5064_CHANNELS(ad5669_channels, 16, 0, ad5064_ext_info); -static DECLARE_AD5064_CHANNELS(ad5629_channels, 12, 4); -static DECLARE_AD5064_CHANNELS(ltc2617_channels, 14, 2); -static DECLARE_AD5064_CHANNELS(ad5669_channels, 16, 0); +static DECLARE_AD5064_CHANNELS(ltc2607_channels, 16, 0, ltc2617_ext_info); +static DECLARE_AD5064_CHANNELS(ltc2617_channels, 14, 2, ltc2617_ext_info); +static DECLARE_AD5064_CHANNELS(ltc2627_channels, 12, 4, ltc2617_ext_info);static const struct ad5064_chip_info ad5064_chip_info_tbl[] = { [ID_AD5024 ] = {@@ -464,56 +499,65 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = { [ID_LTC2606 ] = { .shared_vref = true, .internal_vref =0 , - .channels = ad5669_channels, + .channels = ltc2607_channels, .num_channels =1 , + .powerdown_ltc = true, }, [ID_LTC2607 ] = { .shared_vref = true, .internal_vref =0 , - .channels = ad5669_channels, + .channels = ltc2607_channels, .num_channels =2 , + .powerdown_ltc = true, }, [ID_LTC2609 ] = { .shared_vref = false, .internal_vref =0 , - .channels = ad5669_channels, + .channels = ltc2607_channels, .num_channels =4 , + .powerdown_ltc = true, }, [ID_LTC2616 ] = { .shared_vref = true, .internal_vref =0 , .channels = ltc2617_channels, .num_channels =1 , + .powerdown_ltc = true, }, [ID_LTC2617 ] = { .shared_vref = true, .internal_vref =0 , .channels = ltc2617_channels, .num_channels =2 , + .powerdown_ltc = true, }, [ID_LTC2619 ] = { .shared_vref = false, .internal_vref =0 , .channels = ltc2617_channels, .num_channels =4 , + .powerdown_ltc = true, }, [ID_LTC2626 ] = { .shared_vref = true, .internal_vref =0 , - .channels = ad5629_channels, + .channels = ltc2627_channels, .num_channels =1 , + .powerdown_ltc = true, }, [ID_LTC2627 ] = { .shared_vref = true, .internal_vref =0 , - .channels = ad5629_channels, + .channels = ltc2627_channels, .num_channels =2 , + .powerdown_ltc = true, }, [ID_LTC2629 ] = { .shared_vref = false, .internal_vref =0 , - .channels = ad5629_channels, + .channels = ltc2627_channels, .num_channels =4 , + .powerdown_ltc = true, }, };
Signature · 2 lines
Peter Meerwald +43-664-2444418 (mobile)
Quoted 9 lines · Marc Andre
Based on the discussion after submitting my patch to add a new driver for LTC2617, I've now implemented the support for the LTC2617 (and similar) devices into the AD5064 driver.
I've split the implementation into two patches. The first patch adds basic support for LTC2617. The second patch fixes the power down functionality because the LTC handle that differently than the AD devices.
Quoted 4 lines
Datasheet for LTC devices:
LTC2606, LTC2616, LTC2626: http://www.linear.com/docs/6398
LTC2607, LTC2617, LTC2627: http://www.linear.com/docs/8977
LTC2709, LTC2619, LTC2629: http://www.linear.com/docs/8477
Please add this links to the commit message of 1/2 patch. Cover letter will most likely be lost in the linux-iio list archives.
I've updated the patches according to the feedback of Peter and Daniel.
- Added datasheet links to the description of patch 1/2.
- Added 90kohm_to_gnd to ABI documentation sysfs-bus-iio
**** Original intro *****
Based on the discussion after submitting my patch to add a new driver for LTC2617, I've now implemented the support for the LTC2617 (and similar) devices into the AD5064 driver.
I've split the implementation into two patches. The first patch adds basic support for LTC2617. The second patch fixes the power down functionality because the LTC handle that differently than the AD devices.
[PATCH v2 1/2] iio:ad5064: Add support for ltc2617 and similar devices [PATCH v2 2/2] iio:ad5064: Fix power down operation with LTC2617
Best Regards,
Marc
PATCH v2 1/2 iio:ad5064: Add support for ltc2617 and similar devices
The Linear Technology LTC2606, LTC2607, LTC2609, LTC2616, LTC2617, LTC2619, LTC2626, LTC2627 and LTC2629 devices are very similar to the AD5064 device.
This patch adds basic support for those devices.
Datasheet for LTC devices:
LTC2606, LTC2616, LTC2626: http://www.linear.com/docs/6398
LTC2607, LTC2617, LTC2627: http://www.linear.com/docs/8977
LTC2709, LTC2619, LTC2629: http://www.linear.com/docs/8477
--- drivers/iio/dac/ad5064.c | 77 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 76 insertions(+), 1 deletion(-)
drivers/iio/dac/ad5064.c +76 -1
@@ -1,6 +1,8 @@/* * AD5024, AD5025, AD5044, AD5045, AD5064, AD5064-1, AD5065, AD5628, AD5629R, -* AD5648, AD5666, AD5668, AD5669R Digital to analog converters driver +* AD5648, AD5666, AD5668, AD5669R, LTC2606, LTC2607, LTC2609, LTC2616, +* LTC2617, LTC2619, LTC2626, LTC2627, LTC2629 +* Digital to analog converters driver * * Copyright 2011 Analog Devices Inc. *
@@ -123,6 +125,15 @@ enum ad5064_type {ID_AD5668_2 ,ID_AD5669_1 ,ID_AD5669_2 , +ID_LTC2606 , +ID_LTC2607 , +ID_LTC2609 , +ID_LTC2616 , +ID_LTC2617 , +ID_LTC2619 , +ID_LTC2626 , +ID_LTC2627 , + ID_LTC2629, }; static int ad5064_write(struct ad5064_state *st, unsigned int cmd,
@@ -339,6 +350,7 @@ static DECLARE_AD5065_CHANNELS(ad5045_channels, 14, 6); static DECLARE_AD5065_CHANNELS(ad5065_channels, 16, 4); static DECLARE_AD5064_CHANNELS(ad5629_channels, 12, 4); +static DECLARE_AD5064_CHANNELS(ltc2617_channels, 14, 2); static DECLARE_AD5064_CHANNELS(ad5669_channels, 16, 0);static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
@@ -449,6 +461,60 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = { .channels = ad5669_channels, .num_channels = 8, }, + [ID_LTC2606] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ad5669_channels, + .num_channels = 1, + }, + [ID_LTC2607] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ad5669_channels, + .num_channels = 2, + }, + [ID_LTC2609] = { + .shared_vref = false, + .internal_vref = 0, + .channels = ad5669_channels, + .num_channels = 4, + }, + [ID_LTC2616] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ltc2617_channels, + .num_channels = 1, + }, + [ID_LTC2617] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ltc2617_channels, + .num_channels = 2, + }, + [ID_LTC2619] = { + .shared_vref = false, + .internal_vref = 0, + .channels = ltc2617_channels, + .num_channels = 4, + }, + [ID_LTC2626] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ad5629_channels, + .num_channels = 1, + }, + [ID_LTC2627] = { + .shared_vref = true, + .internal_vref = 0, + .channels = ad5629_channels, + .num_channels = 2, + }, + [ID_LTC2629] = { + .shared_vref = false, + .internal_vref = 0, + .channels = ad5629_channels, + .num_channels = 4, + }, };static inline unsigned int ad5064_num_vref (struct ad5064_state *st)
@@ -660,6 +726,15 @@ static const struct i2c_device_id ad5064_i2c_ids[] = { {"ad5669-1", ID_AD5669_1}, {"ad5669-2", ID_AD5669_2}, {"ad5669-3", ID_AD5669_2}, /* similar enough to ad5669-2 */ + {"ltc2606", ID_LTC2606}, + {"ltc2607", ID_LTC2607}, + {"ltc2609", ID_LTC2609}, + {"ltc2616", ID_LTC2616}, + {"ltc2617", ID_LTC2617}, + {"ltc2619", ID_LTC2619}, + {"ltc2626", ID_LTC2626}, + {"ltc2627", ID_LTC2627}, + {"ltc2629", ID_LTC2629}, {} };MODULE_DEVICE_TABLE (i2c, ad5064_i2c_ids);
Signature · 1 line
1.9.1
PATCH v2 2/2 iio:ad5064: Fix power down operation with LTC2617
In reply to Marc AndreLTC2617 device (and the other devices from Linear Technology) have a different behavior for power down than the Analog Device devices. The command must be addressed with the right channel address. Also, only a single power down mode (90k to ground) is available.
This patch adjusts the driver to handle the LTC case specifically.
I decided to implement the different power down modes as a separate iio_ext_info structure. An alternative implementation would be to set the iio_ext_info structure not const and then adjust the enum in the probe() function based on a chip_info setting. In my view this would be less ideal because it uses more memory for the kernel.
The different addressing is handled with a flag in the chip_info structure. Alternatively we could implement a copy of all set_powerdown_...() functions. I think this is less nice.
I've added the new setting 90kohm_to_gnd to the ABI sysfs-bus-iio documentation.
--- Documentation/ABI/testing/sysfs-bus-iio | 1 + drivers/iio/dac/ad5064.c | 120 ++++++++++++++++++++++---------- 2 files changed, 83 insertions(+), 38 deletions(-)
Documentation/ABI/testing/sysfs-bus-iio +1 -0
@@ -496,6 +496,7 @@ Description: 1kohm_to_gnd: connected to ground via an 1kOhm resistor, 6kohm_to_gnd: connected to ground via a 6kOhm resistor, 20kohm_to_gnd: connected to ground via a 20kOhm resistor, + 90kohm_to_gnd: connected to ground via a 90kOhm resistor, 100kohm_to_gnd: connected to ground via an 100kOhm resistor, 500kohm_to_gnd: connected to ground via a 500kOhm resistor, three_state: left floating.
drivers/iio/dac/ad5064.c +82 -38
234 lines not on this page · raw message
Signature · 1 line
1.9.1
Lars-Peter Clausen
Acked-byQuoted 4 lines · Marc Andre
I've updated the patches according to the feedback of Peter and Daniel.
- Added datasheet links to the description of patch 1/2.
- Added 90kohm_to_gnd to ABI documentation sysfs-bus-iio
Looks good to me. You can add
I'd prefer though if you change the order of the patches. Patch 1 refactor the macros so you can specify the ext_info. Patch 2 add support for the LTC devices, this way we don't end up with a intermediate step where power-down is broken.
Another thing, if you send a new version of a patch series, don't send it as a response to the old series. Things tend to get lost that way in nested threads.
Quoted 21 lines
**** Original intro *****
Based on the discussion after submitting my patch to add a new driver for LTC2617, I've now implemented the support for the LTC2617 (and similar) devices into the AD5064 driver.
I've split the implementation into two patches. The first patch adds basic support for LTC2617. The second patch fixes the power down functionality because the LTC handle that differently than the AD devices.
[PATCH v2 1/2] iio:ad5064: Add support for ltc2617 and similar devices [PATCH v2 2/2] iio:ad5064: Fix power down operation with LTC2617
Best Regards,
Marc
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 5 lines · Lars-Peter Clausen
Quoted 4 lines · Marc Andre
I've updated the patches according to the feedback of Peter and Daniel.
- Added datasheet links to the description of patch 1/2.
- Added 90kohm_to_gnd to ABI documentation sysfs-bus-iio
Quoted 8 lines
Looks good to me. You can add
I'd prefer though if you change the order of the patches. Patch 1 refactor the macros so you can specify the
ext_info. Patch 2 add support for the LTC devices, this way we don't end up with a intermediate step where power-down is broken.
I will do that, but I am currently traveling on a business trip, I will send it towards the end of the week. I assume I can put the Acked-by on as long as the code doesn't change.
Quoted 25 lines
Quoted 14 lines
**** Original intro *****
Based on the discussion after submitting my patch to add a new driver for LTC2617, I've now implemented the support for the LTC2617 (and similar) devices into the AD5064 driver.
I've split the implementation into two patches. The first patch adds basic support for LTC2617. The second patch fixes the power down functionality because the LTC handle that differently than the AD devices.
[PATCH v2 1/2] iio:ad5064: Add support for ltc2617 and similar devices [PATCH v2 2/2] iio:ad5064: Fix power down operation with LTC2617
Quoted 7 lines
Best Regards,
Marc
--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-iio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 11 lines
Marc André, André-Netline eBusiness-Solutions André-Netline Könizstr. 161 CH-3097 Liebefeld Tel. 031 974 16 66 Fax: 031 974 16 65 [email protected] http://www.netline.ch