1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Lucas Stach
9 #include <asm/arch/clock.h>
10 #include <asm/arch/funcmux.h>
11 #include <asm/arch/pinmux.h>
12 #include <asm/arch-tegra/ap.h>
13 #include <asm/arch-tegra/board.h>
14 #include <asm/arch-tegra/tegra.h>
15 #include <asm/global_data.h>
20 #include <linux/delay.h>
21 #include "../common/tdx-common.h"
23 DECLARE_GLOBAL_DATA_PTR;
25 #define PMU_I2C_ADDRESS 0x34
26 #define MAX_I2C_RETRY 3
27 #define PMU_SUPPLYENE 0x14
28 #define PMU_SUPPLYENE_SYSINEN (1<<5)
29 #define PMU_SUPPLYENE_EXITSLREQ (1<<1)
31 int arch_misc_init(void)
33 /* Disable PMIC sleep mode on low supply voltage */
38 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
40 debug("%s: Cannot find PMIC I2C chip\n", __func__);
46 err = dm_i2c_read(dev, addr, data, 1);
48 debug("failed to get PMU_SUPPLYENE\n");
52 data[0] &= ~PMU_SUPPLYENE_SYSINEN;
53 data[0] |= PMU_SUPPLYENE_EXITSLREQ;
55 err = dm_i2c_write(dev, addr, data, 1);
57 debug("failed to set PMU_SUPPLYENE\n");
61 /* make sure SODIMM pin 87 nRESET_OUT is released properly */
62 pinmux_set_func(PMUX_PINGRP_ATA, PMUX_FUNC_GMI);
64 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
66 printf("USB recovery mode\n");
73 printf("Model: Toradex Colibri T20 %dMB V%s\n",
74 (gd->ram_size == 0x10000000) ? 256 : 512,
75 (get_nand_dev_by_index(0)->erasesize >> 10 == 512) ?
76 ((gd->ram_size == 0x10000000) ? "1.1B" : "1.1C") : "1.2A");
81 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
82 int ft_board_setup(void *blob, struct bd_info *bd)
84 return ft_common_board_setup(blob, bd);
88 #ifdef CONFIG_MMC_SDHCI_TEGRA
90 * Routine: pin_mux_mmc
91 * Description: setup the pin muxes/tristate values for the SDMMC(s)
93 void pin_mux_mmc(void)
95 funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_4_BIT);
96 pinmux_tristate_disable(PMUX_PINGRP_GMB);
100 #ifdef CONFIG_TEGRA_NAND
101 void pin_mux_nand(void)
103 funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT);
106 * configure pingroup ATC to something unrelated to
107 * avoid ATC overriding KBC
109 pinmux_set_func(PMUX_PINGRP_ATC, PMUX_FUNC_GMI);
113 #ifdef CONFIG_USB_EHCI_TEGRA
114 void pin_mux_usb(void)
116 /* module internal USB bus to connect ethernet chipset */
117 funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI);
119 /* ULPI reference clock output */
120 pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4);
121 pinmux_tristate_disable(PMUX_PINGRP_CDEV2);
124 pinmux_tristate_disable(PMUX_PINGRP_UAC);
127 pinmux_tristate_disable(PMUX_PINGRP_DTE);
129 /* Reset ASIX using LAN_RESET */
130 gpio_request(TEGRA_GPIO(V, 4), "LAN_RESET");
131 gpio_direction_output(TEGRA_GPIO(V, 4), 0);
132 pinmux_tristate_disable(PMUX_PINGRP_GPV);
134 gpio_set_value(TEGRA_GPIO(V, 4), 1);
136 /* USBH_PEN: USB 1 aka Tegra USB port 3 VBus */
137 pinmux_tristate_disable(PMUX_PINGRP_SPIG);
141 #ifdef CONFIG_VIDEO_TEGRA20
143 * Routine: pin_mux_display
144 * Description: setup the pin muxes/tristate values for the LCD interface)
146 void pin_mux_display(void)
149 * Manually untristate BL_ON (PT4 - SODIMM 71) as specified through
152 pinmux_tristate_disable(PMUX_PINGRP_DTA);
154 pinmux_set_func(PMUX_PINGRP_SDC, PMUX_FUNC_PWM);
155 pinmux_tristate_disable(PMUX_PINGRP_SDC);
159 * Backlight off before OS handover
161 void board_preboot_os(void)
163 gpio_request(TEGRA_GPIO(T, 4), "BL_ON");
164 gpio_direction_output(TEGRA_GPIO(T, 4), 0);