ad9523.h 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * AD9523 SPI Low Jitter Clock Generator
  3. *
  4. * Copyright 2012 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2.
  7. */
  8. #ifndef IIO_FREQUENCY_AD9523_H_
  9. #define IIO_FREQUENCY_AD9523_H_
  10. enum outp_drv_mode {
  11. TRISTATE,
  12. LVPECL_8mA,
  13. LVDS_4mA,
  14. LVDS_7mA,
  15. HSTL0_16mA,
  16. HSTL1_8mA,
  17. CMOS_CONF1,
  18. CMOS_CONF2,
  19. CMOS_CONF3,
  20. CMOS_CONF4,
  21. CMOS_CONF5,
  22. CMOS_CONF6,
  23. CMOS_CONF7,
  24. CMOS_CONF8,
  25. CMOS_CONF9
  26. };
  27. enum ref_sel_mode {
  28. NONEREVERTIVE_STAY_ON_REFB,
  29. REVERT_TO_REFA,
  30. SELECT_REFA,
  31. SELECT_REFB,
  32. EXT_REF_SEL
  33. };
  34. /**
  35. * struct ad9523_channel_spec - Output channel configuration
  36. *
  37. * @channel_num: Output channel number.
  38. * @divider_output_invert_en: Invert the polarity of the output clock.
  39. * @sync_ignore_en: Ignore chip-level SYNC signal.
  40. * @low_power_mode_en: Reduce power used in the differential output modes.
  41. * @use_alt_clock_src: Channel divider uses alternative clk source.
  42. * @output_dis: Disables, powers down the entire channel.
  43. * @driver_mode: Output driver mode (logic level family).
  44. * @divider_phase: Divider initial phase after a SYNC. Range 0..63
  45. LSB = 1/2 of a period of the divider input clock.
  46. * @channel_divider: 10-bit channel divider.
  47. * @extended_name: Optional descriptive channel name.
  48. */
  49. struct ad9523_channel_spec {
  50. unsigned channel_num;
  51. bool divider_output_invert_en;
  52. bool sync_ignore_en;
  53. bool low_power_mode_en;
  54. /* CH0..CH3 VCXO, CH4..CH9 VCO2 */
  55. bool use_alt_clock_src;
  56. bool output_dis;
  57. enum outp_drv_mode driver_mode;
  58. unsigned char divider_phase;
  59. unsigned short channel_divider;
  60. char extended_name[16];
  61. };
  62. enum pll1_rzero_resistor {
  63. RZERO_883_OHM,
  64. RZERO_677_OHM,
  65. RZERO_341_OHM,
  66. RZERO_135_OHM,
  67. RZERO_10_OHM,
  68. RZERO_USE_EXT_RES = 8,
  69. };
  70. enum rpole2_resistor {
  71. RPOLE2_900_OHM,
  72. RPOLE2_450_OHM,
  73. RPOLE2_300_OHM,
  74. RPOLE2_225_OHM,
  75. };
  76. enum rzero_resistor {
  77. RZERO_3250_OHM,
  78. RZERO_2750_OHM,
  79. RZERO_2250_OHM,
  80. RZERO_2100_OHM,
  81. RZERO_3000_OHM,
  82. RZERO_2500_OHM,
  83. RZERO_2000_OHM,
  84. RZERO_1850_OHM,
  85. };
  86. enum cpole1_capacitor {
  87. CPOLE1_0_PF,
  88. CPOLE1_8_PF,
  89. CPOLE1_16_PF,
  90. CPOLE1_24_PF,
  91. _CPOLE1_24_PF, /* place holder */
  92. CPOLE1_32_PF,
  93. CPOLE1_40_PF,
  94. CPOLE1_48_PF,
  95. };
  96. /**
  97. * struct ad9523_platform_data - platform specific information
  98. *
  99. * @vcxo_freq: External VCXO frequency in Hz
  100. * @refa_diff_rcv_en: REFA differential/single-ended input selection.
  101. * @refb_diff_rcv_en: REFB differential/single-ended input selection.
  102. * @zd_in_diff_en: Zero Delay differential/single-ended input selection.
  103. * @osc_in_diff_en: OSC differential/ single-ended input selection.
  104. * @refa_cmos_neg_inp_en: REFA single-ended neg./pos. input enable.
  105. * @refb_cmos_neg_inp_en: REFB single-ended neg./pos. input enable.
  106. * @zd_in_cmos_neg_inp_en: Zero Delay single-ended neg./pos. input enable.
  107. * @osc_in_cmos_neg_inp_en: OSC single-ended neg./pos. input enable.
  108. * @refa_r_div: PLL1 10-bit REFA R divider.
  109. * @refb_r_div: PLL1 10-bit REFB R divider.
  110. * @pll1_feedback_div: PLL1 10-bit Feedback N divider.
  111. * @pll1_charge_pump_current_nA: Magnitude of PLL1 charge pump current (nA).
  112. * @zero_delay_mode_internal_en: Internal, external Zero Delay mode selection.
  113. * @osc_in_feedback_en: PLL1 feedback path, local feedback from
  114. * the OSC_IN receiver or zero delay mode
  115. * @pll1_loop_filter_rzero: PLL1 Loop Filter Zero Resistor selection.
  116. * @ref_mode: Reference selection mode.
  117. * @pll2_charge_pump_current_nA: Magnitude of PLL2 charge pump current (nA).
  118. * @pll2_ndiv_a_cnt: PLL2 Feedback N-divider, A Counter, range 0..4.
  119. * @pll2_ndiv_b_cnt: PLL2 Feedback N-divider, B Counter, range 0..63.
  120. * @pll2_freq_doubler_en: PLL2 frequency doubler enable.
  121. * @pll2_r2_div: PLL2 R2 divider, range 0..31.
  122. * @pll2_vco_diff_m1: VCO1 divider, range 3..5.
  123. * @pll2_vco_diff_m2: VCO2 divider, range 3..5.
  124. * @rpole2: PLL2 loop filter Rpole resistor value.
  125. * @rzero: PLL2 loop filter Rzero resistor value.
  126. * @cpole1: PLL2 loop filter Cpole capacitor value.
  127. * @rzero_bypass_en: PLL2 loop filter Rzero bypass enable.
  128. * @num_channels: Array size of struct ad9523_channel_spec.
  129. * @channels: Pointer to channel array.
  130. * @name: Optional alternative iio device name.
  131. */
  132. struct ad9523_platform_data {
  133. unsigned long vcxo_freq;
  134. /* Differential/ Single-Ended Input Configuration */
  135. bool refa_diff_rcv_en;
  136. bool refb_diff_rcv_en;
  137. bool zd_in_diff_en;
  138. bool osc_in_diff_en;
  139. /*
  140. * Valid if differential input disabled
  141. * if false defaults to pos input
  142. */
  143. bool refa_cmos_neg_inp_en;
  144. bool refb_cmos_neg_inp_en;
  145. bool zd_in_cmos_neg_inp_en;
  146. bool osc_in_cmos_neg_inp_en;
  147. /* PLL1 Setting */
  148. unsigned short refa_r_div;
  149. unsigned short refb_r_div;
  150. unsigned short pll1_feedback_div;
  151. unsigned short pll1_charge_pump_current_nA;
  152. bool zero_delay_mode_internal_en;
  153. bool osc_in_feedback_en;
  154. enum pll1_rzero_resistor pll1_loop_filter_rzero;
  155. /* Reference */
  156. enum ref_sel_mode ref_mode;
  157. /* PLL2 Setting */
  158. unsigned int pll2_charge_pump_current_nA;
  159. unsigned char pll2_ndiv_a_cnt;
  160. unsigned char pll2_ndiv_b_cnt;
  161. bool pll2_freq_doubler_en;
  162. unsigned char pll2_r2_div;
  163. unsigned char pll2_vco_diff_m1; /* 3..5 */
  164. unsigned char pll2_vco_diff_m2; /* 3..5 */
  165. /* Loop Filter PLL2 */
  166. enum rpole2_resistor rpole2;
  167. enum rzero_resistor rzero;
  168. enum cpole1_capacitor cpole1;
  169. bool rzero_bypass_en;
  170. /* Output Channel Configuration */
  171. int num_channels;
  172. struct ad9523_channel_spec *channels;
  173. char name[SPI_NAME_SIZE];
  174. };
  175. #endif /* IIO_FREQUENCY_AD9523_H_ */