Skip to content

Commit

Permalink
iio: frequency: cf_axi_dds: Fix bug caused by probe sequence ordering
Browse files Browse the repository at this point in the history
For AD9361 based designs the cf_axi_adc in combination ad9361_conv driver
controls FORMAT and RATECTRL registers. in case the cf_axi_dds driver
probes after the the cf_axi_adc settings might be overwritten. To avoid
this scenario add an option to skip writing these shared registers for
such platforms.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
  • Loading branch information
mhennerich authored and commodo committed Aug 6, 2018
1 parent dd100de commit 8bbac0f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions drivers/iio/frequency/cf_axi_dds.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,7 @@ static void dds_converter_put(struct device *conv_dev)
struct axidds_core_info {
unsigned int version;
bool standalone;
bool rate_format_skip_en;
struct cf_axi_dds_chip_info *chip_info;
unsigned int data_format;
unsigned int rate;
Expand All @@ -1197,20 +1198,23 @@ static const struct axidds_core_info ad9122_6_00_a_info = {
static const struct axidds_core_info ad9361_6_00_a_info = {
.version = PCORE_VERSION(9, 0, 'a'),
.standalone = true,
.rate_format_skip_en = true, /* Set by the ad936x_conv driver */
.rate = 3,
.chip_info = &cf_axi_dds_chip_info_ad9361,
};

static const struct axidds_core_info ad9364_6_00_a_info = {
.version = PCORE_VERSION(9, 0, 'a'),
.standalone = true,
.rate_format_skip_en = true, /* Set by the ad936x_conv driver */
.rate = 1,
.chip_info = &cf_axi_dds_chip_info_ad9364,
};

static const struct axidds_core_info ad9361x2_6_00_a_info = {
.version = PCORE_VERSION(9, 0, 'a'),
.standalone = true,
.rate_format_skip_en = true, /* Set by the ad936x_conv driver */
.rate = 3,
.chip_info = &cf_axi_dds_chip_info_ad9361x2,
};
Expand Down Expand Up @@ -1407,7 +1411,8 @@ static int cf_axi_dds_probe(struct platform_device *pdev)
else
rate = 1;

dds_write(st, ADI_REG_RATECNTRL, ADI_RATE(rate));
if (info && !info->rate_format_skip_en)
dds_write(st, ADI_REG_RATECNTRL, ADI_RATE(rate));

if (conv) {
ret = conv->setup(conv);
Expand All @@ -1429,7 +1434,9 @@ static int cf_axi_dds_probe(struct platform_device *pdev)
ctrl_2 |= ADI_DATA_FORMAT;

cf_axi_dds_stop(st);
dds_write(st, ADI_REG_CNTRL_2, ctrl_2);

if (info && !info->rate_format_skip_en)
dds_write(st, ADI_REG_CNTRL_2, ctrl_2);

cf_axi_dds_datasel(st, -1, DATA_SEL_DDS);

Expand Down

0 comments on commit 8bbac0f

Please sign in to comment.