colibri_t20.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Copyright (C) 2012 Lucas Stach
  4. */
  5. #include <common.h>
  6. #include <init.h>
  7. #include <log.h>
  8. #include <asm/arch/clock.h>
  9. #include <asm/arch/funcmux.h>
  10. #include <asm/arch/pinmux.h>
  11. #include <asm/arch-tegra/ap.h>
  12. #include <asm/arch-tegra/board.h>
  13. #include <asm/arch-tegra/tegra.h>
  14. #include <asm/gpio.h>
  15. #include <asm/io.h>
  16. #include <i2c.h>
  17. #include <nand.h>
  18. #include <linux/delay.h>
  19. #include "../common/tdx-common.h"
  20. DECLARE_GLOBAL_DATA_PTR;
  21. #define PMU_I2C_ADDRESS 0x34
  22. #define MAX_I2C_RETRY 3
  23. #define PMU_SUPPLYENE 0x14
  24. #define PMU_SUPPLYENE_SYSINEN (1<<5)
  25. #define PMU_SUPPLYENE_EXITSLREQ (1<<1)
  26. int arch_misc_init(void)
  27. {
  28. /* Disable PMIC sleep mode on low supply voltage */
  29. struct udevice *dev;
  30. u8 addr, data[1];
  31. int err;
  32. err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
  33. if (err) {
  34. debug("%s: Cannot find PMIC I2C chip\n", __func__);
  35. return err;
  36. }
  37. addr = PMU_SUPPLYENE;
  38. err = dm_i2c_read(dev, addr, data, 1);
  39. if (err) {
  40. debug("failed to get PMU_SUPPLYENE\n");
  41. return err;
  42. }
  43. data[0] &= ~PMU_SUPPLYENE_SYSINEN;
  44. data[0] |= PMU_SUPPLYENE_EXITSLREQ;
  45. err = dm_i2c_write(dev, addr, data, 1);
  46. if (err) {
  47. debug("failed to set PMU_SUPPLYENE\n");
  48. return err;
  49. }
  50. /* make sure SODIMM pin 87 nRESET_OUT is released properly */
  51. pinmux_set_func(PMUX_PINGRP_ATA, PMUX_FUNC_GMI);
  52. if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
  53. NVBOOTTYPE_RECOVERY)
  54. printf("USB recovery mode\n");
  55. return 0;
  56. }
  57. int checkboard(void)
  58. {
  59. printf("Model: Toradex Colibri T20 %dMB V%s\n",
  60. (gd->ram_size == 0x10000000) ? 256 : 512,
  61. (get_nand_dev_by_index(0)->erasesize >> 10 == 512) ?
  62. ((gd->ram_size == 0x10000000) ? "1.1B" : "1.1C") : "1.2A");
  63. return 0;
  64. }
  65. #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
  66. int ft_board_setup(void *blob, struct bd_info *bd)
  67. {
  68. return ft_common_board_setup(blob, bd);
  69. }
  70. #endif
  71. #ifdef CONFIG_MMC_SDHCI_TEGRA
  72. /*
  73. * Routine: pin_mux_mmc
  74. * Description: setup the pin muxes/tristate values for the SDMMC(s)
  75. */
  76. void pin_mux_mmc(void)
  77. {
  78. funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_4_BIT);
  79. pinmux_tristate_disable(PMUX_PINGRP_GMB);
  80. }
  81. #endif
  82. #ifdef CONFIG_TEGRA_NAND
  83. void pin_mux_nand(void)
  84. {
  85. funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT);
  86. /*
  87. * configure pingroup ATC to something unrelated to
  88. * avoid ATC overriding KBC
  89. */
  90. pinmux_set_func(PMUX_PINGRP_ATC, PMUX_FUNC_GMI);
  91. }
  92. #endif
  93. #ifdef CONFIG_USB_EHCI_TEGRA
  94. void pin_mux_usb(void)
  95. {
  96. /* module internal USB bus to connect ethernet chipset */
  97. funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI);
  98. /* ULPI reference clock output */
  99. pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4);
  100. pinmux_tristate_disable(PMUX_PINGRP_CDEV2);
  101. /* PHY reset GPIO */
  102. pinmux_tristate_disable(PMUX_PINGRP_UAC);
  103. /* VBus GPIO */
  104. pinmux_tristate_disable(PMUX_PINGRP_DTE);
  105. /* Reset ASIX using LAN_RESET */
  106. gpio_request(TEGRA_GPIO(V, 4), "LAN_RESET");
  107. gpio_direction_output(TEGRA_GPIO(V, 4), 0);
  108. pinmux_tristate_disable(PMUX_PINGRP_GPV);
  109. udelay(5);
  110. gpio_set_value(TEGRA_GPIO(V, 4), 1);
  111. /* USBH_PEN: USB 1 aka Tegra USB port 3 VBus */
  112. pinmux_tristate_disable(PMUX_PINGRP_SPIG);
  113. }
  114. #endif
  115. #ifdef CONFIG_VIDEO_TEGRA20
  116. /*
  117. * Routine: pin_mux_display
  118. * Description: setup the pin muxes/tristate values for the LCD interface)
  119. */
  120. void pin_mux_display(void)
  121. {
  122. /*
  123. * Manually untristate BL_ON (PT4 - SODIMM 71) as specified through
  124. * device-tree
  125. */
  126. pinmux_tristate_disable(PMUX_PINGRP_DTA);
  127. pinmux_set_func(PMUX_PINGRP_SDC, PMUX_FUNC_PWM);
  128. pinmux_tristate_disable(PMUX_PINGRP_SDC);
  129. }
  130. /*
  131. * Backlight off before OS handover
  132. */
  133. void board_preboot_os(void)
  134. {
  135. gpio_request(TEGRA_GPIO(T, 4), "BL_ON");
  136. gpio_direction_output(TEGRA_GPIO(T, 4), 0);
  137. }
  138. #endif