@@ -113,12 +113,16 @@ enum ad5064_type {
113113 ID_AD5065 ,
114114 ID_AD5628_1 ,
115115 ID_AD5628_2 ,
116+ ID_AD5629_1 ,
117+ ID_AD5629_2 ,
116118 ID_AD5648_1 ,
117119 ID_AD5648_2 ,
118120 ID_AD5666_1 ,
119121 ID_AD5666_2 ,
120122 ID_AD5668_1 ,
121123 ID_AD5668_2 ,
124+ ID_AD5669_1 ,
125+ ID_AD5669_2 ,
122126};
123127
124128static int ad5064_write (struct ad5064_state * st , unsigned int cmd ,
@@ -291,7 +295,7 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = {
291295 { },
292296};
293297
294- #define AD5064_CHANNEL (chan , addr , bits ) { \
298+ #define AD5064_CHANNEL (chan , addr , bits , _shift ) { \
295299 .type = IIO_VOLTAGE, \
296300 .indexed = 1, \
297301 .output = 1, \
@@ -303,36 +307,39 @@ static const struct iio_chan_spec_ext_info ad5064_ext_info[] = {
303307 .sign = 'u', \
304308 .realbits = (bits), \
305309 .storagebits = 16, \
306- .shift = 20 - bits , \
310+ .shift = (_shift) , \
307311 }, \
308312 .ext_info = ad5064_ext_info, \
309313}
310314
311- #define DECLARE_AD5064_CHANNELS (name , bits ) \
315+ #define DECLARE_AD5064_CHANNELS (name , bits , shift ) \
312316const struct iio_chan_spec name[] = { \
313- AD5064_CHANNEL(0, 0, bits), \
314- AD5064_CHANNEL(1, 1, bits), \
315- AD5064_CHANNEL(2, 2, bits), \
316- AD5064_CHANNEL(3, 3, bits), \
317- AD5064_CHANNEL(4, 4, bits), \
318- AD5064_CHANNEL(5, 5, bits), \
319- AD5064_CHANNEL(6, 6, bits), \
320- AD5064_CHANNEL(7, 7, bits), \
317+ AD5064_CHANNEL(0, 0, bits, shift ), \
318+ AD5064_CHANNEL(1, 1, bits, shift ), \
319+ AD5064_CHANNEL(2, 2, bits, shift ), \
320+ AD5064_CHANNEL(3, 3, bits, shift ), \
321+ AD5064_CHANNEL(4, 4, bits, shift ), \
322+ AD5064_CHANNEL(5, 5, bits, shift ), \
323+ AD5064_CHANNEL(6, 6, bits, shift ), \
324+ AD5064_CHANNEL(7, 7, bits, shift ), \
321325}
322326
323- #define DECLARE_AD5065_CHANNELS (name , bits ) \
327+ #define DECLARE_AD5065_CHANNELS (name , bits , shift ) \
324328const struct iio_chan_spec name[] = { \
325- AD5064_CHANNEL(0, 0, bits), \
326- AD5064_CHANNEL(1, 3, bits), \
329+ AD5064_CHANNEL(0, 0, bits, shift ), \
330+ AD5064_CHANNEL(1, 3, bits, shift ), \
327331}
328332
329- static DECLARE_AD5064_CHANNELS (ad5024_channels , 12 ) ;
330- static DECLARE_AD5064_CHANNELS (ad5044_channels , 14 ) ;
331- static DECLARE_AD5064_CHANNELS (ad5064_channels , 16 ) ;
333+ static DECLARE_AD5064_CHANNELS (ad5024_channels , 12 , 8 ) ;
334+ static DECLARE_AD5064_CHANNELS (ad5044_channels , 14 , 6 ) ;
335+ static DECLARE_AD5064_CHANNELS (ad5064_channels , 16 , 4 ) ;
332336
333- static DECLARE_AD5065_CHANNELS (ad5025_channels , 12 ) ;
334- static DECLARE_AD5065_CHANNELS (ad5045_channels , 14 ) ;
335- static DECLARE_AD5065_CHANNELS (ad5065_channels , 16 ) ;
337+ static DECLARE_AD5065_CHANNELS (ad5025_channels , 12 , 8 ) ;
338+ static DECLARE_AD5065_CHANNELS (ad5045_channels , 14 , 6 ) ;
339+ static DECLARE_AD5065_CHANNELS (ad5065_channels , 16 , 4 ) ;
340+
341+ static DECLARE_AD5064_CHANNELS (ad5629_channels , 12 , 4 ) ;
342+ static DECLARE_AD5064_CHANNELS (ad5669_channels , 16 , 0 ) ;
336343
337344static const struct ad5064_chip_info ad5064_chip_info_tbl [] = {
338345 [ID_AD5024 ] = {
@@ -382,6 +389,18 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
382389 .channels = ad5024_channels ,
383390 .num_channels = 8 ,
384391 },
392+ [ID_AD5629_1 ] = {
393+ .shared_vref = true,
394+ .internal_vref = 2500000 ,
395+ .channels = ad5629_channels ,
396+ .num_channels = 8 ,
397+ },
398+ [ID_AD5629_2 ] = {
399+ .shared_vref = true,
400+ .internal_vref = 5000000 ,
401+ .channels = ad5629_channels ,
402+ .num_channels = 8 ,
403+ },
385404 [ID_AD5648_1 ] = {
386405 .shared_vref = true,
387406 .internal_vref = 2500000 ,
@@ -418,6 +437,18 @@ static const struct ad5064_chip_info ad5064_chip_info_tbl[] = {
418437 .channels = ad5064_channels ,
419438 .num_channels = 8 ,
420439 },
440+ [ID_AD5669_1 ] = {
441+ .shared_vref = true,
442+ .internal_vref = 2500000 ,
443+ .channels = ad5669_channels ,
444+ .num_channels = 8 ,
445+ },
446+ [ID_AD5669_2 ] = {
447+ .shared_vref = true,
448+ .internal_vref = 5000000 ,
449+ .channels = ad5669_channels ,
450+ .num_channels = 8 ,
451+ },
421452};
422453
423454static inline unsigned int ad5064_num_vref (struct ad5064_state * st )
@@ -597,10 +628,16 @@ static int ad5064_i2c_write(struct ad5064_state *st, unsigned int cmd,
597628 unsigned int addr , unsigned int val )
598629{
599630 struct i2c_client * i2c = to_i2c_client (st -> dev );
631+ int ret ;
600632
601633 st -> data .i2c [0 ] = (cmd << 4 ) | addr ;
602634 put_unaligned_be16 (val , & st -> data .i2c [1 ]);
603- return i2c_master_send (i2c , st -> data .i2c , 3 );
635+
636+ ret = i2c_master_send (i2c , st -> data .i2c , 3 );
637+ if (ret < 0 )
638+ return ret ;
639+
640+ return 0 ;
604641}
605642
606643static int ad5064_i2c_probe (struct i2c_client * i2c ,
@@ -616,12 +653,12 @@ static int ad5064_i2c_remove(struct i2c_client *i2c)
616653}
617654
618655static const struct i2c_device_id ad5064_i2c_ids [] = {
619- {"ad5629-1" , ID_AD5628_1 },
620- {"ad5629-2" , ID_AD5628_2 },
621- {"ad5629-3" , ID_AD5628_2 }, /* similar enough to ad5629-2 */
622- {"ad5669-1" , ID_AD5668_1 },
623- {"ad5669-2" , ID_AD5668_2 },
624- {"ad5669-3" , ID_AD5668_2 }, /* similar enough to ad5669-2 */
656+ {"ad5629-1" , ID_AD5629_1 },
657+ {"ad5629-2" , ID_AD5629_2 },
658+ {"ad5629-3" , ID_AD5629_2 }, /* similar enough to ad5629-2 */
659+ {"ad5669-1" , ID_AD5669_1 },
660+ {"ad5669-2" , ID_AD5669_2 },
661+ {"ad5669-3" , ID_AD5669_2 }, /* similar enough to ad5669-2 */
625662 {}
626663};
627664MODULE_DEVICE_TABLE (i2c , ad5064_i2c_ids );
0 commit comments