p2371-2180.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2013-2015
  4. * NVIDIA Corporation <www.nvidia.com>
  5. */
  6. #include <common.h>
  7. #include <i2c.h>
  8. #include <asm/arch/gpio.h>
  9. #include <asm/arch/pinmux.h>
  10. #include "../p2571/max77620_init.h"
  11. #include "pinmux-config-p2371-2180.h"
  12. void pin_mux_mmc(void)
  13. {
  14. struct udevice *dev;
  15. uchar val;
  16. int ret;
  17. /* Turn on MAX77620 LDO2 to 3.3V for SD card power */
  18. debug("%s: Set LDO2 for VDDIO_SDMMC_AP power to 3.3V\n", __func__);
  19. ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev);
  20. if (ret) {
  21. printf("%s: Cannot find MAX77620 I2C chip\n", __func__);
  22. return;
  23. }
  24. /* 0xF2 for 3.3v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */
  25. val = 0xF2;
  26. ret = dm_i2c_write(dev, MAX77620_CNFG1_L2_REG, &val, 1);
  27. if (ret)
  28. printf("i2c_write 0 0x3c 0x27 failed: %d\n", ret);
  29. /* Disable LDO4 discharge */
  30. ret = dm_i2c_read(dev, MAX77620_CNFG2_L4_REG, &val, 1);
  31. if (ret) {
  32. printf("i2c_read 0 0x3c 0x2c failed: %d\n", ret);
  33. } else {
  34. val &= ~BIT(1); /* ADE */
  35. ret = dm_i2c_write(dev, MAX77620_CNFG2_L4_REG, &val, 1);
  36. if (ret)
  37. printf("i2c_write 0 0x3c 0x2c failed: %d\n", ret);
  38. }
  39. /* Set MBLPD */
  40. ret = dm_i2c_read(dev, MAX77620_CNFGGLBL1_REG, &val, 1);
  41. if (ret) {
  42. printf("i2c_write 0 0x3c 0x00 failed: %d\n", ret);
  43. } else {
  44. val |= BIT(6); /* MBLPD */
  45. ret = dm_i2c_write(dev, MAX77620_CNFGGLBL1_REG, &val, 1);
  46. if (ret)
  47. printf("i2c_write 0 0x3c 0x00 failed: %d\n", ret);
  48. }
  49. }
  50. /*
  51. * Routine: pinmux_init
  52. * Description: Do individual peripheral pinmux configs
  53. */
  54. void pinmux_init(void)
  55. {
  56. pinmux_clear_tristate_input_clamping();
  57. gpio_config_table(p2371_2180_gpio_inits,
  58. ARRAY_SIZE(p2371_2180_gpio_inits));
  59. pinmux_config_pingrp_table(p2371_2180_pingrps,
  60. ARRAY_SIZE(p2371_2180_pingrps));
  61. pinmux_config_drvgrp_table(p2371_2180_drvgrps,
  62. ARRAY_SIZE(p2371_2180_drvgrps));
  63. }
  64. #ifdef CONFIG_PCI_TEGRA
  65. int tegra_pcie_board_init(void)
  66. {
  67. struct udevice *dev;
  68. uchar val;
  69. int ret;
  70. /* Turn on MAX77620 LDO1 to 1.05V for PEX power */
  71. debug("%s: Set LDO1 for PEX power to 1.05V\n", __func__);
  72. ret = i2c_get_chip_for_busnum(0, MAX77620_I2C_ADDR_7BIT, 1, &dev);
  73. if (ret) {
  74. printf("%s: Cannot find MAX77620 I2C chip\n", __func__);
  75. return -1;
  76. }
  77. /* 0xCA for 1.05v, enabled: bit7:6 = 11 = enable, bit5:0 = voltage */
  78. val = 0xCA;
  79. ret = dm_i2c_write(dev, MAX77620_CNFG1_L1_REG, &val, 1);
  80. if (ret)
  81. printf("i2c_write 0 0x3c 0x25 failed: %d\n", ret);
  82. return 0;
  83. }
  84. #endif /* PCI */