ad5446.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * AD5446 SPI DAC driver
  3. *
  4. * Copyright 2010 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #ifndef IIO_DAC_AD5446_H_
  9. #define IIO_DAC_AD5446_H_
  10. /* DAC Control Bits */
  11. #define AD5446_LOAD (0x0 << 14) /* Load and update */
  12. #define AD5446_SDO_DIS (0x1 << 14) /* Disable SDO */
  13. #define AD5446_NOP (0x2 << 14) /* No operation */
  14. #define AD5446_CLK_RISING (0x3 << 14) /* Clock data on rising edge */
  15. #define AD5620_LOAD (0x0 << 14) /* Load and update Norm Operation*/
  16. #define AD5620_PWRDWN_1k (0x1 << 14) /* Power-down: 1kOhm to GND */
  17. #define AD5620_PWRDWN_100k (0x2 << 14) /* Power-down: 100kOhm to GND */
  18. #define AD5620_PWRDWN_TRISTATE (0x3 << 14) /* Power-down: Three-state */
  19. #define AD5660_LOAD (0x0 << 16) /* Load and update Norm Operation*/
  20. #define AD5660_PWRDWN_1k (0x1 << 16) /* Power-down: 1kOhm to GND */
  21. #define AD5660_PWRDWN_100k (0x2 << 16) /* Power-down: 100kOhm to GND */
  22. #define AD5660_PWRDWN_TRISTATE (0x3 << 16) /* Power-down: Three-state */
  23. #define MODE_PWRDWN_1k 0x1
  24. #define MODE_PWRDWN_100k 0x2
  25. #define MODE_PWRDWN_TRISTATE 0x3
  26. /**
  27. * struct ad5446_state - driver instance specific data
  28. * @spi: spi_device
  29. * @chip_info: chip model specific constants, available modes etc
  30. * @reg: supply regulator
  31. * @vref_mv: actual reference voltage used
  32. */
  33. struct ad5446_state {
  34. struct spi_device *spi;
  35. const struct ad5446_chip_info *chip_info;
  36. struct regulator *reg;
  37. unsigned short vref_mv;
  38. unsigned cached_val;
  39. unsigned pwr_down_mode;
  40. unsigned pwr_down;
  41. };
  42. /**
  43. * struct ad5446_chip_info - chip specific information
  44. * @channel: channel spec for the DAC
  45. * @int_vref_mv: AD5620/40/60: the internal reference voltage
  46. * @write: chip specific helper function to write to the register
  47. */
  48. struct ad5446_chip_info {
  49. struct iio_chan_spec channel;
  50. u16 int_vref_mv;
  51. int (*write)(struct ad5446_state *st, unsigned val);
  52. };
  53. /**
  54. * ad5446_supported_device_ids:
  55. * The AD5620/40/60 parts are available in different fixed internal reference
  56. * voltage options. The actual part numbers may look differently
  57. * (and a bit cryptic), however this style is used to make clear which
  58. * parts are supported here.
  59. */
  60. enum ad5446_supported_device_ids {
  61. ID_AD5444,
  62. ID_AD5446,
  63. ID_AD5450,
  64. ID_AD5451,
  65. ID_AD5541A,
  66. ID_AD5512A,
  67. ID_AD5553,
  68. ID_AD5601,
  69. ID_AD5611,
  70. ID_AD5621,
  71. ID_AD5620_2500,
  72. ID_AD5620_1250,
  73. ID_AD5640_2500,
  74. ID_AD5640_1250,
  75. ID_AD5660_2500,
  76. ID_AD5660_1250,
  77. ID_AD5662,
  78. };
  79. #endif /* IIO_DAC_AD5446_H_ */