pmic8058-charger.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /* Copyright (c) 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. #ifndef __PMIC8058_CHARGER_H__
  13. #define __PMIC8058_CHARGER_H__
  14. /**
  15. * enum pmic8058_chg_state - pmic8058 charging states
  16. * @PMIC8058_CHG_STATE_NONE: Initial off state
  17. * @PMIC8058_CHG_STATE_PWR_CHG: Device powered from charger
  18. * @PMIC8058_CHG_STATE_ATC: Device is Auto Tricke Charged (ATC)
  19. * @PMIC8058_CHG_STATE_PWR_BAT: Device powered from Battery
  20. * @PMIC8058_CHG_STATE_ATC_FAIL: ATC failed
  21. * @PMIC8058_CHG_STATE_AUX_EN: Transient state
  22. * @PMIC8058_CHG_STATE_PON_AFTER_ATC: Power on from battery and chg with limit
  23. * of 90mA
  24. * @PMIC8058_CHG_STATE_FAST_CHG: pmic is fast charging the battery
  25. * @PMIC8058_CHG_STATE_TRKL_CHG: pmic is trck charging the battery
  26. * @PMIC8058_CHG_STATE_CHG_FAIL: charging failed
  27. * @PMIC8058_CHG_STATE_EOC: end of charging reached
  28. * @PMIC8058_CHG_STATE_INRUSH_LIMIT: Brings up Vdd with 90mA max drawn from
  29. * VBUS
  30. * @PMIC8058_CHG_STATE_USB_SUSPENDED: USB supended, no current drawn from VBUS
  31. * @PMIC8058_CHG_STATE_PAUSE_ATC: ATC paused
  32. * @PMIC8058_CHG_STATE_PAUSE_FAST_CHG: FAST charging paused
  33. * @PMIC8058_CHG_STATE_PAUSE_TRKL_CHG: TRLK charging paused
  34. *
  35. * The paused states happen when a unfavourable condition for charging is
  36. * detected. The most common one being the battery gets too hot ot gets
  37. * too cold for charging.
  38. */
  39. enum pmic8058_chg_state {
  40. PMIC8058_CHG_STATE_NONE,
  41. PMIC8058_CHG_STATE_PWR_CHG,
  42. PMIC8058_CHG_STATE_ATC,
  43. PMIC8058_CHG_STATE_PWR_BAT,
  44. PMIC8058_CHG_STATE_ATC_FAIL,
  45. PMIC8058_CHG_STATE_AUX_EN,
  46. PMIC8058_CHG_STATE_PON_AFTER_ATC,
  47. PMIC8058_CHG_STATE_FAST_CHG,
  48. PMIC8058_CHG_STATE_TRKL_CHG,
  49. PMIC8058_CHG_STATE_CHG_FAIL,
  50. PMIC8058_CHG_STATE_EOC,
  51. PMIC8058_CHG_STATE_INRUSH_LIMIT,
  52. PMIC8058_CHG_STATE_USB_SUSPENDED,
  53. PMIC8058_CHG_STATE_PAUSE_ATC,
  54. PMIC8058_CHG_STATE_PAUSE_FAST_CHG,
  55. PMIC8058_CHG_STATE_PAUSE_TRKL_CHG
  56. };
  57. #if defined(CONFIG_BATTERY_MSM8X60) || defined(CONFIG_BATTERY_MSM8X60_MODULE)
  58. int pmic8058_get_charge_batt(void);
  59. int pmic8058_set_charge_batt(int);
  60. /**
  61. * pmic8058_get_fsm_state -
  62. *
  63. * CONTEXT: may sleep - should not be called from non-atomic context
  64. *
  65. * RETURNS: The pmic internal state, or error otherwise
  66. */
  67. enum pmic8058_chg_state pmic8058_get_fsm_state(void);
  68. #else
  69. int pmic8058_get_charge_batt(void)
  70. {
  71. return -ENXIO;
  72. }
  73. int pmic8058_set_charge_batt(int)
  74. {
  75. return -ENXIO;
  76. }
  77. enum pmic8058_chg_state pmic8058_get_fsm_state(void)
  78. {
  79. return -ENXIO;
  80. }
  81. #endif
  82. #endif /* __PMIC8058_CHARGER_H__ */