blob: 42b293d81ec33dd884a0e10828ac3eea7fdfc770 [file] [log] [blame]
Lucas Stach85990a92012-10-07 11:36:06 +00001/*
2 * Copyright (C) 2012 Lucas Stach
3 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Lucas Stach85990a92012-10-07 11:36:06 +00005 */
6
7#include <common.h>
Lucas Stach85990a92012-10-07 11:36:06 +00008#include <asm/arch/clock.h>
9#include <asm/arch/funcmux.h>
10#include <asm/arch/pinmux.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020011#include <asm/arch-tegra/ap.h>
Lucas Stach85990a92012-10-07 11:36:06 +000012#include <asm/arch-tegra/board.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020013#include <asm/arch-tegra/tegra.h>
Marcel Ziswileraf722622015-03-26 01:31:53 +010014#include <asm/gpio.h>
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020015#include <asm/io.h>
Marcel Ziswilerf0c3fb72015-08-06 00:47:04 +020016#include <i2c.h>
17
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)
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020023
24int arch_misc_init(void)
25{
Marcel Ziswilerf0c3fb72015-08-06 00:47:04 +020026 /* Disable PMIC sleep mode on low supply voltage */
27 struct udevice *dev;
28 u8 addr, data[1];
29 int err;
30
31 err = i2c_get_chip_for_busnum(0, PMU_I2C_ADDRESS, 1, &dev);
32 if (err) {
33 debug("%s: Cannot find PMIC I2C chip\n", __func__);
34 return err;
35 }
36
37 addr = PMU_SUPPLYENE;
38
39 err = dm_i2c_read(dev, addr, data, 1);
40 if (err) {
41 debug("failed to get PMU_SUPPLYENE\n");
42 return err;
43 }
44
45 data[0] &= ~PMU_SUPPLYENE_SYSINEN;
46 data[0] |= PMU_SUPPLYENE_EXITSLREQ;
47
48 err = dm_i2c_write(dev, addr, data, 1);
49 if (err) {
50 debug("failed to set PMU_SUPPLYENE\n");
51 return err;
52 }
53
Marcel Ziswilerdd899d02015-08-06 00:47:00 +020054 if (readl(NV_PA_BASE_SRAM + NVBOOTINFOTABLE_BOOTTYPE) ==
55 NVBOOTTYPE_RECOVERY)
56 printf("USB recovery mode\n");
57
58 return 0;
59}
Lucas Stach85990a92012-10-07 11:36:06 +000060
61#ifdef CONFIG_TEGRA_MMC
Tom Warren9745cf82013-02-21 12:31:30 +000062/*
63 * Routine: pin_mux_mmc
64 * Description: setup the pin muxes/tristate values for the SDMMC(s)
65 */
66void pin_mux_mmc(void)
Lucas Stach85990a92012-10-07 11:36:06 +000067{
68 funcmux_select(PERIPH_ID_SDMMC4, FUNCMUX_SDMMC4_ATB_GMA_4_BIT);
Stephen Warrenf27f4e82014-03-21 12:28:58 -060069 pinmux_tristate_disable(PMUX_PINGRP_GMB);
Lucas Stach85990a92012-10-07 11:36:06 +000070}
71#endif
Marcel Ziswileraf722622015-03-26 01:31:53 +010072
73#ifdef CONFIG_TEGRA_NAND
74void pin_mux_nand(void)
75{
76 funcmux_select(PERIPH_ID_NDFLASH, FUNCMUX_NDFLASH_KBC_8_BIT);
Marcel Ziswilerbdddbab2015-03-27 01:31:45 +010077
78 /*
79 * configure pingroup ATC to something unrelated to
80 * avoid ATC overriding KBC
81 */
82 pinmux_set_func(PMUX_PINGRP_ATC, PMUX_FUNC_GMI);
Marcel Ziswileraf722622015-03-26 01:31:53 +010083}
84#endif
85
86#ifdef CONFIG_USB_EHCI_TEGRA
87void pin_mux_usb(void)
88{
89 /* module internal USB bus to connect ethernet chipset */
90 funcmux_select(PERIPH_ID_USB2, FUNCMUX_USB2_ULPI);
91
92 /* ULPI reference clock output */
93 pinmux_set_func(PMUX_PINGRP_CDEV2, PMUX_FUNC_PLLP_OUT4);
94 pinmux_tristate_disable(PMUX_PINGRP_CDEV2);
95
96 /* PHY reset GPIO */
97 pinmux_tristate_disable(PMUX_PINGRP_UAC);
98
99 /* VBus GPIO */
100 pinmux_tristate_disable(PMUX_PINGRP_DTE);
101
Marcel Ziswilerc33dd262015-03-26 02:17:07 +0100102 /* 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);
106 udelay(5);
107 gpio_set_value(GPIO_PV4, 1);
108
109 /* USBH_PEN: USB 1 aka Tegra USB port 3 VBus */
Marcel Ziswileraf722622015-03-26 01:31:53 +0100110 pinmux_tristate_disable(PMUX_PINGRP_SPIG);
111}
112#endif
Marcel Ziswilercbd2b512015-08-06 00:47:02 +0200113
114#ifdef CONFIG_VIDEO_TEGRA
115/*
116 * Routine: pin_mux_display
117 * Description: setup the pin muxes/tristate values for the LCD interface)
118 */
119void pin_mux_display(void)
120{
121 /*
122 * Manually untristate BL_ON (PT4 - SODIMM 71) as specified through
123 * device-tree
124 */
125 pinmux_tristate_disable(PMUX_PINGRP_DTA);
126
127 pinmux_set_func(PMUX_PINGRP_SDC, PMUX_FUNC_PWM);
128 pinmux_tristate_disable(PMUX_PINGRP_SDC);
129}
130#endif