Skip to content

Commit

Permalink
iio: ad9361: Highlight selected delay in interface tuning diagnostics
Browse files Browse the repository at this point in the history
For diagnostic purposes it is useful to highlight the selected clock or
data delay. Indicate the chosen delay in the diagnostic by a 'O' character.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
  • Loading branch information
larsclausen committed Jan 23, 2018
1 parent 1f308b9 commit 0a372f6
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions drivers/iio/adc/ad9361_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,11 @@ static int ad9361_dig_tune_iodelay(struct ad9361_rf_phy *phy, bool tx)
}

static void ad9361_dig_tune_verbose_print(struct ad9361_rf_phy *phy,
u8 field[][16], bool tx)
u8 field[][16], bool tx,
int sel_clk, int sel_data)
{
int i, j;
char c;

pr_info("SAMPL CLK: %lu tuning: %s\n",
clk_get_rate(phy->clks[RX_SAMPL_CLK]), tx ? "TX" : "RX");
Expand All @@ -428,7 +430,14 @@ static void ad9361_dig_tune_verbose_print(struct ad9361_rf_phy *phy,
for (i = 0; i < 2; i++) {
pr_info("%x:", i);
for (j = 0; j < 16; j++) {
pr_cont("%c ", (field[i][j] ? '#' : 'o'));
if (field[i][j])
c = '#';
else if ((i == 0 && j == sel_data) ||
(i == 1 && j == sel_clk))
c = 'O';
else
c = 'o';
pr_cont("%c ", c);
}
pr_cont("\n");
}
Expand Down Expand Up @@ -470,20 +479,22 @@ static int ad9361_dig_tune_delay(struct ad9361_rf_phy *phy,
}

if ((flags & BE_MOREVERBOSE) && max_freq) {
ad9361_dig_tune_verbose_print(phy, field, tx);
ad9361_dig_tune_verbose_print(phy, field, tx, -1, -1);
}
}

c0 = ad9361_find_opt(&field[0][0], 16, &s0);
c1 = ad9361_find_opt(&field[1][0], 16, &s1);

if (!c0 && !c1) {
ad9361_dig_tune_verbose_print(phy, field, tx);
ad9361_dig_tune_verbose_print(phy, field, tx, -1, -1);
dev_err(&phy->spi->dev, "%s: Tuning %s FAILED!", __func__,
tx ? "TX" : "RX");
return -EIO;
} else if (flags & BE_VERBOSE) {
ad9361_dig_tune_verbose_print(phy, field, tx);
ad9361_dig_tune_verbose_print(phy, field, tx,
c1 > c0 ? (s1 + c1 / 2) : -1,
c1 > c0 ? -1 : (s0 + c0 / 2));
}

if (c1 > c0)
Expand Down

0 comments on commit 0a372f6

Please sign in to comment.