adf4350.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*
  2. * ADF4350/ADF4351 SPI PLL driver
  3. *
  4. * Copyright 2012-2013 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2.
  7. */
  8. #ifndef IIO_PLL_ADF4350_H_
  9. #define IIO_PLL_ADF4350_H_
  10. /* Registers */
  11. #define ADF4350_REG0 0
  12. #define ADF4350_REG1 1
  13. #define ADF4350_REG2 2
  14. #define ADF4350_REG3 3
  15. #define ADF4350_REG4 4
  16. #define ADF4350_REG5 5
  17. /* REG0 Bit Definitions */
  18. #define ADF4350_REG0_FRACT(x) (((x) & 0xFFF) << 3)
  19. #define ADF4350_REG0_INT(x) (((x) & 0xFFFF) << 15)
  20. /* REG1 Bit Definitions */
  21. #define ADF4350_REG1_MOD(x) (((x) & 0xFFF) << 3)
  22. #define ADF4350_REG1_PHASE(x) (((x) & 0xFFF) << 15)
  23. #define ADF4350_REG1_PRESCALER (1 << 27)
  24. /* REG2 Bit Definitions */
  25. #define ADF4350_REG2_COUNTER_RESET_EN (1 << 3)
  26. #define ADF4350_REG2_CP_THREESTATE_EN (1 << 4)
  27. #define ADF4350_REG2_POWER_DOWN_EN (1 << 5)
  28. #define ADF4350_REG2_PD_POLARITY_POS (1 << 6)
  29. #define ADF4350_REG2_LDP_6ns (1 << 7)
  30. #define ADF4350_REG2_LDP_10ns (0 << 7)
  31. #define ADF4350_REG2_LDF_FRACT_N (0 << 8)
  32. #define ADF4350_REG2_LDF_INT_N (1 << 8)
  33. #define ADF4350_REG2_CHARGE_PUMP_CURR_uA(x) (((((x)-312) / 312) & 0xF) << 9)
  34. #define ADF4350_REG2_DOUBLE_BUFF_EN (1 << 13)
  35. #define ADF4350_REG2_10BIT_R_CNT(x) ((x) << 14)
  36. #define ADF4350_REG2_RDIV2_EN (1 << 24)
  37. #define ADF4350_REG2_RMULT2_EN (1 << 25)
  38. #define ADF4350_REG2_MUXOUT(x) ((x) << 26)
  39. #define ADF4350_REG2_NOISE_MODE(x) (((unsigned)(x)) << 29)
  40. #define ADF4350_MUXOUT_THREESTATE 0
  41. #define ADF4350_MUXOUT_DVDD 1
  42. #define ADF4350_MUXOUT_GND 2
  43. #define ADF4350_MUXOUT_R_DIV_OUT 3
  44. #define ADF4350_MUXOUT_N_DIV_OUT 4
  45. #define ADF4350_MUXOUT_ANALOG_LOCK_DETECT 5
  46. #define ADF4350_MUXOUT_DIGITAL_LOCK_DETECT 6
  47. /* REG3 Bit Definitions */
  48. #define ADF4350_REG3_12BIT_CLKDIV(x) ((x) << 3)
  49. #define ADF4350_REG3_12BIT_CLKDIV_MODE(x) ((x) << 16)
  50. #define ADF4350_REG3_12BIT_CSR_EN (1 << 18)
  51. #define ADF4351_REG3_CHARGE_CANCELLATION_EN (1 << 21)
  52. #define ADF4351_REG3_ANTI_BACKLASH_3ns_EN (1 << 22)
  53. #define ADF4351_REG3_BAND_SEL_CLOCK_MODE_HIGH (1 << 23)
  54. /* REG4 Bit Definitions */
  55. #define ADF4350_REG4_OUTPUT_PWR(x) ((x) << 3)
  56. #define ADF4350_REG4_RF_OUT_EN (1 << 5)
  57. #define ADF4350_REG4_AUX_OUTPUT_PWR(x) ((x) << 6)
  58. #define ADF4350_REG4_AUX_OUTPUT_EN (1 << 8)
  59. #define ADF4350_REG4_AUX_OUTPUT_FUND (1 << 9)
  60. #define ADF4350_REG4_AUX_OUTPUT_DIV (0 << 9)
  61. #define ADF4350_REG4_MUTE_TILL_LOCK_EN (1 << 10)
  62. #define ADF4350_REG4_VCO_PWRDOWN_EN (1 << 11)
  63. #define ADF4350_REG4_8BIT_BAND_SEL_CLKDIV(x) ((x) << 12)
  64. #define ADF4350_REG4_RF_DIV_SEL(x) ((x) << 20)
  65. #define ADF4350_REG4_FEEDBACK_DIVIDED (0 << 23)
  66. #define ADF4350_REG4_FEEDBACK_FUND (1 << 23)
  67. /* REG5 Bit Definitions */
  68. #define ADF4350_REG5_LD_PIN_MODE_LOW (0 << 22)
  69. #define ADF4350_REG5_LD_PIN_MODE_DIGITAL (1 << 22)
  70. #define ADF4350_REG5_LD_PIN_MODE_HIGH (3 << 22)
  71. /* Specifications */
  72. #define ADF4350_MAX_OUT_FREQ 4400000000ULL /* Hz */
  73. #define ADF4350_MIN_OUT_FREQ 137500000 /* Hz */
  74. #define ADF4351_MIN_OUT_FREQ 34375000 /* Hz */
  75. #define ADF4350_MIN_VCO_FREQ 2200000000ULL /* Hz */
  76. #define ADF4350_MAX_FREQ_45_PRESC 3000000000ULL /* Hz */
  77. #define ADF4350_MAX_FREQ_PFD 32000000 /* Hz */
  78. #define ADF4350_MAX_BANDSEL_CLK 125000 /* Hz */
  79. #define ADF4350_MAX_FREQ_REFIN 250000000 /* Hz */
  80. #define ADF4350_MAX_MODULUS 4095
  81. #define ADF4350_MAX_R_CNT 1023
  82. /**
  83. * struct adf4350_platform_data - platform specific information
  84. * @name: Optional device name.
  85. * @clkin: REFin frequency in Hz.
  86. * @channel_spacing: Channel spacing in Hz (influences MODULUS).
  87. * @power_up_frequency: Optional, If set in Hz the PLL tunes to the desired
  88. * frequency on probe.
  89. * @ref_div_factor: Optional, if set the driver skips dynamic calculation
  90. * and uses this default value instead.
  91. * @ref_doubler_en: Enables reference doubler.
  92. * @ref_div2_en: Enables reference divider.
  93. * @r2_user_settings: User defined settings for ADF4350/1 REGISTER_2.
  94. * @r3_user_settings: User defined settings for ADF4350/1 REGISTER_3.
  95. * @r4_user_settings: User defined settings for ADF4350/1 REGISTER_4.
  96. * @gpio_lock_detect: Optional, if set with a valid GPIO number,
  97. * pll lock state is tested upon read.
  98. * If not used - set to -1.
  99. */
  100. struct adf4350_platform_data {
  101. char name[32];
  102. unsigned long clkin;
  103. unsigned long channel_spacing;
  104. unsigned long long power_up_frequency;
  105. unsigned short ref_div_factor; /* 10-bit R counter */
  106. bool ref_doubler_en;
  107. bool ref_div2_en;
  108. unsigned r2_user_settings;
  109. unsigned r3_user_settings;
  110. unsigned r4_user_settings;
  111. int gpio_lock_detect;
  112. };
  113. #endif /* IIO_PLL_ADF4350_H_ */