chore: remove redundant driver and hw config code.
This commit is contained in:
@@ -82,101 +82,6 @@
|
|||||||
// INTC configis
|
// INTC configis
|
||||||
#define INTC_DEVICE_ID XPAR_SCUGIC_0_DEVICE_ID
|
#define INTC_DEVICE_ID XPAR_SCUGIC_0_DEVICE_ID
|
||||||
|
|
||||||
// AD9361 Configuration
|
|
||||||
#define SPI_INTERFACE_SPI_ENGINE
|
|
||||||
#define HAVE_SPLIT_GAIN_TABLE 1 /* only set to 0 in case split_gain_table_mode_enable = 0*/
|
|
||||||
#define HAVE_TDD_SYNTH_TABLE 1 /* only set to 0 in case split_gain_table_mode_enable = 0*/
|
|
||||||
#define AD9361_DEVICE 1 /* set it 1 if AD9361 device is used, 0 otherwise */
|
|
||||||
#define AD9364_DEVICE 0 /* set it 1 if AD9364 device is used, 0 otherwise */
|
|
||||||
#define AD9363A_DEVICE 0 /* set it 1 if AD9363A device is used, 0 otherwise */
|
|
||||||
#define HAVE_VERBOSE_MESSAGES /* Recommended during development prints errors and warnings */
|
|
||||||
// #define HAVE_DEBUG_MESSAGES /* For Debug purposes only */
|
|
||||||
// -- AD9361 SPI Engine Configuration
|
|
||||||
#define AD9361_SPI_DEVICE_ID 0
|
|
||||||
#define AD9361_SPI_ENGINE_REF_CLK FCLK_CLK0_HZ
|
|
||||||
#define AD9361_SPI_ENGINE_MAX_SPEED 5000000
|
|
||||||
#define AD9361_SPI_ENGINE_BASEADDR XPAR_AXI_SPI_ENGINE_AXI_SPI_ENGINE_BASEADDR
|
|
||||||
#define AD9361_SPI_ENGINE_DATA_WIDTH 8
|
|
||||||
#define AD9361_SPI_ENGINE_CS_DELAY 3
|
|
||||||
#define AD9361_SPI_CS_AD9361_1 0x01
|
|
||||||
#define AD9361_SPI_CS_AD9361_2 0x02
|
|
||||||
#define AD9361_TIMEOUT_TH 2000
|
|
||||||
// AD9361 GPIO Configurations
|
|
||||||
#define AD9361_GPIO_DEVICE_ID 0
|
|
||||||
#define AD9361_GPIO_OFFSET 54
|
|
||||||
#define AD9361_GPIO_INPUT 0
|
|
||||||
#define AD9361_GPIO_OUTPUT 1
|
|
||||||
#define AD9361_GPIO_DISABLE 0
|
|
||||||
#define AD9361_GPIO_ENABLE 1
|
|
||||||
// -- AD9361-1
|
|
||||||
#define AD9361_1_TXNRX (AD9361_GPIO_OFFSET + 6)
|
|
||||||
#define AD9361_1_ENABLE (AD9361_GPIO_OFFSET + 7)
|
|
||||||
#define AD9361_1_EN_AGC (AD9361_GPIO_OFFSET + 8)
|
|
||||||
#define AD9361_1_RESET_B (AD9361_GPIO_OFFSET + 9)
|
|
||||||
#define AD9361_1_CTRL_OUT0 (AD9361_GPIO_OFFSET + 10)
|
|
||||||
#define AD9361_1_CTRL_OUT1 (AD9361_GPIO_OFFSET + 11)
|
|
||||||
#define AD9361_1_CTRL_OUT2 (AD9361_GPIO_OFFSET + 12)
|
|
||||||
#define AD9361_1_CTRL_OUT3 (AD9361_GPIO_OFFSET + 13)
|
|
||||||
#define AD9361_1_CTRL_OUT4 (AD9361_GPIO_OFFSET + 14)
|
|
||||||
#define AD9361_1_CTRL_OUT5 (AD9361_GPIO_OFFSET + 15)
|
|
||||||
#define AD9361_1_CTRL_OUT6 (AD9361_GPIO_OFFSET + 16)
|
|
||||||
#define AD9361_1_CTRL_OUT7 (AD9361_GPIO_OFFSET + 17)
|
|
||||||
#define AD9361_1_CTRL_IN0 (AD9361_GPIO_OFFSET + 18)
|
|
||||||
#define AD9361_1_CTRL_IN1 (AD9361_GPIO_OFFSET + 19)
|
|
||||||
#define AD9361_1_CTRL_IN2 (AD9361_GPIO_OFFSET + 20)
|
|
||||||
#define AD9361_1_CTRL_IN3 (AD9361_GPIO_OFFSET + 21)
|
|
||||||
// AD9361-2
|
|
||||||
#define AD9361_2_TXNRX (AD9361_GPIO_OFFSET + 22)
|
|
||||||
#define AD9361_2_ENABLE (AD9361_GPIO_OFFSET + 23)
|
|
||||||
#define AD9361_2_EN_AGC (AD9361_GPIO_OFFSET + 24)
|
|
||||||
#define AD9361_2_RESET_B (AD9361_GPIO_OFFSET + 25)
|
|
||||||
#define AD9361_2_CTRL_OUT0 (AD9361_GPIO_OFFSET + 26)
|
|
||||||
#define AD9361_2_CTRL_OUT1 (AD9361_GPIO_OFFSET + 27)
|
|
||||||
#define AD9361_2_CTRL_OUT2 (AD9361_GPIO_OFFSET + 28)
|
|
||||||
#define AD9361_2_CTRL_OUT3 (AD9361_GPIO_OFFSET + 29)
|
|
||||||
#define AD9361_2_CTRL_OUT4 (AD9361_GPIO_OFFSET + 30)
|
|
||||||
#define AD9361_2_CTRL_OUT5 (AD9361_GPIO_OFFSET + 31)
|
|
||||||
#define AD9361_2_CTRL_OUT6 (AD9361_GPIO_OFFSET + 32)
|
|
||||||
#define AD9361_2_CTRL_OUT7 (AD9361_GPIO_OFFSET + 33)
|
|
||||||
#define AD9361_2_CTRL_IN0 (AD9361_GPIO_OFFSET + 34)
|
|
||||||
#define AD9361_2_CTRL_IN1 (AD9361_GPIO_OFFSET + 35)
|
|
||||||
#define AD9361_2_CTRL_IN2 (AD9361_GPIO_OFFSET + 36)
|
|
||||||
#define AD9361_2_CTRL_IN3 (AD9361_GPIO_OFFSET + 37)
|
|
||||||
// AD9361-Status Code
|
|
||||||
#define AD9361_SYNC (AD9361_GPIO_OFFSET + 38)
|
|
||||||
#define AD9361_RX_FIFO_RST (AD9361_GPIO_OFFSET + 39)
|
|
||||||
#define AD9361_1_CAL_START (AD9361_GPIO_OFFSET + 40)
|
|
||||||
#define AD9361_2_CAL_START (AD9361_GPIO_OFFSET + 41)
|
|
||||||
#define AD9361_RECAL (AD9361_GPIO_OFFSET + 42)
|
|
||||||
#define AD9361_TX_SWITCH (AD9361_GPIO_OFFSET + 43)
|
|
||||||
#define AD9361_1_CAL_DONE (AD9361_GPIO_OFFSET + 44)
|
|
||||||
#define AD9361_2_CAL_DONE (AD9361_GPIO_OFFSET + 45)
|
|
||||||
#define AD9361_CAL_RESULT (AD9361_GPIO_OFFSET + 46)
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
TX_FREQ_125,
|
|
||||||
TX_FREQ_126,
|
|
||||||
TX_FREQ_4125
|
|
||||||
} ad9361TxFreq;
|
|
||||||
|
|
||||||
// HMC7044 Configurations
|
|
||||||
#define HMC7044_GPIO_DEVICE_ID 0
|
|
||||||
#define HMC7044_GPIO_OFFSET 54
|
|
||||||
#define HMC7044_RESET (HMC7044_GPIO_OFFSET + 0)
|
|
||||||
#define HMC7044_SYNC (HMC7044_GPIO_OFFSET + 1)
|
|
||||||
#define HMC7044_GPIO_0 (HMC7044_GPIO_OFFSET + 2)
|
|
||||||
#define HMC7044_GPIO_1 (HMC7044_GPIO_OFFSET + 3)
|
|
||||||
#define HMC7044_GPIO_2 (HMC7044_GPIO_OFFSET + 4)
|
|
||||||
#define HMC7044_GPIO_3 (HMC7044_GPIO_OFFSET + 5)
|
|
||||||
// -- HMC7044 SPI Engine Configuration
|
|
||||||
#define HMC7044_SPI_DEVICE_ID 0
|
|
||||||
#define HMC7044_SPI_ENGINE_REF_CLK FCLK_CLK0_HZ
|
|
||||||
#define HMC7044_SPI_ENGINE_MAX_SPEED 5000000
|
|
||||||
#define HMC7044_SPI_ENGINE_BASEADDR XPAR_AXI_SPI_ENGINE_AXI_SPI_ENGINE_BASEADDR
|
|
||||||
#define HMC7044_SPI_ENGINE_DATA_WIDTH 8
|
|
||||||
#define HMC7044_SPI_ENGINE_CS_DELAY 3
|
|
||||||
#define HMC7044_SPI_CS_HMC7044 0x00
|
|
||||||
|
|
||||||
// Configuration Check
|
// Configuration Check
|
||||||
#if defined(PHY_BEAM_SET_PRESET) && !defined(PHY_BEAM_FORMING_ENABLE)
|
#if defined(PHY_BEAM_SET_PRESET) && !defined(PHY_BEAM_FORMING_ENABLE)
|
||||||
|
|||||||
@@ -1,340 +0,0 @@
|
|||||||
#include "dev_profile.h"
|
|
||||||
#include "../config/app_config.h"
|
|
||||||
#include "../drivers/rf-transceiver/ad9361/ad9361_api.h"
|
|
||||||
#include "../drivers/axi_core/spi_engine/spi_engine.h"
|
|
||||||
#include "../drivers/platform/xilinx_gpio.h"
|
|
||||||
|
|
||||||
struct spi_engine_init_param spi_engine_param = {
|
|
||||||
.ref_clk_hz = AD9361_SPI_ENGINE_REF_CLK,
|
|
||||||
.type = SPI_ENGINE,
|
|
||||||
.spi_engine_baseaddr = AD9361_SPI_ENGINE_BASEADDR,
|
|
||||||
.cs_delay = AD9361_SPI_ENGINE_CS_DELAY,
|
|
||||||
.data_width = AD9361_SPI_ENGINE_DATA_WIDTH
|
|
||||||
};
|
|
||||||
|
|
||||||
struct xil_gpio_init_param xil_gpio_param = {
|
|
||||||
.type = GPIO_PS,
|
|
||||||
.device_id = AD9361_GPIO_DEVICE_ID
|
|
||||||
};
|
|
||||||
|
|
||||||
AD9361_InitParam ad9361_default_init_param = {
|
|
||||||
/* Device selection */
|
|
||||||
ID_AD9361, // dev_sel
|
|
||||||
/* Reference Clock */
|
|
||||||
48000000UL, //reference_clk_rate
|
|
||||||
/* Base Configuration */
|
|
||||||
1, //two_rx_two_tx_mode_enable *** adi,2rx-2tx-mode-enable
|
|
||||||
1, //one_rx_one_tx_mode_use_rx_num *** adi,1rx-1tx-mode-use-rx-num
|
|
||||||
1, //one_rx_one_tx_mode_use_tx_num *** adi,1rx-1tx-mode-use-tx-num
|
|
||||||
1, //frequency_division_duplex_mode_enable *** adi,frequency-division-duplex-mode-enable
|
|
||||||
0, //frequency_division_duplex_independent_mode_enable *** adi,frequency-division-duplex-independent-mode-enable
|
|
||||||
0, //tdd_use_dual_synth_mode_enable *** adi,tdd-use-dual-synth-mode-enable
|
|
||||||
0, //tdd_skip_vco_cal_enable *** adi,tdd-skip-vco-cal-enable
|
|
||||||
0, //tx_fastlock_delay_ns *** adi,tx-fastlock-delay-ns
|
|
||||||
0, //rx_fastlock_delay_ns *** adi,rx-fastlock-delay-ns
|
|
||||||
0, //rx_fastlock_pincontrol_enable *** adi,rx-fastlock-pincontrol-enable
|
|
||||||
0, //tx_fastlock_pincontrol_enable *** adi,tx-fastlock-pincontrol-enable
|
|
||||||
0, //external_rx_lo_enable *** adi,external-rx-lo-enable
|
|
||||||
0, //external_tx_lo_enable *** adi,external-tx-lo-enable
|
|
||||||
5, //dc_offset_tracking_update_event_mask *** adi,dc-offset-tracking-update-event-mask
|
|
||||||
6, //dc_offset_attenuation_high_range *** adi,dc-offset-attenuation-high-range
|
|
||||||
5, //dc_offset_attenuation_low_range *** adi,dc-offset-attenuation-low-range
|
|
||||||
0x28, //dc_offset_count_high_range *** adi,dc-offset-count-high-range
|
|
||||||
0x32, //dc_offset_count_low_range *** adi,dc-offset-count-low-range
|
|
||||||
0, //split_gain_table_mode_enable *** adi,split-gain-table-mode-enable
|
|
||||||
MAX_SYNTH_FREF, //trx_synthesizer_target_fref_overwrite_hz *** adi,trx-synthesizer-target-fref-overwrite-hz
|
|
||||||
0, // qec_tracking_slow_mode_enable *** adi,qec-tracking-slow-mode-enable
|
|
||||||
/* ENSM Control */
|
|
||||||
0, //ensm_enable_pin_pulse_mode_enable *** adi,ensm-enable-pin-pulse-mode-enable
|
|
||||||
0, //ensm_enable_txnrx_control_enable *** adi,ensm-enable-txnrx-control-enable
|
|
||||||
/* LO Control */
|
|
||||||
4125000000UL, //rx_synthesizer_frequency_hz *** adi,rx-synthesizer-frequency-hz
|
|
||||||
4126000000UL, //tx_synthesizer_frequency_hz *** adi,tx-synthesizer-frequency-hz
|
|
||||||
1, //tx_lo_powerdown_managed_enable *** adi,tx-lo-powerdown-managed-enable
|
|
||||||
/* Rate & BW Control */
|
|
||||||
{768000000, 192000000, 96000000, 48000000, 24000000, 24000000},// rx_path_clock_frequencies[6] *** adi,rx-path-clock-frequencies
|
|
||||||
{768000000, 192000000, 96000000, 48000000, 24000000, 24000000},// tx_path_clock_frequencies[6] *** adi,tx-path-clock-frequencies
|
|
||||||
18000000,//rf_rx_bandwidth_hz *** adi,rf-rx-bandwidth-hz
|
|
||||||
18000000,//rf_tx_bandwidth_hz *** adi,rf-tx-bandwidth-hz
|
|
||||||
/* RF Port Control */
|
|
||||||
0, //rx_rf_port_input_select *** adi,rx-rf-port-input-select
|
|
||||||
0, //tx_rf_port_input_select *** adi,tx-rf-port-input-select
|
|
||||||
/* TX Attenuation Control */
|
|
||||||
10000, //tx_attenuation_mdB *** adi,tx-attenuation-mdB
|
|
||||||
0, //update_tx_gain_in_alert_enable *** adi,update-tx-gain-in-alert-enable
|
|
||||||
/* Reference Clock Control */
|
|
||||||
0, //xo_disable_use_ext_refclk_enable *** adi,xo-disable-use-ext-refclk-enable
|
|
||||||
{8, 5920}, //dcxo_coarse_and_fine_tune[2] *** adi,dcxo-coarse-and-fine-tune
|
|
||||||
CLKOUT_DISABLE, //clk_output_mode_select *** adi,clk-output-mode-select
|
|
||||||
/* Gain Control */
|
|
||||||
2, //gc_rx1_mode *** adi,gc-rx1-mode
|
|
||||||
2, //gc_rx2_mode *** adi,gc-rx2-mode
|
|
||||||
58, //gc_adc_large_overload_thresh *** adi,gc-adc-large-overload-thresh
|
|
||||||
4, //gc_adc_ovr_sample_size *** adi,gc-adc-ovr-sample-size
|
|
||||||
47, //gc_adc_small_overload_thresh *** adi,gc-adc-small-overload-thresh
|
|
||||||
8192, //gc_dec_pow_measurement_duration *** adi,gc-dec-pow-measurement-duration
|
|
||||||
0, //gc_dig_gain_enable *** adi,gc-dig-gain-enable
|
|
||||||
800, //gc_lmt_overload_high_thresh *** adi,gc-lmt-overload-high-thresh
|
|
||||||
704, //gc_lmt_overload_low_thresh *** adi,gc-lmt-overload-low-thresh
|
|
||||||
24, //gc_low_power_thresh *** adi,gc-low-power-thresh
|
|
||||||
15, //gc_max_dig_gain *** adi,gc-max-dig-gain
|
|
||||||
0, //gc_use_rx_fir_out_for_dec_pwr_meas_enable *** adi,gc-use-rx-fir-out-for-dec-pwr-meas-enable
|
|
||||||
/* Gain MGC Control */
|
|
||||||
2, //mgc_dec_gain_step *** adi,mgc-dec-gain-step
|
|
||||||
2, //mgc_inc_gain_step *** adi,mgc-inc-gain-step
|
|
||||||
0, //mgc_rx1_ctrl_inp_enable *** adi,mgc-rx1-ctrl-inp-enable
|
|
||||||
0, //mgc_rx2_ctrl_inp_enable *** adi,mgc-rx2-ctrl-inp-enable
|
|
||||||
0, //mgc_split_table_ctrl_inp_gain_mode *** adi,mgc-split-table-ctrl-inp-gain-mode
|
|
||||||
/* Gain AGC Control */
|
|
||||||
10, //agc_adc_large_overload_exceed_counter *** adi,agc-adc-large-overload-exceed-counter
|
|
||||||
2, //agc_adc_large_overload_inc_steps *** adi,agc-adc-large-overload-inc-steps
|
|
||||||
0, //agc_adc_lmt_small_overload_prevent_gain_inc_enable *** adi,agc-adc-lmt-small-overload-prevent-gain-inc-enable
|
|
||||||
10, //agc_adc_small_overload_exceed_counter *** adi,agc-adc-small-overload-exceed-counter
|
|
||||||
4, //agc_dig_gain_step_size *** adi,agc-dig-gain-step-size
|
|
||||||
3, //agc_dig_saturation_exceed_counter *** adi,agc-dig-saturation-exceed-counter
|
|
||||||
1000, // agc_gain_update_interval_us *** adi,agc-gain-update-interval-us
|
|
||||||
0, //agc_immed_gain_change_if_large_adc_overload_enable *** adi,agc-immed-gain-change-if-large-adc-overload-enable
|
|
||||||
0, //agc_immed_gain_change_if_large_lmt_overload_enable *** adi,agc-immed-gain-change-if-large-lmt-overload-enable
|
|
||||||
10, //agc_inner_thresh_high *** adi,agc-inner-thresh-high
|
|
||||||
1, //agc_inner_thresh_high_dec_steps *** adi,agc-inner-thresh-high-dec-steps
|
|
||||||
12, //agc_inner_thresh_low *** adi,agc-inner-thresh-low
|
|
||||||
1, //agc_inner_thresh_low_inc_steps *** adi,agc-inner-thresh-low-inc-steps
|
|
||||||
10, //agc_lmt_overload_large_exceed_counter *** adi,agc-lmt-overload-large-exceed-counter
|
|
||||||
2, //agc_lmt_overload_large_inc_steps *** adi,agc-lmt-overload-large-inc-steps
|
|
||||||
10, //agc_lmt_overload_small_exceed_counter *** adi,agc-lmt-overload-small-exceed-counter
|
|
||||||
5, //agc_outer_thresh_high *** adi,agc-outer-thresh-high
|
|
||||||
2, //agc_outer_thresh_high_dec_steps *** adi,agc-outer-thresh-high-dec-steps
|
|
||||||
18, //agc_outer_thresh_low *** adi,agc-outer-thresh-low
|
|
||||||
2, //agc_outer_thresh_low_inc_steps *** adi,agc-outer-thresh-low-inc-steps
|
|
||||||
1, //agc_attack_delay_extra_margin_us; *** adi,agc-attack-delay-extra-margin-us
|
|
||||||
0, //agc_sync_for_gain_counter_enable *** adi,agc-sync-for-gain-counter-enable
|
|
||||||
/* Fast AGC */
|
|
||||||
64, //fagc_dec_pow_measuremnt_duration *** adi,fagc-dec-pow-measurement-duration
|
|
||||||
260, //fagc_state_wait_time_ns *** adi,fagc-state-wait-time-ns
|
|
||||||
/* Fast AGC - Low Power */
|
|
||||||
0, //fagc_allow_agc_gain_increase *** adi,fagc-allow-agc-gain-increase-enable
|
|
||||||
5, //fagc_lp_thresh_increment_time *** adi,fagc-lp-thresh-increment-time
|
|
||||||
1, //fagc_lp_thresh_increment_steps *** adi,fagc-lp-thresh-increment-steps
|
|
||||||
/* Fast AGC - Lock Level (Lock Level is set via slow AGC inner high threshold) */
|
|
||||||
1, //fagc_lock_level_lmt_gain_increase_en *** adi,fagc-lock-level-lmt-gain-increase-enable
|
|
||||||
5, //fagc_lock_level_gain_increase_upper_limit *** adi,fagc-lock-level-gain-increase-upper-limit
|
|
||||||
/* Fast AGC - Peak Detectors and Final Settling */
|
|
||||||
1, //fagc_lpf_final_settling_steps *** adi,fagc-lpf-final-settling-steps
|
|
||||||
1, //fagc_lmt_final_settling_steps *** adi,fagc-lmt-final-settling-steps
|
|
||||||
3, //fagc_final_overrange_count *** adi,fagc-final-overrange-count
|
|
||||||
/* Fast AGC - Final Power Test */
|
|
||||||
0, //fagc_gain_increase_after_gain_lock_en *** adi,fagc-gain-increase-after-gain-lock-enable
|
|
||||||
/* Fast AGC - Unlocking the Gain */
|
|
||||||
0, //fagc_gain_index_type_after_exit_rx_mode *** adi,fagc-gain-index-type-after-exit-rx-mode
|
|
||||||
1, //fagc_use_last_lock_level_for_set_gain_en *** adi,fagc-use-last-lock-level-for-set-gain-enable
|
|
||||||
1, //fagc_rst_gla_stronger_sig_thresh_exceeded_en *** adi,fagc-rst-gla-stronger-sig-thresh-exceeded-enable
|
|
||||||
5, //fagc_optimized_gain_offset *** adi,fagc-optimized-gain-offset
|
|
||||||
10, //fagc_rst_gla_stronger_sig_thresh_above_ll *** adi,fagc-rst-gla-stronger-sig-thresh-above-ll
|
|
||||||
1, //fagc_rst_gla_engergy_lost_sig_thresh_exceeded_en *** adi,fagc-rst-gla-engergy-lost-sig-thresh-exceeded-enable
|
|
||||||
1, //fagc_rst_gla_engergy_lost_goto_optim_gain_en *** adi,fagc-rst-gla-engergy-lost-goto-optim-gain-enable
|
|
||||||
10, //fagc_rst_gla_engergy_lost_sig_thresh_below_ll *** adi,fagc-rst-gla-engergy-lost-sig-thresh-below-ll
|
|
||||||
8, //fagc_energy_lost_stronger_sig_gain_lock_exit_cnt *** adi,fagc-energy-lost-stronger-sig-gain-lock-exit-cnt
|
|
||||||
1, //fagc_rst_gla_large_adc_overload_en *** adi,fagc-rst-gla-large-adc-overload-enable
|
|
||||||
1, //fagc_rst_gla_large_lmt_overload_en *** adi,fagc-rst-gla-large-lmt-overload-enable
|
|
||||||
0, //fagc_rst_gla_en_agc_pulled_high_en *** adi,fagc-rst-gla-en-agc-pulled-high-enable
|
|
||||||
0, //fagc_rst_gla_if_en_agc_pulled_high_mode *** adi,fagc-rst-gla-if-en-agc-pulled-high-mode
|
|
||||||
64, //fagc_power_measurement_duration_in_state5 *** adi,fagc-power-measurement-duration-in-state5
|
|
||||||
2, //fagc_large_overload_inc_steps *** adi,fagc-adc-large-overload-inc-steps
|
|
||||||
/* RSSI Control */
|
|
||||||
1, //rssi_delay *** adi,rssi-delay
|
|
||||||
1000, //rssi_duration *** adi,rssi-duration
|
|
||||||
3, //rssi_restart_mode *** adi,rssi-restart-mode
|
|
||||||
0, //rssi_unit_is_rx_samples_enable *** adi,rssi-unit-is-rx-samples-enable
|
|
||||||
1, //rssi_wait *** adi,rssi-wait
|
|
||||||
/* Aux ADC Control */
|
|
||||||
256, //aux_adc_decimation *** adi,aux-adc-decimation
|
|
||||||
48000000UL, //aux_adc_rate *** adi,aux-adc-rate
|
|
||||||
/* AuxDAC Control */
|
|
||||||
1, //aux_dac_manual_mode_enable *** adi,aux-dac-manual-mode-enable
|
|
||||||
0, //aux_dac1_default_value_mV *** adi,aux-dac1-default-value-mV
|
|
||||||
0, //aux_dac1_active_in_rx_enable *** adi,aux-dac1-active-in-rx-enable
|
|
||||||
0, //aux_dac1_active_in_tx_enable *** adi,aux-dac1-active-in-tx-enable
|
|
||||||
0, //aux_dac1_active_in_alert_enable *** adi,aux-dac1-active-in-alert-enable
|
|
||||||
0, //aux_dac1_rx_delay_us *** adi,aux-dac1-rx-delay-us
|
|
||||||
0, //aux_dac1_tx_delay_us *** adi,aux-dac1-tx-delay-us
|
|
||||||
0, //aux_dac2_default_value_mV *** adi,aux-dac2-default-value-mV
|
|
||||||
0, //aux_dac2_active_in_rx_enable *** adi,aux-dac2-active-in-rx-enable
|
|
||||||
0, //aux_dac2_active_in_tx_enable *** adi,aux-dac2-active-in-tx-enable
|
|
||||||
0, //aux_dac2_active_in_alert_enable *** adi,aux-dac2-active-in-alert-enable
|
|
||||||
0, //aux_dac2_rx_delay_us *** adi,aux-dac2-rx-delay-us
|
|
||||||
0, //aux_dac2_tx_delay_us *** adi,aux-dac2-tx-delay-us
|
|
||||||
/* Temperature Sensor Control */
|
|
||||||
256, //temp_sense_decimation *** adi,temp-sense-decimation
|
|
||||||
1000, //temp_sense_measurement_interval_ms *** adi,temp-sense-measurement-interval-ms
|
|
||||||
0xCE, //temp_sense_offset_signed *** adi,temp-sense-offset-signed
|
|
||||||
1, //temp_sense_periodic_measurement_enable *** adi,temp-sense-periodic-measurement-enable
|
|
||||||
/* Control Out Setup */
|
|
||||||
0xFF, //ctrl_outs_enable_mask *** adi,ctrl-outs-enable-mask
|
|
||||||
0, //ctrl_outs_index *** adi,ctrl-outs-index
|
|
||||||
/* External LNA Control */
|
|
||||||
0, //elna_settling_delay_ns *** adi,elna-settling-delay-ns
|
|
||||||
0, //elna_gain_mdB *** adi,elna-gain-mdB
|
|
||||||
0, //elna_bypass_loss_mdB *** adi,elna-bypass-loss-mdB
|
|
||||||
0, //elna_rx1_gpo0_control_enable *** adi,elna-rx1-gpo0-control-enable
|
|
||||||
0, //elna_rx2_gpo1_control_enable *** adi,elna-rx2-gpo1-control-enable
|
|
||||||
0, //elna_gaintable_all_index_enable *** adi,elna-gaintable-all-index-enable
|
|
||||||
/* Digital Interface Control */
|
|
||||||
0, //digital_interface_tune_skip_mode *** adi,digital-interface-tune-skip-mode
|
|
||||||
0, //digital_interface_tune_fir_disable *** adi,digital-interface-tune-fir-disable
|
|
||||||
1, //pp_tx_swap_enable *** adi,pp-tx-swap-enable
|
|
||||||
1, //pp_rx_swap_enable *** adi,pp-rx-swap-enable
|
|
||||||
0, //tx_channel_swap_enable *** adi,tx-channel-swap-enable
|
|
||||||
0, //rx_channel_swap_enable *** adi,rx-channel-swap-enable
|
|
||||||
1, //rx_frame_pulse_mode_enable *** adi,rx-frame-pulse-mode-enable
|
|
||||||
0, //two_t_two_r_timing_enable *** adi,2t2r-timing-enable
|
|
||||||
0, //invert_data_bus_enable *** adi,invert-data-bus-enable
|
|
||||||
0, //invert_data_clk_enable *** adi,invert-data-clk-enable
|
|
||||||
0, //fdd_alt_word_order_enable *** adi,fdd-alt-word-order-enable
|
|
||||||
0, //invert_rx_frame_enable *** adi,invert-rx-frame-enable
|
|
||||||
0, //fdd_rx_rate_2tx_enable *** adi,fdd-rx-rate-2tx-enable
|
|
||||||
0, //swap_ports_enable *** adi,swap-ports-enable
|
|
||||||
0, //single_data_rate_enable *** adi,single-data-rate-enable
|
|
||||||
1, //lvds_mode_enable *** adi,lvds-mode-enable
|
|
||||||
0, //half_duplex_mode_enable *** adi,half-duplex-mode-enable
|
|
||||||
0, //single_port_mode_enable *** adi,single-port-mode-enable
|
|
||||||
0, //full_port_enable *** adi,full-port-enable
|
|
||||||
0, //full_duplex_swap_bits_enable *** adi,full-duplex-swap-bits-enable
|
|
||||||
0, //delay_rx_data *** adi,delay-rx-data
|
|
||||||
0, //rx_data_clock_delay *** adi,rx-data-clock-delay
|
|
||||||
4, //rx_data_delay *** adi,rx-data-delay
|
|
||||||
7, //tx_fb_clock_delay *** adi,tx-fb-clock-delay
|
|
||||||
0, //tx_data_delay *** adi,tx-data-delay
|
|
||||||
150, //lvds_bias_mV *** adi,lvds-bias-mV
|
|
||||||
1, //lvds_rx_onchip_termination_enable *** adi,lvds-rx-onchip-termination-enable
|
|
||||||
0, //rx1rx2_phase_inversion_en *** adi,rx1-rx2-phase-inversion-enable
|
|
||||||
0xFF, //lvds_invert1_control *** adi,lvds-invert1-control
|
|
||||||
0x0F, //lvds_invert2_control *** adi,lvds-invert2-control
|
|
||||||
/* GPO Control */
|
|
||||||
0, //gpo_manual_mode_enable *** adi,gpo-manual-mode-enable
|
|
||||||
0, //gpo_manual_mode_enable_mask *** adi,gpo-manual-mode-enable-mask
|
|
||||||
0, //gpo0_inactive_state_high_enable *** adi,gpo0-inactive-state-high-enable
|
|
||||||
0, //gpo1_inactive_state_high_enable *** adi,gpo1-inactive-state-high-enable
|
|
||||||
0, //gpo2_inactive_state_high_enable *** adi,gpo2-inactive-state-high-enable
|
|
||||||
0, //gpo3_inactive_state_high_enable *** adi,gpo3-inactive-state-high-enable
|
|
||||||
0, //gpo0_slave_rx_enable *** adi,gpo0-slave-rx-enable
|
|
||||||
0, //gpo0_slave_tx_enable *** adi,gpo0-slave-tx-enable
|
|
||||||
0, //gpo1_slave_rx_enable *** adi,gpo1-slave-rx-enable
|
|
||||||
0, //gpo1_slave_tx_enable *** adi,gpo1-slave-tx-enable
|
|
||||||
0, //gpo2_slave_rx_enable *** adi,gpo2-slave-rx-enable
|
|
||||||
0, //gpo2_slave_tx_enable *** adi,gpo2-slave-tx-enable
|
|
||||||
0, //gpo3_slave_rx_enable *** adi,gpo3-slave-rx-enable
|
|
||||||
0, //gpo3_slave_tx_enable *** adi,gpo3-slave-tx-enable
|
|
||||||
0, //gpo0_rx_delay_us *** adi,gpo0-rx-delay-us
|
|
||||||
0, //gpo0_tx_delay_us *** adi,gpo0-tx-delay-us
|
|
||||||
0, //gpo1_rx_delay_us *** adi,gpo1-rx-delay-us
|
|
||||||
0, //gpo1_tx_delay_us *** adi,gpo1-tx-delay-us
|
|
||||||
0, //gpo2_rx_delay_us *** adi,gpo2-rx-delay-us
|
|
||||||
0, //gpo2_tx_delay_us *** adi,gpo2-tx-delay-us
|
|
||||||
0, //gpo3_rx_delay_us *** adi,gpo3-rx-delay-us
|
|
||||||
0, //gpo3_tx_delay_us *** adi,gpo3-tx-delay-us
|
|
||||||
/* Tx Monitor Control */
|
|
||||||
37000, //low_high_gain_threshold_mdB *** adi,txmon-low-high-thresh
|
|
||||||
0, //low_gain_dB *** adi,txmon-low-gain
|
|
||||||
24, //high_gain_dB *** adi,txmon-high-gain
|
|
||||||
0, //tx_mon_track_en *** adi,txmon-dc-tracking-enable
|
|
||||||
0, //one_shot_mode_en *** adi,txmon-one-shot-mode-enable
|
|
||||||
511, //tx_mon_delay *** adi,txmon-delay
|
|
||||||
8192, //tx_mon_duration *** adi,txmon-duration
|
|
||||||
2, //tx1_mon_front_end_gain *** adi,txmon-1-front-end-gain
|
|
||||||
2, //tx2_mon_front_end_gain *** adi,txmon-2-front-end-gain
|
|
||||||
48, //tx1_mon_lo_cm *** adi,txmon-1-lo-cm
|
|
||||||
48, //tx2_mon_lo_cm *** adi,txmon-2-lo-cm
|
|
||||||
/* GPIO definitions */
|
|
||||||
/* Reset_b */
|
|
||||||
{
|
|
||||||
.number = AD9361_1_RESET_B,
|
|
||||||
.platform_ops = &xil_gpio_ops,
|
|
||||||
.extra = &xil_gpio_param
|
|
||||||
}, //gpio_resetb *** reset-gpios
|
|
||||||
/* MCS Sync */
|
|
||||||
{
|
|
||||||
.number = -1,
|
|
||||||
.platform_ops = &xil_gpio_ops,
|
|
||||||
.extra = &xil_gpio_param
|
|
||||||
}, //gpio_sync *** sync-gpios
|
|
||||||
/* Cal-SW1 */
|
|
||||||
{
|
|
||||||
.number = -1,
|
|
||||||
.platform_ops = &xil_gpio_ops,
|
|
||||||
.extra = &xil_gpio_param
|
|
||||||
}, //gpio_cal_sw1 *** cal-sw1-gpios
|
|
||||||
/* Cal-SW2 */
|
|
||||||
{
|
|
||||||
.number = -1,
|
|
||||||
.platform_ops = &xil_gpio_ops,
|
|
||||||
.extra = &xil_gpio_param
|
|
||||||
}, //gpio_cal_sw2 *** cal-sw2-gpios
|
|
||||||
|
|
||||||
{
|
|
||||||
.device_id = AD9361_SPI_DEVICE_ID,
|
|
||||||
.mode = SPI_MODE_1,
|
|
||||||
.chip_select = AD9361_SPI_CS_AD9361_1,
|
|
||||||
.platform_ops = &spi_eng_platform_ops,
|
|
||||||
.extra = &spi_engine_param
|
|
||||||
},
|
|
||||||
|
|
||||||
/* External LO clocks */
|
|
||||||
NULL, //(*ad9361_rfpll_ext_recalc_rate)()
|
|
||||||
NULL, //(*ad9361_rfpll_ext_round_rate)()
|
|
||||||
NULL, //(*ad9361_rfpll_ext_set_rate)()
|
|
||||||
};
|
|
||||||
|
|
||||||
AD9361_RXFIRConfig rx_fir_config = { // BPF PASSBAND 3/20 fs to 1/4 fs
|
|
||||||
3, // rx
|
|
||||||
0, // rx_gain
|
|
||||||
1, // rx_dec
|
|
||||||
{
|
|
||||||
-4, -6, -37, 35, 186, 86, -284, -315,
|
|
||||||
107, 219, -4, 271, 558, -307, -1182, -356,
|
|
||||||
658, 157, 207, 1648, 790, -2525, -2553, 748,
|
|
||||||
865, -476, 3737, 6560, -3583, -14731, -5278, 14819,
|
|
||||||
14819, -5278, -14731, -3583, 6560, 3737, -476, 865,
|
|
||||||
748, -2553, -2525, 790, 1648, 207, 157, 658,
|
|
||||||
-356, -1182, -307, 558, 271, -4, 219, 107,
|
|
||||||
-315, -284, 86, 186, 35, -37, -6, -4,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
}, // rx_coef[128]
|
|
||||||
64, // rx_coef_size
|
|
||||||
{0, 0, 0, 0, 0, 0}, //rx_path_clks[6]
|
|
||||||
0 // rx_bandwidth
|
|
||||||
};
|
|
||||||
|
|
||||||
AD9361_TXFIRConfig tx_fir_config = { // BPF PASSBAND 3/20 fs to 1/4 fs
|
|
||||||
3, // tx
|
|
||||||
-6, // tx_gain
|
|
||||||
1, // tx_int
|
|
||||||
{
|
|
||||||
-4, -6, -37, 35, 186, 86, -284, -315,
|
|
||||||
107, 219, -4, 271, 558, -307, -1182, -356,
|
|
||||||
658, 157, 207, 1648, 790, -2525, -2553, 748,
|
|
||||||
865, -476, 3737, 6560, -3583, -14731, -5278, 14819,
|
|
||||||
14819, -5278, -14731, -3583, 6560, 3737, -476, 865,
|
|
||||||
748, -2553, -2525, 790, 1648, 207, 157, 658,
|
|
||||||
-356, -1182, -307, 558, 271, -4, 219, 107,
|
|
||||||
-315, -284, 86, 186, 35, -37, -6, -4,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0
|
|
||||||
}, // tx_coef[128]
|
|
||||||
64, // tx_coef_size
|
|
||||||
{0, 0, 0, 0, 0, 0}, // tx_path_clks[6]
|
|
||||||
0 // tx_bandwidth
|
|
||||||
};
|
|
||||||
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -3,25 +3,9 @@
|
|||||||
|
|
||||||
#include "irq.h"
|
#include "irq.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "../drivers/rf-transceiver/ad9361/ad9361_api.h"
|
|
||||||
#include "../drivers/rf-transceiver/ad9361_reg/ad9361_reg.h"
|
|
||||||
#include "../drivers/frequency/hmc7044/hmc7044.h"
|
|
||||||
#include "../drivers/adc/ad9694/ad9694.h"
|
|
||||||
#include "../config/app_config.h"
|
|
||||||
|
|
||||||
// device parameters
|
// device parameters
|
||||||
extern struct irq_init_param intc_init_param;
|
extern struct irq_init_param intc_init_param;
|
||||||
extern struct timer_init_param scutimer_init_param;
|
extern struct timer_init_param scutimer_init_param;
|
||||||
extern struct global_timer_init_param globaltimer_init_param;
|
extern struct global_timer_init_param globaltimer_init_param;
|
||||||
|
|
||||||
// HMC7044
|
|
||||||
extern struct hmc7044_init_param hmc7044_default_init_param;
|
|
||||||
|
|
||||||
// AD9361
|
|
||||||
extern AD9361_InitParam ad9361_default_init_param;
|
|
||||||
extern AD9361_RXFIRConfig rx_fir_config;
|
|
||||||
extern AD9361_TXFIRConfig tx_fir_config;
|
|
||||||
extern struct ad9361_reg_init_param ad9361_1_reg_default_init_param;
|
|
||||||
extern struct ad9361_reg_init_param ad9361_2_reg_default_init_param;
|
|
||||||
uint32_t ad9361_reg_config(struct ad9361_reg_dev *dev);
|
|
||||||
#endif /* SRC_DEV_PROFILE_H_ */
|
#endif /* SRC_DEV_PROFILE_H_ */
|
||||||
|
|||||||
@@ -1,132 +0,0 @@
|
|||||||
#include "dev_profile.h"
|
|
||||||
#include "../config/app_config.h"
|
|
||||||
#include "../drivers/platform/xilinx_gpio.h"
|
|
||||||
#include "../drivers/axi_core/spi_engine/spi_engine.h"
|
|
||||||
#include "../drivers/frequency/hmc7044/hmc7044.h"
|
|
||||||
|
|
||||||
|
|
||||||
static struct spi_engine_init_param spi_engine_param = {
|
|
||||||
.ref_clk_hz = HMC7044_SPI_ENGINE_REF_CLK,
|
|
||||||
.type = SPI_ENGINE,
|
|
||||||
.spi_engine_baseaddr = HMC7044_SPI_ENGINE_BASEADDR,
|
|
||||||
.cs_delay = HMC7044_SPI_ENGINE_CS_DELAY,
|
|
||||||
.data_width = HMC7044_SPI_ENGINE_DATA_WIDTH
|
|
||||||
};
|
|
||||||
|
|
||||||
//static struct xil_gpio_init_param xil_gpio_param = {
|
|
||||||
// .type = GPIO_PS,
|
|
||||||
// .device_id = AD9361_GPIO_DEVICE_ID
|
|
||||||
//};
|
|
||||||
|
|
||||||
// hmc7044 spi settings
|
|
||||||
static struct spi_init_param hmc7044_spi_init_param = {
|
|
||||||
.device_id = HMC7044_SPI_DEVICE_ID,
|
|
||||||
.max_speed_hz = HMC7044_SPI_ENGINE_MAX_SPEED,
|
|
||||||
.mode = SPI_MODE_4,
|
|
||||||
.chip_select = HMC7044_SPI_CS_HMC7044,
|
|
||||||
.platform_ops = &spi_eng_platform_ops,
|
|
||||||
.extra = &spi_engine_param
|
|
||||||
};
|
|
||||||
|
|
||||||
// hmc7044 channel specifications
|
|
||||||
struct hmc7044_chan_spec hmc7044_chan_spec[4] = {
|
|
||||||
/* AD9361_XTAL */
|
|
||||||
{
|
|
||||||
.disable = 0,
|
|
||||||
.num = 3,
|
|
||||||
.divider = 100,
|
|
||||||
.coarse_delay = 0,
|
|
||||||
.fine_delay = 0,
|
|
||||||
.high_performance_mode_dis = true,
|
|
||||||
.start_up_mode_dynamic_enable = false,
|
|
||||||
.dynamic_driver_enable = false,
|
|
||||||
.output_control0_rb4_enable = true,
|
|
||||||
.force_mute_enable = false,
|
|
||||||
.driver_mode = CML,
|
|
||||||
.driver_impedance = INTERNAL_100OHM_PER_PIN,
|
|
||||||
.out_mux_mode = CHANNEL_DIV
|
|
||||||
},
|
|
||||||
/* FPGA_DAC_LOGIC_CLK */
|
|
||||||
{
|
|
||||||
.disable = 0,
|
|
||||||
.num = 4,
|
|
||||||
.divider = 10,
|
|
||||||
.coarse_delay = 0,
|
|
||||||
.fine_delay = 0,
|
|
||||||
.high_performance_mode_dis = true,
|
|
||||||
.start_up_mode_dynamic_enable = false,
|
|
||||||
.dynamic_driver_enable = false,
|
|
||||||
.output_control0_rb4_enable = true,
|
|
||||||
.force_mute_enable = false,
|
|
||||||
.driver_mode = CML,
|
|
||||||
.driver_impedance = INTERNAL_100OHM_PER_PIN,
|
|
||||||
.out_mux_mode = CHANNEL_DIV
|
|
||||||
},
|
|
||||||
/* B_AD9361_XTAL */
|
|
||||||
{
|
|
||||||
.disable = 0,
|
|
||||||
.num = 12,
|
|
||||||
.divider = 100,
|
|
||||||
.coarse_delay = 0,
|
|
||||||
.fine_delay = 0,
|
|
||||||
.high_performance_mode_dis = false,
|
|
||||||
.start_up_mode_dynamic_enable = false,
|
|
||||||
.dynamic_driver_enable = false,
|
|
||||||
.output_control0_rb4_enable = true,
|
|
||||||
.force_mute_enable = false,
|
|
||||||
.driver_mode = CML,
|
|
||||||
.driver_impedance = INTERNAL_100OHM_PER_PIN,
|
|
||||||
.out_mux_mode = CHANNEL_DIV
|
|
||||||
},
|
|
||||||
/* AD9361_RX_EXT_LO */
|
|
||||||
{
|
|
||||||
.disable = 0,
|
|
||||||
.num = 13,
|
|
||||||
.divider = 10,
|
|
||||||
.coarse_delay = 0,
|
|
||||||
.fine_delay = 0,
|
|
||||||
.high_performance_mode_dis = false,
|
|
||||||
.start_up_mode_dynamic_enable = false,
|
|
||||||
.dynamic_driver_enable = false,
|
|
||||||
.output_control0_rb4_enable = true,
|
|
||||||
.force_mute_enable = false,
|
|
||||||
.driver_mode = CML,
|
|
||||||
.driver_impedance = INTERNAL_100OHM_PER_PIN,
|
|
||||||
.out_mux_mode = CHANNEL_DIV
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
// hmc7044 default configurations
|
|
||||||
struct hmc7044_init_param hmc7044_default_init_param = {
|
|
||||||
.spi_init = &hmc7044_spi_init_param,
|
|
||||||
.clkin_freq = {0, 100000000, 0, 0},
|
|
||||||
.vcxo_freq = 100000000,
|
|
||||||
.pll2_freq = 2500000000,
|
|
||||||
.pll1_loop_bw = 200,
|
|
||||||
.sysref_timer_div = 1536,
|
|
||||||
.in_buf_mode = {
|
|
||||||
BUFFER_DISABLE,
|
|
||||||
ENABLE_AC_COUPLE | ENABLE_INTERNAL_TERM | BUFFER_ENABLE,
|
|
||||||
BUFFER_DISABLE,
|
|
||||||
BUFFER_DISABLE,
|
|
||||||
ENABLE_AC_COUPLE | ENABLE_INTERNAL_TERM | BUFFER_ENABLE
|
|
||||||
},
|
|
||||||
.gpi_ctrl = {
|
|
||||||
GPI_DISABLE,
|
|
||||||
GPI_DISABLE,
|
|
||||||
CHIP_SLEEP_MODE,
|
|
||||||
PULSE_GEN_REQUSET
|
|
||||||
},
|
|
||||||
.gpo_ctrl = {
|
|
||||||
PLL1_LOCK_DETECT | GPO_CMOS_MODE,
|
|
||||||
PLL2_LOCK_DETECT | GPO_CMOS_MODE,
|
|
||||||
GPO_DISABLE,
|
|
||||||
GPO_DISABLE
|
|
||||||
},
|
|
||||||
.num_channels = 4,
|
|
||||||
.pll1_ref_prio_ctrl = 0xE4,
|
|
||||||
.sync_pin_mode = SYNC_MULTICHIP,
|
|
||||||
.high_performance_mode_clock_dist_en = false,
|
|
||||||
.pulse_gen_mode = PULSE_ONE,
|
|
||||||
.channels = hmc7044_chan_spec
|
|
||||||
};
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file ad9694.c
|
|
||||||
* @brief Implementation of AD9680 Driver.
|
|
||||||
* @author DBogdan ([email protected])
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2014-2016(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "ad9694.h"
|
|
||||||
#include "../../../include/error.h"
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief ad9694_read
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t ad9694_read(struct ad9694_dev *dev,
|
|
||||||
uint16_t reg_addr,
|
|
||||||
uint8_t *reg_data)
|
|
||||||
{
|
|
||||||
uint8_t tx_buf[2];
|
|
||||||
uint8_t rx_buf[1];
|
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
tx_buf[0] = 0x80 | (reg_addr >> 8);
|
|
||||||
tx_buf[1] = reg_addr & 0xFF;
|
|
||||||
|
|
||||||
|
|
||||||
ret = spi_write_and_read_3wire(dev->spi_desc,
|
|
||||||
tx_buf, rx_buf, 2, 1);
|
|
||||||
|
|
||||||
*reg_data = rx_buf[0];
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief ad9694_write
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t ad9694_write(struct ad9694_dev *dev,
|
|
||||||
uint16_t reg_addr,
|
|
||||||
uint8_t reg_data)
|
|
||||||
{
|
|
||||||
uint8_t buf[3];
|
|
||||||
|
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
buf[0] = reg_addr >> 8;
|
|
||||||
buf[1] = reg_addr & 0xFF;
|
|
||||||
buf[2] = reg_data;
|
|
||||||
|
|
||||||
ret = spi_write_and_read_3wire(dev->spi_desc,
|
|
||||||
buf, NULL, 3, 0);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief ad9694_init
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t ad9694_init(struct ad9694_dev **device,
|
|
||||||
const struct ad9694_init_param *init_param)
|
|
||||||
{
|
|
||||||
int ret = SUCCESS;
|
|
||||||
struct ad9694_dev *dev;
|
|
||||||
|
|
||||||
dev = (struct ad9694_dev *)malloc(sizeof(*dev));
|
|
||||||
if (!dev)
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
/* SPI */
|
|
||||||
ret = spi_init(&dev->spi_desc, init_param->spi_init);
|
|
||||||
|
|
||||||
*device = dev;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief Free the resources allocated by ad9694_setup().
|
|
||||||
*
|
|
||||||
* @param dev - The device structure.
|
|
||||||
*
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t ad9694_remove(struct ad9694_dev *dev)
|
|
||||||
{
|
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
ret = spi_remove(dev->spi_desc);
|
|
||||||
|
|
||||||
free(dev);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@@ -1,231 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file ad9694.h
|
|
||||||
* @brief Header file of AD9694 Driver.
|
|
||||||
* @author DBogdan ([email protected])
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2014-2016(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef AD9694_H_
|
|
||||||
#define AD9694_H_
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "delay.h"
|
|
||||||
#include "spi.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/********************** Macros and Constants Definitions **********************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#define AD9694_REG_GLOBAL_MAP_SPI_CONF_A 0x0000
|
|
||||||
#define AD9694_REG_GLOBAL_MAP_SPI_CONF_B 0x0001
|
|
||||||
#define AD9694_REG_CH_MAP_CHIP_CONF 0x0002
|
|
||||||
#define AD9694_REG_PAIR_MAP_CHIP_TYPE 0x0003
|
|
||||||
#define AD9694_REG_PAIR_MAP_CHIP_ID_LSB 0x0004
|
|
||||||
#define AD9694_REG_PAIR_MAP_CHIP_GRADE 0x0006
|
|
||||||
#define AD9694_REG_PAIR_MAP_DEV_INDEX 0x0008
|
|
||||||
#define AD9694_REG_GLOBAL_MAP_PAIR_INDEX 0x0009
|
|
||||||
#define AD9694_REG_PAIR_MAP_SCRATCH_PAD 0x000A
|
|
||||||
#define AD9694_REG_PAIR_MAP_SPI_REVISION 0x000B
|
|
||||||
#define AD9694_REG_PAIR_MAP_VENDOR_ID_LSB 0x000C
|
|
||||||
#define AD9694_REG_PAIR_MAP_VENDOR_ID_MSB 0x000D
|
|
||||||
#define AD9694_REG_CH_MAP_CHIP_PD_PIN 0x003F
|
|
||||||
#define AD9694_REG_PAIR_MAP_CHIP_PIN_CTRL_1 0x0040
|
|
||||||
#define AD9694_REG_PAIR_MAP_CLK_DIV_CTRL 0x0108
|
|
||||||
#define AD9694_REG_CH_MAP_CLK_DIV_PHASE 0x0109
|
|
||||||
#define AD9694_REG_PAIR_MAP_CLK_DIV_SYSREF_CTRL 0x010A
|
|
||||||
#define AD9694_REG_PAIR_MAP_CLK_DELAY_CTRL 0x0110
|
|
||||||
#define AD9694_REG_CH_MAP_CLK_SUPER_FINE_DELAY 0x0111
|
|
||||||
#define AD9694_REG_CH_MAP_CLK_FINE_DELAY 0x0112
|
|
||||||
#define AD9694_REG_CLK_DETN_CTRL 0x011A
|
|
||||||
#define AD9694_REG_PAIR_MAP_CLK_STAT 0x011B
|
|
||||||
#define AD9694_REG_CLK_DCS_CTRL_1 0x011C
|
|
||||||
#define AD9694_REG_CLK_DCS_CTRL_2 0x011E
|
|
||||||
#define AD9694_REG_CLK_DCS_CTRL_3 0x011F
|
|
||||||
#define AD9694_REG_PAIR_MAP_SYSREF_CTRL_1 0x0120
|
|
||||||
#define AD9694_REG_PAIR_MAP_SYSREF_CTRL_2 0x0121
|
|
||||||
#define AD9694_REG_PAIR_MAP_SYSREF_CTRL_4 0x0123
|
|
||||||
#define AD9694_REG_PAIR_MAP_SYSREF_STAT_1 0x0128
|
|
||||||
#define AD9694_REG_PAIR_MAP_SYSREF_STAT_2 0x0129
|
|
||||||
#define AD9694_REG_PAIR_MAP_SYSREF_STAT_3 0x012A
|
|
||||||
#define AD9694_REG_PAIR_MAP_CHIP_SYNC 0x01FF
|
|
||||||
#define AD9694_REG_PAIR_MAP_CHIP_MODE 0x0200
|
|
||||||
#define AD9694_REG_PAIR_MAP_CHIP_DEC_RATIO 0x0201
|
|
||||||
#define AD9694_REG_CH_MAP_CUSTOM_OFFSET 0x0228
|
|
||||||
#define AD9694_REG_CH_MAP_FD_CTRL 0x0245
|
|
||||||
#define AD9694_REG_CH_MAP_FD_UT_LSB 0x0247
|
|
||||||
#define AD9694_REG_CH_MAP_FD_UT_MSB 0x0248
|
|
||||||
#define AD9694_REG_CH_MAP_FD_LT_LSB 0x0249
|
|
||||||
#define AD9694_REG_CH_MAP_FD_LT_MSB 0x024A
|
|
||||||
#define AD9694_REG_CH_MAP_FD_DWELL_TIME_LSB 0x024B
|
|
||||||
#define AD9694_REG_CH_MAP_FD_DWELL_TIME_MSB 0x024C
|
|
||||||
#define AD9694_REG_PAIR_MAP_SIG_MON_SYNC_CTRL 0x026F
|
|
||||||
#define AD9694_REG_CH_MAP_SIG_MON_CTRL 0x0270
|
|
||||||
#define AD9694_REG_CH_MAP_SIG_MON_PERIOD_0 0x0271
|
|
||||||
#define AD9694_REG_CH_MAP_SIG_MON_PERIOD_1 0x0272
|
|
||||||
#define AD9694_REG_CH_MAP_SIG_MON_PERIOD_2 0x0273
|
|
||||||
#define AD9694_REG_CH_MAP_SIG_MON_STAT_CTRL 0x0274
|
|
||||||
#define AD9694_REG_CH_MAP_SIG_MON_STAT_0 0x0275
|
|
||||||
#define AD9694_REG_CH_MAP_SIG_MON_STAT_1 0x0276
|
|
||||||
#define AD9694_REG_CH_MAP_SIG_MON_STAT_2 0x0277
|
|
||||||
#define AD9694_REG_CH_MAP_SIG_MON_STAT_FRAME_CNT 0x0278
|
|
||||||
#define AD9694_REG_CH_MAP_SIG_MON_SERIAL_FRAMER_CTRL 0x0279
|
|
||||||
#define AD9694_REG_SPORT_OVER_JESD204B_INPUT_SEL 0x027A
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_SYNC_CTRL 0x0300
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_CTRL 0x0310
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_INPUT_SEL 0x0311
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_INC_0 0x0314
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_INC_1 0x0315
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_INC_2 0x0316
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_INC_3 0x0317
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_INC_4 0x0318
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_INC_5 0x031A
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_OFFSET_0 0x031D
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_OFFSET_1 0x031E
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_OFFSET_2 0x031F
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_OFFSET_3 0x0320
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_OFFSET_4 0x0321
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_PHASE_OFFSET_5 0x0322
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_0_TEST_ENABLE 0x0327
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_CTRL 0x0330
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_INPUT_SEL 0x0331
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_INC_0 0x0334
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_INC_1 0x0335
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_INC_2 0x0336
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_INC_3 0x0337
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_INC_4 0x0338
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_INC_5 0x033A
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_OFFSET_0 0x033D
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_OFFSET_1 0x033E
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_OFFSET_2 0x033F
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_OFFSET_3 0x0340
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_OFFSET_4 0x0341
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_PHASE_OFFSET_5 0x0342
|
|
||||||
#define AD9694_REG_PAIR_MAP_DDC_1_TEST_ENABLE 0x0347
|
|
||||||
#define AD9694_REG_CH_MAP_TEST_MODE_CTRL 0x0550
|
|
||||||
#define AD9694_REG_PAIR_MAP_USER_PATTERN_1_LSB 0x0551
|
|
||||||
#define AD9694_REG_PAIR_MAP_USER_PATTERN_1_MSB 0x0552
|
|
||||||
#define AD9694_REG_PAIR_MAP_USER_PATTERN_2_LSB 0x0553
|
|
||||||
#define AD9694_REG_PAIR_MAP_USER_PATTERN_2_MSB 0x0554
|
|
||||||
#define AD9694_REG_PAIR_MAP_USER_PATTERN_3_LSB 0x0555
|
|
||||||
#define AD9694_REG_PAIR_MAP_USER_PATTERN_3_MSB 0x0556
|
|
||||||
#define AD9694_REG_PAIR_MAP_USER_PATTERN_4_LSB 0x0557
|
|
||||||
#define AD9694_REG_PAIR_MAP_USER_PATTERN_4_MSB 0x0558
|
|
||||||
#define AD9694_REG_PAIR_MAP_OUTPUT_CTRL_MODE_0 0x0559
|
|
||||||
#define AD9694_REG_PAIR_MAP_OUTPUT_CTRL_MODE_1 0x055A
|
|
||||||
#define AD9694_REG_PAIR_MAP_OUTPUT_SAMPLE_MODE 0x0561
|
|
||||||
#define AD9694_REG_PAIR_MAP_OUTPUT_CH_SEL 0x0564
|
|
||||||
#define AD9694_REG_JESD204B_MAP_PLL_CTRL 0x056E
|
|
||||||
#define AD9694_REG_JESD204B_MAP_PLL_STAT 0x056F
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_QUICK_CONF 0x0570
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_LINK_CTRL_1 0x0571
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_LINK_CTRL_2 0x0572
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_LINK_CTRL_3 0x0573
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_LINK_CTRL_4 0x0574
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_LMFC_OFFSET 0x0578
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_DID_CONF 0x0580
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_BID_CONF 0x0581
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_LID_0_CONF 0x0583
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_LID_1_CONF 0x0585
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_SCR_L_CONF 0x058B
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_F_CONF 0x058C
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_K_CONF 0x058D
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_M_CONF 0x058E
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_CS_N_CONF 0x058F
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_SUBCLASS_CONF 0x0590
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_S_CONF 0x0591
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_HD_CF_CONF 0x0592
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_CHECKSUM_0_CONF 0x05A0
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_CHECKSUM_1_CONF 0x05A1
|
|
||||||
#define AD9694_REG_SERDOUTX0_SERDOUTX1_LANE_PD 0x05B0
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_LANE_ASSIGN_1 0x05B2
|
|
||||||
#define AD9694_REG_JESD204B_MAP_JTX_LANE_ASSIGN_2 0x05B3
|
|
||||||
#define AD9694_REG_JESD204B_MAP_SERD_ADJUST_0 0x05C0
|
|
||||||
#define AD9694_REG_JESD204B_MAP_SERD_ADJUST_1 0x05C1
|
|
||||||
#define AD9694_REG_JESD204B_SER_PE_SEL_LANE_0 0x05C4
|
|
||||||
#define AD9694_REG_JESD204B_SER_PE_SEL_LANE_1 0x05C6
|
|
||||||
#define AD9694_REG_LARGE_DITHER_CTRL 0x0922
|
|
||||||
#define AD9694_REG_PLL_CAL 0x1222
|
|
||||||
#define AD9694_REG_JESD204B_STARTUP_CIRCUIT_RST 0x1228
|
|
||||||
#define AD9694_REG_PLL_LOSS_OF_LOCK_CTRL 0x1262
|
|
||||||
#define AD9694_REG_DC_OFFSET_CAL_CTRL 0x0701
|
|
||||||
#define AD9694_REG_DC_OFFSET_CAL_CTRL_2 0x073B
|
|
||||||
#define AD9694_REG_PAIR_MAP_VREF_CTRL 0x18A6
|
|
||||||
#define AD9694_REG_EXT_VCM_BUF_CTRL_1 0x18E0
|
|
||||||
#define AD9694_REG_EXT_VCM_BUF_CTRL_2 0x18E1
|
|
||||||
#define AD9694_REG_EXT_VCM_BUF_CTRL_3 0x18E2
|
|
||||||
#define AD9694_REG_EXT_VCM_BUF_CTRL 0x18E3
|
|
||||||
#define AD9694_REG_TEMP_DIODE_EXPORT 0x18E6
|
|
||||||
#define AD9694_REG_CH_MAP_ANALOG_INPUT_CTRL 0x1908
|
|
||||||
#define AD9694_REG_CH_MAP_INPUT_FULLSCALE_RANGE 0x1910
|
|
||||||
#define AD9694_REG_CH_MAP_BUF_CTRL_1 0x1A4C
|
|
||||||
#define AD9694_REG_CH_MAP_BUF_CTRL_2 0x1A4D
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*************************** Types Declarations *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
struct ad9694_dev {
|
|
||||||
/* SPI */
|
|
||||||
struct spi_desc *spi_desc;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ad9694_init_param {
|
|
||||||
/* SPI */
|
|
||||||
struct spi_init_param *spi_init;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ad9694_config {
|
|
||||||
uint16_t addr;
|
|
||||||
uint8_t value;
|
|
||||||
};
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/************************ Functions Declarations ******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
int32_t ad9694_read(struct ad9694_dev *dev,
|
|
||||||
uint16_t reg_addr,
|
|
||||||
uint8_t *reg_data);
|
|
||||||
|
|
||||||
int32_t ad9694_write(struct ad9694_dev *dev,
|
|
||||||
uint16_t reg_addr,
|
|
||||||
uint8_t reg_data);
|
|
||||||
|
|
||||||
int32_t ad9694_init(struct ad9694_dev **device,
|
|
||||||
const struct ad9694_init_param *init_param);
|
|
||||||
|
|
||||||
int32_t ad9694_remove(struct ad9694_dev *dev);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,241 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file gpio.c
|
|
||||||
* @brief Implementation of the GPIO Interface
|
|
||||||
* @author Antoniu Miclaus ([email protected])
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2020(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include "gpio.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "error.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/************************ Functions Definitions *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Obtain the GPIO decriptor.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param param - GPIO Initialization parameters.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t gpio_get(struct gpio_desc **desc,
|
|
||||||
const struct gpio_init_param *param)
|
|
||||||
{
|
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
if (!param || !param->platform_ops)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (!param->platform_ops->gpio_ops_get)
|
|
||||||
return -ENOSYS;
|
|
||||||
|
|
||||||
ret = param->platform_ops->gpio_ops_get(desc, param);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
(*desc)->platform_ops = param->platform_ops;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the value of an optional GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param param - GPIO Initialization parameters.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t gpio_get_optional(struct gpio_desc **desc,
|
|
||||||
const struct gpio_init_param *param)
|
|
||||||
{
|
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
if (!param || (param->number == -1)) {
|
|
||||||
*desc = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!param->platform_ops)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (!param->platform_ops->gpio_ops_get_optional)
|
|
||||||
return -ENOSYS;
|
|
||||||
|
|
||||||
ret = param->platform_ops->gpio_ops_get_optional(desc, param);
|
|
||||||
if (ret)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
(*desc)->platform_ops = param->platform_ops;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief Free the resources allocated by gpio_get().
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t gpio_remove(struct gpio_desc *desc)
|
|
||||||
{
|
|
||||||
if (desc) {
|
|
||||||
if (!desc->platform_ops)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (!desc->platform_ops->gpio_ops_remove)
|
|
||||||
return -ENOSYS;
|
|
||||||
|
|
||||||
return desc->platform_ops->gpio_ops_remove(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the input direction of the specified GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t gpio_direction_input(struct gpio_desc *desc)
|
|
||||||
{
|
|
||||||
if (desc) {
|
|
||||||
if (!desc->platform_ops)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (!desc->platform_ops->gpio_ops_direction_input)
|
|
||||||
return -ENOSYS;
|
|
||||||
|
|
||||||
return desc->platform_ops->gpio_ops_direction_input(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the output direction of the specified GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param value - The value.
|
|
||||||
* Example: GPIO_HIGH
|
|
||||||
* GPIO_LOW
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t gpio_direction_output(struct gpio_desc *desc,
|
|
||||||
uint8_t value)
|
|
||||||
{
|
|
||||||
if (desc) {
|
|
||||||
if (!desc->platform_ops)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (!desc->platform_ops->gpio_ops_direction_output)
|
|
||||||
return -ENOSYS;
|
|
||||||
|
|
||||||
return desc->platform_ops->
|
|
||||||
gpio_ops_direction_output(desc, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the direction of the specified GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param direction - The direction.
|
|
||||||
* Example: GPIO_OUT
|
|
||||||
* GPIO_IN
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t gpio_get_direction(struct gpio_desc *desc,
|
|
||||||
uint8_t *direction)
|
|
||||||
{
|
|
||||||
if (desc) {
|
|
||||||
if (!desc->platform_ops)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (!desc->platform_ops->gpio_ops_get_direction)
|
|
||||||
return -ENOSYS;
|
|
||||||
|
|
||||||
return desc->platform_ops->
|
|
||||||
gpio_ops_get_direction(desc, direction);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the value of the specified GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param value - The value.
|
|
||||||
* Example: GPIO_HIGH
|
|
||||||
* GPIO_LOW
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t gpio_set_value(struct gpio_desc *desc,
|
|
||||||
uint8_t value)
|
|
||||||
{
|
|
||||||
if (desc) {
|
|
||||||
if (!desc->platform_ops)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (!desc->platform_ops->gpio_ops_set_value)
|
|
||||||
return -ENOSYS;
|
|
||||||
|
|
||||||
return desc->platform_ops->gpio_ops_set_value(desc, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the value of the specified GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param value - The value.
|
|
||||||
* Example: GPIO_HIGH
|
|
||||||
* GPIO_LOW
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t gpio_get_value(struct gpio_desc *desc,
|
|
||||||
uint8_t *value)
|
|
||||||
{
|
|
||||||
if (desc) {
|
|
||||||
if (!desc->platform_ops)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (!desc->platform_ops->gpio_ops_set_value)
|
|
||||||
return -ENOSYS;
|
|
||||||
|
|
||||||
return desc->platform_ops->gpio_ops_get_value(desc, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,927 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file hmc7044.c
|
|
||||||
* @brief Implementation of HMC7044, HMC7043 Driver.
|
|
||||||
* @author DBogdan ([email protected])
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2018-2020(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "hmc7044.h"
|
|
||||||
#include "../../../include/error.h"
|
|
||||||
#include "../../../include/util.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/********************** Macros and Constants Definitions **********************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#define HMC7044_WRITE (0 << 15)
|
|
||||||
#define HMC7044_READ (1 << 15)
|
|
||||||
#define HMC7044_CNT(x) (((x) - 1) << 13)
|
|
||||||
#define HMC7044_ADDR(x) ((x) & 0xFFF)
|
|
||||||
|
|
||||||
/* Global Control */
|
|
||||||
#define HMC7044_REG_SOFT_RESET 0x0000
|
|
||||||
#define HMC7044_SOFT_RESET BIT(0)
|
|
||||||
|
|
||||||
#define HMC7044_REG_REQ_MODE_0 0x0001
|
|
||||||
#define HMC7044_RESEED_REQ BIT(7)
|
|
||||||
#define HMC7044_HIGH_PERF_DISTRIB_PATH BIT(6)
|
|
||||||
#define HMC7044_HIGH_PERF_PLL_VCO BIT(5)
|
|
||||||
#define HMC7044_FORCE_HOLDOVER BIT(4)
|
|
||||||
#define HMC7044_MUTE_OUT_DIV BIT(3)
|
|
||||||
#define HMC7044_PULSE_GEN_REQ BIT(2)
|
|
||||||
#define HMC7044_RESTART_DIV_FSM BIT(1)
|
|
||||||
#define HMC7044_SLEEP_MODE BIT(0)
|
|
||||||
|
|
||||||
#define HMC7044_REG_REQ_MODE_1 0x0002
|
|
||||||
#define HMC7044_PLL2_AUTOTUNE_TRIG BIT(2)
|
|
||||||
#define HMC7044_SLIP_REQ BIT(1)
|
|
||||||
|
|
||||||
#define HMC7044_REG_EN_CTRL_0 0x0003
|
|
||||||
#define HMC7044_RF_RESEEDER_EN BIT(5)
|
|
||||||
#define HMC7044_VCO_SEL(x) (((x) & 0x3) << 3)
|
|
||||||
#define HMC7044_VCO_EXT 0
|
|
||||||
#define HMC7044_VCO_HIGH 1
|
|
||||||
#define HMC7044_VCO_LOW 2
|
|
||||||
#define HMC7044_SYSREF_TIMER_EN BIT(2)
|
|
||||||
#define HMC7044_PLL2_EN BIT(1)
|
|
||||||
#define HMC7044_PLL1_EN BIT(0)
|
|
||||||
|
|
||||||
#define HMC7044_REG_EN_CTRL_1 0x0004
|
|
||||||
#define HMC7044_SEVEN_PAIRS(x) ((x) & 0x7f)
|
|
||||||
|
|
||||||
#define HMC7044_REG_GLOB_MODE 0x0005
|
|
||||||
#define HMC7044_REF_PATH_EN(x) ((x) & 0xf)
|
|
||||||
#define HMC7044_RFSYNC_EN BIT(4)
|
|
||||||
#define HMC7044_VCOIN_MODE_EN BIT(5)
|
|
||||||
#define HMC7044_SYNC_PIN_MODE(x) (((x) & 0x3) << 6)
|
|
||||||
|
|
||||||
/* PLL1 */
|
|
||||||
#define HMC7044_REG_CLKIN0_BUF_CTRL 0x000A
|
|
||||||
#define HMC7044_REG_CLKIN1_BUF_CTRL 0x000B
|
|
||||||
#define HMC7044_REG_CLKIN2_BUF_CTRL 0x000C
|
|
||||||
#define HMC7044_REG_CLKIN3_BUF_CTRL 0x000D
|
|
||||||
#define HMC7044_REG_OSCIN_BUF_CTRL 0x000E
|
|
||||||
|
|
||||||
#define HMC7044_REG_PLL1_REF_PRIO_CTRL 0x0014
|
|
||||||
|
|
||||||
#define HMC7044_HIGH_Z_EN BIT(4)
|
|
||||||
#define HMC7044_LVPECL_EN BIT(3)
|
|
||||||
#define HMC7044_AC_COUPLING_EN BIT(2)
|
|
||||||
#define HMC7044_100_OHM_EN BIT(1)
|
|
||||||
#define HMC7044_BUF_EN BIT(0)
|
|
||||||
|
|
||||||
#define HMC7044_REG_CLKIN_PRESCALER(x) (0x001C + (x))
|
|
||||||
#define HMC7044_REG_OSCIN_PRESCALER 0x0020
|
|
||||||
|
|
||||||
#define HMC7044_REG_PLL1_R_LSB 0x0021
|
|
||||||
#define HMC7044_R1_LSB(x) ((x) & 0xff)
|
|
||||||
|
|
||||||
#define HMC7044_REG_PLL1_R_MSB 0x0022
|
|
||||||
#define HMC7044_R1_MSB(x) (((x) & 0xff00) >> 8)
|
|
||||||
|
|
||||||
#define HMC7044_REG_PLL1_N_LSB 0x0026
|
|
||||||
#define HMC7044_N1_LSB(x) ((x) & 0xff)
|
|
||||||
|
|
||||||
#define HMC7044_REG_PLL1_N_MSB 0x0027
|
|
||||||
#define HMC7044_N1_MSB(x) (((x) & 0xff00) >> 8)
|
|
||||||
|
|
||||||
#define HMC7044_REG_PLL1_LOCK_DETECT 0x0028
|
|
||||||
#define HMC7044_LOCK_DETECT_SLIP BIT(5)
|
|
||||||
#define HMC7044_LOCK_DETECT_TIMER(x) ((x) & 0x1f)
|
|
||||||
|
|
||||||
/* PLL2 */
|
|
||||||
#define HMC7044_REG_PLL2_FREQ_DOUBLER 0x0032
|
|
||||||
#define HMC7044_PLL2_FREQ_DOUBLER_DIS BIT(0)
|
|
||||||
|
|
||||||
#define HMC7044_REG_PLL2_R_LSB 0x0033
|
|
||||||
#define HMC7044_R2_LSB(x) ((x) & 0xff)
|
|
||||||
|
|
||||||
#define HMC7044_REG_PLL2_R_MSB 0x0034
|
|
||||||
#define HMC7044_R2_MSB(x) (((x) & 0xf00) >> 8)
|
|
||||||
|
|
||||||
#define HMC7044_REG_PLL2_N_LSB 0x0035
|
|
||||||
#define HMC7044_N2_LSB(x) ((x) & 0xff)
|
|
||||||
|
|
||||||
#define HMC7044_REG_PLL2_N_MSB 0x0036
|
|
||||||
#define HMC7044_N2_MSB(x) (((x) & 0xff00) >> 8)
|
|
||||||
|
|
||||||
#define HMC7044_REG_OSCOUT_PATH 0x0039
|
|
||||||
#define HMC7044_REG_OSCOUT_DRIVER_0 0x003A
|
|
||||||
#define HMC7044_REG_OSCOUT_DRIVER_1 0x003B
|
|
||||||
|
|
||||||
/* GPIO/SDATA Control */
|
|
||||||
#define HMC7044_REG_GPI_CTRL(x) (0x0046 + (x))
|
|
||||||
#define HMC7044_REG_GPI_SEL(x) ((x) & 0xf)
|
|
||||||
|
|
||||||
#define HMC7044_REG_GPO_CTRL(x) (0x0050 + (x))
|
|
||||||
#define HMC7044_GPO_SEL(x) (((x) & 0x3f) << 2)
|
|
||||||
#define HMC7044_GPO_MODE BIT(1)
|
|
||||||
#define HMC7044_GPO_EN BIT(0)
|
|
||||||
|
|
||||||
/* SYSREF/SYNC Control */
|
|
||||||
#define HMC7044_REG_PULSE_GEN 0x005A
|
|
||||||
#define HMC7044_PULSE_GEN_MODE(x) ((x) & 0x7)
|
|
||||||
|
|
||||||
#define HMC7044_REG_SYNC 0x005B
|
|
||||||
#define HMC7044_SYNC_RETIME BIT(2)
|
|
||||||
#define HMC7044_SYNC_THROUGH_PLL2 BIT(1)
|
|
||||||
#define HMC7044_SYNC_POLARITY BIT(0)
|
|
||||||
|
|
||||||
#define HMC7044_REG_SYSREF_TIMER_LSB 0x005C
|
|
||||||
#define HMC7044_SYSREF_TIMER_LSB(x) ((x) & 0xff)
|
|
||||||
|
|
||||||
#define HMC7044_REG_SYSREF_TIMER_MSB 0x005D
|
|
||||||
#define HMC7044_SYSREF_TIMER_MSB(x) (((x) & 0xf00) >> 8)
|
|
||||||
|
|
||||||
#define HMC7044_CLK_INPUT_CTRL 0x0064
|
|
||||||
#define HMC7044_LOW_FREQ_INPUT_MODE BIT(0)
|
|
||||||
#define HMC7044_DIV_2_INPUT_MODE BIT(1)
|
|
||||||
|
|
||||||
/* Status and Alarm readback */
|
|
||||||
#define HMC7044_REG_ALARM_READBACK 0x007D
|
|
||||||
#define HMC7044_REG_PLL1_STATUS 0x0082
|
|
||||||
|
|
||||||
#define HMC7044_PLL1_FSM_STATE(x) ((x) & 0x7)
|
|
||||||
#define HMC7044_PLL1_ACTIVE_CLKIN(x) (((x) >> 3) & 0x3)
|
|
||||||
|
|
||||||
#define HMC7044_PLL2_LOCK_DETECT(x) ((x) & 0x1)
|
|
||||||
#define HMC7044_SYSREF_SYNC_STAT(x) ((x) & 0x2)
|
|
||||||
#define HMC7044_CLK_OUT_PH_STATUS(x) ((x) & 0x4)
|
|
||||||
#define HMC7044_PLL1_PLL2_LOCK_STAT(x) ((x) & 0x8)
|
|
||||||
#define HMC7044_SYNC_REQ_STATUS(x) ((x) & 0x10)
|
|
||||||
|
|
||||||
/* Other Controls */
|
|
||||||
#define HMC7044_REG_CLK_OUT_DRV_LOW_PW 0x009F
|
|
||||||
#define HMC7044_REG_CLK_OUT_DRV_HIGH_PW 0x00A0
|
|
||||||
#define HMC7044_REG_PLL1_DELAY 0x00A5
|
|
||||||
#define HMC7044_REG_PLL1_HOLDOVER 0x00A8
|
|
||||||
#define HMC7044_REG_VTUNE_PRESET 0x00B0
|
|
||||||
|
|
||||||
/* Clock Distribution */
|
|
||||||
#define HMC7044_REG_CH_OUT_CRTL_0(ch) (0x00C8 + 0xA * (ch))
|
|
||||||
#define HMC7044_HI_PERF_MODE BIT(7)
|
|
||||||
#define HMC7044_SYNC_EN BIT(6)
|
|
||||||
#define HMC7044_CH_EN BIT(0)
|
|
||||||
#define HMC7044_START_UP_MODE_DYN_EN (BIT(3) | BIT(2))
|
|
||||||
|
|
||||||
#define HMC7044_REG_CH_OUT_CRTL_1(ch) (0x00C9 + 0xA * (ch))
|
|
||||||
#define HMC7044_DIV_LSB(x) ((x) & 0xFF)
|
|
||||||
|
|
||||||
#define HMC7044_REG_CH_OUT_CRTL_2(ch) (0x00CA + 0xA * (ch))
|
|
||||||
#define HMC7044_DIV_MSB(x) (((x) >> 8) & 0xFF)
|
|
||||||
|
|
||||||
#define HMC7044_REG_CH_OUT_CRTL_3(ch) (0x00CB + 0xA * (ch))
|
|
||||||
#define HMC7044_REG_CH_OUT_CRTL_4(ch) (0x00CC + 0xA * (ch))
|
|
||||||
#define HMC7044_REG_CH_OUT_CRTL_5(ch) (0x00CD + 0xA * (ch))
|
|
||||||
#define HMC7044_REG_CH_OUT_CRTL_6(ch) (0x00CE + 0xA * (ch))
|
|
||||||
#define HMC7044_REG_CH_OUT_CRTL_7(ch) (0x00CF + 0xA * (ch))
|
|
||||||
|
|
||||||
#define HMC7044_REG_CH_OUT_CRTL_8(ch) (0x00D0 + 0xA * (ch))
|
|
||||||
#define HMC7044_DRIVER_MODE(x) (((x) & 0x3) << 3)
|
|
||||||
#define HMC7044_DRIVER_Z_MODE(x) (((x) & 0x3) << 0)
|
|
||||||
#define HMC7044_DYN_DRIVER_EN BIT(5)
|
|
||||||
#define HMC7044_FORCE_MUTE_EN BIT(7)
|
|
||||||
|
|
||||||
#define HMC7044_NUM_CHAN 14
|
|
||||||
|
|
||||||
#define HMC7044_LOW_VCO_MIN 2150000
|
|
||||||
#define HMC7044_LOW_VCO_MAX 2880000
|
|
||||||
#define HMC7044_HIGH_VCO_MIN 2650000
|
|
||||||
#define HMC7044_HIGH_VCO_MAX 3200000
|
|
||||||
|
|
||||||
#define HMC7044_RECOMM_LCM_MIN 30000
|
|
||||||
#define HMC7044_RECOMM_LCM_MAX 70000
|
|
||||||
#define HMC7044_RECOMM_FPD1 10000
|
|
||||||
|
|
||||||
#define HMC7044_R1_MAX 65535
|
|
||||||
#define HMC7044_N1_MAX 65535
|
|
||||||
|
|
||||||
#define HMC7044_R2_MIN 1
|
|
||||||
#define HMC7044_R2_MAX 4095
|
|
||||||
#define HMC7044_N2_MIN 8
|
|
||||||
#define HMC7044_N2_MAX 65535
|
|
||||||
|
|
||||||
#define HMC7044_OUT_DIV_MIN 1
|
|
||||||
#define HMC7044_OUT_DIV_MAX 4094
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/************************** Functions Implementation **************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SPI register write to device.
|
|
||||||
* @param dev - The device structure.
|
|
||||||
* @param reg - The register address.
|
|
||||||
* @param val - The register data.
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
int32_t hmc7044_write(struct hmc7044_dev *dev,
|
|
||||||
uint16_t reg,
|
|
||||||
uint8_t val)
|
|
||||||
{
|
|
||||||
uint8_t buf[3];
|
|
||||||
uint16_t cmd;
|
|
||||||
|
|
||||||
cmd = HMC7044_WRITE | HMC7044_CNT(1) | HMC7044_ADDR(reg);
|
|
||||||
buf[0] = cmd >> 8;
|
|
||||||
buf[1] = cmd & 0xFF;
|
|
||||||
buf[2] = val;
|
|
||||||
return spi_write_and_read_3wire(dev->spi_desc, buf, NULL,
|
|
||||||
ARRAY_SIZE(buf), 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SPI register read from device.
|
|
||||||
* @param dev - The device structure.
|
|
||||||
* @param reg - The register address.
|
|
||||||
* @param val - The register data.
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
|
|
||||||
int32_t hmc7044_read(struct hmc7044_dev *dev, uint16_t reg, uint8_t *val)
|
|
||||||
{
|
|
||||||
uint8_t wr_buf[2];
|
|
||||||
uint8_t rd_data[1];
|
|
||||||
uint16_t cmd;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
cmd = HMC7044_READ | HMC7044_CNT(1) | HMC7044_ADDR(reg);
|
|
||||||
wr_buf[0] = cmd >> 8;
|
|
||||||
wr_buf[1] = cmd & 0xFF;
|
|
||||||
|
|
||||||
ret = spi_write_and_read_3wire(dev->spi_desc, wr_buf, rd_data,
|
|
||||||
ARRAY_SIZE(wr_buf), ARRAY_SIZE(rd_data));
|
|
||||||
if (ret != SUCCESS)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
*val = rd_data[0];
|
|
||||||
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate the output channel divider.
|
|
||||||
* @param rate - The desired rate.
|
|
||||||
* @param parent_rate - The parent rate.
|
|
||||||
* @return The output divider.
|
|
||||||
*/
|
|
||||||
uint32_t hmc7044_calc_out_div(uint32_t rate,
|
|
||||||
uint32_t parent_rate)
|
|
||||||
{
|
|
||||||
uint32_t div;
|
|
||||||
|
|
||||||
div = DIV_ROUND_CLOSEST(parent_rate, rate);
|
|
||||||
|
|
||||||
/* Supported odd divide ratios are 1, 3, and 5 */
|
|
||||||
if ((div != 1) && (div != 3) && (div != 5) && (div % 2))
|
|
||||||
div = DIV_ROUND_CLOSEST(parent_rate, rate * 2) * 2;
|
|
||||||
|
|
||||||
div = clamp_t(unsigned int,
|
|
||||||
div,
|
|
||||||
HMC7044_OUT_DIV_MIN,
|
|
||||||
HMC7044_OUT_DIV_MAX);
|
|
||||||
|
|
||||||
return div;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recalculate rate corresponding to a channel.
|
|
||||||
* @param dev - The device structure.
|
|
||||||
* @param chan_num - Channel number.
|
|
||||||
* @param rate - Channel rate.
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
int32_t hmc7044_clk_recalc_rate(struct hmc7044_dev *dev, uint32_t chan_num,
|
|
||||||
uint64_t *rate)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
struct hmc7044_chan_spec *chan = NULL;
|
|
||||||
|
|
||||||
/* Find the reqested channel number */
|
|
||||||
for (i = 0; i < dev->num_channels; i++) {
|
|
||||||
if (dev->channels[i].num == chan_num) {
|
|
||||||
chan = &dev->channels[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (chan == NULL )
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
*rate = dev->pll2_freq / chan->divider;
|
|
||||||
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate closest possible rate
|
|
||||||
* @param dev - The device structure
|
|
||||||
* @param rate - The desired rate.
|
|
||||||
* @param rounded_rate - The closest possible rate of desired rate.
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
int32_t hmc7044_clk_round_rate(struct hmc7044_dev *dev, uint32_t rate,
|
|
||||||
uint64_t *rounded_rate)
|
|
||||||
{
|
|
||||||
uint32_t div = hmc7044_calc_out_div(rate, dev->pll2_freq);
|
|
||||||
|
|
||||||
*rounded_rate = DIV_ROUND_CLOSEST(dev->pll2_freq, div);
|
|
||||||
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set channel rate.
|
|
||||||
* @param dev - The device structure.
|
|
||||||
* @param chan_num - Channel number.
|
|
||||||
* @param rate - Channel rate.
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
int32_t hmc7044_clk_set_rate(struct hmc7044_dev *dev, uint32_t chan_num,
|
|
||||||
uint64_t rate)
|
|
||||||
{
|
|
||||||
uint32_t div;
|
|
||||||
int32_t ret;
|
|
||||||
int i;
|
|
||||||
struct hmc7044_chan_spec *chan = NULL;
|
|
||||||
|
|
||||||
/* Find the reqested channel number */
|
|
||||||
for (i = 0; i < dev->num_channels; i++) {
|
|
||||||
if (dev->channels[i].num == chan_num) {
|
|
||||||
chan = &dev->channels[i];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (chan == NULL )
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
div = hmc7044_calc_out_div(rate, dev->pll2_freq);
|
|
||||||
chan->divider = div;
|
|
||||||
|
|
||||||
ret = hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_1(chan->num),
|
|
||||||
HMC7044_DIV_LSB(div));
|
|
||||||
if(ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
return hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_2(chan->num),
|
|
||||||
HMC7044_DIV_MSB(div));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup the device.
|
|
||||||
* @param dev - The device structure.
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
static int32_t hmc7044_setup(struct hmc7044_dev *dev)
|
|
||||||
{
|
|
||||||
struct hmc7044_chan_spec *chan;
|
|
||||||
bool high_vco_en;
|
|
||||||
bool pll2_freq_doubler_en;
|
|
||||||
uint32_t vcxo_freq, pll2_freq;
|
|
||||||
uint32_t clkin_freq[4];
|
|
||||||
uint32_t lcm_freq;
|
|
||||||
uint32_t in_prescaler[5];
|
|
||||||
uint32_t pll1_lock_detect;
|
|
||||||
uint32_t n1, r1;
|
|
||||||
uint32_t pfd1_freq;
|
|
||||||
uint32_t vco_limit;
|
|
||||||
uint32_t n2[2], r2[2];
|
|
||||||
uint32_t i, ref_en = 0;
|
|
||||||
|
|
||||||
vcxo_freq = dev->vcxo_freq / 1000;
|
|
||||||
pll2_freq = dev->pll2_freq / 1000;
|
|
||||||
|
|
||||||
lcm_freq = vcxo_freq;
|
|
||||||
for (i = 0; i < ARRAY_SIZE(clkin_freq); i++) {
|
|
||||||
if (dev->clkin_freq_ccf[i])
|
|
||||||
clkin_freq[i] = dev->clkin_freq_ccf[i] / 1000;
|
|
||||||
else
|
|
||||||
clkin_freq[i] = dev->clkin_freq[i] / 1000;
|
|
||||||
|
|
||||||
if (clkin_freq[i]) {
|
|
||||||
lcm_freq = greatest_common_divisor(clkin_freq[i], lcm_freq);
|
|
||||||
ref_en |= BIT(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while (lcm_freq > HMC7044_RECOMM_LCM_MAX)
|
|
||||||
lcm_freq /= 2;
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(clkin_freq); i++) {
|
|
||||||
if (clkin_freq[i])
|
|
||||||
in_prescaler[i] = clkin_freq[i] / lcm_freq;
|
|
||||||
else
|
|
||||||
in_prescaler[i] = 1;
|
|
||||||
}
|
|
||||||
in_prescaler[4] = vcxo_freq / lcm_freq;
|
|
||||||
|
|
||||||
pll1_lock_detect = log_base_2((lcm_freq * 4000) / dev->pll1_loop_bw);
|
|
||||||
|
|
||||||
/* fVCXO / N1 = fLCM / R1 */
|
|
||||||
rational_best_approximation(vcxo_freq, lcm_freq,
|
|
||||||
HMC7044_N1_MAX, HMC7044_R1_MAX,
|
|
||||||
&n1, &r1);
|
|
||||||
|
|
||||||
pfd1_freq = vcxo_freq / n1;
|
|
||||||
while ((pfd1_freq > HMC7044_RECOMM_FPD1) &&
|
|
||||||
(n1 <= HMC7044_N1_MAX / 2) &&
|
|
||||||
(r1 <= HMC7044_R1_MAX / 2)) {
|
|
||||||
pfd1_freq /= 2;
|
|
||||||
n1 *= 2;
|
|
||||||
r1 *= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
dev->pll1_pfd = pfd1_freq;
|
|
||||||
|
|
||||||
if (pll2_freq < HMC7044_LOW_VCO_MIN ||
|
|
||||||
pll2_freq > HMC7044_HIGH_VCO_MAX)
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
vco_limit = (HMC7044_LOW_VCO_MAX + HMC7044_HIGH_VCO_MIN) / 2;
|
|
||||||
if (pll2_freq >= vco_limit)
|
|
||||||
high_vco_en = true;
|
|
||||||
else
|
|
||||||
high_vco_en = false;
|
|
||||||
|
|
||||||
/* fVCO / N2 = fVCXO * doubler / R2 */
|
|
||||||
pll2_freq_doubler_en = true;
|
|
||||||
rational_best_approximation(pll2_freq, vcxo_freq * 2,
|
|
||||||
HMC7044_N2_MAX, HMC7044_R2_MAX,
|
|
||||||
&n2[0], &r2[0]);
|
|
||||||
|
|
||||||
if (pll2_freq != vcxo_freq * n2[0] / r2[0]) {
|
|
||||||
rational_best_approximation(pll2_freq, vcxo_freq,
|
|
||||||
HMC7044_N2_MAX, HMC7044_R2_MAX,
|
|
||||||
&n2[1], &r2[1]);
|
|
||||||
|
|
||||||
if (abs((int)pll2_freq - (int)(vcxo_freq * 2 * n2[0] / r2[0])) >
|
|
||||||
abs((int)pll2_freq - (int)(vcxo_freq * n2[1] / r2[1]))) {
|
|
||||||
n2[0] = n2[1];
|
|
||||||
r2[0] = r2[1];
|
|
||||||
pll2_freq_doubler_en = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((n2[0] < HMC7044_N2_MIN) && (r2[0] <= HMC7044_R2_MAX / 2)) {
|
|
||||||
n2[0] *= 2;
|
|
||||||
r2[0] *= 2;
|
|
||||||
}
|
|
||||||
if (n2[0] < HMC7044_N2_MIN)
|
|
||||||
return -FAILURE;
|
|
||||||
|
|
||||||
/* Resets all registers to default values */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_SOFT_RESET, HMC7044_SOFT_RESET);
|
|
||||||
mdelay(10);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_SOFT_RESET, 0);
|
|
||||||
mdelay(10);
|
|
||||||
|
|
||||||
/* Disable all channels */
|
|
||||||
for (i = 0; i < HMC7044_NUM_CHAN; i++)
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_0(i), 0);
|
|
||||||
|
|
||||||
/* Load the configuration updates (provided by Analog Devices) */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLK_OUT_DRV_LOW_PW, 0x4d);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLK_OUT_DRV_HIGH_PW, 0xdf);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL1_DELAY, 0x06);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL1_HOLDOVER, 0x06);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_VTUNE_PRESET, 0x04);
|
|
||||||
|
|
||||||
uint8_t rd_back;
|
|
||||||
hmc7044_read(dev, HMC7044_REG_CLK_OUT_DRV_LOW_PW, &rd_back);
|
|
||||||
hmc7044_read(dev, HMC7044_REG_CLK_OUT_DRV_HIGH_PW, &rd_back);
|
|
||||||
hmc7044_read(dev, HMC7044_REG_PLL1_DELAY, &rd_back);
|
|
||||||
hmc7044_read(dev, HMC7044_REG_PLL1_HOLDOVER, &rd_back);
|
|
||||||
hmc7044_read(dev, HMC7044_REG_VTUNE_PRESET, &rd_back);
|
|
||||||
|
|
||||||
hmc7044_write(dev, HMC7044_REG_GLOB_MODE,
|
|
||||||
HMC7044_SYNC_PIN_MODE(dev->sync_pin_mode) |
|
|
||||||
(dev->clkin0_rfsync_en ? HMC7044_RFSYNC_EN : 0) |
|
|
||||||
(dev->clkin1_vcoin_en ? HMC7044_VCOIN_MODE_EN : 0) |
|
|
||||||
HMC7044_REF_PATH_EN(ref_en));
|
|
||||||
|
|
||||||
/* Program PLL2 */
|
|
||||||
|
|
||||||
/* Select the VCO range */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_EN_CTRL_0,
|
|
||||||
(dev->rf_reseeder_en ? HMC7044_RF_RESEEDER_EN : 0) |
|
|
||||||
HMC7044_VCO_SEL(high_vco_en ?
|
|
||||||
HMC7044_VCO_HIGH :
|
|
||||||
HMC7044_VCO_LOW) |
|
|
||||||
HMC7044_SYSREF_TIMER_EN | HMC7044_PLL2_EN |
|
|
||||||
HMC7044_PLL1_EN);
|
|
||||||
|
|
||||||
/* Program the dividers */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL2_R_LSB,
|
|
||||||
HMC7044_R2_LSB(r2[0]));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL2_R_MSB,
|
|
||||||
HMC7044_R2_MSB(r2[0]));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL2_N_LSB,
|
|
||||||
HMC7044_N2_LSB(n2[0]));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL2_N_MSB,
|
|
||||||
HMC7044_N2_MSB(n2[0]));
|
|
||||||
|
|
||||||
/* Program the reference doubler */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL2_FREQ_DOUBLER,
|
|
||||||
pll2_freq_doubler_en ? 0 : HMC7044_PLL2_FREQ_DOUBLER_DIS);
|
|
||||||
|
|
||||||
/* Program PLL1 */
|
|
||||||
|
|
||||||
/* Set the lock detect timer threshold */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL1_LOCK_DETECT,
|
|
||||||
HMC7044_LOCK_DETECT_TIMER(pll1_lock_detect));
|
|
||||||
|
|
||||||
/* Set the LCM */
|
|
||||||
for (i = 0; i < ARRAY_SIZE(clkin_freq); i++) {
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLKIN_PRESCALER(i),
|
|
||||||
in_prescaler[i]);
|
|
||||||
}
|
|
||||||
hmc7044_write(dev, HMC7044_REG_OSCIN_PRESCALER,
|
|
||||||
in_prescaler[4]);
|
|
||||||
|
|
||||||
/* Program the dividers */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL1_R_LSB,
|
|
||||||
HMC7044_R2_LSB(r1));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL1_R_MSB,
|
|
||||||
HMC7044_R2_MSB(r1));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL1_N_LSB,
|
|
||||||
HMC7044_N2_LSB(n1));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL1_N_MSB,
|
|
||||||
HMC7044_N2_MSB(n1));
|
|
||||||
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PLL1_REF_PRIO_CTRL,
|
|
||||||
dev->pll1_ref_prio_ctrl);
|
|
||||||
|
|
||||||
/* Program the SYSREF timer */
|
|
||||||
|
|
||||||
/* Set the divide ratio */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_SYSREF_TIMER_LSB,
|
|
||||||
HMC7044_SYSREF_TIMER_LSB(dev->sysref_timer_div));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_SYSREF_TIMER_MSB,
|
|
||||||
HMC7044_SYSREF_TIMER_MSB(dev->sysref_timer_div));
|
|
||||||
|
|
||||||
/* Set the pulse generator mode configuration */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PULSE_GEN,
|
|
||||||
HMC7044_PULSE_GEN_MODE(dev->pulse_gen_mode));
|
|
||||||
|
|
||||||
/* Enable the input buffers */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLKIN0_BUF_CTRL,
|
|
||||||
dev->in_buf_mode[0]);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLKIN1_BUF_CTRL,
|
|
||||||
dev->in_buf_mode[1]);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLKIN2_BUF_CTRL,
|
|
||||||
dev->in_buf_mode[2]);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLKIN3_BUF_CTRL,
|
|
||||||
dev->in_buf_mode[3]);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_OSCIN_BUF_CTRL,
|
|
||||||
dev->in_buf_mode[4]);
|
|
||||||
|
|
||||||
/* Set GPIOs */
|
|
||||||
for (i = 0; i < ARRAY_SIZE(dev->gpi_ctrl); i++) {
|
|
||||||
hmc7044_write(dev, HMC7044_REG_GPI_CTRL(i),
|
|
||||||
dev->gpi_ctrl[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(dev->gpo_ctrl); i++) {
|
|
||||||
hmc7044_write(dev, HMC7044_REG_GPO_CTRL(i),
|
|
||||||
dev->gpo_ctrl[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
mdelay(10);
|
|
||||||
|
|
||||||
/* Program the output channels */
|
|
||||||
for (i = 0; i < dev->num_channels; i++) {
|
|
||||||
chan = &dev->channels[i];
|
|
||||||
if (chan->num >= HMC7044_NUM_CHAN || chan->disable)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_1(chan->num),
|
|
||||||
HMC7044_DIV_LSB(chan->divider));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_2(chan->num),
|
|
||||||
HMC7044_DIV_MSB(chan->divider));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_8(chan->num),
|
|
||||||
HMC7044_DRIVER_MODE(chan->driver_mode) |
|
|
||||||
HMC7044_DRIVER_Z_MODE(chan->driver_impedance) |
|
|
||||||
(chan->dynamic_driver_enable ?
|
|
||||||
HMC7044_DYN_DRIVER_EN : 0) |
|
|
||||||
(chan->force_mute_enable ?
|
|
||||||
HMC7044_FORCE_MUTE_EN : 0));
|
|
||||||
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_3(chan->num),
|
|
||||||
chan->fine_delay & 0x1F);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_4(chan->num),
|
|
||||||
chan->coarse_delay & 0x1F);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_7(chan->num),
|
|
||||||
chan->out_mux_mode & 0x3);
|
|
||||||
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_0(chan->num),
|
|
||||||
(chan->start_up_mode_dynamic_enable ?
|
|
||||||
HMC7044_START_UP_MODE_DYN_EN : 0) |
|
|
||||||
(chan->output_control0_rb4_enable ? BIT(4) : 0) |
|
|
||||||
(chan->high_performance_mode_dis ?
|
|
||||||
0 : HMC7044_HI_PERF_MODE) | HMC7044_SYNC_EN |
|
|
||||||
HMC7044_CH_EN);
|
|
||||||
}
|
|
||||||
mdelay(10);
|
|
||||||
|
|
||||||
/* Do a restart to reset the system and initiate calibration */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_REQ_MODE_0,
|
|
||||||
HMC7044_RESTART_DIV_FSM);
|
|
||||||
mdelay(1);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_REQ_MODE_0,
|
|
||||||
(dev->high_performance_mode_clock_dist_en ?
|
|
||||||
HMC7044_HIGH_PERF_DISTRIB_PATH : 0));
|
|
||||||
mdelay(1);
|
|
||||||
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup the device.
|
|
||||||
* @param dev - The device structure.
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
static int32_t hmc7043_setup(struct hmc7044_dev *dev)
|
|
||||||
{
|
|
||||||
struct hmc7044_chan_spec *chan;
|
|
||||||
uint32_t i;
|
|
||||||
|
|
||||||
if (dev->clkin_freq_ccf[0])
|
|
||||||
dev->pll2_freq = dev->clkin_freq_ccf[0];
|
|
||||||
else
|
|
||||||
dev->pll2_freq = dev->clkin_freq[0];
|
|
||||||
|
|
||||||
if (!dev->pll2_freq) {
|
|
||||||
printf("%s: Failed to get valid parent rate\n", __func__);
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Resets all registers to default values */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_SOFT_RESET, HMC7044_SOFT_RESET);
|
|
||||||
mdelay(10);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_SOFT_RESET, 0);
|
|
||||||
mdelay(10);
|
|
||||||
|
|
||||||
/* Load the configuration updates (provided by Analog Devices) */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLK_OUT_DRV_LOW_PW, 0x4d);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLK_OUT_DRV_HIGH_PW, 0xdf);
|
|
||||||
|
|
||||||
/* Disable all channels */
|
|
||||||
for (i = 0; i < HMC7044_NUM_CHAN; i++)
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_0(i), 0);
|
|
||||||
|
|
||||||
if (dev->pll2_freq < 1000000000U)
|
|
||||||
hmc7044_write(dev, HMC7044_CLK_INPUT_CTRL,
|
|
||||||
HMC7044_LOW_FREQ_INPUT_MODE);
|
|
||||||
|
|
||||||
hmc7044_write(dev, HMC7044_REG_EN_CTRL_0,
|
|
||||||
(dev->rf_reseeder_en ? HMC7044_RF_RESEEDER_EN : 0) |
|
|
||||||
HMC7044_SYSREF_TIMER_EN);
|
|
||||||
|
|
||||||
/* Program the SYSREF timer */
|
|
||||||
|
|
||||||
/* Set the divide ratio */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_SYSREF_TIMER_LSB,
|
|
||||||
HMC7044_SYSREF_TIMER_LSB(dev->sysref_timer_div));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_SYSREF_TIMER_MSB,
|
|
||||||
HMC7044_SYSREF_TIMER_MSB(dev->sysref_timer_div));
|
|
||||||
|
|
||||||
/* Set the pulse generator mode configuration */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_PULSE_GEN,
|
|
||||||
HMC7044_PULSE_GEN_MODE(dev->pulse_gen_mode));
|
|
||||||
|
|
||||||
/* Enable the input buffers */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLKIN0_BUF_CTRL,
|
|
||||||
dev->in_buf_mode[0]);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CLKIN1_BUF_CTRL,
|
|
||||||
dev->in_buf_mode[1]);
|
|
||||||
|
|
||||||
/* Set GPIOs */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_GPI_CTRL(0),
|
|
||||||
dev->gpi_ctrl[0]);
|
|
||||||
|
|
||||||
hmc7044_write(dev, HMC7044_REG_GPO_CTRL(0),
|
|
||||||
dev->gpo_ctrl[0]);
|
|
||||||
|
|
||||||
/* Program the output channels */
|
|
||||||
for (i = 0; i < dev->num_channels; i++) {
|
|
||||||
chan = &dev->channels[i];
|
|
||||||
|
|
||||||
if (chan->num >= HMC7044_NUM_CHAN || chan->disable)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_1(chan->num),
|
|
||||||
HMC7044_DIV_LSB(chan->divider));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_2(chan->num),
|
|
||||||
HMC7044_DIV_MSB(chan->divider));
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_8(chan->num),
|
|
||||||
HMC7044_DRIVER_MODE(chan->driver_mode) |
|
|
||||||
HMC7044_DRIVER_Z_MODE(chan->driver_impedance) |
|
|
||||||
(chan->dynamic_driver_enable ?
|
|
||||||
HMC7044_DYN_DRIVER_EN : 0) |
|
|
||||||
(chan->force_mute_enable ?
|
|
||||||
HMC7044_FORCE_MUTE_EN : 0));
|
|
||||||
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_3(chan->num),
|
|
||||||
chan->fine_delay & 0x1F);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_4(chan->num),
|
|
||||||
chan->coarse_delay & 0x1F);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_7(chan->num),
|
|
||||||
chan->out_mux_mode & 0x3);
|
|
||||||
|
|
||||||
hmc7044_write(dev, HMC7044_REG_CH_OUT_CRTL_0(chan->num),
|
|
||||||
(chan->start_up_mode_dynamic_enable ?
|
|
||||||
HMC7044_START_UP_MODE_DYN_EN : 0) |
|
|
||||||
(chan->output_control0_rb4_enable ? BIT(4) : 0) |
|
|
||||||
(chan->high_performance_mode_dis ?
|
|
||||||
0 : HMC7044_HI_PERF_MODE) | HMC7044_SYNC_EN |
|
|
||||||
HMC7044_CH_EN);
|
|
||||||
}
|
|
||||||
mdelay(10);
|
|
||||||
|
|
||||||
|
|
||||||
/* Do a restart to reset the system and initiate calibration */
|
|
||||||
hmc7044_write(dev, HMC7044_REG_REQ_MODE_0,
|
|
||||||
HMC7044_RESTART_DIV_FSM);
|
|
||||||
mdelay(1);
|
|
||||||
hmc7044_write(dev, HMC7044_REG_REQ_MODE_0,
|
|
||||||
(dev->high_performance_mode_clock_dist_en ?
|
|
||||||
HMC7044_HIGH_PERF_DISTRIB_PATH : 0));
|
|
||||||
mdelay(1);
|
|
||||||
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief hmc7044_reg_init
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t hmc7044_reg_init(struct hmc7044_dev **device,
|
|
||||||
const struct hmc7044_init_param *init_param)
|
|
||||||
{
|
|
||||||
int ret = SUCCESS;
|
|
||||||
struct hmc7044_dev *dev;
|
|
||||||
|
|
||||||
dev = (struct hmc7044_dev *)malloc(sizeof(*dev));
|
|
||||||
if (!dev)
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
/* SPI */
|
|
||||||
ret = spi_init(&dev->spi_desc, init_param->spi_init);
|
|
||||||
|
|
||||||
*device = dev;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the device.
|
|
||||||
* @param device - The device structure.
|
|
||||||
* @param init_param - The structure that contains the device initial
|
|
||||||
* parameters.
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
int32_t hmc7044_init(struct hmc7044_dev **device,
|
|
||||||
const struct hmc7044_init_param *init_param)
|
|
||||||
{
|
|
||||||
struct hmc7044_dev *dev;
|
|
||||||
int32_t ret;
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
dev = (struct hmc7044_dev *)malloc(sizeof(*dev));
|
|
||||||
if (!dev)
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
ret = spi_init(&dev->spi_desc, init_param->spi_init);
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
dev->is_hmc7043 = init_param->is_hmc7043;
|
|
||||||
|
|
||||||
dev->clkin_freq[0] = init_param->clkin_freq[0];
|
|
||||||
dev->clkin_freq[1] = init_param->clkin_freq[1];
|
|
||||||
dev->clkin_freq[2] = init_param->clkin_freq[2];
|
|
||||||
dev->clkin_freq[3] = init_param->clkin_freq[3];
|
|
||||||
|
|
||||||
dev->clkin_freq_ccf[0] = init_param->clkin_freq_ccf[0];
|
|
||||||
dev->clkin_freq_ccf[1] = init_param->clkin_freq_ccf[1];
|
|
||||||
dev->clkin_freq_ccf[2] = init_param->clkin_freq_ccf[2];
|
|
||||||
dev->clkin_freq_ccf[3] = init_param->clkin_freq_ccf[3];
|
|
||||||
|
|
||||||
dev->vcxo_freq = init_param->vcxo_freq;
|
|
||||||
dev->pll1_pfd = init_param->pll1_pfd;
|
|
||||||
dev->pll2_freq = init_param->pll2_freq;
|
|
||||||
dev->pll1_loop_bw = init_param->pll1_loop_bw;
|
|
||||||
|
|
||||||
dev->sysref_timer_div = init_param->sysref_timer_div;
|
|
||||||
dev->pll1_ref_prio_ctrl = init_param->pll1_ref_prio_ctrl;
|
|
||||||
dev->clkin0_rfsync_en = init_param->clkin0_rfsync_en;
|
|
||||||
dev->clkin1_vcoin_en = init_param->clkin1_vcoin_en;
|
|
||||||
dev->high_performance_mode_clock_dist_en =
|
|
||||||
init_param->high_performance_mode_clock_dist_en;
|
|
||||||
dev->rf_reseeder_en = !init_param->rf_reseeder_disable;
|
|
||||||
dev->sync_pin_mode = init_param->sync_pin_mode;
|
|
||||||
dev->pulse_gen_mode = init_param->pulse_gen_mode;
|
|
||||||
|
|
||||||
dev->in_buf_mode[0] = init_param->in_buf_mode[0];
|
|
||||||
dev->in_buf_mode[1] = init_param->in_buf_mode[1];
|
|
||||||
dev->in_buf_mode[2] = init_param->in_buf_mode[2];
|
|
||||||
dev->in_buf_mode[3] = init_param->in_buf_mode[3];
|
|
||||||
dev->in_buf_mode[4] = init_param->in_buf_mode[4];
|
|
||||||
|
|
||||||
dev->gpi_ctrl[0] = init_param->gpi_ctrl[0];
|
|
||||||
dev->gpi_ctrl[1] = init_param->gpi_ctrl[1];
|
|
||||||
dev->gpi_ctrl[2] = init_param->gpi_ctrl[2];
|
|
||||||
dev->gpi_ctrl[3] = init_param->gpi_ctrl[3];
|
|
||||||
|
|
||||||
dev->gpo_ctrl[0] = init_param->gpo_ctrl[0];
|
|
||||||
dev->gpo_ctrl[1] = init_param->gpo_ctrl[1];
|
|
||||||
dev->gpo_ctrl[2] = init_param->gpo_ctrl[2];
|
|
||||||
dev->gpo_ctrl[3] = init_param->gpo_ctrl[3];
|
|
||||||
|
|
||||||
dev->num_channels = init_param->num_channels;
|
|
||||||
dev->channels = (struct hmc7044_chan_spec *)
|
|
||||||
malloc(sizeof(*dev->channels) * dev->num_channels);
|
|
||||||
|
|
||||||
for (i = 0; i < dev->num_channels; i++) {
|
|
||||||
dev->channels[i].num = init_param->channels[i].num;
|
|
||||||
dev->channels[i].disable = init_param->channels[i].disable;
|
|
||||||
dev->channels[i].divider = init_param->channels[i].divider;
|
|
||||||
dev->channels[i].driver_mode =
|
|
||||||
init_param->channels[i].driver_mode;
|
|
||||||
dev->channels[i].high_performance_mode_dis =
|
|
||||||
init_param->channels[i].high_performance_mode_dis;
|
|
||||||
dev->channels[i].start_up_mode_dynamic_enable =
|
|
||||||
init_param->channels[i].start_up_mode_dynamic_enable;
|
|
||||||
dev->channels[i].dynamic_driver_enable =
|
|
||||||
init_param->channels[i].dynamic_driver_enable;
|
|
||||||
dev->channels[i].output_control0_rb4_enable =
|
|
||||||
init_param->channels[i].output_control0_rb4_enable;
|
|
||||||
dev->channels[i].force_mute_enable =
|
|
||||||
init_param->channels[i].force_mute_enable;
|
|
||||||
dev->channels[i].driver_impedance =
|
|
||||||
init_param->channels[i].driver_impedance;
|
|
||||||
dev->channels[i].coarse_delay =
|
|
||||||
init_param->channels[i].coarse_delay;
|
|
||||||
dev->channels[i].fine_delay =
|
|
||||||
init_param->channels[i].fine_delay;
|
|
||||||
dev->channels[i].out_mux_mode =
|
|
||||||
init_param->channels[i].out_mux_mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
*device = dev;
|
|
||||||
|
|
||||||
if (!dev->is_hmc7043)
|
|
||||||
return hmc7044_setup(dev);
|
|
||||||
else
|
|
||||||
return hmc7043_setup(dev);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Remove the device - release resources.
|
|
||||||
* @param device - The device structure.
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
int32_t hmc7044_remove(struct hmc7044_dev *device)
|
|
||||||
{
|
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
ret = spi_remove(device->spi_desc);
|
|
||||||
free(device->channels);
|
|
||||||
free(device);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@@ -1,276 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file hmc7044.h
|
|
||||||
* @brief Header file of HMC7044, HMC7043 Driver.
|
|
||||||
* @author DBogdan ([email protected])
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2018-2020(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef HMC7044_H_
|
|
||||||
#define HMC7044_H_
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "delay.h"
|
|
||||||
#include "spi.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*************************** Types Declarations *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
// Enum to select SYNC pin configuration with respect to PLL2 (0x0005)
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
SYNC_DISABLED = 0,
|
|
||||||
SYNC_MULTICHIP = 1,
|
|
||||||
SYNC_PULSE_GEN = 2,
|
|
||||||
SYNC_ALARM = 3
|
|
||||||
} hmc7044SyncPinModeSelect_t;
|
|
||||||
|
|
||||||
// Enum to select input buffer mode (0x000A, 0x000B, 0x000C, 0x000D, 0x000E)
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
BUFFER_ENABLE = (1) << 0,
|
|
||||||
BUFFER_DISABLE = (0) << 0,
|
|
||||||
ENABLE_INTERNAL_TERM = (1) << 1,
|
|
||||||
ENABLE_AC_COUPLE = (1) << 2,
|
|
||||||
ENABLE_LVPECL = (1) << 3,
|
|
||||||
ENABLE_HIGH_Z = (1) << 4
|
|
||||||
} hmc7044InputBufferMode_t;
|
|
||||||
|
|
||||||
// Enum to select output driver mode (0x003A, 0x003B, 0x00D0, 0x00DA, 0x00E4,
|
|
||||||
// 0x00EE, 0x00F8, 0x0102, 0x010C, 0x0116, 0x0120, 0x012A, 0x0134, 0x013E,
|
|
||||||
// 0x0148, 0x0152)
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
CML = 0,
|
|
||||||
LVPECL = 1,
|
|
||||||
LVDS = 2,
|
|
||||||
CMOS = 3
|
|
||||||
} hmc7044DriverMode_t;
|
|
||||||
|
|
||||||
// Enum to select the GPIx functionality. (0x0046, 0x0047, 0x0048, 0x0049)
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GPI_ENABLE = (1) << 0,
|
|
||||||
GPI_DISABLE = (0) << 0,
|
|
||||||
FORCE_PLL1_HOLDOVER = (0x01) << 1 | GPI_ENABLE,
|
|
||||||
SELECT_PLL1_REF_BIT1 = (0x02) << 1 | GPI_ENABLE,
|
|
||||||
SELECT_PLL1_REF_BIT2 = (0x03) << 1 | GPI_ENABLE,
|
|
||||||
CHIP_SLEEP_MODE = (0x04) << 1 | GPI_ENABLE,
|
|
||||||
MUTE_REQUSET = (0x05) << 1 | GPI_ENABLE,
|
|
||||||
SELECT_INTERNAL_VCO_TYPE = (0x06) << 1 | GPI_ENABLE,
|
|
||||||
SELECT_HI_PERF_MODE = (0x07) << 1 | GPI_ENABLE,
|
|
||||||
PULSE_GEN_REQUSET = (0x08) << 1 | GPI_ENABLE,
|
|
||||||
RESEED_REQUEST = (0x09) << 1 | GPI_ENABLE,
|
|
||||||
RESTART_REQUSET = (0x0A) << 1 | GPI_ENABLE,
|
|
||||||
FORCE_FANOUT_MODE = (0x0B) << 1 | GPI_ENABLE,
|
|
||||||
SLIP_REQUEST = (0x0D) << 1 | GPI_ENABLE,
|
|
||||||
} hmc7044GPIControl_t;
|
|
||||||
|
|
||||||
// Enum to select the GPOx functionality. (0x0050, 0x0051, 0x0052, 0x0053)
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
GPO_ENABLE = (1) << 0,
|
|
||||||
GPO_DISABLE = (0) << 0,
|
|
||||||
GPO_CMOS_MODE = (1) << 1,
|
|
||||||
GPO_OPEN_DRAIN_MODE = (0) << 1,
|
|
||||||
ALARM_SIGNAL = (0x00) << 3 | GPO_ENABLE,
|
|
||||||
SPI_SDATA = (0x01) << 3 | GPO_ENABLE,
|
|
||||||
CLKIN3_SIGNAL_LOSS = (0x02) << 3 | GPO_ENABLE,
|
|
||||||
CLKIN2_SIGNAL_LOSS = (0x03) << 3 | GPO_ENABLE,
|
|
||||||
CLKIN1_SIGNAL_LOSS = (0x04) << 3 | GPO_ENABLE,
|
|
||||||
CLKIN0_SIGNAL_LOSS = (0x05) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_ENABLE = (0x06) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_LOCK_DETECT = (0x07) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_ACQUIRING_LOCK = (0x08) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_NEAR_CLOCK_ACQ_STAT = (0x09) << 3 | GPO_ENABLE,
|
|
||||||
PLL2_LOCK_DETECT = (0x0A) << 3 | GPO_ENABLE,
|
|
||||||
PLL2_SYSREF_SYNC = (0x0B) << 3 | GPO_ENABLE,
|
|
||||||
CLOCK_OUTPUT_PHASE_STAT = (0x0C) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_PLL2_LOCKED = (0x0D) << 3 | GPO_ENABLE,
|
|
||||||
SYNC_REQUSRT_STAT = (0x0E) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_ACTIVE_CLKIN0 = (0x0F) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_ACTIVE_CLKIN1 = (0x10) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_IN_RANGE_STAT = (0x11) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_IN_STAT = (0x12) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_VCXO_STAT = (0x13) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_ACTIVE_CLKINx_STAT = (0x14) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_FSM_BIT0 = (0x15) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_FSM_BIT1 = (0x16) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_FSM_BIT2 = (0x17) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_EXIT_PHASE_BIT0 = (0x18) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_EXIT_PHASE_BIT1 = (0x19) << 3 | GPO_ENABLE,
|
|
||||||
CHANNEL_OUTPUT_FSM_BUSY = (0x1A) << 3 | GPO_ENABLE,
|
|
||||||
SYSREF_FSM_STAT_BIT0 = (0x1B) << 3 | GPO_ENABLE,
|
|
||||||
SYSREF_FSM_STAT_BIT1 = (0x1C) << 3 | GPO_ENABLE,
|
|
||||||
SYSREF_FSM_STAT_BIT2 = (0x1D) << 3 | GPO_ENABLE,
|
|
||||||
SYSREF_FSM_STAT_BIT3 = (0x1E) << 3 | GPO_ENABLE,
|
|
||||||
FORCE_LOGIC_1 = (0x1F) << 3 | GPO_ENABLE,
|
|
||||||
FORCE_LOGIC_0 = (0x20) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_AVG_VALUE_BIT0 = (0x27) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_AVG_VALUE_BIT1 = (0x28) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_AVG_VALUE_BIT2 = (0x29) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_AVG_VALUE_BIT3 = (0x2A) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_CURR_VALUE_BIT0 = (0x2B) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_CURR_VALUE_BIT1 = (0x2C) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_CURR_VALUE_BIT2 = (0x2D) << 3 | GPO_ENABLE,
|
|
||||||
PLL1_HOLDOVER_CURR_VALUE_BIT3 = (0x2E) << 3 | GPO_ENABLE
|
|
||||||
} hmc7044GPOControl_t;
|
|
||||||
|
|
||||||
// Enum to select output channel (0x00CF, 0x00D9, 0x00E3, 0x00ED, 0x00F7,
|
|
||||||
// 0x0101, 0x010B, 0x0115, 0x011F, 0x0129, 0x0133, 0x013D, 0x0147, 0x0151
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
CHANNEL_DIV = 0,
|
|
||||||
ANALOG_DELAY = 1,
|
|
||||||
OTHER_CHANNEL = 2,
|
|
||||||
VCO_CLOCK = 3
|
|
||||||
} hmc7044OutputMuxSelect_t;
|
|
||||||
|
|
||||||
// Enum to select output driver impedance selection for CML mode (0x00D0,
|
|
||||||
// 0x00DA, 0x00E4, 0x00EE, 0x00F8, 0x0102, 0x010C, 0x0116, 0x0120, 0x012A,
|
|
||||||
// 0x0134, 0x013E, 0x0148, 0x0152)
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
INTERNAL_RES_DISABLE = 0,
|
|
||||||
INTERNAL_100OHM_PER_PIN = 1,
|
|
||||||
// INTERNAL_RES_RESERVED = 2,
|
|
||||||
INTERNAL_50OHM_PER_PIN = 3
|
|
||||||
} hmc7044DriverImpedance_t;
|
|
||||||
|
|
||||||
// Enum to select pulse generator mode (0x005A)
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
PULSE_LEVEL_SENSITIVE = 0,
|
|
||||||
PULSE_ONE = 1,
|
|
||||||
PULSE_TWO = 2,
|
|
||||||
PULSE_FOUR = 3,
|
|
||||||
PULSE_EIGHT = 4,
|
|
||||||
PULSE_SIXTEEN = 5,
|
|
||||||
// PULSE_SIXTEEN = 6,
|
|
||||||
PULSE_CONTINOUS = 7
|
|
||||||
} hmc7044SyncPulseGenControl_t;
|
|
||||||
|
|
||||||
struct hmc7044_chan_spec {
|
|
||||||
unsigned int num;
|
|
||||||
bool disable;
|
|
||||||
bool high_performance_mode_dis;
|
|
||||||
bool start_up_mode_dynamic_enable;
|
|
||||||
bool dynamic_driver_enable;
|
|
||||||
bool output_control0_rb4_enable;
|
|
||||||
bool force_mute_enable;
|
|
||||||
unsigned int divider;
|
|
||||||
unsigned int coarse_delay;
|
|
||||||
unsigned int fine_delay;
|
|
||||||
hmc7044DriverMode_t driver_mode;
|
|
||||||
hmc7044DriverImpedance_t driver_impedance;
|
|
||||||
hmc7044OutputMuxSelect_t out_mux_mode;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hmc7044_config {
|
|
||||||
uint16_t addr;
|
|
||||||
uint8_t value;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hmc7044_dev {
|
|
||||||
struct spi_desc *spi_desc;
|
|
||||||
bool is_hmc7043;
|
|
||||||
uint32_t clkin_freq[4];
|
|
||||||
uint32_t clkin_freq_ccf[4];
|
|
||||||
uint32_t vcxo_freq;
|
|
||||||
uint32_t pll1_pfd;
|
|
||||||
uint32_t pll2_freq;
|
|
||||||
uint32_t pll1_loop_bw;
|
|
||||||
uint32_t sysref_timer_div;
|
|
||||||
unsigned int pll1_ref_prio_ctrl;
|
|
||||||
bool clkin0_rfsync_en;
|
|
||||||
bool clkin1_vcoin_en;
|
|
||||||
bool high_performance_mode_clock_dist_en;
|
|
||||||
bool rf_reseeder_en;
|
|
||||||
hmc7044SyncPinModeSelect_t sync_pin_mode;
|
|
||||||
hmc7044SyncPulseGenControl_t pulse_gen_mode;
|
|
||||||
uint32_t in_buf_mode[5];
|
|
||||||
uint32_t gpi_ctrl[4];
|
|
||||||
uint32_t gpo_ctrl[4];
|
|
||||||
uint32_t num_channels;
|
|
||||||
struct hmc7044_chan_spec *channels;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct hmc7044_init_param {
|
|
||||||
struct spi_init_param *spi_init;
|
|
||||||
bool is_hmc7043;
|
|
||||||
uint32_t clkin_freq[4];
|
|
||||||
uint32_t clkin_freq_ccf[4];
|
|
||||||
uint32_t vcxo_freq;
|
|
||||||
uint32_t pll1_pfd;
|
|
||||||
uint32_t pll2_freq;
|
|
||||||
uint32_t pll1_loop_bw;
|
|
||||||
uint32_t sysref_timer_div;
|
|
||||||
unsigned int pll1_ref_prio_ctrl;
|
|
||||||
bool clkin0_rfsync_en;
|
|
||||||
bool clkin1_vcoin_en;
|
|
||||||
bool high_performance_mode_clock_dist_en;
|
|
||||||
bool rf_reseeder_disable;
|
|
||||||
hmc7044SyncPinModeSelect_t sync_pin_mode;
|
|
||||||
hmc7044SyncPulseGenControl_t pulse_gen_mode;
|
|
||||||
uint32_t in_buf_mode[5];
|
|
||||||
uint32_t gpi_ctrl[4];
|
|
||||||
uint32_t gpo_ctrl[4];
|
|
||||||
uint32_t num_channels;
|
|
||||||
struct hmc7044_chan_spec *channels;
|
|
||||||
};
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/************************ Functions Declarations ******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Initialize the device. */
|
|
||||||
int32_t hmc7044_reg_init(struct hmc7044_dev **device,
|
|
||||||
const struct hmc7044_init_param *init_param);
|
|
||||||
int32_t hmc7044_init(struct hmc7044_dev **device,
|
|
||||||
const struct hmc7044_init_param *init_param);
|
|
||||||
/* Remove the device. */
|
|
||||||
int32_t hmc7044_remove(struct hmc7044_dev *device);
|
|
||||||
int32_t hmc7044_write(struct hmc7044_dev *dev,
|
|
||||||
uint16_t reg, uint8_t val);
|
|
||||||
int32_t hmc7044_read(struct hmc7044_dev *dev, uint16_t reg, uint8_t *val);
|
|
||||||
int32_t hmc7044_clk_recalc_rate(struct hmc7044_dev *dev, uint32_t chan_num,
|
|
||||||
uint64_t *rate);
|
|
||||||
int32_t hmc7044_clk_round_rate(struct hmc7044_dev *dev, uint32_t rate,
|
|
||||||
uint64_t *rounded_rate);
|
|
||||||
int32_t hmc7044_clk_set_rate(struct hmc7044_dev *dev, uint32_t chan_num,
|
|
||||||
uint64_t rate);
|
|
||||||
|
|
||||||
#endif // HMC7044_H_
|
|
||||||
@@ -1,464 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file xilinx/xilinx_gpio.c
|
|
||||||
* @brief Implementation of Xilinx GPIO Generic Driver.
|
|
||||||
* @author Antoniu Miclaus ([email protected])
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2019(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <xparameters.h>
|
|
||||||
#ifdef XPAR_XGPIO_NUM_INSTANCES
|
|
||||||
#include <xgpio.h>
|
|
||||||
#endif
|
|
||||||
#ifdef XPAR_XGPIOPS_NUM_INSTANCES
|
|
||||||
#include <xgpiops.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "error.h"
|
|
||||||
#include "gpio.h"
|
|
||||||
#include "xilinx_gpio.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/************************ Functions Definitions *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Prepare the GPIO decriptor.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param param - The structure that contains the GPIO parameters.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t _gpio_init(struct gpio_desc *desc,
|
|
||||||
const struct gpio_init_param *param)
|
|
||||||
{
|
|
||||||
int32_t ret;
|
|
||||||
struct xil_gpio_desc *xdesc;
|
|
||||||
struct xil_gpio_init_param *xinit;
|
|
||||||
|
|
||||||
ret = -1;
|
|
||||||
|
|
||||||
xdesc = desc->extra;
|
|
||||||
xinit = param->extra;
|
|
||||||
|
|
||||||
xdesc->type = xinit->type;
|
|
||||||
desc->number = param->number;
|
|
||||||
|
|
||||||
switch (xinit->type) {
|
|
||||||
case GPIO_PL:
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
xdesc->instance = (XGpio *)malloc(sizeof(XGpio));
|
|
||||||
if(!xdesc->instance)
|
|
||||||
goto pl_error;
|
|
||||||
|
|
||||||
xdesc->config = XGpio_LookupConfig(xinit->device_id);
|
|
||||||
if(xdesc->config == NULL)
|
|
||||||
goto pl_error;
|
|
||||||
|
|
||||||
ret = XGpio_CfgInitialize(xdesc->instance,
|
|
||||||
xdesc->config,
|
|
||||||
((XGpio_Config*)xdesc->config)
|
|
||||||
->BaseAddress);
|
|
||||||
if(ret < 0)
|
|
||||||
goto pl_error;
|
|
||||||
|
|
||||||
break;
|
|
||||||
pl_error:
|
|
||||||
free(xdesc->instance);
|
|
||||||
#endif
|
|
||||||
goto error;
|
|
||||||
case GPIO_PS:
|
|
||||||
#ifdef XGPIOPS_H
|
|
||||||
xdesc->instance = (XGpioPs *)malloc(sizeof(XGpioPs));
|
|
||||||
if(!xdesc->instance)
|
|
||||||
goto ps_error;
|
|
||||||
|
|
||||||
xdesc->config = XGpioPs_LookupConfig(xinit->device_id);
|
|
||||||
if(xdesc->config == NULL)
|
|
||||||
goto ps_error;
|
|
||||||
|
|
||||||
ret = XGpioPs_CfgInitialize(xdesc->instance,
|
|
||||||
xdesc->config,
|
|
||||||
((XGpioPs_Config*)xdesc->config)->BaseAddr);
|
|
||||||
if(ret < 0)
|
|
||||||
goto ps_error;
|
|
||||||
break;
|
|
||||||
ps_error:
|
|
||||||
free(xdesc->instance);
|
|
||||||
#endif
|
|
||||||
goto error;
|
|
||||||
error:
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Obtain the GPIO decriptor.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param param - GPIO initialization parameters
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_get(struct gpio_desc **desc,
|
|
||||||
const struct gpio_init_param *param)
|
|
||||||
{
|
|
||||||
struct gpio_desc *descriptor;
|
|
||||||
struct xil_gpio_desc *extra;
|
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
descriptor = (struct gpio_desc *)malloc(sizeof(*descriptor));
|
|
||||||
extra = (struct xil_gpio_desc*)malloc(sizeof(*extra));
|
|
||||||
|
|
||||||
if (!descriptor || !extra)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
descriptor->extra = extra;
|
|
||||||
ret = _gpio_init(descriptor, param);
|
|
||||||
|
|
||||||
if(ret != 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
*desc = descriptor;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
error:
|
|
||||||
free(extra);
|
|
||||||
free(descriptor);
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the value of an optional GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param param - GPIO Initialization parameters.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_get_optional(struct gpio_desc **desc,
|
|
||||||
const struct gpio_init_param *param)
|
|
||||||
{
|
|
||||||
if(param == NULL) {
|
|
||||||
*desc = NULL;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
return xil_gpio_get(desc, param);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Free the resources allocated by gpio_get().
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_remove(struct gpio_desc *desc)
|
|
||||||
{
|
|
||||||
if (desc != NULL) {
|
|
||||||
free(((struct xil_gpio_desc *)(desc->extra))->instance);
|
|
||||||
free(desc->extra);
|
|
||||||
free(desc);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the input direction of the specified GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_direction_input(struct gpio_desc *desc)
|
|
||||||
{
|
|
||||||
struct xil_gpio_desc *extra;
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
uint8_t pin = desc->number;
|
|
||||||
uint32_t channel = 1;
|
|
||||||
uint32_t config = 0;
|
|
||||||
#endif
|
|
||||||
extra = desc->extra;
|
|
||||||
|
|
||||||
switch (extra->type) {
|
|
||||||
case GPIO_PL:
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
/* We assume that pin 32 is the first pin from channel 2 */
|
|
||||||
if (pin >= 32) {
|
|
||||||
channel = 2;
|
|
||||||
pin -= 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
config = XGpio_GetDataDirection((XGpio *)extra->instance,
|
|
||||||
channel);
|
|
||||||
config |= (1 << pin);
|
|
||||||
XGpio_SetDataDirection((XGpio *)extra->instance,
|
|
||||||
channel,
|
|
||||||
config);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case GPIO_PS:
|
|
||||||
#ifdef XGPIOPS_H
|
|
||||||
XGpioPs_SetDirectionPin(extra->instance,
|
|
||||||
desc->number,
|
|
||||||
GPIO_IN);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable the output direction of the specified GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param value - The value.
|
|
||||||
* Example: GPIO_HIGH
|
|
||||||
* GPIO_LOW
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_direction_output(struct gpio_desc *desc,
|
|
||||||
uint8_t value)
|
|
||||||
{
|
|
||||||
struct xil_gpio_desc *extra;
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
uint8_t pin = desc->number;
|
|
||||||
uint8_t channel;
|
|
||||||
uint32_t reg_val;
|
|
||||||
#endif
|
|
||||||
extra = desc->extra;
|
|
||||||
|
|
||||||
switch (extra->type) {
|
|
||||||
case GPIO_PL:
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
if (pin >= 32) {
|
|
||||||
channel = 2;
|
|
||||||
pin -= 32;
|
|
||||||
} else
|
|
||||||
channel = 1;
|
|
||||||
|
|
||||||
reg_val = XGpio_GetDataDirection(extra->instance,
|
|
||||||
channel);
|
|
||||||
reg_val &= ~(1 << pin);
|
|
||||||
XGpio_SetDataDirection(extra->instance,
|
|
||||||
channel,
|
|
||||||
reg_val);
|
|
||||||
reg_val = XGpio_DiscreteRead(extra->instance,
|
|
||||||
channel);
|
|
||||||
if(value)
|
|
||||||
reg_val |= (1 << pin);
|
|
||||||
else
|
|
||||||
reg_val &= ~(1 << pin);
|
|
||||||
XGpio_DiscreteWrite(extra->instance,
|
|
||||||
channel,
|
|
||||||
reg_val);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case GPIO_PS:
|
|
||||||
#ifdef XGPIOPS_H
|
|
||||||
XGpioPs_SetDirectionPin(extra->instance,
|
|
||||||
desc->number,
|
|
||||||
GPIO_OUT);
|
|
||||||
XGpioPs_SetOutputEnablePin(extra->instance,
|
|
||||||
desc->number,
|
|
||||||
GPIO_OUT);
|
|
||||||
XGpioPs_WritePin(extra->instance,
|
|
||||||
desc->number,
|
|
||||||
value);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the direction of the specified GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param direction - The direction.
|
|
||||||
* Example: GPIO_OUT
|
|
||||||
* GPIO_IN
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_get_direction(struct gpio_desc *desc,
|
|
||||||
uint8_t *direction)
|
|
||||||
{
|
|
||||||
if (!desc)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
struct xil_gpio_desc *extra;
|
|
||||||
uint8_t pin = desc->number;
|
|
||||||
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
uint8_t channel;
|
|
||||||
#endif
|
|
||||||
extra = desc->extra;
|
|
||||||
|
|
||||||
switch (extra->type) {
|
|
||||||
case GPIO_PL:
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
if (pin >= 32) {
|
|
||||||
channel = 2;
|
|
||||||
pin -= 32;
|
|
||||||
} else
|
|
||||||
channel = 1;
|
|
||||||
*direction = ((XGpio_GetDataDirection(extra->instance,
|
|
||||||
channel) >> pin) & 0x1) ^ 0x1;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case GPIO_PS:
|
|
||||||
#ifdef XGPIOPS_H
|
|
||||||
*direction = XGpioPs_GetDirectionPin(extra->instance, pin);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the value of the specified GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param value - The value.
|
|
||||||
* Example: GPIO_HIGH
|
|
||||||
* GPIO_LOW
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_set_value(struct gpio_desc *desc,
|
|
||||||
uint8_t value)
|
|
||||||
{
|
|
||||||
struct xil_gpio_desc *extra;
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
uint8_t pin = desc->number;
|
|
||||||
uint8_t channel;
|
|
||||||
uint32_t reg_val;
|
|
||||||
#endif
|
|
||||||
extra = desc->extra;
|
|
||||||
|
|
||||||
switch (extra->type) {
|
|
||||||
case GPIO_PL:
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
if (pin >= 32) {
|
|
||||||
channel = 2;
|
|
||||||
pin -= 32;
|
|
||||||
} else
|
|
||||||
channel = 1;
|
|
||||||
|
|
||||||
reg_val = XGpio_DiscreteRead(extra->instance, channel);
|
|
||||||
if(value)
|
|
||||||
reg_val |= (1 << pin);
|
|
||||||
else
|
|
||||||
reg_val &= ~(1 << pin);
|
|
||||||
XGpio_DiscreteWrite(extra->instance, channel, reg_val);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case GPIO_PS:
|
|
||||||
#ifdef XGPIOPS_H
|
|
||||||
XGpioPs_WritePin(extra->instance, desc->number, value);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Get the value of the specified GPIO.
|
|
||||||
* @param desc - The GPIO descriptor.
|
|
||||||
* @param value - The value.
|
|
||||||
* Example: GPIO_HIGH
|
|
||||||
* GPIO_LOW
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_get_value(struct gpio_desc *desc,
|
|
||||||
uint8_t *value)
|
|
||||||
{
|
|
||||||
if (!desc)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
struct xil_gpio_desc *extra;
|
|
||||||
uint8_t pin = desc->number;
|
|
||||||
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
uint8_t channel;
|
|
||||||
#endif
|
|
||||||
extra = desc->extra;
|
|
||||||
|
|
||||||
switch (extra->type) {
|
|
||||||
case GPIO_PL:
|
|
||||||
#ifdef XGPIO_H
|
|
||||||
if (pin >= 32) {
|
|
||||||
channel = 2;
|
|
||||||
pin -= 32;
|
|
||||||
} else
|
|
||||||
channel = 1;
|
|
||||||
*value = (XGpio_DiscreteRead(extra->instance, channel) >> pin) & 0x01;
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
case GPIO_PS:
|
|
||||||
#ifdef XGPIOPS_H
|
|
||||||
*value = XGpioPs_ReadPin(extra->instance, pin);
|
|
||||||
#endif
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Xilinx platform specific GPIO platform ops structure
|
|
||||||
*/
|
|
||||||
const struct gpio_platform_ops xil_gpio_ops = {
|
|
||||||
.gpio_ops_get = &xil_gpio_get,
|
|
||||||
.gpio_ops_get_optional = &xil_gpio_get_optional,
|
|
||||||
.gpio_ops_remove = &xil_gpio_remove,
|
|
||||||
.gpio_ops_direction_input = &xil_gpio_direction_input,
|
|
||||||
.gpio_ops_direction_output = &xil_gpio_direction_output,
|
|
||||||
.gpio_ops_get_direction = &xil_gpio_get_direction,
|
|
||||||
.gpio_ops_set_value = &xil_gpio_set_value,
|
|
||||||
.gpio_ops_get_value = &xil_gpio_get_value,
|
|
||||||
};
|
|
||||||
@@ -1,95 +0,0 @@
|
|||||||
/*******************************************************************************
|
|
||||||
* @file xilinx/xilinx_gpio.h
|
|
||||||
* @brief Header containing extra types used in the gpio driver
|
|
||||||
* @author scuciurean ([email protected])
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2019(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef XILINX_GPIO_H_
|
|
||||||
#define XILINX_GPIO_H_
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*************************** Types Declarations *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum xil_gpio_type
|
|
||||||
* @brief Xilinx platform architecture sections
|
|
||||||
*/
|
|
||||||
enum xil_gpio_type {
|
|
||||||
/** Programmable Logic */
|
|
||||||
GPIO_PL,
|
|
||||||
/** Processing System */
|
|
||||||
GPIO_PS
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct xil_gpio_init_param
|
|
||||||
* @brief Structure holding the initialization parameters for Xilinx platform
|
|
||||||
* specific GPIO parameters.
|
|
||||||
*/
|
|
||||||
struct xil_gpio_init_param {
|
|
||||||
/** Xilinx architecture */
|
|
||||||
enum xil_gpio_type type;
|
|
||||||
/** Device ID */
|
|
||||||
uint32_t device_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct xil_gpio_desc
|
|
||||||
* @brief Xilinx platform specific GPIO descriptor
|
|
||||||
*/
|
|
||||||
struct xil_gpio_desc {
|
|
||||||
/** Xilinx architecture */
|
|
||||||
enum xil_gpio_type type;
|
|
||||||
/** Xilinx GPIO configuration */
|
|
||||||
void *config;
|
|
||||||
/** Xilinx GPIO Instance */
|
|
||||||
void *instance;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Xilinx platform specific gpio platform ops structure
|
|
||||||
*/
|
|
||||||
extern const struct gpio_platform_ops xil_gpio_ops;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,360 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file xilinx/xilinx_gpio_irq.c
|
|
||||||
* @brief Implementation of Xilinx GPIO IRQ Generic Driver.
|
|
||||||
* @author Porumb Andrei ([email protected])
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2021(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "xparameters.h"
|
|
||||||
#include "error.h"
|
|
||||||
#include "xilinx_gpio_irq.h"
|
|
||||||
#include "util.h"
|
|
||||||
#include "list.h"
|
|
||||||
#include "irq.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/************************ Functions Definitions *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Comparing function used by list.
|
|
||||||
* @param desc_a - Compared item
|
|
||||||
* @param desc_b - Reference item
|
|
||||||
* @return - 0 if items match
|
|
||||||
*/
|
|
||||||
static int32_t call_cmp(struct xil_callback_desc *desc_a,
|
|
||||||
struct xil_callback_desc *desc_b)
|
|
||||||
{
|
|
||||||
return desc_a->pin_nb - desc_b->pin_nb;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Function called when GPIO IRQ occurs.
|
|
||||||
* @param param - GPIO IRQ desc's extra field
|
|
||||||
* @return - None.
|
|
||||||
*/
|
|
||||||
static void xil_gpio_irq_handler(struct xil_gpio_irq_desc *param)
|
|
||||||
{
|
|
||||||
int32_t status = 0;
|
|
||||||
int32_t pin_nb;
|
|
||||||
struct xil_callback_desc *callback_desc;
|
|
||||||
|
|
||||||
status = iterator_move_to_idx(param->it, 0);
|
|
||||||
while(!status) {
|
|
||||||
iterator_read(param->it, &callback_desc);
|
|
||||||
status = iterator_move(param->it, 1);
|
|
||||||
if(XGpioPs_IntrGetStatusPin(¶m->my_Gpio, callback_desc->pin_nb))
|
|
||||||
callback_desc->triggered = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = iterator_move_to_idx(param->it, 0);
|
|
||||||
while(!status) {
|
|
||||||
iterator_read(param->it, &callback_desc);
|
|
||||||
status = iterator_move(param->it, 1);
|
|
||||||
if(callback_desc->triggered == true) {
|
|
||||||
callback_desc->triggered = false;
|
|
||||||
XGpioPs_IntrDisablePin(¶m->my_Gpio, callback_desc->pin_nb);
|
|
||||||
XGpioPs_IntrClearPin(¶m->my_Gpio, callback_desc->pin_nb);
|
|
||||||
callback_desc->callback.legacy_callback(callback_desc->callback.ctx, 0U, NULL);
|
|
||||||
if(callback_desc->enabled)
|
|
||||||
XGpioPs_IntrEnablePin(¶m->my_Gpio, callback_desc->pin_nb);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Disable specific GPIO IRQ pin.
|
|
||||||
* @param desc - The GPIO IRQ controller descriptor.
|
|
||||||
* @param irq_id - Pin number.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_irq_disable(struct irq_ctrl_desc *desc, uint32_t irq_id)
|
|
||||||
{
|
|
||||||
int32_t status;
|
|
||||||
struct xil_gpio_irq_desc *extra;
|
|
||||||
struct xil_callback_desc *callback_desc;
|
|
||||||
|
|
||||||
extra = desc->extra;
|
|
||||||
|
|
||||||
status = iterator_move_to_idx(extra->it, 0);
|
|
||||||
while(!status) {
|
|
||||||
iterator_read(extra->it, &callback_desc);
|
|
||||||
status = iterator_move(extra->it, 1);
|
|
||||||
if(callback_desc->pin_nb == irq_id) {
|
|
||||||
callback_desc->enabled = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
XGpioPs_IntrDisablePin(&extra->my_Gpio, irq_id);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Initialize the GPIO IRQ controller.
|
|
||||||
* @param desc - The GPIO IRQ controller descriptor.
|
|
||||||
* @param param - The GPIO IRQ controller initial parameters.
|
|
||||||
* irq_ctrl_id from irq_init_param is the interrupt id for the parent controller
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_irq_ctrl_init(struct irq_ctrl_desc **desc,
|
|
||||||
const struct irq_init_param *param)
|
|
||||||
{
|
|
||||||
int32_t i;
|
|
||||||
int32_t status;
|
|
||||||
struct irq_ctrl_desc *ldesc;
|
|
||||||
static XGpioPs_Config *GPIO_Config;
|
|
||||||
struct xil_gpio_irq_desc *xil_desc;
|
|
||||||
struct xil_gpio_irq_init_param *xil_ip;
|
|
||||||
struct callback_desc callback;
|
|
||||||
|
|
||||||
xil_desc = (struct xil_gpio_irq_desc *)calloc(1, sizeof(*xil_desc));
|
|
||||||
if(!xil_desc)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
ldesc = (struct irq_ctrl_desc *)calloc(1, sizeof(*ldesc));
|
|
||||||
if(!ldesc) {
|
|
||||||
free(xil_desc);
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
|
|
||||||
xil_ip = param->extra;
|
|
||||||
GPIO_Config = XGpioPs_LookupConfig(xil_ip->gpio_device_id);
|
|
||||||
status = XGpioPs_CfgInitialize(&xil_desc->my_Gpio, GPIO_Config,
|
|
||||||
GPIO_Config->BaseAddr);
|
|
||||||
if(status)
|
|
||||||
goto error_desc;
|
|
||||||
|
|
||||||
ldesc->extra = xil_desc;
|
|
||||||
xil_desc->parent_desc = xil_ip->parent_desc;
|
|
||||||
|
|
||||||
status = list_init(&xil_desc->callback_list, LIST_DEFAULT,
|
|
||||||
call_cmp);
|
|
||||||
if(status)
|
|
||||||
goto error_list;
|
|
||||||
|
|
||||||
status = iterator_init(&xil_desc->it, xil_desc->callback_list, 0);
|
|
||||||
if(status) {
|
|
||||||
iterator_remove(xil_desc->it);
|
|
||||||
goto error_list;
|
|
||||||
}
|
|
||||||
|
|
||||||
ldesc->irq_ctrl_id = param->irq_ctrl_id;
|
|
||||||
status = irq_trigger_level_set(xil_desc->parent_desc, ldesc->irq_ctrl_id,
|
|
||||||
IRQ_EDGE_RISING);
|
|
||||||
if(status)
|
|
||||||
goto error_op;
|
|
||||||
|
|
||||||
status = irq_enable(xil_desc->parent_desc, ldesc->irq_ctrl_id);
|
|
||||||
if(status)
|
|
||||||
goto error_op;
|
|
||||||
|
|
||||||
callback.legacy_callback = &xil_gpio_irq_handler;
|
|
||||||
callback.ctx = ldesc->extra;
|
|
||||||
status = irq_register_callback(xil_desc->parent_desc, ldesc->irq_ctrl_id,
|
|
||||||
&callback);
|
|
||||||
if(status)
|
|
||||||
goto error_op;
|
|
||||||
|
|
||||||
*desc = ldesc;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
error_op:
|
|
||||||
iterator_remove(xil_desc->it);
|
|
||||||
error_list:
|
|
||||||
list_remove(xil_desc->callback_list);
|
|
||||||
error_desc:
|
|
||||||
free(xil_desc);
|
|
||||||
free(ldesc);
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set GPIO interrupt trigger level.
|
|
||||||
* @param desc - The GPIO IRQ controller descriptor.
|
|
||||||
* @param irq_id - Pin number.
|
|
||||||
* @param trig - New trigger level for the GPIO interrupt.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_irq_trigger_level_set(struct irq_ctrl_desc *desc,
|
|
||||||
uint32_t irq_id,
|
|
||||||
enum irq_trig_level trig)
|
|
||||||
{
|
|
||||||
static const int32_t trig_level[5] = {XGPIOPS_IRQ_TYPE_LEVEL_LOW,
|
|
||||||
XGPIOPS_IRQ_TYPE_LEVEL_HIGH,
|
|
||||||
XGPIOPS_IRQ_TYPE_EDGE_FALLING,
|
|
||||||
XGPIOPS_IRQ_TYPE_EDGE_RISING,
|
|
||||||
XGPIOPS_IRQ_TYPE_EDGE_BOTH
|
|
||||||
};
|
|
||||||
struct xil_gpio_irq_desc *extra;
|
|
||||||
|
|
||||||
extra = desc->extra;
|
|
||||||
XGpioPs_SetIntrTypePin(&extra->my_Gpio, irq_id, trig_level[trig]);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Register pin specific GPIO interrupt.
|
|
||||||
* @param desc - The GPIO IRQ controller descriptor.
|
|
||||||
* @param irq_id - Pin number.
|
|
||||||
* @param callback_desc - Callback.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_irq_register_callback(struct irq_ctrl_desc *desc,
|
|
||||||
uint32_t irq_id,
|
|
||||||
struct callback_desc *callback_desc)
|
|
||||||
{
|
|
||||||
struct xil_callback_desc *dev_callback;
|
|
||||||
struct xil_gpio_irq_desc *extra;
|
|
||||||
|
|
||||||
dev_callback = (struct xil_callback_desc *)calloc(1,
|
|
||||||
sizeof(*dev_callback));
|
|
||||||
if(!dev_callback)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
dev_callback->pin_nb = irq_id;
|
|
||||||
dev_callback->callback.legacy_callback = callback_desc->legacy_callback;
|
|
||||||
dev_callback->callback.ctx = callback_desc->ctx;
|
|
||||||
dev_callback->triggered = false;
|
|
||||||
|
|
||||||
extra = desc->extra;
|
|
||||||
XGpioPs_SetDirectionPin(&extra->my_Gpio, irq_id, 0);
|
|
||||||
list_add_last(extra->callback_list, dev_callback);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Unregister pin specific GPIO interrupt.
|
|
||||||
* @param desc - The GPIO IRQ controller descriptor.
|
|
||||||
* @param irq_id - Pin number.
|
|
||||||
* @param cb - Callback descriptor.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_irq_unregister_callback(struct irq_ctrl_desc *desc,
|
|
||||||
uint32_t irq_id, struct callback_desc *cb)
|
|
||||||
{
|
|
||||||
int32_t status;
|
|
||||||
struct xil_gpio_irq_desc *extra;
|
|
||||||
struct xil_callback_desc *dev_callback;
|
|
||||||
struct xil_callback_desc search_callback;
|
|
||||||
|
|
||||||
extra = desc->extra;
|
|
||||||
search_callback.pin_nb = irq_id;
|
|
||||||
status = list_get_find(extra->callback_list, &dev_callback,
|
|
||||||
&search_callback);
|
|
||||||
if(status)
|
|
||||||
return -ENXIO;
|
|
||||||
|
|
||||||
free(dev_callback);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Enable specific GPIO IRQ pin.
|
|
||||||
* @param desc - The GPIO IRQ controller descriptor.
|
|
||||||
* @param irq_id - Pin number.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_irq_enable(struct irq_ctrl_desc *desc, uint32_t irq_id)
|
|
||||||
{
|
|
||||||
int32_t status;
|
|
||||||
struct xil_gpio_irq_desc *extra;
|
|
||||||
struct xil_callback_desc *callback_desc;
|
|
||||||
|
|
||||||
extra = desc->extra;
|
|
||||||
|
|
||||||
status = iterator_move_to_idx(extra->it, 0);
|
|
||||||
while(!status) {
|
|
||||||
iterator_read(extra->it, &callback_desc);
|
|
||||||
status = iterator_move(extra->it, 1);
|
|
||||||
if(callback_desc->pin_nb == irq_id) {
|
|
||||||
callback_desc->enabled = true;
|
|
||||||
XGpioPs_IntrClearPin(&extra->my_Gpio, irq_id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
XGpioPs_IntrEnablePin(&extra->my_Gpio, irq_id);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Remove the GPIO IRQ controller.
|
|
||||||
* @param desc - The GPIO IRQ controller descriptor.
|
|
||||||
* @return 0 in case of success, -1 otherwise.
|
|
||||||
*/
|
|
||||||
int32_t xil_gpio_irq_ctrl_remove(struct irq_ctrl_desc *desc)
|
|
||||||
{
|
|
||||||
struct xil_gpio_irq_desc *extra;
|
|
||||||
struct xil_callback_desc *callback_desc;
|
|
||||||
|
|
||||||
if (!desc)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
extra = desc->extra;
|
|
||||||
while (0 == list_get_first(extra->callback_list, &callback_desc))
|
|
||||||
free(callback_desc);
|
|
||||||
|
|
||||||
iterator_remove(extra->it);
|
|
||||||
list_remove(extra->callback_list);
|
|
||||||
free(extra);
|
|
||||||
free(desc);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Xilinx platform specific GPIO IRQ platform ops structure
|
|
||||||
*/
|
|
||||||
const struct irq_platform_ops xil_gpio_irq_ops = {
|
|
||||||
.init = &xil_gpio_irq_ctrl_init,
|
|
||||||
.enable = &xil_gpio_irq_enable,
|
|
||||||
.disable = &xil_gpio_irq_disable,
|
|
||||||
.trigger_level_set = &xil_gpio_irq_trigger_level_set,
|
|
||||||
.register_callback = &xil_gpio_irq_register_callback,
|
|
||||||
.unregister_callback = xil_gpio_irq_unregister_callback,
|
|
||||||
.remove = &xil_gpio_irq_ctrl_remove
|
|
||||||
};
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file xilinx_gpio_irq.h
|
|
||||||
* @brief Implementation of Xilinx GPIO IRQ Generic Driver.
|
|
||||||
* @author Porumb Andrei ([email protected])
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2021(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef XILINX_GPIO_IRQ_H_
|
|
||||||
#define XILINX_GPIO_IRQ_H_
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
#include "stdbool.h"
|
|
||||||
#include "list.h"
|
|
||||||
#include "xgpiops.h"
|
|
||||||
#include "irq.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*************************** Types Declarations *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
/**
|
|
||||||
* @struct xil_callback_desc
|
|
||||||
* @brief Structure holding callback parameters for each pin
|
|
||||||
*/
|
|
||||||
struct xil_callback_desc {
|
|
||||||
int32_t pin_nb;
|
|
||||||
struct callback_desc callback;
|
|
||||||
bool triggered;
|
|
||||||
bool enabled;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct xil_gpio_irq_init_param
|
|
||||||
* @brief Structure holding the initialization parameters for Xilinx platform
|
|
||||||
* specific GPIO IRQ parameters.
|
|
||||||
*/
|
|
||||||
struct xil_gpio_irq_init_param {
|
|
||||||
struct irq_ctrl_desc *parent_desc;
|
|
||||||
int32_t gpio_device_id;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct xil_gpio_irq_desc
|
|
||||||
* @brief Xilinx platform specific GPIO IRQ descriptor
|
|
||||||
*/
|
|
||||||
struct xil_gpio_irq_desc {
|
|
||||||
struct irq_ctrl_desc *parent_desc;
|
|
||||||
XGpioPs my_Gpio;
|
|
||||||
struct list_desc *callback_list;
|
|
||||||
struct iterator *it;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Xilinx specific GPIO IRQ platform ops structure
|
|
||||||
*/
|
|
||||||
extern const struct irq_platform_ops xil_gpio_irq_ops;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -1,552 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file ad9361_api.h
|
|
||||||
* @brief Header file of AD9361 API Driver.
|
|
||||||
* @author DBogdan (dragos.bogdan@analog.com)
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2013(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef AD9361_API_H_
|
|
||||||
#define AD9361_API_H_
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include "ad9361_util.h"
|
|
||||||
#include "gpio.h"
|
|
||||||
#include "spi.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*************************** Types Declarations *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
typedef struct {
|
|
||||||
/* Device selection */
|
|
||||||
enum dev_id dev_sel;
|
|
||||||
/* Reference Clock */
|
|
||||||
uint32_t reference_clk_rate;
|
|
||||||
/* Base Configuration */
|
|
||||||
uint8_t two_rx_two_tx_mode_enable; /* adi,2rx-2tx-mode-enable */
|
|
||||||
uint8_t one_rx_one_tx_mode_use_rx_num; /* adi,1rx-1tx-mode-use-rx-num */
|
|
||||||
uint8_t one_rx_one_tx_mode_use_tx_num; /* adi,1rx-1tx-mode-use-tx-num */
|
|
||||||
uint8_t frequency_division_duplex_mode_enable; /* adi,frequency-division-duplex-mode-enable */
|
|
||||||
uint8_t frequency_division_duplex_independent_mode_enable; /* adi,frequency-division-duplex-independent-mode-enable */
|
|
||||||
uint8_t tdd_use_dual_synth_mode_enable; /* adi,tdd-use-dual-synth-mode-enable */
|
|
||||||
uint8_t tdd_skip_vco_cal_enable; /* adi,tdd-skip-vco-cal-enable */
|
|
||||||
uint32_t tx_fastlock_delay_ns; /* adi,tx-fastlock-delay-ns */
|
|
||||||
uint32_t rx_fastlock_delay_ns; /* adi,rx-fastlock-delay-ns */
|
|
||||||
uint8_t rx_fastlock_pincontrol_enable; /* adi,rx-fastlock-pincontrol-enable */
|
|
||||||
uint8_t tx_fastlock_pincontrol_enable; /* adi,tx-fastlock-pincontrol-enable */
|
|
||||||
uint8_t external_rx_lo_enable; /* adi,external-rx-lo-enable */
|
|
||||||
uint8_t external_tx_lo_enable; /* adi,external-tx-lo-enable */
|
|
||||||
uint8_t dc_offset_tracking_update_event_mask; /* adi,dc-offset-tracking-update-event-mask */
|
|
||||||
uint8_t dc_offset_attenuation_high_range; /* adi,dc-offset-attenuation-high-range */
|
|
||||||
uint8_t dc_offset_attenuation_low_range; /* adi,dc-offset-attenuation-low-range */
|
|
||||||
uint8_t dc_offset_count_high_range; /* adi,dc-offset-count-high-range */
|
|
||||||
uint8_t dc_offset_count_low_range; /* adi,dc-offset-count-low-range */
|
|
||||||
uint8_t split_gain_table_mode_enable; /* adi,split-gain-table-mode-enable */
|
|
||||||
uint32_t trx_synthesizer_target_fref_overwrite_hz; /* adi,trx-synthesizer-target-fref-overwrite-hz */
|
|
||||||
uint8_t qec_tracking_slow_mode_enable; /* adi,qec-tracking-slow-mode-enable */
|
|
||||||
/* ENSM Control */
|
|
||||||
uint8_t ensm_enable_pin_pulse_mode_enable; /* adi,ensm-enable-pin-pulse-mode-enable */
|
|
||||||
uint8_t ensm_enable_txnrx_control_enable; /* adi,ensm-enable-txnrx-control-enable */
|
|
||||||
/* LO Control */
|
|
||||||
uint64_t rx_synthesizer_frequency_hz; /* adi,rx-synthesizer-frequency-hz */
|
|
||||||
uint64_t tx_synthesizer_frequency_hz; /* adi,tx-synthesizer-frequency-hz */
|
|
||||||
uint8_t tx_lo_powerdown_managed_enable; /* adi,tx-lo-powerdown-managed-enable */
|
|
||||||
/* Rate & BW Control */
|
|
||||||
uint32_t rx_path_clock_frequencies[6]; /* adi,rx-path-clock-frequencies */
|
|
||||||
uint32_t tx_path_clock_frequencies[6]; /* adi,tx-path-clock-frequencies */
|
|
||||||
uint32_t rf_rx_bandwidth_hz; /* adi,rf-rx-bandwidth-hz */
|
|
||||||
uint32_t rf_tx_bandwidth_hz; /* adi,rf-tx-bandwidth-hz */
|
|
||||||
/* RF Port Control */
|
|
||||||
uint32_t rx_rf_port_input_select; /* adi,rx-rf-port-input-select */
|
|
||||||
uint32_t tx_rf_port_input_select; /* adi,tx-rf-port-input-select */
|
|
||||||
/* TX Attenuation Control */
|
|
||||||
int32_t tx_attenuation_mdB; /* adi,tx-attenuation-mdB */
|
|
||||||
uint8_t update_tx_gain_in_alert_enable; /* adi,update-tx-gain-in-alert-enable */
|
|
||||||
/* Reference Clock Control */
|
|
||||||
uint8_t xo_disable_use_ext_refclk_enable; /* adi,xo-disable-use-ext-refclk-enable */
|
|
||||||
uint32_t dcxo_coarse_and_fine_tune[2]; /* adi,dcxo-coarse-and-fine-tune */
|
|
||||||
uint32_t clk_output_mode_select; /* adi,clk-output-mode-select */
|
|
||||||
/* Gain Control */
|
|
||||||
uint8_t gc_rx1_mode; /* adi,gc-rx1-mode */
|
|
||||||
uint8_t gc_rx2_mode; /* adi,gc-rx2-mode */
|
|
||||||
uint8_t gc_adc_large_overload_thresh; /* adi,gc-adc-large-overload-thresh */
|
|
||||||
uint8_t gc_adc_ovr_sample_size; /* adi,gc-adc-ovr-sample-size */
|
|
||||||
uint8_t gc_adc_small_overload_thresh; /* adi,gc-adc-small-overload-thresh */
|
|
||||||
uint16_t gc_dec_pow_measurement_duration; /* adi,gc-dec-pow-measurement-duration */
|
|
||||||
uint8_t gc_dig_gain_enable; /* adi,gc-dig-gain-enable */
|
|
||||||
uint16_t gc_lmt_overload_high_thresh; /* adi,gc-lmt-overload-high-thresh */
|
|
||||||
uint16_t gc_lmt_overload_low_thresh; /* adi,gc-lmt-overload-low-thresh */
|
|
||||||
uint8_t gc_low_power_thresh; /* adi,gc-low-power-thresh */
|
|
||||||
uint8_t gc_max_dig_gain; /* adi,gc-max-dig-gain */
|
|
||||||
uint8_t gc_use_rx_fir_out_for_dec_pwr_meas_enable; /* adi,gc-use-rx-fir-out-for-dec-pwr-meas-enable */
|
|
||||||
/* Gain MGC Control */
|
|
||||||
uint8_t mgc_dec_gain_step; /* adi,mgc-dec-gain-step */
|
|
||||||
uint8_t mgc_inc_gain_step; /* adi,mgc-inc-gain-step */
|
|
||||||
uint8_t mgc_rx1_ctrl_inp_enable; /* adi,mgc-rx1-ctrl-inp-enable */
|
|
||||||
uint8_t mgc_rx2_ctrl_inp_enable; /* adi,mgc-rx2-ctrl-inp-enable */
|
|
||||||
uint8_t mgc_split_table_ctrl_inp_gain_mode; /* adi,mgc-split-table-ctrl-inp-gain-mode */
|
|
||||||
/* Gain AGC Control */
|
|
||||||
uint8_t agc_adc_large_overload_exceed_counter; /* adi,agc-adc-large-overload-exceed-counter */
|
|
||||||
uint8_t agc_adc_large_overload_inc_steps; /* adi,agc-adc-large-overload-inc-steps - Name is misleading should be dec-steps*/
|
|
||||||
uint8_t agc_adc_lmt_small_overload_prevent_gain_inc_enable; /* adi,agc-adc-lmt-small-overload-prevent-gain-inc-enable */
|
|
||||||
uint8_t agc_adc_small_overload_exceed_counter; /* adi,agc-adc-small-overload-exceed-counter */
|
|
||||||
uint8_t agc_dig_gain_step_size; /* adi,agc-dig-gain-step-size */
|
|
||||||
uint8_t agc_dig_saturation_exceed_counter; /* adi,agc-dig-saturation-exceed-counter */
|
|
||||||
uint32_t agc_gain_update_interval_us; /* adi,agc-gain-update-interval-us */
|
|
||||||
uint8_t agc_immed_gain_change_if_large_adc_overload_enable; /* adi,agc-immed-gain-change-if-large-adc-overload-enable */
|
|
||||||
uint8_t agc_immed_gain_change_if_large_lmt_overload_enable; /* adi,agc-immed-gain-change-if-large-lmt-overload-enable */
|
|
||||||
uint8_t agc_inner_thresh_high; /* adi,agc-inner-thresh-high */
|
|
||||||
uint8_t agc_inner_thresh_high_dec_steps; /* adi,agc-inner-thresh-high-dec-steps */
|
|
||||||
uint8_t agc_inner_thresh_low; /* adi,agc-inner-thresh-low */
|
|
||||||
uint8_t agc_inner_thresh_low_inc_steps; /* adi,agc-inner-thresh-low-inc-steps */
|
|
||||||
uint8_t agc_lmt_overload_large_exceed_counter; /* adi,agc-lmt-overload-large-exceed-counter */
|
|
||||||
uint8_t agc_lmt_overload_large_inc_steps; /* adi,agc-lmt-overload-large-inc-steps */
|
|
||||||
uint8_t agc_lmt_overload_small_exceed_counter; /* adi,agc-lmt-overload-small-exceed-counter */
|
|
||||||
uint8_t agc_outer_thresh_high; /* adi,agc-outer-thresh-high */
|
|
||||||
uint8_t agc_outer_thresh_high_dec_steps; /* adi,agc-outer-thresh-high-dec-steps */
|
|
||||||
uint8_t agc_outer_thresh_low; /* adi,agc-outer-thresh-low */
|
|
||||||
uint8_t agc_outer_thresh_low_inc_steps; /* adi,agc-outer-thresh-low-inc-steps */
|
|
||||||
uint32_t agc_attack_delay_extra_margin_us; /* adi,agc-attack-delay-extra-margin-us */
|
|
||||||
uint8_t agc_sync_for_gain_counter_enable; /* adi,agc-sync-for-gain-counter-enable */
|
|
||||||
/* Fast AGC */
|
|
||||||
uint32_t fagc_dec_pow_measuremnt_duration; /* adi,fagc-dec-pow-measurement-duration */
|
|
||||||
uint32_t fagc_state_wait_time_ns; /* adi,fagc-state-wait-time-ns */
|
|
||||||
/* Fast AGC - Low Power */
|
|
||||||
uint8_t fagc_allow_agc_gain_increase; /* adi,fagc-allow-agc-gain-increase-enable */
|
|
||||||
uint32_t fagc_lp_thresh_increment_time; /* adi,fagc-lp-thresh-increment-time */
|
|
||||||
uint32_t fagc_lp_thresh_increment_steps; /* adi,fagc-lp-thresh-increment-steps */
|
|
||||||
/* Fast AGC - Lock Level (Lock Level is set via slow AGC inner high threshold) */
|
|
||||||
uint8_t fagc_lock_level_lmt_gain_increase_en; /* adi,fagc-lock-level-lmt-gain-increase-enable */
|
|
||||||
uint32_t fagc_lock_level_gain_increase_upper_limit; /* adi,fagc-lock-level-gain-increase-upper-limit */
|
|
||||||
/* Fast AGC - Peak Detectors and Final Settling */
|
|
||||||
uint32_t fagc_lpf_final_settling_steps; /* adi,fagc-lpf-final-settling-steps */
|
|
||||||
uint32_t fagc_lmt_final_settling_steps; /* adi,fagc-lmt-final-settling-steps */
|
|
||||||
uint32_t fagc_final_overrange_count; /* adi,fagc-final-overrange-count */
|
|
||||||
/* Fast AGC - Final Power Test */
|
|
||||||
uint8_t fagc_gain_increase_after_gain_lock_en; /* adi,fagc-gain-increase-after-gain-lock-enable */
|
|
||||||
/* Fast AGC - Unlocking the Gain */
|
|
||||||
uint32_t fagc_gain_index_type_after_exit_rx_mode; /* adi,fagc-gain-index-type-after-exit-rx-mode */
|
|
||||||
uint8_t fagc_use_last_lock_level_for_set_gain_en; /* adi,fagc-use-last-lock-level-for-set-gain-enable */
|
|
||||||
uint8_t fagc_rst_gla_stronger_sig_thresh_exceeded_en; /* adi,fagc-rst-gla-stronger-sig-thresh-exceeded-enable */
|
|
||||||
uint32_t fagc_optimized_gain_offset; /* adi,fagc-optimized-gain-offset */
|
|
||||||
uint32_t fagc_rst_gla_stronger_sig_thresh_above_ll; /* adi,fagc-rst-gla-stronger-sig-thresh-above-ll */
|
|
||||||
uint8_t fagc_rst_gla_engergy_lost_sig_thresh_exceeded_en; /* adi,fagc-rst-gla-engergy-lost-sig-thresh-exceeded-enable */
|
|
||||||
uint8_t fagc_rst_gla_engergy_lost_goto_optim_gain_en; /* adi,fagc-rst-gla-engergy-lost-goto-optim-gain-enable */
|
|
||||||
uint32_t fagc_rst_gla_engergy_lost_sig_thresh_below_ll; /* adi,fagc-rst-gla-engergy-lost-sig-thresh-below-ll */
|
|
||||||
uint32_t fagc_energy_lost_stronger_sig_gain_lock_exit_cnt; /* adi,fagc-energy-lost-stronger-sig-gain-lock-exit-cnt */
|
|
||||||
uint8_t fagc_rst_gla_large_adc_overload_en; /* adi,fagc-rst-gla-large-adc-overload-enable */
|
|
||||||
uint8_t fagc_rst_gla_large_lmt_overload_en; /* adi,fagc-rst-gla-large-lmt-overload-enable */
|
|
||||||
uint8_t fagc_rst_gla_en_agc_pulled_high_en; /* adi,fagc-rst-gla-en-agc-pulled-high-enable */
|
|
||||||
uint32_t fagc_rst_gla_if_en_agc_pulled_high_mode; /* adi,fagc-rst-gla-if-en-agc-pulled-high-mode */
|
|
||||||
uint32_t fagc_power_measurement_duration_in_state5; /* adi,fagc-power-measurement-duration-in-state5 */
|
|
||||||
uint32_t fagc_large_overload_inc_steps; /* adi,fagc-adc-large-overload-inc-steps - Name is misleading should be dec-steps */
|
|
||||||
/* RSSI Control */
|
|
||||||
uint32_t rssi_delay; /* adi,rssi-delay */
|
|
||||||
uint32_t rssi_duration; /* adi,rssi-duration */
|
|
||||||
uint8_t rssi_restart_mode; /* adi,rssi-restart-mode */
|
|
||||||
uint8_t rssi_unit_is_rx_samples_enable; /* adi,rssi-unit-is-rx-samples-enable */
|
|
||||||
uint32_t rssi_wait; /* adi,rssi-wait */
|
|
||||||
/* Aux ADC Control */
|
|
||||||
uint32_t aux_adc_decimation; /* adi,aux-adc-decimation */
|
|
||||||
uint32_t aux_adc_rate; /* adi,aux-adc-rate */
|
|
||||||
/* AuxDAC Control */
|
|
||||||
uint8_t aux_dac_manual_mode_enable; /* adi,aux-dac-manual-mode-enable */
|
|
||||||
uint32_t aux_dac1_default_value_mV; /* adi,aux-dac1-default-value-mV */
|
|
||||||
uint8_t aux_dac1_active_in_rx_enable; /* adi,aux-dac1-active-in-rx-enable */
|
|
||||||
uint8_t aux_dac1_active_in_tx_enable; /* adi,aux-dac1-active-in-tx-enable */
|
|
||||||
uint8_t aux_dac1_active_in_alert_enable; /* adi,aux-dac1-active-in-alert-enable */
|
|
||||||
uint32_t aux_dac1_rx_delay_us; /* adi,aux-dac1-rx-delay-us */
|
|
||||||
uint32_t aux_dac1_tx_delay_us; /* adi,aux-dac1-tx-delay-us */
|
|
||||||
uint32_t aux_dac2_default_value_mV; /* adi,aux-dac2-default-value-mV */
|
|
||||||
uint8_t aux_dac2_active_in_rx_enable; /* adi,aux-dac2-active-in-rx-enable */
|
|
||||||
uint8_t aux_dac2_active_in_tx_enable; /* adi,aux-dac2-active-in-tx-enable */
|
|
||||||
uint8_t aux_dac2_active_in_alert_enable; /* adi,aux-dac2-active-in-alert-enable */
|
|
||||||
uint32_t aux_dac2_rx_delay_us; /* adi,aux-dac2-rx-delay-us */
|
|
||||||
uint32_t aux_dac2_tx_delay_us; /* adi,aux-dac2-tx-delay-us */
|
|
||||||
/* Temperature Sensor Control */
|
|
||||||
uint32_t temp_sense_decimation; /* adi,temp-sense-decimation */
|
|
||||||
uint16_t temp_sense_measurement_interval_ms; /* adi,temp-sense-measurement-interval-ms */
|
|
||||||
int8_t temp_sense_offset_signed; /* adi,temp-sense-offset-signed */
|
|
||||||
uint8_t temp_sense_periodic_measurement_enable; /* adi,temp-sense-periodic-measurement-enable */
|
|
||||||
/* Control Out Setup */
|
|
||||||
uint8_t ctrl_outs_enable_mask; /* adi,ctrl-outs-enable-mask */
|
|
||||||
uint8_t ctrl_outs_index; /* adi,ctrl-outs-index */
|
|
||||||
/* External LNA Control */
|
|
||||||
uint32_t elna_settling_delay_ns; /* adi,elna-settling-delay-ns */
|
|
||||||
uint32_t elna_gain_mdB; /* adi,elna-gain-mdB */
|
|
||||||
uint32_t elna_bypass_loss_mdB; /* adi,elna-bypass-loss-mdB */
|
|
||||||
uint8_t elna_rx1_gpo0_control_enable; /* adi,elna-rx1-gpo0-control-enable */
|
|
||||||
uint8_t elna_rx2_gpo1_control_enable; /* adi,elna-rx2-gpo1-control-enable */
|
|
||||||
uint8_t elna_gaintable_all_index_enable; /* adi,elna-gaintable-all-index-enable */
|
|
||||||
/* Digital Interface Control */
|
|
||||||
uint8_t digital_interface_tune_skip_mode; /* adi,digital-interface-tune-skip-mode */
|
|
||||||
uint8_t digital_interface_tune_fir_disable; /* adi,digital-interface-tune-fir-disable */
|
|
||||||
uint8_t pp_tx_swap_enable; /* adi,pp-tx-swap-enable */
|
|
||||||
uint8_t pp_rx_swap_enable; /* adi,pp-rx-swap-enable */
|
|
||||||
uint8_t tx_channel_swap_enable; /* adi,tx-channel-swap-enable */
|
|
||||||
uint8_t rx_channel_swap_enable; /* adi,rx-channel-swap-enable */
|
|
||||||
uint8_t rx_frame_pulse_mode_enable; /* adi,rx-frame-pulse-mode-enable */
|
|
||||||
uint8_t two_t_two_r_timing_enable; /* adi,2t2r-timing-enable */
|
|
||||||
uint8_t invert_data_bus_enable; /* adi,invert-data-bus-enable */
|
|
||||||
uint8_t invert_data_clk_enable; /* adi,invert-data-clk-enable */
|
|
||||||
uint8_t fdd_alt_word_order_enable; /* adi,fdd-alt-word-order-enable */
|
|
||||||
uint8_t invert_rx_frame_enable; /* adi,invert-rx-frame-enable */
|
|
||||||
uint8_t fdd_rx_rate_2tx_enable; /* adi,fdd-rx-rate-2tx-enable */
|
|
||||||
uint8_t swap_ports_enable; /* adi,swap-ports-enable */
|
|
||||||
uint8_t single_data_rate_enable; /* adi,single-data-rate-enable */
|
|
||||||
uint8_t lvds_mode_enable; /* adi,lvds-mode-enable */
|
|
||||||
uint8_t half_duplex_mode_enable; /* adi,half-duplex-mode-enable */
|
|
||||||
uint8_t single_port_mode_enable; /* adi,single-port-mode-enable */
|
|
||||||
uint8_t full_port_enable; /* adi,full-port-enable */
|
|
||||||
uint8_t full_duplex_swap_bits_enable; /* adi,full-duplex-swap-bits-enable */
|
|
||||||
uint32_t delay_rx_data; /* adi,delay-rx-data */
|
|
||||||
uint32_t rx_data_clock_delay; /* adi,rx-data-clock-delay */
|
|
||||||
uint32_t rx_data_delay; /* adi,rx-data-delay */
|
|
||||||
uint32_t tx_fb_clock_delay; /* adi,tx-fb-clock-delay */
|
|
||||||
uint32_t tx_data_delay; /* adi,tx-data-delay */
|
|
||||||
uint32_t lvds_bias_mV; /* adi,lvds-bias-mV */
|
|
||||||
uint8_t lvds_rx_onchip_termination_enable; /* adi,lvds-rx-onchip-termination-enable */
|
|
||||||
uint8_t rx1rx2_phase_inversion_en; /* adi,rx1-rx2-phase-inversion-enable */
|
|
||||||
uint8_t lvds_invert1_control; /* adi,lvds-invert1-control */
|
|
||||||
uint8_t lvds_invert2_control; /* adi,lvds-invert2-control */
|
|
||||||
/* GPO Control */
|
|
||||||
uint8_t gpo_manual_mode_enable; /* adi,gpo-manual-mode-enable */
|
|
||||||
uint32_t gpo_manual_mode_enable_mask; /* adi,gpo-manual-mode-enable-mask */
|
|
||||||
uint8_t gpo0_inactive_state_high_enable; /* adi,gpo0-inactive-state-high-enable */
|
|
||||||
uint8_t gpo1_inactive_state_high_enable; /* adi,gpo1-inactive-state-high-enable */
|
|
||||||
uint8_t gpo2_inactive_state_high_enable; /* adi,gpo2-inactive-state-high-enable */
|
|
||||||
uint8_t gpo3_inactive_state_high_enable; /* adi,gpo3-inactive-state-high-enable */
|
|
||||||
uint8_t gpo0_slave_rx_enable; /* adi,gpo0-slave-rx-enable */
|
|
||||||
uint8_t gpo0_slave_tx_enable; /* adi,gpo0-slave-tx-enable */
|
|
||||||
uint8_t gpo1_slave_rx_enable; /* adi,gpo1-slave-rx-enable */
|
|
||||||
uint8_t gpo1_slave_tx_enable; /* adi,gpo1-slave-tx-enable */
|
|
||||||
uint8_t gpo2_slave_rx_enable; /* adi,gpo2-slave-rx-enable */
|
|
||||||
uint8_t gpo2_slave_tx_enable; /* adi,gpo2-slave-tx-enable */
|
|
||||||
uint8_t gpo3_slave_rx_enable; /* adi,gpo3-slave-rx-enable */
|
|
||||||
uint8_t gpo3_slave_tx_enable; /* adi,gpo3-slave-tx-enable */
|
|
||||||
uint8_t gpo0_rx_delay_us; /* adi,gpo0-rx-delay-us */
|
|
||||||
uint8_t gpo0_tx_delay_us; /* adi,gpo0-tx-delay-us */
|
|
||||||
uint8_t gpo1_rx_delay_us; /* adi,gpo1-rx-delay-us */
|
|
||||||
uint8_t gpo1_tx_delay_us; /* adi,gpo1-tx-delay-us */
|
|
||||||
uint8_t gpo2_rx_delay_us; /* adi,gpo2-rx-delay-us */
|
|
||||||
uint8_t gpo2_tx_delay_us; /* adi,gpo2-tx-delay-us */
|
|
||||||
uint8_t gpo3_rx_delay_us; /* adi,gpo3-rx-delay-us */
|
|
||||||
uint8_t gpo3_tx_delay_us; /* adi,gpo3-tx-delay-us */
|
|
||||||
/* Tx Monitor Control */
|
|
||||||
uint32_t low_high_gain_threshold_mdB; /* adi,txmon-low-high-thresh */
|
|
||||||
uint32_t low_gain_dB; /* adi,txmon-low-gain */
|
|
||||||
uint32_t high_gain_dB; /* adi,txmon-high-gain */
|
|
||||||
uint8_t tx_mon_track_en; /* adi,txmon-dc-tracking-enable */
|
|
||||||
uint8_t one_shot_mode_en; /* adi,txmon-one-shot-mode-enable */
|
|
||||||
uint32_t tx_mon_delay; /* adi,txmon-delay */
|
|
||||||
uint32_t tx_mon_duration; /* adi,txmon-duration */
|
|
||||||
uint32_t tx1_mon_front_end_gain; /* adi,txmon-1-front-end-gain */
|
|
||||||
uint32_t tx2_mon_front_end_gain; /* adi,txmon-2-front-end-gain */
|
|
||||||
uint32_t tx1_mon_lo_cm; /* adi,txmon-1-lo-cm */
|
|
||||||
uint32_t tx2_mon_lo_cm; /* adi,txmon-2-lo-cm */
|
|
||||||
/* GPIO definitions */
|
|
||||||
struct gpio_init_param gpio_resetb; /* reset-gpios */
|
|
||||||
/* MCS Sync */
|
|
||||||
struct gpio_init_param gpio_sync; /* sync-gpios */
|
|
||||||
struct gpio_init_param gpio_cal_sw1; /* cal-sw1-gpios */
|
|
||||||
struct gpio_init_param gpio_cal_sw2; /* cal-sw2-gpios */
|
|
||||||
|
|
||||||
struct spi_init_param spi_param;
|
|
||||||
|
|
||||||
/* External LO clocks */
|
|
||||||
uint32_t (*ad9361_rfpll_ext_recalc_rate)(struct refclk_scale *clk_priv);
|
|
||||||
int32_t (*ad9361_rfpll_ext_round_rate)(struct refclk_scale *clk_priv,
|
|
||||||
uint32_t rate);
|
|
||||||
int32_t (*ad9361_rfpll_ext_set_rate)(struct refclk_scale *clk_priv,
|
|
||||||
uint32_t rate);
|
|
||||||
|
|
||||||
} AD9361_InitParam;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t rx; /* 1, 2, 3(both) */
|
|
||||||
int32_t rx_gain; /* -12, -6, 0, 6 */
|
|
||||||
uint32_t rx_dec; /* 1, 2, 4 */
|
|
||||||
int16_t rx_coef[128];
|
|
||||||
uint8_t rx_coef_size;
|
|
||||||
uint32_t rx_path_clks[6];
|
|
||||||
uint32_t rx_bandwidth;
|
|
||||||
} AD9361_RXFIRConfig;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t tx; /* 1, 2, 3(both) */
|
|
||||||
int32_t tx_gain; /* -6, 0 */
|
|
||||||
uint32_t tx_int; /* 1, 2, 4 */
|
|
||||||
int16_t tx_coef[128];
|
|
||||||
uint8_t tx_coef_size;
|
|
||||||
uint32_t tx_path_clks[6];
|
|
||||||
uint32_t tx_bandwidth;
|
|
||||||
} AD9361_TXFIRConfig;
|
|
||||||
|
|
||||||
enum ad9361_ensm_mode {
|
|
||||||
ENSM_MODE_TX,
|
|
||||||
ENSM_MODE_RX,
|
|
||||||
ENSM_MODE_ALERT,
|
|
||||||
ENSM_MODE_FDD,
|
|
||||||
ENSM_MODE_WAIT,
|
|
||||||
ENSM_MODE_SLEEP,
|
|
||||||
ENSM_MODE_PINCTRL,
|
|
||||||
ENSM_MODE_PINCTRL_FDD_INDEP,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ENABLE 1
|
|
||||||
#define DISABLE 0
|
|
||||||
|
|
||||||
#define RX1 0
|
|
||||||
#define RX2 1
|
|
||||||
|
|
||||||
#define TX1 0
|
|
||||||
#define TX2 1
|
|
||||||
|
|
||||||
#define A_BALANCED 0
|
|
||||||
#define B_BALANCED 1
|
|
||||||
#define C_BALANCED 2
|
|
||||||
#define A_N 3
|
|
||||||
#define A_P 4
|
|
||||||
#define B_N 5
|
|
||||||
#define B_P 6
|
|
||||||
#define C_N 7
|
|
||||||
#define C_P 8
|
|
||||||
#define TX_MON1 9
|
|
||||||
#define TX_MON2 10
|
|
||||||
#define TX_MON1_2 11
|
|
||||||
|
|
||||||
#define TXA 0
|
|
||||||
#define TXB 1
|
|
||||||
|
|
||||||
#define MODE_1x1 1
|
|
||||||
#define MODE_2x2 2
|
|
||||||
|
|
||||||
#define HIGHEST_OSR 0
|
|
||||||
#define NOMINAL_OSR 1
|
|
||||||
|
|
||||||
#define INT_LO 0
|
|
||||||
#define EXT_LO 1
|
|
||||||
|
|
||||||
#define ON 0
|
|
||||||
#define OFF 1
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/************************ Functions Declarations ******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Initialize the AD9361 part. */
|
|
||||||
int32_t ad9361_init (struct ad9361_rf_phy **ad9361_phy,
|
|
||||||
AD9361_InitParam *init_param);
|
|
||||||
/* Free the allocated resources. */
|
|
||||||
int32_t ad9361_remove(struct ad9361_rf_phy *phy);
|
|
||||||
/* Set the Enable State Machine (ENSM) mode. */
|
|
||||||
int32_t ad9361_set_en_state_machine_mode (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t mode);
|
|
||||||
/* Get the Enable State Machine (ENSM) mode. */
|
|
||||||
int32_t ad9361_get_en_state_machine_mode (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t *mode);
|
|
||||||
/* Set the receive RF gain for the selected channel. */
|
|
||||||
int32_t ad9361_set_rx_rf_gain (struct ad9361_rf_phy *phy, uint8_t ch,
|
|
||||||
int32_t gain_db);
|
|
||||||
/* Get current receive RF gain for the selected channel. */
|
|
||||||
int32_t ad9361_get_rx_rf_gain (struct ad9361_rf_phy *phy, uint8_t ch,
|
|
||||||
int32_t *gain_db);
|
|
||||||
/* Set the RX RF bandwidth. */
|
|
||||||
int32_t ad9361_set_rx_rf_bandwidth (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t bandwidth_hz);
|
|
||||||
/* Get the RX RF bandwidth. */
|
|
||||||
int32_t ad9361_get_rx_rf_bandwidth (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t *bandwidth_hz);
|
|
||||||
/* Set the RX sampling frequency. */
|
|
||||||
int32_t ad9361_set_rx_sampling_freq (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t sampling_freq_hz);
|
|
||||||
/* Get current RX sampling frequency. */
|
|
||||||
int32_t ad9361_get_rx_sampling_freq (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t *sampling_freq_hz);
|
|
||||||
/* Set the RX LO frequency. */
|
|
||||||
int32_t ad9361_set_rx_lo_freq (struct ad9361_rf_phy *phy, uint64_t lo_freq_hz);
|
|
||||||
/* Get current RX LO frequency. */
|
|
||||||
int32_t ad9361_get_rx_lo_freq (struct ad9361_rf_phy *phy, uint64_t *lo_freq_hz);
|
|
||||||
/* Switch between internal and external LO. */
|
|
||||||
int32_t ad9361_set_rx_lo_int_ext(struct ad9361_rf_phy *phy, uint8_t int_ext);
|
|
||||||
/* Get the RSSI for the selected channel. */
|
|
||||||
int32_t ad9361_get_rx_rssi (struct ad9361_rf_phy *phy, uint8_t ch,
|
|
||||||
struct rf_rssi *rssi);
|
|
||||||
/* Set the gain control mode for the selected channel. */
|
|
||||||
int32_t ad9361_set_rx_gain_control_mode (struct ad9361_rf_phy *phy, uint8_t ch,
|
|
||||||
uint8_t gc_mode);
|
|
||||||
/* Get the gain control mode for the selected channel. */
|
|
||||||
int32_t ad9361_get_rx_gain_control_mode (struct ad9361_rf_phy *phy, uint8_t ch,
|
|
||||||
uint8_t *gc_mode);
|
|
||||||
/* Set the RX FIR filter configuration. */
|
|
||||||
int32_t ad9361_set_rx_fir_config (struct ad9361_rf_phy *phy,
|
|
||||||
AD9361_RXFIRConfig fir_cfg);
|
|
||||||
/* Get the RX FIR filter configuration. */
|
|
||||||
int32_t ad9361_get_rx_fir_config(struct ad9361_rf_phy *phy, uint8_t rx_ch,
|
|
||||||
AD9361_RXFIRConfig *fir_cfg);
|
|
||||||
/* Enable/disable the RX FIR filter. */
|
|
||||||
int32_t ad9361_set_rx_fir_en_dis (struct ad9361_rf_phy *phy, uint8_t en_dis);
|
|
||||||
/* Get the status of the RX FIR filter. */
|
|
||||||
int32_t ad9361_get_rx_fir_en_dis (struct ad9361_rf_phy *phy, uint8_t *en_dis);
|
|
||||||
/* Enable/disable the RX RFDC Tracking. */
|
|
||||||
int32_t ad9361_set_rx_rfdc_track_en_dis (struct ad9361_rf_phy *phy,
|
|
||||||
uint8_t en_dis);
|
|
||||||
/* Get the status of the RX RFDC Tracking. */
|
|
||||||
int32_t ad9361_get_rx_rfdc_track_en_dis (struct ad9361_rf_phy *phy,
|
|
||||||
uint8_t *en_dis);
|
|
||||||
/* Enable/disable the RX BasebandDC Tracking. */
|
|
||||||
int32_t ad9361_set_rx_bbdc_track_en_dis (struct ad9361_rf_phy *phy,
|
|
||||||
uint8_t en_dis);
|
|
||||||
/* Get the status of the RX BasebandDC Tracking. */
|
|
||||||
int32_t ad9361_get_rx_bbdc_track_en_dis (struct ad9361_rf_phy *phy,
|
|
||||||
uint8_t *en_dis);
|
|
||||||
/* Enable/disable the RX Quadrature Tracking. */
|
|
||||||
int32_t ad9361_set_rx_quad_track_en_dis (struct ad9361_rf_phy *phy,
|
|
||||||
uint8_t en_dis);
|
|
||||||
/* Get the status of the RX Quadrature Tracking. */
|
|
||||||
int32_t ad9361_get_rx_quad_track_en_dis (struct ad9361_rf_phy *phy,
|
|
||||||
uint8_t *en_dis);
|
|
||||||
/* Set the RX RF input port. */
|
|
||||||
int32_t ad9361_set_rx_rf_port_input (struct ad9361_rf_phy *phy, uint32_t mode);
|
|
||||||
/* Get the selected RX RF input port. */
|
|
||||||
int32_t ad9361_get_rx_rf_port_input (struct ad9361_rf_phy *phy, uint32_t *mode);
|
|
||||||
/* Store RX fastlock profile. */
|
|
||||||
int32_t ad9361_rx_fastlock_store(struct ad9361_rf_phy *phy, uint32_t profile);
|
|
||||||
/* Recall RX fastlock profile. */
|
|
||||||
int32_t ad9361_rx_fastlock_recall(struct ad9361_rf_phy *phy, uint32_t profile);
|
|
||||||
/* Load RX fastlock profile. */
|
|
||||||
int32_t ad9361_rx_fastlock_load(struct ad9361_rf_phy *phy, uint32_t profile,
|
|
||||||
uint8_t *values);
|
|
||||||
/* Save RX fastlock profile. */
|
|
||||||
int32_t ad9361_rx_fastlock_save(struct ad9361_rf_phy *phy, uint32_t profile,
|
|
||||||
uint8_t *values);
|
|
||||||
/* Power down the RX Local Oscillator. */
|
|
||||||
int32_t ad9361_rx_lo_powerdown(struct ad9361_rf_phy *phy, uint8_t option);
|
|
||||||
/* Get the RX Local Oscillator power status. */
|
|
||||||
int32_t ad9361_get_rx_lo_power(struct ad9361_rf_phy *phy, uint8_t *option);
|
|
||||||
/* Set the transmit attenuation for the selected channel. */
|
|
||||||
int32_t ad9361_set_tx_attenuation (struct ad9361_rf_phy *phy, uint8_t ch,
|
|
||||||
uint32_t attenuation_mdb);
|
|
||||||
/* Get current transmit attenuation for the selected channel. */
|
|
||||||
int32_t ad9361_get_tx_attenuation (struct ad9361_rf_phy *phy, uint8_t ch,
|
|
||||||
uint32_t *attenuation_mdb);
|
|
||||||
/* Set the TX RF bandwidth. */
|
|
||||||
int32_t ad9361_set_tx_rf_bandwidth (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t bandwidth_hz);
|
|
||||||
/* Get the TX RF bandwidth. */
|
|
||||||
int32_t ad9361_get_tx_rf_bandwidth (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t *bandwidth_hz);
|
|
||||||
/* Set the TX sampling frequency. */
|
|
||||||
int32_t ad9361_set_tx_sampling_freq (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t sampling_freq_hz);
|
|
||||||
/* Get current TX sampling frequency. */
|
|
||||||
int32_t ad9361_get_tx_sampling_freq (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t *sampling_freq_hz);
|
|
||||||
/* Set the TX LO frequency. */
|
|
||||||
int32_t ad9361_set_tx_lo_freq (struct ad9361_rf_phy *phy, uint64_t lo_freq_hz);
|
|
||||||
/* Get current TX LO frequency. */
|
|
||||||
int32_t ad9361_get_tx_lo_freq (struct ad9361_rf_phy *phy, uint64_t *lo_freq_hz);
|
|
||||||
/* Switch between internal and external LO. */
|
|
||||||
int32_t ad9361_set_tx_lo_int_ext(struct ad9361_rf_phy *phy, uint8_t int_ext);
|
|
||||||
/* Set the TX FIR filter configuration. */
|
|
||||||
int32_t ad9361_set_tx_fir_config (struct ad9361_rf_phy *phy,
|
|
||||||
AD9361_TXFIRConfig fir_cfg);
|
|
||||||
/* Get the TX FIR filter configuration. */
|
|
||||||
int32_t ad9361_get_tx_fir_config(struct ad9361_rf_phy *phy, uint8_t tx_ch,
|
|
||||||
AD9361_TXFIRConfig *fir_cfg);
|
|
||||||
/* Enable/disable the TX FIR filter. */
|
|
||||||
int32_t ad9361_set_tx_fir_en_dis (struct ad9361_rf_phy *phy, uint8_t en_dis);
|
|
||||||
/* Get the status of the TX FIR filter. */
|
|
||||||
int32_t ad9361_get_tx_fir_en_dis (struct ad9361_rf_phy *phy, uint8_t *en_dis);
|
|
||||||
/* Get the TX RSSI for the selected channel. */
|
|
||||||
int32_t ad9361_get_tx_rssi (struct ad9361_rf_phy *phy, uint8_t ch,
|
|
||||||
uint32_t *rssi_db_x_1000);
|
|
||||||
/* Set the TX RF output port. */
|
|
||||||
int32_t ad9361_set_tx_rf_port_output (struct ad9361_rf_phy *phy, uint32_t mode);
|
|
||||||
/* Get the selected TX RF output port. */
|
|
||||||
int32_t ad9361_get_tx_rf_port_output (struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t *mode);
|
|
||||||
/* Enable/disable the auto calibration. */
|
|
||||||
int32_t ad9361_set_tx_auto_cal_en_dis (struct ad9361_rf_phy *phy,
|
|
||||||
uint8_t en_dis);
|
|
||||||
/* Get the status of the auto calibration flag. */
|
|
||||||
int32_t ad9361_get_tx_auto_cal_en_dis (struct ad9361_rf_phy *phy,
|
|
||||||
uint8_t *en_dis);
|
|
||||||
/* Store TX fastlock profile. */
|
|
||||||
int32_t ad9361_tx_fastlock_store(struct ad9361_rf_phy *phy, uint32_t profile);
|
|
||||||
/* Recall TX fastlock profile. */
|
|
||||||
int32_t ad9361_tx_fastlock_recall(struct ad9361_rf_phy *phy, uint32_t profile);
|
|
||||||
/* Load TX fastlock profile. */
|
|
||||||
int32_t ad9361_tx_fastlock_load(struct ad9361_rf_phy *phy, uint32_t profile,
|
|
||||||
uint8_t *values);
|
|
||||||
/* Save TX fastlock profile. */
|
|
||||||
int32_t ad9361_tx_fastlock_save(struct ad9361_rf_phy *phy, uint32_t profile,
|
|
||||||
uint8_t *values);
|
|
||||||
/* Power down the TX Local Oscillator. */
|
|
||||||
int32_t ad9361_tx_lo_powerdown(struct ad9361_rf_phy *phy, uint8_t option);
|
|
||||||
/* Get the TX Local Oscillator power status. */
|
|
||||||
int32_t ad9361_get_tx_lo_power(struct ad9361_rf_phy *phy, uint8_t *option);
|
|
||||||
/* Set the RX and TX path rates. */
|
|
||||||
int32_t ad9361_set_trx_path_clks(struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t *rx_path_clks, uint32_t *tx_path_clks);
|
|
||||||
/* Get the RX and TX path rates. */
|
|
||||||
int32_t ad9361_get_trx_path_clks(struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t *rx_path_clks, uint32_t *tx_path_clks);
|
|
||||||
/* Set the number of channels mode. */
|
|
||||||
int32_t ad9361_set_no_ch_mode(struct ad9361_rf_phy *phy, uint8_t no_ch_mode);
|
|
||||||
/* Do multi chip synchronization. */
|
|
||||||
int32_t ad9361_do_mcs(struct ad9361_rf_phy *phy_master,
|
|
||||||
struct ad9361_rf_phy *phy_slave);
|
|
||||||
/* Enable/disable the TRX FIR filters. */
|
|
||||||
int32_t ad9361_set_trx_fir_en_dis (struct ad9361_rf_phy *phy, uint8_t en_dis);
|
|
||||||
/* Set the OSR rate governor. */
|
|
||||||
int32_t ad9361_set_trx_rate_gov (struct ad9361_rf_phy *phy, uint32_t rate_gov);
|
|
||||||
/* Get the OSR rate governor. */
|
|
||||||
int32_t ad9361_get_trx_rate_gov (struct ad9361_rf_phy *phy, uint32_t *rate_gov);
|
|
||||||
/* Perform the selected calibration. */
|
|
||||||
int32_t ad9361_do_calib(struct ad9361_rf_phy *phy, uint32_t cal, int32_t arg);
|
|
||||||
/* Load and enable TRX FIR filters configurations. */
|
|
||||||
int32_t ad9361_trx_load_enable_fir(struct ad9361_rf_phy *phy,
|
|
||||||
AD9361_RXFIRConfig rx_fir_cfg,
|
|
||||||
AD9361_TXFIRConfig tx_fir_cfg);
|
|
||||||
/* Do DCXO coarse tuning. */
|
|
||||||
int32_t ad9361_do_dcxo_tune_coarse(struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t coarse);
|
|
||||||
/* Do DCXO fine tuning. */
|
|
||||||
int32_t ad9361_do_dcxo_tune_fine(struct ad9361_rf_phy *phy,
|
|
||||||
uint32_t fine);
|
|
||||||
/* Get the temperature. */
|
|
||||||
int32_t ad9361_get_temperature(struct ad9361_rf_phy *phy,
|
|
||||||
int32_t *temp);
|
|
||||||
#endif
|
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @file ad9361_conv.c
|
|
||||||
* @brief Implementation of AD9361 Conv Driver.
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2014-2015(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include <inttypes.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include "ad9361.h"
|
|
||||||
#include "ad9361_util.h"
|
|
||||||
#include "delay.h"
|
|
||||||
#include "../../../config/app_config.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/********************** Macros and Constants Definitions **********************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* HDL loopback enable/disable.
|
|
||||||
* @param phy The AD9361 state structure.
|
|
||||||
* @param enable Enable/disable option.
|
|
||||||
* @return 0 in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
int32_t ad9361_hdl_loopback(struct ad9361_rf_phy *phy, bool enable)
|
|
||||||
{
|
|
||||||
return -ENODEV;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Digital tune.
|
|
||||||
* @param phy The AD9361 state structure.
|
|
||||||
* @param max_freq Maximum frequency.
|
|
||||||
* @param flags Flags: BE_VERBOSE, BE_MOREVERBOSE, DO_IDELAY, DO_ODELAY.
|
|
||||||
* @return 0 in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
int32_t ad9361_dig_tune(struct ad9361_rf_phy *phy, uint32_t max_freq,
|
|
||||||
enum dig_tune_flags flags)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup the AD9361 device.
|
|
||||||
* @param phy The AD9361 state structure.
|
|
||||||
* @return 0 in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
int32_t ad9361_post_setup(struct ad9361_rf_phy *phy)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
@@ -1,335 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file ad9361_util.c
|
|
||||||
* @brief AD9361 Implementation of Util Driver.
|
|
||||||
* @author DBogdan (dragos.bogdan@analog.com)
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2013(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include <string.h>
|
|
||||||
#include "ad9361_util.h"
|
|
||||||
#include "../../../include/delay.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*************************** Macros Definitions *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#define BITS_PER_LONG 32
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief clk_prepare_enable
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t clk_prepare_enable(struct clk *clk)
|
|
||||||
{
|
|
||||||
if (clk) {
|
|
||||||
// Unused variable - fix compiler warning
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief clk_get_rate
|
|
||||||
*******************************************************************************/
|
|
||||||
uint32_t clk_get_rate(struct ad9361_rf_phy *phy,
|
|
||||||
struct refclk_scale *clk_priv)
|
|
||||||
{
|
|
||||||
uint32_t rate = 0;
|
|
||||||
uint32_t source;
|
|
||||||
|
|
||||||
source = clk_priv->source;
|
|
||||||
|
|
||||||
switch (source) {
|
|
||||||
case TX_REFCLK:
|
|
||||||
case RX_REFCLK:
|
|
||||||
case BB_REFCLK:
|
|
||||||
rate = ad9361_clk_factor_recalc_rate(clk_priv,
|
|
||||||
phy->clk_refin->rate);
|
|
||||||
break;
|
|
||||||
case TX_RFPLL_INT:
|
|
||||||
case RX_RFPLL_INT:
|
|
||||||
rate = ad9361_rfpll_int_recalc_rate(clk_priv,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
break;
|
|
||||||
case RX_RFPLL_DUMMY:
|
|
||||||
case TX_RFPLL_DUMMY:
|
|
||||||
rate = ad9361_rfpll_dummy_recalc_rate(clk_priv);
|
|
||||||
break;
|
|
||||||
case TX_RFPLL:
|
|
||||||
case RX_RFPLL:
|
|
||||||
rate = ad9361_rfpll_recalc_rate(clk_priv);
|
|
||||||
break;
|
|
||||||
case BBPLL_CLK:
|
|
||||||
rate = ad9361_bbpll_recalc_rate(clk_priv,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
break;
|
|
||||||
case ADC_CLK:
|
|
||||||
case R2_CLK:
|
|
||||||
case R1_CLK:
|
|
||||||
case CLKRF_CLK:
|
|
||||||
case RX_SAMPL_CLK:
|
|
||||||
case DAC_CLK:
|
|
||||||
case T2_CLK:
|
|
||||||
case T1_CLK:
|
|
||||||
case CLKTF_CLK:
|
|
||||||
case TX_SAMPL_CLK:
|
|
||||||
rate = ad9361_clk_factor_recalc_rate(clk_priv,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief clk_set_rate
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t clk_set_rate(struct ad9361_rf_phy *phy,
|
|
||||||
struct refclk_scale *clk_priv,
|
|
||||||
uint32_t rate)
|
|
||||||
{
|
|
||||||
uint32_t source;
|
|
||||||
int32_t i;
|
|
||||||
uint32_t round_rate;
|
|
||||||
|
|
||||||
source = clk_priv->source;
|
|
||||||
if(phy->clks[source]->rate != rate)
|
|
||||||
{
|
|
||||||
switch (source) {
|
|
||||||
case TX_REFCLK:
|
|
||||||
case RX_REFCLK:
|
|
||||||
case BB_REFCLK:
|
|
||||||
round_rate = ad9361_clk_factor_round_rate(clk_priv, rate,
|
|
||||||
&phy->clk_refin->rate);
|
|
||||||
ad9361_clk_factor_set_rate(clk_priv, round_rate,
|
|
||||||
phy->clk_refin->rate);
|
|
||||||
phy->clks[source]->rate = ad9361_clk_factor_recalc_rate(clk_priv,
|
|
||||||
phy->clk_refin->rate);
|
|
||||||
break;
|
|
||||||
case TX_RFPLL_INT:
|
|
||||||
case RX_RFPLL_INT:
|
|
||||||
round_rate = ad9361_rfpll_int_round_rate(clk_priv, rate,
|
|
||||||
&phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
ad9361_rfpll_int_set_rate(clk_priv, round_rate,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
phy->clks[source]->rate = ad9361_rfpll_int_recalc_rate(clk_priv,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
break;
|
|
||||||
case RX_RFPLL_DUMMY:
|
|
||||||
case TX_RFPLL_DUMMY:
|
|
||||||
ad9361_rfpll_dummy_set_rate(clk_priv, rate);
|
|
||||||
break;
|
|
||||||
case TX_RFPLL:
|
|
||||||
case RX_RFPLL:
|
|
||||||
round_rate = ad9361_rfpll_round_rate(clk_priv, rate);
|
|
||||||
ad9361_rfpll_set_rate(clk_priv, round_rate);
|
|
||||||
phy->clks[source]->rate = ad9361_rfpll_recalc_rate(clk_priv);
|
|
||||||
break;
|
|
||||||
case BBPLL_CLK:
|
|
||||||
round_rate = ad9361_bbpll_round_rate(clk_priv, rate,
|
|
||||||
&phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
ad9361_bbpll_set_rate(clk_priv, round_rate,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
phy->clks[source]->rate = ad9361_bbpll_recalc_rate(clk_priv,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
phy->bbpll_initialized = true;
|
|
||||||
break;
|
|
||||||
case ADC_CLK:
|
|
||||||
case R2_CLK:
|
|
||||||
case R1_CLK:
|
|
||||||
case CLKRF_CLK:
|
|
||||||
case RX_SAMPL_CLK:
|
|
||||||
case DAC_CLK:
|
|
||||||
case T2_CLK:
|
|
||||||
case T1_CLK:
|
|
||||||
case CLKTF_CLK:
|
|
||||||
case TX_SAMPL_CLK:
|
|
||||||
round_rate = ad9361_clk_factor_round_rate(clk_priv, rate,
|
|
||||||
&phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
ad9361_clk_factor_set_rate(clk_priv, round_rate,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
phy->clks[source]->rate = ad9361_clk_factor_recalc_rate(clk_priv,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
for(i = BB_REFCLK; i < BBPLL_CLK; i++)
|
|
||||||
{
|
|
||||||
phy->clks[i]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[i],
|
|
||||||
phy->clk_refin->rate);
|
|
||||||
}
|
|
||||||
phy->clks[BBPLL_CLK]->rate = ad9361_bbpll_recalc_rate(phy->ref_clk_scale[BBPLL_CLK],
|
|
||||||
phy->clks[phy->ref_clk_scale[BBPLL_CLK]->parent_source]->rate);
|
|
||||||
for(i = ADC_CLK; i < RX_RFPLL_INT; i++)
|
|
||||||
{
|
|
||||||
phy->clks[i]->rate = ad9361_clk_factor_recalc_rate(phy->ref_clk_scale[i],
|
|
||||||
phy->clks[phy->ref_clk_scale[i]->parent_source]->rate);
|
|
||||||
}
|
|
||||||
for(i = RX_RFPLL_INT; i < RX_RFPLL_DUMMY; i++)
|
|
||||||
{
|
|
||||||
phy->clks[i]->rate = ad9361_rfpll_int_recalc_rate(phy->ref_clk_scale[i],
|
|
||||||
phy->clks[phy->ref_clk_scale[i]->parent_source]->rate);
|
|
||||||
}
|
|
||||||
for(i = RX_RFPLL_DUMMY; i < RX_RFPLL; i++)
|
|
||||||
{
|
|
||||||
phy->clks[i]->rate = ad9361_rfpll_dummy_recalc_rate(phy->ref_clk_scale[i]);
|
|
||||||
}
|
|
||||||
for(i = RX_RFPLL; i < NUM_AD9361_CLKS; i++)
|
|
||||||
{
|
|
||||||
phy->clks[i]->rate = ad9361_rfpll_recalc_rate(phy->ref_clk_scale[i]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if ((source == BBPLL_CLK) && !phy->bbpll_initialized) {
|
|
||||||
round_rate = ad9361_bbpll_round_rate(clk_priv, rate,
|
|
||||||
&phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
ad9361_bbpll_set_rate(clk_priv, round_rate,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
phy->clks[source]->rate = ad9361_bbpll_recalc_rate(clk_priv,
|
|
||||||
phy->clks[clk_priv->parent_source]->rate);
|
|
||||||
phy->bbpll_initialized = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief int_sqrt
|
|
||||||
*******************************************************************************/
|
|
||||||
uint32_t int_sqrt(uint32_t x)
|
|
||||||
{
|
|
||||||
uint32_t b, m, y = 0;
|
|
||||||
|
|
||||||
if (x <= 1)
|
|
||||||
return x;
|
|
||||||
|
|
||||||
m = 1UL << (BITS_PER_LONG - 2);
|
|
||||||
while (m != 0) {
|
|
||||||
b = y + m;
|
|
||||||
y >>= 1;
|
|
||||||
|
|
||||||
if (x >= b) {
|
|
||||||
x -= b;
|
|
||||||
y += m;
|
|
||||||
}
|
|
||||||
m >>= 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief ilog2
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t ilog2(int32_t x)
|
|
||||||
{
|
|
||||||
int32_t A = !(!(x >> 16));
|
|
||||||
int32_t count = 0;
|
|
||||||
int32_t x_copy = x;
|
|
||||||
|
|
||||||
count = count + (A << 4);
|
|
||||||
|
|
||||||
x_copy = (((~A + 1) & (x >> 16)) + (~(~A + 1) & x));
|
|
||||||
|
|
||||||
A = !(!(x_copy >> 8));
|
|
||||||
count = count + (A << 3);
|
|
||||||
x_copy = (((~A + 1) & (x_copy >> 8)) + (~(~A + 1) & x_copy));
|
|
||||||
|
|
||||||
A = !(!(x_copy >> 4));
|
|
||||||
count = count + (A << 2);
|
|
||||||
x_copy = (((~A + 1) & (x_copy >> 4)) + (~(~A + 1) & x_copy));
|
|
||||||
|
|
||||||
A = !(!(x_copy >> 2));
|
|
||||||
count = count + (A << 1);
|
|
||||||
x_copy = (((~A + 1) & (x_copy >> 2)) + (~(~A + 1) & x_copy));
|
|
||||||
|
|
||||||
A = !(!(x_copy >> 1));
|
|
||||||
count = count + A;
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief find_first_bit
|
|
||||||
*******************************************************************************/
|
|
||||||
uint32_t find_first_bit(uint32_t word)
|
|
||||||
{
|
|
||||||
int32_t num = 0;
|
|
||||||
|
|
||||||
if ((word & 0xffff) == 0) {
|
|
||||||
num += 16;
|
|
||||||
word >>= 16;
|
|
||||||
}
|
|
||||||
if ((word & 0xff) == 0) {
|
|
||||||
num += 8;
|
|
||||||
word >>= 8;
|
|
||||||
}
|
|
||||||
if ((word & 0xf) == 0) {
|
|
||||||
num += 4;
|
|
||||||
word >>= 4;
|
|
||||||
}
|
|
||||||
if ((word & 0x3) == 0) {
|
|
||||||
num += 2;
|
|
||||||
word >>= 2;
|
|
||||||
}
|
|
||||||
if ((word & 0x1) == 0)
|
|
||||||
num += 1;
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief ERR_PTR
|
|
||||||
*******************************************************************************/
|
|
||||||
void * ERR_PTR(long error)
|
|
||||||
{
|
|
||||||
return (void *) error;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief zmalloc
|
|
||||||
*******************************************************************************/
|
|
||||||
void *zmalloc(size_t size)
|
|
||||||
{
|
|
||||||
void *ptr = malloc(size);
|
|
||||||
if (ptr)
|
|
||||||
memset(ptr, 0, size);
|
|
||||||
mdelay(1);
|
|
||||||
|
|
||||||
return ptr;
|
|
||||||
}
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file ad9361_util.h
|
|
||||||
* @brief AD9361 Header file of Util driver.
|
|
||||||
* @author DBogdan (dragos.bogdan@analog.com)
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2013(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __AD9361_UTIL_H__
|
|
||||||
#define __AD9361_UTIL_H__
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include "ad9361.h"
|
|
||||||
#include "common.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/********************** Macros and Constants Definitions **********************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#define CLK_IGNORE_UNUSED BIT(3)
|
|
||||||
#define CLK_GET_RATE_NOCACHE BIT(6)
|
|
||||||
|
|
||||||
#if defined(HAVE_VERBOSE_MESSAGES)
|
|
||||||
#define dev_err(dev, format, ...) ({printf(format, ## __VA_ARGS__);printf("\n"); })
|
|
||||||
#define dev_warn(dev, format, ...) ({printf(format, ## __VA_ARGS__);printf("\n"); })
|
|
||||||
#if defined(HAVE_DEBUG_MESSAGES)
|
|
||||||
#define dev_dbg(dev, format, ...) ({printf(format, ## __VA_ARGS__);printf("\n"); })
|
|
||||||
#else
|
|
||||||
#define dev_dbg(dev, format, ...) ({ if (0) printf(format, ## __VA_ARGS__); })
|
|
||||||
#endif
|
|
||||||
#define printk(format, ...) printf(format, ## __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define dev_err(dev, format, ...) ({ if (0) printf(format, ## __VA_ARGS__); })
|
|
||||||
#define dev_warn(dev, format, ...) ({ if (0) printf(format, ## __VA_ARGS__); })
|
|
||||||
#define dev_dbg(dev, format, ...) ({ if (0) printf(format, ## __VA_ARGS__); })
|
|
||||||
#define printk(format, ...) ({ if (0) printf(format, ## __VA_ARGS__); })
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct device {
|
|
||||||
};
|
|
||||||
|
|
||||||
struct spi_device {
|
|
||||||
struct device dev;
|
|
||||||
uint8_t id_no;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct axiadc_state {
|
|
||||||
struct ad9361_rf_phy *phy;
|
|
||||||
uint32_t pcore_version;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct axiadc_chip_info {
|
|
||||||
char *name;
|
|
||||||
int32_t num_channels;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct axiadc_converter {
|
|
||||||
struct axiadc_chip_info *chip_info;
|
|
||||||
uint32_t scratch_reg[16];
|
|
||||||
};
|
|
||||||
|
|
||||||
#ifdef WIN32
|
|
||||||
#include "basetsd.h"
|
|
||||||
typedef SSIZE_T ssize_t;
|
|
||||||
#define strsep(s, ct) 0
|
|
||||||
#define snprintf(s, n, format, ...) 0
|
|
||||||
#define __func__ __FUNCTION__
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/************************ Functions Declarations ******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
int32_t clk_prepare_enable(struct clk *clk);
|
|
||||||
uint32_t clk_get_rate(struct ad9361_rf_phy *phy,
|
|
||||||
struct refclk_scale *clk_priv);
|
|
||||||
int32_t clk_set_rate(struct ad9361_rf_phy *phy,
|
|
||||||
struct refclk_scale *clk_priv,
|
|
||||||
uint32_t rate);
|
|
||||||
uint32_t int_sqrt(uint32_t x);
|
|
||||||
int32_t ilog2(int32_t x);
|
|
||||||
uint32_t find_first_bit(uint32_t word);
|
|
||||||
void * ERR_PTR(long error);
|
|
||||||
void *zmalloc(size_t size);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file common.h
|
|
||||||
* @brief Header file of Common Driver.
|
|
||||||
* @author DBogdan (dragos.bogdan@analog.com)
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2013(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef __AD9361_COMMON_H_
|
|
||||||
#define __AD9361_COMMON_H_
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "../../../include/error.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*************************** Types Declarations *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#if defined (__STDC__) && (__STDC_VERSION__ >= 199901L)
|
|
||||||
#include <stdbool.h>
|
|
||||||
#else
|
|
||||||
typedef enum { false, true } bool;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct clk {
|
|
||||||
const char *name;
|
|
||||||
uint32_t rate;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct clk_hw {
|
|
||||||
struct clk *clk;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // __AD9361_COMMON_H_
|
|
||||||
@@ -1,151 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file ad9361_reg.c
|
|
||||||
* @brief Implementation of AD9680 Driver.
|
|
||||||
* @author DBogdan (dragos.bogdan@analog.com)
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2014-2016(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include "ad9361_reg.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include "../../../include/error.h"
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief ad9361_reg_read
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t ad9361_reg_read(struct ad9361_reg_dev *dev,
|
|
||||||
uint16_t reg_addr,
|
|
||||||
uint8_t *reg_data)
|
|
||||||
{
|
|
||||||
uint8_t tx_buf[2];
|
|
||||||
uint8_t rx_buf[1];
|
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
tx_buf[0] = reg_addr >> 8;
|
|
||||||
tx_buf[1] = reg_addr & 0xFF;
|
|
||||||
|
|
||||||
|
|
||||||
ret = spi_write_and_read_3wire(dev->spi_desc,
|
|
||||||
tx_buf, rx_buf, 2, 1);
|
|
||||||
|
|
||||||
*reg_data = rx_buf[0];
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief ad9361_reg_write
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t ad9361_reg_write(struct ad9361_reg_dev *dev,
|
|
||||||
uint16_t reg_addr,
|
|
||||||
uint8_t reg_data)
|
|
||||||
{
|
|
||||||
uint8_t buf[3];
|
|
||||||
|
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
buf[0] = 0x80 | reg_addr >> 8;
|
|
||||||
buf[1] = reg_addr & 0xFF;
|
|
||||||
buf[2] = reg_data;
|
|
||||||
|
|
||||||
ret = spi_write_and_read_3wire(dev->spi_desc,
|
|
||||||
buf, NULL, 3, 0);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief ad9361_reg_init
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t ad9361_reg_init(struct ad9361_reg_dev **device,
|
|
||||||
const struct ad9361_reg_init_param *init_param)
|
|
||||||
{
|
|
||||||
int ret = SUCCESS;
|
|
||||||
struct ad9361_reg_dev *dev;
|
|
||||||
|
|
||||||
dev = (struct ad9361_reg_dev *)malloc(sizeof(*dev));
|
|
||||||
if (!dev)
|
|
||||||
return FAILURE;
|
|
||||||
|
|
||||||
/* SPI */
|
|
||||||
ret = spi_init(&dev->spi_desc, init_param->spi_init);
|
|
||||||
ret |= gpio_get(&dev->gpio_desc_resetb, init_param->gpio_resetb);
|
|
||||||
|
|
||||||
gpio_direction_output(dev->gpio_desc_resetb, 0);
|
|
||||||
|
|
||||||
ad9361_reg_reset(dev);
|
|
||||||
|
|
||||||
*device = dev;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AD9361 Device Reset
|
|
||||||
* @param phy The AD9361 state structure.
|
|
||||||
* @return 0 in case of success, negative error code otherwise.
|
|
||||||
*/
|
|
||||||
int32_t ad9361_reg_reset(struct ad9361_reg_dev *dev)
|
|
||||||
{
|
|
||||||
if (dev->gpio_desc_resetb) {
|
|
||||||
gpio_set_value(dev->gpio_desc_resetb, 0);
|
|
||||||
mdelay(10);
|
|
||||||
gpio_set_value(dev->gpio_desc_resetb, 1);
|
|
||||||
mdelay(10);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***************************************************************************//**
|
|
||||||
* @brief Free the resources allocated by ad9361_reg_setup().
|
|
||||||
*
|
|
||||||
* @param dev - The device structure.
|
|
||||||
*
|
|
||||||
* @return SUCCESS in case of success, negative error code otherwise.
|
|
||||||
*******************************************************************************/
|
|
||||||
int32_t ad9361_reg_remove(struct ad9361_reg_dev *dev)
|
|
||||||
{
|
|
||||||
int32_t ret;
|
|
||||||
|
|
||||||
ret = spi_remove(dev->spi_desc);
|
|
||||||
|
|
||||||
free(dev);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file ad9361_reg.h
|
|
||||||
* @brief Header file of ad9361_reg Driver.
|
|
||||||
* @author DBogdan (dragos.bogdan@analog.com)
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2014-2016(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
#ifndef ad9361_reg_H_
|
|
||||||
#define ad9361_reg_H_
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "delay.h"
|
|
||||||
#include "spi.h"
|
|
||||||
#include "gpio.h"
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/********************** Macros and Constants Definitions **********************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*************************** Types Declarations *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
struct ad9361_reg_dev {
|
|
||||||
/* SPI */
|
|
||||||
struct spi_desc *spi_desc;
|
|
||||||
struct gpio_desc *gpio_desc_resetb;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ad9361_reg_init_param {
|
|
||||||
/* SPI */
|
|
||||||
struct spi_init_param *spi_init;
|
|
||||||
struct gpio_init_param *gpio_resetb;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum Operation_Type{
|
|
||||||
AD9361_WRITE,
|
|
||||||
AD9361_READ,
|
|
||||||
AD9361_WAIT,
|
|
||||||
AD9361_WHEN
|
|
||||||
};
|
|
||||||
|
|
||||||
struct ad9361_reg_config {
|
|
||||||
int operation;
|
|
||||||
uint16_t val1;
|
|
||||||
uint16_t val2;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/************************ Functions Declarations ******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
int32_t ad9361_reg_read(struct ad9361_reg_dev *dev,
|
|
||||||
uint16_t reg_addr,
|
|
||||||
uint8_t *reg_data);
|
|
||||||
|
|
||||||
int32_t ad9361_reg_write(struct ad9361_reg_dev *dev,
|
|
||||||
uint16_t reg_addr,
|
|
||||||
uint8_t reg_data);
|
|
||||||
|
|
||||||
int32_t ad9361_reg_init(struct ad9361_reg_dev **device,
|
|
||||||
const struct ad9361_reg_init_param *init_param);
|
|
||||||
|
|
||||||
int32_t ad9361_reg_reset(struct ad9361_reg_dev *dev);
|
|
||||||
|
|
||||||
int32_t ad9361_reg_remove(struct ad9361_reg_dev *dev);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
-474
@@ -1,474 +0,0 @@
|
|||||||
/*****************************************************************************/
|
|
||||||
/**
|
|
||||||
* Description: hwconfig.h
|
|
||||||
*
|
|
||||||
|
|
||||||
* Date: 2024-02-20 13:19
|
|
||||||
* Last Edit Time: [2024-02-20 13:19]
|
|
||||||
*
|
|
||||||
* Revisions: Rev 0.0
|
|
||||||
* History:
|
|
||||||
* [2023-05-07]: Initial edition.
|
|
||||||
*
|
|
||||||
* Copyright(c) 2024 Beijing Institute of Technology.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
|
|
||||||
/***************************** Include Files *********************************/
|
|
||||||
// Standard
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdbool.h>
|
|
||||||
// Xilinx
|
|
||||||
#include "xgpiops.h"
|
|
||||||
#include "drivers/rf-transceiver/ad9361_reg/ad9361_reg.h"
|
|
||||||
#include "drivers/rf-transceiver/ad9361/ad9361_api.h"
|
|
||||||
#include "drivers/axi_core/spi_engine/spi_engine.h"
|
|
||||||
// App
|
|
||||||
#include "common.h"
|
|
||||||
#include "error.h"
|
|
||||||
#include "delay.h"
|
|
||||||
#include "system_monitor.h"
|
|
||||||
#include "hwconfig.h"
|
|
||||||
#include "config/app_config.h"
|
|
||||||
#include "dev_profile/dev_profile.h"
|
|
||||||
|
|
||||||
/************************** Function Prototypes ******************************/
|
|
||||||
/*********************** Driver Instance Definitions **************************/
|
|
||||||
static struct hmc7044_dev *hmc7044_inst = NULL;
|
|
||||||
static struct ad9361_reg_dev *ad9361_1_reg_inst = NULL;
|
|
||||||
static struct ad9361_reg_dev *ad9361_2_reg_inst = NULL;
|
|
||||||
// static struct ad9361_rf_phy *ad9361_phy;
|
|
||||||
// static struct ad9361_rf_phy *ad9361_2_phy;
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/**
|
|
||||||
* @brief Hardware_Init
|
|
||||||
*
|
|
||||||
* @param none.
|
|
||||||
*
|
|
||||||
* @return None.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
int32_t Hardware_Init(void)
|
|
||||||
{
|
|
||||||
int32_t Status;
|
|
||||||
XGpioPs Gpio;
|
|
||||||
XGpioPs_Config *ConfigPtr;
|
|
||||||
ConfigPtr = XGpioPs_LookupConfig(AD9361_GPIO_DEVICE_ID);
|
|
||||||
Status = XGpioPs_CfgInitialize(&Gpio, ConfigPtr, ConfigPtr->BaseAddr);
|
|
||||||
if (Status != SUCCESS)
|
|
||||||
{
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************/
|
|
||||||
/****************** HMC7044 Configuration *****************/
|
|
||||||
/**********************************************************/
|
|
||||||
Status = hmc7044_init(&hmc7044_inst, &hmc7044_default_init_param);
|
|
||||||
if (Status != SUCCESS)
|
|
||||||
{
|
|
||||||
DBG_ERROR("hmc7044_init() error: %" PRId32 "\n", Status);
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************/
|
|
||||||
/***************** AD9361-1 Configuration *****************/
|
|
||||||
/**********************************************************/
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_1_TXNRX, AD9361_GPIO_OUTPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_1_ENABLE, AD9361_GPIO_OUTPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_1_EN_AGC, AD9361_GPIO_OUTPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_1_RESET_B, AD9361_GPIO_OUTPUT);
|
|
||||||
|
|
||||||
ad9361_reg_init(&ad9361_1_reg_inst, &ad9361_1_reg_default_init_param);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_1_ENABLE, 0);
|
|
||||||
ad9361_reg_config(ad9361_1_reg_inst);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_1_ENABLE, 1);
|
|
||||||
|
|
||||||
// Status = ad9361_init(&ad9361_phy, &ad9361_default_init_param);
|
|
||||||
// if (Status != XST_SUCCESS){
|
|
||||||
// return XST_FAILURE;
|
|
||||||
// }else{
|
|
||||||
// printf("Configurate AD9361 Completely!\n");
|
|
||||||
// }
|
|
||||||
// ad9361_set_tx_fir_config(ad9361_phy, tx_fir_config);
|
|
||||||
// ad9361_set_rx_fir_config(ad9361_phy, rx_fir_config);
|
|
||||||
|
|
||||||
/**********************************************************/
|
|
||||||
/***************** AD9361-2 Configuration *****************/
|
|
||||||
/**********************************************************/
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_2_TXNRX, AD9361_GPIO_OUTPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_2_ENABLE, AD9361_GPIO_OUTPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_2_EN_AGC, AD9361_GPIO_OUTPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_2_RESET_B, AD9361_GPIO_OUTPUT);
|
|
||||||
|
|
||||||
ad9361_reg_init(&ad9361_2_reg_inst, &ad9361_2_reg_default_init_param);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_2_ENABLE, 0);
|
|
||||||
ad9361_reg_config(ad9361_2_reg_inst);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_2_ENABLE, 1);
|
|
||||||
|
|
||||||
// uint8_t rd_back;
|
|
||||||
// Status = ad9361_reg_read(ad9361_1_reg_inst, 0x0002, &rd_back);
|
|
||||||
// Status = ad9361_reg_read(ad9361_2_reg_inst, 0x0002, &rd_back);
|
|
||||||
|
|
||||||
/**********************************************************/
|
|
||||||
/******* AD9361 Baseband Multichip Synchronization ********/
|
|
||||||
/**********************************************************/
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_SYNC, AD9361_GPIO_OUTPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_RX_FIFO_RST, AD9361_GPIO_OUTPUT);
|
|
||||||
|
|
||||||
// SYNC BBPLL and DIGITAL SAMPLING CLOCKS
|
|
||||||
ad9361_reg_write(ad9361_1_reg_inst, 0x0001, 0x0D); // MCS RF Enable; MCS BBPLL Enable; MCS BB Enable
|
|
||||||
ad9361_reg_write(ad9361_2_reg_inst, 0x0001, 0x0D);
|
|
||||||
ad9361_reg_write(ad9361_1_reg_inst, 0x0047, 0x80); // MCS refclk Scale Enable
|
|
||||||
ad9361_reg_write(ad9361_2_reg_inst, 0x0047, 0x80);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_SYNC, 0);
|
|
||||||
mdelay(20);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_SYNC, 1); // Input a rising-edge pulse to the SYNC_IN pin
|
|
||||||
mdelay(500);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_SYNC, 0);
|
|
||||||
mdelay(2000);
|
|
||||||
ad9361_reg_write(ad9361_1_reg_inst, 0x0001, 0x0B); // MCS RF Enable; MCS Digital CLK Enable ; MCS BB Enable
|
|
||||||
ad9361_reg_write(ad9361_2_reg_inst, 0x0001, 0x0B);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_SYNC, 1); // Input another rising-edge pulse to the SYNC_IN pin
|
|
||||||
mdelay(500);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_SYNC, 0);
|
|
||||||
ad9361_reg_write(ad9361_1_reg_inst, 0x0001, 0x08); // clear MCS bits
|
|
||||||
ad9361_reg_write(ad9361_2_reg_inst, 0x0001, 0x08);
|
|
||||||
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_RX_FIFO_RST, 0);
|
|
||||||
mdelay(20);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_RX_FIFO_RST, 1);
|
|
||||||
mdelay(20);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_RX_FIFO_RST, 0);
|
|
||||||
|
|
||||||
/**********************************************************/
|
|
||||||
/********* AD9361 Multichip Rx Phase Calibration **********/
|
|
||||||
/**********************************************************/
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_TX_SWITCH, AD9361_GPIO_OUTPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_1_CAL_START, AD9361_GPIO_OUTPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_1_CAL_DONE, AD9361_GPIO_INPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_2_CAL_START, AD9361_GPIO_OUTPUT);
|
|
||||||
XGpioPs_SetDirectionPin(&Gpio, AD9361_2_CAL_DONE, AD9361_GPIO_INPUT);
|
|
||||||
|
|
||||||
// switch to lower frequency
|
|
||||||
Status = Hardware_SwitchFreq(ad9361_1_reg_inst, TX_FREQ_126);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_TX_SWITCH, 1);
|
|
||||||
mdelay(20);
|
|
||||||
|
|
||||||
// switch rx channel
|
|
||||||
Status = ad9361_reg_write(ad9361_1_reg_inst, 0x0004, 0x30);
|
|
||||||
Status = ad9361_reg_write(ad9361_2_reg_inst, 0x0004, 0x30);
|
|
||||||
|
|
||||||
// enable dual ad9361 tx channels
|
|
||||||
Status = ad9361_reg_write(ad9361_1_reg_inst, 0x0002, 0xE4); // Setup Tx Digital Filters/ Channels
|
|
||||||
|
|
||||||
// switch ad9361 tx channel
|
|
||||||
Status = ad9361_reg_write(ad9361_1_reg_inst, 0x0004, 0x70); // Select Rx input pin(A,B,C)/ Tx out pin (A,B)
|
|
||||||
mdelay(20);
|
|
||||||
|
|
||||||
// begin to calibrate the 1st ad9361
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_1_CAL_START, 0);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_1_CAL_START, 1);
|
|
||||||
mdelay(1);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_1_CAL_START, 0);
|
|
||||||
|
|
||||||
// read calibration status
|
|
||||||
int32_t time_out_cnt = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
mdelay(1); // Wait 1ms
|
|
||||||
time_out_cnt++;
|
|
||||||
} while (((XGpioPs_ReadPin(&Gpio, AD9361_1_CAL_DONE) == 0) && time_out_cnt <= AD9361_TIMEOUT_TH));
|
|
||||||
|
|
||||||
if (time_out_cnt == AD9361_TIMEOUT_TH)
|
|
||||||
{
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// begin to calibrate the 2nd ad9361
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_2_CAL_START, 1);
|
|
||||||
mdelay(1);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_2_CAL_START, 0);
|
|
||||||
|
|
||||||
// read calibration status
|
|
||||||
time_out_cnt = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
mdelay(1); // Wait 1ms
|
|
||||||
time_out_cnt++;
|
|
||||||
} while (((XGpioPs_ReadPin(&Gpio, AD9361_2_CAL_DONE) == 0) && time_out_cnt <= AD9361_TIMEOUT_TH));
|
|
||||||
|
|
||||||
if (time_out_cnt == AD9361_TIMEOUT_TH)
|
|
||||||
{
|
|
||||||
return FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// enable single ad9361 tx channels
|
|
||||||
Status = ad9361_reg_write(ad9361_1_reg_inst, 0x0002, 0xA4); // Setup Tx Digital Filters/ Channels
|
|
||||||
|
|
||||||
// switch ad9361 tx & rx channel
|
|
||||||
Status = ad9361_reg_write(ad9361_1_reg_inst, 0x0004, 0x03);
|
|
||||||
Status = ad9361_reg_write(ad9361_2_reg_inst, 0x0004, 0x03);
|
|
||||||
|
|
||||||
// switch to higher frequency
|
|
||||||
Status = Hardware_SwitchFreq(ad9361_1_reg_inst, TX_FREQ_4125);
|
|
||||||
XGpioPs_WritePin(&Gpio, AD9361_TX_SWITCH, 0);
|
|
||||||
|
|
||||||
Status = ad9361_reg_write(ad9361_1_reg_inst, 0x0109, 0x00); // Rx Gain
|
|
||||||
Status = ad9361_reg_write(ad9361_1_reg_inst, 0x010C, 0x00); // Rx Gain
|
|
||||||
Status = ad9361_reg_write(ad9361_2_reg_inst, 0x0109, 0x00); // Rx Gain
|
|
||||||
Status = ad9361_reg_write(ad9361_2_reg_inst, 0x010C, 0x00); // Rx Gain
|
|
||||||
|
|
||||||
DBG_PRINT("Done.\n");
|
|
||||||
|
|
||||||
return SUCCESS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
|
||||||
/**
|
|
||||||
* @brief Hardware_SwitchFreq
|
|
||||||
*
|
|
||||||
* @param devSysMonitor_UpdateHardwareStatus(newHwState);
|
|
||||||
* @param freq
|
|
||||||
*
|
|
||||||
* @return None.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
int32_t Hardware_SwitchFreq(struct ad9361_reg_dev *dev, ad9361TxFreq freq)
|
|
||||||
{
|
|
||||||
int32_t status = 0;
|
|
||||||
uint8_t value = 0;
|
|
||||||
int32_t time_out_cnt = 0;
|
|
||||||
|
|
||||||
switch (freq)
|
|
||||||
{
|
|
||||||
case TX_FREQ_125:
|
|
||||||
{
|
|
||||||
//************************************************************
|
|
||||||
// Setup Tx Frequency-Dependent Syntheisizer Registers
|
|
||||||
//************************************************************
|
|
||||||
status = ad9361_reg_write(dev, 0x027A, 0x4A); // Set VCO Output level[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0279, 0xC1); // Set Init ALC Value[3:0] and VCO Varactor[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0282, 0x0E); // Set VCO Bias Tcf[1:0] and VCO Bias Ref[2:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0278, 0x78); // Set VCO Cal Offset[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0285, 0x00); // Set VCO Cal Ref Tcf[2:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0291, 0x0B); // Set VCO Varactor Reference[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0290, 0x70); // Set VCO Varactor Ref Tcf[2:0] and VCO Varactor Offset[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x027B, 0x94); // Set Synth Loop Filter charge pump current (Icp)
|
|
||||||
status = ad9361_reg_write(dev, 0x027E, 0xF4); // Set Synth Loop Filter C2 and C1
|
|
||||||
status = ad9361_reg_write(dev, 0x027F, 0xDF); // Set Synth Loop Filter R1 and C3
|
|
||||||
status = ad9361_reg_write(dev, 0x0280, 0x0A); // Set Synth Loop Filter R3
|
|
||||||
|
|
||||||
//************************************************************
|
|
||||||
// Write Tx Frequency Words
|
|
||||||
//************************************************************
|
|
||||||
status = ad9361_reg_write(dev, 0x0273, 0x00); // Write Tx Synth Fractional Freq Word[7:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0274, 0x00); // Write Tx Synth Fractional Freq Word[15:8]
|
|
||||||
status = ad9361_reg_write(dev, 0x0275, 0x00); // Write Tx Synth Fractional Freq Word[22:16]
|
|
||||||
status = ad9361_reg_write(dev, 0x0272, 0x00); // Write Tx Synth Integer Freq Word[10:8]
|
|
||||||
status = ad9361_reg_write(dev, 0x0271, 0xA0); // Write Tx Synth Integer Freq Word[7:0] (starts VCO cal)
|
|
||||||
status = ad9361_reg_write(dev, 0x0005, 0x57); // Set LO divider setting
|
|
||||||
|
|
||||||
//************************************************************
|
|
||||||
// Tx Quadrature Calibration Settings
|
|
||||||
//************************************************************
|
|
||||||
status = ad9361_reg_write(dev, 0x00A0, 0x75); // Set TxQuadcal NCO frequency
|
|
||||||
status = ad9361_reg_write(dev, 0x00A3, 0xC0); // Set TxQuadcal NCO frequency (Only update bits [7:6])
|
|
||||||
status = ad9361_reg_write(dev, 0x00A1, 0x7B); // Tx Quad Cal Configuration, Phase and Gain Cal Enable
|
|
||||||
status = ad9361_reg_write(dev, 0x00A9, 0xFF); // Set Tx Quad Cal Count
|
|
||||||
status = ad9361_reg_write(dev, 0x00A2, 0x7F); // Set Tx Quad Cal Kexp
|
|
||||||
status = ad9361_reg_write(dev, 0x00A5, 0x01); // Set Tx Quad Cal Magnitude Threshhold
|
|
||||||
status = ad9361_reg_write(dev, 0x00A6, 0x01); // Set Tx Quad Cal Magnitude Threshhold
|
|
||||||
status = ad9361_reg_write(dev, 0x00AA, 0x22); // Set Tx Quad Cal Gain Table index
|
|
||||||
status = ad9361_reg_write(dev, 0x00A4, 0xF0); // Set Tx Quad Cal Settle Count
|
|
||||||
status = ad9361_reg_write(dev, 0x00AE, 0x00); // Set Tx Quad Cal LPF Gain index incase Split table mode used
|
|
||||||
|
|
||||||
status = ad9361_reg_write(dev, 0x0169, 0xC0); // Disable Rx Quadrature Calibration before Running Tx Quadrature Calibration
|
|
||||||
status = ad9361_reg_write(dev, 0x0016, 0x10); // Start Tx Quad cal
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TX_FREQ_126:
|
|
||||||
{
|
|
||||||
//************************************************************
|
|
||||||
// Setup Tx Frequency-Dependent Syntheisizer Registers
|
|
||||||
//************************************************************
|
|
||||||
status = ad9361_reg_write(dev, 0x027A, 0x4A); // Set VCO Output level[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0279, 0xC1); // Set Init ALC Value[3:0] and VCO Varactor[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0282, 0x0E); // Set VCO Bias Tcf[1:0] and VCO Bias Ref[2:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0278, 0x78); // Set VCO Cal Offset[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0285, 0x00); // Set VCO Cal Ref Tcf[2:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0291, 0x0B); // Set VCO Varactor Reference[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0290, 0x70); // Set VCO Varactor Ref Tcf[2:0] and VCO Varactor Offset[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x027B, 0x93); // Set Synth Loop Filter charge pump current (Icp)
|
|
||||||
status = ad9361_reg_write(dev, 0x027E, 0xF4); // Set Synth Loop Filter C2 and C1
|
|
||||||
status = ad9361_reg_write(dev, 0x027F, 0xDF); // Set Synth Loop Filter R1 and C3
|
|
||||||
status = ad9361_reg_write(dev, 0x0280, 0x0A); // Set Synth Loop Filter R3
|
|
||||||
|
|
||||||
//************************************************************
|
|
||||||
// Write Tx Frequency Words
|
|
||||||
//************************************************************
|
|
||||||
status = ad9361_reg_write(dev, 0x0273, 0x06); // Write Tx Synth Fractional Freq Word[7:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0274, 0xD7); // Write Tx Synth Fractional Freq Word[15:8]
|
|
||||||
status = ad9361_reg_write(dev, 0x0275, 0x23); // Write Tx Synth Fractional Freq Word[22:16]
|
|
||||||
status = ad9361_reg_write(dev, 0x0272, 0x00); // Write Tx Synth Integer Freq Word[10:8]
|
|
||||||
status = ad9361_reg_write(dev, 0x0271, 0xA1); // Write Tx Synth Integer Freq Word[7:0] (starts VCO cal)
|
|
||||||
status = ad9361_reg_write(dev, 0x0005, 0x57); // Set LO divider setting
|
|
||||||
|
|
||||||
//************************************************************
|
|
||||||
// Tx Quadrature Calibration Settings
|
|
||||||
//************************************************************
|
|
||||||
status = ad9361_reg_write(dev, 0x00A0, 0x75); // Set TxQuadcal NCO frequency
|
|
||||||
status = ad9361_reg_write(dev, 0x00A3, 0xC0); // Set TxQuadcal NCO frequency (Only update bits [7:6])
|
|
||||||
status = ad9361_reg_write(dev, 0x00A1, 0x7B); // Tx Quad Cal Configuration, Phase and Gain Cal Enable
|
|
||||||
status = ad9361_reg_write(dev, 0x00A9, 0xFF); // Set Tx Quad Cal Count
|
|
||||||
status = ad9361_reg_write(dev, 0x00A2, 0x7F); // Set Tx Quad Cal Kexp
|
|
||||||
status = ad9361_reg_write(dev, 0x00A5, 0x01); // Set Tx Quad Cal Magnitude Threshhold
|
|
||||||
status = ad9361_reg_write(dev, 0x00A6, 0x01); // Set Tx Quad Cal Magnitude Threshhold
|
|
||||||
status = ad9361_reg_write(dev, 0x00AA, 0x22); // Set Tx Quad Cal Gain Table index
|
|
||||||
status = ad9361_reg_write(dev, 0x00A4, 0xF0); // Set Tx Quad Cal Settle Count
|
|
||||||
status = ad9361_reg_write(dev, 0x00AE, 0x00); // Set Tx Quad Cal LPF Gain index incase Split table mode used
|
|
||||||
|
|
||||||
status = ad9361_reg_write(dev, 0x0169, 0xC0); // Disable Rx Quadrature Calibration before Running Tx Quadrature Calibration
|
|
||||||
status = ad9361_reg_write(dev, 0x0016, 0x10); // Start Tx Quad cal
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case TX_FREQ_4125:
|
|
||||||
{
|
|
||||||
//************************************************************
|
|
||||||
// Setup Tx Frequency-Dependent Syntheisizer Registers
|
|
||||||
//************************************************************
|
|
||||||
status = ad9361_reg_write(dev, 0x027A, 0x4A); // Set VCO Output level[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0279, 0xC1); // Set Init ALC Value[3:0] and VCO Varactor[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0282, 0x0E); // Set VCO Bias Tcf[1:0] and VCO Bias Ref[2:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0278, 0x78); // Set VCO Cal Offset[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0285, 0x00); // Set VCO Cal Ref Tcf[2:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0291, 0x0B); // Set VCO Varactor Reference[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0290, 0x70); // Set VCO Varactor Ref Tcf[2:0] and VCO Varactor Offset[3:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x027B, 0x93); // Set Synth Loop Filter charge pump current (Icp)
|
|
||||||
status = ad9361_reg_write(dev, 0x027E, 0xF4); // Set Synth Loop Filter C2 and C1
|
|
||||||
status = ad9361_reg_write(dev, 0x027F, 0xDF); // Set Synth Loop Filter R1 and C3
|
|
||||||
status = ad9361_reg_write(dev, 0x0280, 0x0A); // Set Synth Loop Filter R3
|
|
||||||
|
|
||||||
//************************************************************
|
|
||||||
// Write Rx Frequency Words
|
|
||||||
//************************************************************
|
|
||||||
status = ad9361_reg_write(dev, 0x0273, 0x00); // Write Tx Synth Fractional Freq Word[7:0]
|
|
||||||
status = ad9361_reg_write(dev, 0x0274, 0x00); // Write Tx Synth Fractional Freq Word[15:8]
|
|
||||||
status = ad9361_reg_write(dev, 0x0275, 0x00); // Write Tx Synth Fractional Freq Word[22:16]
|
|
||||||
status = ad9361_reg_write(dev, 0x0272, 0x00); // Write Tx Synth Integer Freq Word[10:8]
|
|
||||||
status = ad9361_reg_write(dev, 0x0271, 0xA5); // Write Tx Synth Integer Freq Word[7:0] (starts VCO cal)
|
|
||||||
status = ad9361_reg_write(dev, 0x0005, 0x07); // Set LO divider setting
|
|
||||||
|
|
||||||
//************************************************************
|
|
||||||
// Tx Quadrature Calibration Settings
|
|
||||||
//************************************************************
|
|
||||||
status = ad9361_reg_write(dev, 0x00A0, 0x75); // Set TxQuadcal NCO frequency
|
|
||||||
status = ad9361_reg_write(dev, 0x00A3, 0xC0); // Set TxQuadcal NCO frequency (Only update bits [7:6])
|
|
||||||
status = ad9361_reg_write(dev, 0x00A1, 0x7B); // Tx Quad Cal Configuration, Phase and Gain Cal Enable
|
|
||||||
status = ad9361_reg_write(dev, 0x00A9, 0xFF); // Set Tx Quad Cal Count
|
|
||||||
status = ad9361_reg_write(dev, 0x00A2, 0x7F); // Set Tx Quad Cal Kexp
|
|
||||||
status = ad9361_reg_write(dev, 0x00A5, 0x01); // Set Tx Quad Cal Magnitude Threshhold
|
|
||||||
status = ad9361_reg_write(dev, 0x00A6, 0x01); // Set Tx Quad Cal Magnitude Threshhold
|
|
||||||
status = ad9361_reg_write(dev, 0x00AA, 0x28); // Set Tx Quad Cal Gain Table index
|
|
||||||
status = ad9361_reg_write(dev, 0x00A4, 0xF0); // Set Tx Quad Cal Settle Count
|
|
||||||
status = ad9361_reg_write(dev, 0x00AE, 0x04); // Set Tx Quad Cal LPF Gain index incase Split table mode used
|
|
||||||
|
|
||||||
status = ad9361_reg_write(dev, 0x0169, 0xC0); // Disable Rx Quadrature Calibration before Running Tx Quadrature Calibration
|
|
||||||
status = ad9361_reg_write(dev, 0x0016, 0x10); // Start Tx Quad cal
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wait for cal to complete (Done when 0x016[4]==0)
|
|
||||||
time_out_cnt = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
status |= ad9361_reg_read(dev, 0x0016, &value);
|
|
||||||
mdelay(1); // Wait 1ms
|
|
||||||
time_out_cnt++;
|
|
||||||
} while ((value & 0x10) != 0x00 && time_out_cnt <= AD9361_TIMEOUT_TH);
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ Get AD9361 - 1 temperature (Celsius Degree)
|
|
||||||
/**
|
|
||||||
* Read corresponding register to get AD9361 - 1 current temperature.
|
|
||||||
*/
|
|
||||||
int8_t Hardware_GetAD9361Temp_1(void)
|
|
||||||
{
|
|
||||||
int8_t scaleTemp;
|
|
||||||
double temp;
|
|
||||||
|
|
||||||
ad9361_reg_write(ad9361_1_reg_inst, 0x000B, -64);
|
|
||||||
ad9361_reg_write(ad9361_1_reg_inst, 0x001D, 0x01); // disable aux adc
|
|
||||||
ad9361_reg_read(ad9361_1_reg_inst, 0x000E, (uint8_t*)&scaleTemp);
|
|
||||||
ad9361_reg_write(ad9361_1_reg_inst, 0x001D, 0x00); // enable aux adc
|
|
||||||
|
|
||||||
temp = ((double)scaleTemp + 64)/1.16;
|
|
||||||
return ((temp > INT8_MAX) ? INT8_MAX : (int8_t)temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ Get AD9361 - 2 temperature (Celsius Degree)
|
|
||||||
/**
|
|
||||||
* Read corresponding register to get AD9361 - 2 current temperature.
|
|
||||||
*/
|
|
||||||
int8_t Hardware_GetAD9361Temp_2(void)
|
|
||||||
{
|
|
||||||
int8_t scaleTemp;
|
|
||||||
double temp;
|
|
||||||
|
|
||||||
ad9361_reg_write(ad9361_2_reg_inst, 0x000B, -64);
|
|
||||||
ad9361_reg_write(ad9361_2_reg_inst, 0x001D, 0x01); // disable aux adc
|
|
||||||
ad9361_reg_read(ad9361_2_reg_inst, 0x000E, (uint8_t*)&scaleTemp);
|
|
||||||
ad9361_reg_write(ad9361_2_reg_inst, 0x001D, 0x00); // enable aux adc
|
|
||||||
temp = ((double)scaleTemp + 64)/1.16;
|
|
||||||
return ((temp > INT8_MAX) ? INT8_MAX : (int8_t)temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ Determine AD9361 lock state
|
|
||||||
/**
|
|
||||||
* Read corresponding register to determine AD9361(both) lock state.
|
|
||||||
*/
|
|
||||||
uint8_t Hardware_GetAD9361LockStatus(void)
|
|
||||||
{
|
|
||||||
uint8_t ret = 0;
|
|
||||||
uint8_t regVal;
|
|
||||||
|
|
||||||
// bbpll
|
|
||||||
ad9361_reg_read(ad9361_1_reg_inst, 0x005E, ®Val); // [D7] is lock indicator
|
|
||||||
ret |= ((regVal & 0x80) == 0x80) ? CLK_AD0_BBPLL_LOCK : 0;
|
|
||||||
ad9361_reg_read(ad9361_2_reg_inst, 0x005E, ®Val); // [D7] is lock indicator
|
|
||||||
ret |= ((regVal & 0x80) == 0x80) ? CLK_AD1_BBPLL_LOCK : 0;
|
|
||||||
|
|
||||||
// rfpll
|
|
||||||
ad9361_reg_read(ad9361_1_reg_inst, 0x0287, ®Val); // [D1] is lock indicator
|
|
||||||
ret |= ((regVal & 0x02) == 0x02) ? CLK_AD0_RFPLL_LOCK : 0;
|
|
||||||
ad9361_reg_read(ad9361_2_reg_inst, 0x0287, ®Val); // [D1] is lock indicator
|
|
||||||
ret |= ((regVal & 0x02) == 0x02) ? CLK_AD1_RFPLL_LOCK : 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
// @ Determine HMC7044 lock state
|
|
||||||
/**
|
|
||||||
* Read corresponding register to determine clock lock state.
|
|
||||||
*/
|
|
||||||
uint8_t Hardware_GetHMC7044LockStatus(void)
|
|
||||||
{
|
|
||||||
uint8_t ret = 0;
|
|
||||||
uint8_t regVal;
|
|
||||||
|
|
||||||
// pll1
|
|
||||||
hmc7044_read(hmc7044_inst, 0x007C, ®Val); // [D5] is lock indicator
|
|
||||||
ret |= ((regVal & 0xE0) != 0x00) ? CLK_SP_PLL0_LOCK : 0;
|
|
||||||
|
|
||||||
// pll2
|
|
||||||
hmc7044_read(hmc7044_inst, 0x007D, ®Val); // [D0] is lock indicator
|
|
||||||
ret |= ((regVal & 0x01) == 0x01) ? CLK_SP_PLL1_LOCK : 0;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
/*****************************************************************************/
|
|
||||||
/**
|
|
||||||
* Description: hwconfig.h
|
|
||||||
*
|
|
||||||
|
|
||||||
* Date: 2024-02-20 13:19
|
|
||||||
* Last Edit Time: [2024-02-20 13:19]
|
|
||||||
*
|
|
||||||
* Revisions: Rev 0.0
|
|
||||||
* History:
|
|
||||||
* [2023-05-07]: Initial edition.
|
|
||||||
*
|
|
||||||
* Copyright(c) 2024 Beijing Institute of Technology.
|
|
||||||
*
|
|
||||||
******************************************************************************/
|
|
||||||
#ifndef HWCONFIG_H_
|
|
||||||
#define HWCONFIG_H_
|
|
||||||
/***************************** Include Files *********************************/
|
|
||||||
// Standard
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "config/app_config.h"
|
|
||||||
#include "drivers/rf-transceiver/ad9361_reg/ad9361_reg.h"
|
|
||||||
#include "drivers/rf-transceiver/ad9361/ad9361_api.h"
|
|
||||||
|
|
||||||
/************************** Function Prototypes ******************************/
|
|
||||||
int32_t Hardware_Init(void);
|
|
||||||
int32_t Hardware_SwitchFreq(struct ad9361_reg_dev *dev, ad9361TxFreq freq);
|
|
||||||
int8_t Hardware_GetAD9361Temp_1(void);
|
|
||||||
int8_t Hardware_GetAD9361Temp_2(void);
|
|
||||||
uint8_t Hardware_GetAD9361LockStatus(void);
|
|
||||||
uint8_t Hardware_GetHMC7044LockStatus(void);
|
|
||||||
|
|
||||||
#endif // HWCONFIG_H_
|
|
||||||
@@ -1,188 +0,0 @@
|
|||||||
/***************************************************************************//**
|
|
||||||
* @file gpio.h
|
|
||||||
* @brief Header file of GPIO Interface
|
|
||||||
* @author DBogdan (dragos.bogdan@analog.com)
|
|
||||||
********************************************************************************
|
|
||||||
* Copyright 2019(c) Analog Devices, Inc.
|
|
||||||
*
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in
|
|
||||||
* the documentation and/or other materials provided with the
|
|
||||||
* distribution.
|
|
||||||
* - Neither the name of Analog Devices, Inc. nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
* - The use of this software may or may not infringe the patent rights
|
|
||||||
* of one or more patent holders. This license does not release you
|
|
||||||
* from the requirement that you obtain separate licenses from these
|
|
||||||
* patent holders to use this software.
|
|
||||||
* - Use of the software either in source or binary form, must be run
|
|
||||||
* on or directly connected to an Analog Devices Inc. component.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
|
|
||||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
||||||
* IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
||||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
||||||
* LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*******************************************************************************/
|
|
||||||
|
|
||||||
#ifndef _GPIO_H_
|
|
||||||
#define _GPIO_H_
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/***************************** Include Files **********************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/********************** Macros and Constants Definitions **********************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
#define GPIO_OUT 0x01
|
|
||||||
#define GPIO_IN 0x00
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/*************************** Types Declarations *******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct gpio_platform_ops
|
|
||||||
* @brief Structure holding gpio function pointers that point to the platform
|
|
||||||
* specific function
|
|
||||||
*/
|
|
||||||
struct gpio_platform_ops ;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum gpio_pull_up
|
|
||||||
* @brief Enum that holds the possible pull up/ pull down resistor configuration.
|
|
||||||
*/
|
|
||||||
enum gpio_pull_up {
|
|
||||||
PULL_NONE,
|
|
||||||
/** Strong pull up */
|
|
||||||
PULL_UP,
|
|
||||||
/** Strong pull down */
|
|
||||||
PULL_DOWN,
|
|
||||||
PULL_UP_WEAK,
|
|
||||||
PULL_DOWN_WEAK
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct gpio_init_param
|
|
||||||
* @brief Structure holding the parameters for GPIO initialization.
|
|
||||||
*/
|
|
||||||
struct gpio_init_param {
|
|
||||||
/** Port number */
|
|
||||||
int32_t port;
|
|
||||||
/** GPIO number */
|
|
||||||
int32_t number;
|
|
||||||
/** Pull up/down resistor configuration */
|
|
||||||
enum gpio_pull_up pull;
|
|
||||||
/** GPIO platform specific functions */
|
|
||||||
const struct gpio_platform_ops *platform_ops;
|
|
||||||
/** GPIO extra parameters (device specific) */
|
|
||||||
void *extra;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct gpio_desc
|
|
||||||
* @brief Structure holding the GPIO descriptor.
|
|
||||||
*/
|
|
||||||
struct gpio_desc {
|
|
||||||
/** Port number */
|
|
||||||
int32_t port;
|
|
||||||
/** GPIO number */
|
|
||||||
int32_t number;
|
|
||||||
/** Pull up/down resistor configuration */
|
|
||||||
enum gpio_pull_up pull;
|
|
||||||
/** GPIO platform specific functions */
|
|
||||||
const struct gpio_platform_ops *platform_ops;
|
|
||||||
/** GPIO extra parameters (device specific) */
|
|
||||||
void *extra;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum gpio_values
|
|
||||||
* @brief Enum that holds the possible output states of a GPIO.
|
|
||||||
*/
|
|
||||||
enum gpio_values {
|
|
||||||
/** GPIO logic low */
|
|
||||||
GPIO_LOW,
|
|
||||||
/** GPIO logic high */
|
|
||||||
GPIO_HIGH,
|
|
||||||
/** GPIO high impedance */
|
|
||||||
GPIO_HIGH_Z
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @struct gpio_platform_ops
|
|
||||||
* @brief Structure holding gpio function pointers that point to the platform
|
|
||||||
* specific function
|
|
||||||
*/
|
|
||||||
struct gpio_platform_ops {
|
|
||||||
/** gpio initialization function pointer */
|
|
||||||
int32_t (*gpio_ops_get)(struct gpio_desc **,
|
|
||||||
const struct gpio_init_param *);
|
|
||||||
/** gpio optional descriptor function pointer */
|
|
||||||
int32_t (*gpio_ops_get_optional)(struct gpio_desc **,
|
|
||||||
const struct gpio_init_param *);
|
|
||||||
/** gpio remove function pointer */
|
|
||||||
int32_t (*gpio_ops_remove)(struct gpio_desc *);
|
|
||||||
/** gpio direction input function pointer */
|
|
||||||
int32_t (*gpio_ops_direction_input)(struct gpio_desc *);
|
|
||||||
/** gpio direction output function pointer */
|
|
||||||
int32_t (*gpio_ops_direction_output)(struct gpio_desc *, uint8_t);
|
|
||||||
/** gpio get direction function pointer */
|
|
||||||
int32_t (*gpio_ops_get_direction)(struct gpio_desc *, uint8_t *);
|
|
||||||
/** gpio set value function pointer */
|
|
||||||
int32_t (*gpio_ops_set_value)(struct gpio_desc *, uint8_t);
|
|
||||||
/** gpio get value function pointer */
|
|
||||||
int32_t (*gpio_ops_get_value)(struct gpio_desc *, uint8_t *);
|
|
||||||
};
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/************************ Functions Declarations ******************************/
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
/* Obtain the GPIO decriptor. */
|
|
||||||
int32_t gpio_get(struct gpio_desc **desc,
|
|
||||||
const struct gpio_init_param *param);
|
|
||||||
|
|
||||||
/* Obtain optional GPIO descriptor. */
|
|
||||||
int32_t gpio_get_optional(struct gpio_desc **desc,
|
|
||||||
const struct gpio_init_param *param);
|
|
||||||
|
|
||||||
/* Free the resources allocated by gpio_get(). */
|
|
||||||
int32_t gpio_remove(struct gpio_desc *desc);
|
|
||||||
|
|
||||||
/* Enable the input direction of the specified GPIO. */
|
|
||||||
int32_t gpio_direction_input(struct gpio_desc *desc);
|
|
||||||
|
|
||||||
/* Enable the output direction of the specified GPIO. */
|
|
||||||
int32_t gpio_direction_output(struct gpio_desc *desc,
|
|
||||||
uint8_t value);
|
|
||||||
|
|
||||||
/* Get the direction of the specified GPIO. */
|
|
||||||
int32_t gpio_get_direction(struct gpio_desc *desc,
|
|
||||||
uint8_t *direction);
|
|
||||||
|
|
||||||
/* Set the value of the specified GPIO. */
|
|
||||||
int32_t gpio_set_value(struct gpio_desc *desc,
|
|
||||||
uint8_t value);
|
|
||||||
|
|
||||||
/* Get the value of the specified GPIO. */
|
|
||||||
int32_t gpio_get_value(struct gpio_desc *desc,
|
|
||||||
uint8_t *value);
|
|
||||||
|
|
||||||
#endif // _GPIO_H_
|
|
||||||
+4
-17
@@ -27,7 +27,6 @@
|
|||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "hwconfig.h"
|
|
||||||
#include "system_monitor.h"
|
#include "system_monitor.h"
|
||||||
#include "config/app_config.h"
|
#include "config/app_config.h"
|
||||||
#include "dev_profile/dev_profile.h"
|
#include "dev_profile/dev_profile.h"
|
||||||
@@ -92,10 +91,10 @@ static PHY_CONFIG phyConfig = {
|
|||||||
.txBramId = PHY_TXBUFF_BRAM_DEVICE_ID,
|
.txBramId = PHY_TXBUFF_BRAM_DEVICE_ID,
|
||||||
.rxBramId = PHY_RXBUFF_BRAM_DEVICE_ID,
|
.rxBramId = PHY_RXBUFF_BRAM_DEVICE_ID,
|
||||||
.hwXadcId = PHY_HW_XADC_DEVICE_ID,
|
.hwXadcId = PHY_HW_XADC_DEVICE_ID,
|
||||||
.get_clk_state = Hardware_GetHMC7044LockStatus,
|
.get_clk_state = NULL,
|
||||||
.get_ad_lock_state = Hardware_GetAD9361LockStatus,
|
.get_ad_lock_state = NULL,
|
||||||
.get_ad0_temp = Hardware_GetAD9361Temp_1,
|
.get_ad0_temp = NULL,
|
||||||
.get_ad1_temp = Hardware_GetAD9361Temp_2
|
.get_ad1_temp = NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
TMC_CONFIG tmcConfig = {
|
TMC_CONFIG tmcConfig = {
|
||||||
@@ -365,18 +364,6 @@ int main(void)
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Hardware Initialize */
|
|
||||||
Status = Hardware_Init();
|
|
||||||
if (Status == SUCCESS)
|
|
||||||
{
|
|
||||||
DBG_PRINT("Hardware Init SUCCESS! \n");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DBG_PRINT("Hardware Init FAILED! \n");
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Time controller Initialize */
|
/* Time controller Initialize */
|
||||||
Status = TimeCtrl_Init(&tmcInstPtr, &tmcConfig);
|
Status = TimeCtrl_Init(&tmcInstPtr, &tmcConfig);
|
||||||
if (Status == SUCCESS)
|
if (Status == SUCCESS)
|
||||||
|
|||||||
Reference in New Issue
Block a user