drv_charger_monitor.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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_CHARGER_MON_H_
  13. #define _DRV_CHARGER_MON_H_
  14. #include <stdint.h>
  15. #include <stdbool.h>
  16. #include <stddef.h>
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #define CAL_TYPR_NO 0
  21. #define CAL_TYPE_NV 1
  22. #define CAL_TYPE_EFUSE 2
  23. #define CHARGER_CURRENT_300MA 300
  24. #define CHARGER_CURRENT_350MA 350
  25. #define CHARGER_CURRENT_400MA 400
  26. #define CHARGER_CURRENT_450MA 450
  27. #define CHARGER_CURRENT_500MA 500
  28. #define CHARGER_CURRENT_550MA 550
  29. #define CHARGER_CURRENT_600MA 600
  30. #define CHARGER_CURRENT_650MA 650
  31. #define CHARGER_CURRENT_700MA 700
  32. #define CHARGER_CURRENT_750MA 750
  33. #define CHARGER_CURRENT_800MA 800
  34. //#define CHARGER_CURRENT_850MA 850
  35. #define CHARGER_CURRENT_900MA 900
  36. //#define CHARGER_CURRENT_950MA 950
  37. #define CHARGER_CURRENT_1000MA 1000
  38. //#define CHARGER_CURRENT_1050MA 1050
  39. #define CHARGER_CURRENT_1100MA 1100
  40. #define CHARGER_CURRENT_1200MA 1200
  41. #define CHARGER_CURRENT_MAX 1300
  42. typedef struct
  43. {
  44. uint16_t warning_vol;
  45. uint16_t shutdown_vol;
  46. uint16_t deadline_vol;
  47. uint16_t warning_count;
  48. } chgDischarge_t;
  49. typedef enum
  50. {
  51. CHG_IDLE = 0,
  52. CHG_STARTING,
  53. CHG_CHARGING,
  54. CHG_PULSECHARGING,
  55. CHG_STOPPING
  56. } chgState_e;
  57. typedef enum
  58. {
  59. CHG_INVALIDREASON = 0,
  60. CHG_CHARGERUNPLUG = 1,
  61. CHG_TIMEOUT,
  62. CHG_VBATEND,
  63. CHG_CHARGEDONE,
  64. CHG_OVERVOLTAGE, //add by paul for charge:over voltage
  65. CHG_OVERTEMP,
  66. CHG_PESUDO_CHARGERUNPLUG
  67. } chgStopReason_e;
  68. typedef enum
  69. {
  70. CHG_VBAT_MONITOR_MSG = 1,
  71. CHG_CHARGER_MONITOR_MSG,
  72. CHG_CHARGER_PLUG_IN_MSG,
  73. CHG_CHARGER_PLUG_OUT_MSG,
  74. CHG_MODULE_RESET_MSG,
  75. CHG_CHARGER_PESUDO_PLUG_OUT_MSG,
  76. #ifdef BATTERY_DETECT_SUPPORT
  77. CHG_BATTERY_OFF_MSG,
  78. #endif
  79. CHG_IDLE_MSG,
  80. CHG_MAX_MSG
  81. } chgMsg_t;
  82. //
  83. //the param of the callback.
  84. // typedef void (* REG_CALLBACK) (uint32 id, uint32 argc, void *argv);
  85. // id : the id that provided when register.
  86. // argc : the event; one of CHR_SVR_MSG_SERVICE_E;
  87. // argv : capacity. you can convert to uint32,
  88. // The message notify to MMI
  89. typedef enum
  90. {
  91. // Charge message.
  92. CHR_CAP_IND = 0x1, // Notify the battery's capacity
  93. CHR_CHARGE_START_IND, // start the charge process.
  94. CHR_CHARGE_END_IND, // the charge ended.
  95. CHR_WARNING_IND, // the capacity is low, should charge.
  96. CHR_SHUTDOWN_IND, // the capacity is very low and must shutdown.
  97. #ifdef BATTERY_DETECT_SUPPORT
  98. CHR_BATTERY_OFF_IND, // the battery is off
  99. #endif
  100. CHR_CHARGE_FINISH, // the charge has been completed.
  101. CHR_CHARGE_DISCONNECT, // the charge be disconnect
  102. CHR_CHARGE_FAULT, // the charge fault, maybe the voltage of charge is too low.
  103. CHR_MSG_MAX_NUM
  104. } CHR_SVR_MSG_SERVICE_E;
  105. /*This enum defines the lowest switchover point between constant-current and
  106. constant-volatage.*/
  107. typedef enum CCtoCVSwitchoverPoint
  108. {
  109. CHG_SWITPOINT_LOWEST = 0x0F,
  110. CHG_SWITPOINT_1 = 0x0E,
  111. CHG_SWITPOINT_2 = 0x0D,
  112. CHG_SWITPOINT_3 = 0x0C,
  113. CHG_SWITPOINT_4 = 0x0B,
  114. CHG_SWITPOINT_5 = 0x0A,
  115. CHG_SWITPOINT_6 = 0x09,
  116. CHG_SWITPOINT_7 = 0x08,
  117. CHG_SWITPOINT_8 = 0x07,
  118. CHG_SWITPOINT_9 = 0x06,
  119. CHG_SWITPOINT_10 = 0x05,
  120. CHG_SWITPOINT_11 = 0x04,
  121. CHG_SWITPOINT_12 = 0x03,
  122. CHG_SWITPOINT_13 = 0x02,
  123. CHG_SWITPOINT_14 = 0x01,
  124. CHG_SWITPOINT_15 = 0x00,
  125. CHG_SWITPOINT_16 = 0x10,
  126. CHG_SWITPOINT_17 = 0x11,
  127. CHG_SWITPOINT_18 = 0x12,
  128. CHG_SWITPOINT_19 = 0x13,
  129. CHG_SWITPOINT_20 = 0x14,
  130. CHG_SWITPOINT_21 = 0x15,
  131. CHG_SWITPOINT_22 = 0x16,
  132. CHG_SWITPOINT_23 = 0x17,
  133. CHG_SWITPOINT_24 = 0x18,
  134. CHG_SWITPOINT_25 = 0x19,
  135. CHG_SWITPOINT_26 = 0x1A,
  136. CHG_SWITPOINT_27 = 0x1B,
  137. CHG_SWITPOINT_28 = 0x1C,
  138. CHG_SWITPOINT_29 = 0x1D,
  139. CHG_SWITPOINT_30 = 0x1E,
  140. CHG_SWITPOINT_HIGHEST = 0x1F
  141. } chgSwitPoiint_e;
  142. typedef enum
  143. {
  144. CHGMNG_ADP_UNKNOW,
  145. CHGMNG_ADP_STANDARD,
  146. CHGMNG_ADP_NONSTANDARD,
  147. CHGMNG_ADP_USB,
  148. } chgAdapterType_e;
  149. typedef struct
  150. {
  151. uint16_t warning_vol;
  152. uint16_t shutdown_vol;
  153. uint16_t deadline_vol;
  154. uint16_t warning_count;
  155. } chgDisChargeParam_t;
  156. typedef struct
  157. {
  158. uint16_t rechg_vol;
  159. uint16_t chg_end_vol;
  160. uint16_t bat_safety_vol;
  161. uint16_t standard_chg_current;
  162. uint16_t usb_chg_current;
  163. uint16_t nonstandard_chg_current;
  164. uint16_t chg_timeout;
  165. } chgChargeParam_t;
  166. typedef struct
  167. {
  168. uint16_t ovp_type;
  169. uint16_t ovp_over_vol;
  170. uint16_t ovp_resume_vol;
  171. } chgOVPparam_t;
  172. typedef struct
  173. {
  174. uint16_t otp_type; ///0:don't support,1:environment temp,2:vbat temp
  175. uint16_t over_low;
  176. uint16_t over_high;
  177. uint16_t resume_low;
  178. uint16_t resume_high;
  179. } chgOtpParam_t;
  180. typedef enum
  181. {
  182. CHR_BATT_MIN_VOLTAGE,
  183. CHR_BATT_MAX_VOLTAGE,
  184. CHR_BATT_IN_CHARGE,
  185. CHR_BATT_OUT_OF_CHARGE
  186. } chgBattState_e;
  187. typedef enum
  188. {
  189. CHG_DEFAULT_MODE = 0,
  190. CHG_NORMAL_ADAPTER,
  191. CHG_USB_ADAPTER
  192. } chgAdapterMode_e;
  193. #define CHR_BATTERY_NONE_S 0x1 // No battery
  194. #define CHR_BATTERY_NORMAL_S 0x2 // battery is in normal model( not in charge )
  195. #define CHR_BATTERY_CHARGING_S 0x3 // is charging.
  196. #define BAT_TABLE_SIZE (13)
  197. #define PROD_HW_CONFIG (20)
  198. #define CHR_PARAM_RESERVE_SIZE (48 - (PROD_HW_CONFIG + 2 * BAT_TABLE_SIZE))
  199. // All the voltage unit is mV
  200. typedef struct
  201. {
  202. struct dischg_param_t
  203. {
  204. uint16_t voltage_warning; // when low than the voltage, send the warning msg to client.
  205. uint16_t voltage_shutdown; // when low than the voltage, send the shutdown msg to client.
  206. uint16_t voltage_deadline; //adjust_backlight; //
  207. uint16_t warning_count; // when reach the warning count, will send the voltage warning to client.
  208. } dischg_param;
  209. struct chg_param_t
  210. {
  211. uint16_t recharge_voltage;
  212. uint16_t charge_end_voltage;
  213. uint16_t bat_safety_vol;
  214. uint16_t standard_current_type; //standard adapter charge current type
  215. uint16_t usb_current_type; //pc charge current type
  216. uint16_t nonstandard_current_type; //nonstandard adapter charge current select,0:usb 1:standard adapter
  217. uint16_t chg_timeout;
  218. } chg_param;
  219. struct ovp_param_t
  220. {
  221. uint16_t ovp_type; //ovp type
  222. uint16_t ovp_over_vol;
  223. uint16_t ovp_resume_vol;
  224. } ovp_param;
  225. struct
  226. {
  227. uint16_t otp_type; ///0:don't support,1:environment temp,2:vbat temp
  228. uint16_t over_low;
  229. uint16_t over_high;
  230. uint16_t resume_low;
  231. uint16_t resume_high;
  232. } otp_param;
  233. uint16_t hw_switch_point; //set the lowest hardware switchover point between cc-cv
  234. // The table define as following:
  235. // If the voltage >= the low WORD of table[n], the capacity is the high WORD of table[n].
  236. // The last one item of the table must be 0xFFFFFFFF
  237. uint16_t dischg_bat_capacity_table[BAT_TABLE_SIZE];
  238. uint16_t chg_bat_capacity_table[BAT_TABLE_SIZE];
  239. uint16_t reseved[CHR_PARAM_RESERVE_SIZE];
  240. } chgParamProd_t; // Size is 112 bytes
  241. #ifdef __cplusplus
  242. }
  243. #endif
  244. #endif