1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Lucas Stach
7 #include <fdt_support.h>
10 #include <asm/arch/clock.h>
11 #include <asm/arch/funcmux.h>
12 #include <asm/arch/pinmux.h>
13 #include <asm/arch-tegra/ap.h>
14 #include <asm/arch-tegra/board.h>
15 #include <asm/arch-tegra/tegra.h>
16 #include <asm/global_data.h>
21 #include <linux/delay.h>
22 #include "../common/tdx-common.h"
24 DECLARE_GLOBAL_DATA_PTR;
26 #define PMU_I2C_ADDRESS 0x34
27 #define MAX_I2C_RETRY 3
28 #define PMU_SUPPLYENE 0x14
29 #define PMU_SUPPLYENE_SYSINEN (1<<5)
30 #define PMU_SUPPLYENE_EXITSLREQ (1<<1)
32 int arch_misc_init(void)
34 /* Disable PMIC sleep mode on low supply voltage */
39 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
41 debug("%s: Cannot find PMIC I2C chip\n", __func__);
47 err = dm_i2c_read(dev, addr, data, 1);
49 debug("failed to get PMU_SUPPLYENE\n");
53 data[0] &= ~PMU_SUPPLYENE_SYSINEN;
54 data[0] |= PMU_SUPPLYENE_EXITSLREQ;
56 err = dm_i2c_write(dev, addr, data, 1);
58 debug("failed to set PMU_SUPPLYENE\n");
62 /* make sure SODIMM pin 87 nRESET_OUT is released properly */
63 pinmux_set_func(PMUX_PINGRP_ATA, PMUX_FUNC_GMI);
65 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
67 printf("USB recovery mode\n");
72 #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
73 int ft_board_setup(void *blob, struct bd_info *bd)
78 if (eth_env_get_enetaddr("ethaddr", enetaddr)) {
79 int err = fdt_find_and_setprop(blob,
80 "/usb@7d004000/ethernet@1",
81 "local-mac-address", enetaddr, 6, 0);
83 /* Older device trees might have used a different node name */
85 err = fdt_find_and_setprop(blob,
86 "/usb@7d004000/asix@1",
87 "local-mac-address", enetaddr, 6, 0);
90 puts(" MAC address updated...\n");
93 return ft_common_board_setup(blob, bd);
97 #ifdef CONFIG_MMC_SDHCI_TEGRA
99 * Routine: pin_mux_mmc
100 * Description: setup the pin muxes/tristate values for the SDMMC(s)
102 void pin_mux_mmc(void)
104 funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_4_BIT);
105 pinmux_tristate_disable(PMUX_PINGRP_GMB);
109 #ifdef CONFIG_TEGRA_NAND
110 void pin_mux_nand(void)
112 funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT);
115 * configure pingroup ATC to something unrelated to
116 * avoid ATC overriding KBC
118 pinmux_set_func(PMUX_PINGRP_ATC, PMUX_FUNC_GMI);
122 #ifdef CONFIG_USB_EHCI_TEGRA
123 void pin_mux_usb(void)
125 /* module internal USB bus to connect ethernet chipset */
126 funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI);
128 /* ULPI reference clock output */
129 pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4);
130 pinmux_tristate_disable(PMUX_PINGRP_CDEV2);
133 pinmux_tristate_disable(PMUX_PINGRP_UAC);
136 pinmux_tristate_disable(PMUX_PINGRP_DTE);
138 /* Reset ASIX using LAN_RESET */
139 gpio_request(TEGRA_GPIO(V, 4), "LAN_RESET");
140 gpio_direction_output(TEGRA_GPIO(V, 4), 0);
141 pinmux_tristate_disable(PMUX_PINGRP_GPV);
143 gpio_set_value(TEGRA_GPIO(V, 4), 1);
145 /* USBH_PEN: USB 1 aka Tegra USB port 3 VBus */
146 pinmux_tristate_disable(PMUX_PINGRP_SPIG);
150 #ifdef CONFIG_VIDEO_TEGRA20
152 * Routine: pin_mux_display
153 * Description: setup the pin muxes/tristate values for the LCD interface)
155 void pin_mux_display(void)
158 * Manually untristate BL_ON (PT4 - SODIMM 71) as specified through
161 pinmux_tristate_disable(PMUX_PINGRP_DTA);
163 pinmux_set_func(PMUX_PINGRP_SDC, PMUX_FUNC_PWM);
164 pinmux_tristate_disable(PMUX_PINGRP_SDC);
168 * Backlight off before OS handover
170 void board_preboot_os(void)
172 gpio_request(TEGRA_GPIO(T, 4), "BL_ON");
173 gpio_direction_output(TEGRA_GPIO(T, 4), 0);