cardhu.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2010-2013
  4. * NVIDIA Corporation <www.nvidia.com>
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <asm/arch/pinmux.h>
  9. #include <asm/arch/gp_padctrl.h>
  10. #include <asm/arch/gpio.h>
  11. #include <asm/gpio.h>
  12. #include "pinmux-config-cardhu.h"
  13. #include <i2c.h>
  14. #define PMU_I2C_ADDRESS 0x2D
  15. #define MAX_I2C_RETRY 3
  16. /*
  17. * Routine: pinmux_init
  18. * Description: Do individual peripheral pinmux configs
  19. */
  20. void pinmux_init(void)
  21. {
  22. pinmux_config_pingrp_table(tegra3_pinmux_common,
  23. ARRAY_SIZE(tegra3_pinmux_common));
  24. pinmux_config_pingrp_table(unused_pins_lowpower,
  25. ARRAY_SIZE(unused_pins_lowpower));
  26. /* Initialize any non-default pad configs (APB_MISC_GP regs) */
  27. pinmux_config_drvgrp_table(cardhu_padctrl, ARRAY_SIZE(cardhu_padctrl));
  28. }
  29. #if defined(CONFIG_MMC_SDHCI_TEGRA)
  30. /*
  31. * Do I2C/PMU writes to bring up SD card bus power
  32. *
  33. */
  34. void board_sdmmc_voltage_init(void)
  35. {
  36. struct udevice *dev;
  37. uchar reg, data_buffer[1];
  38. int ret;
  39. int i;
  40. ret = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
  41. if (ret) {
  42. debug("%s: Cannot find PMIC I2C chip\n", __func__);
  43. return;
  44. }
  45. /* TPS659110: LDO5_REG = 3.3v, ACTIVE to SDMMC1 */
  46. data_buffer[0] = 0x65;
  47. reg = 0x32;
  48. for (i = 0; i < MAX_I2C_RETRY; ++i) {
  49. if (dm_i2c_write(dev, reg, data_buffer, 1))
  50. udelay(100);
  51. }
  52. /* TPS659110: GPIO7_REG = PDEN, output a 1 to EN_3V3_SYS */
  53. data_buffer[0] = 0x09;
  54. reg = 0x67;
  55. for (i = 0; i < MAX_I2C_RETRY; ++i) {
  56. if (dm_i2c_write(dev, reg, data_buffer, 1))
  57. udelay(100);
  58. }
  59. }
  60. /*
  61. * Routine: pin_mux_mmc
  62. * Description: setup the MMC muxes, power rails, etc.
  63. */
  64. void pin_mux_mmc(void)
  65. {
  66. /*
  67. * NOTE: We don't do mmc-specific pin muxes here.
  68. * They were done globally in pinmux_init().
  69. */
  70. /* Bring up the SDIO1 power rail */
  71. board_sdmmc_voltage_init();
  72. }
  73. #endif /* MMC */
  74. #ifdef CONFIG_PCI_TEGRA
  75. int tegra_pcie_board_init(void)
  76. {
  77. struct udevice *dev;
  78. u8 addr, data[1];
  79. int err;
  80. err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
  81. if (err) {
  82. debug("failed to find PMU bus\n");
  83. return err;
  84. }
  85. /* TPS659110: LDO1_REG = 1.05V, ACTIVE */
  86. data[0] = 0x15;
  87. addr = 0x30;
  88. err = dm_i2c_write(dev, addr, data, 1);
  89. if (err) {
  90. debug("failed to set VDD supply\n");
  91. return err;
  92. }
  93. /* GPIO: PEX = 3.3V */
  94. err = gpio_request(TEGRA_GPIO(L, 7), "PEX");
  95. if (err < 0)
  96. return err;
  97. gpio_direction_output(TEGRA_GPIO(L, 7), 1);
  98. /* TPS659110: LDO2_REG = 1.05V, ACTIVE */
  99. data[0] = 0x15;
  100. addr = 0x31;
  101. err = dm_i2c_write(dev, addr, data, 1);
  102. if (err) {
  103. debug("failed to set AVDD supply\n");
  104. return err;
  105. }
  106. return 0;
  107. }
  108. #endif /* PCI */