as3722_init.c 3.2 KB

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