palmas.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * (C) Copyright 2012-2013
  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. #ifndef PALMAS_H
  24. #define PALMAS_H
  25. #include <common.h>
  26. #include <i2c.h>
  27. /* I2C chip addresses, TW6035/37 */
  28. #define TWL603X_CHIP_P1 0x48 /* Page 1 */
  29. #define TWL603X_CHIP_P2 0x49 /* Page 2 */
  30. #define TWL603X_CHIP_P3 0x4a /* Page 3 */
  31. /* TPS659038/39 */
  32. #define TPS65903X_CHIP_P1 0x58 /* Page 1 */
  33. /* Page 1 registers (0x1XY translates to page 1, reg addr 0xXY): */
  34. /* LDO1 control/voltage */
  35. #define LDO1_CTRL 0x50
  36. #define LDO1_VOLTAGE 0x51
  37. /* LDO9 control/voltage */
  38. #define LDO9_CTRL 0x60
  39. #define LDO9_VOLTAGE 0x61
  40. /* LDOUSB control/voltage */
  41. #define LDOUSB_CTRL 0x64
  42. #define LDOUSB_VOLTAGE 0x65
  43. /* Control of 32 kHz audio clock */
  44. #define CLK32KGAUDIO_CTRL 0xd5
  45. /* SYSEN2_CTRL for VCC_3v3_AUX supply on the sEVM */
  46. #define SYSEN2_CTRL 0xd9
  47. /*
  48. * Bit field definitions for LDOx_CTRL, SYSENx_CTRL
  49. * and some other xxx_CTRL resources:
  50. */
  51. #define LDO9_BYP_EN (1 << 6) /* LDO9 only! */
  52. #define RSC_STAT_ON (1 << 4) /* RO status bit! */
  53. #define RSC_MODE_SLEEP (1 << 2)
  54. #define RSC_MODE_ACTIVE (1 << 0)
  55. /* Some LDO voltage values */
  56. #define LDO_VOLT_OFF 0
  57. #define LDO_VOLT_1V8 0x13
  58. #define LDO_VOLT_3V0 0x2b
  59. #define LDO_VOLT_3V3 0x31
  60. /* Request bypass, LDO9 only */
  61. #define LDO9_BYPASS 0x3f
  62. /* SMPS7_CTRL */
  63. #define SMPS7_CTRL 0x30
  64. /* SMPS9_CTRL */
  65. #define SMPS9_CTRL 0x38
  66. #define SMPS9_VOLTAGE 0x3b
  67. /* Bit field definitions for SMPSx_CTRL */
  68. #define SMPS_MODE_ACT_AUTO 1
  69. #define SMPS_MODE_ACT_ECO 2
  70. #define SMPS_MODE_ACT_FPWM 3
  71. #define SMPS_MODE_SLP_AUTO (1 << 2)
  72. #define SMPS_MODE_SLP_ECO (2 << 2)
  73. #define SMPS_MODE_SLP_FPWM (3 << 2)
  74. /*
  75. * Some popular SMPS voltages, all with RANGE=1; note
  76. * that RANGE cannot be changed on the fly
  77. */
  78. #define SMPS_VOLT_OFF 0
  79. #define SMPS_VOLT_1V2 0x90
  80. #define SMPS_VOLT_1V8 0xae
  81. #define SMPS_VOLT_2V1 0xbd
  82. #define SMPS_VOLT_3V0 0xea
  83. #define SMPS_VOLT_3V3 0xf9
  84. /* Backup Battery & VRTC Control */
  85. #define BB_VRTC_CTRL 0xa8
  86. /* Bit definitions for BB_VRTC_CTRL */
  87. #define VRTC_EN_SLP (1 << 6)
  88. #define VRTC_EN_OFF (1 << 5)
  89. #define VRTC_PWEN (1 << 4)
  90. #define BB_LOW_ICHRG (1 << 3)
  91. #define BB_HIGH_ICHRG (0 << 3)
  92. #define BB_VSEL_3V0 (0 << 1)
  93. #define BB_VSEL_2V5 (1 << 1)
  94. #define BB_VSEL_3V15 (2 << 1)
  95. #define BB_VSEL_VBAT (3 << 1)
  96. #define BB_CHRG_EN (1 << 0)
  97. /*
  98. * Functions to read and write from TPS659038/TWL6035/TWL6037
  99. * or other Palmas family of TI PMICs
  100. */
  101. static inline int palmas_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
  102. {
  103. return i2c_write(chip_no, reg, 1, &val, 1);
  104. }
  105. static inline int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
  106. {
  107. return i2c_read(chip_no, reg, 1, val, 1);
  108. }
  109. void palmas_init_settings(void);
  110. int palmas_mmc1_poweron_ldo(void);
  111. int twl603x_mmc1_set_ldo9(u8 vsel);
  112. int twl603x_audio_power(u8 on);
  113. int twl603x_enable_bb_charge(u8 bb_fields);
  114. #endif /* PALMAS_H */