tamonten-ng.c 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2013
  4. * Avionic Design GmbH <www.avionic-design.de>
  5. */
  6. #include <common.h>
  7. #include <dm.h>
  8. #include <log.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-tamonten-ng.h"
  14. #include <i2c.h>
  15. #define PMU_I2C_ADDRESS 0x2D
  16. #define PMU_REG_LDO5 0x32
  17. #define PMU_REG_LDO_HIGH_POWER 1
  18. /* Voltage selection for the LDOs with 100mV resolution */
  19. #define PMU_REG_LDO_SEL_100(mV) ((((mV - 1000) / 100) + 2) << 2)
  20. #define PMU_REG_LDO_100(st, mV) (PMU_REG_LDO_##st | PMU_REG_LDO_SEL_100(mV))
  21. #define PMU_LDO5(st, mV) PMU_REG_LDO_100(st, mV)
  22. void pinmux_init(void)
  23. {
  24. pinmux_config_pingrp_table(tamonten_ng_pinmux_common,
  25. ARRAY_SIZE(tamonten_ng_pinmux_common));
  26. pinmux_config_pingrp_table(unused_pins_lowpower,
  27. ARRAY_SIZE(unused_pins_lowpower));
  28. /* Initialize any non-default pad configs (APB_MISC_GP regs) */
  29. pinmux_config_drvgrp_table(tamonten_ng_padctrl,
  30. ARRAY_SIZE(tamonten_ng_padctrl));
  31. }
  32. void gpio_early_init(void)
  33. {
  34. /* Turn on the alive signal */
  35. gpio_request(TEGRA_GPIO(V, 2), "ALIVE");
  36. gpio_direction_output(TEGRA_GPIO(V, 2), 1);
  37. /* Remove the reset on the external periph */
  38. gpio_request(TEGRA_GPIO(I, 4), "nRST_PERIPH");
  39. gpio_direction_output(TEGRA_GPIO(I, 4), 1);
  40. }
  41. void pmu_write(uchar reg, uchar data)
  42. {
  43. struct udevice *dev;
  44. int ret;
  45. ret = i2c_get_chip_for_busnum(4, PMU_I2C_ADDRESS, 1, &dev);
  46. if (ret) {
  47. debug("%s: Cannot find PMIC I2C chip\n", __func__);
  48. return;
  49. }
  50. dm_i2c_write(dev, reg, &data, 1);
  51. }
  52. /*
  53. * Do I2C/PMU writes to bring up SD card bus power
  54. *
  55. */
  56. void board_sdmmc_voltage_init(void)
  57. {
  58. /* Enable LDO5 with 3.3v for SDMMC3 */
  59. pmu_write(PMU_REG_LDO5, PMU_LDO5(HIGH_POWER, 3300));
  60. /* Switch the power on */
  61. gpio_request(TEGRA_GPIO(J, 2), "EN_3V3_EMMC");
  62. gpio_direction_output(TEGRA_GPIO(J, 2), 1);
  63. }
  64. /*
  65. * Routine: pin_mux_mmc
  66. * Description: setup the MMC muxes, power rails, etc.
  67. */
  68. void pin_mux_mmc(void)
  69. {
  70. /*
  71. * NOTE: We don't do mmc-specific pin muxes here.
  72. * They were done globally in pinmux_init().
  73. */
  74. /* Bring up the SDIO1 power rail */
  75. board_sdmmc_voltage_init();
  76. }