whistler.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * (C) Copyright 2010-2012
  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/io.h>
  10. #include <asm/arch/tegra.h>
  11. #include <asm/arch/clock.h>
  12. #include <asm/arch/funcmux.h>
  13. #include <asm/arch/pinmux.h>
  14. #include <asm/gpio.h>
  15. #include <i2c.h>
  16. #ifdef CONFIG_TEGRA_MMC
  17. /*
  18. * Routine: pin_mux_mmc
  19. * Description: setup the pin muxes/tristate values for the SDMMC(s)
  20. */
  21. void pin_mux_mmc(void)
  22. {
  23. struct udevice *dev;
  24. uchar val;
  25. int ret;
  26. /* Turn on MAX8907B LDO12 to 2.8V for J40 power */
  27. ret = i2c_get_chip_for_busnum(0, 0x3c, 1, &dev);
  28. if (ret) {
  29. printf("%s: Cannot find MAX8907B I2C chip\n", __func__);
  30. return;
  31. }
  32. val = 0x29;
  33. ret = dm_i2c_write(dev, 0x46, &val, 1);
  34. if (ret)
  35. printf("i2c_write 0 0x3c 0x46 failed: %d\n", ret);
  36. val = 0x00;
  37. ret = dm_i2c_write(dev, 0x45, &val, 1);
  38. if (ret)
  39. printf("i2c_write 0 0x3c 0x45 failed: %d\n", ret);
  40. val = 0x1f;
  41. ret = dm_i2c_write(dev, 0x44, &val, 1);
  42. if (ret)
  43. printf("i2c_write 0 0x3c 0x44 failed: %d\n", ret);
  44. funcmux_select(PERIPH_ID_SDMMC3, FUNCMUX_SDMMC3_SDB_SLXA_8BIT);
  45. funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATC_ATD_8BIT);
  46. }
  47. #endif
  48. /* this is a weak define that we are overriding */
  49. void pin_mux_usb(void)
  50. {
  51. struct udevice *dev;
  52. uchar val;
  53. int ret;
  54. /*
  55. * This is a hack. This should be represented in DT using the
  56. * vbus-gpio property. However, U-Boot's DT support doesn't
  57. * support any GPIO controller other than the Tegra's yet.
  58. */
  59. /* Turn on TAC6416's GPIO 0+1 for USB1/3's VBUS */
  60. ret = i2c_get_chip_for_busnum(0, 0x20, 1, &dev);
  61. if (ret) {
  62. printf("%s: Cannot find TAC6416 I2C chip\n", __func__);
  63. return;
  64. }
  65. val = 0x03;
  66. ret = dm_i2c_write(dev, 2, &val, 1);
  67. if (ret)
  68. printf("i2c_write 0 0x20 2 failed: %d\n", ret);
  69. val = 0xfc;
  70. ret = dm_i2c_write(dev, 6, &val, 1);
  71. if (ret)
  72. printf("i2c_write 0 0x20 6 failed: %d\n", ret);
  73. }