as3722_init.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. * (C) Copyright 2013
  3. * NVIDIA Corporation <www.nvidia.com>
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <asm/io.h>
  9. #include <asm/arch-tegra/tegra_i2c.h>
  10. #include "as3722_init.h"
  11. /* AS3722-PMIC-specific early init code - get CPU rails up, etc */
  12. void tegra_i2c_ll_write_addr(uint addr, uint config)
  13. {
  14. struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
  15. writel(addr, &reg->cmd_addr0);
  16. writel(config, &reg->cnfg);
  17. }
  18. void tegra_i2c_ll_write_data(uint data, uint config)
  19. {
  20. struct i2c_ctlr *reg = (struct i2c_ctlr *)TEGRA_DVC_BASE;
  21. writel(data, &reg->cmd_data1);
  22. writel(config, &reg->cnfg);
  23. }
  24. void pmic_enable_cpu_vdd(void)
  25. {
  26. debug("%s entry\n", __func__);
  27. #ifdef AS3722_SD1VOLTAGE_DATA
  28. /* Set up VDD_CORE, for boards where OTP is incorrect*/
  29. debug("%s: Setting VDD_CORE via AS3722 reg 1\n", __func__);
  30. /* Configure VDD_CORE via the AS3722 PMIC on the PWR I2C bus */
  31. tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
  32. tegra_i2c_ll_write_data(AS3722_SD1VOLTAGE_DATA, I2C_SEND_2_BYTES);
  33. /*
  34. * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
  35. * tegra_i2c_ll_write_data(AS3722_SD1CONTROL_DATA, I2C_SEND_2_BYTES);
  36. */
  37. udelay(10 * 1000);
  38. #endif
  39. debug("%s: Setting VDD_CPU to 1.0V via AS3722 reg 0/4D\n", __func__);
  40. /*
  41. * Bring up VDD_CPU via the AS3722 PMIC on the PWR I2C bus.
  42. * First set VDD to 1.0V, then enable the VDD regulator.
  43. */
  44. tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
  45. tegra_i2c_ll_write_data(AS3722_SD0VOLTAGE_DATA, I2C_SEND_2_BYTES);
  46. /*
  47. * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
  48. * tegra_i2c_ll_write_data(AS3722_SD0CONTROL_DATA, I2C_SEND_2_BYTES);
  49. */
  50. udelay(10 * 1000);
  51. debug("%s: Setting VDD_GPU to 1.0V via AS3722 reg 6/4D\n", __func__);
  52. /*
  53. * Bring up VDD_GPU via the AS3722 PMIC on the PWR I2C bus.
  54. * First set VDD to 1.0V, then enable the VDD regulator.
  55. */
  56. tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
  57. tegra_i2c_ll_write_data(AS3722_SD6VOLTAGE_DATA, I2C_SEND_2_BYTES);
  58. /*
  59. * Don't write SDCONTROL - it's already 0x7F, i.e. all SDs enabled.
  60. * tegra_i2c_ll_write_data(AS3722_SD6CONTROL_DATA, I2C_SEND_2_BYTES);
  61. */
  62. udelay(10 * 1000);
  63. debug("%s: Set VPP_FUSE to 1.2V via AS3722 reg 0x12/4E\n", __func__);
  64. /*
  65. * Bring up VPP_FUSE via the AS3722 PMIC on the PWR I2C bus.
  66. * First set VDD to 1.2V, then enable the VDD regulator.
  67. */
  68. tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
  69. tegra_i2c_ll_write_data(AS3722_LDO2VOLTAGE_DATA, I2C_SEND_2_BYTES);
  70. /*
  71. * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
  72. * tegra_i2c_ll_write_data(AS3722_LDO2CONTROL_DATA, I2C_SEND_2_BYTES);
  73. */
  74. udelay(10 * 1000);
  75. debug("%s: Set VDD_SDMMC to 3.3V via AS3722 reg 0x16/4E\n", __func__);
  76. /*
  77. * Bring up VDD_SDMMC via the AS3722 PMIC on the PWR I2C bus.
  78. * First set it to bypass 3.3V straight thru, then enable the regulator
  79. *
  80. * NOTE: We do this early because doing it later seems to hose the CPU
  81. * power rail/partition startup. Need to debug.
  82. */
  83. tegra_i2c_ll_write_addr(AS3722_I2C_ADDR, 2);
  84. tegra_i2c_ll_write_data(AS3722_LDO6VOLTAGE_DATA, I2C_SEND_2_BYTES);
  85. /*
  86. * Don't write LDCONTROL - it's already 0xFF, i.e. all LDOs enabled.
  87. * tegra_i2c_ll_write_data(AS3722_LDO6CONTROL_DATA, I2C_SEND_2_BYTES);
  88. */
  89. udelay(10 * 1000);
  90. }