palmas.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2012-2013
  4. * Texas Instruments, <www.ti.com>
  5. */
  6. #ifndef PALMAS_H
  7. #define PALMAS_H
  8. #include <common.h>
  9. #include <i2c.h>
  10. /* I2C chip addresses, TW6035/37 */
  11. #define TWL603X_CHIP_P1 0x48 /* Page 1 */
  12. #define TWL603X_CHIP_P2 0x49 /* Page 2 */
  13. #define TWL603X_CHIP_P3 0x4a /* Page 3 */
  14. /* TPS659038/39 */
  15. #define TPS65903X_CHIP_P1 0x58 /* Page 1 */
  16. /* Page 1 registers (0x1XY translates to page 1, reg addr 0xXY): */
  17. /* LDO1 control/voltage */
  18. #define LDO1_CTRL 0x50
  19. #define LDO1_VOLTAGE 0x51
  20. /* LDO1 control/voltage for LP873x */
  21. #define LP873X_LDO1_ADDR 0x60
  22. #define LP873X_LDO1_CTRL 0x9
  23. #define LP873X_LDO1_VOLTAGE 0xa
  24. #define LP873X_LDO_VOLT_3V0 0x19
  25. #define LP873X_LDO_VOLT_1V8 0xa
  26. #define LP873X_LDO_CTRL_EN (0x1 << 0)
  27. #define LP873X_LDO_CTRL_EN_PINCTRL (0x1 << 1)
  28. #define LP873X_LDO_CTRL_RDIS_EN (0x1 << 2)
  29. /* LDO2 control/voltage */
  30. #define LDO2_CTRL 0x52
  31. #define LDO2_VOLTAGE 0x53
  32. /* LDO2 control/voltage */
  33. #define LDO4_CTRL 0x5e
  34. #define LDO4_VOLTAGE 0x5f
  35. /* LDO9 control/voltage */
  36. #define LDO9_CTRL 0x60
  37. #define LDO9_VOLTAGE 0x61
  38. /* LDOUSB control/voltage */
  39. #define LDOUSB_CTRL 0x64
  40. #define LDOUSB_VOLTAGE 0x65
  41. #define LDO_CTRL 0x6a
  42. /* Control of 32 kHz audio clock */
  43. #define CLK32KGAUDIO_CTRL 0xd5
  44. /* SYSEN2_CTRL for VCC_3v3_AUX supply on the sEVM */
  45. #define SYSEN2_CTRL 0xd9
  46. /*
  47. * Bit field definitions for LDOx_CTRL, SYSENx_CTRL
  48. * and some other xxx_CTRL resources:
  49. */
  50. #define LDO9_BYP_EN (1 << 6) /* LDO9 only! */
  51. #define RSC_STAT_ON (1 << 4) /* RO status bit! */
  52. #define RSC_MODE_SLEEP (1 << 2)
  53. #define RSC_MODE_ACTIVE (1 << 0)
  54. /* Some LDO voltage values */
  55. #define LDO_VOLT_OFF 0
  56. #define LDO_VOLT_1V8 0x13
  57. #define LDO_VOLT_3V0 0x2b
  58. #define LDO_VOLT_3V3 0x31
  59. /* Request bypass, LDO9 only */
  60. #define LDO9_BYPASS 0x3f
  61. /* SMPS7_CTRL */
  62. #define SMPS7_CTRL 0x30
  63. /* SMPS9_CTRL */
  64. #define SMPS9_CTRL 0x38
  65. #define SMPS9_VOLTAGE 0x3b
  66. /* SMPS10_CTRL */
  67. #define SMPS10_CTRL 0x3c
  68. #define SMPS10_MODE_ACTIVE_D 0x0d
  69. /* Bit field definitions for SMPSx_CTRL */
  70. #define SMPS_MODE_ACT_AUTO 1
  71. #define SMPS_MODE_ACT_ECO 2
  72. #define SMPS_MODE_ACT_FPWM 3
  73. #define SMPS_MODE_SLP_AUTO (1 << 2)
  74. #define SMPS_MODE_SLP_ECO (2 << 2)
  75. #define SMPS_MODE_SLP_FPWM (3 << 2)
  76. /*
  77. * Some popular SMPS voltages, all with RANGE=1; note
  78. * that RANGE cannot be changed on the fly
  79. */
  80. #define SMPS_VOLT_OFF 0
  81. #define SMPS_VOLT_1V2 0x90
  82. #define SMPS_VOLT_1V8 0xae
  83. #define SMPS_VOLT_2V1 0xbd
  84. #define SMPS_VOLT_3V0 0xea
  85. #define SMPS_VOLT_3V3 0xf9
  86. /* Backup Battery & VRTC Control */
  87. #define BB_VRTC_CTRL 0xa8
  88. /* Bit definitions for BB_VRTC_CTRL */
  89. #define VRTC_EN_SLP (1 << 6)
  90. #define VRTC_EN_OFF (1 << 5)
  91. #define VRTC_PWEN (1 << 4)
  92. #define BB_LOW_ICHRG (1 << 3)
  93. #define BB_HIGH_ICHRG (0 << 3)
  94. #define BB_VSEL_3V0 (0 << 1)
  95. #define BB_VSEL_2V5 (1 << 1)
  96. #define BB_VSEL_3V15 (2 << 1)
  97. #define BB_VSEL_VBAT (3 << 1)
  98. #define BB_CHRG_EN (1 << 0)
  99. #ifndef CONFIG_DM_I2C
  100. /*
  101. * Functions to read and write from TPS659038/TWL6035/TWL6037
  102. * or other Palmas family of TI PMICs
  103. */
  104. static inline int palmas_i2c_write_u8(u8 chip_no, u8 reg, u8 val)
  105. {
  106. return i2c_write(chip_no, reg, 1, &val, 1);
  107. }
  108. static inline int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *val)
  109. {
  110. return i2c_read(chip_no, reg, 1, val, 1);
  111. }
  112. #else
  113. int palmas_i2c_write_u8(u8 chip_no, u8 reg, u8 val);
  114. int palmas_i2c_read_u8(u8 chip_no, u8 reg, u8 *val);
  115. #endif
  116. void palmas_init_settings(void);
  117. int palmas_mmc1_poweron_ldo(uint ldo_volt, uint ldo_ctrl, uint voltage);
  118. int lp873x_mmc1_poweron_ldo(uint voltage);
  119. int twl603x_mmc1_set_ldo9(u8 vsel);
  120. int twl603x_audio_power(u8 on);
  121. int twl603x_enable_bb_charge(u8 bb_fields);
  122. int palmas_enable_ss_ldo(void);
  123. #endif /* PALMAS_H */