qpnp-sec-charger.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /* Copyright (c) 2011-2013, 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. #ifndef __QPNP_SEC_CHARGER_H
  13. #define __QPNP_SEC_CHARGER_H
  14. #include <linux/errno.h>
  15. #include <linux/power_supply.h>
  16. /* Enable Samsung Charging specification code */
  17. #define SEC_CHARGER_CODE
  18. #define NUM_SIOP_LEVEL 5
  19. //extern bool ovp_state;
  20. /*
  21. * Charging current table
  22. */
  23. struct pm8226_charging_current {
  24. unsigned int ibat;
  25. };
  26. /*
  27. * SAMSUNG battery platform data
  28. */
  29. struct sec_battery_data {
  30. /* for absolute timer (first) */
  31. unsigned long charging_time;
  32. /* for recharging timer (second) */
  33. unsigned long recharging_time;
  34. /* charging current set */
  35. int imax_ta; /* mA */
  36. int imax_usb; /* mA */
  37. /* temperature set */
  38. int temp_high_block_event;
  39. int temp_high_recover_event;
  40. int temp_low_block_event;
  41. int temp_low_recover_event;
  42. int temp_high_block_normal;
  43. int temp_high_recover_normal;
  44. int temp_low_block_normal;
  45. int temp_low_recover_normal;
  46. int temp_high_block_lpm;
  47. int temp_high_recover_lpm;
  48. int temp_low_block_lpm;
  49. int temp_low_recover_lpm;
  50. #if defined(CONFIG_WIRELESS_CHARGING)
  51. int temp_high_block_wc;
  52. int temp_high_recover_wc;
  53. int temp_low_block_wc;
  54. int temp_low_recover_wc;
  55. #endif
  56. /* event check model flag */
  57. unsigned int event_check;
  58. /* sustaining event after deactivated (second) */
  59. unsigned int event_waiting_time;
  60. /* soc should be soc x 10 (0.1% degree)
  61. * only for scaling
  62. */
  63. unsigned int capacity_max;
  64. unsigned int capacity_max_margin;
  65. unsigned int capacity_min;
  66. unsigned int ui_full_soc;
  67. unsigned int ui_full_current; /* mA */
  68. unsigned int ui_full_voltage; /* mV */
  69. unsigned int ui_full_count;
  70. unsigned int charging_term_time; /* sec */
  71. unsigned int recharging_voltage; /* mV */
  72. unsigned int poweroff_check_soc; /* % */
  73. //struct pm8226_charging_current *chg_current_table;
  74. //unsigned int *siop_table;
  75. };
  76. /*******************************************
  77. SAMSUNG BATTERY ATTRS
  78. *******************************************/
  79. /* event check */
  80. #define EVENT_NONE (0)
  81. #define EVENT_2G_CALL (0x1 << 0)
  82. #define EVENT_3G_CALL (0x1 << 1)
  83. #define EVENT_MUSIC (0x1 << 2)
  84. #define EVENT_VIDEO (0x1 << 3)
  85. #define EVENT_BROWSER (0x1 << 4)
  86. #define EVENT_HOTSPOT (0x1 << 5)
  87. #define EVENT_CAMERA (0x1 << 6)
  88. #define EVENT_CAMCORDER (0x1 << 7)
  89. #define EVENT_DATA_CALL (0x1 << 8)
  90. #define EVENT_WIFI (0x1 << 9)
  91. #define EVENT_WIBRO (0x1 << 10)
  92. #define EVENT_LTE (0x1 << 11)
  93. #define EVENT_LCD (0x1 << 12)
  94. #define EVENT_GPS (0x1 << 13)
  95. #ifdef SEC_CHARGER_CODE
  96. ssize_t sec_bat_show_attrs(struct device *dev,
  97. struct device_attribute *attr, char *buf);
  98. ssize_t sec_bat_store_attrs(struct device *dev,
  99. struct device_attribute *attr,
  100. const char *buf, size_t count);
  101. #define SEC_BATTERY_ATTR(_name) \
  102. { \
  103. .attr = {.name = #_name, .mode = 0664}, \
  104. .show = sec_bat_show_attrs, \
  105. .store = sec_bat_store_attrs, \
  106. }
  107. static struct device_attribute sec_battery_attrs[] = {
  108. SEC_BATTERY_ATTR(batt_reset_soc),
  109. SEC_BATTERY_ATTR(batt_read_raw_soc),
  110. SEC_BATTERY_ATTR(batt_read_adj_soc),
  111. SEC_BATTERY_ATTR(batt_type),
  112. SEC_BATTERY_ATTR(batt_vfocv),
  113. SEC_BATTERY_ATTR(batt_vol_adc),
  114. SEC_BATTERY_ATTR(batt_vol_adc_cal),
  115. SEC_BATTERY_ATTR(batt_vol_aver),
  116. SEC_BATTERY_ATTR(batt_vol_adc_aver),
  117. SEC_BATTERY_ATTR(batt_temp_adc),
  118. SEC_BATTERY_ATTR(batt_temp_aver),
  119. SEC_BATTERY_ATTR(batt_temp_adc_aver),
  120. SEC_BATTERY_ATTR(batt_vf_adc),
  121. SEC_BATTERY_ATTR(batt_lp_charging),
  122. SEC_BATTERY_ATTR(siop_activated),
  123. SEC_BATTERY_ATTR(siop_level),
  124. SEC_BATTERY_ATTR(batt_charging_source),
  125. SEC_BATTERY_ATTR(fg_reg_dump),
  126. SEC_BATTERY_ATTR(fg_reset_cap),
  127. SEC_BATTERY_ATTR(fg_capacity),
  128. SEC_BATTERY_ATTR(auth),
  129. SEC_BATTERY_ATTR(chg_current_adc),
  130. SEC_BATTERY_ATTR(wc_adc),
  131. SEC_BATTERY_ATTR(wc_status),
  132. SEC_BATTERY_ATTR(factory_mode),
  133. SEC_BATTERY_ATTR(update),
  134. SEC_BATTERY_ATTR(test_mode),
  135. SEC_BATTERY_ATTR(talk_gsm),
  136. SEC_BATTERY_ATTR(talk_wcdma),
  137. SEC_BATTERY_ATTR(music),
  138. SEC_BATTERY_ATTR(video),
  139. SEC_BATTERY_ATTR(browser),
  140. SEC_BATTERY_ATTR(hotspot),
  141. SEC_BATTERY_ATTR(camera),
  142. SEC_BATTERY_ATTR(data_call),
  143. SEC_BATTERY_ATTR(wifi),
  144. SEC_BATTERY_ATTR(lte),
  145. SEC_BATTERY_ATTR(event),
  146. SEC_BATTERY_ATTR(batt_slate_mode),
  147. };
  148. enum {
  149. BATT_RESET_SOC = 0,
  150. BATT_READ_RAW_SOC,
  151. BATT_READ_ADJ_SOC,
  152. BATT_TYPE,
  153. BATT_VFOCV,
  154. BATT_VOL_ADC,
  155. BATT_VOL_ADC_CAL,
  156. BATT_VOL_AVER,
  157. BATT_VOL_ADC_AVER,
  158. BATT_TEMP_ADC,
  159. BATT_TEMP_AVER,
  160. BATT_TEMP_ADC_AVER,
  161. BATT_VF_ADC,
  162. BATT_LP_CHARGING,
  163. SIOP_ACTIVATED,
  164. SIOP_LEVEL,
  165. BATT_CHARGING_SOURCE,
  166. FG_REG_DUMP,
  167. FG_RESET_CAP,
  168. FG_CAPACITY,
  169. AUTH,
  170. CHG_CURRENT_ADC,
  171. WC_ADC,
  172. WC_STATUS,
  173. FACTORY_MODE,
  174. UPDATE,
  175. TEST_MODE,
  176. BATT_EVENT_GSM_CALL,
  177. BATT_EVENT_WCDMA_CALL,
  178. BATT_EVENT_MUSIC,
  179. BATT_EVENT_VIDEO,
  180. BATT_EVENT_BROWSER,
  181. BATT_EVENT_HOTSPOT,
  182. BATT_EVENT_CAMERA,
  183. BATT_EVENT_DATA_CALL,
  184. BATT_EVENT_WIFI,
  185. BATT_EVENT_LTE,
  186. BATT_EVENT,
  187. BATT_SLATE_MODE,
  188. };
  189. #endif
  190. /*******************************************
  191. SAMSUNG FG ATTRS
  192. *******************************************/
  193. /*
  194. ssize_t sec_fg_show_attrs(struct device *dev,
  195. struct device_attribute *attr, char *buf);
  196. ssize_t sec_fg_store_attrs(struct device *dev,
  197. struct device_attribute *attr,
  198. const char *buf, size_t count);
  199. static struct device_attribute sec_fuelgauge_attrs[] = {
  200. SEC_FUELGAUGE_ATTR(fg_curr_ua),
  201. };
  202. #define SEC_FUELGAUGE_ATTR(_name) \
  203. { \
  204. .attr = {.name = #_name, .mode = 0664}, \
  205. .show = sec_fg_show_attrs, \
  206. .store = sec_fg_store_attrs, \
  207. }
  208. enum {
  209. FG_CURR_UA = 0,
  210. };
  211. */
  212. #endif /* __QPNP_SEC_CHARGER_H */