sec_direct_charger.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * sec_direct_charger.h
  3. * Samsung Mobile Charger Header
  4. *
  5. * Copyright (C) 2018 Samsung Electronics, Inc.
  6. *
  7. *
  8. * This software is licensed under the terms of the GNU General Public
  9. * License version 2, as published by the Free Software Foundation, and
  10. * may be copied, distributed, and modified under those terms.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. */
  18. #ifndef __SEC_DIRECT_CHARGER_H
  19. #define __SEC_DIRECT_CHARGER_H __FILE__
  20. #include "sec_battery.h"
  21. #include "sec_charging_common.h"
  22. #include "sb_pass_through.h"
  23. #define SEC_DIRECT_CHG_MIN_IOUT 2000
  24. #define SEC_DIRECT_CHG_MIN_VBAT 3500
  25. #define SEC_DIRECT_CHG_MAX_VBAT 4200
  26. #define FPDO_DC_MIN_VBAT 3500
  27. #define FPDO_DC_MAX_VBAT 5000
  28. #if IS_ENABLED(CONFIG_SEC_ABC)
  29. #define ABC_DC_CNT 5
  30. #endif
  31. typedef enum _sec_direct_chg_src {
  32. SEC_CHARGING_SOURCE_SWITCHING = 0,
  33. SEC_CHARGING_SOURCE_DIRECT,
  34. } sec_direct_chg_src_t;
  35. typedef enum _sec_direct_chg_mode {
  36. SEC_DIRECT_CHG_MODE_DIRECT_OFF = 0,
  37. SEC_DIRECT_CHG_MODE_DIRECT_CHECK_VBAT,
  38. SEC_DIRECT_CHG_MODE_DIRECT_PRESET,
  39. SEC_DIRECT_CHG_MODE_DIRECT_ON_ADJUST,
  40. SEC_DIRECT_CHG_MODE_DIRECT_ON,
  41. SEC_DIRECT_CHG_MODE_DIRECT_DONE,
  42. SEC_DIRECT_CHG_MODE_DIRECT_BYPASS,
  43. SEC_DIRECT_CHG_MODE_MAX,
  44. } sec_direct_chg_mode_t;
  45. enum {
  46. LOW_VBAT_SET = 0,
  47. LOW_VBAT_NONE,
  48. LOW_VBAT_OFF,
  49. };
  50. enum {
  51. DC_NORMAL_MODE = 0,
  52. DC_BYPASS_MODE,
  53. };
  54. #define is_direct_chg_mode_on(direct_chg_mode) ( \
  55. direct_chg_mode == SEC_DIRECT_CHG_MODE_DIRECT_PRESET || \
  56. direct_chg_mode == SEC_DIRECT_CHG_MODE_DIRECT_ON) || \
  57. direct_chg_mode == SEC_DIRECT_CHG_MODE_DIRECT_ON_ADJUST
  58. struct sec_direct_charger_platform_data {
  59. char *battery_name;
  60. char *main_charger_name;
  61. char *direct_charger_name;
  62. char *direct_sub_charger_name;
  63. int dchg_min_current;
  64. int dchg_min_vbat;
  65. int dchg_temp_low_threshold;
  66. int dchg_temp_high_threshold;
  67. int dchg_end_soc;
  68. int dchg_dc_in_swelling;
  69. int swelling_high_rechg_voltage;
  70. int fpdo_dc_min_vbat;
  71. int fpdo_dc_max_vbat;
  72. #if IS_ENABLED(CONFIG_DUAL_BATTERY)
  73. int fpdo_dc_max_main_vbat;
  74. int fpdo_dc_max_sub_vbat;
  75. #endif
  76. bool chgen_over_swell_rechg_vol;
  77. };
  78. struct sec_direct_charger_info {
  79. struct device *dev;
  80. struct sec_direct_charger_platform_data *pdata;
  81. struct power_supply* psy_chg;
  82. struct mutex charger_mutex;
  83. struct sb_pt *pt;
  84. sec_direct_chg_mode_t direct_chg_mode;
  85. unsigned int charger_mode;
  86. unsigned int charger_mode_main;
  87. unsigned int charger_mode_direct;
  88. unsigned int dc_retry_cnt;
  89. int cable_type;
  90. int input_current;
  91. int charging_current;
  92. int topoff_current;
  93. int float_voltage;
  94. bool dc_err;
  95. bool ta_alert_wa;
  96. int ta_alert_mode;
  97. bool is_charging;
  98. int batt_status;
  99. int capacity;
  100. bool direct_chg_done;
  101. bool wc_tx_enable;
  102. bool now_isApdo;
  103. bool store_mode;
  104. int vbat_min_src;
  105. bool dc_rcp;
  106. int bat_temp;
  107. sec_direct_chg_src_t charging_source;
  108. int fpdo_pos;
  109. int dc_input_current;
  110. int dc_charging_current;
  111. int test_mode_source;
  112. #if IS_ENABLED(CONFIG_SEC_ABC)
  113. int abc_dc_current_cnt;
  114. #endif
  115. };
  116. #endif /* __SEC_DIRECT_CHARGER_H */