twl6030.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*
  2. * (C) Copyright 2010
  3. * Texas Instruments, <www.ti.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <i2c.h>
  25. /* I2C chip addresses */
  26. #define TWL6030_CHIP_PM 0x48
  27. #define TWL6030_CHIP_USB 0x49
  28. #define TWL6030_CHIP_ADC 0x49
  29. #define TWL6030_CHIP_CHARGER 0x49
  30. #define TWL6030_CHIP_PWM 0x49
  31. /* Slave Address 0x48 */
  32. #define VMMC_CFG_STATE 0x9A
  33. #define VMMC_CFG_VOLTATE 0x9B
  34. #define VUSB_CFG_STATE 0xA2
  35. #define MISC1 0xE4
  36. #define VAC_MEAS (1 << 2)
  37. #define VBAT_MEAS (1 << 1)
  38. #define BB_MEAS (1 << 0)
  39. #define MISC2 0xE5
  40. /* Slave Address 0x49 */
  41. /* Battery CHARGER REGISTERS */
  42. #define CONTROLLER_INT_MASK 0xE0
  43. #define CONTROLLER_CTRL1 0xE1
  44. #define CONTROLLER_WDG 0xE2
  45. #define CONTROLLER_STAT1 0xE3
  46. #define CHARGERUSB_INT_STATUS 0xE4
  47. #define CHARGERUSB_INT_MASK 0xE5
  48. #define CHARGERUSB_STATUS_INT1 0xE6
  49. #define CHARGERUSB_STATUS_INT2 0xE7
  50. #define CHARGERUSB_CTRL1 0xE8
  51. #define CHARGERUSB_CTRL2 0xE9
  52. #define CHARGERUSB_CTRL3 0xEA
  53. #define CHARGERUSB_STAT1 0xEB
  54. #define CHARGERUSB_VOREG 0xEC
  55. #define CHARGERUSB_VICHRG 0xED
  56. #define CHARGERUSB_CINLIMIT 0xEE
  57. #define CHARGERUSB_CTRLLIMIT1 0xEF
  58. /* CHARGERUSB_VICHRG */
  59. #define CHARGERUSB_VICHRG_500 0x4
  60. #define CHARGERUSB_VICHRG_1500 0xE
  61. /* CHARGERUSB_CINLIMIT */
  62. #define CHARGERUSB_CIN_LIMIT_100 0x1
  63. #define CHARGERUSB_CIN_LIMIT_300 0x5
  64. #define CHARGERUSB_CIN_LIMIT_500 0x9
  65. #define CHARGERUSB_CIN_LIMIT_NONE 0xF
  66. /* CONTROLLER_INT_MASK */
  67. #define MVAC_FAULT (1 << 6)
  68. #define MAC_EOC (1 << 5)
  69. #define MBAT_REMOVED (1 << 4)
  70. #define MFAULT_WDG (1 << 3)
  71. #define MBAT_TEMP (1 << 2)
  72. #define MVBUS_DET (1 << 1)
  73. #define MVAC_DET (1 << 0)
  74. /* CHARGERUSB_INT_MASK */
  75. #define MASK_MCURRENT_TERM (1 << 3)
  76. #define MASK_MCHARGERUSB_STAT (1 << 2)
  77. #define MASK_MCHARGERUSB_THMREG (1 << 1)
  78. #define MASK_MCHARGERUSB_FAULT (1 << 0)
  79. /* CHARGERUSB_VOREG */
  80. #define CHARGERUSB_VOREG_3P52 0x01
  81. #define CHARGERUSB_VOREG_4P0 0x19
  82. #define CHARGERUSB_VOREG_4P2 0x23
  83. #define CHARGERUSB_VOREG_4P76 0x3F
  84. /* CHARGERUSB_CTRL1 */
  85. #define SUSPEND_BOOT (1 << 7)
  86. #define OPA_MODE (1 << 6)
  87. #define HZ_MODE (1 << 5)
  88. #define TERM (1 << 4)
  89. /* CHARGERUSB_CTRL2 */
  90. #define CHARGERUSB_CTRL2_VITERM_50 (0 << 5)
  91. #define CHARGERUSB_CTRL2_VITERM_100 (1 << 5)
  92. #define CHARGERUSB_CTRL2_VITERM_150 (2 << 5)
  93. #define CHARGERUSB_CTRL2_VITERM_400 (7 << 5)
  94. /* CONTROLLER_CTRL1 */
  95. #define CONTROLLER_CTRL1_EN_CHARGER (1 << 4)
  96. #define CONTROLLER_CTRL1_SEL_CHARGER (1 << 3)
  97. /* CONTROLLER_STAT1 */
  98. #define CHRG_EXTCHRG_STATZ (1 << 7)
  99. #define CHRG_DET_N (1 << 5)
  100. #define VAC_DET (1 << 3)
  101. #define VBUS_DET (1 << 2)
  102. #define FG_REG_10 0xCA
  103. #define FG_REG_11 0xCB
  104. #define TOGGLE1 0x90
  105. #define FGS (1 << 5)
  106. #define FGR (1 << 4)
  107. #define GPADCS (1 << 1)
  108. #define GPADCR (1 << 0)
  109. #define CTRL_P2 0x34
  110. #define CTRL_P2_SP2 (1 << 2)
  111. #define CTRL_P2_EOCP2 (1 << 1)
  112. #define CTRL_P2_BUSY (1 << 0)
  113. #define GPCH0_LSB 0x57
  114. #define GPCH0_MSB 0x58
  115. void twl6030_init_battery_charging(void);
  116. void twl6030_usb_device_settings(void);
  117. void twl6030_start_usb_charging(void);
  118. void twl6030_stop_usb_charging(void);
  119. int twl6030_get_battery_voltage(void);
  120. int twl6030_get_battery_current(void);
  121. void twl6030_power_mmc_init(void);