PageRenderTime 24ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/drivers/staging/iio/dds/ad9832.h

https://bitbucket.org/wisechild/galaxy-nexus
C++ Header | 128 lines | 71 code | 12 blank | 45 comment | 0 complexity | 426f418a71b9bfa17f82c685b9b5a945 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /*
  2. * AD9832 SPI DDS driver
  3. *
  4. * Copyright 2011 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #ifndef IIO_DDS_AD9832_H_
  9. #define IIO_DDS_AD9832_H_
  10. /* Registers */
  11. #define AD9832_FREQ0LL 0x0
  12. #define AD9832_FREQ0HL 0x1
  13. #define AD9832_FREQ0LM 0x2
  14. #define AD9832_FREQ0HM 0x3
  15. #define AD9832_FREQ1LL 0x4
  16. #define AD9832_FREQ1HL 0x5
  17. #define AD9832_FREQ1LM 0x6
  18. #define AD9832_FREQ1HM 0x7
  19. #define AD9832_PHASE0L 0x8
  20. #define AD9832_PHASE0H 0x9
  21. #define AD9832_PHASE1L 0xA
  22. #define AD9832_PHASE1H 0xB
  23. #define AD9832_PHASE2L 0xC
  24. #define AD9832_PHASE2H 0xD
  25. #define AD9832_PHASE3L 0xE
  26. #define AD9832_PHASE3H 0xF
  27. #define AD9832_PHASE_SYM 0x10
  28. #define AD9832_FREQ_SYM 0x11
  29. #define AD9832_PINCTRL_EN 0x12
  30. #define AD9832_OUTPUT_EN 0x13
  31. /* Command Control Bits */
  32. #define AD9832_CMD_PHA8BITSW 0x1
  33. #define AD9832_CMD_PHA16BITSW 0x0
  34. #define AD9832_CMD_FRE8BITSW 0x3
  35. #define AD9832_CMD_FRE16BITSW 0x2
  36. #define AD9832_CMD_FPSELECT 0x6
  37. #define AD9832_CMD_SYNCSELSRC 0x8
  38. #define AD9832_CMD_SLEEPRESCLR 0xC
  39. #define AD9832_FREQ (1 << 11)
  40. #define AD9832_PHASE(x) (((x) & 3) << 9)
  41. #define AD9832_SYNC (1 << 13)
  42. #define AD9832_SELSRC (1 << 12)
  43. #define AD9832_SLEEP (1 << 13)
  44. #define AD9832_RESET (1 << 12)
  45. #define AD9832_CLR (1 << 11)
  46. #define CMD_SHIFT 12
  47. #define ADD_SHIFT 8
  48. #define AD9832_FREQ_BITS 32
  49. #define AD9832_PHASE_BITS 12
  50. #define RES_MASK(bits) ((1 << (bits)) - 1)
  51. /**
  52. * struct ad9832_state - driver instance specific data
  53. * @indio_dev: the industrial I/O device
  54. * @spi: spi_device
  55. * @reg: supply regulator
  56. * @mclk: external master clock
  57. * @ctrl_fp: cached frequency/phase control word
  58. * @ctrl_ss: cached sync/selsrc control word
  59. * @ctrl_src: cached sleep/reset/clr word
  60. * @xfer: default spi transfer
  61. * @msg: default spi message
  62. * @freq_xfer: tuning word spi transfer
  63. * @freq_msg: tuning word spi message
  64. * @phase_xfer: tuning word spi transfer
  65. * @phase_msg: tuning word spi message
  66. * @data: spi transmit buffer
  67. * @phase_data: tuning word spi transmit buffer
  68. * @freq_data: tuning word spi transmit buffer
  69. */
  70. struct ad9832_state {
  71. struct iio_dev *indio_dev;
  72. struct spi_device *spi;
  73. struct regulator *reg;
  74. unsigned long mclk;
  75. unsigned short ctrl_fp;
  76. unsigned short ctrl_ss;
  77. unsigned short ctrl_src;
  78. struct spi_transfer xfer;
  79. struct spi_message msg;
  80. struct spi_transfer freq_xfer[4];
  81. struct spi_message freq_msg;
  82. struct spi_transfer phase_xfer[2];
  83. struct spi_message phase_msg;
  84. /*
  85. * DMA (thus cache coherency maintenance) requires the
  86. * transfer buffers to live in their own cache lines.
  87. */
  88. union {
  89. unsigned short freq_data[4]____cacheline_aligned;
  90. unsigned short phase_data[2];
  91. unsigned short data;
  92. };
  93. };
  94. /*
  95. * TODO: struct ad9832_platform_data needs to go into include/linux/iio
  96. */
  97. /**
  98. * struct ad9832_platform_data - platform specific information
  99. * @mclk: master clock in Hz
  100. * @freq0: power up freq0 tuning word in Hz
  101. * @freq1: power up freq1 tuning word in Hz
  102. * @phase0: power up phase0 value [0..4095] correlates with 0..2PI
  103. * @phase1: power up phase1 value [0..4095] correlates with 0..2PI
  104. * @phase2: power up phase2 value [0..4095] correlates with 0..2PI
  105. * @phase3: power up phase3 value [0..4095] correlates with 0..2PI
  106. */
  107. struct ad9832_platform_data {
  108. unsigned long mclk;
  109. unsigned long freq0;
  110. unsigned long freq1;
  111. unsigned short phase0;
  112. unsigned short phase1;
  113. unsigned short phase2;
  114. unsigned short phase3;
  115. };
  116. #endif /* IIO_DDS_AD9832_H_ */