cardhu.c 2.6 KB

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