Skip to content

Commit

Permalink
iio: adc: ad9361: hide ENSM mode pinctrl logic
Browse files Browse the repository at this point in the history
The current logic, exposes too much of `pdata` outside of `ad9361.c`.
Added `ad9361_ensm_mode_disable_pinctrl()` and
`ad9361_ensm_mode_restore_pinctrl()` accessor functions to hide it.

Signed-off-by: Alexandru Ardelean <alexandru.ardelean@analog.com>
  • Loading branch information
commodo committed Apr 18, 2018
1 parent 5387132 commit e0f37fc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 11 deletions.
21 changes: 19 additions & 2 deletions drivers/iio/adc/ad9361.c
Original file line number Diff line number Diff line change
Expand Up @@ -4179,7 +4179,7 @@ int ad9361_set_trx_clock_chain_freq(struct ad9361_rf_phy *phy,
}
EXPORT_SYMBOL(ad9361_set_trx_clock_chain_freq);

int ad9361_set_ensm_mode(struct ad9361_rf_phy *phy, bool fdd, bool pinctrl)
static int ad9361_set_ensm_mode(struct ad9361_rf_phy *phy, bool fdd, bool pinctrl)
{
struct ad9361_phy_platform_data *pd = phy->pdata;
int ret;
Expand All @@ -4202,7 +4202,24 @@ int ad9361_set_ensm_mode(struct ad9361_rf_phy *phy, bool fdd, bool pinctrl)

return ret;
}
EXPORT_SYMBOL(ad9361_set_ensm_mode);

int ad9361_ensm_mode_disable_pinctrl(struct ad9361_rf_phy *phy)
{
if (!phy->pdata->fdd)
return ad9361_set_ensm_mode(phy, true, false);
return 0;
}
EXPORT_SYMBOL(ad9361_ensm_mode_disable_pinctrl);

int ad9361_ensm_mode_restore_pinctrl(struct ad9361_rf_phy *phy)
{
if (!phy->pdata->fdd)
return ad9361_set_ensm_mode(phy,
phy->pdata->fdd,
phy->pdata->ensm_pin_ctrl);
return 0;
}
EXPORT_SYMBOL(ad9361_ensm_mode_restore_pinctrl);

/* Fast Lock */

Expand Down
3 changes: 2 additions & 1 deletion drivers/iio/adc/ad9361.h
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,8 @@ int ad9361_spi_write(struct spi_device *spi, u32 reg, u32 val);
int ad9361_bist_loopback(struct ad9361_rf_phy *phy, unsigned mode);
int ad9361_bist_prbs(struct ad9361_rf_phy *phy, enum ad9361_bist_mode mode);
int ad9361_find_opt(u8 *field, u32 size, u32 *ret_start);
int ad9361_set_ensm_mode(struct ad9361_rf_phy *phy, bool fdd, bool pinctrl);
int ad9361_ensm_mode_disable_pinctrl(struct ad9361_rf_phy *phy);
int ad9361_ensm_mode_restore_pinctrl(struct ad9361_rf_phy *phy);
void ad9361_ensm_force_state(struct ad9361_rf_phy *phy, u8 ensm_state);
u8 ad9361_ensm_get_state(struct ad9361_rf_phy *phy);
void ad9361_ensm_restore_state(struct ad9361_rf_phy *phy, u8 ensm_state);
Expand Down
12 changes: 4 additions & 8 deletions drivers/iio/adc/ad9361_conv.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ ssize_t ad9361_dig_interface_timing_analysis(struct ad9361_rf_phy *phy,
/* Mute TX, we don't want to transmit the PRBS */
ad9361_tx_mute(phy, 1);

if (!phy->pdata->fdd)
ad9361_set_ensm_mode(phy, true, false);
ad9361_ensm_mode_disable_pinctrl(phy);

ad9361_bist_loopback(phy, 0);
ad9361_bist_prbs(phy, BIST_INJ_RX);
Expand All @@ -113,8 +112,7 @@ ssize_t ad9361_dig_interface_timing_analysis(struct ad9361_rf_phy *phy,
ad9361_bist_loopback(phy, loopback);
ad9361_write_bist_reg(phy, bist);

if (!phy->pdata->fdd)
ad9361_set_ensm_mode(phy, phy->pdata->fdd, phy->pdata->ensm_pin_ctrl);
ad9361_ensm_mode_restore_pinctrl(phy);
ad9361_ensm_restore_state(phy, ensm_state);

ad9361_tx_mute(phy, 0);
Expand Down Expand Up @@ -632,8 +630,7 @@ int ad9361_dig_tune(struct ad9361_rf_phy *phy, unsigned long max_freq,
/* Mute TX, we don't want to transmit the PRBS */
ad9361_tx_mute(phy, 1);

if (!phy->pdata->fdd)
ad9361_set_ensm_mode(phy, true, false);
ad9361_ensm_mode_disable_pinctrl(phy);

if (flags & DO_IDELAY)
ad9361_midscale_iodelay(phy, false);
Expand Down Expand Up @@ -667,8 +664,7 @@ int ad9361_dig_tune(struct ad9361_rf_phy *phy, unsigned long max_freq,
ad9361_spi_read(phy->spi, REG_TX_CLOCK_DATA_DELAY);
}

if (!phy->pdata->fdd)
ad9361_set_ensm_mode(phy, phy->pdata->fdd, phy->pdata->ensm_pin_ctrl);
ad9361_ensm_mode_restore_pinctrl(phy);
ad9361_ensm_restore_state(phy, ensm_state);

axiadc_write(st, ADI_REG_RSTN, ADI_MMCM_RSTN);
Expand Down

0 comments on commit e0f37fc

Please sign in to comment.