2 * Copyright (C) 2012 Lucas Stach
4 * SPDX-License-Identifier: GPL-2.0+
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>
18 #define PMU_I2C_ADDRESS 0x34
19 #define MAX_I2C_RETRY 3
20 #define PMU_SUPPLYENE 0x14
21 #define PMU_SUPPLYENE_SYSINEN (1<<5)
22 #define PMU_SUPPLYENE_EXITSLREQ (1<<1)
24 int arch_misc_init(void)
26 /* Disable PMIC sleep mode on low supply voltage */
31 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
33 debug("%s: Cannot find PMIC I2C chip\n", __func__);
39 err = dm_i2c_read(dev, addr, data, 1);
41 debug("failed to get PMU_SUPPLYENE\n");
45 data[0] &= ~PMU_SUPPLYENE_SYSINEN;
46 data[0] |= PMU_SUPPLYENE_EXITSLREQ;
48 err = dm_i2c_write(dev, addr, data, 1);
50 debug("failed to set PMU_SUPPLYENE\n");
54 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
56 printf("USB recovery mode\n");
61 #ifdef CONFIG_TEGRA_MMC
63 * Routine: pin_mux_mmc
64 * Description: setup the pin muxes/tristate values for the SDMMC(s)
66 void pin_mux_mmc(void)
68 funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_4_BIT);
69 pinmux_tristate_disable(PMUX_PINGRP_GMB);
73 #ifdef CONFIG_TEGRA_NAND
74 void pin_mux_nand(void)
76 funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT);
79 * configure pingroup ATC to something unrelated to
80 * avoid ATC overriding KBC
82 pinmux_set_func(PMUX_PINGRP_ATC, PMUX_FUNC_GMI);
86 #ifdef CONFIG_USB_EHCI_TEGRA
87 void pin_mux_usb(void)
89 /* module internal USB bus to connect ethernet chipset */
90 funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI);
92 /* ULPI reference clock output */
93 pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4);
94 pinmux_tristate_disable(PMUX_PINGRP_CDEV2);
97 pinmux_tristate_disable(PMUX_PINGRP_UAC);
100 pinmux_tristate_disable(PMUX_PINGRP_DTE);
102 /* Reset ASIX using LAN_RESET */
103 gpio_request(GPIO_PV4, "LAN_RESET");
104 gpio_direction_output(GPIO_PV4, 0);
105 pinmux_tristate_disable(PMUX_PINGRP_GPV);
107 gpio_set_value(GPIO_PV4, 1);
109 /* USBH_PEN: USB 1 aka Tegra USB port 3 VBus */
110 pinmux_tristate_disable(PMUX_PINGRP_SPIG);
114 #ifdef CONFIG_VIDEO_TEGRA
116 * Routine: pin_mux_display
117 * Description: setup the pin muxes/tristate values for the LCD interface)
119 void pin_mux_display(void)
122 * Manually untristate BL_ON (PT4 - SODIMM 71) as specified through
125 pinmux_tristate_disable(PMUX_PINGRP_DTA);
127 pinmux_set_func(PMUX_PINGRP_SDC, PMUX_FUNC_PWM);
128 pinmux_tristate_disable(PMUX_PINGRP_SDC);