tamonten-ng.c 2.1 KB

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