pmic8058-xoadc.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. * Qualcomm XOADC Driver header file
  13. */
  14. #ifndef _PMIC8058_XOADC_H_
  15. #define _PMIC8058_XOADC_H_
  16. #include <linux/kernel.h>
  17. #include <linux/list.h>
  18. #include <linux/workqueue.h>
  19. struct xoadc_conv_state {
  20. struct adc_conv_slot *context;
  21. struct list_head slots;
  22. struct mutex list_lock;
  23. };
  24. #define CHANNEL_VCOIN 0
  25. #define CHANNEL_VBAT 1
  26. #define CHANNEL_VCHG 2
  27. #define CHANNEL_CHG_MONITOR 3
  28. #define CHANNEL_VPH_PWR 4
  29. #define CHANNEL_MPP5 5
  30. #define CHANNEL_MPP6 6
  31. #define CHANNEL_MPP7 7
  32. #define CHANNEL_MPP8 8
  33. #define CHANNEL_MPP9 9
  34. #define CHANNEL_USB_VBUS 0Xa
  35. #define CHANNEL_DIE_TEMP 0Xb
  36. #define CHANNEL_INTERNAL 0xc
  37. #define CHANNEL_125V 0xd
  38. #define CHANNEL_INTERNAL_2 0Xe
  39. #define CHANNEL_MUXOFF 0xf
  40. #define XOADC_MPP_3 0x2
  41. #define XOADC_MPP_4 0X3
  42. #define XOADC_MPP_5 0x4
  43. #define XOADC_MPP_7 0x6
  44. #define XOADC_MPP_8 0x7
  45. #define XOADC_MPP_10 0X9
  46. #define XOADC_PMIC_0 0x0
  47. #define CHANNEL_ADC_625_MV 625
  48. struct xoadc_platform_data {
  49. struct adc_properties *xoadc_prop;
  50. u32 (*xoadc_setup) (void);
  51. void (*xoadc_shutdown) (void);
  52. void (*xoadc_mpp_config) (void);
  53. int (*xoadc_vreg_set) (int);
  54. int (*xoadc_vreg_setup) (void);
  55. void (*xoadc_vreg_shutdown) (void);
  56. u32 xoadc_num;
  57. u32 xoadc_wakeup;
  58. };
  59. #ifdef CONFIG_PMIC8058_XOADC
  60. int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance, int32_t *data);
  61. int32_t pm8058_xoadc_select_chan_and_start_conv(uint32_t adc_instance,
  62. struct adc_conv_slot *slot);
  63. void pm8058_xoadc_slot_request(uint32_t adc_instance,
  64. struct adc_conv_slot **slot);
  65. void pm8058_xoadc_restore_slot(uint32_t adc_instance,
  66. struct adc_conv_slot *slot);
  67. struct adc_properties *pm8058_xoadc_get_properties(uint32_t dev_instance);
  68. int32_t pm8058_xoadc_calibrate(uint32_t dev_instance,
  69. struct adc_conv_slot *slot, int * calib_status);
  70. int32_t pm8058_xoadc_registered(void);
  71. int32_t pm8058_xoadc_calib_device(uint32_t adc_instance);
  72. #else
  73. static inline int32_t pm8058_xoadc_read_adc_code(uint32_t adc_instance,
  74. int32_t *data)
  75. { return -ENXIO; }
  76. static inline int32_t pm8058_xoadc_select_chan_and_start_conv(
  77. uint32_t adc_instance, struct adc_conv_slot *slot)
  78. { return -ENXIO; }
  79. static inline void pm8058_xoadc_slot_request(uint32_t adc_instance,
  80. struct adc_conv_slot **slot)
  81. { return; }
  82. static inline void pm8058_xoadc_restore_slot(uint32_t adc_instance,
  83. struct adc_conv_slot *slot)
  84. { return; }
  85. static inline struct adc_properties *pm8058_xoadc_get_properties(
  86. uint32_t dev_instance)
  87. { return NULL; }
  88. static inline int32_t pm8058_xoadc_calibrate(uint32_t dev_instance,
  89. struct adc_conv_slot *slot, int *calib_status)
  90. { return -ENXIO; }
  91. static inline int32_t pm8058_xoadc_registered(void)
  92. { return -ENXIO; }
  93. static inline int32_t pm8058_xoadc_calib_device(uint32_t adc_instance)
  94. { return -ENXIO; }
  95. #endif
  96. #endif