drv_adc.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /* Copyright (C) 2018 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _DRV_ADC_H_
  13. #define _DRV_ADC_H_
  14. #define ADC_CHANNEL_INVALID -1
  15. enum adc_aux_scale
  16. {
  17. ADC_SCALE_0 = 0, ///< scale0:8910 1v250/8811 1v250
  18. ADC_SCALE_1 = 1, ///< scale1:8910 2v444/8811 1v600
  19. ADC_SCALE_2 = 2, ///< scale2:8910 3v233/8811 2v800
  20. ADC_SCALE_3 = 3, ///< scale3:8910 5v000/8811 5v000
  21. ADC_SCALE_MAX = 3,
  22. };
  23. enum adc_aux_channel
  24. {
  25. ADC_CHANNEL_BAT_DET = 0,
  26. ADC_CHANNEL_1 = 1,
  27. ADC_CHANNEL_2 = 2,
  28. ADC_CHANNEL_3 = 3,
  29. ADC_CHANNEL_4 = 4,
  30. ADC_CHANNEL_VBATSENSE = 5,
  31. ADC_CHANNEL_6 = 6, //no use
  32. ADC_CHANNEL_TYPEC_CC1 = 7,
  33. ADC_CHANNEL_THM = 8,
  34. ADC_CHANNEL_TYPEC_CC2 = 9,
  35. ADC_CHANNEL_10 = 10, //no use
  36. ADC_CHANNEL_11 = 11, //8850 for bat sense
  37. ADC_CHANNEL_12 = 12, //no use
  38. ADC_CHANNEL_DCDC_CALOUT = 13,
  39. ADC_CHANNEL_VCHGSEN = 14,
  40. ADC_CHANNEL_VCHG_BG = 15,
  41. ADC_CHANNEL_PROG2ADC = 16,
  42. ADC_CHANNEL_17 = 17,
  43. ADC_CHANNEL_18 = 18,
  44. ADC_CHANNEL_SDAVDD = 19,
  45. ADC_CHANNEL_HEADMIC = 20,
  46. ADC_CHANNEL_LDO_CALOUT0 = 21,
  47. ADC_CHANNEL_LDO_CALOUT1 = 22,
  48. ADC_CHANNEL_LDO_CALOUT2 = 23,
  49. ADC_CHANNEL_24 = 24, //no use
  50. ADC_CHANNEL_25 = 25, //no use
  51. ADC_CHANNEL_26 = 26, //no use
  52. ADC_CHANNEL_27 = 27, //no use
  53. ADC_CHANNEL_28 = 28, //no use
  54. ADC_CHANNEL_SELF_OFFSET_MEASURE = 29,
  55. ADC_CHANNEL_DP = 30,
  56. ADC_CHANNEL_DM = 31,
  57. ADC_CHANNEL_MAX = 31,
  58. };
  59. /**
  60. * @brief initialize ADC driver
  61. * it should be called after ADI bus is initialized.
  62. */
  63. void drvAdcInit(void);
  64. /**
  65. * @brief return the volt for the given channel in mV.
  66. *
  67. * @param channel set the channel to measue
  68. * @param scale set the scale of the channel
  69. * @return
  70. * -1 failure
  71. * the volt vlaue.
  72. */
  73. int32_t drvAdcGetChannelVolt(uint32_t channel, int32_t scale);
  74. /**
  75. * @brief return the raw adc value for the given channel.
  76. *
  77. * @param channel set the channel to measue
  78. * @param scale set the scale of the channel
  79. * @return
  80. * -1 failure
  81. * the raw vlaue.
  82. */
  83. int32_t drvAdcGetRawValue(uint32_t channel, int32_t scale);
  84. /**
  85. * @brief return the volt for the hmic channel in mV.
  86. *
  87. * @param scale set the scale of the hmic channel,default use ADC_SCALE_1V250
  88. * @param con_mode set the scale ratio of the channel,match with rg_aud_hedet_v2ad_scale
  89. * @return
  90. * -1 failure
  91. * the volt vlaue.
  92. */
  93. int32_t drvAdcGetHMicChannelVolt(int32_t scale, int32_t con_mode);
  94. /**
  95. * @brief return the tep from THM module.
  96. *
  97. * -1 failure
  98. * the volt vlaue.
  99. */
  100. #ifdef CONFIG_SOC_8811
  101. int32_t drvAdcGetTHM(void);
  102. #endif
  103. /**
  104. * @brief return the tep from THM module.
  105. *
  106. * the temperature vlaue of ADC_CHANNEL_12
  107. */
  108. #if defined(CONFIG_SOC_8850)
  109. int32_t drvAdcVoltToTemperature(int32_t volt, uint32_t adcChannel);
  110. #endif
  111. /**
  112. * @brief return the volt of auxadc for the given channel in mV.
  113. *
  114. * @param channel set the channel to measue
  115. * @param scale set the scale of the channel
  116. * @param reg
  117. * @return
  118. * -1 failure
  119. * the volt vlaue.
  120. */
  121. int32_t drvAuxAdcGetChannelVolt(uint32_t channel, int32_t scale, uint8_t reg);
  122. #endif /*__RDA_ADC_H__*/