Commit 5b30937b authored by Nuno Sa's avatar Nuno Sa Committed by Jonathan Cameron

iio: adc: ad9467: add backend test mode helpers

Group the backend configurations to be done in preparing and stopping
calibration in two new helpers analogous to ad9467_testmode_set(). This
is in preparation for adding support for debugFS test_mode where
we need similar configurations as in the calibration process.
Signed-off-by: default avatarNuno Sa <nuno.sa@analog.com>
Link: https://patch.msgid.link/20240802-dev-iio-backend-add-debugfs-v2-7-4cb62852f0d0@analog.comSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent c031fee0
......@@ -494,11 +494,49 @@ static int ad9467_testmode_set(struct ad9467_state *st, unsigned int chan,
AN877_ADC_TRANSFER_SYNC);
}
static int ad9647_calibrate_prepare(struct ad9467_state *st)
static int ad9467_backend_testmode_on(struct ad9467_state *st,
unsigned int chan,
enum iio_backend_test_pattern pattern)
{
struct iio_backend_data_fmt data = {
.enable = false,
};
int ret;
ret = iio_backend_data_format_set(st->back, chan, &data);
if (ret)
return ret;
ret = iio_backend_test_pattern_set(st->back, chan, pattern);
if (ret)
return ret;
return iio_backend_chan_enable(st->back, chan);
}
static int ad9467_backend_testmode_off(struct ad9467_state *st,
unsigned int chan)
{
struct iio_backend_data_fmt data = {
.enable = true,
.sign_extend = true,
};
int ret;
ret = iio_backend_chan_disable(st->back, chan);
if (ret)
return ret;
ret = iio_backend_test_pattern_set(st->back, chan,
IIO_BACKEND_NO_TEST_PATTERN);
if (ret)
return ret;
return iio_backend_data_format_set(st->back, chan, &data);
}
static int ad9647_calibrate_prepare(struct ad9467_state *st)
{
unsigned int c;
int ret;
......@@ -511,16 +549,8 @@ static int ad9647_calibrate_prepare(struct ad9467_state *st)
if (ret)
return ret;
ret = iio_backend_data_format_set(st->back, c, &data);
if (ret)
return ret;
ret = iio_backend_test_pattern_set(st->back, c,
IIO_BACKEND_ADI_PRBS_9A);
if (ret)
return ret;
ret = iio_backend_chan_enable(st->back, c);
ret = ad9467_backend_testmode_on(st, c,
IIO_BACKEND_ADI_PRBS_9A);
if (ret)
return ret;
}
......@@ -601,24 +631,11 @@ static int ad9467_calibrate_apply(struct ad9467_state *st, unsigned int val)
static int ad9647_calibrate_stop(struct ad9467_state *st)
{
struct iio_backend_data_fmt data = {
.sign_extend = true,
.enable = true,
};
unsigned int c, mode;
int ret;
for (c = 0; c < st->info->num_channels; c++) {
ret = iio_backend_chan_disable(st->back, c);
if (ret)
return ret;
ret = iio_backend_test_pattern_set(st->back, c,
IIO_BACKEND_NO_TEST_PATTERN);
if (ret)
return ret;
ret = iio_backend_data_format_set(st->back, c, &data);
ret = ad9467_backend_testmode_off(st, c);
if (ret)
return ret;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment