Skip to content

Commit 0eaecea

Browse files
Mircea Capriorujic23
authored andcommitted
iio: adc: ad7124: Add buffered input support
This patch adds the option to enable the buffered mode for positive and negative inputs. Each option can be enabled independently. In buffered mode, the input channel feeds into a high impedance input stage of the buffer amplifier. Therefore, the input can tolerate significant source impedances and is tailored for direct connection to external resistive type sensors such as strain gages or RTDs. Signed-off-by: Mircea Caprioru <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent f1794fd commit 0eaecea

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

drivers/iio/adc/ad7124.c

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
#define AD7124_CONFIG_REF_SEL(x) FIELD_PREP(AD7124_CONFIG_REF_SEL_MSK, x)
6262
#define AD7124_CONFIG_PGA_MSK GENMASK(2, 0)
6363
#define AD7124_CONFIG_PGA(x) FIELD_PREP(AD7124_CONFIG_PGA_MSK, x)
64+
#define AD7124_CONFIG_IN_BUFF_MSK GENMASK(7, 6)
65+
#define AD7124_CONFIG_IN_BUFF(x) FIELD_PREP(AD7124_CONFIG_IN_BUFF_MSK, x)
6466

6567
/* AD7124_FILTER_X */
6668
#define AD7124_FILTER_FS_MSK GENMASK(10, 0)
@@ -108,6 +110,8 @@ struct ad7124_chip_info {
108110
struct ad7124_channel_config {
109111
enum ad7124_ref_sel refsel;
110112
bool bipolar;
113+
bool buf_positive;
114+
bool buf_negative;
111115
unsigned int ain;
112116
unsigned int vref_mv;
113117
unsigned int pga_bits;
@@ -473,6 +477,11 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
473477
else
474478
st->channel_config[channel].refsel = tmp;
475479

480+
st->channel_config[channel].buf_positive =
481+
of_property_read_bool(child, "adi,buffered-positive");
482+
st->channel_config[channel].buf_negative =
483+
of_property_read_bool(child, "adi,buffered-negative");
484+
476485
*chan = ad7124_channel_template;
477486
chan->address = channel;
478487
chan->scan_index = channel;
@@ -492,7 +501,7 @@ static int ad7124_of_parse_channel_config(struct iio_dev *indio_dev,
492501
static int ad7124_setup(struct ad7124_state *st)
493502
{
494503
unsigned int val, fclk, power_mode;
495-
int i, ret;
504+
int i, ret, tmp;
496505

497506
fclk = clk_get_rate(st->mclk);
498507
if (!fclk)
@@ -525,8 +534,12 @@ static int ad7124_setup(struct ad7124_state *st)
525534
if (ret < 0)
526535
return ret;
527536

537+
tmp = (st->channel_config[i].buf_positive << 1) +
538+
st->channel_config[i].buf_negative;
539+
528540
val = AD7124_CONFIG_BIPOLAR(st->channel_config[i].bipolar) |
529-
AD7124_CONFIG_REF_SEL(st->channel_config[i].refsel);
541+
AD7124_CONFIG_REF_SEL(st->channel_config[i].refsel) |
542+
AD7124_CONFIG_IN_BUFF(tmp);
530543
ret = ad_sd_write_reg(&st->sd, AD7124_CONFIG(i), 2, val);
531544
if (ret < 0)
532545
return ret;

0 commit comments

Comments
 (0)