battery_meter_hal.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. #ifndef _BATTERY_METER_HAL_H
  2. #define _BATTERY_METER_HAL_H
  3. /* ============================================================ */
  4. /* define */
  5. /* ============================================================ */
  6. #define BM_LOG_CRTI 7
  7. #define BM_LOG_FULL 8
  8. #define bm_print(num, fmt, args...) \
  9. do { \
  10. if (Enable_FGADC_LOG >= (int)num) { \
  11. pr_debug(fmt, ##args); \
  12. } \
  13. } while (0)
  14. #define BMLOG_ERROR_LEVEL 3
  15. #define BMLOG_WARNING_LEVEL 4
  16. #define BMLOG_NOTICE_LEVEL 5
  17. #define BMLOG_INFO_LEVEL 6
  18. #define BMLOG_DEBUG_LEVEL 7
  19. #define BMLOG_TRACE_LEVEL 8
  20. #define bm_err(fmt, args...) \
  21. do { \
  22. if (Enable_FGADC_LOG >= BMLOG_ERROR_LEVEL) { \
  23. pr_err(fmt, ##args); \
  24. } \
  25. } while (0)
  26. #define bm_warn(fmt, args...) \
  27. do { \
  28. if (Enable_FGADC_LOG >= BMLOG_WARNING_LEVEL) { \
  29. pr_warn(fmt, ##args); \
  30. } \
  31. } while (0)
  32. #define bm_notice(fmt, args...) \
  33. do { \
  34. if (Enable_FGADC_LOG >= BMLOG_NOTICE_LEVEL) { \
  35. pr_notice(fmt, ##args); \
  36. } \
  37. } while (0)
  38. #define bm_info(fmt, args...) \
  39. do { \
  40. if (Enable_FGADC_LOG >= BMLOG_INFO_LEVEL) { \
  41. pr_info(fmt, ##args); \
  42. } \
  43. } while (0)
  44. #define bm_debug(fmt, args...) \
  45. do { \
  46. if (Enable_FGADC_LOG >= BMLOG_DEBUG_LEVEL) { \
  47. pr_debug(fmt, ##args); \
  48. } \
  49. } while (0)
  50. #define bm_trace(fmt, args...)\
  51. do { \
  52. if (Enable_FGADC_LOG >= BMLOG_TRACE_LEVEL) { \
  53. pr_debug(fmt, ##args);\
  54. } \
  55. } while (0)
  56. #define BM_DAEMON_DEFAULT_LOG_LEVEL 3
  57. /* ============================================================ */
  58. /* ENUM */
  59. /* ============================================================ */
  60. typedef enum {
  61. BATTERY_METER_CMD_HW_FG_INIT,
  62. BATTERY_METER_CMD_GET_HW_FG_CURRENT, /* fgauge_read_current */
  63. BATTERY_METER_CMD_GET_HW_FG_CURRENT_SIGN, /* */
  64. BATTERY_METER_CMD_GET_HW_FG_CAR, /* fgauge_read_columb */
  65. BATTERY_METER_CMD_HW_RESET, /* FGADC_Reset_SW_Parameter */
  66. BATTERY_METER_CMD_GET_ADC_V_BAT_SENSE,
  67. BATTERY_METER_CMD_GET_ADC_V_I_SENSE,
  68. BATTERY_METER_CMD_GET_ADC_V_BAT_TEMP,
  69. BATTERY_METER_CMD_GET_ADC_V_CHARGER,
  70. BATTERY_METER_CMD_GET_HW_OCV,
  71. BATTERY_METER_CMD_DUMP_REGISTER,
  72. BATTERY_METER_CMD_SET_COLUMB_INTERRUPT,
  73. BATTERY_METER_CMD_GET_BATTERY_PLUG_STATUS,
  74. BATTERY_METER_CMD_GET_HW_FG_CAR_ACT, /* fgauge_read_columb */
  75. BATTERY_METER_CMD_SET_LOW_BAT_INTERRUPT,
  76. BATTERY_METER_CMD_GET_LOW_BAT_INTERRUPT_STATUS,
  77. BATTERY_METER_CMD_GET_REFRESH_HW_OCV,
  78. BATTERY_METER_CMD_GET_IS_HW_OCV_READY,
  79. BATTERY_METER_CMD_NUMBER
  80. } BATTERY_METER_CTRL_CMD;
  81. #ifndef BATTERY_BOOL
  82. #define BATTERY_BOOL
  83. typedef enum {
  84. KAL_FALSE = 0,
  85. KAL_TRUE = 1,
  86. } kal_bool;
  87. #endif
  88. /* ============================================================ */
  89. /* structure */
  90. /* ============================================================ */
  91. /* ============================================================ */
  92. /* typedef */
  93. /* ============================================================ */
  94. typedef signed int(*BATTERY_METER_CONTROL) (BATTERY_METER_CTRL_CMD cmd, void *data);
  95. /* ============================================================ */
  96. /* External Variables */
  97. /* ============================================================ */
  98. extern int Enable_FGADC_LOG;
  99. /* ============================================================ */
  100. /* External function */
  101. /* ============================================================ */
  102. extern signed int bm_ctrl_cmd(BATTERY_METER_CTRL_CMD cmd, void *data);
  103. extern signed int pmic_is_battery_plugout(void);
  104. #endif /* #ifndef _BATTERY_METER_HAL_H */