as3722_init.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2013
  4. * NVIDIA Corporation <www.nvidia.com>
  5. */
  6. #include <common.h>
  7. #include <log.h>
  8. #include <asm/io.h>
  9. #include <asm/arch-tegra/tegra_i2c.h>
  10. #include <linux/delay.h>
  11. /* AS3722-PMIC-specific early init regs */
  12. #define AS3722_I2C_ADDR 0x80
  13. #define AS3722_SD0VOLTAGE_REG 0x00 /* CPU */
  14. #define AS3722_SD1VOLTAGE_REG 0x01 /* CORE, already set by OTP */
  15. #define AS3722_SD6VOLTAGE_REG 0x06 /* GPU */
  16. #define AS3722_SDCONTROL_REG 0x4D
  17. #define AS3722_LDO2VOLTAGE_REG 0x12 /* VPP_FUSE */
  18. #define AS3722_LDO6VOLTAGE_REG 0x16 /* VDD_SDMMC */
  19. #define AS3722_LDCONTROL_REG 0x4E
  20. #if defined(CONFIG_TARGET_VENICE2)
  21. #define AS3722_SD0VOLTAGE_DATA (0x2800 | AS3722_SD0VOLTAGE_REG)
  22. #else /* TK1 or Nyan-Big */
  23. #define AS3722_SD0VOLTAGE_DATA (0x3C00 | AS3722_SD0VOLTAGE_REG)
  24. #endif
  25. #define AS3722_SD0CONTROL_DATA (0x0100 | AS3722_SDCONTROL_REG)
  26. #if defined(CONFIG_TARGET_JETSON_TK1) || defined(CONFIG_TARGET_CEI_TK1_SOM)
  27. #define AS3722_SD1VOLTAGE_DATA (0x2800 | AS3722_SD1VOLTAGE_REG)
  28. #define AS3722_SD1CONTROL_DATA (0x0200 | AS3722_SDCONTROL_REG)
  29. #endif
  30. #define AS3722_SD6CONTROL_DATA (0x4000 | AS3722_SDCONTROL_REG)
  31. #define AS3722_SD6VOLTAGE_DATA (0x2800 | AS3722_SD6VOLTAGE_REG)
  32. #define AS3722_LDO2CONTROL_DATA (0x0400 | AS3722_LDCONTROL_REG)
  33. #define AS3722_LDO2VOLTAGE_DATA (0x1000 | AS3722_LDO2VOLTAGE_REG)
  34. #define AS3722_LDO6CONTROL_DATA (0x4000 | AS3722_LDCONTROL_REG)
  35. #define AS3722_LDO6VOLTAGE_DATA (0x3F00 | AS3722_LDO6VOLTAGE_REG)
  36. /* AS3722-PMIC-specific early init code - get CPU rails up, etc */
  37. void pmic_enable_cpu_vdd(void)
  38. {
  39. debug("%s entry\n", __func__);
  40. #ifdef AS3722_SD1VOLTAGE_DATA
  41. /* Set up VDD_CORE, for boards where OTP is incorrect*/
  42. debug("%s: Setting VDD_CORE via AS3722 reg 1\n", __func__);
  43. /* Configure VDD_CORE via the AS3722 PMIC on the PWR I2C bus */
  44. tegra_i2c_ll_write(AS3722_I2C_ADDR,
  45. AS3722_SD1VOLTAGE_DATA);
  46. /*
  47. * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
  48. * tegra_i2c_ll_write_data(AS3722_SD1CONTROL_DATA, I2C_SEND_2_BYTES);
  49. */
  50. udelay(10 * 1000);
  51. #endif
  52. debug("%s: Setting VDD_CPU to 1.0V via AS3722 reg 0/4D\n", __func__);
  53. /*
  54. * Bring up VDD_CPU via the AS3722 PMIC on the PWR I2C bus.
  55. * First set VDD to 1.0V, then enable the VDD regulator.
  56. */
  57. tegra_i2c_ll_write(AS3722_I2C_ADDR,
  58. AS3722_SD0VOLTAGE_DATA);
  59. /*
  60. * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
  61. * tegra_i2c_ll_write_data(AS3722_SD0CONTROL_DATA, I2C_SEND_2_BYTES);
  62. */
  63. udelay(10 * 1000);
  64. debug("%s: Setting VDD_GPU to 1.0V via AS3722 reg 6/4D\n", __func__);
  65. /*
  66. * Bring up VDD_GPU via the AS3722 PMIC on the PWR I2C bus.
  67. * First set VDD to 1.0V, then enable the VDD regulator.
  68. */
  69. tegra_i2c_ll_write(AS3722_I2C_ADDR,
  70. AS3722_SD6VOLTAGE_DATA);
  71. /*
  72. * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
  73. * tegra_i2c_ll_write_data(AS3722_SD6CONTROL_DATA, I2C_SEND_2_BYTES);
  74. */
  75. udelay(10 * 1000);
  76. debug("%s: Set VPP_FUSE to 1.2V via AS3722 reg 0x12/4E\n", __func__);
  77. /*
  78. * Bring up VPP_FUSE via the AS3722 PMIC on the PWR I2C bus.
  79. * First set VDD to 1.2V, then enable the VDD regulator.
  80. */
  81. tegra_i2c_ll_write(AS3722_I2C_ADDR,
  82. AS3722_LDO2VOLTAGE_DATA);
  83. /*
  84. * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
  85. * tegra_i2c_ll_write_data(AS3722_LDO2CONTROL_DATA, I2C_SEND_2_BYTES);
  86. */
  87. udelay(10 * 1000);
  88. debug("%s: Set VDD_SDMMC to 3.3V via AS3722 reg 0x16/4E\n", __func__);
  89. /*
  90. * Bring up VDD_SDMMC via the AS3722 PMIC on the PWR I2C bus.
  91. * First set it to bypass 3.3V straight thru, then enable the regulator
  92. *
  93. * NOTE: We do this early because doing it later seems to hose the CPU
  94. * power rail/partition startup. Need to debug.
  95. */
  96. tegra_i2c_ll_write(AS3722_I2C_ADDR,
  97. AS3722_LDO6VOLTAGE_DATA);
  98. /*
  99. * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
  100. * tegra_i2c_ll_write_data(AS3722_LDO6CONTROL_DATA, I2C_SEND_2_BYTES);
  101. */
  102. udelay(10 * 1000);
  103. }