Skip to content

Commit

Permalink
drivers:iio:frequency: Add fir85_enable attribute
Browse files Browse the repository at this point in the history
fir85_enable is added as an attribute to extended info.

Signed-off-by: Mihail Chindris <[email protected]>
  • Loading branch information
Mihail Chindris authored and commodo committed Oct 29, 2020
1 parent 2633fd7 commit 3c7fe6b
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions drivers/iio/frequency/ad9162.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ enum {
AD916x_NCO_FREQ,
AD916x_SAMPLING_FREQUENCY,
AD916x_TEMP_CALIB,
AD916x_FIR85_ENABLE,
};

struct ad916x_chip_info {
Expand Down Expand Up @@ -594,6 +595,7 @@ static ssize_t ad916x_write_ext(struct iio_dev *indio_dev,
u64 samp_freq_hz;
/* en just because we have to pass it to ad916x_dc_test_get_mod */
int ret, en;
bool fir85_en;

mutex_lock(&st->lock);
switch ((u32)private) {
Expand Down Expand Up @@ -633,6 +635,12 @@ static ssize_t ad916x_write_ext(struct iio_dev *indio_dev,
conv->temp_slope = ad9162_temp_slope(conv->temp_calib, code);
conv->temp_calib_code = code;
break;
case AD916x_FIR85_ENABLE:
ret = kstrtobool(buf, &fir85_en);
if (ret)
break;
ret = ad916x_fir85_set_enable(&st->dac_h, (int)fir85_en);
break;
default:
ret = -EINVAL;
break;
Expand All @@ -651,6 +659,7 @@ static ssize_t ad916x_read_ext(struct iio_dev *indio_dev,
struct ad9162_state *st = to_ad916x_state(conv);
s64 freq;
u16 test_word;
int fir85_en;
int ret, dc_test_en;

mutex_lock(&st->lock);
Expand All @@ -664,6 +673,10 @@ static ssize_t ad916x_read_ext(struct iio_dev *indio_dev,
case AD916x_SAMPLING_FREQUENCY:
ret = sprintf(buf, "%llu\n", ad9162_get_data_clk(conv));
break;
case AD916x_FIR85_ENABLE:
ad916x_fir85_get_enable(&st->dac_h, &fir85_en);
ret = sprintf(buf, "%d\n", !!fir85_en);
break;
default:
ret = -EINVAL;
break;
Expand Down Expand Up @@ -698,6 +711,8 @@ static const struct iio_chan_spec_ext_info ad916x_ext_info[] = {
_AD916x_CHAN_EXT_INFO("nco_frequency", AD916x_NCO_FREQ, IIO_SEPARATE),
_AD916x_CHAN_EXT_INFO("sampling_frequency", AD916x_SAMPLING_FREQUENCY,
IIO_SHARED_BY_ALL),
_AD916x_CHAN_EXT_INFO("fir85_enable", AD916x_FIR85_ENABLE,
IIO_SHARED_BY_ALL),
{},
};

Expand Down

0 comments on commit 3c7fe6b

Please sign in to comment.