| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
#include "ad9361.h" |
| 44 |
#include "ad9361_api.h" |
| 45 |
#include "platform.h" |
| 46 |
#include "util.h" |
| 47 |
#include "config.h" |
| 48 |
#include <string.h> |
| 49 |
|
| 50 |
#ifndef AXI_ADC_NOT_PRESENT |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
static struct axiadc_chip_info axiadc_chip_info_tbl[] = |
| 55 |
{ |
| 56 |
{ |
| 57 |
"4_CH_DEV", |
| 58 |
4 |
| 59 |
}, |
| 60 |
{ |
| 61 |
"2_CH_DEV", |
| 62 |
2 |
| 63 |
}, |
| 64 |
}; |
| 65 |
#endif |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy, AD9361_InitParam *init_param) |
| 76 |
{ |
| 77 |
struct ad9361_rf_phy *phy; |
| 78 |
int32_t ret = 0; |
| 79 |
int32_t rev = 0; |
| 80 |
int32_t i = 0; |
| 81 |
|
| 82 |
phy = (struct ad9361_rf_phy *)zmalloc(sizeof(*phy)); |
| 83 |
if (!phy) { |
| 84 |
return -ENOMEM; |
| 85 |
} |
| 86 |
|
| 87 |
phy->spi = (struct spi_device *)zmalloc(sizeof(*phy->spi)); |
| 88 |
if (!phy->spi) { |
| 89 |
return -ENOMEM; |
| 90 |
} |
| 91 |
|
| 92 |
phy->clk_refin = (struct clk *)zmalloc(sizeof(*phy->clk_refin)); |
| 93 |
if (!phy->clk_refin) { |
| 94 |
return -ENOMEM; |
| 95 |
} |
| 96 |
|
| 97 |
phy->pdata = (struct ad9361_phy_platform_data *)zmalloc(sizeof(*phy->pdata)); |
| 98 |
if (!phy->pdata) { |
| 99 |
return -ENOMEM; |
| 100 |
} |
| 101 |
#ifndef AXI_ADC_NOT_PRESENT |
| 102 |
phy->adc_conv = (struct axiadc_converter *)zmalloc(sizeof(*phy->adc_conv)); |
| 103 |
if (!phy->adc_conv) { |
| 104 |
return -ENOMEM; |
| 105 |
} |
| 106 |
|
| 107 |
phy->adc_state = (struct axiadc_state *)zmalloc(sizeof(*phy->adc_state)); |
| 108 |
if (!phy->adc_state) { |
| 109 |
return -ENOMEM; |
| 110 |
} |
| 111 |
phy->adc_state->phy = phy; |
| 112 |
#endif |
| 113 |
|
| 114 |
|
| 115 |
phy->dev_sel = init_param->dev_sel; |
| 116 |
|
| 117 |
|
| 118 |
phy->spi->id_no = init_param->id_no; |
| 119 |
phy->id_no = init_param->id_no; |
| 120 |
|
| 121 |
|
| 122 |
phy->clk_refin->rate = init_param->reference_clk_rate; |
| 123 |
|
| 124 |
|
| 125 |
phy->pdata->fdd = init_param->frequency_division_duplex_mode_enable; |
| 126 |
phy->pdata->fdd_independent_mode = init_param->frequency_division_duplex_independent_mode_enable; |
| 127 |
phy->pdata->rx2tx2 = init_param->two_rx_two_tx_mode_enable; |
| 128 |
phy->pdata->rx1tx1_mode_use_rx_num = init_param->one_rx_one_tx_mode_use_rx_num; |
| 129 |
phy->pdata->rx1tx1_mode_use_tx_num = init_param->one_rx_one_tx_mode_use_tx_num; |
| 130 |
phy->pdata->tdd_use_dual_synth = init_param->tdd_use_dual_synth_mode_enable; |
| 131 |
phy->pdata->tdd_skip_vco_cal = init_param->tdd_skip_vco_cal_enable; |
| 132 |
phy->pdata->rx_fastlock_delay_ns = init_param->rx_fastlock_delay_ns; |
| 133 |
phy->pdata->tx_fastlock_delay_ns = init_param->tx_fastlock_delay_ns; |
| 134 |
phy->pdata->trx_fastlock_pinctrl_en[0] = init_param->rx_fastlock_pincontrol_enable; |
| 135 |
phy->pdata->trx_fastlock_pinctrl_en[1] = init_param->tx_fastlock_pincontrol_enable; |
| 136 |
if (phy->dev_sel == ID_AD9363A) { |
| 137 |
phy->pdata->use_ext_rx_lo = false; |
| 138 |
phy->pdata->use_ext_tx_lo = false; |
| 139 |
} else { |
| 140 |
phy->pdata->use_ext_rx_lo = init_param->external_rx_lo_enable; |
| 141 |
phy->pdata->use_ext_tx_lo = init_param->external_tx_lo_enable; |
| 142 |
} |
| 143 |
phy->pdata->dc_offset_update_events = init_param->dc_offset_tracking_update_event_mask; |
| 144 |
phy->pdata->dc_offset_attenuation_high = init_param->dc_offset_attenuation_high_range; |
| 145 |
phy->pdata->dc_offset_attenuation_low = init_param->dc_offset_attenuation_low_range; |
| 146 |
phy->pdata->rf_dc_offset_count_high = init_param->dc_offset_count_high_range; |
| 147 |
phy->pdata->rf_dc_offset_count_low = init_param->dc_offset_count_low_range; |
| 148 |
phy->pdata->split_gt = init_param->split_gain_table_mode_enable; |
| 149 |
phy->pdata->trx_synth_max_fref = init_param->trx_synthesizer_target_fref_overwrite_hz; |
| 150 |
phy->pdata->qec_tracking_slow_mode_en = init_param->qec_tracking_slow_mode_enable; |
| 151 |
|
| 152 |
|
| 153 |
phy->pdata->ensm_pin_pulse_mode = init_param->ensm_enable_pin_pulse_mode_enable; |
| 154 |
phy->pdata->ensm_pin_ctrl = init_param->ensm_enable_txnrx_control_enable; |
| 155 |
|
| 156 |
|
| 157 |
phy->pdata->rx_synth_freq = init_param->rx_synthesizer_frequency_hz; |
| 158 |
phy->pdata->tx_synth_freq = init_param->tx_synthesizer_frequency_hz; |
| 159 |
|
| 160 |
|
| 161 |
for(i = 0; i < 6; i++) { |
| 162 |
phy->pdata->rx_path_clks[i] = init_param->rx_path_clock_frequencies[i]; |
| 163 |
} |
| 164 |
for(i = 0; i < 6; i++) { |
| 165 |
phy->pdata->tx_path_clks[i] = init_param->tx_path_clock_frequencies[i]; |
| 166 |
} |
| 167 |
phy->pdata->rf_rx_bandwidth_Hz = init_param->rf_rx_bandwidth_hz; |
| 168 |
phy->pdata->rf_tx_bandwidth_Hz = init_param->rf_tx_bandwidth_hz; |
| 169 |
|
| 170 |
|
| 171 |
phy->pdata->rf_rx_input_sel = init_param->rx_rf_port_input_select; |
| 172 |
phy->pdata->rf_tx_output_sel = init_param->tx_rf_port_input_select; |
| 173 |
|
| 174 |
|
| 175 |
phy->pdata->tx_atten = init_param->tx_attenuation_mdB; |
| 176 |
phy->pdata->update_tx_gain_via_alert = init_param->update_tx_gain_in_alert_enable; |
| 177 |
|
| 178 |
|
| 179 |
switch (phy->dev_sel) { |
| 180 |
case ID_AD9363A: |
| 181 |
phy->pdata->use_extclk = true; |
| 182 |
break; |
| 183 |
default: |
| 184 |
phy->pdata->use_extclk = init_param->xo_disable_use_ext_refclk_enable; |
| 185 |
} |
| 186 |
phy->pdata->dcxo_coarse = init_param->dcxo_coarse_and_fine_tune[0]; |
| 187 |
phy->pdata->dcxo_fine = init_param->dcxo_coarse_and_fine_tune[1]; |
| 188 |
phy->pdata->ad9361_clkout_mode = (enum ad9361_clkout)init_param->clk_output_mode_select; |
| 189 |
|
| 190 |
|
| 191 |
phy->pdata->gain_ctrl.rx1_mode = (enum rf_gain_ctrl_mode)init_param->gc_rx1_mode; |
| 192 |
phy->pdata->gain_ctrl.rx2_mode = (enum rf_gain_ctrl_mode)init_param->gc_rx2_mode; |
| 193 |
phy->pdata->gain_ctrl.adc_large_overload_thresh = init_param->gc_adc_large_overload_thresh; |
| 194 |
phy->pdata->gain_ctrl.adc_ovr_sample_size = init_param->gc_adc_ovr_sample_size; |
| 195 |
phy->pdata->gain_ctrl.adc_small_overload_thresh = init_param->gc_adc_small_overload_thresh; |
| 196 |
phy->pdata->gain_ctrl.dec_pow_measuremnt_duration = init_param->gc_dec_pow_measurement_duration; |
| 197 |
phy->pdata->gain_ctrl.dig_gain_en = init_param->gc_dig_gain_enable; |
| 198 |
phy->pdata->gain_ctrl.lmt_overload_high_thresh = init_param->gc_lmt_overload_high_thresh; |
| 199 |
phy->pdata->gain_ctrl.lmt_overload_low_thresh = init_param->gc_lmt_overload_low_thresh; |
| 200 |
phy->pdata->gain_ctrl.low_power_thresh = init_param->gc_low_power_thresh; |
| 201 |
phy->pdata->gain_ctrl.max_dig_gain = init_param->gc_max_dig_gain; |
| 202 |
|
| 203 |
|
| 204 |
phy->pdata->gain_ctrl.mgc_dec_gain_step = init_param->mgc_dec_gain_step; |
| 205 |
phy->pdata->gain_ctrl.mgc_inc_gain_step = init_param->mgc_inc_gain_step; |
| 206 |
phy->pdata->gain_ctrl.mgc_rx1_ctrl_inp_en = init_param->mgc_rx1_ctrl_inp_enable; |
| 207 |
phy->pdata->gain_ctrl.mgc_rx2_ctrl_inp_en = init_param->mgc_rx2_ctrl_inp_enable; |
| 208 |
phy->pdata->gain_ctrl.mgc_split_table_ctrl_inp_gain_mode = init_param->mgc_split_table_ctrl_inp_gain_mode; |
| 209 |
|
| 210 |
|
| 211 |
phy->pdata->gain_ctrl.adc_large_overload_exceed_counter = init_param->agc_adc_large_overload_exceed_counter; |
| 212 |
phy->pdata->gain_ctrl.adc_large_overload_inc_steps = init_param->agc_adc_large_overload_inc_steps; |
| 213 |
phy->pdata->gain_ctrl.adc_lmt_small_overload_prevent_gain_inc = init_param->agc_adc_lmt_small_overload_prevent_gain_inc_enable; |
| 214 |
phy->pdata->gain_ctrl.adc_small_overload_exceed_counter = init_param->agc_adc_small_overload_exceed_counter; |
| 215 |
phy->pdata->gain_ctrl.dig_gain_step_size = init_param->agc_dig_gain_step_size; |
| 216 |
phy->pdata->gain_ctrl.dig_saturation_exceed_counter = init_param->agc_dig_saturation_exceed_counter; |
| 217 |
phy->pdata->gain_ctrl.gain_update_interval_us = init_param->agc_gain_update_interval_us; |
| 218 |
phy->pdata->gain_ctrl.immed_gain_change_if_large_adc_overload = init_param->agc_immed_gain_change_if_large_adc_overload_enable; |
| 219 |
phy->pdata->gain_ctrl.immed_gain_change_if_large_lmt_overload = init_param->agc_immed_gain_change_if_large_lmt_overload_enable; |
| 220 |
phy->pdata->gain_ctrl.agc_inner_thresh_high = init_param->agc_inner_thresh_high; |
| 221 |
phy->pdata->gain_ctrl.agc_inner_thresh_high_dec_steps = init_param->agc_inner_thresh_high_dec_steps; |
| 222 |
phy->pdata->gain_ctrl.agc_inner_thresh_low = init_param->agc_inner_thresh_low; |
| 223 |
phy->pdata->gain_ctrl.agc_inner_thresh_low_inc_steps = init_param->agc_inner_thresh_low_inc_steps; |
| 224 |
phy->pdata->gain_ctrl.lmt_overload_large_exceed_counter = init_param->agc_lmt_overload_large_exceed_counter; |
| 225 |
phy->pdata->gain_ctrl.lmt_overload_large_inc_steps = init_param->agc_lmt_overload_large_inc_steps; |
| 226 |
phy->pdata->gain_ctrl.lmt_overload_small_exceed_counter = init_param->agc_lmt_overload_small_exceed_counter; |
| 227 |
phy->pdata->gain_ctrl.agc_outer_thresh_high = init_param->agc_outer_thresh_high; |
| 228 |
phy->pdata->gain_ctrl.agc_outer_thresh_high_dec_steps = init_param->agc_outer_thresh_high_dec_steps; |
| 229 |
phy->pdata->gain_ctrl.agc_outer_thresh_low = init_param->agc_outer_thresh_low; |
| 230 |
phy->pdata->gain_ctrl.agc_outer_thresh_low_inc_steps = init_param->agc_outer_thresh_low_inc_steps; |
| 231 |
phy->pdata->gain_ctrl.agc_attack_delay_extra_margin_us = init_param->agc_attack_delay_extra_margin_us; |
| 232 |
phy->pdata->gain_ctrl.sync_for_gain_counter_en = init_param->agc_sync_for_gain_counter_enable; |
| 233 |
|
| 234 |
|
| 235 |
phy->pdata->gain_ctrl.f_agc_dec_pow_measuremnt_duration = init_param->fagc_dec_pow_measuremnt_duration; |
| 236 |
phy->pdata->gain_ctrl.f_agc_state_wait_time_ns = init_param->fagc_state_wait_time_ns; |
| 237 |
|
| 238 |
phy->pdata->gain_ctrl.f_agc_allow_agc_gain_increase = init_param->fagc_allow_agc_gain_increase; |
| 239 |
phy->pdata->gain_ctrl.f_agc_lp_thresh_increment_time = init_param->fagc_lp_thresh_increment_time; |
| 240 |
phy->pdata->gain_ctrl.f_agc_lp_thresh_increment_steps = init_param->fagc_lp_thresh_increment_steps; |
| 241 |
|
| 242 |
phy->pdata->gain_ctrl.f_agc_lock_level = init_param->fagc_lock_level; |
| 243 |
phy->pdata->gain_ctrl.f_agc_lock_level_lmt_gain_increase_en = init_param->fagc_lock_level_lmt_gain_increase_en; |
| 244 |
phy->pdata->gain_ctrl.f_agc_lock_level_gain_increase_upper_limit = init_param->fagc_lock_level_gain_increase_upper_limit; |
| 245 |
|
| 246 |
phy->pdata->gain_ctrl.f_agc_lpf_final_settling_steps = init_param->fagc_lpf_final_settling_steps; |
| 247 |
phy->pdata->gain_ctrl.f_agc_lmt_final_settling_steps = init_param->fagc_lmt_final_settling_steps; |
| 248 |
phy->pdata->gain_ctrl.f_agc_final_overrange_count = init_param->fagc_final_overrange_count; |
| 249 |
|
| 250 |
phy->pdata->gain_ctrl.f_agc_gain_increase_after_gain_lock_en = init_param->fagc_gain_increase_after_gain_lock_en; |
| 251 |
|
| 252 |
phy->pdata->gain_ctrl.f_agc_gain_index_type_after_exit_rx_mode = (enum f_agc_target_gain_index_type)init_param->fagc_gain_index_type_after_exit_rx_mode; |
| 253 |
phy->pdata->gain_ctrl.f_agc_use_last_lock_level_for_set_gain_en = init_param->fagc_use_last_lock_level_for_set_gain_en; |
| 254 |
phy->pdata->gain_ctrl.f_agc_rst_gla_stronger_sig_thresh_exceeded_en = init_param->fagc_rst_gla_stronger_sig_thresh_exceeded_en; |
| 255 |
phy->pdata->gain_ctrl.f_agc_optimized_gain_offset = init_param->fagc_optimized_gain_offset; |
| 256 |
phy->pdata->gain_ctrl.f_agc_rst_gla_stronger_sig_thresh_above_ll = init_param->fagc_rst_gla_stronger_sig_thresh_above_ll; |
| 257 |
phy->pdata->gain_ctrl.f_agc_rst_gla_engergy_lost_sig_thresh_exceeded_en = init_param->fagc_rst_gla_engergy_lost_sig_thresh_exceeded_en; |
| 258 |
phy->pdata->gain_ctrl.f_agc_rst_gla_engergy_lost_goto_optim_gain_en = init_param->fagc_rst_gla_engergy_lost_goto_optim_gain_en; |
| 259 |
phy->pdata->gain_ctrl.f_agc_rst_gla_engergy_lost_sig_thresh_below_ll = init_param->fagc_rst_gla_engergy_lost_sig_thresh_below_ll; |
| 260 |
phy->pdata->gain_ctrl.f_agc_energy_lost_stronger_sig_gain_lock_exit_cnt = init_param->fagc_energy_lost_stronger_sig_gain_lock_exit_cnt; |
| 261 |
phy->pdata->gain_ctrl.f_agc_rst_gla_large_adc_overload_en = init_param->fagc_rst_gla_large_adc_overload_en; |
| 262 |
phy->pdata->gain_ctrl.f_agc_rst_gla_large_lmt_overload_en = init_param->fagc_rst_gla_large_lmt_overload_en; |
| 263 |
phy->pdata->gain_ctrl.f_agc_rst_gla_en_agc_pulled_high_en = init_param->fagc_rst_gla_en_agc_pulled_high_en; |
| 264 |
phy->pdata->gain_ctrl.f_agc_rst_gla_if_en_agc_pulled_high_mode = (enum f_agc_target_gain_index_type)init_param->fagc_rst_gla_if_en_agc_pulled_high_mode; |
| 265 |
phy->pdata->gain_ctrl.f_agc_power_measurement_duration_in_state5 = init_param->fagc_power_measurement_duration_in_state5; |
| 266 |
|
| 267 |
|
| 268 |
phy->pdata->rssi_ctrl.rssi_delay = init_param->rssi_delay; |
| 269 |
phy->pdata->rssi_ctrl.rssi_duration = init_param->rssi_duration; |
| 270 |
phy->pdata->rssi_ctrl.restart_mode = (enum rssi_restart_mode)init_param->rssi_restart_mode; |
| 271 |
phy->pdata->rssi_ctrl.rssi_unit_is_rx_samples = init_param->rssi_unit_is_rx_samples_enable; |
| 272 |
phy->pdata->rssi_ctrl.rssi_wait = init_param->rssi_wait; |
| 273 |
|
| 274 |
|
| 275 |
phy->pdata->auxadc_ctrl.auxadc_decimation = init_param->aux_adc_decimation; |
| 276 |
phy->pdata->auxadc_ctrl.auxadc_clock_rate = init_param->aux_adc_rate; |
| 277 |
|
| 278 |
|
| 279 |
phy->pdata->auxdac_ctrl.auxdac_manual_mode_en = init_param->aux_dac_manual_mode_enable; |
| 280 |
phy->pdata->auxdac_ctrl.dac1_default_value = init_param->aux_dac1_default_value_mV; |
| 281 |
phy->pdata->auxdac_ctrl.dac1_in_rx_en = init_param->aux_dac1_active_in_rx_enable; |
| 282 |
phy->pdata->auxdac_ctrl.dac1_in_tx_en = init_param->aux_dac1_active_in_tx_enable; |
| 283 |
phy->pdata->auxdac_ctrl.dac1_in_alert_en = init_param->aux_dac1_active_in_alert_enable; |
| 284 |
phy->pdata->auxdac_ctrl.dac1_rx_delay_us = init_param->aux_dac1_rx_delay_us; |
| 285 |
phy->pdata->auxdac_ctrl.dac1_tx_delay_us = init_param->aux_dac1_tx_delay_us; |
| 286 |
phy->pdata->auxdac_ctrl.dac2_default_value = init_param->aux_dac2_default_value_mV; |
| 287 |
phy->pdata->auxdac_ctrl.dac2_in_rx_en = init_param->aux_dac2_active_in_rx_enable; |
| 288 |
phy->pdata->auxdac_ctrl.dac2_in_tx_en = init_param->aux_dac2_active_in_tx_enable; |
| 289 |
phy->pdata->auxdac_ctrl.dac2_in_alert_en = init_param->aux_dac2_active_in_alert_enable; |
| 290 |
phy->pdata->auxdac_ctrl.dac2_rx_delay_us = init_param->aux_dac2_rx_delay_us; |
| 291 |
phy->pdata->auxdac_ctrl.dac2_tx_delay_us = init_param->aux_dac2_tx_delay_us; |
| 292 |
|
| 293 |
|
| 294 |
phy->pdata->auxadc_ctrl.temp_sensor_decimation = init_param->temp_sense_decimation; |
| 295 |
phy->pdata->auxadc_ctrl.temp_time_inteval_ms = init_param->temp_sense_measurement_interval_ms; |
| 296 |
phy->pdata->auxadc_ctrl.offset = init_param->temp_sense_offset_signed; |
| 297 |
phy->pdata->auxadc_ctrl.periodic_temp_measuremnt = init_param->temp_sense_periodic_measurement_enable; |
| 298 |
|
| 299 |
|
| 300 |
phy->pdata->ctrl_outs_ctrl.en_mask = init_param->ctrl_outs_enable_mask; |
| 301 |
phy->pdata->ctrl_outs_ctrl.index = init_param->ctrl_outs_index; |
| 302 |
|
| 303 |
|
| 304 |
phy->pdata->elna_ctrl.settling_delay_ns = init_param->elna_settling_delay_ns; |
| 305 |
phy->pdata->elna_ctrl.gain_mdB = init_param->elna_gain_mdB; |
| 306 |
phy->pdata->elna_ctrl.bypass_loss_mdB = init_param->elna_bypass_loss_mdB; |
| 307 |
phy->pdata->elna_ctrl.elna_1_control_en = init_param->elna_rx1_gpo0_control_enable; |
| 308 |
phy->pdata->elna_ctrl.elna_2_control_en = init_param->elna_rx2_gpo1_control_enable; |
| 309 |
phy->pdata->elna_ctrl.elna_in_gaintable_all_index_en = init_param->elna_gaintable_all_index_enable; |
| 310 |
|
| 311 |
|
| 312 |
phy->pdata->dig_interface_tune_skipmode = (init_param->digital_interface_tune_skip_mode); |
| 313 |
phy->pdata->dig_interface_tune_fir_disable = (init_param->digital_interface_tune_fir_disable); |
| 314 |
phy->pdata->port_ctrl.pp_conf[0] = (init_param->pp_tx_swap_enable << 7); |
| 315 |
phy->pdata->port_ctrl.pp_conf[0] |= (init_param->pp_rx_swap_enable << 6); |
| 316 |
phy->pdata->port_ctrl.pp_conf[0] |= (init_param->tx_channel_swap_enable << 5); |
| 317 |
phy->pdata->port_ctrl.pp_conf[0] |= (init_param->rx_channel_swap_enable << 4); |
| 318 |
phy->pdata->port_ctrl.pp_conf[0] |= (init_param->rx_frame_pulse_mode_enable << 3); |
| 319 |
phy->pdata->port_ctrl.pp_conf[0] |= (init_param->two_t_two_r_timing_enable << 2); |
| 320 |
phy->pdata->port_ctrl.pp_conf[0] |= (init_param->invert_data_bus_enable << 1); |
| 321 |
phy->pdata->port_ctrl.pp_conf[0] |= (init_param->invert_data_clk_enable << 0); |
| 322 |
phy->pdata->port_ctrl.pp_conf[1] = (init_param->fdd_alt_word_order_enable << 7); |
| 323 |
phy->pdata->port_ctrl.pp_conf[1] |= (init_param->invert_rx_frame_enable << 2); |
| 324 |
phy->pdata->port_ctrl.pp_conf[2] = (init_param->fdd_rx_rate_2tx_enable << 7); |
| 325 |
phy->pdata->port_ctrl.pp_conf[2] |= (init_param->swap_ports_enable << 6); |
| 326 |
phy->pdata->port_ctrl.pp_conf[2] |= (init_param->single_data_rate_enable << 5); |
| 327 |
phy->pdata->port_ctrl.pp_conf[2] |= (init_param->lvds_mode_enable << 4); |
| 328 |
phy->pdata->port_ctrl.pp_conf[2] |= (init_param->half_duplex_mode_enable << 3); |
| 329 |
phy->pdata->port_ctrl.pp_conf[2] |= (init_param->single_port_mode_enable << 2); |
| 330 |
phy->pdata->port_ctrl.pp_conf[2] |= (init_param->full_port_enable << 1); |
| 331 |
phy->pdata->port_ctrl.pp_conf[2] |= (init_param->full_duplex_swap_bits_enable << 0); |
| 332 |
phy->pdata->port_ctrl.pp_conf[1] |= (init_param->delay_rx_data & 0x3); |
| 333 |
phy->pdata->port_ctrl.rx_clk_data_delay = DATA_CLK_DELAY(init_param->rx_data_clock_delay); |
| 334 |
phy->pdata->port_ctrl.rx_clk_data_delay |= RX_DATA_DELAY(init_param->rx_data_delay); |
| 335 |
phy->pdata->port_ctrl.tx_clk_data_delay = FB_CLK_DELAY(init_param->tx_fb_clock_delay); |
| 336 |
phy->pdata->port_ctrl.tx_clk_data_delay |= TX_DATA_DELAY(init_param->tx_data_delay); |
| 337 |
phy->pdata->port_ctrl.lvds_bias_ctrl = ((init_param->lvds_bias_mV - 75) / 75) & 0x7; |
| 338 |
phy->pdata->port_ctrl.lvds_bias_ctrl |= (init_param->lvds_rx_onchip_termination_enable << 5); |
| 339 |
phy->pdata->rx1rx2_phase_inversion_en = init_param->rx1rx2_phase_inversion_en; |
| 340 |
|
| 341 |
|
| 342 |
phy->pdata->gpo_ctrl.gpo0_inactive_state_high_en = init_param->gpo0_inactive_state_high_enable; |
| 343 |
phy->pdata->gpo_ctrl.gpo1_inactive_state_high_en = init_param->gpo1_inactive_state_high_enable; |
| 344 |
phy->pdata->gpo_ctrl.gpo2_inactive_state_high_en = init_param->gpo2_inactive_state_high_enable; |
| 345 |
phy->pdata->gpo_ctrl.gpo3_inactive_state_high_en = init_param->gpo3_inactive_state_high_enable; |
| 346 |
|
| 347 |
phy->pdata->gpo_ctrl.gpo0_slave_rx_en = init_param->gpo0_slave_rx_enable; |
| 348 |
phy->pdata->gpo_ctrl.gpo0_slave_tx_en = init_param->gpo0_slave_tx_enable; |
| 349 |
phy->pdata->gpo_ctrl.gpo1_slave_rx_en = init_param->gpo1_slave_rx_enable; |
| 350 |
phy->pdata->gpo_ctrl.gpo1_slave_tx_en = init_param->gpo1_slave_tx_enable; |
| 351 |
phy->pdata->gpo_ctrl.gpo2_slave_rx_en = init_param->gpo2_slave_rx_enable; |
| 352 |
phy->pdata->gpo_ctrl.gpo2_slave_tx_en = init_param->gpo2_slave_tx_enable; |
| 353 |
phy->pdata->gpo_ctrl.gpo3_slave_rx_en = init_param->gpo3_slave_rx_enable; |
| 354 |
phy->pdata->gpo_ctrl.gpo3_slave_tx_en = init_param->gpo3_slave_tx_enable; |
| 355 |
|
| 356 |
phy->pdata->gpo_ctrl.gpo0_rx_delay_us = init_param->gpo0_rx_delay_us; |
| 357 |
phy->pdata->gpo_ctrl.gpo0_tx_delay_us = init_param->gpo0_tx_delay_us; |
| 358 |
phy->pdata->gpo_ctrl.gpo1_rx_delay_us = init_param->gpo1_rx_delay_us; |
| 359 |
phy->pdata->gpo_ctrl.gpo1_tx_delay_us = init_param->gpo1_tx_delay_us; |
| 360 |
phy->pdata->gpo_ctrl.gpo2_rx_delay_us = init_param->gpo2_rx_delay_us; |
| 361 |
phy->pdata->gpo_ctrl.gpo2_tx_delay_us = init_param->gpo2_tx_delay_us; |
| 362 |
phy->pdata->gpo_ctrl.gpo3_rx_delay_us = init_param->gpo3_rx_delay_us; |
| 363 |
phy->pdata->gpo_ctrl.gpo3_tx_delay_us = init_param->gpo3_tx_delay_us; |
| 364 |
|
| 365 |
|
| 366 |
phy->pdata->txmon_ctrl.low_high_gain_threshold_mdB = init_param->low_high_gain_threshold_mdB; |
| 367 |
phy->pdata->txmon_ctrl.low_gain_dB = init_param->low_gain_dB; |
| 368 |
phy->pdata->txmon_ctrl.high_gain_dB = init_param->high_gain_dB; |
| 369 |
phy->pdata->txmon_ctrl.tx_mon_track_en = init_param->tx_mon_track_en; |
| 370 |
phy->pdata->txmon_ctrl.one_shot_mode_en = init_param->one_shot_mode_en; |
| 371 |
phy->pdata->txmon_ctrl.tx_mon_delay = init_param->tx_mon_delay; |
| 372 |
phy->pdata->txmon_ctrl.tx_mon_duration = init_param->tx_mon_duration; |
| 373 |
phy->pdata->txmon_ctrl.tx1_mon_front_end_gain = init_param->tx1_mon_front_end_gain; |
| 374 |
phy->pdata->txmon_ctrl.tx2_mon_front_end_gain = init_param->tx2_mon_front_end_gain; |
| 375 |
phy->pdata->txmon_ctrl.tx1_mon_lo_cm = init_param->tx1_mon_lo_cm; |
| 376 |
phy->pdata->txmon_ctrl.tx2_mon_lo_cm = init_param->tx2_mon_lo_cm; |
| 377 |
|
| 378 |
phy->pdata->debug_mode = true; |
| 379 |
phy->pdata->gpio_resetb = init_param->gpio_resetb; |
| 380 |
|
| 381 |
phy->pdata->gpio_sync = init_param->gpio_sync; |
| 382 |
phy->pdata->gpio_cal_sw1 = init_param->gpio_cal_sw1; |
| 383 |
phy->pdata->gpio_cal_sw2 = init_param->gpio_cal_sw2; |
| 384 |
|
| 385 |
phy->pdata->port_ctrl.digital_io_ctrl = 0; |
| 386 |
phy->pdata->port_ctrl.lvds_invert[0] = init_param->lvds_invert1_control; |
| 387 |
phy->pdata->port_ctrl.lvds_invert[1] = init_param->lvds_invert2_control; |
| 388 |
|
| 389 |
#ifndef AXI_ADC_NOT_PRESENT |
| 390 |
phy->adc_conv->chip_info = &axiadc_chip_info_tbl[phy->pdata->rx2tx2 ? ID_AD9361 : ID_AD9364]; |
| 391 |
#endif |
| 392 |
|
| 393 |
phy->rx_eq_2tx = false; |
| 394 |
|
| 395 |
phy->current_table = RXGAIN_TBLS_END; |
| 396 |
phy->bypass_tx_fir = true; |
| 397 |
phy->bypass_rx_fir = true; |
| 398 |
phy->rate_governor = 1; |
| 399 |
phy->rfdc_track_en = true; |
| 400 |
phy->bbdc_track_en = true; |
| 401 |
phy->quad_track_en = true; |
| 402 |
|
| 403 |
phy->bist_loopback_mode = 0; |
| 404 |
phy->bist_prbs_mode = BIST_DISABLE; |
| 405 |
phy->bist_tone_mode = BIST_DISABLE; |
| 406 |
phy->bist_tone_freq_Hz = 0; |
| 407 |
phy->bist_tone_level_dB = 0; |
| 408 |
phy->bist_tone_mask = 0; |
| 409 |
|
| 410 |
ad9361_reset(phy); |
| 411 |
|
| 412 |
ret = ad9361_spi_read(phy->spi, REG_PRODUCT_ID); |
| 413 |
if ((ret & PRODUCT_ID_MASK) != PRODUCT_ID_9361) { |
| 414 |
printf("%s : Unsupported PRODUCT_ID 0x%X", __func__, (unsigned int)ret); |
| 415 |
ret = -ENODEV; |
| 416 |
goto out; |
| 417 |
} |
| 418 |
rev = ret & REV_MASK; |
| 419 |
|
| 420 |
if (AD9364_DEVICE) { |
| 421 |
phy->pdata->rx2tx2 = false; |
| 422 |
phy->pdata->rx1tx1_mode_use_rx_num = 1; |
| 423 |
phy->pdata->rx1tx1_mode_use_tx_num = 1; |
| 424 |
} |
| 425 |
|
| 426 |
phy->ad9361_rfpll_ext_recalc_rate = init_param->ad9361_rfpll_ext_recalc_rate; |
| 427 |
phy->ad9361_rfpll_ext_round_rate = init_param->ad9361_rfpll_ext_round_rate; |
| 428 |
phy->ad9361_rfpll_ext_set_rate = init_param->ad9361_rfpll_ext_set_rate; |
| 429 |
|
| 430 |
ret = register_clocks(phy); |
| 431 |
if (ret < 0) |
| 432 |
goto out; |
| 433 |
|
| 434 |
#ifndef AXI_ADC_NOT_PRESENT |
| 435 |
axiadc_init(phy); |
| 436 |
phy->adc_state->pcore_version = axiadc_read(phy->adc_state, ADI_REG_VERSION); |
| 437 |
#endif |
| 438 |
|
| 439 |
ad9361_init_gain_tables(phy); |
| 440 |
|
| 441 |
ret = ad9361_setup(phy); |
| 442 |
if (ret < 0) |
| 443 |
goto out; |
| 444 |
|
| 445 |
#ifndef AXI_ADC_NOT_PRESENT |
| 446 |
|
| 447 |
ret = axiadc_post_setup(phy); |
| 448 |
if (ret < 0) |
| 449 |
goto out; |
| 450 |
#endif |
| 451 |
|
| 452 |
printf("%s : AD936x Rev %d successfully initialized\n", __func__, (int)rev); |
| 453 |
|
| 454 |
*ad9361_phy = phy; |
| 455 |
|
| 456 |
return 0; |
| 457 |
|
| 458 |
out: |
| 459 |
free(phy->spi); |
| 460 |
#ifndef AXI_ADC_NOT_PRESENT |
| 461 |
free(phy->adc_conv); |
| 462 |
free(phy->adc_state); |
| 463 |
#endif |
| 464 |
free(phy->clk_refin); |
| 465 |
free(phy->pdata); |
| 466 |
free(phy); |
| 467 |
printf("%s : AD936x initialization error\n", __func__); |
| 468 |
|
| 469 |
return -ENODEV; |
| 470 |
} |
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
int32_t ad9361_set_en_state_machine_mode (struct ad9361_rf_phy *phy, |
| 490 |
uint32_t mode) |
| 491 |
{ |
| 492 |
int32_t ret; |
| 493 |
uint8_t ensm_state; |
| 494 |
bool pinctrl = false; |
| 495 |
|
| 496 |
phy->pdata->fdd_independent_mode = false; |
| 497 |
|
| 498 |
switch (mode) { |
| 499 |
case ENSM_MODE_TX: |
| 500 |
ensm_state = ENSM_STATE_TX; |
| 501 |
break; |
| 502 |
case ENSM_MODE_RX: |
| 503 |
ensm_state = ENSM_STATE_RX; |
| 504 |
break; |
| 505 |
case ENSM_MODE_ALERT: |
| 506 |
ensm_state = ENSM_STATE_ALERT; |
| 507 |
break; |
| 508 |
case ENSM_MODE_FDD: |
| 509 |
ensm_state = ENSM_STATE_FDD; |
| 510 |
break; |
| 511 |
case ENSM_MODE_WAIT: |
| 512 |
ensm_state = ENSM_STATE_SLEEP_WAIT; |
| 513 |
break; |
| 514 |
case ENSM_MODE_SLEEP: |
| 515 |
ensm_state = ENSM_STATE_SLEEP; |
| 516 |
break; |
| 517 |
case ENSM_MODE_PINCTRL: |
| 518 |
ensm_state = ENSM_STATE_SLEEP_WAIT; |
| 519 |
pinctrl = true; |
| 520 |
break; |
| 521 |
case ENSM_MODE_PINCTRL_FDD_INDEP: |
| 522 |
ensm_state = ENSM_STATE_FDD; |
| 523 |
phy->pdata->fdd_independent_mode = true; |
| 524 |
break; |
| 525 |
default: |
| 526 |
return -EINVAL; |
| 527 |
} |
| 528 |
|
| 529 |
ad9361_set_ensm_mode(phy, phy->pdata->fdd, pinctrl); |
| 530 |
ret = ad9361_ensm_set_state(phy, ensm_state, pinctrl); |
| 531 |
|
| 532 |
return ret; |
| 533 |
} |
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
int32_t ad9361_get_en_state_machine_mode (struct ad9361_rf_phy *phy, |
| 542 |
uint32_t *mode) |
| 543 |
{ |
| 544 |
uint8_t ensm_state; |
| 545 |
bool pinctrl = false; |
| 546 |
int32_t ret; |
| 547 |
|
| 548 |
ensm_state = ad9361_spi_read(phy->spi, REG_STATE); |
| 549 |
ensm_state &= ENSM_STATE(~0); |
| 550 |
ret = ad9361_spi_read(phy->spi, REG_ENSM_CONFIG_1); |
| 551 |
if ((ret & ENABLE_ENSM_PIN_CTRL) == ENABLE_ENSM_PIN_CTRL) |
| 552 |
pinctrl = true; |
| 553 |
|
| 554 |
switch (ensm_state) { |
| 555 |
case ENSM_STATE_TX: |
| 556 |
*mode = ENSM_MODE_TX; |
| 557 |
break; |
| 558 |
case ENSM_STATE_RX: |
| 559 |
*mode = ENSM_MODE_RX; |
| 560 |
break; |
| 561 |
case ENSM_STATE_ALERT: |
| 562 |
*mode = ENSM_MODE_ALERT; |
| 563 |
break; |
| 564 |
case ENSM_STATE_FDD: |
| 565 |
if (phy->pdata->fdd_independent_mode) |
| 566 |
*mode = ENSM_MODE_PINCTRL_FDD_INDEP; |
| 567 |
else |
| 568 |
*mode = ENSM_MODE_FDD; |
| 569 |
break; |
| 570 |
case ENSM_STATE_SLEEP_WAIT: |
| 571 |
if (pinctrl) |
| 572 |
*mode = ENSM_MODE_PINCTRL; |
| 573 |
else |
| 574 |
*mode = ENSM_MODE_WAIT; |
| 575 |
break; |
| 576 |
case ENSM_STATE_SLEEP: |
| 577 |
*mode = ENSM_MODE_SLEEP; |
| 578 |
break; |
| 579 |
default: |
| 580 |
return -EINVAL; |
| 581 |
} |
| 582 |
|
| 583 |
return 0; |
| 584 |
} |
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
int32_t ad9361_set_rx_rf_gain (struct ad9361_rf_phy *phy, |
| 601 |
uint8_t ch, int32_t gain_db) |
| 602 |
{ |
| 603 |
struct rf_rx_gain rx_gain = {0}; |
| 604 |
int32_t ret = 0; |
| 605 |
|
| 606 |
if ((phy->pdata->rx2tx2 == 0) && (ch == RX2)) { |
| 607 |
printf("%s : RX2 is an invalid option in 1x1 mode!\n", __func__); |
| 608 |
return -1; |
| 609 |
} |
| 610 |
|
| 611 |
rx_gain.gain_db = gain_db; |
| 612 |
ret = ad9361_set_rx_gain(phy, |
| 613 |
ad9361_1rx1tx_channel_map(phy, false, |
| 614 |
ch + 1), &rx_gain); |
| 615 |
|
| 616 |
return ret; |
| 617 |
} |
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
int32_t ad9361_get_rx_rf_gain (struct ad9361_rf_phy *phy, |
| 632 |
uint8_t ch, int32_t *gain_db) |
| 633 |
{ |
| 634 |
struct rf_rx_gain rx_gain = {0}; |
| 635 |
int32_t ret = 0; |
| 636 |
|
| 637 |
if ((phy->pdata->rx2tx2 == 0) && (ch == RX2)) { |
| 638 |
printf("%s : RX2 is an invalid option in 1x1 mode!\n", __func__); |
| 639 |
return -1; |
| 640 |
} |
| 641 |
|
| 642 |
ret = ad9361_get_rx_gain(phy, ad9361_1rx1tx_channel_map(phy, |
| 643 |
false, ch + 1), &rx_gain); |
| 644 |
|
| 645 |
*gain_db = rx_gain.gain_db; |
| 646 |
|
| 647 |
return ret; |
| 648 |
} |
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
int32_t ad9361_set_rx_rf_bandwidth (struct ad9361_rf_phy *phy, |
| 661 |
uint32_t bandwidth_hz) |
| 662 |
{ |
| 663 |
int32_t ret = 0; |
| 664 |
|
| 665 |
bandwidth_hz = ad9361_validate_rf_bw(phy, bandwidth_hz); |
| 666 |
|
| 667 |
if (phy->current_rx_bw_Hz != bandwidth_hz) |
| 668 |
ret = ad9361_update_rf_bandwidth(phy, bandwidth_hz, |
| 669 |
phy->current_tx_bw_Hz); |
| 670 |
else |
| 671 |
ret = 0; |
| 672 |
|
| 673 |
return ret; |
| 674 |
} |
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
int32_t ad9361_get_rx_rf_bandwidth (struct ad9361_rf_phy *phy, |
| 683 |
uint32_t *bandwidth_hz) |
| 684 |
{ |
| 685 |
*bandwidth_hz = phy->current_rx_bw_Hz; |
| 686 |
|
| 687 |
return 0; |
| 688 |
} |
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
int32_t ad9361_set_rx_sampling_freq (struct ad9361_rf_phy *phy, |
| 701 |
uint32_t sampling_freq_hz) |
| 702 |
{ |
| 703 |
int32_t ret; |
| 704 |
uint32_t rx[6], tx[6]; |
| 705 |
|
| 706 |
ret = ad9361_calculate_rf_clock_chain(phy, sampling_freq_hz, |
| 707 |
phy->rate_governor, rx, tx); |
| 708 |
if (ret < 0) |
| 709 |
return ret; |
| 710 |
|
| 711 |
ad9361_set_trx_clock_chain(phy, rx, tx); |
| 712 |
|
| 713 |
ret = ad9361_update_rf_bandwidth(phy, phy->current_rx_bw_Hz, |
| 714 |
phy->current_tx_bw_Hz); |
| 715 |
|
| 716 |
return ret; |
| 717 |
} |
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
int32_t ad9361_get_rx_sampling_freq (struct ad9361_rf_phy *phy, |
| 726 |
uint32_t *sampling_freq_hz) |
| 727 |
{ |
| 728 |
*sampling_freq_hz = (uint32_t)clk_get_rate(phy, |
| 729 |
phy->ref_clk_scale[RX_SAMPL_CLK]); |
| 730 |
|
| 731 |
return 0; |
| 732 |
} |
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
int32_t ad9361_set_rx_lo_freq (struct ad9361_rf_phy *phy, |
| 745 |
uint64_t lo_freq_hz) |
| 746 |
{ |
| 747 |
int32_t ret; |
| 748 |
|
| 749 |
ret = clk_set_rate(phy, phy->ref_clk_scale[RX_RFPLL], |
| 750 |
ad9361_to_clk(lo_freq_hz)); |
| 751 |
|
| 752 |
return ret; |
| 753 |
} |
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
int32_t ad9361_get_rx_lo_freq (struct ad9361_rf_phy *phy, |
| 762 |
uint64_t *lo_freq_hz) |
| 763 |
{ |
| 764 |
*lo_freq_hz = ad9361_from_clk(clk_get_rate(phy, |
| 765 |
phy->ref_clk_scale[RX_RFPLL])); |
| 766 |
|
| 767 |
return 0; |
| 768 |
} |
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
int32_t ad9361_set_rx_lo_int_ext(struct ad9361_rf_phy *phy, uint8_t int_ext) |
| 780 |
{ |
| 781 |
if ((phy->dev_sel == ID_AD9363A) && (int_ext = EXT_LO)) { |
| 782 |
printf("%s : EXT_LO is not supported by AD9363!\n", __func__); |
| 783 |
return -1; |
| 784 |
} |
| 785 |
|
| 786 |
phy->pdata->use_ext_rx_lo = int_ext; |
| 787 |
|
| 788 |
return ad9361_clk_mux_set_parent(phy->ref_clk_scale[RX_RFPLL], int_ext); |
| 789 |
} |
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
int32_t ad9361_get_rx_rssi (struct ad9361_rf_phy *phy, |
| 804 |
uint8_t ch, struct rf_rssi *rssi) |
| 805 |
{ |
| 806 |
int32_t ret; |
| 807 |
|
| 808 |
if ((phy->pdata->rx2tx2 == 0) && (ch == RX2)) { |
| 809 |
printf("%s : RX2 is an invalid option in 1x1 mode!\n", __func__); |
| 810 |
return -1; |
| 811 |
} |
| 812 |
|
| 813 |
rssi->ant = ad9361_1rx1tx_channel_map(phy, false, ch + 1); |
| 814 |
rssi->duration = 1; |
| 815 |
ret = ad9361_read_rssi(phy, rssi); |
| 816 |
|
| 817 |
return ret; |
| 818 |
} |
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
int32_t ad9361_set_rx_gain_control_mode (struct ad9361_rf_phy *phy, |
| 839 |
uint8_t ch, uint8_t gc_mode) |
| 840 |
{ |
| 841 |
struct rf_gain_ctrl gc = {0}; |
| 842 |
|
| 843 |
if ((phy->pdata->rx2tx2 == 0) && (ch == RX2)) { |
| 844 |
printf("%s : RX2 is an invalid option in 1x1 mode!\n", __func__); |
| 845 |
return -1; |
| 846 |
} |
| 847 |
|
| 848 |
gc.ant = ad9361_1rx1tx_channel_map(phy, false, ch + 1); |
| 849 |
gc.mode = phy->agc_mode[ch] = gc_mode; |
| 850 |
|
| 851 |
ad9361_set_gain_ctrl_mode(phy, &gc); |
| 852 |
|
| 853 |
return 0; |
| 854 |
} |
| 855 |
|
| 856 |
|
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
int32_t ad9361_get_rx_gain_control_mode (struct ad9361_rf_phy *phy, |
| 867 |
uint8_t ch, uint8_t *gc_mode) |
| 868 |
{ |
| 869 |
*gc_mode = phy->agc_mode[ch]; |
| 870 |
|
| 871 |
return 0; |
| 872 |
} |
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
|
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
int32_t ad9361_set_rx_fir_config (struct ad9361_rf_phy *phy, |
| 883 |
AD9361_RXFIRConfig fir_cfg) |
| 884 |
{ |
| 885 |
int32_t ret; |
| 886 |
|
| 887 |
phy->rx_fir_dec = fir_cfg.rx_dec; |
| 888 |
ret = ad9361_load_fir_filter_coef(phy, (enum fir_dest)(fir_cfg.rx | FIR_IS_RX), |
| 889 |
fir_cfg.rx_gain, fir_cfg.rx_coef_size, fir_cfg.rx_coef); |
| 890 |
|
| 891 |
return ret; |
| 892 |
} |
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
|
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
int32_t ad9361_get_rx_fir_config(struct ad9361_rf_phy *phy, uint8_t rx_ch, AD9361_RXFIRConfig *fir_cfg) |
| 905 |
{ |
| 906 |
int32_t ret; |
| 907 |
uint32_t fir_conf; |
| 908 |
uint8_t index; |
| 909 |
|
| 910 |
rx_ch += 1; |
| 911 |
|
| 912 |
ret = ad9361_spi_read(phy->spi, REG_RX_FILTER_CONFIG); |
| 913 |
if(ret < 0) |
| 914 |
return ret; |
| 915 |
fir_conf = ret; |
| 916 |
|
| 917 |
fir_cfg->rx_coef_size = (((fir_conf & FIR_NUM_TAPS(7)) >> 5) + 1) * 16; |
| 918 |
|
| 919 |
ret = ad9361_spi_read(phy->spi, REG_RX_FILTER_GAIN); |
| 920 |
if(ret < 0) |
| 921 |
return ret; |
| 922 |
fir_cfg->rx_gain = -6 * (ret & FILTER_GAIN(3)) + 6; |
| 923 |
fir_cfg->rx = rx_ch; |
| 924 |
|
| 925 |
fir_conf &= ~FIR_SELECT(3); |
| 926 |
fir_conf |= FIR_SELECT(rx_ch) | FIR_START_CLK; |
| 927 |
ad9361_spi_write(phy->spi, REG_RX_FILTER_CONFIG, fir_conf); |
| 928 |
|
| 929 |
for(index = 0; index < 128; index++) |
| 930 |
{ |
| 931 |
ad9361_spi_write(phy->spi, REG_RX_FILTER_COEF_ADDR, index); |
| 932 |
ret = ad9361_spi_read(phy->spi, REG_RX_FILTER_COEF_READ_DATA_1); |
| 933 |
if(ret < 0) |
| 934 |
return ret; |
| 935 |
fir_cfg->rx_coef[index] = ret; |
| 936 |
ret = ad9361_spi_read(phy->spi, REG_RX_FILTER_COEF_READ_DATA_2); |
| 937 |
if(ret < 0) |
| 938 |
return ret; |
| 939 |
fir_cfg->rx_coef[index] |= (ret << 8); |
| 940 |
} |
| 941 |
|
| 942 |
fir_conf &= ~FIR_START_CLK; |
| 943 |
ad9361_spi_write(phy->spi, REG_RX_FILTER_CONFIG, fir_conf); |
| 944 |
|
| 945 |
fir_cfg->rx_dec = phy->rx_fir_dec; |
| 946 |
|
| 947 |
return 0; |
| 948 |
} |
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
|
| 960 |
|
| 961 |
int32_t ad9361_set_rx_fir_en_dis (struct ad9361_rf_phy *phy, |
| 962 |
uint8_t en_dis) |
| 963 |
{ |
| 964 |
int32_t ret = 0; |
| 965 |
|
| 966 |
if(phy->bypass_rx_fir == !en_dis) |
| 967 |
return ret; |
| 968 |
|
| 969 |
phy->bypass_rx_fir = !en_dis; |
| 970 |
ret = ad9361_validate_enable_fir(phy); |
| 971 |
if (ret < 0) { |
| 972 |
phy->bypass_rx_fir = true; |
| 973 |
} |
| 974 |
|
| 975 |
return ret; |
| 976 |
} |
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
int32_t ad9361_get_rx_fir_en_dis (struct ad9361_rf_phy *phy, |
| 985 |
uint8_t *en_dis) |
| 986 |
{ |
| 987 |
*en_dis = !phy->bypass_rx_fir; |
| 988 |
|
| 989 |
return 0; |
| 990 |
} |
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
|
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
int32_t ad9361_set_rx_rfdc_track_en_dis (struct ad9361_rf_phy *phy, |
| 1002 |
uint8_t en_dis) |
| 1003 |
{ |
| 1004 |
int32_t ret = 0; |
| 1005 |
|
| 1006 |
if(phy->rfdc_track_en == en_dis) |
| 1007 |
return ret; |
| 1008 |
|
| 1009 |
phy->rfdc_track_en = en_dis; |
| 1010 |
ret = ad9361_tracking_control(phy, phy->bbdc_track_en, |
| 1011 |
phy->rfdc_track_en, phy->quad_track_en); |
| 1012 |
|
| 1013 |
return ret; |
| 1014 |
} |
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
int32_t ad9361_get_rx_rfdc_track_en_dis (struct ad9361_rf_phy *phy, |
| 1023 |
uint8_t *en_dis) |
| 1024 |
{ |
| 1025 |
*en_dis = phy->rfdc_track_en; |
| 1026 |
|
| 1027 |
return 0; |
| 1028 |
} |
| 1029 |
|
| 1030 |
|
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
|
| 1039 |
int32_t ad9361_set_rx_bbdc_track_en_dis (struct ad9361_rf_phy *phy, |
| 1040 |
uint8_t en_dis) |
| 1041 |
{ |
| 1042 |
int32_t ret = 0; |
| 1043 |
|
| 1044 |
if(phy->bbdc_track_en == en_dis) |
| 1045 |
return ret; |
| 1046 |
|
| 1047 |
phy->bbdc_track_en = en_dis; |
| 1048 |
ret = ad9361_tracking_control(phy, phy->bbdc_track_en, |
| 1049 |
phy->rfdc_track_en, phy->quad_track_en); |
| 1050 |
|
| 1051 |
return ret; |
| 1052 |
} |
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
|
| 1060 |
int32_t ad9361_get_rx_bbdc_track_en_dis (struct ad9361_rf_phy *phy, |
| 1061 |
uint8_t *en_dis) |
| 1062 |
{ |
| 1063 |
*en_dis = phy->bbdc_track_en; |
| 1064 |
|
| 1065 |
return 0; |
| 1066 |
} |
| 1067 |
|
| 1068 |
|
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
|
| 1076 |
|
| 1077 |
int32_t ad9361_set_rx_quad_track_en_dis (struct ad9361_rf_phy *phy, |
| 1078 |
uint8_t en_dis) |
| 1079 |
{ |
| 1080 |
int32_t ret = 0; |
| 1081 |
|
| 1082 |
if(phy->quad_track_en == en_dis) |
| 1083 |
return ret; |
| 1084 |
|
| 1085 |
phy->quad_track_en = en_dis; |
| 1086 |
ret = ad9361_tracking_control(phy, phy->bbdc_track_en, |
| 1087 |
phy->rfdc_track_en, phy->quad_track_en); |
| 1088 |
|
| 1089 |
return ret; |
| 1090 |
} |
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
int32_t ad9361_get_rx_quad_track_en_dis (struct ad9361_rf_phy *phy, |
| 1099 |
uint8_t *en_dis) |
| 1100 |
{ |
| 1101 |
*en_dis = phy->quad_track_en; |
| 1102 |
|
| 1103 |
return 0; |
| 1104 |
} |
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
int32_t ad9361_set_rx_rf_port_input (struct ad9361_rf_phy *phy, |
| 1126 |
uint32_t mode) |
| 1127 |
{ |
| 1128 |
int32_t ret; |
| 1129 |
|
| 1130 |
phy->pdata->rf_rx_input_sel = mode; |
| 1131 |
|
| 1132 |
ret = ad9361_rf_port_setup(phy, false, |
| 1133 |
phy->pdata->rf_rx_input_sel, |
| 1134 |
phy->pdata->rf_tx_output_sel); |
| 1135 |
|
| 1136 |
return ret; |
| 1137 |
} |
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
int32_t ad9361_get_rx_rf_port_input (struct ad9361_rf_phy *phy, |
| 1146 |
uint32_t *mode) |
| 1147 |
{ |
| 1148 |
*mode = phy->pdata->rf_rx_input_sel; |
| 1149 |
|
| 1150 |
return 0; |
| 1151 |
} |
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
int32_t ad9361_rx_fastlock_store(struct ad9361_rf_phy *phy, uint32_t profile) |
| 1164 |
{ |
| 1165 |
return ad9361_fastlock_store(phy, 0, profile); |
| 1166 |
} |
| 1167 |
|
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
|
| 1178 |
int32_t ad9361_rx_fastlock_recall(struct ad9361_rf_phy *phy, uint32_t profile) |
| 1179 |
{ |
| 1180 |
return ad9361_fastlock_recall(phy, 0, profile); |
| 1181 |
} |
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
|
| 1192 |
5 |
| 1193 |
|
| 1194 |
|
| 1195 |
int32_t ad9361_rx_fastlock_load(struct ad9361_rf_phy *phy, uint32_t profile, uint8_t *values) |
| 1196 |
{ |
| 1197 |
return ad9361_fastlock_load(phy, 0, profile, values); |
| 1198 |
} |
| 1199 |
|
| 1200 |
|
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
int32_t ad9361_rx_fastlock_save(struct ad9361_rf_phy *phy, uint32_t profile, uint8_t *values) |
| 1211 |
{ |
| 1212 |
return ad9361_fastlock_save(phy, 0, profile, values); |
| 1213 |
} |
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
|
| 1218 |
|
| 1219 |
|
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
|
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
int32_t ad9361_set_tx_attenuation (struct ad9361_rf_phy *phy, |
| 1230 |
uint8_t ch, uint32_t attenuation_mdb) |
| 1231 |
{ |
| 1232 |
int32_t ret; |
| 1233 |
int32_t channel; |
| 1234 |
|
| 1235 |
if ((phy->pdata->rx2tx2 == 0) && (ch == TX2)) { |
| 1236 |
printf("%s : TX2 is an invalid option in 1x1 mode!\n", __func__); |
| 1237 |
return -1; |
| 1238 |
} |
| 1239 |
|
| 1240 |
channel = ad9361_1rx1tx_channel_map(phy, true, ch); |
| 1241 |
ret = ad9361_set_tx_atten(phy, attenuation_mdb, |
| 1242 |
channel == 0, channel == 1, |
| 1243 |
!phy->pdata->update_tx_gain_via_alert); |
| 1244 |
|
| 1245 |
return ret; |
| 1246 |
} |
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
|
| 1259 |
|
| 1260 |
int32_t ad9361_get_tx_attenuation (struct ad9361_rf_phy *phy, |
| 1261 |
uint8_t ch, uint32_t *attenuation_db) |
| 1262 |
{ |
| 1263 |
int32_t ret; |
| 1264 |
|
| 1265 |
if ((phy->pdata->rx2tx2 == 0) && (ch == TX2)) { |
| 1266 |
printf("%s : TX2 is an invalid option in 1x1 mode!\n", __func__); |
| 1267 |
return -1; |
| 1268 |
} |
| 1269 |
|
| 1270 |
ret = ad9361_get_tx_atten(phy, |
| 1271 |
ad9361_1rx1tx_channel_map(phy, true, |
| 1272 |
ch + 1)); |
| 1273 |
|
| 1274 |
if(ret < 0) |
| 1275 |
return ret; |
| 1276 |
*attenuation_db = ret; |
| 1277 |
|
| 1278 |
return 0; |
| 1279 |
} |
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
int32_t ad9361_set_tx_rf_bandwidth (struct ad9361_rf_phy *phy, |
| 1292 |
uint32_t bandwidth_hz) |
| 1293 |
{ |
| 1294 |
int32_t ret = 0; |
| 1295 |
|
| 1296 |
bandwidth_hz = ad9361_validate_rf_bw(phy, bandwidth_hz); |
| 1297 |
|
| 1298 |
if (phy->current_tx_bw_Hz != bandwidth_hz) |
| 1299 |
ret = ad9361_update_rf_bandwidth(phy, |
| 1300 |
phy->current_rx_bw_Hz, bandwidth_hz); |
| 1301 |
else |
| 1302 |
ret = 0; |
| 1303 |
|
| 1304 |
return ret; |
| 1305 |
} |
| 1306 |
|
| 1307 |
|
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
int32_t ad9361_get_tx_rf_bandwidth (struct ad9361_rf_phy *phy, |
| 1314 |
uint32_t *bandwidth_hz) |
| 1315 |
{ |
| 1316 |
*bandwidth_hz = phy->current_tx_bw_Hz; |
| 1317 |
|
| 1318 |
return 0; |
| 1319 |
} |
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
int32_t ad9361_set_tx_sampling_freq (struct ad9361_rf_phy *phy, |
| 1332 |
uint32_t sampling_freq_hz) |
| 1333 |
{ |
| 1334 |
int32_t ret; |
| 1335 |
uint32_t rx[6], tx[6]; |
| 1336 |
|
| 1337 |
ret = ad9361_calculate_rf_clock_chain(phy, sampling_freq_hz, |
| 1338 |
phy->rate_governor, rx, tx); |
| 1339 |
if (ret < 0) |
| 1340 |
return ret; |
| 1341 |
|
| 1342 |
ad9361_set_trx_clock_chain(phy, rx, tx); |
| 1343 |
|
| 1344 |
ret = ad9361_update_rf_bandwidth(phy, phy->current_rx_bw_Hz, |
| 1345 |
phy->current_tx_bw_Hz); |
| 1346 |
|
| 1347 |
return ret; |
| 1348 |
} |
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
int32_t ad9361_get_tx_sampling_freq (struct ad9361_rf_phy *phy, |
| 1357 |
uint32_t *sampling_freq_hz) |
| 1358 |
{ |
| 1359 |
*sampling_freq_hz = (uint32_t)clk_get_rate(phy, |
| 1360 |
phy->ref_clk_scale[TX_SAMPL_CLK]); |
| 1361 |
|
| 1362 |
return 0; |
| 1363 |
} |
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
|
| 1374 |
|
| 1375 |
int32_t ad9361_set_tx_lo_freq (struct ad9361_rf_phy *phy, |
| 1376 |
uint64_t lo_freq_hz) |
| 1377 |
{ |
| 1378 |
int32_t ret; |
| 1379 |
|
| 1380 |
ret = clk_set_rate(phy, phy->ref_clk_scale[TX_RFPLL], |
| 1381 |
ad9361_to_clk(lo_freq_hz)); |
| 1382 |
|
| 1383 |
return ret; |
| 1384 |
} |
| 1385 |
|
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
|
| 1391 |
|
| 1392 |
int32_t ad9361_get_tx_lo_freq (struct ad9361_rf_phy *phy, |
| 1393 |
uint64_t *lo_freq_hz) |
| 1394 |
{ |
| 1395 |
*lo_freq_hz = ad9361_from_clk(clk_get_rate(phy, |
| 1396 |
phy->ref_clk_scale[TX_RFPLL])); |
| 1397 |
|
| 1398 |
return 0; |
| 1399 |
} |
| 1400 |
|
| 1401 |
|
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
|
| 1410 |
int32_t ad9361_set_tx_lo_int_ext(struct ad9361_rf_phy *phy, uint8_t int_ext) |
| 1411 |
{ |
| 1412 |
if ((phy->dev_sel == ID_AD9363A) && (int_ext = EXT_LO)) { |
| 1413 |
printf("%s : EXT_LO is not supported by AD9363!\n", __func__); |
| 1414 |
return -1; |
| 1415 |
} |
| 1416 |
|
| 1417 |
phy->pdata->use_ext_tx_lo = int_ext; |
| 1418 |
|
| 1419 |
return ad9361_clk_mux_set_parent(phy->ref_clk_scale[TX_RFPLL], int_ext); |
| 1420 |
} |
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
|
| 1426 |
|
| 1427 |
|
| 1428 |
|
| 1429 |
|
| 1430 |
int32_t ad9361_set_tx_fir_config (struct ad9361_rf_phy *phy, |
| 1431 |
AD9361_TXFIRConfig fir_cfg) |
| 1432 |
{ |
| 1433 |
int32_t ret; |
| 1434 |
|
| 1435 |
phy->tx_fir_int = fir_cfg.tx_int; |
| 1436 |
ret = ad9361_load_fir_filter_coef(phy, (enum fir_dest)fir_cfg.tx, |
| 1437 |
fir_cfg.tx_gain, fir_cfg.tx_coef_size, fir_cfg.tx_coef); |
| 1438 |
|
| 1439 |
return ret; |
| 1440 |
} |
| 1441 |
|
| 1442 |
|
| 1443 |
|
| 1444 |
|
| 1445 |
|
| 1446 |
|
| 1447 |
|
| 1448 |
|
| 1449 |
|
| 1450 |
|
| 1451 |
|
| 1452 |
int32_t ad9361_get_tx_fir_config(struct ad9361_rf_phy *phy, uint8_t tx_ch, AD9361_TXFIRConfig *fir_cfg) |
| 1453 |
{ |
| 1454 |
int32_t ret; |
| 1455 |
uint32_t fir_conf; |
| 1456 |
uint8_t index; |
| 1457 |
|
| 1458 |
tx_ch += 1; |
| 1459 |
|
| 1460 |
ret = ad9361_spi_read(phy->spi, REG_TX_FILTER_CONF); |
| 1461 |
if(ret < 0) |
| 1462 |
return ret; |
| 1463 |
fir_conf = ret; |
| 1464 |
fir_cfg->tx_coef_size = (((fir_conf & FIR_NUM_TAPS(7)) >> 5) + 1) * 16; |
| 1465 |
fir_cfg->tx_gain = -6 * (fir_conf & TX_FIR_GAIN_6DB); |
| 1466 |
fir_cfg->tx = tx_ch; |
| 1467 |
|
| 1468 |
fir_conf &= ~FIR_SELECT(3); |
| 1469 |
fir_conf |= FIR_SELECT(tx_ch) | FIR_START_CLK; |
| 1470 |
ad9361_spi_write(phy->spi, REG_TX_FILTER_CONF, fir_conf); |
| 1471 |
|
| 1472 |
for(index = 0; index < 128; index++) |
| 1473 |
{ |
| 1474 |
ad9361_spi_write(phy->spi, REG_TX_FILTER_COEF_ADDR, index); |
| 1475 |
ret = ad9361_spi_read(phy->spi, REG_TX_FILTER_COEF_READ_DATA_1); |
| 1476 |
if(ret < 0) |
| 1477 |
return ret; |
| 1478 |
fir_cfg->tx_coef[index] = ret; |
| 1479 |
ret = ad9361_spi_read(phy->spi, REG_TX_FILTER_COEF_READ_DATA_2); |
| 1480 |
if(ret < 0) |
| 1481 |
return ret; |
| 1482 |
fir_cfg->tx_coef[index] |= (ret << 8); |
| 1483 |
} |
| 1484 |
|
| 1485 |
fir_conf &= ~FIR_START_CLK; |
| 1486 |
ad9361_spi_write(phy->spi, REG_TX_FILTER_CONF, fir_conf); |
| 1487 |
|
| 1488 |
fir_cfg->tx_int = phy->tx_fir_int; |
| 1489 |
|
| 1490 |
return 0; |
| 1491 |
} |
| 1492 |
|
| 1493 |
|
| 1494 |
|
| 1495 |
|
| 1496 |
|
| 1497 |
|
| 1498 |
|
| 1499 |
|
| 1500 |
|
| 1501 |
|
| 1502 |
|
| 1503 |
|
| 1504 |
int32_t ad9361_set_tx_fir_en_dis (struct ad9361_rf_phy *phy, |
| 1505 |
uint8_t en_dis) |
| 1506 |
{ |
| 1507 |
int32_t ret = 0; |
| 1508 |
|
| 1509 |
if(phy->bypass_tx_fir == !en_dis) |
| 1510 |
return ret; |
| 1511 |
|
| 1512 |
phy->bypass_tx_fir = !en_dis; |
| 1513 |
ret = ad9361_validate_enable_fir(phy); |
| 1514 |
if (ret < 0) { |
| 1515 |
phy->bypass_tx_fir = true; |
| 1516 |
} |
| 1517 |
|
| 1518 |
return ret; |
| 1519 |
} |
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
int32_t ad9361_get_tx_fir_en_dis (struct ad9361_rf_phy *phy, |
| 1528 |
uint8_t *en_dis) |
| 1529 |
{ |
| 1530 |
*en_dis = !phy->bypass_tx_fir; |
| 1531 |
|
| 1532 |
return 0; |
| 1533 |
} |
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
|
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
int32_t ad9361_get_tx_rssi (struct ad9361_rf_phy *phy, |
| 1546 |
uint8_t ch, |
| 1547 |
uint32_t *rssi_db_x_1000) |
| 1548 |
{ |
| 1549 |
uint8_t reg_val_buf[3]; |
| 1550 |
uint32_t val; |
| 1551 |
int32_t ret; |
| 1552 |
|
| 1553 |
ret = ad9361_spi_readm(phy->spi, REG_TX_RSSI_LSB, |
| 1554 |
reg_val_buf, ARRAY_SIZE(reg_val_buf)); |
| 1555 |
if (ret < 0) { |
| 1556 |
return ret; |
| 1557 |
} |
| 1558 |
|
| 1559 |
switch (ch) { |
| 1560 |
case 0: |
| 1561 |
val = (reg_val_buf[2] << 1) | (reg_val_buf[0] & TX_RSSI_1); |
| 1562 |
break; |
| 1563 |
case 1: |
| 1564 |
val = (reg_val_buf[1] << 1) | ((reg_val_buf[0] & TX_RSSI_2) >> 1); |
| 1565 |
break; |
| 1566 |
default: |
| 1567 |
return -EINVAL; |
| 1568 |
} |
| 1569 |
|
| 1570 |
val *= RSSI_RESOLUTION; |
| 1571 |
|
| 1572 |
*rssi_db_x_1000 = ((val / RSSI_MULTIPLIER) * 1000) + |
| 1573 |
(val % RSSI_MULTIPLIER); |
| 1574 |
|
| 1575 |
return 0; |
| 1576 |
} |
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
|
| 1581 |
|
| 1582 |
|
| 1583 |
|
| 1584 |
|
| 1585 |
|
| 1586 |
|
| 1587 |
int32_t ad9361_set_tx_rf_port_output (struct ad9361_rf_phy *phy, |
| 1588 |
uint32_t mode) |
| 1589 |
{ |
| 1590 |
int32_t ret; |
| 1591 |
|
| 1592 |
phy->pdata->rf_tx_output_sel = mode; |
| 1593 |
|
| 1594 |
ret = ad9361_rf_port_setup(phy, true, |
| 1595 |
phy->pdata->rf_rx_input_sel, |
| 1596 |
phy->pdata->rf_tx_output_sel); |
| 1597 |
|
| 1598 |
return ret; |
| 1599 |
} |
| 1600 |
|
| 1601 |
|
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
|
| 1607 |
int32_t ad9361_get_tx_rf_port_output (struct ad9361_rf_phy *phy, |
| 1608 |
uint32_t *mode) |
| 1609 |
{ |
| 1610 |
*mode = phy->pdata->rf_tx_output_sel; |
| 1611 |
|
| 1612 |
return 0; |
| 1613 |
} |
| 1614 |
|
| 1615 |
|
| 1616 |
|
| 1617 |
|
| 1618 |
|
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
int32_t ad9361_set_tx_auto_cal_en_dis (struct ad9361_rf_phy *phy, uint8_t en_dis) |
| 1625 |
{ |
| 1626 |
if (en_dis == 0) |
| 1627 |
phy->auto_cal_en = 0; |
| 1628 |
else |
| 1629 |
phy->auto_cal_en = 1; |
| 1630 |
|
| 1631 |
return 0; |
| 1632 |
} |
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
int32_t ad9361_get_tx_auto_cal_en_dis (struct ad9361_rf_phy *phy, uint8_t *en_dis) |
| 1641 |
{ |
| 1642 |
*en_dis = phy->auto_cal_en; |
| 1643 |
|
| 1644 |
return 0; |
| 1645 |
} |
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
|
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
|
| 1657 |
int32_t ad9361_tx_fastlock_store(struct ad9361_rf_phy *phy, uint32_t profile) |
| 1658 |
{ |
| 1659 |
return ad9361_fastlock_store(phy, 1, profile); |
| 1660 |
} |
| 1661 |
|
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
|
| 1670 |
|
| 1671 |
|
| 1672 |
int32_t ad9361_tx_fastlock_recall(struct ad9361_rf_phy *phy, uint32_t profile) |
| 1673 |
{ |
| 1674 |
return ad9361_fastlock_recall(phy, 1, profile); |
| 1675 |
} |
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
|
| 1685 |
|
| 1686 |
5 |
| 1687 |
|
| 1688 |
|
| 1689 |
int32_t ad9361_tx_fastlock_load(struct ad9361_rf_phy *phy, uint32_t profile, uint8_t *values) |
| 1690 |
{ |
| 1691 |
return ad9361_fastlock_load(phy, 1, profile, values); |
| 1692 |
} |
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
|
| 1698 |
|
| 1699 |
|
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
int32_t ad9361_tx_fastlock_save(struct ad9361_rf_phy *phy, uint32_t profile, uint8_t *values) |
| 1705 |
{ |
| 1706 |
return ad9361_fastlock_save(phy, 1, profile, values); |
| 1707 |
} |
| 1708 |
|
| 1709 |
|
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
int32_t ad9361_set_trx_path_clks(struct ad9361_rf_phy *phy, |
| 1719 |
uint32_t *rx_path_clks, |
| 1720 |
uint32_t *tx_path_clks) |
| 1721 |
{ |
| 1722 |
int32_t ret; |
| 1723 |
|
| 1724 |
ret = ad9361_set_trx_clock_chain(phy, rx_path_clks, tx_path_clks); |
| 1725 |
if (ret < 0) |
| 1726 |
return ret; |
| 1727 |
|
| 1728 |
ret = ad9361_update_rf_bandwidth(phy, phy->current_rx_bw_Hz, |
| 1729 |
phy->current_tx_bw_Hz); |
| 1730 |
|
| 1731 |
return ret; |
| 1732 |
} |
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
int32_t ad9361_get_trx_path_clks(struct ad9361_rf_phy *phy, |
| 1742 |
uint32_t *rx_path_clks, |
| 1743 |
uint32_t *tx_path_clks) |
| 1744 |
{ |
| 1745 |
return ad9361_get_trx_clock_chain(phy, rx_path_clks, tx_path_clks); |
| 1746 |
} |
| 1747 |
|
| 1748 |
|
| 1749 |
|
| 1750 |
|
| 1751 |
|
| 1752 |
|
| 1753 |
|
| 1754 |
|
| 1755 |
|
| 1756 |
|
| 1757 |
int32_t ad9361_set_no_ch_mode(struct ad9361_rf_phy *phy, uint8_t no_ch_mode) |
| 1758 |
{ |
| 1759 |
switch (no_ch_mode) { |
| 1760 |
case 1: |
| 1761 |
phy->pdata->rx2tx2 = 0; |
| 1762 |
break; |
| 1763 |
case 2: |
| 1764 |
phy->pdata->rx2tx2 = 1; |
| 1765 |
break; |
| 1766 |
default: |
| 1767 |
return -EINVAL; |
| 1768 |
} |
| 1769 |
|
| 1770 |
#ifndef AXI_ADC_NOT_PRESENT |
| 1771 |
phy->adc_conv->chip_info = &axiadc_chip_info_tbl[phy->pdata->rx2tx2 ? ID_AD9361 : ID_AD9364]; |
| 1772 |
#endif |
| 1773 |
ad9361_reset(phy); |
| 1774 |
ad9361_spi_write(phy->spi, REG_SPI_CONF, SOFT_RESET | _SOFT_RESET); |
| 1775 |
ad9361_spi_write(phy->spi, REG_SPI_CONF, 0x0); |
| 1776 |
|
| 1777 |
phy->clks[TX_REFCLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[TX_REFCLK], phy->clk_refin->rate); |
| 1778 |
phy->clks[TX_REFCLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[TX_REFCLK], phy->clk_refin->rate); |
| 1779 |
phy->clks[RX_REFCLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[RX_REFCLK], phy->clk_refin->rate); |
| 1780 |
phy->clks[BB_REFCLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[BB_REFCLK], phy->clk_refin->rate); |
| 1781 |
phy->clks[BBPLL_CLK]->rate = ad9361_bbpll_recalc_rate(phy->ref_clk_scale[BBPLL_CLK], phy->clks[BB_REFCLK]->rate); |
| 1782 |
phy->clks[ADC_CLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[ADC_CLK], phy->clks[BBPLL_CLK]->rate); |
| 1783 |
phy->clks[R2_CLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[R2_CLK], phy->clks[ADC_CLK]->rate); |
| 1784 |
phy->clks[R1_CLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[R1_CLK], phy->clks[R2_CLK]->rate); |
| 1785 |
phy->clks[CLKRF_CLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[CLKRF_CLK], phy->clks[R1_CLK]->rate); |
| 1786 |
phy->clks[RX_SAMPL_CLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[RX_SAMPL_CLK], phy->clks[CLKRF_CLK]->rate); |
| 1787 |
phy->clks[DAC_CLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[DAC_CLK], phy->clks[ADC_CLK]->rate); |
| 1788 |
phy->clks[T2_CLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[T2_CLK], phy->clks[DAC_CLK]->rate); |
| 1789 |
phy->clks[T1_CLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[T1_CLK], phy->clks[T2_CLK]->rate); |
| 1790 |
phy->clks[CLKTF_CLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[CLKTF_CLK], phy->clks[T1_CLK]->rate); |
| 1791 |
phy->clks[TX_SAMPL_CLK]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[TX_SAMPL_CLK], phy->clks[CLKTF_CLK]->rate); |
| 1792 |
phy->clks[RX_RFPLL_INT]->rate = ad9361_rfpll_int_recalc_rate(phy->ref_clk_scale[RX_RFPLL_INT], phy->clks[RX_REFCLK]->rate); |
| 1793 |
phy->clks[TX_RFPLL_INT]->rate = ad9361_rfpll_int_recalc_rate(phy->ref_clk_scale[TX_RFPLL_INT], phy->clks[TX_REFCLK]->rate); |
| 1794 |
phy->clks[RX_RFPLL_DUMMY]->rate = ad9361_rfpll_dummy_recalc_rate(phy->ref_clk_scale[RX_RFPLL_DUMMY]); |
| 1795 |
phy->clks[TX_RFPLL_DUMMY]->rate = ad9361_rfpll_dummy_recalc_rate(phy->ref_clk_scale[TX_RFPLL_DUMMY]); |
| 1796 |
phy->clks[RX_RFPLL]->rate = ad9361_rfpll_recalc_rate(phy->ref_clk_scale[RX_RFPLL]); |
| 1797 |
phy->clks[TX_RFPLL]->rate = ad9361_rfpll_recalc_rate(phy->ref_clk_scale[TX_RFPLL]); |
| 1798 |
|
| 1799 |
#ifndef AXI_ADC_NOT_PRESENT |
| 1800 |
axiadc_init(phy); |
| 1801 |
#endif |
| 1802 |
ad9361_setup(phy); |
| 1803 |
#ifndef AXI_ADC_NOT_PRESENT |
| 1804 |
|
| 1805 |
axiadc_post_setup(phy); |
| 1806 |
#endif |
| 1807 |
|
| 1808 |
return 0; |
| 1809 |
} |
| 1810 |
|
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
|
| 1818 |
|
| 1819 |
int32_t ad9361_do_mcs(struct ad9361_rf_phy *phy_master, struct ad9361_rf_phy *phy_slave) |
| 1820 |
{ |
| 1821 |
uint32_t ensm_mode; |
| 1822 |
int32_t step; |
| 1823 |
int32_t reg; |
| 1824 |
|
| 1825 |
if ((phy_master->dev_sel == ID_AD9363A) || |
| 1826 |
(phy_slave->dev_sel == ID_AD9363A)) { |
| 1827 |
printf("%s : MCS is not supported by AD9363!\n", __func__); |
| 1828 |
return -1; |
| 1829 |
} |
| 1830 |
|
| 1831 |
reg = ad9361_spi_read(phy_master->spi, REG_RX_CLOCK_DATA_DELAY); |
| 1832 |
ad9361_spi_write(phy_slave->spi, REG_RX_CLOCK_DATA_DELAY, reg); |
| 1833 |
reg = ad9361_spi_read(phy_master->spi, REG_TX_CLOCK_DATA_DELAY); |
| 1834 |
ad9361_spi_write(phy_slave->spi, REG_TX_CLOCK_DATA_DELAY, reg); |
| 1835 |
|
| 1836 |
ad9361_get_en_state_machine_mode(phy_master, &ensm_mode); |
| 1837 |
|
| 1838 |
ad9361_set_en_state_machine_mode(phy_master, ENSM_MODE_ALERT); |
| 1839 |
ad9361_set_en_state_machine_mode(phy_slave, ENSM_MODE_ALERT); |
| 1840 |
|
| 1841 |
for (step = 0; step <= 5; step++) |
| 1842 |
{ |
| 1843 |
ad9361_mcs(phy_slave, step); |
| 1844 |
ad9361_mcs(phy_master, step); |
| 1845 |
mdelay(100); |
| 1846 |
} |
| 1847 |
|
| 1848 |
ad9361_set_en_state_machine_mode(phy_master, ensm_mode); |
| 1849 |
ad9361_set_en_state_machine_mode(phy_slave, ensm_mode); |
| 1850 |
|
| 1851 |
return 0; |
| 1852 |
} |
| 1853 |
|
| 1854 |
|
| 1855 |
|
| 1856 |
|
| 1857 |
|
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
|
| 1863 |
|
| 1864 |
|
| 1865 |
int32_t ad9361_set_trx_fir_en_dis (struct ad9361_rf_phy *phy, |
| 1866 |
uint8_t en_dis) |
| 1867 |
{ |
| 1868 |
int32_t ret = 0; |
| 1869 |
|
| 1870 |
if ((phy->bypass_rx_fir == phy->bypass_tx_fir) && |
| 1871 |
(phy->bypass_rx_fir == !en_dis)) |
| 1872 |
return ret; |
| 1873 |
|
| 1874 |
phy->bypass_rx_fir = !en_dis; |
| 1875 |
phy->bypass_tx_fir = !en_dis; |
| 1876 |
ret = ad9361_validate_enable_fir(phy); |
| 1877 |
if (ret < 0) { |
| 1878 |
phy->bypass_rx_fir = true; |
| 1879 |
phy->bypass_tx_fir = true; |
| 1880 |
} |
| 1881 |
|
| 1882 |
return ret; |
| 1883 |
} |
| 1884 |
|
| 1885 |
|
| 1886 |
|
| 1887 |
|
| 1888 |
|
| 1889 |
|
| 1890 |
|
| 1891 |
|
| 1892 |
|
| 1893 |
|
| 1894 |
int32_t ad9361_set_trx_rate_gov (struct ad9361_rf_phy *phy, uint32_t rate_gov) |
| 1895 |
{ |
| 1896 |
if (rate_gov == 0) |
| 1897 |
phy->rate_governor = 0; |
| 1898 |
else |
| 1899 |
phy->rate_governor = 1; |
| 1900 |
|
| 1901 |
return 0; |
| 1902 |
} |
| 1903 |
|
| 1904 |
|
| 1905 |
|
| 1906 |
|
| 1907 |
|
| 1908 |
|
| 1909 |
|
| 1910 |
int32_t ad9361_get_trx_rate_gov (struct ad9361_rf_phy *phy, uint32_t *rate_gov) |
| 1911 |
{ |
| 1912 |
*rate_gov = phy->rate_governor; |
| 1913 |
|
| 1914 |
return 0; |
| 1915 |
} |
| 1916 |
|
| 1917 |
|
| 1918 |
|
| 1919 |
|
| 1920 |
|
| 1921 |
|
| 1922 |
|
| 1923 |
|
| 1924 |
|
| 1925 |
|
| 1926 |
|
| 1927 |
|
| 1928 |
|
| 1929 |
int32_t ad9361_do_calib(struct ad9361_rf_phy *phy, uint32_t cal, int32_t arg) |
| 1930 |
{ |
| 1931 |
return ad9361_do_calib_run(phy, cal, arg); |
| 1932 |
} |
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
|
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
|
| 1943 |
int32_t ad9361_trx_load_enable_fir(struct ad9361_rf_phy *phy, |
| 1944 |
AD9361_RXFIRConfig rx_fir_cfg, |
| 1945 |
AD9361_TXFIRConfig tx_fir_cfg) |
| 1946 |
{ |
| 1947 |
int32_t rtx = -1, rrx = -1; |
| 1948 |
|
| 1949 |
phy->filt_rx_bw_Hz = 0; |
| 1950 |
phy->filt_tx_bw_Hz = 0; |
| 1951 |
phy->filt_valid = false; |
| 1952 |
|
| 1953 |
if (tx_fir_cfg.tx_path_clks[TX_SAMPL_FREQ]) { |
| 1954 |
memcpy(phy->filt_tx_path_clks, tx_fir_cfg.tx_path_clks, |
| 1955 |
sizeof(phy->filt_tx_path_clks)); |
| 1956 |
rtx = 0; |
| 1957 |
} |
| 1958 |
|
| 1959 |
if (rx_fir_cfg.rx_path_clks[RX_SAMPL_FREQ]) { |
| 1960 |
memcpy(phy->filt_rx_path_clks, rx_fir_cfg.rx_path_clks, |
| 1961 |
sizeof(phy->filt_rx_path_clks)); |
| 1962 |
rrx = 0; |
| 1963 |
} |
| 1964 |
|
| 1965 |
if (tx_fir_cfg.tx_bandwidth) { |
| 1966 |
phy->filt_tx_bw_Hz = tx_fir_cfg.tx_bandwidth; |
| 1967 |
} |
| 1968 |
|
| 1969 |
if (rx_fir_cfg.rx_bandwidth) { |
| 1970 |
phy->filt_rx_bw_Hz = rx_fir_cfg.rx_bandwidth; |
| 1971 |
} |
| 1972 |
|
| 1973 |
ad9361_set_tx_fir_config(phy, tx_fir_cfg); |
| 1974 |
ad9361_set_rx_fir_config(phy, rx_fir_cfg); |
| 1975 |
|
| 1976 |
if (!(rrx | rtx)) |
| 1977 |
phy->filt_valid = true; |
| 1978 |
|
| 1979 |
ad9361_set_trx_fir_en_dis(phy, 1); |
| 1980 |
|
| 1981 |
return 0; |
| 1982 |
} |
| 1983 |
|
| 1984 |
|
| 1985 |
|
| 1986 |
|
| 1987 |
|
| 1988 |
|
| 1989 |
|
| 1990 |
int32_t ad9361_do_dcxo_tune_coarse(struct ad9361_rf_phy *phy, |
| 1991 |
uint32_t coarse) |
| 1992 |
{ |
| 1993 |
phy->pdata->dcxo_coarse = coarse; |
| 1994 |
|
| 1995 |
return ad9361_set_dcxo_tune(phy, phy->pdata->dcxo_coarse, |
| 1996 |
phy->pdata->dcxo_fine); |
| 1997 |
} |
| 1998 |
|
| 1999 |
|
| 2000 |
|
| 2001 |
|
| 2002 |
|
| 2003 |
|
| 2004 |
|
| 2005 |
int32_t ad9361_do_dcxo_tune_fine(struct ad9361_rf_phy *phy, |
| 2006 |
uint32_t fine) |
| 2007 |
{ |
| 2008 |
phy->pdata->dcxo_fine = fine; |
| 2009 |
|
| 2010 |
return ad9361_set_dcxo_tune(phy, phy->pdata->dcxo_coarse, |
| 2011 |
phy->pdata->dcxo_fine); |
| 2012 |
} |