Skip to content

Commit 8277d20

Browse files
committed
ad9361: ad9361_dig_interface_timing_analysis(): Properly setup and cleanup
Make sure that all timing analysis relevant configuration parameters have the right value. E.g. currently bist timing analysis does not work in TDD mode or when loopback mode is enabled. Also make sure to restore all configuration parameters to their previous value after the timing analysis has completed. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
1 parent 0a372f6 commit 8277d20

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

drivers/iio/adc/ad9361_conv.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,28 @@ ssize_t ad9361_dig_interface_timing_analysis(struct ad9361_rf_phy *phy,
7777
char *buf, unsigned buflen)
7878
{
7979
struct axiadc_converter *conv = spi_get_drvdata(phy->spi);
80+
unsigned int loopback, bist, ensm_state;
8081
int i, j, len = 0;
8182
u8 field[16][16];
82-
u8 ensm_state;
8383
u8 rx;
8484

8585
if (!conv)
8686
return -ENODEV;
8787

8888
dev_dbg(&phy->spi->dev, "%s:\n", __func__);
8989

90+
loopback = phy->bist_loopback_mode;
91+
bist = phy->bist_config;
9092
ensm_state = ad9361_ensm_get_state(phy);
9193
rx = ad9361_spi_read(phy->spi, REG_RX_CLOCK_DATA_DELAY);
9294

95+
/* Mute TX, we don't want to transmit the PRBS */
96+
ad9361_tx_mute(phy, 1);
97+
98+
if (!phy->pdata->fdd)
99+
ad9361_set_ensm_mode(phy, true, false);
100+
101+
ad9361_bist_loopback(phy, 0);
93102
ad9361_bist_prbs(phy, BIST_INJ_RX);
94103

95104
for (i = 0; i < 16; i++) {
@@ -101,9 +110,14 @@ ssize_t ad9361_dig_interface_timing_analysis(struct ad9361_rf_phy *phy,
101110

102111
ad9361_ensm_force_state(phy, ENSM_STATE_ALERT);
103112
ad9361_spi_write(phy->spi, REG_RX_CLOCK_DATA_DELAY, rx);
113+
ad9361_bist_loopback(phy, loopback);
114+
ad9361_spi_write(phy->spi, REG_BIST_CONFIG, bist);
115+
116+
if (!phy->pdata->fdd)
117+
ad9361_set_ensm_mode(phy, phy->pdata->fdd, phy->pdata->ensm_pin_ctrl);
104118
ad9361_ensm_restore_state(phy, ensm_state);
105119

106-
ad9361_bist_prbs(phy, BIST_DISABLE);
120+
ad9361_tx_mute(phy, 0);
107121

108122
len += snprintf(buf + len, buflen, "CLK: %lu Hz 'o' = PASS\n",
109123
clk_get_rate(phy->clks[RX_SAMPL_CLK]));

0 commit comments

Comments
 (0)