Skip to content

Commit 6bc471b

Browse files
romandarianajic23
authored andcommitted
iio: adc: ad7192: Fix ac excitation feature
AC excitation enable feature exposed to user on AD7192, allowing a bit which should be 0 to be set. This feature is specific only to AD7195. AC excitation attribute moved accordingly. In the AD7195 documentation, the AC excitation enable bit is on position 22 in the Configuration register. ACX macro changed to match correct register and bit. Note that the fix tag is for the commit that moved the driver out of staging. Fixes: b581f74 ("staging: iio: adc: ad7192: move out of staging") Signed-off-by: Alisa Roman <[email protected]> Cc: [email protected] Reviewed-by: Nuno Sa <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 06c2afb commit 6bc471b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

drivers/iio/adc/ad7192.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
#define AD7192_MODE_STA_MASK BIT(20) /* Status Register transmission Mask */
6363
#define AD7192_MODE_CLKSRC(x) (((x) & 0x3) << 18) /* Clock Source Select */
6464
#define AD7192_MODE_SINC3 BIT(15) /* SINC3 Filter Select */
65-
#define AD7192_MODE_ACX BIT(14) /* AC excitation enable(AD7195 only)*/
6665
#define AD7192_MODE_ENPAR BIT(13) /* Parity Enable */
6766
#define AD7192_MODE_CLKDIV BIT(12) /* Clock divide by 2 (AD7190/2 only)*/
6867
#define AD7192_MODE_SCYCLE BIT(11) /* Single cycle conversion */
@@ -91,6 +90,7 @@
9190
/* Configuration Register Bit Designations (AD7192_REG_CONF) */
9291

9392
#define AD7192_CONF_CHOP BIT(23) /* CHOP enable */
93+
#define AD7192_CONF_ACX BIT(22) /* AC excitation enable(AD7195 only) */
9494
#define AD7192_CONF_REFSEL BIT(20) /* REFIN1/REFIN2 Reference Select */
9595
#define AD7192_CONF_CHAN(x) ((x) << 8) /* Channel select */
9696
#define AD7192_CONF_CHAN_MASK (0x7FF << 8) /* Channel select mask */
@@ -472,7 +472,7 @@ static ssize_t ad7192_show_ac_excitation(struct device *dev,
472472
struct iio_dev *indio_dev = dev_to_iio_dev(dev);
473473
struct ad7192_state *st = iio_priv(indio_dev);
474474

475-
return sysfs_emit(buf, "%d\n", !!(st->mode & AD7192_MODE_ACX));
475+
return sysfs_emit(buf, "%d\n", !!(st->conf & AD7192_CONF_ACX));
476476
}
477477

478478
static ssize_t ad7192_show_bridge_switch(struct device *dev,
@@ -513,13 +513,13 @@ static ssize_t ad7192_set(struct device *dev,
513513

514514
ad_sd_write_reg(&st->sd, AD7192_REG_GPOCON, 1, st->gpocon);
515515
break;
516-
case AD7192_REG_MODE:
516+
case AD7192_REG_CONF:
517517
if (val)
518-
st->mode |= AD7192_MODE_ACX;
518+
st->conf |= AD7192_CONF_ACX;
519519
else
520-
st->mode &= ~AD7192_MODE_ACX;
520+
st->conf &= ~AD7192_CONF_ACX;
521521

522-
ad_sd_write_reg(&st->sd, AD7192_REG_MODE, 3, st->mode);
522+
ad_sd_write_reg(&st->sd, AD7192_REG_CONF, 3, st->conf);
523523
break;
524524
default:
525525
ret = -EINVAL;
@@ -579,12 +579,11 @@ static IIO_DEVICE_ATTR(bridge_switch_en, 0644,
579579

580580
static IIO_DEVICE_ATTR(ac_excitation_en, 0644,
581581
ad7192_show_ac_excitation, ad7192_set,
582-
AD7192_REG_MODE);
582+
AD7192_REG_CONF);
583583

584584
static struct attribute *ad7192_attributes[] = {
585585
&iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr,
586586
&iio_dev_attr_bridge_switch_en.dev_attr.attr,
587-
&iio_dev_attr_ac_excitation_en.dev_attr.attr,
588587
NULL
589588
};
590589

@@ -595,6 +594,7 @@ static const struct attribute_group ad7192_attribute_group = {
595594
static struct attribute *ad7195_attributes[] = {
596595
&iio_dev_attr_filter_low_pass_3db_frequency_available.dev_attr.attr,
597596
&iio_dev_attr_bridge_switch_en.dev_attr.attr,
597+
&iio_dev_attr_ac_excitation_en.dev_attr.attr,
598598
NULL
599599
};
600600

0 commit comments

Comments
 (0)