PageRenderTime 61ms CodeModel.GetById 39ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/staging/iio/adc/ad799x.h

https://bitbucket.org/wisechild/galaxy-nexus
C++ Header | 147 lines | 93 code | 22 blank | 32 comment | 0 complexity | e23c2ee9f5601d4d207882740d94946c MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.0, AGPL-1.0
  1. /*
  2. * Copyright (C) 2010-2011 Michael Hennerich, Analog Devices Inc.
  3. * Copyright (C) 2008-2010 Jonathan Cameron
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * ad799x.h
  10. */
  11. #ifndef _AD799X_H_
  12. #define _AD799X_H_
  13. #define AD799X_CHANNEL_SHIFT 4
  14. #define AD799X_STORAGEBITS 16
  15. /*
  16. * AD7991, AD7995 and AD7999 defines
  17. */
  18. #define AD7991_REF_SEL 0x08
  19. #define AD7991_FLTR 0x04
  20. #define AD7991_BIT_TRIAL_DELAY 0x02
  21. #define AD7991_SAMPLE_DELAY 0x01
  22. /*
  23. * AD7992, AD7993, AD7994, AD7997 and AD7998 defines
  24. */
  25. #define AD7998_FLTR 0x08
  26. #define AD7998_ALERT_EN 0x04
  27. #define AD7998_BUSY_ALERT 0x02
  28. #define AD7998_BUSY_ALERT_POL 0x01
  29. #define AD7998_CONV_RES_REG 0x0
  30. #define AD7998_ALERT_STAT_REG 0x1
  31. #define AD7998_CONF_REG 0x2
  32. #define AD7998_CYCLE_TMR_REG 0x3
  33. #define AD7998_DATALOW_CH1_REG 0x4
  34. #define AD7998_DATAHIGH_CH1_REG 0x5
  35. #define AD7998_HYST_CH1_REG 0x6
  36. #define AD7998_DATALOW_CH2_REG 0x7
  37. #define AD7998_DATAHIGH_CH2_REG 0x8
  38. #define AD7998_HYST_CH2_REG 0x9
  39. #define AD7998_DATALOW_CH3_REG 0xA
  40. #define AD7998_DATAHIGH_CH3_REG 0xB
  41. #define AD7998_HYST_CH3_REG 0xC
  42. #define AD7998_DATALOW_CH4_REG 0xD
  43. #define AD7998_DATAHIGH_CH4_REG 0xE
  44. #define AD7998_HYST_CH4_REG 0xF
  45. #define AD7998_CYC_MASK 0x7
  46. #define AD7998_CYC_DIS 0x0
  47. #define AD7998_CYC_TCONF_32 0x1
  48. #define AD7998_CYC_TCONF_64 0x2
  49. #define AD7998_CYC_TCONF_128 0x3
  50. #define AD7998_CYC_TCONF_256 0x4
  51. #define AD7998_CYC_TCONF_512 0x5
  52. #define AD7998_CYC_TCONF_1024 0x6
  53. #define AD7998_CYC_TCONF_2048 0x7
  54. #define AD7998_ALERT_STAT_CLEAR 0xFF
  55. /*
  56. * AD7997 and AD7997 defines
  57. */
  58. #define AD7997_8_READ_SINGLE 0x80
  59. #define AD7997_8_READ_SEQUENCE 0x70
  60. /* TODO: move this into a common header */
  61. #define RES_MASK(bits) ((1 << (bits)) - 1)
  62. enum {
  63. ad7991,
  64. ad7995,
  65. ad7999,
  66. ad7992,
  67. ad7993,
  68. ad7994,
  69. ad7997,
  70. ad7998
  71. };
  72. struct ad799x_state;
  73. /**
  74. * struct ad799x_chip_info - chip specifc information
  75. * @channel: channel specification
  76. * @num_channels: number of channels
  77. * @int_vref_mv: the internal reference voltage
  78. * @monitor_mode: whether the chip supports monitor interrupts
  79. * @default_config: device default configuration
  80. * @event_attrs: pointer to the monitor event attribute group
  81. */
  82. struct ad799x_chip_info {
  83. struct iio_chan_spec channel[9];
  84. int num_channels;
  85. u16 int_vref_mv;
  86. u16 default_config;
  87. const struct iio_info *info;
  88. };
  89. struct ad799x_state {
  90. struct i2c_client *client;
  91. const struct ad799x_chip_info *chip_info;
  92. size_t d_size;
  93. struct iio_trigger *trig;
  94. struct regulator *reg;
  95. u16 int_vref_mv;
  96. unsigned id;
  97. char *name;
  98. u16 config;
  99. };
  100. /*
  101. * TODO: struct ad799x_platform_data needs to go into include/linux/iio
  102. */
  103. struct ad799x_platform_data {
  104. u16 vref_mv;
  105. };
  106. int ad7997_8_set_scan_mode(struct ad799x_state *st, unsigned mask);
  107. #ifdef CONFIG_AD799X_RING_BUFFER
  108. int ad799x_single_channel_from_ring(struct ad799x_state *st, long mask);
  109. int ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev);
  110. void ad799x_ring_cleanup(struct iio_dev *indio_dev);
  111. #else /* CONFIG_AD799X_RING_BUFFER */
  112. int ad799x_single_channel_from_ring(struct ad799x_state *st, long mask)
  113. {
  114. return -EINVAL;
  115. }
  116. static inline int
  117. ad799x_register_ring_funcs_and_init(struct iio_dev *indio_dev)
  118. {
  119. return 0;
  120. }
  121. static inline void ad799x_ring_cleanup(struct iio_dev *indio_dev)
  122. {
  123. }
  124. #endif /* CONFIG_AD799X_RING_BUFFER */
  125. #endif /* _AD799X_H_ */