1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Lucas Stach
8 #include <fdt_support.h>
11 #include <asm/arch/clock.h>
12 #include <asm/arch/funcmux.h>
13 #include <asm/arch/pinmux.h>
14 #include <asm/arch-tegra/ap.h>
15 #include <asm/arch-tegra/board.h>
16 #include <asm/arch-tegra/tegra.h>
17 #include <asm/global_data.h>
22 #include <linux/delay.h>
23 #include "../common/tdx-common.h"
25 DECLARE_GLOBAL_DATA_PTR;
27 #define PMU_I2C_ADDRESS 0x34
28 #define MAX_I2C_RETRY 3
29 #define PMU_SUPPLYENE 0x14
30 #define PMU_SUPPLYENE_SYSINEN (1<<5)
31 #define PMU_SUPPLYENE_EXITSLREQ (1<<1)
33 int arch_misc_init(void)
35 /* Disable PMIC sleep mode on low supply voltage */
40 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
42 debug("%s: Cannot find PMIC I2C chip\n", __func__);
48 err = dm_i2c_read(dev, addr, data, 1);
50 debug("failed to get PMU_SUPPLYENE\n");
54 data[0] &= ~PMU_SUPPLYENE_SYSINEN;
55 data[0] |= PMU_SUPPLYENE_EXITSLREQ;
57 err = dm_i2c_write(dev, addr, data, 1);
59 debug("failed to set PMU_SUPPLYENE\n");
63 /* make sure SODIMM pin 87 nRESET_OUT is released properly */
64 pinmux_set_func(PMUX_PINGRP_ATA, PMUX_FUNC_GMI);
66 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
68 printf("USB recovery mode\n");
75 printf("Model: Toradex Colibri T20 %dMB V%s\n",
76 (gd->ram_size == 0x10000000) ? 256 : 512,
77 (get_nand_dev_by_index(0)->erasesize >> 10 == 512) ?
78 ((gd->ram_size == 0x10000000) ? "1.1B" : "1.1C") : "1.2A");
83 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
84 int ft_board_setup(void *blob, struct bd_info *bd)
89 if (eth_env_get_enetaddr("ethaddr", enetaddr)) {
90 int err = fdt_find_and_setprop(blob,
91 "/usb@7d004000/ethernet@1",
92 "local-mac-address", enetaddr, 6, 0);
94 /* Older device trees might have used a different node name */
96 err = fdt_find_and_setprop(blob,
97 "/usb@7d004000/asix@1",
98 "local-mac-address", enetaddr, 6, 0);
101 puts(" MAC address updated...\n");
104 return ft_common_board_setup(blob, bd);
108 #ifdef CONFIG_MMC_SDHCI_TEGRA
110 * Routine: pin_mux_mmc
111 * Description: setup the pin muxes/tristate values for the SDMMC(s)
113 void pin_mux_mmc(void)
115 funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_4_BIT);
116 pinmux_tristate_disable(PMUX_PINGRP_GMB);
120 #ifdef CONFIG_TEGRA_NAND
121 void pin_mux_nand(void)
123 funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT);
126 * configure pingroup ATC to something unrelated to
127 * avoid ATC overriding KBC
129 pinmux_set_func(PMUX_PINGRP_ATC, PMUX_FUNC_GMI);
133 #ifdef CONFIG_USB_EHCI_TEGRA
134 void pin_mux_usb(void)
136 /* module internal USB bus to connect ethernet chipset */
137 funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI);
139 /* ULPI reference clock output */
140 pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4);
141 pinmux_tristate_disable(PMUX_PINGRP_CDEV2);
144 pinmux_tristate_disable(PMUX_PINGRP_UAC);
147 pinmux_tristate_disable(PMUX_PINGRP_DTE);
149 /* Reset ASIX using LAN_RESET */
150 gpio_request(TEGRA_GPIO(V, 4), "LAN_RESET");
151 gpio_direction_output(TEGRA_GPIO(V, 4), 0);
152 pinmux_tristate_disable(PMUX_PINGRP_GPV);
154 gpio_set_value(TEGRA_GPIO(V, 4), 1);
156 /* USBH_PEN: USB 1 aka Tegra USB port 3 VBus */
157 pinmux_tristate_disable(PMUX_PINGRP_SPIG);
161 #ifdef CONFIG_VIDEO_TEGRA20
163 * Routine: pin_mux_display
164 * Description: setup the pin muxes/tristate values for the LCD interface)
166 void pin_mux_display(void)
169 * Manually untristate BL_ON (PT4 - SODIMM 71) as specified through
172 pinmux_tristate_disable(PMUX_PINGRP_DTA);
174 pinmux_set_func(PMUX_PINGRP_SDC, PMUX_FUNC_PWM);
175 pinmux_tristate_disable(PMUX_PINGRP_SDC);
179 * Backlight off before OS handover
181 void board_preboot_os(void)
183 gpio_request(TEGRA_GPIO(T, 4), "BL_ON");
184 gpio_direction_output(TEGRA_GPIO(T, 4), 0);